You have to tell acronym
both spellings:
\documentclass{article}
\usepackage{acronym}
\usepackage{etoolbox}
\makeatletter
\newif\if@in@acrolist
\AtBeginEnvironment{acronym}{\@in@acrolisttrue}
\newrobustcmd{\LU}[2]{\if@in@acrolist#1\else#2\fi}
\newcommand{\ACF}[1]{{\@in@acrolisttrue\acf{#1}}}
\makeatother
\begin{document}
\begin{acronym}
\acro{SRS}{\LU{S}{s}patial \LU{R}{r}eference \LU{S}{s}ystem}
\acro{DC}{\LU{D}{d}irect \LU{C}{c}urrent}
\end{acronym}
Batteries run on \ac{DC} and \ac{SRS} are different things.
\end{document}
The macro \LU
just takes the alternate forms as its arguments; the \AtBeginEnvironment
instruction tells this macro that the first argument is to be used, since the conditional \if@in@acrolist
returns true. In normal text the conditional returns false (note that at the end of the acronym
environment the setting of the conditional will be automatically reverted, because environments form groups).
I've added a macro \ACF
that acts similarly to \acf
(printing the full version along with the acronym) that uses the uppercase version.
The glossaries
package (and its extension glossaries-extra
) provides commands to index and reference terms or abbreviations. This is done by first defining the entries and then using markup commands like \gls
within the document.
Here's the modified MWE (thank you for providing one!)
\documentclass[fontsize=11pt,paper=a4]{scrbook}
\usepackage[acronym,automake]{glossaries}
\makeglossaries
\newacronym{ny}{NY}{New York}
\newacronym{la}{LA}{Los Angeles}
\newacronym{us}{US}{United States}
\begin{document}
\section{A}
\gls{ny} and \gls{la} are in \gls{us}.
\printglossary[type=\acronymtype,title=Abbreviations]
\end{document}
In order to make the glossary (list of abbreviations) appear. You need the following build sequence:
pdflatex
makeglossaries
(a Perl script that automatically runs makeindex
or xindy
according to the document settings)
pdflatex
The second step sometimes causes confusion, so there's an automake
package option, which will use TeX's shell escape to automatically run makeindex
or xindy
for you.
If those steps are successful, the above produces:
on the first page and
on the last page.
Note I've moved the \newacronym
definitions to the preamble. If you want them in the document use the following instead:
\documentclass[fontsize=11pt,paper=a4]{scrbook}
\usepackage[acronym,automake,docdef=restricted]{glossaries-extra}
\makeglossaries
% set the "short" style:
\setabbreviationstyle[acronym]{short}
\begin{document}
\newacronym{ny}{NY}{New York}
\newacronym{la}{LA}{Los Angeles}
\newacronym{us}{US}{United States}
\section{A}
\gls{ny} and \gls{la} are in \gls{us}.
\printglossary[type=\acronymtype,title=Abbreviations]
\end{document}
Alternatively:
\documentclass[fontsize=11pt,paper=a4]{scrbook}
\usepackage[abbreviations,automake,docdef=restricted]{glossaries-extra}
\makeglossaries
% set the "short" style:
\setabbreviationstyle{short}
\begin{document}
\newabbreviation{ny}{NY}{New York}
\newabbreviation{la}{LA}{Los Angeles}
\newabbreviation{us}{US}{United States}
\section{A}
\gls{ny} and \gls{la} are in \gls{us}.
\printabbreviations
\end{document}
Note that only those entries that have been explicitly marked with commands like \gls
are added to the list.
If you get the error message:
LaTeX Error: Unknown option `automake' for package `glossaries'.
then your version of glossaries
is too old. If you don't get this message and you are using automake
but your list of abbreviations is still missing, check the log file for lines starting with runsystem
. If it has disabled
at the end of the line then the shell escape has been disabled, in which case you'll need to find a way to run makeindex
or makeglossaries
. Related resources:
If you're not interested in the indexing and referencing commands provided by glossaries
(such as \gls
), then you don't actually need glossaries
. For example:
\documentclass[fontsize=11pt,paper=a4]{scrbook}
\newenvironment{abbrevlist}
{%
\chapter*{List of Abbreviations}
\newcommand\entry[2]{\item[##1] ##2}%
\begin{description}%
}
{\end{description}}
\begin{document}
\section{A}
NY and LA are in US.
\begin{abbrevlist}
\entry{LA}{Los Angeles}
\entry{NY}{New York}
\entry{US}{United States}
\end{abbrevlist}
\end{document}
This only requires one run of pdflatex
and no extra applications. This produces:
Best Answer
The simplest method is to use the extension package glossaries-extra and use the category attributes
glossname
(for the display of thename
field in the glossary) and, optionally,glossdesc
(for the display of thedescription
field in the glossary):Since
\newacronym
automatically sets thecategory
toacronym
, this modification will affect any entries defined with\newacronym
but not any entries that are defined using other commands, such as\newabbreviation
or\newglossaryentry
(unless thecategory
is set explicitly).