我的文档有一个前言,而不是称呼它第1章,或者使用\chapter*
不将其包含在目录中,我希望它而不是1我有一个磷.然后恢复正常计数——有点像附录。
所以我的目录如下所示:
P Preface
P.1 Stuff
P.2 More Stuff
I All about stuff
1 Stuff in itself
1.1 Does stuff exist
1.2 Does stuff matter
1.2.1 The ethical implications of the non-existence of stuff
etc.
编辑:额外的问题:我也不想让它说:
Chapter P
Preface
只是
Preface
在序言的开始处 - 也许可以手动添加到目录中 - 但我的天真的尝试并没有取得很好的效果。
答案1
您应该在异常章节之前手动切换章节计数器表示。基本思路如下(请记住,章节计数器在开始时递增\chapter
):
\setcounter{chapter}{15}% Equivalent to "letter O"
\renewcommand{\thechapter}{\Alph{chapter}}%
\chapter{Preface}
%...
\setcounter{chapter}{8}% Equivalent to "letter H"
\chapter{All about stuff}
%...
\setcounter{chapter}{0}%
\renewcommand{\thechapter}{\arabic{chapter}}%
\chapter{Stuff in itself}
%...
这是一个更完整的例子,用于\chapter*
序言和\part
“所有关于东西”:
\documentclass{book}
\begin{document}
\tableofcontents
\setcounter{chapter}{16}% Equivalent to "letter P"
\renewcommand{\thechapter}{\Alph{chapter}}%
% Alternatively, replace the above two commands with
% \renewcommand{\thechapter}{P}
% as in Gonzalo's answer - it's just simpler.
%\chapter{Preface}
\chapter*{Preface}
\addcontentsline{toc}{chapter}{\numberline{P}Preface}
%...
\part{All about stuff}
%...
%\setcounter{chapter}{0}%
%\renewcommand{\thechapter}{\arabic{chapter}}%
\chapter{Stuff in itself}
%...
\end{document}
答案2
您可以简单地在本地重新定义章节计数器的表示,然后将计数器设置为常规章节的正确值。标题安全包可用于本地重新定义章节标题格式:
\documentclass{book}
\usepackage{titlesec}
\begin{document}
\tableofcontents
\begingroup
\renewcommand\thechapter{P}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{}{20pt}{\Huge}
\chapter{Preface}
\section{Preface Section One}
\section{Preface Section Two}
\endgroup
\part{First Part}
\addtocounter{chapter}{-1}
\chapter{First Regular Chapter}
\section{Regular Section One One}
\section{Regular Section One Two}
\end{document}