使用 tocbasic 删除部分的页码并定义页码前的空格

使用 tocbasic 删除部分的页码并定义页码前的空格
  1. 我想从目录中省略各部分的页码。

  2. ---( \mypagestyle) 和页码之间的间距不同,因为它们是右对齐的。间距应始终相同。

`

\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}

在此处输入图片描述

答案1

设置tocpagenumberformat更改(或吞噬)带有页码的框:

\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}

结果:

在此处输入图片描述

相关内容