[Tex/LaTex] Use of starred \ac commands in the acronym package

acronyms

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?

Best Answer

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}