% \iffalse
%
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{dyntree}
%<package> [2023/05/03 v1 Dynkin Tree Typsetting]
%<package>\RequirePackage{coollist}
%<package>\RequirePackage{calc}
%<package>\RequirePackage{epic}
%<package>\RequirePackage{eepic}
%<package>\RequirePackage{amsmath}
%<package>\RequirePackage{amssymb}
%
% Update on 2023/05/03 purely to clarify the license; no code changes.
% This package is released under the GNU LGPL.
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{dyntree}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{dyntree.dtx}
\end{document}
%</driver>
% \fi
%
% \iffalse meta-comment
% remove this comment to get a checksum
% \CheckSum{0}
% \fi
%
%% \CharacterTable
%%  {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
%%   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
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%
% \changes{v1.0}{2006/08/14}{Initial Release}
%
% \GetFileInfo{dyntree.sty}
%
% \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ ,\!,\(,\),\,}
% \DoNotIndex{\@ne,\expandafter}
% \DoNotIndex{\advance,\begingroup,\catcode,\closein,\errmessage}
% \DoNotIndex{\newcommand,\renewcommand,\providecommand}
% \DoNotIndex{\closeout,\day,\def,\edef,\xdef,\gdef,\let,\empty,\endgroup}
% \DoNotIndex{\newcounter,\providecounter,\addtocounter,\setcounter,\stepcounter,\value,\arabic,\the}
% \DoNotIndex{\if,\fi,\ifthenelse,\else,\setboolean,\boolean,\newboolean,\provideboolean,\equal,\AND,\OR,\NOT,\whiledo}
% \DoNotIndex{\ifcase,\ifcat,\or,\else}
% \DoNotIndex{\par,\parbox,\mbox,\hbox,\begin,\end,\nabla,\partial}
% \DoNotIndex{\overline,\bar,\small,\tiny,\mathchoice,\scriptsize,\textrm,\texttt}
% \DoNotIndex{\alpha,\beta,\gamma,\epsilon,\varepsilon,\delta,\zeta,\eta,\theta,\vartheta,\iota,\kappa,\lambda,\mu,\nu}
% \DoNotIndex{\xi,\omicron,\pi,\varpi,\rho,\varrho,\sigma,\tau,\upsilon,\phi,\varphi,\chi,\psi,\omega}
% \DoNotIndex{\Delta,\Gamma,\Theta,\Lambda,\Xi,\Pi,\Sigma,\Phi,\Psi,\Omega}
% \DoNotIndex{\digamma,\lceil,\rceil,\lfloor,\rfloor,\left,\right,\inp,\inb,\inbr,\inap,\nop}
% \DoNotIndex{\sum,\prod,\int,\log,\ln,\exp,\sin,\cos,\tan,\csc,\sec,\cot,\arcsin,\arccos,\arctan,\det}
% \DoNotIndex{\sinh,\cosh,\tanh,\csch,\sech,\coth,\arcsinh,\arccosh,\arctanh}
% \DoNotIndex{\mod,\max,\min,\gcd,\lcm,\wp,\arg,\dots,\infty,}
% \DoNotIndex{\frac,\binom,\braket,\@@atop}
% \DoNotIndex{\cdot,\ldots,\tilde,\times,\dagger,\relax}
% \DoNotIndex{\mathbb,\roman,\bf,\mathord,\cal,\DeclareMathOperator,\PackageError,\PackageWarning}
% \DoNotIndex{\csname,\endcsname,\ifx,\ifnum}
% \DoNotIndex{\makeatother,\makeatletter}
% \DoNotIndex{\copy,\setbox,\usebox,\newbox}
% \DoNotIndex{\addtolength,\setlength,\newlength,\unitlength,\settoheight,\settodepth,\settowidth,\lengthtest}
% \DoNotIndex{\drawline,\line,\put}
% \DoNotIndex{
% \DYNTREE@temparray,\DYNTREE@templen,\DYNTREE@tempboxnum,\DYNTREE@tempxCoord,
% \DYNTREE@tempinsert,\DYNTREE@temproot,\DYNTREE@tempswap,\DYNTREE@temprootX}
%
% \title{The \textsf{dyntree} package\thanks{This document
% corresponds to \textsf{dyntree}~\fileversion,
% dated~\filedate.}}
% \author{nsetzer}
%
% \maketitle
%
% \setcounter{IndexColumns}{2}
% \StopEventually{\PrintChanges\PrintIndex}
%
% The \textsf{dyntree} package is intended for users needing to typeset a dykin tree---a group theoretical construct 
% consisting of cartan coefficients in boxes connected by a series of lines.  
% This package makes it easy for the user to generate these objects by allowing the user to specify only the 
% cartan coefficients and the root number(s) that they connect to below.
%
% This package requires the \textsf{coollist} package, which is not a standard \LaTeX package but is available at CTAN.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\section{Basics}
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% To create a Dynkin Tree Diagram, the syntax is as follows \DescribeEnv{dyntree} \DescribeMacro{\dynbox}:
%
% |\start{dyntree}|\marg{num\_roots}
%
% |\dynbox|\marg{cartan\_coefficients}\marg{cvs\_descendant\_root\_list} |\lend|
%
% $\vdots$
%
% |\finish{dyntree}|
%
% where 
%
% \meta{num\_roots} is an integer indicating the number of simple roots
%
% \meta{cartan\_coefficients} is an \emph{ampersand} (\&) delimited list of cartan coefficients 
% (the number of which \emph{must} be equal to \meta{num\_roots}
%
% \meta{cvs\_descendant\_root\_list} is a comma delimited list of integers indicating which simple root can be lowered
% from this box.  The simple roots are numbered from left to right starting at $1$ and ending at \meta{num\_roots}
%
%
% Thus, if the group of interest had $3$ simple roots, each |\dynbox| would have a \meta{cartan\_coefficients} with three entries; that is, it would be a list with three integers as in 
%
% \begin{center}
% |1 & 0 & 0|
% \end{center}
%
% and the list \meta{cvs\_descendant\_root\_list} would have at most three entries (but it need not have exactly three entries) with the entries being between $1$ and $3$.  The entry $1$ would correspond to the first (left-most) simple root being lowered, the entry $2$ the second simple root, and $3$ the third:
% 
% \DeleteShortVerb{\|}
% \begin{center}
% \begin{picture}(200,70)
% \put(20,40){simple root:}
% \put(80,40){$\begin{array}{ccc} 1 & 2 & 3 \end{array}$}
% \put(80,30){$\begin{array}{|ccc|} \hline 1 & 0 & 0 \\ \hline \end{array}$}
% \end{picture}
% \end{center}
% \MakeShortVerb{\|}
%
% So, finally, an entry such as
%
% \begin{center}
% |\dynbox{-1 & 0 & 0}{1,3}|
% \end{center}
%
% would specify that the program should draw two lines below the box \DeleteShortVerb{\|} $\begin{array}{|ccc|} \hline 1 & 0 & 0 \\ \hline \end{array}$ \MakeShortVerb{\|}; one for the first simple root, and another for the third simple root.  The resulting portion of the diagram would look like
%
% \begin{center}
% \start{dyntree}{3}
% \dynbox{-1 & 0 & 0}{1,3} \lend
% \finish{dyntree}
% \end{center}
% 
% \makeatletter
% \vspace{\DYNTREE@levelsep}
% \makeatother
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%\subsection{Quirks}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% There are two quirks with this package, and they are
% \begin{itemize}
% \item{if there are multiple Dynkin Tree Diagrams required for your document, you \emph{must} enclose each tree in braces}
% \item{The lowest state (bottom-most dynbox) must have a non-empty entry in \meta{cvs\_descendant\_root\_list} even though no lines are to be drawn from it.  To meet both criteria, place a zero in this spot.}
% \end{itemize}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%\subsection{Examples}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \newcounter{examples}
% \setcounter{examples}{1}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %
%\subsubsection{Example \theexamples} \stepcounter{examples} 
% %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \begin{verbatim}
% {
% \start{dyntree}{2}
% \dynbox{3 & 0}{1} \lend
% \dynbox{1 & 1}{1,2} \lend
% \dynbox{2 & -1}{1}
% \dynbox{-1 & 2}{1,2} \lend
% \dynbox{0 & 0}{1,2}
% \dynbox{-3 & 3}{0,2} \lend
% \dynbox{1 & -2}{1}
% \dynbox{-2 & 1}{0,2} \lend
% \dynbox{-1 & -1}{0,2} \lend
% \dynbox{0 & -3}{0} \lend
% \finish{dyntree}
% }
% \end{verbatim}
%
% {
% \start{dyntree}{2}
% \dynbox{3 & 0}{1} \lend
% \dynbox{1 & 1}{1,2} \lend
% \dynbox{2 & -1}{1}
% \dynbox{-1 & 2}{1,2} \lend
% \dynbox{0 & 0}{1,2}
% \dynbox{-3 & 3}{0,2} \lend
% \dynbox{1 & -2}{1}
% \dynbox{-2 & 1}{0,2} \lend
% \dynbox{-1 & -1}{0,2} \lend
% \dynbox{0 & -3}{0} \lend
% \finish{dyntree}
% }
% 
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %
%\subsubsection{Example \theexamples} \stepcounter{examples} 
% %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \begin{verbatim}
% \begin{center}
% {
% \start{dyntree}{3}
% \dynbox{2 & 0 & 0}{1} \lend
% \dynbox{0 & 1 & 0}{1,2} \lend
% \dynbox{1 & -1 & 1}{1,3}
% \dynbox{-2 & 2 & 0}{2} \lend
% \dynbox{1 & 1 & -1}{1,2}
% \dynbox{-1 & 0 & 1}{2,3} \lend
% \dynbox{2 & -1 & 0}{1}
% \dynbox{-1 & 2 & -1}{2}
% \dynbox{0 & -2 & 2}{3} \lend
% \dynbox{0 & 0 & 0}{0} \lend
% \finish{dyntree}
% }
% \end{center}
% \end{verbatim}
%
% \begin{center}
% {
% \start{dyntree}{3}
% \dynbox{2 & 0 & 0}{1} \lend
% \dynbox{0 & 1 & 0}{1,2} \lend
% \dynbox{1 & -1 & 1}{1,3}
% \dynbox{-2 & 2 & 0}{2} \lend
% \dynbox{1 & 1 & -1}{1,2}
% \dynbox{-1 & 0 & 1}{2,3} \lend
% \dynbox{2 & -1 & 0}{1}
% \dynbox{-1 & 2 & -1}{2}
% \dynbox{0 & -2 & 2}{3} \lend
% \dynbox{0 & 0 & 0}{0} \lend
% \finish{dyntree}
% }
% \end{center}
% 
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %
%\subsubsection{Example \theexamples} \stepcounter{examples} 
% %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \begin{verbatim}
% This is a $15$ of $SU(5)$
% 
% \begin{center}
% {
% \start{dyntree}{4}
% \dynbox{2 & 0 & 0 & 0}{1} \lend
% \dynbox{0 & 1 & 0 & 0}{1,2} \lend
% \dynbox{1 & -1 & 1 & 0}{1,3}
% \dynbox{-2 & 2 & 0 & 0}{2} \lend
% \dynbox{1 & 0 & -1 & 0}{1,4}
% \dynbox{-1 & 0 & 1 & 0}{2,3} \lend
% \dynbox{1 & 0 & 0 &-1}{1}
% \dynbox{-1 & 1 & -1 & 1}{2,4}
% \dynbox{0 & -2 & 2 & 0}{3} \lend
% \dynbox{-1 & 1 & 0 & -1}{2}
% \dynbox{0 & -1 & 0 & 1}{3,4} \lend
% \dynbox{0 & -1 & 1 & -1}{3}
% \dynbox{0 & 0 & -2 & 2}{4} \lend
% \dynbox{0 & 0 & -1 & 0}{4} \lend
% \dynbox{0 & 0 & 0 & -2}{0} \lend
% \finish{dyntree}
% }
% \end{center}
% \end{verbatim}
%
% This is a $15$ of $SU(5)$
% 
% \begin{center}
% {
% \start{dyntree}{4}
% \dynbox{2 & 0 & 0 & 0}{1} \lend
% \dynbox{0 & 1 & 0 & 0}{1,2} \lend
% \dynbox{1 & -1 & 1 & 0}{1,3}
% \dynbox{-2 & 2 & 0 & 0}{2} \lend
% \dynbox{1 & 0 & -1 & 0}{1,4}
% \dynbox{-1 & 0 & 1 & 0}{2,3} \lend
% \dynbox{1 & 0 & 0 &-1}{1}
% \dynbox{-1 & 1 & -1 & 1}{2,4}
% \dynbox{0 & -2 & 2 & 0}{3} \lend
% \dynbox{-1 & 1 & 0 & -1}{2}
% \dynbox{0 & -1 & 0 & 1}{3,4} \lend
% \dynbox{0 & -1 & 1 & -1}{3}
% \dynbox{0 & 0 & -2 & 2}{4} \lend
% \dynbox{0 & 0 & -1 & 0}{4} \lend
% \dynbox{0 & 0 & 0 & -2}{0} \lend
% \finish{dyntree}
% }
% \end{center}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %
%\subsubsection{Example \theexamples} \stepcounter{examples} 
% %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \begin{verbatim}
% \begin{center}
% {
% \start{dyntree}{2}
% \dynbox{0 & 2}{2} \lend
% \dynbox{1 & 0}{1,2} \lend
% \dynbox{2 & -2}{1}
% \dynbox{-1 & 1}{2} \lend
% \dynbox{0 & -1}{1} \lend
% \dynbox{-2 & 0}{0} \lend
% \finish{dyntree}
% }
% \end{center}
% \end{verbatim}
%
% \begin{center}
% {
% \start{dyntree}{2}
% \dynbox{0 & 2}{2} \lend
% \dynbox{1 & 0}{1,2} \lend
% \dynbox{2 & -2}{1}
% \dynbox{-1 & 1}{2} \lend
% \dynbox{0 & -1}{1} \lend
% \dynbox{-2 & 0}{0} \lend
% \finish{dyntree}
% }
% \end{center}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\section{Implementation}
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%\subsection{Variables and Constants}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% The \textsf{dyntree} package utilizes a picture environment to create the tree.  To do this it requires several
% constant length values, as well as calculated length values and counters.  These are define below.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %
%\subsubsection{Cartan Coefficients Box Variables}
% %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% The first thing to do is declare the length variables associated with a cartan coefficients box---dynbox for short.
% These variables are
%
% \begin{tabular}{lp{.5\textwidth}}
% |\DYNTREE@widechar|		& the width of a $-1$								\\
% |\DYNTREE@thinchar|		& the width of a $1$								\\
% |\DYNTREE@cartancoefwidth|	& the width of a cartan coefficient (a combination of $-1$ and $1$)		\\
% |\DYNTREE@marginwidth|	& the width of the margin of the cartan coefficients box			\\
% |\DYNTREE@colsepwidth|	& the width between columns of the cartan coefficients box			\\
% |\DYNTREE@dynboxheight|	& the height (baseline to top) of the cartan coefficients box			\\
% |\DYNTREE@dynboxdepth|	& the depth (baseline to bottom) of the cartan coefficients box			\\
% |\DYNTREE@dynboxvlen|		& the full vertical height of a cartan coefficients box				\\
% |\DYNTREE@dynboxwidth|	& the width of a dynbox (calculated based on numroots)				\\
% \end{tabular}
%
%    \begin{macrocode}
\newlength{\DYNTREE@widechar}%
\newlength{\DYNTREE@thinchar}%
\newlength{\DYNTREE@cartancoefwidth}%
\newlength{\DYNTREE@marginwidth}%
\newlength{\DYNTREE@colsepwidth}%
\newlength{\DYNTREE@dynboxheight}%
\newlength{\DYNTREE@dynboxdepth}%
\newlength{\DYNTREE@dynboxvlen}%
\newlength{\DYNTREE@dynboxwidth}%
%    \end{macrocode}
%
% Now that they are declared, initialize the ``exterior" ones
%
%    \begin{macrocode}
\settowidth{\DYNTREE@widechar}{$-1$}%
\settowidth{\DYNTREE@thinchar}{$1$}%
\setlength{\DYNTREE@cartancoefwidth}%
	{\DYNTREE@widechar*1/2 + \DYNTREE@thinchar*1/2}%
\settowidth{\DYNTREE@marginwidth}%
	{$\begin{array}{|c|}\hline 1 \\ \hline \end{array}$}%
	\addtolength{\DYNTREE@marginwidth}{-\DYNTREE@thinchar}%
\settowidth{\DYNTREE@colsepwidth}%
	{$\begin{array}{|cc|}\hline 1 & 1 \\ \hline \end{array}$}%
	\addtolength{\DYNTREE@colsepwidth}{-\DYNTREE@marginwidth - \DYNTREE@thinchar*2}%
\settoheight{\DYNTREE@dynboxheight}%
	{$\begin{array}{|c|}\hline 1 \\ \hline \end{array}$}%
\settodepth{\DYNTREE@dynboxdepth}%
	{$\begin{array}{|c|}\hline 1 \\ \hline \end{array}$}%
\setlength{\DYNTREE@dynboxvlen}{\DYNTREE@dynboxheight + \DYNTREE@dynboxdepth}%
%    \end{macrocode}
%
% and now for convenience and error testing, print them out
%
% \makeatletter
% \begin{tabular}{rl}
% widechar:		& \the\DYNTREE@widechar 	\\
% thinchar:		& \the\DYNTREE@thinchar		\\
% cartancoefwidth:	& \the\DYNTREE@cartancoefwidth	\\
% marginwidth:		& \the\DYNTREE@marginwidth	\\
% colsepwidth:		& \the\DYNTREE@colsepwidth	\\
% dynboxheight		& \the\DYNTREE@dynboxheight	\\
% dynboxdepth		& \the\DYNTREE@dynboxdepth	\\
% dynboxvlen		& \the\DYNTREE@dynboxvlen	\\
% \end{tabular}
% \makeatother
%
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %
%\subsubsection{Dynkin Tree Variables}
% %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %%  %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% These variables are specific to the actual creation of the tree structure.
%
% \begin{tabular}{lp{0.55\textwidth}}
% {\bf \Large counters}												\\
% |DYNTREE@numlevel|		& the number of levels in the tree						\\
% |DYNTREE@nextlevel|		& the number of the next level							\\
% |DYNTREE@numboxes|		& counter for counting number of boxes in a row					\\
% |DYNTREE@nextnumboxes|	& counter for counting number of boxes in the next row				\\
% |DYNTREE@target|		& used to record the `targeted' array element when sorting			\\
% |DYNTREE@listlen|		& the length of the list of descendents						\\
% |DYNTREE@xCoord|		& the x coordinate in scaled points						\\
% |DYNTREE@yCoord|		& the y coordinate in scaled points						\\
% |DYNTREE@xPos|		& the x coordinate in scaled points						\\
% |DYNTREE@yPos|		& the y coordinate in scaled points						\\
% |DYNTREE@xComp|		& the x coordinate in scaled points						\\
% |DYNTREE@yComp|		& the y coordinate in scaled points						\\
% |DYNTREE@leftX|		& the left most x coordinate in scaled points					\\
% |DYNTREE@ct|			& generic counter								\\
% |DYNTREE@counter|		& generic counter								\\
% |DYNTREE@index|		& generic counter								\\
% |DYNTREE@root|		& the root number								\\
% \end{tabular}
%		
% \begin{tabular}{lp{0.55\textwidth}}
% {\bf \Large lengths}												\\
% |\DYNTREE@dynboxsep|		& the distance between dynkin boxes						\\
% |\DYNTREE@levelsep|		& the distances between each level (from dynkin box bottom to top of next layer's dynbox)
%														\\
% |\DYNTREE@leftmostX|		& the left most x value								\\
% |\DYNTREE@rightmostX|		& the right most x value							\\
% |\DYNTREE@unitlen|		& the unit length value before altering (to allow it to be restored)		\\
% |\DYNTREE@templen|		& temporary length storage							\\
% |\DYNTREE@holdlen|		& temporary length storage							\\
% \end{tabular}
%		
% \begin{tabular}{lp{0.55\textwidth}}
% {\bf \Large commands}												\\
% |\DYNTREE@treestop|		& indicates the point where the gobbler stops reading (to allow \LaTeX to properly
%				  read all the data.  Its value is |\&\&\&|					\\
% |\DYNTREE@treeend|		& indicates the end of the tree.  It is in the definition of the gobbler.
%				  It has a value of |\%\%\%|							\\
% \end{tabular}
%
%
% \begin{macro}{\lend}
% \begin{macro}{\dynbox}
%
% And there are two external commands:
%
% \begin{tabular}{lp{0.75\textwidth}}
% |\lend|			& indicates the end of one tree level. The value is never used: this token is used as
%				  a delimiter by the user and the code. Its value, which should never be typed, 
%				  is |\&\%\&\%|									\\
% |\dynbox|			& indicates the start of a dynbox.  The value is never used: this token is purely for
%				  delimiting the start of the dynbox by the user; it is only defined to satisfy the 
%				  |\ifthenelse| statement							\\
% \end{tabular}
% \end{macro}
% \end{macro}
%
%    \begin{macrocode}
\newcounter{DYNTREE@numlevel}%
\newcounter{DYNTREE@nextlevel}%
\newcounter{DYNTREE@numboxes}%
\newcounter{DYNTREE@nextnumboxes}%
\newcounter{DYNTREE@target}%
\newcounter{DYNTREE@listlen}%
\newcounter{DYNTREE@xCoord}%
\newcounter{DYNTREE@yCoord}%
\newcounter{DYNTREE@xPos}%
\newcounter{DYNTREE@yPos}%
\newcounter{DYNTREE@xComp}%
\newcounter{DYNTREE@yComp}%
\newcounter{DYNTREE@leftX}%
\newcounter{DYNTREE@ct}%
\newcounter{DYNTREE@counter}%
\newcounter{DYNTREE@index}%
\newcounter{DYNTREE@root}%
\newlength{\DYNTREE@dynboxsep}%
\newlength{\DYNTREE@levelsep}%
\newlength{\DYNTREE@leftmostX}%
\newlength{\DYNTREE@rightmostX}%
\newlength{\DYNTREE@unitlen}%
\newlength{\DYNTREE@templen}%
\newlength{\DYNTREE@holdlen}%
\newcommand{\DYNTREE@treestop}{\&\&\&}%
\newcommand{\DYNTREE@treeend}{\%\%\%}%
\newcommand{\lend}{\&\%\&\%}%
\newcommand{\dynbox}{}%
%    \end{macrocode}
%
% Now that they are declared, initialize the ``exterior" ones
%
%    \begin{macrocode}
\setlength{\DYNTREE@dynboxsep}{\DYNTREE@colsepwidth}%
\setlength{\DYNTREE@levelsep}{1cm}%
%    \end{macrocode}
%
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%\subsection{The Tree Eater}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% While the dynkin tree structure resembles that of an environment, it actually consists of a \LaTeX command that 
% consumes the data, sorts it, and displays the proper items.  The basis of this consumption are several 
% ``gobblers"---the first of which eats the tree one level at a time
%
%
%    \begin{macrocode}
\def\DYNTREE@gobbletree#1\lend#2\DYNTREE@treeend{%
%    \end{macrocode}
% Before the level can be processed, several things must be adjusted.  First, since a new level is beginning
% the counter must be incremented by one
%    \begin{macrocode}
\addtocounter{DYNTREE@numlevel}{1}%
%    \end{macrocode}
% initialize the number of boxes for this level
%    \begin{macrocode}
\setcounter{DYNTREE@numboxes}{0}%
%    \end{macrocode}
% initialize the number of boxes for the next level
%    \begin{macrocode}
\setcounter{DYNTREE@nextnumboxes}{0}%
%    \end{macrocode}
% Process the level:
%    \begin{macrocode}
\DYNTREE@gobbledynboxes#1\lend%
%    \end{macrocode}
% \iffalse
% \makeatletter
% \begin{tabular}{lp{.55\textwidth}}
% \multicolumn{2}{l}{{\bf ERROR CHECK}}			\\
% level:	& \arabic{DYNTREE@numlevel}		\\
% boxes: 	& \arabic{DYNTREE@numboxes}		\\
% \end{tabular}
% \makeatother
% \fi
% Record the number of boxes for this level
%    \begin{macrocode}
\expandafter\xdef%
	\csname DYNTREE@level@\roman{DYNTREE@numlevel}@numbox\endcsname%
	{\arabic{DYNTREE@numboxes}}%
%    \end{macrocode}
% Now check for the signal to stop processing
%    \begin{macrocode}
\ifthenelse{ \equal{#2}{\DYNTREE@treestop} }%
	{%
%    \end{macrocode}
%	The End---just do nothing
%    \begin{macrocode}
	}%
% Else
	{%
%    \end{macrocode}
% continue processing levels until the end of the tree
%    \begin{macrocode}
	\DYNTREE@gobbletree#2\DYNTREE@treeend%
	}%
}%
%    \end{macrocode}
%
%
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%\subsection{The Box Eater}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% The second ``gobbler" eats the boxes one by one:
%
%    \begin{macrocode}
\def\DYNTREE@gobbledynboxes#1\dynbox#2#3#4{%
%    \end{macrocode}
% increment the number of boxes
%    \begin{macrocode}
\addtocounter{DYNTREE@numboxes}{1}%
%    \end{macrocode}
% \iffalse
%! boxnum: \arabic{DYNTREE@numboxes}
% \fi
% Store the boxes for this level in registers
%    \begin{macrocode}
\expandafter\newbox%
	\csname DYNTREE@box@\roman{DYNTREE@numlevel}@\roman{DYNTREE@numboxes}\endcsname%
\expandafter\setbox%
	\csname DYNTREE@box@\roman{DYNTREE@numlevel}@\roman{DYNTREE@numboxes}\endcsname=%
	\hbox{$\begin{array}{|*{\DYNTREE@numroots}{c}|}\hline #2 \\ \hline \end{array}$}%
%    \end{macrocode}
% Calculate the X value for each descendent and place in sorted list
%
% * Get the length of the list
%    \begin{macrocode}
\listlenstore{DYNTREE@listlen}{#3}%
\expandafter\xdef
	\csname DYNTREE@childline@\roman{DYNTREE@numlevel}@\roman{DYNTREE@numboxes}@boxnum\endcsname%
		{\arabic{DYNTREE@listlen}}%
\ifthenelse{\value{DYNTREE@listlen} > \DYNTREE@numroots}%
	{%
	\PackageError{dyntree}%
		{%
		Length of descendant of \arabic{DYNTREE@numboxes}%
	 	on level \arabic{DYNTREE@numlevel} exceeds number of roots%
	 	(\DYNTREE@numroots)%
	 	}%
	}%
% Else
	{}%
%    \end{macrocode}
% * store the list in a temp variable for convenience in typing, store it more permanently for use later on.
%    \begin{macrocode}
\liststore{#3}{DYNTREE@templist@}%
\liststore{#3}%
	{DYNTREE@childlist@\roman{DYNTREE@numlevel}@\roman{DYNTREE@numboxes}@}%
%    \end{macrocode}
% * go through the list and generate the sorted 'array' |DYNTREE@level@|\meta{level}|@|\meta{boxnum}|@X|
%    \begin{macrocode}
\setcounter{DYNTREE@ct}{1}%
\whiledo{	\NOT \(\value{DYNTREE@ct} > \value{DYNTREE@listlen}\) \AND 
		\NOT\(\value{DYNTREE@ct} > \DYNTREE@numroots\)			}%
	{%
%    \end{macrocode}
	% need to store the `root' value in a counter to retrieve the data
%    \begin{macrocode}
	\setcounter{DYNTREE@counter}{\csname DYNTREE@templist@\roman{DYNTREE@ct}\endcsname}%
%    \end{macrocode}
	% check that the number submitted is within the allowed range
%    \begin{macrocode}
	\ifthenelse{	\(\value{DYNTREE@counter} > \DYNTREE@numroots\) \OR 
			\(\value{DYNTREE@counter} < 1\) 			}%
		{%
		\ifthenelse{\value{DYNTREE@counter} = 0}%
			{%
%    \end{macrocode}
			% Do nothing - this is the last level
%    \begin{macrocode}
			}%
		% Else
			{%
			\PackageError{dyntree}%
				{%
				Descendant root of \arabic{DYNTREE@numboxes} on level%
				 \arabic{DYNTREE@numlevel} out of bounds%
				 (\arabic{DYNTREE@counter} > \DYNTREE@numroots)%
				}%
			}%
		}%
	% Else
		{%
%    \end{macrocode}
		% temporarily store the length
%    \begin{macrocode}
		\setlength{\DYNTREE@templen}%
			{\csname DYNTREE@level@\roman{DYNTREE@numlevel}@\roman{DYNTREE@numboxes}@X\endcsname}%
		\addtolength{\DYNTREE@templen}%
			{\csname DYNTREE@rootX@\roman{DYNTREE@counter}\endcsname*(-1)}%
%    \end{macrocode}
		% adjust the left most length
%    \begin{macrocode}
		\ifthenelse{\DYNTREE@templen < \DYNTREE@leftmostX}%
			{%
			\setlength{\DYNTREE@leftmostX}{\DYNTREE@templen}%
			}%
		% Else
			{}%
%    \end{macrocode}
		% adjust right most length
%    \begin{macrocode}
		\setlength{\DYNTREE@holdlen}{\DYNTREE@templen}%
		\addtolength{\DYNTREE@holdlen}{\DYNTREE@dynboxwidth}%
		\ifthenelse{ \DYNTREE@holdlen > \DYNTREE@rightmostX }%
			{%
			\setlength{\DYNTREE@rightmostX}{\DYNTREE@holdlen}%
			}%
		% Else
			{}%
%    \end{macrocode}
		% now store the x value for the line
%    \begin{macrocode}
		\setlength{\DYNTREE@holdlen}%
			{\expandafter\csname DYNTREE@dynboxX@\roman{DYNTREE@counter}\endcsname}%
		\addtolength{\DYNTREE@holdlen}{\DYNTREE@templen}%
		\setcounter{DYNTREE@xPos}{\DYNTREE@holdlen}%
%    \end{macrocode}
		% \iffalse
		%! \begin{tabular}{cc}
		%! rootX.\roman{DYNTREE@counter}	& \csname DYNTREE@rootX@\roman{DYNTREE@counter}\endcsname	\\
		%! DYNTREE@numlevel:		& \arabic{DYNTREE@numlevel}				\\
		%! numboxes:		& \arabic{DYNTREE@numboxes}				\\
		%! templen: 		& \the\DYNTREE@templen					\\
		%! \end{tabular}
		%! 
		% \fi
		% |counter| has served its purpose and may be used in another context
		%
		% add the length to the sorted 'array'
		%
		% * initialize the counter to the END of the array
%    \begin{macrocode}
		\setcounter{DYNTREE@counter}{\value{DYNTREE@nextnumboxes}}%
%    \end{macrocode}
		% * get the value of the next level
%    \begin{macrocode}
		\setcounter{DYNTREE@nextlevel}{\value{DYNTREE@numlevel} + 1}%
%    \end{macrocode}
		% * Check for array elements
%    \begin{macrocode}
		\ifthenelse{\value{DYNTREE@counter} = 0}%
			{%
%    \end{macrocode}
			% set the first element as the length
%    \begin{macrocode}
			\expandafter\xdef%
				\csname DYNTREE@level@\roman{DYNTREE@nextlevel}@i@X\endcsname%
					{\the\DYNTREE@templen}%
%    \end{macrocode}
			% increment the number of elements
%    \begin{macrocode}
			\addtocounter{DYNTREE@nextnumboxes}{1}%
			}%
		% Else
			{%
%    \end{macrocode}
			% there is at least one element
%    \begin{macrocode}
			\edef\DYNTREE@temparray%
				{\csname DYNTREE@level@\roman{DYNTREE@nextlevel}@\roman{DYNTREE@counter}@X\endcsname}%
			\edef\DYNTREE@tempinsert{\the\DYNTREE@templen}%
%    \end{macrocode}
			% \iffalse
			%! \begin{tabular}{cc}
			%! nextnumboxes:	& \arabic{DYNTREE@nextnumboxes}					\\
			%! nextlevel:	& \arabic{DYNTREE@nextlevel}						\\
			%! counter:	& \arabic{DYNTREE@counter}						\\
			%! temparray:	& \DYNTREE@temparray							\\
			%! level\&\roman{DYNTREE@nextlevel}\&\roman{DYNTREE@counter}\&X
			%! 		& 
			%!	\csname DYNTREE@level@\roman{DYNTREE@nextlevel}@\roman{DYNTREE@counter}@X\endcsname	
			%!											\\
			%! tempinsert:	& \DYNTREE@tempinsert							\\
			%! \end{tabular}
			% \fi
			% find where element should be inserted
%    \begin{macrocode}
			\whiledo{	\(\value{DYNTREE@counter} > 0\) \AND 
					\lengthtest{\DYNTREE@tempinsert < \DYNTREE@temparray}		}%
				{%
				\edef\DYNTREE@temparray%
				{\csname DYNTREE@level@\roman{DYNTREE@nextlevel}@\roman{DYNTREE@counter}@X\endcsname}%
				\addtocounter{DYNTREE@counter}{-1}%
				}%
%    \end{macrocode}
			% the thing needs to be inserted at \value{DYNTREE@counter} + 1
%    \begin{macrocode}
			\setcounter{DYNTREE@target}{\value{DYNTREE@counter} + 1}%
%    \end{macrocode}
			% \iffalse
			%! \begin{tabular}{cc}
			%! target: \arabic{DYNTREE@target}		\\
			%! temparray:	& \DYNTREE@temparray		\\
			%! tempinsert:	& \DYNTREE@tempinsert		\\
			%! \end{tabular}	
			%!
			%!
			% \fi
			% if they aren't equal, move from target to nextnumboxes up to target+1 to nextnumboxes+1
%    \begin{macrocode}
			\ifthenelse{ \NOT \lengthtest{\DYNTREE@tempinsert = \DYNTREE@temparray} }%
				{%
				\setcounter{DYNTREE@counter}{\value{DYNTREE@nextnumboxes} + 1}%
				\whiledo{ \value{DYNTREE@counter} > \value{DYNTREE@target} }%
					{%
%    \end{macrocode}
					% get the value in the array spot one before
%    \begin{macrocode}
					\addtocounter{DYNTREE@counter}{-1}%
					\edef\DYNTREE@tempswap%
						{%
				\csname DYNTREE@level@\roman{DYNTREE@nextlevel}@\roman{DYNTREE@counter}@X\endcsname%
						}%
%    \end{macrocode}
					% store this value in the next array spot
%    \begin{macrocode}
					\addtocounter{DYNTREE@counter}{1}%
					\expandafter\xdef%
				\csname DYNTREE@level@\roman{DYNTREE@nextlevel}@\roman{DYNTREE@counter}@X\endcsname%
						{\DYNTREE@tempswap}%
					\addtocounter{DYNTREE@counter}{-1}%
					}%
%    \end{macrocode}
				% insert the original
%    \begin{macrocode}
				\expandafter\xdef%
				\csname DYNTREE@level@\roman{DYNTREE@nextlevel}@\roman{DYNTREE@target}@X\endcsname%
					{\DYNTREE@tempinsert}%
%    \end{macrocode}
				% increment the number of boxes in the next level
%    \begin{macrocode}
				\addtocounter{DYNTREE@nextnumboxes}{1}%
				}%
			% Else
				{%
%    \end{macrocode}
				% Do nothing
%    \begin{macrocode}
				}%
			}%
		}%
	\addtocounter{DYNTREE@ct}{1}%
	}%
