The ToC of the book I am preparing needs additional formatting. I'm working in the KOMA-script scrbook
-class. The book contains a large number of lectures, which I treat as chapters, some of which end with a section called "Questions and answers". My issue is with the dots filling up the space in the ToC between chapter title and page number. With earlier help, and follow up help, and the answer I found here, the following is my MWE. What I am not satisfied with yet though, is the resulting misalignment of the dots in the ToC.
\DeclareTOCStyleEntry[
linefill={},
]{tocline}{chapter}
\makeatletter
\newcommand \Dotfill {\leavevmode \cleaders \hb@xt@ 0.83em{\hss .\hss }\hfill \kern \z@}
\makeatother
\newcommand{\toclineinsert}[3][14mm]{%
\Dotfill #2\makebox[#1][l]{#3\Dotfill}%
}
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\addchap
[tocentry={Second lecture title \toclineinsert{\normalfont{2nd half January}}},head={}]
{Second lecture title}
\lipsum[1-20]
\addsec[tocentry={Questions and answers},head={}]{}
There has got to be a better way than tweaking the em
-size of \hb@xt@
part the \Dotfill
command to get the dots in the ToC to match up.
Best Answer
With the KOMA-Script class
scrbook
the default line filling for section (and subsection etc.) entries in TOC is\TOCLineLeaderFill
. The distance between the dots depends on the size of the dots and the font. So you have to useThen the dots between the chapter title and the date are aligned with the dots after the section title.
But it is difficult to align the dots between the date and the page number with the dots of the section entries. Here is a suggestion that still needs adjustment depending on the font size and
\@dotfil
.But I would suggest to use either
or