目录中的页码错误

目录中的页码错误

我正在准备我的论文报告。我的目录从罗马页码 (iii) 开始,总共有 3 页。但不幸的是,目录的最后一页再次显示页码 (iii)。lof (3 页) 的情况也是如此。我正在使用\documentclass[a4paper,12pt]{report}。我是 LaTeX 的初学者,所以请帮助我。

\documentclass[a4paper,12pt]{report}

\setcounter{tocdepth}{3}
\addcontentsline{toc}{chapter}{Contents}
\tableofcontents
\pagenumbering{roman}\setcounter{page}{3}
\clearpage

\addcontentsline{toc}{chapter}{Summary}
\pagenumbering{roman}
\setcounter{page}{6}    
\chapter*{Summary}    
\clearpage

\listoffigures
\pagestyle{plain}
\pagenumbering{roman}
\setcounter{page}{7}
\addcontentsline{toc}{chapter}{\listfigurename}
\clearpage

\listoftables
\pagenumbering{roman}
\setcounter{page}{10}
\addcontentsline{toc}{chapter}{\listtablename}
\clearpage

答案1

您不应该给出重复的\pagenumbering{roman}命令:LaTeX 只知道页码。

请注意在正确的时间发出\addcontentsline命令,即在新页面开始之后。

\documentclass[a4paper,12pt]{report}

\setcounter{tocdepth}{3}

\begin{document}

\cleardoublepage % if some contents comes before
\pagenumbering{roman}\setcounter{page}{3}
\addcontentsline{toc}{chapter}{Contents}
\tableofcontents

\cleardoublepage

\addcontentsline{toc}{chapter}{Summary}
\chapter*{Summary}    

\cleardoublepage

\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures

\cleardoublepage

\addcontentsline{toc}{chapter}{\listtablename}
\listoftables

\cleardoublepage

\pagenumbering{arabic}

\def\one{%
  \chapter{Something}
  \section{A}
  some text
  \section{A}
  some text
  \begin{figure}
  \caption{Whatever}
  \end{figure}
  \section{A}
  some text
  \begin{table}
  \caption{Whatever}
  \end{table}
}
\def\many{\one\one\one\one\one\one\one\one\one\one\one\one\one\one\one}

\many % make as much contents as to produce three pages in the toc

\end{document}

tocbibind您可以使用包和类大大简化输入book

\documentclass[a4paper,12pt,oneside]{book}
\usepackage{tocbibind}

\setcounter{tocdepth}{3}
\pagestyle{plain} % this is what report uses

\begin{document}

\frontmatter
\setcounter{page}{3}

\tableofcontents

\chapter{Summary}    

\listoffigures

\listoftables

\mainmatter

\def\one{%
  \chapter{Something}
  \section{A}
  some text
  \section{A}
  some text
  \begin{figure}
  \caption{Whatever}
  \end{figure}
  \section{A}
  some text
  \begin{table}
  \caption{Whatever}
  \end{table}
}
\def\many{\one\one\one\one\one\one\one\one\one\one\one\one\one\one\one}

\many

\end{document}

在此处输入图片描述

答案2

找到解决方案了!我按照以下顺序重新排列了这些行:

\setcounter{tocdepth}{3}
\addcontentsline{toc}{chapter}{Contents}
\pagenumbering{roman}\setcounter{page}{3}
\tableofcontents

相关内容