7

I'm using the acronym package. Normally, if I enter an acronym like this:

 This is a system with \ac{LTI} propertiesSystem. It can be ...

The pdf shows something like this:

This is a system with linear, time invariant (LTI) properties. It can be ...

But I would like to have something like this:

This is a system with LTI (linear, time invariant) properties. It can be ...

How can I set up the acronym package to put the brackets around the description and not around the acronym?

edit:

I tried now using this self defined command:

\newcommand{\A}[1]{\acs{#1} (\aclu{#1})}

It shows the acronym first and the long version in brackets. But if I use the same acronym later, the full description ist shown again and again. I would prefer, that it is shown just the first time...

7
  • Welcome to TeX - LaTeX! Do you want this only for the one acronym or for all acronyms?
    – cgnieder
    Commented Jan 18, 2016 at 13:23
  • See the accepted answer to this question: Print acronym + full name in brackets at the first occurence of \ac{XYZ}
    – Alenanno
    Commented Jan 18, 2016 at 14:21
  • I want to do this for all acronyms. I used the solution from Alenanno's link. It works perfectly for me. What to do now? May I reply on my own post to answer my question and mark it as solved??
    – eDeviser
    Commented Jan 18, 2016 at 14:25
  • @eDeviser No, it's a duplicate. :P Nothing really bad, don't worry. Glad it helped!
    – Alenanno
    Commented Jan 18, 2016 at 14:35
  • This is not an exact duplicate: the other question wants the change only for some acronyms. Here it would be better to change the definitions of \acfa and \acfpa.
    – cgnieder
    Commented Jan 18, 2016 at 15:00

2 Answers 2

6

In order to generally swap acronym and description one can redefine \@acf and \acfa for singular forms and \@acfp and \acfpa for plural forms. Their definitions are

\newcommand*{\acfa}[1]{%
   \texorpdfstring{\protect\@acf{#1}}{\AC@acl{#1} (#1)}}
\newcommand*{\@acf}[1]{%
    \ifAC@footnote
       \acsfont{\AC@acs{#1}}%
       \footnote{\AC@placelabel{#1}\AC@acl{#1}{}}%
    \else
       \acffont{%
          \AC@placelabel{#1}\AC@acl{#1}%
          \nolinebreak[3] %
          \acfsfont{(\acsfont{\AC@acs{#1}})}%
        }%
     \fi
     \ifAC@starred\else\AC@logged{#1}\fi}

and

\newcommand*{\acfpa}[1]{%
   \texorpdfstring{\protect\@acfp{#1}}{\AC@aclp{#1} (\AC@acsp{#1})}}
\newcommand*{\@acfp}[1]{%
   \ifAC@footnote
      \acsfont{\AC@acsp{#1}}%
      \footnote{\AC@placelabel{#1}\AC@aclp{#1}{}}%
   \else
      \acffont{%
         \AC@placelabel{#1}\AC@aclp{#1}%
         \nolinebreak[3] %
         \acfsfont{(\acsfont{\AC@acsp{#1}})}%
         }%
   \fi
   \ifAC@starred\else\AC@logged{#1}\fi}

The change is rather trivial – exchange short (\AC@acs{#1}) and long (\AC@acl{#1}) forms and surround the long form with parentheses rather than the short form:

\documentclass{article}
\usepackage{acronym}

\newacro{CSS}{Cascading Style Sheets}
\newacro{CD}{Compact Disc}

\makeatletter
% singular:
\renewcommand*{\acfa}[1]{%
  \texorpdfstring{\protect\@acf{#1}}{#1 (\AC@acl{#1})}%
}
\renewcommand*{\@acf}[1]{%
  \ifAC@footnote
    \acsfont{\AC@acs{#1}}%
    \footnote{\AC@placelabel{#1}\AC@acl{#1}{}}%
  \else
    \acffont{%
      \AC@placelabel{#1}%
      \acfsfont{\acsfont{\AC@acs{#1}}}%
      \nolinebreak[3] %
      (\AC@acl{#1})%
    }%
  \fi
  \ifAC@starred\else\AC@logged{#1}\fi
}

% plural:
\renewcommand*{\acfpa}[1]{%
  \texorpdfstring{\protect\@acfp{#1}}{\AC@acsp{#1} (\AC@aclp{#1})}
}
\renewcommand*{\@acfp}[1]{%
  \ifAC@footnote
    \acsfont{\AC@acsp{#1}}%
    \footnote{\AC@placelabel{#1}\AC@aclp{#1}{}}%
  \else
    \acffont{%
      \AC@placelabel{#1}%
      \acfsfont{\acsfont{\AC@acsp{#1}}}%
      \nolinebreak[3] %
      (\AC@aclp{#1})%
    }%
  \fi
  \ifAC@starred\else\AC@logged{#1}\fi
}
\makeatother

\begin{document}

\ac{CSS}

\acp{CD}

\end{document}
0

Update for acronym package v1.47 (2020/04/17)

\makeatletter
%% singular:
\renewcommand*{\acfa}[2][\AC@linebreakpenalty]{%
   \texorpdfstring{\protect\@acf[#1]{#2}}{#2 (\AC@acl{#2})}}
\renewcommand*{\@acf}[2][\AC@linebreakpenalty]{%
    \ifAC@footnote
       \acsfont{\AC@acs{#2}}%
       \footnote{\AC@placelabel{#2}\AC@acl{#2}{}}%
    \else
       \acffont{%
          \AC@placelabel{#2}%             
          \acfsfont{\acsfont{\AC@acs{#2}}}%
          \nolinebreak[#1] %
          (\AC@acl{#2})%
        }%
     \fi
     \ifAC@starred\else\AC@logged{#2}\fi}
\makeatother

also as own command \acr for using both (normal \ac and the reverse one):

\makeatletter
\newcommand*{\acr}{\AC@starredfalse\protect\@acr}%
\newcommand{\@acr}[2][\AC@linebreakpenalty]{%
  \ifAC@dua
     \ifAC@starred\acl*{#2}\else\acl{#2}\fi%
  \else
     \expandafter\ifx\csname AC@\AC@prefix#2\endcsname\AC@used%
     \ifAC@starred\acs*{#2}\else\acs{#2}\fi%
   \else
     \acs{#2} (\aclu{#2})%
   \fi
  \fi}
\makeatother

You must log in to answer this question.

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