3

Feeding

\documentclass{article}
\usepackage[greek]{babel}%%% greek should not necessarily be the main language; e.g., [greek, ngerman] would also expose the bug.
\usepackage{cleveref}%%% option [ngerman] would not change the outcome.
\begin{document}
\pagenumbering{Roman}
\label{someLabel}
\end{document}

as mwe.tex to pdflatex leads to

! Incomplete \iffalse; all text was ignored after line 6. \fi <*> mwe

?

Versions:

  • pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2022/dev/Debian)
  • LaTeX2e <2021-06-01> patch level 1
  • cleveref 0.21.4 or 0.21.5 (both expose the bug)
  • greek.ldf 2020/11/10 v1.10
  • babel 2021/07/22 3.63

The bug occurs in current Debian testing "bookworm": https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=997024

The maintainers of cleveref, greek.ldf, and babel have been informed. Meanwhile, any workaround?

3

The problem is in the \ensureascii macro. You can make it \protected.

\documentclass{article}
\usepackage[greek]{babel}
\usepackage{etoolbox}
\usepackage{cleveref}

\AtBeginDocument{\robustify\ensureascii}

\begin{document}

\pagenumbering{Roman}
\label{someLabel}

\end{document}
9
  • Actually, \ensureascii is (indirectly) protected. The real issue in an \edef applied to \thepage instead of a \protected@edef in cleveref. But it’s a nice workaround. Oct 23 at 6:12
  • @JavierBezos cleveref expects \@Roman to be fully expandable (which it should be). Of course we all know the quirks of LGR encoding… In any case, littering the .aux file with {\fontencoding{OT1}\selectfont...} is not the best.
    – egreg
    Oct 23 at 16:22
  • Not exactly – cleveref expects \thepage to be fully expandable, and that’s wrong (the buggy line is \edef\@tempb{\thepage}) . \the... representations are not required to be fully expandable, and you can find examples in the LaTeX Companion where clearly they are not. Using \edef instead of \protected@edef with arbitrary stuff is a ‘classic’ (I myself have made this mistake several times). In fact, it fails even if you define \ensureascii with \DeclareRobustCommand, because the \protect is ignored, the reason being, again, the \edef. @egreg Oct 23 at 17:29
  • Here is a MWE bombing without babel: \documentclass{article} \usepackage{cleveref} \renewcommand\thepage{\textit{\arabic{page}}} \begin{document} \label{someLabel} Text \end{document}. Oct 23 at 18:01
  • @JavierBezos Yes, that bombs, but the definition is very dubiously useful.
    – egreg
    Oct 23 at 20:00
3

You can restore the original Roman counter formatting:

\documentclass{article}

\makeatletter
\let\@RomanSaved\@Roman
\usepackage[greek]{babel}%%% greek should not necessarily be the main language; e.g., [greek, ngerman] would also expose the bug.
\usepackage{cleveref}%%% option [ngerman] would not change the outcome.
\let\@Roman\@RomanSaved
\makeatother

\begin{document}
\pagenumbering{Roman}

\setcounter{page}{5}

\label{someLabel}
{\fontencoding{T1}\selectfont\pageref{someLabel}}
\end{document}

enter image description here

7
  • But \pageref{someLabel} might produce really weird output. Try with \setcounter{page}{5} and issue \pageref{someLabel}.
    – egreg
    Oct 22 at 17:20
  • @egreg well it typesets as V so in either case you need \fontencoding{T1}\selectfont or a babel equivalent to see it typeset using a latin font. Oct 22 at 17:47
  • No, it typesets an accent.
    – egreg
    Oct 22 at 17:54
  • @egreg ? it looks like a V to me, example extended. Oct 22 at 18:25
  • Of course that works, but… My solution works without special treatments.
    – egreg
    Oct 22 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.