I am trying to define a command that would easily create aliases for acronyms defined with the acro
package. I would like to define dozens of aliases of different acronyms without having to duplicate the definitions, and the use of any alias would mark the acronym as used globally. Then, I want to keep the aliases and the original acronyms distinct, printing them with different commands, so that I can define i.e. an alias abc
for xyz
even there is an acronym abc
independently defined.
Ideally, I would like to be able to type something like:
\DeclareAcronym{xyz}{short=xyz, long={X, X, and Z}}
\DeclareAcronymAlias{abc}{xyz}
\aliasac{abc}
with \aliasac{abc}
producing the same result as \ac{xyz}
.
My idea was to first create a command \DeclareAcronymAlias
that takes 2 arguments and defines another command whose name includes argument #1 (\acroalias#1
) and whose definition is argument #2, the target acronym's ID. Then another command \aliasac
is defined: it takes 1 argument and passes the expanded command \acroalias#1
(i.e. the target acronym's ID) to the acronym printing command \ac
. But I get an error.
Here is a minimal example:
\documentclass[a4paper,10pt]{article}
\usepackage{acro}
\DeclareAcronym{xyz}{short=xyz, long={X, X, and Z}}
\newcommand{\DeclareAcronymAlias}[2]{%
\expandafter\newcommand\csname acroalias#1\endcsname{#2}%
}
\newcommand{\aliasac}[1]{%
\expandafter\ac{\csname acroalias#1\endcsname}%
}
\DeclareAcronymAlias{abc}{xyz}
\begin{document}
\aliasac{abc}
\printacronyms
\end{document}