# moderncv and babel spanish cause "Missing \endcsname..." error

When I run the following code it compiles as expected:

\documentclass[%
11pt
,a4paper
,sans
]{moderncv}

\moderncvstyle{classic}
\moderncvcolor{blue}

\usepackage[scale=0.75]{geometry}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%\usepackage[spanish, activeacute]{babel}

% Personal Data
\firstname{John}
\familyname{Doe}
\title{CV}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{john@doe.com}
\homepage{www.johndoe.com}
\extrainfo{extrainfo}
\quote{somequote}

\begin{document}

\makecvtitle

\section{First section}
\cventry{Prueba}{Alimentación}{alimentaci'on}{}{}{}

\end{document}


Uncommenting \usepackage[spanish, activeacute]{babel} generates the following error (pasting here only the first part):

! Missing \endcsname inserted. \protect l.22 \phone[mobile]{+1~(234)~567~890} The control sequence marked should not appear between \csname and \endcsname.

If I then comment out the \phone lines (so babel is still uncommented) it runs fine. Furthermore, using babel with another language (e.g. ngerman) and the \phone lines, also works fine.

Can anybody tell me waht's going on? Why can't I have both babel spanish and \phone uncommented?

I use moderncv 1.5.1, Texlive 2012.20120611-5 and Texmaker 3.4 on Linux Mint Debian edition.

Thanks.

The babel module for Spanish redefines \roman to use small caps and in many places moderncv uses \roman for building indexed macros, basically by doing

\csname xyz\roman{counter}\endcsname


which won't work if \roman is redefined in that way.

Solution: add the es-lcroman option when loading babel:

\usepackage[spanish,es-lcroman]{babel}


I'm not sure that activeacute is really necessary with UTF-8 input. I wouldn't use ~ for the phone numbers: a normal space seems sufficient.

A different strategy, if es-scroman is needed, is to patch all the moderncv commands that use \roman:

\documentclass[
11pt,
a4paper,
sans,
]{moderncv}

\moderncvstyle{classic}
\moderncvcolor{blue}

\usepackage[scale=0.75]{geometry}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish, activeacute]{babel}

\usepackage{regexpatch}
\makeatletter
\regexpatchcmd*{\endcvcolumns}
{\c{roman}\cB.tmpiteratorcounter\cE.}
{\c{romannumeral}\c{c@tmpiteratorcounter}}
{}{}
\regexpatchcmd*{\cvcolumn}
{\c{roman}\cB.cvcolumnscounter\cE.}
{\c{roman}\c{c@cvcolumnscounter}}
{}{}
{\c{roman}\cB.(collection@\cP.2@count)\cE.}
{\c{romannumeral}\c{csname}c@\1\c{endcsname}}
{}{}
\makeatother

% Personal Data
\firstname{John}
\familyname{Doe}
\title{CV}
\phone[mobile]{+1 (234) 567~890}
\phone[fixed]{+2 (345) 678 901}
\phone[fax]{+3 (456) 789 012}
\email{john@doe.com}
\homepage{www.johndoe.com}
\extrainfo{extrainfo}
\quote{somequote}

\begin{document}
\makecvtitle

\section{First section}
\cventry{Prueba}{Alimentación}{alimentaci'on}{}{}{}

\end{document}


A request for bug fix should be filed to the maintainer of moderncv. The macros involved are

1. \endcvcolumns which is defined by \newenvironment{cvcolumns}, where the occurrences of

\roman{tmpiteratorcounter}


should become

\romannumeral\c@tmpiteratorcounter

2. \cvcolumn, where the occurrences of

\roman{cvcolumnscounter}


should become

\romannumeral\c@cvcolumnscounter

3. \collectionadd (in moderncvcollection.sty), where the occurrences of

\roman{collection@#2@count}


should become

\romannumeral\csname c@collection@#2@count\endcsname


A similar problem that shows when \moderncvstyle{banking} is used can be solved by adding

\renewcommand*{\maketitlesymbol}{%


The style uses ~~~ instead of \quad and, due to how the Spanish module of babel treats ~, using this in the title breaks the compilation. I believe that \quad or \hspace{...} should be used anyway: leave sequences of spaces to word processors, LaTeX can do better. ;-)

• Thank you @egreg. That worked just fine. I ended up using \usepackage[spanish,es-lcroman,activeacute]{babel}. I mix in the activeacute so I get properly accented words when I input something like alimentaci'on. I have an English keyboard with which I type a lot of Spanish. Oct 22, 2013 at 21:33
• @refp16 Will you make a bug report? I've listed the necessary changes to be made to moderncv.cls and moderncvcollection.sty. With TeX Live 2012 you don't have regexpatch, I believe; but I tested the changes and they work. Oct 22, 2013 at 21:42
• I filed the bug report at bugs.launchpad.net/moderncv/+bug/1243455 . Thanks. Oct 22, 2013 at 23:14
• If \moderncvstyle{classic} is changed to \moderncvstyle{banking}, for example, both solutions (one with es-lcroman, the other with es-scroman) break with a similar error. Can someone suggest a fix for this? @egreg Oct 23, 2013 at 1:41
• @refp16 I added the workaround for banking Oct 23, 2013 at 7:09

The propossed solution is not complete. You will run into the same problem in other cv-scripts. Load spanish-babel as:

\usepackage[spanish,es-noquoting,es-noshorthands]{babel}


or

\usepackage[spanish,es-noquoting,es-noshorthands,activeacute]{babel}


in case you write María as Mar'ia. The short-hands interfere with moderncv.