\ifthenelse{\equal{#4}{\lend}}%
	{%
	}%
% Else
	{%
%    \end{macrocode}
%	% Eat the boxes until there are no more
%    \begin{macrocode}
	\DYNTREE@gobbledynboxes#4%
	}%
}%
%    \end{macrocode}
%
%
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%\subsection{The Dyntree Environment}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Dynkin Tree Environment
%
%
%    \begin{macrocode}
\def\start#1#2#3\finish#4%
{%
\ifthenelse{\equal{#1}{#4} \AND \equal{#4}{dyntree}}%
	{%
	\providecommand{\DYNTREE@numroots}{#2}%
%    \end{macrocode}
	% \iffalse
	%! \DYNTREE@numroots
	% \fi
	% Initialize Interior Dynkin Box Variables
%    \begin{macrocode}
	\setlength{\DYNTREE@dynboxwidth}
		{%
		\DYNTREE@marginwidth + 
		\DYNTREE@cartancoefwidth*\DYNTREE@numroots + 
		\DYNTREE@colsepwidth*(\DYNTREE@numroots-1)
		}%
%    \end{macrocode}
	% Initialize Interior Dynkin Tree Variables
%    \begin{macrocode}
	\setlength{\DYNTREE@leftmostX}{0pt}%
	\setlength{\DYNTREE@rightmostX}{\DYNTREE@dynboxwidth}%
%    \end{macrocode}
	% the highest left starts at zero, so initialize this value
%    \begin{macrocode}
	\expandafter\gdef\csname DYNTREE@level@i@i@X\endcsname{0pt}%
%    \end{macrocode}
	% There are no levels, so initialize |numlevel| to zero
%    \begin{macrocode}
	\setcounter{DYNTREE@numlevel}{0}%
%    \end{macrocode}
	% Determine the root lines and dynkin box offsets
%    \begin{macrocode}
	\setcounter{DYNTREE@ct}{1}%
	\whiledo{\NOT \(\value{DYNTREE@ct}>\DYNTREE@numroots\)}%
		{%
%    \end{macrocode}
		% Calculate the length and store it in a temporary length
%    \begin{macrocode}
		\setlength{\DYNTREE@templen}%
			{%
			  (\DYNTREE@dynboxwidth + \DYNTREE@dynboxsep)*\value{DYNTREE@ct}%
			 -(\DYNTREE@dynboxwidth + \DYNTREE@dynboxsep)*1/2%
			 -(\DYNTREE@dynboxwidth + \DYNTREE@dynboxsep)*\DYNTREE@numroots/2%
			}%
%    \end{macrocode}
		% \iffalse
		%! ct: \arabic{DYNTREE@ct}
		%! templen: \the\DYNTREE@templen
		% \fi
		% store the actual length in a command
%    \begin{macrocode}
		\expandafter\xdef\csname DYNTREE@rootX@\roman{DYNTREE@ct}\endcsname%
			{\the\DYNTREE@templen}%
%    \end{macrocode}
		% Calculate the dynkin box x offset and store it in a temporary length
%    \begin{macrocode}
		\setlength{\DYNTREE@templen}%
			{%
			\DYNTREE@dynboxwidth/2/\DYNTREE@numroots + 
			\DYNTREE@dynboxwidth*(\value{DYNTREE@ct}-1)/\DYNTREE@numroots
			}%
%    \end{macrocode}
		% store the actual length in a command
%    \begin{macrocode}
		\expandafter\xdef\csname DYNTREE@dynboxX@\roman{DYNTREE@ct}\endcsname%
			{\the\DYNTREE@templen}%
%    \end{macrocode}
		% \iffalse
		% Print the Lengths
		%! DYNTREE@rootX@\roman{DYNTREE@ct}: \expandafter\csname DYNTREE@rootX@\roman{DYNTREE@ct}\endcsname
		%!
		%! DYNTREE@dynboxX@\roman{DYNTREE@ct}: \expandafter\csname DYNTREE@dynboxX@\roman{DYNTREE@ct}\endcsname
		% \fi
%    \begin{macrocode}
		\addtocounter{DYNTREE@ct}{1}%
		}%
%    \end{macrocode}
	% \iffalse
	% dynboxwidth: \the\DYNTREE@dynboxwidth
	% \fi
	% Eat the tree
%    \begin{macrocode}
	\DYNTREE@gobbletree#3\DYNTREE@treestop\DYNTREE@treeend%
%    \end{macrocode}
	% \iffalse
	%! numlevels: \arabic{DYNTREE@numlevel}
	% \fi
	% Now the data has been stored, Draw The Tree:
	%
	% store the current unit length to restore when finished
%    \begin{macrocode}
	\setlength{\DYNTREE@unitlen}{\unitlength}%
	\setlength{\unitlength}{1sp}%
%    \end{macrocode}
	% get the width of the picture
%    \begin{macrocode}
	\setcounter{DYNTREE@xCoord}{\DYNTREE@rightmostX - \DYNTREE@leftmostX}%
%    \end{macrocode}
	% store the leftmost point as a counter
%    \begin{macrocode}
	\setcounter{DYNTREE@leftX}{\DYNTREE@leftmostX}%
%    \end{macrocode}
	% get the height of the picture
%    \begin{macrocode}
	\setcounter{DYNTREE@yCoord}%
		{%
		\DYNTREE@dynboxvlen*\value{DYNTREE@numlevel} + 
		\DYNTREE@levelsep*(\value{DYNTREE@numlevel} - 1)
		}%
	\begin{picture}%
		(\arabic{DYNTREE@xCoord},\arabic{DYNTREE@yCoord})%
		(\value{DYNTREE@leftX},0)%
	\setcounter{DYNTREE@ct}{1}%
	\whiledo{\NOT \(\value{DYNTREE@ct} > \value{DYNTREE@numlevel}\)}%
		{%
		\setcounter{DYNTREE@counter}{1}%
%    \end{macrocode}
		% get the y coordinate as a length
%    \begin{macrocode}
		\setlength{\DYNTREE@templen}%
			{%
			  \DYNTREE@dynboxvlen*\value{DYNTREE@numlevel}
			- \DYNTREE@dynboxvlen*\value{DYNTREE@ct}
			+ \DYNTREE@levelsep*\value{DYNTREE@numlevel} 
			- \DYNTREE@levelsep*\value{DYNTREE@ct}
			+ \DYNTREE@dynboxdepth
			}%
%    \end{macrocode}
		% convert the length to an integer in scaled points (sp)
%    \begin{macrocode}
		\setcounter{DYNTREE@yCoord}{\DYNTREE@templen}%
		\def\DYNTREE@tempboxnum{\csname DYNTREE@level@\roman{DYNTREE@ct}@numbox\endcsname}%
		\whiledo{\NOT \( \value{DYNTREE@counter} > \DYNTREE@tempboxnum \)}%
			{%
%    \end{macrocode}
			% grab the value of the x coordinate (it's a length but not stored as one)
%    \begin{macrocode}
			\xdef\DYNTREE@tempxCoord%
				{%
				\expandafter%
				\csname DYNTREE@level@\roman{DYNTREE@ct}@\roman{DYNTREE@counter}@X\endcsname%
				}%
%    \end{macrocode}
			% convert x coordinate to a length
%    \begin{macrocode}
			\setlength{\DYNTREE@holdlen}{\DYNTREE@tempxCoord}%
%    \end{macrocode}
			% convert length to an integer in scaled points (sp)
%    \begin{macrocode}
			\setcounter{DYNTREE@xCoord}{\DYNTREE@holdlen}%
%    \end{macrocode}
			% place each dynkin box
%    \begin{macrocode}
			\put(\arabic{DYNTREE@xCoord},\arabic{DYNTREE@yCoord})%
				{%
				\expandafter%
				\copy\csname DYNTREE@box@\roman{DYNTREE@ct}@\roman{DYNTREE@counter}\endcsname%
				}%
%    \end{macrocode}
			% go through the descendants and place the lines
%    \begin{macrocode}
			\setcounter{DYNTREE@listlen}%
				{%
				\expandafter%
				\csname DYNTREE@childline@\roman{DYNTREE@ct}@\roman{DYNTREE@counter}@boxnum\endcsname%
				}%
			\setcounter{DYNTREE@index}{1}%
			\whiledo{\NOT \(\value{DYNTREE@index} > \value{DYNTREE@listlen}\)}%
				{%
				\xdef\DYNTREE@childroot%
					{%
					\expandafter%
		\csname DYNTREE@childlist@\roman{DYNTREE@ct}@\roman{DYNTREE@counter}@\roman{DYNTREE@index}\endcsname%
					}%
				\ifthenelse{\NOT \DYNTREE@childroot = 0 }%
					{%
					\setcounter{DYNTREE@root}{\DYNTREE@childroot}%
					\setcounter{DYNTREE@xPos}{\value{DYNTREE@xCoord}}%
					\setcounter{DYNTREE@xComp}{\value{DYNTREE@xCoord}}%
					\setcounter{DYNTREE@yPos}{\value{DYNTREE@yCoord}}%
					\setcounter{DYNTREE@yComp}{\value{DYNTREE@yCoord}}%
					\xdef\DYNTREE@temprootX%
						{\expandafter\csname DYNTREE@rootX@\roman{DYNTREE@root}\endcsname}%
					\setlength{\DYNTREE@templen}{\DYNTREE@temprootX}%
					\addtocounter{DYNTREE@xPos}{\DYNTREE@templen*(-1)}%
					\xdef\DYNTREE@dynoffset%
						{\expandafter\csname DYNTREE@dynboxX@\roman{DYNTREE@root}\endcsname}%
					\setlength{\DYNTREE@templen}{\DYNTREE@dynoffset}%
					\addtocounter{DYNTREE@xPos}{\DYNTREE@templen}%
					\addtocounter{DYNTREE@xComp}{\DYNTREE@templen}%
					\setlength{\DYNTREE@templen}{1pt}% for frame thickness
					\addtocounter{DYNTREE@yPos}%
						{\DYNTREE@levelsep*(-1) - \DYNTREE@dynboxdepth - \DYNTREE@templen}%
					\addtocounter{DYNTREE@yComp}{\DYNTREE@dynboxdepth*(-1) - \DYNTREE@templen}%
					\put(0,0)%
						{%
						\drawline%
						(\arabic{DYNTREE@xComp},\arabic{DYNTREE@yComp})%
						(\arabic{DYNTREE@xPos},\arabic{DYNTREE@yPos})%
						}%
					}%
				% Else
					{%
					}%
				\addtocounter{DYNTREE@index}{1}%
				}%
			\addtocounter{DYNTREE@counter}{1}%
			}%
		\addtocounter{DYNTREE@ct}{1}%
		}%
	\end{picture}%
%    \end{macrocode}
	% restore the unit length to original value
%    \begin{macrocode}
	\setlength{\unitlength}{\DYNTREE@unitlen}%
%    \end{macrocode}
% \iffalse
	%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Error Check BEGIN
	%! \setcounter{DYNTREE@ct}{1}
	%! \whiledo{\NOT \(\value{DYNTREE@ct} > \value{DYNTREE@numlevel}\)}%
	%! 	{%
	%! 	\setcounter{act}{1}%
	%! 	\def\DYNTREE@tempboxnum{\csname DYNTREE@level@\roman{DYNTREE@ct}@numbox\endcsname}
	%! 	\whiledo{\NOT \( \value{act} > \DYNTREE@tempboxnum \)}%
	%! 		{%
	%! 		level.\roman{DYNTREE@ct}.\roman{act}.x: \csname DYNTREE@level@\roman{DYNTREE@ct}@\roman{act}@X\endcsname;
	%! 
	%! 		\addtocounter{act}{1}
	%! 		}
	%! 	\addtocounter{DYNTREE@ct}{1}%
	%! 	}%
	%! 
	%! 
	%! \setcounter{DYNTREE@ct}{1}%
	%! \whiledo{\NOT \(\value{DYNTREE@ct}>\value{DYNTREE@numlevel}\)}%
	%!	{%
	%!	\setcounter{act}{1}%
	%!	\def\DYNTREE@tempboxnum{\csname DYNTREE@level@\roman{DYNTREE@ct}@numbox\endcsname}%
	%!	\whiledo{\NOT \(\value{act}>\DYNTREE@tempboxnum\)}%
	%!		{%
	%!		level: \arabic{DYNTREE@ct}, box: \arabic{act};
	%!		\expandafter\copy\csname DYNTREE@box@\roman{DYNTREE@ct}@\roman{act}\endcsname
	%!		
	%!		\addtocounter{act}{1}%
	%!		}%
	%!	\addtocounter{DYNTREE@ct}{1}%
	%!	}%
	%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Error Check END
% \fi
%    \begin{macrocode}
	}%
% Else
	{%
	\PackageError{dyntree}{Invalid start(#1)/finish(#4) call}%
	}%
}%
%    \end{macrocode}
%
%
% \Finale
\endinput
