3

I'm using the acronym package to produce a list of abbreviations and acronyms. Now, I want that the full name is printed for one acronym on a specific place after it has been already used.

Example:

\documentclass{scrreprt}
\usepackage{acronym}
\begin{document}
\begin{acronym}
    \acro{REST}{Representational State Transfer}
\end{acronym}

\section{Somesection}
The API provides an \ac{REST} API and prints "Representational State Transfer (REST)". 
\subsection{Someothersection}
Now \ac{REST} should again print "Representational State Transfer (REST)"
\end{document}

I know the command \acresetall from the similar question Acronym package: Full name after each section / chapter, but dont want to use it because it resets all acronyms and I only want to reset one.

Is there another command which resets only one acronym?

  • 1
    Note that next time you ask a question it would be helpful to add a complete minimal example (MWE), like in my answer below. That makes it much easier to reproduce the behavior and to start writing a solution. Now, for my answer, I had to add several things and look up some syntax (e.g., \acro vs \newacro) before I could start. It did not take much time or effort, but still it would be nice if you make it as easy as possible to focus on the issue and not on the practical stuff around it. – Marijn Jan 18 at 15:24
  • Thanks for your input, youre right. I edited my question and it contains now a fully working example. :) – Joker Jan 18 at 15:34
4

To use the full form with the abbreviated form in brackets, you can use the \acf command. \acf treats the acronym like it appears the first time in the text.

For example, \acf{REST} will output "Representational State Transfer (REST)".

Please note that this is not "intelligent", as so far that it does not "reset" like \acresetall or \AC@reset{REST}. You should keep this in mind when adding a previous occurence of your acronym in the same section, etc.

For more information, see the acronym package documentation (page 1).

  • Thanks a lot. Seems like that was the command I was searching for. Can you elaborate why its "not" intelligent? Just because I would need to add \acf as well if add it before the initial \acf? – Joker Jan 18 at 15:36
  • 1
    No problem. I wanted to say that this will write the full word exactly where you have it in your tex file (even if it is not the first time it appears in a section). Marijns answer would automatically write the full form in the new section. – Tom Jan 18 at 15:41
2

The implementation of \acresetall (see page 12 of the acronym manual) uses an internal macro \AC@reset for single acronyms. You can use that too in your document, however because it is internal (i.e., it uses the @ character) you need to wrap it in a pair of \makeatletter and \makeatother (see What do \makeatletter and \makeatother do?).

MWE:

\documentclass{article}
\usepackage{acronym}
\begin{document}
\newacro{REST}{Representational State Transfer}
\newacro{API}{Application Programming Interface}

\section{First section}
The API provides a \ac{REST} \ac{API}. Used a second time: \ac{REST} and \ac{API}.

\makeatletter
\AC@reset{REST}
\makeatother
\section{Second section}
After reset: \ac{REST} and \ac{REST}. Other acronym: \ac{API}.
\end{document}

Result: enter image description here

In case you want to reset more than one acronym then you can write a small macro to save some typing, e.g.,

\makeatletter
\newcommand{\myreset}[1]{%
\AC@reset{#1}%
}
\makeatother

which you can use with, e.g., \myreset{REST}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.