1

Hey i have two problems with my table of contents: First I would like to reduce the vspace between chapters (or sections ...). The second problem is that long roman letters in appendix are too wide outside the frame of geometry.

I found the solution for each problems, but I can solve only one problem, not both together. Maybe the two packages make problems?

\documentclass[ngerman]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage{babel}
\newcounter{SeitenzahlSpeicher}

% Set long roman letters in geometry frame
\usepackage[tocindentauto]{tocstyle}
\usetocstyle{KOMAlike}
\settocstylefeature{pagenumberbox}{\hbox}

% Reducing vspace in toc
\usepackage{tocbasic}
\DeclareTOCStyleEntry[
beforeskip=.1em plus 1pt,
pagenumberformat=\textbf,
]{tocline}{chapter}

\usepackage{blindtext}

\begin{document}
\pagenumbering{Roman}
\tableofcontents
\chapter{Test}
\chapter{Test}
\chapter{Test}
\chapter{Test}
\setcounter{SeitenzahlSpeicher}{\value{page}}
\pagenumbering{arabic}
\chapter{Test}
\pagenumbering{Roman}
\setcounter{page}{\theSeitenzahlSpeicher}
\appendix
\chapter{Test}
\blindtext[50]
\chapter{Test}
\end{document}

Here with reducing space:

Reducing space

Here with roman letters in frame:

Roman letters in frame

When I add the solution from Pieter for section level, the dotlines are to short.

enter image description here

2 Answers 2

2

Note that the KOMA-Script class loads package tocbasic automatically. So you should remove \usepackage{tocbasic}.

You can use \mbox for the page numbers in TOC, LOT and LOF with

\DeclareTOCStyleEntries[
  pagenumberbox=\mbox
]{tocline}{
  part,chapter,
  section,subsection,subsubsection,
  paragraph,subparagraph,
  figure,table
}

Example:

\documentclass[ngerman]{scrreprt}% loads package tocbasic
\usepackage{blindtext}% only for dummy text
\usepackage[T1]{fontenc}
\usepackage{babel}

\DeclareTOCStyleEntry[
  beforeskip=.1em plus 1pt
]{tocline}{chapter}

\DeclareTOCStyleEntries[
  pagenumberbox=\mbox
]{tocline}{
  part,chapter,
  section,subsection,subsubsection,
  paragraph,subparagraph,
  figure,table
}

\begin{document}
\pagenumbering{Roman}
\tableofcontents
\chapter{Test}
\chapter{Test}
\chapter{Test}
\Blinddocument
\Blinddocument
\end{document}

enter image description here

2
  • I'd suggest \mbox rather than \hbox: properly documented command versus undocumented (in the LaTeX manuals) primitive.
    – egreg
    May 19, 2021 at 10:25
  • @egreg Thanks for the hint. I have changed the command.
    – esdd
    May 19, 2021 at 14:47
1

Forget about the tocstyle stuff, it is outdated, and it isn't even part of TeX Live. tocbasic can do it with the pagenumberwidth parameter. Just make it big enough that the Roman numbers fit in it.

\usepackage{tocbasic}
\DeclareTOCStyleEntry[
  beforeskip=.1em plus 1pt,
  pagenumberformat=\textbf,
  pagenumberwidth=2cm,
]{tocline}{chapter}

enter image description here

1
  • When I do this with the section level, too (because I have sections in appendix), The dotline goes not to the Roman letter. Maybe it ends 2cm before... Is there a way to change this? (I update my question with a picture) May 19, 2021 at 5:27

You must log in to answer this question.

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