4

I'm trying to control the vertical spacing of my table contents title, however I'm getting into overflow issues because I'm loading both tocloft and titletoc. I found a similar case, but just removing tocloft just won't do as I need to remove the spacing between the title and the entries.

custom TOC text overflow

Overflow!

Here's a MWE:

\documentclass[12pt]{report}

    \usepackage{tabto}

    \usepackage{tocloft}
        \setlength\cftaftertoctitleskip{0pt}

    \usepackage{titletoc}
        \titlecontents{chapter}% <section-type>
            [0pt]% <left>
            {\vspace{1em}}% <above-code>
            {\MakeUppercase \chaptername\ \thecontentslabel \tabto{1.25in} \MakeUppercase}% <numbered-entry-format>
            {}% <numberless-entry-format>
            {\titlerule*[5pt]{.}\contentspage}% <filler-page-format>

        \titlecontents{section}% <section-type>
            [0pt]% <left>
            {\vspace{0.5em}}% <above-code>
            {\tabto{0.5in} \thecontentslabel \tabto{1.25in}}% <numbered-entry-format>
            {}% <numberless-entry-format>
            {\titlerule*[5pt]{.}\contentspage}% <filler-page-format>

        \titlecontents{subsection}% <section-type>
            [0pt]% <left>
            {}% <above-code>
            {\tabto{1.25in} \thecontentslabel \tabto{2.0in}}% <numbered-entry-format>
            {}% <numberless-entry-format>
            {\titlerule*[5pt]{.}\contentspage}% <filler-page-format>

\begin{document}
    \tableofcontents

    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
\end{document}
0

1 Answer 1

1

Instead of using tocloft, you can patch the \tableofcontents command to insert some negative vertical spacing after the heading as follows:

\usepackage{etoolbox}
\patchcmd{\tableofcontents}{\@starttoc}{\vspace{-1cm}\@starttoc}{}{}

This reduces the space by 1cm. The removal of the tocloft package, means that the overflow problem disappears.

Sample output

\documentclass[12pt]{report}

    \usepackage{tabto}

    \usepackage{titletoc}
        \titlecontents{chapter}% <section-type>
            [0pt]% <left>
            {\vspace{1em}}% <above-code>
            {\MakeUppercase \chaptername\ \thecontentslabel \tabto{1.25in} \MakeUppercase}% <numbered-entry-format>
            {}% <numberless-entry-format>
            {\titlerule*[5pt]{.}\contentspage}% <filler-page-format>

        \titlecontents{section}% <section-type>
            [0pt]% <left>
            {\vspace{0.5em}}% <above-code>
            {\tabto{0.5in} \thecontentslabel \tabto{1.25in}}% <numbered-entry-format>
            {}% <numberless-entry-format>
            {\titlerule*[5pt]{.}\contentspage}% <filler-page-format>

        \titlecontents{subsection}% <section-type>
            [0pt]% <left>
            {}% <above-code>
            {\tabto{1.25in} \thecontentslabel \tabto{2.0in}}% <numbered-entry-format>
            {}% <numberless-entry-format>
            {\titlerule*[5pt]{.}\contentspage}% <filler-page-format>

\usepackage{etoolbox}
\patchcmd{\tableofcontents}{\@starttoc}{\vspace{-1cm}\@starttoc}{}{}

\begin{document}


    \tableofcontents

    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
    \chapter{A Chapter}
        \section{A Section}
            \subsection{A Sub-Section}
\end{document}
1
  • Awesome, this is better than the workaround I came up with. I was just testing the addition of \addtocontents{toc}{\vspace{-3em}} at the beginning of the document. Thank you for your solution.
    – RTN3000
    Mar 8, 2016 at 19:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .