I have a short command that allows me to highlight some text for internal review purposes. Unfortunately, when I use it in a Caption of a figure it gives me the following error.

Argument of \@textcolor has an extra }. ...MA{This is my comment} More caption text.}
Paragraph ended before \@textcolor was complete. ...MA{This is my comment} More caption text.}

Here is my MWE that generates that error:


\usepackage{graphicx}           % For figures and stuff
\usepackage{xcolor}             % Colors
\usepackage{soul}               % Highlight with \hl

%Colored comments for internal review purposes


Highlighting \MA{in the text} works fine.

    \caption{This is a picture. \MA{This is my comment} More caption text.}


Macro \MA is not robust for moving arguments like figure captions.

  • Use \protect:

  • Or define a robust command:

    \newcommand{\MA}{}% Error, if \MA is already defined.

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.