# Glossaries: the page number appear at a wrong position

I use the glossaries package like this:

\usepackage[toc,xindy]{glossaries}
\include{glossaryentries}
\renewcommand*\glspostdescription{\dotfill}
\makeglossaries

....

\setglossarystyle{long}
\printglossary[title=List of Notations]

and get that

It does exactly what I want, except for some entries like the second one on the picture, where the page number appear on the left instead of the right. I have no idea why. Does someone know what I should do?

This specific entry is described by

\newglossaryentry{supportfunction}{
name         ={\ensuremath{h(K, \vect{u} )}},
description  ={support function of $K$ evaluated in the direction $\vect{u}$},
sort         =hKu
}

A minimal example:

\documentclass[11pt]{book}
\usepackage{hyperref}
\usepackage{glossaries}

\renewcommand*\glspostdescription{\dotfill}
\makeglossaries

\newglossaryentry{supportfunction}{
name          ={\ensuremath{h(K, \boldsymbol{u} )}},
description   ={support function of $K$ evaluated in the direction $\boldsymbol{u}$},
sort          =hKu
}

\begin{document}
\gls{supportfunction}
\setglossarystyle{long}
\printglossary
\end{document}
• Please, make a minimal example, but also try \dotfill\nolinebreak Sep 26 '16 at 13:01
• @egreg Thanks for your comment. \nolinebreak works. Problem solved :-) You can post it as an answer if you wish. Sep 26 '16 at 14:48
• Not without a full (minimal) example that shows the issue. Sep 26 '16 at 16:11
• @egreg Sorry for my laziness of not having provided a minimal example earlier. Shame on me. I just added one to my question. Sep 26 '16 at 18:39

This can be reproduced by explicitly using longtable:

\documentclass[11pt]{book}
\usepackage{hyperref}
\usepackage{glossaries}
\begin{document}
\begin{longtable}{lp{\glsdescwidth}}
\ensuremath{h(K, \boldsymbol{u} )} &
support function of $K$ evaluated in the direction
$\boldsymbol{u}$\dotfill\space
1\tabularnewline
\end{longtable}
\end{document}

This is essentially what the long style does. The problem seems to be the space after \dotfill. Since this is part of the style, the simplest solution is to define a custom style based on long:

\documentclass[11pt]{book}
\usepackage{hyperref}
\usepackage{glossaries}

\makeglossaries

\newglossarystyle{longdotted}{%
\setglossarystyle{long}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\glossentrydesc{##1}\dotfill ##2\tabularnewline
}%
}

\newglossaryentry{supportfunction}{
name          ={\ensuremath{h(K, \boldsymbol{u} )}},
description   ={support function of $K$ evaluated in the direction
$\boldsymbol{u}$},
sort          =hKu
}

\begin{document}
\gls{supportfunction}
\setglossarystyle{longdotted}
\printglossary
\end{document}