到目前為止,我已經使用 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}
在此更新中,我添加了第二棵樹用於說明,並將所有定義打包為您可以回收的樣式,並且允許您進行全域變更。相對垂直對齊改編自這個很好的答案。