4

I'm running a minimal, up-to-date TeX Live installation on Windows 11. I am trying to use biblatex and biber for bibliography management.

The problem I am experiencing is that I must run pdflatex thrice to clear all warnings. I know that this is expected behaviour for bibtex; but my understanding was that biblatex only requires a single pdflatex-biber-pdflatex run to work.

I have provided a MWE below with the contents of the two files, demo.tex and refs.bib:

demo.tex

\documentclass{article}
\usepackage[backend=biber]{biblatex}
\addbibresource{refs.bib}
\begin{document}

According to Smith \cite{smith99}, blah blah blah.

\printbibliography

\end{document}

refs.bib

@book{smith99,
        title = {Clever Book Title},
        author = {John Smith},
        publisher = {Smith Publishing},
        year = {1999}
}

Here is my approach: I first run the command pdflatex demo.tex, and the terminal outputs these warnings:

LaTeX Warning: Citation 'smith99' on page 1 undefined on input line 6.

LaTeX Warning: Empty bibliography on input line 8.

LaTeX Warning: There were undefined references.

Package biblatex Warning: Please (re)run Biber on the file:
(biblatex)                demo
(biblatex)                and rerun LaTeX afterwards.

Then, I run biber demo as instructed. There are no errors.

Then, I run pdflatex demo.tex again, only to see the following warnings:

LaTeX Warning: There were undefined references.

Package biblatex Warning: Please rerun LaTeX.

Which is odd, as the output PDF looks fine - it has the in-text numeric citation as well as the bibliography.

When I run pdflatex demo.tex (for the third time), there are no warnings in the output.

This behaviour is consistent across trials. I have tried running pdflatex without the file extension (pdflatex demo); I have tried different keys instead of smith99; I have tried other source types such as online or article, all to no avail.

Both files are located in the folder C:\demo, and there are no other files in this directory. I have tried to isolate the problem as much as I possibly can, but biblatex tells me to rerun LaTeX every single time.

I have also tried running latexmk -pdf demo.tex, and it runs pdflatex-biber-pdflatex-pdflatex.

What is causing this problen? Any help is greatly appreciated. Thank you.

