Tree Drawing in LaTeX
[ LaTeX for Linguists, .dvi, .ps, .pdf, TestFile]

A number of excellent packages and other tools have been developed which make drawing trees one of the easier tasks in LaTeX. Several are described here. In some ways, the main problem is the range of choice available. For what it is worth, I recommend:

Otherwise, you will have to look around and make up your own mind and choose one (or more) of these packages.

It is probably worth saying that there is no reason why you should only use one package all the time - some things are easier to do, or get nicer results with one package, other things with another. You may even want to use several packages within one document (e.g. if you have very different kinds of tree).

A general note: several of these packages (marked "[PostScript]") use what are called `PostScript Specials' to draw lines, rather than using LaTeX's native apparatus. This should not be a problem with modern TeX installations, but depending on the previewer you use, this may mean that you will not be able to see the lines when you preview LaTeX's dvi output. There may be a similar complication if you use pdftex to produce pdf output. If you have this problem, it seems that using normal TeX/LaTeX to produce dvi, and then a tool like dvipdfm or ps2pdf to produce the pdf works okay. (Thanks to Joost Kremers for pointing this last point out).

Another general note: many of these packages provide very nice, intuitive, ways of drawing trees (e.g. by essentially specifying labeled bracketing). This is very nice, but it has a downside: you will not generally be able to use these methods inside commands that you define yourself. For example, if you have a particularly complicated piece of tree (perhaps it has lots complicated semantics in the labels or something) which you need to appear in several places, you might want to define a command to draw it, and just repeat this command in different places. You will not be able to do this with such packages (you may have to find out about the underlying commands, or use a different package in addition to your normal one -- there is not reason why you have to restrict yourself to one package for everything).

Access to the documentation for the following packages is provided here, in some fashion or other:

  • qtree package one of the easiest way to draw `normal' trees.
  • the syntree package, by Matijs van Zuijlen - this provides a very simple and neat way of doing `normal' trees (e.g. ones where the node labels are just atomic symbols like `NP'). It has good, very detailed documentation.
  • parsetree: a very easy way to draw trees with fewer than three daughters per node.
  • Ralf Vogel's xyling package: this package is very flexible and powerful, and does not use pstricks etc. (so you can see the trees in the dvi output). It supports labeling of branches as well as nodes, as well as lines and arrows that relate discontinuous pieces of the tree. [package, documentation]
  • tree-dvips: very powerful and flexible.[PostScript] (If you are thinking of using this, you might consider the Wolfgang Sternefeld's linguex package, available from "the usual places", which extends it somewhat. You might also consider Ralf Vogel's xyling package (see above), which has the same power and flexibility, but which is easier to use). Avery Andrew's lingtrees.sty package (mentioned next) provides an easy to use `front-end' to tree-dvips.
  • Avery Andrew's lingtrees.sty package is another neat package for tree drawing - simple trees are very simple, and it can be used also for very complicated ones. It is available from "the usual places".
  • the PStricks package provides very powerful apparatus for lots of figures, including trees. [PostScript]
  • John Frampton has a package, ps-jftree, which uses PStricks. [documentation accompanies with the package; PostScript]
  • ecltree [only a little documented]
  • jpsgtree [only a little documented]
  • the RRGtrees package, by David Gardner, provides LaTeX macros for the sorts of tree diagram used in Role and Reference Grammar. This includes trees with crossing lines, as is required by some languages in this theory. It uses pstricks. [The distribution includes a `make' file (so, just `make rrgtrees.sty' will create the style file), but if you haven't got `make' you can create rrgtrees.sty by running latex over rrgtrees.ins.]
  • Greg Lee's "tree" preprocessor: this is a general (unix) tool for drawing trees. It runs as a preprocessor, and can produce output suitable for TeX and LaTeX. It is very simple and quite flexible, but has two major drawbacks: (a) it runs as a preprocessor (so you have to remember to run it every time before you run LaTeX); (b) it gives poor results when the node labels are complex: in particular, when there is a significant difference between the amount of space a node label occupies in the LaTeX source and the space it requires in the output -- i.e. it is useful only where node labels are very simple.

  • LaTeX for Linguists,
    Doug Arnold,,
    October 19, 2009.