如何在树上自上而下画一个圆圈

如何在树上自上而下画一个圆圈

我怎样才能在树中从上到下绘制一个圆圈?我需要从 PartP 向下到 # 绘制一个圆圈。以下是代码:

\documentclass[a4paper,12pt, twoside]{report}
\usepackage{tikz-cd}
\usepackage[linguistics]{forest}
\begin{document}
\begin{forest}
[PartP
[Part]
[$\pi$
[$\pi$]
[PlP
[Pl]
[\#P
[\#]
[TP
[T]
[IndP
[Ind]
[MoodP
[Mood]
[AspP
[Asp]
[ResP
[Res]
[ProcP [Proc] [State]]
]
]
]
]
]
]
]
]
]
\end{forest}
\end{document}

答案1

您可以命名相关节点,然后使用fitting库(由 自动加载forest)来绘制圆圈:

\documentclass[a4paper,12pt, twoside]{report}
\usepackage{tikz-cd}
\usepackage[linguistics]{forest}
\begin{document}
\begin{forest}
[PartP,name=PartP,tikz={\node[draw,circle,fit=(PartP) (NumP)] {};}
[Part]
[$\pi$
[$\pi$]
[PlP
[Pl]
[\#P,name=NumP
[\#]
[TP
[T]
[IndP
[Ind]
[MoodP
[Mood]
[AspP
[Asp]
[ResP
[Res]
[ProcP [Proc] [State]]
]
]
]
]
]
]
]
]
]
\end{forest}

\end{document}

代码输出

相关内容