[Tex/LaTex] Change header layout in moderncv

moderncvtitles

I am creating a CV with the moderncv classic style. My header looks so far like this:

enter image description here:

I would like to achieve that

  1. the name and title are not aligned at the lower, but at the upper end of the box.
  2. the name is "overlapping" with the address box, because I have to make the name smaller at the moment to avoid a line break.

I guess that I have to change moderncvstyleclassic.sty. Unfortunately I'm not that familiar with the syntax so I cannot figure out what to change.

Here is my code:

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

\moderncvstyle{classic}            
\moderncvcolor{grey}         
\renewcommand*{\namefont}{\fontsize{25}{36}\mdseries\upshape}
\usepackage[ansinew]{inputenc}
\usepackage[scale=0.75]{geometry}

% personal data
\firstname{Dr. Marcus}
\familyname{Surname}
\title{Biochemist}           
\address{Street abc}{D-80331 Munich}  
\mobile{+49 xxx / xx xx xx xx}               
\email{marcus.surname@dummy.com}         

\photo[90pt][0.4pt]{dummy}                      
\begin{document}
\makecvtitle
\end{document}

Many thanks!

Best Answer

You can modify \makecvtitle (however unwieldy):

enter image description here

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

\moderncvstyle{classic}            
\moderncvcolor{grey}         
\renewcommand*{\namefont}{\fontsize{25}{36}\mdseries\upshape}
\usepackage[scale=0.75]{geometry}

\makeatletter
\renewcommand*{\makecvtitle}{%
  % recompute lengths (in case we are switching from letter to resume, or vice versa)
  \recomputecvlengths%
  % optional detailed information (pre-rendering)
  \def\phonesdetails{}%
  \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
    \protected@edef\phonesdetails{\phonesdetails\protect\makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
  \def\socialsdetails{}%
  \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
    \protected@edef\socialsdetails{\socialsdetails\protect\makenewline\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
  % optional photo (pre-rendering)
  \newbox{\makecvtitlepicturebox}%
  \savebox{\makecvtitlepicturebox}{%
    \ifthenelse{\isundefined{\@photo}}%
    {}%
    {%
      \hspace*{\separatorcolumnwidth}%
      \color{color1}%
      \setlength{\fboxrule}{\@photoframewidth}%
      \ifdim\@photoframewidth=0pt%
        \setlength{\fboxsep}{0pt}\fi%
      \framebox{\includegraphics[width=\@photowidth]{\@photo}}}}%
  \newbox{\makecvtitledetailsbox}%
  \savebox{\makecvtitledetailsbox}{%
    \addressfont\color{color2}%
    \begin{tabular}[b]{@{}r@{}}%
      \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
        \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
        \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
      \phonesdetails% needs to be pre-rendered as loops and tabulars seem to conflict
      \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
      \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
      \socialsdetails% needs to be pre-rendered as loops and tabulars seem to conflict
      \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}%
    \end{tabular}
  }%
  % name and title
  \newlength{\makecvtitledetailswidth}\settowidth{\makecvtitledetailswidth}{\usebox{\makecvtitledetailsbox}}%
  \newlength{\makecvtitlepicturewidth}\settowidth{\makecvtitlepicturewidth}{\usebox{\makecvtitlepicturebox}}%
  \ifthenelse{\lengthtest{\makecvtitlenamewidth=0pt}}% check for dummy value (equivalent to \ifdim\makecvtitlenamewidth=0pt)
    {\setlength{\makecvtitlenamewidth}{\textwidth-\makecvtitledetailswidth-\makecvtitlepicturewidth}}%
    {}%
  \begin{minipage}[b][\ht\makecvtitlepicturebox][t]{\makecvtitlenamewidth}%
    \namestyle{\@firstname\ \@lastname}%
    \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
  \end{minipage}%
  \hfill%
  % optional detailed information (rendering)
  \llap{\usebox{\makecvtitledetailsbox}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvtitlenamewidth is forced
  % optional photo (rendering)
  \usebox{\makecvtitlepicturebox}\\[2.5em]%
  % optional quote
  \ifthenelse{\isundefined{\@quote}}%
    {}%
    {{\centering\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[2.5em]}}%
  \par}% to avoid weird spacing bug at the first section if no blank line is left after \makecvtitle
\makeatother

% personal data
\firstname{Dr. Marcus}
\familyname{\rlap{Surname that is long}}
\title{Biochemist}
\address{Street abc}{D-80331 Munich}  
\mobile{+49 xxx / xx xx xx xx}               
\email{marcus.surname@dummy.com}         

\photo[90pt][0.4pt]{example-image-golden-upright}                      
\begin{document}
\makecvtitle
\end{document}

It's all about adjusting the boxes that make up the header. It's easiest to still supply your \familyname with an additional \rlap. The adjustment for the name uses some detail about minipage - specifically specifying a fixed height.