8

I let the MWE speak for itself.

\documentclass{minimal}
% remove babel and it works
% remove one language and it works
% reorder the languages and it works
\usepackage[italian,spanish,UKenglish]{babel}
% remove the color package and it works
\usepackage{color}
\begin{document}
hi
\end{document}

which outputs

This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)

...

(/usr/share/texlive/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
! Missing = inserted for \ifnum.
<to be read again> 
                   \let 
l.400 \newcount\nofMPsegments
  • 1
    Add \usepackage{etex} to allow for more count register. – Ulrike Fischer Mar 15 '15 at 17:45
  • @UlrikeFischer That works. But why should a certain language order use more registers than the same languages in another order? I can even add many more languages and packages without any problems, but this particular language order 'crashes'. – mhchem Mar 15 '15 at 17:52
  • italian.ldf actually loads etoolbox (and so etex), but it is often important to load it early enough. I didn't really check what exactly break here. (The next latex version will make it unnecessary to load etex). – Ulrike Fischer Mar 15 '15 at 18:01
  • I still don't understand why it should be a register limit problem. Why should [italian,spanish,UKenglish] need more memory than [italian,UKenglish,spanish] or [danish,french,ngerman,spanish,italian,UKenglish]? – mhchem Mar 15 '15 at 18:20
  • The problem is not the number of registers but (probably) when exactly etex enters the game. etex changes the allocation system, and when it does it at the wrong moment you can get problems. But this is speculation, I didn't really check. – Ulrike Fischer Mar 15 '15 at 18:30
5

This is a complement to egreg's answer

The source of the problem is that etoolbox hence etex will be loaded at a time where < is active. This is not completely catastrophic though, because even with < active, it might well expand to a catcode 12 < hence could work ok in \ifnum tests. However when package color is loaded and used with driver pdftex it then loads support file supp-pdf.mkii for MPS to PDF conversion. This file temporarily modifies the definition of \protect. And the active < then gives something unacceptable to \ifnum.

With only \usepackage[italian,spanish]{babel} and without color there is thus no error.

For some reason spanish.ldf temporarily makes makes < and > active during the time it is loaded by babel at the very end of spanish.ldf. This activity is cancelled for the rest of the preamble until \AtBeginDocument by code executed immediately after babel.sty is loaded. In the order \usepackage[spanish, italian]{babel} the loading of etoolbox which was demanded by italian.ldf at the end of package Babel is thus executed after the code, also at end of package Babel, which resets to unactive the catcodes of the activated characters by spanish (edit: activated at the very end of spanish.ldf itself).

In the order of \usepackage[italian,spanish]{babel} the end of package Babel demands of italian (which include the loading of package etoolbox hence also of package etex) are executed before those of spanish. As a result this is done at a time where < is active. Hence etex definition of \alloc@ is done with an active <. This is recipe for disaster although as seen above in some circumstances it may remain hidden, becasue the active < still will extend to a catcode 12 <.

I do not know enough the innards of Babel, but it appears to me that spanish.ldf should not demand to Babel to reset the catcodes of < and > at the end of loading of babel.sty [snip] but do it him/herself at the end of spanish.ldf... in fact I am not sure spanish.ldf makes any explicit demand of this type what I see is that

  1. it demands to Babel to activate < and >,
  2. then it immediately resets the catcodes to 12,
  3. then at the very last command of spanish.ldf one sees it re-activates < and >.

Babel by default I think resets to 12 the catcodes for the rest of the preamble when the activation was done properly (I do not investigate more, but I tested it in the case of spanish by itself).

Thus, I recommend this issue should be raised to the spanish.ldf and babel.sty maintainers. In fact, it would seem that the \csname activatequoting\endcsname at the end of spanish.ldf might be a bug (perhaps should be from what I understand only \let\es@quoting\activatequoting but not do \shorthandon{<>} ?), as anyhow Babel resets for the rest of the preamble the catcodes to 12.

  • 1
    Yes, it was a bug. Fixed. – Javier Bezos Jan 28 '16 at 14:38
  • @JavierBezos apologies for not having made a legit bug report... – user4686 Jan 28 '16 at 17:30
5

The problem is in the fact that babel-spanish, by default, makes < as a shorthand character and with certain combinations of languages this ends with this strange error that is surely due to this fact. The complete error message if one enables more \errorcontextlines is

! Missing = inserted for \ifnum.
<to be read again> 
                   \let 
\protect ->\let 
                \protect \@@mpstopdf@@protect \let \unprotect \@@mpstopdf@@u...

\active@prefix ...tect \noexpand #1\else \protect 
                                                  #1\fi \expandafter \@gobbl...

<->\active@prefix <
                   \normal@char< 
\alloc@ #1#2#3#4#5->\ifnum \count 1#1<
                                      #4\allocationnumber \count 1#1 \global...
l.400 \newcount\nofMPsegments

It's not very clear why loading italian before spanish produces the error and it's quite unclear why \usepackage[italian,spanish]{babel} doesn't stop.

However, calling the languages in a different order “fixes” the issue:

\usepackage[spanish,italian,UKenglish]{babel}

Alternatively, load etex just after the \documentclass lines.

What happens is that etoolbox is loaded at the wrong time, but there doesn't seem a better place for calling it from italian.ldf (apart not loading it in the first place).

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.