1

For my resume I'm using the great moderncv, but I'd like to customize it a little.

For example I'd like to reduce the heigth of the blank space after the title.

In moderncvstyleclassic.sty, I could change line 143 from

\usebox{\makecvtitlepicturebox}\\[2.5em]%

to

\usebox{\makecvtitlepicturebox}\\[0.5em]%

which does the job. How can I achive the same result without editing the .sty located on /usr/local/texlive...?

1

Line 143, the \usebox{\makecvtitlepicturebox}\\[2.5em]% command, is part of the \renewcommand*{}{} command that begins on line 93. The scope of this \renewcommand*{}{} extends all of the way until line 148.

So, you can copy and paste the entirety of this \renewcommand*{}{} into your preamble, only editing the part that is relevant for you. That is to say, place the following code in the preamble of your .tex file:

\makeatletter
\renewcommand*{\makecvtitle}{%
  % recompute lengths (in case we are switching from letter to resume, or vice versa)
  \recomputecvlengths%
  % optional detailed information (pre-rendering)
  \def\phonesdetails{}%
  \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
    \protected@edef\phonesdetails{\phonesdetails\protect\makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
  \def\socialsdetails{}%
  \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
    \protected@edef\socialsdetails{\socialsdetails\protect\makenewline\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
  \newbox{\makecvtitledetailsbox}%
  \savebox{\makecvtitledetailsbox}{%
    \addressfont\color{color2}%
    \begin{tabular}[b]{@{}r@{}}%
      \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
        \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
        \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
      \phonesdetails% needs to be pre-rendered as loops and tabulars seem to conflict
      \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
      \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
      \socialsdetails% needs to be pre-rendered as loops and tabulars seem to conflict
      \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}[b]{\makecvtitlenamewidth}%
    \namestyle{\@firstname\ \@lastname}%
    \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
  \end{minipage}%
  \hfill%
  % optional detailed information (rendering)
  \llap{\usebox{\makecvtitledetailsbox}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvtitlenamewidth is forced
  % optional photo (rendering)
  % -------------------------------------------------------------------
  % this part immediately below has been modified for your purposes
  % -------------------------------------------------------------------
  \usebox{\makecvtitlepicturebox}\\[0.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

Note that you need to wrap the contents of the \renewcommand*{}{} in \makeatletter . . . \makeatother.

Finally, you may want to see this answer for some discussion about modifying the content of .sty files, particularly in light of the LaTeX Project Public License (LPPL).

2

You can add two lines to your preamble to patch the \makecvtitle command.

\usepackage{xpatch}
\xpatchcmd{\makecvtitle}{\usebox{\makecvtitlepicturebox}\\[2.5em]}{\usebox{\makecvtitlepicturebox}\\[0.5em]}{}{}

(This is also possible using the etoolbox package but I prefer xpatch.)

You can use the last two parameters to set code snippets for Success and Failure of the patching (a warning for example).

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.