[Tex/LaTex] LaTeX moderncv classic: Change the width of the title

horizontal alignmentmoderncvspacing

I'm looking to change the width of the \title environment in the moderncv template.

As it is now, the maximum width of the title under my name goes all the way to the "address"/information box on the right.

Best Answer

The "header" (or title) under the classic moderncv style is comprised of three components: name, details, picture

enter image description here

Each are set in a box, but the width of the name box is calculated to fit exactly within the remaining text block if no other width is specified. So, unfortunately, there's no easy way to specify the gap between these boxes. Some options exist though:

  1. Insert some phantom space to the left of the widest entry in the details box;
  2. The following patch (with the aid of etoolbox) of \makecvtitle allows you to specify a length \namedetailsgap. Add this to your moderncv preamble:

    \usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
    \patchcmd{\makecvtitle}% <cmd>
      {\textwidth}% <search>
      {\textwidth-\namedetailsgap}% <replace>
      {}{}% <success><failure>
    \newlength{\namedetailsgap}\setlength{\namedetailsgap}{50pt}% Specify gap
    

    For example, the above patch changes this:

    enter image description here

    into this:

    enter image description here

    (For better line-spacing of multi-line titles, use \title{<title>\endgraf}.)

  3. Set the \title using \parbox[b]{\linewidth-<len>}{<title>} where you specify the length <len>. For example, output similar to the above is obtained via

    \title{\parbox[b]{\linewidth-50pt}{<title>}}
    

    (No need for \endgraf or \par here, since \parbox does this automatically.)

  4. Manually fiddle around with the length \makecvtitlenamewidth. As stated in the example template.tex,

    ...for the classic style, if you want to force the width allocated to your name and avoid line breaks. Be careful though, the length is normally calculated to avoid any overlap with your personal info; use this at your own typographical risks...

    The default is 0pt, which implies an automatic calculation of the required width to fit within the remainder of \textwidth after the details and picture boxes have been set.