I want to draw several trees with tikZ (Version 2.10) which are very similar in the sense that there is a first tree and the others are obtained by ommiting some of the nodes of the first one. I wanted to avoid copy and paste in order to keep things editable. So a minimal example of how the result should look like is this:
\begin{tikz}
\node {eins}
child{
node{zwei}
child{
node{drei}
}
}
;
\end{tikz}
\begin{tikz}
\node {eins}
child{
child{
node{drei}
}
}
;
\end{tikz}
I tried to use the following \newif \if construct:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\newif\ifShow
\Showtrue
\node {eins}
child{
\ifShow
node{zwei}
\fi
child{
node{drei}
}
}
;
\end{tikzpicture}
\end{document}
but it results in the error message "ERROR: Package pgf Error: No shape named is known." The problem seems to be with the child{node{drei}}. If I remove this part, the conditional drawing of node{zwei} works fine.
Do you have any suggestions how to conditionally draw tree nodes with TikZ?
tikzpictureenvironment instead. – percusse Oct 16 '14 at 08:28\pgfversionsomewhere outside the tikzpicture environment it shows the version of TikZ/PGF – percusse Oct 16 '14 at 20:10