Debian Codegraph @

texmf-dist/tex/plain/cweb/cwebbin/pdfctwimac.tex

raw
1 % standard macros for CWEB listings (in addition to plain.tex)
2 % Version 4.12 --- August 2024
3 % modified for pages produced by CTWILL
4 % further modified for page size of the MMIXware book
5 % modified for PDF output with 'tex "\let\pdf+' or '{lua|pdf|xe}tex'
6 % This file is not copyrighted and can be used freely.
7 \ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros
8 \xdef\fmtversion{\fmtversion+CTWILL4.12+LNCS+PDF}
9
10 \let\:=\. % preserve a way to get the dot accent
11 % (all other accents will still work as usual)
12
13 \newdimen\em \em=10pt % this "em" will not change with font size
14 \parskip 0pt plus .1pt % almost no stretch between paragraphs
15 \parindent 1\em % for paragraphs and for the first line of C text
16
17 \newif\ifsorted
18 \newread\sreffile
19 \newwrite\reffile
20 \ifx\norefs\def\else
21 \openin\sreffile=\jobname.sref
22 \ifeof\sreffile \immediate\openout\reffile=\jobname.ref
23 \sortedfalse \message{This is the first pass!}
24 \else \sortedtrue \message{This is the second pass!} \fi
25 \fi
26
27 \font\ninerm=cmr9
28 \let\mc=\ninerm % medium caps
29 \font\eightrm=cmr8
30 \font\sixrm=cmr6
31 \font\ninei=cmmi9
32 \font\eighti=cmmi8
33 \font\sixi=cmmi6
34 \skewchar\ninei='177 \skewchar\eighti='177 \skewchar\sixi='177
35 \font\ninesy=cmsy9
36 \font\eightsy=cmsy8
37 \font\sixsy=cmsy6
38 \skewchar\ninesy='60 \skewchar\eightsy='60 \skewchar\sixsy='60
39 \font\ninebf=cmbx9
40 \font\eightbf=cmbx8
41 \font\sixbf=cmbx6
42 \font\ninett=cmtt9
43 \font\eighttt=cmtt8
44 \hyphenchar\ninett=-1 \hyphenchar\eighttt=-1
45 \font\ninesl=cmsl9
46 \font\eightsl=cmsl8
47 \font\nineit=cmti9
48 \font\eightit=cmti8
49 \font\tentex=cmtex10
50 \font\ninetex=cmtex9 % TeX extended character set (used in strings)
51 \font\eighttex=cmtex8
52 \fontdimen7\tentex=0pt % no double space after sentences
53 \fontdimen7\ninetex=0pt
54 \fontdimen7\eighttex=0pt
55
56 \newif\iftenpoint
57 \def\tenpoint{\tenpointtrue
58 \def\rm{\fam0\tenrm}%
59 \textfont0=\tenrm \scriptfont0=\sevenrm \scriptscriptfont0=\fiverm
60 \textfont1=\teni \scriptfont1=\seveni \scriptscriptfont1=\fivei
61 \textfont2=\tensy \scriptfont2=\sevensy \scriptscriptfont2=\fivesy
62 \textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex
63 \def\it{\fam\itfam\tenit}%
64 \textfont\itfam=\tenit
65 \def\sl{\fam\slfam\tensl}%
66 \textfont\slfam=\tensl
67 \def\bf{\fam\bffam\tenbf}%
68 \textfont\bffam=\tenbf \scriptfont\bffam=\sevenbf
69 \scriptscriptfont\bffam=\fivebf
70 \def\tt{\fam\ttfam\tentt}%
71 \textfont\ttfam=\tentt
72 \def\ttx{\tentex}%
73 \normalbaselineskip=12pt
74 \let\cmntfont=\tenrm
75 \let\mc=\ninerm
76 \let\sc=\eightrm
77 \let\big=\tenbig
78 \setbox\strutbox=\hbox{\vrule height8pt depth3pt width 0pt}%
79 \normalbaselines\rm}
80
81 \def\ninepoint{\tenpointfalse
82 \def\rm{\fam0\ninerm}%
83 \textfont0=\ninerm \scriptfont0=\sixrm \scriptscriptfont0=\fiverm
84 \textfont1=\ninei \scriptfont1=\sixi \scriptscriptfont1=\fivei
85 \textfont2=\ninesy \scriptfont2=\sixsy \scriptscriptfont2=\fivesy
86 \textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex
87 \def\it{\fam\itfam\nineit}%
88 \textfont\itfam=\nineit
89 \def\sl{\fam\slfam\ninesl}%
90 \textfont\slfam=\ninesl
91 \def\bf{\fam\bffam\ninebf}%
92 \textfont\bffam=\ninebf \scriptfont\bffam=\sixbf
93 \scriptscriptfont\bffam=\fivebf
94 \def\tt{\fam\ttfam\ninett}%
95 \textfont\ttfam=\ninett
96 \def\ttx{\ninetex}%
97 \normalbaselineskip=11pt
98 \let\cmntfont=\ninerm
99 \let\mc=\eightrm
100 \let\sc=\sevenrm
101 \let\big=\ninebig
102 \setbox\strutbox=\hbox{\vrule height8pt depth3pt width 0pt}%
103 \normalbaselines\rm}
104
105 \def\eightpoint{%
106 \def\rm{\fam0\eightrm}%
107 \textfont0=\eightrm \scriptfont0=\sixrm \scriptscriptfont0=\fiverm
108 \textfont1=\eighti \scriptfont1=\sixi \scriptscriptfont1=\fivei
109 \textfont2=\eightsy \scriptfont2=\sixsy \scriptscriptfont2=\fivesy
110 \textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex
111 \def\it{\fam\itfam\eightit}%
112 \textfont\itfam=\eightit
113 \def\sl{\fam\slfam\eightsl}%
114 \textfont\slfam=\eightsl
115 \def\bf{\fam\bffam\eightbf}%
116 \textfont\bffam=\eightbf \scriptfont\bffam=\sixbf
117 \scriptscriptfont\bffam=\fivebf
118 \def\tt{\fam\ttfam\eighttt}%
119 \textfont\ttfam=\eighttt
120 \def\ttx{\eighttex}%
121 \normalbaselineskip=9pt
122 \let\cmntfont=\eightrm
123 \let\mc=\sevenrm
124 \let\sc=\sixrm
125 \let\big=\eightbig
126 \setbox\strutbox=\hbox{\vrule height7pt depth2pt width 0pt}%
127 \normalbaselines\rm}
128
129 \tenpoint
130 \def\tenbig#1{{\hbox{$\left#1\vbox to8.5pt{}\right.\nulldelimiterspace=0pt$}}}
131 \def\ninebig#1{{\hbox{$\textfont0=\tenrm\textfont2=\tensy
132 \left#1\vbox to7.25pt{}\right.\nulldelimiterspace=0pt$}}}
133 \def\eightbig#1{{\hbox{$\textfont0=\ninerm\textfont2=\ninesy
134 \left#1\vbox to6.5pt{}\right.\nulldelimiterspace=0pt$}}}
135
136 %\font\tenss=cmss10 \let\cmntfont\tenss % alternative comment font
137 \font\titlefont=cmr7 scaled\magstep4 % title on the contents page
138 \font\ttitlefont=cmtt10 scaled\magstep2 % typewriter type in title
139
140 \def\CEE/{{\mc C\spacefactor1000}}
141 \def\UNIX/{{\mc U\kern-.05emNIX\spacefactor1000}}
142 \def\TEX/{\TeX}
143 \def\CPLUSPLUS/{{\mc C\PP\spacefactor1000}}
144 \def\Cee{\CEE/} % for backward compatibility
145 \def\Cpp{\CPLUSPLUS/} % for backward compatibility
146 \def\9#1{}
147 % with this definition of \9 you can say @:sort key}{TeX code@>
148 % to alphabetize an index entry by the sort key but format with the TeX code
149
150 \def\\#1{\leavevmode\hbox{\it#1\/\kern.05em}} % italic type for identifiers
151 \def\|#1{\leavevmode\hbox{$#1$}} % one-letter identifiers look better this way
152 \def\&#1{\leavevmode\hbox{\bf
153 \def\_{\kern.04em\vbox{\hrule width.3em height .6pt}\kern.08em}%
154 #1\/\kern.05em}} % boldface type for reserved words
155 \def\.#1{\leavevmode\hbox{\ttx % typewriter type for strings
156 \let\\=\BS % backslash in a string
157 \let\{=\LB % left brace in a string
158 \let\}=\RB % right brace in a string
159 \let\~=\TL % tilde in a string
160 \let\ =\SP % space in a string
161 \let\_=\UL % underline in a string
162 \let\&=\AM % ampersand in a string
163 \let\^=\CF % circumflex in a string
164 #1\kern.05em}}
165 \def\){{\tentex\kern-.05em}\discretionary{\hbox{\tentex\BS}}{}{}}
166 \def\AT{@} % at sign for control text (not needed in versions >= 2.9)
167 \def\ATL{\par\noindent\bgroup\catcode`\_=12 \postATL} % print @l in limbo
168 \def\postATL#1 #2 {\bf letter \\{\uppercase{\char"#1}}
169 tangles as \tentex "#2"\egroup\par}
170 \def\noATL#1 #2 {}
171 \def\noatl{\let\ATL=\noATL} % suppress output from @l
172 \def\ATH{{\pdffalse\X\kern-.5em:Preprocessor definitions\X}}
173 \let\PB=\relax % hook for program brackets |...| in TeX part or section name
174
175 \chardef\AM=`\& % ampersand character in a string
176 \chardef\BS=`\\ % backslash in a string
177 \chardef\LB=`\{ % left brace in a string
178 \chardef\RB=`\} % right brace in a string
179 \def\SP{{\tt\char`\ }} % (visible) space in a string
180 \chardef\TL=`\~ % tilde in a string
181 \chardef\UL=`\_ % underline character in a string
182 \chardef\CF=`\^ % circumflex character in a string
183
184 \newbox\PPbox % symbol for ++
185 \setbox\PPbox=\hbox{\kern.5pt\raise1pt\hbox{\sevenrm+\kern-1pt+}\kern.5pt}
186 \def\PP{\copy\PPbox}
187 \newbox\MMbox \setbox\MMbox=\hbox{\kern.5pt\raise1pt\hbox{\sevensy\char0
188 \kern-1pt\char0}\kern.5pt}
189 \def\MM{\copy\MMbox}
190 \newbox\MGbox % symbol for ->
191 \setbox\MGbox=\hbox{\kern-2pt\lower3pt\hbox{\teni\char'176}\kern1pt}
192 \def\MG{\copy\MGbox}
193 \def\MRL#1{\mathrel{\let\K==#1}}
194 \let\GG=\gg
195 \let\LL=\ll
196 \let\NULL=\Lambda
197 \mathchardef\AND="2026 % bitwise and; also \& (unary operator)
198 \let\OR=\mid % bitwise or
199 \let\XOR=\oplus % bitwise exclusive or
200 \def\CM{{\sim}} % bitwise complement
201 \newbox\MODbox \setbox\MODbox=\hbox{\eightrm\%}
202 \def\MOD{\mathbin{\copy\MODbox}}
203 \def\DC{\kern.1em{::}\kern.1em} % symbol for ::
204 \def\PA{\mathbin{.*}} % symbol for .*
205 \def\MGA{\mathbin{\MG*}} % symbol for ->*
206 \def\this{\&{this}}
207
208 \newbox\bak \setbox\bak=\hbox to -1\em{} % backspace one em
209 \newbox\bakk\setbox\bakk=\hbox to -2\em{} % backspace two ems
210
211 \newcount\ind % current indentation in ems
212 \def\1{\global\advance\ind by1\hangindent\ind\em} % indent one more notch
213 \def\2{\global\advance\ind by-1} % indent one less notch
214 \def\3#1{\hfil\penalty#10\hfilneg} % optional break within a statement
215 \def\4{\copy\bak} % backspace one notch
216 \def\5{\hfil\penalty-1\hfilneg\kern2.5\em\copy\bakk\ignorespaces}% optional break
217 \def\6{\ifmmode\else\par % forced break
218 \hangindent\ind\em\noindent\kern\ind\em\copy\bakk\ignorespaces\fi}
219 \def\7{\Y\6} % forced break and a little extra space
220 \def\8{\hskip-\ind\em\hskip 2\em} % no indentation
221
222 \newcount\gdepth % depth of current major group, plus one
223 \newtoks\gtitle % title of current major group
224 \newskip\intersecskip \intersecskip=12pt minus 3pt % space between sections
225 \let\yskip=\smallskip
226 \def\?{\mathrel?}
227 \def\,{\relax\ifmmode\mskip\thinmuskip\else\thinspace\fi}
228 \def\note#1#2.{\par\penalty5000
229 \Y\noindent{\hangindent2\em\baselineskip10pt%
230 \eightrm#1~\ifacro{\pdfnote#2.}\else#2\fi.\par}}
231
232 \newtoks\toksA \newtoks\toksE
233 \newcount\countA \countA=0 \newcount\countB \countB=0
234 \newcount\countNOS \countNOS=0
235 {\def\\{\global\let\spacechar= }\\ }
236
237 % Here we decide the output format, depending on the TeX engine in use:
238 \input iftex.sty % TeX engine tests
239 \ifx\pdf+\pdftrue\fi % for plain TeX in combination with dvipdfm
240 % Uncomment the following line if you want PDF goodies to be the default
241 %\ifx\pdf-\else\pdftrue\fi
242 \ifxetex\pdftrue\fi % XeTeX produces PDF output
243 \ifpdf \def\pdflinkcolor{0 0 1} \fi % the RGB values for hyperlink color
244 \let\ifacro=\ifpdf
245 \ifhint\message{These macros are not suitable for HiTeX.}
246 \message{Please use 'ctwill +P [+lpdf]' instead.}
247 \end
248 \fi
249 \newif\ifacrohint \ifacro\acrohinttrue\fi \ifhint\acrohinttrue\fi
250 \newif\ifpdflua \ifluatex\pdfluatrue\fi \ifpdftex\pdfluatrue\fi
251 \ifpdflua % luaTeX and pdfTeX produce PDF output if \pdfoutput>0
252 \def\Black{\pdfliteral{0 g 0 G}} % use rgb colors for direct PDF output too
253 \def\Blue{\pdfliteral{\pdflinkcolor\space rg \pdflinkcolor\space RG}}
254 \fi
255 \input cwebacromac % load hypertext macros
256
257 \def\lapstar{\rlap{*}}
258 \def\stsec{\tenpoint\rightskip=0pt % get out of C mode (cf. \B)
259 \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50
260 \noindent\strut{\let\*=\lapstar\bf\secno.\quad}%
261 \ifacro \smash{\raise\baselineskip\hbox to0pt{\let\*=\empty
262 \ifpdflua \pdfdest num \secstar fith%
263 \else \special{pdf: dest (\romannumeral\secstar)
264 [ @thispage /FitH @ypos ]}\fi}}\fi}
265 \def\startsection{\titletrue
266 \line{\smash{\titlefont\title}\quad\hrulefill}\bigskip
267 \let\startsection=\stsec\stsec}
268 \def\defin#1{\global\advance\ind by 2 \1\&{#1 }} % begin `define' or `format'
269 \def\A{\note{See also section}} % xref for doubly defined section name
270 \def\As{\note{See also sections}} % xref for multiply defined section name
271 \def\B{\iftenpoint\ninepoint\fi
272 \font\niness=cmss9 \let\cmntfont\niness % alternative comment font
273 \rightskip=0pt plus 100pt minus 10pt % go into C mode
274 \sfcode`;=3000
275 \pretolerance 10000
276 \hyphenpenalty 9999 % so strings can be broken (discretionary \ is inserted)
277 \exhyphenpenalty 10000
278 \global\ind=2 \1\ \unskip}
279 %\def\C#1{\5\5\quad$/\ast\,${\cmntfont #1}$\,\ast/$}
280 %\let\SHC\C % "// short comments" treated like "/* ordinary comments */"
281 \def\C#1{\5\5\quad$\triangleright\,${\cmntfont#1}$\,\triangleleft$}
282 \def\SHC#1{\5\5\quad$\diamond\,${\cmntfont#1}}
283 \def\D{\defin{{\rm\#}define}} % macro definition
284 \let\E=\equiv % equivalence sign
285 \def\ET{ and~} % conjunction between two section numbers
286 \def\ETs{, and~} % conjunction between the last two of several section numbers
287 \def\F{\defin{format}} % format definition
288 \let\G=\ge % greater than or equal sign
289 % \H is long Hungarian umlaut accent
290 \let\I=\ne % unequal sign
291 \def\J{\.{@\&}} % CTANGLE's join operation
292 %\let\K== % assignment operator
293 \let\K=\leftarrow % "honest" alternative to standard assignment operator
294 % \L is Polish letter suppressed-L
295 \outer\def\M#1{%
296 {\xdef\secstar{#1}\let\*=\empty\xdef\secno{#1}}% remove \* from section name
297 \vskip\intersecskip\startsection\ignorespaces}
298 \outer\def\N{\ifvoid\partialpage\lefttrue
299 \else\ifdim\ht\partialpage<\pageheight \leftfalse\else\lefttrue\fi\fi\NNN}
300 \outer\def\NN{\ifvoid\partialpage\leftfalse
301 \else\ifdim\ht\partialpage<\pageheight \lefttrue\else\leftfalse\fi\fi\NNN}
302 \outer\def\NNN#1#2#3.{% beginning of starred section
303 \ifacro{\makeoutlinetoks#3\outlinedone}\fi
304 \gdepth=#1\gtitle={#3}\def\secno{#2}\xdef\secstar{#2}
305 \ifleft \flushout
306 \gdef\rlhead{\let\i=I\uppercase{\ignorespaces#3}} % running left headline
307 \global\let\rrhead=\rlhead % running right headline
308 \else\global\setbox\partialpage=\vbox{
309 \vbox to\pageheight{\unvbox\partialpage\vfill}\break}
310 \gdef\rrhead{\let\i=I\uppercase{\ignorespaces#3}}
311 \fi
312 \message{*\secno} % progress report
313 \ifpdf \ifpdflua\def\stripprefix##1>{}\def\gtitletoks{#3}%
314 \edef\gtitletoks{\expandafter\stripprefix\meaning\gtitletoks}%
315 {\immediate\write\cont{\ZZ{\gtitletoks}{#1}{\secno}% write to contents file
316 {\noexpand\the\pageno}{\the\toksE}}} % \ZZ{title}{depth}{sec}{page}{ss}
317 \expandafter\xdef\csname curr#1\endcsname{\secno}
318 \ifnum#1>0\countB=#1 \advance\countB by-1
319 \advancenumber{chunk\the\countB.\expnumber{curr\the\countB}}\fi
320 \else \special{pdf: outline #1 << /Title (\the\toksE)
321 /Dest [ @thispage /FitH @ypos ] >>}\fi \fi
322 \startsection{\bf\ignorespaces#3.\quad}\ignorespaces}
323 \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
324 \else \csname#1\endcsname \fi} % Petr Olsak's macros from texinfo.tex
325 \def\advancenumber#1{\countA=\expnumber{#1}\relax \advance\countA by1
326 \expandafter\xdef\csname#1\endcsname{\the\countA}}
327 % \O is Scandinavian letter O-with-slash
328 % \P is paragraph sign
329 \def\Q{\note{This code is cited in section}} % xref for mention of a section
330 \def\Qs{\note{This code is cited in sections}} % xref for mentions of a section
331 \let\R=\lnot % logical not
332 % \S is section sign
333 \def\T#1{\leavevmode % octal, hex or decimal constant
334 \hbox{$\def\?{\kern.2em}%$%
335 \let\ \, % C++ digit separator becomes a little white space
336 \def\$##1{\egroup_{\rm##1}\bgroup}%$% suffix to constant
337 \def\_{\cdot 10^{\aftergroup}}% power of ten (via dirty trick)
338 \let\~=\oct \let\^=\hex \let\\=\bin {#1}$}}%$%
339 \def\U{\note{This code is used in section}} % xref for use of a section
340 \def\Us{\note{This code is used in sections}} % xref for uses of a section
341 \let\V=\lor % logical or
342 \let\W=\land % logical and
343 \def\X#1:#2\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi %$% section name
344 \XX$\langle\,${\let\I=\ne#2\sevenrm\kern.5em
345 \ifpdf{\pdfnote#1.}\else#1\fi}$\,\rangle$\XX}
346 \def\Y{\par\yskip}
347 \let\Z=\le
348 \let\ZZ=\let % now you can \write the control sequence \ZZ
349 \let\*=*
350
351 %\def\oct{\hbox{\rm\char'23\kern-.2em\it\aftergroup\?\aftergroup}} % WEB style
352 %\def\hex{\hbox{\rm\char"7D\tt\aftergroup}} % WEB style
353 \def\oct{\hbox{$^\circ$\kern-.1em\it\aftergroup\?\aftergroup}} % CWEB style
354 \def\hex{\hbox{$^{\scriptscriptstyle\#}$\tt\aftergroup}} % CWEB style
355 \def\bin{\hbox{$^{\scriptscriptstyle b}$\tt\aftergroup}} % new in CWEB 4.3
356 \def\vb#1{\leavevmode\hbox{\kern2pt\vrule\vtop{\vbox{\hrule
357 \hbox{\strut\kern2pt\.{#1}\kern2pt}}
358 \hrule}\vrule\kern2pt}} % verbatim string
359 \def\p#1{\cdot 2^{#1}} % power of two (hex exponent)
360
361 % now here's the mini-index formatting control
362 \newcount\nrefs % total number of references in partial page
363 \newcount\baseno % smallest section number in partial page
364 \toksdef\prefs=199 % references to previous sections in current program
365 \toksdef\frefs=220 % references to future sections in current program
366 \toksdef\erefs=221 % references to sections in another program
367 % \count and \toks registers 200--219 are also used to keep track of refs
368 \catcode`\@=11
369 \newcount\@n \newcount\@m \newcount\@p
370 \newdimen\pageheight \pageheight=19cm
371 \newdimen\pagewidth \pagewidth=13cm
372 \newdimen\colwd \colwd=\pagewidth
373 \advance\colwd by -2pc \divide\colwd by 3 % for three columns
374 \newdimen\fullpageheight \fullpageheight=\pageheight \advance\fullpageheight by 4pc
375 \newdimen\pagethresh \pagethresh=2\pageheight
376 \newdimen\nsize \newdimen\msize
377 \newskip\intersecskip \intersecskip=8pt plus 2pt minus 3pt
378 \newbox\partialpage
379 \newbox\newsec
380 \newtoks\newrefs
381 \newtoks\ttoks
382 \newdimen\ninept \ninept=9pt
383 \newif\iftitle \newif\ifleft
384
385 \def\flushout{\ifvoid\partialpage\else
386 \setbox0=\vsplit\partialpage to \pageheight
387 \shipout\vbox{
388 \vbox to 3pc{\leftheadline\vfill}
389 \nointerlineskip\box0}
390 \global\advance\pageno 1
391 \global\let\[=\makeinref \global\let\]=\makeoutref
392 \ifsorted \let\readin=\readln \readrefs
393 \else \immediate\write\reffile{!\the\pageno}\let\readin=\readrefs \fi
394 \setbox0=\vbox{\eightpoint \hsize=\colwd
395 \rightskip=0pt plus 100pt minus 10pt
396 \pretolerance 10000
397 \hyphenpenalty 10000 \exhyphenpenalty 10000
398 \noindent\vbox to1pt{}\par % 1pt = \topskip - \ninept
399 \readin}
400 \shipout\vbox to\fullpageheight{
401 \vbox to 3pc{\rightheadline\vfill}
402 \unvbox\partialpage
403 \vfill
404 \ifdim\ht0>1pt \kern11pt\hrule \hbox{%
405 \nsize=\ht0 \advance\nsize-\topskip
406 \divide\nsize by 3 \divide\nsize by\ninept
407 \multiply\nsize by\ninept \advance\nsize\topskip
408 \vsplit0 to\nsize \kern1pc
409 \msize=\ht0 \advance\msize-\topskip
410 \divide\msize by 2 \divide\msize by\ninept
411 \multiply\msize by\ninept \advance\msize\topskip
412 \vbox to\nsize{\vsplit0 to\msize\vss}\kern1pc
413 \vbox to\nsize{\box0\vss}} \fi}
414 \global\advance\pageno 1 \global\let\rlhead=\rrhead\fi
415 {\globaldefs=1
416 \@n=199 \loop \ifnum\@n<222 \toks\@n={} \count\@n=0 \advance\@n 1 \repeat
417 \nrefs=0
418 \baseno=\secno}}
419 \def\leftheadline{\hbox to\pagewidth{\vbox to10pt{}%
420 \iftitle\global\titlefalse\else\ninerm\title:\enspace \eightsl\rlhead\fi
421 \hfil\eightrm\folio}}
422 \def\rightheadline{\hbox to\pagewidth{\vbox to10pt{}%
423 \eightrm\folio\hfil\ninerm\title:\enspace \eightsl\rrhead\/}}
424
425 \def\mini{\begingroup \obeylines \globaldefs=1 \newrefs=\bgroup}
426 \def\FI{\@n=\secno \advance\@n-\baseno \advance\@n 200
427 \advance\nrefs-\count\@n \@n=\nrefs
428 \let\[=\countnewref \let\]=\cn \the\newrefs \endgroup
429 \nobreak\null\nobreak\vskip-\baselineskip\penalty-500\vfil\eject}
430 \def\twillout{\setbox\newsec=\vbox{\unvbox255}
431 \ifnum\@n=0 \nsize=0pt
432 \else \nsize=3pt \multiply\nsize\@n \advance\nsize 1.25pc \fi
433 \ifvoid\partialpage\else\advance\nsize 5pt \advance\nsize\ht\partialpage\fi
434 \advance\nsize\ht\newsec
435 \message{\the\nsize} % show the page break decision amount
436 \ifbr \global\brfalse \flushout \message{/\secno}\fi
437 \ifdim\nsize>\pagethresh \flushout \message{\secno}\fi
438 \addtopartialpage}
439 \def\addtopartialpage{\globaldefs=1
440 \let\[=\addnewref \let\]=\addneweref \the\newrefs
441 \setbox\partialpage=\ifvoid\partialpage \box\newsec
442 \else \vbox{\unvbox\partialpage \vfilneg
443 \vskip\intersecskip \unvbox\newsec}\fi}
444 \def\shortpage{\par\vskip-2\baselineskip
445 \null\vfill\penalty-5000\message{(shortpage)}}
446 \newif\ifbr
447 \def\forcebr{\global\brtrue}
448
449 \def\countnewref #1 {\ifnum#1<\baseno \let\next\cn
450 \else\ifnum#1>\secno \let\next\cn \else\let\next\flushref\fi\fi\next#1 }
451 \def\cn #1 #2 {\begintest{#1 #2}\cnr\endtest}
452
453 % here's a tricky way to present \cnr with a csname unexpanded inside:
454 \def\begintest#1{\def\TEST{#1}\expandafter\expandafter\expandafter}
455 \def\endtest{\csname\expandafter\gobb\meaning\TEST\endcsname}
456 \expandafter\def\expandafter\gobb\meaning\empty{}
457
458 {\obeylines\gdef\cnr#1#2
459 {\ifx#1\relax \advance\@n 1 \fi}}
460 {\obeylines\gdef\flushref#1
461 {}}
462 \def\addnewref #1 {\ifnum#1<\baseno \let\next\an \@n=199
463 \else\ifnum#1>\secno \let\next\an \@n=#1 \advance\@n-\baseno
464 \advance\@n200 \ifnum\@n>219 \@n=220 \fi
465 \else\let\next\flushref\fi\fi\next#1 }
466 \def\an#1 #2 {\begintest{#1 #2}\anr\endtest\[#1 #2 }
467 \def\addneweref#1 #2 {\@n=221 \begintest{#1 #2}\anr\endtest\]#1 #2 }
468 {\obeylines\gdef\anr#1#2
469 {\ifx#1\relax \advance\nrefs1 \advance\count\@n 1 %
470 \def#1{#2
471 }\toks\@n=\expandafter{\the\toks\@n\lmda#1}\fi}}
472 \ifsorted \def\lmda#1{\global\let#1\relax}
473 \else \def\lmda#1{#1\global\let#1\relax} \fi
474 {\obeylines\gdef\makeinref#1 #2 #3
475 {\ifsorted\else\ttoks={\[#1 #2 #3}\immediate\write\reffile{+ \the\ttoks}\fi %
476 \hangindent=1em \noindent #2\miniform#3, %<== space!
477 \S\ifacro{\pdfnote#1.}\else{#1}\fi.\par}}
478 {\obeylines\gdef\makeoutref#1 #2 #3
479 {\ifsorted\else\ttoks={\]#1 #2 #3}\immediate\write\reffile{+ \the\ttoks}\fi %
480 \hangindent=1em \noindent #2\miniform#3, \extref#1.\par}}
481 \def\miniform{\futurelet\next\miniforma}
482 \def\miniforma{\ifx\next\zip
483 \else\if=\noexpand\next \let\next\gobbleq
484 \else\let\next\colon\fi\fi\next}
485 \def\zip{}
486 \def\gobbleq={\,=\,}
487 \def\colon{: }
488 \def\extref{\futurelet\next\extrefa}
489 \def\extrefa{\if"\next\let\next\gobblest\else\let\next\cite\fi\next}
490 \def\gobblest"#1"{{\ttx#1}}
491 \def\cite#1#2.{{\sc#1}\,\S#2.}
492 \def\uninitialized{???}
493
494 \def\readrefs{\the\prefs \@m=\secno \advance\@m-\baseno \advance\@m200
495 {\def\lmda##1{\global\let##1\relax}\@p=200
496 \loop\ifnum\@p<\@m \the\toks\@p \advance\@p 1 \repeat}
497 \loop\ifnum\@m<222 \the\toks\@m \advance\@m 1 \repeat}
498 \def\readln{\read\sreffile to\next \expandafter\next\newline \readin}
499 {\obeylines\gdef\newline{\unskip\noexpand
500 }}
501 \def\donewithpage#1 {\let\readin=\relax}
502 \catcode`\@=12
503
504 \hsize=\pagewidth \vsize=\maxdimen \output={\twillout}
505
506 %\let\page=\pagebody \raggedbottom
507 \def\page{\box255 }\normalbottom % faster, but loses plain TeX footnotes
508 \def\normaloutput#1#2#3{\shipout\vbox{\vbox to\fullpageheight{%
509 \iftitle\global\titlefalse
510 \else\hbox to\pagewidth{\vbox to10pt{}%
511 \ifodd\pageno\vbox to3pc{#3\vfill}\else\vbox to3pc{#2\vfill}\fi}\fi
512 #1\vfill}} % parameter #1 is the page itself
513 \global\advance\pageno by1}
514 %\def\topofcontents{\centerline{\titlefont\title}\vskip.7in
515 %\vfill} % this material will start the table of contents page
516 %\def\botofcontents{\vfill
517 %\centerline{\covernote}} % this material will end the table of contents page
518 %\def\covernote{}
519 \def\contentspagenumber{0} % default page number for table of contents
520 %\newdimen\pageshift \pageshift=\hoffset
521 %% shift righthand pages wrt lefthand ones (changed in version 3.70)
522 \def\setpage{\hsize\pagewidth\vsize\pageheight} % use after changing page size
523 \def\contentsfile{\jobname.toc} % file that gets table of contents info
524 \def\readcontents{\input \contentsfile}
525 \def\readsections{\input \jobname.scn}
526
527 \newwrite\cont
528 \ifpdflua
529 \immediate\openout\cont=\contentsfile
530 \immediate\write\cont{\catcode `\noexpand\@=11\relax} % \makeatletter
531 \fi
532
533 \def\inx{\flushout % No full index at the end
534 \ifpdflua
535 \immediate\write\cont{\catcode `\noexpand\@=12\relax} % \makeatother
536 \immediate\closeout\cont % the contents information has been fully gathered
537 \fi}
538 \def\fin{\ifacro \message{Section names:} \let\Xpdf\X
539 \def\note##1##2.{\quad{\eightrm##1~{\sevenrm\pdfnote##2.}.}}
540 \def\Q{\note{Cited in section}} % crossref for mention of a section
541 \def\Qs{\note{Cited in sections}} % crossref for mentions of a section
542 \def\U{\note{Used in section}} % crossref for use of a section
543 \def\Us{\note{Used in sections}} % crossref for uses of a section
544 \def\I{\par\hangindent 2em\noindent}\let\*=*
545 \def\rlhead{NAMES OF THE SECTIONS} % running left headline
546 \let\rrhead=\rlhead % running right headline
547 \output={\normaloutput\page\rightheadline\leftheadline}
548 \setpage \startpdf
549 \def\outsecname{Names of the sections}
550 \ifpdflua \makebookmarks \countsections
551 \pdfdest name {NOS} fith
552 \pdfoutline goto name {NOS} count -\the\countNOS {\outsecname}
553 \else \special{pdf: outline -1 << /Title (\outsecname)
554 /Dest [ @thispage /FitH @ypos ] >>}\fi
555 \def\X##1:##2\X{\Xpdf##1:##2\X \firstsecno##1.%
556 {\makeoutlinetoks##2\outlinedone}%
557 \ifpdflua \pdfoutline goto num \the\toksA \expandafter{\the\toksE}
558 \else \special{pdf: outline 0 << /Title (\the\toksE)
559 /A << /S /GoTo /D (\romannumeral\the\toksA) >> >>}\fi}
560 \readsections \fi}
561 \def\makebookmarks{\let\ZZ=\writebookmarkline \readcontents\relax}
562 \def\countsections{\message{Number of named sections:}
563 {\def\I{\global\advance\countNOS by 1}\def\X##1\X{\relax}
564 \def\Q##1.{\relax}\def\Qs##1.{\relax}\def\U##1.{\relax}\def\Us##1.{\relax}
565 \readsections\relax}\message{\the\countNOS}}
566 \def\writebookmarkline#1#2#3#4#5{{%
567 \let\(=\let \let\)=\let \let\[=\let \let\]=\let \let\/=\let
568 \pdfoutline goto num #3 count -\expnumber{chunk#2.#3} {#5}}}
569 \let\con=\end % no table of contents
570 %\def\con{\par\vfill\eject % finish the section names
571 % \ifodd\pageno\else\titletrue\null\vfill\eject\fi % for duplex printers
572 %\rightskip 0pt \hyphenpenalty 50 \tolerance 200
573 %\setpage \output={\normaloutput\page\lheader\rheader}
574 %\ifpdf\startpdf\fi \titletrue % prepare to output the table of contents
575 %\pageno=\contentspagenumber
576 %\def\grouptitle{TABLE OF CONTENTS}
577 %\message{Table of contents:}
578 %\topofcontents
579 %\line{\hfil Section\hbox to3em{\hss Page}}
580 %\let\ZZ=\contentsline
581 %\readcontents\relax % read the contents info
582 %\botofcontents \end} % print the contents page(s) and terminate
583 %\def\contentsline#1#2#3#4#5{\ifnum#2=0 \smallbreak\fi
584 %\line{\consetup{#2}#1
585 %\rm\leaders\hbox to .5em{.\hfil}\hfil
586 %\ \ifacro\pdflink{#3}\else#3\fi\hbox to3em{\hss#4}}}
587 %\def\consetup#1{\ifcase#1 \bf % depth -1 (@**)
588 %\or % depth 0 (@*)
589 %\or \hskip2em % depth 1 (@*1)
590 %\or \hskip4em \or \hskip6em \or \hskip8em \or \hskip10em % depth 2,3,4,5
591 %\else \hskip12em \fi} % depth 6 or more
592 \def\today{\ifcase\month\or
593 January\or February\or March\or April\or May\or June\or
594 July\or August\or September\or October\or November\or December\fi
595 \space\number\day, \number\year}
596 \newcount\twodigits
597 \def\hours{\twodigits=\time \divide\twodigits by 60 \printtwodigits
598 \multiply\twodigits by-60 \advance\twodigits by\time :\printtwodigits}
599 \def\gobbleone1{}
600 \def\printtwodigits{\advance\twodigits100
601 \expandafter\gobbleone\number\twodigits
602 \advance\twodigits-100 }
603 \def\datethis{\def\startsection{\leftline{\sc\today\ at \hours}\bigskip
604 \let\startsection=\stsec\stsec}}
605 % say `\datethis' in limbo, to get your listing timestamped before section 1
606 \def\datecontentspage{}
607
608 % To produce only a subset of pages, put the page numbers on separate
609 % lines in a file called pages.tex
610 \let\Shipout=\shipout
611 \newread\pages \newcount\nextpage \openin\pages=pages
612 \def\getnextpage{\ifeof\pages\else
613 {\endlinechar=-1\read\pages to\next
614 \ifx\next\empty % in this case we should have eof now
615 \else\global\nextpage=\next\fi}\fi}
616 \ifeof\pages\else\message{OK, I'll ship only the requested pages!}
617 \getnextpage\fi
618 \def\shipout{\ifeof\pages\let\next=\Shipout
619 \else\ifnum\pageno=\nextpage\getnextpage\let\next=\Shipout
620 \else\let\next=\Tosspage\fi\fi \next}
621 \newbox\garbage \def\Tosspage{\deadcycles=0\setbox\garbage=}