makecvtitle-如何在新命令中区分两个名称的大小

makecvtitle-如何在新命令中区分两个名称的大小

在 moderncv 中,我的理解是moderncvheadii.sty指定 \makecvtitle 如何设置名称,例如 John Doe。它从中的定义中绘制 John 和 Doe \name{John}{Doe}。大小似乎由控制

\renewcommand*{\namefont}{\fontsize{38}{40}\mdseries\upshape}

在默认代码中,两个名称组件的大小相同。我想定义一个\MYmakecvtitle命令,对第一个名称组件使用不同的字体大小,例如 John at,{\fontsize{20}{30}\mdseries\upshape}同时保持第二个名称组件 Doe 的大小相同。我该如何定义这样的新命令?

答案1

\makecvhead这是一个可能不太优雅的解决方案。我复制了from的定义moderncvheadii.sty,并将其添加到\fontsize{20}{30}\mdseries\upshape我用 突出显示的行中<--------

在此处输入图片描述

\documentclass{moderncv}
\moderncvstyle{casual} 
\name{John}{Doe}

\makeatletter
\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
        {\fontsize{20}{30}\mdseries\upshape\color{color2!50}\@firstname} {\fontsize{20}{30}\namefont\color{color2}\@lastname}\fi}}% <---------------------- Added \fontsize{20}{30}\mdseries\upshape and \namefont here
  % 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%
    }\\[2.5em]%
  % optional quote
  \ifthenelse{\isundefined{\@quote}}%
    {}%
    {{\null\hfill%
      \begin{minipage}{\quotewidth}%
        \centering%
        \quotestyle{\@quote}%
      \end{minipage}\hfill\null\\[2.5em]}}%
  \par}% to avoid weird spacing bug at the first section if no blank line is left after \maketitle
\makeatother
\begin{document}
\makecvhead
contents
\end{document}

相关内容