Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

3 Answers 3

up vote 6 down vote accepted

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}
share|improve this answer
    
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 :) –  tohecz Mar 23 '12 at 10:05

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

\acro{M\string&M}{I like them}
share|improve this answer
    
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}
share|improve this answer
    
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. –  tohecz Mar 8 '12 at 23:33
    
Thank you for your efforts. –  Fred Mar 12 '12 at 14:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.