我的代码使用了旧的 2011 版 moderncv。相同的代码无法使用最新版本 (texlive 2015) 进行编译。我找不到新的 API 来替换我的旧代码。
失败(未找到命令)
\renewcommand*{\firstnamefont}{\fontsize{28}{40}\sffamily\mdseries\upshape}
\renewcommand*{\familynamefont}{\firstnamefont}
\renewcommand*{\firstnamestyle}[1]{{\firstnamefont\color{firstnamecolor}#1}}
\renewcommand*{\familynamestyle}[1]{{\familynamefont\color{familynamecolor}#1}}
我发现:\namefont
而且\namestyle
,那又如何\familynamestyle
?
为了
\color{firstnamecolor}
\color{sectionrectanglecolor}
我找不到替代者。
答案1
这些宏已更改。现在查看示例文件moderncvheadi.sty
。在第 40-49 行中,你会发现:
\renewcommand*{\namefont}{\fontsize{34}{36}\mdseries\upshape}
\renewcommand*{\titlefont}{\LARGE\mdseries\slshape}
\renewcommand*{\addressfont}{\small\mdseries\slshape}
\renewcommand*{\quotefont}{\large\slshape}
% styles
\renewcommand*{\namestyle}[1]{{\namefont\textcolor{color0}{#1}}}
\renewcommand*{\titlestyle}[1]{{\titlefont\textcolor{color2}{#1}}}
\renewcommand*{\addressstyle}[1]{{\addressfont\textcolor{color2}{#1}}}
\renewcommand*{\quotestyle}[1]{{\quotefont\textcolor{color1}{#1}}}
颜色:
% colors
%-------
\definecolor{color0}{rgb}{0,0,0}% main default color, normally left to black
\definecolor{color1}{rgb}{0,0,0}% primary scheme color
\definecolor{color2}{rgb}{0,0,0}% secondary scheme color
\definecolor{color3}{rgb}{0,0,0}% tertiary scheme color
或更多moderncvcolor?.sty
哪个文件包含与您相关的定义取决于您使用的风格。
您搜索的两个宏
\color{firstnamecolor}
\color{sectionrectanglecolor}
不再存在。
但您可以使用自己的代码来获得相同的结果。
而是\color{firstnamecolor}
使用\name{\textcolor{red}{John}}{Doe}
例如红色来获取名字。
相反,\color{sectionrectanglecolor}
您可以重新定义命令\section
以使用红色而不是标准颜色color1
:
\makeatletter
\RenewDocumentCommand{\section}{sm}{%
\par\addvspace{2.5ex}%
\phantomsection{}% reset the anchor for hyperrefs
\addcontentsline{toc}{section}{#2}%
\cvitem[0ex]{\strut\raggedleft\raisebox{\baseletterheight}{\color{red}\rule{\hintscolumnwidth}{0.95ex}}}{\strut\sectionstyle{#2}}% <== new color red
% ^^^^^^^^^^^
%\cvitem[0ex]{\strut\raggedleft\raisebox{\baseletterheight}{\color{color1}\rule{\hintscolumnwidth}{0.95ex}}}{\strut\sectionstyle{#2}}% <============== original line
\par\nobreak\addvspace{1ex}\@afterheading}% to avoid a pagebreak after the heading
\makeatother
使用以下完整的 MWE
\documentclass[11pt,a4paper,sans]{moderncv}
% moderncv themes
\moderncvstyle{casual}
\moderncvcolor{blue}
\nopagenumbers{}
\usepackage[utf8]{inputenc}
\usepackage[scale=0.75]{geometry}
%\setlength{\hintscolumnwidth}{3cm}
%\setlength{\makecvtitlenamewidth}{10cm}
\setlength{\footskip}{70pt}
% personal data
\name{\textcolor{red}{John}}{Doe} % <===================================
%\color{firstnamecolor} --> \name{\textcolor{red}{John}}{Doe}
%\color{sectionrectanglecolor}
%%\renewcommand*{\sectionstyle}[1]{{\sectionfont\textcolor{color1}{#1}}}
\makeatletter
\RenewDocumentCommand{\section}{sm}{%
\par\addvspace{2.5ex}%
\phantomsection{}% reset the anchor for hyperrefs
\addcontentsline{toc}{section}{#2}%
\cvitem[0ex]{\strut\raggedleft\raisebox{\baseletterheight}{\color{red}\rule{\hintscolumnwidth}{0.95ex}}}{\strut\sectionstyle{#2}}% <== new color red
%\cvitem[0ex]{\strut\raggedleft\raisebox{\baseletterheight}{\color{color1}\rule{\hintscolumnwidth}{0.95ex}}}{\strut\sectionstyle{#2}}% <============== original line
\par\nobreak\addvspace{1ex}\@afterheading}% to avoid a pagebreak after the heading
\makeatother
\title{Resumé title}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{[email protected]}
\homepage{www.johndoe.com}
\social[linkedin]{john.doe}
\social[twitter]{jdoe}
\social[github]{jdoe}
\extrainfo{additional information}
\photo[64pt][0.4pt]{example-image-a}
\quote{Some quote}
% to show numerical labels in the bibliography (default is to show no labels)
\makeatletter\renewcommand*{\bibliographyitemlabel}{\@biblabel{\arabic{enumiv}}}\makeatother
\begin{document}
\makecvtitle
\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description} % arguments 3 to 6 can be left empty
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\section{Master thesis}
\cvitem{title}{\emph{Title}}
\cvitem{supervisors}{Supervisors}
\cvitem{description}{Short thesis abstract}
\section{Experience}
\subsection{Vocational}
\cventry{year--year}{Job title}{Employer}{City}{}{General description no longer than 1--2 lines.\newline{}%
Detailed achievements:%
\begin{itemize}%
\item Achievement 1;
\item Achievement 2, with sub-achievements:
\begin{itemize}%
\item Sub-achievement (a);
\item Sub-achievement (b), with sub-sub-achievements (don't do this!);
\begin{itemize}
\item Sub-sub-achievement i;
\item Sub-sub-achievement ii;
\item Sub-sub-achievement iii;
\end{itemize}
\item Sub-achievement (c);
\end{itemize}
\item Achievement 3.
\end{itemize}}
\cventry{year--year}{Job title}{Employer}{City}{}{Description line 1\newline{}Description line 2}
\subsection{Miscellaneous}
\cventry{year--year}{Job title}{Employer}{City}{}{Description}
\section{Languages}
\cvitemwithcomment{Language 1}{Skill level}{Comment}
\cvitemwithcomment{Language 2}{Skill level}{Comment}
\cvitemwithcomment{Language 3}{Skill level}{Comment}
\section{Computer skills}
\cvdoubleitem{category 1}{XXX, YYY, ZZZ}{category 4}{XXX, YYY, ZZZ}
\cvdoubleitem{category 2}{XXX, YYY, ZZZ}{category 5}{XXX, YYY, ZZZ}
\cvdoubleitem{category 3}{XXX, YYY, ZZZ}{category 6}{XXX, YYY, ZZZ}
\section{Interests}
\cvitem{hobby 1}{Description}
\cvitem{hobby 2}{Description}
\cvitem{hobby 3}{Description}
%=======================================================================
% moderncv sets the \cventry as an unbreakable block - a tabular - to achieve the display alignment. Also, the seventh argument #7 of \cventry - your itemized list - is set inside a minipage which also doesn't allow for breaking across the page boundary.
%
%You can manually format separate items to allow for page breaking by setting them inside an empty \cvitem{}:
\cvitem{}{
\begin{itemize}
\item Worked on camera calibration and homography for the mapping of
objects onto a common coordinate system for object fusion and
analysis in world coordinates
\end{itemize}
}
%In order to allow for this to happen naturally would require a complete rewrite of that part (which is substantial).
% ======================================================================
\section{Extra 1}
\cvlistitem{Item 1}
\cvlistitem{Item 2}
\cvlistitem{Item 3. This item is particularly long and therefore normally spans over several lines. Did you notice the indentation when the line wraps?}
\section{Extra 2}
\cvlistdoubleitem{Item 1}{Item 4}
\cvlistdoubleitem{Item 2}{Item 5}%\cite{book1}}
\cvlistdoubleitem{Item 3}{Item 6. Like item 3 in the single column list before, this item is particularly long to wrap over several lines.}
\section{References}
\begin{cvcolumns}
\cvcolumn{Category 1}{\begin{itemize}\item Person 1\item Person 2\item Person 3\end{itemize}}
\cvcolumn{Category 2}{Amongst others:\begin{itemize}\item Person 1, and\item Person 2\end{itemize}(more upon request)}
\cvcolumn[0.5]{All the rest \& some more}{\textit{That} person, and \textbf{those} also (all available upon request).}
\end{cvcolumns}
\clearpage % to get bibliography to next page
\nocite{*}
\bibliographystyle{plain}
\bibliography{publications}
\end{document}
您将获得以下结果:
编辑:
要添加和使用消失的旧命令和颜色,您需要将以下代码添加到您的 cv 前言中:
\makeatletter
% Define vanished commands and colors:
\newcommand*{\firstnamefont}{\fontsize{28}{40}\sffamily\mdseries\upshape}
\newcommand*{\familynamefont}{\firstnamefont}
\newcommand*{\firstnamestyle}[1]{{\firstnamefont\color{firstnamecolor}#1}}
\newcommand*{\familynamestyle}[1]{{\familynamefont\color{familynamecolor}#1}}
\definecolor{firstnamecolor}{rgb}{255,0,0}% firstname color
\definecolor{familynamecolor}{rgb}{0,0,255}% familyname color
\definecolor{sectionrectanglecolor}{rgb}{0,255,0}% section rectangle color
%add old styling possibilities to current class
\patchcmd{\makecvhead}%
{%search
{\color{color2!50}\@firstname} {\color{color2}\@lastname}%
}%
{%replace
\firstnamestyle{\@firstname} \familynamestyle{\@lastname}%% <===================
}%
{}%success
{error}%failure
%New color for section rectangle
\RenewDocumentCommand{\section}{sm}{%
\par\addvspace{2.5ex}%
\phantomsection{}% reset the anchor for hyperrefs
\addcontentsline{toc}{section}{#2}%
\cvitem[0ex]{\strut\raggedleft\raisebox{\baseletterheight}{\color{sectionrectanglecolor}\rule{\hintscolumnwidth}{0.95ex}}}{\strut\sectionstyle{#2}}% <== new color sectionrectanglecolor
\par\nobreak\addvspace{1ex}\@afterheading}% to avoid a pagebreak after the heading
\makeatother
它定义了所需的颜色(请根据您的需要将我的示例颜色更改为红色、蓝色和绿色)、消失的命令和修补类以便能够使用新的信息。
拥有完整的 MWE
\documentclass[11pt,a4paper,sans]{moderncv}
% moderncv themes
\moderncvstyle{casual}
\moderncvcolor{blue}
\nopagenumbers{}
\usepackage[utf8]{inputenc}
\usepackage[scale=0.75]{geometry}
\makeatletter
% Define vanished commands and colors:
\newcommand*{\firstnamefont}{\fontsize{28}{40}\sffamily\mdseries\upshape}
\newcommand*{\familynamefont}{\firstnamefont}
\newcommand*{\firstnamestyle}[1]{{\firstnamefont\color{firstnamecolor}#1}}
\newcommand*{\familynamestyle}[1]{{\familynamefont\color{familynamecolor}#1}}
\definecolor{firstnamecolor}{rgb}{255,0,0}% firstname color
\definecolor{familynamecolor}{rgb}{0,0,255}% familyname color
\definecolor{sectionrectanglecolor}{rgb}{0,255,0}% section rectangle color
%add old styling possibilities to current class
\patchcmd{\makecvhead}%
{%search
{\color{color2!50}\@firstname} {\color{color2}\@lastname}%
}%
{%replace
\firstnamestyle{\@firstname} \familynamestyle{\@lastname}%% <===================
}%
{}%success
{error}%failure
%New color for section rectangle
\RenewDocumentCommand{\section}{sm}{%
\par\addvspace{2.5ex}%
\phantomsection{}% reset the anchor for hyperrefs
\addcontentsline{toc}{section}{#2}%
\cvitem[0ex]{\strut\raggedleft\raisebox{\baseletterheight}{\color{sectionrectanglecolor}\rule{\hintscolumnwidth}{0.95ex}}}{\strut\sectionstyle{#2}}% <== new color sectionrectanglecolor
\par\nobreak\addvspace{1ex}\@afterheading}% to avoid a pagebreak after the heading
\makeatother
% personal data
\name{John}{Doe}
\title{Resumé title}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{[email protected]}
\homepage{www.johndoe.com}
\social[linkedin]{john.doe}
\social[twitter]{jdoe}
\social[github]{jdoe}
\extrainfo{additional information}
\photo[64pt][0.4pt]{example-image-a} % -10x16
\quote{Some quote}
\setlength{\footskip}{70pt} % depends on number of infos in footer, comment and check log file
\begin{document}
\makecvtitle
\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description} % arguments 3 to 6 can be left empty
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\section{Master thesis}
\cvitem{title}{\emph{Title}}
\cvitem{supervisors}{Supervisors}
\cvitem{description}{Short thesis abstract}
\section{Experience}
\subsection{Vocational}
\cventry{year--year}{Job title}{Employer}{City}{}{General description no longer than 1--2 lines.\newline{}%
Detailed achievements:%
\begin{itemize}%
\item Achievement 1;
\item Achievement 2, with sub-achievements:
\begin{itemize}%
\item Sub-achievement (a);
\item Sub-achievement (b), with sub-sub-achievements (don't do this!);
\begin{itemize}
\item Sub-sub-achievement i;
\item Sub-sub-achievement ii;
\item Sub-sub-achievement iii;
\end{itemize}
\item Sub-achievement (c);
\end{itemize}
\item Achievement 3.
\end{itemize}}
\cventry{year--year}{Job title}{Employer}{City}{}{Description line 1\newline{}Description line 2}
\end{document}
你得到了想要的结果: