| 1 |
%% ps-trees-doc.tex version 2 |
| 2 |
%% Author: [email protected] |
| 3 |
%% filedate 99/05/04 |
| 4 |
\documentclass{article} |
| 5 |
\usepackage{ps-trees} |
| 6 |
\parindent0pt\sloppy |
| 7 |
\parskip\bigskipamount |
| 8 |
\raggedbottom |
| 9 |
%\overfullrule2pt |
| 10 |
|
| 11 |
\begin{document} |
| 12 |
\title{ps-trees.sty Documentation} |
| 13 |
\author{Wolfgang Sternefeld\\ |
| 14 |
Version 2 --- May 1998} |
| 15 |
\maketitle |
| 16 |
|
| 17 |
Experimenting with a number of tree-macros I found that complex |
| 18 |
real-life examples often lead to problems with controlling the |
| 19 |
positioning of nodes in a tree. I therefore decided to use |
| 20 |
tree-dvips.sty (by Emma Pease), where the user has full control |
| 21 |
over the position of nodes by putting them into a table. The present |
| 22 |
macro inputs tree-dvips.sty and presupposes knowledge of its |
| 23 |
node-commands. |
| 24 |
|
| 25 |
One of the shortcomings of tree-dvips.sty is that it does not control |
| 26 |
the correct use of the names for nodes. This means that in case of a |
| 27 |
user error, no warning will appear and no output will be printed. |
| 28 |
The basic idea of the present macro is to regain control |
| 29 |
over the use of names by using them as an encoding of the structure of |
| 30 |
a tree. More specifically, for a node named $x$ to be connected with |
| 31 |
a node named $y$ (i.e. $x$ and $y$ are the first arguments of the |
| 32 |
command \verb|\node|) $y$ must have the form $cx$, where $x$ and $y$ |
| 33 |
are strings of characters and $c$ is exactly one character. For |
| 34 |
ordinary branching trees, this makes the specification of |
| 35 |
\verb.\nodeconnect{#1}{#2}. superfluous. Consider the following |
| 36 |
example and compare the printed file with the .tex-source of this |
| 37 |
file: |
| 38 |
|
| 39 |
\begin{treetab}{*4c} |
| 40 |
&\Node{}{IP} \\[3ex] |
| 41 |
\Node{l}{D} & &\Node{r}{VP}\\[3ex] |
| 42 |
\Node{ml}{She}&\Node{lr}{V} & &\Node{rr}{D}\\[3ex] |
| 43 |
&\Node{mlr}{exonerated}& &\Node{mrr}{him} |
| 44 |
\end{treetab} |
| 45 |
% |
| 46 |
\hspace*{\fill} |
| 47 |
\begin{minipage}{.7\textwidth} |
| 48 |
\begin{verbatim} |
| 49 |
\begin{treetab}{*4c} |
| 50 |
&\Node{}{IP}\\[3ex] |
| 51 |
\Node{l}{D}&&\Node{r}{VP}\\[3ex] |
| 52 |
\Node{ml}{She}&\Node{lr}{V}&&\Node{rr}{D}\\[3ex] |
| 53 |
&\Node{mlr}{exonerated}&&\Node{mrr}{him} |
| 54 |
\end{treetab} |
| 55 |
\end{verbatim} |
| 56 |
\end{minipage}\hfill |
| 57 |
% |
| 58 |
|
| 59 |
\verb.\begin{treetab}. is defined in terms of \verb.\begin{tabular}.. |
| 60 |
The actual execution of the node connections (based on the node names |
| 61 |
as specified by the first argument of \verb|\Node|) is performed as a part of |
| 62 |
\verb.\end{treetab}.. In case a node cannot be interpreted as a node |
| 63 |
in a tree, a warning will be typed out. |
| 64 |
|
| 65 |
The remaining problem is to gain control over the width of columns in |
| 66 |
a table. This is often tedious, but the effort seems worthwhile as |
| 67 |
evidenced by the poor results of macros that calculate the position of |
| 68 |
nodes automatically. Being essentially an aesthetic problem, the |
| 69 |
present macro offers only limited support towards a uniform solution. |
| 70 |
The following, however, might be helpful. |
| 71 |
|
| 72 |
First of all, the effects of \verb.\tabcolsep. and \verb.\nodemargin. |
| 73 |
on a precise positioning of nodes are disturbing, so both values are |
| 74 |
set to zero by \verb.\begin{treetab}.. In order to achieve a minimum |
| 75 |
of symmetry of branchings, a first idea would be that all rows should |
| 76 |
have the same width, implying that the width of each node should be |
| 77 |
determined by the widest leave. Since individual nodes that come |
| 78 |
later in a table might determine the size of previous nodes, it might |
| 79 |
be a good idea to put all relevant nodes (by default: all leaves) into |
| 80 |
boxes before starting the table. The minimal size of all nodes (or |
| 81 |
columns) can then be determined by the command \verb.\NodeWidthNo{n}., |
| 82 |
where $n$ is the number of the box, whose width should become the |
| 83 |
minimal width of all other columns. \verb.\NodeWidthNo. is defined |
| 84 |
as follows: |
| 85 |
\begin{verbatim} |
| 86 |
\newcommand{\NodeWidthNo}[1]{\setlength{\MinNodeWidth}{\the\wd#1}} |
| 87 |
\end{verbatim} |
| 88 |
The length \verb|\MinNodeWidth| will subsequently be used to |
| 89 |
determine the minimal width of each node. (In order to give an |
| 90 |
individual node the width of a particular prespecified box |
| 91 |
$n$, the node command can take an optional argument |
| 92 |
\verb|\Node[n]{...}{...}|). |
| 93 |
|
| 94 |
For example, if we let the word \textit{exonerate} determine the size |
| 95 |
of all nodes, the result is the following: |
| 96 |
|
| 97 |
\begin{verbatim} |
| 98 |
\setbox1=\hbox{She} |
| 99 |
\setbox2=\hbox{exonerated} |
| 100 |
\setbox3=\hbox{him} |
| 101 |
\NodeWidthNo2 |
| 102 |
% |
| 103 |
\begin{treetab}{*4c} |
| 104 |
&\Node{}{IP}\\[3ex] |
| 105 |
\Node{l} {DP}&&\Node{r}{VP}\\[3ex] |
| 106 |
\NodeNo1{ml}&\Node{lr}{V}&&\Node{rr} {DP}\\[3ex] |
| 107 |
&\NodeNo2{mlr}&&\NodeNo3{mrr} |
| 108 |
\end{treetab} |
| 109 |
\end{verbatim} |
| 110 |
\setbox1=\hbox{She} |
| 111 |
\setbox2=\hbox{exonerated} |
| 112 |
\setbox3=\hbox{him} |
| 113 |
\NodeWidthNo2 |
| 114 |
% |
| 115 |
\begin{treetab}{*4c} |
| 116 |
&\Node{}{IP}\\[3ex] |
| 117 |
\Node{l} {DP}&&\Node{r}{VP}\\[3ex] |
| 118 |
\NodeNo1{ml}&\Node{lr}{V}&&\Node{rr} {DP}\\[3ex] |
| 119 |
&\NodeNo2{mlr}&&\NodeNo3{mrr} |
| 120 |
\end{treetab} |
| 121 |
|
| 122 |
But now the space between box2 and box3 might strike one as too wide, |
| 123 |
being seperated by the box of the VP. One possibility would be to |
| 124 |
specify VPs node as \verb|\Node[0]{r}{VP}| which puts VP into a box |
| 125 |
whose width is \verb|\wd0|, which is zero because box0 has not yet |
| 126 |
been used. A more general way would be to place the VP node right |
| 127 |
into the middle between two columns. This saves us one column in the |
| 128 |
table; the command \verb.\NodeZ. makes a box of width zero and puts it |
| 129 |
at the right edge of a column (i.e. ``between'' two columns): % |
| 130 |
\begin{verbatim} |
| 131 |
\begin{treetab}{ccc} |
| 132 |
&\Node{}{IP}\\[3ex] |
| 133 |
\Node{l} {DP}&\NodeZ{r}{VP}\\[3ex] |
| 134 |
\NodeNo1{ml}&\Node{lr}{V}&\Node{rr} {DP}\\[3ex] |
| 135 |
&\NodeNo2{mlr}&\NodeNo3{mrr} |
| 136 |
\end{treetab} |
| 137 |
\end{verbatim} |
| 138 |
\setbox1=\hbox{She} |
| 139 |
\setbox2=\hbox{exonerated} |
| 140 |
\setbox3=\hbox{him} |
| 141 |
\NodeWidthNo2 |
| 142 |
% |
| 143 |
\begin{treetab}{ccc} |
| 144 |
&\Node{}{IP}\\[3ex] |
| 145 |
\Node{l} {DP}&\NodeZ{r}{VP}\\[3ex] |
| 146 |
\NodeNo1{ml}&\Node{lr}{V}&\Node{rr} {DP}\\[3ex] |
| 147 |
&\NodeNo2{mlr}&\NodeNo3{mrr} |
| 148 |
\end{treetab} |
| 149 |
|
| 150 |
But now we got an asymmetry of the branches at the top level, which |
| 151 |
can be fixed by shifting the IP to the left. This can be done by |
| 152 |
replacing \verb|\Node{}{IP}| by \verb|\NodeZ{}{IP}\hspace*{0.75\wd2}|: |
| 153 |
|
| 154 |
\setbox1=\hbox{She} |
| 155 |
\setbox2=\hbox{exonerated} |
| 156 |
\setbox3=\hbox{him} |
| 157 |
\NodeWidthNo2 |
| 158 |
\begin{treetab}{ccc} |
| 159 |
&\NodeZ{}{IP}\hspace*{0.75\wd2}\\[3ex] |
| 160 |
\Node{l} {DP}&\NodeZ{r}{VP}\\[3ex] |
| 161 |
\NodeNo1{ml}&\Node{lr}{V}&\Node{rr} {DP}\\[3ex] |
| 162 |
&\NodeNo2{mlr}&\NodeNo3{mrr} |
| 163 |
\end{treetab} |
| 164 |
|
| 165 |
For larger trees these asymmetries have to be levelled out |
| 166 |
consecutively, as shown in the next tree (an example from real life): |
| 167 |
|
| 168 |
%%%%%%%%%%%%%%%%%%%%%%%%% |
| 169 |
\let\N=\Node |
| 170 |
\let\NZ=\NodeZ |
| 171 |
\let\NNo=\NodeNo |
| 172 |
\let\NTNo=\NodeTNo |
| 173 |
\let\MNW=\MinNodeWidth |
| 174 |
%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 175 |
\newcommand{\End}{\\[4ex]} |
| 176 |
\newcommand{\trivtab}[2]{\hbox{\begin{tabular}[t]{@{}c@{}}#1\\ |
| 177 |
#2\end{tabular}}} |
| 178 |
\newcommand{\twotab}[2]{\hbox{\begin{tabular}[t]{@{}ll@{}}#1\\ |
| 179 |
#2\end{tabular}}} |
| 180 |
% |
| 181 |
\tabcolsep2pt |
| 182 |
\setbox0=\twotab{mit & wem$_i$}{with & who} |
| 183 |
\setbox1=\trivtab{glaubst}{think} |
| 184 |
\setbox2=\trivtab{du}{you} |
| 185 |
\setbox3=\hbox{t$_j$} |
| 186 |
\setbox4=\hbox{t$_i$} |
| 187 |
\setbox5=\trivtab{dass}{that} |
| 188 |
\setbox6=\trivtab{Maria}{Maria} |
| 189 |
\setbox7=\hbox{t$_i$} |
| 190 |
\setbox8=\twotab{gesprochen & hat}{spoken & has} |
| 191 |
|
| 192 |
% |
| 193 |
\NodeWidthNo1% |
| 194 |
\newcommand{\adjustA}{\hspace*{.75\MNW}} |
| 195 |
\newcommand{\adjustB}{\hspace*{.625\MNW}} |
| 196 |
\newcommand{\adjustC}{\hspace*{.5625\MNW}} |
| 197 |
\newcommand{\adjustD}{\hspace*{.53125\MNW}} |
| 198 |
\newcommand{\adjustE}{\hspace*{.515625\MNW}} |
| 199 |
% |
| 200 |
\begin{treetab}{*9{c}} |
| 201 |
\rlap{\hspace*{.25\wd0}\adjustA\makebox[0pt]{\N{}{CP}}}\End |
| 202 |
\N{l}{Spec}&&\N{r}{C$'$}\End |
| 203 |
\NTNo0{ml}&\N{lr}{C$^0$}&&\N{rr}{IP}\End |
| 204 |
&\NNo1[6]{mlr}&\N{lrr}{DP}&&\NZ{rrr}{V}\adjustE\End |
| 205 |
&&\NNo2{mlrr}&\N{lrrr}{V}&&\NZ{rrrr}{CP}\adjustD\End |
| 206 |
&&&\NNo3{mlrrr}&\N{lrrrr}{Spec}&&\NZ{rrrrr}{C$'$}\adjustC\End |
| 207 |
&&&&\NNo4{mlrrrr}&\N{lrrrrr}{C$^0$}&&\NZ{rrrrrr}{IP}\adjustB\End |
| 208 |
&&&&&\NNo5{mlrrrrr}&\N{lrrrrrr}{DP}&&\NZ{rrrrrrr}{V}\adjustA\End |
| 209 |
&&&&&&\NNo6{mlrrrrrr}&\N{lrrrrrrr}{PP}&\hspace{\wd1}\NZ{rrrrrrrr}{V}\End |
| 210 |
&&&&&&&\NNo7{mlrrrrrrr}&\NodeTZNo8{mrrrrrrrr} |
| 211 |
\end{treetab} |
| 212 |
|
| 213 |
We first define a number of shortcuts which will keep the table |
| 214 |
managable: |
| 215 |
\begin{verbatim} |
| 216 |
\let\N=\Node |
| 217 |
\let\NZ=\NodeZ |
| 218 |
\let\NNo=\NodeNo |
| 219 |
\let\NTNo=\NodeTNo |
| 220 |
\let\MNW=\MinNodeWidth |
| 221 |
\newcommand{\adjustA}{\hspace*{.75\MNW}} |
| 222 |
\newcommand{\adjustB}{\hspace*{.625\MNW}} |
| 223 |
\newcommand{\adjustC}{\hspace*{.5625\MNW}} |
| 224 |
\newcommand{\adjustD}{\hspace*{.53125\MNW}} |
| 225 |
\newcommand{\adjustE}{\hspace*{.515625\MNW}} |
| 226 |
\newcommand{\End}{\\[4ex]} |
| 227 |
\newcommand{\trivtab}[2]{\hbox{\begin{tabular}[t]{@{}c@{}}#1\\ |
| 228 |
#2\end{tabular}}} |
| 229 |
\newcommand{\twotab}[2]{\hbox{\begin{tabular}[t]{@{}ll@{}}#1\\ |
| 230 |
#2\end{tabular}}} |
| 231 |
\end{verbatim} |
| 232 |
% |
| 233 |
Next we put all leaves into boxes: |
| 234 |
\begin{verbatim} |
| 235 |
\tabcolsep2pt |
| 236 |
\setbox0=\twotab{mit & wem$_i$}{with & who} |
| 237 |
\setbox1=\trivtab{glaubst}{think} |
| 238 |
\setbox2=\trivtab{du}{you} |
| 239 |
\setbox3=\hbox{t$_j$} |
| 240 |
\setbox4=\hbox{t$_i$} |
| 241 |
\setbox5=\trivtab{dass}{that} |
| 242 |
\setbox6=\trivtab{Maria}{Maria} |
| 243 |
\setbox7=\hbox{t$_i$} |
| 244 |
\setbox8=\twotab{gesprochen & hat}{spoken & has} |
| 245 |
\end{verbatim} |
| 246 |
And finially we specify the minimal node width and construct the table: |
| 247 |
\begin{small}\begin{verbatim} |
| 248 |
\NodeWidthNo1 |
| 249 |
\begin{treetab}{*9{c}} |
| 250 |
&\N{}{CP}\End |
| 251 |
\N{l}{Spec}&&\N{r}{C$'$}\End |
| 252 |
\NTNo0{ml}&\N{lr}{C$^0$}&&\N{rr}{IP}\End |
| 253 |
&\NNo1[6]{mlr}&\N{lrr}{DP}&&\NZ{rrr}{V}\adjustE\End |
| 254 |
&&\NNo2{mlrr}&\N{lrrr}{V}&&\NZ{rrrr}{CP}\adjustD\End |
| 255 |
&&&\NNo3{mlrrr}&\N{lrrrr}{Spec}&&\NZ{rrrrr}{C$'$}\adjustC\End |
| 256 |
&&&&\NNo4{mlrrrr}&\N{lrrrrr}{C$^0$}&&\NZ{rrrrrr}{IP}\adjustB\End |
| 257 |
&&&&&\NNo5{mlrrrrr}&\N{lrrrrrr}{DP}&&\NZ{rrrrrrr}{V}\adjustA\End |
| 258 |
&&&&&&\NNo6{mlrrrrrr}&\N{lrrrrrrr}{PP}&\hspace{\wd1}\NZ{rrrrrrrr}{V}\End |
| 259 |
&&&&&&&\NNo7{mlrrrrrrr}&\NodeTZNo8{mrrrrrrrr} |
| 260 |
\end{treetab} |
| 261 |
\end{verbatim}\end{small} |
| 262 |
|
| 263 |
Note that box0 is wider than box1, therefore the root should not be in |
| 264 |
the middle of box1 but should appear |
| 265 |
exactly in the middle between box0 and box2. We therefore have to |
| 266 |
replace the first line of the table by |
| 267 |
\begin{verbatim} |
| 268 |
\rlap{\hspace*{.25\wd0}\adjustA\makebox[0pt]{\N{}{CP}}}\End |
| 269 |
\end{verbatim} |
| 270 |
|
| 271 |
|
| 272 |
Here is another real life example from phonology: |
| 273 |
|
| 274 |
\setbox1=\hbox{mn} |
| 275 |
\NodeWidthNo1 |
| 276 |
\begin{treetab}[t]{*4c} |
| 277 |
\nodeZ{l}{$\sigma$}&&\nodeZ{r}{$\sigma$}\End |
| 278 |
\Node{ll}{V}&\Node{rl}{C}\nodeZ{xx}{=}&\Node{gr}{C}&\Node{lr}{V}\End |
| 279 |
\Node{mll}{e}&\NodeZ{mrl}{b}&&\Node{mlr}{e} |
| 280 |
\end{treetab} |
| 281 |
\nodeconnect{gr}{mrl} |
| 282 |
|
| 283 |
The main point to be observed is that the first line cannot contain |
| 284 |
\verb|\Node|'s (but must contain \verb|\node|'s), otherwise the macro |
| 285 |
will complain that it cannot find the root of a tree: |
| 286 |
|
| 287 |
\begin{verbatim} |
| 288 |
\setbox1=\hbox{mn} |
| 289 |
\NodeWidthNo1 |
| 290 |
\begin{treetab}[t]{*4c} |
| 291 |
\nodeZ{l}{$\sigma$}&&\nodeZ{r}{$\sigma$}\End |
| 292 |
\Node{ll}{V}&\Node{rl}{C}\nodeZ{xx}{=}&\Node{gr}{C}&\Node{lr}{V}\End |
| 293 |
\Node{mll}{e}&\NodeZ{mrl}{b}&&\Node{mlr}{e} |
| 294 |
\end{treetab} |
| 295 |
\nodeconnect{gr}{mrl} |
| 296 |
|
| 297 |
\end{verbatim} |
| 298 |
One final warning: It seems to me that \TeX\ internally uses certain |
| 299 |
boxes to construct its tables. This means that the width of a box |
| 300 |
might have changed by \TeX\ internally to zero before you come to the |
| 301 |
point where you want to use the lenght prespecified by \verb|\setbox|. It |
| 302 |
might therefore be necessary to store this lenght as soon as possible; |
| 303 |
e.g. by saying \verb|\NodeWidthNo{n}| immediately after having defined |
| 304 |
\verb|\setboxn|. |
| 305 |
\end{document} |