0

I'm preparing a document and want to remove space (except for maybe a \qquad) and dotted lines between the entries in my table of contents and the page numbers. would like my table of contents to go from looking like this:

enter image description here

to this:

enter image description here

It's only because I chose chapter and section titles poorly that the numbers are lined up; ideally, they'd be a constant distance from the end of the chapter/section title, rather than vertically aligned with each other.

This is very similar but not quite the same task as some other questions here, and I feel certain that a sufficiently competent TeXer could use those answers, and the information in the titletoc package to do this, but I just don't understand it.

My file is as follows:

\documentclass[letterpaper,10pt,twocolumn]{scrreprt}

\KOMAoption{DIV}{calc}

\begin{document}

\tableofcontents

\chapter{A}

\section{A1}

\chapter{B}

\section{B1}

\end{document}

Ideally I (and you) wouldn't have to recreate the Koma-Script table of contents style from scratch, but could instead just modify this value. Also ideally this answer would be portable to documents on other paper sizes and classes -- but I started with scrreprt, because that's what I'm actually working with. Thank you in advance!

1 Answer 1

1

This should work in Koma and standard classes:

\documentclass[letterpaper,10pt,twocolumn]{book}
\usepackage{tocloft} 
\renewcommand\cftchapleader{\qquad}
\renewcommand\cftsecleader{\qquad}
\renewcommand\cftsubsecleader{\qquad}
\begin{document}
\tableofcontents
\chapter{A}
\section{A1}
\chapter{B}
\section{B1}
\subsection{B11}
\end{document}

mwe

3
  • There's a bug, I'm afraid... Try it with a multiple-word section or chapter title, and you'll see that it goes haywire, stretching the spaces between words out madly
    – Canyon
    Jul 14, 2023 at 5:35
  • Yes, because still want to fill the line and these spaces are now the only stretchable places. Surely there is a better solution, but one obvious solution is avoid completely the stretchable spaces in the toc titles, e.g.: \chapter[\mbox{foo bar}]{foo bar}
    – Fran
    Jul 14, 2023 at 6:18
  • In case of the multiline titles in the ToC (always ugly), also could work a \parbox, e.g.:work \chapter[\parbox{3cm}{foo foo foo foo foo foo foo}]{foo ...}
    – Fran
    Jul 14, 2023 at 6:27

You must log in to answer this question.

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