# TeX capacity exceeded, sorry [input stack size=5000] error with glossaries

I'm getting the following error when I simply include \gls{rsh} in my paper, and there's clearly an okay reference to rsh in my file glossaries.tex, which looks like the entry below:

\newglossaryentry{rsh}
{
name={\ensuremath{R'(\hat{S})}},
description={Function of aggregate per-capita social capital},
sort=S-hat
}


This doesn't seem to be much like anyone else's query, as I'm almost certain this has something to do with my \usepackage{glossaries}, but I can't tell what.

Check out my project files here. Thanks!

• What happens when you change the name field to something more ordinary, like RS? – Werner May 5 '15 at 5:17
• Same thing, unfortunately, this time with \gls{w}. So it looks like your intuition is right, it's something in the name -- but how to render the macro as a math character? – Robin B. May 5 '15 at 5:29
• Don't use \ensuremath. Try $R(\hat{S})$, and if that doesn't work, try $R(\protect\hat{S})$... – Werner May 5 '15 at 5:40
• ...my suggestion would be to include your project in what is called a minimal working example (MWE) (click the link and read it) right here on this site. Next week, once your problem is solved, your project files link will become invalid, making most of the question lose its context. Providing a MWE that reproduces the problem will make it far more beneficial for you and the future community. – Werner May 5 '15 at 5:40
• Thanks for your help so far... I'd love to provide you with an MWE. Unfortunately when I try to compile a "minimal" page such as [link] (drive.google.com/…), it works fine, but embedded in my document the stack seems to be too large. – Robin B. May 5 '15 at 5:54

Remove the hanging package. Or at least disable the hanging quotes with \usepackage[notquote]{hanging}.