题
在乳胶,一个如何可以使用的信的DocumentClass创建一个文档,但是定制的页眉和页脚?
通常我会使用:
\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}
然而,随着\ {的DocumentClass信},这并不在所有的工作。建议后即被理解。
修改强>以下是示例代码不工作(对于任何明显的理由):
\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}
解决方案
只要你行“信的内容”前,增加\thispagestyle{fancy}
它应该表现出你所定义的头。 (它为我。)
下面就是我用于测试的完整文件:
\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}
在\opening
命令设置页面样式firstpage
或empty
,让您有一个命令后使用\thispagestyle
。
其他提示
在我除去
\usepackage{fontspec}% font selecting commands
\usepackage{xunicode}% unicode character macros
\usepackage{xltxtra} % some fixes/extras
似乎已经奏效 “正确”。
这可能是值得注意的是,页眉和页脚只从第2页起出现。虽然我已经试过这样做的fancyhdr文档中提供的修复,我无法得到它的工作的。
供参考:MIKTEX 2.7 Vista下
对于Brent.Longborough的答案(appering只起第2页),也许你需要设置的 \ thispagestyle {} 之后的 \ {开始}文件即可。我不知道这封信类设置第一个页面样式设置为空。
不隶属于 StackOverflow