我有一个绘制一些对象的宏,它将可选参数(left
或)作为参数。为了避免重复代码,我检查该(或)right
上的输入参数和条件 TikZ 参数:left=of
right=of
\newcommand{\mycommand}[1]{
\ifthenelse{\equal{#1}{left}}{
\def\side left
}{
\def\side right
}
\node (A) {$A$}
\node (B) [\side=of A] {$B$};
我收到以下错误:
Use of \side doesn't match its definition.
您能帮我解决这个问题吗?非常感谢!
答案1
(简化的)语法\def
是\def\tokenname#1...{...}
\newcommand{\mycommand}[1]{
\ifthenelse{\equal{#1}{left}}{
\def\side{left}
}{
\def\side{right}
}
\node (A) {$A$}
\node (B) [\side=of A] {$B$};