20

I would like to output acronyms with the first letter of a word in upper case when they are printed to the list of acronyms. However, it certain cases I would like to print the written out form in lower case (english language) when I add them to a paragraph using the \ac{} or \acf{} commands. A third case would be to use the mixed letter variant somewhere in the document.

Examples:

% 1) In the list of acronyms.
Spatial Reference System (SRS)

...

% 2) In a paragraph.
... the spatial reference system (SRS) is important because ... 

...

% 3) Somewhere else in the document.
... it may happen that you still want to use the 
mixed variant when writing about the Spatial Reference System (SRS) ....

Question:

  • How would you configure acronyms to distiguish between those three cases?
0

1 Answer 1

21

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).

enter image description here

I've added a macro \ACF that acts similarly to \acf (printing the full version along with the acronym) that uses the uppercase version.

3
  • Thank you! Could you please add some comments to the modifications especially why you included the line: \expandafter\show\csname if@in@acrolist\endcsname?
    – JJD
    Sep 10, 2012 at 10:33
  • @JJD Sorry, that line is a relict of my debugging.
    – egreg
    Sep 10, 2012 at 10:40
  • 2
    @JJD I've added an \ACF macro.
    – egreg
    Sep 14, 2012 at 17:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .