[Tex/LaTex] Modern CV – change position of title and name

header-footermoderncv

I have the following problem. I need to change the position of name and title in my cv, because I'm using the title field for my academic title and that needs to stand in front of the name. So I would like to change the lines in my header, title first and name in the second line. Unfortunately I haven't been able to do this myself. Does anybody know a solution?

Thx!!

MWE:

\documentclass[12pt,a4paper]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{black}
\nopagenumbers{}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[top=2.5cm, bottom=2cm, left=2.5cm, right=2.5cm]{geometry}

\title{Dr.med.univ.}
\firstname{john}
\familyname{doe}
\address{xxroad 123}{5555 city}
\phone[mobile]{+43~1234~123123123}
\email{johndoe@gmail.com}

\begin{document}
    \makecvtitle

    \section{Berufserfahrung}

\end{document}

Best Answer

You could use etoolbox \patchcmd like this:

\patchcmd{\makecvhead}
{%
\namestyle{\@firstname\ \@lastname}%
\ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
}
{%
\titlestyle{\@title}\\[1.25em]
\namestyle{\@firstname\ \@lastname} 
}
{}{}

Will basically switch \titlestyle and \namestyle

complete MWE:

\documentclass[12pt,a4paper]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{black}
\nopagenumbers{}


\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[top=2.5cm, bottom=2cm, left=2.5cm, right=2.5cm]{geometry}


\title{Dr. med. univ.}
\firstname{john}
\familyname{doe}
\address{xxroad 123}{5555 city}
\phone[mobile]{+43~1234~123123123}
\email{johndoe@gmail.com}

\makeatletter
\patchcmd{\makecvhead}{%
\namestyle{\@firstname\ \@lastname}%
\ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
}
{
\titlestyle{\@title}\\[1.25em]
\namestyle{\@firstname\ \@lastname} 
}
{}{}
\makeatother

\begin{document}
    \makecvtitle

    \section{Berufserfahrung}

\end{document}

enter image description here

as for an hackish alternative, you could simply empty the \title macro and insert your title into the \firstname macro, like this

\title{}
\firstname{{\huge\textit{Dr. med. univ.}}\\[12pt] john}

and the set the styling of the "fake" title at will.