如何向目录添加自定义标题

如何向目录添加自定义标题

问题

我正在尝试将标题“目录 - 续”添加到目录第一页之后的每一页。我尝试过:

\addtocontents{toc}{\hfill TABLE OF CONTENTS -- CONTINUED \hfill ~ \newline\newline} 

在文档中,就在开始第 2 页的部分之前。它在 PDF 输出中成功,但在 .toc 中导致错误。给出以下消息:

Something's wrong--perhaps a missing \item. ...e {section}{\numberline {24}Section X}{26}

我该如何避免这种情况?我在工作示例中进行了一些自定义,这些自定义是论文提交所必需的格式。

工作示例

%Document Class
    \documentclass[12pt]{article}%12 Pt font, article document class
%List of Packages
    \usepackage{caption} %Flexibility in reported contents/table/figures titles
    \usepackage[left=1.5in, top=1.15in, bottom=1in, right=1in, headsep=12pt]{geometry}
    \usepackage{setspace}%single spacing, double spacing
    \usepackage{tocloft}%Custom Table of Contents   
%Formatting the Table of Contents
    \renewcommand*\contentsname{\normalsize{\normalfont{TABLE OF CONTENTS}}} %centers table of contents title and puts it in normal font
    \renewcommand{\cftsecfont}{\normalfont} %gets rid of bold font for section titles
    \renewcommand{\cftsecpagefont}{\normalfont} %gets rid of bold font for section page numbers
    \renewcommand{\cftsecaftersnum}{.} %Adds a period after section numbers in table of contents
    \renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} %adds dots between the chapters and page numbers
    \cftsetindents{subsection}{1.1em}{2.3em}% Lines up subsection directly below section, may need adjustment
    \cftsetindents{subsubsection}{3em}{2.3em}% Indents sub subsection to properly
    \renewcommand{\cftdotsep}{.5}   %Setting Dot ``density'' between Titles and Page Numbers for TOC

%\nofiles %The nofiles command uses forces LaTeX to use pre-existing TOC, LOT, and LOF documents. I can manually edit each.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% BEGIN DOCUMENT %%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\newpage
%TABLE OF CONTENTS PAGE
    \tableofcontents%Changes to the basic TOC format are done in the preamble; "TABLE OF CONTENTS --CONTINUED" added below
\newpage

\newcounter{counter}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
        \addtocontents{toc}{\hfill TABLE OF CONTENTS -- CONTINUED \hfill ~ \newline\newline} %HERE is the problem
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\stepcounter{counter}\newpage
\section{Section \Alph{counter}}
\end{document}

答案1

为什么不做点简单的事情呢?

\documentclass[12pt]{article}
\usepackage{tocloft,fancyhdr}
\newif\iftoccont
\renewcommand*\contentsname{Table of Contents}
\renewcommand*\cfttoctitlefont{\normalsize\normalfont\MakeUppercase}
\renewcommand\cftsecfont{\normalfont}
\renewcommand\cftsecpagefont{\normalfont}
\renewcommand\cftsecaftersnum{.}
\renewcommand\cftsecleader{\cftdotfill{\cftdotsep}}
\cftsetindents{subsection}{1.1em}{2.3em}
\cftsetindents{subsubsection}{3em}{2.3em}
\renewcommand\cftdotsep{.5}
\pagestyle{fancy}
\fancyhf{}
\fancyhf[ch]{\MakeUppercase{\contentsname{} --- continued}}
\fancyhf[cf]{\thepage}
\renewcommand\headrulewidth{0pt}

\begin{document}

  \tableofcontents
  \newpage\toccontfalse

  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
  \newpage
  \section{Section \Alph{section}}
\end{document}

简单的

相关内容