Debian Codegraph @

texmf-dist/doc/generic/dratex/Examples.tex

raw
1 %\def\TexFiles{}
2 \def\ext{Changeable}
3
4
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 %% Compile this file with TeX and review the document. %%
7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8 \hfill 15 Apr. 94
9 \bigskip
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 % Code of examples and exercises from %
12 % %
13 % TeX and LaTeX: Drawing and Literate Programming %
14 % %
15 % [email protected] %
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17
18
19 \immediate\write16{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}
20 \immediate\write16{<<< tex Examples.tex <<<<<<<<<<<}
21 \immediate\write16{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}
22
23
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 %%
27 %%
28 \input ProTex.sty %%%%%%%%%%%%%%%%%%%%
29
30
31 \expandafter\def\csname :warn\endcsname#1{}
32 \Code\top{}{\immediate\write16{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}
33 \immediate\write16{<<<<< \op \name.\ext}
34 \immediate\write16{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}
35
36 % \com
37 }
38
39 \ifx \TexFiles\empty %%%%%%%%%%%%%%%%%%%%%%%%
40 \def\tex{tex}
41
42 \def\DEFEND{\% LaTeX requires a {\tt\string\Defend} here \%}
43
44 \Code\Open{}{\files
45 \startInput
46 }
47
48 \Code\Close{}{
49 \endInput
50 \\bye}
51 \else %%%%%%%%%%%%%%%%%%%%%%%%
52 \def\tex{latex}
53
54 \Code\DEFEND{{\it LaTeX requires a {\tt\string\Defend}
55 here}}{\% LaTeX requires a \string\Defend here \%\string\Defend}
56
57 \Code\Open{}{\\documentstyle{book}
58 \files
59 \\begin{document}
60 \startInput}
61
62 \Code\Close{}{
63 \endInput
64 \\end{document}}
65 \fi %%%%%%%%%%%%%%%%%%%%%%%%
66
67 \Code\fileD{}{
68 \\input DraTex.sty }
69
70 \Code\fileAD{}{
71 \\input DraTex.sty
72 \\input AlDraTex.sty }
73
74 \Code\fileP{}{
75 \\input ProTex.sty }
76
77 \Code\startInput{}{\\Draw}
78 \Code\endInput{}{\\EndDraw}
79
80 \AlProTex{\ext,<<<>>>,[],list,|,ShowFile,NoShow} %%%%%%%%%%%%%%%%%%%%
81
82 \let\SC=\ShowCode
83 \Code\execute{}<<<
84 >>>
85
86 \newcount\exron
87 \def\nop#1{\ifnum \exron>0 #1 \fi}
88
89 \catcode`\^^M=13 \catcode`\#=12 %
90 \def\<<<{%
91 \edef\temp{%
92 \noexpand\AppendCode\noexpand\execute<<<
93 \nop#\op\space\space \name.\ext\space\space\space # \com
94 \nop#xdvi\space\space \name.dvi
95 >>>}\ShowOff\temp\ShowOn%
96 \def\ShowCode{%
97 \expandafter\OutputCode\csname\name\endcsname \def\top
98 {} \global\let\ShowCode=\SC \ShowCode}%
99 \expandafter\Code\csname\name\endcsname{}<<<
100 \top}%
101 \catcode`\^^M=5 \catcode`\#=6
102
103 \def\newpage{\def\newpage{\par\vfill\break}}
104 \newcount\1 \newcount\2 \newcount\3
105
106 \def\ForTex{tex}
107
108 \def\Ex#1#2#3{\global\advance\exron by -1
109 \edef\op{#1}
110 \edef\For{for \ifx \op\ForTex \else La\fi TeX}
111 \def\com{#2}
112 \def\name{#3} \hrule
113 \medskip\noindent$\underline{\hbox{#1\quad\name.\ext}}$
114 \qquad{\it #2\/} {\rm(\For)}\medskip}
115
116 \def\Exr#1#2#3{\global\exron=2
117 \setbox0=\hbox{\global\1#1 \global\2#2 \global\3#3}
118 \Ex{\tex}{Exercise \the\1.\the\2.\the\3}{exr#1#2#3}}
119
120 \def\Lib#1{\newpage\hrule
121 \noindent\hfil{\bf \strut#1}\hrule}
122
123 \hbadness=10000 \vbadness=10000 \hfuzz=99in \vfuzz=99in
124 %%
125 %%
126 %%
127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
129
130 \noindent NOTES
131
132 (a) If you want to get TeX files instead of LaTeX files, remove `\%'
133 from the first line of file `{\tt Examples.tex}'.%%% first line of this file
134
135
136 (b) If you want different extensions in the files' names,
137 change the definition of {\tt\string\ext} in the second line
138 of file `{\tt Examples.tex}'.%%% second line of this file
139
140 (c) Files carrying names that start with `exr' have been retrieved
141 from exercises. Many of these files are incomplete, and they expect
142 that the reader will provide the missing code. (La)TeX will prompt you
143 with `?' on incomplete files. In such cases, type `x' followed by
144 RETURN.
145
146 \bigskip \Lib{DraTeX} \def\files{\fileD}
147
148 \Ex{tex}{First example in section 6.2}{sec62a}
149
150 \<<<
151 \input DraTex.sty
152 \Draw
153 \LineAt(0.1, 0,-18,-10)
154 \LineAt(-18,-10,- 6, 26)
155 \LineAt(- 6, 26, 18,- 4)
156 \LineAt( 18,- 4, 12,-40)
157 \LineAt( 18,- 4, 24,-40)
158 \LineAt( 18,- 4, 58,- 4)
159 \LineAt( 58,- 4, 52,-40)
160 \LineAt(58,-4,64,-40) \LineAt(58,-4,66,4)
161 \EndDraw
162 \bye >>>
163
164 \Ex{latex}{First example in section 6.2}{sec62b}
165
166 \<<<
167 \documentstyle{report}
168 \input DraTex.sty
169 \begin{document}
170 \Draw
171 \LineAt(0.1, 0,-18,-10)
172 \LineAt(-18,-10,- 6, 26)
173 \LineAt(- 6, 26, 18,- 4)
174 \LineAt( 18,- 4, 12,-40)
175 \LineAt( 18,- 4, 24,-40)
176 \LineAt( 18,- 4, 58,- 4)
177 \LineAt( 58,- 4, 52,-40)
178 \LineAt(58,-4,64,-40) \LineAt( 58,-4,66,4)
179 \EndDraw
180 \end{document}>>>
181
182
183 \Ex{latex}{First example in section 6.2---second version}{sec62c}
184
185 \<<<
186 \documentstyle[DraTex]{report}
187 \begin{document}
188 \Draw
189 \LineAt(0.1, 0,-18,-10)
190 \LineAt(-18,-10,- 6, 26)
191 \LineAt(- 6, 26, 18,- 4)
192 \LineAt( 18,- 4, 12,-40)
193 \LineAt( 18,- 4, 24,-40)
194 \LineAt( 18,- 4, 58,- 4)
195 \LineAt( 58,- 4, 52,-40)
196 \LineAt(58,-4,64,-40) \LineAt(58,-4,66,4)
197 \EndDraw
198 \end{document}>>>
199
200
201
202 \Exr672
203
204 \<<<
205 |Open
206 \MarkLoc(a) \Move(50,0)
207 \MarkLoc(A) \Move(50,0)
208 \MarkLoc(b) \Move(-30,30)
209 \MarkLoc(B) \Move(-30,30)
210 \MarkLoc(c) \Move(-20,-30)
211 \MarkLoc(C)
212 \Curve(A,b,b,B)
213 \Curve(B,c,c,C)
214 \Curve(C,a,a,A)
215 |Close>>>
216
217
218 \Ex{tex}{First example in section 6.1}{sec61}
219
220 \<<<
221 \input DraTex.sty
222
223 We can draw clocks of
224 different styles and sizes.
225
226 \Draw
227 \Move(0,20) \Line(0,-50) \Line(50,0)
228 \PenSize(1.5pt) \Line(0,50) \Line(-50,0)
229 \Move(5,-25) \Text(--9--)
230 \Move(20,-18) \Text(--6--)
231 \Move(20,18) \Text(--3--)
232 \Move(-20,18) \Text(--12--)
233 \Move(0,-18) {\RotateTo(60) \LineF(19)}
234 \RotateTo(210) \LineF(14)
235 \EndDraw
236
237 We can draw people of
238 different shapes and looks.
239
240 \Draw(0.6pt,0.6pt)
241 \DrawOvalArc(30,45)(0,180)
242 \DrawOvalArc(30,12)(180,360)
243 \DrawOvalArc(60,25)(140,400)
244 \Move(0,5)
245 \DrawOvalArc(30,60)(225,315)
246 \DrawOvalArc(20,52)(260,280)
247 \Move(-10,-37) {\Text(--$\cdotp$--)} \Text(--o--)
248 \Move(20,0) {\Text(--$\cdotp$--)} \Text(--o--)
249 \EndDraw
250
251 And we can produce many other
252 types of drawings. \bye>>>
253
254
255
256 \Ex{latex}{First example in section 6.1}{sec61a}
257
258 \<<<
259 \documentstyle{report}
260 \input DraTex.sty
261 \begin{document}
262
263 We can draw clocks of
264 different styles and sizes.
265
266 \Draw
267 \Move(0,20) \Line(0,-50) \Line(50,0)
268 \PenSize(1.5pt) \Line(0,50) \Line(-50,0)
269 \Move(5,-25) \Text(--9--)
270 \Move(20,-18) \Text(--6--)
271 \Move(20,18) \Text(--3--)
272 \Move(-20,18) \Text(--12--)
273 \Move(0,-18) {\RotateTo(60) \LineF(19)}
274 \RotateTo(210) \LineF(14)
275 \EndDraw
276
277 We can draw people of
278 different shapes and looks.
279
280 \Draw(0.6pt,0.6pt)
281 \DrawOvalArc(30,45)(0,180)
282 \DrawOvalArc(30,12)(180,360)
283 \DrawOvalArc(60,25)(140,400)
284 \Move(0,5)
285 \DrawOvalArc(30,60)(225,315)
286 \DrawOvalArc(20,52)(260,280)
287 \Move(-10,-37) {\Text(--$\cdotp$--)} \Text(--o--)
288 \Move(20,0) {\Text(--$\cdotp$--)} \Text(--o--)
289 \EndDraw
290
291 And we can produce many other
292 types of drawings. \end{document}>>>
293
294 \Ex{latex}{First example in section 6.1---second version}{sec61b}
295
296 \<<<
297 \documentstyle[DraTex]{report}
298 \begin{document}
299
300 We can draw clocks of
301 different styles and sizes.
302
303 \Draw
304 \Move(0,20) \Line(0,-50) \Line(50,0)
305 \PenSize(1.5pt) \Line(0,50) \Line(-50,0)
306 \Move(5,-25) \Text(--9--)
307 \Move(20,-18) \Text(--6--)
308 \Move(20,18) \Text(--3--)
309 \Move(-20,18) \Text(--12--)
310 \Move(0,-18) {\RotateTo(60) \LineF(19)}
311 \RotateTo(210) \LineF(14)
312 \EndDraw
313
314 We can draw people of
315 different shapes and looks.
316
317 \Draw(0.6pt,0.6pt)
318 \DrawOvalArc(30,45)(0,180)
319 \DrawOvalArc(30,12)(180,360)
320 \DrawOvalArc(60,25)(140,400)
321 \Move(0,5)
322 \DrawOvalArc(30,60)(225,315)
323 \DrawOvalArc(20,52)(260,280)
324 \Move(-10,-37) {\Text(--$\cdotp$--)} \Text(--o--)
325 \Move(20,0) {\Text(--$\cdotp$--)} \Text(--o--)
326 \EndDraw
327
328 And we can produce many other
329 types of drawings. \end{document}>>>
330
331
332 \Exr732
333
334 \<<<
335 |Open
336 \font\ARROWS=line10\space scaled\magstep5
337 \font\CIRCLES=lcircle10\space scaled\magstep5
338 % \newfont{\ARROWS}{line10\space scaled\magstep5}
339 % \newfont{\CIRCLES}{lcircle10\space scaled\magstep5}
340
341 \Text(--\CIRCLES \char 10--)
342 \Text(--\CIRCLES \char 11--) \Text(--\ARROWS \char 55--)
343 \Text(--\CIRCLES \char 110--)\EntryExit(-1,0,-1,0)
344 \Text(--\CIRCLES \char 114--)|Close>>>
345
346 \Exr741
347
348 \<<<
349 |Open
350 \Ragged(8)
351 \Line(10,-10) \Line(10,20)
352 \LineTo(0,0)
353 |Close>>>
354
355
356 \Ex{\tex}{First example in section 8.1}{sec81}
357
358 \<<<
359 |Open
360 \ThreeDim(-150,-60,-600)
361 \Line(60,0,0) \Line(0,0,60)
362 \Line(-60,0,0) \Line(0,0,-60)
363 \LineTo(0,60,0) \Line(60,0,0)
364 \Line(0,-60,0)
365 \LineAt(0,60,0,0,60,60)
366 \Line(0,-60,0)
367 \EndThreeDim |Close>>>
368
369
370 \Ex{\tex}{Example of USA map in section 9.3}{usa}
371
372 \<<<
373 |Open(0.9pt,0.9pt)
374 \Table\USA{ % California
375 -60,-35 & -77,-30 & -80,
376 -20 & -90,-15 & -100,40 &
377 % Oregon
378 -100,50 & -90,80 &
379 % Wash
380 -90,95 & -78,90 & -75,95 &
381 % Minn
382 100,70 & 85,60 &
383 % Wisc-Mich
384 95,60 & 105,65 & 102,63 & 110,60 & 125,60 & 110,55 & 110,30 &
385 115,25 & 120,30 & 115,40 & 115,50 & 120,55 & 130,55 & 140,40 &
386 135,25 &
387 % Ohio-NY-Vt
388 145,25 & 155,30 & 160,45 & 175,45 & 175,55 & 180,60 & 195,65 &
389 % Maine
390 200,75 & 200,85 & 205,90 & 210,90 & 215,80 & 220,75 & 205,60 & 205,50 &
391 % Mass--NY
392 210,43 & 208,47 & 215,43 & 190,30 & 202,35 &
393 % NJ--Va
394 197,25 & 190,18 & 185,20 & 190,15 & 190,5 & 182,18 & 182,0 & 185,0 &
395 % NC
396 190,-8 & 185,-4 & 183,-6 & 186,-6 & 182,-15 &
397 190,-18 & 190,-10 & 192,-10 &
398 195,-18 &
399 % Ga-Fl
400 165,-40 & 160,-50 & 175,-80 & 175,-90 & 170,-100 & 165,-100 &
401 155,-80 & 155,-65 & 145,-60 & 140,-62 & 136,-62 & 120,-60 &
402 % Alaba--La
403 102,-63 & 107,-67 & 107,-72 & 110,-75 & 90,-65 &
404 78,-65 &
405 % Texas
406 62,-78 & 57,-78 & 50,-82 & 53,-92 & 48,-90 & 25,-65 & 15,-65 &
407 15,-68 & -10,-50 &
408 % New Mexico
409 -40,-50 &
410 % Back to California
411 -60,-35 }
412 { \USA(0,0){\MoveTo} \USA(1,99){\LineTo} } \Text(--USA--)
413 \Scale(0.5,0.5) \USA(46,46){\MoveTo} \USA(47,92){\LineTo}
414 \MoveTo(-30,0) \MarkLoc(a) \USA(0,0){\Move} \MarkLoc(b)
415 \USA(0,46){{\LineToLoc(b)} \MarkLoc(b) \MoveToLoc(a) \Move}
416 |Close>>>
417
418
419 \Exr{10}1{1a}
420 \<<<
421 |Open
422 \Text(--Government~%
423 Bonds (\%)--)
424 \Table\B{Britain,9.59 &
425 Canada,7.98 & Japan,5.46 &
426 U.S., 6.84 & Mexico,14.9}
427 \B(0,4){\PutBar}
428 |Close >>>
429
430 \Exr{10}1{1b}
431 \<<<
432 |Open
433 \chick(0,75) \Scale(-1,1)
434 \chick(0,140)
435 |Close >>>
436
437 \Exr{10}1{1c}
438 \<<<
439 |Open
440 \Table\x{ 30,40
441 & 15,60 & 27,15 & 35,35
442 & 50,45 & 25,70 & 20,20
443 & 25,75 } \x(0,99){\Tr}
444 |Close >>>
445
446 \Exr{10}1{1d}
447 \<<<
448 |Open
449 \sqr(-24,0)
450 \sqr(0,32)
451 \sqr(24,-32)
452 |Close >>>
453
454 \Exr{10}1{1e}
455 \<<<
456 |Open
457 \engine(90) \MoveTo(50,0)
458 \engine(180) \MoveTo(100,0)
459 \engine(-30)
460 |Close >>>
461
462 \Exr{10}1{1f}
463 \<<<
464 |Open
465 \MarkLoc(A)
466 \spring(110) \Rotate(70)
467 \spring(60) \MarkLoc(B)
468 \DSeg\RotateTo(B,A)
469 \LSeg\spring(B,A)
470 |Close >>>
471
472 \Exr{10}21
473 \<<<
474 |Open
475 \new(BODY) \<BODY>(20)
476 \LineF(20) \Rotate(55) \LineF(16)
477 \new(hand) \<BODY>(140) \LineF(35)
478 \new(hand) \<BODY>(90) \LineF(7)
479 \new(head) \<BODY>(-60) \LineF(19)
480 \new(left-leg) \<BODY>(210) \LineF(12)
481 \Rotate(30) \LineF(14) \new(right-leg)
482 \Do(1,11){\I+15; \<head>(\Val\I)
483 \LineF(11)}
484 |Close >>>
485
486
487 \Exr{10}22
488
489 \<<<
490 |Open
491 \def\DefineSymbol#1{%
492 \Indirect\Define<#1>}
493
494 \def\DrawText(--#1--){%
495 \let\xNextSym=\xDrawSym \xNextSym#1{}}
496
497 \def\xDrawSym#1{\def\temp{#1}%
498 \ifx \temp\empty \let \xNextSym=\relax
499 \else \Indirect<#1>\fi \xNextSym }
500
501 \DefineSymbol A{{ \Line(21,60)
502 \Line(21,-60) \Move(-7,20)
503 \Line(-28,0) } \Move(52,0) }
504 \DefineSymbol B{{ \DrawText(--P--)
505 \Move(-25,18)
506 \DrawOvalArc(15,18)(-90,90)
507 \Move(0,-18) \Line(-25,0)}
508 \Move(50,0) } \DefineSymbol P
509 {{ \Line(0,60) \Line(25,0)
510 \Move(0,-12) \DrawOvalArc(15,12)(-90,90)
511 \Move(0,-12) \Line(-25,0) } \Move(50,0) }
512 \DefineSymbol C{{ \Move(20,30)
513 \DrawOvalArc(20,30)(45,315) } \Move(46.6,0) }
514 \DefineSymbol D{{ \Line(0,60) \Line(20,0)
515 \Move(0 ,-30) \DrawOvalArc(20,30)(-90,90) \Move(0,-30)
516 \Line(-20,0) } \Move(50,0) }
517 \DefineSymbol E{{ \DrawText(--F--) \Move(-50,0)
518 \Line(40,0) } \Move(50,0) }
519 \DefineSymbol F{{ \Line(0,60) \Line(40,0)
520 \Move(-40,-30) \Line(30,0) } \Move(50,0) }
521 \DefineSymbol G{{ \DrawText(--C--)
522 \Move(-10,30) {\Line(-20,0)} \Line(0,-30) }
523 \Move(46.6,0) }
524 \DefineSymbol H{{ \Line(0,60) \Move(40,0)
525 \Line(0,-60) \Move(0,30) \Line(-40,0) } \Move(50,0) }
526 \DefineSymbol I{{ \Line(0,60) } \Move(10,0) }
527 \DefineSymbol J{{ \Move(20,17) \DrawOvalArc(20,17)(180,360)
528 \Move(20,0) \Line(0,43) } \Move(50,0) }
529 \DefineSymbol K{{ \Line(0,60) \Move(0,-35)
530 \Line(40,35) \Move(-32,-28) \Line(32,-32) } \Move(50,0) }
531 \DefineSymbol L{{ { \Line(0,60) } \Line(40,0) } \Move(50,0) }
532 \DefineSymbol M{{ \Line(0,60) \Line(25,-60)
533 \Line(25,60) \Line(0,-60) } \Move(60,0) }
534 \DefineSymbol N{{ \Line(0,60) \Line(40,-60)
535 \Line(0,60) } \Move(50,0) }
536 \DefineSymbol O{{ \Move(22,30) \DrawOval(22,30) } \Move(54,0) }
537 \DefineSymbol P{{ \Line(0,60) \Line(25,0)
538 \Move(0,-12) \DrawOvalArc(15,12)(-90,90)
539 \Move(0,-12) \Line(-25,0) } \Move(50,0) }
540 \DefineSymbol Q{{ \DrawText(--O--) \Move(-10,-5)
541 \Line(-15,15) } \Move(55,0) }
542 \DefineSymbol R{{ \DrawText(--P--) \Move(-10,0)
543 \Line(-15,36) } \Move(50,0) }
544 \DefineSymbol S{{ \Move(20,18) \DrawOvalArc(20,18)(-140,90)
545 \Move(0,30) \DrawOvalArc(20,12)(40,270) } \Move(50,0) }
546 \DefineSymbol T{{ \Move(22,0) \Line(0,60) \Move(-22,0)
547 \Line(44,0) } \Move(54,0) }
548 \DefineSymbol U{{ \Move(20,15) \DrawOvalArc(20,15)(180,360)
549 \Move(-20,0) \Line(0,45) \Move(40,0) \Line(0,-45) }
550 \Move(50,0) }
551 \DefineSymbol V{{ \Move(0,60) \Line(22,-60)
552 \Line(22,60) } \Move(54,0) }
553 \DefineSymbol W{{ \Move(0,60) \Line(15,-60)
554 \Line(15,60) \Line(15,-60) \Line(15,60) } \Move(70,0) }
555 \DefineSymbol X{{ \Line(40,60) \Move(-40,0)
556 \Line(40,-60) } \Move(50,0) }
557 \DefineSymbol Y{{ \Move(20,0) \Line(0,34) { \Line(-20,26)}
558 \Line(20,26) } \Move(50,0) }
559 \DefineSymbol Z{{ \Move(0,60) \Line(40,0) \Line(-40,-60)
560 \Line(40,0) } \Move(50,0) }
561 \DefineSymbol 0{{ \Move(25,30) \DrawOval(25,30) } \Move(60,0) }
562 \DefineSymbol 1{{ \Line(0,60) } \Move(10,0) }
563 \DefineSymbol 2{{ \MarkLoc(a) \Move(0,10)
564 \MarkLoc(a') \Move(40,30) \MarkLoc(b)
565 \Move(0,-10) \MarkLoc(b') \Curve(a,a',b',b)
566 \Move(-20,10) \DrawOvalArc(20,20)(0,180)
567 \Move(-20,-40) \Line(40,0) } \Move(50,0) }
568 \DefineSymbol 3{{ \MarkLoc(a') \Move(0,10) \MarkLoc(a)
569 \Move(20,-10) \MarkLoc(b) \Move(-10,0) \MarkLoc(b')
570 \Curve(a,a',b',b) \Move(22,0) \MarkLoc(b')
571 \Move(8,8) \MarkLoc(a') \Move(0,10) \MarkLoc(a)
572 \Curve(a,a',b',b) \Move(0,10) \MarkLoc(a')
573 \Move(-8,8) \MarkLoc(b') \Move(-10,0)
574 \MarkLoc(b) \Curve(a,a',b',b) \Move(-5,0)
575 \MarkLoc(b') \Move(-5,-3) \MarkLoc(a')
576 \Move(0,-2) \MarkLoc(a) \Curve(a,a',b',b)
577 \Line(30,29) \Line(-40,0) } \Move(50,0) }
578 \DefineSymbol 4{{ \Move(35,0) \Line(0,60)
579 \Line(-35,-35) \Line(45,0)} \Move(55,0) }
580 \DefineSymbol 5{{ \Move(15,20) \DrawOvalArc(19,20)(-140,140)
581 \Move(-15,10) \Line(0,30) \Line(30,0) } \Move(44,0) }
582 \DefineSymbol 6{{ \Move(22,30) \DrawOvalArc(22,30)(70,270)
583 \Move(0,-10) \DrawOvalArc(22,15)(0,174)
584 \DrawOvalArc(22,20)(270,360) } \Move(54,0) }
585 \DefineSymbol 7{{ \Move(0,60) \Line(40,0)
586 \MarkLoc(a) \Move(-20,-60) \MarkLoc(b)
587 \DSeg\RotateTo(b,a) \Rotate(20) \MoveF(10) \MarkLoc(b')
588 \MoveToLoc(a)
589 \DSeg\RotateTo(a,b) \Rotate(-20) \MoveF(10) \MarkLoc(a')
590 \Curve(a,a',b',b) } \Move(50,0) }
591 \DefineSymbol 8{{ \Move(20,17) \DrawOval(20,17)
592 \Move(0,30) \DrawOval(20,13) } \Move(50,0) }
593 \DefineSymbol 9{{\Move(50,60) \Scale(-1,-1) \DrawText(--6--) } \Move(54,0)
594 }
595
596 \Scale(0.1,0.1) \Ragged(1)
597 \DrawText(--BOLD--)
598 \PenSize(0.2pt) \MoveTo(0,-100)
599 { \Scale(-1,1)
600 \DrawText(--BACKWARD--) }
601 \MoveTo(0,-200) \RotatedAxes(0,75) \DrawText(--SLANTED--)
602 \EndRotatedAxes \MoveTo(0,-300) \RotatedAxes(-45,45)
603 \DrawText(--ROTATED--) \EndRotatedAxes
604 |Close>>>
605
606 \Ex{\tex}{Last example in section 11.2}{boxes}
607
608 \<<<
609 |Open
610 \Object\ch(1){\Text(--#1--)
611 \MoveToExit(-1,-1)
612 \FigSize\Q\R{\Text(--#1--)}
613 \DrawRect(\Val\Q,\Val\R) }
614 \Define\chrs(1){\font\f=#1\space scaled\magstep4 \f
615 \Table\chrs{A & l & l & ~ & i & n & ~ &
616 b & o & x & e & s & .} \chrs(0,99){\ch} }
617 \PenSize(0.2pt) \EntryExit(-1,-1,1,-1)
618 {\chrs(cmtt10)} \Move(0,-20) \chrs(cmsl10)
619 |Close>>>
620
621 \Exr{11}21
622 \<<<
623 |Open
624 \Define\side(3){
625 \ProjectedAxes(#1,#2)(#1,#3)
626 \DrawRect(1,1) \Move(0.5,0.5)
627 \DrawCircle(0.5)
628 \EndProjectedAxes }
629 \ThreeDim(80,70,-40) \MarkPLoc(a)
630 \Move(0,-50,0) \MarkPLoc(b)
631 \Move(0,50,25) \MarkPLoc(c)
632 \Move(-25,0,-25) \MarkPLoc(d)
633 \side(a,b,d) \side(a,b,c) \side(a,c,d)
634 \EndThreeDim
635 |Close >>>
636
637
638 \Exr{11}24
639
640 \<<<
641 |Open
642 \Define\Spline(1){
643 \MarkLoc(0) \MoveTo(0,0) \MarkLoc(00)
644 \Table\P{#1} \Define\Count(1){\K+1;} \K=-4;
645 \P(0,999){\Count}
646 \Do(0,\Val\K){
647 \GetCoefficients
648 \MoveTo(\Val\Ao,\Val\Bo) \CSeg\Move(00,0)
649 \MarkLoc(o) \f \MarkLoc(x)
650 \Do(1,30){
651 \T=\DoReg; \T/30;
652 \X=\Aiii; \X*\T; \X+\Aii; \X*\T; \X+\Ai; \X*\T;
653 \Y=\Biii; \Y*\T; \Y+\Bii; \Y*\T; \Y+\Bi; \Y*\T;
654 \MoveToLoc(o) \Move(\Val\X,\Val\Y) \f
655 {\LineToLoc(x)} \MarkLoc(x) }}
656 \MoveToLoc(0)}
657
658 \Define\f{}
659 \DecVar\Ao \DecVar\Ai \DecVar\Aii \DecVar\Aiii \DecVar\X
660 \DecVar\Bo \DecVar\Bi \DecVar\Bii \DecVar\Biii \DecVar\Y
661
662 \Define\GetCoefficients{
663 \I=\DoReg; \P(\Val\I,\Val\I){\First}
664 \I+1; \P(\Val\I,\Val\I){\Second}
665 \I+1; \P(\Val\I,\Val\I){\Third}
666 \I+1; \P(\Val\I,\Val\I){\Fourth} }
667 \Define\First(2){\Ao=#1; \Ai=-#1; \Aii=#1; \Aiii=-#1;
668 \Bo=#2; \Bi=-#2; \Bii=#2; \Biii=-#2;}
669 \Define\Second(2){
670 \T=#1; \T* 4; \Ao +\T; \T=#2; \T* 4; \Bo +\T;
671 \T=#1; \T*-2; \Aii+\T; \T=#2; \T*-2; \Bii+\T;
672 \T=#1; \T* 3; \Aiii +\T; \T=#2; \T* 3; \Biii +\T;}
673 \Define\Third(2){ \Ao +#1; \Ao /6; \Bo +#2; \Bo /6;
674 \Ai +#1; \Ai /2; \Bi +#2; \Bi /2;
675 \Aii+#1; \Aii/2; \Bii+#2; \Bii/2;
676 \T=#1; \T*-3; \Aiii+\T; \T=#2; \T*-3; \Biii+\T;}
677 \Define\Fourth(2){
678 \Aiii+#1; \Aiii/6; \Biii+#2; \Biii/6;}
679
680 \Spline(0,15 & 30,-70
681 & 40,-50 & 10,0 & 15,30
682 & 50,5 &60,10 & 8,45 &
683 8,55 & 30,70 & 0,80 &
684 -30,70 &-8,55 & -8,45 &
685 -60,10 &-50,5 & -15,30 &
686 -10,0 &-40,-50 &-30,-70 &
687 0,15 & 30,-70 & 40,-50 )
688 \Define\ShowPoint(2){
689 \MoveToLoc(0) \Move(#1,#2)
690 \Text(--$\circ$--)}
691 \P(0,99){\ShowPoint}
692
693 \Define\TEX{
694 \Spline(0,-15 & 0,-15 &
695 0,-15 & 0, 15 &
696 0, 15 & 0, 15 )
697 \Spline(-10,15 &
698 -10,15 & -10,15 & 10,15 &
699 10,15 & 10,15)
700 \Move(12,0)
701 \Spline(0,0 & 0,0 & 0,0 & 14,0 & 14,0 & 14,0)
702 \Spline( 20,15 &20,15 &20,15 & 0,15 & 0,15
703 & 0,-15 & 0,-15 & 20,-15 &20,-15&20,-15)
704 \Move(32,0) \Spline( -10,-15 & -10,-15 &
705 -10,-15 & 10,15 & 10,15 & 10,15)
706 \Spline( -10,15 &
707 -10,15 & -10,15 & 10,-15 & 10,-15 & 10,-15) }
708 \TEX \MoveTo(0,0) \F
709 \TEX \MoveTo(0,-35) \G
710 \TEX
711 |Close >>>
712
713
714 \Exr{11}31
715 \<<<
716 |Open
717 \Define\put(2){
718 \IF \EqText(,#1) \THEN
719 \top \Define\put(1){}
720 \ELSE \push(#1) \FI \put(#2)}
721 \Define\stack(1){
722 {\put(#1,,)} \Move(0,-13)}
723 \Table\x{ & 1& 1, 2&
724 1, 2, 3& 1, 2, 3, 4&
725 1, 2, 3, 4, *& 1, 2, 12&
726 1, 2, 12,+& 1, 14& 1, 14,+& 15}
727 \x(0,100){\stack}
728 |Close >>>
729
730
731 \Exr{11}32
732 \<<<
733 |Open
734 \Table\g{
735 16 & 8 & 4 & 2 & 1 &
736 20 & 16 & 8 & 4 & 2 &
737 17 & 12 & 16 & 8 & 4 &
738 23 & 20 & 12 & 13 & 17 }
739 \ThreeDim(160,75,-70)
740 \Scale(20,5,20)
741 \g(0,140){\surface}
742 \EndThreeDim
743 |Close >>>
744
745
746
747
748
749
750 \Ex{\tex}{NEW OPTION FOR {\tt\char92}ThreeDim}{NewThreeDim}
751
752
753
754 {\tt\string\ThreeDim($x_e$,$y_e$,$z_e$)} perspective projections (old option)
755
756 {\tt\string\ThreeDim($\alpha_{xy}$,$\alpha_z$)} parallel projections (new additional option):
757 $\alpha_{xy}$ --- direction within xy plane,
758 $\alpha_z$ --- direction with respect to xy plane.
759
760 e.g., {\tt\string\ThreeDim(30,60)} or
761 {\tt\string \ThreeDim(45,60)}
762
763
764 \<<<
765 |Open
766 \Define\cube{
767 \Line(50,0,0){\Line(0,0,50)}
768 \Line(0,50,0){\Line(0,0,50)}
769 \Line(-50,0,0){\Line(0,0,50)}
770 \Line(0,-50,0) \Move(0,0,50)
771 \Move(50,0,0) \Line(0,50,0)
772 \Line(-50,0,0) }
773 \ThreeDim(80,80,-100) \cube \EndThreeDim
774 \MoveTo(0,-130)
775 \ThreeDim(45,60) \cube \EndThreeDim
776 \MoveTo(0,-260)
777 \ThreeDim(30,60) \cube \EndThreeDim
778 |Close>>>
779
780 \Lib{AlDraTeX} \def\files{\fileAD}
781
782
783 \Ex{tex}{Example in section 13.2}{sec132}
784
785 \<<<
786 \input DraTex.sty
787 \input AlDraTex.sty
788 \Draw
789 \Scale(1,0.5)
790 \PieChartSpec(1,50,20)()
791 \PieChart(15 & 10 & 30)
792 \Move(0,-6)
793 \DrawOvalArc(50,50)(180,360)
794 \EndDraw
795 \bye>>>
796
797 \Ex{tex}{Example in section 13.2---second version}{sec132a}
798
799 \<<<
800 \input DraTex.sty
801 \def\AlDraTex{pie}
802 \input AlDraTex.sty
803 \Draw
804 \Scale(1,0.5)
805 \PieChartSpec(1,50,20)()
806 \PieChart(15 & 10 & 30)
807 \Move(0,-6)
808 \DrawOvalArc(50,50)(180,360)
809 \EndDraw
810 \bye>>>
811
812
813 \Ex{latex}{Example in section 13.2}{sec132b}
814
815 \<<<
816 \documentstyle{report}
817 \input DraTex.sty
818 \input AlDraTex.sty
819 \begin{document}
820 \Draw
821 \Scale(1,0.5)
822 \PieChartSpec(1,50,20)()
823 \PieChart(15 & 10 & 30)
824 \Move(0,-6)
825 \DrawOvalArc(50,50)(180,360)
826 \EndDraw
827 \end{document}>>>
828
829 \Ex{latex}{Example in section 13.2---second version}{sec132c}
830
831 \<<<
832 \documentstyle[DraTex,AlDraTex]{report}
833 \begin{document}
834 \Draw
835 \Scale(1,0.5)
836 \PieChartSpec(1,50,20)()
837 \PieChart(15 & 10 & 30)
838 \Move(0,-6)
839 \DrawOvalArc(50,50)(180,360)
840 \EndDraw
841 \end{document}>>>
842
843 \Ex{latex}{Example in section 13.2---third version}{sec132d}
844
845 \<<<
846 \documentstyle{report}
847 \input DraTex.sty
848 \def\AlDraTex{pie}
849 \input AlDraTex.sty
850 \begin{document}
851 \Draw
852 \Scale(1,0.5)
853 \PieChartSpec(1,50,20)()
854 \PieChart(15 & 10 & 30)
855 \Move(0,-6)
856 \DrawOvalArc(50,50)(180,360)
857 \EndDraw
858 \end{document}>>>
859
860 \Ex{latex}{Example in section 13.2---forth version}{sec132e}
861
862 \<<<
863 \def\AlDraTex{pie}
864 \documentstyle[DraTex,AlDraTex]{report}
865 \begin{document}
866 \Draw
867 \Scale(1,0.5)
868 \PieChartSpec(1,50,20)()
869 \PieChart(15 & 10 & 30)
870 \Move(0,-6)
871 \DrawOvalArc(50,50)(180,360)
872 \EndDraw
873 \end{document}>>>
874
875 \Ex{\tex}{Chemical diagram in section 16.1}{sec161}
876
877 \<<<
878 |Open
879 \Define\ChemEdge(3){{
880 \MoveToNodeDir(#2,#1)
881 \MarkLoc(b) \MoveToNodeDir(#1,#2)
882 \MarkLoc(a) \DSeg\RotateTo(a,b)
883 \Rotate(-90)\Q=#3; \Q/2; \Q-0.5;
884 \Q*2.2; \MoveF(\Val\Q)
885 \Do(1,#3){ {\CSeg\Line(a,b)}
886 \MoveF(-2.2) } }}
887 \Do(1,6){ \MoveF(30)
888 \Node(\DoReg)(--C--) \MoveF(20) \Node(x)(--H--)
889 \ChemEdge(\DoReg,x,1) \MoveTo(0,0) \Rotate(60) }
890 \ChemEdge(1,2,2) \ChemEdge(2,3,1) \ChemEdge(3,4,2)
891 \ChemEdge(4,5,1) \ChemEdge(5,6,2) \ChemEdge(6,1,1)
892 |Close >>>
893
894
895 \Ex{\tex}{Finite automaton in last example of chapter 17}{FA}
896
897 \<<<
898 |Open
899 \NewCIRCNode(\StateNode,106,)
900 \NewCIRCNode(\AStateNode,106,103)
901 \Define\StateAt(3){ \MoveTo(#2,#3)
902 \StateNode(#1)(--$q_{#1}$--)}
903 \Define\AStateAt(3){
904 \MoveTo(#2,#3)
905 \AStateNode(#1)(--$q_{#1}$--)}
906 \DiagramSpec(\StateAt&
907 \AStateAt&\TransEdge)
908 \ArrowHeads(1) \Diagram
909 ( 0,0,0 & 1,50,50 &
910 3,90,-50 & 4,20,-50 )(2,75,0)
911 (0,1,a,b & 1,2,a, & 0,2, ,b & 2,2,0,b & 0,4,a, & 4,3,a,b )
912 \CurvedEdgeAt(3,1,0,1,1,0)(20,0.3,0,0.5) \EdgeLabel[+](--a--)
913 |Close>>>
914
915
916 \noindent\dotfill\
917
918 New commands in AlDraTeX for setting spread diagrams (add to end of ch
919 17)
920
921 \noindent\dotfill\
922
923 \begingroup
924 \leftskip= 1.5em
925 \parindent = -\leftskip
926
927 \def\item{\medskip\leavevmode\hbox to \leftskip{$\circ$\hss}}
928
929 \item
930 `{\tt\string\DefNode}'. A prefix to a node-generating command. The
931 prefix asks that the command will produce an invisble node. The
932 invisible node is assigned addresses but is not drawn into the
933 figure.
934
935
936 \item
937 `{\tt\string\PutNode(N)}'. This command realizes, according to the current
938 conditions, a specified invisible node that has been defined earlier
939 by `{\tt\string\DefNode}'.
940
941 \item
942 `{\tt\string\ZeroNodesDim}'. Sets the pseudovariables `{\tt\string\WidthX}',
943 `{\tt\string\WidthY}', `{\tt\string\MaxX}', and `{\tt\string\MaxY}' to 0.
944
945 \item
946 `{\tt\string\AddNodeDim(N)}'. Inserts the horizontal and vertical
947 dimensions of node N to the pseudovariables `{\tt\string\Widthx}' and
948 `{\tt\string\Widthy}', respectively. Adds these values to the
949 pseudovariables `{\tt\string\WidthX}' and `{\tt\string\WidthY}',
950 respectively. In addition, half the horizontal dimension of node N is
951 stored in `{\tt\string\MaxX}' if the pseudovariable contains a smaller
952 value, and a similar outcome holds for the vertical dimension with
953 respect to the pseudovariable `{\tt\string\MaxY}'.
954 \par\endgroup
955
956 \Ex{\tex}{}{newA}
957
958 \<<<
959 |Open
960 \DefNode\CircleNode(a)(--Two--)
961 \MoveToNode(a,0,0) \MarkLoc(A)
962 \MoveToNode(a,1,0) \MarkLoc(B)
963 \LSeg\R(A,B) \MoveTo(0,0)
964 \OvalNode(b)(--Touching Nodes--)
965 \RotateTo(19.5) \MoveF(5) \MarkLoc(A)
966 \MoveToNodeDir(b,A) \MarkLoc(A)
967 \MoveToNode(b,0,0)
968 \RotateTo(20.5) \MoveF(5) \MarkLoc(B)
969 \MoveToNodeDir(b,B) \MarkLoc(B)
970 \RotateTo(20) \MoveF(5) \MarkLoc(C)
971 \MoveToNode(b,0,0) \MoveToNodeDir(b,C)
972 \DSeg\RotateTo(A,B) \Rotate(-90)
973 \MoveF(\Val\R) \PutNode(a)
974 |Close>>>
975
976
977 \Ex{\tex}{}{newB}
978
979 \<<<
980 |Open
981
982 \def\Dist#1(#2,#3,#4){\MarkLoc(a*)%
983 \MoveToNode(#2,0,0)\MarkLoc(b*)%
984 \MoveToNode(#2,#3,#4)\MarkLoc(c*)%
985 \LSeg#1(b*,c*)\MoveToLoc(a*)}
986
987 \EntryExit(1,1,1,-1.5)
988 \Object\G(3){
989 \RectNode(a)(--#1--)
990 \DefNode\RectNode(b)(--#2--)
991 \DefNode\RectNode(c)(--#3--)
992 \Dist\T(a,1,0) \Dist\R(b,1,0) \Dist\Q(c,1,0)
993 \R+\Q; \T-\R; \T*2;
994 \ZeroNodesDim \AddNodeDim(b)
995 \AddNodeDim(c) \Q=\MaxY;
996 \Dist\R(a,0,1) \Q+\R;
997 \Q+20; \EntryExit(-1,0,1,0)
998 \IF \GtDec(\T,40) \THEN
999 \T+40; \T/3;
1000 \SetNodes(20,\Val\T)
1001 \ELSE \T=-\T; \T+60; \T/2;
1002 \SetNodes(\Val\T,20) \FI
1003 \Edge(b,c) \ArrowHeads(1)
1004 \VHEdge(A,c) \VHEdge(B,b) }
1005 \Define\SetNodes(2){
1006 \MoveToNode(a, 1,0) \Line( #1,0) \FcNode(A)
1007 \MoveToNode(a,-1,0) \Line(-#1,0) \FcNode(B)
1008 \Move(#2,-\Val\Q) \PutNode(b)
1009 \Move(#2, 0) \PutNode(c) }
1010 \G(short~~and~~deep,d~~e~~e~~p,shallow)
1011 \G(very~very~long~node,shallow,d~~e~~e~~p)
1012 |Close>>>
1013
1014
1015 \Ex{\tex}{}{newC}
1016
1017
1018
1019
1020 \<<<
1021 |Open
1022 \Define\Vertex(2){
1023 \IF \EqText(r,#1) \THEN \Define\NodeType{\RectNode}
1024 \ELSE \IF \EqText(d,#1) \THEN \Define\NodeType{\DiamondNode}
1025 \ELSE \IF \EqText(o,#1) \THEN \Define\NodeType{\OvalNode}
1026 \ELSE \Define\NodeType{\Node}
1027 \FI\FI\FI
1028 \DefNode\NodeType(\Val\I..\Val\J)(--#2--)
1029 \AddNodeDim(\Val\I..\Val\J) }
1030 \Define\DefRow(1){
1031 \IF \EqText({},{#1}) \THEN \Define\g{\MoveToLoc(start)}
1032 \ELSE \ZeroNodesDim \J=-1;
1033 \Table\x{#1} \x(0,99){\J+1; \Vertex}
1034 \Move( 0,-\MaxY) \MarkLoc(\Val\I) \Move(5,0) \MarkLoc(\Val\I')
1035 \Move(-5,-\MaxY) \Move(0,-\Sy) \I+1;
1036 \FI \g }
1037
1038 \Define\ProjectToRow(1){
1039 \MarkLoc(x) \Move(0,5) \MarkLoc(x')
1040 \MoveToLL(#1,#1')(x,x') }
1041
1042 \Define\VSpace(1){ \Define\Sy{#1} }
1043 \VSpace(15)
1044
1045 \Define\DefRowDiagram{
1046 \MarkLoc(start) \I=0; \Define\g{\DefRow} \g}
1047
1048 \DefRowDiagram
1049 ( o, An~ approach~~ for~ setting~~ flow~ diagrams
1050 & r, Use~~ {\tt\char92DefineRowDiagram}~~
1051 to~ define~~ the~ rows~~ of~ nodes
1052 )( r, Derive~~ x~ coordinate~~ for~ N~ then~
1053 call~~ {\tt\char92ProjectToRow}
1054 & r, Choose~~ nonrealized~~ node~ N
1055 & d, More~ nodes~~ to~ realize?
1056 )( r, Realize~ N~~ with~ {\tt\char92PutNode}
1057 & o, Done
1058 )()
1059 \ProjectToRow(0) \EntryExit(0,0,-1,0) \PutNode(0..0)
1060 \ProjectToRow(2) \MarkLoc(A)
1061 \ProjectToRow(1) \EntryExit(-1,0,1,0) \PutNode(1..0)
1062 \Move(20,0) \PutNode(1..1) \Move(20,0)
1063 \EntryExit(-1,0,0,0) \PutNode(1..2)
1064 \ProjectToRow(0) \EntryExit(0,0, 0,0) \PutNode(0..1)
1065 \ProjectToRow(2) \EntryExit(0,0,-1,0) \PutNode(2..1)
1066 \MarkLoc(B) \CSeg[0.5]\Move(B,A) \PutNode(2..0)
1067 \ArrowHeads(1) \Edge(0..0,0..1) \Edge(0..1,1..2)
1068 \Edge(1..2,1..1) \EdgeLabel(--Yes--)
1069 \Edge(1..2,2..1) \EdgeLabel(--No--)
1070 \Edge(1..1,1..0) \VHEdge(1..0,2..0)
1071 \EdgeFrom(2..0,1,0,1..2)
1072 |Close>>>
1073
1074 \begingroup
1075 \def\startInput{}
1076 \def\endInput{}
1077
1078 \Ex{\tex}{}{newD}
1079
1080 \<<<
1081 |Open
1082 \Define\DefNd(1){
1083 \DefNode\RectNode(\Val\I)(--#1--)
1084 \AddNodeDim(\Val\I) \I+1; }
1085 \Define\D(1){
1086 \IF \EqText({},{#1}) \THEN \Define\g{}
1087 \ELSE \ZeroNodesDim \J=-1;
1088 \Table\x{#1} \x(0,99){\J+1; \DefNd}
1089 \T=\J; \T*15; \T+\WidthX; \T/\F;
1090 \Move(0,-\MaxY) \MarkLoc(a) \Move(\Val\T,0)
1091 \K=\I;
1092 \Do(0,\Val\J){ \K-1; \PutNode(\Val\K) \Move(-15,0) }
1093 \MoveToLoc(a) \Move(0,-\MaxY) \Move(0,-15)
1094 \FI \g }
1095 \Define\G(1){\I=0; \EntryExit(1,0,-1,0)
1096 \Define\g{\D} \Define\F{#1} \g}
1097
1098 \Draw
1099 \G(2)(first & diagram)
1100 (centers & of~~rows~~on & vertical~~line )
1101 (distance~=~15 & between~~rows)
1102 ()
1103 \Table\x{0,2 & 0,3 & 1,3 & 1,4 & 2,5 & 3,5 & 3,6 & 4,6}
1104 \x(0,99){\Edge}
1105 \EndDraw
1106
1107 \Draw\Move(0,-15)
1108 \G(1)(new~diagram)
1109 (left~~margins & for~rows) ()
1110 \Edge(0,1) \Edge(1,2) \Edge(2,0)
1111 \EndDraw
1112
1113 \Draw
1114 \Move(0,-15)
1115 \G(10000)(new~diagram)
1116 (right~margins & for~~rows) ()
1117 \Edge(0,1) \Edge(1,2) \Edge(2,0)
1118 \EndDraw
1119 |Close>>>
1120
1121
1122 \Ex{\tex}{}{newE}
1123
1124 \<<<
1125 |Open
1126 \Define\DefNd(1){
1127 \DefNode\RectNode(\Val\I..\Val\J)(--#1--)
1128 \AddNodeDim(\Val\I..\Val\J) }
1129 \Define\DefG(1){
1130 \IF \EqText({},{#1}) \THEN \Define\g{\PutG}
1131 \ELSE \ZeroNodesDim \J=-1;
1132 \Table\x{#1} \x(0,99){\J+1; \DefNd}
1133 \Indirect\let<\Val\I.width>=\WidthX
1134 \Indirect\edef<\Val\I.size>{\Val\J}
1135 \T=\J; \T*\Sx; \T+\WidthX;
1136 \IF \GtDec(\T,\Q) \THEN \Q=\T; \FI
1137 \Move(0,-\MaxY) \MarkLoc(\Val\I)
1138 \Move(0,-\MaxY) \Move(0,-\Sy) \I+1;
1139 \FI \g }
1140 \Define\PutG(1){ \I-1; \EntryExit(-1,0,1,0)
1141 \Do(0,\Val\I){ \MoveToLoc(\DoReg)
1142 \R=\Q; \Indirect{\R-}<\DoReg.width>;
1143 \Indirect{\J=}<\DoReg.size>; \K=\J;
1144 \DiagType
1145 \IF \GtDec(\Q,\T) \THEN
1146 \K+2; \R/\K; \Move(\Val\R,0)
1147 \ELSE
1148 \IF \GtInt(\J,0) \THEN \R/\K; \FI
1149 \FI
1150 \I=\DoReg;
1151 \Do(0,\Val\J){ \J=\DoReg;
1152 \PutNode(\Val\I..\Val\J) \Move(\Val\R,0) }
1153 }
1154 \Table\x{#1} \x(0,99){\Edge} }
1155 \Define\G{ \I=0; \Q=0;
1156 \Define\g{\DefG} \g}
1157
1158 \Define\FillDiagram{
1159 \Define\DiagType{\T=\Q;}
1160 \G}
1161 \Define\MarginsDiagram{
1162 \Define\DiagType{\T=\J; \T*\Sx; \Indirect{\T+}<\DoReg.width>;}
1163 \G}
1164 \Define\HVSpaces(2){ \Define\Sx{#1} \Define\Sy{#2} }
1165 \HVSpaces(15,15)
1166
1167 \Draw
1168 \FillDiagram(Fill & Diagram)
1169 (fixed & distances & between~~rows)
1170 (uniform & spaces &within~~each &row)
1171 ()
1172 ( 0..0,1..0 & 0..0,1..1 & 0..1,1..1 & 0..1,1..2
1173 & 1..0,2..0 & 1..0,2..1 & 1..1,2..1 & 1..1,2..2
1174 & 1..2,2..2 & 1..2,2..3)
1175 \EndDraw
1176
1177 \Draw \HVSpaces(25,15)
1178 \MarginsDiagram(Margins & Diagram)
1179 (fixed & distances &between~~rows)
1180 (uniform~~spaces&between~nodes&within~~each~row)
1181 ()
1182 ( 0..0,1..0 & 0..0,1..1 & 0..1,1..1 & 0..1,1..2
1183 & 1..0,2..0 & 1..0,2..1 & 1..1,2..1 & 1..1,2..2
1184 & 1..2,2..2 )
1185
1186 \EndDraw
1187 |Close>>>
1188
1189 \endgroup
1190 \noindent\dotfill\
1191
1192 End new commands for setting spread diagrams (end of ch 17)
1193
1194 \noindent\dotfill\
1195
1196
1197
1198 \Ex{\tex}{Commutative diagram in last example of section 18.3}{CM}
1199
1200 \<<<
1201 |Open
1202 \GridDiagramSpec()(\MyEdge)
1203 \Define\L(4){,+#1..+#2\,L\,#3\,#4}
1204 \Define\D(4){,+#1..+#2\,D\,#3\,#4}
1205 \Define\MyEdge(5){
1206 \IF \EqText(#3,D) \THEN\EdgeSpec(D)
1207 \ELSE \EdgeSpec(L) \FI
1208 \IF \EqText(#1,#2) \THEN
1209 \RotateTo(#4) \CycleEdge(#1)
1210 \EdgeLabel(--$#5$--)
1211 \ELSE\Edge(#1,#2)
1212 \IF \EqText(,#4) \THEN \EdgeLabel(--$#5$--)
1213 \ELSE \EdgeLabel[#4](--$#5$--) \FI
1214 \FI}
1215 \ArrowHeads(1)
1216 \GridDiagram(3,3)()()({
1217 & T \D(0,1,,f) \D(2,0,,h) & N \L(2,0,,\sigma)//
1218 S \L(0,0,180,t) \L(-1,1,,f) \L(1,1,+,g\circ f)//
1219 & W \L(0,1,,f) & X \D(0,0,-45,r)//})
1220 |Close >>>
1221
1222
1223 \Ex{\tex}{Second example in section 20.2}{sec202}
1224
1225 \<<<
1226 |Open
1227 \NewNode(\MyNode,\MoveToRect){
1228 \Move(-24,-8) \DrawRect(48,16)
1229 \Move(16,0) {\Line(0,16)}
1230 \Move(16,0) \Line(0,16) }
1231 \Define\MyEdge(2){
1232 \CSeg\FindSign(#1,#2)
1233 \EdgeAt(#1,\sign 0.66,0,#2,0,1)}
1234 \Define\FindSign(2){
1235 \IF \GtDec(#1,0) \THEN
1236 \Define\sign{}
1237 \ELSE \Define\sign{-} \FI}
1238 \TextNode(2){ \Text(--$#2$--)
1239 \IF \EqInt(#1,0) \THEN {
1240 \Move(-16,0) \Text(--$\Lambda$--)
1241 \Move(32,0) \Text(--$\Lambda$--)
1242 }\FI }
1243 \ArrowHeads(1)
1244 \TreeSpace(D,10,20)
1245 \TreeSpec(\MyNode)()(\MyEdge)
1246 \Tree()(2,2,A// 0,0,B&2,2,C// 2,2,D&0,0,E// 0,0,F&0,0,G//)
1247 |Close >>>
1248
1249
1250 \Ex{\tex}{Last example in section 20.2}{LR}
1251
1252 \<<<
1253 |Open
1254 \GridDiagramSpec(\RNode)(\MyEdge)
1255 \GridSpace(10,10) \ArrowSpec(F,5,3,3)
1256 \ArrowHeads(1) \CycleEdgeSpec(-30,20)
1257 \NewNode(\RNode,\MoveToOval){
1258 \GetNodeSize \Va+4; \Vb+4;
1259 \SetMinNodeSize \Move(0,3)
1260 \DrawOval(\Val\Va,\Val\Vb) }
1261 \Define\MyEdge(3){
1262 \IF \EqText(#1,#2) \THEN
1263 \RotateTo(45) \LabelPos(+0.5;,3)
1264 \CycleEdge(#1)
1265 \ELSE \DSeg\Q(#1,#2)
1266 \IF \GtDec(\Q,180) \THEN
1267 \LabelPos(+0.4;,3) \ELSE \LabelPos(0.5;,3)
1268 \FI \Edge(#1,#2) \FI \EdgeLabel(--$#3$--) }
1269 \baselineskip=9pt \Define\NEXT(3){,#1..#2\,#3}
1270 \def\/#1/#2.#3;{\hbox{$\scriptstyle#1\rightarrow #2\cdotp#3$}~~}
1271 \GridDiagram(3,3)()()({
1272 & \/S'/ S. ; \/A / S.a; $I_1$ \NEXT(+0,+1,a)
1273 & \/A / Sa.; $I_2$
1274 // \/S'/ .S ; \/S / .AS; \/ / .b ;
1275 \/A / .Sa; \/ / .a ; $I_0$ \NEXT(-1,+1,S) \NEXT(+0,+1,A)
1276 \NEXT(+1,+1,b) \NEXT(+1,+0,a)
1277 & \/S /A.S ; \/S /.AS ; \/ /.b ;
1278 \/A /.Sa ; \/ /.a ; $I_3$ \NEXT(+0,+1,S) \NEXT(+0,+0,A)
1279 & \/A/ S.a ; $I_4$ \NEXT(+1,+0,a)
1280 //
1281 \/A/a.; $I_5$
1282 & \/S/ b. ; $I_6$
1283 & \/A/ Sa. ; $I_7$
1284 //
1285 })
1286 |Close >>>
1287
1288
1289
1290 \Ex{\tex}{Last example in chapter 20}{TM}
1291
1292
1293 \<<<
1294 |Open
1295 \NewCIRCNode(\StateNode,104,)
1296 \NewCIRCNode(\AStateNode,104,102)
1297 \Define\StateAt(3){ \MoveTo(#2,#3)
1298 \StateNode(#1)(--$q_{#1}$--)}
1299 \Define\AStateAt(3){\MoveTo(#2,#3)
1300 \AStateNode(#1)(--$q_{#1}$--)}
1301 \LabelSpec(4){\PictLabel{
1302 { \Move(1,-5) \Line(8,20) }
1303 { \Move(4,10) { \EntryExit(1,0,0,0)
1304 \Text(--\strut$#1$--) } \Move(6,0)
1305 \EntryExit(-1,0,0,0) \Text(--\strut$#3$--) }
1306 { \EntryExit( 1,0,0,0) \Text(--\strut$#2$--) }
1307 \Move(6,0) \EntryExit(-1,0,0,0) \Text(--\strut$#4$--) }}
1308 \DiagramSpec(\StateAt&\AStateAt&\TransEdge) \ArrowHeads(1)
1309 \Diagram( 0,0,0 & 1,80,0 )(2,80,-60)(
1310 0,0,90,{a,B,+1,a{,+}1} &
1311 0,1, {a,B,+1,a{,+}1}, {b,B,0,B{,-}1} &
1312 1,2, {|DEFEND\$,B,0,B{, }0}, )
1313 |Close >>>
1314
1315
1316
1317
1318
1319 \Lib{ProTeX and AlProTex} \def\files{\fileP} \def\LLL{>>>}
1320
1321 \let\startInput=\empty
1322
1323 \let\endInput=\empty
1324
1325 NOTE. The La\TeX{} files of this part put the
1326 {\tt\string\AlProTex....} command after the
1327 {\tt\string\begin\string{document\string}} command. This is not a nice
1328 style for files.
1329
1330 \Exr{22}2{2a}
1331 \<<<
1332 |Open
1333 \AlProTex{awk,<<<|LLL,@,%
1334 list,title,[]}
1335 \catcode`\@=0
1336
1337 An Awk program for deriving
1338 the distribution of words.
1339
1340 @<dist@><<<
1341 BEGIN {print"words\t lines"}
1342 @<count the words@>
1343 END { i=0
1344 while (i<=m)
1345 {if (c[i]>0)
1346 {print i "\t " c[i]}
1347 i=i+1 }}
1348 |LLL
1349
1350 NF is a built-in variable
1351 that holds the number of
1352 words in the current input
1353 line.
1354
1355 @<count the words@><<<
1356 { c[NF]=c[NF]+1
1357 {if (NF>m) m=NF} }
1358 |LLL \OutputCode@<dist@>
1359 |Close >>>
1360
1361
1362 \Exr{22}2{2b}
1363 \<<<
1364 |Open
1365 \AlProTex{awk,<<<|LLL,@,%
1366 list,title,[]}
1367
1368 An Awk program for deriving
1369 the distribution of words.
1370
1371 \<dist\><<<
1372 BEGIN {print"words\t lines"}
1373 @<count the words@>
1374 END { i=0
1375 while (i<=m)
1376 {if (c[i]>0)
1377 {print i "\t " c[i]}
1378 i=i+1 }}
1379 |LLL
1380
1381 NF is a built-in variable
1382 that holds the number of
1383 words in the current input
1384 line.
1385
1386 \<count the words\><<<
1387 { c[NF]=c[NF]+1
1388 {if (NF>m) m=NF} }
1389 |LLL \OutputCode\<dist\>
1390 |Close >>>
1391
1392
1393 \Exr{22}2{3}
1394
1395 \<<<
1396 |Open
1397 \AlProTex{p,<<<|LLL,%
1398 title,list,[]}
1399
1400 \<prog\><<<
1401 PROGRAM prog;|LLL
1402
1403 \<body\><<<
1404 { comment } |LLL
1405
1406 \<prog\><<<
1407 BEGIN
1408 \<body\>
1409 END.|LLL
1410
1411 \OutputCode\<prog\>
1412 |Close >>>
1413
1414 \Exr{22}2{4a}
1415
1416 \<<<
1417 |Open
1418 \AlProTex{p,list,%
1419 <<<|LLL,title,[]}
1420
1421 \<\><<<
1422 PROGRAM prog;|LLL
1423
1424 \<body\><<<
1425 { comment } |LLL
1426
1427 \<\><<<
1428 BEGIN
1429 \<body\>
1430 END.|LLL
1431
1432 \OutputCode\<\>
1433 |Close >>>
1434
1435 \Exr{22}2{4b}
1436
1437 \<<<
1438 |Open
1439 \AlProTex{p,%
1440 <<<|LLL,title,[]}
1441
1442 \<\><<<
1443 PROGRAM prog;|LLL
1444 \ShowCode-\<\>
1445
1446 \<body\><<<
1447 { comment } |LLL
1448 \ShowCode\<body\>
1449
1450 \<\><<<
1451 BEGIN
1452 \<body\>
1453 END.|LLL
1454 \ShowCode\<\>
1455 \OutputCode\<\>
1456 |Close >>>
1457
1458 \Exr{22}2{4c}
1459
1460 \<<<
1461 |Open
1462 \AlProTex{p,%
1463 <<<|LLL,title,[]}
1464
1465 \<\><<<
1466 PROGRAM prog;|LLL
1467
1468 \<body\><<<
1469 { comment } |LLL
1470
1471 \<\><<<
1472 BEGIN
1473 \<body\>
1474 END.|LLL
1475
1476 \OutputCode\<\>
1477 |Close >>>
1478
1479
1480
1481 \Exr{22}2{5a}
1482
1483 \<<<
1484 |Open
1485 \AlProTex{p,<<<|LLL,%
1486 title,list,[]}
1487
1488 \<myprog\><<<
1489 PROGRAM prog;|LLL
1490
1491 \<body\><<<
1492 { comment } |LLL
1493
1494 \<myprog\><<<
1495 BEGIN
1496 \<body\>
1497 END.|LLL
1498 \OutputCode\<myprog\>
1499
1500 |Close >>>
1501
1502 \Exr{22}2{5b}
1503
1504 \<<<
1505 |Open
1506 \AlProTex{p,title,list,[]}
1507
1508 \<myprog\>{PROGRAM prog;}
1509
1510 \<body\>{ \{ comment \} }
1511
1512 \<myprog\>{BEGIN
1513 \<body\>
1514 END.}
1515 \OutputCode\<myprog\>
1516
1517 |Close >>>
1518
1519
1520
1521
1522 \Exr{22}2{6a}
1523
1524 \<<<
1525 |Open
1526 \AlProTex{p,<<<|LLL,[],%
1527 title,list}
1528 \<myprog\><<<
1529 PROGRAM prog;
1530 BEGIN
1531 \<body\>
1532 END.|LLL
1533
1534 \<body\><<<
1535 { comment: \\@||` } |LLL
1536 |Close >>>
1537
1538 \Exr{22}2{6b}
1539
1540 \<<<
1541 |Open
1542 \AlProTex{p,<<<|LLL,[],%
1543 title,list,@}
1544 \<myprog\><<<
1545 PROGRAM prog;
1546 BEGIN
1547 @<body@>
1548 END.|LLL
1549
1550 \<body\><<<
1551 { comment: \@@||` } |LLL
1552 |Close >>>
1553
1554 \Exr{22}2{6c}
1555
1556
1557 \<<<
1558 |Open
1559 \AlProTex{p,<<<|LLL,[],%
1560 title,list,||}
1561 \<myprog\><<<
1562 PROGRAM prog;
1563 BEGIN
1564 ||<body||>
1565 END.|LLL
1566
1567 \<body\><<<
1568 { comment: \@||||` } |LLL
1569 |Close >>>
1570
1571
1572 \Exr{22}2{6d}
1573
1574 \<<<
1575 |Open
1576 \AlProTex{p,<<<|LLL,[],%
1577 title,list,`}
1578 \<myprog\><<<
1579 PROGRAM prog;
1580 BEGIN
1581 `<body`>
1582 END.|LLL
1583
1584 \<body\><<<
1585 { comment: \@||`` } |LLL
1586 |Close >>>
1587
1588 \Exr{22}2{7}
1589
1590 \<<<
1591 |Open
1592 \AlProTex{p,<<<|LLL,[],%
1593 title,list,||}
1594
1595 \<temp\><<<
1596 \<prog\><<<
1597 PROGRAM prog;
1598 BEGIN
1599 ||||<body||||>
1600 END.>||empty>>
1601
1602 \<body\><<<
1603 {comment: \@||||||||} >||empty>>
1604
1605 \OutputCode\<prog\> |LLL
1606
1607 \OutputCode[prg]\<temp\>
1608 \input temp.prg
1609 |Close >>>
1610
1611
1612 \Exr{22}2{8a}
1613
1614 \<<<
1615 |Open
1616 \Code\myprog{my
1617 program}{PROGRAM prog;}
1618 \ShowCode-\myprog
1619
1620 \AppendCode\myprog{BEGIN
1621 \body
1622 END.}
1623 \Code\body{body}{}
1624 \ShowCode-\myprog
1625
1626 \AppendCode\body{\{comment\}}
1627 \ShowCode\body
1628
1629 Code of title \myprog{}
1630 linearized within
1631 the paragraph:
1632 `\ShowCode-\myprog'.
1633
1634 \OutputCode\myprog
1635 |Close >>>
1636
1637 \Exr{22}2{8b}
1638
1639
1640 \<<<
1641 |Open
1642 \AlProTex{p,<<<|LLL,list,@}
1643
1644 \Code\myprog{my program}<<<
1645 PROGRAM prog;|LLL
1646
1647 \Code\body{body}<<<
1648 |LLL
1649 \AppendCode\myprog<<<
1650 BEGIN
1651 @body
1652 END.|LLL
1653
1654 \AppendCode\body<<<
1655 {comment} |LLL
1656
1657 Code of title \myprog{}
1658 linearized within the
1659 paragraph:
1660 `\ShowCode-\myprog'.
1661
1662 \OutputCode\myprog
1663 |Close >>>
1664
1665
1666 \Exr{22}2{9}
1667
1668 \<<<
1669 |Open
1670 \AlProTex{p,<<<|LLL,%
1671 title,list,[]}
1672
1673 \<myprog\><<<
1674 PROGRAM prog;|LLL
1675
1676 \<body\><<<
1677 { comment } |LLL
1678
1679 \<myprog\><<<
1680 BEGIN
1681 \<body\>
1682 END.|LLL
1683
1684 \OutputCode\<myprog\>
1685 |Close >>>
1686
1687 \Exr{22}2{10a}
1688
1689 \<<<
1690 |Open
1691 \AlProTex{p,<<<|LLL,title,%
1692 list,[],enumerate}
1693
1694 See lines \RefLine[*].
1695
1696 \<myprog\><<<
1697 PROGRAM prog;\TagLine[*] |LLL
1698
1699 \<body\><<<
1700 {comment: see \RefLine[*]}|LLL
1701
1702 \<myprog\><<<
1703 BEGIN
1704 \<body\> \TagLine[*] |LLL
1705
1706 \ResetLineCount
1707 \<myprog\><<<
1708 END.|LLL \OutputCode\<myprog\>
1709 |Close >>>
1710
1711 \Exr{22}2{10b}
1712
1713
1714 \<<<
1715 |Open
1716 \AlProTex{p,<<<|LLL,title,%
1717 list,[]}
1718 \def\CodeRef[#1]{\Ref{#1}}
1719 \def\CodeTag[#1][#2]{%
1720 \Tag{#1}{#2}}
1721
1722 See lines \Ref{*}.
1723
1724 \<myprog\><<<
1725 PROGRAM prog;\CodeTag[*][1]|LLL
1726
1727 \<body\><<<
1728 {comment: see \CodeRef[*]}|LLL
1729
1730 \<myprog\><<<
1731 BEGIN
1732 \<body\> \CodeTag[*][2]|LLL
1733
1734 \ResetLineCount \Tag{*}{3}
1735 \<myprog\><<<
1736 END.|LLL \OutputCode\<myprog\>
1737 |Close >>>
1738
1739
1740
1741
1742 \Exr{22}2{11}
1743
1744 \<<<
1745 |Open
1746 \AlProTex{p,<<<|LLL,title,%
1747 list,[],ShowIndex}
1748
1749 \<myprog\><<<
1750 PROGRAM prog;|LLL
1751
1752 \<body\><<<
1753 { comment } |LLL
1754 \TextIndex{Tracing}
1755 \SecIndex{***}
1756
1757 \<myprog\><<<
1758 BEGIN
1759 \<body\>
1760 END.|LLL
1761
1762 \def\BeforeIndex{Index}
1763 \ShowIndex
1764 |Close >>>
1765
1766
1767 \Exr{22}2{12}
1768
1769 \<<<
1770 |Open
1771 \AlProTex{p,<<<|LLL,%
1772 title,[],ShowTop}
1773
1774 \<my prog\><<<
1775 PROGRAM prog;
1776 BEGIN \<body\>
1777 END.|LLL
1778 \<body\><<<
1779 { comment 1}
1780 |LLL
1781 \<body\><<<
1782 \<subbody\>
1783 |LLL
1784 \<subbody\><<<
1785 { comment 2 } |LLL
1786 \ShowTop\<body\>
1787
1788 \def\ShowSep{(* ***** *)\par}
1789 \ShowTop\<body\>
1790 |Close >>>
1791
1792 \Exr{22}2{13}
1793
1794
1795 \<<<
1796 |Open
1797 \AlProTex{p,<<<|LLL,title,%
1798 list,[],NoShow}
1799
1800 First piece of text.
1801
1802 \<myprog\><<<
1803 PROGRAM prog; |LLL
1804
1805 \ShowOff Second piece of text.
1806
1807 \<body\><<<
1808 { comment } |LLL
1809
1810 \Note Third piece of
1811 text. \EndNote\ShowOn
1812
1813 \<myprog\><<<
1814 BEGIN
1815 \<body\>
1816 END.|LLL
1817
1818 Last piece of text.
1819 |Close >>>
1820
1821 \Exr{22}2{14}
1822
1823 \<<<
1824 |Open
1825 \AlProTex{p,<<<|LLL,title,%
1826 list,ShowIndex,ClearCode}
1827
1828 Chapter 1
1829
1830 \<progA\><<<
1831 PROGRAM prog;
1832 |LLL
1833 \<progA\><<<
1834 BEGIN
1835 { comment 1 }
1836 END.|LLL \ShowIndex
1837 \ClearCode
1838 \vfil\break Chapter 2
1839
1840 \<progB\><<<
1841 PROGRAM prog;
1842 |LLL
1843 \<progB\><<<
1844 BEGIN
1845 { comment 2 }
1846 END.|LLL \ShowIndex
1847 |Close >>>
1848
1849 \begingroup
1850 \def\tex{tex}\let\op=\ForTex \Exr{22}2{15}\par\nobreak
1851
1852 \<<<
1853 \hsize=2.5in \noindent{\bf
1854 LITERATE PROGRAM IN WEB}
1855 \medskip We compute a
1856 two-dimensional view of a
1857 three-dimensional point.
1858
1859 @* The mapping. The view
1860 {\tt (x,y)} is on the
1861 {\tt Z=0} plane.
1862 @<map(x,y) := mapping of
1863 (X,Y,Z)@>=
1864 x := X * D DIV (D + Z);
1865
1866 @ The viewer is located
1867 at {\tt (0,0,-D)}.
1868 @<CONST + VAR @>=
1869 CONST D=100;
1870 VAR X {x}, Z: INTEGER;
1871
1872 @
1873 @<map...@>=
1874 y := Y * D DIV (D + Z);
1875
1876 @
1877 @<CON...@>=Y {y}: INTEGER;
1878
1879 @* Main program.
1880 @p PROGRAM D2view;
1881 @<CON...@>
1882 BEGIN read(X,Y,Z);
1883 @<map...@>
1884 write(x,y)
1885 END.
1886 \bye>>>
1887 \endgroup
1888
1889
1890 \Ex{\tex}{NEW OPTION `[[]]' FOR {\tt\char92}AlProTex}{NewAlPrOptionA}
1891
1892 An extension of `[]' which frame also the code fragments.
1893
1894 \<<<
1895 |Open
1896 \AlProTex{p,<<<|LLL,%
1897 title,list,[[]]}
1898
1899 Foooo...
1900
1901 \<myprog\><<<
1902 PROGRAM prog;|LLL
1903
1904 Foooo...
1905
1906 \<body\><<<
1907 { comment } |LLL
1908
1909 Foooo...
1910
1911 \<myprog\><<<
1912 BEGIN
1913 \<body\>
1914 END.|LLL
1915
1916 Foooo...
1917
1918 \OutputCode\<myprog\>
1919 |Close >>>
1920
1921 \begingroup
1922 \def\tex{latex}\let\op=\ForTex
1923
1924
1925 \Ex{\tex}{NEW OPTION `basic' FOR {\tt\char92}AlProTex}{NewAlPrOptionB}
1926
1927
1928 An option that requires compilation by latex. The following
1929 are the only available commands.
1930
1931
1932 A. References to code segments: \hfill {\tt\string\<code title\string\>}
1933
1934 B. Definitions of code fragments: \hfill {\tt\string\<code title\string\><<<
1935
1936 \hfill code fragment>>>}
1937
1938 B. Output file of code (`[{\it extension}]' is optional):
1939 \hfill{\tt\string\o[{\it extention}]\string\<code title\string\>}
1940
1941
1942 C. The character `{\tt\char92}' \hfill{\tt\string\\}
1943
1944 D. End of source program \hfill{\tt\string\e}
1945
1946 E. Logical partitioning of prose (chapters, sections, subsections, and verbatim):
1947 \hfill\hbox{\tt\string\c, \string\s, \string\u, \string\v{$\cdots$}{\char92}}
1948
1949 \noindent\phantom{E.} A title
1950 must be delimited by an empty line.
1951
1952 F. Reference to {\tt\string\ClearCode} \hfill {\tt\string\c}
1953
1954
1955
1956
1957 \<<<
1958 \input ProTex.sty
1959 \AlProTex{foo,basic}
1960
1961 \cFirst Chapter
1962
1963 Foooo...
1964
1965 \sSsssss...
1966
1967 Foooo.
1968
1969 \uUuuuuuu.....
1970
1971 \vVerbatim
1972 verbatim\
1973 \<myprog\><<<
1974 PROGRAM prog;|LLL
1975 \cCccc...
1976
1977 Foooo...
1978
1979 \<body\><<<
1980 { comment } |LLL
1981
1982 Foooo...
1983
1984 \<myprog\><<<
1985 BEGIN
1986 \<body\>
1987 END.|LLL
1988
1989 Foooo...
1990
1991 \o\<myprog\>
1992
1993 \e
1994 >>>
1995
1996 \Ex{\tex}{variant of `basic'}{NewAlPrOptionC}
1997
1998 The options `{\tt @}', `{\tt|}', and `{\tt`}' ask that the listed
1999 characters will be used instead of `{\tt\char92}', respectively,
2000 within the commands of option `{\tt basic}'.
2001
2002 \<<<
2003 \input ProTex.sty
2004 \AlProTex{foo,@,basic}
2005
2006 @cFirst Chapter
2007
2008 Foooo...
2009
2010 @sSsssss...
2011
2012 Foooo.
2013
2014 @uUuuuuuu.....
2015
2016 @vVerbatim
2017 verbatim@
2018
2019 @<myprog@><<<
2020 PROGRAM prog;|LLL
2021 @cCccc...
2022
2023 Foooo...
2024
2025 @<body@><<<
2026 { comment } |LLL
2027
2028 Foooo...
2029
2030 @<myprog@><<<
2031 BEGIN
2032 @<body@>
2033 END.|LLL
2034
2035 Foooo...
2036
2037 @o@<myprog@>
2038
2039 @e
2040 >>>
2041
2042 \endgroup
2043
2044 \newpage \OutputCode[me]\execute
2045
2046
2047 On a Unix system containing the xdvi application, the instructions of
2048 the following file can be executed with the compound command
2049 `chmod 777 execute.me ; execute.me'.
2050
2051 \bigskip
2052 \ShowFile{execute.me}
2053
2054 \write16{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}
2055 \write16{<< Please review the document <<}
2056 \write16{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}
2057
2058 \bye