下面的树看起来完全符合要求。但是,有没有一种更优雅的方法是将每一层上的所有节点左对齐,而无需明确指定tier
每个节点?这很容易出错,而且确实会使源代码变得混乱。我是否可以在for tree
-propagator 中放入一个全局选项?
\documentclass{article}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree={grow'=east, anchor=west}
[Root,
[C1, for children={tier=1}
[GC1Long, for children={tier=2} [GGC1][GGC2]]
[GC2, for children={tier=2} [GGC1][GGC2Long]]
]
[C2Long, for children={tier=1}
[GC1, for children={tier=2} [GGC1][GGC2]]
[GC2]
]
[C3VeryLong, for children={tier=1}
[GC1][GC2]
]
]
\end{forest}
\end{document}
答案1
这样的事情会起作用吗?这是基于forest
手册第 45-46 页的示例。
\documentclass{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree={grow'=east, child anchor=west, anchor=base
west, tier/.pgfmath=level()}
[Root,
[C1
[GC1Long [GGC1][GGC2]]
[GC2 [GGC1][GGC2Long]]
]
[C2Long,
[GC1 [GGC1][GGC2]]
[GC2]
]
[C3VeryLong
[GC1][GC2]
]
]
\end{forest}
\end{document}