I'm trying to draw a tree with some text in the leaves that I'd like to rotate. The below code works fine except that the edges to the leaves are anchored to the right-hand side of the leaves rather than to the top.
\documentclass{article}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{tikz-qtree}
\begin{document}
\begin{tikzpicture}
\tikzset{every leaf node/.style={font=\tiny,anchor=base west,rotate=-90}}
\tikzset{edge from parent/.style=
{draw,
edge from parent path={(\tikzparentnode.south)
-- +(0,-8pt)
-| (\tikzchildnode)}}}
\Tree [.{$\rightarrow$}
[.{$\land$}
[.{$\circlearrowleft$} {$\tau$} {CRP} ]
[.{$\rightarrow$}
[.{$\land$}
[.{$\circlearrowleft$} {$\tau$} {Leucocytes} ]
[.{$\circlearrowleft$} {$\tau$} {IV Antibiotics} {IV Liquid} {ER Registration} {Admission IC} {Admission NC} {LacticAcid} {ER Triage} {ER Sepsis Triage} ]
]
[.{$\times$} {Release A} {$\tau$} ]
]
]
[.{$\times$} {Release C} {Release B}
[.{$\rightarrow$}
[.{$\times$} {Release E} {Release D} {$\tau$} ]
{Return ER}
]
{$\tau$}
]
]
\end{tikzpicture}
\end{document}
It renders as:
How to anchor the edges to the top of leaves?
Note that by changing
\tikzset{edge from parent/.style=
{draw,
edge from parent path={(\tikzparentnode.south)
-- +(0,-8pt)
-| (\tikzchildnode)}}}
to
\tikzset{edge from parent/.style=
{draw,
edge from parent path={(\tikzparentnode.south)
-- +(0,-8pt)
-| (\tikzchildnode.west)}}}
the edges between the intermediate nodes anchor to the left of the children nodes. This is undesired.
Best Answer
tikz-qtree
is very inflexible, so we need an anchor point that works for both unrotated and rotated nodes. Instead of using.north
for one and.west
for the other, I use.north west
for both and project it horizontal to align with.center
- that is: