I want to create syntactic trees and align them in LaTeX as in the picture below.

enter image description here

Can you help me?

  • The tikz-qtree package gives an example similar to this in its documentation. Try that and come back with a sample document if you're having problems. There are also lots of tikz-qtree questions on the site.
    – Alan Munn
    Apr 28, 2013 at 16:01
  • I would recommend that you tag this question with linguistics, because it is a linguistics-related question; and tikz because it deals with graphics. This will grab more attention to your question. Apr 28, 2013 at 16:38
  • @macmadness86 although it's likely that your answer will be the only one in this case, it's usually considered polite to wait some time before reminding people about accepting your answer. There's a fine line between informing new users about how the site works and badgering them to accept your answer. Also, tags are for questions, not answers, so while the linguistics tag is entirely appropriate, the tikz-qtree tag is really based on your answer and not the question; there are other viable ways to create trees in LaTeX.
    – Alan Munn
    Apr 28, 2013 at 18:57
  • @Alan Munn, duly noted! I only said that in this case because he wrote a comment (which has since been deleted because it was inappropriate-a typical new-user thank you very much comment-) which made it seem like my answer had solved his question. As he is a very new user, I wanted to ensure that he checks the mark without just ignoring it like many new users. You are right about the tikz-qtree tag. I wasn't sure if I should include that tag. I will keep that in mind for next time. I will also delete my comment. I want to show good manners! Apr 28, 2013 at 21:01
  • @justlife Since macmadness has definitely provided an answer to your question, it would now be helpful to click on the green checkmark beside it to "accept" the answer.
    – Alan Munn
    Apr 29, 2013 at 17:53

1 Answer 1


You will need

  • tikz package
  • tikz-qtree package

This code will get you pretty near what you are trying to achieve:


\tikzset{level 1/.style={level distance=20pt}}
\tikzset{level 2/.style={level distance=30pt}}
\tikzset{level 3+/.style={level distance=20pt}}
\tikzset{frontier/.style={distance from root=10\baselineskip}}
\begin{tikzpicture}[remember picture]
        [.NNP \node[](john){John}; ]
        [.NNP \node[](smith){Smith}; ] ]%done
    [.{VP} % level 2 VP contains VP1 CC VP2
        [.{VBD} \node[](walked){walked}; ]
            [.{PRP\$} \node[](his){his}; ]
            [.{NN} \node[](dog){dog}; ] ] ]
        [.{CC} \node[](and){and}; ] 
                [.{RB} \node[] (afterwards) {afterwards}; ] ]
            [.{VBD} \node[] (met) {Met}; ]
                [.{NNP} \node[] (mary) {Mary}; ] ] ] ]
        [[[\node[](dot){.}; ] ] ] ] ] ]

        [.{NNP} \node[] (john2) {John}; ]
        [.{NNP} \node[] (smith2) {Smith}; ]]
        [.{VBD} \node[] (walked2) {walked}; ]
            [.{PRP\$} \node[] (his2) {his}; ]
            [.{NN} \node[] (dog2) {dog}; ] ]]
        [[[[\node[] (dot2){.}; ]]]] ] ]

        [.{PRP} \node[] (he2) {He}; ] ]
        [.{VBD} \node[] (met2) {met}; ]
            [.{NNP} \node[] (mary2) {Mary}; ] ]
            [.{RB} \node[] (later2) {later}; ] ] ]
            [[[[{.} ]]]] ] ]
        %draw the lines
\begin{scope}[remember picture, overlay]
    \draw[black,dotted,thick](john)     to (john2);
    \draw[black,dotted,thick] (smith)   to (smith2);
    \draw[black,dotted,thick] (walked)to (walked2);
    \draw[black,dotted,thick] (his)     to (his2);
    \draw[black,dotted,thick] (dog)     to (dog2);
    \draw[black,dotted,thick] (dot)     to [out=220,in=50] (dot2);
    \draw[black,dotted,thick] (met)     to (met2);
    \draw[black,dotted,thick] (mary)  to (mary2);



I will post updated code once I get the leaf nodes aligned! I am not sure why the . leaf is not being aligned with the rest of the leaves.

UPDATE The solution to the problem of getting the . leaf nodes aligned with the other leaves is to nest it within brackets [[[]]], which puts it on a deeper level.

Sample Output

sample output updated to match code

If you are looking for more information, check out Alan Munn's informative answer here.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .