I am using a \widebar accent as implemented here, since I don't want to use mathabx; but when I use the accent in the caption of a figure, I get a compiler error.

Here's the offending code:

\caption{(Blah blah) and $(\widebar{N},\widebar{X})$.

And the error:

Argument of \Hy@tempa has an extra }.\par ...n the right $(\widebar{N},\widebar{X})$.} Paragraph ended before \Hy@tempa was complete.\par ...n the right $(\widebar{N},\widebar{X})$.}

I have no trouble using \widebar in the body of my document, and when I comment out this instance in the caption, everything compiles correctly.

Can this implementation be fixed? Is there a comparably good implementation of \widebar that doesn't have this problem?


The code in Hendrik Vogt's answer has the line


but the definition is “unsafe” for usage in moving arguments, such as captions and sectional titles. So \widebar is to be considered fragile. See What is the difference between Fragile and Robust commands? for more information.

Either you keep the definition as is and use \protect\widebar in moving arguments, or remove the problem altogether by changing that line into

\newcommand{\widebar}{}% initialize

The “initialize” line is just for ensuring \widebar is not yet defined, because \DeclareRobustCommand silently overrides previous definitions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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