I decided to enrich my list of symbols by adding a unit column with a newly defined key "unit".
\glsaddkey
{unit}
{}
{\glsentryunit}
{\Glsentryunit}
{\glsunit}
{\Glsunit}
{\GLSunit}
A new entry looks like
\newglossaryentry{insu}{
type=symbols,
name=thermal resistance,
symbol={\ensuremath{R\mathrm{c}}},
description={ratio of the temperature difference across an insulator and the heat flux for a particular material or assembly of materials},
unit={\ensuremath\protect\si{\watt}},
}
and produces following error with the last curly brace, that closes the \newglossaryentry
.
> ! Undefined control sequence.
\@glo@tmp ->\ensuremath \protect \si {\watt }
Moving the code inside the unit
key, for testing purpose, to the key symbol
works like a charm, but unfortunately not the intended place.
Changes around the protect
and ensuremath
have no effect.
The asterisk variant of \glsaddkey*
doesn't help either.
What is the conflict between adding a new key to a glossary entry and the \si
command?
Here a short MWE:
\documentclass{scrreprt}%
\usepackage{siunitx}
\usepackage{glossaries}
\glsaddkey
{unit}
{}
{\glsentryunit}
{\Glsentryunit}
{\glsunit}
{\Glsunit}
{\GLSunit}
\makeglossaries
\newglossaryentry{test}{
name=Test,
unit=\si{\meter},
description=sample description}
%-------------------------
\begin{document}
\printglossaries
\gls{test}
\end{document}
\ensuremath
and\protect
withsiunitx
? The error here is happening has\watt
is undefined outside ofsiunitx
's commands: could you make a full minimal working example (MWE) so we can see exactly what is happening.