在问题中Moderncv 将出生日期添加到个人信息中,给出了一个解决方案,可以生成一个字段,供人们输入生日,并使其出现在简历标题小页面标题中。按照已接受答案中描述的步骤操作后,我无法让它为我工作。这是 MWE:
%% start of modified file `template.tex'.
%% Copyright 2006-2015 Xavier Danaux ([email protected]).
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c,
% available at http://www.latex-project.org/lppl/.
\documentclass[11pt,a4paper,sans]{moderncv}
\usepackage{duckuments}
% source: https://tex.stackexchange.com/questions/267604
\makeatletter
\newcommand*{\dateofbirth}[1]{\def\@dateofbirth{#1}}
\newcommand*{\dateofbirthfont}{}
\newcommand*{\dateofbirthstyle}[1]{{\dateofbirthfont#1}}
\renewcommand*{\makecvhead}{%
\recomputecvlengths%
\@initializebox{\makecvheaddetailsbox}%
\if@details%
\def\phonesdetails{}%
\collectionloop{phones}{%
\protected@edef\phonesdetails{\phonesdetails\protect\makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
\def\socialsdetails{}%
\collectionloop{socials}{%
\protected@edef\socialsdetails{\socialsdetails\protect\makenewline\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
\savebox{\makecvheaddetailsbox}{%
\addressfont\color{color2}%
\if@left\begin{tabular}[b]{@{}r@{}}\fi%
\if@right\begin{tabular}[b]{@{}l@{}}\fi%
\ifthenelse{\isundefined{\@dateofbirth}}{}{\makenewline\@dateofbirth}%
\ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
\ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}%
\ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
\phonesdetails%
\ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
\ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
\socialsdetails%
\ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}%
\end{tabular}
}\fi%
\@initializebox{\makecvheadpicturebox}%
\savebox{\makecvheadpicturebox}{%
\ifthenelse{\isundefined{\@photo}}%
{}%
{%
\if@left%
\hspace*{\separatorcolumnwidth}\fi%
\color{color1}%
\setlength{\fboxrule}{\@photoframewidth}%
\ifdim\@photoframewidth=0pt%
\setlength{\fboxsep}{0pt}\fi%
\framebox{\includegraphics[width=\@photowidth]{\@photo}}}%
\if@right%
\hspace*{\separatorcolumnwidth}\fi}%
% name and title (pre-rendering)
\@initializelength{\makecvheaddetailswidth}\settowidth{\makecvheaddetailswidth}{\usebox{\makecvheaddetailsbox}}%
\@initializelength{\makecvheadpicturewidth}\settowidth{\makecvheadpicturewidth}{\usebox{\makecvheadpicturebox}}%
\ifthenelse{\lengthtest{\makecvheadnamewidth=0pt}}%
{\setlength{\makecvheadnamewidth}{\textwidth-\makecvheaddetailswidth-\makecvheadpicturewidth}}%
{}%
\@initializebox{\makecvheadnamebox}%
\savebox{\makecvheadnamebox}{%
\begin{minipage}[b]{\makecvheadnamewidth}%
\if@left\raggedright\fi%
\if@right\raggedleft\fi%
\namestyle{\@firstname\ \@lastname}%
\ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
\end{minipage}}%
% rendering
\if@left%
\usebox{\makecvheadnamebox}%
\hfill%
\llap{\usebox{\makecvheaddetailsbox}}%
\usebox{\makecvheadpicturebox}\fi%
\if@right%
\usebox{\makecvheadpicturebox}%
\rlap{\usebox{\makecvheaddetailsbox}}%
\hfill%
\usebox{\makecvheadnamebox}\fi%
\\[2.5em]%
% optional quote
\ifthenelse{\isundefined{\@quote}}%
{}%
{{\centering\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[2.5em]}}%
\par}%
\makeatother
\moderncvstyle{classic}
\moderncvcolor{burgundy}
\usepackage[scale=0.82,bottom=20mm]{geometry}
\setlength{\hintscolumnwidth}{35mm}
\name{Megenn}{Marggel}
\title{Da Duchess Life is da best}
\address{Deal 24}{2007 Nodeal}{}
\phone[mobile]{+55~(555)~555~55~55}
\email{[email protected]}
\homepage{www.mema.com}
\social[linkedin]{mema}
\social[github]{mema}
\extrainfo{I like fruit}
\dateofbirth{4 August 1981}
\photo[64pt][0.4pt]{picture}
\quote{noli simul flare sobereque}
\begin{document}
\makecvtitle
\end{document}
答案1
这里的问题是不同命令的顺序:首先,定义包含出生日期字段的自定义标题。紧接着,设置 moderncv 样式和配色方案:
\makeatletter
% Definition of custom header
\makeatother
\moderncvstyle{classic}
\moderncvcolor{burgundy}
该命令\moderncvstyle{classic}
重新定义标题以匹配 moderncv 的“经典”样式。因此,您的自定义定义将被经典样式覆盖,并且不会打印出生日期。
解决方法是交换这两个块的位置,即
\moderncvstyle{classic}
\moderncvcolor{burgundy}
\makeatletter
% Definition of custom header
\makeatother
这样,首先将标题定义为 moderncv 的“经典”标题,然后才重新定义它以包含出生日期。