我用包制作了以下树forest
,但不幸的是,到 Z 的边穿过了 M。这是为什么?我已经尝试增加选项,s sep
但无法修复它。有人知道如何增加这两个节点之间的距离吗?
\documentclass[aspectratio=169,xcolor=dvipsnames]{beamer}
\usepackage[edges]{forest}
\begin{document}
\begin{frame}
\begin{forest}
for tree={circle, draw,
minimum size=1.5em,
inner sep=1pt, s sep=5pt,
align=center, top color=white},
for leaves={rectangle}
[, top color=gray, bottom color=gray, minimum size=4mm
[E
[I
[L
[I
[G]]]]
[U
[C
[H]]
[L
[E]]
[R
[O]]]]
[F
[L
[O
[G]]]]
[G
[E
[L
[B
[E]]
[D]]]]
[M
[I
[T]]]
[Z
[U]]]
\end{forest}
\end{frame}
\end{document}
答案1
只需为第 1 级添加一个选项,如下所示:if level=1{l=18mm}{}
增加根节点和第一个子节点之间的级别距离。这可以防止破坏树的样式(就像 imho 中的情况一样child anchor = north
)。
\documentclass[aspectratio=169,xcolor=dvipsnames]{beamer}
\usepackage[edges]{forest}
\begin{document}
\begin{frame}
\begin{forest}
for tree={circle, draw,
minimum size=1.5em,
inner sep=1pt, s sep=5pt,
align=center, top color=white,
if level=1{l=18mm}{} % <---------- This is it
},
for leaves={rectangle}
[, top color=gray, bottom color=gray, minimum size=4mm
[E
[I
[L
[I
[G]]]]
[U
[C
[H]]
[L
[E]]
[R
[O]]]]
[F
[L
[O
[G]]]]
[G
[E
[L
[B
[E]]
[D]]]]
[M
[I
[T]]]
[Z
[U]]]
\end{forest}
\end{frame}
\end{document}