# Glossaries page list with only specified links

When using the glossaries package to generate a glossary the page list for each entry gets very long when the \gls{} command is used in many places, e.g.

I want to be able to suppress the page list (keeping the link in the text to the glossary) and leave only specified link entries, e.g. like the one in bold, which is nicely achieved with

 \gls[format=hyperbf]{label}


So something similar to, e.g.

 \gls[format=pagelistinclude]{label}


such that this appear in the page list, while just \gls{label} does not.

How can I make this?

• Just use \gls{rhubarb} only with those instances that you DO want to show up in glossary, and simply type rhubarb where you don't. Dec 30, 2016 at 16:13

The glossaries-extra provides an extra key noindex that can be used in the optional argument of commands like \gls that suppresses the indexing for that use, so you can use \gls{label} to index as normal and \gls[noindex]{label} to suppress the indexing. However, where you more often want to suppress the indexing, you may find it easier to switch off the default indexing, which can be done with:

\GlsXtrSetDefaultGlsOpts{noindex}


and then you just need to switch it on using \gls[noindex=false]{label} where you actually want to index the entry. For example:

\documentclass{article}

\usepackage{glossaries-extra}

\makeglossaries

\GlsXtrSetDefaultGlsOpts{noindex}

\newglossaryentry{sample}{name={sample},description={an example}}

\begin{document}
This is a sample document.

\newpage

\newpage

\newpage
\printglossaries

\end{document}


You may prefer to set up a modifier character to provide a shorthand version. Choose a character, say, > and set it as the modifier:

\GlsXtrSetAltModifier{>}{noindex=false}


Now \gls>{label} is equivalent to \gls[noindex=false]{label}.

\documentclass{article}

\usepackage{glossaries-extra}

\makeglossaries

\GlsXtrSetDefaultGlsOpts{noindex}
\GlsXtrSetAltModifier{>}{noindex=false}

\newglossaryentry{sample}{name={sample},description={an example}}

\begin{document}
This is a sample document.

\newpage

\newpage

\newpage
\printglossaries

\end{document}


Use a dummy counter (that produces no text) for the entries where you don't want the page numbers.

\newcounter{dummy}
\renewcommand\thedummy{}

This one gets the bold reference in the glossary:
\gls[format=hyperbf]{term}
\newpage

This one will get a link to the glossary, but no page number in the glossary:
\gls[counter=dummy]{term}


You can even make the counter=dummy the default, by giving an extra optional argument to \newglossary, like in

\newglossary[slg]{symbol}{sot}{stn}{Symbols}[dummy]


or giving it as a package option:

\usepackage[counter=dummy,...]{glossaries}


But then you have at add the counter=page option for those entries that must have the page number registered.

\gls[format=hyperbf,counter=page]{term}


The \usepackage option might not be the best choice if you have more than one glossary, like a nomenclature.