使用 \setcounter{page} 来设置目录和重新编号的页面

使用 \setcounter{page} 来设置目录和重新编号的页面

在本文档中,我需要将第一章之前的所有部分都用罗马数字(i、ii、iii 等)编号,之后的部分用阿拉伯数字编号,从 1 开始。我遇到的问题是在目录中。页码正确地从 1 开始,但在目录中,它显示第一部分从第 4 页开始(目录中有 3 页)。换句话说,目录中的页码与实际打印在页面底部的页码不匹配。(下面的代码)

\begin{document}
\renewcommand{\thepage}{\roman{page}}
\tableofcontents
\pagebreak
\setcounter{page}{1}
\renewcommand{\thepage}{\arabic{page}}

答案1

如果你不使用hyperref,则应使用以下命令序列:

\pagenumbering{roman}
\tableofcontents
\clearpage
\pagenumbering{arabic}

根据您使用的文档类别,您还可以用\pagenumbering...\frontmatter代替\mainmatter。例如,book.cls定义:

\newcommand\frontmatter{%
    \cleardoublepage
  \@mainmatterfalse
  \pagenumbering{roman}}
\newcommand\mainmatter{%
    \cleardoublepage
  \@mainmattertrue
  \pagenumbering{arabic}}

为什么关于 的声明hyperref很重要?将页码重置为罗马/阿拉伯/其他格式不会更改 设置的页面锚点引用hyperref。因此,可能会设置重复的目标。

相关内容