这个问题与另一个问题相关这里几年前。当时的目标是在使用 制作的经典简历中,将联系方式设置在姓名下方moderncv
。
我只是尝试复制代码:
\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}
但是,我收到了几个以 开头的错误!Undefined control sequenec error
。一旦我注释掉 renewcommand 函数,错误就消失了。
以下是文件中的一段代码,log
但它对我没有太大帮助:
! 未定义的控制序列。\makecvtitlenamewidth =0pt l.66 \makecvtitle 错误消息顶行末尾的控制序列从未被 \def 过。如果您拼错了它(例如,
\hobx'), type
I')和正确的拼写(例如,`I\hbox')。否则继续,我会忘记未定义的内容。! 缺少数字,视为零。= l.66 \makecvtitle 这里应该有一个数字;我
0'. (If you can't figure out why I needed to see a number, look up
在 The TeXbook 索引中插入了“奇怪的错误”。)! 非法测量单位(插入 pt)。= l.66 \makecvtitle 尺寸的单位可以是 em、ex、in、pt、pc、cm、mm、dd、cc、nd、nc、bp 或 sp;但您的单位是新的!我假设您指的是 pt,表示打印点。要从此错误中顺利恢复,最好删除错误的单位;例如,键入“2”以删除两个字母。(请参阅 TeXbook 的第 27 章。)
! 未定义的控制序列。\makecvtitlenamewidth l.66 \makecvtitle 错误消息顶行末尾的控制序列从未被 \def 过。如果您拼错了它(例如,
\hobx'), type
I')和正确的拼写(例如,`I\hbox')。否则请继续,我会忘记未定义的内容。! 缺少数字,视为零。\let l.66 \makecvtitle 这里应该有一个数字;我
0'. (If you can't figure out why I needed to see a number, look up
在 The TeXbook 索引中插入了“奇怪的错误”。)! 非法计量单位(插入 pt)。 \let l.66 \makecvtitle
您能帮我使该示例可编译吗?
答案1
在早期版本中,使用的变量在当前版本(版本 2.0.0)中\makecvtitlenamewidth
已被重命名为。\makecvheadnamewidth
moderncv
因此,您必须在代码中更改变量名称。请参阅以下 MWE(更改标有<==============
):
\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}
结果: