我不明白为什么以下宏定义\gcmarknode
不起作用:
\documentclass{beamer}
\usepackage{tikz}
\usepackage{pifont}
\newcommand{\cmark}{\ding{51}}
\usetikzlibrary{calc}
\newcommand{\gcmark}{\llap{\vphantom{Ay}\normalsize\textcolor{green}{\cmark}}}
\newcommand[1]{\gcmarknode}{ \node[left] at ($(#1.north east)!0.5!(#1.south east)$) {\gcmark}; } % does not work!
\tikzstyle{baseBlock}=[
minimum width = 5cm, minimum height = 2cm, text width = 4cm,
draw = black, thick, align = center, font = \footnotesize\bf]
\begin{document}
\begin{tikzpicture}
\node[baseBlock] (Y2) {Hello}; \node[left] at ($(Y2.north east)!0.5!(Y2.south east)$) {\cmark}; % works!
\node[baseBlock] (X2) {Hello}; \gcmarknode{X2} % does not work!
\end{tikzpicture}
\end{document}
我做错什么了?宏代码本身有效。
答案1
带参数的宏定义为
\newcommand{<macro>}[<number of arguments>][<default value of optional arg>]{<definition>}
你放[<number of arguments>]
错地方了,
\newcommand{\gcmarknode}[1]{ \node[left] at ($(#1.north east)!0.5!(#1.south east)$) {\gcmark}; }
作品。
顺便问一下,为什么不使用#1.east
?