[Tex/LaTex] Not all symbols showing in glossaries

glossaries

I use the glossaries package to create a list of symbols. My problem is that not all symbols show up in the glossary. It follows a minimal (not) working example.

\documentclass[11pt,a4paper,twoside]{book}

\usepackage{amsmath} % assumes amsmath package installed
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{dsfont}
\usepackage[english,germanb]{babel}

\usepackage[xindy,nomain]{glossaries}


\newglossary[slg]{symbols}{sym}{sbl}{List of Symbols}
\makeglossaries

\newglossaryentry{symb:m}{%
type=symbols,
name={$m$},
text={m},
description={symb m}}

\newglossaryentry{symb:m2}{%
type=symbols,
name={$\widetilde{m}$},
text={\widetilde{m}},
description={symbol m2}}

\newglossaryentry{symb:f}{%
type=symbols,
name={$f(\cdot)$},
text={f},
description={This is a function}}

\begin{document}
    \chapter{Test}
    Here comes the first symbol: $\gls{symb:m}$; and now the second: $\gls{symb:m2}$. 

    Here is a function: $\gls{symb:f}(t)$.

    \printglossary[type=symbols, nonumberlist]

    %\glsaddall[types={symbols}]
\end{document}

In total three symbols are defined which are also referenced in the test chapter. Compiling this will only list two symbols: m and f. \widetilde{m} is missing though it should be there. Also, if one uncomments the \glsaddall the result doesn't change. If I change the name of the symbol entry for \widetilde{m}, it does work. But of course this yields a wrong symbol. It seems the glossaries package has a problem with widetilde. Is this the case and if so, is there a workaround?

Best Answer

xindy ignores commands contained in the sort field, so it treats the sort value \widetilde{m} as just m but you already have an entry with that sort value so the second entry is merged with the first. You can see this more clearly when the numberlist is displayed and the two entries are on separate pages:

\documentclass[11pt,a4paper,twoside]{book}

\usepackage[xindy,nomain]{glossaries}


\newglossary[slg]{symbols}{sym}{sbl}{List of Symbols}
\makeglossaries

\newglossaryentry{symb:m}{%
type=symbols,
name={$m$},
text={m},
description={symb m}}

\newglossaryentry{symb:m2}{%
type=symbols,
name={$\widetilde{m}$},
text={\widetilde{m}},
description={symbol m2}}

\newglossaryentry{symb:f}{%
type=symbols,
name={$f(\cdot)$},
text={f},
description={This is a function}}

\begin{document}
    \chapter{Test}
    Here comes the first symbol: $\gls{symb:m}$; 
    \newpage
    and now the second: $\gls{symb:m2}$. 

    Here is a function: $\gls{symb:f}(t)$.

    \printglossary[type=symbols]

\end{document}

The list of symbols now looks like:

image of glossary

The m entry has two pages in the page list. The first one (page 1) is the symb:m entry and the second one (page 2) is the symb:m2 entry. Since xindy does this silently, it's best to always use the sort key if you have any entries that contain commands. For example:

\newglossaryentry{symb:m2}{%
type=symbols,
name={$\widetilde{m}$},
text={\widetilde{m}},
sort=m2,
description={symbol m2}}