I think this may be easier to do with the extension package glossaries-extra
. This provides extra keys and a more flexible abbreviation interface. Abbreviations are defined using \newabbreviation[
options]{
label}{
short}{
long}
but to assist users who have pre-existing glossaries
code, \newacronym
is redefined to use this new interface, so \newacronym[
options]
is now equivalent to \newabbreviation[category=acronym,
options]
, but the style now needs to be set using \setabbreviationstyle[acronym]
instead of \setacronymstyle
. The short and long forms are now accessed using \glsxtrshort
and \glsxtrlong
. The original \acrshort
and \acrlong
commands may still be used, but they don't work properly if the document has multiple abbreviation styles. (The base glossaries
package only allows one abbreviation style.)
The extension package also provides a new key noindex
which can be used in the optional argument of commands like \gls
. We can therefore take advantage of these new features to redefine \acrshort
in terms of \glsxtrshort
with the noindex
key automatically set:
\renewcommand*{\acrshort}[1][]{\glsxtrshort[noindex,#1]}
Now none of your \acrshort
commands will perform any indexing (unless this setting is overridden using \acrshort[noindex=false]
.
Here's a modified version of your MWE. I've added a couple of \gls
commands for comparison:
\documentclass{article}
\usepackage{hyperref}
\usepackage{glossaries-extra}
\makeglossaries
\setabbreviationstyle[acronym]{long-short}
\newacronym{sdk}{SDK}{Software Development Kit}
\renewcommand*{\acrshort}[1][]{\glsxtrshort[noindex,#1]}
\begin{document}
Test \acrshort{sdk}
\newpage
Test \acrshort{sdk}.
\newpage
Test \acrshort{sdk}\newpage
Test \newpage
Test \acrshort{sdk}\newpage
Test [gls] \gls{sdk}
\newpage
Test \newpage
Test [gls] \gls{sdk}
\newpage
Test \newpage
Test \acrshort{sdk}\newpage
Test \acrshort{sdk}\newpage
\printglossaries
\end{document}
The glossary now only has two entries in the location list for sdk
.

These correspond to the two instances of \gls{sdk}
. These can be dealt with through the indexonlyfirst
package option:
\usepackage[indexonlyfirst]{glossaries-extra}
or to only apply this option to entries that have the category
set to acronym
(which is done by \newacronym
):
\glssetcategoryattribute{acronym}{indexonlyfirst}{true}
Note that the indexonlyfirst
setting will override noindex=false
in commands like \gls
(but you can still use noindex=false
for commands like \acrshort
).
You can still use the acronym
package option with glossaries-extra
\usepackage[acronym]{glossaries-extra}
with the glossary type identified by \acronymtype
(and \printacronyms
as a shortcut for \printglossary[type=\acronymtype]
, or you can use the abbreviations
package option:
\usepackage[abbreviations]{glossaries-extra}
with \printabbreviations
(the glossary type is can be identified using \glsxtrabbrvtype
).
Here's the updated MWE:
\documentclass{article}
\usepackage{hyperref}
\usepackage[abbreviations]{glossaries-extra}
\makeglossaries
\glssetcategoryattribute{acronym}{indexonlyfirst}{true}
\setabbreviationstyle[acronym]{long-short}
\newacronym{sdk}{SDK}{Software Development Kit}
\renewcommand*{\acrshort}[1][]{\glsxtrshort[noindex,#1]}
\begin{document}
Test \acrshort{sdk}
\newpage
Test \acrshort{sdk}.
\newpage
Test \acrshort{sdk}\newpage
Test \newpage
Test \acrshort{sdk}\newpage
Test [gls] \gls{sdk}
\newpage
Test \newpage
Test [gls] \gls{sdk}
\newpage
Test \newpage
Test \acrshort{sdk}\newpage
Test \acrshort{sdk}\newpage
\printabbreviations
\end{document}
This produces the glossary:
