# How can I add a new address line within moderncv style

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?

-

## 2 Answers

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:

\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}
-

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.

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