[Tex/LaTex] How to use instead of tocstyle

tocstyle

I'm using tocstyle in my document:

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

Which gives me this warning:

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.

What should I use instead?

Best Answer

With a KOMA-Script class you should use tocbasic. Note that the KOMA-Script class loads tocbasic automatically.

Example:

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

Run three times to get:

enter image description here

With a standard class you can use package tocbasic.

Example:

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

Run three times to get:

enter image description here