Document Classes ⇒ \tableofcontents in book class space issue
\tableofcontents in book class space issue
I am currently using the Book.cls to create my table of contents but after adjusting a few things I see that the section number is overlapping into the title. I have uploaded an image so you can see for youself.
Does anyone have any idea where the latex is that controls the spacing bettween the section number and the tile?
Thanks
- Attachments
-
- TitleMerge.jpg (12.48 KiB) Viewed 7371 times
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
\tableofcontents in book class space issue
\tableofcontents in book class space issue
It seems I need this
Code: Select all
\@dottedtocline{seclevel}{indent}{numwidth}
Code: Select all
\newcommand*{\l@section}{\@dottedtocline{1}{1.5em}{2.3em}}
Any ideas what I am doing wrong?! LaTeX Error: Command \l@section already defined.
Or name \end... illegal,.
Thanks
EDIT:
I managed to fix it by doing this:
Code: Select all
\makeatletter
\renewcommand*\l@section{\@dottedtocline{1}{0em}{3em}}
\makeatother
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
\tableofcontents in book class space issue
Code: Select all
\setlength{\cftsecnumwidth}{3em}
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: \tableofcontents in book class space issue
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
\tableofcontents in book class space issue
That's an issue I can't comprehend. Consider the following example.4fingers wrote:Thanks for the suggestion but that pushes the page number to the right as well.
Code: Select all
\documentclass[11pt,a4paper,english]{book}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[includeheadfoot,margin=2cm]{geometry}
\usepackage{tocloft}
\usepackage{blindtext}
\setlength{\cftsecnumwidth}{3em}
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\Blinddocument
\end{document}
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: \tableofcontents in book class space issue
One thing I have found is that I really only need to adjust the numwidth on the first table of contents. To save space am I able to detect if I am on the first table of contents, in which case apply a differnt numwidth to all the other table of contents?
THanks
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
\tableofcontents in book class space issue
As long as my method yields unexpected results in your document, your code is flawed.4fingers wrote:Its Ok, as long as my previous method works I dont mind if your suggested method returns different results that you might expect. [...]
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10