Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

compare

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.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You don't need to know the lengths or give them explicitly (which is surely prone to error). Simply use the settings from tocloft in your definition of \Dotfill:

\documentclass{report}
\usepackage[toc]{glossaries}
\usepackage{tocloft}

\newcommand\Dotfill{\cftdotfill{\cftsecdotsep}}
    \renewcommand{\cftchapleader}{\cftdotfill{\cftsecdotsep}}

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

You can even do without the \Dotfill command:

\documentclass{report}
\usepackage[toc]{glossaries}
\usepackage{tocloft}

\renewcommand{\cftchapleader}{\cftdotfill{\cftsecdotsep}}

\makeglossaries
\renewcommand*\glspostdescription{\cftdotfill{\cftsecdotsep}}

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

The ToC

enter image description here

The entry in the glossary:

enter image description here

share|improve this answer

You can convert the value 4.5 to em to get the correct number. As is in the documentation, the 4.5 is in math units. There are 18 math units to 1 em.

18 / 4.5 = 4, so 4.5 math units is 1/4 * 1 em = 0.25 em.

Using the value 0.25 em will give you the correct standard spacing used by tocloft.

share|improve this answer
    
When I use .25em in the MWE above, it makes the dots even closer together than if I just used \dotfill. –  James Rohal Jun 6 '13 at 22:21
    
That might be, but then for whatever reason the default values of tocloft are not being used. According to the documentation, the default is 4.5 mu = 0.25 em. If the spacing than is not correct, the default values are altered somehow. However, Gonzalo's answer is definitely a better solution, even though it doesn't answer to question on how to use the 4.5 value :-) –  Mythio Jun 9 '13 at 14:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.