日期在字母类别中的位置

日期在字母类别中的位置

我使用的是letterwiki 中的模板。代码如下:

\documentclass{letter}
\usepackage{hyperref}
\signature{Joe Bloggs}
\address{21 Bridge Street \\ Smallville \\ Dunwich DU3 4WE}
\begin{document}

\begin{letter}{Director \\ Doe \& Co \\ 35 Anthony Road
\\ Newport \\ Ipswich IP3 5RT}
\date{March 27, 2016}
\opening{Dear Sir or Madam:}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tellus lacus,
suscipit ac condimentum eget, commodo in metus. Praesent malesuada placerat 
tortor ac convallis. Nam ultrices est metus, et pellentesque augue porta 
non. Nulla risus diam, congue non massa in, fermentum commodo lectus. Aenean
quis aliquam velit

\closing{Yours Faithfully,}

\end{letter}
\end{document}

我只想将日期保留在右侧,但将其移到第二个地址块下方。这是我在 StackExchange 上的第一篇文章,因此很抱歉没有图片。

答案1

\patchcmd您可以使用etoolbox软件包修补\opening命令:

\documentclass{letter}
\usepackage{hyperref}
\usepackage{etoolbox}

\makeatletter
% If pagestyle is firstpage, remove old placement of date
\patchcmd\opening{{\raggedleft\@date\par}}{}{}{}
% If pagestyle is empty, remove vertical space after addess
\patchcmd\opening{\fromaddress \\*[2\parskip]}{\fromaddress}{}{}
% If pagestyle is empty, remove old placement of date
\patchcmd\opening{\@date \end{tabular}\par}{\end{tabular}\par}{}{}
% Insert new placement of date
\patchcmd\opening{{\raggedright \toname \\ \toaddress \par}}{{\raggedright \toname \\ \toaddress \par}{\raggedleft\@date\par}}{}{}
\makeatother

\signature{Joe Bloggs}
\address{21 Bridge Street \\ Smallville \\ Dunwich DU3 4WE}

\begin{document}

\begin{letter}{Director \\ Doe \& Co \\ 35 Anthony Road
\\ Newport \\ Ipswich IP3 5RT}
\date{March 27, 2016}
\opening{Dear Sir or Madam:}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tellus lacus,
suscipit ac condimentum eget, commodo in metus. Praesent malesuada placerat 
tortor ac convallis. Nam ultrices est metus, et pellentesque augue porta 
non. Nulla risus diam, congue non massa in, fermentum commodo lectus. Aenean
quis aliquam velit

\closing{Yours Faithfully,}

\end{letter}
\end{document}

或者您可以通过在序言中包含以下内容来手动修补它:

\makeatletter
\renewcommand*{\opening}[1]{\ifx\@empty\fromaddress
  \thispagestyle{firstpage}%
    %{\raggedleft\@date\par}%       <--- REMOVED
  \else  % home address
    \thispagestyle{empty}%
    {\raggedleft\begin{tabular}{l@{}}\ignorespaces
      %\fromaddress \\*[2\parskip]% <--- REMOVED
      %\@date \end{tabular}\par}%   <--- REMOVED
      \fromaddress%                 <--- ADDED
      \end{tabular}\par}%           <--- ADDED
  \fi
  \vspace{2\parskip}%
  {\raggedright \toname \\ \toaddress \par}%
  {\raggedleft\@date\par}%          <--- ADDED
  \vspace{2\parskip}%
  #1\par\nobreak}
\makeatother

两者都产生相同的输出:

输出收件人下方的日期

相关内容