I would like to add a line segment of specified length in the Table of Contents to separate two distinct portions. (I have search this site, but could only find an example to add a full-length horizontal line.)
I am surprised at my difficulty in accomplishing this because \rule{1.25in}{.15mm} works fine within the document itself. However, when I try to add the following, I get an error message:
\addcontentsline{toc}{\rule{1.25in}{.15mm}}
Consider the working example:
\documentclass[12pt]{book}
\usepackage{tocloft}
\renewcommand\cftchapafterpnum{\vskip 12pt} %set space after each Chapter in the Table of Contents
\renewcommand\cftsecafterpnum{\vskip 8pt} %set space after each Section in the Table of Contents
\renewcommand\cftsubsecafterpnum{\vskip 8pt} %set space after each Subsection in the Table of Contents
% Centering Table of Contents
\renewcommand{\cfttoctitlefont}{\hfill\Huge\bfseries}
\renewcommand{\cftaftertoctitle}{\hfill}
\begin{document}
\addtocontents{toc}{\protect\thispagestyle{empty}}
\tableofcontents
\addcontentsline{toc}{chapter}{Chapter 1}
\addcontentsline{toc}{chapter}{Chapter 2}
\addcontentsline{toc}{chapter}{Chapter 3}
\addtocontents{toc}{\vspace{\normalbaselineskip}}
%\addcontentsline{toc}{\rule{1.25in}{.15mm}}
\addtocontents{toc}{\vspace{\normalbaselineskip}}
\addcontentsline{toc}{chapter}{Next Part of the Table of Contents}
\end{document}
which produces the output
However, when I run the code with the \addcontentsline{toc}{\rule{1.25in}{.15mm}} command, I get the error message "Argument of \reserved@a has an extra }. \addtocontents".
And the following output results:
Again, I would like to add a horizontal line segment of specified length to the TOC---but everything I've tried so far has failed. Could someone please advise what I am doing wrong and how to correct it? Thank you.
\l@chapter
. Anyway, if you don't want the page number, use\addtocontents
.