forest's manual opens with a confession by its author: for years he had been a grateful user of qtree and synttree, but every tool on the market had the same flaw — the trees sometimes came out too wide. That single irritation produced what is now the first choice for drawing trees in LaTeX: syntax trees, directory listings, decision trees, probability trees. The older qtree and tikz-qtree are still very much alive, though, and their bracket notations look almost identical while differing in exactly one decisive place. Move between them without knowing about it and you get, with no error at all, a node literally named .S. This page runs from that difference through to choosing between the tools.
Bracket notation: building a tree without a single coordinate
Every tree-drawing tool takes nested brackets as its input because a tree is itself a recursive structure. There is a root, children hang beneath it, those children have grandchildren — mirror that nesting with nested [ ] and all the coordinate arithmetic becomes the tool's problem, not yours. In forest you write [S [NP] [VP]]; in qtree, \Tree [.S [.NP ] [.VP ] ]. What you are typing is not a layout but a structure.
There are effectively three options. forest (Sašo Živanović; v2.1.5 in TeX Live 2024), built on TikZ and pgfkeys, is the most flexible and does the layout for you. The classics for drawing a linguistic syntax tree in the fewest keystrokes are qtree (v3.1b) and tikz-qtree (David Chiang, v1.2), which reimplements the same notation on TikZ. And for a tree of a few levels where you would rather not add a package, TikZ's own trees library — child and node — is enough. Below, we clear up the difference between the two bracket notations first, then take each tool in turn.
The difference between [.S [.NP ]] and [S [NP]]: qtree's dot means nothing to forest
The short answer: in qtree a leading period marks "this is a branching node", while in forest a period is just a character. In qtree, [.S ... ] means "a non-terminal node called S", and a bare word with no period is a leaf. forest has no such convention: everything from the [ up to the next [ or ] is the label. So handing forest a [.S [.NP Kim ]] produces — with no error whatsoever — two nodes labelled .S and .NP Kim. Kim does not become a leaf; it ends up inside the same box as .NP.
% qtree / tikz-qtree: a leading dot marks a branching node,
% and a closing ] must be preceded by whitespace
\Tree [.S [.NP Kim ] [.VP [.V saw ] [.NP Lee ] ] ]
% forest: no dots, and every word is a node of its own
\begin{forest}
[S
[NP [Kim]]
[VP [V [saw]] [NP [Lee]]]
]
\end{forest}The mistake in the other direction fails far more loudly. qtree requires whitespace before a closing ], so writing [.NP Kim] tight gives you ! LaTeX Error: \begin{tabular} on input line 5 ended by \end{document}. — an error that names tabular in a document containing no table at all. Do the same to tikz-qtree and you get ! Emergency stop. with no PDF produced. A hand trained on forest trips here first when it touches a qtree source. In short, neither notation quietly accepts the other, so when moving a file between them, check the package and the notation as a pair.
forest's automatic layout, and tightening the spacing by hand
The central feature of forest is the answer to the "too wide" complaint from the top of this page: automatic packing. It places each node according to the real width of the subtree it dominates and pushes siblings as close together as they will go without colliding, so even a busy tree settles into something presentable as-is. To intervene, apply for tree={...} to the whole tree or to a subtree. The three keys you reach for most are s sep (horizontal separation between siblings), l (the vertical distance between levels) and inner sep (the padding around a node's contents).
\usepackage[linguistics]{forest}
\begin{forest}
for tree={s sep=10mm, inner sep=0, l=0}
[CP
[C]
[IP, for tree={s sep=20mm}
[I, name=src]
[VP
[V]
[DP, roof, name=tgt [the woman]]
]
]
]
\draw[->] (src) to[out=south west, in=south] (tgt);
\end{forest}That short example carries most of forest's idioms. The opening for tree={...} becomes the default for the whole tree, and putting a comma after a node label — as in [IP, for tree={s sep=20mm} — overrides the setting for just that subtree. Give a node a name= and, after the tree is closed, you can draw a movement arrow with \draw[->] (src) to[...] (tgt);, because TikZ commands work directly inside a forest environment. To put a comma inside a label, wrap it in braces as {NP, PP} so it is not read as a layout instruction. And if you do not want to write the same look every time, define a default in the preamble with \forestset{default preamble={for tree={...}}}.
And here is the pitfall people hit most often: a blank line inside a forest source makes the parse fail. A blank line is a paragraph break to TeX, so parsing is cut off mid-tree and you get ! Paragraph ended before \forestOappto was complete. — an error that looks unrelated to trees. The urge to air out a long tree is understandable, but line breaks and indentation are allowed and blank lines are not. Indentation depth, on the other hand, is entirely free, so use that to show the hierarchy.
The linguistics and edges libraries: without them, roof and folder do not exist
Part of forest's functionality lives in libraries, which you have to load as options — \usepackage[linguistics]{forest}, for instance. The one people trip over most is roof, which puts a triangular "roof" over a phrase. It is defined in the linguistics library rather than in forest's core, so writing [DP, roof [the woman]] under a plain \usepackage{forest} stops with ! Package pgfkeys Error: I do not know the key '/tikz/roof'. Likewise folder, the style everyone recognises from directory diagrams, belongs to the edges library.
It also helps to know what the linguistics library actually does. First, sn edges: forest's default joins a parent and child border to border, and this changes it to run from the parent's south to the child's north — the shape you recognise from linguistic syntax trees. Second, it aligns the baseline with the root, which is why the tree lines up with the example number or the gloss beside it. Third, it defines nodewalks for c-command, so c-commanded and c-commanders let you address that whole set of nodes at once. The edges library, for its part, supplies folder and also forked edge / forked edges, which bend the branches into right angles.
qtree and tikz-qtree: a syntax tree on one line
For dashing off a single syntax tree, the \Tree notation is still the shortest route. Load \usepackage{qtree} and one line — \Tree [.S [.NP Kim ] [.VP [.V saw ] [.NP Lee ] ] ] — gives you a tree. Inside, it is the confluence of two people's work: the tree-drawing macros themselves are Jeffrey Mark Siskind's QobiTree, and the front end and extensions that make them comfortable from LaTeX are by Alexis Dimitriadis. Since version 3.0b (2005) the lines are drawn with pict2e, so you get the same result whether you go through DVI/PostScript or straight to PDF.
qtree comes with a set of conveniences aimed squarely at syntax trees. Inside a tree, NP_i and N^0 are turned into subscripts and superscripts in math mode automatically, and X\1 abbreviates X$'$ (X′). To put a triangle over a phrase, write \qroof{out of style}.PP — the same job as forest's roof, spelled differently. Trees are centred by default, so load \usepackage[nocenter]{qtree} if you want them flush left.
tikz-qtree (David Chiang) rebuilds the same \Tree notation on top of TikZ. Load \usepackage{tikz} and \usepackage{tikz-qtree} together and the same source goes through unchanged. Its author names three gains: it lays nodes out without collisions, unlike TikZ's standard trees; it adds TikZ features to qtree — edge labels, arrows between nodes; and unlike pst-qtree it works with pdfTeX and XeTeX. The growth direction is adjustable too: give the tikzpicture a [grow'=right] and the tree runs left to right. Compatibility is high but not total, so compile and look before trusting a complicated tree to the move.
\usepackage{tikz}
\usepackage{tikz-qtree}
% sideways tree: grow to the right instead of downwards
\begin{tikzpicture}[grow'=right]
\Tree [.S [.NP Kim ] [.VP [.V saw ] [.NP Lee ] ] ]
\end{tikzpicture}Trees that are not syntax trees: directories, decisions, probabilities
forest is not a linguistics-only tool. For a directory diagram, the standard combination is folder from the edges library together with grow'=east, which spreads left to right with the right-angled branches that read as folders. For a decision or probability tree, you want numbers on the branches themselves — and since a forest branch is a TikZ path, hanging a node on it with edge label={node[midway,above]{0.3}} writes the probability or condition straight onto the edge. The manual shipped with forest includes a worked decision-tree example.
\usepackage[edges]{forest}
% a file hierarchy: right-angled branches, growing to the right
\begin{forest}
for tree={grow'=east, folder, s sep=1mm}
[project
[src [main.tex] [chapters]]
[figures [plot.pdf]]
]
\end{forest}
% a probability tree: labels ride on the edges
\begin{forest}
for tree={grow'=east, l sep=18mm, s sep=6mm, anchor=west}
[start
[rain, edge label={node[midway,above,font=\scriptsize]{0.3}}]
[dry, edge label={node[midway,below,font=\scriptsize]{0.7}}]
]
\end{forest}For a tree of a few levels where you want no new package at all, TikZ's own trees library is enough. Place a node, follow it with child {...}, and the contents are laid out as a child with the parent-to-child edge drawn for you. Inside a child you normally write node {...}, and you nest further childs for grandchildren. Two distances govern the placement: the vertical gap between a parent's level and its children's, level distance, and the spacing between siblings side by side, sibling distance — both 15 mm by default. To vary them per level use level ⟨n⟩/.style, as in level 1/.style={sibling distance=4cm}; the growth direction changes with [grow=right] and friends, and the branch shape is controlled by edge from parent (edge from parent fork down for right-angled connectors).
\usetikzlibrary{trees}
\begin{tikzpicture}[level distance=12mm, sibling distance=24mm]
\node {root}
child { node {a} }
child { node {b}
child { node {c} }
child { node {d} }
}; % one semicolon for the whole tree
\end{tikzpicture}Watch out for one thing: there is exactly one semicolon ; for the whole tree, at the end of \node ... ;. And plain TikZ has no automatic packing of the kind forest does, so as the number of children or the depth grows you will be widening sibling distance by hand to keep things from overlapping. That is fine for a small tree of a few levels — but the moment you catch yourself wishing the spacing followed the contents, that is the signal to move to forest.
Which one to choose
When in doubt, use forest for a tree you are drawing fresh. Its layout is automatic, its range runs from linguistics to general diagrams, and the whole of TikZ is available for decoration. If you are inheriting an existing \Tree source, or a co-author writes in \Tree, stay with qtree / tikz-qtree — of the two, tikz-qtree gives better output and more room to adjust. For a few-level tree with no new dependency at all, plain TikZ's child will do. All four are on CTAN; forest and tikz-qtree live under graphics/pgf/contrib/ and depend on TikZ/pgf. For the details, the surest reference is texdoc forest, texdoc qtree or texdoc tikz-qtree on your own machine.
| Tool | Notation | Best for |
|---|---|---|
forest | [S [NP] [VP]] (no dots) | any new tree; automatic packing, linguistics through decision trees |
qtree | \Tree [.S [.NP Kim ] ] (dots and spaces required) | the shortest syntax tree; lightweight, built on pict2e |
tikz-qtree | \Tree (same as qtree) | the same notation at TikZ quality; edge labels and arrows too |
tikz trees library | \node {r} child {node {a}}; | a small few-level tree, when you want no extra package |
One practical closing note. A great many people want a syntax tree on a conference slide or a lecture deck, and in that case it is often quicker to export the tree as a standalone image and paste it into PowerPoint or Keynote than to keep it inside a LaTeX document. Since both forest and tikz-qtree sit on top of TikZ, wrapping the tree in the standalone class turns it directly into a tightly cropped PDF or SVG. The page on exporting images walks through that.