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've now tried mathtools for the first time, for the sake of showonlyrefs. It works fine, except if I put an \eqref command into a figure caption, in which case I get:

! Argument of \@caption has an extra }.
! Paragraph ended before \@caption was complete.

Here is the MWE:

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}
\mathtoolsset{showonlyrefs=true,showmanualtags=true} % do not number unreferenced equations
\begin{document}
  \begin{equation}\label{eq:EVE-HEH}
    x
  \end{equation}
  \begin{figure}
    \caption{See eigenvalue equation \eqref{eq:EVE-HEH}.}
  \end{figure}
\end{document}

What do I do wrong?

Update: Found here that \protect before \eqref in caption helps, and indeed it does. However this is not mentioned in the mathtools. Is it the right solution?

share|improve this question

1 Answer 1

up vote 10 down vote accepted

Unfortunately \eqref is not a robust command, so it needs \protect in front of it when used in a moving argument, such as the argument of \caption or \section.

If you happen to use many times \eqref in such places, you can consider "robusting" it:

\usepackage{fixltx2e,amsmath}
\MakeRobust{\eqref}

Note that \eqref is provided by amsmath, rather than mathtools (this last package loads amsmath).

share|improve this answer

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.