I get the error "Improper alphabetic constant" while using the package glossaries. My MWE:
main file:
\documentclass{article}
\usepackage{glossaries}
\usepackage{amssymb}
\newglossary[slg]{symbolslist}{syi}{syg}{List of Symbols}
\makenoidxglossaries
\loadglsentries{gloss}
\begin{document}
Text
%
\glsaddall
\printnoidxglossary[type=symbolslist]
\end{document}
glossaries entries:
\newglossaryentry{natnumb}{
name={\ensuremath{\mathbb{N}}},
description={The natural numbers $\mathbb{N} = \lbrace 1,2,3,\ldots \rbrace$.},
type=symbolslist
}
\newglossaryentry{natnumbzero}{
name={\ensuremath{\mathbb{N}_0}},
description={The natural nubers with $0$, $\mathbb{N}_0 = \mathbb{N} \cup \lbrace 0 \rbrace$.},
type=symbolslist
}
I can handle this by adding a sort={…} to each glossary entry, but since I have a lot of entries, I don't want to add this everytime. Is there another solution for this?
Best Answer
The simplest solution is to sort by definition or sort by order of use:
or
Another method is to define your own sort handler that will strip the maths commands. For example:
Any other commands that occur in the
name
will similarly need to be temporarily redefined. Note the spaces inThis is because the
sort
key is in the form:The commands may look like
\ensuremath
and\mathbb
, but they're actually\ensuremath
and\mathbb
(trailing space is part of the command name).Edit: Another method is to use the
sanitizesort
package option. This will convert command names like\mathbb
into the sequence of characters\
m
a
t
h
b
b
, so it will behave much likemakeindex
.The difference in these methods can be observed by adding a few extra sample entries:
Using
sanitizesort
:Using custom sort: