1

I've been trying to ignore acronyms that are only used once, as described in this question. Unfortunately, I have two issues:

  1. 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?
  2. 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: result of tex compile

4
  • Have you tried my answer for that question which doesn't try to hack the internal commands but instead uses a new feature introduced in glossaries version 4.14? Commented Mar 10, 2015 at 9:46
  • I have just tried, but even with version 4.14 it gives me an undefined control sequence \glsenableentrycount error.
    – DoubleYou
    Commented Mar 11, 2015 at 23:45
  • Can you double-check that the log file contains 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.) Commented Mar 12, 2015 at 19:04
  • It indeed uses the oldest one. Looks like my updater/package manager has issues - so posted a separate question related to that here.
    – DoubleYou
    Commented Mar 15, 2015 at 23:49

1 Answer 1

1

With glossaries 4.14, released not long after the question was posted, it is possible to ignore acronyms and glossary items that are only used once, with the results exactly as requested above.

The example above converts to the following:

\documentclass{article}

\usepackage{glossaries}

\makeglossaries

\glsenableentrycount

\newacronym{ANO}{ANO}{Acronym Number One}
\newacronym{ANT}{ANT}{Acronym Number Two}
\newglossaryentry{test} {
    name={test},
    description={A test is used for testing}
}

\begin{document}

\printglossaries

\noindent
\cgls{ANO}, \cgls{ANO}\\
\cgls{ANT}\\
\gls{test}

\end{document}

Note the different position of \makeglossaries, the addition of \glsenableentrycount and the use of \cgls instead of \gls.

Referred to by Nicola from the answer here, where also more information can be found on how this works.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .