1

does anybody know how to put a square on a tree? I want to put a square surrounding [.DP [.D' [.D\$\emptyset$ ] [.NP [.N' [.N\Jill ] ] ] ] ] this part, but couldn't find a way to do so with tikz-qtree. Thanks!

\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

As explained in the tikz-qtree manual, you can use \node commands in the tree. This allows you to use fit to draw a frame around nodes that you gave names.

\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}

enter image description here

  • Thanks! It did the trick! Great! – Erda Sep 25 '19 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.