[Tex/LaTex] How to change dot spacing in \dotfill


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)

Best Answer

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@}