# supremum with glossaries

Let's assume that you wish to reference all occurrences of a particular mathematical operator, say, supremum \sup, in a glossary. How? Well, my try would be to \let\sup\relax and then \DeclareMathOperator{\sup}{\gls{...}}. However, this approach generates unwanted horizontal space in front of "sup". How to get rid of it by default and still maintain the hyperlinks? Below, I compare the standard \sup with my approach.

Code:

\documentclass{svmono}%%% Obtainable from https://www.springer.com/gp/authors-editors/book-authors-editors/manuscript-preparation/5636
\mathtoolsset{mathic=true} %%% See https://tex.stackexchange.com/a/3496/
%%% The next hack improves how hyperref jives with svindd.ist, see https://tex.stackexchange.com/a/429446
\makeatletter
\def\@commahyperpage#1{\@@commahyperpage#1,\,,\\}
\def\@@commahyperpage#1,\,#2,#3\\{%
\ifx\\#2\\%
\else
\fi
}
\makeatother
\usepackage[makeindex,toc,nogroupskip,nomain]{glossaries-extra}
\setglossarystyle{long3col}\renewcommand{\glspagelistwidth}{10em}
\GlsSetQuote{+} %%% Hack to work with makeindex
\newglossary[nlg]{notation}{not}{ntn}{Notation}
\makeglossaries
\glssetcategoryattribute{mathoperator}{hyperoutside}{false}
\glssetcategoryattribute{mathoperator}{textformat}{mathop}
\newglossaryentry{not:supremum}{type=notation, name={$$\mathrm{sup}$$}, category=mathoperator, text={\mathop{\mathrm{sup}}}, sort={supremum}, description={The supremum of a set is the smallest upper bound for the set.}}
\DeclareMathOperator{\mysup}{\gls{not:supremum}}
\begin{document}
\begin{align*}
f(\sup S) &= \sup f(S)\\
f(\mysup S) &= \mysup f(S)
\end{align*}
\printglossaries
\end{document}


Output, page 1:

Output, page 3:

As you see, there is some unwanted space between "(" and "sup" as well as some more space between "=" and "sup".

(An aside: I apologize for the size of the the question; a prior smaller revision of the question seems to have a technically correct but a useless answer.)

• \DeclareMathOperator{\mysup}{sup\glsadd{not:supremum}} seems to work in your MWE, but I don't know if it works in general and how it interacts with the links you intend to use later. Jun 6, 2018 at 20:30
• Ah just as I feared, you lose the linking from \gls to the index with \glsadd{not:supremum}. Sorry ... Jun 6, 2018 at 20:51
• Please, use standard classes for minimal examples, if specific features are not needed. Jun 6, 2018 at 21:04

I don't think it's a good idea to index every appearance of an object.

Anyway, the problem is that an ordinary atom is inserted in an inappropriate spot, which you can cure with \!

\documentclass{article}
\mathtoolsset{mathic=true} %%% See https://tex.stackexchange.com/a/3496/
%%% The next hack improves how hyperref jives with svindd.ist, see https://tex.stackexchange.com/a/429446
\makeatletter
\def\@commahyperpage#1{\@@commahyperpage#1,\,,\\}
\def\@@commahyperpage#1,\,#2,#3\\{%
\ifx\\#2\\%
\else
\fi
}
\makeatother
\usepackage[makeindex,toc,nogroupskip,nomain]{glossaries-extra}

\setglossarystyle{long3col}\renewcommand{\glspagelistwidth}{10em}

\GlsSetQuote{+} %%% Hack to work with makeindex
\newglossary[nlg]{notation}{not}{ntn}{Notation}
\makeglossaries

\glssetcategoryattribute{mathoperator}{hyperoutside}{false}
\glssetcategoryattribute{mathoperator}{textformat}{mathop}

\let\supop\sup \let\sup\relax
\DeclareMathOperator*{\sup}{\gls{not:supremum}}

\newglossaryentry{not:supremum}{
type=notation,
name={$$\supop$$},
category=mathoperator,
text=\!\supop,
sort={supremum},
description={The supremum of a set is the smallest upper bound for the set.}
}

\begin{document}
\begin{align*}
f(\supop S) &= \supop f(S)\\
f(\sup S) &= \sup f(S) \\
\max\sup\max &= \max\supop\max
\end{align*}

\printglossaries

\end{document}


• @MdAyquassar No, that empty atom causes the insertion of a thin space. Jun 6, 2018 at 21:11
• @MdAyquassar Sorry, it should have been \DeclareMathOperator*, fixed. I just modified your code. Jun 7, 2018 at 22:58