LaTeX forum ⇒ Page LayoutExtra dot in ToC. Why ?

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

Extra dot in ToC. Why ?

Postby Cham » Sun Oct 15, 2017 6:29 pm

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

  1. \documentclass[11pt,letterpaper,twoside]{article}
  2. \usepackage{microtype}
  3. \usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
  4. \usepackage{tocloft}
  5. \renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} % Add ... to sections
  6. \renewcommand{\cftsecpresnum}{\hfill} % To define a constant space
  7. \renewcommand{\cftsecaftersnum}{\hspace*{8pt}}
  8. \addtolength{\cftsecnumwidth}{8pt}
  9.  
  10. \begin{document}
  11. \tableofcontents
  12.  
  13. \newpage
  14. \section{Title}
  15. Blabla
  16.  
  17. \newpage
  18. \section{Title}
  19. Blabla
  20.  
  21. \newpage
  22. \section{Title}
  23. Blabla
  24.  
  25. \newpage
  26. \section{Title}
  27. Blabla
  28.  
  29. \newpage
  30. \section{Title}
  31. Blabla
  32.  
  33. \newpage
  34. \section{Title}
  35. Blabla
  36.  
  37. \newpage
  38. \section{Title}
  39. Blabla
  40.  
  41. \newpage
  42. \section{Title}
  43. Blabla
  44.  
  45. \newpage
  46. \section{Title}
  47. Blabla
  48.  
  49. \newpage
  50. \section{Title}
  51. Blabla
  52. \end{document}


Here's a preview with the extra dot shown in red :
extra-dot.jpg
extra-dot.jpg (33.63 KiB) Viewed 159 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 ?

User avatar
Stefan Kottwitz
Site Admin
Posts: 8527
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Sun Oct 15, 2017 11:18 pm

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:

  1. \makeatletter
  2. \renewcommand{\@pnumwidth}{1.5em}
  3. \makeatother


Stefan
Site admin

User avatar
Cham
Posts: 813
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Mon Oct 16, 2017 3:04 am

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: 813
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Mon Oct 16, 2017 9:14 pm

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: 149
Joined: Sun Nov 16, 2014 8:51 pm

Postby rais » Mon Oct 16, 2017 9:43 pm

If I turn protrusion off---without changing \@pnumwidth---it seems to work in the TOC:
  1. [...]
  2. \microtypesetup{protrusion=false}%
  3. \tableofcontents
  4. \clearpage
  5. \microtypesetup{protrusion=true}%
  6. \section{Title}
  7. [...]

KR
Rainer


Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 2 guests