# How to get glossary terms to properly typeset subscripts/superscripts?

I have just begun using the glossaries package. I have created a glossary entry for the coproduct symbol as disjoint union:

\newglossaryentry{coprod}
{
name = {\ensuremath{\coprod}},
description = {The coproduct in the category of sets, i.e., the disjoint union},
sort = coprod,
symbol = {\ensuremath{\coprod}}
}

Where I put either \gls{coprod} or \glssymbol{coprod} in the body of my document, it prints the coproduct symbol correctly, but it doesn't format subscripts and superscripts (e.g. \gls{coprod}_1^r) as it would for the \coprod symbol in math mode (i.e. above and below). Instead, they're to the right, and too close together. How can I fix this?

Addendum: An example of the call to \gls{coprod} in my code looks like:

$[n] = \gls{coprod}_1^r \lambda_i$
• Are you in math mode issuing your \gls? If not that's your problem, but since it is not clear what your context is please provide a MWE. Feb 15, 2017 at 5:27
• Yes the \gls is in math mode. I will try Elad Den's displaystyle idea. Feb 15, 2017 at 17:53
• @TeXnician - I would have tried what Elad Den put in his answer as a MWE, but actually it comes out fine for me too. My issue is happening in a large project (a PhD thesis), using a lot of different packages. I assume at this point that the issue has to do with interaction among the parts. If it is not already a known bug, then I doubt I will be able to isolate the issue without more work than it is worth to me. Feb 16, 2017 at 0:18

I had the exact same problem and when researching found this answer immediately, yet it did not solve my problem.

It seems to be necessary to pass the superscripts or subscript as optional argument to the \gls{} call in the form of \gls{<name>}[_{xx}^{yy}]. Below is an example of this in action:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{glossaries}

\newglossaryentry{sym}{
name = {\ensuremath{\mathbb{R}}},
description = {Real numbers}
}

\makeglossaries

\begin{document}

$\gls{sym}[^3_x]$ in a text.
\begin{align}
\gls{sym}[_t^{2\times3}]
\end{align}

\printglossaries
\end{document}

And this is the result:

It's hard to tell what the problem is. Trying to simulate it I was unable to recreate it.

\documentclass {article}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{glossaries}

\newglossaryentry{coprod}
{
name = {\ensuremath{\coprod}},
description = {The coproduct in the category of sets, i.e., the disjoint union},
sort = coprod,
symbol = {\ensuremath{\coprod}}
}

\begin{document}
coprod in a paragraph $\coprod_{1}^{2}$
$\coprod_{1}^{2}$

gls in paragraph $\gls{coprod}_{1}^{2}$
$\gls{coprod}_{1}^{2}$

\end{document}

It sounds like you are not in display style, so either you using \gls in a $$environment, in which case the super and subscript SHOULD be on the side, or there's some other problem. In any case, try defining name = {\ensuremath{\displaystyle\coprod}}, • Thanks (+1). I tried adding the \displaystyle but it didn't help. If I replace the \gls{coprod} in the body of my document with \coprod, it prints as I want it to. Could glossaries be interacting badly with some other package? Feb 16, 2017 at 0:18 • maybe... hard to tell, that's why a MWE is needed... If I had to guess I'd bet on the documentclass rather than a package, are you using some sort of thesis documentclass ? Feb 16, 2017 at 7:37 • I'm using \documentclass{report} Feb 16, 2017 at 13:06 • When I try your code with \documentclass{report} instead of {article} it still looks fine. I think that figuring out a MWE is going to take far more work than it's worth to me. I will either just have to live with the bad formatting, figure out a manual workaround, or else take \coprod out of the glossary. I posted the question hoping it was a known bug. Feb 16, 2017 at 13:10 • In the  environment, I can get around the need to fix this using \underset and \overset. In the$$ environment, it's still a problem because although the subscript/superscript are to the right like they should be, they're further from the \coprod symbol than they should be, and too close together. Feb 16, 2017 at 13:29