[Tex/LaTex] Table of Contents: Titles for Parts with \tocloft

table of contentstocloft

I use the tocloft package to design the Table of Contents. I wanted to add the word Part before the numbers of parts in TOC (f.e. using \cftpartpresnum), but I want to add it only for numbered parts. For example I want to have:

Intro ..... 1
Part I Lalala ...2
Part II Lalalala...4
Conclusion ....6

Is it possible? \cftpartpresnum adds to all parts.

Best Answer

Probably not the most elegant way: Add appropriate redefinitions of \cftpartpresnum to the .toc file using the \addtocontents macro. (Note: I'm using the tocvsec2 package to add unnumbered parts to the ToC.)

\documentclass{book}

\usepackage{tocloft}
\usepackage{tocvsec2}

\begin{document}

\setsecnumdepth{none}
\addtocontents{toc}{\protect\renewcommand{\protect\cftpartpresnum}{}}

\tableofcontents

\part{Intro}

\resetsecnumdepth
\addtocontents{toc}{\protect\renewcommand{\protect\cftpartpresnum}{\partname~}}

\part{First part}

\part{Second part}

\setsecnumdepth{none}
\addtocontents{toc}{\protect\renewcommand{\protect\cftpartpresnum}{}}

\part{Conclusion}

\end{document}