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

lukascbossert
  • 3,015
  • 1
  • 16
  • 37

1 Answers1

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

esdd
  • 85,675
  • Brilliant. But how can I apply e.g. the indent to the starred versions of section, chapter etc.? – lukascbossert Feb 22 '18 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 '18 at 17:04
  • You are right: follow up question here: https://tex.stackexchange.com/questions/417074/how-to-indent-toc-entries-which-have-no-numbers-with-tocbasic thanks! – lukascbossert Feb 24 '18 at 21:28