Here, siunitx
abbreviations throw an error if used inside a glossary entry key, however, if the unit is given without abbreviations, no error shows up.
\documentclass{article}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{calc,siunitx}
\sisetup{load-configurations = abbreviations}
\usepackage{glossaries}
\makenoidxglossaries
\newlength\glsnamewidth
\newlength\glsunitwidth
\settowidth{\glsnamewidth}{\textbf{sign}}
\settowidth{\glsunitwidth}{\textbf{unit}}
\newglossarystyle{namedescunit}{%
\setlength{\glsdescwidth}{\linewidth-\glsnamewidth-\glsunitwidth-6\tabcolsep}%
\renewenvironment{theglossary}%
{\begin{supertabular}{p{\glsnamewidth}p{\glsunitwidth}p{\glsdescwidth}}}%
{\end{supertabular}}%
\renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand{\glossentry}[2]{%
\raggedright\glstarget{##1}{\glossentryname{##1}} &
\centering\glossentrysymbol{##1} &
\glossentrydesc{##1}\tabularnewline
}%
\renewcommand{\subglossentry}[3]{\glossentry{##2}{##3}}%
\renewcommand*{\glsgroupskip}{}%
}
\setglossarystyle{namedescunit}
%%%%%%%%% this code block causes the crash %%%%%%%%%%%
\makeatletter
\appto\@newglossaryentryposthook{%
\settowidth{\dimen@}{\glsentryname{\@glo@label}}%
\ifdim\dimen@>\glsnamewidth
\setlength{\glsnamewidth}{\dimen@}%
\fi
\settowidth{\dimen@}{\glsentrysymbol{\@glo@label}}%
\ifdim\dimen@>\glsunitwidth
\setlength{\glsunitwidth}{\dimen@}%
\fi
}%
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glssetnoexpandfield{symbol}
\newglossaryentry{L}{name={L},description={Buchstabe},symbol={---}}
\newglossaryentry{P}{name={Cp},description={specific heat},symbol={[\si{\J\per\kg\per\K}]}}
\begin{document}
\lipsum[1]
\glsaddall
\printnoidxglossaries
\end{document}
\sisetup{load-configurations = abbreviations}
is actually deprecated syntax, the correct in versions 2.3 and above ofsiunitx
would be\sisetup{abbreviations=true}
, which is also the default behaviour. See manual sections 8.3 and 5.11.)\glsnoexpandfields
to the preamble, as discussed in this question: tex.stackexchange.com/questions/390273/…\glssetnoexpandfield{symbol}
in the preamble before the new glossary entries.\documentclass{article} \usepackage{etoolbox,siunitx} \newcommand{\tmp}{} \appto\tmp{\settowidth{\dimen0}{[\si{\J\per\kg\per\K}]}} \tmp \begin{document} \end{document}
. (This is essentially what theglossaries
code is trying to do.) If the\tmp
block is moved to the document environment the error goes away.