我想添加一些额外信息,但当然是在地址信息行之前,在我的名字之后。
我怎样才能做到这一点?
答案1
以下最小示例补丁\maketitle
在标题中插入包含“额外信息”的宏moderncv
banking
样式。用于调整此“额外信息”的命令是\someextrainfo{<stuff>}
。如果需要,您还可以使用 调整字体\someextrainfofont{<font>}
。请注意,您可能必须使用 重置任何此类字体更改\addressfont{<font>}
,因为字体是使用开关。
\documentclass{moderncv}
\moderncvstyle{banking}
\moderncvcolor{blue}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\maketitle}% <cmd>
{\addressfont\color{color2}}% <search>
{\@someextrainfofont\color{color2}%
\ifcsdef{@someextrainfo}{\@someextrainfo\\}{}%
\addressfont}% <replace>
{}{}% <success><failure>
\providecommand{\@someextrainfofont}{}
\newcommand{\someextrainfo}[1]{\gdef\@someextrainfo{#1}}
\newcommand{\someextrainfofont}[1]{\gdef\@someextrainfofont{#1}}
\makeatother
\usepackage{libertine}
\usepackage[scale=0.75]{geometry}
\name{John}{Doe}
\someextrainfo{some extra information}
\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}
\quote{Some quote}
\begin{document}
\makecvtitle
\section{A test section}
Some test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text
\end{document}
答案2
最后,我编辑了 Wener 的代码。只是为了区分默认的 extrainfo 和这个新的 extrainfo
The following minimal example patches `\maketitle` to insert a macro that contains "extra information" in the title for the [`moderncv`](http://ctan.org/pkg/moderncv) `banking` style. The command used to adjust this "extra information" is `\extrainfo{<stuff>}`. You can also adjust the font, if needed, using `\extrainfofont{<font>}`. Note that you may have to reset any such font changes using `\addressfont{<font>}`, as fonts are set using *switches*.
\documentclass{moderncv}
\moderncvstyle{banking}
\moderncvcolor{blue}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\maketitle}% <cmd>
{\addressfont\color{color2}}% <search>
{\@extrainfofont\color{color2}%
\ifcsdef{@extrainf}{\@extrainf\\}{}%
\addressfont}% <replace>
{}{}% <success><failure>
\providecommand{\@extrainfofont}{}
\newcommand{\extrainf}[1]{\gdef\@extrainf{#1}}
\newcommand{\extrainfofont}[1]{\gdef\@extrainfofont{#1}}
\makeatother
\usepackage{libertine}
\usepackage[scale=0.75]{geometry}
\name{John}{Doe}
\extrainf{some extra information}
\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}
\quote{Some quote}
\begin{document}
\makecvtitle
\section{A test section}
Some test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text
\end{document}