2

I would like to print the first usage of a math symbol defined in my glossary in bold without defining a new glossary entry.

Using the text environment \textbf{\glssymbol{T1}} has no effect, because the symbol is in math mode.

Using the symbol in math mode does not work either: $\glssymbol{T1}$.

How do I print the math symbol in bold?

\documentclass{article}

\usepackage{glossaries}
\usepackage{bm}
\makeglossaries

\newglossaryentry{T1}{name={T1}, symbol={\ensuremath{T_1}}, description={longitudinal relaxation time}}
\newglossaryentry{T1bold}{name={T1}, symbol={\ensuremath{\bm{T_1}}}, description={longitudinal relaxation time (bold entry)}}

\begin{document}
This is the first time I use \textbf{\glssymbol{T1}} (should be \textbf{bold} like \glssymbol{T1bold}) and this the second time: \glssymbol{T1} (not bold).

Defining another symbol in the glossary leads to a second entry:
\printglossaries
\end{document}
Corbie
  • 256

2 Answers2

1

Simply use the optional user fields to declare your bold variable. Its much easier to handle than to define a new command. Tip: you could also define a new gls field (say 'glsBoldVar', compare your problem to my answer here)

\documentclass{article}

\usepackage{glossaries}
\usepackage{bm}
\makeglossaries

\newglossaryentry{T1}{name={T1}, 
    symbol={\ensuremath{T_1}},
    user1={\ensuremath{\bm{T_1}}},
    description={longitudinal relaxation time}
}
 description={longitudinal relaxation time (bold entry)}}

\begin{document}
    This is the first time I use \textbf{\glssymbol{T1}} (should be \textbf{bold} like \glsuseri{T1}) and this the second time: \glssymbol{T1} (not bold).

    Defining another symbol in the glossary leads to a second entry:
    \printglossaries
\end{document}
Venez
  • 611
  • Note that \boldsymbol from amsmath is a more standard command than \bm. It will work even when you load bm. – Davislor Dec 20 '20 at 23:00
0

One possible solution is to use the \text environment in a bold math (bm) mode.

As a new command, this looks like:

\newcommand{\glssymbold}[1]{\ensuremath{\bm{\text{\glssymbol{#1}}}}}

that can be used like this:

\glssymbold{T1}
Corbie
  • 256
  • Note that \boldsymbol from amsmath is a more standard command than \bm. It will work even when you load bm. – Davislor Dec 20 '20 at 23:00