I'm using the \dotfill command in a nomenclature to add units at the end of each line. Here is the code I'm using:

\renewcommand*{\pagedeclaration}[1]{\unskip, \hyperpage{#1}}

That works correctly, but in my table of contents where there is also automatic dot filling, spacing in not the same. So how could I modify the \dotfill spacing ? (to match the one of the table of contents actually)

4 Answers 4


The definition of \dotfill is

\leavevmode \cleaders \hb@xt@ .44em{\hss .\hss }\hfill \kern \z@

The spacing is given by .44em, so you can put this in your preamble:

\renewcommand \dotfill {\leavevmode \cleaders \hb@xt@ .33em{\hss .\hss }\hfill \kern \z@}

I would, however, suggest that you create your own command called e.g. \Dotfill, like this, so that the spacing is modified only when you want (\dotfill is used by LaTeX in various places):

\newcommand \Dotfill {\leavevmode \cleaders \hb@xt@ .33em{\hss .\hss }\hfill \kern \z@}
  • Thanks that's perfect! And I've also discovered the \makeatletter and \makeatother commands by the way... And just for my information, where can I find the \dotfill definition ?
    – Remy F
    Dec 3, 2012 at 15:49
  • 1
    @RemyF who knows? I went to the chat and typed a message !!/texdef -t latex dotfill but texdef -t latex dotfill should work in your commandline somehow...
    – yo'
    Dec 3, 2012 at 16:27

This isn't really an answer, but I don't see how to add a link in the comments.

Look at Want to fill line with repeating string. That solution might work for you.

I took at look at The Advanced TeXbook suggested by that link. You could write something like \def\mydots{\xleaders\hbox to1em{\hfil.\hfil}\hfil}. You can change the 1em to a measure you'd prefer. BUT when I did my own sample of this, it didn't quite fill the page. Sigh. :(

\def\mydots{\xleaders\hbox to0.25em{\hfil.\hfil}\hfil}


A \mydots B



enter image description here

I think the problem is with the final \hfil but when I try to get rid of it, I get an error.

Overfull \hbox (0.27779pt too wide) detected at line 10
 \OT1/cmr/m/n/10 . 
! Leaders not followed by proper glue.
<to be read again> 
l.10 A \mydots B


When I rewrote \mydots as

\def\mydots{\leavevmode\xleaders\hbox to 0.25em{\hfil.\hfil}\hfill\kern0pt}

I got the result that I wanted. (Was I being too faithful to TeX within a LaTeX context?)

enter image description here

  • Great answer! How can I insert space after \mydots? For such result: A ... B?
    – pogibas
    Apr 28, 2014 at 9:25
  • How can I also remove the space in between ... and , ?
    – alper
    Jan 8, 2022 at 14:54

@tohecz has shown what you need to do, just a further comment on why your version didn't work.

You defined it with fil stretch (one l) which in the standard classes is the same as the \parfillskip glue used to allow the last line of a paragraph to be short. thus your paragraph

A \mydots B

had 2 fil worth of stretch, one coming from \mydots and one coming from \parfillskip. these will stretch the same amount thus B was pushed to the centre of the space between A and the right margin with dots to the left and glue to the right.


(For further readers). If you just want to stretch dots of toc, lof, lot in (ext)article (ext)book classes just write the following code in preamble:

\renewcommand{\@dotsep}{1}% default value is 4.5

enter image description here

You must log in to answer this question.

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