Debian Codegraph @

texmf-dist/tex/plain/treetex/treetex.tex

raw
1 % This is file treetex.tex of TreeTeX, Version 2.1 (May 23, 1989).
2 % For changes search for "vs. 2.1".
3 %
4 % TreeTeX is a public domain macro package for drawing
5 % trees with TeX. It may be freely distributed, provided
6 % that the following files are kept together:
7 %
8 % classes.tex, l_pic.tex, readme, tree_doc.aux, tree_doc.bbl
9 % tree_doc.dvi, tree_doc.tex, treetex.tex
10 %
11 % Copyright is with Anne Brueggemann-Klein and Derick Wood.
12 % Print tree_doc.dvi to get more information about TreeTeX.
13 %
14 % All remarks, bug reports etc. should be directed to
15 %
16 % Dr. Anne Brueggemann-Klein
17 % Institut fuer Informatik
18 % Rheinstr. 10--12
19 % 7800 Freiburg, West Germany
20 %
21 % email: [email protected]
22 %
23
24 \catcode`\@=11
25
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 %%% Only for testing, delete later %%%
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29
30 \tracingonline=2 %
31 % \showboxbreadth=100 % Only for testing
32 % \showboxdepth=100 %
33
34 \newcount\cnta\newcount\cntb\newcount\cntc
35
36 \def\showlasttree{%
37 \g\cnta\count\l@stdiminfo
38 \g\cntb\cnta
39 \g\advance\cntb 5
40 \g\advance\cntb \count\l@sttreeheight
41 \g\advance\cntb \count\l@sttreeheight
42 \ifnum\count\l@sttreeheight=-1\relax
43 \g\advance\cntb by 2
44 \immediate\write16{Tree contour for dummy node:}
45 \else\immediate\write16{Tree contour:}%
46 \fi
47 \for\cntc:=\cnta\to\cntb\do\immediate\write16{\the\dimen\cntc}\od}
48
49
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 %%% TeX vs. LaTeX %%%
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53
54 \def\lplain{lplain} % Set \LaTeXtrue if TreeTeX is
55 \newif\ifLaTeX % used together with LaTeX,
56 \ifx\fmtname\lplain\LaTeXtrue % otherwise set \LaTeXfalse
57 \else\LaTeXfalse\fi % (LaTeX defines \fmtname=={lplain}).
58
59 \immediate\write16{This is TreeTeX, Version 2.1, for use with \ifLaTeX LaTeX%
60 \else plain TeX\fi.}
61
62 \ifLaTeX \let\lineseg\line % latex_picture is part of latex.tex,
63 \else \let\@line\line % so you don't need it if you use
64 \input l_pic % TreeTeX together with LaTeX. LaTeX
65 \let\lineseg\line % has the command \line for geometric
66 \let\line\@line % lines, and plain TeX has the same
67 \fi % command for lines of text. Because
68 % both versions of \line play an
69 % important role in the respective
70 % macro packages, we introduce a new
71 % command \lineseg in TreeTeX for the
72 % geometric lines, and \line will have
73 % the LaTeX-meaning if TreeTeX is used
74 % with LaTeX, and the plain \TeX
75 % meaning otherwise.
76
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 %%% General programming environment %%%
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80
81 \catcode`\@=11
82 \let\g\global
83 \def\gxdef{\global\xdef}
84
85 % The command \newcount is redefined such that it can be used
86 % inside a definition (i.e. it is no longer an \outer-command).
87
88 \def\newcount{\alloc@0\count\countdef\insc@unt}
89
90 % Implementing a for-loop (first argument must be a counter).
91 % Usage: \for<counter>:=<start value>\to<stop value>\do<operations>\od
92 % Semantics: the same as a PASCAL for-loop
93 % Precautions: Don't change the counter-value inside the loop!
94 % for-loops cannot be nested (nor can the \loop-commands!).
95
96 \def\for#1:=#2\to#3\do#4\od{%
97 \def\f@rcount{#1}\def\upp@rlimit{#3}\def\b@dy{#4}\f@rcount=#2\relax\dof@r}
98
99 \def\dof@r{\ifnum\f@rcount>\upp@rlimit\relax\let\n@xt\relax
100 \else\b@dy\advance\f@rcount\@ne\let\n@xt\dof@r\fi
101 \n@xt}
102
103 % \ex repeats a sequence of commands a predetermined number of times.
104 % Usage: \ex<number>\times<operations>\xe
105 % Semantics: <operations> is executed as often as <number> says
106 % Precautions: \ex commands cannot be nested.
107
108 \newcount\@xcount
109 \newcount\t@mes
110
111 \def\ex#1\times#2\xe{%
112 \@xcount1 \t@mes#1\def\b@dy{#2}\do@x}
113
114 \def\do@x{\ifnum\@xcount>\t@mes\let\n@xt\relax
115 \else\b@dy\advance\@xcount\@ne\let\n@xt\do@x\fi
116 \n@xt}
117
118 % \rect@ngle produces a rectangle with horizontal edge length #1, vertical
119 % edge length #2 and line thickness #3. The reference point is in the center of
120 % the rectangle. The width is 0pt.
121
122 \newskip\thickn@ss
123 \newskip\@nner
124 \newskip\@uter
125
126 \def\rect@ngle#1#2#3{\hbox to 0pt{%
127 \thickn@ss#3%
128 \g\@nner#2\g\advance\@nner-\thickn@ss
129 \g\divide\@nner\tw@
130 \g\@uter#2\g\advance\@uter\thickn@ss
131 \g\divide\@uter\tw@
132 \hskip 0pt minus .5fil%
133 \vrule height\@uter depth\@nner width\thickn@ss
134 \vrule height\@uter depth-\@nner width#1%
135 \hskip 0pt minus 1fil%
136 \vrule height-\@nner depth\@uter width#1%
137 \vrule height\@nner depth\@uter width\thickn@ss
138 \hskip 0pt minus .5fil%
139 }% \hbox
140 }% \def
141
142 % \s@ries takes two arguments. The first one is a name, say XXX, and
143 % the second is a series of arguments, devided by two slashs (//).
144 % \s@ries assigns this last series of arguments one after another to the
145 % control sequences \XXXi, \XXXii, and so on. Furthermore, a control
146 % sequence \XXX is defined, which takes a number k as its argument and
147 % expands to \XXXk', where k' is the roman numeral equivalent to k.
148
149 \def\s@ries#1#2{%
150 \g\t@mpcnta1
151 \gdef\t@mp{#1}%
152 \@ssign#2/\l@st % \l@st is a sentinal element
153 \expandafter\gdef\csname#1\endcsname##1{%
154 \csname#1\romannumeral##1\endcsname}%
155 }
156
157 \def\@ssign#1/#2{%
158 \expandafter\gdef\csname\t@mp\romannumeral\t@mpcnta\endcsname{#1}%
159 \g\advance\t@mpcnta\@ne
160 \ifx#2\l@st
161 \g\let\n@xt\relax
162 \else\g\let\n@xt\@ssign
163 \fi
164 \n@xt}
165
166 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
167 %%% Allocation of internal registers %%%
168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
169
170 \newdimen\leftdist
171 \newdimen\rightdist
172 \newbox\TeXTree
173
174 \newcount\sl@pe
175 \newcount\l@vels
176 \newcount\s@ze
177
178 \newbox\circleb@x
179 \newbox\squareb@x
180 \newbox\dotb@x
181 \newbox\triangleb@x
182 \newbox\textb@x
183 \newbox\frameb@x
184
185 \newdimen\circlew@dth
186 \newdimen\squarew@dth
187 \newdimen\dotw@dth
188 \newdimen\trianglew@dth
189 \newdimen\textw@dth
190 \newdimen\framew@dth
191
192 \newdimen\vd@st
193 \newdimen\hd@st
194 \newdimen\based@st
195 \newdimen\dummyhalfcenterdim@n
196
197 \newcount\t@mpcnta
198 \newcount\t@mpcntb
199 \newcount\t@mpcntc
200 \newcount\t@mpcntd
201 \newdimen\t@mpdima
202 \newdimen\t@mpdimb
203 \newdimen\t@mpdimc
204 \newbox\t@mpboxa
205 \newbox\t@mpboxb
206
207 \newbox\leftb@x
208 \newbox\rightb@x
209 \newbox\centerb@x
210 \newbox\beneathb@x
211 \newtoks\typ@
212 \newbox\centerb@@x
213 \newdimen\centerdim@n
214 \newdimen\halfcenterdim@n
215
216 \newdimen\mins@p
217 \newdimen\halfmins@p
218 \newdimen\tots@p
219 \newdimen\halftots@p
220 \newdimen\currs@p
221 \newdimen\adds@p
222 \newcount\l@ftht
223 \newcount\r@ghtht
224 \newcount\l@ftinfo
225 \newcount\r@ghtinfo
226 \newbox\l@ftbox
227 \newbox\r@ghtbox
228
229 \newif\ifr@ghthigher % true iff the right subtree is higher than the left one
230 \newif\ifadds@p
231
232 \newcount\@larg
233 \newcount\@rarg
234
235 \newif\ifl@fttop
236 \newif\ifl@ftonly
237 \newif\ifr@ghtonly
238 \newif\if@xt
239 \newif\ifl@ftedge
240 \newif\ifr@ghtedge
241 \newif\ifext@nded
242
243 \newdimen\lm@ff
244 \newdimen\rm@ff
245 \newdimen\lb@ff
246 \newdimen\rb@ff
247 \newdimen\lt@p
248 \newdimen\rt@p
249
250 \newcount\l@sttreebox % These four counter allocations have been copied
251 \newcount\l@sttreeheight % to this position from the \Tree command
252 \newcount\l@stdiminfo % (vs. 2.1). Previously each tree allocated its own
253 \newcount\l@sttreetype % counters, using up counters for nothing.
254
255 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256 %%% Slope handling for the edges %%%
257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
258
259 % The picture environment of LaTeX gives us a choice of 24 positive
260 % slopes for lines (i.e. edges of trees in this context),
261 % including vertical ones. The slope of a line is
262 % given by an x- and an y-value, see L. Lamport, LaTeX, pp. 105f for
263 % further details. x/y can have the following values (decreasing amount
264 % of slope): 0/1 1/6 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 5/6 1/1 6/5 5/4
265 % 4/3 3/2 5/3 2/1 5/2 3/1 4/1 5/1 6/1.
266 % The x-values are allocated to \xv@li, \xv@lii,..., \xv@lxxiv, and
267 % they can conveniently be accessed by the command \xv@l{<number>}.
268 % The same holds for the y-values.
269
270 \s@ries{xv@l}{0//1//1//1//1//2//1//3//2//3//4//5//1//6//%
271 5//4//3//5//2//5//3//4//5//6}
272 \s@ries{yv@l}{1//6//5//4//3//5//2//5//3//4//5//6//1//5//%
273 4//3//2//3//1//2//1//1//1//1}
274
275 % \hv@ldef calculates \hv@li, \hv@lii,..., \hv@lxxiv for a given dimen
276 % \vd@st according to the following picture:
277 %
278 % /-|
279 % / |
280 % / |
281 % / |
282 % / |\vd@st
283 % / |
284 % / |
285 % / -| |
286 % / |\yv@l|
287 % / _| _|
288 %
289 % |___|
290 % \xv@l
291 % |_________|
292 % .5\hv@l
293 %
294 % \hv@li,..., \hv@lxxiv are initialized in \beginTree, when the
295 % actual value for \vd@st is known (\vd@st will depend on the point size of
296 % the picture). As before, these values can conveniently be accessed by the
297 % command \hv@l{<number>}.
298
299 \def\hv@ldef{%
300 \for\t@mpcnta:=1\to24%
301 \do\g\t@mpdima\vd@st\g\multiply\t@mpdima by\xv@l{\t@mpcnta}%
302 \g\divide\t@mpdima by\yv@l{\t@mpcnta}\g\multiply\t@mpdima by 2
303 \expandafter\gxdef\csname hv@l\romannumeral\t@mpcnta\endcsname{%
304 \the\t@mpdima}%
305 \od}
306
307 \def\hv@l#1{\csname hv@l\romannumeral#1\endcsname}
308
309 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
310 %%% Naming trees %%%
311 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
312
313 % A TeXtree is stored in TeX's internal registers in the following way:
314 % A TeXtree of height h has associated to itself the following internal
315 % TeX registers: a box, holding the graphical appearance of the tree,
316 % a consecutive number of 6+2h internal dimen registers, holding the
317 % additional information about the contour of the tree, a counter
318 % holding the height h of the tree, a counter holding the first
319 % position of the additional information registers, and a toks register
320 % holding the type of the node (circle, square, dot, triangle, text, or frame).
321 % The height and position
322 % of additional information are stored in consecutive order for
323 % consecutive trees. The same is true for the boxes and toks.
324
325 % Four key numbers, the register numbers (addresses)
326 % for the height, diminfo, box, and type
327 % of a tree, enable you to access all information which is stored about the
328 % tree. For the last tree on the stack, the four key numbers are stored in the
329 % counters \l@sttreeheight, \l@stdiminfo, \l@sttreebox, and \l@sttreetype,
330 % the key numbers for the next tree are \l@sttreeheight-2, \l@stdiminfo-2,
331 % \l@sttreebox-1, and \l@sttreetype-1, and so on.
332
333 % The macro \n@metree gives names to some registers associated with the tree.
334 % The tree to be named is specified by its four key numbers. \n@metree takes
335 % five arguments, namely the keynumbers for height, info, box and type of the
336 % tree, and the name to be given to the tree. If the tree gets the name XXX and
337 % the key numbers are h, i, b, and t, the commands on the left side of the
338 % following list get the meaning on the right side.
339
340 % \XXXht <--- \count h
341 % \XXXinfo <--- \count i
342 % \XXXbox <--- b
343 % \XXXtype <--- \toks t
344 % \XXXlmoff <--- \dimen f where f is the address stored
345 % in \count i
346 % \XXXrmoff <--- \dimen (f+1)
347 % \XXXlboff <--- \dimen (f+2)
348 % \XXXrboff <--- \dimen (f+3)
349 % \XXXltop <--- \dimen (f+4)
350 % \XXXrtop <--- \dimen (f+5)
351 % \XXXloff <--- \dimen (f+4+2g) where g is the height stored in
352 % \count h, i.e. \dimen (f+4+2g)
353 % holds loff(1) of the tree, if g>0
354 % \XXXroff <--- \dimen (f+5+2g)
355
356 % The macro \pr@vioustree sets \l@sttreeheight, \l@stdiminfo,
357 % \l@sttreebox and \l@sttreetype to the key numbers of the previous tree
358 % and gives the name `l@st' to this tree.
359
360 % The macro \@ddname which has two names n1 and n2 as arguments, gives
361 % the tree with name n1 the additional name n2.
362
363 % The macro \n@mel@st gives the name `l@st' to the tree with the
364 % key numbers \l@sttreeheight, \l@stdiminfo, \l@sttreebox and \l@sttreetype.
365
366 % The macro \n@xttree sets \l@sttreebox, \l@sttreeheight, \l@stdiminfo,
367 % \count\l@stdiminfo, and \l@sttreetype to the next free position.
368
369 % The macro \@ppenddummy pushs a dummy onto the stack and names it `l@st'.
370 % The dummy has height -1, its box is the empty box, its type is circle,
371 % and all dimensions are 0pt.
372
373 % \p@s#1#2#3 sets counter #1 to position #2 of tree #3. #1 must be a counter,
374 % #3 must be a name for the tree. If the tree has the name XXX, \XXXinfo
375 % must be a number holding the first position of the dimen-parameters of
376 % the tree and \XXXht must hold the height of the tree.
377 % #2 must be one of the following control sequences indicating the
378 % desired position: \lmoff, \rmoff, \lboff, \rboff, \ltop, \rtop, \loff, or
379 % \roff. \loff and \roff give the left resp. right offset of the *top*
380 % level of the tree.
381
382 \def\p@s#1#2#3{%
383 \g#1\csname#3info\endcsname
384 \gxdef\t@mp{\csname#3ht\endcsname}%
385 \ifnum\t@mp<0 \gxdef\t@mp{0}\fi
386 #2{#1}%
387 }
388
389 \chardef\@lmoff0 \chardef\@rmoff1 \chardef\@ltop4 \chardef\@rtop5
390 \chardef\@lboff2 \chardef\@rboff3 \chardef\@loff4 \chardef\@roff5
391
392 \def\lmoff#1{\g\advance#1 by\@lmoff}
393 \def\rmoff#1{\g\advance#1 by\@rmoff}
394 \def\lboff#1{\g\advance#1 by\@lboff}
395 \def\rboff#1{\g\advance#1 by\@rboff}
396 \def\ltop#1{\g\advance#1 by\@ltop}
397 \def\rtop#1{\g\advance#1 by\@rtop}
398 \def\loff#1{\g\advance#1 by\@loff\g\advance#1 by\t@mp
399 \g\advance#1 by\t@mp\relax}
400 \def\roff#1{\g\advance#1 by\@roff\g\advance#1 by\t@mp
401 \g\advance#1 by\t@mp\relax}
402
403 % \n@meinfo#1 defines for an argument XXX (name of a tree) \XXXlmoff,
404 % \XXXrmoff, ... as lmoff(XXX), rmoff(XXX),... .
405 % The following arguments will be used: l@ft, r@ght, l@st,
406 % m@n, and m@x.
407
408 \def\n@meinfo#1{%
409 \n@me@nfo{#1}{lmoff}\n@me@nfo{#1}{rmoff}%
410 \n@me@nfo{#1}{lboff}\n@me@nfo{#1}{rboff}%
411 \n@me@nfo{#1}{ltop}\n@me@nfo{#1}{rtop}%
412 \n@me@nfo{#1}{loff}\n@me@nfo{#1}{roff}%
413 }
414
415 \def\n@me@nfo#1#2{%
416 \p@s\t@mpcnta{\csname#2\endcsname}{#1}%
417 \expandafter\gxdef\csname#1#2\endcsname{\dimen\the\t@mpcnta}}
418
419 \def\n@metree#1#2#3#4#5{%
420 \expandafter\gxdef\csname#5ht\endcsname{\count\the#1}%
421 \expandafter\gxdef\csname#5info\endcsname{\count\the#2}%
422 \expandafter\gxdef\csname#5box\endcsname{\the#3}%
423 \expandafter\gxdef\csname#5type\endcsname{\toks\the#4}%
424 \n@meinfo{#5}%
425 }
426
427 \chardef\@cntoff3 \chardef\@boxoff1 \chardef\@dimoff2 \chardef\@typeoff1
428
429 \def\pr@vioustree{%
430 \g\advance\l@sttreeheight by-\@cntoff
431 \g\advance\l@stdiminfo by-\@cntoff
432 \g\advance\l@sttreetype by-\@cntoff
433 \g\advance\l@sttreebox by-\@boxoff
434 \n@mel@st
435 }
436
437 \def\@ddname#1#2{%
438 \expandafter\gxdef\csname#2ht\endcsname{\csname#1ht\endcsname}%
439 \expandafter\gxdef\csname#2info\endcsname{\csname#1info\endcsname}%
440 \expandafter\gxdef\csname#2type\endcsname{\csname#1type\endcsname}%
441 \expandafter\gxdef\csname#2box\endcsname{\csname#1box\endcsname}%
442 \n@meinfo{#2}%
443 }
444
445 \def\n@xttree{%
446 \p@s\t@mpcnta\loff{l@st}\g\advance\t@mpcnta by\@dimoff
447 \g\advance\l@sttreeheight by\@cntoff
448 \g\advance\l@stdiminfo by\@cntoff
449 \g\advance\l@sttreetype by\@cntoff
450 \g\advance\l@sttreebox by\@boxoff
451 \g\count\l@stdiminfo\t@mpcnta
452 }
453
454 \def\@ppenddummy{% pushs a dummy onto the stack and names it `l@st'
455 % The dummy has height -1, its box is the empty box, the type
456 % is circle, and all dimensions are 0pt.
457 \n@xttree \g\count\l@sttreeheight-\@ne\n@mel@st
458 \l@sttype{circle}%
459 \g\setbox\l@stbox\copy\voidb@x
460 \g\l@stlmoff=0pt\g\l@strmoff=0pt\g\l@stlboff=0pt\g\l@strboff=0pt%
461 \g\l@stltop=0pt\g\l@strtop=0pt\g\l@stloff=0pt\g\l@stroff=0pt%
462 }
463
464 \def\g@tchildren{% enables us to talk about the left and the right child
465 % (names l@ft resp. r@ght) and the smaller and the larger
466 % child (names m@n resp. m@x)
467 \ifl@fttop\@ddname{l@st}{l@ft}%
468 \pr@vioustree
469 \@ddname{l@st}{r@ght}%
470 \else\@ddname{l@st}{r@ght}%
471 \pr@vioustree
472 \@ddname{l@st}{l@ft}%
473 \fi
474 \ifnum\r@ghtht>\l@ftht\relax
475 \r@ghthighertrue
476 \@ddname{r@ght}{m@x}%
477 \@ddname{l@ft}{m@n}%
478 \else\r@ghthigherfalse
479 \@ddname{l@ft}{m@x}%
480 \@ddname{r@ght}{m@n}%
481 \fi
482 }
483
484 \def\n@mel@st{%
485 \n@metree\l@sttreeheight\l@stdiminfo\l@sttreebox\l@sttreetype{l@st}}
486
487 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
488 %%% Initialization of the tree environment %%%
489 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
490
491 \def\beginTree{%
492 \begingroup
493 \unitlength 1pt%
494 \divide\unitlength by 65536
495 \l@sttreebox\count14
496 \l@sttreeheight\count10
497 \advance\l@sttreeheight by \@ne
498 \count\l@sttreeheight=-1
499 \l@stdiminfo\l@sttreeheight
500 \advance\l@stdiminfo by \@ne
501 \count\l@stdiminfo\count11
502 \advance\count\l@stdiminfo by -5
503 \l@sttreetype\l@stdiminfo
504 \advance\l@sttreetype by\@ne
505 \count\l@sttreetype\count15
506 \n@mel@st\ignorespaces
507 }
508
509 \let\Tree\beginTree
510
511 \def\endTree{%
512 \g\leftdist-\l@stlmoff\g\advance\leftdist by \l@stltop
513 \g\rightdist\l@strmoff\g\advance\rightdist by\l@strtop
514 \g\setbox\TeXTree\box\l@stbox\endgroup\ignorespaces}
515
516 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
517 %%% Specification of nodes %%%
518 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
519
520 % A node is defined by the command \node{<specifications>}.
521 % <specifications> defines the labels, graphical appearence and the order
522 % of the node and the thickness of the edges.
523 % Labels are defined by the commands \lft, \rght, \cntr,
524 % and \bnth. The specification of empty labels may be omitted.
525 % The graphical appearence is defined by the command \type{<type>}.
526 % <type> can have the values `circle', `square', `dot',
527 % `triangle', 'text', or 'frame'. The thickness of the edges is defined by
528 % \leftthick and \rightthick that give thick edges instead of the
529 % normal thin ones. Furthermore,
530 % the order of the node is given by the following commands:
531 % \external (if the node is an external node), \leftonly (if the node has a
532 % left successor only), \rightonly (analogous), \unary (if the node is an
533 % unary one), and \lefttop (the
534 % node which has been defined before this one, is supposed to be the left
535 % successor instead of the right one).
536 % Default: two children, no labels, type circle, thin edges,
537 % left child has been entered first.
538
539 \def\th@ck{\let\@linefnt\tenlnw
540 \@wholewidth\fontdimen8\tenlnw\@halfwidth.5\@wholewidth}
541
542 \def\leftthick{\g\let\l@ftthick\th@ck}
543 \def\rightthick{\g\let\r@ghtthick\th@ck}
544 \def\lft#1{\g\setbox\leftb@x\hbox{#1\ }}
545 \def\rght#1{\g\setbox\rightb@x\hbox{\ #1}}
546 \def\cntr#1{\g\setbox\centerb@x\hbox{#1\strut}}
547 \def\bnth#1{\g\setbox\beneathb@x\hbox to0pt{\hss\strut#1\hss}}
548 \def\type#1{%
549 \g\setbox\centerb@@x\copy\csname#1b@x\endcsname
550 \g\centerdim@n\csname#1w@dth\endcsname
551 \typ@{#1}%
552 \g\halfcenterdim@n=.5\centerdim@n}
553
554 \def\ext@nded{\g\ext@ndedfalse} % This definition must precede
555 % \input TreeTeX.sty (outdated now!)
556
557 \def\node#1{%
558 %%% Initialization (node type and labels), defaults and actual values
559 \g\setbox\leftb@x\copy\voidb@x
560 \g\setbox\rightb@x\copy\voidb@x
561 \g\setbox\centerb@x\copy\voidb@x
562 \g\setbox\beneathb@x\copy\voidb@x
563 \type{circle}%
564 \g\l@fttopfalse\g\l@ftonlyfalse\g\l@ftedgetrue
565 \g\r@ghtonlyfalse\g\r@ghtedgetrue\g\@xtfalse\ext@nded\n@dummy
566 \g\let\l@ftthick\relax\g\let\r@ghtthick\relax
567 #1%
568 \@pdcenter
569 \d@mmy
570 \n@de
571 \ignorespaces
572 }
573
574 \def\@pdcenter{\csname\the\typ@ @cntr\endcsname}
575
576 \let\circle@cntr\relax
577 \let\square@cntr\relax
578 \let\triangle@cntr\relax
579 \let\dot@cntr\relax
580
581 \def\text@cntr{%
582 \g\centerdim@n\wd\centerb@x
583 \g\[email protected]\centerdim@n}
584
585 \def\frame@cntr{%
586 \g\setbox\centerb@x\hbox{\ \unhcopy\centerb@x\ }
587 \g\centerdim@n\wd\centerb@x
588 % \g\advance\centerdim@n\fontdimen2\font
589 \g\[email protected]\centerdim@n
590 \g\setbox\centerb@@x\rect@ngle{\centerdim@n}{\squarew@dth}{.4pt}}
591
592 \def\leftonly{\g\l@ftonlytrue\g\r@ghtedgefalse\g\let\d@mmy\l@ftdummy}
593 \def\rightonly{\g\r@ghtonlytrue\g\l@ftedgefalse\g\let\d@mmy\r@ghtdummy}
594 \def\unary{\g\r@ghtedgefalse\g\let\d@mmy\@ndummy}
595 \def\external{\g\@xttrue\g\l@ftedgefalse\g\r@ghtedgefalse\g\let\d@mmy\@xtdummy}
596
597 \def\lefttop{\g\l@fttoptrue}
598
599 \def\@xtdummy{%
600 \@ppenddummy
601 \g\l@strtop-\halfmins@p
602 \@ppenddummy
603 \g\l@stltop-\halfmins@p
604 }
605
606 \def\n@dummy{\g\let\d@mmy\relax}
607
608 \def\l@ftdummy{% cf. \g@tposition
609 \@ppenddummy
610 \g\l@stltop=\dummyhalfcenterdim@n
611 \g\l@strtop=\dummyhalfcenterdim@n
612 }
613
614 \def\r@ghtdummy{% cf. \g@tposition
615 \lefttop
616 \@ppenddummy
617 \g\l@stltop=\dummyhalfcenterdim@n
618 \g\l@strtop=\dummyhalfcenterdim@n
619 }
620
621 \def\@ndummy{%
622 \g\t@mpdima\l@strtop\relax
623 \@ppenddummy
624 \g\l@stltop-\mins@p\g\advance\l@stltop by-\t@mpdima
625 \g\l@strtop=\t@mpdima
626 }
627
628 \def\n@de{%
629 \g@tposition % naming children and calculating \sl@pe and \tots@p
630 \g@tlt@p\g@trt@p % calculating \lt@p and \rt@p
631 \g@tlm@ff\g@trm@ff % calculating \lm@ff and \rm@ff
632 \g@tlb@ff\g@trb@ff % calculating \lb@ff and \rb@ff
633 \@pdlroff % updating loff and roff for all levels but the top one
634 \@pdloffl\@pdroffl % updating loff(1) and roff(1) of the parent tree
635 \@pddim % updating ltop, rtop, lmoff, rmoff, lboff, and rboff
636 \@pdinfo\@pdht % updating diminfo and treeheight
637 \@pdbox % updating treebox
638 \@pdtype % updating type
639 \n@mel@st % giving the name `l@st' to the new tree
640 \ignorespaces
641 }
642
643 \def\g@tposition{% naming children and calculating \sl@pe, \tots@p, and node offsets
644 \g@tchildren\c@lcsep\c@lcslope\c@lcoffsets
645 \ifext@nded\relax
646 \else\ifl@ftonly\g\r@ghtrtop=-\tots@p
647 \g\advance\r@ghtrtop by\l@ftrtop
648 \fi
649 \ifr@ghtonly\g\l@ftltop=-\tots@p
650 \g\advance\l@ftltop by\r@ghtltop
651 \fi
652 \fi % cf. \l@ftdummy and \r@ghtdummy
653 }
654
655 \def\@pdinfo{% updating diminfo
656 \g\l@stinfo=\m@xinfo\relax
657 }
658
659 \def\@pdht{% updating treeheight
660 \g\l@stht=\m@xht
661 \g\advance\l@stht by\@ne
662 }
663
664 \def\@pdtype{% updating type
665 \g\l@sttype\typ@
666 }
667
668 \def\g@tlt@p{% calculating \lt@p
669 \g\lt@p\wd\leftb@x\g\advance\lt@p by\halfcenterdim@n
670 }
671
672 \def\g@trt@p{% calculating \rt@p
673 \g\rt@p\wd\rightb@x\g\advance\rt@p by\halfcenterdim@n
674 }
675
676 \def\g@tlm@ff{% calculating \lm@ff
677 % \lm@ff:=lmoff(left tree)-ltop(left tree)
678 % -.5\tots@p+\lt@p
679 \g\lm@ff\l@ftlmoff
680 \g\advance\lm@ff by-\l@ftltop
681 \g\advance\lm@ff by-\halftots@p
682 \g\advance\lm@ff by\lt@p\relax
683 % if ht(left tree) < ht(right tree)
684 % \t@mpdima:=lmoff(right tree)-ltop(right tree)+.5\tots@p+\lt@p
685 % \lm@ff:=min(\lm@ff,\t@mpdima) fi
686 \ifnum\l@ftht<\r@ghtht\relax
687 \g\t@mpdima\r@ghtlmoff
688 \g\advance\t@mpdima by-\r@ghtltop
689 \g\advance\t@mpdima by\halftots@p
690 \g\advance\t@mpdima by\lt@p\relax
691 \ifdim\t@mpdima<\lm@ff\relax
692 \g\lm@ff\t@mpdima
693 \fi
694 \fi
695 % \lm@ff:=min(\lm@ff,0pt)
696 \ifdim0pt<\lm@ff\relax
697 \g\lm@ff=0pt%
698 \fi
699 }
700
701 \def\g@trm@ff{% calculating \rm@ff
702 % analog to lm@ff
703 % \rm@ff:=rmoff(right tree)+rtop(right tree)
704 % +.5\tots@p-\rt@p
705 \g\rm@ff\r@ghtrmoff
706 \g\advance\rm@ff by\r@ghtrtop
707 \g\advance\rm@ff by\halftots@p
708 \g\advance\rm@ff by-\rt@p\relax
709 % \t@mpdima:=rmoff(left tree)+rtop(left tree)-.5\tots@p-\rt@p
710 \ifnum\r@ghtht<\l@ftht\relax
711 \g\t@mpdima\l@ftrmoff
712 \g\advance\t@mpdima by\l@ftrtop
713 \g\advance\t@mpdima by-\halftots@p
714 \g\advance\t@mpdima by-\rt@p\relax
715 \ifdim\t@mpdima>\rm@ff\relax
716 \g\rm@ff\t@mpdima
717 \fi
718 \fi
719 % \rm@ff:=max(\rm@ff,0pt)
720 \ifdim0pt>\rm@ff\relax
721 \g\rm@ff=0pt
722 \fi
723 }
724
725 \def\g@tlb@ff{% calculating \lb@ff
726 % \lb@ff:=lboff(right tree)-ltop(right tree)+.5\tots@p+\lt@p
727 % resp.:=lboff(left tree)-ltop(left tree)
728 % -.5\tots@p+\lt@p
729 \if@xt\g\lb@ff0pt%
730 \else\ifnum\l@ftht<\r@ghtht\relax
731 \g\lb@ff\r@ghtlboff
732 \g\advance\lb@ff by-\r@ghtltop
733 \g\advance\lb@ff by\halftots@p
734 \g\advance\lb@ff by\lt@p\relax
735 \else\g\lb@ff\l@ftlboff
736 \g\advance\lb@ff by-\l@ftltop
737 \g\advance\lb@ff by-\halftots@p
738 \g\advance\lb@ff by\lt@p\relax
739 \fi
740 \fi
741 }
742
743 \def\g@trb@ff{% calculating \rb@ff
744 % \rb@ff:=rboff(left tree)+rtop(left tree)-.5\tots@p-\rt@p
745 % resp.:=rboff(right tree)+rtop(right tree)
746 % +.5\tots@p-\rt@p
747 \if@xt\g\rb@ff0pt%
748 \else\ifnum\r@ghtht<\l@ftht\relax
749 \g\rb@ff\l@ftrboff
750 \g\advance\rb@ff by\l@ftrtop
751 \advance\rb@ff by-\halftots@p
752 \g\advance\rb@ff by-\rt@p\relax
753 \else\g\rb@ff\r@ghtrboff
754 \g\advance\rb@ff by\r@ghtrtop
755 \g\advance\rb@ff by\halftots@p
756 \g\advance\rb@ff by-\rt@p\relax
757 \fi
758 \fi
759 }
760
761 \def\@pdlroff{% updating loff and roff for all levels but the top one
762 % if right tree higher \t@mpdima:=-ltop(right tree)
763 % \t@mpdimb:=lboff(left tree)-ltop(left tree)
764 % % \t@mpdimb holds the offset between the node
765 % % and the left edge of the bottom of the left tree
766 % else \t@mpdima:=rtop(left tree)
767 % \t@mpdimb:=lboff(right tree)+rtop(right tree)
768 % % substitute left by right
769 % fi
770 \ifr@ghthigher\g\t@mpdima-\r@ghtltop\relax
771 \g\t@mpdimb\l@ftlboff
772 \g\advance\t@mpdimb by-\l@ftltop\relax
773 \else\g\t@mpdima\l@ftrtop\relax
774 \g\t@mpdimb\r@ghtlboff
775 \g\advance\t@mpdimb by\r@ghtrtop\relax
776 \fi
777 \ifr@ghthigher\p@s\t@mpcnta\loff{m@n}% pointer to loff(1) of smaller tree
778 \p@s\t@mpcntb\loff{m@x}% pointer to loff(1) of larger tree
779 \else\p@s\t@mpcnta\roff{m@n}% pointer to roff(1) of smaller tree
780 \p@s\t@mpcntb\roff{m@x}% pointer to roff(1) of larger tree
781 \fi % if the right tree is the higher one you have to shift
782 % the left profile of the smaller tree, otherwise the
783 % right one
784 % For every level, \t@mpdima contains the offset between the node of the
785 % higher tree and the inner edge of the next level. Furthermore, if the
786 % right tree is the higher one, the left profile of the left tree becomes
787 % the upper part of the left profile of the parent tree, otherwise
788 % substitute `left' by `right.'
789 \ex\m@nht\times
790 \g\advance\t@mpdima by\dimen\t@mpcntb
791 \g\dimen\t@mpcntb\dimen\t@mpcnta
792 \g\advance\t@mpcnta by-\@dimoff
793 \g\advance\t@mpcntb by-\@dimoff\relax
794 \xe
795 % The link between the last outer level of the smaller tree and the next
796 % level of the higher one:
797 % \dimen\t@mpcntb:=\dimen\t@mpcntb+\t@mpdima+\tots@p-\t@mpdimb
798 % if left tree is smaller than right tree
799 % resp.\dimen\t@mpcntb+\t@mpdima-\tots@p-\t@mpdimb
800 % if right tree is smaller than left tree
801 \ifnum\m@xht=\m@nht\relax
802 \else\g\advance\dimen\t@mpcntb by\t@mpdima
803 \ifnum\l@ftht<\r@ghtht\relax
804 \g\advance\dimen\t@mpcntb by\tots@p
805 \else\g\advance\dimen\t@mpcntb by-\tots@p
806 \fi
807 \g\advance\dimen\t@mpcntb by-\t@mpdimb
808 \fi
809 }
810
811 \def\@pdloffl{% updating loff(1) of parent tree
812 % loff(1) of parent tree:=+\[email protected]\tots@p-ltop(left tree)
813 \p@s\t@mpcnta\loff{m@x}%
814 \g\advance\t@mpcnta by \@dimoff\relax % pointer to loff(0) of parent tree
815 \g\dimen\t@mpcnta\lt@p
816 \g\advance\dimen\t@mpcnta by-\halftots@p
817 \g\advance\dimen\t@mpcnta by-\l@ftltop\relax
818 }
819
820 \def\@pdroffl{% updating roff(1) of parent tree
821 % roff(l) of parent tree:=-\rt@p+.5\tots@p+rtop(right tree)
822 \p@s\t@mpcnta\roff{m@x}%
823 \g\advance\t@mpcnta by \@dimoff\relax % pointer to roff(0) of parent tree
824 \g\dimen\t@mpcnta-\rt@p
825 \g\advance\dimen\t@mpcnta by\halftots@p
826 \g\advance\dimen\t@mpcnta by\r@ghtrtop\relax
827 }
828
829 \def\@pddim{% updating ltop, rtop, lmoff, rmoff, lboff, and rboff
830 \g\m@xlmoff=\lm@ff\g\m@xrmoff=\rm@ff
831 \g\m@xlboff=\lb@ff\g\m@xrboff=\rb@ff
832 \g\m@xltop=\lt@p\g\m@xrtop=\rt@p
833 }
834
835 \def\@pdbox{% pushing the nodebox on the stack: updating treebox
836 \g\@xarg\xv@l\sl@pe\g\@yarg\yv@l\sl@pe
837 \ifnum\sl@pe=1 % vertical edge
838 \g\t@mpdima\vd@st
839 \g\advance\t@mpdima by-\y@ff\typ@
840 \g\advance\t@mpdima by-\y@ff\l@fttype
841 \g\@larg\t@mpdima % \@larg is a number register!
842 \g\t@mpdima\vd@st
843 \g\advance\t@mpdima by-\y@ff\typ@
844 \g\advance\t@mpdima by-\y@ff\r@ghttype
845 \g\@rarg\t@mpdima % \@rarg is a number register!
846 \else\g\t@mpdima\halftots@p
847 \g\advance\t@mpdima by-\x@ff\typ@
848 \g\advance\t@mpdima by-\x@ff\l@fttype
849 \g\@larg\t@mpdima % \@larg is a number register!
850 \g\t@mpdima\halftots@p
851 \g\advance\t@mpdima by-\x@ff\typ@
852 \g\advance\t@mpdima by-\x@ff\r@ghttype
853 \g\@rarg\t@mpdima % \@rarg is a number register!
854 \fi
855 \g\setbox\l@sttreebox\hbox{%
856 \ifvoid\leftb@x\relax
857 \else\hskip-\halfcenterdim@n\hskip-\wd\leftb@x
858 \unhcopy\leftb@x\hskip\halfcenterdim@n
859 \fi
860 \ifvoid\centerb@x\relax
861 \else\g\[email protected]\wd\centerb@x\hskip\t@mpdima
862 \unhbox\centerb@x\hskip\t@mpdima
863 \fi
864 \ifvoid\rightb@x\relax
865 \else\g\t@mpdima-\wd\rightb@x\hskip\halfcenterdim@n
866 \unhbox\rightb@x\hskip\t@mpdima\hskip-\halfcenterdim@n
867 \fi
868 \raise\based@st\copy\centerb@@x
869 \if@xt\relax
870 \lower\s@ze pt\hbox to0pt{\hss\unhbox\beneathb@x\hss}%
871 \else\hskip-\halftots@p
872 \lower\vd@st\box\l@ftbox
873 \ifl@ftedge\drawl@ftedge\else\hskip\halftots@p\fi
874 \ifr@ghtedge\drawr@ghtedge\else\hskip\halftots@p\fi
875 \lower\vd@st\box\r@ghtbox
876 \hskip-\halftots@p
877 \fi
878 }% of hbox
879 }
880
881 \def\drawl@ftedge{%
882 \hskip\x@ff\l@fttype
883 \g\t@mpdimc\y@ff\l@fttype\g\advance\t@mpdimc by\based@st
884 \g\advance\t@mpdimc-\vd@st
885 \raise\t@mpdimc
886 \hbox{\l@ftthick\lineseg(\@xarg,\@yarg){\@larg}}%
887 \hskip\x@ff\typ@
888 }
889
890 \def\drawr@ghtedge{%
891 \hskip\x@ff\typ@
892 \g\t@mpdimc\vd@st
893 \g\advance\t@mpdimc by \based@st
894 \g\advance\t@mpdimc by -\y@ff\typ@\relax
895 \g\advance\t@mpdimc by- \vd@st
896 \raise\t@mpdimc
897 \hbox{\r@ghtthick\lineseg(\@xarg,-\@yarg){\@rarg}}%
898 \hskip\x@ff\r@ghttype
899 }
900
901 \def\x@ff#1{%
902 \csname\the#1x@ff\endcsname\sl@pe
903 }
904
905 \def\y@ff#1{%
906 \csname\the#1y@ff\endcsname\sl@pe
907 }
908
909 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
910 %%% Calculating the separation of subtrees %%%
911 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
912
913 % \c@lcslope will calculate the required slope of the edges
914 % when the nodes are to be \vd@st apart vertically
915 % and at least \tots@p apart horizontally. This slope is returned by
916 % the value of the counter \sl@pe (a number between 1 and 23).
917 % Furthermore, \tots@p is updated in order to fit to this slope.
918
919 \def\c@lcslope{%
920 \g\sl@pe1
921 \loop
922 \ifdim\hv@l\sl@pe < \tots@p
923 \g\advance\sl@pe by1
924 \repeat
925 \g\tots@p\hv@l\sl@pe
926 \g\[email protected]\tots@p}
927
928
929 \def\c@lcsep{%
930 %%% \tots@p:=\mins@p + rtop(left tree) + ltop(right tree)
931 %%% \currs@p:=\mins@p
932 \g\tots@p\mins@p
933 \g\advance\tots@p by\l@ftrtop
934 \g\advance\tots@p by\r@ghtltop\relax
935 \g\currs@p\mins@p
936 %%% \t@mpcnta:= pointer to roff(0) of left tree
937 %%% \t@mpcntb:= pointer to loff(0) of right tree
938 \p@s\t@mpcnta\roff{l@ft}%
939 \p@s\t@mpcntb\loff{r@ght}%
940 %%% Calculate \currs@p and update \tots@p for each level of the
941 %%% smaller tree
942 %%% If at any level the subtrees are as close or closer than at
943 %%% the level of their roots, they will be moved apart by the additional
944 %%% amount of \adds@p
945 \g\adds@pfalse
946 \g\t@mpcntc\m@nht
947 \ex\t@mpcntc\times
948 \g\advance\currs@p by-\dimen\t@mpcnta
949 \g\advance\currs@p by \dimen\t@mpcntb
950 \ifdim\mins@p<\currs@p
951 \else\g\adds@ptrue
952 \fi
953 \ifdim\currs@p<\mins@p
954 \g\advance\tots@p by\mins@p
955 \g\advance\tots@p by -\currs@p
956 \g\currs@p\mins@p
957 \fi
958 \g\advance\t@mpcnta by -\@dimoff
959 \g\advance\t@mpcntb by -\@dimoff
960 \xe
961 \ifadds@p\g\advance\tots@p by\adds@p\fi}
962
963 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
964 %%% Predefined trees %%%
965 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
966
967 % \tri@ngle produces a triangle which covers \l@vels many level of a tree.
968 % The slope of the edges is given by \sl@pe, the reference point of the
969 % triangle is in the top, the width is 0pt.
970
971 \def\tri@ngle{%
972 \vtop{\g\@xarg\xv@l\sl@pe \g\@yarg\yv@l\sl@pe
973 \g\t@mpdimc\l@vels\vd@st
974 \g\advance\t@mpdimc by .5\squarew@dth
975 \g\multiply\t@mpdimc\xv@l\sl@pe
976 \g\divide\t@mpdimc\yv@l\sl@pe
977 \g\@larg\t@mpdimc
978 \offinterlineskip
979 \vskip0pt% Force the reference point to the top
980 \hbox to0pt{\hss\lineseg(\@xarg,\@yarg){\@larg}%
981 \hskip\t@mpdimc\rlap{\lineseg(-\@xarg,\@yarg){\@larg}}%
982 \hss}%
983 \setbox\t@mpboxa
984 \hbox to0pt{\hss\vrule height.2pt depth.2pt width2\t@mpdimc\hss}%
985 \[email protected]\squarew@dth\advance\t@mpdimc\based@st
986 \ht\t@mpboxa0pt\dp\t@mpboxa\t@mpdimc\copy\t@mpboxa
987 }%
988 }
989
990 \def\lvls#1{\g\l@vels#1}
991 \def\slnt#1{\g\sl@pe#1}
992
993 \def\treesymbol#1{%
994 \g\setbox\leftb@x\copy\voidb@x
995 \g\setbox\rightb@x\copy\voidb@x
996 \g\setbox\centerb@x\copy\voidb@x
997 \g\setbox\beneathb@x\copy\voidb@x
998 \lvls{1}\slnt{3}%
999 #1%
1000 \g\centerdim@n\trianglew@dth
1001 \g\[email protected]\trianglew@dth
1002 \n@xttree
1003 \g\count\l@sttreeheight\l@vels% \g\advance\count\l@sttreeheight by\tw@
1004 \g\toks\l@sttreetype{triangle}%
1005 \n@mel@st
1006 \g\hd@st\hv@l\sl@pe \g\divide\hd@st by\tw@
1007 \g\l@stltop=\halfcenterdim@n\g\advance\l@stltop by\wd\leftb@x
1008 \g\l@strtop=\halfcenterdim@n\g\advance\l@strtop by\wd\rightb@x
1009 \g\l@stlboff=-\hd@st \g\multiply\l@stlboff by\l@vels
1010 \g\advance\l@stlboff by\wd\leftb@x
1011 \g\l@strboff=\hd@st \g\multiply\l@strboff by\l@vels
1012 \g\advance\l@strboff by-\wd\rightb@x
1013 \g\l@stlmoff=\l@stlboff\relax
1014 \ifdim\l@stlmoff>0pt\relax\g\l@stlmoff=0pt\fi
1015 \g\l@strmoff=\l@strboff
1016 \ifdim\l@strmoff<0pt\relax\g\l@strmoff=0pt\fi
1017 \g\t@mpcnta\l@stinfo\g\advance\t@mpcnta by6% preliminary
1018 \ex\l@vels\times
1019 \g\dimen\t@mpcnta-\hd@st\g\advance\t@mpcnta by\@ne
1020 \g\dimen\t@mpcnta\hd@st\g\advance\t@mpcnta by\@ne
1021 \xe
1022 \g\advance\t@mpcnta by-\tw@
1023 \g\advance\dimen\t@mpcnta by\wd\leftb@x
1024 \g\advance\t@mpcnta by\@ne
1025 \g\advance\dimen\t@mpcnta by-\wd\rightb@x
1026 \g\setbox\l@stbox\vtop % to\l@vels\vd@st
1027 {\offinterlineskip
1028 \g\setbox\t@mpboxa
1029 \hbox{\hskip-\halfcenterdim@n\hskip-\wd\leftb@x\unhbox\leftb@x
1030 \hskip\halfcenterdim@n
1031 \raise\based@st\tri@ngle
1032 \hskip\halfcenterdim@n\t@mpdima-\wd\rightb@x
1033 \unhbox\rightb@x\hskip\t@mpdima\hskip-\halfcenterdim@n}
1034 \g\ht\t@mpboxa=0pt\box\t@mpboxa
1035 \setbox\centerb@x\hbox to0pt{\hss\unhbox\centerb@x\hss}%
1036 \ht\centerb@x0pt\dp\centerb@x0pt\box\centerb@x
1037 \vskip\s@ze pt
1038 \ht\beneathb@x0pt\box\beneathb@x
1039 \vskip-\dp\beneathb@x\vskip-\ht\beneathb@x}%
1040 \ignorespaces
1041 }
1042
1043 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1044 %%% Node sizes %%%
1045 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1046
1047 % The algorithm (macros \@pdbox, \drawl@ftedge, \drawr@ghtedge) accesses the
1048 % horizontal and vertical offset fo any node type XXX (circle, square,
1049 % dot, triangle, text, and frame) via the macros \XXXx@ff resp. \XXXy@ff.
1050 % These two macros take the slope of the outgoing edges
1051 % of the current node as their argument. Though horizontal offsets can
1052 % be calculated from the vertical offsets and vice versa, there is no
1053 % room to do so in the \XXXx@ff or \YYYy@ff macros, because these macros
1054 % have to expand to a dimension!
1055 %
1056 % Let k be a <number>. Actually k will be the slope of the outgoing
1057 % edges of the current node.
1058 %
1059 % There are three methods how, e.g., \XXXx@ff can be defined , depending
1060 % on the node type and the x- or y-orientation.
1061 % First, \XXXx@ff can be defined to expand to \XXXx@ffk', k' beeing
1062 % the roman numeral representation of the value of k, that in turn
1063 % expands to the appropriate dimension (example: \circley@ff).
1064 % In this case, \XXXx@ffi,...,\XXXx@ffiv are predefined by a \s@ries
1065 % command.
1066 % Second, \XXXx@ff can be defined to expand to a fixed dimension,
1067 % independent of its argument (example: \dotx@ff).
1068 % Third, the value of \XXXx@ff can be defined by the macro
1069 % \c@lcoffsets, when the slope k is already known. In this case,
1070 % the computation of \XXXx@ff makes use of the actual value
1071 % of k and possibly other offsets that are already predefined by method I
1072 % (examples: \circlex@ff, \squarex@ff).
1073
1074 \def\norm@ff{% everything set up for 10pt node size
1075 \s@ries{circley@ff}{0.50000pt//0.49320pt//0.49029pt//0.48507pt//%
1076 0.47434pt//0.46424pt//0.44721pt//0.42875pt//%
1077 0.41603pt//0.40000pt//0.39043pt//0.38411pt//%
1078 0.35355pt//0.32009pt//0.31235pt//0.30000pt//%
1079 0.27735pt//0.25725pt//0.22361pt//0.18570pt//%
1080 0.15811pt//0.12127pt//0.09806pt//0.08220pt}%
1081 }
1082
1083 \def\dotx@ff#1{0pt}
1084 \def\doty@ff#1{0pt}
1085
1086 \def\trianglex@ff#1{0pt}
1087 \def\triangley@ff#1{0pt}
1088
1089 \def\c@lcoffsets{%
1090 % \circlex@ff uses predefined \circley@ffi, \circley@ffii etc.
1091 \ifnum\sl@pe=\@ne\relax
1092 \xdef\circlex@ff##1{0pt}%
1093 \else\g\t@mpcnta26 % number of slopes + 2
1094 \g\advance\t@mpcnta-\sl@pe
1095 \xdef\circlex@ff##1{\circley@ff\t@mpcnta}%
1096 \fi
1097 % \squarex@ff and \squarey@ff are computed directly from \sl@pe and \squarew@dth
1098 \ifnum\sl@pe<13\relax % incoming edge meets upper border of a square node
1099 % (slope 13 corresponds to 45 degrees)
1100 \g\[email protected]\squarew@dth
1101 \xdef\squarey@ff##1{\the\t@mpdima}%
1102 \g\multiply\t@mpdima\xv@l\sl@pe
1103 \g\divide\t@mpdima\yv@l\sl@pe
1104 \xdef\squarex@ff##1{\the\t@mpdima}%
1105 \else\g\[email protected]\squarew@dth
1106 \xdef\squarex@ff##1{\the\t@mpdima}%
1107 \g\multiply\t@mpdima\yv@l\sl@pe
1108 \g\divide\t@mpdima\xv@l\sl@pe
1109 \xdef\squarey@ff##1{\the\t@mpdima}%
1110 \fi
1111 % \texty@ff is .5\squarew@dth, \textx@ff is adjusted accordingly
1112 \g\[email protected]\squarew@dth
1113 \xdef\texty@ff##1{\the\t@mpdima}%
1114 \g\multiply\t@mpdima\xv@l\sl@pe
1115 \g\divide\t@mpdima\yv@l\sl@pe
1116 \xdef\textx@ff##1{\the\t@mpdima}%
1117 \let\framex@ff\textx@ff
1118 \let\framey@ff\texty@ff
1119 }
1120
1121 \def\upds@ze#1{%
1122 \for\t@mpcntc:=1\to24
1123 \do\g\t@mpdimc=\csname#1\romannumeral\t@mpcntc\endcsname\relax
1124 \g\multiply\t@mpdimc by\s@ze
1125 \expandafter\gxdef\csname#1\romannumeral\t@mpcntc\endcsname
1126 {\the\t@mpdimc}%
1127 \od}
1128
1129 \def\nodes@ze{%
1130 \begingroup
1131 \unitlength 1pt%
1132 \divide\unitlength by 65536
1133 \g\based@st\s@ze pt\g\divide\based@st by 10 % \based@st is 10 % of
1134 % circle diameter
1135 \g\dummyhalfcenterdim@n=\s@ze pt\g\divide\dummyhalfcenterdim@n by\tw@
1136 \g\circlew@dth=\s@ze pt%
1137 \g\t@mpcntc\s@ze\g\multiply\t@mpcntc by 65536
1138 \g\setbox\circleb@x\hbox to0pt{\circle{\t@mpcntc}\hss}%
1139 \upds@ze{circley@ff}%
1140 \g\[email protected]\g\multiply\squarew@dth by\s@ze
1141 \g\setbox\squareb@x\rect@ngle{\squarew@dth}{\squarew@dth}{.4pt}%
1142 \g\dotw@dth=\s@ze pt\g\divide\dotw@dth by 5
1143 \ifdim\dotw@dth < 1pt\relax
1144 \g\dotw@dth1pt\relax
1145 \fi
1146 \g\t@mpcntc\dotw@dth
1147 \g\setbox\dotb@x\hbox to 0pt{\circle*{\t@mpcntc}\hss}%
1148 \g\trianglew@dth=\s@ze pt\g\multiply\trianglew@dth by \tw@
1149 \g\divide\trianglew@dth by 3
1150 \g\textw@dth=0pt%
1151 \g\setbox\textb@x\copy\voidb@x
1152 \g\framew@dth0pt%
1153 \g\setbox\frameb@x\copy\voidb@x
1154 \hv@ldef
1155 \endgroup
1156 }
1157
1158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1159 %%% Changing the style %%%
1160 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1161
1162 \def\treefonts#1{#1}
1163 \def\vdist#1{\g\vd@st=#1\relax}
1164 \def\minsep#1{\g\mins@p=#1\relax\g\halfmins@p=.5\mins@p}
1165 \def\addsep#1{\g\adds@p=#1\relax}
1166 \def\extended{\def\ext@nded{\g\ext@ndedtrue}}
1167 \def\noextended{\def\ext@nded{\g\ext@ndedfalse}}
1168 \def\nodesize#1{\g\t@mpdima=#1\relax\g\s@ze=\t@mpdima
1169 \g\divide\s@ze by 65536\relax} % conversion from dimension to number
1170 \def\Treestyle#1{\norm@ff#1\nodes@ze\ignorespaces}
1171
1172 \input classes
1173
1174 \Treestyle{%
1175 \ifLaTeX\treefonts{\normalsize\rm}%
1176 \else\treefonts{\tenrm}%
1177 \fi
1178 \vdist{60pt}%
1179 \minsep{20pt}%
1180 \addsep{0pt}%
1181 \nodesize{20pt}%
1182 }
1183
1184
1185 %
1186
1187