As @cfr has mentioned, the problem is \glsresetall
, which marks each entry as unused. This means that the next time it's used, it's considered "first use" and so is indexed.
I think this is a job for glossaries-extra
, which extends the glossaries
package. Your example can be adapted as follows:
\documentclass{report}
\usepackage[abbreviations,% "acronyms" -> "abbreviations"
xindy,% no change from original
nomain % don't define "main" glossary
]{glossaries-extra}% "glossaries" -> "glossaries-extra"
\usepackage{glossary-mcols}
% setup abbreviation style
\setabbreviationstyle{footnote}
\renewcommand*{\glsfirstlongdefaultfont}[1]{\textit{#1}}
\renewcommand*{\glossentrydesc}[1]{%
\glsdoifexistsorwarn{#1}%
{%
\textit{\glsentrydesc{#1}}%
}%
}
% switch off automatic indexing
\GlsXtrSetDefaultGlsOpts{noindex}
%% glossary entries
\newabbreviation{NMR}{NMR}{Nuclear Magnetic Resonance}
\makeglossaries
\begin{document}
\glsresetall
A glossary acronym : \gls{NMR} \gls{NMR} \gls{NMR}.
\glsresetall
\newpage
The same acronym : \gls[noindex=false]{NMR} \gls{NMR} \gls{NMR}
\glsresetall
\newpage
A third time the same acronym : \gls{NMR} \gls{NMR} \gls{NMR}
\printglossaries
\end{document}
Here, instead of trying to index first use, the automatic indexing for all entries is suppressed using
\GlsXtrSetDefaultGlsOpts{noindex}
The indexing now has to be explicitly invoked by cancelling this setting using \gls[noindex=false]{NMR}
. This means you have precise control over which use of the term is actually indexed.
If you like, you can set up a modifier for commands such as \gls
to provide a shortcut for [noindex=false]
:
\GlsXtrSetAltModifier{!}{noindex=false}
Now you can just use \gls!{NMR}
instead of \gls[noindex=false]{NMR}
. (You can choose another symbol, if you prefer, but make sure it doesn't later have its category code changed. Don't use *
or +
as they're already modifiers.)
This produces:
You can modify the title using the optional argument of \printglossary
or \printabbreviations
to get it the same as with the straight glossaries
example:
\printglossary[type=\glsxtrabbrvtype,title=Acronyms]
or
\printabbreviations[title=Acronyms]
or you can redefine \abbreviationsname
\renewcommand{\abbreviationsname}{Acronyms}
You can retain the original \newacronym
commands, but you'll need to set the style using:
\setabbreviationstyle[acronym]{footnote}
instead of
\setacronymstyle{footnote}
This is because glossaries-extra
has different categories of abbreviations and acronym
is a sub-category. This allows you to have different styles for different types of abbreviations, which you can't do with glossaries
. (The original commands provided by glossaries
can be restored, if necessary, but they may conflict with some of the glossaries-extra
styles.)
I've moved the font command \textit
out of the abbreviation definition and adjusted the formatting commands using:
\renewcommand*{\glsfirstlongdefaultfont}[1]{\textit{#1}}
\renewcommand*{\glossentrydesc}[1]{%
\glsdoifexistsorwarn{#1}%
{%
\textit{\glsentrydesc{#1}}%
}%
}
This is unrelated, but is semantically better as it separates content from style. This is assuming that all your entries require italic. If that's not the case then just remove those lines.
\glsresetall
? Since that sets the first-use flag back to false, I think, ensuring it is added again on next use.\glsresetall
, the acronym would only be mentionned in fulled on page 1, and only page 1 will be added to the index. I want to get the acronyms cited in full only once between the\glsresetall
, which is what this does right now, but also that only page 2 is added to the index. Currently, it adds three occurences.