# Do not add glossaries entries to numberlist from inside the glossary

With the glossaries package and activated numberlist, I want to avoid that a reference appears inside the numberlist, when I reference an entry using one of the \gls-like commands inside another entry of the glossary. Effectively, the numberlist should only show pages inside the main document that referenced to the respective entries.

Here is an MWE to demonstrate what I want to achieve:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[nopostdot,style=indexgroup,nolist]{glossaries}

\makenoidxglossaries
\newglossaryentry{target}
{
name={target},
description={Foo foo bar. Page 2 should not appear here.}
}
{
description={This one has a \gls{target}, but this use of \gls{target} should not appear in the numberlist.}
}

\begin{document}

This usage of \gls{target} should appear in the number list.

We also have \glspl{link} here.

\newpage

\printnoidxglossary

\end{document}


With just the base glossaries package you can use \glshyperlink instead of \gls:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[nopostdot,style=indexgroup,nolist]{glossaries}

\makenoidxglossaries
\newglossaryentry{target}
{
name={target},
description={Foo foo bar. Page 2 should not appear here.}
}
{
description={This one has a \glshyperlink{target}, but this use of
\glshyperlink{target} should not appear in the numberlist.}
}

\begin{document}

This usage of \gls{target} should appear in the number list.

We also have \glspl{link} here.

\newpage

\printnoidxglossary

\end{document}


This omits page 2 from the number list:

Without hyperref, \glshyperlink{label} effectively just does \glsentrytext{label}. With hyperref, it will also have a hyperlink.

With the glossaries-extra extension package you can switch off indexing with the noindex option. (The nopostdot option is automatically implemented. For some reason, glossaries-extra doesn't seem to like nolist, so I've removed it. I'll look into that.)

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[style=indexgroup]{glossaries-extra}

\makenoidxglossaries
\newglossaryentry{target}
{
name={target},
description={Foo foo bar. Page 2 should not appear here.}
}
{
description={This one has a \gls{target}, but this use of
\gls{target} should not appear in the numberlist.}
}

\begin{document}

This usage of \gls{target} should appear in the number list.

We also have \glspl{link} here.

\newpage

\GlsXtrSetDefaultGlsOpts{noindex}

\printnoidxglossary

\end{document}


In both examples, if target isn't indexed elsewhere in the document it won't appear in the glossary. The result is the same as before.

• Thanks! I'll have to use the nolist option due to compatibility issues. With glshyperlink, are there also plural forms etc? Aug 10 '17 at 13:45
• @languitar \glshyperlink has an optional argument, so you could do \glshyperlink[\glsentryplural{label}]{label} (or you can just to \glsentryplural{label} if you're not using hyperref). I'll see if I can get the nolist bug fix. Aug 10 '17 at 13:49
• @languitar The nolist problem was caused by a weird interaction between glossaries.sty and glossaries-extra.sty. I've fixed the problem by making a minor alteration to glossaries.sty. So to fix the nolist bug in glossaries-extra.sty you need at least v4.31 (2017-08-10) of the base glossaries.sty. (Allow a few days for the new version to make it into the TeX distributions.) Aug 10 '17 at 15:15
• But the fixed version is already on CTAN? I could put it to my project for now. Aug 11 '17 at 8:33
• @languitar Alternatively just copy the glossaries.sty file to your document's directory as a temporary fix. That's the only file that's been changed (aside from version details) Aug 11 '17 at 9:58