2

I have been using tocstyle until it was removed. Here is my definition

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

enter image description here

I have found this definition for tocbasic and changed the second line to \dotfill, but the dotted line is different to before

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

So the question is how to restore the dotted line with spacing as in the first example?

enter image description here

3
  • Just for clarification: you want the dots to be further apart?
    – Marijn
    Commented Aug 8, 2022 at 19:43
  • Something like \renewcommand*{\@dotsep}{4.5} ?
    – Ingmar
    Commented Aug 8, 2022 at 19:45
  • That changes the \dotfill for the whole document. I want a definition only for the section. How is the line defined in standard classes? Is there a command that can be used? Commented Aug 8, 2022 at 20:32

2 Answers 2

3

Package tocbasic provides \TOCLineLeaderFill for the dotted line between the entry text and the page number in TOC. So you could use

hfill=\TOCLineLeaderFill

But chapter entries without dots and other levels with dots are the default for book and report classes! Therefore you simple have to remove all your hfill settings to get the desired result.

Example:

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

enter image description here

If you do not use a KOMA-Script class, you have to load package tocbasic and have to declare that the section indent follows the chapter settings and the paragraph indent follows the indent and number width of subsubsection entries.

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

enter image description here

3

The defintion of the dotted line in the tocstyle package was:

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

I am unsure whether it is a good idea to take over the exact defintion from this outdated package, but if you really want the identical thing, you can store this definition in a macro and use this instead of \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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .