I'm attempting to make my code more readable by replacing a long bit of text I intend to use several times with a macro.
Before I use the macro, I have the following code:
\documentclass{minimal}
\usepackage{tikz-qtree}
\newcommand{\llabel}[1]{\edge node[auto=left]{#1};}
\begin{document}
\begin{tikzpicture}
\Tree [.$P_1$ [.$P_2$ ]
\edge node[auto=left]{1,2}; [.$P_2$ ] ]
\end{tikzpicture}
\end{document}
This produces the correct output:
When I replace the edge label with my macro, the following code produces the following error:
\documentclass{minimal}
\usepackage{tikz-qtree}
\newcommand{\llabel}[1]{\edge node[auto=left]{#1};}
\begin{document}
\begin{tikzpicture}
\Tree [.$P_1$ [.$P_2$ ]
\llabel{1,2} [.$P_2$ ] ]
\end{tikzpicture}
\end{document}
Undefined control sequence. \llabel #1->\edge node[auto=left]{#1}; l.8 \end {tikzpicture}
Is there a way to do this?
\edge
seems to be unknown outside of\Tree
-- there is a premature expansion, unfortunately, of\llabel
, trying to execute the\edge
macro before it can be handed over to\Tree
→ this must fail – user31729 Mar 17 '16 at 20:40