2
  1. I would like to omit the page number of parts from the TOC.

  2. The space between --- (\mypagestyle) and the page number differs, since they are raggedright. The space should always be the same.

`

\documentclass[ngerman,twoside=false]{scrbook}
\def\mypagestyle{\,\mbox{---}\,}

\RedeclareSectionCommands[
  tocraggedpagenumber,
  toclinefill={\footnotesize\mypagestyle},
  tocindent=0em,
  tocnumwidth=4em,
]{chapter,section,subsection,subsubsection,paragraph}

\RedeclareSectionCommand[
   ,tocentryformat=\large\scshape%
   ,tocindent=0em
   ,tocnumwidth=4em
]{part}

\RedeclareSectionCommand[%
    ,tocentryformat=\textbf,%
]{chapter}
\begin{document}
  \tableofcontents
  \part{part}
  \chapter{chapter chapter}
  \section{section section section}  \section{section section section}  \section{section section section}
  \part{part}
  \chapter{chapter chapter}
  \section{section section section}  \section{section section section}  \section{section section section}
  \setcounter{page}{100}
  \part{part}
  \chapter{chapter chapter}
  \section{section section section}  \section{section section section}  \section{section section section}
\end{document}

enter image description here

1 Answer 1

3

Set tocpagenumberformat to change (or gobble) the boxes with the page numbers:

\documentclass[ngerman,twoside=false]{scrbook}

\newcommand\gobble[1]{}% <- added
\newcommand\tocpageseparator{\footnotesize\,\mbox{---}\,}
\newcommand\tocpagenumberbox[1]{\mbox{#1}}% <- added

\RedeclareSectionCommands[
  tocraggedpagenumber,
  toclinefill=\tocpageseparator,
  tocindent=0em,
  tocnumwidth=4em,
  tocpagenumberbox=\tocpagenumberbox% <- added
]{chapter,section,subsection,subsubsection,paragraph}

\RedeclareSectionCommand[
  tocentryformat=\large\scshape,
  tocindent=0em,
  tocnumwidth=4em,
  tocpagenumberbox=\gobble% <- added
]{part}

\RedeclareSectionCommand[%
  tocentryformat=\textbf%
]{chapter}
\begin{document}
  \tableofcontents
  \part{part}
  \chapter{chapter chapter}
  \section{section section section}  \section{section section section}  \section{section section section}
  \part{part}
  \chapter{chapter chapter}
  \section{section section section}  \section{section section section}  \section{section section section}
  \setcounter{page}{100}
  \part{part}
  \chapter{chapter chapter}
  \section{section section section}  \section{section section section}  \section{section section section}
\end{document}

Result:

enter image description here

3
  • Brilliant. But how can I apply e.g. the indent to the starred versions of section, chapter etc.? Feb 22, 2018 at 21:46
  • There are no starred sections etc. in your MWE and I do not understand which indent do you mean. By default there are no ToC entries for starred sections etc. Maybe you can ask a follow up question with a new MWE.
    – esdd
    Feb 24, 2018 at 17:04
  • You are right: follow up question here: tex.stackexchange.com/questions/417074/… thanks! Feb 24, 2018 at 21:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .