[Tex/LaTex] moderncv – modify size of blank spaces

moderncvspacing

I'm trying to find a way to modify the moderncv LaTeX "library" (dk if library is the right word).
As shown on the picture below, I want the space 1 & 2 to be reduced by half.

I'm new in LaTeX, it's awesome btw, sorry if this is a stupid question.

enter image description here

Best Answer

The answer depends on the style used. Assuming the casual style, you can redefine \makecvtitle in the following way (modified lines are signaled with % NEW; feel free to change the lengths used according to your needs):

\documentclass{moderncv}
\moderncvstyle{casual}
\moderncvcolor{blue}

\firstname{John}
\familyname{Doe}
\photo{ctanlion}

\makeatletter
\renewcommand*{\makecvtitle}{%
  \recomputecvlengths%
  \vspace*{-3em} % NEW
  \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}}}}}%
  \usebox{\makecvtitlepicturebox}%
  % name
  \@initializelength{\makecvtitlepicturewidth}%
  \settowidth{\makecvtitlepicturewidth}{\usebox{\makecvtitlepicturebox}}%
  \parbox[b]{\textwidth-\makecvtitlepicturewidth}{%
    \raggedleft\namefont{\color{color2!50}\@firstname} {\color{color2}\@familyname}}\\[-.35em]% alternate design: \MakeLowercase and no space
  {\color{color2!50}\rule{\textwidth}{.25ex}}%
  % optional title
  \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\null\hfill\titlestyle{\@title}}\\[0em]% NEW original 2.5em
  \ifthenelse{\isundefined{\@quote}}%
    {}%
    {{\null\hfill\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\hfill\null\\[2.5em]}}%
  \par}% to avoid weird spacing bug at the first section if no blank line is left after \maketitle
\makeatother
\begin{document}

\makecvtitle
\section{Test Section}

\end{document}