[Tex/LaTex] How to set different alignment for Name/Title in ModernCV

moderncvvertical alignment

I'm trying to write my CV using ModernCV template.

As you see in the picture below, the Name/Title section at the left-top of the first page in this template is bottom-aligned to the personal information at the right-top of the first page.

Bottom-Alignment

I was just wondering how is that possible to change the alignment of Name/Title to be top-aligned, or even better middle-aligned with the personal information section!?

Your great help is truly appreciated.
Thank you.

Best Answer

The name etc. are placed in a \begin{minipage}[b]...\end{minipage} and the information on the right is in a \begin{tabular}[b]..\end{tabular}. You can remove or change the alignment arguments [b] with the patching commands from etoolbox. The following will give vertical centering, which was your preferred option. Updated for newer versions of moderncv:

Sample ouptut

\documentclass{moderncv}

\moderncvstyle{classic}

\name{John}{Doe}
\address{Street St., 167}{8888 Town}{Country}
\phone{+1~(234)~567~890}
\homepage{xxx.ddd.cc.ee}

\usepackage{etoolbox}
\patchcmd{\makecvhead}{{minipage}[b]}{{minipage}[c]}{}{}
\patchcmd{\makecvhead}{{tabular}[b]}{{tabular}[c]}{}{}

\begin{document}
\makecvtitle

\end{document}

Use [t] arguments aligns at the top, but this with respect to baselines of the first line of each box, so is often not what you expect.

Working a bit harder we get top alignment as follows:

Sample output

\documentclass{moderncv}

\moderncvstyle{classic}

\name{John}{Doe}
\address{Street St., 167}{8888 Town}{Country}
\phone{+1~(234)~567~890}
\homepage{xxx.ddd.cc.ee}

\usepackage{etoolbox}

\patchcmd{\makecvhead}{{minipage}[b]}{{minipage}[t]}{}{}

\newsavebox{\mytempbox}
\newlength{\mytitleoffset}
\savebox{\mytempbox}{\addressfont S}
\setlength{\mytitleoffset}{\ht\mytempbox}

\patchcmd{\makecvhead}{\raggedleft\fi}{\raggedleft\fi\vspace{-\mytitleoffset}}{}{}
\patchcmd{\makecvhead}{{tabular}[b]}{{tabular}[t]}{}{}


\begin{document}
\makecvtitle

\end{document}

Note that we have measured the height of the largest character S in the first line of the address. With other material in that block you would have find something appropriate to measure.