# How to escape ampersand in \acro command?

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.
\&


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}

-

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}
\end{acronym}

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

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

\end{document}

-
Awesome! This works for both the & and registered trademark symbols. I will be using this in my document. – Fred Mar 12 '12 at 14:30
@egreg +1 for \textit :) – yo' Mar 23 '12 at 10:05

Perhaps not the best way to input it, but this works:

\acro{M\string&M}{I like them}

-
Great! It looks like it will work, thank you. – Fred Mar 8 '12 at 21:54

You can define macros \makeampletter and \makeampcolsep similar to \makeatletter and \makeatother. This makes & to locally behave like a letter.

\documentclass{article}

\usepackage{amsmath}
\usepackage{acronym}

\def\makeampletter{\catcode\&11\relax} % <-- HERE
\def\makeampcolsep{\catcode\&4\relax} % <-- HERE

\begin{document}

\tracingmacros=1
\begin{acronym}
\makeampletter % <-- HERE
\acro{M&M}{I like them}
\makeampcolsep % <-- HERE
\end{acronym}

\begin{tabular}{cc}
Just to test & that ampersand works
\end{tabular}

\end{document}

-
Will this work on the registered trademark symbol? – Fred Mar 8 '12 at 22:11
At first I was sure it will work with \usepackage[utf8]{inputenc}. But I tried and unsuccessfully. I'm unable to make it work, neither via unicode nor via command definition. – yo' Mar 8 '12 at 23:33
Thank you for your efforts. – Fred Mar 12 '12 at 14:20