biblatex icon indicating copy to clipboard operation
biblatex copied to clipboard

\textcite changes bcf after second latex run -> latexmk runs biber twice

Open real-or-random opened this issue 10 months ago • 2 comments

If you run the following document, which uses \textcite, through pdflatex, biber, pdflatex, then the bcf file after the first run of pdflatex is different from the bcf file after the second run.

\documentclass{article}
\usepackage{biblatex}
\begin{filecontents*}{\jobname.bib}
@InProceedings{CCS:BelNev06,
  author =       "Mihir Bellare and Gregory Neven",
  title =        "Multi-signatures in the plain public-Key model and a general forking lemma",
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
\textcite{CCS:BelNev06}
\end{document}

After the first run:

    <bcf:citekey order="1" intorder="1">CCS:BelNev06</bcf:citekey>

After the second run:

    <bcf:citekey order="1" intorder="1">CCS:BelNev06</bcf:citekey>
    <bcf:citekey order="2" intorder="1">CCS:BelNev06</bcf:citekey>

I think this makes sense to me, at least a bit. After the first run, there's just the single missing citation, but after the second run, we'll have the names and then the label, i.e., two "citations". The problem here is that latexmk will think that it needs to run biber again, even though this won't be necessary in this case. The bbl files are identical.

If there's no deep reason why this must the case (I'm not sure), then perhaps \textcite could be changed to always count as a single citation, or alternatively, always count as two citations (even in the case of a missing citation).

real-or-random avatar May 07 '25 22:05 real-or-random

This is because in most styles \textcite is implemented via a two-pass structure

https://github.com/plk/biblatex/blob/c743d5419c16a281ce852ef60e50c66ef7ae31a3/tex/latex/biblatex/cbx/numeric.cbx#L110-L146

The inner pass of the two passes is only executed if the entry data is available in the outer citation command.

So for a new citation you will only get the outer pass on a first LaTeX run, after the Biber run the subsequent LaTeX run will execute both passes. Then both the outer and the inner pass write a cite request to the .bcf file meaning you get a different .bcf from the first run.

The two-pass implementation of \textcite is not something we can realistically change. I had a quick lock at somehow 'blocking' writing the cite request of the inner pass to the .bcf, but that appeared to be tricky to get exactly right. I might have a look at this later if I have time, but this probably is not going to be high-priority for me: Functionality is not impacted, it's just a one-time (assuming you don't delete your auxiliary files) performance hit with tools that monitor the .bcf for change.

moewew avatar May 08 '25 07:05 moewew

I had a quick lock at somehow 'blocking' writing the cite request of the inner pass to the .bcf, but that appeared to be tricky to get exactly right.

Could it be easier to run the outer pass twice (perhaps the second time only partly) for \textcite?

But this probably is not going to be high-priority for me: Functionality is not impacted, it's just a one-time (assuming you don't delete your auxiliary files) performance hit with tools that monitor the .bcf for change.

Sure, I agree.

real-or-random avatar May 08 '25 15:05 real-or-random