[Tex/LaTex] Customizing ModernCV Header: Photo below line, aligned right

header-footermoderncvtitles

I'm a newbie in LaTeX and like to customize the moderncv layout.

Based on the solution of Moderncv casual header – photo right, name and title on the left, I tried to position the photo below the line instead of above.

But I am getting some errors

How can I achieve this?

Best Answer

One option, building on the answer you linked to:

\documentclass[11pt,a4paper]{moderncv}
\moderncvstyle{casual}
\moderncvcolor{blue}

\firstname{John}
\familyname{Doe}
\title{Optional title}
\address{street and number}{postcode city}
\mobile{+1~(234)~567~890}
\phone{+2~(345)~678~901}
\fax{+3~(456)~789~012}
\email{john@doe.org}
\homepage{www.johndoe.com}
\extrainfo{additional information}
\photo[64pt][0.4pt]{picture}
\quote{Some quote}

\makeatletter
%\AtBeginDocument
%{
% reverse the name and photo
\renewcommand*{\makecvtitle}{%
  \recomputecvlengths%
  \makecvfooter%
  % define optional picture
  \newbox{\makecvtitlepicturebox}%
  \savebox{\makecvtitlepicturebox}{%
    \ifthenelse{\isundefined{\@photo}}%
      {
        \@initializelength{\makecvtitlepicturewidth}% Damit Länge bekannt bei Name
        \settowidth{\makecvtitlepicturewidth}{0pt}%
      }%
      {%
       \setlength\fboxrule{\@photoframewidth}%
       \ifdim\@photoframewidth=0pt%
         \setlength{\fboxsep}{0pt}\fi%
       {\color{color1}\framebox{\includegraphics[width=\@photowidth]{\@photo}}}}
        \@initializelength{\makecvtitlepicturewidth}% Damit Länge bekannt bei Name
        \settowidth{\makecvtitlepicturewidth}{\usebox{\makecvtitlepicturebox}}%
      }%
  % end define optional picture

  % name
%    \parbox[b]{\textwidth-\makecvtitlepicturewidth}{%
 {   \raggedright\namefont{\color{color2!50}\@firstname} {\color{color2}\@familyname}}%\lastname -> error
    %
%    \parbox[b]{\textwidth-\makecvtitlepicturewidth}{%
%   \raggedleft\namefont{\color{color2!50}\@firstname} {\color{color2}\@lastname}}%\familyname
\\[-.35em]%
  {\color{color2!50}\rule{\textwidth}{.25ex}}\par\medskip%
\hfill\usebox{\makecvtitlepicturebox}
  % optional title
  \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\null\hfill\titlestyle{\@title}}\\[2.5em]% 
  % optional quote
  \ifthenelse{\isundefined{\@quote}}%
    {}%
    {{\null\hfill\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\hfill\null\\[2.5em]}}%
  \par}% 
%}% AtBeginDocument ende
\makeatother


\begin{document}
\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{ \textit{Grade} }{Description}  % arguments 3 to 6 can be left empty
\cvitem{title}{ \emph{Title} }
\cvitemwithcomment{Language 1}{Skill level}{Comment}
\cvdoubleitem{category X}{XXX, YYY, ZZZ}{category Y}{XXX, YYY, ZZZ}
\cvlistitem{Item 1}
\cvlistdoubleitem{Item 2}{Item 3}
\end{document}

enter image description here