summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ecltree/ecltree.sty
blob: 927f50a54b0aa10e38e6c043d3b9a38fd0bb5f84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
% ecltree.sty (C) hideki isozaki Nov. 12, 1990
%
% In this style file, I intentionally didn't use ordinary 
% terms such as \tree, \subtree, \leaf etc.
% because I will use different tree macros in one file.
%
% This macro needs epic.sty
% Confirm your epic.sty does not contain \makeatother at EOF.

\makeatletter
\typeout{ECL Tree graph macro by isozaki, Nov. 12, 1990}

% Ignore End Of Line

\endlinechar=-1\relax

% Dimensions and Boxes : See below

\newdimen\@BundleWidth
\newdimen\@BundleDepth
\newdimen\@BundleHeight
\newbox\@NodeBox
\newdimen\GapDepth
\GapDepth=15\p@
\newdimen\GapWidth
\GapWidth=4\p@
\newdimen\EdgeLabelSep
\EdgeLabelSep=7\p@

%
%          ---------------                          -
%          | \@TopLabel  |                          |
%          ---------------         -                |
%     (\@SupportX,\@SupportY)      |                |
%              /   \               |                |
%             /     \              |                |
%            /       \             | \GapDepth      | \@BundleHeight
%           /         \            |                |
%          /           \           |                |
%(\@HandleX,0)          \          |                |
% --------------   --------------  -                -
% | \@NodeBox  |   | \@NodeBox  |  | \@BundleDepth  
% |            |   --------------  |                
% --------------                   -                
%              |---|
%            \GapWidth
%
% |-----------------------------|
%           \@PicWidth

%
% The main environment to make a (sub)tree: bundle
% \begin{bundle} \chunk_1 \chunk_2 ... \chunk_n \end{bundle}
%
\def\bundle#1{\leavevmode\hbox\bgroup
	\endlinechar=-1
	\def\@TopLabel{#1}
	\def\@HandleList{}
	\def\@EdgeLabels{}
	\edef\@EdgeLabelsY{\expandafter\@RemoveDim\the\EdgeLabelSep}
	\unitlength=\p@
	\@BundleWidth=\z@
	\@BundleHeight=\z@
	\@BundleDepth=\z@
	\ignorespaces}

\def\endbundle{
	\advance\@BundleWidth by -\GapWidth
	\hskip-\GapWidth
	\setbox\@NodeBox=\hbox{\vbox{\null\@TopLabel}}
	\advance\@BundleHeight by \GapDepth
	\advance\@BundleHeight by \ht\@NodeBox
	\advance\@BundleHeight by \dp\@NodeBox
	\vrule\@height\@BundleHeight\@width\z@\@depth\@BundleDepth
	\edef\@SupportY{\expandafter\@RemoveDim\the\GapDepth}
	\edef\@SupportX{\expandafter\@RemoveDim\the\@BundleWidth}
	\setbox\@NodeBox=\hbox to \z@{\hss\@TopLabel\hss}
	\hskip-\@BundleWidth
	\edef\@EdgeLabels{\@EdgeLabels{}}
	\edef\@PicWidth{\expandafter\@RemoveDim\the\@BundleWidth}
	\@BundleWidth=0.5\@BundleWidth
	\edef\@SupportX{\expandafter\@RemoveDim\the\@BundleWidth}
	\@DrawBundle}


\def\@DrawBundle{
	\begin{picture}(\@PicWidth,0)(0,0)
	\edef\@HandleList{\expandafter\@cdr\@HandleList\@nil}
	\@for\@HandleX:=\@HandleList\do{
		\@DrawLine(\@SupportX,\@SupportY)(\@HandleX,0)
		\put(\@HandleX,\@EdgeLabelsY){
			\makebox(0,0){\expandafter\@car\@EdgeLabels\@nil}}
		\edef\@EdgeLabels{\expandafter\@cdr\@EdgeLabels\@nil}}
	\put(\@SupportX,\@SupportY){\raise\dp\@NodeBox\box\@NodeBox}
	\end{picture}\egroup}


%
%  \chunk[#1]{#2} means a leaf or a subtree.
%   #1  ... Label for the edge which connects the leaf or the subtree
%           with its parent node. (optional argument)
%   #2  ... Label for the leaf or the subtree 
%

\def\chunk{\@ifnextchar[{\@chunk}{\@chunk[]}}

\def\@chunk[#1]#2{\edef\@EdgeLabels{\@EdgeLabels{#1}}
	\setbox\@NodeBox=\vtop{\null\hbox{#2}}
	\advance\@BundleWidth by 0.5\wd\@NodeBox
	\ifnum\@BundleDepth<\dp\@NodeBox
		\@BundleDepth=\dp\@NodeBox\fi
	\edef\@HandleList{\@HandleList,
		\expandafter\@RemoveDim\the\@BundleWidth}
	\advance\@BundleWidth by 0.5\wd\@NodeBox
	\advance\@BundleWidth by \GapWidth
	\box\@NodeBox\hskip\GapWidth
	\ignorespaces}

%  To change line attribute
%  ex.
%  \drawwith{\path}        ... efficient solid line defined by eepic.sty
%  \drawwith{\dashline{2}} 

\def\drawwith#1{\def\@DrawLine{#1}}

% Default
\drawwith{\drawline}

%  Ordinary catcode for p and t is 11
%  Application of \the to dimen generates text such as 1.0pt.
%  This pt's catcode is 12.

{\catcode`\p=12 \catcode`\t=12
\gdef\@RemoveDim#1pt{#1}}

% Restore original End Of Line

\endlinechar=13\relax

\endinput