1

I am using acronym package. I was wondering if there is a way to force the package skip showing abbreviation for items with less than 3, appearances throughout the document.

For example:

\documentclass{article}
\usepackage{acronym}
\acrodef{SYS}{system}
\acrodef{NET}{network}

\begin{document}
A \ac{NET} is a set of \acp{SYS}. A super-\ac{NET} is a \ac{NET} of \acp{NET}. 
\end{document}

This will yield:

A network (NET) is a set of systems (SYSs). A super-NET is a NET of NETs.

However, I want to have:

A network (NET) is a set of systems. A super-NET is a NET of NETs.

So acronym package automatically count the number of appearances and show the full text, without abbreviation, if they appear less than 3 times.

cgnieder
  • 66,645
Jeff
  • 359
  • 1
  • 3
  • 7
  • I'm confused, in your MWE you only seem to want to omit the (SYSs), which does not seem to fit with your description? Also, according to the manual "The first time you use an acronym, the full name of the acronym along with the acronym in brackets will be printed...The next time you access the acronym only the acronym will be printed." So, k=1 is what happens by default. –  Dec 11 '17 at 14:25
  • In my MWE, I want to have ''systems'' instead of ''systems (SYSs)''. To avoid confusion, I removed $k$ and asked for 3 appearances. I agree that $k=1$ is what happens by default, but I want to change it to 3. – Jeff Dec 11 '17 at 15:08
  • You can do this with glossaries. (See, for example, https://tex.stackexchange.com/questions/338667 .) I don't know how to do it with the acronym package. – Nicola Talbot Dec 11 '17 at 15:29
  • OK, you want to have ''systems'' instead of ''systems (SYSs)'' but you said that also wanted to have "network (NET)" the first three times that \ac{NET} is used.... –  Dec 11 '17 at 17:14

1 Answers1

1

Here's a hack that directly makes the acronym package work as you described. I haven't tested it with other features of the package, so it might take a few extra definitions to make this work smoothly with some other commands in the package.

\documentclass{article}

\usepackage{acronym}
%% Hack here:
\makeatletter
\let\oldacronymused\acronymused
\AtBeginDocument{\let\acronymused\oldacronymused}
\renewcommand*{\acronymused}[1]{%
    \expandafter\ifx\csname acused@#1\endcsname\AC@used
        \expandafter\xdef\csname acusedcount@#1\endcsname{\the\numexpr1+\csname acusedcount@#1\endcsname}
    \else
        \global\expandafter\let\csname acused@#1\endcsname\AC@used
        \global\let\AC@populated\AC@used
        \expandafter\gdef\csname acusedcount@#1\endcsname{1}
    \fi
}

\def\AC@iffewuses#1{%
    \expandafter\ifx\csname acusedcount@#1\endcsname\relax
        \expandafter\@firstoftwo
    \else
        \ifnum\csname acusedcount@#1\endcsname<\appearancecount\relax
            \expandafter\@firstoftwo\romannumeral-`0%
        \else
            \expandafter\@secondoftwo\romannumeral-`0%
        \fi
    \fi
}

\let\@@ac\@ac
\def\@ac#1{\AC@iffewuses{#1}{\ifAC@starred\acl*{#1}\else\acl{#1}\fi}{\@@ac{#1}}}

\let\@@acp\@acp
\def\@acp#1{\AC@iffewuses{#1}{\ifAC@starred\aclp*{#1}\else\aclp{#1}\fi}{\@@acp{#1}}}
\makeatother
%% end hack


\def\appearancecount{3}% Display acronym if used at least 3 times.
\acrodef{SYS}{system}
\acrodef{NET}{network}

\begin{document}

A \ac{NET} is a set of \acp{SYS}. A super-\ac{NET} is a \ac{NET} of \acp{NET}.

\ac{SYS}
\end{document} 
Hood Chatham
  • 5,467