8

I'm using the letter template from the wiki. Here's the code:

\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}

All I want to do is keep the date on the right hand side, but move it down below the second address block. This is my first post on StackExchange so I'm sorry for the lack of an image.

sodd
  • 5,771

1 Answers1

8

You can use the \patchcmd command from the etoolbox package to patch the \opening command:

\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}

or you can patch it manually by including the following in your preamble:

\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

Both yield the same output:

Output with date below to-address

sodd
  • 5,771
  • 1
    Thanks, in the second version, there is a { missing here: #1\par\nobreak}. In the first version, the date appears twice: between the 2 addresses and at the correct pos. Can you help? – user3123159 Mar 28 '18 at 15:45
  • @user3123159 There is no { missing, the opening brace is just after the [1]. I see now that I didn't take into account the case in the first version that when the page style was empty it would output the date twice - good catch. Fixed now. – sodd Mar 30 '18 at 11:49