align names, data and picture in CV

I would like that the picture and the name, personal information and picture appear at the same height, instead of the picture above like here:

\documentclass{moderncv}
\usepackage{etoolbox}

\moderncvstyle{classic}
\moderncvcolor{green}

\patchcmd{\makecvtitle}{[b]}{[t]}{}{}% For tabular
\patchcmd{\makecvtitle}{[b]}{[t]}{}{}% For minipage

\setlength{\makecvtitlenamewidth}{12cm}
\renewcommand*{\namefont}{\fontsize{24}{29}\mdseries\upshape}

\firstname{Manuel}
\familyname{Fern\'andez-P\'erez}
\title{CV}
\mobile{+1~(234)~567~890}
\phone{+2~(345)~678~901}
\fax{+3~(456)~789~012}
\email{manuel@fernandez-perez-galdos.com}
\homepage{www.johndoe.com}
\photo[64pt]{picture}
\begin{document}

\makecvtitle
\section{Education}

\end{document}

-
This question clarifies the previous question tex.stackexchange.com/questions/80428/… and leads here to a better result. – strpeter Oct 8 '13 at 14:04

Well, it's a bit tricky due to how \maketitle is composed. You don't know it, but TeX is doing exactly what you are asking him to do: aligning the different elements at their top. But the trick is that LaTeX aligns on their top baseline, not their utmost top border. If you look carefully, you can see that the baseline of your title (the first line of a minipage that contains your name and your title) and the first line of a tabular) are perfectly aligned (the red line was added to show the alignment):

Why LaTeX sometimes take the first or the last line of a box as its reference point is another topic :)

\patchcmd{\makecvtitle}{[b]}{[t]}{}{}


your name, title, personal information and picture will all be aligned (to the bottom baseline).

Now if you want these aligned bottom to the baseline of your name, keep the line. You now know from my first paragraph that the items are actually aligned and that the only thing you need to do, is to shift that personal information box a few "lines" to the top.
Start by getting the height and depth of the information box:

\the\ht\makecvtitledetailsbox
\the\dp\makecvtitledetailsbox


which is equal to 84pt in your example (it is equal to 6 x 14pt, the interline spacing of \addressfont, as one could expect given \addressfont is typeset in \normalsize). Then use a trick to shift the box:

\address{\vspace{-84pt}\makenewline{}street and number}{postcode city}


and now everything is perfectly aligned to the bottom (note that I only kept one of your \patchcmd{\makecvtitle}{[b]}{[t]}{}{} lines):

If you want to align the elements to the top of their boxes (causing unaligned baselines), I have only found an ugly solution: redefine \makecvtitle to enable you to shift the information and picture vertically, and adjust the shift to get what you desire.

How much should you shift? Well, you can probably calculate a theoretical shift comparing the height of the boxes, but as the upper most line of the boxes are not of the same black density (different glyph extenders vs a colored line with white space), you should also take into account optical effects...

You could also be lazzy and notive by trial an error that 17pt is probably good enough :)

\makeatletter
\renewcommand*{\makecvtitle}{%
% recompute lengths (in case we are switching from letter to resume, or vice versa)
\recomputecvlengths%
% optional detailed information box
\newbox{\makecvtitledetailsbox}%
\savebox{\makecvtitledetailsbox}{%
\begin{tabular}[t]{@{}r@{}}%
\ifthenelse{\isundefined{\@mobile}}{}{\makenewline\mobilesymbol\@mobile}%
\ifthenelse{\isundefined{\@phone}}{}{\makenewline\phonesymbol\@phone}%
\ifthenelse{\isundefined{\@fax}}{}{\makenewline\faxsymbol\@fax}%
\ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}%
\end{tabular}
}%
% 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}}}}%
% 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}[t]{\makecvtitlenamewidth}%
\namestyle{\@firstname\ \@familyname}%
\ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
\end{minipage}%
\hfill%
% detailed information
\llap{%
\begin{minipage}[t]{\makecvtitledetailswidth}%
\vspace*{-17pt}%
\usebox{\makecvtitledetailsbox}%
\end{minipage}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvtitlenamewidth is forced
% optional photo (rendering)
\begin{minipage}[t]{\makecvtitlepicturewidth}%
\vspace*{-17pt}%
\vbox to 0pt{%
\usebox{\makecvtitlepicturebox}%
}%
\end{minipage}\\[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


and enjoy the result:

-
Thanks. What should I do to align the top corner of the name with street and number" ? – inquisitor Nov 10 '12 at 20:07
@inquisitor That's rather tricky, as everything TeX / typography works relative to a baseline. Aligning "corners" and misaligning baselines will give your readers a headache in my opinion. But If that's what you want, I've edited my answer above. – Xavier Nov 11 '12 at 6:01