定制 ModernCV

定制 ModernCV

对于我的简历,我使用的是出色的moderncv,但我想对其进行一些自定义。

例如,我想减少标题后空白处的高度。

moderncvstyleclassic.sty,我可以将第 143 行从

\usebox{\makecvtitlepicturebox}\\[2.5em]%

\usebox{\makecvtitlepicturebox}\\[0.5em]%

它可以完成这项工作。如何在不编辑.sty位于 的情况下获得相同的结果/usr/local/texlive...

答案1

第 143 行,该\usebox{\makecvtitlepicturebox}\\[2.5em]%命令,是从第 93 行开始的命令的一部分。\renewcommand*{}{}其范围\renewcommand*{}{}一直延伸到第 148 行。

因此,您可以将整个内容复制并粘贴\renewcommand*{}{}到您的前言中,只需编辑与您相关的部分。也就是说,将以下代码放在文件的前言中.tex

\makeatletter
\renewcommand*{\makecvtitle}{%
  % recompute lengths (in case we are switching from letter to resume, or vice versa)
  \recomputecvlengths%
  % optional detailed information (pre-rendering)
  \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}}%
  \newbox{\makecvtitledetailsbox}%
  \savebox{\makecvtitledetailsbox}{%
    \addressfont\color{color2}%
    \begin{tabular}[b]{@{}r@{}}%
      \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}
  }%
  % 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-\makecvtitledetailswidth-\makecvtitlepicturewidth}}%
    {}%
  \begin{minipage}[b]{\makecvtitlenamewidth}%
    \namestyle{\@firstname\ \@lastname}%
    \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
  \end{minipage}%
  \hfill%
  % optional detailed information (rendering)
  \llap{\usebox{\makecvtitledetailsbox}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvtitlenamewidth is forced
  % optional photo (rendering)
  % -------------------------------------------------------------------
  % this part immediately below has been modified for your purposes
  % -------------------------------------------------------------------
  \usebox{\makecvtitlepicturebox}\\[0.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

请注意,需要将内容包装在...\renewcommand*{}{}中。\makeatletter\makeatother

最后,你可能想看看这个答案关于修改文件内容的一些讨论.sty,特别是考虑到LaTeX 项目公共许可证(低功率脉冲激光二极管)。

答案2

您可以在前言中添加两行来修补该\makecvtitle命令。

\usepackage{xpatch}
\xpatchcmd{\makecvtitle}{\usebox{\makecvtitlepicturebox}\\[2.5em]}{\usebox{\makecvtitlepicturebox}\\[0.5em]}{}{}

(使用包也可以实现,etoolbox但我更喜欢xpatch。)

您可以使用最后两个参数来设置修补的代码片段SuccessFailure例如警告)。

相关内容