plk / biblatex

biblatex is a sophisticated bibliography system for LaTeX users. It has considerably more features than traditional bibtex and supports UTF-8
515 stars 118 forks source link

"Incomplete \iffalse" error with both `backref` option, `greek` `babel`'s language and `hyperref` #1175

Closed dbitouze closed 1 year ago

dbitouze commented 3 years ago

(Disclaimer: I'm not sure whether biblatex is the culprit or not.)

When both:

references in the \frontmatter of a document lead to the error:

! Incomplete \iffalse; all text was ignored after line 17.
<inserted text> 
                \fi

(As an unsatisfactory workaround, one can use \backtrackerfalse/\backtrackertrue.)

\documentclass[greek,english]{book}
\usepackage{csquotes}
\usepackage[backref]{biblatex}
\usepackage{babel}
\usepackage{hyperref}

\addbibresource{biblatex-examples.bib}

\begin{document}
\frontmatter
% \backtrackerfalse
\autocite{knuth:ct}
% \backtrackertrue
\mainmatter
\autocite{knuth:ct}
\printbibliography
\end{document}
jspitz commented 2 years ago

The problem seems to be that \blx@addbackref@i writes

\abx@aux@backref{1}{knuth:ct}{0}{{\fontencoding  {OT1}\selectfont  i}}{1}

which is due to babel-greek redefining \@roman as

\def\@roman#1{\expandafter\ensureascii\expandafter{\romannumeral#1}}

which does not seem to be liked by the backref meachnism.

If you redefine \@roman in the preamble, the document compiles:

\documentclass[greek,english]{book}
\usepackage{csquotes}
\usepackage[backref]{biblatex}
\usepackage{babel}
\usepackage{hyperref}

\makeatletter
\def\@roman#1{\romannumeral#1}
\makeatother

\addbibresource{biblatex-examples.bib}

\begin{document}
    \frontmatter
    % \backtrackerfalse
    \autocite{knuth:ct}
    % \backtrackertrue
    \mainmatter
    \autocite{knuth:ct}
    \printbibliography
\end{document}

But of course that's not a solution. Locally making \ensureascii a no-op within \blx@addbackref@i (analogouos to the solution to a similar problem proposed at https://tex.stackexchange.com/a/207267) does not seem to work.

Hope this helps to debug this.

jspitz commented 2 years ago

See also https://tex.stackexchange.com/a/619885 for a related discussion.

jspitz commented 2 years ago

See also https://tex.stackexchange.com/a/619885 for a related discussion.

BTW the workaround proposed here works in the case here as well:

\AtBeginDocument{\robustify\ensureascii}
jspitz commented 2 years ago

Also related: latex3/babel/issues/170

jspitz commented 2 years ago

This MWE demonstrates that the problem is not in biblatex, but rather in babel(-greek) or hyperref/backref:

\documentclass[greek,english]{book}
\usepackage{babel}
\usepackage[backref=page]{hyperref}

%Workaround:
%\usepackage{etoolbox}
%\AtBeginDocument{\robustify\ensureascii}

\begin{document}
    \frontmatter
    \cite{article-minimal}
    \mainmatter
    \cite{article-minimal}
    \bibliographystyle{plain}
    \bibliography{xampl}
\end{document}