- 我
forest
第一次使用,很难理解(非常好的)手册。 - 我想让树更紧凑(参见注释)。
- 哪个参数控制它?
\documentclass{article}
\usepackage[edges]{forest}
\begin{document}
\begin{forest}
forked edges,
for tree = {
align = center, % needed for "\\" in nodes.
draw,
font = \tiny,
where level = 0{
}{
folder,
grow' = 0,
},
},
[0
[1]
[\ldots]
[2
[2.1]
[2.2]
[\ldots]
]
[3
[3.1]
[3.2]
]
[4
[4.1
[4.1.1]
[4.1.2]
[4.1.3]
[4.1.4]
[4.1.5]
]
[5.1
[5.1.1]
[5.1.2]
[5.1.3]
[5.1.4]
[5.1.5]
]
]
]
\end{forest}
\end{document}
有关的
答案1
可以使用l=something
根的子节点来缩短最顶层的间隙(我将其设置为原来的 0.6 l
),但请注意,由于我们缩短了距离,因此我们还需要l sep=0
在根节点上进行设置。
其他缺陷是folder
每个节点使用多次的人工制品。问题是,在原始代码中,folder
位于两个循环内,for tree
并且。这通常不是一个好主意,因为它会花费更多时间,但在这棵树中,效果也是显而易见的。在这些情况下,where level
我通常建议使用if level
而不是,但在这里,后面跟着似乎更优雅。where level
for tree
for descendants
\documentclass{article}
\usepackage[edges]{forest}
\begin{document}
\begin{forest}
forked edges,
l sep = 0, for children = {l*= 0.6},
for tree = {
align = center, % needed for "\\" in nodes.
draw,
font = \tiny,
},
for descendants={
grow' = 0,
folder,
},
[0
[1]
[\ldots]
[2
[2.1]
[2.2]
[\ldots]
]
[3
[3.1]
[3.2]
]
[4
[4.1
[4.1.1]
[4.1.2]
[4.1.3]
[4.1.4]
[4.1.5]
]
[5.1
[5.1.1]
[5.1.2]
[5.1.3]
[5.1.4]
[5.1.5]
]
]
]
\end{forest}
\end{document}