I'm trying to set a number of hierarchy trees directly in LaTeX and found tikz-qtree
quite helpful for this task.
Since the descriptions for the nodes and children are rather long words, the layout doesn't seem optimal in a vertical tree.
Additionally, I'll merge those trees in a bigger tree and then things start getting crowded.
So, I thought of a horizontal tree. They're nice, too. But I just cannot get them to work properly.
The tikz-qtree
-manual is pretty short and the containing example-nodes consist of a small number of letters only.
What I'm trying to achieve is something like the first tree, but "rotated" by 90°. The titles of nodes and children will be long (sometimes several words) and it will be a total of three levels in the end.
Simply growing the first tree to the right does not suffice. :)
Where can I find documentation about the properties of the "edge from parent path"-parameter? I didn't find them in the tikz
-manual either.
I looked into the regular tikz
-package, too, but ran into similar issues there. tikz-qtree
has a prettier syntax, so I stuck with it.. Maybe something like dirtree
would be suited better?
Anyway, here's a minimal working example:
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree}
\begin{document}
Nice vertical tree. Bad for lots of subcategories.
\begin{figure}[h!]
\centering
\begin{tikzpicture}
\tikzset{edge from parent/.style=
{thick, draw,
edge from parent path={(\tikzparentnode.south)
-- +(0,-8pt)
-| (\tikzchildnode)}}}
\Tree
[. parent
[. {nice child0} ]
[. child1 ]
[. child2 ]
[. child3 ]
]
\end{tikzpicture}
\end{figure}
Vertical tree with different growth direction. Doesn't look quite right. o\_O
\begin{figure}[h!]
\centering
\begin{tikzpicture}
\tikzset{grow'=right, edge from parent/.style=
{thick, draw,
edge from parent path={(\tikzparentnode.east)
-- +(0,-8pt)
-| (\tikzchildnode)}}}
\tikzset{every tree node/.style={anchor=base west}}
\Tree
[. parent
[. {nice child0} ]
[. child1 ]
[. child2 ]
[. child3 ]
]
\end{tikzpicture}
\end{figure}
Nice horizontal tree. Good for lots of subcategories, but `wrong' edges.
\begin{figure}[h!]
\centering
\begin{tikzpicture}
\tikzset{grow'=right,level distance=32pt}
\tikzset{execute at begin node=\strut}
\tikzset{every tree node/.style={anchor=base west}}
\Tree
[.p
[.c0 ]
[.c1 ]
[.c2 ]
[.c3 ]
]
\end{tikzpicture}
\end{figure}
Almost identical horizontal tree as above, but messed up layout for longer node-names.
\begin{figure}[h!]
\centering
\begin{tikzpicture}
\tikzset{grow'=right,level distance=32pt}
\tikzset{execute at begin node=\strut}
\tikzset{every tree node/.style={anchor=base west}}
\Tree
[.parent
[.c1 ]
[.c2 ]
]
\end{tikzpicture}
\end{figure}
\end{document}
Thank you guys for any pointers and your help!