从 tocstyle 移至 tocbasic

从 tocstyle 移至 tocbasic

我一直在使用 tocstyle,直到它被删除。这是我的定义

\usepackage[%
%%% toc width calculation 
  tocindentauto,     % all widths at the TOCs are calculated by tocindentauto
%%% indentation of toc
  tocgraduated,      % standard
%%%  page breaking rules
  tocbreaksstrict,   % sets a lot of penalties before and after TOC entries 
                     % to avoid page break between a TOC entry and it's parent. 
%%%  indentation of unnumbered TOC entries
  toctextentriesleft,   % indented as if they have an empty number.
]{tocstyle}

在此处输入图片描述

我已经发现这是 tocbasic 的定义并将第二行改为 \dotfill,但虚线与之前不同

\DeclareTOCStyleEntries[
raggedentrytext,
linefill=\hfill,
numwidth=0pt,
numsep=1ex,
dynnumwidth
]{tocline}{chapter,section,subsection,subsubsection,paragraph,subparagraph}

\DeclareTOCStyleEntries[
linefill=\dotfill,
indent=0pt,
dynindent
]{tocline}{section,subsection,subsubsection,paragraph,subparagraph}

\setkomafont{chapterentry}{\bfseries}

那么问题是如何恢复像第一个例子中那样有间距的虚线?

在此处输入图片描述

答案1

软件包tocbasic提供了\TOCLineLeaderFill在目录中条目文本和页码之间的虚线。因此,您可以使用

hfill=\TOCLineLeaderFill

但是章节条目没有点,其他级别带点是bookreport类别的默认设置!因此,您只需删除所有hfill设置即可获得所需的结果。

例子:

\documentclass{scrbook}

\DeclareTOCStyleEntries[
  %raggedentrytext,
  numwidth=0pt,
  numsep=1ex,
  dynnumwidth
]{tocline}{chapter,figure,table}

\DeclareTOCStyleEntries[
  %raggedentrytext,
  numwidth=0pt,
  numsep=1ex,
  dynnumwidth,
  indent=0pt,
  dynindent,
]{tocline}{section,subsection,subsubsection,paragraph,subparagraph}

\setkomafont{chapterentry}{\bfseries}

\setcounter{tocdepth}{\subsubsectiontocdepth}

\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{Introduction}
\chapter{Theory}
\section{Section heading}
\subsection{Subsection heading}
\subsubsection{Subsubsection heading}
\end{document}

在此处输入图片描述

如果您不使用 KOMA-Script 类,则必须加载包tocbasic并声明section缩进遵循chapter设置并且paragraph缩进遵循条目的缩进和数字宽度subsubsection

\documentclass{book}

\usepackage{tocbasic}
\DeclareTOCStyleEntries[
  indentfollows={chapter,subsubsection}
]{tocline}{section,paragraph}

\DeclareTOCStyleEntries[
  %raggedentrytext,
  numwidth=0pt,
  numsep=1ex,
  dynnumwidth
]{tocline}{chapter,figure,table}

\DeclareTOCStyleEntries[
  %raggedentrytext,
  numwidth=0pt,
  numsep=1ex,
  dynnumwidth,
  indent=0pt,
  dynindent,
]{tocline}{section,subsection,subsubsection,paragraph,subparagraph}

\setcounter{tocdepth}{\subsubsectiontocdepth}

\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{Introduction}
\chapter{Theory}
\section{Section heading}
\subsection{Subsection heading}
\subsubsection{Subsubsection heading}
\end{document}

在此处输入图片描述

答案2

包中虚线的定义tocstyle是:

\leaders\hbox{$\m@th\mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}\hfill

我不确定从这个过时的包中接管确切的定义是否是个好主意,但如果你真的想要相同的东西,你可以将这个定义存储在宏中并使用它来代替\dotfill

\documentclass{scrbook}

\makeatletter
\def\mydotfill{\leaders\hbox{$\m@th\mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}\hfill}
\makeatother

\DeclareTOCStyleEntries[
raggedentrytext,
linefill=\hfill,
numwidth=0pt,
numsep=1ex,
dynnumwidth
]{tocline}{chapter,section,subsection,subsubsection,paragraph,subparagraph}

\DeclareTOCStyleEntries[
linefill=\mydotfill,
indent=0pt,
dynindent
]{tocline}{section,subsection,subsubsection,paragraph,subparagraph}

\setkomafont{chapterentry}{\bfseries}

\begin{document}

\tableofcontents

\chapter{One}
\section{Two}
\subsection{Three}

\end{document}

在此处输入图片描述

相关内容