[Tex/LaTex] How to escape ampersand in \acro command

acronymsampersand

I am trying to use the acronym package to create an acronym list. The problem is that one of the acronyms I need to use contains an ampersand ('&').

But when I try to compile the .tex file I get this error:

! Missing \endcsname inserted.
<to be read again> 
                   \&
l.2 ...&M}[\AC@hyperlink{M\&M}{M\&M}]{I like them}

Here is an example:

\usepackage{amsmath}
\usepackage{acronym}

\begin{document}

\begin{acronym}
\acro{M\&M}{I like them}
\end{acronym}

\end{document}

So how do I use an ampersand in an acronym using the acronym package?

More generally, how is it possible to apply special formatting to a single acronym? For example

\acro{\textit{IAF}}{Italic acronym frenzy}

Best Answer

Completely different way than in my previous answer, is reading the package documentation, for example here.

\documentclass{article}

\usepackage{amsmath}
\usepackage{acronym}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\begin{document}

\begin{acronym}
\acro{FoobAR(tm)}[FoobARâ„¢]{Copyrighted}
\end{acronym}

\begin{acronym}
\acro{MM}[M\&M]{I like them}

\acro{IAF}[\textit{IAF}]{Italic acronym frenzy}
\end{acronym}

\end{document}