Trees and macros with tikz
Posted
by Tsf
on Stack Overflow
See other posts from Stack Overflow
or by Tsf
Published on 2010-01-05T19:32:11Z
Indexed on
2010/06/03
4:04 UTC
Read the original article
Hit count: 298
I am trying to build my trees using macros but I don't get the result I want. Here is a minimal example:
\documentclass{article} \usepackage{tikz} \usetikzlibrary{trees} \newcommand{\LeafNode}[1]{% child {node {#1}} } \newcommand{\InnerNode}[3]{% child {node {#3} #1 #2 } } \begin{document} \begin{tikzpicture} \node (A) {A} \LeafNode{B} \LeafNode{C} ; \end{tikzpicture}% \hspace{2cm}% \begin{tikzpicture} \node (A) {A} \InnerNode{\LeafNode{D}}{\LeafNode{E}}{B} \LeafNode{C} ; \end{tikzpicture} \end{document}
I expected this to produce two trees:
A A / \ / \ B C B C / \ D E
but I am getting:
A | A B | | B D | | C C
Am I missing something or there is no way to do it?
BTW, if I omit the label on my root node, I get a PGF error:
! Package pgf Error: No shape named is known.
-- Tsf
© Stack Overflow or respective owner