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.

I would like to use the option counterwithin to get my numbering as I, I.1., I.2, .., II, II.1, II.2,...

I use the following minimal script

\documentclass[11pt, a4paper, twoside, openany]{scrbook}
\usepackage{chngcntr}
\counterwithin{chapter}{part}
\begin{document}
\tableofcontents
\part{This is part 1}
\chapter{This is I.1}
\part{This is part 2}
\chapter{This is II.1}
\end{document}

This does what I want, but in the table of content, for some reason, there is not enough space between the numbers and the chapter names. As the roman numbers get longer, the numbers and text even overlap. in table of contenn, spacing between number and text is not correct

share|improve this question

2 Answers 2

You can use tocloft and change the numwidth:

\setlength{\cftchapnumwidth}{2em}

Change 2em to whatever you desire.

\documentclass[11pt, a4paper, twoside, openany]{scrbook}
\usepackage{chngcntr}
\usepackage{tocloft}
\counterwithin{chapter}{part}
\setlength{\cftchapnumwidth}{2em}
\begin{document}
\tableofcontents
\part{This is part 1}
\chapter{This is I.1}
\part{This is part 2}
\chapter{This is II.1}
\end{document}

enter image description here

You can do the same for part, sec subsec, subsubsec para and subpara in a similar fashion. Do

\setlength{\cftXnumwidth}{<dimension>}

Where X has to be replaced by part sec etc.

share|improve this answer
    
But I would use \counterwithin*{chapter}{part} so that chapter numbers are not prepended by part number. –  Harish Kumar May 30 at 11:15

You can use the package tocstyle which is part of the KOMA-Script-bundle.

\documentclass[openany]{scrbook}
\usepackage{tocstyle} 
\usetocstyle{KOMAlike} 
\usepackage{chngcntr}
\usepackage{blindtext}
\counterwithin{chapter}{part}
\begin{document}
\tableofcontents
\part{This is part 1}
\blinddocument\blinddocument
\part{This is part 2}
\blinddocument\blinddocument
\end{document}

You have to run the code several times to get:

enter image description here

Or you can use the option toc=flat:

\documentclass[openany,toc=flat]{scrbook}
\usepackage{chngcntr}
\usepackage{blindtext}
\counterwithin{chapter}{part}
\begin{document}
\tableofcontents
\part{This is part 1}
\blinddocument\blinddocument
\part{This is part 2}
\blinddocument\blinddocument
\end{document}

Run twice to get

enter image description here

share|improve this answer

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.