9

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}
\address{city}{state}{country}
\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{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\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.

13

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}}
 {}{}
\regexpatchcmd*{\collectionadd}
 {\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}
\address{city}{state}{country}
\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{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\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}{%
    {\quad{\rmfamily\textbullet}\quad}}

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. – Roberto Ferrer Oct 22 '13 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. – egreg Oct 22 '13 at 21:42
  • I filed the bug report at bugs.launchpad.net/moderncv/+bug/1243455 . Thanks. – Roberto Ferrer Oct 22 '13 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 – Roberto Ferrer Oct 23 '13 at 1:41
  • @refp16 I added the workaround for banking – egreg Oct 23 '13 at 7:09

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.