setup-boxfig.tex 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. \def\IgnoreLineBreaks{\catcode'15=9 \catcode'12=9}
  2. \def\IgnoreWhiteSpace{\catcode'11=9 \catcode'40=9 \IgnoreLineBreaks}
  3. \def\DontIgnoreWhiteSpace{\catcode'12=\active\catcode'15=5\catcode'11=10\catcode'40=10}
  4. %\font \pipefont= lcirclew10
  5. \font \pipefont= circle10
  6. \font \foofont = cmr10
  7. %\font \foofont = amr10
  8. \IgnoreWhiteSpace
  9. \let \adv=\advance
  10. \def\he{height}
  11. \def\wi{width}
  12. \def\de{depth}
  13. \newdimen \stroke
  14. \stroke= \fontdimen8\pipefont % thickness of line in circles
  15. \newdimen \radius \radius=6pt % radius of circles
  16. \newdimen\irad \irad=\radius\advance\irad by -.5\stroke
  17. \newdimen\orad \orad=\radius\advance\irad by .5\stroke
  18. \newbox\BStrutbox
  19. \setbox\BStrutbox\hbox{\vrule\wi0pt\he10pt\de10pt}
  20. \def\BoxStrut{\unhcopy\BStrutbox}
  21. % Arrows
  22. \newdimen\ArrowShift
  23. \ArrowShift=\fontdimen22\tensy
  24. \advance\ArrowShift by -0.5\stroke
  25. \def\StrikeOut #1
  26. { \setbox0\hbox{#1}
  27. \hbox to 1\wd0
  28. { \vrule \he\stroke\de0pt\wi\wd0
  29. \hskip-\wd0
  30. \unhbox0
  31. }
  32. }
  33. \def\LeftArrow
  34. { \hskip 0.5\stroke
  35. \StrikeOut{\lower\ArrowShift\hbox to 10pt{\tensy\char'40\hss}}
  36. }
  37. \def\RightArrow
  38. { \StrikeOut{\lower\ArrowShift\hbox to 10pt{\hss\tensy\char'41}}
  39. \hskip 0.5\stroke
  40. }
  41. \def\ArrowLine
  42. { \StrikeOut{\hskip 10pt\hskip 0.5\stroke}
  43. }
  44. \def\LeftToRight
  45. { \let\RightSideArrow=\ArrowLine
  46. \let\LeftSideArrow=\RightArrow
  47. }
  48. \def\RightToLeft
  49. { \let\LeftSideArrow=\ArrowLine
  50. \let\RightSideArrow=\LeftArrow
  51. }
  52. \def\NoArrows
  53. { \let\LeftSideArrow=\ArrowLine
  54. \let\RightSideArrow=\ArrowLine
  55. }
  56. % boxes around words
  57. \let\NonterminalFont=\tenrm
  58. \newbox\TStrutbox
  59. \setbox0\hbox{\NonterminalFont{Bg}}
  60. \setbox\TStrutbox\hbox{\vrule\wi0pt\he\ht0\de\dp0}
  61. \def\TextStrut{\unhcopy\TStrutbox}
  62. \def\HorzLine{\hrule \he \stroke \de 0pt}
  63. \def\HFil{\leaders\HorzLine\hfil}
  64. \def\HFill{\leaders\HorzLine\hfill}
  65. \def\Nonterminal#1
  66. {\setbox1\vbox to 0pt{
  67. \vss
  68. \hbox{\TextStrut\NonterminalFont\space#1\space\hskip-\stroke}
  69. \vss}
  70. \hbox{
  71. \BoxStrut
  72. \LeftSideArrow
  73. \lower\irad\vbox{
  74. \TopSquare
  75. \copy1
  76. \BotSquare}
  77. \RightSideArrow}
  78. }
  79. \def\TopSquare
  80. { \hbox{
  81. \vrule\he\stroke\de\irad\wi\stroke
  82. \vrule\he\stroke\de0pt\wi\wd1
  83. \vrule\he\stroke\de\irad\wi\stroke}
  84. }
  85. \def\BotSquare
  86. { \hbox{
  87. \vrule\he\orad\de0pt\wi\stroke
  88. \vrule\he\stroke\de0pt\wi\wd1
  89. \vrule\he\orad\de0pt\wi\stroke}
  90. }
  91. \def\\#1{\Nonterminal{#1}\HFil}
  92. \def\last#1{{\def\RightSideArrow{}\Nonterminal{#1}}}
  93. % piping
  94. %\def\foo{\rlap{\foofont\char'40}}
  95. \def\foo{\null}
  96. \def\FulVert{\vrule \wi\stroke\foo\hskip-\stroke}
  97. \def\TopVert{\vrule\de-\irad \wi\stroke\foo\hskip-\stroke}
  98. \def\BotVert{\vrule\he-\orad \wi\stroke\foo\hskip-\stroke}
  99. \def\Center#1,#2.
  100. {\hskip\radius\foo#1\lower.5\stroke\hbox{\pipefont#2}\hskip\radius}
  101. \def\ru{\char'10\hskip -2\radius}
  102. \def\rd{\char'11\hskip -2\radius}
  103. \def\ld{\char'12\hskip -2\radius}
  104. \def\lu{\char'13\hskip -2\radius}
  105. \def\thru{\hskip-\radius\vrule\he\stroke\de0pt\wi2\radius\hskip\radius\hskip-2\radius}
  106. \def\Center#1,#2.
  107. {\foo\hskip\radius#1{\pipefont#2\unskip}\hskip-\radius}
  108. \def\LT{\Center\BotVert,\lu.}
  109. \def\LU{\Center\FulVert,\lu.}
  110. \def\LL{\Center\FulVert,\ld.}
  111. \def\LB{\Center\TopVert,\ld.}
  112. \def\LMid{\Center\TopVert\BotVert,\rd\ru\thru.}
  113. \def\LMU{\Center\TopVert,\rd\thru.}
  114. \def\LML{\Center\BotVert,\ru\thru.}
  115. \def\LFD{\Center\FulVert,\ru\thru.}
  116. \def\LS{\Center\TopVert\BotVert,\rd\ru.}
  117. \def\RT{\Center\BotVert,\ru.}
  118. \def\RU{\Center\FulVert,\ru.}
  119. \def\RL{\Center\FulVert,\rd.}
  120. \def\RB{\Center\TopVert,\rd.}
  121. \def\RMid{\Center\TopVert\BotVert,\ld\lu\thru.}
  122. \def\RMU{\Center\TopVert,\ld\thru.}
  123. \def\RML{\Center\BotVert,\lu\thru.}
  124. \def\Cross{\Center\FulVert,\thru.}
  125. \def\LR{\Center,\thru.}
  126. \def\TB{\Center\FulVert,.}
  127. % ShiftBox
  128. \newbox\x
  129. \newbox\y
  130. \newbox\tempy
  131. \newbox\z
  132. \newbox\tempz
  133. \def\ShiftBox#1{
  134. \savemod
  135. \saverulebox
  136. \setbox\x
  137. \vbox{ \everycr{\noalign{{\modifyrulebox\global\setbox\z\hbox{}}}}
  138. \halign{&\setbox\x\hbox{##}
  139. \global \setbox\z\hbox{\unhbox\z\vrule\he\ht\x\de\dp\x\wi0pt}
  140. \unhbox\x
  141. \cr
  142. #1}}%
  143. \lower\ht\y\box\x\HFil
  144. \restoremod
  145. \restorerulebox
  146. }
  147. \def\saverulebox{
  148. \setbox\tempy\box\y
  149. \global \setbox\y\vbox{}
  150. \setbox\tempz\box\z
  151. \global \setbox\z\hbox{}
  152. }
  153. \def\restorerulebox{
  154. \global \setbox\y\box\tempy
  155. \global \setbox\z\box\tempz
  156. }
  157. \def\topmod{}
  158. \def\thisrow{\global\let\modifyrulebox\firstmod}
  159. \def\firstmod{
  160. \global\setbox\y\vbox{\hrule\he0pt\wi0pt\de\dp\z}
  161. \global\let\modifyrulebox\latermod
  162. }
  163. \def\latermod{
  164. \global\setbox\y\vbox{\unvbox\y\hrule\he\ht\z\de\dp\z\wi0pt}
  165. }
  166. \def\savemod{
  167. \let\tempmod\modifyrulebox
  168. \global \let\modifyrulebox\topmod
  169. }
  170. \def\restoremod{
  171. \global\let\modifyrulebox\tempmod
  172. }
  173. \DontIgnoreWhiteSpace