# Producing Syntactic Trees with LaTeX

Often when I see syntactic trees, they are produced by creating the graphics in Powerpoint, saved as an image file, and then imported it into Word. It’s cumbersome, slow, and not a very flexible way of dealing with it. There might be other more elegant solutions, but this was the method I was taught when I was an undergrad. It is also possible to draw up trees directly in Word, but drawing up every single line, making text boxes etc. is equally cumbersome. Alternatively, there are online tools that can do this for you, but then you can’t always be sure that the site is always working, or that you’re online when you need to produce the tree.

### Enter qtree

In LaTeX we have a package dedicated to producing syntactic trees called qtree, and with just a single line of code you’re able to produce rather elaborate trees. This makes the process much more flexibe, and it’s much easier to reproduce and adapt if you need to produce multiple trees. I must admit though at a first glance the code to produce a tree seems daunting:

\Tree [.S [ I [.VP use [.NP {\LaTeX} ]]]]


which will produce:

However, it is actually quite simple. In fact, I find producing these trees with qtree to be much easier than to conceptually understand the trees themselves. Every square bracket [ ] starts a new branch. Every branch begins with a full stop ‘.’ followed by an optional label, for example .VP. This is followed by the text that comes below the label, for example ‘love’. You can make branches within branches. In the example here above PP, VP and NP are all placed with the S branch.

To see how this works, we can add a bit of complexity to our sentence:

\Tree [.S [ I [.VP use [.NP {\LaTeX} [.Adv.P [all [.NP the time ]]]]]]]


which will produce the following tree:

Here’s a full example that will produce both trees:

\documentclass{article}
\usepackage{qtree}

\begin{document}

\Tree [.S [ I [.VP use [.NP {\LaTeX} ]]]]
\vspace{48pt}
\Tree [.S [ I [.VP use [.NP {\LaTeX} [.Adv.P [all [.NP the time ]]]]]]]

\end{document}


The nice thing about this is that you can focus on the logic behind the trees and leave all of the grahical formatting to LaTeX.  Here I’ve shown only the basic functionality of the qtree package. Look up the documention in the link below if you’re missing some features.

https://ctan.org/pkg/qtree

This site uses Akismet to reduce spam. Learn how your comment data is processed.