Why do I need to run latex/bibtex three times to make everything look good?

Posted on In QA

Why does latex need to be executed 3 times like following?

pdflatex main.tex
bibtex main
pdflatex main.tex
pdflatex main.tex


Copied from https://tex.stackexchange.com/questions/53235/why-does-latex-bibtex-need-three-passes-to-clear-up-all-warnings.

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…

Leave a Reply

Your email address will not be published. Required fields are marked *