3

I generate the following TOC with the code below. Is there a way to not include "Part" before the non numbered part entry?

enter image description here

\documentclass[a4paper, 12pt]{report}

\setcounter{tocdepth}{1}
\usepackage[titles]{tocloft}

\renewcommand{\thepart}{\Roman{part} :}
\renewcommand\cftpartpresnum{Part~}

\begin{document}

\tableofcontents

\cleardoublepage
\addcontentsline{toc}{part}{Non Numbered part}
\part*{Non Numbered part}

\part{Numbered part}
\chapter{Chap 1}

\part{Numbered part}

\chapter{Chap 1}
\chapter{Chap 2}

\end{document}
1

Here is a solution that redefine \cftpartpresnum locally to be empty.

\documentclass[a4paper, 12pt]{report}

\setcounter{tocdepth}{1}
\usepackage[titles]{tocloft}

\renewcommand{\thepart}{\Roman{part} :}
\renewcommand\cftpartpresnum{Part~}

\newcommand{\addparttoc}[1]{%
\addtocontents{toc}{\begingroup\def\protect\cftpartpresnum{}}
\addcontentsline{toc}{part}{#1}
\addtocontents{toc}{\endgroup}}



\begin{document}


\tableofcontents

\cleardoublepage
\addparttoc{Non Numbered part}

\part*{Non Numbered part}

\part{Numbered part}
\chapter{Chap 1}

\part{Numbered part}

\chapter{Chap 1}
\chapter{Chap 2}


\end{document}

enter image description here

1

An abbreviated version of your MWE effectively does what you want (after you have corrected any of my typos).

\documentclass{report}
\usepackage[titles]{tocloft}
\renewcommand{\thepart}{\Roman{part} :}
\begin{document}
\tableofcontents

\addcontentsline{toc}{part}{Unnumbered}
\part*{Unnumbered}

\addtocontents{toc}{%
  \protect\renewcommand{\protect\cftpartpresnum}{Part~}}
\part{Numbered Part}

\part{Second numbered part}

\end{document}

Using the default ToC entry style does not print PART which you don't want your Unnumbered part. For numbered parts you have to insert the Part~ change into the ToC file itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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