CTAN Comprehensive TeX Archive Network

Directory graphics/pgf/contrib/terminaltrees

README.md

terminaltrees

Evenly spaced leaves. Rounded branches. Ordinary Forest syntax.The same expression tree in default Forest (left) and terminaltrees (right). terminaltrees aligns x, +, y, *, and 2 at equal intervals on one baseline and rounds the side branches.

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

Live:

tlmgr install terminaltrees

If your operating system manages Live, use its package manager instead.

MiK: 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 installation also needs Forest and needspace.

Compile this example with pdf:

\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 , including \\ for line breaks.

Keep the type size, or fit the page

Both forms use Forest and the same layout:

  • Natural size: use forest with terminal tree. You choose paper large enough for the tree and manage its placement, including in figures or minipages.
  • Fit to the existing layout: use fittedterminaltree in 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

License and credits

Copyright 2026 Adi Edelhaus. Licensed under the 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 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.

PackageTerminaltrees
Bug tracker
Announcements
Repository
Version1.0.2
LicensesThe Project Public License 1.3c
Copyright2026 Adi Edelhaus
MaintainerAdi Edelhaus
Contained inTeX Live as terminaltrees
MiKTeX as terminaltrees
TopicsTree
PGF
...
Guest Book Sitemap Contact Contact Author