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}
3
  • Did you try \ensuremath{\boldsymbol{T_1}} or \boldmath\ensuremath{T_1}?
    – Bernard
    Commented Feb 24, 2020 at 13:57
  • Yes, but as I wrote above, this would apply to every single usage of that symbol, not only a single one.
    – Corbie
    Commented Feb 24, 2020 at 15:02
  • Do I understand correctly that the bold usage is the first in the main text, as opposed to in the glossary? Commented Mar 25, 2020 at 19:42

2 Answers 2

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}
1
  • Note that \boldsymbol from amsmath is a more standard command than \bm. It will work even when you load bm.
    – Davislor
    Commented Dec 20, 2020 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}
1
  • Note that \boldsymbol from amsmath is a more standard command than \bm. It will work even when you load bm.
    – Davislor
    Commented Dec 20, 2020 at 23:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .