到目前为止,我已经使用 TikZ 完成了此操作:
\documentclass{article}
\usepackage{tikz}
\usepackage{calc}
\begin{document}
\def\mytext{The man}
\newlength{\basewidth}
\setlength{\basewidth}{\widthof{\mytext}}
\begin{tikzpicture}[
firstnode/.style={
shape = rectangle,
inner sep = 2pt,
anchor=south west,
}
]
\draw[thin] (0,0) -- (\basewidth + 2ex,0);
\draw[thin] (0,0) -- (0, 1.5em);
draw (0,0) \node[firstnode,
minimum width = \basewidth] {\mytext};
\end{tikzpicture}
\end{document}
结果如下:
我怎样才能完成该图表(以可重复、有效的方式)?
答案1
这个怎么样?
\documentclass{article}
\usepackage[edges]{forest}
\forestset{students/.style={folder,
grow'=0,edge = {semithick},
edge path'={(!u.south-|.south west) |- (.south east)},
anchor=west,l sep=2.5em,s sep=0em}}
\usepackage{adjustbox}
\begin{document}
\begin{tabular}{lll}
\begin{adjustbox}{valign=T}
\begin{forest}
for tree={students}
[The man
[big]
[who lept
[nimbly]
[over the wall]
]
]
\end{forest}\end{adjustbox}&
\begin{adjustbox}{valign=T}\begin{forest}
for tree={students}
[sends
[always]
[to mother
[his]
]
[because he loves her
[truly,xshift=3em]]
]
\end{forest}\end{adjustbox}&
\begin{adjustbox}{valign=T}\begin{forest}
for tree={students}
[flowers
[expansive]
]
\end{forest}
\end{adjustbox}
\end{tabular}
\end{document}
在此更新中,我添加了第二棵树以供说明,并将所有定义打包成可以重复使用的样式,并允许您全局进行更改。相对垂直对齐改编自这个很好的答案。