Compiling – Situations Requiring Multiple Document Compilations

compiling

You have to compile a file twice to get the desired output in the accepted answer to Lineno for 2 column. The accepted answer to How can I avoid compiling twice? provides a way to avoid compiling multiple times.

My question is, what are those situations where you have to compile a file more than once?
(We know of at least two such situations with reference to the linked questions.)

Best Answer

Any document that requires information to be written to and read from an ancillary file will need compiling more than once. These include documents that contain

  • references using \ref, or vref from varioref, or cref from cleveref
  • \tableofcontents, \listoffigures, \listoftables
  • \thumbsoverview (thumbs package)
  • bibliographies
  • indexes

In particular, one would need to compile more than once if any of the above has cause to change- for example, you add a new section to your document, which would necessarily change the \tableofcontents.

Of course, in the case of bibliographies and indexes one would need to run biblatex (or biber) or makeidx between multiple compilations to ensure that these are kept up to date.

Following Gonzalo's comment, there are also cases in which no ancillary files are involved as is the case with some table-building packages which require several passes to calculate the proper elements of the table (longtable, for example); or code using PGF/TikZ specially when using the remember picture/overlay options.