The expected behavior of the following code would be that nodes descending from a myFolder node are positioned below the parent node with some indentation.
As you can see from the image, however, it would seem that the direct children of the myFolder node are positioned so that their left side is aligned with the center of the parent node.
Is there any way to fix this?
I would also like to understand how to align nodes on the same level with different heights at the top and not at the center.
\usepackage[edges]{forest}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\forestset{
declare boolean={folderDescendants}{false},
myFolder/.style={
l sep = 0,
for tree={
grow'=0,
folder,
align=center,
s sep'=1mm,
minimum height=5mm,
},
folder indent'=5mm,
for descendants={
folderDescendants,
inner xsep=2mm,
inner ysep=0mm,
edge path'/.expanded={
([xshift=\forestregister{folder indent}]!u.parent anchor) |- ([yshift=.6ex].base west)
},
},
},
myFork/.style={
for tree={
fit=band,
rounded corners,
ultra thick,
font=\sffamily\bfseries\Large,
inner xsep=5mm,
inner ysep=5mm,
edge+={ultra thick, rounded corners},
align=center,
l sep'=20mm,
s sep'=7mm,
fork sep'=8mm,
align = center,
},
forked edges,
before typesetting nodes={
where folderDescendants={}{
draw,
minimum height=15mm,
minimum width=20mm,
anchor=center,
},
},
},
}
\begin{document}
\begin{forest}
myFork,
[Root,calign=child, calign child=2
[Lorem ipsum, myFolder
[Lorem ipsum dolor sit amet
[Lorem ipsum dolor sit amet]
[Lorem ipsum dolor sit amet]
[Lorem ipsum dolor sit amet]
]
[Lorem ipsum dolor sit amet]
[Lorem ipsum]
]
[Lorem ipsum dolor sit amet
[Lorem ipsum dolor sit amet]
[Lorem ipsum\dolor sit amet]
[Lorem ipsum dolor sit amet,myFolder
[Lorem 4
[Lorem ipsum dolor sit amet]
[Lorem ipsum dolor sit amet]
[Lorem ipsum dolor sit amet]
]
[Lorem 5.1\Lorem 5.2\Lorem 5.3]
[Lorem 6]
]
]
[Lorem ipsum\dolor sit amet]
[Lorem ipsum]
[Lorem ipsum]
]
\end{forest}
\end{document}
The desired result (in green and fuchsia I have highlighted the spaces that I would like to modify)
The desired result with possible alignment to the top of the nodes




anchor=centertoanchor=norththe nodes with a border get top-aligned (might need you to adjust the distance to its first child, though). – Qrrbrbirlbel Jul 08 '23 at 21:38\documentclass{}etc. – cfr Jul 09 '23 at 00:17The fuchsia lines in the first image indicated the need to maintain the same space between the various subtrees, while in the second image they indicated that the nodes were horizontally aligned at the top.
Regarding the links I had read several discussions online and had not kept track of the pages so I would not have been able to indicate the sources.
Anyway thanks for these indications, next time I will try to pay more attention to these things.
– Datboi Jul 11 '23 at 10:11