9
  • 1
    The correct minimal build sequence of a document with biblatex is: LaTeX, Biber, LaTeX, LaTeX. So you always need at least two LaTeX runs after biber. See tex.stackexchange.com/questions/63852/… But note: Depending on the document and used packages, additional LaTeX runs could be needed (but usually not because of the bibiography).
    – cabohah
    Jun 7 at 9:38
  • 1
    After pdflatex-biber-pdflatex the aux file contains now \abx@aux@defaultrefcontext{0}{smith99}{nty/global//global/global}. Before that it does not contain that command. That command will make something defined at begin document on 3rd run only, without it \cite{smith99} will cause a command \blx@rerun@latex to be issued at end document. User is then prompted to rerun LaTeX.
    – user691586
    Jun 7 at 10:01
  • 2
    In your example imho biblatex is overdoing and the third compilation is not needed. But for more complex bibliographies e.g. with delayed numbering and similar you need one more, so probably the package is a bit overcautious. Jun 7 at 10:06
  • 1
    The answer you link to dates back to 2011. I tested with TeXLive 2013 and indeed at that time pdflatex-biber-pdflatex was enough (meaning that biblatex did not prompt user for a 3rd run of pdflatex). The structure of the biblatex instructions in the .aux file is very different with the TL2013 context. biblatex has evolved since. I don't know when its internal refactorings induced the new behavior.
    – user691586
    Jun 7 at 10:09
  • 1
    Most things have already been discussed in the question, but just a bit of background on the LaTeX Warning: There were undefined references.. Whenever biblatex detects that a LaTeX rerun is required it issues a warning of the form Please rerun LaTeX, but it will also activate \G@refundefinedtrue, which the LaTeX kernel uses to decide whether or not to print the LaTeX Warning: There were undefined references.. It has used this command from the kernel from the start. I'm assuming to make it easier for tools that analyse the .log file to detect that a rerun is requested. ...
    – moewe
    Jun 8 at 5:55

4 Answers 4

6

Let's see, what happens while running LaTeX and Biber in your case:

  1. While the first LaTeX run, LaTeX and biblatex do not have any information about the reference smith99 and therefore LaTeX reports an undefined citation and an empty bibliography. biblatex warns to first run Biber and rerun LaTeX afterwards. But while this run, it also writes a bcf file with information about the requires resource and cite requests.

  2. While the Biber run, it reads the bcf file and uses the information about cites and resources to generate a bbl file.

  3. While this LaTeX run, biblatex reads the bbl file and uses the information to generate an often already valid PDF. But it cannot read some information like the reference context or the md5 checksum of the bbl file from the aux file (because Biber has not changed the aux file). So it reports, that there could still be changes, e.g., because the assumed reference context could be wrong. While the LaTeX run, it also writes a valid md5 checksum of the bbl file and some other information like the reference context to the aux file.

  4. While this LaTeX run, biblatex can already compare the md5 checksum from the aux file with the md5 checksum of the found bbl file and the other information like the reference context. So (together with all references are found in the bcf file) now it knows, that no more LaTeX runs are needed.

So as you can see, the last LaTeX run is not always needed to get a valid PDF, but it is at least needed, to make biblatex knows, that no more LaTeX (or Biber) run is needed. But this is not always the case. There could be a scenario, where step 4 is really needed to get a valid PDF.

3
  • 1
    AFAICS the actual code path that triggers the rerun warning is not concerned with \abx@aux@read@bbl@mdfivesum. biblatex is more worried about the default refcontext assignments here.
    – moewe
    Jun 8 at 6:13
  • @moewe Better now?
    – cabohah
    Jun 8 at 9:06
  • 1
    Yes, though I still feel it puts too much emphasis on the md5 sum, which does not cause biblatex to request the rerun here. The rerun is only due the refcontext assignment. I might be a bit too sensitive/defensive about it though, because I wrote the md5 code.
    – moewe
    Jun 8 at 15:51
4

rerun messages don't need to be correct. E.g. this here issues a rerun message too:

\documentclass{article}
\begin{document}
\section{test}\label{test}
\end{document}

LaTeX does detect here that the labels have changed, but doesn't check if this label is actually used and so if the change is relevant. Something similar happens in your example with biblatex (and also with other packages issuing rerun messages): it assumes wrongly that another compilation is needed.

One could naturally try to refine such tests and catch these cases. The question is if it is worth the trouble: with a small document you save a compilation, but in real documents a second or third compilation is needed anyway and so you don't gain anything by making the tests more complicated (and slower).

2

The information you found on this site are partly deprecated. In particular this answer dates back to 2011 and indeed testing your example with a TL2013 installation confirms at that time there was no prompting at end of second run for one more run. But since then biblatex has evolved.

Generally speaking anyhow 3 LaTeX runs is often needed: for example a \tableofcontents will typeset material only on second run. In article class this will quite probably cause a shift of material due to the injected TOC (less likely with chapter class as it uses a chapter-like rendering, doing a \cleardoublepage, and also the page numbering style can change from roman to arabic, so extra stuff in TOC does not cause page numbers of document to change). Generally speaking, any thing which happens on second run only as a result of first run having stored data in auxiliary files is susceptible to shift page numbering for some references, hence a third run is often necessary.

Only simple documents need only 2 runs, not to speak of 1 run.

1
  • +1. Three re-runs of pdflatex after the initial pdflatex+biber calls were required to remove all "Please rerun LaTeX" warnings for some of the documents I was working on. Aug 21 at 7:39
1

Just for comparison.

If you are using OpTeX, then you need only two runs: optex-optex and no external program (like Biber) is needed. I used exactly the same refs.bib file as given in your question. And I prepared following demo.tex file:

\fontfam[lm]

According to Smith \cite[smith99], blah blah blah.

\usebib/s (iso690) refs

\bye

Before the first run of optex, there is no demo.ref file (the *.ref file is something similar like LaTeX's aux, toc, lof, lot, bbl etc. files together, but it is only single file for all purposes). The first run of OpTeX reports:

This is LuaTeX, Version 1.17.0 (TeX Live 2023) 
 restricted system commands enabled.
(./demo.tex This is OpTeX (Olsak's Plain TeX), version <1.12+ May 2023>
(/home/olsak/texmf/tex/optex/base/f-lmfonts.opm
FONT: [Latin Modern] -- \LMfonts (TeX Gyre fonts based on Computer Modern)
...)
WARNING l.3: {} \cite [smith99] unknown. Try to TeX me again.
(/home/olsak/texmf/tex/optex/base/usebib.opm)
(/home/olsak/texmf/tex/optex/base/bib-iso690.opm) (./refs.bib)
OpTeX: Sorting \_citelist (en) ...
WARNING l.5: Missing field "address" in [smith99].
WARNING l.5: Missing field "isbn" in [smith99].
[1...]
WARNING l.7: Try to rerun, demo.ref file was created.
Output written on demo.pdf (1 page, 9699 bytes).
Transcript written on demo.log.

After this first run the pdf output looks like:

According to Smith [??], blah blah blah.

[1] Smith, John. Clever Book Title. Smith Publishing, 1999.

It means that the \cite macro did know nothing about the [smith99] label and it printed ?? only. Moreover, it added the [smith99] label to the \_citelist. Then the macro \usebib reads the refs.bib file, finds the [smith99] label here (and maybe others used cite-labels in the document and accumulated in the \_citelist macro), then it sorts the \_citelist and finally it prints the \_citelist by formatting rules declared in the bib style file bib-iso690.opm. When printing, the numbers are assigned to the labels, so OpTeX knows, that [smith99] has the number 1. This information is saved to the demo.ref file.

The second run starts by reading the demo.ref file and then the document is created. All needed information is known and the result is:

This is LuaTeX, Version 1.17.0 (TeX Live 2023) 
 restricted system commands enabled.
(./demo.tex This is OpTeX (Olsak's Plain TeX), version <1.12+ May 2023>
(./demo.ref) (/home/olsak/texmf/tex/optex/base/f-lmfonts.opm
FONT: [Latin Modern] -- \LMfonts (TeX Gyre fonts based on Computer Modern)
...)
(/home/olsak/texmf/tex/optex/base/usebib.opm)
(/home/olsak/texmf/tex/optex/base/bib-iso690.opm) (./refs.bib)
OpTeX: Sorting \_citelist (en) ...
WARNING l.5: Missing field "address" in [smith99].
WARNING l.5: Missing field "isbn" in [smith99].
[1...]
Output written on demo.pdf (1 page, 9699 bytes).
Transcript written on demo.log.

According to Smith [1], blah blah blah.

[1] Smith, John. Clever Book Title. Smith Publishing, 1999.

The md5sum checking of the demo.ref file is done at the end of the second run, but this file isn't changed, so we have no warning like this:

WARNING l.7: Try to rerun, demo.ref file was changed.

We can see only warnings about missing fields address and isbn because they are mandatory when @book entry is printed via bib-iso690 style file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .