# Error when using \BC (from abbrevs) in \caption

I'm using the abbrevs package to provide nicer formatting of BC/AD in dates, but when I use one of the commands in a caption I get an error. Example document:

\documentclass{article}
\usepackage{abbrevs}

\begin{document}

\begin{figure}
\caption{1500--1000 \BC.}
\end{figure}

\end{document}


The error is:

! Argument of \@caption has an extra }.


Removing the \BC eliminates the error, which leads me to think the problem is in the combination of the two... so how can I use an abbreviation in a caption? Alternatively, is there a better package for formatting BC/AD in dates?

-
Such an error almost always means: "you have a fragile command in a moving argument", in this case the argument to \caption. Use \protect\BC. –  egreg Mar 4 '13 at 9:09

Many of the commands defined by abbrevs are fragile; for example, \BC expands to \DateMark {b.c} and, in turn, the definition of \DateMark is

\newcommand\DateMark [1] {%
\hspace{.2em}{\DateMarkSize\scshape #1}%
\@ifnextchar. {%
\spacefactor\@m
}{% ELSE
.\maybe@ic@space
}%
}


Any command with \@ifnextchar in its definition is fragile, so it needs to be "protected" when in a moving argument.

Solutions:

1. Easy, if you don't have too many of these commands in moving arguments

\caption{1500--1000 \protect\BC.}

2. Safer, if you don't want to bother with all these \protect

\usepackage{abbrevs}
\usepackage{etoolbox}

\robustify{\DateMark} % after having loaded abbrevs


It's better to robustify \DateMark rather than \BC, as this covers all date abbreviations.

-
Fantastic, many thanks. I went with option 2 as that seemed cleaner. –  stusmith Mar 4 '13 at 9:34