Page LayoutExtra dot in ToC. Why ?

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Extra dot in ToC. Why ?

Post by Cham »

I'm getting an extra dot in the ToC, from this MWE code. Why ?

Code: Select all

\documentclass[11pt,letterpaper,twoside]{article}
\usepackage{microtype}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{tocloft}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}  % Add ... to sections
\renewcommand{\cftsecpresnum}{\hfill}  % To define a constant space
	\renewcommand{\cftsecaftersnum}{\hspace*{8pt}}
	\addtolength{\cftsecnumwidth}{8pt}

\begin{document}
\tableofcontents

\newpage
\section{Title}
Blabla

\newpage
\section{Title}
Blabla

\newpage
\section{Title}
Blabla

\newpage
\section{Title}
Blabla

\newpage
\section{Title}
Blabla

\newpage
\section{Title}
Blabla

\newpage
\section{Title}
Blabla

\newpage
\section{Title}
Blabla

\newpage
\section{Title}
Blabla

\newpage
\section{Title}
Blabla
\end{document}
Here's a preview with the extra dot shown in red :
extra-dot.jpg
extra-dot.jpg (33.63 KiB) Viewed 3187 times
This is weird ! If I change a few lines in the code, the extra dot may be gone, or may stay there. I don't understand what is happening here. Any idea ?

Recommended reading 2024:

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

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Extra dot in ToC. Why ?

Post by Stefan Kottwitz »

Hi Cham!

Interesting. I guess 11 is less wide than 10 and so there's just enough space to have one more dot filled in. However, I guess that should not happen because the boxes with the page numbers should have a fixed width.

A quick way of getting rid of the dot would be setting a slightly larger page number width yourself, such as:

Code: Select all

\makeatletter
\renewcommand{\@pnumwidth}{1.5em}
\makeatother
Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Extra dot in ToC. Why ?

Post by Cham »

Thanks Stefan.

It's working nicely, but it's weird to me (I would never understand that kind of LaTeX coding ! :oops: ). Is this a kind of hack ?
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Extra dot in ToC. Why ?

Post by Cham »

Stefan,

is there another way (i.e. simpler ?) of doing the same ToC style, using another package ?

While your solution is working great and solved my issue, I may be interested in using something like titletoc instead of tocloft. How would you define the same ToC style ?
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

Extra dot in ToC. Why ?

Post by rais »

If I turn protrusion off---without changing \@pnumwidth---it seems to work in the TOC:

Code: Select all

[...]
\microtypesetup{protrusion=false}%
\tableofcontents
\clearpage
\microtypesetup{protrusion=true}%
\section{Title}
[...]
KR
Rainer
Post Reply