I want to modify the distance between a parent node and a child node when drawing a tree using TiKZ package. I looked at the example at TiKZ site, and add a property called sibling distance
. However, no matter where I added (parent and child), it points to a wrong place.
As we can see, if I add more children to node 2
, it will overlap with 5
. Adding a sibling distance
yield even a worse result:
And I couldn't figure out what caused this issue. Any idea? Thank you.
Minimal Example
\documentclass[a4paper,landscape]{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[auto]
\node [circle,draw] (z){0}
child { [sibling distance=10mm]
node[circle,draw] (a) {1}
child {
node[circle,draw] (c) {5}
}
child {
node[circle,draw] (d) {5}
}
child {
node[circle,draw] (e) {5}
}
child {
node[circle,draw] (f) {5}
}
}
child {
node[circle,draw] (b) {2}
}
;
\path (z) -- (a);
\path (z) -- (b);
\path (a) -- (c);
\end{tikzpicture}
\end{document}
Best Answer
You can change the
sibling distance
for each level of the tree individually, usinglevel <number>/.style={sibling distance=<value>}
: