TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As explained by Andy Roberts, if you need to compile a new document with bibtex citations, then you need to run latex three times, and bibtex once:

latex document
bibtex document
latex document
latex document

Why can't latex figure this out itself, and just do what it needs to do? What is it doing in the later runs that it can't do in the earlier runs?

share|improve this question
I recommend latexmk (Homepage/CTAN), which does what you're demanding: It figures out what needs to be run how often all by itself. It works well with BibTeX and Biber, but might need some fine-tuning for other things, e.g. glossaries, about which you'll find questions on here. The author is also very responsive and actually answers questions here on tex.sx. – doncherry Apr 25 '12 at 9:46
@doncherry: I actually use pdflatex, does latexmk output to pdf? – naught101 Apr 25 '12 at 10:26
Yes, use it like this: latexmk -pdf foo.tex. There are many more options available, e.g. latexmk can automatically compile whenever you save the .tex file (that's the -pvc [preview continuously] option). Check out its manual, it's fairly comprehensible. – doncherry Apr 25 '12 at 10:46
up vote 36 down vote accepted

The reason is as follows:

  1. At the first latex run, all \cite{...} arguments are written in the file document.aux.

  2. At the bibtex run, this information is taken by bibtex and the relevant entries are put into the .bbl file, sorted either alphabetically or by citation order (sometimes called "unsorted") and formatted according to the instructions provided by the bibliography style that's in use.

  3. At the next run of latex, the .bbl file is included at the point the \bibliography instructions, and the correct labels for \cite{...} commands are written in .aux file.

  4. Only at the last run, latex knows what the correct labels are and includes them in the document.

The reason why TeX and BibTeX have been made this way is that back then, the memories used to be small, and file systems were the only good ways to store files. But you cannot read and write the same file (well, you can, but it's more complicated), that's why you have to run latex twice after bibtex, as well as you have to run it twice where you cross-reference etc.

Some passes can be saved using biblatex instead of bibtex. Anyways, all references (and cross-references) stabilize during the document preparation since all of us compile our documents many times...

share|improve this answer
biblatex doesn't avoid the need of multiple pass processing. – egreg Apr 25 '12 at 8:58
I have always thought that it reduces at least one pass... – yo' Apr 25 '12 at 9:02
Yes, it may avoid one pass. But it's not so important to always do all passes: it's quite often only a waste of time. Cross references will stabilize during document preparation and it's not necessary that they are always correct. Just remember to run BibTeX (or Biber) when citations are added. – egreg Apr 25 '12 at 9:15
I've taken the liberty of providing a bit more information about the output of the bibtex run. Hope you agree. – Mico Oct 29 '14 at 20:22
I've already upvoted the answer for you. -:) – Mico Oct 30 '14 at 11:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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