summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/williams/antree.sty
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/williams/antree.sty
Initial commit
Diffstat (limited to 'macros/latex/contrib/williams/antree.sty')
-rw-r--r--macros/latex/contrib/williams/antree.sty191
1 files changed, 191 insertions, 0 deletions
diff --git a/macros/latex/contrib/williams/antree.sty b/macros/latex/contrib/williams/antree.sty
new file mode 100644
index 0000000000..73544951e5
--- /dev/null
+++ b/macros/latex/contrib/williams/antree.sty
@@ -0,0 +1,191 @@
+% antree.sty -- annotated node trees
+% Copyright 1994 -- Peter Williams (pwil3058@bigpond.net.au)
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Peter Williams.
+%
+% This work consists of the files antree.sty and toklist.sty.
+%
+% Licence notice added and email updated on behalf of Peter Williams
+% by Clea F. Rees 2009/01/30.
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{antree}[1994/06/22]
+\RequirePackage{calc}
+\RequirePackage{ifthen}
+\RequirePackage{epic}
+\RequirePackage{eepic}
+\RequirePackage{toklist}
+
+\newlength{\ANhspace}
+\setlength{\ANhspace}{4pt}
+\newlength{\ANvspace}
+\setlength{\ANvspace}{30pt}
+\newlength{\ANesep}
+\setlength{\ANesep}{12pt}
+\newlength{\ANespace}
+\setlength{\ANespace}{1pt}
+\newlength{\AN@ehsp}
+\newlength{\AN@evsp}
+\newlength{\AN@a}
+\newlength{\AN@b}
+\newlength{\AN@c}
+\newlength{\AN@stw}
+\newlength{\AN@sth}
+\newsavebox{\leaf@content}
+\newsavebox{\link@content}
+\newsavebox{\link@label}
+\newsavebox{\node@content}
+\newboolean{AN@firstlink}
+
+\endlinechar=-1\relax
+
+{\catcode`\p=12 \catcode`\t=12
+\gdef\AN@rmd#1pt{#1}}
+
+\newenvironment{antree}[2][\null]{%
+\newcommand{\leaf}[2][\null]{%
+ \sbox{\leaf@content}{##2}
+ \settowidth{\AN@a}{\usebox{\leaf@content}}%
+ \settoheight{\AN@b}{\usebox{\leaf@content}}%
+ \settodepth{\AN@c}{\usebox{\leaf@content}}%
+ \addtolength{\AN@b}{\AN@c}%
+ \begin{picture}(\AN@Xpos,\AN@Ypos)%
+ \settodepth{\AN@c}{\usebox{\leaf@content}}%
+ \put(0,\AN@Zpos){\usebox{\leaf@content}}%
+ \put(\AN@Xpos,\AN@Ypos){##1}%
+ \end{picture}%}%}
+ \ignorespaces%
+}%
+%
+\newcommand{\link}[2][\null]{%
+ \TOKL@append##1\to\AN@indices%
+ \sbox{\link@content}{##2}
+ \settowidth{\AN@a}{\usebox{\link@content}}%
+ \addtolength{\AN@stw}{0.5\AN@a}%
+ \ifthenelse{\boolean{AN@firstlink}}%
+ {\setboolean{AN@firstlink}{false}}%
+ {\hspace*{\ANhspace}\addtolength{\AN@stw}{\ANhspace}}%
+ \TOKL@appendv\expandafter\AN@rmd\the\AN@stw\to\AN@xlist%
+ \addtolength{\AN@stw}{0.5\AN@a}%
+ \settoheight{\AN@b}{\usebox{\link@content}}
+ \settodepth{\AN@c}{\usebox{\link@content}}
+ \raisebox{0pt}{\vtop{\null\hbox{\usebox{\link@content}}}}
+ \ignorespaces%
+}%
+%
+\def\AN@Xpos{\expandafter\AN@rmd\the\AN@a}%
+\def\AN@Ypos{\expandafter\AN@rmd\the\AN@b}%
+\def\AN@Zpos{\expandafter\AN@rmd\the\AN@c}%
+%
+\newenvironment{node}[2][\null]{%
+ \leavevmode\hbox\bgroup%
+ \endlinechar=-1
+ \sbox{\node@content}{\leaf[##1]{##2}}
+ \def\AN@xlist{}%
+ \def\AN@indices{}%
+ \setlength{\unitlength}{\p@}%
+ \setlength{\AN@stw}{\z@}%
+ \setlength{\AN@sth}{\z@}%
+ \setboolean{AN@firstlink}{true}
+ \ignorespaces%
+}{\ignorespaces%
+ \setlength{\AN@sth}{\ANvspace}%
+ \settoheight{\AN@a}{\usebox{\node@content}}%
+ \addtolength{\AN@sth}{\AN@a}%
+ \settodepth{\AN@a}{\usebox{\node@content}}%
+ \addtolength{\AN@sth}{\AN@a}%
+ \hspace*{-\AN@stw}%
+ \setlength{\AN@a}{0.5\AN@stw}%
+ \edef\AN@nodex{\expandafter\AN@rmd\the\AN@a}%
+ \edef\AN@nodey{\expandafter\AN@rmd\the\ANvspace}%
+ \edef\AN@picx{\expandafter\AN@rmd\the\AN@stw}%
+ \edef\AN@picy{\expandafter\AN@rmd\the\AN@sth}%
+ \begin{picture}(\AN@picx,\AN@picy)%
+ \whiledo{\equal{\TOK@empty\AN@xlist}{false}}{%
+ \TOKL@lop\AN@xlist\to\AN@x
+ \TOKL@lop\AN@indices\to\AN@elabel
+ \settowidth{\AN@ehsp}{\AN@elabel}%
+ \setlength{\AN@ehsp}{0.5\AN@ehsp+\ANespace}%
+ \settoheight{\AN@evsp}{\AN@elabel}%
+ \setlength{\AN@evsp}{0.5\AN@evsp+\ANespace}%
+ \ifthenelse{\equal{\AN@elabel}{\null}}{%
+ \drawline(\AN@nodex,\AN@nodey)(\AN@x,0)%
+ }{%
+ \ifthenelse{\lengthtest{\ANesep<\AN@evsp}}{%
+ \setlength{\AN@b}{2\AN@evsp}%
+ \drawline(\AN@nodex,\AN@nodey)(\AN@x,\AN@Ypos)%
+ \put(\AN@x,\AN@evsp){\makebox(0,0){\AN@elabel}}%
+ }{%
+ \ifthenelse{\lengthtest{\AN@x\p@=\AN@nodex\p@}}{%
+ \setlength{\AN@b}{\ANesep-\AN@evsp}%
+ \drawline(\AN@x,\AN@Ypos)(\AN@x,0)%
+ \setlength{\AN@b}{\ANesep+\AN@evsp}%
+ \drawline(\AN@nodex,\AN@nodey)(\AN@x,\AN@Ypos)%
+ \setlength{\AN@a}{\AN@x\p@}%
+ }{%
+ \setlength{\AN@c}{100pt*\ratio{\AN@ehsp}{\AN@evsp}}%
+ \ifthenelse{\lengthtest{\AN@x\p@ > \AN@nodex\p@}}{%
+ \setlength{\AN@a}{100pt*\ratio{\AN@x\p@-\AN@nodex\p@}{\AN@nodey\p@}}%
+ \ifthenelse{\lengthtest{\AN@a < \AN@c}}{%
+ \setlength{\AN@b}{\ANesep-\AN@evsp}%
+ \setlength{\AN@a}{\AN@x\p@-\AN@b*\ratio{\AN@x\p@-\AN@nodex\p@}{\AN@nodey\p@}}%
+ \drawline(\AN@Xpos,\AN@Ypos)(\AN@x,0)%
+ \setlength{\AN@b}{\ANesep+\AN@evsp}%
+ \setlength{\AN@a}{\AN@x\p@-\AN@b*\ratio{\AN@x\p@-\AN@nodex\p@}{\AN@nodey\p@}}%
+ \drawline(\AN@Xpos,\AN@Ypos)(\AN@nodex,\AN@nodey)%
+ }{%
+ \setlength{\AN@a}{\ANesep*\ratio{\AN@x\p@-\AN@nodex\p@}{\AN@nodey\p@}-(\AN@ehsp)}%
+ \setlength{\AN@b}{\AN@a*\ratio{\AN@nodey\p@}{\AN@x\p@-\AN@nodex\p@}}%
+ \setlength{\AN@a}{\AN@x\p@-\AN@a}%
+ \drawline(\AN@Xpos,\AN@Ypos)(\AN@x,0)%
+ \setlength{\AN@a}{\ANesep*\ratio{\AN@x\p@-\AN@nodex\p@}{\AN@nodey\p@}+(\AN@ehsp)}%
+ \setlength{\AN@b}{\AN@a*\ratio{\AN@nodey\p@}{\AN@x\p@-\AN@nodex\p@}}%
+ \setlength{\AN@a}{\AN@x\p@-\AN@a}%
+ \drawline(\AN@Xpos,\AN@Ypos)(\AN@nodex,\AN@nodey)%
+ }%
+ \setlength{\AN@a}{\AN@x\p@-\ANesep*\ratio{\AN@x\p@-\AN@nodex\p@}{\AN@nodey\p@}}%
+ }{%
+ \setlength{\AN@a}{100pt*\ratio{\AN@nodex\p@-\AN@x\p@}{\AN@nodey\p@}}%
+ \ifthenelse{\lengthtest{\AN@a < \AN@c}}{%
+ \setlength{\AN@b}{\ANesep-\AN@evsp}%
+ \setlength{\AN@a}{\AN@x\p@+\AN@b*\ratio{\AN@nodex\p@-\AN@x\p@}{\AN@nodey\p@}}%
+ \drawline(\AN@Xpos,\AN@Ypos)(\AN@x,0)%
+ \setlength{\AN@b}{\ANesep+\AN@evsp}%
+ \setlength{\AN@a}{\AN@x\p@+\AN@b*\ratio{\AN@nodex\p@-\AN@x\p@}{\AN@nodey\p@}}%
+ \drawline(\AN@Xpos,\AN@Ypos)(\AN@nodex,\AN@nodey)%
+ }{%
+ \setlength{\AN@a}{\ANesep*\ratio{\AN@nodex\p@-\AN@x\p@}{\AN@nodey\p@}-(\AN@ehsp)}%
+ \setlength{\AN@b}{\AN@a*\ratio{\AN@nodey\p@}{\AN@nodex\p@-\AN@x\p@}}%
+ \setlength{\AN@a}{\AN@x\p@+\AN@a}%
+ \drawline(\AN@Xpos,\AN@Ypos)(\AN@x,0)%
+ \setlength{\AN@a}{\ANesep*\ratio{\AN@nodex\p@-\AN@x\p@}{\AN@nodey\p@}+(\AN@ehsp)}%
+ \setlength{\AN@b}{\AN@a*\ratio{\AN@nodey\p@}{\AN@nodex\p@-\AN@x\p@}}%
+ \setlength{\AN@a}{\AN@x\p@+\AN@a}%
+ \drawline(\AN@Xpos,\AN@Ypos)(\AN@nodex,\AN@nodey)%
+ }%
+ \setlength{\AN@a}{\AN@x\p@+\ANesep*\ratio{\AN@nodex\p@-\AN@x\p@}{\AN@nodey\p@}}%
+ }%
+ }%
+ \put(\AN@Xpos,\expandafter\AN@rmd\the\ANesep){\makebox(0,0){\AN@elabel}}%
+ }%
+ }%
+ }%
+ \put(\AN@nodex,\AN@nodey){\makebox(0,0)[bc]{\usebox{\node@content}}}%
+ \end{picture}%
+ \egroup%
+}
+\begin{tabular}[t]{c}\begin{node}[#1]{#2}}
+{\end{node}\end{tabular}}
+
+\endlinechar=13\relax
+
+\endinput