GeneralRoman numbers in table of contents

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Isopropyl
Posts: 29
Joined: Thu Sep 24, 2009 10:49 pm

Roman numbers in table of contents

Post by Isopropyl »

Hi,

in formatting my table of contents I have the following problem. As per style guidelines of my university I am required to typeset the page numbers of the appendix using roman numbers. Unfortunately, roman numbers tend to get very large (e.g. LXXXVIII).

Using tocloft I therefore have to set:

Code: Select all

\cftsetpnumwidth{45pt}
\cftsetrmarg{65pt}
Which are pretty high values. This, however, causes the dots in the table of contents to end way before the arabic page numbers start (because they do not get so big and I have to reserve so much space for the roman numbers).

So, is there any way to make the dots in the table of contents run up all the way to each individual number?

Minimal Working Example:

Code: Select all

\documentclass[12pt, numbers=noenddot]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[babel, german=quotes]{csquotes}
\usepackage[T1]{fontenc}

\usepackage{tocloft}
\cftsetpnumwidth{70pt}
\cftsetrmarg{85pt}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}

\begin{document}

\tableofcontents

\clearpage

\section{Sec1}

\clearpage

\pagenumbering{Roman}
\setcounter{page}{88}
\section{Sec2}

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Isopropyl
Posts: 29
Joined: Thu Sep 24, 2009 10:49 pm

Roman numbers in table of contents

Post by Isopropyl »

Hi,

today I accidentally stumbled across the solution to the above problem while searching for something completely unrelated :lol:

One way to solve the roman numbers trouble appears to be to abolish the box around the page numbers like this:

Code: Select all

\makeatletter
	\renewcommand*\cftsecfillnum[1]{%
	\cftsecleader\nobreak%
	#1\cftsecafterpnum\par}

	\renewcommand*\cftsubsecfillnum[1]{%
	\cftsubsecleader\nobreak%
	#1\cftsubsecafterpnum\par}
	
	\renewcommand*\cftsubsubsecfillnum[1]{%
	\cftsubsubsecleader\nobreak%
	#1\cftsubsubsecafterpnum\par}
	
	\renewcommand*\cftparafillnum[1]{%
	\cftparaleader\nobreak%
	#1\cftparaafterpnum\par}
	
	\renewcommand*\cfttabfillnum[1]{%
	\cfttableader\nobreak%
	#1\cfttabafterpnum\par}
\makeatother

This will make the dots in the toc and lot run up all the way to the numbers.
Post Reply