我怎样在LaTeX中设置自定义页码?

26

我有一个带有附录的报告。

我想在附录开始时使用不同的页码样式。

在附录之前,我使用阿拉伯数字进行编号。当到达附录时,我想做这样的事情:

我想要自定义的页面编号是:

Chapter: A
Section: {Chapter}{1}       (A-1)
\newpage
\pagenumbering{custompagenumbering}

这可行吗?


为了获得更精确的答案,您应该详细说明您要查找的“自定义页码”的确切格式和行为。 - glts
我投票关闭此问题,因为它与LaTeX有关,不属于讨论范围。 - Flexo
3个回答

32
Some paragraph. Some paragraph. Some paragraph. Some paragraph. Some paragraph.

\newpage
\setcounter{page}{1}
\renewcommand{\thepage}{A-\arabic{page}}

Some paragraph. Some paragraph. Some paragraph. Some paragraph. Some paragraph.

这是否与您想做的事情有关?以下是如何操作page计数器和\thepage命令以确定页码打印方式。使用\roman{page}将会得到罗马数字,使用\alph{page}则会得到abc等字母序列。

另一个明智的解决方案是使用fancyhdr宏包,正如之前建议的那样。


+1 很好的回答。如果有使用 fancyhdr 的示例,这将是一个非常棒的答案。 - Geoff

4

首先,我会创建一个名为main.tex或thesis.tex的文件,其中包含所有章节和附录等内容。

在该文件中,您可以进行所有包含和文档设置,还可以进行页眉和页脚设置:

% Free Header and Footer
\usepackage{fancyhdr}
\lfoot[\fancyplain{}{}]{\fancyplain{}{}}
\rfoot[\fancyplain{}{}]{\fancyplain{}{}}
\cfoot[\fancyplain{}{\footnotesize\thepage}]{\fancyplain{}{\footnotesize\thepage}}
\lhead[\fancyplain{}{\footnotesize\nouppercase\leftmark}]{\fancyplain{}{}}
\chead{}
\rhead[\fancyplain{}{}]{\fancyplain{}{\footnotesize\nouppercase\sc\leftmark}} 

这里将使页面底部的页码居中显示,章节标题出现在页面头部的左侧,并且如果你的作品是双面打印的,章节标题也会出现在右侧。然后你就可以开始加入其他章节了...... 我的文件(thesis.tex)看起来像这样:
% --- Start of Document ----------------------------------------
\begin{document}

\pagenumbering{roman}       %roemische ziffern

\pagestyle{fancy}           % Initialize Header and Footer

\include{title}         % Title Page
\include{affidavit}     % affidavit
\include{abstracts}     % Englisch and German abstracts
\include{acknowl}       % Acknowledgements
\include{glossary}      % Glossary
\include{abbreviation}  % Abkuerzungen
%\include{keywords}     % Keywords
\include{toc}       % Table of Contents

%--- Include your chapters here ----------
\setcounter{page}{1}    % set page to 1 again to start arabic count
\pagenumbering{arabic}
%\include{chapter0}
\include{chapter1}      % Introduction
\include{chapter2}      % Background
\include{chapter3}      % Konzeption
\include{chapter4}      % Technische Umsetzung
\include{chapter5}

\include{chapter6}

%
%% ....

\appendix
\include{appendix}          % Appendix A

\end{document}

希望能帮到您!页眉和页脚有时很棘手,如果更改文档类型可能会出现不同的情况。 ;)

2
如果您能使用Memoir类(我建议这样做),您可以使用页面样式。请参阅“第7.2章页面样式”。例如,创建两个样式:
\pagestyle{plain} % Regular page numbering

... STUFF ...

\clearpage % make a new page numbering down here
\copypagestyle{AppendixPS}{plain}
\renewcommand{\thepage}{Chapter \chapter Section \section page \page}
\pagestyle{AppendixPS}

我没有测试过这个方法,也有一段时间没有使用LaTeX了,但我希望它能为您提供一些启示或至少让您走上正确的道路。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接