2

Since accepting Jasper Habicht's working answer to my earlier question, I have switched from standard book-class to KOMA-script's scrbook. I still need to add a specific column to my ToC, and the following MWE is a book-class solution that unfortunately no longer works for me in the KOMA-script environment:

\documentclass{book}
\usepackage[utf8]{inputenc}

\newcommand{\toclineinsert}[3][25mm]{% \dotfill\ #2\makebox[#1][l]{#3\dotfill}% }

\title{test} \author{name} \date{now}

\begin{document}

\tableofcontents

\addcontentsline{toc}{chapter}{first lecture title \toclineinsert{4 }{January}}

\addcontentsline{toc}{chapter}{second lecture title \toclineinsert{2nd half }{January}}

\addcontentsline{toc}{chapter}{third lecture title \toclineinsert{February/}{March}}

\addcontentsline{toc}{chapter}{a pretty long fourth lecture title \newline that goes over two lines \toclineinsert{29 or 30 }{March}}

\end{document}

Table of Contents

How can achieve the same (or similar) in the scrbook class?

Parvana
  • 97

1 Answers1

3

Add

\DeclareTOCStyleEntry[
  linefill={},% default for chapter is linefill=\hfill
]{tocline}{chapter}

to the preamble.

Example:

\documentclass{scrbook}

\DeclareTOCStyleEntry[ linefill={}, ]{tocline}{chapter}

\newcommand{\toclineinsert}[3][25mm]{% \dotfill \ #2\makebox[#1][l]{#3\dotfill}% }

\begin{document} \tableofcontents

\addxcontentsline{toc}{chapter}{first lecture title \toclineinsert{4 }{January}} \addxcontentsline{toc}{chapter}{second lecture title \toclineinsert{2nd half }{January}} \addxcontentsline{toc}{chapter}{third lecture title \toclineinsert{February/}{March}} \addxcontentsline{toc}{chapter}{a pretty long fourth lecture title \newline that goes over two lines \toclineinsert{29 or 30 }{March}} \end{document}

enter image description here


Maybe you want to use \addchap with its optional argument. Then you can set class option headings=optiontotocandhead to activate the advanced functionality of the optional argument of the sectioning commands.

\documentclass[headings=optiontotocandhead]{scrbook}
\usepackage{lipsum}% only for dummy text

\DeclareTOCStyleEntry[ linefill={}, ]{tocline}{chapter}

\newcommand{\toclineinsert}[3][25mm]{% \dotfill \ #2\makebox[#1][l]{#3\dotfill}% }

\begin{document} \tableofcontents

\addchap [tocentry={first lecture title \toclineinsert{4 }{January}}] {first lecture title} \lipsum[1-20]

\addchap [tocentry={second lecture title \toclineinsert{2nd half }{January}},head={different entry in page header}] {second lecture title} \lipsum[1-20]

\addchap [tocentry={third lecture title \toclineinsert{February/}{March}}] {third lecture title} \addchap [tocentry={a pretty long fourth lecture title \newline that goes over two lines \toclineinsert{29 or 30 }{March}}] {a pretty long fourth lecture title that goes over two lines} \end{document}

esdd
  • 85,675