From 2.3 Entry Counting Modifications:
The \glsenableentrycount
command is modified to allow for the
entrycount
attribute. This means that you not only need to enable
entry counting with \glsenableentrycount
, but you also need to set the
appropriate attribute (see §5 Categories).
For example, instead of just doing:
\glsenableentrycount
you now need to do:
\glsenableentrycount
\glssetcategoryattribute{abbreviation}{entrycount}{1}
This will enable the entry counting for entries in the abbreviation
category, but any entries assigned to other categories will be
unchanged.
This allows the entry counting to be applied to certain types of entries, and it also allows you to set a different trigger value. There should have been a warning in your transcript file:
Package glossaries-extra Warning: Entry counting has been enabled
(glossaries-extra) with \glsenableentrycount but the
(glossaries-extra) attribute `entrycount' hasn't
(glossaries-extra) been assigned to any of the defined
(glossaries-extra) entries.
This is a reminder that you need to set the entrycount
attribute.
In your example, you have entry definitions like
\newglossaryentry{SRS}{ type={acronym}, sort={stimulated Raman scattering}, name={SRS}, short={SRS}, long={stimulated Raman scattering}, first={stimulated Raman scattering (SRS)}, description={stimulated Raman scattering } }
Since this doesn't explicitly set the category, it defaults to the general
category, so you'd need to add:
\glssetcategoryattribute{general}{entrycount}{1}
However, this type of explicit definition of an abbreviation using \newglossaryentry
defeats the purpose of the entry counting, since first
contains the abbreviation so it will always show (since it's a regular entry, \cgls
internally uses the value of the first
key). If you want the abbreviation suppressed with \cgls
, you need to define the abbreviation using \newabbreviation
(or \newacronym
).
Example:
\documentclass{article}
\usepackage[savewrites=true,nogroupskip,acronym]{glossaries-extra}
\usepackage{scrwfile}
\ifdefined\HCode \usepackage{morewrites} \else \fi
\makeindex % activate index-making
\makeglossaries
\glsenableentrycount % enable \cgls, \cglspl, \cGls, \cGlspl
\glssetcategoryattribute{acronym}{entrycount}{1}
\let\gls\cgls
\let\glspl\cglspl
\let\Gls\cGls
\let\Glspl\cGlspl
\glssetnoexpandfield{first}
\glssetnoexpandfield{firstpl}
\setabbreviationstyle[acronym]{long-short}
\newacronym[sort={stimulated Raman scattering}]
{SRS}{SRS}{stimulated Raman scattering}
\newacronym[sort={coherent anti-Stokes Raman scattering}]
{CARS}{CARS}{coherent anti-Stokes Raman scattering}
\glssetexpandfield{first}
\glssetexpandfield{firstpl}
%=============================================================================
% END GLOSSARY SETUP
%=============================================================================
\begin{document}\noindent\begin{sloppypar}
\gls{CARS} -- I shouldn't see the abbreviation
\cgls{SRS} -- I shouldn't see the abbreviation
\clearpage\end{sloppypar}\end{document}
This produces:

Now suppose I change the CARS
entry so that it uses \newabbreviation
instead of \newacronym
. This sets the category to abbreviation
, so it's not controlled by the entry counting mechanism (which has only been enabled for the acronym
category).
\newabbreviation[sort={coherent anti-Stokes Raman scattering}]
{CARS}{CARS}{coherent anti-Stokes Raman scattering}
Now this entry includes the abbreviation even though it's only used once:

Edit: If you really want to use \newglossaryentry
instead of \newabbreviation
(or \newacronym
) then you'll need to redefine \cglsformat
to just check for the long
field (and ignore the regular atttibute). For example:
\documentclass{article}
\usepackage[savewrites=true,nogroupskip,acronym]{glossaries-extra}
\makeglossaries
\glsenableentrycount % enable \cgls, \cglspl, \cGls, \cGlspl
\glssetcategoryattribute{acronym}{entrycount}{1}
\let\gls\cgls
\let\glspl\cglspl
\let\Gls\cGls
\let\Glspl\cGlspl
\glssetnoexpandfield{first}
\glssetnoexpandfield{firstpl}
\newglossaryentry{SRS}{
type={acronym},
category={acronym},% <- category
sort={stimulated Raman scattering},
name={SRS},
short={SRS},
long={stimulated Raman scattering},
first={stimulated Raman scattering (SRS)},
description={stimulated Raman scattering}
}
\newglossaryentry{CARS}{
type={acronym},
category={acronym},% <- category
sort={coherent anti-Stokes Raman scattering},
name={CARS},
short={CARS},
long={coherent anti-Stokes Raman scattering},
first={coherent anti-Stokes Raman scattering (CARS)},
description={coherent anti-Stokes Raman scattering}
}
\glssetexpandfield{first}
\glssetexpandfield{firstpl}
% Not using \newabbreviation so redefine \cglsformat
% to just check for the long field.
\renewcommand*{\cglsformat}[2]{%
\ifglshaslong{#1}{\glsentrylong{#1}}{\glsentryfirst{#1}}#2%
}
\begin{document}\noindent\begin{sloppypar}
\gls{CARS} -- I shouldn't see the abbreviation
\cgls{SRS} -- I shouldn't see the abbreviation
\clearpage\end{sloppypar}\end{document}
This produces:

If you're still getting the above warning, first check that the category
has been correctly set for your entries. For example, if you add:
Category of CARS: \glscategory{CARS}.
Category of SRS: \glscategory{SRS}.
to your document, the PDF should show

If it doesn't, then check the category
element in \newglossaryentry
.
Next check that the entrycount
attribute has been correctly set. You can do this by adding the following to your document:
entrycount attribute for CARS: \glsgetattribute{CARS}{entrycount}.
entrycount attribute for SRS: \glsgetattribute{SRS}{entrycount}.
This should show

If it doesn't check the spelling of the category label and the attribute label in
\glssetcategoryattribute{acronym}{entrycount}{1}
If you need to use the plural or case-changing versions, you similarly need to redefine the analogous commands. The first letter uppercase command \cGls
uses \cGlsformat
:
\renewcommand*{\cGlsformat}[2]{%
\ifglshaslong{#1}{\Glsentrylong{#1}}{\Glsentryfirst{#1}}#2%
}
(Make sure you have at least v1.14 of glossaries-extra
that fixes the bug with \cGls
.)
The all capitals version \cGLS
uses \cGLSformat
:
\renewcommand*{\cGLSformat}[2]{%
\ifglshaslong{#1}%
{\MakeUppercase{\glsentrylong{#1}}}
{\MakeUppercase{\glsentryfirst{#1}}}\MakeUppercase{#2}%
}
(or you may prefer to use \mfirstucMakeUppercase
to be consistent with \GLS
.)
If you need to use the plural forms, remember that the long
, short
, longplural
and shortplural
keys were actually provided for \newacronym
and \newabbreviation
and require explicit setting if used directly in \newglossaryentry
. This means that if you're not using the abbreviation interface but are explicitly uses \newglossaryentry
(as in the above example), then longplural
and shortplural
must be explicitly set if required, otherwise they will be empty.
There isn't a plural equivalent to \ifglshaslong
, although you can use \ifglshasfield
instead. There are several ways of redefining \cglsplformat
. The simplistic approach is:
\renewcommand*{\cglsplformat}[2]{%
\ifglshaslong{#1}{\glsentrylongpl{#1}}{\glsentryfirstpl{#1}}#2%
}
This just checks if the long
field has been set. In the above example, the long
field has been set (so \ifglshaslong
is true) but longplural
hasn't been set, which means that \glsentrylongpl
will expand to nothing for the entries in the above example. It really depends on what you want to happen in this situation. You could instead check for longplural
:
\renewcommand*{\cglsplformat}[2]{%
\ifglshasfield{longplural}{#1}{\glsentrylongpl{#1}}{\glsentryfirstpl{#1}}#2%
}
or you might want to default to the long
field if long
has been set but longplural
hasn't:
\renewcommand*{\cglsplformat}[2]{%
\ifglshaslong{#1}%
{\ifglshasfield{longplural}{#1}{\glsentrylongpl{#1}}{\glsentrylong{#1}}}%
{\glsentryfirstpl{#1}}#2%
}
Similarly for \cGlsplformat
and \cGLSplformat
.
\glssetcategoryattribute{abbreviation}{entrycount}{1}
and\glssetcategoryattribute{acronym}{entrycount}{1}
but no change. I will update my question to reflect where I inserted this. – EngBIRD Jul 19 '16 at 19:41\newglossaryentry
to\newacronym
is not ideal. – EngBIRD Jul 19 '16 at 19:49\glssetcategoryattribute{acronym}{regular}{false}
\glssetcategoryattribute{acronym}{entrycount}{1}
and\glsenableentrycount
. My log file still includes thePackage glossaries-extra Warning: Entry counting has been enabled
that you describe below in your answer. Is there anything else from my log file I can quote that would be helpful? – EngBIRD Jul 19 '16 at 20:11