7

When drawing syntactic representations in linguistics, one often uses a triangle to represent a unit whose internal structure is irrelevant. This can be accomplished with the tikz-qtree command \edge[roof]; {John}.

Now, sometimes I need to show the movement of such a unit whose internal structure is irrelevant to the point at hand. To do this, I usually make use of the positioning library, and define a node relative to the node above the triangle, like so:

\documentclass{article}

\usepackage{tikz}
\usepackage{tikz-qtree}
\tikzset{every tree node/.style={align=center, anchor=north}}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}
\Tree
[.TP
    [.\node(DP1-rel){DP}; \edge[roof]; {John} ]
    [.T$'$
        [.T ]
        [.\emph{v}P
            [.\node(DP2-rel){DP}; \edge[roof]; {$<$John$>$} ]
            [.\emph{v}$'$
                [.\emph{v}
                    [.V \node(V1){likes}; ]
                    [.\emph{v} ]
                ]
                [.VP
                    [.V \node(V2){$<$likes$>$}; ]
                    [.DP \edge[roof]; {Mary} ]
                ]
            ]
        ]
    ]
]
\node (DP1) [below=1cm of DP1-rel] {};
\node (DP2) [below=1cm of DP2-rel] {};
\draw[->] (DP2)..controls +(south west:1) and +(south:1)..(DP1);
\draw[->] (V2)..controls +(south:1) and +(south:1)..(V1);
\end{tikzpicture}

\end{document}

syntactic-tree

Is there an easier/better way to do this, where I don't have to define a relative node each time I need to move a unit whose internal structure is irrelevant (i.e., whose structure I'm representing with a triangle, using the tikz-qtree command \edge[roof]; {John})?

percusse
  • 157,807
Adam Liter
  • 12,567

2 Answers2

10

You can just make the text of the roof a node. (I also simplified the arrow syntax a bit.)

\documentclass{article}

\usepackage{tikz-qtree,tikz-qtree-compat}
\tikzset{every tree node/.style={align=center, anchor=north}}

\begin{document}


\begin{tikzpicture}
\Tree
[.TP
    [.DP \edge[roof]; \node (J) {John}; ]
    [.T$'$
        [.T ]
        [.\emph{v}P
            [.DP \edge[roof]; \node (Jtrace) {$<$John$>$}; ]
            [.\emph{v}$'$
                [.\emph{v}
                    [.V \node(V1){likes}; ]
                    [.\emph{v} ]
                ]
                [.VP
                    [.V \node(V2){$<$likes$>$}; ]
                    [.DP \edge[roof]; {Mary} ]
                ]
            ]
        ]
    ]
]

\draw[->] (Jtrace) [in=-90,out=-90,looseness=1.5]  to (J);
\draw[->] (V2) [in=-90,out=-90]  to (V1);
\end{tikzpicture}

\end{document}

output of code

Alan Munn
  • 218,180
  • Huh, nice, I didn't know you could do that. I always tried putting the node inside of the {}. Thanks, Alan! Thanks for the simpler way of drawing arrows, too. – Adam Liter Nov 11 '13 at 01:12
3

I don’t know about tikz-qtree but with forest, you can access the tree’s node with the special ! syntax. The node (!2211) (in your examples, this is <John>), is the root’s (TP) second child’s (T') second child’s (vP) first child’s (DP) first child (<John>).

Then, there is always the possibility to give a node a name with the usual TikZ key: name (or alias if you need more than one name).

There is also the possibility to give a node that is relative to another (which is actually the general case for the ! syntax). In this example, we go up, then to the last child and to its 2nd child’s 1st child which leads to (!ul21).

Each has its advantages, depending on how much static the tree actually is. If you move a lot around, it would be wise to give the nodes a fixed name. If one always keeps relative fixed to another node, you can use the relative node name. If a node always keeps relative to the root, you can use the special relative syntax after the tree (i.e. after the root node).

In the code below, I took the liberty to define a style angled that adds < and > automatically to its content. I also used another path for the connections (which I think looks a bit better but I’m not a linguist).

Code

\documentclass[tikz]{standalone}
\usepackage{forest}
\usetikzlibrary{paths.ortho}% http://tex.stackexchange.com/a/110172/16595
\forestset{angled/.style={content/.expanded={$<$\forestov{content}$>$}}}
\begin{document}
\begin{forest} s sep*=3
[TP
  [DP, tikz={\draw[blue, ->] () -- node[sloped, above] {\ttfamily !ul21} (!ul21);}
    [John, triangle] ]
  [T'
    [T]
    [\emph{v}P
      [DP
        [John, triangle, angled] ]
      [\emph{v}'
        [\emph{v}
          [V
            [likes, name=V1] ]
          [\emph{v} ] ]
        [VP
          [V
            [likes, angled, name=V2] ]
          [DP
            [Mary, triangle] ] ] ] ] ] ]
%
\path[rounded corners, du, -latex] (!2211) edge (!11)
                                   (V2)    edge (V1);
\end{forest}
\end{document}

Output

enter image description here

Qrrbrbirlbel
  • 119,821