Similiar to acronym package: don't write acronym if single occurence i'd like to avoid listing acronyms that i only used once with the glossaries
package. The answer to this question Ignoring an acronym that is only used once contains code which detects one time use. Can i alter this code snippet to only print the acronym description without putting an entry+pagenumber into the glossary?
Sample:
\documentclass[8pt]{scrartcl}
\usepackage[xindy,style=long,numberline,savewrites=true,acronym,nomain]{glossaries}
\makeglossaries
\newacronym{seqse}{SE}{spin echo}
\newacronym{seqffe}{FFE}{fast field echo}
\newacronym{mri}{MRI}{magnetic resonance imaging}
\begin{document}
\printglossaries
\begin{itemize}
\item Multiple use: \gls{seqse}, \gls{seqse}, \gls{seqse}.
\item Multiple use: \gls{seqffe}, \gls{seqffe}.
\item One-time use: \gls{mri}.
\end{itemize}
\end{document}
Best Answer
Yes, this is possible. My first attempt was to define a new style that suppresses the output of items that are used only once (see the definition of
mylong
). But this fails when the style is "grouped", i.e., when there are group headings, or skips between the groups, as then a suppressed item that is the only item in a group leads to a superfluous group head.So we have to completely suppress that items that are used only once are written to the
acn
file. To achieve this, we hack into the output routine\@do@wrglossary
, and let it write only items that are used at least twice. After than that, we use the code from this answer.Note that you have to run
pdflatex
twice before creating the index with xindy/makeindex. BTW, this would be a nice feature request for theglossaries
package (@NicolaTalbot).