Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to have 3 lines for address with moderncv style. So I've added this lines in my file

\makeatletter
\renewcommand*{\address}[3]{\def\@addressstreet{#1}\def\@addresscity{#2}\def\@addresscountry{#3}}
\makeatother

\address{Street }{town}{Country}

but nothing has changed. Can anybody tell me how can I do?

share|improve this question

2 Answers 2

The latest version of moderncv actually takes 3 arguments for the address. But your question would still apply if you needed a fourth line.

As Ilya says, the \address command only does storing of the components of the address in some variables for later use. He suggests writing something like

\address{Street}{Town\\Country}

but that does not work, producing the error

! Argument of \@firstoftwo has an extra }.

The way moderncvstyleclassic prints the address involves a series of tests on its arguments with \ifthenelse. The error above occurs because, including \\ in the string confuses this test.

The package etoolbox provides more robust commands to do similar tests, in particular it has an \ifstrempty command that will not breakdown on a string containing \\.

One can patch the title making command of moderncvstyleclassic so that the third argument of \address is allowed to contain \\ as follows:

\usepackage{etoolbox}

\makeatletter
\patchcmd{\makecvtitle}{\ifthenelse{\equal{\@addresscountry}{}}}%
{\ifstrempty{\@addresscountry}}{}{}
\makeatother

Here is a small document showing thi working:

Sample output

\documentclass{moderncv}

\moderncvstyle{classic}

\usepackage{etoolbox}

\makeatletter
\patchcmd{\makecvtitle}{\ifthenelse{\equal{\@addresscountry}{}}}%
{\ifstrempty{\@addresscountry}}{}{}
\makeatother

\name{John}{Doe}

\address{street and number}{postcode city}{county\\ country}

\begin{document}

\makecvtitle

\end{document}
share|improve this answer

The easiest solution is to simply use multi-line arguments, i.e. \address{Street}{Town\\Country}.

Your definition doesn't work, because \address only stores the information. The actual printing is done by the \maketitle command, which is redefined in the corresponding .sty file, i.e. moderncvthemeclassic.sty.

share|improve this answer
    
Sorry but this doesn't work. I get this error message "!Argument of \@firstoftow has an extra" –  user22432 Dec 2 '12 at 19:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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