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