我应该用什么来代替 tocstyle?

我应该用什么来代替 tocstyle?

tocstyle在我的文档中使用:

% table of contents customizations:
\usepackage{tocstyle}
\usetocstyle{standard}
\settocfeature{raggedhook}{\raggedright}
\settocfeature{leaders}{\hfill}

这给了我这个警告:

Writing index file book.idx
(/usr/local/texlive/2020/texmf-dist/tex/latex/koma-script/tocstyle.sty

Package tocstyle Warning: THIS IS A DEPRECATED ALPHA VERSION!
(tocstyle)                USAGE OF THIS VERSION IS ON YOUR OWN RISK!
(tocstyle)                EVERYTHING MAY HAPPEN!
(tocstyle)                THE PACKAGE IS FROZEN WITH ALL IT'S BUGS!
(tocstyle)                IT WILL BE REMOVED FROM KOMA-SCRIPT SOON!
(tocstyle)                THERE IS NO SUPPORT, IF YOU USE THIS PACKAGE!
(tocstyle)                Maybe it would be better, not to load this package.

我应该用什么来代替?

答案1

KOMA-Script 类您应该使用tocbasic。请注意,KOMA-Script 类会tocbasic自动加载。

例子:

\documentclass{scrreprt}[2020/07/22]% needs KOMA-Script version 3.31
\usepackage{blindtext}% only for dummy text

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

\begin{document}
\tableofcontents
\blinddocument
\blinddocument
\section{\blindtext}
\end{document}

运行三次得到:

在此处输入图片描述

标准班您可以使用包tocbasic

例子:

\documentclass{report}
\usepackage{blindtext}% only for dummy text

\usepackage{tocbasic}[2020/07/22]% needs KOMA-Script version 3.31
\DeclareTOCStyleEntries[
  raggedentrytext,
  linefill=\hfill,
  numwidth=0pt,
  numsep=1ex,
  dynnumwidth
]{tocline}{chapter,section,subsection,subsubsection,paragraph,subparagraph}
\DeclareTOCStyleEntries[
  indent=0pt,
  dynindent
]{tocline}{section,subsection,subsubsection,paragraph,subparagraph}
\DeclareTOCStyleEntry[indentfollows=chapter]{tocline}{section}
\DeclareTOCStyleEntry[indentfollows=subsubsection]{tocline}{paragraph}

\begin{document}
\tableofcontents
\blinddocument
\blinddocument
\section{\blindtext}
\end{document}

运行三次得到:

在此处输入图片描述

相关内容