| 1 |
Copyright 1996 Jeffrey Mark Siskind |
| 2 |
|
| 3 |
This work may be distributed and/or modified under the |
| 4 |
conditions of the LaTeX Project Public License, either version 1.3 |
| 5 |
of this license or (at your option) any later version. |
| 6 |
The latest version of this license is in |
| 7 |
http://www.latex-project.org/lppl.txt |
| 8 |
and version 1.3 or later is part of all distributions of LaTeX |
| 9 |
version 2005/12/01 or later. |
| 10 |
|
| 11 |
This work has the LPPL maintenance status `unmaintained'. |
| 12 |
|
| 13 |
This work consists of all files listed in manifest.txt. |
| 14 |
|
| 15 |
Copyright and licensing notice added 2008/11/29 by |
| 16 |
Clea F. Rees on behalf of Jeffrey Mark Siskind. |
| 17 |
|
| 18 |
While writing my PhD thesis, I put together some useful LaTeX macros for |
| 19 |
typesetting trees. I thought that they would be of general interest so I am |
| 20 |
making them available. I gave an earlier version of these macros to Phil |
| 21 |
Resnik a few months ago. These new macros are much easier to use and produce |
| 22 |
much nicer output. For arcane reasons, the new macros, however, use a |
| 23 |
different calling sequence. To use the new package get the file |
| 24 |
~qobi/tex/QobiTree/QobiTree.tex from unagi and put in wherever you put your TeX |
| 25 |
macros. Put the line: |
| 26 |
|
| 27 |
\input{QobiTree} |
| 28 |
|
| 29 |
somewhere at the beginning of your LaTeX file. The tree macros operate like a |
| 30 |
stack machine. You push TeX boxes onto the stack containing text for the nodes |
| 31 |
of the tree and then you pop them off the make branching nodes which get |
| 32 |
pushed back on the stack. The following commands are supported: |
| 33 |
|
| 34 |
\leaf{<text>} |
| 35 |
|
| 36 |
Pushes a node onto the stack containing <text>. The <text> can contain |
| 37 |
`\\' commands to create a node with more than one line. For example: |
| 38 |
|
| 39 |
\leaf{NP\\{\em John}} |
| 40 |
|
| 41 |
creates a two line node with NP (in roman) on top of John (in italics). |
| 42 |
You can put any TeX box inside a leaf node, including math mode, LaTeX |
| 43 |
picture environments, tables, embedded postscript, and other trees. |
| 44 |
QobiTree automatically figures out how big the node is and sizes the tree and |
| 45 |
its branches accordingly. |
| 46 |
|
| 47 |
The command: |
| 48 |
|
| 49 |
\branch{n}{<text>} |
| 50 |
|
| 51 |
pops n nodes off the stack and creates a branching node with n children and |
| 52 |
pushes it back on the stack. The first node popped off becomes the rightmost |
| 53 |
child and the last node popped off becomes the leftmost child. n must be an |
| 54 |
integer between 1 and 5. (It is possible to extend QobiTree to handle trees of |
| 55 |
greater branching factor. See me if you need to.) The branching node created |
| 56 |
is given <text> as its label. Again <text> can have `\\' commands and can be |
| 57 |
any TeX box. For example: |
| 58 |
|
| 59 |
\leaf{NP\\{\em John}} |
| 60 |
\leaf{V\\{\em saw}} |
| 61 |
\leaf{NP\\{\em Mary}} |
| 62 |
\branch{2}{VP\\{em saw Mary}} |
| 63 |
\branch{2}{S\\{\em John saw Mary}} |
| 64 |
|
| 65 |
creates a simple binary branching tree. |
| 66 |
|
| 67 |
The \leaf and \branch command don't generate any typeset output. They just |
| 68 |
push trees onto the stack. The output is generated with the following command: |
| 69 |
|
| 70 |
\tree |
| 71 |
|
| 72 |
which pops one node off the stack and typesets it as a single box. Usually you |
| 73 |
would center this box as in: |
| 74 |
|
| 75 |
\leaf{NP\\{\em John}} |
| 76 |
\leaf{V\\{\em saw}} |
| 77 |
\leaf{NP\\{\em Mary}} |
| 78 |
\branch{2}{VP\\{em saw Mary}} |
| 79 |
\branch{2}{S\\{\em John saw Mary}} |
| 80 |
\begin{center} |
| 81 |
\tree |
| 82 |
\end{center} |
| 83 |
|
| 84 |
but it is also possible to put a tree in a sentence, in a table, in a math |
| 85 |
mode formula, in a picture environment, or in another tree. |
| 86 |
The file ~qobi/tex/QobiTree/examples.tex contains some examples taken |
| 87 |
from my thesis. |
| 88 |
|
| 89 |
Most of the time, QobiTree does a good job of figuring out how to space the |
| 90 |
children of a tree. It never mistakingly overlaps children. Unlike the earlier |
| 91 |
version of the tree macros I gave Phil, it is usually able to space the tree |
| 92 |
better without inordinate growth in deep trees. Sometimes however, you can |
| 93 |
give it some help to produce even better looking output. The command: |
| 94 |
|
| 95 |
\faketreewidth{<text>} |
| 96 |
|
| 97 |
tells QobiTree to override its default calculation of the width of the node on |
| 98 |
the top of the stack and replace it with the width of <text> (which again can |
| 99 |
have `\\' commands etc.) <text> is not actually typeset but is used just to |
| 100 |
compute the fake width of the node on the top of the stack. When you use |
| 101 |
\faketreewidth you are on your own. This can either shrink or enlarge the |
| 102 |
space taken by the node and may result in trees with overlapping children. |
| 103 |
Usually a few tries with xdvi and you can adjust the tree widths to produce |
| 104 |
the desired output. See ~qobi/tex/QobiTree/examples.tex for some |
| 105 |
examples using \faketreewidth. |
| 106 |
|
| 107 |
I hope that people find these macros useful. Feel free to pass them on to |
| 108 |
whoever wants them. |
| 109 |
Jeff |