The acronym package
Manages acronyms without an external program: \acro defines them in the acronym environment, and \ac prints the long form at the first use and the short form afterwards.
Loading the package
\usepackage[printonlyused]{acronym}The list of acronyms is an environment that you write yourself, usually at the start or the end of the document. Each \acro line in it defines one acronym and is also its entry in the list.
No tool such as makeglossaries is involved; two LaTeX runs are enough. In return the list is not sorted: the entries appear in the order in which you wrote them. For sorted lists and a glossary with descriptions, see glossaries.
Main commands
\begin{acronym}[HTML] ... \end{acronym} | The list. The optional argument is the longest short form; it sets the width of the first column. |
\acro{pdf}[PDF]{Portable Document Format} | Defines an acronym: label, short form (optional when it equals the label), long form. |
\ac{pdf} | First use: long form with the short form in parentheses. After that: the short form. |
\acs{pdf}, \acl{pdf}, \acf{pdf} | Force the short, the long or the full form. |
\acp{pdf} | Plural form with an appended s. |
\acresetall | Treats all acronyms as unused again, for example at the start of a chapter. |
printonlyused | Option: the list shows only acronyms that occur in the text. withpage adds the page of the first use. |
Complete example
\documentclass{article}
\usepackage[printonlyused]{acronym}
\begin{document}
\section{Text}
A \ac{PDF} file can be shown in a browser next to \ac{HTML} pages.
The second use is short: \ac{PDF}.
\section*{Acronyms}
\begin{acronym}[HTML]
\acro{HTML}{Hypertext Markup Language}
\acro{PDF}{Portable Document Format}
\acro{SVG}{Scalable Vector Graphics}
\end{acronym}
\end{document}Compiled with pdfLaTeX from TeX Live 2023. Tools run in this order: pdflatex → pdflatex.
Pitfalls
- After the first run the acronyms print as their label with an exclamation mark and the log warns
Acronym ... is not defined, because the definitions are read from the.auxfile. The second run fixes this. - Sort the
\acrolines by hand; the package keeps your order. - With
printonlyused, an acronym that is used only through\acsor\aclstill counts as used.
Related pages
- How-to Glossary and list of acronyms in LaTeX
- Package
glossaries - Package
nomencl