summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/synttree
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-07-21 23:47:43 +0000
committerKarl Berry <karl@freefriends.org>2006-07-21 23:47:43 +0000
commitc3ea4d2926cc433f86635f1d9d122be96311c55f (patch)
tree03180fca9c5e6288c81b7c2bbd4dcea80c7eb0ab /Master/texmf-dist/source/latex/synttree
parent51e3a37989b9f2ace36eb360c42fee6dcff11458 (diff)
synttree update (20jul06)
git-svn-id: svn://tug.org/texlive/trunk@1891 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/synttree')
-rw-r--r--Master/texmf-dist/source/latex/synttree/synttree.dtx489
1 files changed, 232 insertions, 257 deletions
diff --git a/Master/texmf-dist/source/latex/synttree/synttree.dtx b/Master/texmf-dist/source/latex/synttree/synttree.dtx
index 523a57ad0e0..71d4908ddec 100644
--- a/Master/texmf-dist/source/latex/synttree/synttree.dtx
+++ b/Master/texmf-dist/source/latex/synttree/synttree.dtx
@@ -1,8 +1,8 @@
-%% \CheckSum{806}
+%% \CheckSum{747}
% \iffalse meta-comment
%% synttree.dtx
%% Package `synttree' for use with LaTeX 2e
-%% Version 1.3.1
+%% Version 1.4.1
%
% See the section "Author and License" below for copyright and licensing
% information
@@ -36,6 +36,12 @@
% 1.2 2001 Totally new system
% 1.3 2004/11/07 New system up and running.
% 1.3.1 2004/11/07 Prepared for packaging, clarified licensing.
+% 2004/12/30 Ignore leading and trailing spaces in labels.
+% 2005/04/13 Allow up to 10 children (or any number, in theory).
+% 1.4 2005/05/01 Allow any number of children, just warn.
+% Updated documentation.
+% 1.4.1 2006/07/20 Remove spurious spaces in output.
+% Simplify label typesetting.
%
%<*driver>
\documentclass[a4paper]{ltxdoc}
@@ -44,7 +50,7 @@
%\DisableCrossrefs % Say \DisableCrossrefs if index is ready
\CodelineIndex
\RecordChanges % Gather update information
- \OnlyDescription % comment out for implementation details
+ %\OnlyDescription % comment out for implementation details
\OldMakeindex % use if your MakeIndex is pre-v2.9
\setlength\hfuzz{15pt} % dont make so many
\hbadness=7000 % over and under full box warnings
@@ -56,7 +62,7 @@
%\fi
%\MakeShortVerb{\"}
% \title{The "synttree" package for typesetting syntactic
-% trees.\footnote{Package version 1.3.1}}
+% trees.\footnote{Package version 1.4.1}}
% \author{Matijs van Zuijlen\footnote{e-mail: \texttt{mvz@xs4all}; web:
% \texttt{http://www.matijs.net/}}}
%
@@ -75,27 +81,29 @@
%
% The "synttree" package provides a macro for creating syntactic tree
% structures such as those used in Noam Chomsky's Generative Grammar.
-% It is designed to create a tree that looks nice, with as little use
-% of `special effects', such as PostScript, as possible.
-%
-% The current implementation can use either em\TeX{} "\special"'s or
-% \LaTeXe{}'s "\qbezier" macro to draw the lines in the tree,
-% although the latter option is probably not very nice. The behavior
-% defaults to the \LaTeXe{} version.
+% It is designed to create a tree that looks nice, without manual
+% tweaking, and with as little use of `special effects', such as
+% PostScript, as possible.
%
% Since the application is very specific, there is no need for a very
-% complex drawing algorithm. A more complex package is the TreeTeX
-% system \cite{TreeTeX}. This system, however, produces nodes
-% consisting of a node symbol \emph{and} a label, whereas in
-% syntactic trees the label \emph{is} the node symbol. Additionally,
-% the method of specifying the tree structure itself makes the source
-% code hard to read.
+% complex set of options: "synttree" is designed to do one thing, and do
+% it well.
+%
+% Using "synttree", you can create trees of any depth, and an unlimited
+% number of branches (up to the memory limit of your version of \TeX, of
+% course).
%
% \section{Usage}
%
-% \subsection{Package Options}
+% \subsection{Drawing Options}
%
-% The following options are supported:
+% The current implementation can use either em\TeX{} "\special"'s or
+% \LaTeXe{}'s "\qbezier" macro to draw the lines in the tree,
+% although the latter option is probably technically not very nice. Still,
+% the behavior defaults to the \LaTeXe{} version.
+%
+% In order to switch between the two modes, the following options are
+% supported:
%
% \begin{description}
%
@@ -107,74 +115,124 @@
%
% \subsection{Defined Macros}
%
+% \DescribeMacro{\synttree}
% The main macro defined by this package is the "\synttree" macro. It
% takes as arguments first an optional parameter indicating the
-% maximum level of the tree, and second a parameter describing the
-% structure of the tree. Levels are surrounded by "[" and "]".
+% maximum depth of the tree, and second a parameter describing the
+% structure of the tree, delimited by square brackets ("[" and "]").
+%
+% A tree consists of the parent node's label, followed by the child trees.
+% In principle, an unlimited number of children can be specified, but
+% to signal runaway trees, a warning will be issued when the number is
+% more than ten.
+% Each of the child trees is again surrounded by square brackets.
+% For example, the line
+%\begin{verbatim}
+%\synttree[A[B][C]]
+%\end{verbatim}
+% creates the following tree:
+% \begin{trivlist}
+% \item \synttree[A[B][C]]
+% \end{trivlist}
%
-% Within a level, first, parameters may be added. These are specified
-% by appending a "." to the opening bracket, and appending letters
-% that modify the appearance of the next level. Append a "t" to
+% Note that leading and trailing spaces in the label will be ignored, so
+% the following has the same result:
+%\begin{verbatim}
+%\synttree[ A [ B ][ C ]]
+%\end{verbatim}
+%^^A Nodes and subtrees are surrounded by square
+%^^A brackets ("[" and "]"), as is the entire tree.
+%
+% Before the label, a parameter may be added. This is specified
+% by appending a period (".") to the opening bracket, and appending a letter
+% that modifies the appearance of the tree. Append a "t" to
% create a triangle instead of a line going from the label to the
% level above it, and a "b" to specify that the node has to appear at
-% the bottom of the tree, on a line with the outermost branches. To
+% the bottom of the tree, on a line with the lowest leaves. To
% use "b", a maximum tree depth has to be specified. To combine the
% two features, use "x".
%
-% Then, the label follows. If spaces are included in the label, surround
-% them (or the entire label) by braces, or use "~". After the label, the
-% node's children follow. They are of course surrounded by brackets. No
-% words may appear between the children.
-%
-% The distance between levels can be adjusted by using
-% "\branchheight". It takes a length as its argument, and sets the
-% distance to that length. Default is half an inch.
-%
-% The balancing of the triangles can be adjusted by using
-% "\trianglebalance". It takes a number from 0 to 100, indicating the
-% percentage of the triangle on the right side of its attachment point to
-% the parent.
-%
-% \subsection{Examples}
-%
-% As a simple example, the line
+% Using the optional parameters, the code
%\begin{verbatim}
-% \synttree[A[B][C]]
-%\end{verbatim}
-% creates the following tree:
+%\synttree{4}
+%[A
+% [B [.x Some text] ]
+% [D [E] [F[.t G]] [H] ]
+%]
+%\end{verbatim}%
+% creates this tree:
% \begin{trivlist}
-% \item \synttree[A[B][C]]
+% \item
+% \synttree{4}
+% [A
+% [B [.x Some text] ]
+% [D [E] [F[.t G]] [H] ]
+% ]
% \end{trivlist}
%
-% Using the optional parameters, we may specify
+% If brackets are included in the label, surround
+% them (or the entire label) by braces:
+%
%\begin{verbatim}
-% \synttree{4}[A[B[.x {Some text}]][D[E][F[.t G]][H]]]
-%\end{verbatim}%
-% to create:
+% \synttree[A[{B]D}][C]]
+%\end{verbatim}
% \begin{trivlist}
-% \item \synttree{4}[A[B[.x {Some text}]][D[E][F[.t G]][H]]]
+% \item \synttree[
+% A[{B]D}][C]]
% \end{trivlist}
%
+% The other defined macros affect the look and sizing of the trees.
+% The distance between levels can be adjusted by using
+% \DescribeMacro{\branchheight}
+% "\branchheight". It takes a length as its argument, and sets the
+% distance to that length. The default distance is half an inch. This
+% value is the distance between the baselines of the labels, so setting it
+% to zero will cause everything to be on one line.
+% The minimum horizontal separation between edges of two children is set
+% by
+% \DescribeMacro{\childsidesep}
+% "\childsidesep". The default is "1em".
+% The length
+% \DescribeMacro{\childattachsep}
+% "\childattachsep" indicates the minimum distance between the
+% attachment points of two children. Here, the default is "0.5in".
+% Finally, the balancing of the triangles can be adjusted by using
+% \DescribeMacro{\trianglebalance}
+% "\trianglebalance". It takes a number from 0 to 100, indicating the
+% percentage of the triangle on the right side of its attachment point to
+% the parent. The default is 50, resulting in isosceles triangles.
+%
% \section{Wish List and Bugs}
%
-% I hope to add the following features sooner or later:
-% \begin{itemize}
-% \item Larger number of children. The current limit is three.
-% \item Control over other parameters affecting the `look' of the tree.
-% \item The possibility of `sinking' the tree on the current line,
-% so that the top label aligns with the other text, instead of the
-% bottom label.
-% \item The possibility of creating trees within trees.
-% \item Let labels ignore starting and trailing whitespace.
-% \end{itemize}
-%
-% \section{Known Bugs}
-% Triangles on non-leaf nodes are not forbidden, but do not give the
-% desired result.
+% It is important to note that this package may not prevent you from doing
+% certain things `wrong'. For example, triangles on non-leaf nodes are
+% not forbidden, but may not give the desired result.
+%
+% Sometimes, the label of a parent may be a phrase, and it may be
+% desirable to attach the children to a particular element in that phrase
+% (e.g., to elaborate on the structure of that particular element). This
+% is currently not possible: The children are always attached to the
+% center of the label. Support for this may be added sooner or later.
+%
+% \section{Related Packages}
+% A more complex package is the TreeTeX
+% system\cite{TreeTeX}. This system, however, produces nodes
+% consisting of a node symbol \emph{and} a label, whereas in
+% syntactic trees the label \emph{is} the node symbol. Additionally,
+% the method of specifying the tree structure itself makes the source
+% code hard to read.
+%
+% The "xyling" package\cite{xyling} is a very powerful package, allowing
+% many things that "synttree" will not do. However, the nodes have to be
+% laid out meticulously in an array. Once that's done, however, the result
+% looks very good.
+%
+% The ``\LaTeX\ for Linguists'' website\cite{LfL} lists other tree-drawing
+% packages, with comments on their usefulness.
%
% \section{Author and License}
%
-% Copyright (c) 1998, 1999, 2001, 2004 Matijs van Zuijlen.
+% Copyright (c) 1998, 1999, 2001, 2004--2006 Matijs van Zuijlen.
%
% The "synttree" package is free software. It has been released under the
% terms of the Latex Project Public License, version 1.3a.
@@ -185,18 +243,24 @@
%
% \StopEventually{
% \begin{thebibliography}{1}
+% \bibitem{LfL} Doug Arnold
+% \newblock {\it \LaTeX\ for Linguists} \\
+% \newblock {At \texttt{http://www.essex.ac.uk/linguistics/clmt/latex4ling/}}
% \bibitem{TreeTeX} A. Br{\"u}ggemann-Klein and D. Wood.
% \newblock {\it Drawing trees nicely with \TeX{}}
-% \newblock {File \texttt{tree\_doc.tex}}
+% \newblock {File \texttt{tree\_doc.tex} in the "treetex" package}
% \bibitem{BasicControl} Jonathan Fine.
% \newblock {\it Some Basic Control Macros for \TeX{}}
% \newblock {TUGboat, Volume 13 (1992), No. 1}
+% \bibitem{xyling} Ralf Vogel
+% \newblock {\it xyling --- \LaTeX\ macros for linguistic graphics} \\
+% \newblock {At \texttt{http://www.ling.uni-potsdam.de/~rvogel/xyling/}}
% \end{thebibliography}
% }
%
% \section{Implementation}
%
-% \subsection{Two utility macros}
+% \subsection{Utility macros}
%
% Very useful for putting stuff after a "\fi" (as the name implies)
% \cite{BasicControl}.
@@ -297,30 +361,23 @@
% "branchmult" indicates how many levels below the parent the child should
% be typeset.
% \begin{macrocode}
-\def\MTr@makechildcounter#1{
+\def\MTr@makechildcounter#1{%
\expandafter\newcount\csname MTr@child#1\endcsname%
}
-\def\MTr@makechildstoreage#1{
+\def\MTr@makechildstoreage#1{%
\expandafter\newsavebox\csname MTr@child#1box\endcsname%
- \MTr@makechildcounter{#1x}
- \MTr@makechildcounter{#1y}
- \MTr@makechildcounter{#1v}
- \MTr@makechildcounter{#1w}
- \MTr@makechildcounter{#1height}
- \MTr@makechildcounter{#1depth}
- \MTr@makechildcounter{#1branchmult}
- \expandafter\newcount\csname MTr@pic#1height\endcsname
- \expandafter\newif\csname ifMTr@child#1triangle\endcsname%
+ \MTr@makechildcounter{#1x}%
+ \MTr@makechildcounter{#1y}%
+ \MTr@makechildcounter{#1v}%
+ \MTr@makechildcounter{#1w}%
+ \MTr@makechildcounter{#1height}%
+ \MTr@makechildcounter{#1depth}%
+ \MTr@makechildcounter{#1branchmult}%
+ \MTr@makechildcounter{#1picheight}%
+ \MTr@makechildcounter{#1triangle}%
}
% \end{macrocode}
%
-% For now, we make three children:
-% \begin{macrocode}
-\MTr@makechildstoreage{i}
-\MTr@makechildstoreage{ii}
-\MTr@makechildstoreage{iii}
-% \end{macrocode}
-%
% \begin{macro}{\MTr@childparam}
% We also need an easy way to retrieve each child's parameters. This way,
% we don't have to use the "\csname" construct all the time.
@@ -356,17 +413,19 @@
\newcount\MTr@picwidth
\newcount\MTr@picheight
% \end{macrocode}
-% Finally, we need a temporary length, and three temporary counters.
+% Finally, we need a temporary length, and four temporary counters.
% \begin{macrocode}
\newlength{\MTr@templength}
+\newcount\MTr@loopcnta
\newcount\MTr@tempcnta
\newcount\MTr@tempcntb
\newcount\MTr@tempcntc
% \end{macrocode}
%
% \subsection{Adjustable and other parameters}
+% \begin{macro}{\branchheight}
% The user can set up several parameters.
-% First,\begin{macro}{\branchheight} "\branchheight" will set the distance
+% First, "\branchheight" will set the distance
% between levels. Default value is half an inch.
% ^^A TODO: let default value depend on font size.
% \begin{macrocode}
@@ -459,7 +518,7 @@
% \end{macro}
%
% \subsection{Parsing}
-% \iffalse[[[\fi
+% \iffalse[[[\fi^^A Brackets needed for bracket balancing in text editor
%
% Parsing will only work if at least one "]" is present.
% \begin{macro}{\MTr@parserightbracket}
@@ -474,7 +533,7 @@
\advance\MTr@level by -1%
\MTr@dorightbracket%
\ifnum\MTr@level=0%
- \unhbox\MTr@childibox%
+ \unhbox\MTr@childibox{}%
\else
\@AfterFi{\MTr@parserightbracket}%
\fi%
@@ -496,8 +555,8 @@
\MTr@mytrianglefalse%
\MTr@parsedot#1.: \END%
\fi%
- \ifx:#2
- \else
+ \ifx:#2%
+ \else%
\MTr@doleftbracket%
\advance\MTr@level by 1%
\@AfterFi{\MTr@parseleftbracket#2\END}%
@@ -506,10 +565,12 @@
% \end{macrocode}
% \end{macro}
% \begin{macro}{\Mtr@parsedot}
+% Parse the optional node argument.
+%^^A TODO: Maybe this can be done simpler by using "\futurelet" in some way.
% \begin{macrocode}
-\def\MTr@parsedot#1.#2 #3\END{
- \ifx:#2
- \setbox\MTr@labelbox\hbox{#1}
+\def\MTr@parsedot#1.#2 #3\END{%
+ \ifx:#2%
+ \setbox\MTr@labelbox\hbox{\ignorespaces#1\unskip}%
\else
\ifx#2b\MTr@bottomnodetrue\else%
\ifx#2x\MTr@bottomnodetrue\MTr@mytriangletrue\else%
@@ -556,25 +617,36 @@
% \end{macro}
% \begin{macro}{\MTr@savecurrentchildbox}
% Save the current picture, with all its data, in the box and registers for
-% the next empty child. Basically, we just copy from the tree registers to
-% the child registers, except $x$ is set to $v$ initially.
+% the next empty child.
% \begin{macrocode}
\def\MTr@savecurrentchildbox{%
\advance\MTr@numchildren by 1
\ifnum\MTr@numchildren<1%
- \typeout{There is no child box to save.}%
+ \typeout{synttree internal warning: There is no child box to save.}%
\else
- \ifnum\MTr@numchildren>3%
- \typeout{I can save at most three child boxes.}%
- \else
- \MTr@savechildbox{\romannumeral\MTr@numchildren}%
+ \ifnum\MTr@numchildren>10%
+ \typeout{synttree warning: More than 10 child boxes.
+ Can this be true?}%
\fi
+ \MTr@savechildbox{\romannumeral\MTr@numchildren}%
\fi
}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MTr@savechildbox}
+% Save current tree in a specific child box. Basically, we just copy from
+% the tree registers to the child registers, except $x$ is set to $v$
+% initially. Used only in "\MTr@savecurrentchildbox".
+% \begin{macrocode}
\def\MTr@savechildbox#1{%
+ \expandafter
+ \ifx\csname MTr@child#1box\endcsname\relax%
+ \MTr@makechildstoreage{#1}%
+ \fi%
\setbox%
- \csname MTr@child#1box\endcsname%
- \hbox{\unhbox\MTr@treebox}%
+ \csname MTr@child#1box\endcsname%
+ \hbox{\unhbox\MTr@treebox}%
\csname MTr@child#1v\endcsname\MTr@treev%
\csname MTr@child#1w\endcsname\MTr@treew%
\csname MTr@child#1x\endcsname\MTr@treev%
@@ -582,9 +654,9 @@
\csname MTr@child#1depth\endcsname\MTr@treedepth%
\csname MTr@child#1branchmult\endcsname\MTr@branchmult%
\ifMTr@triangle%
- \csname MTr@child#1triangletrue\endcsname%
+ \csname MTr@child#1triangle\endcsname 1%
\else%
- \csname MTr@child#1trianglefalse\endcsname%
+ \csname MTr@child#1triangle\endcsname 0%
\fi
}
% \end{macrocode}
@@ -599,17 +671,6 @@
% \begin{macro}{\MTr@bottomnodetrue}
% The node is a bottom node. Calculate the difference between this
% level and the bottom level as passed to "\synttree", and use this to
-% \begin{macro}{\MTr@drawchild}
-% \begin{macrocode}
-\def\MTr@drawchild#1{%
- \MTr@tempcnta\MTr@childparam{#1}{x}
- \advance\MTr@tempcnta-\MTr@childparam{#1}{v}
- \put(\MTr@tempcnta,\MTr@childparam{#1}{y}){%
- \makebox(0,0)[tl]{%
- \usebox{\csname MTr@child#1box\endcsname}}}%
-}
-% \end{macrocode}
-% \end{macro}
% determine how many levels the node has to be advanced vertically to
% get it at the correct position. In effect, the distance between two
% levels is multiplied by the ``branch multiplication.'' For
@@ -654,7 +715,7 @@
\advance\MTr@tempcnta-\MTr@labelheight%
\advance\MTr@tempcnta\csname MTr@child#1height\endcsname%
\csname MTr@child#1y\endcsname\MTr@tempcnta%
- \csname MTr@pic#1height\endcsname\MTr@tempcntb%
+ \csname MTr@child#1picheight\endcsname\MTr@tempcntb%
}
% \end{macrocode}
% \end{macro}
@@ -762,11 +823,13 @@
% \begin{macrocode}
\def\MTr@drawchildline#1{
% \end{macrocode}
-% Advance child's $y$ to make the line stop just above the label.
+% Use child's $y$, but advance it to make the line stop just above the
+% label.
% \begin{macrocode}
\MTr@tempcnta\MTr@childparam{#1}{y}
\advance\MTr@tempcnta\MTr@lineoffset%
- \csname ifMTr@child#1triangle\endcsname%
+ \expandafter
+ \ifnum\csname MTr@child#1triangle\endcsname=1%
\MTr@tempcntb\MTr@childparam{#1}{x}%
\MTr@tempcntc\MTr@tempcntb%
\advance\MTr@tempcntb \MTr@childparam{#1}{w}%
@@ -802,17 +865,11 @@
\MTr@labelhalfwidth\wd\MTr@labelbox%
\divide\MTr@labelhalfwidth 2%
\ifnum\MTr@numchildren=0%
- \global\setbox\MTr@treebox\hbox{\MTr@outputlabel}
- \fi
- \ifnum\MTr@numchildren=1%
- \global\setbox\MTr@treebox\hbox{\MTr@outputonechild}
- \fi
- \ifnum\MTr@numchildren=2%
- \global\setbox\MTr@treebox\hbox{\MTr@outputtwochildren}
- \fi
- \ifnum\MTr@numchildren=3%
- \global\setbox\MTr@treebox\hbox{\MTr@outputthreechildren}
- \fi
+ \global\setbox\MTr@treebox\hbox{\MTr@outputlabel}%
+ \fi%
+ \ifnum\MTr@numchildren>0%
+ \global\setbox\MTr@treebox\hbox{\MTr@outputchildren{\the\MTr@numchildren}}%
+ \fi%
\global\MTr@branchmult\MTr@mybranchmult%
\ifMTr@mytriangle%
\global\MTr@triangletrue%
@@ -823,7 +880,7 @@
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MTr@outputlabel}
-% Output just the label.
+% Output a tree that is just a label, with no children.
% \begin{macrocode}
\def\MTr@outputlabel{%
% \end{macrocode}
@@ -869,144 +926,62 @@
}
% \end{macrocode}
% \end{macro}
-% \begin{macro}{\MTr@outputonechild}
-% Output label and one child.
-% \begin{macrocode}
-\def\MTr@outputonechild{%
-% \end{macrocode}
-% Calculate the subtree's $v$ and $w$, based on the single child, and the
-% label's width. After the call to "setparentdimens", all children's $x$
-% values must be advanced by "morex"
-% \begin{macrocode}
- \MTr@setparentdimens{i}{i}%
- \advance\MTr@childix\MTr@morex%
-% \end{macrocode}
-% Set vertical position and picture height for child one
-% \begin{macrocode}
- \MTr@setverticalchilddimens{i}%
-% \end{macrocode}
-% Set height based on child one.
-% \begin{macrocode}
- \MTr@picheight\MTr@piciheight%
-% \end{macrocode}
-% Set various other parameters.
-% \begin{macrocode}
- \MTr@setpictureparameters%
-% \end{macrocode}
-% Start the picture, draw the label, the single child, and the line to the
-% child, and end the picture.
-% \begin{macrocode}
- \begin{picture}%
- (\MTr@picwidth,\MTr@picheight)%
- (0,-\MTr@picheight)%
- %\put(0,-\MTr@picheight){\framebox(\MTr@picwidth,\MTr@picheight){}}%
- \MTr@drawlabel%
- \MTr@drawchild{i}%
- \MTr@drawchildline{i}
- \end{picture}%
-}
-% \end{macrocode}
-% \end{macro}
%
-% \begin{macro}{\MTr@outputtwochildren}
-% Two children.
-% \begin{macrocode}
-\def\MTr@outputtwochildren{%
-% \end{macrocode}
-% Calculate desired distance between the two children.
-% "treev" is used to store the resulting value. Next, set paramaters for
-% the parent label.
-% \begin{macrocode}
- \MTr@adjustdistance{i}{ii}%
- \MTr@setparentdimens{i}{ii}%
-% \end{macrocode}
-% Adjust children's $x$ to include "morex",
-% \begin{macrocode}
- \advance\MTr@childix\MTr@morex%
- \advance\MTr@childiix\MTr@morex%
-% \end{macrocode}
-% Set vertical position and picture height for child one and two
-% \begin{macrocode}
- \MTr@setverticalchilddimens{i}%
- \MTr@setverticalchilddimens{ii}%
-% \end{macrocode}
-% Compare height based on child one with that based on child two.
-% \begin{macrocode}
- \ifnum\MTr@piciheight>\MTr@piciiheight%
- \MTr@picheight\MTr@piciheight%
- \else%
- \MTr@picheight\MTr@piciiheight%
- \fi%
-% \end{macrocode}
-% Set various other parameters.
+% \begin{macro}{\MTr@outputchildren}
+% Output a tree or subtree with at least one child tree.
% \begin{macrocode}
- \MTr@setpictureparameters%
+\def\MTr@outputchildren#1{%
% \end{macrocode}
-% Start the picture, draw the label, the children, and the lines to the
-% children, and end the picture.
+% Calculate desired distance between the children.
+% The cumulative value is put into "treev".
% \begin{macrocode}
- \begin{picture}(\MTr@picwidth,\MTr@picheight)(0,-\MTr@picheight)%
- %\put(0,-\MTr@picheight){\framebox(\MTr@picwidth,\MTr@picheight){}}%
- \MTr@drawlabel%
- \MTr@drawchild{i}
- \MTr@drawchild{ii}
- \MTr@drawchildline{i}
- \MTr@drawchildline{ii}
- \end{picture}%
-}
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\MTr@outputthreechildren}
-% Three children.
-% \begin{macrocode}
-\def\MTr@outputthreechildren{%
-% \end{macrocode}
-% Calculate desired distance between the three children.
-% The cumulative value is put into "treev". Next, set dimensions for the
-% label.
-% \begin{macrocode}
- \MTr@adjustdistance{i}{ii}%
- \MTr@adjustdistance{ii}{iii}%
- \MTr@setparentdimens{i}{iii}%
- \advance\MTr@childix\MTr@morex%
- \advance\MTr@childiix\MTr@morex%
- \advance\MTr@childiiix\MTr@morex%
+ \ifnum#1>1
+ \MTr@loopcnta 1
+ \loop
+ \edef\MTr@temp{\romannumeral\MTr@loopcnta}%
+ \ifnum\MTr@loopcnta<#1
+ \advance \MTr@loopcnta by 1
+ \MTr@adjustdistance{\MTr@temp}{\romannumeral\MTr@loopcnta}%
+ \repeat
+ \fi
% \end{macrocode}
-%
-% Set vertical position and picture height for all children.
+% Calculate the subtree's $v$ and $w$, based on the children, and the
+% label's width.
% \begin{macrocode}
- \MTr@setverticalchilddimens{i}%
- \MTr@setverticalchilddimens{ii}%
- \MTr@setverticalchilddimens{iii}%
+ \MTr@setparentdimens{i}{\romannumeral#1}%
% \end{macrocode}
-% Height is the height of the largest child.
+% After the call to "setparentdimens", all children's $x$
+% values must be advanced by "morex". In the same loop, also
+% set vertical position and picture height for each child.
+% The height of the picture is the height of the largest child.
% \begin{macrocode}
- \MTr@picheight\MTr@piciheight%
- \ifnum\MTr@piciiheight>\MTr@picheight%
- \MTr@picheight\MTr@piciiheight%
- \fi%
- \ifnum\MTr@piciiiheight>\MTr@picheight%
- \MTr@picheight\MTr@piciiiheight%
- \fi%
+ \MTr@picheight 0%
+ \MTr@loopcnta #1
+ \loop
+ \edef\MTr@temp{\romannumeral\MTr@loopcnta}%
+ \advance\MTr@childparam{\MTr@temp}{x}\MTr@morex%
+ \MTr@setverticalchilddimens{\romannumeral\MTr@loopcnta}%
+ \ifnum\MTr@childparam{\MTr@temp}{picheight}>\MTr@picheight%
+ \MTr@picheight\MTr@childparam{\MTr@temp}{picheight}%
+ \fi%
+ \advance \MTr@loopcnta by -1 \ifnum\MTr@loopcnta>0 \repeat
% \end{macrocode}
% Set various other parameters.
% \begin{macrocode}
- \MTr@setpictureparameters%
+ \MTr@setpictureparameters%
% \end{macrocode}
-% Start the picture, draw the label, the children, and the lines to the
-% children, and end the picture.
+% Start the picture and draw the label. Next, draw each child, and the line
+% to that child. Then, end the picture.
% \begin{macrocode}
- \begin{picture}(\MTr@picwidth,\MTr@picheight)(0,-\MTr@picheight)%
- %\put(0,-\MTr@picheight){\framebox(\MTr@picwidth,\MTr@picheight){}}%
- \MTr@drawlabel%
- \MTr@drawchild{i}%
- \MTr@drawchild{ii}%
- \MTr@drawchild{iii}%
- \MTr@drawchildline{i}
- \MTr@drawchildline{ii}
- \MTr@drawchildline{iii}
- \end{picture}%
+ \begin{picture}(\MTr@picwidth,\MTr@picheight)(0,-\MTr@picheight)%
+ %\put(0,-\MTr@picheight){\framebox(\MTr@picwidth,\MTr@picheight){}}%
+ \MTr@drawlabel%
+ \MTr@loopcnta #1
+ \loop
+ \expandafter\MTr@drawchild{\romannumeral\MTr@loopcnta}%
+ \expandafter\MTr@drawchildline{\romannumeral\MTr@loopcnta}
+ \advance \MTr@loopcnta by -1 \ifnum\MTr@loopcnta>0 \repeat
+ \end{picture}%
}
% \end{macrocode}
% \end{macro}