As barbara mentioned, you can use \ensuremath
like this:
\documentclass{article}
\usepackage{glossaries}
\makeglossaries
\newglossaryentry{lengthtree}%
{%
name={\ensuremath{L_t}},
description={description here},
sort={L}
}
\begin{document}
In line: \gls{lengthtree}. In math mode:
\[
\gls{lengthtree}
\]
\printglossary[title={List of Symbols}]
\end{document}
The arguments against \ensuremath
come down to two main issues (see When not to use \ensuremath for math macro?):
Firstly, you might end up with $
inside the argument of \ensuremath
. This won't occur in this example, as the argument of \ensuremath
is being explicitly set to L_t
.
Secondly, there is an issue of semantics. Following this line of argument, you should define the entry without \ensuremath
and do $\gls{lengthtest}$
, which is fine in the document text that you type, but this will cause a problem in the glossary where the style doesn't automatically shift to math mode when it comes to the entry name. Personally, I think \ensuremath
is okay in this context, but for the purists who can't stand it, here's an alternative solution:
\documentclass{article}
\usepackage{glossaries}
\makeglossaries
\newglossaryentry{lengthtree}%
{%
name={$L_t$},
text={L_t},
description={description here},
sort={L}
}
\begin{document}
In line: $\gls{lengthtree}$. In math mode:
\[
\gls{lengthtree}
\]
\printglossary[title={List of Symbols}]
\end{document}
Both the above examples produce:

\ensuremath
.amsmath
, they you might try\text{$...$}
as the expansion of your symbol code.\text
ensures the correct size in sub- and superscripts, but it's expected to be used within a math context, so if you use it in text (such as in an ordinary sentence, or even as the entry for your symbols list), you need to put it in$...$'. and if any of these symbols are supposed to be large operators (like
\sum), this also won't automatically go into
\displaystyle` in a display equation.