Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How do I reduce the vertical space before a part title in the ToC?

Here is what I have that's related to headers and their ToC entries (I think):

\documentclass{article}

\usepackage{titletoc}

\makeatletter
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >\m@ne
       \Large\bfseries\hfil\partname~\thepart\hfil
       \par\nobreak
     \fi
     \huge\bfseries\sffamily\raggedleft #2%
     \markboth{}{}\par}%
    \nobreak
    \vskip 3ex
    \@afterheading}
\makeatother

\makeatletter
  \@addtoreset{section}{part}
  \@addtoreset{subsection}{section}
  \@addtoreset{subsubsection}{subsection}
\makeatother
\titlecontents{section}[1.8em]{}{\contentslabel{1.8em}}{\hspace*{0em}}{\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsection}[4.65em]{}{\contentslabel{2.85em}}{\hspace*{0em}}{\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsubsection}[8.35em]{}{\contentslabel{3.75em}}{\hspace*{0em}}{\titlerule*[1pc]{.}\contentspage}

\renewcommand*\thepart{\arabic{part}}
\renewcommand*\thesection{\thepart.\arabic{section}}


\begin{document}

\tableofcontents
\newpage

\part{sxsafawf}
\section{sasrvth}

\part{sxsafawf}
\section{sasrvth}

\end{document}

output

share|improve this question

3 Answers 3

up vote 5 down vote accepted

I think you are talking about \part and not \chapter.

Since you are redefining the \part command, it suffices to add the line

\addtocontents{toc}{\protect\vspace*{-15\p@}}

in the redefinition (adjust -15\p@ to your needs).

MWE:

\documentclass{article}

\usepackage{titletoc}

\makeatletter
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
      \addtocontents{toc}{\protect\vspace*{-15\p@}}% <------------ added
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addtocontents{toc}{\protect\vspace*{-15\p@}}% <------------ added
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >\m@ne
       \Large\bfseries\hfil\partname~\thepart\hfil
       \par\nobreak
     \fi
     \huge\bfseries\sffamily\raggedleft #2%
     \markboth{}{}\par}%
    \nobreak
    \vskip 3ex
    \@afterheading}
\makeatother

\makeatletter
  \@addtoreset{section}{part}
  \@addtoreset{subsection}{section}
  \@addtoreset{subsubsection}{subsection}
\makeatother
\titlecontents{section}[1.8em]{}{\contentslabel{1.8em}}{\hspace*{0em}}{\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsection}[4.65em]{}{\contentslabel{2.85em}}{\hspace*{0em}}{\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsubsection}[8.35em]{}{\contentslabel{3.75em}}{\hspace*{0em}}{\titlerule*[1pc]{.}\contentspage}

\renewcommand*\thepart{\arabic{part}}
\renewcommand*\thesection{\thepart.\arabic{section}}


\begin{document}

\tableofcontents
\newpage

\part{sxsafawf}
\section{sasrvth}

\part{sxsafawf}
\section{sasrvth}

\end{document} 

Output:

enter image description here

share|improve this answer

It suffices to also re-define the formatting of \part in the table of contents and give spacing parameters. By the way, writing

\@addtoreset{subsection}{section}
\@addtoreset{subsubsection}{subsection}

is useless — it is the default.

Here is a possibility:

\documentclass{article}

\usepackage{titletoc}

\makeatletter
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >\m@ne
       \Large\bfseries\hfil\partname~\thepart\hfil
       \par\nobreak
     \fi
     \huge\bfseries\sffamily\raggedleft #2%
     \markboth{}{}\par}%
    \nobreak
    \vskip 3ex
    \@afterheading}
\makeatother

\makeatletter
  \@addtoreset{section}{part}
  \@addtoreset{subsection}{section}
  \@addtoreset{subsubsection}{subsection}
\makeatother
\titlecontents{part}[0em]{\vspace{2ex}\bfseries}{\contentslabel{1.8em}}{\hspace*{0em}}{\titlerule*[1pc]{.}\contentspage}[\smallskip]
\titlecontents{section}[3.6em]{}{\contentslabel{1.8em}}{\hspace*{0em}}{\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsection}[4.65em]{}{\contentslabel{2.85em}}{\hspace*{0em}}{\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsubsection}[8.35em]{}{\contentslabel{3.75em}}{\hspace*{0em}}{\titlerule*[1pc]{.}\contentspage}

\renewcommand*\thepart{\arabic{part}}
\renewcommand*\thesection{\thepart.\arabic{section}}

\begin{document}

\tableofcontents
\newpage

\part{sxsafawf}
\section{sasrvth}

\section{another section}

\section{a third section}

\part{sxsafawf}
\section{sasrvth}

\end{document} 

enter image description here

share|improve this answer

If you don't want to specify \titlecontents{part} and are satisfied by the default typesetting by the article class, it's sufficient to patch the original \l@part command, which titletoc calls \ttl@savel@part:

\documentclass{article}

\usepackage{titletoc}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\ttl@savel@part}{2.25em}{1em}{}{} % <--- adjust to suit

\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >\m@ne
       \Large\bfseries\hfil\partname~\thepart\hfil
       \par\nobreak
     \fi
     \huge\bfseries\sffamily\raggedleft #2%
     \markboth{}{}\par}%
    \nobreak
    \vskip 3ex
    \@afterheading}
\makeatother

\makeatletter
  \@addtoreset{section}{part}
  \@addtoreset{subsection}{section}
  \@addtoreset{subsubsection}{subsection}
\makeatother
\titlecontents{section}[1.8em]{}{\contentslabel{1.8em}}{\hspace*{0em}}{\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsection}[4.65em]{}{\contentslabel{2.85em}}{\hspace*{0em}}{\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsubsection}[8.35em]{}{\contentslabel{3.75em}}{\hspace*{0em}}{\titlerule*[1pc]{.}\contentspage}

\renewcommand*\thepart{\arabic{part}}
\renewcommand*\thesection{\thepart.\arabic{section}}


\begin{document}

\tableofcontents
\newpage

\part{sxsafawf}
\section{sasrvth}

\part{sxsafawf}
\section{sasrvth}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.