1

Some background: I have been working on a 600 page LaTeX document (a scientific writing with a lot of math) for 15+ years. The source is trilingual (English, Norwegian and Spanish) with identical numbering of all chapters/ figures/ tables/ equations in all the three languages. It is (semi)automatically translated to a series of Beamer slideshows - one show for each language - again with identical numbering of the same text elements as mentioned above. The idea has been to write and maintain one piece of code to make cross referencing of text elements easier (not to say possible), with a view to teaching the same subject for different people in different grades from MSc to PhD, both physically and online at the same time. The software worked flawlessly for many years (and saved me a lot of time) until changes in the outside world made it harder for me to keep up with the good intentions. A week ago I decided to install my old scripts on a new computer to see if I could save the project and to my delight it compiled again (after years of dormancy). Another triumph with open source software!

However, inside the Spanish version of the Beamer slideshow there was a new error saying "! Extra \else." All the remaining material compiled just fine. Now, the root of the problem seems to be the unintentional misuse of \vpageref inside a Beamer frame, but only if the frame is inserted via a file that is part of an \include statement. My question is not primarily how to fix the problem but rather what is the cause of it, so that I can learn how to steer away in the future. I find errors like this very difficult to deal with - maybe I have too little understanding of the TeX language.

This is the MWE:

% Mac OS Big Sur v11.4
% This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/MacPorts 2020.54632_4)
% LaTeX2e <2020-02-02> patch level 5
% Document Class: beamer 2019/09/29 v3.57

\documentclass{beamer}
\usepackage{varioref}
\begin{document}
\include{./includefile}
\end{document}

The includefile is:

\begin{frame}
\vpageref{aRef} % or \vref{aRef}
\end{frame}%

The exact error message is:

! Extra \else.
\@include ...ediate \closeout \@partaux \fi \else
                                                  \deadcycles \z@ \@nameuse ...
l.9 \include{./inputfile}
5
  • Well, yes and no. One reason is that I am using \includeonly to speed up the compilation. It takes time to generate a few thousand slides and document pages. Also, I want to understand the cause of this cryptic message. It sounds like a syntax error but I have the suspicion it's a feature more than a bug.
    – Tore H-W
    Jul 6, 2021 at 17:39
  • This is exactly the kind of information I need to avoid problems and sense what can possibly go wrong without knowing every detail.
    – Tore H-W
    Jul 7, 2021 at 6:33
  • I'm going to delete these comments as Ulrike has spotted the real issue (and Frank is fixing it at source) so they are misleading now Jul 7, 2021 at 8:28
  • just for the record: the problem got solved in the LATeX release of 2021/11/15 Dec 5, 2021 at 10:45
  • In fact, and it works now on my side too. 5000 pages and slides without any fatal errors. I am grateful...
    – Tore H-W
    Feb 23 at 14:20

1 Answer 1

3

beamer loads hyperref and nameref and this changes the internal structure of a label:

A label has now five sub arguments in his second argument:

\newlabel{abc}{{}{1}} %without hyperref 
\newlabel{abc}{{}{1}{}{Doc-Start}{}} %with hyperref

varioref doesn't take that into account. In one place, if a label is unknown, it gives it a dummy definition with two sub arguments, and then the code grabs the rest from the following code and various things can fail.

You can try this:

\documentclass{beamer}
\usepackage{varioref}

\makeatletter
\def\vref@pagenum#1#2{%
  \@ifundefined{r@#2}{\@namedef{r@#2}{{??}{??}{??}{??}{??}}}{}% 5 arguments
  \expandafter\expandafter\expandafter\vref@@pagenum
  \csname r@#2\endcsname{}{}\@nil#1%
}
\makeatother
\begin{document}
\include{includefile}% \vpageref{aRef} 
\end{document}
5
  • I see. It's probably time to leave varioref. Compare also (tex.stackexchange.com/questions/83037/…)
    – Tore H-W
    Jul 6, 2021 at 22:10
  • Well i would prefer varioref over cleveref currently. The probability that such an error is corrected is higher with varioref. Jul 6, 2021 at 22:14
  • This is a valuable comment. I have experience with smart referencing from before and do not expect wonders - what I need for automatic typesetting of slides from text (whether this is smart can of course be discussed) is something that gives the fewest surprises. Like the one I stumbled across here.
    – Tore H-W
    Jul 7, 2021 at 6:21
  • @ToreH-W it will be fixed with the next LaTeX release, for now please use Ulrike's suggested workaround after loading varioref. Jul 7, 2021 at 7:47
  • Yes I will. I have also accepted Ulrike's answer.
    – Tore H-W
    Jul 7, 2021 at 9:50

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.