5

Moderncv has a line of empty space between address and phone/email, like this: figure

MWE:

\documentclass[12pt]{moderncv}
\moderncvstyle{banking}
\name{Sherlock}{Holmes}
\address{221B Baker Street}{London}{U.K.} % Your current address
\phone[mobile] {+44~(0)71234 00000}    % Your mobile phone number
\email{superdetective@mail.com} 
\begin{document}
\makecvtitle
\end{document}

How do I remove/decrease that space by shifting the phone and email line up?

8

For the current version of moderncv you can use the following "hack". But please keep an eye on the version number moderncv.cls 2015/07/28 v2.0.0 modern curriculum vitae and letter document class. If the version changes it could be that this code can't work longer ...

In line 21 of the following MWE (marked with <===============) you see the code:

\flushmakeheaddetails\@firstmakeheaddetailselementtrue\par\vspace{-\baselineskip}\null}

In the original file moderncvheadiii.sty in line 91 you will find:

\flushmakeheaddetails\@firstmakeheaddetailselementtrue\\\null}

The changing of \\ to \par\vspace{-\baselineskip} gives the result you want.

BTW: I would not do this, the cv looks better with the space, I think.

Complete code:

% http://tex.stackexchange.com/questions/277361/moderncv-banking-style-default-space-between-address-and-phone
\listfiles
\documentclass[12pt]{moderncv}
\moderncvstyle{banking}

\makeatletter
\renewcommand{\makehead}{%\@initializecommand
  \setlength{\makeheaddetailswidth}{0.8\textwidth}%
  \hfil%
  \parbox{\makeheaddetailswidth}{%
    \centering%
    % name and title
    \namestyle{\@firstname~\@lastname}%
    \ifthenelse{\equal{\@title}{}}{}{\titlestyle{~|~\@title}}\\% \isundefined doesn't work on \@title, as LaTeX itself defines \@title (before it possibly gets redefined by \title) 
    % optional detailed information
    \if@details{%
      \addressfont\color{color2}%
      \ifthenelse{\isundefined{\@addressstreet}}{}{\addtomakeheaddetails{\addresssymbol\@addressstreet}%
        \ifthenelse{\equal{\@addresscity}{}}{}{\addtomakeheaddetails[~--~]{\@addresscity}}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
        \ifthenelse{\equal{\@addresscountry}{}}{}{\addtomakeheaddetails[~--~]{\@addresscountry}}%
        \flushmakeheaddetails\@firstmakeheaddetailselementtrue\par\vspace{-\baselineskip}\null}% <========================
      \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
        \addtomakeheaddetails{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
      \ifthenelse{\isundefined{\@email}}{}{\addtomakeheaddetails{\emailsymbol\emaillink{\@email}}}%
      \ifthenelse{\isundefined{\@homepage}}{}{\addtomakeheaddetails{\homepagesymbol\httplink{\@homepage}}}%
      \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
        \addtomakeheaddetails{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
      \ifthenelse{\isundefined{\@extrainfo}}{}{\addtomakeheaddetails{\@extrainfo}}%
    \flushmakeheaddetails}\fi}\\[2.5em]}
\makeatother


\name{Sherlock}{Holmes}
\address{221B Baker Street}{London}{U.K.} % Your current address
\phone[mobile] {+44~(0)71234 00000}    % Your mobile phone number
\email{superdetective@mail.com} 
\begin{document}
\makecvtitle
\end{document}

Result:

changed header without blank line

A second way is to use command patchcmd of package etoolbox to change the line showed above.

The code for \patchcmd is (\makeatletter and \makeatother are needed because @ is used in the searched line):

\makeatletter
\patchcmd{\makehead}{%search
  \flushmakeheaddetails\@firstmakeheaddetailselementtrue\\\null}{%replace
  \flushmakeheaddetails\@firstmakeheaddetailselementtrue\par\vspace{-\baselineskip}\null}{%success
  }{%failure
  }
\makeatother

Then you have the complete MWE:

\documentclass[12pt]{moderncv}
\moderncvstyle{banking}
%\usepackage{etoolbox} % already loaded by moderncv!

\makeatletter
\patchcmd{\makehead}{%search
  \flushmakeheaddetails\@firstmakeheaddetailselementtrue\\\null}{%replace
  \flushmakeheaddetails\@firstmakeheaddetailselementtrue\par\vspace{-\baselineskip}\null}{%success
  }{%failure
  }
\makeatother


\name{Sherlock}{Holmes}
\address{221B Baker Street}{London}{U.K.} % Your current address
\phone[mobile] {+44~(0)71234 00000}    % Your mobile phone number
\email{superdetective@mail.com} 
\begin{document}
\makecvtitle
\end{document}

with the same result. Thanks to @Werner for his comment.

  • 2
    It seems more convenient to do \usepackage{etoolbox} \patchcmd{\makehead}{\\\null}{\par\vspace{-\baselineskip}\null}{}{} (I've added the \vspace. – Werner Nov 9 '15 at 7:01

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.