When has a LaTeX document compiled enough times for cross-references to be final?
0 reputation · 21 Jan 2020, 15:57 UTC
I am building a small automated pipeline that compiles LaTeX documents and I need to decide when compilation is actually done. From what I understand, LaTeX writes \label data to the .aux file during a run, and \ref commands read the previous run's data, which is why a first pass prints ?? and logs an undefined-reference warning.
What I cannot pin down is the stopping condition. LaTeX appears to emit a rerun warning when labels changed, but it only reports one pending pass at a time rather than stating how many runs remain. I have also read that elements like table-of-contents page numbers, longtable column widths, and hyperref bookmarks can shift across several runs, so two passes are not always sufficient. Tools like latexmk seem to rerun until generated files stop changing, which suggests the convergence decision is delegated outside the engine itself.
Assume a current pdfLaTeX-based setup with a standard document class.
Is comparing the .aux file between runs a reliable convergence test, or can references still be wrong when it stops changing? Does the log's rerun warning guarantee that one more pass is enough? And when a bibliography via BibTeX or Biber is involved, how should the extra engine runs be sequenced into that decision?