答案1
这应该满足要求——帮助在乳胶中画一棵树
必须输入数据
\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{forest}
\usetikzlibrary{shadows}
\begin{document}
\tikzset{
my node/.style={
draw=gray,
inner color=gray!5,
outer color=gray!10,
thick,
minimum width=1cm,
% rounded corners=3,
text height=1.5ex,
text depth=0ex,
font=\sffamily,
drop shadow,
}
}
\begin{forest}
for tree={%
my node,
l sep+=5pt,
grow'=east,
edge={gray, thick},
parent anchor=east,
child anchor=west,
if n children=0{tier=last}{},
edge path={
\noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) -- +(10pt,0) |- (.child anchor)\forestoption{edge label};
},
if={isodd(n_children())}{
for children={
if={equal(n,(n_children("!u")+1)/2)}{calign with current}{}
}
}{}
}
[A
[b
[l]]
[c
[e[m]][f[n]][g[o]][h[p]]]
[d
[j[r]][k[s]]]
]
\end{forest}
\end{document}
答案2
已经有一个使用森林的正确答案,所以这只是一个社区维基评论:首先,最好有一个更简单的例子。
\documentclass[tikz,border=10pt]{standalone}
\usepackage[edges]{forest}
\begin{document}
\begin{forest}
forked edges,
for tree={grow=0,draw,
font=\strut\footnotesize\sffamily\em},
[Homo
[Homo ergaster $\dagger$]
[Homo erectus
[Homo stultus]
[Homo sapiens $\dagger$]]
[Homo habilis $\dagger$ ]]]
\end{forest}
\end{document}