I've been trying to ignore acronyms that are only used once, as described in this question. Unfortunately, I have two issues:
- The once-used abbreviation is still displayed in as the first entry (long text with the abbreviation in brackets instead of long text only). The message
Patching failed (2)
showed up so maybe the\patchcmd
needs updating to reflect the latest glossaries code? - The etoolbox issues a
'Boolean '\ifglo@test@usedonlyonce' undefined
error for each\newglossaryentry
.
How can I use both acronyms and glossary entries with once-used acronyms being ignored? Once-used glossary entries still have to be displayed in the list but acronyms should not.
Minimum example that issues the errors:
\documentclass{article}
\usepackage{etoolbox}
\usepackage{glossaries}
\makeatletter
\appto\newacronymhook{%
\newbool{glo@\the\glslabeltok @usedonlyonce}% define an additional switch per acronym
}
\patchcmd{\@gls@}{%
\glsunset{#2}%
}{% write appropriate information to the main auxiliary file
\ifglsused{#2}{%
\write\@auxout{\global\setbool{glo@#2@usedonlyonce}{false}}%
}{%
\write\@auxout{\global\setbool{glo@#2@usedonlyonce}{true}}%
}%
\glsunset{#2}%
}{}{\message{^^JPatching failed (1)^^J}}
\patchcmd{\@gls@}{%
\glsentryfirst{#2}%
}{% print the long form of the acronym if the acronym is used only once
\ifbool{glo@#2@usedonlyonce}{\glsentrylong{#2}}{\glsentryfirst{#2}}%
}{}{\message{^^JPatching failed (2)^^J}}
\let\old@do@wrglossary\@do@wrglossary
\renewcommand{\@do@wrglossary}[1]{\ifbool{glo@#1@usedonlyonce}{}{\old@do@wrglossary{#1}}}
\makeatother
\newacronym{ANO}{ANO}{Acronym Number One}
\newacronym{ANT}{ANT}{Acronym Number Two}
\newglossaryentry{test} {
name={test},
description={A test is used for testing}
}
\makeglossaries
\begin{document}
\printglossaries
\noindent
\gls{ANO}, \gls{ANO}\\
\gls{ANT}\\
\gls{test}
\end{document}
I have MikTeX and TeXnicCenter setup as described here. The result I get when the \newglossaryentry
and corresponding \gls
is commented out:
glossaries
version 4.14?undefined control sequence \glsenableentrycount
error.Package: glossaries 2015/02/28 v4.14
. The example in my answer I linked to compiles without error for me. (It may be that there's an older version installed as well that's being loaded instead, which can happen sometimes.)