10

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.

0

2 Answers 2

3

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.

11
  • Thanks a billion. This works greatly. (Sorry that I can't vote up your answer; because I don't have enough reputation power.)
    – Omid1989
    Oct 1, 2013 at 9:41
  • But just one question: what does [b] & [t] in \patchcmd... command mean !? (I'm newbie to LaTeX)
    – Omid1989
    Oct 1, 2013 at 9:42
  • 1
    The first \patchcmd searches the first argument \makecvtitle for the pattern {minipage}[b] and replaces it with {minipage}[t]. The [b] and [t] are optional arguments to the minipage environment specifying the vertical placement. Oct 1, 2013 at 9:47
  • Thanks a lot for your fast answer. Does [b] & [t] set the alignments to bottom & middle respectively !?
    – Omid1989
    Oct 1, 2013 at 10:00
  • 1
    [b] is align to bottom row, [t] is align top row, empty centers. Beware that the alignment is to the baselines of the rows, and that the name is printed with letters that stretch way above the standard baseline. Oct 1, 2013 at 10:17
7

It might be a bit hacky, a bit lame, pretty manual and you will even get a warning. Nevertheless, I will add this answer anyway, because it is really easy and often sufficient (at least for myself). You can move the name+title part with a \vspace:

\name{John}{Doe}
\title{Curriculum Vitae\vspace*{20pt}}

The name+title part will then just move upward.

Before: before, normal

After: after, with vspace

2
  • This works great for the layout but makes *20pt appear in the resulting PDF's title. To work around this, set the PDF's title like this: \AtBeginDocument{\hypersetup{pdftitle = {My CV}}} Mar 3, 2016 at 9:45
  • @MatthiasBraun I do not have that problem myself and I do not know why you do, but great that you have found a way around it that helps! Mar 4, 2016 at 11:26

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.