0

How to compile when using biblatex and hyperref?

Currently I use lualatex-biber-lualatex-lualatex

I don't know why and I am thinking that can it be reduced to maybe biber-lualatex?

PS: I use TeX Live 2022 + VS code + Latex Workshop

1 Answers1

2

(In what follows I will write LaTeX for what can be a pdfLaTeX, XeLaTeX or LuaLaTeX call.)

Generally speaking, no, the compilation sequence cannot simply be reduced to Biber+LaTeX.

The exact details are a bit more complex.

  • LaTeX only reads your file from start to finish and processes it sequentially. LaTeX cannot look ahead for content that is to come in the future. In order to be able to properly support references to objects that only come later in the document (think a \ref to a \section \label or the table of contents), LaTeX relies on auxiliary files that are produced by each LaTeX run and that are read by a subsequent LaTeX run. See also Understanding how references and labels work.

    Effectively this means that documents with cross-references, a table of contents and similar objects need two LaTeX compilation runs assuming the auxiliary files are not present. If auxiliary files are already present, the second run is only required LaTeX needs to use look-ahead information that is not yet present in the auxiliary files or the look-ahead info has changed. LaTeX has a detection mechanism in place that should produce a warning if another LaTeX run is required.

  • LaTeX does not understand .bib files directly. Those files need to be prepared by an external bibliography tool like Biber or BibTeX. This requires communication between LaTeX and the external tool, which again happens via auxiliary files. On a first LaTeX run, LaTeX creates an auxiliary file that tells Biber/BibTeX which .bib files are used in your document, which entries from those files were cited and which information/in which style the document wants the bibliography entries. The bibliography tool reads this auxiliary file and processes the .bib files. It then generates a further auxiliary file with the bibliography data. This auxiliary file can then be read by a subsequent LaTeX run. See also Question mark or bold citation key instead of citation number.

    This means that you need at least a compilation sequence of

    • LaTeX
    • Biber/BibTeX
    • LaTeX

    assuming that no auxiliary files are present. Since the last LaTeX run may need look-ahead information, the effective minimal compilation sequence is actually

    • LaTeX
    • Biber/BibTeX
    • LaTeX
    • LaTeX

    by the previous observation.

    It is not necessary to rerun the whole compilation cycle each time you change anything about your document. But as soon as you change something related to your citations or the bibliography a LaTeX run followed by a Biber and one or two further LaTeX runs are required. Again there are some detection mechanisms in place that tell you whether or not reruns are required.

Generally, speaking a full compilation sequence for your document would involve at least LaTeX, Biber, LaTeX, LaTeX. But not every change you apply to your document needs a full cycle rerun assuming the auxiliary files are still present. For very small changes you may well get away with only running LaTeX once. Usually, LaTeX should tell you which reruns are required in the log output. This "automatic rerun warning" feature is pretty solid, but it does not always catch all rerun requirements. So if you want to be on the safe side, run at least LaTeX, Biber, LaTeX, LaTeX before you produce the final version of your document.

If you are worried about running the LaTeX-Biber-LaTeX-LaTeX cycle when it is not necessary to run the whole thing, look into the wonderful latexmk tool. latexmk has an advanced heuristics that tries to detect exactly which LaTeX/Biber/whatever runs are required to produce a stable output.


Just to add what would happen if we'd run just Biber+LaTeX on an document if there are no auxiliary present.

Biber would throw an error because it needs the auxiliary file from a LaTeX run to do its work. The subsequent LaTeX run would not be able to produce a bibliography, but it would generate the required auxiliary files for Biber.

If you then run Biber+LaTeX again (and do not delete the auxiliary files in between), Biber would compile the bibliography to an auxiliary file and the subsequent LaTeX run would be able to generate a bibliography. Cross-references to the bibliography and citations might be off, because that would require at least another LaTeX run.

moewe
  • 175,683