To draw a LaTeX syntax tree, load \usepackage[linguistics]{forest}, write the tree as labeled brackets inside a forest environment, give every word its own brackets, add roof for triangles, then name two nodes and join them with \draw for movement arrows. Compile with pdflatex.
This guide is for syntax students who hand in homework or a thesis typed in LaTeX. One sentence runs through every step: the statement The students will read the paper and its question form Which paper will the students read? Every code block below was compiled with pdflatex (TeX Live 2026, forest 2.1.5) on the free TeXLive.net online compiler on 25 October 2026. The broken examples in Step 7 were compiled too, so the error messages are copied from real logs.
Step 1: Load forest with the linguistics library
Put one line in your preamble: \usepackage[linguistics]{forest}.
The forest package is a TikZ-based package for drawing linguistic trees, written by Sašo Živanović and distributed on CTAN under the LaTeX Project Public License. The linguistics option loads a small library that changes three defaults, per the forest manual (section 4.1). Branches meet under the parent node (sn edges), the top of the tree lines up with your example number, and node labels can run over several lines. The same library defines roof, which you need in Step 5.
Example: a minimal document that compiles on its own:
\documentclass{article}
\usepackage[linguistics]{forest}
\begin{document}
\begin{forest}
[TP [DP] [T$'$ [T] [VP]]]
\end{forest}
\end{document}
No TeX installed? Overleaf and TeXLive.net compile the same file in the browser. \documentclass[border=8pt]{standalone} crops the PDF to the tree, which is how the images in this guide were made. Convert that PDF to PNG to put the tree into Word or Google Slides.
Check: you get a small tree with TP on top and DP, T′ under it.
Step 2: Get a labeled bracket string for your sentence
Before any LaTeX, you need the analysis written as labeled brackets: [TP [DP the students] [T' [T will] [VP [V read] [DP the paper]]]].
The forest package only typesets the syntax tree you give it. It does not parse English. Getting the brackets right is the syntax part of the homework. Turning them into a picture is the typing part.
Example: there are three common ways to get the string.
- Write it by hand. Draw the tree on paper first, then type it top-down, one bracket per node. This is the only route that shows your own analysis, so it is the one most instructors expect.
- Use a free bracket previewer. Several web pages turn a bracket string into a tree picture as you type. They are good for catching a misplaced bracket, but you still write the brackets yourself.
-
Start from a plain sentence. Some tools take the sentence, write the analysis, and draw it. Vizcept, a syntax tree generator, works this way: you type the sentence, pick Traditional, X-bar or Minimalist labels, and the tree is typeset from code. Paid plans can copy the labeled bracket string or forest code. If you already have a labeled bracket string, paste it instead and the tree is drawn exactly as written. Plans start at $14.90 a month, and you can try the first tree free as a watermarked PNG. The copied forest code leaves out movement arrows and there is no .tex file export, so you still add arrows yourself with
\draw(Step 6).

Starting from a plain sentence instead of brackets. Screenshot of Vizcept's tool page, October 2026.
Check: count the brackets. Every [ needs a matching ], and every node has exactly one label. Whatever produced the string, compare it with your own analysis before you hand it in. The tree is only as right as the analysis.
Step 3: Convert the bracket string into forest code
Keep the labels and the nesting, and change two things: put every word string in its own brackets, and write primes in math mode.
In a plain labeled bracket string, [DP the students] means "a DP node with the words the students under it". forest reads the same text as one node whose label is "DP the students". When we pasted the string from Step 2 into forest unchanged, it compiled without a single error and drew nodes labeled "DP the students" and "V read". No error message tells you something is wrong. A bare T' prints a curly apostrophe (T’) instead of a prime (T′), so write T$'$.
Example: the bracket string from Step 2, converted:
\begin{forest}
[TP
[DP [the students]]
[T$'$
[T [will]]
[VP
[V [read]]
[DP [the paper]]]]]
\end{forest}

Same tree, two notations: forest needs the words in their own brackets and the prime written as T$'$. Diagram drawn for this guide.
Check: each word or word group sits at the bottom of its own branch. Spaces and line breaks between brackets do not matter, so indent one level per node. That makes a missing ] easy to spot. Blank lines are the exception (see Step 7).
Step 4: Build the X-bar layers of the syntax tree
In X-bar theory, every phrase XP has an intermediate X′ level between the phrase and its head X.
X-bar theory builds every phrase from the same schema: a specifier, an X′ and a complement. The forest manual opens its decoration section with exactly this XP, specifier, X′, complement template. Your instructor will check that each projection is there, even when it does not branch.
Example: the same sentence with D′, N′ and V′ added. The first line puts every word on the same baseline. It uses where n children=0{tier=word}{}, the manual's example (12), which assigns all nodes with no children to one tier:
\begin{forest}
where n children=0{tier=word}{}
[TP
[DP
[D$'$
[D [the]]
[NP [N$'$ [N [students]]]]]]
[T$'$
[T [will]]
[VP
[V$'$
[V [read]]
[DP
[D$'$
[D [the]]
[NP [N$'$ [N [paper]]]]]]]]]]
\end{forest}

The Step 4 code as pdflatex renders it, with terminals aligned by tier=word. Compiled on TeXLive.net, October 2026.
Check: trace each head up to its phrase. N goes to N′ goes to NP, D goes to D′ goes to DP, V goes to V′ goes to VP. If one link is missing, a bracket is in the wrong place.
Step 5: Add triangles to a syntax tree with roof
Add roof after the words of a phrase you do not want to analyze: [DP [the students, roof]].
A full X-bar syntax tree gets tall fast. When a phrase's inside does not matter for the point you are making, linguists draw a triangle over its words. In forest the comma after the words starts the node's options, and roof is an option from the linguistics library. The Forest Quickstart Guide for Linguists (section 5) shows the same pattern.
Example: both DPs as triangles, so the tree only shows what matters for the clause:
\begin{forest}
[TP
[DP [the students, roof]]
[T$'$
[T [will]]
[VP
[V$'$
[V [read]]
[DP [the paper, roof]]]]]]
\end{forest}
Check: the triangle spans the words, and its top point touches the DP label. A long phrase makes a wide triangle. The quickstart guide's fix is a line break inside the label, as in [walked \\ the dog, roof].
Step 6: Add traces and movement arrows to a syntax tree
Give the moved phrase and its trace a name, then draw an arrow between the two names with TikZ after the tree's last bracket.
The forest package has no built-in movement command. Instead, any node can get a TikZ name, and the \draw command can connect two names. In Which paper will the students read? two things move. The wh-phrase goes from object position to Spec-CP, and will goes from T to C.

The forest manual's movement example: name two nodes, then \draw between them. Source: forest documentation, p. 8, by Sašo Živanović, LaTeX Project Public License 1.3.
Example: traces are written as $t_i$ and $t_j$, with matching subscripts on the moved items:
\begin{forest}
[CP
[DP [which paper$_i$, roof, name=wh]]
[C$'$
[C [will$_j$, name=aux]]
[TP
[DP [the students, roof]]
[T$'$
[T [$t_j$, name=auxtrace]]
[VP
[V$'$
[V [read]]
[DP [$t_i$, name=whtrace]]]]]]]]
\draw[->] (whtrace) to[out=south west, in=south] (wh);
\draw[->] (auxtrace) to[out=south west, in=south] (aux);
\end{forest}

The Step 6 code compiled: wh-movement to Spec-CP and T-to-C movement, drawn with \draw. Compiled on TeXLive.net, October 2026.
Check: each arrow starts at a trace and ends under the phrase that moved. out= and in= set the angle the curve leaves and enters. In the compiled tree the will arrow crosses the subject triangle; changing the out= and in= angles moves the curve if you want it clear. Some textbooks strike through the lower copy instead of writing t. \sout{the paper} does that, and it needs \usepackage[normalem]{ulem}.
Step 7: Fix the compile errors you will hit first
When forest fails, read the first line that starts with ! in the log. The table below lists the messages pdflatex printed for seven common mistakes.
| Mistake | Error message (first line) | Fix |
|---|---|---|
A blank line inside forest
|
Paragraph ended before \forestOappto was complete. |
Delete empty lines inside the environment |
A comma in a label, like [NP, PP]
|
I do not know the key '/tikz/PP' |
Wrap the label in braces: [{NP, PP}]
|
roof with plain \usepackage{forest}
|
I do not know the key '/tikz/roof' |
Load \usepackage[linguistics]{forest}
|
\draw without the final ;
|
Giving up on this path. Did you forget a semicolon? |
End every \draw with ;
|
\draw placed after a node without braces |
Same semicolon message | Wrap code after a node in { }, or move it after the last ]
|
One ] missing |
Argument of \bracket@Parse@token has an extra }. |
Count brackets, or indent one level per node |
\sout without ulem |
Undefined control sequence. |
Add \usepackage[normalem]{ulem}
|
Two of these are easy to misread. The comma error names PP as an unknown key because forest reads everything after a comma as options. The unbraced \draw reports a missing semicolon even when the semicolon is there. The manual's warning is that TikZ code after a node "should usually be enclosed in braces to hide it from the bracket parser".
Is forest better than qtree or tikz-qtree for syntax trees?
For most syntax homework, forest is the safer choice, but qtree is closer to the bracket notation you already know. qtree (version 3.1b, 2008) writes a node as [.VP ... ], with a dot before each label and words separated by spaces. That is almost the labeled bracket string unchanged. Its manual limits trees to 20 levels and five branches per node. tikz-qtree keeps the qtree syntax and draws with TikZ, which adds arrows between nodes. forest uses its own bracket syntax, has a packing algorithm its manual describes as producing very compact trees, and has the linguistics library with roof and c-command helpers. If a classmate's template uses \Tree [.S ...], that is qtree or tikz-qtree, and it will not paste into a forest environment as is.
FAQ
How do I create a tree in LaTeX?
Load \usepackage[linguistics]{forest}, then write the tree inside \begin{forest} ... \end{forest} with one pair of square brackets per node, label first. Words go in their own brackets under their category. Compile with pdflatex. Overleaf has a ready-made forest syntax tree template.
How do you do a syntax tree?
Find the main verb and its arguments, group words into phrases around their heads (NP, VP, PP), then attach the phrases to a clause node (S, TP or CP) from the bottom up. Write the result as labeled brackets and check that every word appears once, left to right, along the bottom.
Why do my nodes show "DP the students" instead of a branch?
The forest package treats everything before the first nested bracket as one label, so [DP the students] becomes a single node. Put the words in their own brackets, [DP [the students]], and the DP gets a branch down to the words.
Disclosure: written by the team behind Vizcept.
Top comments (0)