views:

20028

answers:

5

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}
A: 

fancyhdr should work. What's happening when you try it?

Charlie Martin
My sentiments exactly. I've edited the question to add non-functional code that I think ought to work ...
Brian M. Hunt
+1  A: 

After I removed

\usepackage{fontspec}% font selecting commands 
\usepackage{xunicode}% unicode character macros 
\usepackage{xltxtra} % some fixes/extras

it seems to have worked "correctly".

It may be worth noting that the headers and footers only appear from page 2 onwards. Although I've tried the fix for this given in the fancyhdr documentation, I can't get it to work either.

FYI: MikTeX 2.7 under Vista

Brent.Longborough
The usepackages there will only work with xe(la)tex- sorry, I should have mentioned that.
Brian M. Hunt
+1  A: 

With regard to Brent.Longborough's answer (appering only on page 2 onward), perhaps you need to set the \thispagestyle{} after \begin{document}. I wonder if the letter class is setting the first page style to empty.

JLR
tried that - no luck...
Brent.Longborough
+6  A: 

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.

godbyk
Great catch. Thank you.
Brian M. Hunt
Yep, who'd have thought it needed moving so far down. Yuck. Back to memoir...
Brent.Longborough
A: 

hi, I am using IEEETrans.cls to format my paper.Now I need to add the name of the conference at the right hand corner of each page. Please advice me how to do that.mail me in [email protected]. Its really urgent.

raqib
-1 @Raqib: (1) You're asking a new question; please do that by clicking "ask question" on this website; (2) the question you are asking is almost completely unrelated to the question above; (3) the proper response is not by email; (4) it's poor etiquette to demand advice as in your post.
Brian M. Hunt