| 1 |
%% \CheckSum{753} |
| 2 |
% \iffalse meta-comment |
| 3 |
%% synttree.dtx |
| 4 |
%% Package `synttree' for use with LaTeX 2e |
| 5 |
%% Version 1.4.2 |
| 6 |
% |
| 7 |
% See the section "Author and License" below for copyright and licensing |
| 8 |
% information |
| 9 |
% |
| 10 |
% \fi |
| 11 |
% |
| 12 |
%% \CharacterTable |
| 13 |
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 14 |
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 15 |
%% Digits \0\1\2\3\4\5\6\7\8\9 |
| 16 |
%% Exclamation \! Double quote \" Hash (number) \# |
| 17 |
%% Dollar \$ Percent \% Ampersand \& |
| 18 |
%% Acute accent \' Left paren \( Right paren \) |
| 19 |
%% Asterisk \* Plus \+ Comma \, |
| 20 |
%% Minus \- Point \. Solidus \/ |
| 21 |
%% Colon \: Semicolon \; Less than \< |
| 22 |
%% Equals \= Greater than \> Question mark \? |
| 23 |
%% Commercial at \@ Left bracket \[ Backslash \\ |
| 24 |
%% Right bracket \] Circumflex \^ Underscore \_ |
| 25 |
%% Grave accent \` Left brace \{ Vertical bar \| |
| 26 |
%% Right brace \} Tilde \~} |
| 27 |
%% |
| 28 |
%\iffalse This is a METACOMMENT |
| 29 |
% |
| 30 |
% Version: Date: Changes: |
| 31 |
% 0.9 1998/07/19 First version as a .dtx distibution. |
| 32 |
% 0.9a ? ? |
| 33 |
% 1.0 ? ? |
| 34 |
% 1.0a 1999/10/02 Bugfix: bt combination changed to x. |
| 35 |
% 1.1 1999/10/13 More children, better code. |
| 36 |
% 1.2 2001 Totally new system |
| 37 |
% 1.3 2004/11/07 New system up and running. |
| 38 |
% 1.3.1 2004/11/07 Prepared for packaging, clarified licensing. |
| 39 |
% 2004/12/30 Ignore leading and trailing spaces in labels. |
| 40 |
% 2005/04/13 Allow up to 10 children (or any number, in theory). |
| 41 |
% 1.4 2005/05/01 Allow any number of children, just warn. |
| 42 |
% Updated documentation. |
| 43 |
% 1.4.1 2006/07/20 Remove spurious spaces in output. |
| 44 |
% Simplify label typesetting. |
| 45 |
% 1.4.2 2008/03/30 Fix dot option warning message. |
| 46 |
% Some refactoring to allow hacks. |
| 47 |
% |
| 48 |
%<*driver> |
| 49 |
\documentclass[a4paper]{ltxdoc} |
| 50 |
\usepackage[specials]{synttree} |
| 51 |
\EnableCrossrefs |
| 52 |
%\DisableCrossrefs % Say \DisableCrossrefs if index is ready |
| 53 |
\CodelineIndex |
| 54 |
\RecordChanges % Gather update information |
| 55 |
%\OnlyDescription % comment out for implementation details |
| 56 |
\OldMakeindex % use if your MakeIndex is pre-v2.9 |
| 57 |
\setlength\hfuzz{15pt} % dont make so many |
| 58 |
\hbadness=7000 % over and under full box warnings |
| 59 |
\begin{document} |
| 60 |
\DocInput{synttree.dtx} |
| 61 |
\end{document} |
| 62 |
%</driver> |
| 63 |
% |
| 64 |
%\fi |
| 65 |
%\MakeShortVerb{\"} |
| 66 |
% \title{The "synttree" package for typesetting syntactic |
| 67 |
% trees.\footnote{Package version 1.4.2}} |
| 68 |
% \author{Matijs van Zuijlen\footnote{e-mail: \texttt{mvz@xs4all}; web: |
| 69 |
% \texttt{http://www.matijs.net/}}} |
| 70 |
% |
| 71 |
% \maketitle |
| 72 |
% |
| 73 |
% \begin{abstract} |
| 74 |
% The "synttree" package provides a simple way to typeset syntactic |
| 75 |
% trees as used in Chomsky's Generative Grammar. |
| 76 |
% \end{abstract} |
| 77 |
% |
| 78 |
% {\parskip 0pt ^^A We have to reset \parskip |
| 79 |
% ^^A (bug in \LaTeX) |
| 80 |
% \tableofcontents |
| 81 |
% } |
| 82 |
% \section{Introduction} |
| 83 |
% |
| 84 |
% The "synttree" package provides a macro for creating syntactic tree |
| 85 |
% structures such as those used in Noam Chomsky's Generative Grammar. |
| 86 |
% It is designed to create a tree that looks nice, without manual |
| 87 |
% tweaking, and with as little use of `special effects', such as |
| 88 |
% PostScript, as possible. |
| 89 |
% |
| 90 |
% Since the application is very specific, there is no need for a very |
| 91 |
% complex set of options: "synttree" is designed to do one thing, and do |
| 92 |
% it well. |
| 93 |
% |
| 94 |
% Using "synttree", you can create trees of any depth, and an unlimited |
| 95 |
% number of branches (up to the memory limit of your version of \TeX, of |
| 96 |
% course). |
| 97 |
% |
| 98 |
% \section{Usage} |
| 99 |
% |
| 100 |
% \subsection{Drawing Options} |
| 101 |
% |
| 102 |
% The current implementation can use either em\TeX{} "\special"'s or |
| 103 |
% \LaTeXe{}'s "\qbezier" macro to draw the lines in the tree, |
| 104 |
% although the latter option is probably technically not very nice. Still, |
| 105 |
% the behavior defaults to the \LaTeXe{} version. |
| 106 |
% |
| 107 |
% In order to switch between the two modes, the following options are |
| 108 |
% supported: |
| 109 |
% |
| 110 |
% \begin{description} |
| 111 |
% |
| 112 |
% \item[specials] Use em\TeX{} special commands. |
| 113 |
% \item[nospecials] Don't use em\TeX{} special commands. This is the |
| 114 |
% default. |
| 115 |
% |
| 116 |
% \end{description} |
| 117 |
% |
| 118 |
% \subsection{Defined Macros} |
| 119 |
% |
| 120 |
% \DescribeMacro{\synttree} |
| 121 |
% The main macro defined by this package is the "\synttree" macro. It |
| 122 |
% takes as arguments first an optional parameter indicating the |
| 123 |
% maximum depth of the tree, and second a parameter describing the |
| 124 |
% structure of the tree, delimited by square brackets ("[" and "]"). |
| 125 |
% |
| 126 |
% A tree consists of the parent node's label, followed by the child trees. |
| 127 |
% In principle, an unlimited number of children can be specified, but |
| 128 |
% to signal runaway trees, a warning will be issued when the number is |
| 129 |
% more than ten. |
| 130 |
% Each of the child trees is again surrounded by square brackets. |
| 131 |
% For example, the line |
| 132 |
%\begin{verbatim} |
| 133 |
%\synttree[A[B][C]] |
| 134 |
%\end{verbatim} |
| 135 |
% creates the following tree: |
| 136 |
% \begin{trivlist} |
| 137 |
% \item \synttree[A[B][C]] |
| 138 |
% \end{trivlist} |
| 139 |
% |
| 140 |
% Note that leading and trailing spaces in the label will be ignored, so |
| 141 |
% the following has the same result: |
| 142 |
%\begin{verbatim} |
| 143 |
%\synttree[ A [ B ][ C ]] |
| 144 |
%\end{verbatim} |
| 145 |
%^^A Nodes and subtrees are surrounded by square |
| 146 |
%^^A brackets ("[" and "]"), as is the entire tree. |
| 147 |
% |
| 148 |
% Before the label, a parameter may be added. This is specified |
| 149 |
% by appending a period (".") to the opening bracket, and appending a letter |
| 150 |
% that modifies the appearance of the tree. Append a "t" to |
| 151 |
% create a triangle instead of a line going from the label to the |
| 152 |
% level above it, and a "b" to specify that the node has to appear at |
| 153 |
% the bottom of the tree, on a line with the lowest leaves. To |
| 154 |
% use "b", a maximum tree depth has to be specified. To combine the |
| 155 |
% two features, use "x". |
| 156 |
% |
| 157 |
% Using the optional parameters, the code |
| 158 |
%\begin{verbatim} |
| 159 |
%\synttree{4} |
| 160 |
%[A |
| 161 |
% [B [.x Some text] ] |
| 162 |
% [D [E] [F[.t G]] [H] ] |
| 163 |
%] |
| 164 |
%\end{verbatim}% |
| 165 |
% creates this tree: |
| 166 |
% \begin{trivlist} |
| 167 |
% \item |
| 168 |
% \synttree{4} |
| 169 |
% [A |
| 170 |
% [B [.x Some text] ] |
| 171 |
% [D [E] [F[.t G]] [H] ] |
| 172 |
% ] |
| 173 |
% \end{trivlist} |
| 174 |
% |
| 175 |
% If brackets are included in the label, surround |
| 176 |
% them (or the entire label) by braces: |
| 177 |
% |
| 178 |
%\begin{verbatim} |
| 179 |
% \synttree[A[{B]D}][C]] |
| 180 |
%\end{verbatim} |
| 181 |
% \begin{trivlist} |
| 182 |
% \item \synttree[ |
| 183 |
% A[{B]D}][C]] |
| 184 |
% \end{trivlist} |
| 185 |
% |
| 186 |
% The other defined macros affect the look and sizing of the trees. |
| 187 |
% The distance between levels can be adjusted by using |
| 188 |
% \DescribeMacro{\branchheight} |
| 189 |
% "\branchheight". It takes a length as its argument, and sets the |
| 190 |
% distance to that length. The default distance is half an inch. This |
| 191 |
% value is the distance between the baselines of the labels, so setting it |
| 192 |
% to zero will cause everything to be on one line. |
| 193 |
% The minimum horizontal separation between edges of two children is set |
| 194 |
% by |
| 195 |
% \DescribeMacro{\childsidesep} |
| 196 |
% "\childsidesep". The default is "1em". |
| 197 |
% The length |
| 198 |
% \DescribeMacro{\childattachsep} |
| 199 |
% "\childattachsep" indicates the minimum distance between the |
| 200 |
% attachment points of two children. Here, the default is "0.5in". |
| 201 |
% Finally, the balancing of the triangles can be adjusted by using |
| 202 |
% \DescribeMacro{\trianglebalance} |
| 203 |
% "\trianglebalance". It takes a number from 0 to 100, indicating the |
| 204 |
% percentage of the triangle on the right side of its attachment point to |
| 205 |
% the parent. The default is 50, resulting in isosceles triangles. |
| 206 |
% |
| 207 |
% \section{Wish List and Bugs} |
| 208 |
% |
| 209 |
% It is important to note that this package may not prevent you from doing |
| 210 |
% certain things `wrong'. For example, triangles on non-leaf nodes are |
| 211 |
% not forbidden, but may not give the desired result. |
| 212 |
% |
| 213 |
% Sometimes, the label of a parent may be a phrase, and it may be |
| 214 |
% desirable to attach the children to a particular element in that phrase |
| 215 |
% (e.g., to elaborate on the structure of that particular element). This |
| 216 |
% is currently not possible: The children are always attached to the |
| 217 |
% center of the label. Support for this may be added sooner or later. |
| 218 |
% |
| 219 |
% \section{Related Packages} |
| 220 |
% A more complex package is the TreeTeX |
| 221 |
% system\cite{TreeTeX}. This system, however, produces nodes |
| 222 |
% consisting of a node symbol \emph{and} a label, whereas in |
| 223 |
% syntactic trees the label \emph{is} the node symbol. Additionally, |
| 224 |
% the method of specifying the tree structure itself makes the source |
| 225 |
% code hard to read. |
| 226 |
% |
| 227 |
% The "xyling" package\cite{xyling} is a very powerful package, allowing |
| 228 |
% many things that "synttree" will not do. However, the nodes have to be |
| 229 |
% laid out meticulously in an array. Once that's done, however, the result |
| 230 |
% looks very good. |
| 231 |
% |
| 232 |
% The ``\LaTeX\ for Linguists'' website\cite{LfL} lists other tree-drawing |
| 233 |
% packages, with comments on their usefulness. |
| 234 |
% |
| 235 |
% \section{Author and License} |
| 236 |
% |
| 237 |
% Copyright (c) 1998, 1999, 2001, 2004--2006 Matijs van Zuijlen. |
| 238 |
% |
| 239 |
% The "synttree" package is free software. It has been released under the |
| 240 |
% terms of the Latex Project Public License, version 1.3a. |
| 241 |
% |
| 242 |
% This work has the LPPL maintenance status `maintained'. Its current |
| 243 |
% maintainer is Matijs van Zuijlen. This work consists of the files |
| 244 |
% "synttree.dtx" and "synttree.ins". |
| 245 |
% |
| 246 |
% \StopEventually{ |
| 247 |
% \begin{thebibliography}{1} |
| 248 |
% \bibitem{LfL} Doug Arnold |
| 249 |
% \newblock {\it \LaTeX\ for Linguists} \\ |
| 250 |
% \newblock {At \texttt{http://www.essex.ac.uk/linguistics/clmt/latex4ling/}} |
| 251 |
% \bibitem{TreeTeX} A. Br{\"u}ggemann-Klein and D. Wood. |
| 252 |
% \newblock {\it Drawing trees nicely with \TeX{}} |
| 253 |
% \newblock {File \texttt{tree\_doc.tex} in the "treetex" package} |
| 254 |
% \bibitem{BasicControl} Jonathan Fine. |
| 255 |
% \newblock {\it Some Basic Control Macros for \TeX{}} |
| 256 |
% \newblock {TUGboat, Volume 13 (1992), No. 1} |
| 257 |
% \bibitem{xyling} Ralf Vogel |
| 258 |
% \newblock {\it xyling --- \LaTeX\ macros for linguistic graphics} \\ |
| 259 |
% \newblock {At \texttt{http://www.ling.uni-potsdam.de/~rvogel/xyling/}} |
| 260 |
% \end{thebibliography} |
| 261 |
% } |
| 262 |
% |
| 263 |
% \section{Implementation} |
| 264 |
% |
| 265 |
% \subsection{Utility macros} |
| 266 |
% |
| 267 |
% Very useful for putting stuff after a "\fi" (as the name implies) |
| 268 |
% \cite{BasicControl}. |
| 269 |
% \begin{macrocode} |
| 270 |
\def\@AfterFi#1\fi{\fi#1} |
| 271 |
\def\@AfterElseFi#1\else#2\fi{\fi#1} |
| 272 |
% \end{macrocode} |
| 273 |
% |
| 274 |
% \subsection{Drawing commands} |
| 275 |
% |
| 276 |
% These command are used to draw the lines between the nodes. There are two |
| 277 |
% versions: one that uses the \LaTeXe{} "\qbezier" command, and one that is |
| 278 |
% an adaptation of the unsupported "eepic" package, and uses specials. |
| 279 |
% Currently, the package just uses the \LaTeXe{} version. |
| 280 |
% |
| 281 |
% First, the line drawing macros themselves. These simply draw a line |
| 282 |
% between the two points given. Arguments are counters. |
| 283 |
% \begin{macrocode} |
| 284 |
\def\MTr@latexdrawline(#1,#2)(#3,#4){% |
| 285 |
{% |
| 286 |
\count0=#1 \advance\count0 by #3 \divide\count0 2 |
| 287 |
\count1=#2 \advance\count1 by #4 \divide\count1 2 |
| 288 |
\qbezier(#1,#2)(\count0,\count1)(#3,#4)% |
| 289 |
}% |
| 290 |
} |
| 291 |
\def\MTr@etexdrawline(#1,#2)(#3,#4){% |
| 292 |
{% |
| 293 |
\count0=\@wholewidth \divide\count0 by 4736 |
| 294 |
\special{pn \the\count0}% |
| 295 |
\count0= #1\advance \count0 2368 \divide \count0 4736 |
| 296 |
\count1=-#2\advance \count1 -2368 \divide \count1 4736 |
| 297 |
\special{pa \the\count0 \space \the\count1}% |
| 298 |
\count0= #3\advance \count0 2368 \divide \count0 4736 |
| 299 |
\count1=-#4\advance \count1 -2368 \divide \count1 4736 |
| 300 |
\special{pa \the\count0 \space \the\count1}% |
| 301 |
\special{fp}% |
| 302 |
}% |
| 303 |
} |
| 304 |
% \end{macrocode} |
| 305 |
% |
| 306 |
% Options to select either version: |
| 307 |
% \begin{macrocode} |
| 308 |
\DeclareOption{specials}{ |
| 309 |
\let\MTr@drawline\MTr@etexdrawline% |
| 310 |
} |
| 311 |
\DeclareOption{nospecials}{ |
| 312 |
\let\MTr@drawline\MTr@latexdrawline% |
| 313 |
} |
| 314 |
\ExecuteOptions{nospecials}% |
| 315 |
\ProcessOptions% |
| 316 |
% \end{macrocode} |
| 317 |
% |
| 318 |
% \subsection{Definitions} |
| 319 |
% |
| 320 |
% Some counters etc.\ are defined: The current level, the number of |
| 321 |
% children the current node has, the maximum level specified, also, the |
| 322 |
% current "branchmult", and whether the current node should be typeset |
| 323 |
% with a triangle. We need a separate counter to hold the current |
| 324 |
% "branchmult", because we calculate it before parsing the children, which |
| 325 |
% will each set "branchmult" globally to save it into the child registers. |
| 326 |
% \begin{macrocode} |
| 327 |
\newcount\MTr@level |
| 328 |
\newcount\MTr@numchildren |
| 329 |
\newcount\MTr@maxlevel |
| 330 |
\newcount\MTr@mybranchmult |
| 331 |
\newif\ifMTr@mytriangle |
| 332 |
% \end{macrocode} |
| 333 |
% |
| 334 |
% A boolean to specify whether read tokens that are not "[" or "]" should |
| 335 |
% be used as a label for a node, or just ignored. |
| 336 |
% \begin{macrocode} |
| 337 |
\newif\ifMTr@uselabel |
| 338 |
% \end{macrocode} |
| 339 |
% |
| 340 |
% Two "savebox"es, one for the label, one to put the child in while it is |
| 341 |
% being defined. |
| 342 |
% ^^A There was: , and a token register, to put the label in before it is |
| 343 |
% ^^A ready. |
| 344 |
% \begin{macrocode} |
| 345 |
\newbox\MTr@labelbox |
| 346 |
\newbox\MTr@treebox |
| 347 |
% \end{macrocode} |
| 348 |
% |
| 349 |
% \subsection{Storage for information on (sub)trees} |
| 350 |
% |
| 351 |
% Define storage space to store contents of and information about a tree's |
| 352 |
% children. Distances are measured from the child's label's virtual |
| 353 |
% attachment point to the line to its parent --- in reality, for aesthetic |
| 354 |
% reasons, the line is drawn up to a point that lies slightly higher. |
| 355 |
% Drawing a box around the whole child tree, we find the distance from the |
| 356 |
% left side to the central point, $v$, the distance from the right side, |
| 357 |
% $w$. Then, we have the height (equal to the height of the label), and the |
| 358 |
% depth (the height of the box minus the height of the label). There are |
| 359 |
% also two external dimensions: the vertical distance from the parent |
| 360 |
% label, $y$, and the horizontal distance from the parent tree's box, $x$. |
| 361 |
% Usually, a child node is typeset one level below its parent. However, we |
| 362 |
% may set it lower, e.g., to set the child on the bottom level. |
| 363 |
% "branchmult" indicates how many levels below the parent the child should |
| 364 |
% be typeset. |
| 365 |
% \begin{macrocode} |
| 366 |
\def\MTr@makechildcounter#1{% |
| 367 |
\expandafter\newcount\csname MTr@child#1\endcsname% |
| 368 |
} |
| 369 |
\def\MTr@makechildstoreage#1{% |
| 370 |
\expandafter\newsavebox\csname MTr@child#1box\endcsname% |
| 371 |
\MTr@makechildcounter{#1x}% |
| 372 |
\MTr@makechildcounter{#1y}% |
| 373 |
\MTr@makechildcounter{#1v}% |
| 374 |
\MTr@makechildcounter{#1w}% |
| 375 |
\MTr@makechildcounter{#1height}% |
| 376 |
\MTr@makechildcounter{#1depth}% |
| 377 |
\MTr@makechildcounter{#1branchmult}% |
| 378 |
\MTr@makechildcounter{#1picheight}% |
| 379 |
\MTr@makechildcounter{#1triangle}% |
| 380 |
} |
| 381 |
% \end{macrocode} |
| 382 |
% |
| 383 |
% \begin{macro}{\MTr@childparam} |
| 384 |
% We also need an easy way to retrieve each child's parameters. This way, |
| 385 |
% we don't have to use the "\csname" construct all the time. |
| 386 |
% \begin{macrocode} |
| 387 |
\def\MTr@childparam#1#2{\csname MTr@child#1#2\endcsname} |
| 388 |
% \end{macrocode} |
| 389 |
% \end{macro} |
| 390 |
% |
| 391 |
% Store info for current subtree: $v$, $w$ ($x$ and $y$ are external, thus |
| 392 |
% not important), height, depth, "branchmult", triangle status. |
| 393 |
% \begin{macrocode} |
| 394 |
\newcount\MTr@treev |
| 395 |
\newcount\MTr@treew |
| 396 |
\newcount\MTr@treeheight |
| 397 |
\newcount\MTr@treedepth |
| 398 |
\newcount\MTr@branchmult |
| 399 |
\MTr@branchmult 1 |
| 400 |
\newif\ifMTr@triangle |
| 401 |
% \end{macrocode} |
| 402 |
% Next, the depth, height and half the width of the label. |
| 403 |
% \begin{macrocode} |
| 404 |
\newcount\MTr@labeldepth |
| 405 |
\newcount\MTr@labelheight |
| 406 |
\newcount\MTr@labelhalfwidth |
| 407 |
% \end{macrocode} |
| 408 |
% When drawing, we need "morex", to store extra shift to the right when |
| 409 |
% drawing the children, and "parenty", the vertical position of the point |
| 410 |
% where the line from the parent to the child starts. Also, we need the |
| 411 |
% width and height of the picture being drawn. |
| 412 |
% \begin{macrocode} |
| 413 |
\newcount\MTr@morex |
| 414 |
\newcount\MTr@parenty |
| 415 |
\newcount\MTr@picwidth |
| 416 |
\newcount\MTr@picheight |
| 417 |
% \end{macrocode} |
| 418 |
% Finally, we need a temporary length, and four temporary counters. |
| 419 |
% \begin{macrocode} |
| 420 |
\newlength{\MTr@templength} |
| 421 |
\newcount\MTr@loopcnta |
| 422 |
\newcount\MTr@tempcnta |
| 423 |
\newcount\MTr@tempcntb |
| 424 |
\newcount\MTr@tempcntc |
| 425 |
% \end{macrocode} |
| 426 |
% |
| 427 |
% \subsection{Adjustable and other parameters} |
| 428 |
% \begin{macro}{\branchheight} |
| 429 |
% The user can set up several parameters. |
| 430 |
% First, "\branchheight" will set the distance |
| 431 |
% between levels. Default value is half an inch. |
| 432 |
% ^^A TODO: let default value depend on font size. |
| 433 |
% \begin{macrocode} |
| 434 |
\newcount\MTr@branchheight% |
| 435 |
\newcommand{\branchheight}[1]{% |
| 436 |
\setlength{\MTr@templength}{#1}% |
| 437 |
\MTr@branchheight\MTr@templength% |
| 438 |
} |
| 439 |
\branchheight{.5in}% |
| 440 |
% \end{macrocode} |
| 441 |
% \end{macro} |
| 442 |
% |
| 443 |
% \begin{macro}{\trianglebalance}Next, "\trianglebalance" will set the |
| 444 |
% balancing of the triangle. Default value is $50$. |
| 445 |
% \begin{macrocode} |
| 446 |
\newcount\MTr@trianglemultright% |
| 447 |
\newcount\MTr@trianglemultleft% |
| 448 |
\newcommand{\trianglebalance}[1]{% |
| 449 |
\MTr@trianglemultleft100% |
| 450 |
\MTr@trianglemultright#1% |
| 451 |
\advance\MTr@trianglemultleft-#1% |
| 452 |
} |
| 453 |
\trianglebalance{50}% |
| 454 |
% \end{macrocode} |
| 455 |
% \end{macro} |
| 456 |
% Distance between the labels and the lines. |
| 457 |
% \begin{macrocode} |
| 458 |
\newcount\MTr@lineoffset |
| 459 |
\setlength{\MTr@templength}{2pt}% |
| 460 |
\MTr@lineoffset\MTr@templength% |
| 461 |
% \end{macrocode} |
| 462 |
% Minimum label height. |
| 463 |
% \begin{macrocode} |
| 464 |
\newlength{\MTr@minheight} |
| 465 |
\setlength{\MTr@minheight}{8pt}% |
| 466 |
% \end{macrocode} |
| 467 |
% \begin{macro}{\childsidesep} Minimum separation between edges of two |
| 468 |
% children. |
| 469 |
% \begin{macrocode} |
| 470 |
\newcount\MTr@childsidesep |
| 471 |
\newcommand{\childsidesep}[1]{% |
| 472 |
\setlength{\MTr@templength}{#1}% |
| 473 |
\MTr@childsidesep\MTr@templength% |
| 474 |
\ignorespaces% |
| 475 |
} |
| 476 |
\childsidesep{1em} |
| 477 |
% \end{macrocode} |
| 478 |
% \end{macro} |
| 479 |
% \begin{macro}{\childattachsep}How far apart are the attachment points of |
| 480 |
% two children? |
| 481 |
% \begin{macrocode} |
| 482 |
\newcount\MTr@childattachsep |
| 483 |
\newcommand{\childattachsep}[1]{% |
| 484 |
\setlength{\MTr@templength}{#1}% |
| 485 |
\MTr@childattachsep\MTr@templength% |
| 486 |
\ignorespaces% |
| 487 |
} |
| 488 |
\childattachsep{0.5in} |
| 489 |
% \end{macrocode} |
| 490 |
% \end{macro} |
| 491 |
% |
| 492 |
% \subsection{Main macro} |
| 493 |
% \begin{macro}{\synttree} |
| 494 |
% "\synttree" is the main macro. |
| 495 |
% If the user has not provided a maximum depth, set it to 0. There |
| 496 |
% will be no messages concerning depth, except when the bottomlevel |
| 497 |
% modifier is used. |
| 498 |
% Control is passed on to "\MTr@synttree" |
| 499 |
% \begin{macrocode} |
| 500 |
\def\synttree{% |
| 501 |
\@ifnextchar[{\MTr@synttree{0}}{\MTr@synttree}%] |
| 502 |
} |
| 503 |
% \end{macrocode} |
| 504 |
% \end{macro} |
| 505 |
% |
| 506 |
% \begin{macro}{\MTr@synttree} |
| 507 |
% This macro sets maximum depth, end sets picture coordinates to scaled |
| 508 |
% points. Next, initial values of some variables are set, and the first |
| 509 |
% real parsing macro, "\MTr@parserightbracket", is called. |
| 510 |
% \begin{macrocode} |
| 511 |
\def\MTr@synttree#1{% |
| 512 |
\MTr@maxlevel#1% |
| 513 |
\unitlength 1sp% |
| 514 |
\MTr@level=0% |
| 515 |
\MTr@numchildren=0% |
| 516 |
\MTr@uselabelfalse% |
| 517 |
\MTr@parserightbracket% |
| 518 |
} |
| 519 |
% \end{macrocode} |
| 520 |
% \end{macro} |
| 521 |
% |
| 522 |
% \subsection{Parsing} |
| 523 |
% \iffalse[[[\fi^^A Brackets needed for bracket balancing in text editor |
| 524 |
% |
| 525 |
% Parsing will only work if at least one "]" is present. |
| 526 |
% \begin{macro}{\MTr@parserightbracket} |
| 527 |
% First, scan until the first occurrance of "]". Argument "#1" will contain no |
| 528 |
% "]", but may contain some "[", which are detected by |
| 529 |
% "\MTr@parseleftbracket". After "#1" has been processed, lower the nesting |
| 530 |
% level. If we're back at 0, we're done. Otherwise, continue looking for |
| 531 |
% "]". |
| 532 |
% \begin{macrocode} |
| 533 |
\def\MTr@parserightbracket#1]{% |
| 534 |
\MTr@parseleftbracket#1[:\END% |
| 535 |
\advance\MTr@level by -1% |
| 536 |
\MTr@dorightbracket% |
| 537 |
\ifnum\MTr@level=0% |
| 538 |
\unhbox\MTr@childibox{}% |
| 539 |
\else |
| 540 |
\@AfterFi{\MTr@parserightbracket}% |
| 541 |
\fi% |
| 542 |
} |
| 543 |
% \end{macrocode} |
| 544 |
% \end{macro} |
| 545 |
% \begin{macro}{\Mtr@parseleftbracket} |
| 546 |
% ^^A Scan after we already had one or more children: Just ignore anything |
| 547 |
% ^^A that is not a "[" or "]". |
| 548 |
% Scan until the first occurrance of "[". Argument "#1" will contain no "]" |
| 549 |
% or "[". "#2" may contain more "]". |
| 550 |
% Possibly, "#1" is a label. |
| 551 |
% If "#2"=":", the "[" was placed by "\MTr@parserightbracket", and we're |
| 552 |
% done. |
| 553 |
% \begin{macrocode} |
| 554 |
\def\MTr@parseleftbracket#1[#2\END{% |
| 555 |
\ifMTr@uselabel% |
| 556 |
\MTr@bottomnodefalse% |
| 557 |
\MTr@mytrianglefalse% |
| 558 |
\MTr@parsedot#1.: \END% |
| 559 |
\fi% |
| 560 |
\ifx:#2% |
| 561 |
\else% |
| 562 |
\MTr@doleftbracket% |
| 563 |
\advance\MTr@level by 1% |
| 564 |
\@AfterFi{\MTr@parseleftbracket#2\END}% |
| 565 |
\fi% |
| 566 |
} |
| 567 |
% \end{macrocode} |
| 568 |
% \end{macro} |
| 569 |
% \begin{macro}{\Mtr@parsedot} |
| 570 |
% Parse the optional node argument. |
| 571 |
%^^A TODO: Maybe this can be done simpler by using "\futurelet" in some way. |
| 572 |
% \begin{macrocode} |
| 573 |
\def\MTr@parsedot#1.#2 #3\END{% |
| 574 |
\ifx:#2% |
| 575 |
\setbox\MTr@labelbox\hbox{\ignorespaces#1\unskip}% |
| 576 |
\else |
| 577 |
\ifx#2b\MTr@bottomnodetrue\else% |
| 578 |
\ifx#2x\MTr@bottomnodetrue\MTr@mytriangletrue\else% |
| 579 |
\ifx#2t\MTr@mytriangletrue\else% |
| 580 |
\typeout{synttree Warning: unknown dot option #2 in tree}% |
| 581 |
\fi\fi\fi% |
| 582 |
\MTr@parsedot#3\END |
| 583 |
\fi |
| 584 |
} |
| 585 |
% \end{macrocode} |
| 586 |
% \end{macro} |
| 587 |
% |
| 588 |
% \subsection{Action} |
| 589 |
% |
| 590 |
% The next macros implement the actions to be undertaken when encountering |
| 591 |
% one of the square brackets. |
| 592 |
% |
| 593 |
% \begin{macro}{\MTr@doleftbracket} |
| 594 |
% Upon encountering a "[", we go one level deeper: Begin a group, and reset |
| 595 |
% parameters. |
| 596 |
% \begin{macrocode} |
| 597 |
\def\MTr@doleftbracket{% |
| 598 |
\bgroup% |
| 599 |
\MTr@numchildren=0% |
| 600 |
\MTr@uselabeltrue% |
| 601 |
} |
| 602 |
% \end{macrocode} |
| 603 |
% \end{macro} |
| 604 |
% |
| 605 |
% \begin{macro}{\MTr@dorightbracket} |
| 606 |
% Upon encountering a "]", we typeset the current group's tree, and end the |
| 607 |
% group. Until we encounter some brackets, we should not add tokens to any |
| 608 |
% label. Save the just-typeset tree as the newest child in the parent group |
| 609 |
% --- now the current group. |
| 610 |
% ^^A TODO: Put this back into parserightbracket. |
| 611 |
% \begin{macrocode} |
| 612 |
\def\MTr@dorightbracket{% |
| 613 |
\MTr@maketreebox% |
| 614 |
\egroup% |
| 615 |
\MTr@uselabelfalse% |
| 616 |
\MTr@savecurrentchildbox% |
| 617 |
} |
| 618 |
% \end{macrocode} |
| 619 |
% \end{macro} |
| 620 |
% \begin{macro}{\MTr@savecurrentchildbox} |
| 621 |
% Save the current picture, with all its data, in the box and registers for |
| 622 |
% the next empty child. |
| 623 |
% \begin{macrocode} |
| 624 |
\def\MTr@savecurrentchildbox{% |
| 625 |
\advance\MTr@numchildren by 1 |
| 626 |
\ifnum\MTr@numchildren<1% |
| 627 |
\typeout{synttree internal warning: There is no child box to save.}% |
| 628 |
\else |
| 629 |
\ifnum\MTr@numchildren>10% |
| 630 |
\typeout{synttree warning: More than 10 child boxes. |
| 631 |
Can this be true?}% |
| 632 |
\fi |
| 633 |
\MTr@savechildbox{\romannumeral\MTr@numchildren}% |
| 634 |
\fi |
| 635 |
} |
| 636 |
% \end{macrocode} |
| 637 |
% \end{macro} |
| 638 |
% |
| 639 |
% \begin{macro}{\MTr@savechildbox} |
| 640 |
% Save current tree in a specific child box. Basically, we just copy from |
| 641 |
% the tree registers to the child registers, except $x$ is set to $v$ |
| 642 |
% initially. Used only in "\MTr@savecurrentchildbox". |
| 643 |
% \begin{macrocode} |
| 644 |
\def\MTr@savechildbox#1{% |
| 645 |
\expandafter |
| 646 |
\ifx\csname MTr@child#1box\endcsname\relax% |
| 647 |
\MTr@makechildstoreage{#1}% |
| 648 |
\fi% |
| 649 |
\setbox% |
| 650 |
\csname MTr@child#1box\endcsname% |
| 651 |
\hbox{\unhbox\MTr@treebox}% |
| 652 |
\csname MTr@child#1v\endcsname\MTr@treev% |
| 653 |
\csname MTr@child#1w\endcsname\MTr@treew% |
| 654 |
\csname MTr@child#1x\endcsname\MTr@treev% |
| 655 |
\csname MTr@child#1height\endcsname\MTr@treeheight% |
| 656 |
\csname MTr@child#1depth\endcsname\MTr@treedepth% |
| 657 |
\csname MTr@child#1branchmult\endcsname\MTr@branchmult% |
| 658 |
\ifMTr@triangle% |
| 659 |
\csname MTr@child#1triangle\endcsname 1% |
| 660 |
\else% |
| 661 |
\csname MTr@child#1triangle\endcsname 0% |
| 662 |
\fi |
| 663 |
} |
| 664 |
% \end{macrocode} |
| 665 |
% \end{macro} |
| 666 |
% |
| 667 |
% \subsection{Bottom Nodes} |
| 668 |
% |
| 669 |
% For bottom nodes, we have to adapt the vertical position so that |
| 670 |
% they become, indeed, bottom nodes. This is done by the macros |
| 671 |
% "\MTr@bottomnodetrue" and "\MTr@bottomnodefalse". |
| 672 |
% |
| 673 |
% \begin{macro}{\MTr@bottomnodetrue} |
| 674 |
% The node is a bottom node. Calculate the difference between this |
| 675 |
% level and the bottom level as passed to "\synttree", and use this to |
| 676 |
% determine how many levels the node has to be advanced vertically to |
| 677 |
% get it at the correct position. In effect, the distance between two |
| 678 |
% levels is multiplied by the ``branch multiplication.'' For |
| 679 |
% non-bottom nodes this is set to 1. |
| 680 |
% ^^A TODO: always check levels if a maxlevel has been specified. |
| 681 |
% \begin{macrocode} |
| 682 |
\def\MTr@bottomnodetrue{% |
| 683 |
\MTr@branchmult\MTr@maxlevel% |
| 684 |
\advance\MTr@branchmult-\MTr@level% |
| 685 |
\advance\MTr@branchmult 1% |
| 686 |
\ifnum\MTr@branchmult<1% |
| 687 |
\typeout{synttree Warning: Tree has more levels than indicated.}% |
| 688 |
\typeout{>> Indicated: \the\MTr@maxlevel.}% |
| 689 |
\typeout{>> Level now: \the\MTr@level.}% |
| 690 |
\MTr@branchmult1% |
| 691 |
\fi% |
| 692 |
\MTr@mybranchmult\MTr@branchmult% |
| 693 |
} |
| 694 |
% \end{macrocode} |
| 695 |
% \end{macro} |
| 696 |
% |
| 697 |
% \begin{macro}{\MTr@bottomnodefalse} |
| 698 |
% It's not a bottom node: Just set the branch multiplication to 1. |
| 699 |
% \begin{macrocode} |
| 700 |
\def\MTr@bottomnodefalse{% |
| 701 |
\MTr@mybranchmult1% |
| 702 |
} |
| 703 |
% \end{macrocode} |
| 704 |
% \end{macro} |
| 705 |
% |
| 706 |
% \subsection{Utility macros for the output routines} |
| 707 |
% |
| 708 |
% \begin{macro}{\MTr@setverticalchilddimens} |
| 709 |
% Set vertical dimensions for a given child: $y$ and "picheight". |
| 710 |
% ^^A TODO: Maybe we can set these while saving the child. |
| 711 |
% \begin{macrocode} |
| 712 |
\def\MTr@setverticalchilddimens#1{% |
| 713 |
\MTr@tempcnta-\MTr@branchheight% |
| 714 |
\multiply\MTr@tempcnta\MTr@childparam{#1}{branchmult}% |
| 715 |
\MTr@tempcntb-\MTr@tempcnta% |
| 716 |
\advance\MTr@tempcntb\csname MTr@child#1depth\endcsname% |
| 717 |
\advance\MTr@tempcnta-\MTr@labelheight% |
| 718 |
\advance\MTr@tempcnta\csname MTr@child#1height\endcsname% |
| 719 |
\csname MTr@child#1y\endcsname\MTr@tempcnta% |
| 720 |
\csname MTr@child#1picheight\endcsname\MTr@tempcntb% |
| 721 |
} |
| 722 |
% \end{macrocode} |
| 723 |
% \end{macro} |
| 724 |
% |
| 725 |
% \begin{macro}{\MTr@adjustdistance} |
| 726 |
% Adjust the distance between two children. For the pair of |
| 727 |
% neighboring children, "tempcnta" is used temporarily to store what |
| 728 |
% amounts to the distance between the central points of the two children |
| 729 |
% (the left child's $w$, plus the right child's $v$). |
| 730 |
% If it is below the value "childattachsep", adjust values so that is equal |
| 731 |
% to it. "tempcnta" stores the resulting value. |
| 732 |
% The right child's $x$ is now set to put it in the correct position |
| 733 |
% w.r.t.\ the left child. |
| 734 |
% \begin{macrocode} |
| 735 |
\def\MTr@adjustdistance#1#2{% |
| 736 |
\MTr@tempcnta\MTr@childparam{#1}{w}% |
| 737 |
\advance\MTr@tempcnta\MTr@childsidesep% |
| 738 |
\advance\MTr@tempcnta\csname MTr@child#2v\endcsname% |
| 739 |
\ifnum\MTr@tempcnta<\MTr@childattachsep% |
| 740 |
\MTr@tempcnta\MTr@childattachsep% |
| 741 |
\fi% |
| 742 |
\csname MTr@child#2x\endcsname\MTr@childparam{#1}{x}% |
| 743 |
\advance\csname MTr@child#2x\endcsname\MTr@tempcnta% |
| 744 |
} |
| 745 |
% \end{macrocode} |
| 746 |
% \end{macro} |
| 747 |
% \begin{macro}{\MTr@setparentdimens} |
| 748 |
% Set some parameters for the parent node. Parameters are the leftmost and |
| 749 |
% rightmost child label. |
| 750 |
% \begin{macrocode} |
| 751 |
\def\MTr@setparentdimens#1#2{% |
| 752 |
% \end{macrocode} |
| 753 |
% Calculate the subtree's $v$ and $w$: |
| 754 |
% \begin{macrocode} |
| 755 |
\MTr@tempcnta\MTr@childparam{#2}{x}% |
| 756 |
\advance \MTr@tempcnta -\MTr@childparam{#1}{x}% |
| 757 |
\divide\MTr@tempcnta 2% |
| 758 |
\MTr@treev\MTr@tempcnta% |
| 759 |
\MTr@treew\MTr@treev% |
| 760 |
\advance \MTr@treev \csname MTr@child#1x\endcsname% |
| 761 |
\advance \MTr@treew \csname MTr@child#2w\endcsname% |
| 762 |
% \end{macrocode} |
| 763 |
% Calculate "morex": The distance the (first) subtree has to be shifted to |
| 764 |
% the right to accomodate a large parent label size. |
| 765 |
% \begin{macrocode} |
| 766 |
\MTr@morex\MTr@labelhalfwidth% |
| 767 |
\advance\MTr@morex-\MTr@treev% |
| 768 |
\ifnum\MTr@morex<0\MTr@morex0\fi% |
| 769 |
% \end{macrocode} |
| 770 |
% Large label sizes are also incorporated into $w$ and $x$. |
| 771 |
% \begin{macrocode} |
| 772 |
\ifnum\MTr@treew<\MTr@labelhalfwidth |
| 773 |
\MTr@treew\MTr@labelhalfwidth |
| 774 |
\fi% |
| 775 |
\ifnum\MTr@treev<\MTr@labelhalfwidth |
| 776 |
\MTr@treev\MTr@labelhalfwidth |
| 777 |
\fi% |
| 778 |
% \end{macrocode} |
| 779 |
% Picture width. |
| 780 |
% \begin{macrocode} |
| 781 |
\MTr@picwidth\MTr@treev% |
| 782 |
\advance\MTr@picwidth\MTr@treew% |
| 783 |
} |
| 784 |
% \end{macrocode} |
| 785 |
% \end{macro} |
| 786 |
% \begin{macro}{\MTr@setpictureparameters} |
| 787 |
% Set some parameters for the picture. |
| 788 |
% \begin{macrocode} |
| 789 |
\def\MTr@setpictureparameters{% |
| 790 |
\global\MTr@treedepth\MTr@picheight% |
| 791 |
\advance\MTr@picheight\MTr@labelheight% |
| 792 |
\global\MTr@treeheight\MTr@labelheight% |
| 793 |
\MTr@parenty-\MTr@labelheight% |
| 794 |
\advance\MTr@parenty-\MTr@labeldepth% |
| 795 |
\advance\MTr@parenty-\MTr@lineoffset% |
| 796 |
\global\MTr@treev\MTr@treev% |
| 797 |
\global\MTr@treew\MTr@treew% |
| 798 |
} |
| 799 |
% \end{macrocode} |
| 800 |
% \end{macro} |
| 801 |
% \begin{macro}{\MTr@drawlabel} |
| 802 |
% \begin{macrocode} |
| 803 |
\def\MTr@drawlabel{% |
| 804 |
\put(\MTr@treev,0){% |
| 805 |
\makebox(0,0)[t]{% |
| 806 |
\rule{0pt}{\MTr@minheight}% |
| 807 |
\usebox{\MTr@labelbox}}}% |
| 808 |
} |
| 809 |
% \end{macrocode} |
| 810 |
% \end{macro} |
| 811 |
% \begin{macro}{\MTr@drawchild} |
| 812 |
% Draws the saved child node's picture. |
| 813 |
% \begin{macrocode} |
| 814 |
\def\MTr@drawchild#1{% |
| 815 |
\MTr@tempcnta\MTr@childparam{#1}{x} |
| 816 |
\advance\MTr@tempcnta-\MTr@childparam{#1}{v} |
| 817 |
\put(\MTr@tempcnta,\MTr@childparam{#1}{y}){% |
| 818 |
\makebox(0,0)[tl]{% |
| 819 |
\usebox{\csname MTr@child#1box\endcsname}}}% |
| 820 |
} |
| 821 |
% \end{macrocode} |
| 822 |
% \end{macro} |
| 823 |
% \begin{macro}{\MTr@drawchildline} |
| 824 |
% Draws the line or triangle from the parent to the given child. |
| 825 |
% \begin{macrocode} |
| 826 |
\def\MTr@drawchildline#1{ |
| 827 |
% \end{macrocode} |
| 828 |
% Use child's $y$, but advance it to make the line stop just above the |
| 829 |
% label. |
| 830 |
% \begin{macrocode} |
| 831 |
\MTr@tempcnta\MTr@childparam{#1}{y} |
| 832 |
\advance\MTr@tempcnta\MTr@lineoffset% |
| 833 |
\expandafter |
| 834 |
\ifnum\csname MTr@child#1triangle\endcsname=1% |
| 835 |
\MTr@drawchildlinetriangle{#1}% |
| 836 |
\else% |
| 837 |
\MTr@drawchildlineline{#1}% |
| 838 |
\fi% |
| 839 |
} |
| 840 |
\def\MTr@drawchildlineline#1{% |
| 841 |
\put(0,0){\MTr@drawline% |
| 842 |
(\MTr@treev,\MTr@parenty)% |
| 843 |
(\MTr@childparam{#1}{x},\MTr@tempcnta)}% |
| 844 |
} |
| 845 |
\def\MTr@drawchildlinetriangle#1{% |
| 846 |
\MTr@tempcntb\MTr@childparam{#1}{x}% |
| 847 |
\MTr@tempcntc\MTr@tempcntb% |
| 848 |
\advance\MTr@tempcntb \MTr@childparam{#1}{w}% |
| 849 |
\advance\MTr@tempcntc -\MTr@childparam{#1}{v}% |
| 850 |
\put(0,0){\MTr@drawline% |
| 851 |
(\MTr@treev,\MTr@parenty)% |
| 852 |
(\MTr@tempcntc,\MTr@tempcnta)}% |
| 853 |
\put(0,0){\MTr@drawline% |
| 854 |
(\MTr@treev,\MTr@parenty)% |
| 855 |
(\MTr@tempcntb,\MTr@tempcnta)}% |
| 856 |
\put(0,0){\MTr@drawline% |
| 857 |
(\MTr@tempcntc,\MTr@tempcnta)% |
| 858 |
(\MTr@tempcntb,\MTr@tempcnta)}% |
| 859 |
} |
| 860 |
% \end{macrocode} |
| 861 |
% \end{macro} |
| 862 |
% |
| 863 |
% \subsection{Output routines} |
| 864 |
% |
| 865 |
% \begin{macro}{\MTr@maketreebox} |
| 866 |
% This is the main macro that starts the output. |
| 867 |
% ^^A TODO: Maybe move \global\setbox\MTr@treebox out of the \ifnum s |
| 868 |
% \begin{macrocode} |
| 869 |
\def\MTr@maketreebox{% |
| 870 |
\MTr@labelheight\ht\MTr@labelbox% |
| 871 |
\ifnum\MTr@labelheight<\MTr@minheight\MTr@labelheight\MTr@minheight\fi%% |
| 872 |
\MTr@labeldepth\dp\MTr@labelbox% |
| 873 |
\MTr@labelhalfwidth\wd\MTr@labelbox% |
| 874 |
\divide\MTr@labelhalfwidth 2% |
| 875 |
\ifnum\MTr@numchildren=0% |
| 876 |
\global\setbox\MTr@treebox\hbox{\MTr@outputlabel}% |
| 877 |
\fi% |
| 878 |
\ifnum\MTr@numchildren>0% |
| 879 |
\global\setbox\MTr@treebox\hbox{\MTr@outputchildren{\the\MTr@numchildren}}% |
| 880 |
\fi% |
| 881 |
\global\MTr@branchmult\MTr@mybranchmult% |
| 882 |
\ifMTr@mytriangle% |
| 883 |
\global\MTr@triangletrue% |
| 884 |
\else% |
| 885 |
\global\MTr@trianglefalse% |
| 886 |
\fi% |
| 887 |
} |
| 888 |
% \end{macrocode} |
| 889 |
% \end{macro} |
| 890 |
% \begin{macro}{\MTr@outputlabel} |
| 891 |
% Output a tree that is just a label, with no children. |
| 892 |
% \begin{macrocode} |
| 893 |
\def\MTr@outputlabel{% |
| 894 |
% \end{macrocode} |
| 895 |
% First, set parameters: Height and depth of the subtree are equal to |
| 896 |
% height and depth of the label. The $x$ and $w$ of the subtree each equal |
| 897 |
% half the width of the label. Optionally, $x$ may be zero and $w$ may |
| 898 |
% equal to the entire width of the label. The width and height of the |
| 899 |
% picture to be drawn equal the width of the label and the height of the |
| 900 |
% tree. |
| 901 |
% \begin{macrocode} |
| 902 |
\global\MTr@treeheight\MTr@labelheight% |
| 903 |
\global\MTr@treedepth\MTr@labeldepth% |
| 904 |
\ifMTr@mytriangle% |
| 905 |
\MTr@treew\MTr@labelhalfwidth% |
| 906 |
\MTr@treev\MTr@labelhalfwidth% |
| 907 |
\multiply\MTr@treew \MTr@trianglemultright% |
| 908 |
\multiply\MTr@treev \MTr@trianglemultleft% |
| 909 |
\divide\MTr@treew 50% |
| 910 |
\divide\MTr@treev 50% |
| 911 |
\global\MTr@treew\MTr@treew% |
| 912 |
\global\MTr@treev\MTr@treev% |
| 913 |
\else% |
| 914 |
\global\MTr@treew\MTr@labelhalfwidth% |
| 915 |
\global\MTr@treev\MTr@labelhalfwidth% |
| 916 |
\fi% |
| 917 |
\MTr@picwidth\wd\MTr@labelbox% |
| 918 |
\MTr@picheight\MTr@treeheight% |
| 919 |
% \end{macrocode} |
| 920 |
% Second, draw the picture. The coordinates for the picture are nearly |
| 921 |
% the same throughout. In any event, the label is centered in the |
| 922 |
% picture, its baseline aligned with the bottom of the picture. |
| 923 |
% \begin{macrocode} |
| 924 |
\advance\MTr@picheight\MTr@treedepth% |
| 925 |
\begin{picture}% |
| 926 |
(\MTr@picwidth,\MTr@picheight)% |
| 927 |
(-\MTr@treev,-\MTr@picheight)% |
| 928 |
%\put(-\MTr@treev,-\MTr@picheight){\framebox(\MTr@picwidth,\MTr@picheight){}}% |
| 929 |
\put(-\MTr@treev,0){% |
| 930 |
\makebox(0,0)[tl]{% |
| 931 |
\rule{0pt}{\MTr@minheight}% |
| 932 |
\usebox{\MTr@labelbox}}}% |
| 933 |
\end{picture}% |
| 934 |
} |
| 935 |
% \end{macrocode} |
| 936 |
% \end{macro} |
| 937 |
% |
| 938 |
% \begin{macro}{\MTr@outputchildren} |
| 939 |
% Output a tree or subtree with at least one child tree. |
| 940 |
% \begin{macrocode} |
| 941 |
\def\MTr@outputchildren#1{% |
| 942 |
% \end{macrocode} |
| 943 |
% Calculate desired distance between the children. |
| 944 |
% The cumulative value is put into "treev". |
| 945 |
% \begin{macrocode} |
| 946 |
\ifnum#1>1 |
| 947 |
\MTr@loopcnta 1 |
| 948 |
\loop |
| 949 |
\edef\MTr@temp{\romannumeral\MTr@loopcnta}% |
| 950 |
\ifnum\MTr@loopcnta<#1 |
| 951 |
\advance \MTr@loopcnta by 1 |
| 952 |
\MTr@adjustdistance{\MTr@temp}{\romannumeral\MTr@loopcnta}% |
| 953 |
\repeat |
| 954 |
\fi |
| 955 |
% \end{macrocode} |
| 956 |
% Calculate the subtree's $v$ and $w$, based on the children, and the |
| 957 |
% label's width. |
| 958 |
% \begin{macrocode} |
| 959 |
\MTr@setparentdimens{i}{\romannumeral#1}% |
| 960 |
% \end{macrocode} |
| 961 |
% After the call to "setparentdimens", all children's $x$ |
| 962 |
% values must be advanced by "morex". In the same loop, also |
| 963 |
% set vertical position and picture height for each child. |
| 964 |
% The height of the picture is the height of the largest child. |
| 965 |
% \begin{macrocode} |
| 966 |
\MTr@picheight 0% |
| 967 |
\MTr@loopcnta #1 |
| 968 |
\loop |
| 969 |
\edef\MTr@temp{\romannumeral\MTr@loopcnta}% |
| 970 |
\advance\MTr@childparam{\MTr@temp}{x}\MTr@morex% |
| 971 |
\MTr@setverticalchilddimens{\romannumeral\MTr@loopcnta}% |
| 972 |
\ifnum\MTr@childparam{\MTr@temp}{picheight}>\MTr@picheight% |
| 973 |
\MTr@picheight\MTr@childparam{\MTr@temp}{picheight}% |
| 974 |
\fi% |
| 975 |
\advance \MTr@loopcnta by -1 \ifnum\MTr@loopcnta>0 \repeat |
| 976 |
% \end{macrocode} |
| 977 |
% Set various other parameters. |
| 978 |
% \begin{macrocode} |
| 979 |
\MTr@setpictureparameters% |
| 980 |
% \end{macrocode} |
| 981 |
% Start the picture and draw the label. Next, draw each child, and the line |
| 982 |
% to that child. Then, end the picture. |
| 983 |
% \begin{macrocode} |
| 984 |
\begin{picture}(\MTr@picwidth,\MTr@picheight)(0,-\MTr@picheight)% |
| 985 |
%\put(0,-\MTr@picheight){\framebox(\MTr@picwidth,\MTr@picheight){}}% |
| 986 |
\MTr@drawlabel% |
| 987 |
\MTr@loopcnta #1 |
| 988 |
\loop |
| 989 |
\expandafter\MTr@drawchild{\romannumeral\MTr@loopcnta}% |
| 990 |
\expandafter\MTr@drawchildline{\romannumeral\MTr@loopcnta} |
| 991 |
\advance \MTr@loopcnta by -1 \ifnum\MTr@loopcnta>0 \repeat |
| 992 |
\end{picture}% |
| 993 |
} |
| 994 |
% \end{macrocode} |
| 995 |
% \end{macro} |
| 996 |
% |
| 997 |
% \Finale |
| 998 |
% \PrintIndex \PrintChanges |
| 999 |
\endinput |