3

I am trying to generate a list of math symbols, based on How to create a list of symbols where symbols can be used in math mode?. When I try to use the code below it gives me an error of

'! TeX capacity exceeded, sorry [input stack size=5000]'

\documentclass{article}

\usepackage{glossaries}
\makenoidxglossaries

\newglossaryentry{rho}{%
    name={\ensuremath{\rho}},
    sort=rho,
    description={Normalized Cross Correlation Metric}
}

\begin{document}

\printnoidxglossary

\renewcommand{\rho}{\gls{rho}}

$\rho$

\gls{rho}

\end{document}

How can I overcome this?

  • 2
    You are doing a recursive definition of \rho\gls{rho}\rho\gls{rho}... no wonder TeX is exhausted at some point. By the way, I don't recommend to use \rho this way. – user31729 Sep 15 '15 at 20:38
  • @ChristianHupfer is right: this is really not a good idea. The original answer you link to does not redefine basic macros: it uses new macro names, so that it is clear that something other is intended. Redefining these this way may seem like less trouble now, but it will come back to bite you. – cfr Sep 15 '15 at 22:41
5

Use \let\rhoorig\rho to make a copy of \rho, otherwise you get into a recursive, endless definition loop of \rho

Note I don't recommend using the redefinition of \rho this way!

\documentclass{article}

\usepackage{glossaries}
\makenoidxglossaries

\let\rhoorig\rho

\newglossaryentry{rho}{%
    name={\ensuremath{\rhoorig}},
    sort=rho,
    description={Normalized Cross Correlation Metric}
}

\begin{document}

\printnoidxglossary

\renewcommand{\rho}{\gls{rho}}

$\rho$

\gls{rho}

\end{document}
  • You said "I don't recommend using the redefinition of \rho this way". Do you have a better option to use it? – cacamailg Sep 15 '15 at 21:46
  • @cacamailg: Well, I don't understand why you are redefine it at all? Shall each occurence of \rho point to the glossary using hyperref? – user31729 Sep 15 '15 at 21:57
  • I know this is not the perfect way, but the idea is to build a list of symbols with glossaries. The redefinition is just to be able to use it widely without being worried if its added to the list of symbols or not. With glossaries, I know that if I do not use a symbol it is not added to the list. Moreover, which is optional, with glossaries I have the page where that symbol is used. But if you have a better approach, I would like to hear from you. – cacamailg Sep 15 '15 at 22:11
  • @cacamailg: Thanks for accepting the answer. I'll think about another approach for the usage of symbols instead of redefining the corresponding symbol control sequence – user31729 Sep 17 '15 at 16:01

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.