Menu

HowTo_TocPartPrefix

How to prepend a "Part" to the number of part entries in the table of contents

In principle, this is just a variant of the question: How to prepend a “Chapter” to the number of chapter entries in the table of contents. However, there are a few simplifications. As the entries below \part—whether chapter entries in scrbook or scrreprt or section entries in scrartcl—are not indented, their indentation does not have to be adapted to the changes in the part entries. So a all should be done with:

\renewcommand*{\addparttocentry}[2]{%
  \IfArgIsEmpty{#1}{% no number:
    \addtocentrydefault{part}{#1}{#2}% same as before the change
  }{% with number:
    \addtocentrydefault{part}{\partname\ #1}{#2}% prepend the number
  }%
}
\DeclareTOCStyleEntry[dynnumwidth]{tocline}{part}

The alternative is even simpler, where formatting is done completely via \DeclareTOCStyleEntry and unnumbered entries are also given a prefix:

\newcommand*{\entrynumberwithprefix}[2]{#1\ #2}
\DeclareTOCStyleEntry[%
  dynnumwidth,
  entrynumberformat=\entrynumberwithprefix{\partname}%
]{tocline}{part}

Incidentally, this does not work with the standard classes because the \part entries in the standard classes do not use \numberline and there is no \addparttocentry.


Related

Wiki (English): HowTo_ToCConfiguration
Wiki (English): HowTo_TocChapterPrefix

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.