使用“moderncv”文档类的法式求职信

使用“moderncv”文档类的法式求职信

我遇到了与该帖子中提出的问题非常类似的问题: 在 moderncv 中更新命令 \makelettertitle,但提出的解决方案并不能完全满足我的需求。

提醒一下,法国人输入信头的方式传统上是将发件人的信息放在文件的左上角,将收件人的信息放在下方,但在文件的右侧。

我的问题是,我无法找到一种可行的方法,通过修改上面链接中提出的解决方案来将文本块“收件人地址”刷新到右侧。

我也想为这封信的正文辩解,但我的解决方案,正如本帖中所提议的那样,在 moderncv 求职信中对齐文本,干扰 \makelettertittle 命令的修改。

下面是一个 MWE 来总结一切:(请注意,签名也向右对齐)

\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic}          
\moderncvcolor{blue}                      
\nopagenumbers{}
\usepackage{etoolbox}
\usepackage{lipsum}

%%%%%%%%%%%%% Beginning of \makelettertittle modification %%%%%%%%%%%%%%%%%%

\makeatletter
%-------------------------------------------------------------------------------
%                letter style definition
%-------------------------------------------------------------------------------
% commands
\renewcommand*{\recomputeletterlengths}{%
\recomputecvlengths%
\setlength{\parskip}{6\p@}}

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

\renewcommand*{\makelettertitle}{%
% 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~\@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{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
  \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
  \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}%
\end{minipage}\\[2em]
% recipient block
\hspace{0.5\textwidth} \begin{minipage}[t]{.5\textwidth}       
\raggedright%
\addressfont%
{\bfseries\upshape\@recipientname}\\%
\@recipientaddress\\[2em]%
\@date\\[1.5em]%                                               
\end{minipage}
% date
\hfill
\null\\[2em]%                                              
\raggedright%
\ifthenelse{\isundefined{\@subject}}{}{%                             
\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%
%%%%%%%%%%%%%%%%% End of \makelettertittle modification%%%%%%%%%%%%%%%%%%%%%%%%%%%

\makeatletter
\patchcmd{\makelettertitle}               %%% Text body justifying attempt
{\raggedright \@opening}
{\@opening}
{}{}

\patchcmd{\makeletterclosing}             %%% Flushing right the signature
{\@closing}
{\flushright \@closing}
{}{}
\makeatother

% character encoding
\usepackage[ansinew]{inputenc}
\usepackage[francais]{babel}

% adjust the page margins
\usepackage[top=1.1cm, bottom=1.1cm, left=2cm, right=2cm]{geometry}
\setlength{\hintscolumnwidth}{3cm}

% personal data
\firstname{Mr Foo}
\familyname{Bar}
\title{Resume title}
\address{address}{city}{country}
\mobile{0987654321}             
\phone{0123456789}          
\email{[email protected]}     

\begin{document}

%%%%Recipient infos%%%%
\recipient{Recruitment Office}{Derp Corp.\\12 Some Way\\Foobar}
\date{\today}
\subject{Job application ref. 121212}
\opening{Dear Sir or Madam,}
\closing{Yours faithfully,}
\enclosure[Attached]{curriculum vit\ae{}}

\makelettertitle

\lipsum[1-3]

\makeletterclosing

\end{document}

答案1

因此,我不得不说,你的例子远非简单;我强烈建议你看一下一些减少代码量的小技巧已在 Meta 站点上提供。

但对于您的问题。您的代码中的几个项目都混杂在一起,可能是将来自不同地方的多个解决方案组合在一起的结果。换行符的位置(例如,\\[2em])干扰了在第二个minipage环境前面添加空格的能力。同样,日期被移动了足够多次,以至于有些行(现在仍然)可能没有必要(如所示\hfill)。由于我不知道您的最终产品应该是什么样子,我将把清理工作留给您自己。

最后,您使用\patchcmd来“修补”您已经直接重新定义的命令。这毫无必要地复杂,除非您预计再次使用部分代码而不进行您尝试修补的更改。只需在命令的更新定义中进行更改即可。我已经\raggedright多次更改了第一个命令,删除了现在不需要的部分。第二个\patchcmd命令有效(我将其更改为\raggedleft,这是环境的正确声明形式flushright),但如果您希望它“正常工作”,最好只在更新的定义中进行更改。

你的例子现在变成:

\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic}          
\moderncvcolor{blue}                      
\nopagenumbers{}
\usepackage{etoolbox}
\usepackage{lipsum}

%%%%%%%%%%%%% Beginning of \makelettertittle modification %%%%%%%%%%%%%%%%%%

\makeatletter
%-------------------------------------------------------------------------------
%                letter style definition
%-------------------------------------------------------------------------------
% commands
\renewcommand*{\recomputeletterlengths}{%
\recomputecvlengths%
\setlength{\parskip}{6\p@}}

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

\renewcommand*{\makelettertitle}{%
% 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~\@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{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
  \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
  \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}%
\end{minipage}\vspace{2em}% << Add space with \vspace, have actual paragraph break

% recipient block        V--V Adjust to fit text and align as desired
\hfill\begin{minipage}[t]{.5\textwidth}       % << \hfill now works
\raggedright%
\addressfont%
{\bfseries\upshape\@recipientname}\\%
\@recipientaddress\\[2em]%
\@date\\[1.5em]%                                               
\end{minipage} % << Another paragraph break here needed

% date
\hfill  % << This wasn't doing anything good before, probably not now either.
\null\\[2em]%                                              
%\raggedright % << Remove ragged right from definition
\ifthenelse{\isundefined{\@subject}}{}{%                             
\begin{tabular}{ p{0.08\textwidth} p{0.92\textwidth} }
Objet: & \raggedright \@subject
\end{tabular}
\\[1.5em]}%
% opening
%\raggedright % << Remove ragged right from definition
\@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%
%%%%%%%%%%%%%%%%% End of \makelettertittle modification%%%%%%%%%%%%%%%%%%%%%%%%%%%

\patchcmd{\makeletterclosing}             %%% Flushing right the signature
{\@closing}
{\raggedleft \@closing}
{}{}
\makeatother

% character encoding
\usepackage[ansinew]{inputenc}
\usepackage[francais]{babel}

% adjust the page margins
\usepackage[top=1.1cm, bottom=1.1cm, left=2cm, right=2cm]{geometry}
\setlength{\hintscolumnwidth}{3cm}

% personal data
\firstname{Mr Foo}
\familyname{Bar}
\title{Resume title}
\address{address}{city}{country}
\mobile{0987654321}             
\phone{0123456789}          
\email{[email protected]}     

\begin{document}

%%%%Recipient infos%%%%
\recipient{Recruitment Office}{Derp Corp.\\12 Some Way\\Foobar}
\date{\today}
\subject{Job application ref. 121212}
\opening{Dear Sir or Madam,}
\closing{Yours faithfully,}
\enclosure[Attached]{curriculum vit\ae{}}

\makelettertitle

\lipsum[1-3]

\makeletterclosing

\end{document}

信

相关内容