5

I'm facing a very odd issue with spacing in my table of contents. For the first 25-30 entries, there is a space between the entry and corresponding page number. Thereafter, the space disappears!

ToC Anomaly

See the line at Section 4.2 and onwards. There are no spacing or \cft commands in that chapter. In fact, if I remove chapters 3 and 4 entirely, the spacing is proper until the first 25 entries, then gets distorted again.

I checked the .toc file and couldn't find anything odd in it. For what it's worth, I'm using the memoir document class.

Any ideas on why this might be happening? I've played around with the various \cft commands to no avail.

Here are the \cft commands from my TeX file:

\renewcommand{\cftchapterfont}{\normalfont} 
\renewcommand{\cftsectionfont}{\itshape} 
\renewcommand{\cftchapterpagefont}{\normalfont} 
\renewcommand{\cftchapterpresnum}{\bfseries} 
\renewcommand{\cftchapterleader}{} 
\renewcommand{\cftsectionleader}{} 
\renewcommand{\cftchapterafterpnum}{\cftparfillskip} 
\renewcommand{\cftsectionafterpnum}{\cftparfillskip} 
1
  • Please provide a fully compilable minimal example.
    – daleif
    Commented Jul 20, 2015 at 6:24

2 Answers 2

2

the spacing has nothing to do with the number of entries in the toc, but in the number of digits in the page number.

in most document classes, there is a box of fixed width assigned for the page number.

it looks like you are using a class designed for a article of fewer than 100 pages in length, because as soon as the page number exceeds two digits, it fills the space available. to test this, you could artificially reset the page number as \setcounter{page}{999} and see what happens when it exceeds a thousand. depending on the definition, it will either extend to the right (with an overfull hbox warning in the log, and a black mark if you have applied the [draft] option to the \documentclass line), or overprint the end of the entry text to the left.

to fix this, it's probably easiest to use one of the packages intended for modification of the toc format, although i'd also take a look into the document class itself and consider increasing the capacity of the field that formats the page number to allow more digits. since in the format shown the page numbers are not flush right, perhaps simply adding a space of fixed width at the beginning of the page number and setting the number flush left to that space is what you want -- you didn't show any one-digit page numbers, so there's no clue as to what you prefer, other than an assurance that you do want some separation.

3
  • Ah! Thanks! I'm using the memoir class (it's mentioned in the question). I believe memoir provides an option to set the width field; will look into that now.
    – Ansari
    Commented Jul 20, 2015 at 4:49
  • That was it - thanks again. Do you happen to know if it's possible to left-align the page number in that fixed-width box?
    – Ansari
    Commented Jul 20, 2015 at 4:54
  • oh -- spaced over the mention of memoir. have adjusted text appropriately. regarding setting the number flush left, there's probably an \hfil or \hspace in the box; removing that or moving it to after where the page number is filled in will shift the number to the left. Commented Jul 20, 2015 at 4:54
4

This is what I would do. As Barbara mentioned it is the box that exists around the page number. In the example below, we simply redefine the macro that provides this box, such that the box is gone (as it makes no sense in this application)

\documentclass[a4paper]{memoir}

\renewcommand{\cftchapterfont}{\normalfont} 
\renewcommand{\cftsectionfont}{\itshape} 
\renewcommand{\cftchapterpagefont}{\normalfont} 
\renewcommand{\cftchapterpresnum}{\bfseries} 
\renewcommand{\cftchapterleader}{} 
\renewcommand{\cftsectionleader}{} 
\renewcommand{\cftchapterafterpnum}{\cftparfillskip} 
\renewcommand{\cftsectionafterpnum}{\cftparfillskip} 

\renewcommand\cftchapterformatpnum[1]{~{\cftchapterpagefont #1}}
\renewcommand\cftsectionformatpnum[1]{~{\cftsectionpagefont #1}}

\begin{document}

\tableofcontents*


\clearforchapter

\setcounter{page}{51}


\chapter{chapter}

\section{section}

\clearforchapter


\setcounter{page}{101}


\chapter{chapter}

\section{section}

\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .