summaryrefslogtreecommitdiff
path: root/macros/generic/misc/emtrees.tex
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/generic/misc/emtrees.tex
Initial commit
Diffstat (limited to 'macros/generic/misc/emtrees.tex')
-rw-r--r--macros/generic/misc/emtrees.tex87
1 files changed, 87 insertions, 0 deletions
diff --git a/macros/generic/misc/emtrees.tex b/macros/generic/misc/emtrees.tex
new file mode 100644
index 0000000000..3c9c5e1a3f
--- /dev/null
+++ b/macros/generic/misc/emtrees.tex
@@ -0,0 +1,87 @@
+%From: hwb@texnix.stgt.sub.org (Harald Boegeholz)
+%Newsgroups: comp.text.tex
+%Date: 14 Jan 91 13:44:29 GMT
+%
+%Hi!
+%
+%Some time ago I wrote some TeX-macros to typeset trees. Since
+%two people asked recently, here they are (quite short, so I thought
+%I might post). Be aware, though, of two possible problems:
+% 1. The macros use the \specials defined by emTeX. If your DVI-driver
+% doesn't support these, you won't see any lines.
+% 2. The semantic nest size required is considerable (too many boxes
+% inside of boxes inside of boxes...), so you'll possibly need
+% a TeX which is "large" in this respect for typesetting complex trees.
+%
+%Hope this helps
+%Harald
+%------------------ cut here with a sharp knife ------------------------
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% tree macros by Harald Boegeholz
+% This file uses the \specials defined by emTeX to draw the lines!
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newcount\pointnumber \pointnumber=0
+\newcount\father
+\font\nodefont=cmr7
+\def\nextpoint{\global\advance\pointnumber by 1\relax}
+\def\endsubtrees{\endsubtrees}
+\def\tn#1{\vbox{%
+ \vskip.5mm
+ \hbox{\nodefont\hskip1ex\relax #1\hskip1ex}
+ \vskip.5mm
+ }%
+}
+\def\tree#1#2{%
+ \vtop{%
+ \nextpoint
+ \father=\pointnumber
+ \halign{\hfil##\hfil\cr
+ #1\cr
+ \special{em:point \number\father}\cr
+ \noalign{\vskip5mm}
+ \hbox{\subtrees#2\endsubtrees}\cr
+ }%
+ }%
+}%
+\def\subtrees#1{\ifx#1\endsubtrees\let\next\relax\else
+ \vbox{\halign{\hfil##\hfil\cr
+ \nextpoint
+ \special{em:point \number\pointnumber}%
+ \special{em:line \number\pointnumber h,\number\father h}\cr
+ #1\cr
+ }}%
+ \let\next\subtrees\fi
+ \next
+}
+\def\labeledtree#1#2{\vbox{\offinterlineskip\halign{\hfil##\hfil\cr
+ #1\cr
+ \noalign{\vskip3pt}%
+ $\scriptstyle#2$\cr
+}}}
+
+\parindent0pt
+\raggedbottom
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% macros end here ... sample follows:
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\endinput
+
+{\labeledtree{%
+ {\tree{\tn{1}}{%
+ {\tree{\tn{2}}{%
+ {\tn{3}}%
+ {\tn{4}}%
+ }}%
+ {\tree{\tn{5}}{%
+ {\tn{6}}%
+ }}%
+ }}%
+}{[1,2,2,1,5]}}%
+
+\bye
+------------------ cut here with a sharp knife ------------------------
+--
+Harald Boegeholz |Home: hwb@texnix.stgt.sub.org (read daily)
+ |University: boegehol@az3.informatik.uni-stuttgart.de
+ | ^ please use the latter for large (>100k) mails