Square edges in forest package
You need to do \begin{forest} for tree={edge path=<your path>}}
(without []
!).
I adjusted the distance a little bit, better would be to use for example half the level distance and not a fixed distance.
One can also use my paths.ortho
library (needs both tikzlibarypaths.ortho.code.tex
and tikzlibarypaths.ortho.tex
) and be available to use |-|
instead of --
.
Code
\documentclass[10pt,twoside,a4paper]{memoir}
\usepackage{graphicx}
\usepackage{forest}
\usepackage{tikz-qtree}
\begin{document}
\begin{tikzpicture}
\tikzset{edge from parent/.style={draw,edge from parent path={(\tikzparentnode.south)-- +(0,-8pt)-| (\tikzchildnode)}}}
\Tree [.ZZ
[.Bax
[.X
[.Y [.A ] [.B ] ]
[.Z [.C ] [.D ] ] ]
[.F
[.M [.E ] [.F ] ]
[.G [.G ] [.H ] ] ] ]
[.A
[.B
[.S [.I P R T V U ] [.J ] ]
[.I [.K ] [.L ] ] ]
[.M
[.L [.M ] [.N ] ]
[.A [.O ] [.P ] ] ] ] ] ]
\end{tikzpicture}
\begin{forest} for tree={
edge path={\noexpand\path[\forestoption{edge}] (\forestOve{\forestove{@parent}}{name}.parent anchor) -- +(0,-12pt)-| (\forestove{name}.child anchor)\forestoption{edge label};}
}
[ZZ
[Bax
[X
[Y [A ] [B ] ]
[Z [C ] [D ] ] ]
[F
[M [E ] [F ] ]
[G [G ] [H ] ] ] ]
[A
[B
[S [I [P][R][T][V][U]] [J ] ]
[I [K ] [L ] ] ]
[M
[L [M ] [.N ] ]
[A [O ] [P ] ] ] ] ] ]
\end{forest}
\end{document}
Output
With current Forest, it is a simple question of loading the edges
library and adding forked edges
to the tree's preamble.
\documentclass[border=10pt]{standalone}
\usepackage[edges]{forest}
\begin{document}
\begin{forest}
forked edges,
[ZZ
[Bax
[X
[Y [A ] [B ] ]
[Z [C ] [D ] ] ]
[F
[M [E ] [F ] ]
[G [G ] [H ] ] ] ]
[A
[B
[S [I [P][R][T][V][U]] [J ] ]
[I [K ] [L ] ] ]
[M
[L [M ] [.N ] ]
[A [O ] [P ] ] ] ] ] ]
\end{forest}
\end{document}
If you have only version 1 of Forest, this won't work. In that case, you should update. If that's not possible, note that macros such as \forestove
are intended as part of the internal implementation and should be avoided in end-user code as they are liable to break on update. Instead, use the wrappers which Forest provides for this purpose, which are much more likely to survive any changes to Forest's innards.
\documentclass[border=10pt]{standalone}
\usepackage{forest}% version 1
\begin{document}
\begin{forest}
for tree={
parent anchor=south,
edge path={
\noexpand\path [\forestoption{edge}] (!u.parent anchor) -- ++(0,-5pt) -| (.child anchor)\forestoption{edge label};
}
}
[ZZ
[Bax
[X
[Y [A ] [B ] ]
[Z [C ] [D ] ] ]
[F
[M [E ] [F ] ]
[G [G ] [H ] ] ] ]
[A
[B
[S [I [P][R][T][V][U]] [J ] ]
[I [K ] [L ] ] ]
[M
[L [M ] [N ] ]
[A [O ] [P ] ] ] ] ] ]
\end{forest}
\end{document}