[Tex/LaTex] Customizing ModernCV Header: Photo below line, “Title aligned left”

moderncv

I would like to change like the moderncv casual theme:

  1. There is too much space below the picture, or above "Persönliches"… The picture should be directly on the right of the first block.
  2. I would like to have "Lebenslauf" on the left or in the middle of the line… but not on the right…

I tried a bit to change the header but it was not completly successful. And I also think there is lot in my header, which is not really needed.

Can someone give me a hint?

Thank you

enter image description here

\documentclass[a4paper,11pt]{moderncv}
\usepackage[scale=0.75,tmargin=2.0cm,right=2.8cm,left=2.5cm,bmargin=2.7cm]{geometry}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{paralist}
\usepackage{lmodern}

\moderncvtheme[red]{casual}
\nopagenumbers{}

\usepackage[scale=0.75]{geometry}       
\renewcommand*{\titlefont}{\LARGE\mdseries\upshape}
\makeatletter
\renewcommand*{\makecvtitle}{
\recomputecvlengths
\makecvfooter%

\newbox{\makecvtitlepicturebox}
\savebox{\makecvtitlepicturebox}{
\ifthenelse{\isundefined{\@photo}}
{}
{%
\setlength\fboxrule{\@photoframewidth}%
\ifdim\@photoframewidth=0pt%
\setlength{\fboxsep}{0pt}\fi%
{\color{color1}\framebox{\includegraphics[width=\@photowidth]{\@photo}}}}}
\hfill%\usebox{\makecvtitlepicturebox}%

\@initializelength{\makecvtitlepicturewidth}
\settowidth{\makecvtitlepicturewidth}{\usebox{\makecvtitlepicturebox}}%
\parbox[b]{\textwidth-\makecvtitlepicturewidth}{
\raggedleft\namefont{\color{color2!50}\textsf{\@firstname}} {
\color{color2}\textsf{\@familyname}}}\\        [-.35em] 
{\color{color2!50}\rule{\textwidth}{.25ex}}%

\ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\null\titlestyle{\@title}}
\hfill\smash{\raisebox{\dimexpr-\ht\makecvtitlepicturebox+\baselineskip \relax}{
\usebox{\makecvtitlepicturebox}}}\\[0.5em]  
\ifthenelse{\isundefined{\@quote}}%
{}
{{\null\hfill\begin{minipage}   {\quotewidth}\centering \quotestyle{\@quote}\end{minipage}\hfill\null\\[2.5em]}}
\par}%
\makeatother

\setlength{\hintscolumnwidth}{3.5cm}    
\name{}{Lebenslauf}
\photo[110pt][0.0pt]{picture.jpg}
\title{~}

\begin{document}
\maketitle

\section{Persönliches}
\cvitem{Name}{-------------}
\cvitem{Adresse}{--------------------------}
\cvitem{Handy}{0176 / 0000 0000}

\cvitem{E-Mail}{mail@mail.by}

\cvitem{Geburtsdatum}{40. Dezember 1900}
\cvitem{Geburtsort}{Berlin}
\cvitem{Nationalität}{Deutsch}

\section{Promotion}
\end{document}

Best Answer

You asked two things:

  1. There is too much space below the picture, or above "Persönliches"... The picture should be directly on the right of the first block.
  2. I would like to have "Lebenslauf" on the left or in the middle of the line... but not on the right...

To get what you want in this case an easy way is to set the photo with package textpos in this way:

\usepackage[absolute,overlay]{textpos} 
...
%  in cm:           (length from right, length from above)
\begin{textblock}{0}(8.5,2.6) % <=======================================
  \includegraphics[width=110pt]{example-image-a}\par
\end{textblock}

Please change the given width width=110pt and the position (8.5,2.6), given in cm, where the image has to be placed for your own needs. It depends at last of the used image and where you want it to be ...

Because you did not tell us if yu are using the letter (then you perhaps need the usage of given variables of moderncv) I changed your header code that you can now use:

\name{Max}{Musterfrau}
%\photo[110pt][0.0pt]{example-image-a} % <============================!!
\title{Lebenslauf} % <==================================================

You see I commented the definition of \photo, in your case it is not needed.

Because your wish complete destroys the layout of style casual we can now short the code to only generate the wanted title (see font changing please!) and the rule (there were a lot of new lines in your old code resulting in the huge distance between title and first section of cv):

\renewcommand*{\titlefont}{\fontsize{34}{36}\mdseries\upshape} % <======

\makeatletter
\renewcommand*{\makecvtitle}{%
  \recomputecvlengths
  %\makecvfooter%

  \newbox{\makecvtitlepicturebox}
  \savebox{\makecvtitlepicturebox}{}
  \@initializelength{\makecvtitlepicturewidth}
  \settowidth{\makecvtitlepicturewidth}{\usebox{\makecvtitlepicturebox}}%
  \parbox[b]{\textwidth-\makecvtitlepicturewidth}{%
    \raggedright\titlestyle{\@title}\\[-.35em] 
    {\color{color2!50}\rule{\textwidth}{.25ex}}%
    \\[2ex]% <==================== change to your needs: space title-cv
  }%
}
%  \par}}%
\makeatother

You can change the distance between title/rule and first section of your cv (Persönliches) with changing the code \\[2ex] to a number, what you need, for example \\[2cm].

The complete MWE

\documentclass[a4paper,11pt]{moderncv} % version 2.0.0

\usepackage[scale=0.75]{geometry}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

% \moderncvtheme[red]{casual} % <=========================== old version 
\moderncvstyle{casual}  % <=============================================
\moderncvcolor{red}
\nopagenumbers{}

\renewcommand*{\titlefont}{\fontsize{34}{36}\mdseries\upshape} % <======

\makeatletter
\renewcommand*{\makecvtitle}{%
  \recomputecvlengths
  %\makecvfooter%

  \newbox{\makecvtitlepicturebox}
  \savebox{\makecvtitlepicturebox}{}
  \@initializelength{\makecvtitlepicturewidth}
  \settowidth{\makecvtitlepicturewidth}{\usebox{\makecvtitlepicturebox}}%
  \parbox[b]{\textwidth-\makecvtitlepicturewidth}{%
    \raggedright\titlestyle{\@title}\\[-.35em] 
    {\color{color2!50}\rule{\textwidth}{.25ex}}%
    \\[2ex]% <==================== change to your needs: space title-cv
  }%
}
%  \par}}%
\makeatother


\setlength{\hintscolumnwidth}{3.5cm}    
\name{Max}{Musterfrau}
%\photo[110pt][0.0pt]{example-image-a} % <============================!!
\title{Lebenslauf} % <==================================================

\usepackage[absolute,overlay]{textpos} % <==============================


\begin{document}

\makecvtitle

%  in cm:           (length from right, length from above)
\begin{textblock}{0}(8.5,2.6) % <=======================================
  \includegraphics[width=110pt]{example-image-a}\par
\end{textblock}

\section{Persönliches}
\cvitem{Name}{-------------}
\cvitem{Adresse}{--------------------------}
\cvitem{Handy}{0176 / 0000 0000}

\cvitem{E-Mail}{mail@mail.by}

\cvitem{Geburtsdatum}{40. Dezember 1900}
\cvitem{Geburtsort}{Berlin}
\cvitem{Nationalität}{Deutsch}

\section{Promotion}
\end{document}

gives the the wished result:

result of mwe above