Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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):

screenshot

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?

share|improve this question
1  
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
add comment

5 Answers

up vote 8 down vote accepted

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)

share|improve this answer
    
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
add comment

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

alt text

share|improve this answer
1  
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
add comment

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.

share|improve this answer
add comment

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

or look for packages like titletoc

share|improve this answer
1  
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
2  
true. But by that reasoning one can stifle all criticism – not really fair, is it? –  Konrad Rudolph Dec 19 '10 at 18:58
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.