TeX - LaTeX Asked by Rithaniel on April 10, 2021
So, I am fairly new to using Forest, and I’m finding it rather difficult to wrap my head around the package. I’m currently trying to make a tree with paths that curve towards the horizontal when moving horizontally but which don’t curve at all when moving strictly vertical. However, my attempts to do this end up with paths being slightly offset from each other, and I’m unsure why.
If what I mean is unclear, here is what I believe to be a minimal working example, displaying the misalignment that I’m having issue with. The vertical line from Root to Middle is slightly to the left of the other two paths, but I would prefer if they were all along the same line. If it matters, I am using XeLaTeX in texmaker.
documentclass{article}
usepackage[a4paper,left=25mm,right=25mm,top=25mm,bottom=25mm]{geometry}
usepackage{tikz}
usepackage[linguistics]{forest}
begin{document}
begin{center}
begin{forest}
for tree={
font=sffamilybfseries,
line width=1pt,
align=center,
child anchor=north,
parent anchor=south,
l sep+=90pt,
}
[{large Root}
[{large Left},
edge path={
noexpandpath[rounded corners=15pt, line width=1.5pt, forestoption{edge}]
(!u.parent anchor) -- +(0,-37.5pt) -| (.child anchor)forestoption{edge label};
}]
[{large Middle},
edge path={
noexpandpath[line width=1.5pt, forestoption{edge}]
(!u.parent anchor) -| (.child anchor)forestoption{edge label};
}]
[{large Right},
edge path={
noexpandpath[rounded corners=15pt, line width=1.5pt, forestoption{edge}]
(!u.parent anchor) -- +(0,-67.5pt) -| (.child anchor)forestoption{edge label};
}]
]
end{forest}
end{center}
end{document}
Also, while we’re at it, I’d like to inquire about a smaller topic which I don’t think is sufficient for a question on its own: Is it possible to add decorations to paths? As an example, small leaves coming out of a path to make it look like a vine.
Add calign with current edge
to the middle node. The problem is that the parent's parent anchor isn't quite aligned with the child's child anchor. 'Left' and 'Right' are not the same width and the anchors are not aligned by default. You have to say if you want a non-default alignment. (There are lots of different variations ....)
Correct answer by cfr on April 10, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP