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[colorlinks]{hyperref}
\usepackage{glossaries-extra}
\makeglossaries
\GlsXtrSetDefaultGlsOpts{noindex}
\newglossaryentry{sample}{name={sample},description={an example}}
\begin{document}
This is a sample document.
The \gls{sample} entry is used on this page but isn't indexed.
\newpage
The \gls[noindex=false]{sample} entry is used on this page and is indexed.
\newpage
The \gls{sample} entry is used on this page but isn't indexed.
\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[colorlinks]{hyperref}
\usepackage{glossaries-extra}
\makeglossaries
\GlsXtrSetDefaultGlsOpts{noindex}
\GlsXtrSetAltModifier{>}{noindex=false}
\newglossaryentry{sample}{name={sample},description={an example}}
\begin{document}
This is a sample document.
The \gls{sample} entry is used on this page but isn't indexed.
\newpage
The \gls>{sample} entry is used on this page and is indexed.
\newpage
The \gls{sample} entry is used on this page but isn't indexed.
\newpage
\printglossaries
\end{document}
\gls{rhubarb}
only with those instances that you DO want to show up in glossary, and simply typerhubarb
where you don't.