In LaTeX, how can one create a document using the Letter documentclass, but with customized headers and footers?
Typically I would use:
\usepackage{fancyhdr} \pagestyle{fancy} \lhead{\footnotesize \parbox{11cm}{Custom left-head-note} } \lfoot{\footnotesize \parbox{11cm}{\textit{#2}}} \rfoot{\footnotesize Page \thepage\ of \pageref{LastPage}} \renewcommand\headheight{24pt} \renewcommand\footrulewidth{0.4pt}
However, with \documentclass{letter}, this doesn't work at all. Suggestions are duly appreciated.
EDIT: Here is sample code that doesn't work (for any apparent reason):
\documentclass[12pt]{letter} \usepackage{fontspec}% font selecting commands \usepackage{xunicode}% unicode character macros \usepackage{xltxtra} % some fixes/extras % page counting, header/footer \usepackage{fancyhdr} \usepackage{lastpage} \pagestyle{fancy} \lhead{\footnotesize \parbox{11cm}{Draft 1} } \lfoot{\footnotesize \parbox{11cm}{\textit{2}}} \cfoot{} \rhead{\footnotesize 3} \rfoot{\footnotesize Page \thepage\ of \pageref{LastPage}} \renewcommand{\headheight}{24pt} \renewcommand{\footrulewidth}{0.4pt} \begin{document} \name{ Joe Laroo } \signature{ Joe Laroo } \begin{letter}{ To-Address } \renewcommand{\today}{ February 16, 2009 } \opening{ Opening } Content of the letter. \closing{ Yours truly, } \end{letter} \end{document}
Just before your "Content of the letter" line, add \thispagestyle{fancy}
and it should show the headers you defined. (It worked for me.)
Here's the full document that I used to test:
\documentclass[12pt]{letter} \usepackage{fontspec}% font selecting commands \usepackage{xunicode}% unicode character macros \usepackage{xltxtra} % some fixes/extras % page counting, header/footer \usepackage{fancyhdr} \usepackage{lastpage} \pagestyle{fancy} \lhead{\footnotesize \parbox{11cm}{Draft 1} } \lfoot{\footnotesize \parbox{11cm}{\textit{2}}} \cfoot{} \rhead{\footnotesize 3} \rfoot{\footnotesize Page \thepage\ of \pageref{LastPage}} \renewcommand{\headheight}{24pt} \renewcommand{\footrulewidth}{0.4pt} \usepackage{lipsum}% provides filler text \begin{document} \name{ Joe Laroo } \signature{ Joe Laroo } \begin{letter}{ To-Address } \renewcommand{\today}{ February 16, 2009 } \opening{ Opening } \thispagestyle{fancy}% sets the current page style to 'fancy' -- must occur *after* \opening \lipsum[1-10]% just dumps ten paragraphs of filler text \closing{ Yours truly, } \end{letter} \end{document}
The \opening
command sets the page style to firstpage
or empty
, so you have to use \thispagestyle
after that command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With