[Tex/LaTex] remove leading “part” number in toc with titletoc

partstable of contentstitletoc

Is there a way to display part names, but not numbers in ToC with titletoc?

simply removing \thecontentslabel seems easy enough for chapter, section etc, but not part.

Background: I used the starred variant (\part*{foo}) but as I also would like some parts to have a line break in the document and be on the same line in ToC and page header, I would need the optional argument, which doesn't work with the starred variant (see this question for the reasons).

\documentclass[12pt,a4paper,oneside]{scrbook}

\usepackage{titlesec}
\titleformat{\part}[display]{}{}{1em}{\sffamily\huge}

\usepackage{titletoc}
\titlecontents{part}[0em]
    {\vspace{2em}\large\bfseries\sffamily}
    {}{}{}

\begin{document}

\tableofcontents

\part{Introduction}
    Bla

\part[Example 1: Foo]{Example 1:\\Foo}
    Bla

\part[Example 2: Bar]{Example 2:\\Bar}
    Bla

\part{Appendix}
    Bla

\end{document}

Best Answer

You don't have to use the starred version if you want no part label to appear in the toc. With the newlinetospace option, it is needless to use the optional argument to remove a line break in titles: it is automatically converted to a horizontal space in table of contents and headers.

\documentclass[12pt,a4paper,oneside]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

\usepackage[newlinetospace, newparttoc]{titlesec}

\titleformat{\part}[display]{}{}{1em}{\sffamily\huge}

\usepackage{titletoc}
\titlecontents{part}[0em]
    {\vspace{2em}\large\bfseries\sffamily\relax}
    {\contentslabel[\relax]{0em}}{}{\hfill\contentspage}

\begin{document}

\tableofcontents

\part{Introduction}
    Bla

\part{Example 1:\\Foo}%
    Bla

\part{Example 2:\\Bar}%[
    Bla

\part{Appendix}
    Bla

\end{document} 

enter image description here

Related Question