Forest
Libraries
4.2 edges¶
\ProvidesForestLibrary{edges}[2016/12/05 v0.1.1]
forked edge’¶
Sets a forked edge to the current node. Arbitrary growth direction and node rotation are supported.
forked edge¶
Like forked edge’, but it also sets parent anchor and child anchor to the likely values of children and parent, respectively.
forked edges=⟨nodewalk⟩(default tree)¶
Invokes forked edge for all nodes in the ⟨nodewalk⟩, by default the entire (sub)tree rooted in the current node.
\begin{forest}
for tree={grow'=0,draw},
forked edges,
[/
[home
[saso
[Download]
[TeX]
]
[alja]
[joe]
]
[usr
[bin]
[share]
]
]
\end{forest}
See how growth direction based anchors children and parent are used in the definition below to easily take care of arbitrary grow and rotate.
\forestset{
declare dimen={fork sep}{0.5em},
forked edge'/.style={
edge={rotate/.option=!parent.grow},
edge path'={(!u.parent anchor) -- ++(\forestoption{fork sep},0) |- (.child anchor)},
},
forked edge/.style={
on invalid={fake}{!parent.parent anchor=children},
child anchor=parent,
forked edge',
},
forked edges/.style={for nodewalk={#1}{forked edge}},
forked edges/.default=tree,
}
folder¶
The children of the node are drawn like folders.
All growth directions are supported (well, cardinal directions work perfectly; the others await the sensitivity of packing to edge path), as well as node rotation and reversed order of children.
The outlook of the folder can be influenced by setting standard Forest’s options l sep and s sep any time before packing, or l and s after packing. Setting l and s before packing will have no influence on the layout of the tree.
\begin{forest}
for tree={grow'=0,~folder~,draw}
[/
[home
[saso
[Download]
[TeX]
]
[alja]
[joe]
]
[usr
[bin]
[share]
]
]
\end{forest}
\forestset{
declare dimen register=folder indent,
folder indent=.45em,
folder/.style={
parent anchor=-children last,
anchor=parent first,
calign=child,
calign primary child=1,
for children={
child anchor=parent,
anchor=parent first,
edge={rotate/.option=!parent.grow},
edge path'/.expanded={
([xshift=\forestregister{folder indent}]!u.parent anchor) |- (.child anchor)
},
},
after packing node={
if n children=0{}{
tempdiml=l_sep()-l("!1"),
tempdims={-abs(max_s("","")-min_s("",""))-s_sep()},
for children={
l+=tempdiml,
s+=tempdims()*(reversed()-0.5)*2,
},
},
},
}
}