按照提供的示例这里,我想在文本中插入彩色圆圈数字,这些数字表示图中的项目(图形细节留给读者练习)。这些数字定义如下:
\definecolor{highlightcolor}{RGB}{241,90,36}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,fill=highlightcolor,inner sep=2pt] (char) {\textcolor{white}#1};}}
我在文本中将其称为\circled{1}
、\circled{2}
等。效果很好。当我尝试在图形中添加此命令时,会出现问题\caption{}
。LateX 强烈抱怨,指责我这样做,以及其他无法打印的事情:
main.tex:121 Use of \tikz@picture doesn't match its definition.
\pgfutil@ifnextchar ...1\def \pgfutil@reserved@a {
#2}\def \pgfutil@reserved@...
l.121 ... indicator; 7: currently-selected page. }
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
我究竟做错了什么?
答案1
您需要保护命令:
\caption{\protect\circled{1}}
\circled
另一种选择是首先将其定义为稳健的