I have written LaTeX rules for Bazel.
One of the uglier problems of LaTeX, which people of the likes of Leslie Lamport and Donald Knuth should have been able to solve, one might think.
There are LaTeX documents which never reach a fixed point (I've made one by accident exactly once), and need slight adjustment.
Actually I think you can do it iteratively by never decreasing the space occupied by an element between iterations. Of course this might yield ugly results but at least it halts with a solution.
IME any time you need performance & stability with unknown input, it’s gonna end up looking like streaming.
- Use separate page numbering for the table of contents.
- Since the number of table of contents entries will not change, just use two passes; you don't need a separate page numbering for the table of contents.
- Never reference page numbers within the main text; use section numbers instead. This avoids problems with their size changed.
Anyways, when I need to do this, I do it purely in TeX rather than using a separate build system. (There is a way to use insertions containing alternating marks and penalties to extract the information needed without shipping out the page.)
Normal C code, not that I can think of. But it is not difficult to give a real-world example:
A LaTeX document with a table of contents and an index has a cyclic dependency: The final document, including its pagination, depends on the table of contents, and the table of contents depends on the final document.