目录中的页码

目录中的页码

我正在写一份大型报告,但目录中的页码编号出现了小问题。

MWE:(抱歉,章节太多了,这是为了确保目录有两页)

\documentclass[11pt,a4paper,openright,twoside]{report}

% Fixing the appearance of the footer in the empty pages in between chapters.
\let\origdoublepage\cleardoublepage
\newcommand{\clearemptydoublepage}{%
  \clearpage
  {\pagestyle{empty}\origdoublepage}%
}
\let\cleardoublepage\clearemptydoublepage
% Finished fixing appearance

\begin{document}

\begin{titlepage}
This is the title page
\mbox{}
\end{titlepage}

\cleardoublepage
\pagenumbering{roman} % Yay, roman numbering (i, ii, iii, iv) for the abstract and table of contents.
\begin{center}
\subsection*{Abstract}
\end{center}
Abstract text

\cleardoublepage
\tableofcontents

\chapter{First chapter}
\pagenumbering{arabic} % And moving back to arabic numbering (1,2,3,4) for the body.
\setcounter{page}{1}   % Starting the page numbering at 1 again.
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Second chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Third chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Fourth chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Fifth chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Sixth chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Seventh chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Eight chapter}
\section{First section}
\section{Second section}
\section{Third section}
\end{document}

我希望标题页、摘要和目录第一页以及每个章节的第一页都位于右侧页面。这样就行了。摘要很好地用 i 表示页码。但是,我希望目录第一页的页码为 ii,而不是现在的 iii(目录第二页应为 iii)。我尝试添加

\setcounter{page}{2}

紧接在 之前 或 之后\tableofcontents,但不起作用。紧接在 之前 会产生一个额外的不需要的空白页(并且目录从 iii 开始),而紧接在 之后 会将目录的第二页设置为页码 ii,而第一页仍保留在 iii。

关于如何让我的目录从这里的第 ii 页开始,有什么建议吗?

答案1

我认为这不是一个好主意,但我知道有些机构有疯狂的要求。

如果您只需要简单的小写罗马数字,这很简单。请参阅代码中的注释。

我还为获取“真正空白的页面”的问题添加了一个更简单的解决方案:加载包emptypage。此外,\pagenumbering{arabic}应该发出第一章。

\documentclass[11pt,a4paper,openright,twoside]{report}

\usepackage{emptypage}

\begin{document}

\begin{titlepage}
This is the title page
\mbox{}
\end{titlepage}

\cleardoublepage
\pagenumbering{roman} 

\begin{center}
\large\bfseries Abstract
\end{center}

Abstract text

\cleardoublepage
% Let's change \thepage so it prints one less than
% the real page number; \pagenumbering{arabic}
% will redefine it to the right meaning afterwards.
\renewcommand\thepage{\romannumeral\numexpr\value{page}-1\relax}

\tableofcontents

\cleardoublepage
\pagenumbering{arabic}
\chapter{First chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Second chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Third chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Fourth chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Fifth chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Sixth chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Seventh chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Eight chapter}
\section{First section}
\section{Second section}
\section{Third section}
\end{document}

答案2

它比乍一看的要复杂得多……

首先,去掉openright加载文档类时的选项,然后加载包etoolbox

\setcounter{page}{2}然后在 之前插入\tableofcontents

此时在第一章之后插入以下几行:

\patchcmd{\chapter}
  {\clearpage}
  {\cleardoublepage}
  {}
  {}

请注意,\setcounter{page}{1}after\pagenumbering{arabic}不是必需的,\cleardoublepage可以用简单的方式重新定义:

\let\origdoublepage\cleardoublepage
\renewcommand{\cleardoublepage}{%
  \clearpage
  {\pagestyle{empty}\origdoublepage}%
}

梅威瑟:

\documentclass[11pt,a4paper,twoside]{report}
\usepackage{etoolbox}

% Fixing the appearance of the footer in the empty pages in between chapters.
\let\origdoublepage\cleardoublepage
\renewcommand{\cleardoublepage}{%
  \clearpage
  {\pagestyle{empty}\origdoublepage}%
}
% Finished fixing appearance

\begin{document}

\begin{titlepage}
This is the title page
\mbox{}
\end{titlepage}

\cleardoublepage
\pagenumbering{roman} % Yay, roman numbering (i, ii, iii, iv) for the abstract and table of contents.
\begin{center}
\subsection*{Abstract}
\end{center}
Abstract text

\cleardoublepage
\setcounter{page}{2}
\tableofcontents

\chapter{First chapter}
\pagenumbering{arabic} % And moving back to arabic numbering (1,2,3,4) for the body.
\patchcmd{\chapter}
  {\clearpage}
  {\cleardoublepage}
  {}
  {}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Second chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Third chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Fourth chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Fifth chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Sixth chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Seventh chapter}
\section{First section}
\section{Second section}
\section{Third section}

\chapter{Eight chapter}
\section{First section}
\section{Second section}
\section{Third section}
\end{document}  

输出:

在此处输入图片描述

相关内容