我想修改 moderncv 包中的命令 \makelettertitle,这样我就可以拥有一个法语风格的标题,即左侧是我的数据,下面两列左侧是“formule de courtesse”,右侧是公司数据。左侧下方是日期,右侧是“objet”(我发送这封信的原因),下方是 \opening。
问题是,如果我尝试执行更新命令,它会给我带来许多额外的错误:P
提前致谢
答案1
简单的方法是从中获取定义moderncvstyleclassic.sty
并进行修改,然后将其放入主文件本身makeatletter
中\makeatother
。(我不建议修改moderncvstyleclassic.sty
)
修改内容如下:
\makeatletter
%-------------------------------------------------------------------------------
% letter style definition
%-------------------------------------------------------------------------------
% commands
\renewcommand*{\recomputeletterlengths}{%
\recomputecvlengths%
\setlength{\parskip}{6\p@}}
\newcommand*{\subject}[1]{\def\@subject{#1}} %% new command added
\renewcommand*{\makelettertitle}{%
% recompute lengths (in case we are switching from letter to resume, or vice versa)
\recomputeletterlengths%
% sender contact info
%\hfill% %%% <========== This commented
\begin{minipage}{.5\textwidth}%
\raggedright% %%% \reggedleft changed to raggedright
\addressfont\textcolor{color2}{% %%% change color here if you want it black or...
{\bfseries\upshape\@firstname~\@familyname}\@firstdetailselementfalse%
\ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
\ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}}%
\ifthenelse{\isundefined{\@mobile}}{}{\makenewline\mobilesymbol\@mobile}%
\ifthenelse{\isundefined{\@phone}}{}{\makenewline\phonesymbol\@phone}%
\ifthenelse{\isundefined{\@fax}}{}{\makenewline\faxsymbol\@fax}%
\ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
\ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
\ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}%
\end{minipage}\\[2em]
% recipient block
Attention: \quad \begin{minipage}[t]{.5\textwidth} %%% Changed here
\raggedright%
\addressfont%
{\bfseries\upshape\@recipientname}\\%
\@recipientaddress\\[2em]%
\@date\\[1.5em]% %%% Changed here
\end{minipage}
% date
\hfill% US style
% \\[1em]% UK style
\null\\[2em]% %%% Changed here
\raggedright%
\ifthenelse{\isundefined{\@subject}}{}{% %% new command added
\begin{tabular}{ p{0.08\textwidth} p{0.92\textwidth} }
Objet: & \raggedright \@subject
\end{tabular}
\\[1.5em]}%
% opening
\raggedright%
\@opening\\[1.5em]%
\hspace{0pt}\par\vspace{-\baselineskip}\vspace{-\parskip}}
\renewcommand*{\makeletterclosing}{
\@closing\\[3em]%
{\bfseries \@firstname~\@familyname}%
\ifthenelse{\isundefined{\@enclosure}}{}{%
\\%
\vfill%
{\color{color2}\itshape\enclname: \@enclosure}}}
\makeatother
在此更改您想要的任何内容,例如地址的颜色等等。
完整代码如下
\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage[scale=0.75]{geometry}
\makeatletter
%-------------------------------------------------------------------------------
% letter style definition
%-------------------------------------------------------------------------------
% commands
\renewcommand*{\recomputeletterlengths}{%
\recomputecvlengths%
\setlength{\parskip}{6\p@}}
\newcommand*{\subject}[1]{\def\@subject{#1}} %% new command added
\renewcommand*{\makelettertitle}{%
% recompute lengths (in case we are switching from letter to resume, or vice versa)
\recomputeletterlengths%
% sender contact info
%\hfill% %%% <========== This commented
\begin{minipage}{.5\textwidth}%
\raggedright% %%% \reggedleft changed to raggedright
\addressfont\textcolor{color2}{% %%% change color here if you want it black or...
{\bfseries\upshape\@firstname~\@familyname}\@firstdetailselementfalse%
\ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
\ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}}%
\ifthenelse{\isundefined{\@mobile}}{}{\makenewline\mobilesymbol\@mobile}%
\ifthenelse{\isundefined{\@phone}}{}{\makenewline\phonesymbol\@phone}%
\ifthenelse{\isundefined{\@fax}}{}{\makenewline\faxsymbol\@fax}%
\ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
\ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
\ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}%
\end{minipage}\\[2em]
% recipient block
Attention: \quad \begin{minipage}[t]{.5\textwidth} %%% Changed here
\raggedright%
\addressfont%
{\bfseries\upshape\@recipientname}\\%
\@recipientaddress\\[2em]%
\@date\\[1.5em]% %%% Changed here
\end{minipage}
% date
\hfill% US style
% \\[1em]% UK style
\null\\[2em]% %%% Changed here
\raggedright%
\ifthenelse{\isundefined{\@subject}}{}{% %% new command added
\begin{tabular}{ p{0.08\textwidth} p{0.92\textwidth} }
Objet: & \raggedright \@subject
\end{tabular}
\\[1.5em]}%
% opening
\raggedright%
\@opening\\[1.5em]%
\hspace{0pt}\par\vspace{-\baselineskip}\vspace{-\parskip}}
\renewcommand*{\makeletterclosing}{
\@closing\\[3em]%
{\bfseries \@firstname~\@familyname}%
\ifthenelse{\isundefined{\@enclosure}}{}{%
\\%
\vfill%
{\color{color2}\itshape\enclname: \@enclosure}}}
\makeatother
% personal data
\firstname{John}
\familyname{Doe}
\title{Resumé title} % optional, remove / comment the line if not wanted
\address{street and number}{postcode city} % optional, remove / comment the line if not wanted
\mobile{+1~(234)~567~890} % optional, remove / comment the line if not wanted
\phone{+2~(345)~678~901} % optional, remove / comment the line if not wanted
\fax{+3~(456)~789~012} % optional, remove / comment the line if not wanted
\email{[email protected]} % optional, remove / comment the line if not wanted
\homepage{www.johndoe.com} % optional, remove / comment the line if not wanted
\extrainfo{additional information} % optional, remove / comment the line if not wanted
\photo[64pt][0.4pt]{picture} % optional, remove / comment the line if not wanted;
\quote{`` A witty and playful quote''} % optional, remove / comment the line if not wanted
%----------------------------------------------------------------------------------
\begin{document}
%----- letter ---------------------------------------------------------
% recipient data
\recipient{Company Recruitment team}{Company, Inc.\\123 somestreet\\some city}
\date{January 01, 1984}
\subject{This is to fill some text that goes in to two lines and many more here we come to the second line and it is neat} %% use subject here
\opening{Dear Sir or Madam,}
\closing{Yours faithfully,}
\enclosure[Attached]{curriculum vit\ae{}}
\makelettertitle
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis ullamcorper neque sit amet lectus facilisis sed luctus nisl iaculis. Vivamus at neque arcu, sed tempor quam. Curabitur pharetra tincidunt tincidunt. Morbi volutpat feugiat mauris, quis tempor neque vehicula volutpat. Duis tristique justo vel massa fermentum accumsan. Mauris ante elit, feugiat vestibulum tempor eget, eleifend ac ipsum. Donec scelerisque lobortis ipsum eu vestibulum. Pellentesque vel massa at felis accumsan rhoncus.
Suspendisse commodo, massa eu congue tincidunt, elit mauris pellentesque orci, cursus tempor odio nisl euismod augue. Aliquam adipiscing nibh ut odio sodales et pulvinar tortor laoreet. Mauris a accumsan ligula. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse vulputate sem vehicula ipsum varius nec tempus dui dapibus. Phasellus et est urna, ut auctor erat. Sed tincidunt odio id odio aliquam mattis. Donec sapien nulla, feugiat eget adipiscing sit amet, lacinia ut dolor. Phasellus tincidunt, leo a fringilla consectetur, felis diam aliquam urna, vitae aliquet lectus orci nec velit. Vivamus dapibus varius blandit.
Duis sit amet magna ante, at sodales diam. Aenean consectetur porta risus et sagittis. Ut interdum, enim varius pellentesque tincidunt, magna libero sodales tortor, ut fermentum nunc metus a ante. Vivamus odio leo, tincidunt eu luctus ut, sollicitudin sit amet metus. Nunc sed orci lectus. Ut sodales magna sed velit volutpat sit amet pulvinar diam venenatis.
Albert Einstein discovered that $e=mc^2$ in 1905.
\[ e=\lim_{n \to \infty} \left(1+\frac{1}{n}\right)^n \]
\makeletterclosing
\end{document}
答案2
这是一个可能的解决方案:
1)进入 moderncv 文件夹,可能位于/usr/local/texlive/2013/texmf-dist/tex/latex/moderncv
2) 在我的情况下,编辑您使用的相应主题moderncvstyleclassic.sty
3)添加以下文字:
\newcommand*{\entete}[1]{\def\@entete{#1}}
\newcommand*{\objetlettre}[1]{\def\@objetlettre{#1}}
\newcommand*{\fairetitrelettre}{%
% recompute lengths (in case we are switching from letter to resume, or vice versa)
\recomputeletterlengths%
% sender contact info
%\hfill%
\begin{minipage}{.5\textwidth}%
\raggedright%
\addressfont\textcolor{color2}{%
{\bfseries\upshape\@firstname~\@lastname}\@firstdetailselementfalse%
\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}}%
\ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}%
\end{minipage}
% recipient block
\ifthenelse{\isundefined{\@entete}}{}{
\begin{minipage}{.5\textwidth}
\raggedright%
\@entete
\end{minipage}
\vspace*{-1.2\baselineskip}
}
\hfill
\begin{minipage}{.5\textwidth}
\raggedleft%
\addressfont%
{\bfseries\upshape\@recipientname}\\%
\@recipientaddress%
\end{minipage}
% date
\vspace{2em}
\hfill% US style
% \\[1em]% UK style
\@date\\[2em]% US informal style: "January 1, 1900"; UK formal style: "01/01/1900"
% opening
\raggedright%
\ifthenelse{\isundefined{\@objetlettre}}{}{
\begin{tabular}{ p{0.08\textwidth} p{0.92\textwidth} }
Objet: & \@objetlettre
\end{tabular}
\\[1.5em]}
\@opening\\[1.5em]%
% ensure no extra spacing after \makelettertitle due to a possible blank line
% \ignorespacesafterend% not working
\hspace{0pt}\par\vspace{-\baselineskip}\vspace{-\parskip}}
4)当你写动机信时,只需使用以下命令
\opening{Madame, Monsieur,}
\closing{Veuillez agréer, Madame, Monsieur, l'expression de mes salutations distinguées.}
\enclosure[P.S.]{Veuillez trouver ci-joint mon curriculum vit\ae}
\objetlettre{candidature pour le poste de XXX. Annonce parue sur le site YYY. Référence: ZZZ} % Optional parameter
%\entete{À l'attention du responsable du recrutement} % Optional parameter
%\makelettertitle % DON'T USE THIS
\fairetitrelettre % But this one
Here goes the text of the LM
\makeletterclosing