[Tex/LaTex] adding a node to a qroof in tikz-qtree

linguisticstikz-qtreetrees

I need a node in the head element of a qroof in tikz-qtree (using tikz-qtree-compat). I need the 'np' to be a node so I can draw an arrow to it. However, the following breaks:

\documentclass[10pt]{article}
\usepackage{tikz-qtree}
\usepackage{tikz-qtree-compat}
\begin{document}
\begin{tikzpicture}
\Tree [ .TP I [ .T' T[past] [ .\node(vp){vP}; { } [ .v' v\\saw [ .VP { } [ .V' V(saw) \qroof{a man}.\node(nP){nP} ] ] ] ] ] ]
\end{tikzpicture}
\end{document}

The error is: Undefined control sequence \node(nP)nP.

Any ideas on how to accomplish a node there?

Best Answer

There are limits to the direct compatibility of qtree commands. The \qroof command is emulated with the \node command, which is why it can't use a \node as its label. But tikz-qtree has its own method for doing roof structures. You should use this for more complex roofs:

\documentclass[10pt]{article}
\usepackage{tikz-qtree}
\usepackage{tikz-qtree-compat}
\tikzset{every tree node/.style={align=center, anchor=north}} % to allow linebreaks
\begin{document}
\begin{tikzpicture}
\Tree [ .TP I [ .T\1 T\\{[past]} [ .\node(vp){vP}; { } [ .v\1 v\\saw 
      [ .VP { } [ .V\1 V\\(saw) [.\node(nP){nP}; \edge[roof]; {a man} ] ] ] ] ] ] ]
\end{tikzpicture}
\end{document}

P.S. I also cleaned up some of your formatting: you should use \1 for formatting bar levels instead of just '.

Related Question