I want to make the dot separations I get using \dotfill
in the glossaries
package to match the dot separation I get in the tocloft
package. The image below shows an entry from the table of contents on the top and an entry from the glossary on the bottom:
According to this answer, I can create a command called \Dotfill
which has different spacing than \dotfill
. Below is the definition for \Dotfill
where the space between dots in .33em
.
\makeatletter
\newcommand \Dotfill {\leavevmode \cleaders \hb@xt@ .33em{\hss .\hss }\hfill \kern \z@}
\makeatother
I can then use \Dotfill
to add dots after the description in my glossary:
renewcommand*\glspostdescription{\Dotfill}
I can manually change .33em
until the dot spacing appears to match, but is there a better way to do this? According to the documentation for tocloft, the value describing the space between the dots in the table of contents is given by \@dotsep
which has default value 4.5. I am not sure how to utilize this in what is given above.
Here is a minimal working example:
\documentclass{report}
\makeatletter
\newcommand \Dotfill {\leavevmode \cleaders \hb@xt@ .33em{\hss .\hss }\hfill \kern \z@}
\makeatother
\usepackage{tocloft}
\renewcommand{\cftchapleader}{\cftdotfill{\cftsecdotsep}}
\usepackage[toc]{glossaries}
\makeglossaries
\renewcommand*\glspostdescription{\Dotfill}
\begin{document}
\newglossaryentry{Cab}{name={$C[a,b]$},sort=C,description={The space of continuous functions defined on $[a,b]$}}
\tableofcontents
\printglossary
\chapter{Chap 1}
\gls{Cab}
\end{document}
To compile, you must run makeglossaries
in between calls to latex
.