# Roman numerals become “too wide” in table of contents

Following minimal document:

\documentclass{report}

\begin{document}
\renewcommand*\thechapter{\Roman{chapter}}
\tableofcontents
\setcounter{chapter}{6} % Problem starts at chapter 7
\chapter{Seven}
\chapter{Eight}
\section{Eight-one}
\section{Eight-two}
\end{document}


yields this output (cut to size for your convenience):

Clearly, the chapter (and section) headings hang into the chapter (section) numbers. For the previous chapter numbers, this isn’t a problem since all chapter titles are aligned to the same column and the numbers I–VI are sufficiently narrow.

(The same happens regardless of document type, I’m actually using scrreprt with the same result.)

How can I prevent this?

-
For which class do you need a fix? A solution for scrreprt may be easier. A solution for report doesn't necessarily have to be the best for scrreprt. –  Stefan Kottwitz Dec 19 '10 at 17:38
@Stefan: someone once told me to always use standard classes for MWEs. I’m actually using screprt. I didn’t find a solution in the KOMA documentation, though. –  Konrad Rudolph Dec 19 '10 at 18:02
if the problem is not depending on class features, a standard class MWE is fine. Here I just prefer a tiny class adjustment over a general package which is 1110 lines long and replaces many class macros, besides the TOC also for lists of tables and contents. –  Stefan Kottwitz Dec 19 '10 at 18:21

You could also use the tocstyle package, part of KOMA-script:

\documentclass[pagesize]{scrreprt}
\usepackage[tocindentauto]{tocstyle}
\usetocstyle{KOMAlike} %the previous line resets it
\begin{document}
\renewcommand*{\thechapter}{\Roman{chapter}}
\tableofcontents
\setcounter{chapter}{6} % Problem starts at chapter 7
\chapter{Seven}
\chapter{Eight}
\section{Eight-one}
\section{Eight-two}
\end{document}


(compile twice)

-
Of all the solutions here, this one probably plays nicest with KOMA. Oddly enough, it also resets the TOC style to “normal” so that the style explicitly needs to be reset to KOMA-like. –  Konrad Rudolph Dec 19 '10 at 19:11

tocloft works fine with standard classes. If I use KOMA classes, such as the mentioned scrreprt, I don't like tocloft to redefine class macros. For example, features such as koma fonts and the auto end dot are would be lost.

I would make a small modification myself, so I know that few is changed:

\makeatletter
\renewcommand*{\raggedchapterentry}{\setlength\@tempdima{2.3em}}
\renewcommand*\l@section{\bprot@dottedtocline{1}{1.5em}{3.2em}}
\makeatother


-
I’m extremely wary of such low-level modifications since they (1) require an intimate knowledge of the classes that surpasses the documented features by far, and (2) is extremely fragile, i.e. not future-proof. Any minor change in the scrreprt class may break this code. This is also the reason why I usually abhor the concept of these super classes like KOMA and memoir (and, indeed, ConTeXt). A modular approach (as implemented by packages) is technically much more sound. Put differently, this problem showcases everything that’s wrong with the “architecture” of TeX. :-( –  Konrad Rudolph Dec 19 '10 at 18:46
(That said, I’m grateful for the answer and I’ll probably use it.) –  Konrad Rudolph Dec 19 '10 at 18:47

For the record, I ended up using the tocloft package, as follows

\usepackage[titles]{tocloft}


(Option titles since all I want from the package is manipulate the space of the table of content lines; the title should still be rendered using the standard LaTeX method).

\renewcommand*\cftchapnumwidth{2em}
\renewcommand*\cftsecnumwidth{3em}


That said, it’s perhaps more appropriate to change the display of the contents lines so that only the section number is displayed for sections, not the whole “chapter.section” number.

-

http://projekte.dante.de/DanteFAQ/Verzeichnisse#3

or look for packages like titletoc

-
Wow. The titletoc documentation is really, really bad and I ended up using the (somewhat simpler, or at least more readably documented) tocloft package. –  Konrad Rudolph Dec 19 '10 at 17:51
it is easy to say that a documentation is bad ... but it is really difficult to write a good one ;-) –  Herbert Dec 19 '10 at 18:55
true. But by that reasoning one can stifle all criticism – not really fair, is it? –  Konrad Rudolph Dec 19 '10 at 18:58

I encountered the same problem today and I found that there is an easy solution for me without changing the font of the section title (like what KOMAlike tocstyle does).

\documentclass[pagesize]{scrreprt}
\usepackage{tocstyle}
\usetocstyle{standard}
\begin{document}
\renewcommand*{\thechapter}{\Roman{chapter}}
....
\end{document}


There are other predefined tocstyle you can choose if you would like to explore more options(See tocstyle manual). Hope this would be helpful for future readers.

-

I'll provide an example of the use of titletoc for this problem. It requires loading the eqparbox package to have an automatic alignment of chapter titles, section titles, &c.:

\documentclass{report}
\usepackage[showframe, nomarginpar]{geometry}
% Font Style
\usepackage{eqparbox}
\usepackage{titletoc}

\titlecontents{chapter}[0em]{\vspace{.25\baselineskip}}
{\eqparbox{ch}{\bfseries\thecontentslabel}\enspace}{}
{\hspace{.5em}\hfill\contentspage}

\titlecontents{section}[0em]{\vspace{.25\baselineskip}}
{\hskip\eqboxwidth{ch}{}\enspace\eqparbox{sec}{\thecontentslabel}\enspace}{}
{\hspace{.5em}\titlerule*[10pt]{$\cdot$}\contentspage}

\begin{document}

\renewcommand*\thechapter{\Roman{chapter}}
\tableofcontents
\setcounter{chapter}{6} % Problem starts at chapter 7
\chapter{Seven}
\chapter{Eight}
\section{Eight-one} \thesection\setcounter{section}{99}
\section{Eight-hundred}

\end{document}


-