Introduction to Linguistic Trees
In linguistics, visual representations of structure—whether for syntax, morphology, or phonology—are essential. While you could draw these by hand or use general-purpose drawing software, LaTeX offers specialized packages that create mathematically precise, professional-looking trees that automatically adjust their spacing based on the content.
The gold standard for modern linguistics in LaTeX is the forest package. It is built on top of PGF/TikZ and provides a concise "bracket notation" that is much easier to read and write than raw drawing commands.
Getting Started with the forest Package
To begin creating trees, you must include the forest package in your document preamble. If you are also doing heavy linguistic work, you might want the gb4e or linguex packages for numbered examples, but forest handles the drawing itself.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{forest}
\begin{document}
% Your trees will go here
\end{document}The basic environment is \begin{forest} ... \end{forest}. Inside this environment, you define your tree using nested square brackets.
The Basic Syntax: Bracket Notation
The logic of a tree in forest follows a simple rule: [Mother [Daughter1] [Daughter2]].
\begin{forest}
[VP
[V [eats]]
[NP
[D [the]]
[N [apple]]
]
]
\end{forest}How it works:
- Every node is enclosed in square brackets
[]. - The first text after the opening bracket is the label of that node.
- To create "children" for a node, you simply place more brackets inside the parent's brackets.
Note: Pay close attention to your closing brackets! A missing
]is the most common cause of "Dimension too large" or "Paragraph ended before \forest@collect@args was complete" errors.
Essential Customizations for Linguists
Linguistic trees often require specific formatting, such as triangles for unanalyzed phrases or specific alignment for glosses.
1. Drawing "Roofs" (Triangles)
When you don't want to show the internal structure of a phrase (like an NP), you use a triangle or "roof." In forest, you can use the roof option.
\begin{forest}
[S
[NP [the student, roof]]
[VP
[V [slept]]
]
]
\end{forest}2. Styling the Nodes
By default, nodes are centered. However, you can apply styles to the whole tree or specific nodes. One common linguistic style is making the nodes align nicely at the bottom.
\begin{forest}
for tree={
parent anchor=south,
child anchor=north,
align=center
}
[TP
[NP [She]]
[T'
[T [will]]
[VP [dance]]
]
]
\end{forest}for tree={...}applies the settings to every node in that specific tree.parent anchorandchild anchorensure the lines (edges) connect to the centers of the text.
Representing Movement and Relations
In generative syntax, we often need to show "movement" (displacement) using arrows. Since forest is based on TikZ, you can name nodes and draw arrows between them.
To do this:
- Give a node a name using the
name=xyzsyntax inside the brackets. - Use the
\drawcommand after the tree structure but before the end of the environment.
\begin{forest}
[CP
[DP, name=wh [which book]]
[C'
[C [did]]
[TP
[NP [you]]
[VP
[V [read]]
[DP, name=trace [t]]
]
]
]
]
% Draw the arrow from the trace to the wh-element
\draw[->, dotted] (trace) to [out=south, in=south] (wh);
\end{forest}Best Practice: Use out and in angles (like south or 270) to control the curve of the arrow so it doesn't cross through your text labels.
Morphological and Phonological Trees
Linguistic trees aren't just for syntax. You can use the same logic for word structure (morphology) or syllable structure (phonology).
Morphological Example
For morphology, you often want the branches to meet at a single point without much horizontal spacing.
\begin{forest}
[Word
[Prefix [un-]]
[Stem
[Adj [happy]]
[Suffix [-ly]]
]
]
\end{forest}Phonological Example (Syllables)
In phonology, we often use Greek letters like $\sigma$ for syllables.
\begin{forest}
[$\sigma$
[Onset [c]]
[Rhyme
[Nucleus [a]]
[Coda [t]]
]
]
\end{forest}Common Pitfalls and Best Practices
As you begin building more complex diagrams, keep these tips in mind to keep your code maintainable.
1. Indentation is Your Friend
While LaTeX doesn't care about whitespace, you should. Always indent your brackets to match the depth of the tree. This makes it much easier to spot where a branch starts and ends.
2. Handling Reserved Characters
If your node labels contain brackets (e.g., features like [+past]), LaTeX will get confused and think you are starting a new node. Wrap these in curly braces:
- Incorrect:
[V [+past]] - Correct:
[V [{[+past]}]]
3. Scaling Large Trees
If a tree is too wide for your page, don't try to manually resize it with \small. Instead, use the scale option within the forest environment or use the adjustbox package.
Expert Tip: If you find yourself writing the same styling code (like
for tree={...}) for every single tree, define a custom style in your preamble:\forestset{default tree/.style={for tree={parent anchor=south, child anchor=north}}}Then use\begin{forest} default tree [...] \end{forest}.
Summary Checklist
- Use
\usepackage{forest}in the preamble. - Use
[Mother [Daughter]]syntax. - Use
, rooffor triangles over unanalyzed phrases. - Use
name=...and\drawfor movement arrows. - Ensure every opening
[has a corresponding closing].
