答案1
使用forest
。我添加了一个键nplet
,通过自动插入一系列编号的项目来帮助避免重复。
\documentclass{article}
\usepackage[edges]{forest}
\usepackage{geometry}
\forestset{nplet/.style n args={2}{%
repeat={#2}{append={[#1_{\pgfmathparse{n}\pgfmathresult},math content,draw,text width=1.55em,forked edges]}}}}
\begin{document}
\begin{forest}
forked edges,
for tree={grow'=0,draw,math content,if={level()==1}{s sep+=-1ex}{}}
[P
[L_{21},nplet={C}{12}
]
[L_{22},nplet={D}{6}
]
[L_{23},nplet={E}{7}
]
[L_{24},nplet={F}{2}
]
[L_{25},nplet={G}{1}
]
]
\end{forest}
\end{document}