biblatex icon indicating copy to clipboard operation
biblatex copied to clipboard

BibLaTeX changes the pagenumbering in warnings

Open touhami opened this issue 4 years ago • 1 comments

With this code

\documentclass{book}
%\usepackage{biblatex}
\begin{document}
\frontmatter
foo\cite{mt} \ref{foo}
\mainmatter
foo\cite{mt1} \ref{foo1}
\end{document} 

I get the following warnings, which is good.

LaTeX Warning: Citation 'mt' on page i undefined on input line 5.

LaTeX Warning: Reference `foo' on page i undefined on input line 5.


LaTeX Warning: Citation 'mt1' on page 1 undefined on input line 7.

LaTeX Warning: Reference `foo1' on page 1 undefined on input line 7.

But if i uncomment \usepackage{biblatex}, then i get

LaTeX Warning: Citation 'mt' on page 1 undefined on input line 5. which seems to be wrong.

I mean why the roman page numbering is lost?

touhami avatar Jul 29 '21 11:07 touhami

Mhh, yeah biblatex has \the\c@page

https://github.com/plk/biblatex/blob/cadac4c1b8a9385faeec818ffde5102566ec3c13/tex/latex/biblatex/biblatex.sty#L1520-L1521

where the LaTeX kernel has \thepage (https://github.com/latex3/latex2e/blob/43065449eb954a1170340ec4b75e145619cf289a/base/ltbibl.dtx#L267-L268).

I can't tell you why (it has been like this since version v1.0 of biblatex ten years ago), but I suspect it might be because we cannot guarantee that \thepage is expandable. For example

\documentclass[spanish]{book}
\usepackage{babel}
%\usepackage{biblatex}
\begin{document}
\frontmatter
foo\cite{mt} \ref{foo}
\mainmatter
foo\cite{mt1} \ref{foo1}
\end{document}

gives

LaTeX Warning: Citation `mt' on page \es@scroman {i} undefined on input line 6.

LaTeX Warning: Reference `foo' on page \es@scroman {i} undefined on input line 
6.

If \thepage is not expandable, then presumably \the\c@page might be a good enough approximation to the page number, but of course different numbering schemes can mean that certain numbers appear multiple times.


I'm not opposed to use \thepage here, but the question is if we should not respect PL's wish to use something that definitely won't break here. Nonsensical example, but the following works with biblatex, but breaks without it.

\documentclass{book}
\usepackage{biblatex}
\begin{document}
\frontmatter
foo\cite{mt}
\mainmatter
\def\thepage{\def\undefinedcommand{huh?}}
foo\cite{mt1}
Lorem
\end{document}

That said, we'd only break documents that would also break with the LaTeX kernel definitions, so we'd probably have good reason to declare this a user error.

moewew avatar Jul 29 '21 15:07 moewew