2

I am using the moderncv class (http://www.ctan.org/pkg/moderncv) to write my CV. In order to modify the address section, I modified moderncvstyleclassic.sty.

I want to get the text of the address section left-justified (which worked), but now I have the problem that the first line of the address (addressstreet) is indented.

My question is: How do I prevent this indentation of the first line within this information box

So far I did not find any solutions for this problem.

Code in moderncvstyleclassic.sty with my change commented:

%% code above omitted
      % optional detailed information box
      \newbox{\makecvtitledetailsbox}%
      \savebox{\makecvtitledetailsbox}{%
        \addressfont\color{color2}%
        \begin{tabular}[b]{@{}l@{}}%% MY MODIFICATION <<-- l for left-justified (instead of "r")
          \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\@addressstreet%\addresssymbol##
            \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}}% if \addresstreet is defined, \addresscity will always be defined but could be empty
            \ifthenelse{\isundefined{\@countryinfo}}{}{\makenewline\@countryinfo}%%##moved up to use as country
          \ifthenelse{\isundefined{\@mobile}}{}{\makenewline\mobilesymbol\@mobile}%
          \ifthenelse{\isundefined{\@phone}}{}{\makenewline\phonesymbol\@phone}%
          \ifthenelse{\isundefined{\@fax}}{}{\makenewline\faxsymbol\@fax}%
          \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
          \ifthenelse{\isundefined{\@homepage}}{}{%
        \ifthenelse{\equal{\@homepagetitle}{}}% \homepagetitle could be empty
        {\makenewline\homepagesymbol\httplink{\@homepage}}%
        {\makenewline\homepagesymbol\httplink[\@homepagetitle]{\@homepage}}}% 
          \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}%##moved up to use as country
        \end{tabular}
      }% 
      %% code below omitted
4

Using the \patchcmd macro:

\makeatletter
\patchcmd{\makecvtitle}{@{}r@{}}{@{}l@{}}{}{}
\patchcmd{\makecvtitle}{\makenewline\addresssymbol\@addressstreet}{\addresssymbol\@addressstreet\makenewline}{}{}
\makeatother

after the style declaration.

Before:

enter image description here

After:

enter image description here

Or if you want to manually edit the .sty file (discouraged) just change from:

\makenewline\addresssymbol\@addressstreet

to:

\addresssymbol\@addressstreet\makenewline

For also putting the extrainfo below city use the following set of commands instead of the previous:

\makeatletter
\patchcmd{\makecvtitle}{@{}r@{}}{@{}l@{}}{}{}
\patchcmd{\makecvtitle}{\makenewline\addresssymbol\@addressstreet}{\addresssymbol\@addressstreet\makenewline}{}{}
\patchcmd{\makecvtitle}{\makenewline\@extrainfo}{}{}{}
\patchcmd{\makecvtitle}{\ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}{\ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}\makenewline\@extrainfo}{}{}
\makeatother

result:

enter image description here

the country field is optional, if you set the address like this:

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

you'll have a country. Otherwise, like this:

\address{street and number}{postcode city}

you'll have no country (as in my last picture).

Complete MWE

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

\makeatletter
\patchcmd{\makecvtitle}{@{}r@{}}{@{}l@{}}{}{}
\patchcmd{\makecvtitle}{\makenewline\addresssymbol\@addressstreet}{\addresssymbol\@addressstreet\makenewline}{}{}
\patchcmd{\makecvtitle}{\makenewline\@extrainfo}{}{}{}
\patchcmd{\makecvtitle}{\ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}{\ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}\makenewline\@extrainfo}{}{}
\makeatother

\moderncvcolor{blue}
\usepackage[scale=0.75]{geometry}

% personal data
\name{John}{Doe}
\title{Resumé title}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}                   
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{john@doe.org}                               
\homepage{www.johndoe.com}                         
\social[linkedin]{john.doe}                        
\social[twitter]{jdoe}                             
\social[github]{jdoe}                              
\extrainfo{additional information}                 
\photo[64pt][0.4pt]{picture}                       
\quote{Some quote}                                 

\begin{document}
\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\end{document}
  • First solution works! Related Question: How do I alter the position of the "additional information" line without altering the .sty file? – HTS Sep 24 '14 at 8:19
  • @HTS where do you want to put it? – Nico Boni Sep 24 '14 at 8:21
  • below city. I want to use it as an information for "country". My version of moderncv ( Version 1.11 (19/6/14)) seems to miss the "country" option in the \address{Street}{City} command. Using \address{Street}{City}{Country} throws an error. Editing the .sty file is an option which I would like to avoid. – HTS Sep 24 '14 at 8:31
  • @HTS see the edit. – Nico Boni Sep 24 '14 at 8:51
  • the proposed newest solutions for "country" or the "additional information" did not work for me. Using \address{Street}{City}{Country} throws an error and the "additional information" does not show up. In your first code example "additional information" can be seen. – HTS Sep 24 '14 at 9:15

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.