首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在LaTeX中,如何在文档类信函中添加页眉/页脚?

在LaTeX中,如何在文档类信函中添加页眉/页脚?
EN

Stack Overflow用户
提问于 2009-02-18 05:19:06
回答 4查看 116.8K关注 0票数 22

在LaTeX中,如何使用信函文档类创建文档,但使用定制的页眉和页脚?

通常我会使用:

代码语言:javascript
复制
\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{信函},这一点都不起作用。建议得到应有的赞赏。

编辑:这里的是不工作的示例代码(出于任何明显的原因):

代码语言:javascript
复制
\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}
EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2009-02-18 16:06:41

就在“信函内容”行的前面,添加\thispagestyle{fancy},它应该显示您定义的标题。(对我来说很管用。)

下面是我用来测试的完整文档:

代码语言:javascript
复制
\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命令将页面样式设置为firstpageempty,因此必须在该命令之后使用\thispagestyle

票数 24
EN

Stack Overflow用户

发布于 2009-02-18 14:16:46

在我移除之后

代码语言:javascript
复制
\usepackage{fontspec}% font selecting commands 
\usepackage{xunicode}% unicode character macros 
\usepackage{xltxtra} % some fixes/extras 

它似乎“正确地”起了作用。

值得注意的是,页眉和页脚仅从第2页开始出现。虽然我已经尝试了fancyhdr文档中给出的修复方法,但我也无法让它工作。

MikTeX 2.7在Vista下

票数 1
EN

Stack Overflow用户

发布于 2009-02-18 15:05:43

关于Brent.Longborough的答案(只在第2页继续),也许您需要在\begin{document}.之后设置\begin{document}.我不知道信函类是否将第一页样式设置为空。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/559938

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档