The mechanisms for the process are described in Understanding how references and labels work and Question mark or bold citation key instead of citation number, but that perhaps doesn't immediately explain why it is so for classical BibTeX use.
The need for at least three runs for BibTeX arises from three related factors:
- The need to extract references from a separate file
- The need to set up cross-references for internal 'links'
- Memory constraints
In the classical BibTeX workflow, the first run has no citations available, so writes these to a file for later extraction by BibTeX. The first run that has happens (so after
bibtex, i.e. the second LaTeX run), the references are inserted by the
.bbl file (which is simply 'some stuff to typeset). Typically, this is toward the end of the file so (normally) earlier citations can't 'know' what reference numbers will be used. At the end of the second run, the necessary data is written to file and is read during the third LaTeX run.
The need for at least two runs cannot be avoided as there may always be forward references. However, the need for three runs can be avoided. If all of the citation data is read at the start of the document, it's possible to assign reference numbers before the second typesetting run starts. This allows citations to be resolved by a workflow
- BibTeX (or Biber: see below)
This workflow is implemented by
biblatex, and nowadays the Biber 'backend' is favoured over BibTeX (the program). What is does requires is sufficient memory to be able to hold all of the citation data during the typesetting run: fine today but much less so when the classical BibTeX workflow was designed (1980s). (Note that other parts of the document structure may require three runs: for example if there is a
\tableofcontents and any sections after the bibliography, then those will only have the correct page numbers after three runs.)
Notice that in the classical workflow only the cross-references which are actually used are held in memory, as only those get written to the intermediate files. This also impacts on the more general cross-reference business: TeX ships out pages 'as they are made' so places where one could 'back up' to resolve references in a single pass can't be handled.