summaryrefslogtreecommitdiff
path: root/web/tweb/rcs/tweb.tw%
blob: 3ddeec9f2b707dfab4f913a88176eeba02e8a7d9 (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
head	1.2;
access;
symbols;
locks
	WB:1.2;
comment	@# @;


1.2
date	95.07.12.22.44.09;	author WB;	state Exp;
branches;
next	1.1;

1.1
date	95.07.12.22.05.55;	author WB;	state Exp;
branches;
next	;


desc
@@


1.2
log
@*** empty log message ***
@
text
@%%%-*-diff-switches:"-U 0"; compile-command:"notangle tweb.tw>tweb.sty"-*-
%%%=====================================================================
%%% @@Noweb-file{
%%%  author     = "W\l{}odzimierz Bzyl",
%%%  version    = "1.1",
%%%  date       = "11 July 1995",
%%%  filename   = "tweb.tw",
%%%  address    = "Instytut Matematyki,
%%%                Uniwersytet Gda\'nski,
%%%                Wita Stwosza 57,
%%%                80--952 Gda\'nsk, Poland",
%%%  email      = "matwb@@halina.univ.gda.pl (Internet)",
%%%  abstract   = "",
%%% }
%%%=====================================================================

\title{TWEB.TW}{W\l{}odek Bzyl\hfil matwb@@halina.univ.gda.pl}

%%%\printcontents

@@
<<*>>=
\newlinechar `^^J

\def \savecat #1%
    {\expandafter\xdef\csname\string#1savedcat\endcsname{\the\catcode`#1}}
\def \restorecat #1%
    {\catcode`#1=\csname\string#1savedcat\endcsname}
\savecat\@@

\catcode`\@@ = 11

<<Web source formatting macros>>
<<Setting layout of web source>>
<<Macros written by [[web2tex]] script>>
<<Multicolumn environment for indexes>>
<<Index macros>>
<<Cross-reference macros>>
<<Initialize the layout>>

\restorecat\@@
@@
\section{Layout of a web source}

<<Setting layout of web source>>=
<<Fonts for typeseting headings, chapter names, etc.>>
<<Page dimensions>>
<<Headlines>>
<<Table of contents>>
<<Title, chapter, section... macros>>
@@
<<Fonts for typeseting headings, chapter names, etc.>>=
\font \chapterfont = cmbx10 at 20pt
\font \titlefont   = cmssbx10 at 17pt
\font \authorfont  = cmssbx10 at 12pt
\font \sectionfont = cmbx10 at 12pt
\font \tocfont     = cmssbx10 at 12pt

\font \tenbxit     = cmbxti10 \def \bfit {\tenbxit}
\font \tenss       = cmss10
\font \tenssbf     = cmssbx10
\font \ninerm      = cmr9
\font \sevenrm     = cmr7
\font \ninebf      = cmbx9
\font \nineit      = cmti9
\font \ninebxit    = cmbxti10 at 8.5pt
\font \ninett      = cmtt9
\font \ninei       = cmmi9
\font \seveni      = cmmi7
\font \ninesy      = cmsy9
\font \nineex      = cmex9
@@
<<Page dimensions>>=
\hoffset = 0.5in % extra space used to print code line numbers
\hsize   = 6.0in % less 0.5 than plain.tex value
\vsize   = 8.9in % default value
<<Round [[\vsize]] to the nearest multiple of [[\baselineskip]]>>
@@
<<Headlines>>=
\def \RCS {\relax}  \def \RCSversion {Experimental}

\newdimen\textsize \textsize=\hsize

\def \pagenumber
    {\folio}

\headline =
    {\hbox to \textsize{\strut%
          \ifnum\pageno>1
              \tenss\filename\hfil Version \RCSversion%
              \hbox to 4em{\hfil\pagenumber}%
          \else
              \hfil\tenss\RCS%
          \fi}\hss}

\footline = {\hfil}
@@
<<Table of contents>>=
\def \tocline #1#2%
    {\line{{\ignorespaces#1}\leaders\hbox to 3pt{.\hfil}\hfil
     \hbox to 15pt{\hss#2}}}

\def \settocparms #1%
       {\count@@=#1
        \ifnum\count@@<1
            \def\tocskip
               {\vskip 3pt plus 1in
                \penalty-100
                \vskip 0pt plus -1in^^J}
            \def\tocstyle{\tenssbf}
            \def\tocindent{\z@@}
        \else
            \def\tocskip{}
            \def\tocstyle{\tenss}
            \dimen@@=20pt \advance\count@@ by \m@@ne \dimen@@=\count@@\dimen@@
            \edef\tocindent{\the\dimen@@}
        \fi}

\def \topofcontents
    {\vskip2\baselineskip
     \leftline{\tocfont Contents}
     \vskip2ex
     \begingroup\rm}

\def \botofcontents
    {\endgroup
     \semifilbreak{0.9}
     \vskip3\baselineskip}

\def \printcontents
    {\topofcontents
     \Input{\jobname.toc}
     \botofcontents}
@@
[[\startsection{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}{HEADING}]]\par
\leavevmode%
[[               #1     #2      #3           #4         #5      #6]]\par
\medskip
[[#1  LEVEL:         ]] depth; e.g. chapter=0 sectino=1...\par
[[#2  INDENT:        ]] indentation of heading from left margin\par
[[#3  BEFORESKIP:    ]] skip before header\par
[[#4  AFTERSKIP:     ]] skip after header\par
[[#5  STYLE:         ]] style of heading; e.g. [[\bf]]\par
[[#6  HEADING        ]]
@@
<<Title, chapter, section... macros>>=
\def \title #1#2%
    {\vglue4\baselineskip
     \noindent{\rightskip = 0in plus 4em
               \hyphenpenalty = 10000 \exhyphenpenalty = 10000
               \baselineskip = 20pt
               \titlefont#1\par}
     \vskip 0.5\baselineskip
     \hrule height 2pt width \hsize
     \vskip 0.5\baselineskip
     \noindent
     \line{\authorfont #2}
     \vskip2\baselineskip}

\def \startsection#1#2#3#4#5#6%
    {\ifnum#1<2
        \semifilbreak{0.8}
     \fi
     \vskip #3
     \def\titl@@{#6}
     \edef\themodtitle{\sanitize\titl@@}
     \message{[\themodtitle]}
     \settocparms{#1}
     {\edef\next
          {\noexpand\write\cont{\tocskip\string\tocline%
             {\hskip\tocindent\tocstyle\space\sanitize\themodtitle}%
             {\noexpand\the\pageno}}}%
           \next}% write to toc
     \vbox{\leftskip=#2
           \rightskip=0.5true in plus 4em minus 0.5 true in
           \hyphenpenalty=9999 \exhyphenpenalty=9999
           \noindent#5#6}%
     \nobreak
     \vskip#4}

\def \gobblemeaning#1:->{}
\def \sanitize {\expandafter\gobblemeaning\meaning}

\def \chapter#1%
    {\vfil\eject\startsection{0}{\z@@}{\z@@}{6ex}{\chapterfont}{#1}}
\def \section#1%
    {\startsection{1}{\z@@}{4ex}{2ex}{\sectionfont}{#1}}
\def \subsection#1%
    {\startsection{2}{\z@@}{2ex}{1ex}{\tenbf}{#1}}
\def \subsubsection#1%
    {\startsection{3}{\z@@}{1ex}{0ex}{\tenit}{#1}}
\def \paragraph#1%
    {\startsection{4}{\z@@}{1.5ex}{0ex}{\tenit}{#1}}
@@
\section{Indexes}

The user sets the pagenumber style with the [[\pagenumbering{FOO}]]
command, which sets the page counter to 1 and defines [[\thepage]]
to be [[\FOO]]. For example, [[\pagenumbering{roman}]] causes pages
to be numbered i, ii, etc.

<<Index macros>>=
\def \newwrite
    {\alloc@@7\write\chardef\sixt@@@@n} % remove \outer

\def \@@nameuse#1%
    {\csname #1\endcsname}

\def \arabic#1{\@@arabic{\@@nameuse{c@@#1}}}
\def \roman#1{\@@roman{\@@nameuse{c@@#1}}}
\def \Roman#1{\@@Roman{\@@nameuse{c@@#1}}}
\def \alph#1{\@@alph{\@@nameuse{c@@#1}}}
\def \Alph#1{\@@Alph{\@@nameuse{c@@#1}}}

\def \@@arabic#1{\ifnum #1>0 \number #1\fi}
\def \@@roman#1{\romannumeral #1}
\def \@@Roman#1{\expandafter\uppercase\expandafter{\romannumeral #1}}
\def \@@alph#1{\ifcase#1\or a\or b\or c\or d\else\@@ialph{#1}\fi}
\def \@@ialph#1%
    {\ifcase#1\or \or \or \or \or e\or f\or g\or h\or i\or j\or k\or l\or
         m\or n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or y\or
         z\else\@@ctrerr\fi}
\def \@@Alph#1{\ifcase#1\or A\or B\or C\or D\else\@@Ialph{#1}\fi}
\def \@@Ialph#1%
    {\ifcase#1\or \or \or \or \or E\or F\or G\or H\or I\or J\or K\or L\or
         M\or N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or X\or Y\or
         Z\else\@@ctrerr\fi}

\def \pagenumbering#1%
    {\global\pageno \@@ne \gdef\thepage{\csname @@#1\endcsname\pageno}}

\pagenumbering {arabic}
@@
Environment [[\@@bsphack ... \@@esphack]] is
used by macros such as [[\index]] that want to be invisible i.e.,
not leave any extra space when used in the middle of text. Such
a macro should begin with [[\@@bsphack]] and end with [[\@@esphack]].
The macro in question should not create any text, nor change the mode.

<<Index macros>>=
\newdimen \@@savsk
\newcount \@@savsf

\def \@@bsphack
    {\@@savsk\lastskip\ifhmode\@@savsf\spacefactor\fi}

\def \@@esphack
    {\relax%
     \ifhmode\spacefactor\@@savsf
        {}\ifdim \@@savsk >\z@@ \ignorespaces\fi
     \fi}

@@
The command [[\@@sanitize]] changes the catcode of all special characters
except for braces to `other'.  It can be used for commands like
[[\index]] that want to write their arguments verbatim.

<<Index macros>>=
\def \makeother #1{\catcode`#1=12\relax}

\def \@@sanitize
    {\makeother\ \makeother\\\makeother\$%
     \makeother\&\makeother\#\makeother\^%
     \makeother\_\makeother\%\makeother\~\relax}
@@
Default command name [[\indexentry]] is shortened to [[\E]].
This change will make input files for [[makeindex]] shorter.
This would allow to process some indexes on MSDOS
(there is no `big' version of [[makeindx.exe]]).
Above change must be told to [[makeindex]] via style files,
where the following line should be added:
\begindisplay
[[keyword "\\E"]]&\cr
\enddisplay
<<Index macros>>=
\def \makeindex
    {\newwrite\@@indexfile
     \immediate\openout \@@indexfile = \jobname.idx
     \def\index {\@@bsphack\begingroup\@@sanitize\@@wrindex\@@indexfile}
     \message{^^J--> Writing index file \jobname.idx }}
\def \@@wrindex#1#2%
    {\let \thepage = \relax%
     \xdef\gtempa
         {\write#1{\string\E{#2}{\thepage}}}%
          \endgroup\gtempa\@@esphack}
\def \index
    {\@@bsphack\begingroup\@@sanitize\@@index}
\def \@@index#1%
    {\endgroup\@@esphack}

\def \makeglossary
    {\newwrite\@@glossaryfile
     \immediate\openout\@@glossaryfile=\jobname.glo
     \def\glossary{\@@bsphack\begingroup\@@sanitize\@@wrindex\@@glossaryfile}
     \message{Writing glossary file \jobname.glo }\fi}
\def \glossary {\@@bsphack\begingroup\@@sanitize\index}

\def \@@idxitem {\par\hangindent 20pt }
\def \subitem {\par\hangindent 20pt \hskip 20pt }
\def \subsubitem {\par\hangindent 20pt \hskip 30pt }

\def \seeterm{see}
\def \see#1#2%
    {{\it \seeterm\/} #1}

<<Macros for printing web indexes>>
@@
<<Macros for printing web indexes>>=
\def \Input#1%
    {\openin1 #1
     \ifeof1
       \message{^^J--- I cannot find file #1 }
     \else
       \closein1
       \input #1
       \message{^^J<-- Reading file #1 }
     \fi}

\def \indexspace
    {\relax}

\def \printuserleveldefs
    {\singlecolumn
     \vfill\eject
     \Input{\jobname.und}}
\def \printdefs
    {\singlecolumn
     \vfill\eject
     \Input{\jobname.dnd}}
\def \printchunks
    {\singlecolumn
     \vfill\eject
     \let \pagenumber = \relax
     \Input{\jobname.chn}}

\def \beginuserleveldefs
    {\begingroup
     <<Ninepoint environment for printing indexes>>
     \section{User-level definitions}
     \let\item\@@idxitem
     \triplecolumns \tt}
\def \begindefs
    {\begingroup
     <<Ninepoint environment for printing indexes>>
     \section{Definitions}
     \let\item\@@idxitem
     \triplecolumns \tt}
\def \beginchunks
    {\begingroup
     <<Ninepoint environment for printing indexes>>
     \parskip = 2\p@@ plus 2\p@@
     \let\item\@@idxitem
     \section{Chunks}
     \bf}

\def \endindex
    {\endgroup}

\def \makeindexes
    {\par
     \newwrite\@@userleveldefsfile
     \immediate\openout\@@userleveldefsfile=\jobname.udx
     \def\udx{\@@bsphack\begingroup\@@sanitize\@@wrindex\@@userleveldefsfile}
     \message{^^J--> Writing index file \jobname.udx }
     \newwrite\@@defsfile
     \immediate\openout\@@defsfile=\jobname.ddx
     \def\ddx{\@@bsphack\begingroup\@@sanitize\@@wrindex\@@defsfile}
     \message{^^J--> Writing index file \jobname.ddx }
     \newwrite\@@chunkfile
     \immediate\openout\@@chunkfile=\jobname.chk
     \def\chk{\@@bsphack\begingroup\@@sanitize\@@wrindex\@@chunkfile}
     \message{^^J--> Writing index file \jobname.chk }}
@@
<<Ninepoint environment for printing indexes>>=
\textfont0 = \ninerm \scriptfont0 = \sevenrm%
\textfont1 = \ninei \scriptfont1 = \seveni%
\textfont2 = \sevensy%
\textfont3 = \nineex%
\def \rm {\fam0\ninerm} \rm%
\def \it {\nineit}%
\def \bfit {\ninebxit}%
\def \bf {\ninebf}%
\def \tt {\ninett}%
\def \oldstyle {\fam\@@ne\ninei}%
\chardef\\  = "5C%
\parindent = \z@@ \parskip = \z@@%
\hfuzz = \hsize % index pages are wider
\baselineskip = 11pt \topskip = \baselineskip%
<<Round [[\vsize]] to the nearest multiple of [[\baselineskip]]>>
@@
<<Round [[\vsize]] to the nearest multiple of [[\baselineskip]]>>=
\advance \vsize by 0.5\baselineskip
\divide \vsize by \baselineskip
\multiply \vsize by \baselineskip
@@
\section{Multicolumn environment for index formatting}

<<Multicolumn environment for indexes>>=
\def \gobble#1{}
\let \wlog = \gobble

\newskip\abovecolumnskip \abovecolumnskip = \bigskipamount
\newskip\belowcolumnskip \belowcolumnskip = \bigskipamount
\newdimen \gutter \gutter = 2pc
\newdimen \c@@lumnhsize
\newdimen \pagegoal@@limit
\newdimen \htp@@rtialpage
\newtoks \previousoutput
\newcount \number@@fcolumns
\newbox \@@partialpage
\newdimen \singlec@@lumnhsize
\newdimen \singlec@@lumnvsize
\newtoks \previousoutput
\let \@@ndcolumns = \relax
@@
We have a few synonymous ways to refer to multiple column modes.

<<Multicolumn environment for indexes>>=
\def \doublecolumns {\@@columns2}
\def \triplecolumns {\@@columns3}
\def \quadcolumns   {\@@columns4}

\def \singlecolumn
    {\@@ndcolumns\vskip\belowcolumnskip\nointerlineskip}

\let \endcolumns = \singlecolumn

\def \@@columns #1%
    {\@@ndcolumns%
     \begingroup
     \global\let\@@ndcolumns=\@@@@endcolumns
     \par % Shouldn't start in horizontal mode.
     \global\previousoutput = \expandafter{\the\output}
     \pagegoal@@limit = \pagegoal
     \advance \pagegoal@@limit by -5\baselineskip
     \ifdim\pagetotal > \pagegoal@@limit
        \vfill\eject
     \else
        \global\output =
              {\global\setbox\@@partialpage =
                      \vbox{\unvbox255\vskip\abovecolumnskip}}
     \pagegoal = \pagetotal
     \eject % now expand the \output just above.
     \fi
     \global\number@@fcolumns=#1
     \global\c@@lumnhsize = \hsize % if \hsize changed, get the new value.
     \global\advance\c@@lumnhsize by -#1\gutter
     \global\divide\c@@lumnhsize by #1
     \global\output = {\c@@lumnoutput}
     \global\singlec@@lumnhsize = \hsize
     \global\singlec@@lumnvsize = \vsize
     \hsize = \c@@lumnhsize
     \htp@@rtialpage = \ht\@@partialpage
     \advance \htp@@rtialpage by 0.5\baselineskip
     \divide \htp@@rtialpage by \baselineskip
     \multiply \htp@@rtialpage by \baselineskip
     \ht\@@partialpage = \htp@@rtialpage
     \global\advance\vsize by -\htp@@rtialpage
     \global\vsize = #1\vsize }
@@
When this is invoked [[\box 255]] should contain just the right amount of
material, whether triggered by an output routine or a change in the
number of columns. Because columns have to contain a whole number of
lines of type, we take a bit of care with balancing the heights of the
columns to prevent either losing material or having a very short last
column.

{\it Note:} when a page ends due to [[\bye]] or [[\eject]],
[[\box255]] will contain lots of white space, so the columns will not look
balanced. To fix this use [[\singlecolumn]] before ending the page.

<<Multicolumn environment for indexes>>=
\def \@@columnsplit
    {<<Balance columns>>
     \global\setbox255 = \vbox{% see the last line on p.417 (wb)
        \unvbox\@@partialpage
        \ifnum\number@@fcolumns>0%
          \setbox1 = \vbox to \dimen0{\dimen2=\dp1 \unvbox1\kern-\dimen2\vfil}
          \ifnum\number@@fcolumns=1%
             \hbox to \singlec@@lumnhsize{\box1}
          \fi
        \fi
        \ifnum\number@@fcolumns>1%
          \setbox3 = \vbox to \dimen0{\dimen2=\dp3 \unvbox3\kern-\dimen2\vfil}
          \ifnum\number@@fcolumns=1%
            \hbox to \singlec@@lumnhsize{\box1\hfil\box3}
          \fi
        \fi
        \ifnum\number@@fcolumns>2%
          \setbox5 = \vbox to \dimen0{\dimen2=\dp5 \unvbox5\kern-\dimen2\vfil}
          \ifnum\number@@fcolumns=3%
            \hbox to\singlec@@lumnhsize{\box1\hfil\box3\hfil\box5}
          \fi
        \fi
        \ifnum\number@@fcolumns>3%
          \setbox7 = \vbox to \dimen0{\dimen2=\dp7 \unvbox7\kern-\dimen2\vfil}
          \ifnum\number@@fcolumns=4%
            \hbox to\singlec@@lumnhsize{\box1\hfil\box3\hfil\box5\hfil\box7}
          \fi
        \fi}}

\def \c@@lumnoutput
    {\@@columnsplit
     \hsize = \singlec@@lumnhsize % local to the \output group
     \vsize = \singlec@@lumnvsize
     \the\previousoutput
     \global\vsize=\number@@fcolumns\singlec@@lumnvsize}

\def \@@@@endcolumns
    {\global\let\@@ndcolumns=\relax%
     \par % Shouldn't start in horizontal mode.
     \global\output = {\global\setbox1 = \box255}%
     \pagegoal = \pagetotal
     \eject
     \global\setbox255 = \box1
     \@@columnsplit
     \global\vsize = \singlec@@lumnvsize
     \global\output = \expandafter{\the\previousoutput}%
     \endgroup
     \unvbox255}
@@
<<Balance columns>>=
\dimen0 = \ht255
\advance \dimen0 by \topskip
\advance \dimen0 by -\baselineskip
\divide\dimen0 by \number@@fcolumns
\splittopskip = \topskip
\begingroup
   \vbadness = 10000
   \loop
     \setbox8=\copy255
     \global\setbox1 = \vsplit8 to \dimen0
     \global\setbox3 = \vsplit8 to \dimen0
     \ifnum\number@@fcolumns>2%
       \global\setbox5 = \vsplit8 to \dimen0
     \fi
     \ifnum\number@@fcolumns>3%
       \global\setbox7 = \vsplit8 to \dimen0
     \fi
     \ifdim\ht8>\z@@ \global\advance\dimen0 by 1pt
   \repeat
\endgroup
@@
\section{Cross references}

[[\ref{value}{name}]] gives value to [[name]]\par
[[\pageref{name}]] writes [[\ref{]]\stress{page number}[[}{name}]] to [[.ref]] file \par
[[\refpage{name}]] prints page number referenced by [[name]] \par
[[\showmissestrue]] if you want to see missing references

<<Cross-reference macros>>=
\newcount\miscount      % number of unknown references
\newif\ifshowmisses

\def \ref #1#2%
    {\xdef\temp{#1}
     \expandafter\dordef\csname#2\endcsname}
\def \dordef #1%
    {\global\let#1\temp}

\Input{\jobname.ref}
\newwrite\refo \immediate\openout\refo=\jobname.ref

\def \pageref #1%
    {\write\refo{\string\ref{\number\pageno}{#1}}}
\def \refpage #1%
    {\expandafter\usedef\csname#1\endcsname}

\def \usedef #1%
    {\ifx#1\relax%
       \ifshowmisses\showmiss #1 \fi%
       \global\advance\miscount by 1 ???%
     \else%
       #1%
     \fi}

\def \showmiss #1%
    {{\escapechar=-1%
     \message{^^J*** WARNING: Undefined reference > #1<}}}

\outer \def \bye
      {\write \cont {\string\restorecat\string\@@}
       \closeout\cont
       \ifnum\miscount>0
           \message{^^J!!! \the\miscount\space %
                    undefined reference(s) were present }%
       \fi
       \par\vfill\supereject
       \end}
@@
\section{Web2tex macros}

<<Macros written by [[web2tex]] script>>=
{\obeyspaces\global\let = \ } % from texbook, p.381

{\catcode`\`=\active \gdef`{\relax\lq}}
{\catcode`\^^I=\active \gdef^^I{\ \ \ }}

{\obeyspaces\global\def\gobblespace#1{\ifx#1 \else#1\fi}}

\def \setupmodname
    {\catcode`\$=3 \catcode`\&=4%
     \catcode`\#=6 \catcode`\%=14%
     \catcode`\~=13 \catcode`\_=8%
     \catcode`\^=7 \catcode`\ =10%
     \catcode`\^^M=5\relax}

\def \LA {\begingroup\setupmodname$\langle\,$\bfit}
\def \RA {\/$\,\rangle$\endgroup}

\gdef \ttverbatim
     {\begingroup%
      \makeother\\\makeother\{\makeother\}\makeother\$%
      \makeother\&\makeother\#\makeother\%\makeother\~%
      \makeother\_\makeother\^\makeother\"%
      \obeyspaces\obeylines\tt}

\newskip\ttglue
\ttglue=.5em plus.25em minus.15em

{\catcode`\|=\active
 \obeylines \gdef|{\ttverbatim \spaceskip\ttglue \let^^M=\  \let|=\endgroup}}

\def \CODE%
    {\ttverbatim%
     \let\par=\endgraf%
     \parskip=\z@@%
     \leavevmode%
     \ttfinish}% written by web2tex script itself

%%% {\catcode`\| = 0 |catcode`|\ = 12 %
%%% |obeylines |gdef|ttfinish#1<EDOC>{|gobblespace#1|endgroup}}

\def \NO #1% line numbers which appear in the margin
    {\noindent\llap{\ninei #1\qquad}\kern\parindent}

\def \N #1#2% page number -- line number (indexes)
    {$#2_{\oldstyle#1}$}

\def \BEGINCODE
    {\semifilbreak{0.9}
     \bigskip
     \begingroup
     \obeylines}
\def \ENDCODE
    {\endgroup
     \semifilbreak{0.9}}

\def \BEGINDOC
    {\bigskip
     \begingroup
     \catcode`\|=\active}
\def \ENDDOC
    {\endgroup}

\newif \iffullpages

\newdimen \upperbound

\def \semifilbreak #1%
    {\par
     \upperbound = #1\vsize       %% 0.1\vsize \approx 5\baselineskip
     \ifdim\pagetotal > \pagegoal %% page already overfull;
                                  %% left to page builder
     \else
       \ifdim\pagetotal > \upperbound
          \vfill\eject
       \fi
     \fi}
@@
\section{Macros used for web source formatting}

<<Web source formatting macros>>=
<<Changing font>>
<<Typeseting font tables>>
<<Non-centered displays>>
<<Typeseting units of measure and syntactic quantities>>
@@
<<Typeseting font tables>>=
\def \oct#1{\hbox{\rm\'{}\kern-.2em\it#1\/\kern.05em}} % octal constant
\def \hex#1{\hbox{\rm\H{}\tt#1}} % hexadecimal constant

\def \oddline#1%
    {\cr
     \noalign{\nointerlineskip}
     \multispan{19}\hrulefill&
     \setbox0=\hbox{\lower 2.3pt\hbox{\hex{#1x}}}\smash{\box0}\cr
     \noalign{\nointerlineskip}}

\def \evenline {\cr\noalign{\hrule}}

\def \chartstrut {\lower4.5pt\vbox to14pt{}}

\def \beginchart#1%
    {$$\postdisplaypenalty=-10000 \global\count@@=0 #1
     \halign to\hsize\bgroup
     \chartstrut##\tabskip0pt plus10pt&
     &\hfil##\hfil&\vrule##\cr
     \lower6.5pt\null
     &&&\oct0&&\oct1&&\oct2&&\oct3&&\oct4&&\oct5&&\oct6&&\oct7&\evenline}

\def \endchart
    {\raise11.5pt\null&&&\hex 8&&\hex 9&&\hex A&&\hex B&
     &\hex C&&\hex D&&\hex E&&\hex F&\cr\egroup$$}

\def \:{\setbox0=\hbox{\char\count@@}%
        \ifdim\ht0>7.5pt\reposition
        \else\ifdim\dp0>2.5pt\reposition\fi\fi
       \box0\global\advance\count@@ by1 }

\def \reposition {\setbox0=\hbox{$\vcenter{\kern2pt\box0\kern2pt}$}}

\def \normalchart
    {&\oct{00x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\oddline0
     &\oct{01x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&\evenline
     &\oct{02x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\oddline1
     &\oct{03x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&\evenline
     &\oct{04x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\oddline2
     &\oct{05x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&\evenline
     &\oct{06x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\oddline3
     &\oct{07x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&\evenline
     &\oct{10x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\oddline4
     &\oct{11x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&\evenline
     &\oct{12x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\oddline5
     &\oct{13x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&\evenline
     &\oct{14x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\oddline6
     &\oct{15x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&\evenline
     &\oct{16x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\oddline7
     &\oct{17x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&\evenline}

@@
<<Non-centered displays>>=
\outer\def \begindisplay
          {\obeylines\startdisplay}

{\obeylines\gdef\startdisplay#1
  {\catcode`\^^M=5$$#1\halign\bgroup\indent##\hfil&&\qquad##\hfil\cr}}

\outer\def\enddisplay{\crcr\egroup$$}
@@
<<Changing font>>=
\def \bold#{\bgroup\bf\let\next = }

\def \ttt#{\bgroup\tt\let\next = }% typewriter

\def \stress #1%
    {\begingroup
     \def \next
         {\def \next
              {\setbox 0 = \hbox {\nexttoken}%
               \ifdim \ht 0< \fontdimen 5 \font
                      \it #1%
               \else
                      \it #1\/%
               \fi}%
          \ifcat A\noexpand \nexttoken
                \next
          \else
                \ifcat 0\noexpand \nexttoken
                        \next
                \else
                        \ifcat \space \noexpand \nexttoken
                        \else
                               %%% \message {?: \meaning \nexttoken}%
                        \fi
                        \it #1\/%
                \fi
          \fi
          \endgroup}%
     \futurelet \nexttoken \next }
@@
<<Typeseting units of measure and syntactic quantities>>=
\def \<#1>{\leavevmode\hbox{$\langle$#1\/$\rangle$}}

\def \pt {\,{\rm pt}} % units of points, in math formulas
\def \in {\,{\rm in}} % units of inches, in math formulas
\def \em {\,{\rm em}} % units of em, in math formulas
@@
<<Initialize the layout>>=
\raggedbottom
\frenchspacing
\fullpagesfalse
\newwrite \cont
\openout \cont = \jobname.toc
\write \cont {\string\savecat\string\@@}
\write \cont {\string\catcode`\string\@@=11}
@


1.1
log
@Initial revision
@
text
@d5 2
a6 3
%%%  version    = "$Id: tweb.tw,v 2.74 1995/07/05 10:38:39 web Exp $",
%%%  date       = "13 June 1995",
%%%  time       = "17:34:59 MET",
a7 1
%%%  checksum   = "11515 801 2110 24084",
a11 1
%%%  checksum   = "61084 897 2387 27063",
d80 1
a80 1
\def \RCS {\jobname.tw}  \def \RCSversion {Experimental}
@