tree-dvips Tree Macros

[ LaTeX for Linguists , .dvi, .ps, .pdf]

Emma Pease


  • Locating Commands
  • Connecting Commands
  • Single Node commands
  • Parameters
  • How to Run
  • Examples
  • Errors
  • Footnotes

  • [ This is Emma Pease's original documentation, slightly edited and adapted for the Web by Doug Arnold ]

    This documentation is available as a PostScript File

    The tree-dvips package is available at the usual places (follow this link for some suggestions. ]

    The tree macros package allows one to integrate TeX and Postscript. For example, one can use TeX to layout a tree and have Postscript draw the lines.

    These macros work by defining locations on a page and then manipulating them in a variety of ways. The commands that created the above tree are as follows:

    \begin{tabular}{ccc}
                        &\node{a}{top node}\\[3ex]
    \node{b}{left node} &     & \node{c}{right node}\\[3ex]
                        &     & \node{d}{odd node}
    \end{tabular}
    \nodeconnect{a}{b} 
    \nodeconnect{a}{c}
    \nodeconnect{c}{d}
    \nodecurve[r]{a}[r]{d}{1in}
    \anodeconnect[b]{b}[l]{d}
    \anodecurve[l]{a}[l]{b}{1in}
    
    You will notice that four nodes are defined, a, b, c, and d, using the \node command. These nodes are then connected using the \nodeconnect and \nodecurve commands.

    Locating Commands

    Location commands are those that deal with defining a location on a page. The basic command

    \node{nodename}{object}
    
    Each node has its name, height, width, and the location of the lower left hand corner point passed down to postscript where it will remain until needed. Note that the object will be printed by TeX but the lines drawn by Postscript. A variant of this command is
    \nodepoint{nodename}[horizontal displace][vertical displace]
    
    The node's height and width are 0pts, but the location can be displaced.

    Connecting Commands

    These commands connect two or more nodes. The two basic ones are

    \nodeconnect[fromloc]{fromnodename}[toloc]{tonodename}
    \nodecurve[fromloc]{fromnodename}[toloc]{tonodename}{depth}
    
    fromnodename and tonodename must be the names of two existing nodes. Imagine the node as a box, fromloc and toloc are the locations on that box to draw the connecting lines. The present choices are t [top], b [bottom], l [left], r [right], tl [topleft], tr [topright], bl [bottomleft], and br [bottomright]. These could be expanded.

    Other connecting commands are

    \barnodeconnect[depth]{fromnodename}{tonodename}
    \anodeconnect[fromloc]{fromnodename}[toloc]{tonodename}
    \anodecurve[fromloc]{fromnodename}[toloc]{tonodename}{depth}
    
    For example,
    \node{c}{\strut This} \node{a}{\strut is} a \node{b}{\strut test} 
    of barnodeconnect.  
    \barnodeconnect{a}{b}
    \barnodeconnect[-5pt]{a}{c}
    \bigskip\bigskip
    
    \node{c}{\strut This} \node{a}{\strut is} a \node{b}{\strut test}
    \node{d}{\strut of} abarnodeconnect.  \node{e}{\strut Note} arrows.
    \abarnodeconnect[10pt]{a}{b}
    \abarnodeconnect[-10pt]{a}{c}
    \abarnodeconnect[-10pt]{b}{d}
    \abarnodeconnect[10pt]{e}{d}
    
    A negative depth places the bar below the line; a positive depth (or the default, which is 5pt) places the bar above the line.

    A few odd commands

    \nodetriangle{fromnodename}{tonodename}
    
    This creates a triangle whose apex is the bottom of fromnodename and whose base is the top of tonodename.

    \anodeconnect and \anodecurve are the same as \nodeconnect and \node- curve except that the connecting line has a arrowhead on it pointing to the second node.

    Single Node commands

    These commands adjust something around a single node rather than connecting nodes. The basic commands are

    \nodebox{nodename}
    \nodecircle[depth]{nodename}
    \nodeoval{nodename}
    
    They draw, respectively, a box, circle, or oval around the given node. You will probably wish to call these commands after you have called all the connecting commands you will be using in a particular diagram.

    Parameters

    At the moment there are three parameters that can be changed. They are

    How to Run

    In the preamble, put:

    \usepackage{tree-dvips}
    
    Run through LaTeX and send to a postscript printer using dvips

    Examples

    A series of examples follow.

    \let\mc=\multicolumn
    \begin{tabular}[t]{@{}lllllllll@{}}
        &    &    &      &\node{a}{VP} \\[2ex]
        &\node{b}{PP} 
             &    &      &    &    &\mc{2}{c}{\node{c}{V$'$}}\\[2ex]
        &    &    &\node{d}{NP} \\[2ex]
        &    &\nodepoint{e}   
                  &      &\node{f}{NP} \\
        &    &    &\hfill\nodepoint{r}[0pt][3pt]   \\
        &\hfil\node{g}{AP} 
             &    &\hfil\node{h}{NP}
                         &    &    &     &\hfil\node{i}{NP}\\[2ex]
    \node{j}{P}  
        &\hfil\node{k}{A}  
             & \node{l}{Prt}
                  &\hfil\node{m}{N}   
                         &\node{n}{Prt} 
                              &\node{o}{N} 
                                   &\node{p}{V}
                                         &\hfil\node{q}{N}\\[2ex]
    `zaw&`oN &`geq&?njiaw&`geq&`dou& khe &tshjaN \\
    toward &red &    & bird &    &head& open&gun \\[1ex]
    \mc{9}{@{}l}{`shoot at the red head of the bird'} \\
    \end{tabular}
    \nodeconnect{a}{b}     \nodeconnect{e}{l}
    \nodeconnect{a}{c}     \nodeconnect{d}{f}
    \nodeconnect{b}{d}     \nodeconnect{g}{k}
    \nodeconnect{b}{j}     \nodeconnect{f}{r}
    \nodeconnect{c}{p}     \nodeconnect{r}{h}
    \nodeconnect{c}{i}     \nodeconnect{r}{n}
    \nodeconnect{d}{e}     \nodeconnect{f}{o}
    \nodeconnect{e}{g}     \nodeconnect{h}{m}
    \nodeconnect{i}{q}
    

    The following two examples use \outerfs and \modsmalltree; these are both part of the lingmacros package. See lingmacros.sty for more information.

    \enumsentence[(100)]{\evnup[2pt]
    {\outerfs{ 
    Focus & \outerfs{subj       & \outerfs{\ \nodepoint{a}\ }\\[1ex]
                     obl$_{th}$ & \outerfs{Pred & `Pro'\\
                                           Refl & +}\\[1ex]
                     Pred       & `proud$\langle(\uparrow {\rm subj})
                                 (\uparrow {\rm obl}_{th})\rangle$'}%
    \nodepoint{d}[-3pt][0pt]\\[2ex]
    Subj & \outerfs{Pred & `Max'}\\[1ex]
    Comp & \outerfs{Subj &\outerfs{Pred & `Larry'}%
    \nodepoint{c}[-3pt][0pt]\\[1ex]
                    Xcomp&\outerfs{\ \nodepoint{b}\ }\\[1ex]
                    Pred & `be$\langle(\uparrow {\rm xcomp})
                           (\uparrow {\rm subj})\rangle$'}\\[1ex]
    Pred & `think$\langle(\uparrow {\rm subj})
                         (\uparrow {\rm comp})\rangle$'}\\
    }
    \nodecurve[r]{a}[r]{c}{2in}[.5in]
    \anodecurve[r]{d}[r]{b}{1in}[2in]
    }
    

    \enumsentence{\modsmalltree{6}{
         &       &   &\ns\node{a}{\begin{tabular}[t]{@{}c@{}}S\\ 
                            {}[+R]\end{tabular}}   \\
         &\node{b}{NP} 
                 &   &  && \node{c}{VP} \\
    \node{d}{Det}
         &       &\node{e}{N$^1$} \\
    \node{h}{the}
         &\node{i}{N}  
                 &   &\node{f}{PP} 
                        &&\node{g}{are totally false}\\
         &\node{n}{rumors}
                 &\node{j}{P} 
                     &  &\ns\node{k}{\begin{tabular}[t]{@{}c@{}}NP\\
                                     {}[+R] \end{tabular}}\\
         &       &\node{l}{about} 
                     &  &\node{m}{whom}}
    \nodeconnect{a}{b}         \nodeconnect{e}{f}
    \nodeconnect{a}{c}         \nodeconnect{i}{n}
    \nodeconnect{b}{d}         \nodeconnect{f}{j}
    \nodeconnect{b}{e}         \nodeconnect{f}{k}
    \nodeconnect{d}{h}         \nodeconnect{j}{l}
    \nodeconnect{e}{i}         \nodeconnect{k}{m}
    \nodetriangle{c}{g}
    {\makedash{4pt}
    \anodecurve[t]{b}[l]{a}{10pt}  \anodecurve[t]{f}[r]{e}{10pt}
    \anodecurve[t]{e}[r]{b}{10pt}  \anodecurve[t]{k}[r]{f}{10pt}
    }}
    

    Errors

    A multitude of caveats.


    LaTeX for Linguists ,
    Doug Arnold,
    doug@essex.ac.uk,
    January 19, 2005.