# Using both bold and non-bold symbols in glossaries symbol list

I am using glossaries for creating lists of acronyms and symbols. For the list of symbols including units, I use code from this answer by Christian Hupfer: glossaries: How to customize list of symbols with additional column for units?

However, I need to differ between bold and non-bold symbols (referring to tensors or scalars), which is apparently not possible with that code. I'm struggling with the code adjustment pretty much and I could not find any way to make that possible. Could somebody help me out, please? Thanks a lot!!

MWE:

\documentclass{book}
\usepackage{siunitx}
\usepackage[acronym,toc]{glossaries}              % use glossaries-package

\setlength{\glsdescwidth}{15cm}

\makeglossaries                                   % activate glossaries-    package

% ==== EXEMPLARY ENTRY FOR SYMBOLS LIST =========================================
\newglossaryentry{sig}{name=\ensuremath{\sigma},
description={This is a non-bold stress scalar},
unit={\si{\mega\pascal}},
type=symbolslist}

\newglossaryentry{csig}{name=\ensuremath{\boldsymbol{\sigma}},
description={This is a bold Cauchy stress tensor},
unit={\si{\mega\pascal}},
type=symbolslist}

% ==== EXEMPLARY ENTRY FOR ACRONYMS LIST     ========================================
\newacronym{frp}{FRP}{Fiber Reinforced Polymers}

\newglossarystyle{symbunitlong}{%
\setglossarystyle{long3col}% base this style on the list style
\renewenvironment{theglossary}{% Change the table type --> 3 columns
\begin{longtable}{lp{0.6\glsdescwidth}>{\centeringarraybackslash}p{2cm}}}%
{\end{longtable}}%
%
\bfseries Sign & \bfseries Description & \bfseries Unit \\
\hline
\renewcommand*{\glossentry}[2]{%  Change the displayed items
\glstarget{##1}{\glossentryname{##1}} %
& \glossentrydesc{##1}% Description
& \glsunit{##1}  \tabularnewline
}
}

\begin{document}

\printglossary[type=\acronymtype,style=long]  % list of acronyms
\printglossary[type=symbolslist,style=symbunitlong]   % list of     symbols

\end{document}


Your example doesn't compile without errors. When using siunitx commands in glossary entry you should disable expansion of the glossary fields with \glsnoexpandfields or (not really recommended as it has other issues) move the definition behind \begin{document} as siunitx does a lot initialization only a \begin{document}. Beside this you have typo (a missing backslash). If I correct the errors the bold symbols work fine:

\documentclass{book}
\usepackage{siunitx}

\usepackage[acronym,toc]{glossaries}              % use glossaries-package

\setlength{\glsdescwidth}{15cm}

\makeglossaries                                   % activate glossaries-    package

% ==== EXEMPLARY ENTRY FOR ACRONYMS LIST     ========================================
\newacronym{frp}{FRP}{Fiber Reinforced Polymers}

\newglossarystyle{symbunitlong}{%
\setglossarystyle{long3col}% base this style on the list style
\renewenvironment{theglossary}{% Change the table type --> 3 columns
\begin{longtable}{lp{0.6\glsdescwidth}>{\centering\arraybackslash}p{2cm}}}%
{\end{longtable}}%
%
\bfseries Sign & \bfseries Description & \bfseries Unit \\
\hline
\renewcommand*{\glossentry}[2]{%  Change the displayed items
\glstarget{##1}{\glossentryname{##1}} %
& \glossentrydesc{##1}% Description
& \glsunit{##1}  \tabularnewline
}
}
\glsnoexpandfields
% ==== EXEMPLARY ENTRY FOR SYMBOLS LIST =========================================

\newglossaryentry{sig}{name=\ensuremath{\sigma},
description={This is a non-bold stress scalar},
unit={\si{\mega\pascal}},
type=symbolslist}

\newglossaryentry{csig}{name=\ensuremath{\boldsymbol{\sigma}},
description={This is a bold Cauchy stress tensor},
unit={\si{\mega\pascal}},
type=symbolslist}

\begin{document}

• I really don't recommend putting the definitions in the document environment. (Unless you use \usepackage[docdef=restricted]{glossaries-extra} and have all the glossaries at the end of the document.) – Nicola Talbot May 24 '18 at 10:58
• @NicolaTalbot I understand the problems. But if glossaries expands everything by default the preamble isn't a good place either ;-). Why doesn't glossaries use \glsnoexpandfields by default? – Ulrike Fischer May 24 '18 at 13:33
• @UlrikeFischer Historical reasons. I can't change it now or it will affect existing documents that programatically define entries. With the new glossaries-extra+bib2gls method, \glsnoexpandfields is implemented by default. – Nicola Talbot May 24 '18 at 14:20