Moderncv 将出生日期添加到个人信息中

Moderncv 将出生日期添加到个人信息中

我正在使用 moderncv 包制作简历,使用的是经典风格。我想在地址上方直接添加出生日期行。有人知道怎么做吗?我尝试了各种解决方案,但似乎都不起作用。

答案1

要将出生日期放在地址上方,您必须调整 moderncv 创建的 CV 标题,方法是重新定义打印标题的命令。我建议创建一个新命令\dateofbirth,这样您仍然可以使用\extrainfo它来获取(嗯……)额外的信息。我尝试相当笼统地描述该过程,这样您也可以将其适应除经典风格之外的其他风格。

如果你看看moderncv 包的结构,您将找到加载的包(moderncv.cls),以及许多其他文件。在第 317 行,您将找到的命令定义\moderncvstyle

\newcommand*{\moderncvstyle}[2][]{
  \RequirePackage[#1]{moderncvstyle#2}}

这只是加载了一个名为的包moderncvstyle+ 你正在使用的样式的名称,classic在你的情况下是这样的。因此,我们将继续处理文件moderncvstyleclassic.sty。在那里,在第 45 行,标题定义为\moderncvhead[...]{1}。要找出它的含义,我们必须\moderncvhead在文件中找到 的定义,它位于第 321 行moderncv.cls

\newcommand*{\moderncvhead}[2][]{
  \expandafter\RequirePackage\expandafter[\expandafter#1\expandafter]{\expandafter moderncvhead\romannumeral #2}}

这也是一个\RequirePackage命令,它将第二个参数转换\moderncvhead为罗马数字。正如经典风格\moderncvhead使用参数 1 调用(或罗马数字:),这将加载包moderncvheadi.sty。现在,我们终于在那里(第 63-134 行)找到了创建标题的定义\makecvhead。现在的任务是调整此命令,使其在地址上方打印出生日期。

为了做到这一点,你应该将现有的定义复制到你的序言中并在那里进行更改。要添加出生日期,我们只需创建一个新命令

\newcommand*{\dateofbirth}[1]{\def\@dateofbirth{#1}}

如果存在则打印出生日期\@dateofbirth(已定义):

\ifthenelse{\isundefined{\@dateofbirth}}{}{\makenewline\@dateofbirth}%

将所有东西放在一起形成一个小的 MWE 产生

结果

\documentclass{moderncv}
\moderncvstyle{classic}

\makeatletter
\newcommand*{\dateofbirth}[1]{\def\@dateofbirth{#1}}
\renewcommand*{\makecvhead}{%
  % recompute lengths (in case we are switching from letter to resume, or vice versa)
  \recomputecvlengths%
  % optional detailed information (pre-rendering)
  \@initializebox{\makecvheaddetailsbox}%
  \if@details%
    \def\phonesdetails{}%
    \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
      \protected@edef\phonesdetails{\phonesdetails\protect\makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
    \def\socialsdetails{}%
    \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
      \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}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
          \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
        \phonesdetails% needs to be pre-rendered as loops and tabulars seem to conflict
        \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
        \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
        \socialsdetails% needs to be pre-rendered as loops and tabulars seem to conflict
        \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}%
      \end{tabular}
    }\fi%
  % optional photo (pre-rendering)
  \@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}}% check for dummy value (equivalent to \ifdim\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}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvheadnamewidth is forced
    \usebox{\makecvheadpicturebox}\fi%
  \if@right%
    \usebox{\makecvheadpicturebox}%
    \rlap{\usebox{\makecvheaddetailsbox}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvheadnamewidth is forced
    \hfill%
    \usebox{\makecvheadnamebox}\fi%
  \\[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 \makecvhead
\makeatother

\firstname{Peter}
\familyname{Muster}
\dateofbirth{* 01 January 1900}
\address{1 Infinite Loop}{Cupertino, CA 95014}

\begin{document}
    \makecvtitle
\end{document}

答案2

无需修复/修补模板即可获取出生日期的另一种方法是“创造性地”使用地址命令,如下所示:

\address{\mbox{\hspace*{-2cm}\textsuperscript{\textborn}01.~April~1900,~Berlin}\makenewline Somestreet 123}{12345 Somewhere}{InACountry}

这将在您的地址前添加您的出生日期和换行符。注意:如果您想在简历的其他部分(页脚、页眉、回信地址等)重复使用您的邮政地址,那么这是一个非常糟糕的主意。但如果您不想这样做,这是一个简单的解决方法。

答案3

您可以使用以下方式添加您的出生日期

\born{Your Date birth}

答案4

因为我花了很大力气将出生日期和家庭状况放入所有五种预先存在的风格(休闲、经典、银行、老式和花式)中,并让它们开箱即用,而不必过多地定义其他任何东西,所以我想在这里发布 MWE,以防其他人想在其他风格中使用这些变量,而不仅仅是经典风格:

我们(称其为最小可能有点不对...)只需要改变样式信息:

    \documentclass[12pt]{moderncv}

    % These commands have to come BEFORE you choose the style!
    \usepackage{xpatch}
    \makeatletter
    \providecommand{\@moderncvstyle}{}
    \providecommand{\@moderncvstyleoptions}{}
    \xapptocmd{\moderncvstyle}{%
        \renewcommand{\@moderncvstyleoptions}{#1}{}{}
        \renewcommand{\@moderncvstyle}{#2}{}{}
    }
    \makeatother

    % Choose one of the 5 styles here (casual, classic, banking, oldstyle or fancy):
    \moderncvstyle{fancy}


    \makeatletter
    % new commands to enter the birth of date and the family status:
    \newcommand*{\dateofbirth}[1]{\def\@dateofbirth{#1}}
    \newcommand*{\family}[1]{\def\@family{#1}}

    % 5 ifthenelse statements to test for the 5 styles and change the header accordingly:

    \ifthenelse{\equal{\@moderncvstyle}{casual}}{
        \renewcommand*{\makecvhead}{% TODO: use \@initializecommand,         which requires modifying its definition to handle \par
    % recompute lengths (in case we are switching from letter to resume, or vice versa)
    \recomputecvlengths%
    % optional picture (pre-rendering)
    \@initializebox{\makecvheadpicturebox}%
    \savebox{\makecvheadpicturebox}{%
        \ifthenelse{\isundefined{\@photo}}%
        {}%
        {%
            \setlength\fboxrule{\@photoframewidth}%
            \ifdim\@photoframewidth=0pt%
            \setlength{\fboxsep}{0pt}\fi%
            {\color{color1}\framebox{\includegraphics[width=\@photowidth]{\@photo}}}}}%
    % name (pre-rendering)
    \@initializelength{\makecvheadpicturewidth}%
    \settowidth{\makecvheadpicturewidth}{\usebox{\makecvheadpicturebox}}%
    \@initializebox{\makecvheadnamebox}%
    \savebox{\makecvheadnamebox}{%
        \parbox[b]{\textwidth-\makecvheadpicturewidth}{%
            \if@left\raggedright\fi%
            \if@right\raggedleft\fi%
            \namefont%
            \if@alternate% alternate design: first- and lastname in lowercase with no space in between (distinction is made by color difference)
            {\color{color2!50}\MakeLowercase\@firstname}{\color{color2}\MakeLowercase\@lastname}%
            \else% default design: first- and lastname as given with a space in between
            {\color{color2!50}\@firstname} {\color{color2}\@lastname}\fi}}%
    % rendering
    \if@left%
    \usebox{\makecvheadnamebox}%
    \usebox{\makecvheadpicturebox}\fi
    \if@right%
    \usebox{\makecvheadpicturebox}%
    \usebox{\makecvheadnamebox}\fi\\[-.35em]%
    {\color{color2!50}\rule{\textwidth}{.25ex}}%
    % optional detailed information
    \if@details{%
        \\\null%
        \addressfont\color{color2}%
        \ifthenelse{\isundefined{\@addressstreet}}{}{\addtomakeheaddetails{\addresssymbol\@addressstreet}%
            \ifthenelse{\equal{\@addresscity}{}}{}{\addtomakeheaddetails[~--~]{\@addresscity}}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
            \ifthenelse{\equal{\@addresscountry}{}}{}{\addtomakeheaddetails[~--~]{\@addresscountry}}%
            \flushmakeheaddetails\@firstmakeheaddetailselementtrue\\\null}%
        \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
            \addtomakeheaddetails{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
        \ifthenelse{\isundefined{\@email}}{}{\addtomakeheaddetails{\emailsymbol\emaillink{\@email}}}%
        \ifthenelse{\isundefined{\@homepage}}{}{\addtomakeheaddetails{\homepagesymbol\httplink{\@homepage}}}%
        \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
            \addtomakeheaddetails{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
        \ifthenelse{\isundefined{\@extrainfo}}{}{\addtomakeheaddetails{\@extrainfo}}%
        \flushmakeheaddetails}\fi% need to force a \par after this to avoid weird spacing bug at the first section if no blank line is left after \makehead
    % optional title
    \ifthenelse{\equal{\@title}{}}{}{%
        \\[1.25em]\null% \null is required as there is no box on the line after \\, so glue such as \hfill (and leaders) disappear; this is in contrast to after \par, where the next line starts with an indent box (even after \noindent)
        \if@right\hfill\fi%
        \if@alternate%
        \titlestyle{\MakeLowercase\@title}%
        \else%
        \titlestyle{\@title}\fi%
    }%
    % optional birthofdate and family:
    \ifthenelse{\not\isundefined{\@dateofbirth} \and \not\isundefined{\@family}}{
        {\null\hfill%
            \begin{flushright}
                \textsl{\@dateofbirth\\
                    \@family
                }
            \end{flushright}\hfill\null
    }}{}
    % optional no birthofdate and no family needs no ifthenelse
    % optional birthofdate but no family:
    \ifthenelse{\not\isundefined{\@dateofbirth} \and \isundefined{\@family}}{
        {\null\hfill%
            \begin{flushright}
                \textsl{\@dateofbirth}
            \end{flushright}\hfill\null
    }}{}
    % optional family but no birthofdate:
    \ifthenelse{\isundefined{\@dateofbirth} \and \not\isundefined{\@family}}{
        {\null\hfill%
            \begin{flushright}
                \textsl{\@family}
            \end{flushright}\hfill\null
    }}{}\\[2em]%
    % optional quote
    \ifthenelse{\isundefined{\@quote}}%
    {}%
    {{\null\hfill%
            \begin{minipage}{\quotewidth}%
                \centering%
                \quotestyle{\@quote}%
            \end{minipage}\hfill\null\\[2em]
        }
    }%
    \par}% to avoid weird spacing bug at the first section if no blank line is left after \maketitle
    }{}
    \ifthenelse{\equal{\@moderncvstyle}{classic}}{
        \renewcommand*{\makecvhead}{%
            % recompute lengths (in case we are switching from letter to resume, or vice versa)
    \recomputecvlengths%
    % optional detailed information (pre-rendering)
    \@initializebox{\makecvheaddetailsbox}%
    \if@details%
    \def\phonesdetails{}%
    \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
        \protected@edef\phonesdetails{\phonesdetails\protect\makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
    \def\socialsdetails{}%
    \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
        \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{\@family}}{}{\makenewline\@family}%
                \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
                    \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
                    \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
                \phonesdetails% needs to be pre-rendered as loops and tabulars seem to conflict
                \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
                \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
                \socialsdetails% needs to be pre-rendered as loops and tabulars seem to conflict
                \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}%
            \end{tabular}
        }\fi%
        % optional photo (pre-rendering)
        \@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}}% check for dummy value (equivalent to \ifdim\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}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvheadnamewidth is forced
        \usebox{\makecvheadpicturebox}\fi%
        \if@right%
        \usebox{\makecvheadpicturebox}%
        \rlap{\usebox{\makecvheaddetailsbox}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvheadnamewidth is forced
        \hfill%
        \usebox{\makecvheadnamebox}\fi%
        \\[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 \makecvhead
}{}
\ifthenelse{\equal{\@moderncvstyle}{banking}}{
    \@initializecommand{\makehead}{%
        \setlength{\makeheaddetailswidth}{0.8\textwidth}%
        \hfil%
        \parbox{\makeheaddetailswidth}{%
            \centering%
            % name and title
            \namestyle{\@firstname~\@lastname}%
            \ifthenelse{\equal{\@title}{}}{}{\titlestyle{~|~\@title}}\\% \isundefined doesn't work on \@title, as LaTeX itself defines \@title (before it possibly gets redefined by \title) 
            % optional birthofdate and family:
            \ifthenelse{\not\isundefined{\@dateofbirth} \and \not\isundefined{\@family}}{
                {\null\hfill%
                    \textsl{\@dateofbirth~~\textbullet~~\@family}\hfill\null\\[1.5em]
            }}{}
            % optional no birthofdate and no family needs no ifthenelse
            % optional birthofdate but no family:
            \ifthenelse{\not\isundefined{\@dateofbirth} \and \isundefined{\@family}}{
                {\null\hfill%
                    \textsl{\@dateofbirth}\hfill\null\\[1.5em]
            }}{}
            % optional family but no birthofdate:
            \ifthenelse{\isundefined{\@dateofbirth} \and \not\isundefined{\@family}}{
                {\null\hfill%
                    \textsl{\@family}\hfill\null\\[1.5em]
            }}{}
            % optional detailed information
            \if@details{%
                \addressfont\color{color2}%
                \ifthenelse{\isundefined{\@addressstreet}}{}{\addtomakeheaddetails{\addresssymbol\@addressstreet}%
                    \ifthenelse{\equal{\@addresscity}{}}{}{\addtomakeheaddetails[~--~]{\@addresscity}}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
                    \ifthenelse{\equal{\@addresscountry}{}}{}{\addtomakeheaddetails[~--~]{\@addresscountry}}%
                    \flushmakeheaddetails\@firstmakeheaddetailselementtrue\\\null}%
                \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
                    \addtomakeheaddetails{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
                \ifthenelse{\isundefined{\@email}}{}{\addtomakeheaddetails{\emailsymbol\emaillink{\@email}}}%
                \ifthenelse{\isundefined{\@homepage}}{}{\addtomakeheaddetails{\homepagesymbol\httplink{\@homepage}}}%
                \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
                    \addtomakeheaddetails{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
                \ifthenelse{\isundefined{\@extrainfo}}{}{\addtomakeheaddetails{\@extrainfo}}%
                \flushmakeheaddetails}\fi}\\[2.5em]}% need to force a \par after this to avoid weird spacing bug at the first section if no blank line is left after \makehead
}{}
\ifthenelse{\equal{\@moderncvstyle}{oldstyle}}{
    \renewcommand*{\makecvhead}{
        % recompute lengths (in case we are switching from letter to resume, or vice versa)
        \recomputecvlengths%
        % optional picture box
        \newbox{\makecvheadpicturebox}%
        \savebox{\makecvheadpicturebox}{%
            \ifthenelse{\isundefined{\@photo}}%
            {}%
            {%
                \color{color1}%
                \setlength\fboxrule{\@photoframewidth}%
                \ifdim\@photoframewidth=0pt%
                \setlength{\fboxsep}{0pt}\fi%
                \framebox{\includegraphics[width=\@photowidth]{\@photo}}}}%
        % name and optional title
        \newlength{\makecvheadpicturewidth}\settowidth{\makecvheadpicturewidth}{\usebox{\makecvheadpicturebox}}%
        \newlength{\makecvheadnamewidth}\setlength{\makecvheadnamewidth}{\textwidth-\makecvheadpicturewidth}%
        \begin{minipage}[b]{\makecvheadnamewidth}%
            \namestyle{\@firstname\ \@lastname}%
            \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
            % optional birthofdate and family:
            \ifthenelse{\not\isundefined{\@dateofbirth} \and \not\isundefined{\@family}}{
                {\null\hfill%
                    \begin{flushleft}
                        \textsl{\@dateofbirth\\
                            \@family
                        }
                    \end{flushleft}\hfill\null
            }}{}
            % optional no birthofdate and no family needs no ifthenelse
            % optional birthofdate but no family:
            \ifthenelse{\not\isundefined{\@dateofbirth} \and \isundefined{\@family}}{
                {\null\hfill%
                    \begin{flushleft}
                        \textsl{\@dateofbirth}
                    \end{flushleft}\hfill\null
            }}{}
            % optional family but no birthofdate:
            \ifthenelse{\isundefined{\@dateofbirth} \and \not\isundefined{\@family}}{
                {\null\hfill%
                    \begin{flushleft}
                        \textsl{\@family}
                    \end{flushleft}\hfill\null
            }}{}
        \end{minipage}%
        % optional photo
        \usebox{\makecvheadpicturebox}\\[2.5em]%
        % optional quote
        \ifthenelse{\isundefined{\@quote}}%
        {}%
        {{\centering\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[2.5em]}}%
        % optional details
        \if@details%
        \makecvheadinfo{%
            \addressfont\color{color2}%
            \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
                \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
                \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
            \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
                \makenewline\hbox to 1.0em{\csname\collectionloopkey phonesymbol\endcsname}~\collectionloopitem}%
            \ifthenelse{\isundefined{\@email}}{}{\makenewline\hbox to 1.0em{\emailsymbol}~\emaillink{\@email}}%
            \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\hbox to 1.0em{\homepagesymbol}~\httplink{\@homepage}}%
            \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
                \makenewline\hbox to 1.0em{\csname\collectionloopkey socialsymbol\endcsname}~\collectionloopitem}%
            \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}\fi}
}{}
\ifthenelse{\equal{\@moderncvstyle}{fancy}}{
    \renewcommand*{\makecvhead}{%
        % recompute lengths (in case we are switching from letter to resume, or vice versa)
        \recomputecvlengths%
        % optional photo (pre-rendering)
        \@initializebox{\makecvheadpicturebox}%
        \savebox{\makecvheadpicturebox}{%
            \ifthenelse{\isundefined{\@photo}}%
            {}%
            {%
                \color{color1}%
                \setlength{\fboxrule}{\@photoframewidth}%
                \ifdim\@photoframewidth=0pt%
                \setlength{\fboxsep}{0pt}\fi%
                \framebox{\includegraphics[width=\@photowidth]{\@photo}}}}%
        % rendering
        \@makecvtitle%
        {%
            \raggedleft%
            % optional photo
            \usebox{\makecvheadpicturebox}%
            % optional details
            \if@details%
            \ifthenelse{\isundefined{\@photo}}{}{\\[0.5em]}%
            \addressfont\color{color2}%
            \ifthenelse{\isundefined{\@dateofbirth}}{}{\makenewline\@dateofbirth}%
            \ifthenelse{\isundefined{\@family}}{}{\makenewline\@family}%
            \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
                \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
                \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
            \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
                \makenewline\csname\collectionloopkey phonesymbol\endcsname~\collectionloopitem}%
            \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol~\emaillink{\@email}}%
            \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol~\httplink{\@homepage}}%
            \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
                \makenewline\csname\collectionloopkey                socialsymbol\endcsname~\collectionloopitem}%
            \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline        \@extrainfo}\fi}%
                {%
                    % name and optional title
                    \newlength{\makecvheadpictureboxskip}%
            \setlength{\makecvheadpictureboxskip}        {\totalheightof{\usebox{\makecvheadpicturebox}}}%
                    \namestyle{\@firstname\ \@lastname}%
            \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]        \titlestyle{\@title}}\\[2.5em]%
                    % optional quote
                    \ifthenelse{\isundefined{\@quote}}%
                    {}%
            {\begin{minipage}{\quotewidth}\quotestyle{\@quote}        \end{minipage}\\[2.5em]}}%
        \par}% to avoid weird spacing bug at the first section if no         blank line is left after \makecvhead
        }{}
        \makeatother

    \name{John}{Doe}
    \dateofbirth{01.01.1970}
    \family{married}
    \address{111 Mimimi}{Here}{Somewhere}
    \phone[mobile] {+01~(0)123 456789}
    \email{[email protected]} 
    \title{CV}
    \begin{document}

    \makecvtitle

    \end{document}

我知道它相当冗长,但它应该可以工作...我遇到了结构问题\ifnum0=\pdfstrcmp{}{}所以我使用了它\ifthenelse,这个例子现在对我来说很好用。

希望这可以帮助!

PS 这只有在@christian-hupfer 的帮助下才有可能,他为我的问题提供了如何捕获用于条件的样式信息的答案:

https://tex.stackexchange.com/a/376757/136789

相关内容