3

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}

\newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist} % create add. symbolslist


\glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit}

\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}}%
%
\renewcommand*{\glossaryheader}{%  Change the table header
  \bfseries Sign & \bfseries Description & \bfseries Unit \\
  \hline
  \endhead}
\renewcommand*{\glossentry}[2]{%  Change the displayed items
\glstarget{##1}{\glossentryname{##1}} %
& \glossentrydesc{##1}% Description
& \glsunit{##1}  \tabularnewline
}
}


\begin{document}

    \glsaddall

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

\end{document}
3

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}

\newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist} % create add. symbolslist


\glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit}

\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}}%
%
\renewcommand*{\glossaryheader}{%  Change the table header
  \bfseries Sign & \bfseries Description & \bfseries Unit \\
  \hline
  \endhead}
\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}
    \glsaddall

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

\end{document}

enter image description here

  • 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
  • Thanks you very much Ulrike for your fast Response. There were some copy-paste-mistakes done by myself which hid the actual Problem: using the \usepackage{mathptmx} impeded the bold symbols. Is there a suitable alternative to mathptmx? Furthermore, does \glsnoexpandfields Need to be at a certain Location when the definitions are put in the preamble? Thanks! – Michele May 24 '18 at 13:41
  • Load the bm package. And next time you ask a question test the example before posting and so avoid to waste the time of the helpers. – Ulrike Fischer May 24 '18 at 13:47
  • @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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.