Tikz-qtree:如何在树上放置正方形?

Tikz-qtree:如何在树上放置正方形?

有人知道如何在树上放置一个正方形吗?我想在 [.DP [.D' [.D\$\emptyset$ ] [.NP [.N' [.N\Jill ] ] ] ] ] 这部分周围放置一个正方形,但找不到使用 tikz-qtree 的方法。谢谢!

\documentclass[12pt]{article}

\usepackage{dingbat}
\usepackage{enumitem}
\usepackage{tipa}
\usepackage{multicol}
\usepackage{qtree}
\setlength\parindent{0pt}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage[bottom]{footmisc}
\usepackage{newtxtext}
\usepackage{lipsum}
\usepackage[margin=2cm,left=2cm,includefoot]{geometry}
\usepackage{setspace}
\setstretch{1.5}
\usepackage{apacite}
\usepackage{caption}
%\captionsetup[table]{position=bottom}
\usepackage{array}
\usepackage{tabulary}
\newcolumntype{K}[1]{>{\centering\arraybackslash}p{#1}}
\usepackage{multirow}
\usepackage{gb4e}
\usepackage{ulem}
\usepackage{graphicx} 
\tikzset{every tree node/.style={align=center, anchor=north}}
\usepackage{arydshln}

\begin{document}

\begin{tikzpicture}[scale = 0.7]

\Tree [.IP [.DP [.D' [.D\\$\emptyset$ ] [.NP [.N' [.N\\Jill ] ] ] ] ] 
          [.I' [.I\\past ]
          [.VP [.V' [.V' [.V' [.V\\smashed ] [.DP \edge[roof]; {beans/them} ] ] 
          [.DP [.D' [.D\\every ] [.NP \edge[roof]; {day} ] ] ] ]           
          [.PP [.P' [.P\\for ] [.DP [.D' [.D\\$\emptyset$ ] [.NP \edge[roof]; {fun} ] ] ] ] ] ] ] ] ]

\end{tikzpicture}


%%%tree2%%%
\newpage
\textbf{Tree Two}

\begin{tikzpicture}[scale = 0.7]

\Tree [.IP [.NP [.D^{0}\\A ] [.N' [.AP [.A' [.A^{0}\\fake ] ] ] [.N' [.N' [.N^{0}\\semanticist ] ] [.PP [.P' [.P^{0}\\from ] ] [.NP [.N' [.N^{0}\\T{\"u}bingen ] ] ] ] ] ] ] [.I' [.I^{0}\\will ] [.VP [.V' 
          [.V^{0}\\discuss ] [.NP [.D^{0}\\the ] [.N' [.N' [.N^{0}\\problem ] ] [.PP [.P' [.P^{0}\\with ] [.NP [.N' [.N^{0}\\syntacticians ] ] ] ] ] ] ] 
] ] ] ]

\end{tikzpicture}

答案1

tikz-qtree手册中所述,您可以使用\node树中的命令。这允许您使用fit在命名的节点周围绘制框架。

\documentclass[12pt]{article}
\usepackage[margin=2cm,left=2cm,includefoot]{geometry}
\usepackage{tikz-qtree}
\usetikzlibrary{fit}
\begin{document}

\begin{tikzpicture}[scale = 0.7]

\Tree [.IP [.\node(DP){DP}; [.D' [.\node(D0){D\\$\emptyset$}; ] [.NP [.N' [.\node(NJ){N\\Jill}; ] ] ] ] ] 
          [.I' [.I\\past ]
          [.VP [.V' [.V' [.V' [.V\\smashed ] [.DP \edge[roof]; {beans/them} ] ] 
          [.DP [.D' [.D\\every ] [.NP \edge[roof]; {day} ] ] ] ]           
          [.PP [.P' [.P\\for ] [.DP [.D' [.D\\$\emptyset$ ] [.NP \edge[roof]; {fun} ] ] ] ] ] ] ] ] ]

\node[fit=(DP)(NJ)(D0),inner sep=0pt,draw]{};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容