2

This question relates to another one asked here a few years ago. The goal back then was to set the contact details below the name in a classic cv made with moderncv.

I simply tried to copy the code:

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

\makeatletter
\renewcommand*{\makecvtitle}{%
  % recompute lengths (in case we are switching from letter to resume, or vice versa)
  \recomputecvlengths%
  % optional detailed information box
  \newbox{\makecvtitledetailsbox}%
  \savebox{\makecvtitledetailsbox}{%
    \addressfont\color{color2}%
    \begin{tabular}[b]{@{}p{10cm}@{}}%
      \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet %
        \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}} % if \addresstreet is defined, \addresscity will always be defined but could be empty
      \ifthenelse{\isundefined{\@mobile}}{}{\makenewline\mobilesymbol\@mobile} %
      \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
    \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-\makecvtitlepicturewidth
}}%
    {}%
 % \begin{minipage}[b]{\makecvtitlenamewidth}%
    \raggedright\namestyle{\@firstname\ \@familyname}\par\medskip%
    \ifthenelse{\equal{\@title}{}}{}{{\centering\titlestyle{\@title}\par}\medskip}%
  %\hfill%
  % detailed information
%  \llap{
%
\usebox{\makecvtitledetailsbox}%
%\end{minipage}\ignorespaces%
%}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvtitlenamewidth is forced
  % optional photo (rendering)
  \usebox{\makecvtitlepicturebox}\\[2.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

\usepackage[scale=0.75]{geometry}
% personal data
\name{John}{Doe}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\email{[email protected]}
\photo[64pt][0.4pt]{C:/Users/wwa594/Documents/Downloads/pictures/picture}
\begin{document}
\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}

\end{document} 

However, I receive a couple of errors starting with a !Undefined control sequenec error. The errors are gone once I comment out the renewcommand function.

Here is a snippet from the log file which does not help me a lot:

! Undefined control sequence. \makecvtitlenamewidth =0pt l.66 \makecvtitle The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., \hobx'), typeI' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined.

! Missing number, treated as zero. = l.66 \makecvtitle A number should have been here; I inserted 0'. (If you can't figure out why I needed to see a number, look upweird error' in the index to The TeXbook.)

! Illegal unit of measure (pt inserted). = l.66 \makecvtitle Dimensions can be in units of em, ex, in, pt, pc, cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one! I'll assume that you meant to say pt, for printer's points. To recover gracefully from this error, it's best to delete the erroneous units; e.g., type `2' to delete two letters. (See Chapter 27 of The TeXbook.)

! Undefined control sequence. \makecvtitlenamewidth l.66 \makecvtitle The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., \hobx'), typeI' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined.

! Missing number, treated as zero. \let l.66 \makecvtitle A number should have been here; I inserted 0'. (If you can't figure out why I needed to see a number, look upweird error' in the index to The TeXbook.)

! Illegal unit of measure (pt inserted). \let l.66 \makecvtitle

Could you help me please to make this example compilable?

7
  • 1
    Moderncv got an update renaming many commands. You can try if it works with the (still old) version on latextemplates. But i think an update would be better.
    – Johannes_B
    Jul 20, 2016 at 10:09
  • So I uninstalled the package using the MikTex package manager, reinstalled the package and refreshed the FNDB. Unfortunately, the problem remains. Does the example work for you under an updated version? Jul 20, 2016 at 10:40
  • I haven't tried, but a solution that works for the old version of moderncv, and not for the new version of moderncv, will most likely not work if you reinstall the new version of moderncv. An update of the solution would be better. Or use the old version of moderncv, for which the old solution (most likely) works.
    – Johannes_B
    Jul 20, 2016 at 10:47
  • Okay, but this is exactly the question: How would an update of the solution look like? I do not have enough experience to find one myself. Jul 20, 2016 at 10:50
  • 1
    Part of the complaint seems to be that \makecvtitlenamewidth is not defined, adding in \newlength{\makecvtitlenamewidth} at the start makes your code compile for me.
    – Dai Bowen
    Jul 20, 2016 at 18:43

1 Answer 1

5

In an earlier version used variable \makecvtitlenamewidth has been renamed to \makecvheadnamewidth in the current version of moderncv, version 2.0.0.

So you have to change the variable name in your code. See the following MWE (changes marked with <==============):

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

% Variable \makecvtitlenamewidth is renamed to \makecvheadnamewidth
\makeatletter
\renewcommand*{\makecvtitle}{%
  % recompute lengths (in case we are switching from letter to resume, or vice versa)
  \recomputecvlengths%
  % optional detailed information box
  \newbox{\makecvtitledetailsbox}%
  \savebox{\makecvtitledetailsbox}{%
    \addressfont\color{color2}%
    \begin{tabular}[b]{@{}p{10cm}@{}}%
      \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet %
        \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}} % if \addresstreet is defined, \addresscity will always be defined but could be empty
      \ifthenelse{\isundefined{\@mobile}}{}{\makenewline\mobilesymbol\@mobile} %
      \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
    \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{\makecvheadnamewidth=0pt}}% check for dummy value (equivalent to \ifdim\makecvtitlenamewidth=0pt) % <=========================
    {\setlength{\makecvheadnamewidth}{\textwidth-\makecvtitlepicturewidth % <====================
}}%
    {}%
 % \begin{minipage}[b]{\makecvtitlenamewidth}%
    \raggedright\namestyle{\@firstname\ \@familyname}\par\medskip%
    \ifthenelse{\equal{\@title}{}}{}{{\centering\titlestyle{\@title}\par}\medskip}%
  %\hfill%
  % detailed information
%  \llap{
%
\usebox{\makecvtitledetailsbox}%
%\end{minipage}\ignorespaces%
%}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvtitlenamewidth is forced
  % optional photo (rendering)
  \usebox{\makecvtitlepicturebox}\\[2.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

\usepackage[scale=0.75]{geometry}
% personal data
\name{John}{Doe}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\email{[email protected]}
\photo[64pt][0.4pt]{example-image-A}
\begin{document}
\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}

\end{document} 

and the result:

enter image description here

1
  • Thanks, this works like a charm. I am curious, how could I have found about the change of the command names? How did you know? Jul 21, 2016 at 6:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .