我有一个简短的命令,可以让我突出显示一些文本以供内部审查。不幸的是,当我在图片的标题中使用它时,它给出了以下错误。
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.}
这是生成该错误的 MWE:
\documentclass{article}
\usepackage{graphicx} % For figures and stuff
\usepackage{xcolor} % Colors
\usepackage{soul} % Highlight with \hl
%Colored comments for internal review purposes
\newcommand{\MA}[1]{{\sethlcolor{lime}\hl{#1}}}
\begin{document}
Highlighting \MA{in the text} works fine.
\begin{figure}[htbp!]
\centering
\includegraphics[width=3cm]{example-image}
\caption{This is a picture. \MA{This is my comment} More caption text.}
\label{fig:Examplefigure}
\end{figure}
\end{document}
答案1
宏\MA
对于图形标题等移动参数来说不够强大。
使用
\protect
:\protect\MA{...}
或者定义一个强大的命令:
\newcommand{\MA}{}% Error, if \MA is already defined. \DeclareRobustCommand{\MA}[1]{{\sethlcolor{lime}\hl{#1}}}