I am able to use BibTeX and pdfLaTeX if I compile with pdfLaTeX THREE TIMES. This seemed absurd, but appears to be confirmed by this previous question.

That is:

  1. Compile with pdflatex to generate .aux file that BibTeX needs- references will show as '?' for now
  2. Run BibTeX with .aux file as argument
  3. Compile with pdfLaTeX again - references STILL show as '?'
  4. Compile yet again - references now good with inline numbers in [].

This DOES work, and so clearly is A way to do it - but surely it can't be THE way to do it? My understanding is that LaTeX and all derivatives stem originally from Donald Knuth, one of the greatest computer scientists ever. This duplication just seems ridiculous, and no less so for being made easier with a python script.

  • 6
    why is it absurd? tex does not have the whole document in memory (not usually more than a page) so any forward references need to use data saved on an earlier run. It can take more than three runs to resolve all such references. A more modern design might have held it all in memory and hidden the extra passes but it makes no difference really, and unless you write an entire error free document in one sitting, it makes little practical difference to the user. references are resolved by the time the document is finished. Dec 5, 2016 at 11:58
  • 1
    If you want to launch only one command, use arara package.
    – CarLaTeX
    Dec 5, 2016 at 11:59
  • 1
    Note that when using biblatex you don't need the third run of pdflatex. Dec 5, 2016 at 12:14
  • 5
    Not directly relevant, but whilst Knuth wrote TeX, LaTeX was written by Leslie Lamport and BibTeX at Lamport's suggestion by Oren Patashnik. Knuth's approach remains plain TeX, where citations and other cross-referencing is done by hand.
    – Joseph Wright
    Dec 5, 2016 at 12:20
  • 1
    @Mark because the bibliography is made after the first, input at the end of the document on the second so the string to use for \cite is only available on the third pass. Dec 5, 2016 at 12:35

1 Answer 1


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 latex, 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

  • LaTeX
  • BibTeX (or Biber: see below)
  • LaTeX

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.

  • 2
    It's probably worth noting that while biblatex can get rid of the need to do a third pass for the bibliography the third pass is usually needed anyway for a typical document with a table of contents as the bibliography won't be inserted until the second pass so the final page numbers of any section after the bibliography won't be known when \tableofcontents is encountered at the start of the second pass., so the table of contents will only be correct on the third pass. Dec 5, 2016 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.