gpt4 book ai didi

latex - 在LaTeX中,如何在文档类Letter中添加页眉/页脚?

转载 作者:行者123 更新时间:2023-12-03 11:41:37 30 4
gpt4 key购买 nike

在LaTeX中,如何使用Letter文档类创建具有自定义页眉和页脚的文档?

通常,我会使用:

\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 {letter},这根本不起作用。建议应受到赞赏。

编辑:这是无效的示例代码(出于任何明显的原因):
\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命令将页面样式设置为 firstpageempty,因此您必须在该命令之后使用 \thispagestyle

关于latex - 在LaTeX中,如何在文档类Letter中添加页眉/页脚?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/559938/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com