GeneralAdd a new line after a Section in TOC

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
mgarruda
Posts: 5
Joined: Thu Mar 19, 2009 5:18 am

Add a new line after a Section in TOC

Post by mgarruda »

I'm using the tocloft package to format my TOC, change its title, and add Sections to the TOC for the article class. What I want to add is a blank line after a Section entry in the TOC. The commented part of the included code does indeed give me a blank line. However, it also indents the page number to the left.

Code: Select all

\renewcommand{\contentsname}{\begin{center}\normalsize{\mdseries{TABLE OF CONTENTS}}\end{center}}
\renewcommand{\cftaftertoctitle}{\mbox{}Chapter\hfill{\normalfont Page}}
\renewcommand{\cftsecfont}{\mdseries}
\renewcommand{\cftsecpagefont}{\mdseries}
\renewcommand{\cftsecleader}{\mdseries\cftdotfill{\cftdotsep}}

%\renewcommand{\cftsecafterpnum}{\\}
I would like to be able to add this blank line without having to add:

Code: Select all

\addtocontents{toc}{\protect\mbox{}\protect}

after each \section{...} command.

While the tocloft package offers a \cftbeforesecskip, there is no \cftaftersecskip, which would suit my purposes.

Any help will be appreciated. Thank you.

-Michael

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Add a new line after a Section in TOC

Post by gmedina »

Hi,
mgarruda wrote:...The commented part of the included code does indeed give me a blank line. However, it also indents the page number to the left...
That's not the only undesired side effect; with that line of code uncommented you will also get some badboxes.

Instead of

Code: Select all

\renewcommand{\cftsecafterpnum}{\\}
use

Code: Select all

\renewcommand{\cftsecafterpnum}{\vspace*{\baselineskip}}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
mgarruda
Posts: 5
Joined: Thu Mar 19, 2009 5:18 am

Add a new line after a Section in TOC

Post by mgarruda »

Thanks for the answer, that worked great!

Now, another question. My TOC runs over two pages, and on the second page, I need the exact same title and after title text as on the first page. I'm having trouble forcing it to happen by using the \addtocontents command. The current code is an attempt to force feed LaTeX the right answer.

Code: Select all

\addtocontents{toc}{\protect\newpage}
%\addtocontents{toc}{\contentsname}
\addtocontents{toc}{\protect\makebox[6.5in][c]{TABLE OF CONTENTS (continued)}\protect}
\addtocontents{toc}{\protect\newline}
\addtocontents{toc}{\protect\newline}
\addtocontents{toc}{\protect\newline}
\addtocontents{toc}{\protect\makebox[6.5in][c]{Chapter\hfill{\normalfont Page}}\protect}
\addtocontents{toc}{\protect\newline}
\addtocontents{toc}{\protect\newline}
The "Chapter\hfill{\normalfont Page}" was used in the preamble in the following command:

Code: Select all

\renewcommand{\cftaftertoctitle}{\vspace*{\baselineskip}\mbox{}Chapter\hfill{\normalfont Page}}
Now, this would work, but the text boxes start not at the left margin, but at the point where a section heading starts in the TOC.

Thanks again, any help is greatly appreciated!

-Michael
mgarruda
Posts: 5
Joined: Thu Mar 19, 2009 5:18 am

Add a new line after a Section in TOC

Post by mgarruda »

I stumbled across a possible solution. Added some backspace indentation and resized the text boxes to fit.

Code: Select all

\addtocontents{toc}{\protect\newpage}
\addtocontents{toc}{\protect\makebox[6.5in][c]{\hspace{-0.5in}TABLE OF CONTENTS (continued)}\protect}
\addtocontents{toc}{\protect\newline}
\addtocontents{toc}{\protect\newline}
\addtocontents{toc}{\protect\newline}
\addtocontents{toc}{\protect\makebox[6.0in][c]{\hspace{-0.5in}Chapter\hfill{\normalfont Page}}\protect}
\addtocontents{toc}{\protect\newline}
\addtocontents{toc}{\protect\newline}
-Michael
Post Reply