# superimposed nodes & connection labels in TikZ decision tree

I'm trying to build a decision tree using the TikZ package and have run into an issue. Two of my nodes from separate branches are superimposed, so I can only see one of the nodes and on the surface the two separate branches are conflated. The code allows me only to manipulate node distance through a global parameter that affects the distance between all nodes at once. Is there a way to manipulate only a subset of nodes and separate the overlapping nodes, without changing the distance between all the nodes?

This is my code and output:

\documentclass{article}
\usepackage{pgf, tikz}
\begin{document}

\begin{tikzpicture}[sibling distance=15em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=gray!20}]]
\node {no slopes}
child { node {subj slope}
child { node {subj \& item slopes}
child { node {\textbf{max RE}} }
child { node {\textbf{subj slope}} }} %this node is buried and not visible
child { node {item slope}
child { node {subj \& item slopes}
child { node {\textbf{max RE}} }
child { node {\textbf{item slope}} } }
child { node {\textbf{no slopes}} } }};
\end{tikzpicture}

\end{document}


With pure TikZ is less elegant as with forest ... but with appropriate determined sibling distance for the first and the third level you can obtain:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[
level 1/.style = {sibling distance=17em},
level 3/.style = {sibling distance=8em},
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=gray!20}
]
\node {no slopes}
child { node {subj slope}
child { node {subj \& item slopes}
child { node {\textbf{max RE}} }
child { node {\textbf{subj slope}} }
} %this node is buried and not visible
child { node {item slope}
child { node {subj \& item slopes}
child { node {\textbf{max RE}} }
child { node {\textbf{item slope}} }
}
child { node {\textbf{no slopes}} }
}
};
\end{tikzpicture}
\end{document}

• Thank you for working within TikZ! It is a little easier to modify existing code that you use a different package, even if it's less elegant. – Des Grieux Mar 19 '17 at 23:13

A forest version of your tree, where s sep define the minimum distance between nodes boundaries, and l sep the minimal distance between node and its descendants. to increase them just add + sign.

\documentclass{article}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree={l sep+=.8cm,s sep+=.5cm,shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=gray!20}
[no slopes
[subject slope
[subj \& item slopes,for children={font=\bfseries}
[max RE]
[subj slope]
]
[max RE,font=\bfseries
[subj \& item slopes,for children={font=\bfseries}
[max RE]
[item slope]
]
[no slopes]
]
]
]
\end{forest}
\end{document}


• Thank you for introducing me to the forest package. It seems easier to use that TikZ. – Des Grieux Mar 19 '17 at 23:12