I'm trying to build a glossary where some terms are constants with units, and I'm hitting the problem than the units of siunitx are not defined.
\documentclass{article}
\usepackage{glossaries-extra}
\usepackage{siunitx}
\makenoidxglossaries
\newglossaryentry{working entry}{type=main, name={$e = 1.6e-19$ C}, description={electron charge}}
\newglossaryentry{failing entry}{name={$e = \qty{1.6e-19}{\coulomb}$}, description={electron charge}}
\begin{document}
\printunsrtglossary
\end{document}
fails with:
! Undefined control sequence.
\@gls@value ->$e = \qty {1.6e-19}{\coulomb
}$
l.7 ...\coulomb}$}, description={electron charge}}
! ==> Fatal error occurred, no output PDF file produced!
It's not a problem of the expansion of the field, because according to the glossaries manual, the name field is not expanded (and any combination of \glssetnoexpandfield, \unexpanded, \protect and similar didn't help).
Rather I suspect after reading this somewhat related answer that the siunitx units macros are not defined in the preambule. According to question like this one it used to work, but maybe something changed between siunitx 2 and siunitx 3.
The answer was solving the problem of the abbreviated units not being loaded yet with this code:
%load abbreviations:
\ExplSyntaxOn
\__siunitx_load_abbreviations:
\ExplSyntaxOff
So I'm wondering if there exist something similar for siunitx 3 for loading the whole units before defining the glossary entries.
\AtBeginDocument{...}– daleif Mar 03 '22 at 13:20