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 ofsiunitxwould be\sisetup{abbreviations=true}, which is also the default behaviour. See manual sections 8.3 and 5.11.) – Torbjørn T. Sep 06 '17 at 00:19\glsnoexpandfieldsto the preamble, as discussed in this question: https://tex.stackexchange.com/questions/390273/creating-new-command-including-siunitx-error-due-to-spacing – Steven B. Segletes Sep 08 '17 at 15:34\glssetnoexpandfield{symbol}in the preamble before the new glossary entries. – Diaa Sep 08 '17 at 15:36\protecting those units. – Steven B. Segletes Sep 08 '17 at 15:37\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 theglossariescode is trying to do.) If the\tmpblock is moved to the document environment the error goes away. – Nicola Talbot Sep 08 '17 at 16:36