5

I know when I have a .bib file I need to do the following compilation order:

  1. Latex compiler
  2. biber
  3. Latex compiler
  4. Latex copmiler

But what about when I'm not using a .bib file? How many times do I need to compile then and why?

Nukesub
  • 607
  • A very simple LaTeX document may only need one LaTeX run. But if you use cross-references/labels (or other stuff implemented like labels), you usually need two LaTeX runs: The first run writes out the labels to an auxiliary, the second run then has them available from the start (this is required because LaTeX can't look into the future, a much more precise explanation can be found in https://tex.stackexchange.com/q/111280/35864). Table of contents and similar lists also add another run. Usually you will find warnings/hints about this in the .log file. – moewe Dec 05 '20 at 16:06
  • Some compilation tools like latexmk use heuristics and file monitoring to make sure to compile your document often enough so the output 'converges'. – moewe Dec 05 '20 at 16:07
  • @moewe normally two today (to get rid of the temporary last page). – Ulrike Fischer Dec 05 '20 at 16:12
  • @UlrikeFischer Two runs for a simple document as well, you mean? I'm getting old - when I started with LaTeX it was just one run :-) – moewe Dec 05 '20 at 16:17
  • @moewe not it all documents, but to be able to issue some code on the last page, one has to know which page this is so you get more often a temporary last page. – Ulrike Fischer Dec 05 '20 at 16:22
  • 1
    also beware documents that never converge https://tex.stackexchange.com/a/79699/1090 – David Carlisle Dec 05 '20 at 16:27

1 Answers1

8

If your document doesn't contain references or ToC, LoT, LoF material, a single pass through LaTeX might be enough (or was, with newer versions of LaTeX this might add an additional unwanted page on first pass, so as a rule of thumb: the minimum for guaranteed correct output is two).

If your document contains references, or ToC, LoT, LoF material, at least three times. The reasoning is pretty simple: First pass creates the labels and ToC, LoT, LoF material. Second pass has everything, but due to changes in layout and the additional material that wasn't available during first pass, the page numbers might change. Third pass is the first one that might be correct, but there could still be some changes affecting cross-referencing, so you might need more than three.

Skillmon
  • 60,462
  • Okay - so if no .bib file, do 3 times anyway just to be safe. – Nukesub Dec 05 '20 at 16:08
  • @Nukesub it really depends on what you're using. If you're using longtable you have to rerun LaTeX several times until it's done as well, and it doesn't have to be done after the third run. The best bet is what @moewe told you: Pay attention to the log, it usually tells you to rerun LaTeX if things aren't done yet. – Skillmon Dec 05 '20 at 16:11
  • Okay - will do. Thank you all for the quick responses! – Nukesub Dec 05 '20 at 16:12
  • 3
    @Nukesub there iis no need to guess how many runs are needed, you will always get a message in the log file if you need another run. Some tools search for those warnings and re-run automatically. – David Carlisle Dec 05 '20 at 16:25