I'm drawing tree structures of sentences with tikz, where nodes contain words, which may be longer sometimes. If that occurs, they are likely to overlap with neighbouring nodes. How can I tell tikz to keep a minimum spacing between neighbouring nodes? My MWE:
\documentclass{standalone}
\usepackage{tikz}
\tikzset{
treenode/.style = {align=center, inner sep=3pt, text centered,
font=\sffamily},
arn_n/.style = {treenode, rectangle, text width=3em},
arn_x/.style = {treenode},
gray-arrow/.style = {draw=gray}
}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[->,>=stealth',level/.style={sibling distance = 10cm/#1,
level distance = 1cm}]
\node [arn_n]{NP}
child { node [arn_n] {N'}
child { node [arn_n] {N'}
child { node [arn_n] {aa}
child { node [arn_x] {der}
}
}
child { node [arn_n] {N'}
child { node [arn_n] {AP}
child { node [arn_x] {geduldigsten}
}
}
child { node [arn_n] {N'}
child { node [arn_n] {N}
child { node [arn_x] {Konservativen}
}
}
}
}
}
child { node [arn_n] {N'}
child { node [arn_n] {aa}
child { node [arn_x] {unserer}
}
}
child { node [arn_n] {N'}
child { node [arn_n] {N}
child { node [arn_x] {Partei}
}
}
}
}
}
;
\end{tikzpicture}
\end{document}
In this case, the nodes containing "unserer" and "N'" overlap on the fifth level. What's a smart way to prevent that?
Best Answer
forest
does it for you: