9

I'm trying to use the starred commands for the acronym package, i.e. \ac*, \acs*, \acl*, etc.

But, I can't seem to get the package not to set the AC@used flag (which I believe is used by the acronym package to track commands that are used in the document.

Below is a minimum working example:

\documentclass{article}

\usepackage{acronym}
\newacro{TMN}{This Means Nothing}

\begin{document}

First use works as intended:

\ac*{TMN}

But the acronym is still marked as used:

\ac*{TMN}

\end{document}

The end result is something like this:

First use works as intended:

This Means Nothing (TMN)

But the acronym is still marked as used:

TMN

Any ideas? Or should I switch to the glossaries package?

Shaun Siau
  • 218
  • 1
  • 3
  • 8

2 Answers2

6

It appears as we have both misinterpreted the meaning of \ac* as I too interpreted the documentation the same way. As per @GonzaloMedina's comment:

The starred versions only control if the acronym should appear in the acronyms list or not; the starred versions do not control how the acronym appears in the body of the document.

However, one way to get the desired behavior is to redefine \@ac which is copied from the acronym package, and insert a \AC@reset{#1} call in three places which seems to produce the desired results:

enter image description here

Note that you could use \acf to always get the full name as well.

\documentclass{article}
\usepackage{acronym}

\makeatletter
\renewcommand{\@ac}[1]{%
  \ifAC@dua
     \ifAC@starred\acl*{#1}\AC@reset{#1}\else\acl{#1}\fi%
  \else
     \expandafter\ifx\csname ac@#1\endcsname\AC@used%
     \ifAC@starred\acs*{#1}\AC@reset{#1}\else\acs{#1}\fi%
   \else
     \ifAC@starred\acf*{#1}\AC@reset{#1}\else\acf{#1}\fi%
   \fi
  \fi}
\makeatother

\newacro{TMN}{This Means Nothing}
\newacro{DMS}{Does Means Something}

\begin{document}
1st use works as intended: \ac*{TMN}\par
2nd use works as intended: \ac{TMN}\par
3nd use works as intended: \ac{TMN}\par
\medskip
1st use works as intended: \ac{DMS}\par
2nd use works as intended: \ac{DMS}\par
\end{document}
Peter Grill
  • 223,288
  • I think that there's a misunderstanding. The starred versions only control if the acronym should appear in the acronyms list or not; the starred versions do not control how the acronym appears in the body of the document. – Gonzalo Medina Oct 16 '11 at 01:02
  • @GonzaloMedina: Thanks that makes sense. I have included your comments in the answer so it is not missed when others come across this. – Peter Grill Oct 16 '11 at 01:13
6

As I understand it, the starred versions don't mark an acronym as "used", but only to control if the acronym should be shown or not when the printonlyused option has been used; in every other aspect they act the same as the unstarred versions. For example: the following code won't print the acronym TMN in the list of acronyms, although for both acronyms, the first time they appear in the document, you'll see the description and the acronym, and the second time you will only see the acronym:

\documentclass{article}
\usepackage[printonlyused]{acronym}

\begin{document}

\ac*{TMN}\ac*{TMN}

\ac{TMS}\ac{TMS}

\begin{acronym}
\acro{TMN}{This Means Nothing}
\acro{TMS}{This Means Something}
\end{acronym}

\end{document}

enter image description here

So the meaning of a starred versions is: "use it always for each occurrence of an acronym to prevent it from appearing in the list of acronyms".

Gonzalo Medina
  • 505,128