Directory graphics/pgf/contrib/terminaltrees
terminaltrees
Evenly spaced leaves. Rounded branches. Ordinary Forest syntax.
Zoom the vector comparison. Both trees use the same content and 10pt type, without scaling.
Add terminal tree to a Forest tree to align its leaves, center each parent between its first and last immediate children, and draw rounded branches. Wider labels increase spacing automatically. Children directly below their parent connect straight down.
Install and draw a tree
TeX Live:
tlmgr install terminaltrees
If your operating system manages TeX Live, use its package manager instead.
MiKTeX: refresh the package catalogue, then install:
miktex packages update-package-database miktex packages install terminaltrees
Manual installation or Overleaf: download the CTAN archive and place terminaltrees.sty beside your document. Your TeX installation also needs Forest and needspace.
Compile this example with pdfLaTeX:
\documentclass{article} \usepackage{terminaltrees} \begin{document} \begin{forest} terminal tree [EXPR [EXPR [ID [x]]] [+] [EXPR [EXPR [ID [y]]] [*] [EXPR [NUM [2]]]] ] \end{forest} \end{document}
This produces the right-hand tree. Remove terminal tree for Forest's default layout on the left. Labels use ordinary LaTeX, including \\ for line breaks.
Keep the type size, or fit the page
Both forms use Forest and the same layout:
- Natural size: use
forestwithterminal tree. You choose paper large enough for the tree and manage its placement, including in figures or minipages. - Fit to the existing layout: use
fittedterminaltreein ordinary single-column document flow. It shrinks the whole tree when needed and moves it to the next page if the remaining space is insufficient.
\begin{fittedterminaltree} [EXPR [EXPR [x]] [+] [EXPR [1]]] \end{fittedterminaltree}
fittedterminaltree applies terminal tree automatically. It scales labels and branches together, with a minimum label size based on the current \footnotesize. Compilation stops if that limit cannot be met. Neither form changes paper or margins, enlarges trees, or splits them across pages. Fitting does not support floats, minipages, or multicolumn layouts.
See the manual for fitting comparisons, font-size settings, and measurement limits. The font-size floor is not a readability guarantee.
Adjust the layout
Put these options after terminal tree, or before the root bracket in fittedterminaltree:
| Option | Default | Effect |
|---|---|---|
leaf pitch |
0pt |
Minimum distance between leaf centers. Zero uses label measurements and Forest's padding alone. |
roundness |
1 |
From square corners (0) to the largest bends that fit (1). Does not move nodes or change fitting. |
For example, terminal tree, leaf pitch=3em, roundness=0.5 sets a minimum leaf spacing and tighter bends. Both options reset for each tree. Forest's font, label, arrow and vertical-spacing options remain available.
Equal leaf spacing does not imply equal internal sibling spacing. Custom anchors, shifted labels, overlays and arrow styles need visual inspection. The package does not add tagged-PDF tree semantics or screen-reader support.
Documentation and support
- Changelog: changes by release.
- User manual: examples, fitting, geometry, and compatibility limits.
- Contributor guide: checks, previews, and release builds.
- Report an issue.
License and credits
Copyright 2026 Adi Edelhaus. Licensed under the LaTeX Project Public License, version 1.3c or later. Maintenance status: maintained. Current maintainer: Adi Edelhaus. The work's files are listed in manifest.txt.
Built on Forest by Sašo Živanović, PGF/TikZ, the LaTeX kernel and needspace. These dependencies retain their own licenses and are not bundled.
Download the contents of this package in one zip archive (457.6k).
Terminaltrees – Evenly spaced leaves and rounded branches for Forest trees
terminaltrees adds a layout style to forest for trees with evenly spaced terminal leaves on a shared baseline. It centers each parent between its first and last immediate children and draws rounded side branches. Label measurements determine spacing automatically.
The package uses ordinary forest bracket syntax. An optional fittedterminaltree environment shrinks the whole tree to the existing page layout, subject to a minimum label size. It can move the tree to the next page but does not change the paper size or split trees across pages.
| Package | Terminaltrees |
| Bug tracker | |
| Announcements | |
| Repository | |
| Version | 1.0.2 |
| Licenses | The LaTeX Project Public License 1.3c |
| Copyright | 2026 Adi Edelhaus |
| Maintainer | Adi Edelhaus |
| Contained in | TeX Live as terminaltrees MiKTeX as terminaltrees |
| Topics | Tree PGF TikZ |