13

I use the acronym package to create and manage acronyms in my document, e.g.:

\newacro{css}[CSS]{Cascading Style Sheets}

Can you use \ac{css}?

However, sometimes I must add typesetting to documents which already have acronyms typed out entirely, but I still need them to be automatically shortened after the first appearance. They are typed out like this:

Can you use Cascading Style Sheets (CSS)?

As there are such a large number of acronyms, maintaining a list of used acronyms in the preamble creates confusion. E.g.: If I changed the adove to Can you use \ac{css}?, but later encountered another different acronym called "css", I could possible introduce an error, and have difficulty checking the data. For this reason, it would be better if I had a syntax which made as few changes to the existing text as possible, such as this:

Can you use \addac{Cascading Style Sheets}{CSS}?

In this way, I can still see the original text that was used, and if I need to use "Customer Support System (CSS)" later in the document, I would not need to worry about managing the duplicate.

How can this be done?

Village
  • 13,603
  • 23
  • 116
  • 219

2 Answers2

9

You can define them this way,

\newacro{css1}[CSS]{Cascading Style Sheets}
\newacro{css2}[CSS]{Customer Support Service}

This means you will need to remember, which is which but probably still easier than typing the whole thing out.

\documentclass{article}
\usepackage{acronym}
\newacro{css1}[CSS]{Cascading Style Sheets}
\newacro{css2}[CSS]{Customer Support Service}
\begin{document}
Use \ac{css1}, but there is no  \ac{css2}.
\end{document}

Instead of numbers, yo can also use more descriptive labels, in a similar fashion to referencing.

\newacro{customersupport}[CSS]{Customer Support Service}
yannisl
  • 117,160
7

If I understand what you want, with a slight adjustment to your syntax, you can obtain the desired results. The revised syntax is:

\addac{<acronym>}{<short name>}{<full name>}

This will allow you to also use the standard \ac{<acronym>} macro.

enter image description here

\documentclass{article}
\usepackage{acronym}
\newcommand{\addac}[3]{\newacro{#1}[#2]{#3}\ac{#1}}%
\begin{document}
Use \addac{css1}{CSS}{Cascading Style Sheets}, 
but not \addac{css2}{CSS}{Customer Support System}.

Use \addac{css1}{CSS}{Cascading Style Sheets}, 
but not \addac{css2}{CSS}{Customer Support System}.

Use \ac{css1}, but there is no  \ac{css2}.
\end{document}
Thorsten
  • 12,872
Peter Grill
  • 223,288