Debian Codegraph @

texmf-dist/doc/hitex/base/hintmac.tex

raw
1 % Copyright 2017-2022 Martin Ruckert, Hochschule Muenchen, Lothstrasse 64, 80336 Muenchen
2 %
3 % Permission is hereby granted, free of charge, to any person obtaining a copy
4 % of this software and associated documentation files (the "Software"), to deal
5 % in the Software without restriction, including without limitation the rights
6 % to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 % copies of the Software, and to permit persons to whom the Software is
8 % furnished to do so, subject to the following conditions:
9 %
10 % The above copyright notice and this permission notice shall be
11 % included in all copies or substantial portions of the Software.
12 %
13 % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 % IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 % FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 % COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17 % WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
18 % OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 % THE SOFTWARE.
20 %
21 % Except as contained in this notice, the name of the copyright holders shall
22 % not be used in advertising or otherwise to promote the sale, use or other
23 % dealings in this Software without prior written authorization from the
24 % copyright holders.
25
26 \input idxmac.tex
27 \let\displayverbatimfont=\tt
28
29 % V E R B A T I M . T E X
30 %
31 % THIS SET OF MACROs IS TAKEN FROM D.E.K.'s TeXBook
32 % AND PROVIDES AN EASY WAY OF TYPESETTING TEXTS VERBATIM:
33 %
34 % 1. \verbatim<character><text without that character><character>
35 % causes the text to be set verbatim using \tt font;
36 % 2. if the text uses up all the alphabet, \doubleverbatim macro
37 % can be used instead; this is similar to the previous one but
38 % a pair of characters is now used as a delimiter;
39 % 3. in case of emergency \tripleverbatim macro may be of help...
40 %
41 %---------------------------------------------
42 \def\uncatcodespecials % see D.E.K., pp. 344 and 380
43 {\def\do##1{\catcode`##1=12}\dospecials}%
44 %---------------------------------------------
45 {\catcode`\^^I=\active \gdef^^I{\ \ \ \ }% TAB character is replaced by
46 % 4 spaces; it is better than
47 % nothing, but it does not mimic
48 % true tabbing satisfactorily---maybe
49 % some nice day...
50 \catcode`\`=\active\gdef`{\relax\lq}}% this line inhibits Spanish
51 % ligatures ?` and !` of \tt font
52 \def\setupverbatim % see D.E.K., p. 381
53 {\tt %
54 \spaceskip=0pt \xspaceskip=0pt % just in case...
55 \catcode`\^^I=\active %
56 \catcode`\`=\active %
57 \def\par{\leavevmode\endgraf}% this causes that empty lines aren't
58 % skipped
59 \obeylines \uncatcodespecials \obeyspaces}%
60 {\obeyspaces \global\let =\ }% this causes that leading blanks aren't
61 % skipped; cf. also def's of \space, \endgraf,
62 % \lq, \obeyspaces, and \obeylines,
63 % D.E.K., pp. 351--352
64 %---------------------------------------------
65 % see D.E.K., p. 382
66 \def\doverbatim#1{\def\next##1#1{##1\endgroup}\next}%
67 \def\verbatim{\begingroup\setupverbatim\doverbatim}%
68 %----------
69 \def\dodoubleverbatim#1#2{\def\next##1#1#2{##1\endgroup}\next}%
70 \def\doubleverbatim{\begingroup\setupverbatim\dodoubleverbatim}%
71 %----------
72 \def\dotripleverbatim#1#2#3{\def\next##1#1#2#3{##1\endgroup}\next}%
73 \def\tripleverbatim{\begingroup\setupverbatim\dotripleverbatim}%
74 %---------------------------------------------
75
76
77
78 %%
79 %% special treatment for @
80 %%
81
82 \def\makeatletter{\catcode`\@=11\relax}
83 \def\makeatother{\catcode`\@=12\relax}
84 \makeatletter
85
86 %%
87 %% Conditionals
88 %%
89
90 \newif\ifhint
91 \newif\ifbook
92 \newif\ifpdf
93
94 % HINT
95 \expandafter\ifx\csname HINTversion\endcsname\relax
96 \hintfalse
97 \else
98 \hinttrue
99 \fi
100
101 % PDF
102 \expandafter\ifx\csname pdfliteral\endcsname\relax
103 \pdffalse
104 \else
105 \pdftrue
106 \fi
107
108 % Book
109 \expandafter\ifx\csname book\endcsname\relax
110 \ifhint\bookfalse
111 \else\ifpdf\bookfalse % This might change
112 \else\bookfalse
113 \fi\fi
114 \else
115 \booktrue
116 \hintfalse
117 \pdffalse
118 \fi
119
120 \message{Book: \ifbook true \else false \fi}
121 \message{PDF: \ifpdf true \else false \fi}
122 \message{HINT: \ifhint true \else false \fi}
123
124 %%
125 %% Additional fonts
126 %%
127 \font\largetitlefont=cmssbx10 scaled\magstep4
128 \font\Largetitlefont=cmssbx10 at 40pt
129 \font\hugetitlefont=cmssbx10 at 48pt
130 \font\smalltitlefontit=cmbxti10 scaled\magstep3
131 \font\smalltitlefont=cmssbx10 scaled\magstep3
132
133 \font\tenss=cmss10 % used for the HINT name
134 \font\tenssbx=cmssbx10 % used for the bold HINT name
135 \font\largess=cmss12 scaled\magstep1 % used for large HINT name
136 \font\largessbx=cmssbx10 scaled\magstep2 % used for large bold HINT name
137 \font\manual=manfnt % font used for the METAFONT logo, etc.
138 \let\sf\tenss
139 \def\bf{\let\sf\tenssbx\fam\bffam\tenbf}
140
141
142 %% Large Font for sections
143 %\font\largebf=cmb14 scaled\magstep0
144 %\font\largebf=cmb12 scaled\magstep1
145 \font\largebf=cmbx12 scaled\magstep1
146 %\font\largebf=cmbx8 scaled\magstep3
147 %\font\largeit=cmti14 scaled\magstep0
148 \font\largeit=cmti12 scaled\magstep1
149 %\font\largett=cmtt14 scaled\magstep0
150 \font\largett=cmtt12 scaled\magstep1
151 %\font\largerm=cmr14 scaled\magstep0
152 \font\largerm=cmr12 scaled\magstep1
153 % for mathbolditalic
154 %\font\tenmib=cmmib10 scaled\magstep0
155 \font\tenmib=cmmib10 scaled\magstep0
156 \font\largemib=cmmib10 scaled\magstep1
157
158 %% Small Fonts for Figure and Table descriptions
159 \font\figbf=cmbx9 scaled\magstep0
160 \font\figit=cmti9 scaled\magstep0
161 \font\figmit=cmmi9 scaled\magstep0
162 \font\figsy=cmsy9 scaled\magstep0
163 \font\figtt=cmtt9 scaled\magstep0
164 \font\figrm=cmr9 scaled\magstep0
165 % for mathbolditalic
166 \font\figmib=cmmib9 scaled\magstep0
167
168 \def\largebold{\let\bf\largebf\let\sf\largessbx\bf}
169
170 \def\large{\def\rm{\fam0\largerm}\let\bf\largebold\let\it\largeit\let\tt\largett\let\mib\largemib\let\sf\largess%
171 \textfont0=\largerm\textfont1=\largeit
172 \setbox\strutbox=\hbox{\vrule height9.5pt depth5.0pt width\z@}\rm}
173
174 \def\small{\def\rm{\fam0\figrm}\let\bf\figbf\let\it\figit\let\tt\figtt\let\mib\figmib%
175 \textfont0=\figrm\textfont1=\figmit\textfont2=\figsy%
176 \setbox\strutbox=\hbox{\vrule height9.0pt depth4.5pt width\z@}\rm}
177
178 \let\tiny\eightrm
179 \let\mib\tenmib
180
181
182 %%
183 %% Logos
184 %%
185
186 %\def\Pascal/{{\mc P\kern-.05emascal\spacefactor1000}}
187 \def\CEE{{\mc C\spacefactor1000}}
188 \def\Pascal{\leavevmode\hbox{\mc P\kern-.05emascal}}
189 \def\PDF{\leavevmode\hbox{\mc PDF}}
190 \def\WEB{\leavevmode\hbox{\tt WEB\spacefactor1000}}
191 \def\GNU{\leavevmode\hbox{\mc GNU}}
192 \def\Prote{{\tenrm P\kern-0.1em R\kern-0.15em\raise.11ex\hbox{o}%
193 \kern-0.22em T\kern-0.05em E}}
194 \def\eTeX{$\varepsilon$-\TeX}
195 \def\XeTeX{X\kern-.125em\lower.5ex\hbox{E}\kern-.1667em\TeX}
196 \def\LuaTeX{Lua\TeX}
197 \def\HiTeX{Hi\TeX}
198 \def\HINT{\leavevmode\hbox{\sf HINT\spacefactor1000}}
199 \def\cweb{\leavevmode\hbox{\tt cweb}}
200 \def\web2w{\leavevmode\hbox{\tt web2w}}
201 \def\LaTeX{L\kern-.36em\raise.3ex\hbox{\sc A}\kern-.15em\TeX}%
202 \def\MF{{\manual META}\-{\manual FONT}}%
203 \def\TL{\TeX~Live}
204 \def\kpse{\leavevmode\hbox{\tt kpathsearch\spacefactor1000}}
205 \def\TUB{{\sl TUGboat\/}}
206 \def\TUG{\TeX\ \UG}
207 \def\tug{{\mc TUG}}
208 \def\UG{Users Group}
209 \def\UTF{{\mc UTF}}
210 \ifpdf
211 \sanitizecommand{\TeX}{TeX}
212 \sanitizecommand{\eTeX}{eTeX}
213 \sanitizecommand{\Prote}{PRoTE}
214 \fi
215 %%
216 %% Special controlsequences
217 %%
218
219 \def\abs#1{\left|#1\right|}
220 \def\<#1>{$\langle\,$#1$\,\rangle$}
221 \def\registered{{\ooalign{\hfil\raise.07ex\hbox{\sevenrm R}\hfil\crcr\Orb}}}
222 \def\hair{\kern.05em\relax} % teeny tiny space
223 \def\center#1{\bigskip\line{\hfil#1\hfil}\bigbreak}
224 \chardef\VB=`\| % vertical bar character in a string
225 \def\^{\ifmmode\mathchar"222 \else\char`^ \fi}%from webmac.tex: pointer or hat
226 \ifhint
227 \def\_{{\tt\UL}} % make underline an ordinary character for better searching
228 \fi
229 \def\ATH{{\<Preprocessor definitions>}} % redefine @h from cwebmac.tex
230
231
232 % Bibtex needs this
233 \def\mbox#1{\leavevmode\hbox{#1}}
234
235 % URLs
236 {\gdef\urldot{.}\catcode`.=13
237 \gdef\urlslash{/}\catcode`/=13
238 \gdef\urlspecials{\def.{\urldot\penalty 0}\def/{\urlslash\penalty 0}}
239 }
240 \def\url{\bgroup\hskip 1cm plus 5cm\penalty -100\hskip -1cm plus -5cm\tt
241 \catcode`_=12\catcode`\~=12\catcode`.=13\catcode`/=13\urlspecials}
242 \def\endurl{\egroup}
243
244
245 % for the index
246 \def\see#1#2{\hskip 0pt plus 100pt\penalty 0\hskip 0 pt plus -100pt{\it see\/} #1}
247
248 % typewriter type for strings
249 \def\.#1{{\tentex\spaceskip=0.333em minus 0.1em\relax
250 \let\\=\BS% backslash in a string
251 \let\{=\LB% left brace in a string
252 \let\}=\RB% right brace in a string
253 \let\~=\TL% tilde in a string
254 \let\ =\SP% space in a string
255 \let\_=\UL% underline in a string
256 \let\&=\AM% ampersand in a string
257 \let\^=\CF% circumflex in a string
258 \let\|=\VB% vertical bar in a string
259 \ifmmode\hbox{#1\kern.05em}\else #1\kern.05em\fi}}
260
261 %{\rm\gdef\strutdepth{\dp\strutbox}}
262
263 \def\raggedleft{\leftskip=0pt plus 5em\parfillskip=0pt
264 \spaceskip=.3333em \xspaceskip=0.5em \emergencystretch=2em\relax
265 \hyphenpenalty=1000\exhyphenpenalty=1000\pretolerance=10000\linepenalty=5000
266 }
267 \def\raggedright{\rightskip=0pt plus 5em\parindent=0pt
268 \spaceskip=.3333em \xspaceskip=0.5em \emergencystretch=2em\relax
269 \hyphenpenalty=1000\exhyphenpenalty=1000\pretolerance=10000\linepenalty=5000
270 }
271
272 %%
273 %% Environments
274 %%
275
276 % Quotations (form the standard)
277 \def\beginquote{\bgroup\narrower\noindent\sl}
278 \def\endquote{\egroup}
279
280 % Enumerate
281 \newcount\enum
282 %other styles use \medskip instead of \par
283 \def\enumerate{\par\bgroup\advance\leftskip by\parindent\enum=0%
284 \def\item{\advance\enum by 1\par\enumdest\smallskip\noindent\hbox to 0pt{\hss\the\enum.~}\ignorespaces}}
285 \def\endenumerate{\medskip\egroup\noindent}
286
287 %Itemize
288 \def\itemize{\par\bgroup\advance\leftskip by\parindent\relax%
289 \def\item{\par\smallskip\noindent\llap{$\bullet$\enspace}\ignorespaces}}
290 \def\enditemize{\medskip\egroup\noindent}
291
292 %Float
293 \long\def\float#1{\midinsert\parindent 0pt\relax#1\endinsert}
294 %\def\float#1{\midinsert
295 %\hsize\pagewidth
296 %\parindent 0pt\vbox{\hbox{\kern-\marginwidth\vbox{#1}}}\endinsert}
297
298 %%
299 %% Redefining cwebmac.tex macros
300 %%
301
302 %defining how to output terminals and nonterminals
303 \def\ts#1{\ifmmode\hbox{\sc #1}\else{\sc #1}\fi}% terminal symbol
304 \def\nts#1{{\sl #1\/}}% nonterminal symbol
305 % redefining the box around verbatim code
306 \def\vb#1{\hbox{\strut\.{#1}}}
307 % regular expressions and actions
308 \newbox\rebox
309 \def\re#1{\leavevmode\setbox\rebox\hbox{#1\hfill}\ifdim\wd\rebox<7em\wd\rebox=7em\fi\box\rebox\quad}
310 \def\ac{\global\ind=10\hangindent=\ind em\relax}
311 \def\eac{\global\ind=3\hangindent=\ind em\relax}
312 % yskip is usually a smallskip = 3pt pus 1pt minus 1pt
313 % I give it some extra stretchability
314 %\def\yskip{\vskip 3pt plus 3pt minus 1pt}
315 \let\yskip\smallbreak
316
317 % redefine \5 for an optional break without the 2.5em reduced indentation
318 %\def\5{\hskip 0pt plus 2.5em\penalty-1\hskip 0pt plus -2.5em\kern0.5em\ignorespaces}% optional break
319 %redefine \5 to give some shrinkability
320 % from hitex and hint style:
321 %\def\5{\hfil\penalty-1\hskip 0pt minus 6pt\hfilneg\kern2.5em\copy\bakk\ignorespaces}% optional break
322 \def\5{\hfil\penalty10\hfilneg\hskip 0pt minus 6pt\kern2.5em\copy\bakk\ignorespaces}% optional break
323 \def\J{}% dont show @& in the tex output
324 \def\Y{\par\yskip}
325
326 % start sections
327 \def\stsec{\rightskip=0pt % get out of C mode (cf. \B)
328 \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50 %
329 }
330
331 % the box for the points to operator "->" in C
332 \setbox\MGbox=\hbox{$\rightarrow$}
333
334 % how to display NULL
335 \def\NULL{\tt NULL}
336
337 %other styles make this a \par
338 \def\note#1#2.{}
339 %\Y\noindent{\hfill%
340 % \baselineskip10pt\tiny#1~\ifacro{\pdfnote#2.}\else#2\fi.\par}}
341
342 %other styles make this minus 10pt
343 \def\B{\rightskip=0pt plus 100pt minus 0pt % go into C mode
344 \sfcode`;=3000
345 \pretolerance 10000
346 \hyphenpenalty 1000 % so strings can be broken (discretionary \ is inserted)
347 \exhyphenpenalty 1000
348 \codedest
349 \global\ind=2 \1\ \unskip
350 \vadjust{\vtop to 0pt{\vss\hbox to \hsize{\hfill\tiny(\secstar)}\kern 0pt}}}
351
352 % formating of C comments
353 \def\C#1{\5\hfill$/\ast\,${\cmntfont #1}$\,\ast/$}
354
355 % section begin
356 \def\M#1{\MN{#1}\ifon\stsec\smallskip
357 %\everypar{{\setbox0=\lastbox}\everypar{}}% no indentation in the next paragraph
358 \noindent\ignorespaces}% beginning of section
359
360 % stared section begin: depth number title
361 \def\N#1#2#3.{\MN{#2}\ifon\stsec\smallskip
362 %\everypar{{\setbox0=\lastbox}\everypar{}}% no indentation in the next paragraph
363 \noindent{\bf#3\quad}\ignorespaces}% beginning of section
364
365 \newcount\codeno
366 \codeno=0
367 \def\MN#1{\smallskip
368 {\xdef\secstar{#1}\let\*=\empty\xdef\secno{#1}}%
369 \global\codeno=#1\relax
370 \ontrue}
371
372 % Used in section text
373 \def\U{\rightnote{Used in}} % xref for use of a section
374 \def\Us{\rightnote{Used in}} % xref for uses of a section
375 % replacing \note in \U and \Us by \rightnote
376 %\def\rightnote#1#2.{\vskip-\baselineskip\vtop to 0pt{\vss\hbox to \hsize{\hfill
377 % \tiny#1~\ifacro{\pdfnote#2.}\else#2\fi.}\kern 0pt}}
378 %\def\rightnote#1#2.{\vskip-\baselineskip\hbox to \hsize{\hfill
379 % \tiny#1~\ifacro{\pdfnote#2.}\else#2\fi.}}
380 %\def\rightnote#1#2.{\penalty1000\discretionary{}{\hbox{}}{\kern 2em}\penalty1000\hfill
381 % \hbox{\tiny#1~\ifacro{\pdfnote#2.}\else#2\fi.}}
382 \def\rightnote#1#2.{%
383 \penalty1000\discretionary{}{\hbox{}}{\kern 4em}\penalty1000\hfill
384 \hskip -4em plus 4em\hbox{\tiny #1~\codenote#2.}.}
385
386 \def\X#1:#2\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi %$% section name
387 \XX$\langle\,${\let\I=\ne#2\kern.5em\coderef{#1}$\,\rangle$\XX}}
388
389
390 % how to display hex numbers
391 \def\hex{\hbox{$^{\scriptstyle\#}$\tt\aftergroup}} % CWEB style
392
393 \def\(#1){} % this is used to make section names sort themselves better
394
395
396 %%
397 %% Dimensions to achive the desired layout
398 %%
399
400
401 % the other variables are defined in cwebmac.tex
402 \newdimen\headheight
403 \newdimen\footheight
404 \newdimen\leftmargin
405 \newdimen\rightmargin
406 \newdimen\topmargin
407 \newdimen\bottommargin
408 \newdimen\marginwidth
409
410 \parskip 0pt plus .8pt
411
412 \leftmargin=22mm
413 \rightmargin=22mm
414 \topmargin=15mm
415 \bottommargin=27mm
416 \marginwidth=0pt % we do not have notes in the margin
417
418 \headheight=12pt % Text in Head
419 \advance\headheight+13pt % Abstand 1pt, Linie 0.47pt und Abstand zum Text 11.53pt
420 \footheight=0pt % Text in Footer
421
422 \pagewidth=6.69in
423 \advance\pagewidth-\leftmargin % left margin/offset
424 \advance\pagewidth-\rightmargin % left margin/offset
425
426 % 6.69in = 169.926
427 % - 2*22mm = 125.926mm
428 %
429 % 9.61in = 244.094
430 % - 15mm -27 mm = 202.094
431 % (12+13)pt = 8.786 mm
432 % -8.786 = 193.308 mm
433
434 \fullpageheight=9.61in
435 \advance\fullpageheight-\topmargin% topmargin
436 \advance\fullpageheight-\bottommargin% bottommargin
437
438 \pageheight=\fullpageheight
439 \advance\pageheight-\headheight
440 \advance\pageheight-\footheight
441
442 \def\setpage{\hsize\pagewidth\advance\hsize-\marginwidth\vsize\pageheight} % use after changing page size
443
444 \setpage
445
446 % setting the papersize for postscript and pdf
447
448 \ifbook
449 %\overfullrule=0pt
450 \pdfpageheight=9.61in
451 \pdfpagewidth=6.69in
452 \pdfhorigin=\leftmargin
453 \pdfvorigin=\topmargin
454 \pdfcompresslevel=9
455 \pdfdecimaldigits=4
456 \pdfpkresolution=1200
457 \pdfimageresolution=1200
458 \else\ifpdf
459 \pdfpageheight=9.61in
460 \pdfpagewidth=6.69in
461 \pdfhorigin=\leftmargin
462 \pdfvorigin=\topmargin
463 \pdfcompresslevel=9
464 \pdfdecimaldigits=4
465 \pdfpkresolution=1200
466 \pdfimageresolution=1200
467 \else
468 \special{papersize=6.69in,9.61in}% postscript und ps2pdf
469 \fi\fi
470
471
472
473 %%
474 %% Page layout
475 %%
476
477 \long\def\leftmark#1#2{#1}
478 \long\def\subsectionmark#1#2{#2}
479 \long\def\rightmark#1#2{\if0#1\else\expandafter\subsectionmark\botmark\fi}
480
481 \def\lheader{\mainfont\strut
482 \thepageno\hfill\expandafter\leftmark\firstmark} % top line on left-hand pages
483
484 \def\rheader{\mainfont\strut
485 \expandafter\rightmark\firstmark\hfill\thepageno} % top line on right-hand pages
486
487 \let\page=\pagebody
488 %\raggedbottom
489 \normalbottom
490 %\def\page{\box255 }\normalbottom % faster, but loses plain TeX footnotes
491 \def\normaloutput#1#2#3{\ifodd\pageno\hoffset=\pageshift\fi
492 \shipout\vbox{
493 \vbox to\fullpageheight{\pagelabel
494 \iftitle\global\titlefalse
495 \else\hbox{\vbox to \headheight{
496 \hbox to \pagewidth{\ifodd\pageno #3\else#2\fi}
497 \vskip 1pt\relax
498 \nointerlineskip
499 \hrule height .47pt
500 % \hbox{\hrule}%fill\psfig{file=image/topline.eps}\hfil}%
501 \vfil}}%
502 \fi
503 \nointerlineskip
504 \hbox{\kern\marginwidth\vbox to \pageheight{#1}}}} % parameter #1 is the page itself
505 \global\advance\pageno by1}
506
507 \def\nomarginoutput#1#2#3{%
508 \ifodd\pageno\hoffset=\pageshift\fi
509 \shipout\vbox to\fullpageheight{\pagelabel\nointerlineskip
510 \iftitle\global\titlefalse
511 \hbox{\vbox to \headheight{\vfil}}
512 \else
513 \hbox{\vbox to \headheight{\nointerlineskip
514 \hbox to \pagewidth{\ifodd\pageno#3\else#2\fi}%
515 \vskip 1 pt
516 \nointerlineskip
517 \hrule height .47pt
518 % \hbox{\psfig{silent=,bbllx=0pt,bblly=0pt,bburx=368pt,bbury=2pt,file=image/topline.eps}\hfil}%
519 \vfil}}%
520 \fi\nointerlineskip #1 % parameter #1 is the page itself
521 % \vss
522 % \hbox to \pagewidth{\ifodd\pageno\else#2\fi}%
523 % \nointerlineskip
524 % \hbox{\psfig{file=image/topline.eps}\hfil}%
525 }%
526 \global\advance\pageno by1}
527
528 %% switch to global nomargin
529 \let\normaloutput\nomarginoutput
530 \def\sectionbox#1{\hbox{#1}}
531 \marginwidth=0mm
532 \setpage
533
534
535 %%
536 %% Frontmatter and mainmatter
537 %%
538 \pageno=1
539 \def\thepageno{\romannumeral\pageno}
540 \def\frontmatter{\pageno=4\def\thepageno{\romannumeral\pageno}}
541 \def\mainmatter{
542 \mark{{\sectionname}{\subsectionname}}
543 %\message{Mark {\sectionname}{\subsectionname}}
544 \vfil\break\ifodd\pageno\pageno=1\else\pageno=0\fi
545 \def\thepageno{\the\pageno}%
546 \sectioncount=0
547 \mark{{0}{0}}%
548 %\hbox{Mark empty empty}%
549 \gdef\sectionname{}
550 \gdef\subsectionname{}
551 \gdef\codetitle{}
552 \gdef\subcodetitle{}
553 }
554
555
556
557
558 %%
559 %% Sections
560 %%
561
562 \newcount\sectioncount
563 \sectioncount=0
564 \newcount\subsectioncount
565 \subsectioncount=0
566 \newcount\subsubsectioncount
567 \subsubsectioncount=0
568
569 \newskip\abovesecskip
570 \newskip\belowsecskip
571 \newskip\abovesubsecskip
572 \newskip\belowsubsecskip
573
574 %\abovesecskip= 6ex plus 1ex minus .2ex %space above the section
575 %\belowsecskip=3.7ex plus .2ex% space after section
576 \abovesecskip= 0.15\vsize plus 5ex minus 1ex %space above the section
577 \belowsecskip=10pt plus 2pt% space after section
578 \abovesubsecskip=9pt plus 4pt minus 2pt%space above the section
579 \belowsubsecskip=3pt plus 1pt minus 0.5pt% space after section
580
581
582 \newif\ifappendix
583 \appendixfalse
584
585 \mark{{0}{0}}\vskip 0pt minus 100pt
586 %\hbox{Mark empty empty}%
587 \def\thesection{\the\sectioncount}
588 \def\topsection{\the\sectioncount}
589
590 %\def\sectionbox#1{\hskip-\marginwidth\hbox to \marginwidth{#1\hfil}}
591
592 \def\heading#1#2{%
593 \def\secno{{\noindent\large\bf\strut{#1}#2}}%
594 \par\ifhmode\unskip\fi% end paragraph and remove vertical space
595 \penalty-500
596 \vskip 0pt plus 72pt%allow some empty space at the bottom
597 \penalty-500
598 \vskip 0pt plus -72pt% room for stetching and a page break
599 \hbox{}\vskip\abovesecskip% space above the section
600 %%\titletrue % omits page header for section
601 %\hbox{Mark null null}%
602 \mark{{0}{0}}%
603 \secno% The section title
604 \mark{{\sectionname}{\sectionname}}%
605 %\message{Mark heading {\sectionname}{\subsectionname}}
606 \nobreak\vskip\belowsecskip% space after section
607 \everypar{{\setbox0=\lastbox}\everypar{}}% no indentation in the next paragraph
608 \ignorespaces}
609
610
611
612 \newcount\plaincount
613 \def\plainsection#1{%
614 \mark{{\sectionname}{\subsectionname}}%
615 %\message{Mark plain {\sectionname}{\subsectionname}}
616 \subsubsectioncount=0\subsectioncount=0%
617 \advance\plaincount by 1\relax
618 \def\thesection{}
619 \sectionpage%
620 \gdef\sectionname{#1}%
621 \gdef\subsectionname{#1}%
622 \gdef\codetitle{#1}%
623 \gdef\subcodetitle{#1}%
624 \tocsection{0}{}{#1}
625 \heading{}{#1}%
626 }
627
628 \def\part#1{%
629 \vfill\eject
630 \tocsection{-1}{}{#1}
631 \strut
632 \vskip -\topskip
633 \vskip 0pt plus 1fill
634 \vskip -60pt
635 {\noindent\baselineskip=60pt\Largetitlefont\raggedleft #1\par}
636 \vskip 0pt plus 1fill
637 \everypar{{\setbox0=\lastbox}\everypar{}}% no indentation in the next paragraph
638 \ignorespaces
639 }
640
641
642
643
644
645 \gdef\sectionname{}
646 \gdef\subsectionname{}
647 \gdef\codetitle{}%
648 \gdef\subcodetitle{}
649
650 \def\sectionpage{%
651 \vfil\break
652 \ifodd\pageno\else
653 \hbox{}%
654 \titletrue
655 \fi
656 \vfil\break
657 }
658
659
660 \def\section#1{%
661 \mark{{\sectionname}{\subsectionname}}%
662 %\message{Mark section {\sectionname}{\subsectionname}}
663 \subsubsectioncount=0\subsectioncount=0%
664 \advance\sectioncount by 1%updating counts
665 \let\thesection\topsection
666 \sectionpage%
667 \gdef\sectionname{\topsection\quad#1}%
668 \gdef\subsectionname{\thesection\quad#1}%
669 \gdef\codetitle{#1}%
670 \gdef\subcodetitle{#1}%
671 \ifnum\sectioncount=1\ifappendix\tocsection{0}{}{Appendix}\heading{}{Appendix}\fi\fi
672 \tocsection{0}{\thesection}{#1}%
673 \heading{\thesection~}{#1}%
674 }
675
676
677 \def\subsection#1{%
678 \subsubsectioncount=0\advance\subsectioncount by 1%updating counts
679 \def\thesection{\topsection.\the\subsectioncount}
680 \def\secno{{\noindent\bf\strut\sectionbox{\thesection~}#1}}%
681 \par\ifhmode\unskip\fi% end paragraph and remove vertical space
682 \tocsection{1}{\thesection}{#1}%
683 \penalty-200
684 \vskip 0pt plus 36pt% allow some empty space at the bottom
685 \penalty-200
686 \vskip 0pt plus -36pt% room for stetching and a page break
687 \gdef\subsectionname{\thesection\quad#1}%
688 \mark{{\sectionname}{\subsectionname}}%
689 %\message{Mark subsection {\sectionname}{\subsectionname}}
690 \vskip\abovesubsecskip% space above the subsection
691 \secno% The subsection title
692 \gdef\subcodetitle{#1}%
693 %\mark{{\sectionname}{\subsectionname}}%
694 %\hbox{Mark {\sectionname}{\subsectionname}}%
695 \nobreak\vskip\belowsubsecskip% space after subsection
696 \everypar{{\setbox0=\lastbox}\everypar{}}% no indentation in the next paragraph
697 \ignorespaces}
698
699
700 \def\subsubsection#1{%
701 %\mark{{\sectionname}{\subsectionname}}%
702 %\hbox{Mark {\sectionname}{\subsectionname}}%
703 \advance\subsubsectioncount by 1%updating counts
704 \def\thesection{\topsection.\the\subsectioncount.\the\subsubsectioncount}
705 \def\secno{{\noindent\it\strut\sectionbox{\thesection~}#1}}%
706 \par\ifhmode\unskip\fi% end paragraph and remove vertical space
707 \tocsection{2}{\thesection}{#1}%
708 \penalty-200
709 \vskip 0pt plus 36pt% allow some empty space at the bottom
710 \penalty-200
711 \vskip 0pt plus -36pt% room for stetching and a page break
712 \vskip\abovesubsecskip% space above the subsection
713 \secno% The subsubsection title
714 \nobreak\vskip\belowsubsecskip% space after subsection
715 \everypar{{\setbox0=\lastbox}\everypar{}}% no indentation in the next paragraph
716 \ignorespaces}
717
718 %%
719 %% Appendix
720 %%
721
722 \def\Alphanum#1{%
723 \ifcase#1\or A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or
724 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
725 Y\or Z\else\number#1\fi}
726
727 \def\appendix{%
728 \mark{{\sectionname}{\subsectionname}}%
729 %\message{Mark appendix {\sectionname}{\subsectionname}}
730 \sectioncount=0
731 \subsectioncount=0
732 \gdef\thesection{\Alphanum\sectioncount}%
733 \gdef\topsection{\Alphanum\sectioncount}%
734 \appendixtrue
735 }
736
737 %%
738 %% Crossreference of Identifiers and Sections
739 %%
740 \iftrue %% No Crossreference of identifiers
741 \def\inx{\def\lr{L}} % this tells whether the left or right column is next
742 \def\con{\end} % this tells whether the left or right column is next
743 \else
744 \def\inx{%
745 \hsize=\pagewidth
746 \def\page{\box255 } \normalbottom
747 \output{\ifpagesaved\normaloutput{\box\sbox}\lheader\rheader\fi
748 \global\setbox\sbox=\page \global\pagesavedtrue}
749 \pagesavedfalse
750 \plainsection{Crossreference of Identifiers}% we are beginning the index
751 \mark{{0}{0}}%
752 %\hbox{Mark empty empty}%
753 \eject % eject the page-so-far and predecessors
754 \setbox\sbox\vbox{\unvbox\sbox} % take it out of its box
755 \vsize=\pageheight \advance\vsize by -\ht\sbox % the remaining height
756 \hsize=.5\pagewidth \advance\hsize by -10pt
757 % column width for the index (20pt between cols)
758 \parfillskip 0pt plus .6\hsize % try to avoid almost empty lines
759 \def\lr{L} % this tells whether the left or right column is next
760 \output{\if L\lr\global\setbox\lbox=\page \gdef\lr{R}
761 \else\nomarginoutput{\vbox to\pageheight{\box\sbox\vss
762 \hbox to\pagewidth{\box\lbox\hfil\page}}}\lheader\rheader
763 \global\vsize\pageheight\gdef\lr{L}\global\pagesavedfalse
764 \mark{{Crossreference of Identifiers}{Crossreference of Identifiers}}%
765 \fi}
766 \parfillskip 0pt plus 1fil
767 \let\topsecno=\nullsec
768 \message{Crossreference of Identifiers:}
769 \parskip 0pt plus .5pt
770 \outer\def\I##1, ##2.{\par\hangindent2em\noindent##1:\kern1em
771 \ifbook##2\else\ifpdf\pdfnote##2.\else##2\fi\fi.} % index entry
772 \def\[##1]{$\underline{##1}$} % underlined index item
773 \rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar
774 \hyphenpenalty 10000 \parindent0pt
775 \small
776 \readindex
777 }
778 \fi
779
780 \def\fin{%
781 \if L\lr\mark{{}{}}\fi
782 \vfill\eject % complete the current column.
783 \mark{{}{}}
784 \if R\lr\null\vfill\eject\fi % if necessarry add a right column
785 \setpage
786 \def\page{\box255 } \normalbottom
787 \output={\nomarginoutput\page\lheader\rheader}
788 }
789 \ifbook
790 \let\crosssections=\relax
791 \else
792 \def\crosssections{
793 \plainsection{Crossreference of Code}% this is done when we are ending the index
794 \parindent 0pt
795 \parfillskip 0pt plus 1fil
796 \let\topsecno=\nullsec
797 \message{Crossreference of Code:}
798 \def\note##1##2.{\hfil\penalty-1\hfilneg\quad{\tiny##1~\ifbook##2\else
799 \ifpdf{\pdfnote##2.}\else
800 \ifhint\codenote##2.\else##2.\fi\fi\fi}}
801 \def\Q{\note{Cited in section}} % crossref for mention of a section
802 \def\Qs{\note{Cited in sections}} % crossref for mentions of a section
803 \def\U{\note{Used in}} % crossref for use of a section
804 \def\Us{\note{Used in}} % crossref for uses of a section
805 \def\I{\par\hangindent 2em}\let\*=*
806 \def\X##1:##2\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi %$% section name
807 \XX$\langle\,${\let\I=\ne##2}$\,\rangle$\XX\quad{\tiny Defined in~\codenote##1.}}
808 \readsections
809 }
810 \fi
811
812
813
814 %%
815 %% Table of Content
816 %%
817
818 % we separate the identification of a section used in links
819 %from the identification on paper, because plain sections dont
820 %have the latter.
821 \newcount\toccount
822 \toccount=0
823
824 \def\tocsection#1#2#3{% depth sectionnumber sectiontitle
825 \global\advance\toccount by 1%
826 \newtopdest{SC.\the\toccount}%
827 \ifhint
828 \immediate\write\cont{\noexpand\ZZ {#1}{#2}{#3}% write to contents file
829 {\noexpand\thepageno}{\the\toccount}}
830 \else
831 \edef\next{\write\cont{\noexpand\ZZ {#1}{#2}{#3}% write to contents file
832 {\noexpand\thepageno}{\the\toccount}}}\next % \tocline{depth}{sec}{title}{page}{toccount}
833 \fi
834 }
835
836 \output{
837 \ifhint
838 \shipout\box255\relax% otherwise I loose open, write, or close commands
839 \else
840 \setbox0=\page % the first page is garbage
841 \fi
842 % \openout\cont=\contentsfile
843 % \write\cont{\catcode `\noexpand\@=11\relax} % \makeatletter
844 \global\output{\normaloutput\page\lheader\rheader}}
845
846
847 \newbox\tocbox
848 \def\maketoc{%
849 \typeout{Reading table of contents}
850 \setbox\tocbox\vbox\bgroup%
851 \let\ZZ=\tocline
852 \ifbook\relax\else\ifpdf\startpdf\fi\fi
853 \readcontents
854 \relax
855 \egroup
856 \typeout{Writing \contentsfile}
857 \immediate\openout\cont=\contentsfile\relax
858 \immediate\write\cont{\catcode `\noexpand\@=11\relax}
859 }
860
861 \def\tableofcontent{\plainsection{Contents}\ifhint\HINTdest name {HINT.home}\relax\fi
862 \unvbox\tocbox
863 }
864
865
866 \def\tocline#1#2#3#4#5{% depth sectionnumber sectiontitle page toccount
867 \ifnum#1<0\bigskip\vskip 0pt plus 24pt\penalty -100\vskip 0pt plus -24pt\fi
868 \ifnum#1<1 \smallskip\vskip 0pt plus 12pt\penalty -100\vskip 0pt plus -12pt\fi
869 \noindent
870 \line{%
871 \ifnum#1<0%
872 {\smalltitlefont#3\hfill}{}\hfill
873 \hbox to 2em{\hss\bf\tocref{#1}{#3}{#4}{#5}}%
874 \else\ifnum#1=0%
875 \hbox to 2em{\bf#2\hfill}{\bf#3~}\hfill
876 \hbox to 2em{\hss\bf\tocref{#1}{#3}{#4}{#5}}%
877 \else \ifnum#1=1%
878 \kern 2em\hbox to 3em{\rm#2\hfill}{\rm#3~}\leaders\hbox to .5em{.\hfil}\hfill
879 \hbox to 2em{\hss\tocref{#1}{#3}{#4}{#5}}%
880 \else
881 \kern 2em\hbox to 5em{\rm#2\hfill}{\it#3~}\leaders\hbox to .5em{.\hfil}\hfill
882 \hbox to 2em{\hss\tocref{#1}{#3}{#4}{#5}}\fi\fi\fi
883 }%
884 \ifnum#1<0\bigskip\fi
885 }
886
887
888
889 %%
890 %% Figures and Tables
891 %%
892
893 \def\fig#1{\global\advance\figcount by 1%
894 \ifvmode\noindent\fi
895 \def\captype{Fig}%
896 \capskip=1em%
897 \vbox{\nointerlineskip\figdest
898 \hbox{\noindent#1\hskip -2pt\hskip 0pt plus 2pt minus 2pt}%
899 \medskip
900 \rlap{\small\unhbox\capbox}%
901 }}
902
903 \def\tab#1{%
904 \ifvmode\noindent\fi
905 \def\captype{Tab}%
906 \capskip=0pt%
907 \vbox{#1\medskip\rlap{\small\unhbox\capbox}}}
908
909 \def\table#1#2{\global\advance\tabcount by 1%
910 \ifvmode\noindent\fi
911 \def\captype{Tab}%
912 \capskip=0pt%
913 \vbox{\offinterlineskip\tabdest
914 \halign{\large\strut
915 \vrule##&&\quad\hfil##\hfil\quad\vrule\cr
916 \noalign{\hrule}#2\noalign{\hrule}}%
917 \medskip
918 \tabcaption{#1}%
919 \rlap{\small\unhbox\capbox}%
920 }%
921 }
922
923 \def\captype{}
924 \newdimen\capskip
925 \capskip=1em
926 \newbox\capbox
927 \setbox\capbox\hbox{}
928 \newcount\figcount
929 \figcount=0
930 \newcount\tabcount
931 \tabcount=0
932
933 \def\nextfigcaption#1{\small\strut\it\hskip\capskip\figindex{\captype}{\the\figcount}{#1}\captype.~\the\figcount:}
934
935 \def\caption#1{\global\setbox\capbox\hbox{\nextfigcaption{#1} #1}}
936
937 \def\nexttabcaption#1{\small\strut\it\hskip\capskip\tabindex{\captype}{\the\tabcount}{#1}\captype.~\the\tabcount:}
938 \def\tabcaption#1{\global\setbox\capbox\hbox{\nexttabcaption{#1} #1}}
939
940
941 %\long\def\leftfig#1#2#3{%
942 %\ifvmode\noindent\fi
943 %\def\captype{Fig}%
944 %\capskip=1em%
945 %\vbox{%
946 % \tabskip=0pt\halign to \hsize{%
947 % \vtop{\vskip 0pt\parskip=0pt\hsize=62.5mm\relax
948 % ##}\tabskip=5mm plus 2pt minus 2pt&
949 % \vtop{\vskip 0pt\parskip=0pt\hsize=62.5mm\relax##}\tabskip=0pt\cr
950 % #1&\capskip=0pt\nextfigcaption{#2} #3\cr}\medbreak}}
951
952 \long\def\leftright#1#2#3#4{%
953 \ifvmode\noindent\else\par\noindent\fi
954 \vbox{\nointerlineskip
955 \advance\hsize by -\leftskip\advance\hsize by -\rightskip%
956 \leftskip=0pt\rightskip=0pt%
957 \hbox to \hsize{\strut
958 \raise\ht\strutbox
959 \vtop{\vskip 0pt\parskip=0pt\hsize=#1\hsize\advance\hsize by -2.5mm\relax
960 \noindent\strut\ignorespaces#3\vfill}\hfil
961 \raise\ht\strutbox
962 \vtop{\vskip 0pt\parskip=0pt\hsize=#2\hsize\advance\hsize by -2.5mm\relax
963 \noindent\strut\ignorespaces#4\vfill}}}}
964
965
966 \long\def\leftfig#1#2#3{%
967 \def\captype{Fig}%
968 \capskip=0pt%
969 \leftright{0.5}{0.5}{#1\kern -2pt\hskip 2pt plus 2pt minus 2pt}{\nextfigcaption{#2}\strut #3}}
970
971
972 \def\subindex#1{%
973 \par\ifhmode\unskip\fi% end paragraph and remove vertical space
974 \vskip\abovesubsecskip% space above the subsection
975 \vskip 0pt plus 72pt% allow some empty space at the bottom
976 \penalty-200\vskip 0pt plus -72pt % room for stetching and a page break
977 \noindent{\bf\strut#1}%
978 \nobreak\vskip\belowsubsecskip% space after subsection
979 \everypar{{\setbox0=\lastbox}\everypar{}}% no indentation in the next paragraph
980 \ignorespaces
981 }
982
983 \newwrite\@figfile
984 \newwrite\@tabfile
985
986 \def\makefigindex{%
987 \immediate\openout\@figfile=\jobname.fig\relax
988 \def\figindex{\@bsphack\begingroup\@sanitize\@wrfigindex\@figfile}%
989 \immediate\openout\@tabfile=\jobname.tab\relax
990 \def\tabindex{\@bsphack\begingroup\@sanitize\@wrfigindex\@tabfile}%
991 \typeout{Writing index files \jobname.fig \jobname.tab}
992 }
993
994 \newdimen\iboxsize
995 \def\thefigindex{%
996
997 \immediate\closeout\@figfile\relax
998 \immediate\closeout\@tabfile\relax
999 %\small\baselineskip=11pt
1000 \plainsection{List of Figures and Tables}
1001 \makeatletter
1002 \iboxsize=3.7em\relax
1003 \subindex{Figures}
1004 \def\indexentry##1##2##3##4{% captype, fig/tab count, caption, page
1005 \noindent
1006 \line{\hbox to \iboxsize{%
1007 \rm##1.~##2:\hfil}{\rm ##3}\ \leaders\hbox to .5em{.\hfil}%
1008 \hfill\hbox to 1.4em{\hss
1009 \ifbook##4\else
1010 \ifpdf
1011 \pagelnk{##4}%
1012 \else\ifhint\figlink{##2}
1013 \else##4\fi\fi\fi
1014 }}\par
1015 }%
1016 \input\jobname.fig\relax
1017 \iboxsize=3.9em\relax
1018 \subindex{Tables}
1019 \def\indexentry##1##2##3##4{% captype, fig/tab count, caption, page
1020 \noindent
1021 \line{\hbox to \iboxsize{%
1022 \rm##1.~##2:\hfil}{\rm ##3}\ \leaders\hbox to .5em{.\hfil}%
1023 \hfill\hbox to 1.4em{\hss
1024 \ifbook##4\else
1025 \ifpdf
1026 \pagelnk{##4}%
1027 \else\ifhint\tablink{##2}
1028 \else##4\fi\fi\fi
1029 }}\par
1030 }%
1031 \input\jobname.tab\relax
1032 \makefigindex
1033 }
1034
1035
1036 \def\@wrfigindex#1#2#3#4{% file, captype, fig/tab count, caption
1037 \xdef\gtempa{\write#1{\string\indexentry{#2}{#3}{#4}{\noexpand\thepageno}}}\endgroup\gtempa
1038 \if@nobreak\ifvmode\@nobreak\fi\fi\@esphack}
1039
1040 %%
1041 %% Format Definitions
1042 %%
1043
1044 %\newbox\codebox
1045 \newwrite\@getfile
1046 \newwrite\@putfile
1047 \newwrite\@redfile
1048 \newwrite\@wrtfile
1049
1050 \def\makecode{%
1051 \immediate\openout\@getfile=\jobname.get\relax
1052 \immediate\openout\@putfile=\jobname.put\relax
1053 \immediate\openout\@redfile=\jobname.red\relax
1054 \immediate\openout\@wrtfile=\jobname.wrt\relax
1055 \typeout{Writing index files \jobname.get \jobname.put \jobname.red \jobname.wrt}
1056 }
1057
1058 \def\thecodeindex{%
1059 \immediate\closeout\@getfile\relax
1060 \immediate\closeout\@putfile\relax
1061 \immediate\closeout\@redfile\relax
1062 \immediate\closeout\@wrtfile\relax
1063 \def\indexentry##1##2##3##4{% codecount, depth, pagenumber, section
1064 \ifnum##2=0 \smallskip\vskip 0pt plus 12pt\penalty -100\vskip 0pt plus -12pt\fi
1065 \noindent
1066 \line{%
1067 \ifnum##2=0##4\hfill
1068 \else\qquad\rm##4\ \leaders\hbox to .5em{.\hfil}\hfill
1069 \hbox to 1.4em{\hss\pagelnk{##3}}
1070 \fi
1071 }\par
1072 }%
1073 \section{Format Definitions}
1074 \makeatletter
1075 \subsection{Reading the Long Format}\label{codeindex}
1076 \input\jobname.red.srt\relax
1077 \subsection{Writing the Long Format}
1078 \input\jobname.wrt.srt\relax
1079 \subsection{Reading the Short Format}
1080 \input\jobname.get.srt\relax
1081 \subsection{Writing the Short Format}
1082 \input\jobname.put.srt\relax
1083 }
1084
1085
1086 \newcount\codecount
1087 \codecount=0
1088
1089 \ifhint
1090 \def\@wrcodeindex#1#2#3#4{% file, depth, pagenumber, [sub]sectionname
1091 \global\advance\indexcount by 1\indexdest
1092 \xdef\gtempa{\write#1{\string\indexentry{#3}{#2}{\the\indexcount}{#4}}}\endgroup\gtempa\@esphack
1093 }
1094 \else
1095 \def\@wrcodeindex#1#2#3#4{% file, depth, pagenumber, [sub]sectionname
1096 \xdef\gtempa{\write#1{\string\indexentry{#3}{#2}{\noexpand\thepageno}{#4}}}\endgroup\gtempa\@esphack
1097 }
1098 \fi
1099
1100 \def\getindex{\@bsphack\begingroup\@sanitize\@wrcodeindex\@getfile}%
1101 \def\putindex{\@bsphack\begingroup\@sanitize\@wrcodeindex\@putfile}%
1102 \def\redindex{\@bsphack\begingroup\@sanitize\@wrcodeindex\@redfile}%
1103 \def\wrtindex{\@bsphack\begingroup\@sanitize\@wrcodeindex\@wrtfile}%
1104
1105
1106 \def\codelabel#1#2#3{
1107 \getindex{#1}{#2}{#3}%
1108 \putindex{#1}{#2}{#3}%
1109 \redindex{#1}{#2}{#3}%
1110 \wrtindex{#1}{#2}{#3}}
1111 \def\getsymbol{$\cdots\Longrightarrow$}
1112 \def\putsymbol{$\Longrightarrow\cdots$}
1113 \def\redsymbol{$-{}-{}-{}\Longrightarrow$}
1114 \def\wrtsymbol{$\Longrightarrow{}-{}-{}-$}
1115 \def\getcode{\codesection{\getsymbol}{Reading the short format}\getindex{1}{\the\codecount}{\subcodetitle}}
1116 \def\putcode{\codesection{\putsymbol}{Writing the short format}\putindex{1}{\the\codecount}{\subcodetitle}}
1117 \def\writecode{\codesection{\wrtsymbol}{Writing the long format}\wrtindex{1}{\the\codecount}{\subcodetitle}}
1118 \def\readcode{\codesection{\redsymbol}{Reading the long format}\redindex{1}{\the\codecount}{\subcodetitle}}
1119 \newdimen\coderule
1120 \def\codesection#1#2{%
1121 \par\ifhmode\unskip\fi% end paragraph and remove vertical space
1122 \penalty-200
1123 \vskip 0pt plus 72pt% allow some empty space at the bottom
1124 \penalty-200
1125 \vskip 0pt plus -72pt% room for stetching and a page break
1126 \vskip\abovesubsecskip% space above the subsection
1127 %\line{\setbox0=\hbox{#1}%
1128 %\coderule=\hsize\advance\coderule by -\wd0\advance\coderule by -2em%
1129 %$\vcenter{\hrule width \coderule}$\hss\box0}
1130 \line{{\it #2\/}:\hfill#1}
1131 \nobreak\vskip\belowsubsecskip\nobreak% space after subsection
1132 %\everypar{{\setbox0=\lastbox}\everypar{}}% no indentation in the next paragraph
1133 %\noindent
1134 \ignorespaces}
1135
1136 \def\hascode{\global\advance\codecount by 1%
1137 \codelabel{0}{\the\codecount}{\codetitle}}%
1138
1139
1140 %%
1141 %% Makeindex and the Index
1142 %%
1143
1144 \newwrite\@indexfile
1145
1146 % new jobname for index file
1147 \def\makeindex{
1148 \immediate\openout\@indexfile=\jobname.inx%
1149 \def\index{\@bsphack\begingroup\@sanitize\@wrindex\@indexfile}%
1150 \typeout{Writing index file \jobname.inx }%
1151 }
1152
1153 \def\@idxitem{\par\hangindent 40pt}
1154
1155 \newif\ifnextindex
1156 \nextindexfalse
1157
1158 \def\beginindex{%
1159 \ifhint\relax\else
1160 \def\page{\box255} \normalbottom
1161 \output{\ifpagesaved\normaloutput{\box\sbox}\lheader\rheader\fi
1162 \global\setbox\sbox=\page \global\pagesavedtrue}
1163 \pagesavedfalse \eject % eject the page-so-far and predecessors
1164 \setbox\sbox\vbox{\unvbox\sbox} % take it out of its box
1165 \vsize=\pageheight \advance\vsize by -\ht\sbox % the remaining height
1166 \hsize=.5\pagewidth \advance\hsize by -10pt
1167 % column width for the index (20pt between cols)
1168 \parfillskip 0pt plus .6\hsize % try to avoid almost empty lines
1169 \def\lr{L} % this tells whether the left or right column is next
1170 \output{\if L\lr\global\setbox\lbox=\page \gdef\lr{R}
1171 \else\nomarginoutput{\vbox to\pageheight{\box\sbox\vss
1172 \hbox to\pagewidth{\box\lbox\hfil\page}}}\lheader\rheader
1173 \global\nextindextrue
1174 \global\vsize\pageheight\gdef\lr{L}\global\pagesavedfalse\fi}
1175 \fi
1176 \message{Index:}
1177 \mark{{0}{0}}
1178 \noindent\par
1179 \begingroup
1180 \rightskip 0pt plus 12pt
1181 \parskip 0pt plus .5pt
1182 \hyphenpenalty 10000 \parindent0pt
1183 \small\baselineskip=11pt
1184 \def\item{\par\hangindent 40pt\relax\ifnextindex\mark{{Index}{Index}}\fi}%
1185 \def\subitem{\par\hangindent 40pt\hskip 20pt\relax}%
1186 \def\subsubitem{\par\hangindent 40pt\hskip 30pt\relax}%
1187 \def\indexspace{\par\vskip 12pt plus 6pt minus 4pt\vskip 12pt\goodbreak\vskip -12pt\relax}%
1188 \def\indexheading##1{{\tenbf ##1}\nobreak\vskip 3pt\relax}
1189 }
1190 \def\endindex{%
1191 \endgroup
1192 \vfill\eject % complete the current column.
1193 \ifhint\relax\else
1194 \if R\lr\null\vfill\eject\fi % if necessarry add a right column
1195 \fi
1196 }
1197
1198
1199 %%
1200 %% Label page, section, toccount, figure, table, code, enum
1201 %%
1202 \newcount\cdcount
1203 \cdcount=0
1204
1205 \newdimen\labelskip
1206 \def\label#1{% writes \labeldef{name}{{page}{section}{toccount}{figure}{table}{code}{enum}} to aux
1207 \ifhint
1208 \global\advance\indexcount by 1\indexdest
1209 \begingroup\@readauxfile
1210 \edef\next{\@writeaux{\string\labeldef{#1}{{\the\indexcount}%
1211 {\thesection}{\the\toccount}{\the\figcount}{\the\tabcount}{\the\cdcount}{\the\enum}}}\endgroup}%
1212 \else
1213 \begingroup\@readauxfile
1214 \edef\next{\@writeaux{\string\labeldef{#1}{{\noexpand\thepageno}%
1215 {\thesection}{\the\toccount}{\the\figcount}{\the\tabcount}{\the\cdcount}{\the\enum}}}\endgroup}%
1216 \fi
1217 \ifvmode %make \removelastskip work after \label
1218 \labelskip=\lastskip
1219 \vskip-\labelskip
1220 \next
1221 \vskip\labelskip
1222 \else
1223 \next
1224 \fi
1225 }
1226
1227
1228 \def\m@kelabel#1{label@#1}% this makes the controlseqence from the name
1229
1230 \def\labeldef#1#2{% #1 is name #2 is page section subsection figure table code
1231 \expandafter\gdef\csname\m@kelabel{#1}\endcsname{#2}}%
1232
1233 \def\@setref#1#2#3{%
1234 \ifx#1\relax
1235 \message{Undefined reference: #3}
1236 \else
1237 \expandafter#2#1%
1238 \fi}
1239
1240 \def\@iofvii#1#2#3#4#5#6#7{#1}
1241 \def\@iiofvii#1#2#3#4#5#6#7{#2}
1242 \def\@iiiofvii#1#2#3#4#5#6#7{#3}
1243 \def\@ivofvii#1#2#3#4#5#6#7{#4}
1244 \def\@vofvii#1#2#3#4#5#6#7{#5}
1245 \def\@viofvii#1#2#3#4#5#6#7{#6}
1246 \def\@viiofvii#1#2#3#4#5#6#7{#7}
1247
1248
1249 \def\pageref#1{\@readauxfile
1250 \pagelnk{\expandafter\@setref\csname\m@kelabel{#1}\endcsname\@iofvii{#1}}}
1251 \def\secref#1{\@readauxfile
1252 \sectionlink
1253 {\expandafter\@setref\csname\m@kelabel{#1}\endcsname\@iiofvii{#1}}%
1254 {\expandafter\@setref\csname\m@kelabel{#1}\endcsname\@iiiofvii{#1}}%
1255 }
1256 \def\figref#1{\@readauxfile
1257 \figlink{\expandafter\@setref\csname\m@kelabel{#1}\endcsname\@ivofvii{#1}}}
1258 \def\tabref#1{\@readauxfile
1259 \tablink{\expandafter\@setref\csname\m@kelabel{#1}\endcsname\@vofvii{#1}}}
1260 \def\cdref#1{\@readauxfile
1261 \expandafter\@setref\csname\m@kelabel{#1}\endcsname\@viofvii{#1}}
1262 \def\enumref#1{\@readauxfile
1263 \enumlink{\expandafter\@setref\csname\m@kelabel{#1}\endcsname\@viiofvii{#1}}}
1264
1265 %%
1266 %% Links and Destinations
1267 %%
1268
1269 \ifbook
1270 \def\pdflinkcolor{0 0 0} % the RGB values for hyperlink color
1271 \def\linkcolor{\Black}
1272 \def\pdflink#1#2{#1}
1273 \def\pdfnote#1.{#1}
1274 \message{No PDF Links}
1275 \else
1276 \def\pdflinkcolor{0 0 1} % the RGB values for hyperlink color
1277 \def\linkcolor{\Blue}
1278 \message{PDF Links are blue}
1279 \fi
1280
1281 \def\@esphack{\relax\ifhmode\spacefactor\@savsf
1282 {}\ifdim \@savsk >\z@ \ignorespaces
1283 \fi \fi}
1284
1285 %
1286 % Code destinations: by number
1287 %
1288
1289 %The number is set by \M and \N and stored as \secno
1290 %The destination is set in \B where we go into C mode
1291 \newcount\lastcodeno
1292 \lastcodeno=0
1293 \def\codedest{%
1294 \ifnum\lastcodeno<\codeno
1295 \global\lastcodeno=\codeno\relax
1296 \ifbook\else
1297 \ifhint\HINTdest num \the\codeno\relax%\message{New destination num \the\codeno }%
1298 \else\ifpdf\pdfdest num \the\codeno fith\relax
1299 \else\relax
1300 \fi\fi\fi
1301 \fi
1302 }
1303 \def\coderef#1{% used in \X
1304 \ifbook${}_{#1}$\else
1305 \ifhint\HINTstartlink goto num #1 \hbox{${}_{#1}$}\HINTendlink
1306 \else\ifpdf{\eightrm\pdfnote#1.}
1307 \else${}_{#1}$\fi\fi\fi
1308 }
1309
1310 \newcount\countC
1311
1312 \def\codenote#1.{% replaces \pdfnote
1313 \setbox0=\hbox{\toksA={#1.}\toksB={}\maketoks}\the\toksA}
1314 % define the following like for pdf
1315 \def\firstsecno#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}%
1316 \def\makenote{\addtokens\toksB{\the\toksC}\def\makenote{\toksD={}
1317 \toksC={}\let\space\empty}\makenote}\maketoks}}
1318 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1319 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}%
1320 \ifcat\noexpand\first0\countB=`#1\else\countB=0\fi\toksA={#2}}
1321 \def\maketoks{\expandafter\poptoks\the\toksA|ENDTOKS|%
1322 \ifnum\countB>`9 \countB=0 \fi
1323 \ifnum\countB<`0
1324 \ifnum0=\countC\else\makenote\fi
1325 \ifx\first.\let\next=\maketoksdone\else
1326 \let\next=\maketoks
1327 \addtokens\toksB{\the\toksD}
1328 \ifx\first,\addtokens\toksB{\space}\fi
1329 \fi
1330 \else \addtokens\toksC{\the\toksD}\global\countC=1\let\next=\maketoks
1331 \fi
1332 \next
1333 }
1334 \def\makenote{\addtokens\toksB
1335 {\noexpand\codelink{\the\toksC}{\romannumeral\the\toksC}}\toksC={}\global\countC=0}
1336 \def\maketoksdone{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1337
1338 \def\codelink#1#2{
1339 \ifbook#1\else
1340 \ifhint\HINTstartlink goto num #1 #1\HINTendlink
1341 \else\ifpdf\pdflink{#1}{#2}%
1342 \else#1%
1343 \fi\fi\fi}
1344
1345 %
1346 % new destinations and links: by name
1347 %
1348
1349 \def\newdest#1{% used to make a new destination
1350 %\message{New destination #1}%
1351 \ifbook
1352 \else\ifpdf
1353 \pdfdest name {#1} fith%\message{Defining pdf label #1}%
1354 \else\ifhint
1355 \HINTdest name {#1}%\message{Defining HINT label name #1}%
1356 \fi\fi\fi}
1357
1358 \def\newtopdest#1{% used to make a new destination
1359 %\message{New destination #1}%
1360 \ifbook
1361 \else\ifpdf
1362 \pdfdest name {#1} fith%\message{Defining pdf label #1}%
1363 \else\ifhint
1364 \HINTdest name {#1} top %\message{Defining HINT label name #1 top}%
1365 \fi\fi\fi}
1366
1367
1368 \def\newlink#1#2{%
1369 \ifbook #2\else
1370 \ifpdf
1371 \pdfstartlink goto name {#1}\linkcolor#2\Black\pdfendlink
1372 \else\ifhint
1373 \HINTstartlink goto name {#1}#2\HINTendlink
1374 \else
1375 #2%
1376 \fi\fi\fi
1377 }
1378
1379
1380 %SC.-\the\plaincount for plain sections
1381 %SC.\thesection for regular sections, with subsections and letters for the appendix
1382
1383 \def\tocref#1#2#3#4{% depth, title, page, label used in tocline
1384 \ifbook#3\else
1385 \ifpdf
1386 \pdfstartlink goto name {SC.#4}\relax \linkcolor#3\Black\pdfendlink
1387 \ifnum#1=0\pdfoutline goto name {SC.#4} {#2}\fi
1388 \else\ifhint
1389 \HINTstartlink goto name {SC.#4}\relax $\rightarrow$\HINTendlink
1390 \HINToutline goto name {SC.#4} depth #1 {#2}%
1391 \else
1392 #3%
1393 \fi\fi\fi
1394 }%
1395
1396 %
1397 % Page references from the index
1398 %
1399
1400 % \index{keyword} -> \@wrindex{file}{keyword} writes the nectessary information
1401 % makeindex produces the index and pages are enclosed in \hyperref{pagenumber}
1402 % Problems:
1403 % pagenumbers may be roman numerals in the frontmatter
1404 % hyperpage has to cope with 6 different formats
1405 % \hyperpage{50} a single page number
1406 % \hyperpage{51, 52} two numbers
1407 % \hyperpage{53--59} a page range
1408 % \hyperpage{xi} a roman numeral
1409 % \hyperpage{xi, xii} two numbers
1410 % \hyperpage{xi--xx} a page range
1411
1412
1413 % Writing the index file: in HINT replacing the page number by the index count
1414 \newcount\indexcount
1415 \def\theindexcount{\the\indexcount}
1416
1417 \ifhint
1418 \def\@wrindex#1#2{% file, keyword
1419 \global\advance\indexcount by 1\indexdest
1420 \immediate\write#1{\string
1421 \indexentry{#2:hyperpage}{\the\indexcount}}\endgroup
1422 \if@nobreak \ifvmode\@nobreak\fi\fi\@esphack}
1423 \else
1424 \def\@wrindex#1#2{%
1425 \xdef\gtempa{\write#1{\string
1426 \indexentry{#2:hyperpage}{\noexpand\thepageno}}}\endgroup\gtempa
1427 \if@nobreak \ifvmode\@nobreak\fi\fi\@esphack}
1428 \fi
1429
1430
1431 % for HINT and PDF we used hyperrange and hypercomma to split the
1432 % arguments into index/page numbers and then use pagelink
1433 \ifbook
1434 \def\hyperpage#1{#1}\else
1435 \ifhint
1436 \def\hyperpage#1{\hyperrange#1----+\relax}
1437 \else\ifpdf
1438 \def\hyperpage#1{\hyperrange#1----+\relax}
1439 \else
1440 \def\hyperpage#1{#1}
1441 \fi\fi\fi
1442
1443 %\def\indexlink#1{#1}
1444
1445 \def\hyperrange#1--#2--#3+{%
1446 \ifx\empty#2\empty%
1447 \hypercomma#1, ,+%
1448 \else\ifhint
1449 \pagelnk{#1}--\pagelink{#2}{$\leftarrow$}%
1450 \else
1451 \pagelnk{#1}--\pagelnk{#2}%
1452 \fi\fi}
1453
1454 \def\hypercomma#1, #2,#3+{%
1455 \ifx\empty#2\empty%
1456 \pagelnk{#1}%
1457 \else\ifhint%
1458 \pagelink{#1}{$\longrightarrow$}%
1459 \else
1460 \pagelnk{#1}%
1461 % I omit the second page number \ifpdf, \pagelnk{#2}\fi
1462 \fi\fi
1463 }
1464
1465
1466 %
1467 % Labels
1468 %
1469
1470 % section references from \secref use \sectionlink
1471 % for plainsections, we display the label name because there
1472 %is no section number.
1473
1474 \def\sectionlink#1#2{% \message{Sectionlink #1 : #2}%
1475 \ifbook#1\else
1476 \ifpdf
1477 \pdfstartlink goto name {SC.#2} \linkcolor#1\Black\pdfendlink
1478 \else\ifhint
1479 \HINTstartlink goto name {SC.#2}#1\HINTendlink
1480 \else
1481 #1%
1482 \fi\fi\fi
1483 }
1484
1485
1486 % page references from \label and \pageref use \pagelink as before
1487 \def\indexdest{\newdest{page.\the\indexcount}}
1488 \def\pagelnk#1{%
1489 \ifhint
1490 \pagelink{#1}{$\rightarrow$}%
1491 \else
1492 \pagelink{#1}{#1}%
1493 \fi
1494 }
1495 \def\pagelink#1#2{\newlink{page.#1}{#2}}
1496 % For hint the destination is generated with each \index and \label
1497 % Because of the roman numerals, for pdf files
1498 % the pdf destination is generated in the header using \pagelabel
1499
1500
1501 \ifbook\let\pagelabel=\relax\else
1502 \ifpdf
1503 \def\pagelabel{%\message{SETTING pagelabel=\thepageno}
1504 \pdfdest name {page.\thepageno} fitv\relax}
1505 \else
1506 \let\pagelabel=\relax
1507 \fi\fi
1508
1509 % references to Figures, Tables, Enumerations
1510 \def\figdest{\newdest{FI.\the\figcount}}
1511 \def\figlink#1{\newlink{FI.#1}{#1}}
1512 \def\tabdest{\newdest{TA.\the\tabcount}}
1513 \def\tablink#1{\newlink{TA.#1}{#1}}
1514 \def\enumdest{\newdest{EN.\the\enum}}
1515 \def\enumlink#1{\newlink{EN.#1}{#1}}
1516
1517 %
1518 % References to the bibliography
1519 %
1520 \def\citedest#1{\newdest{CI.#1}}
1521 \def\citelink#1{%\message{Citelink #1}%
1522 \newlink{CI.#1}{#1}}
1523
1524 \def\bblhook{%defined before reading the .bbl file
1525 \def\biblabelprint##1{%
1526 \citedest{##1}%
1527 \noindent
1528 \hbox to \biblabelwidth{%
1529 \biblabelprecontents
1530 \biblabelcontents{##1}%
1531 \biblabelpostcontents
1532 }%
1533 \kern\biblabelextraspace
1534 }%
1535 }
1536 \def\@onecitation#1\@@{%called for each citation
1537 \if@notfirstcitation
1538 \printbetweencitations
1539 \fi
1540 %
1541 \expandafter \ifx \csname\@citelabel{#1}\endcsname \relax
1542 \if@citewarning
1543 \message{\@linenumber Undefined citation `#1'.}%
1544 \fi
1545 % Give it a dummy definition:
1546 \expandafter\gdef\csname\@citelabel{#1}\endcsname{%
1547 {\tt
1548 \escapechar = -1
1549 \nobreak\hskip0pt
1550 \expandafter\string\csname#1\endcsname
1551 \nobreak\hskip0pt
1552 }%
1553 }%
1554 \fi
1555 % Now produce the text, whether it was undefined or not.
1556 \citelink{\csname\@citelabel{#1}\endcsname}%
1557 \@notfirstcitationtrue
1558 }%
1559 %%
1560 %% Images
1561 %%
1562
1563 \ifbook
1564 \def\includefig#1{\leavevmode\hbox{\immediate\pdfximage{image/#1.pdf}\pdfrefximage\pdflastximage}}
1565 \else\ifpdf
1566 \def\includefig#1{\leavevmode\hbox{\immediate\pdfximage{image/#1.pdf}\pdfrefximage\pdflastximage}}
1567 \else\ifhint
1568 \def\includefig#1{\HINTimage=image/#1.png\relax}
1569 \else
1570 \input epsf.tex
1571 \def\includefig#1{\epsfbox{image/#1.eps}}% this is a \leavevmode\hbox{...}
1572 \fi\fi\fi
1573
1574 \ifhint\eject\fi% hitex will remove empty pages that were introduced by cwebmac
1575 \makeatother