14

I created a list of symbols table as you can see :

\newglossaryentry{slambda}{
name=$\lambda$,
description={wavelength}
}

When I tried to put this symbol in the equation :

\begin{equation} 
\gls{slambda} = \frac{c}{f} 
\end{equation}

I got an error. I want to do that to show the symbol Lambda in my symbol list, generated as below :

\printglossary

Any ideas ?

4
  • 1
    Can you be a bit more explicit (e.g., tell us what you did to create the list of symbols table, what did you try without success)? Aug 7 '15 at 9:00
  • I'm trying to add symbol in the tag 'equation' to see them in the symbol table, because if I don't add them, I can't see them (I don't know if I'm pretty clear or not, english not my native language ...)
    – Zaertiu
    Aug 7 '15 at 9:07
  • @Zaertiu: If you show us the code how you generated the list of symbols table, it's possible to help you, as of now -- we can only guess
    – user31729
    Aug 7 '15 at 9:12
  • post edited, I shall be clearer now.
    – Zaertiu
    Aug 7 '15 at 9:19
21

Some will frown on this, but the error is $\lambda$ being used in \begin{equation}...\end{equation} when \gls{slambda} is replaced with $\lambda$ then.

It's not possible to use $...$ inside equation-like environments.

Omitting works for the environment, but then \printglossaries complains about missing math mode.

One possible solution is to apply \ensuremath around \lambda. It will use math mode if it's not already in math mode then -- so it is safe to use it.

\documentclass{article}

\usepackage{glossaries}
\makeglossaries

\newglossaryentry{slambda}{%
name=\ensuremath{\lambda},
description={wavelength}
}

\begin{document}


\begin{equation} 
\gls{slambda} = \frac{c}{f} 
\end{equation}

\printglossary  % for usage with makeglossaries program


\end{document}

enter image description here

6
  • @Zaertiu: Alright: Happy TeXing then ;-)
    – user31729
    Aug 7 '15 at 9:29
  • 6
    This is a place where \ensuremath is good. ;-)
    – egreg
    Aug 7 '15 at 9:31
  • 1
    +1 but minor nit-pick ;-) Both \printglossary and \printglossaries will have the same effect here as there's only one glossary. They're not dependent on the document build. (\printglossaries just iterates over all defined glossaries and applies \printglossary[type={...}] to each one.) Feb 25 '18 at 14:20
  • @NicolaTalbot: Thanks, this is one of my older answers related to glossaries. I changed to \printglossary here
    – user31729
    Feb 25 '18 at 15:28
  • @ChristianHupfer Oops, sorry I didn't notice the date! Feb 25 '18 at 16:34

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.