Debian Codegraph @

texk/web2c/texprofdir/texprofilemac.tex

raw
1 % Copyright 2017-2024 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
128 \font\tenss=cmss10 % used for the HINT name
129 \font\tenssbx=cmssbx10 % used for the bold HINT name
130 \font\largess=cmss12 scaled\magstep1 % used for large HINT name
131 \font\largessbx=cmssbx10 scaled\magstep2 % used for large bold HINT name
132 \font\manual=manfnt % font used for the METAFONT logo, etc.
133 \let\sf\tenss
134 \def\bf{\let\sf\tenssbx\fam\bffam\tenbf}
135
136
137 %% Large Font for sections
138 %\font\largebf=cmb14 scaled\magstep0
139 %\font\largebf=cmb12 scaled\magstep1
140 \font\largebf=cmbx12 scaled\magstep1
141 %\font\largebf=cmbx8 scaled\magstep3
142 %\font\largeit=cmti14 scaled\magstep0
143 \font\largeit=cmti12 scaled\magstep1
144 %\font\largett=cmtt14 scaled\magstep0
145 \font\largett=cmtt12 scaled\magstep1
146 %\font\largerm=cmr14 scaled\magstep0
147 \font\largerm=cmr12 scaled\magstep1
148 % for mathbolditalic
149 %\font\tenmib=cmmib10 scaled\magstep0
150 \font\tenmib=cmmib10 scaled\magstep0
151 \font\largemib=cmmib10 scaled\magstep1
152
153 %% Small Fonts for Figure and Table descriptions
154 \font\figbf=cmbx9 scaled\magstep0
155 \font\figit=cmti9 scaled\magstep0
156 \font\figmit=cmmi9 scaled\magstep0
157 \font\figsy=cmsy9 scaled\magstep0
158 \font\figtt=cmtt9 scaled\magstep0
159 \font\figrm=cmr9 scaled\magstep0
160 % for mathbolditalic
161 \font\figmib=cmmib9 scaled\magstep0
162
163 \def\largebold{\let\bf\largebf\let\sf\largessbx\bf}
164
165 \def\large{\def\rm{\fam0\largerm}\let\bf\largebold\let\it\largeit\let\tt\largett\let\mib\largemib\let\sf\largess%
166 \textfont0=\largerm\textfont1=\largeit
167 \setbox\strutbox=\hbox{\vrule height9.5pt depth5.0pt width\z@}\rm}
168
169 \def\small{\def\rm{\fam0\figrm}\let\bf\figbf\let\it\figit\let\tt\figtt\let\mib\figmib%
170 \textfont0=\figrm\textfont1=\figmit\textfont2=\figsy%
171 \setbox\strutbox=\hbox{\vrule height9.0pt depth4.5pt width\z@}\rm}
172
173 \let\tiny\eightrm
174 \let\mib\tenmib
175
176
177 %%
178 %% Logos
179 %%
180
181 %\def\Pascal/{{\mc P\kern-.05emascal\spacefactor1000}}
182 \def\CEE{{\mc C\spacefactor1000}}
183 \def\Pascal{\leavevmode\hbox{\mc P\kern-.05emascal}}
184 \def\PDF{\leavevmode\hbox{\mc PDF}}
185 \def\WEB{\leavevmode\hbox{\tt WEB\spacefactor1000}}
186 \def\GNU{\leavevmode\hbox{\mc GNU}}
187 \def\Prote{{\tenrm P\kern-0.1em R\kern-0.15em\raise.11ex\hbox{o}%
188 \kern-0.22em T\kern-0.05em E}}
189 \def\eTeX{$\varepsilon$-\TeX}
190 \def\HINT{\leavevmode\hbox{\sf HINT\spacefactor1000}}
191 \def\cweb{\leavevmode\hbox{\tt cweb}}
192 \def\web2w{\leavevmode\hbox{\tt web2w}}
193 \def\LaTeX{L\kern-.36em\raise.3ex\hbox{\sc A}\kern-.15em\TeX}%
194 \def\MF{{\manual META}\-{\manual FONT}}%
195 \def\TL{\TeX~Live}
196 \def\kpse{\leavevmode\hbox{\tt kpathsearch\spacefactor1000}}
197 \def\TUB{{\sl TUGboat\/}}
198 \def\TUG{\TeX\ \UG}
199 \def\tug{\acro{TUG}}
200 \def\UG{Users Group}
201 \ifpdf
202 \sanitizecommand{\TeX}{TeX}
203 \sanitizecommand{\eTeX}{eTeX}
204 \sanitizecommand{\Prote}{PRoTE}
205 \fi
206 %%
207 %% Special controlsequences
208 %%
209
210 \def\abs#1{\left|#1\right|}
211 \def\<#1>{$\langle\,$#1$\,\rangle$}
212 \def\registered{{\ooalign{\hfil\raise.07ex\hbox{\sevenrm R}\hfil\crcr\Orb}}}
213 \def\hair{\kern.05em\relax} % teeny tiny space
214 \def\center#1{\bigskip\line{\hfil#1\hfil}\bigbreak}
215 \chardef\VB=`\| % vertical bar character in a string
216 \def\^{\ifmmode\mathchar"222 \else\char`^ \fi}%from webmac.tex: pointer or hat
217 \ifhint
218 \def\_{{\tt\UL}} % make underline an ordinary character for better searching
219 \fi
220
221 % Bibtex needs this
222 \def\mbox#1{\leavevmode\hbox{#1}}
223
224 % URLs
225 {\gdef\urldot{.}\catcode`.=13
226 \gdef\urlslash{/}\catcode`/=13
227 \gdef\urlspecials{\def.{\urldot\penalty 0}\def/{\urlslash\penalty 0}}
228 }
229 \def\url{\bgroup\hskip 1cm plus 5cm\penalty -100\hskip -1cm plus -5cm\tt
230 \catcode`_=12\catcode`\~=12\catcode`.=13\catcode`/=13\urlspecials}
231 \def\endurl{\egroup}
232
233
234 % for the index
235 \def\see#1#2{\hskip 0pt plus 100pt\penalty 0\hskip 0 pt plus -100pt{\it see\/} #1}
236
237 % typewriter type for strings
238 \def\.#1{\leavevmode\hbox{\tt
239 \let\\=\BS % backslash in a string
240 \let\{=\LB % left brace in a string
241 \let\}=\RB % right brace in a string
242 \let\~=\TL % tilde in a string
243 \let\ =\SP % space in a string
244 \let\_=\UL % underline in a string
245 \let\&=\AM % ampersand in a string
246 \let\^=\CF % circumflex in a string
247 \let\|=\VB % vertical bar in a string
248 #1\kern.05em}}
249
250 %{\rm\gdef\strutdepth{\dp\strutbox}}
251
252
253 %%
254 %% Environments
255 %%
256
257 % Quotations (form the standard)
258 \def\beginquote{\bgroup\narrower\noindent\sl}
259 \def\endquote{\egroup}
260
261 % Enumerate
262 \newcount\enum
263 %other styles use \medskip instead of \par
264 \def\enumerate{\par\bgroup\advance\leftskip by\parindent\enum=0%
265 \def\item{\advance\enum by 1\par\enumdest\smallskip\noindent\hbox to 0pt{\hss\the\enum.~}\ignorespaces}}
266 \def\endenumerate{\medskip\egroup\noindent}
267
268 %Itemize
269 \def\itemize{\par\bgroup\advance\leftskip by\parindent\relax%
270 \def\item{\par\smallskip\noindent\llap{$\bullet$\enspace}\ignorespaces}}
271 \def\enditemize{\medskip\egroup\noindent}
272
273 %Float
274 \long\def\float#1{\midinsert\parindent 0pt\relax#1\endinsert}
275 %\def\float#1{\midinsert
276 %\hsize\pagewidth
277 %\parindent 0pt\vbox{\hbox{\kern-\marginwidth\vbox{#1}}}\endinsert}
278
279 %%
280 %% Redefining cwebmac.tex macros
281 %%
282
283 %defining how to output terminals and nonterminals
284 \def\ts#1{\ifmmode\hbox{\sc #1}\else{\sc #1}\fi}% terminal symbol
285 \def\nts#1{{\sl #1\/}}% nonterminal symbol
286 % redefining the box around verbatim code
287 \def\vb#1{\hbox{\strut\.{#1}}}
288 % regular expressions and actions
289 \newbox\rebox
290 \def\re#1{\leavevmode\setbox\rebox\hbox{#1\hfill}\ifdim\wd\rebox<7em\wd\rebox=7em\fi\box\rebox\quad}
291 \def\ac{\global\ind=10\hangindent=\ind em\relax}
292 \def\eac{\global\ind=3\hangindent=\ind em\relax}
293 % yskip is usually a smallskip = 3pt pus 1pt minus 1pt
294 % I give it some extra stretchability
295 %\def\yskip{\vskip 3pt plus 3pt minus 1pt}
296 \let\yskip\smallbreak
297
298 % redefine \5 for an optional break without the 2.5em reduced indentation
299 %\def\5{\hskip 0pt plus 2.5em\penalty-1\hskip 0pt plus -2.5em\kern0.5em\ignorespaces}% optional break
300 %redefine \5 to give some shrinkability
301 % from hitex and hint style:
302 %\def\5{\hfil\penalty-1\hskip 0pt minus 6pt\hfilneg\kern2.5em\copy\bakk\ignorespaces}% optional break
303 \def\5{\hfil\penalty10\hfilneg\hskip 0pt minus 6pt\kern2.5em\copy\bakk\ignorespaces}% optional break
304 \def\J{}% dont show @& in the tex output
305
306
307 \def\Y{\par\setsecstartref\yskip}
308
309 % start sections
310 \def\stsec{\rightskip=0pt % get out of C mode (cf. \B)
311 \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50 %
312 }
313
314 % the box for the points to operator "->" in C
315 \setbox\MGbox=\hbox{$\rightarrow$}
316
317 % how to display NULL
318 \def\NULL{\tt NULL}
319
320 %other styles make this a \par
321 \def\note#1#2.{}
322 %\Y\noindent{\hfill%
323 % \baselineskip10pt\tiny#1~\ifacro{\pdfnote#2.}\else#2\fi.\par}}
324
325 % put the section number to the right
326 \newif\ifshowsecstartref \showsecstartreffalse
327 \newif\ifsetsecstartref \setsecstartreffalse
328
329 \def\secstartref{% used in \MN
330 \ifshowsecstartref
331 \vadjust{\vtop to 0pt{\vss\hbox to \hsize{\hfill\tiny(\secstar)}\kern 0pt}}
332 \global\showsecstartreffalse
333 \fi
334 }
335
336 \def\setsecstartref{% used in \Y
337 \ifsetsecstartref
338 \codedest
339 \global\setsecstartreffalse
340 \fi
341 }
342
343
344 %other styles make this minus 10pt
345 \def\B{\rightskip=0pt plus 100pt minus 0pt % go into C mode
346 \sfcode`;=3000
347 \pretolerance 10000
348 \hyphenpenalty 1000 % so strings can be broken (discretionary \ is inserted)
349 \exhyphenpenalty 1000
350 \global\ind=2 \1\ \unskip
351 }
352
353 % formating of C comments
354 \def\C#1{\5\hfill$/\ast\,${\cmntfont #1}$\,\ast/$}
355
356 % section begin
357 \def\M#1{\MN{#1}\ifon\stsec\smallskip
358 %\everypar{{\setbox0=\lastbox}\everypar{}}% no indentation in the next paragraph
359 \noindent\ignorespaces}% beginning of section
360
361 \def\N#1#2#3.{\MN{#1}\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 \def\MN#1{\smallskip
366 {\xdef\secstar{#1}\let\*=\empty\xdef\secno{#1}}%
367 \gdef\thecode{#1}% common code for \M, \N
368 \ontrue\showsecstartreftrue\setsecstartreftrue}
369
370 % Used in section text
371 \def\U{\rightnote{Used in}} % xref for use of a section
372 \def\Us{\rightnote{Used in}} % xref for uses of a section
373 % replacing \note in \U and \Us by \rightnote
374 %\def\rightnote#1#2.{\vskip-\baselineskip\vtop to 0pt{\vss\hbox to \hsize{\hfill
375 % \tiny#1~\ifacro{\pdfnote#2.}\else#2\fi.}\kern 0pt}}
376 %\def\rightnote#1#2.{\vskip-\baselineskip\hbox to \hsize{\hfill
377 % \tiny#1~\ifacro{\pdfnote#2.}\else#2\fi.}}
378 %\def\rightnote#1#2.{\penalty1000\discretionary{}{\hbox{}}{\kern 2em}\penalty1000\hfill
379 % \hbox{\tiny#1~\ifacro{\pdfnote#2.}\else#2\fi.}}
380 \def\rightnote#1#2.{%
381 \penalty1000\discretionary{}{\hbox{}}{\kern 4em}\penalty1000\hfill
382 \hskip -4em plus 4em\hbox{\tiny #1~\codenote#2.}.}
383
384 \def\X#1:#2\X{\setsecstartref
385 \ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi %$% section name
386 \XX$\langle\,${\let\I=\ne#2\kern.5em\coderef{#1}$\rangle$\XX}%
387 \secstartref}
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
629 \gdef\sectionname{}
630 \gdef\subsectionname{}
631 \gdef\codetitle{}%
632 \gdef\subcodetitle{}
633
634 \def\sectionpage{%
635 \vfil\break
636 \ifodd\pageno\else
637 \hbox{}%
638 \titletrue
639 \fi
640 \vfil\break
641 }
642
643
644 \def\section#1{%
645 \mark{{\sectionname}{\subsectionname}}%
646 %\message{Mark section {\sectionname}{\subsectionname}}
647 \subsubsectioncount=0\subsectioncount=0%
648 \advance\sectioncount by 1%updating counts
649 \let\thesection\topsection
650 \sectionpage%
651 \gdef\sectionname{\topsection\quad#1}%
652 \gdef\subsectionname{\thesection\quad#1}%
653 \gdef\codetitle{#1}%
654 \gdef\subcodetitle{#1}%
655 \ifnum\sectioncount=1\ifappendix\tocsection{0}{}{Appendix}\heading{}{Appendix}\fi\fi
656 \tocsection{0}{\thesection}{#1}%
657 \heading{\thesection~}{#1}%
658 }
659
660
661 \def\subsection#1{%
662 \subsubsectioncount=0\advance\subsectioncount by 1%updating counts
663 \def\thesection{\topsection.\the\subsectioncount}
664 \def\secno{{\noindent\bf\strut\sectionbox{\thesection~}#1}}%
665 \par\ifhmode\unskip\fi% end paragraph and remove vertical space
666 \tocsection{1}{\thesection}{#1}%
667 \penalty-200
668 \vskip 0pt plus 36pt% allow some empty space at the bottom
669 \penalty-200
670 \vskip 0pt plus -36pt% room for stetching and a page break
671 \gdef\subsectionname{\thesection\quad#1}%
672 \mark{{\sectionname}{\subsectionname}}%
673 %\message{Mark subsection {\sectionname}{\subsectionname}}
674 \vskip\abovesubsecskip% space above the subsection
675 \secno% The subsection title
676 \gdef\subcodetitle{#1}%
677 %\mark{{\sectionname}{\subsectionname}}%
678 %\hbox{Mark {\sectionname}{\subsectionname}}%
679 \nobreak\vskip\belowsubsecskip% space after subsection
680 \everypar{{\setbox0=\lastbox}\everypar{}}% no indentation in the next paragraph
681 \ignorespaces}
682
683
684 \def\subsubsection#1{%
685 %\mark{{\sectionname}{\subsectionname}}%
686 %\hbox{Mark {\sectionname}{\subsectionname}}%
687 \advance\subsubsectioncount by 1%updating counts
688 \def\thesection{\topsection.\the\subsectioncount.\the\subsubsectioncount}
689 \def\secno{{\noindent\it\strut\sectionbox{\thesection~}#1}}%
690 \par\ifhmode\unskip\fi% end paragraph and remove vertical space
691 \tocsection{2}{\thesection}{#1}%
692 \penalty-200
693 \vskip 0pt plus 36pt% allow some empty space at the bottom
694 \penalty-200
695 \vskip 0pt plus -36pt% room for stetching and a page break
696 \vskip\abovesubsecskip% space above the subsection
697 \secno% The subsubsection title
698 \nobreak\vskip\belowsubsecskip% space after subsection
699 %\everypar{{\setbox0=\lastbox}\everypar{}}% no indentation in the next paragraph
700 %\noindent
701 \ignorespaces}
702
703 %%
704 %% Appendix
705 %%
706
707 \def\Alphanum#1{%
708 \ifcase#1\or A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or
709 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
710 Y\or Z\else\number#1\fi}
711
712 \def\appendix{%
713 \mark{{\sectionname}{\subsectionname}}%
714 %\message{Mark appendix {\sectionname}{\subsectionname}}
715 \sectioncount=0
716 \subsectioncount=0
717 \gdef\thesection{\Alphanum\sectioncount}%
718 \gdef\topsection{\Alphanum\sectioncount}%
719 \appendixtrue
720 }
721
722 %%
723 %% Crossreference of Identifiers and Sections
724 %%
725 \iftrue %% No Crossreference of identifiers
726 \def\inx{\def\lr{L}} % this tells whether the left or right column is next
727 \else
728 \def\inx{%
729 \hsize=\pagewidth
730 \def\page{\box255 } \normalbottom
731 \output{\ifpagesaved\normaloutput{\box\sbox}\lheader\rheader\fi
732 \global\setbox\sbox=\page \global\pagesavedtrue}
733 \pagesavedfalse
734 \plainsection{Crossreference of Identifiers}% we are beginning the index
735 \mark{{0}{0}}%
736 %\hbox{Mark empty empty}%
737 \eject % eject the page-so-far and predecessors
738 \setbox\sbox\vbox{\unvbox\sbox} % take it out of its box
739 \vsize=\pageheight \advance\vsize by -\ht\sbox % the remaining height
740 \hsize=.5\pagewidth \advance\hsize by -10pt
741 % column width for the index (20pt between cols)
742 \parfillskip 0pt plus .6\hsize % try to avoid almost empty lines
743 \def\lr{L} % this tells whether the left or right column is next
744 \output{\if L\lr\global\setbox\lbox=\page \gdef\lr{R}
745 \else\nomarginoutput{\vbox to\pageheight{\box\sbox\vss
746 \hbox to\pagewidth{\box\lbox\hfil\page}}}\lheader\rheader
747 \global\vsize\pageheight\gdef\lr{L}\global\pagesavedfalse
748 \mark{{Crossreference of Identifiers}{Crossreference of Identifiers}}%
749 \fi}
750 \parfillskip 0pt plus 1fil
751 \let\topsecno=\nullsec
752 \message{Crossreference of Identifiers:}
753 \parskip 0pt plus .5pt
754 \outer\def\I##1, ##2.{\par\hangindent2em\noindent##1:\kern1em
755 \ifbook##2\else\ifpdf\pdfnote##2.\else##2\fi\fi.} % index entry
756 \def\[##1]{$\underline{##1}$} % underlined index item
757 \rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar
758 \hyphenpenalty 10000 \parindent0pt
759 \small
760 \readindex
761 }
762 \fi
763
764 \def\fin{%
765 \if L\lr\mark{{}{}}\fi
766 \vfill\eject % complete the current column.
767 \mark{{}{}}
768 \if R\lr\null\vfill\eject\fi % if necessarry add a right column
769 \setpage
770 \def\page{\box255 } \normalbottom
771 \output={\nomarginoutput\page\lheader\rheader}
772 }
773 \ifbook
774 \let\crosssections=\relax
775 \else
776 \def\crosssections{
777 \plainsection{Crossreference of Code}% this is done when we are ending the index
778 \parindent 0pt
779 \parfillskip 0pt plus 1fil
780 \let\topsecno=\nullsec
781 \message{Crossreference of Code:}
782 \def\note##1##2.{\hfil\penalty-1\hfilneg\quad{\tiny##1~\ifbook##2\else
783 \ifpdf{\pdfnote##2.}\else
784 \ifhint\codenote##2.\else##2.\fi\fi\fi}}
785 \def\Q{\note{Cited in section}} % crossref for mention of a section
786 \def\Qs{\note{Cited in sections}} % crossref for mentions of a section
787 \def\U{\note{Used in}} % crossref for use of a section
788 \def\Us{\note{Used in}} % crossref for uses of a section
789 \def\I{\par\hangindent 2em}\let\*=*
790 \def\X##1:##2\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi %$% section name
791 \XX$\langle\,${\let\I=\ne##2}$\,\rangle$\XX\quad{\tiny Defined in~\codenote##1.}}
792 \readsections
793 }
794 \fi
795
796
797
798 %%
799 %% Table of Content
800 %%
801
802 % we separate the identification of a section used in links
803 %from the identification on paper, because plain sections dont
804 %have the latter.
805 \newcount\toccount
806 \toccount=0
807
808 \def\tocsection#1#2#3{% depth sectionnumber sectiontitle
809 \global\advance\toccount by 1%
810 \newdest{SC.\the\toccount}%
811 \ifhint
812 \immediate\write\cont{\noexpand\ZZ {#1}{#2}{#3}% write to contents file
813 {\noexpand\thepageno}{\the\toccount}}
814 \else
815 \edef\next{\write\cont{\noexpand\ZZ {#1}{#2}{#3}% write to contents file
816 {\noexpand\thepageno}{\the\toccount}}}\next % \tocline{depth}{sec}{title}{page}{toccount}
817 \fi
818 }
819
820 \output{
821 \ifhint
822 \shipout\box255\relax% otherwise I loose open, write, or close commands
823 \else
824 \setbox0=\page % the first page is garbage
825 \fi
826 % \openout\cont=\contentsfile
827 % \write\cont{\catcode `\noexpand\@=11\relax} % \makeatletter
828 \global\output{\normaloutput\page\lheader\rheader}}
829
830
831 \newbox\tocbox
832 \def\maketoc{%
833 \typeout{Reading table of contents}
834 \setbox\tocbox\vbox{%
835 \let\ZZ=\tocline
836 \ifbook\else\ifpdf\startpdf\fi\fi
837 \readcontents\relax
838 }
839 \typeout{Writing \contentsfile}
840 \immediate\openout\cont=\contentsfile\relax
841 \immediate\write\cont{\catcode `\noexpand\@=11\relax}
842 }
843
844 \def\tableofcontent{\plainsection{Contents}\ifhint\HINTdest name {HINT.home}\fi
845 \unvbox\tocbox
846 }
847
848
849 \def\tocline#1#2#3#4#5{% depth sectionnumber sectiontitle page toccount
850 \ifnum#1=0 \smallskip\vskip 0pt plus 12pt\penalty -100\vskip 0pt plus -12pt\fi
851 \noindent
852 \line{%
853 \ifnum#1=0%
854 \hbox to 2em{\bf#2\hfill}{\bf#3~}\hfill
855 \hbox to 2em{\hss\bf\tocref{#1}{#3}{#4}{#5}}%
856 \else \ifnum#1=1%
857 \kern 2em\hbox to 3em{\rm#2\hfill}{\rm#3~}\leaders\hbox to .5em{.\hfil}\hfill
858 \hbox to 2em{\hss\tocref{#1}{#3}{#4}{#5}}%
859 \else
860 \kern 2em\hbox to 5em{\rm#2\hfill}{\it#3~}\leaders\hbox to .5em{.\hfil}\hfill
861 \hbox to 2em{\hss\tocref{#1}{#3}{#4}{#5}}\fi\fi
862 }}
863
864
865
866 %%
867 %% Figures and Tables
868 %%
869
870 \def\fig#1{\global\advance\figcount by 1%
871 \ifvmode\noindent\fi
872 \def\captype{Fig}%
873 \capskip=1em%
874 \vbox{\nointerlineskip\figdest
875 \hbox{\noindent#1\hskip -2pt\hskip 0pt plus 2pt minus 2pt}%
876 \medskip
877 \rlap{\small\unhbox\capbox}%
878 }}
879
880 \def\tab#1{%
881 \ifvmode\noindent\fi
882 \def\captype{Tab}%
883 \capskip=0pt%
884 \vbox{#1\medskip\rlap{\small\unhbox\capbox}}}
885
886 \def\table#1#2{\global\advance\tabcount by 1%
887 \ifvmode\noindent\fi
888 \def\captype{Tab}%
889 \capskip=0pt%
890 \vbox{\offinterlineskip\tabdest
891 \halign{\large\strut
892 \vrule##&&\quad\hfil##\hfil\quad\vrule\cr
893 \noalign{\hrule}#2\noalign{\hrule}}%
894 \medskip
895 \tabcaption{#1}%
896 \rlap{\small\unhbox\capbox}%
897 }%
898 }
899
900 \def\captype{}
901 \newdimen\capskip
902 \capskip=1em
903 \newbox\capbox
904 \setbox\capbox\hbox{}
905 \newcount\figcount
906 \figcount=0
907 \newcount\tabcount
908 \tabcount=0
909
910 \def\nextfigcaption#1{\small\strut\it\hskip\capskip\figindex{\captype}{\the\figcount}{#1}\captype.~\the\figcount:}
911
912 \def\caption#1{\global\setbox\capbox\hbox{\nextfigcaption{#1} #1}}
913
914 \def\nexttabcaption#1{\small\strut\it\hskip\capskip\tabindex{\captype}{\the\tabcount}{#1}\captype.~\the\tabcount:}
915 \def\tabcaption#1{\global\setbox\capbox\hbox{\nexttabcaption{#1} #1}}
916
917
918 %\long\def\leftfig#1#2#3{%
919 %\ifvmode\noindent\fi
920 %\def\captype{Fig}%
921 %\capskip=1em%
922 %\vbox{%
923 % \tabskip=0pt\halign to \hsize{%
924 % \vtop{\vskip 0pt\parskip=0pt\hsize=62.5mm\relax
925 % ##}\tabskip=5mm plus 2pt minus 2pt&
926 % \vtop{\vskip 0pt\parskip=0pt\hsize=62.5mm\relax##}\tabskip=0pt\cr
927 % #1&\capskip=0pt\nextfigcaption{#2} #3\cr}\medbreak}}
928
929 \long\def\leftright#1#2#3#4{%
930 \ifvmode\noindent\else\par\noindent\fi
931 \vbox{\nointerlineskip
932 \advance\hsize by -\leftskip\advance\hsize by -\rightskip%
933 \leftskip=0pt\rightskip=0pt%
934 \hbox to \hsize{\strut
935 \raise\ht\strutbox
936 \vtop{\vskip 0pt\parskip=0pt\hsize=#1\hsize\advance\hsize by -2.5mm\relax
937 \noindent\strut\ignorespaces#3\vfill}\hfil
938 \raise\ht\strutbox
939 \vtop{\vskip 0pt\parskip=0pt\hsize=#2\hsize\advance\hsize by -2.5mm\relax
940 \noindent\strut\ignorespaces#4\vfill}}}}
941
942
943 \long\def\leftfig#1#2#3{%
944 \def\captype{Fig}%
945 \capskip=0pt%
946 \leftright{0.5}{0.5}{#1\kern -2pt\hskip 2pt plus 2pt minus 2pt}{\nextfigcaption{#2}\strut #3}}
947
948
949 \def\subindex#1{%
950 \par\ifhmode\unskip\fi% end paragraph and remove vertical space
951 \vskip\abovesubsecskip% space above the subsection
952 \vskip 0pt plus 72pt% allow some empty space at the bottom
953 \penalty-200\vskip 0pt plus -72pt % room for stetching and a page break
954 \noindent{\bf\strut#1}%
955 \nobreak\vskip\belowsubsecskip% space after subsection
956 \everypar{{\setbox0=\lastbox}\everypar{}}% no indentation in the next paragraph
957 \ignorespaces
958 }
959
960 \newwrite\@figfile
961 \newwrite\@tabfile
962
963 \def\makefigindex{%
964 \immediate\openout\@figfile=\jobname.fig\relax
965 \def\figindex{\@bsphack\begingroup\@sanitize\@wrfigindex\@figfile}%
966 \immediate\openout\@tabfile=\jobname.tab\relax
967 \def\tabindex{\@bsphack\begingroup\@sanitize\@wrfigindex\@tabfile}%
968 \typeout{Writing index files \jobname.fig \jobname.tab}
969 }
970
971 \newdimen\iboxsize
972 \def\thefigindex{%
973
974 \immediate\closeout\@figfile\relax
975 \immediate\closeout\@tabfile\relax
976 %\small\baselineskip=11pt
977 \plainsection{List of Figures and Tables}
978 \makeatletter
979 \iboxsize=3.7em\relax
980 \subindex{Figures}
981 \def\indexentry##1##2##3##4{% captype, fig/tab count, caption, page
982 \noindent
983 \line{\hbox to \iboxsize{%
984 \rm##1.~##2:\hfil}{\rm ##3}\ \leaders\hbox to .5em{.\hfil}%
985 \hfill\hbox to 1.4em{\hss
986 \ifbook##4\else
987 \ifpdf
988 \pagelnk{##4}%
989 \else\ifhint\figlink{##2}
990 \else##4\fi\fi\fi
991 }}\par
992 }%
993 \input\jobname.fig\relax
994 \iboxsize=3.9em\relax
995 \subindex{Tables}
996 \def\indexentry##1##2##3##4{% captype, fig/tab count, caption, page
997 \noindent
998 \line{\hbox to \iboxsize{%
999 \rm##1.~##2:\hfil}{\rm ##3}\ \leaders\hbox to .5em{.\hfil}%
1000 \hfill\hbox to 1.4em{\hss
1001 \ifbook##4\else
1002 \ifpdf
1003 \pagelnk{##4}%
1004 \else\ifhint\tablink{##2}
1005 \else##4\fi\fi\fi
1006 }}\par
1007 }%
1008 \input\jobname.tab\relax
1009 \makefigindex
1010 }
1011
1012
1013 \def\@wrfigindex#1#2#3#4{% file, captype, fig/tab count, caption
1014 \xdef\gtempa{\write#1{\string\indexentry{#2}{#3}{#4}{\noexpand\thepageno}}}\endgroup\gtempa
1015 \if@nobreak\ifvmode\@nobreak\fi\fi\@esphack}
1016
1017 %%
1018 %% Format Definitions
1019 %%
1020
1021 %\newbox\codebox
1022 \newwrite\@getfile
1023 \newwrite\@putfile
1024 \newwrite\@redfile
1025 \newwrite\@wrtfile
1026
1027 \def\makecode{%
1028 \immediate\openout\@getfile=\jobname.get\relax
1029 \immediate\openout\@putfile=\jobname.put\relax
1030 \immediate\openout\@redfile=\jobname.red\relax
1031 \immediate\openout\@wrtfile=\jobname.wrt\relax
1032 \typeout{Writing index files \jobname.get \jobname.put \jobname.red \jobname.wrt}
1033 }
1034
1035 \def\thecodeindex{%
1036 \immediate\closeout\@getfile\relax
1037 \immediate\closeout\@putfile\relax
1038 \immediate\closeout\@redfile\relax
1039 \immediate\closeout\@wrtfile\relax
1040 \def\indexentry##1##2##3##4{% codecount, depth, pagenumber, section
1041 \ifnum##2=0 \smallskip\vskip 0pt plus 12pt\penalty -100\vskip 0pt plus -12pt\fi
1042 \noindent
1043 \line{%
1044 \ifnum##2=0##4\hfill
1045 \else\qquad\rm##4\ \leaders\hbox to .5em{.\hfil}\hfill
1046 \hbox to 1.4em{\hss\pagelnk{##3}}
1047 \fi
1048 }\par
1049 }%
1050 \section{Format Definitions}
1051 \makeatletter
1052 \subsection{Reading the Long Format}\label{codeindex}
1053 \input\jobname.red.srt\relax
1054 \subsection{Writing the Long Format}
1055 \input\jobname.wrt.srt\relax
1056 \subsection{Reading the Short Format}
1057 \input\jobname.get.srt\relax
1058 \subsection{Writing the Short Format}
1059 \input\jobname.put.srt\relax
1060 }
1061
1062
1063 \newcount\codecount
1064 \codecount=0
1065
1066 \ifhint
1067 \def\@wrcodeindex#1#2#3#4{% file, depth, pagenumber, [sub]sectionname
1068 \global\advance\indexcount by 1\indexdest
1069 \xdef\gtempa{\write#1{\string\indexentry{#3}{#2}{\the\indexcount}{#4}}}\endgroup\gtempa\@esphack
1070 }
1071 \else
1072 \def\@wrcodeindex#1#2#3#4{% file, depth, pagenumber, [sub]sectionname
1073 \xdef\gtempa{\write#1{\string\indexentry{#3}{#2}{\noexpand\thepageno}{#4}}}\endgroup\gtempa\@esphack
1074 }
1075 \fi
1076
1077 \def\getindex{\@bsphack\begingroup\@sanitize\@wrcodeindex\@getfile}%
1078 \def\putindex{\@bsphack\begingroup\@sanitize\@wrcodeindex\@putfile}%
1079 \def\redindex{\@bsphack\begingroup\@sanitize\@wrcodeindex\@redfile}%
1080 \def\wrtindex{\@bsphack\begingroup\@sanitize\@wrcodeindex\@wrtfile}%
1081
1082
1083 \def\codelabel#1#2#3{
1084 \getindex{#1}{#2}{#3}%
1085 \putindex{#1}{#2}{#3}%
1086 \redindex{#1}{#2}{#3}%
1087 \wrtindex{#1}{#2}{#3}}
1088 \def\getsymbol{$\cdots\Longrightarrow$}
1089 \def\putsymbol{$\Longrightarrow\cdots$}
1090 \def\redsymbol{$-{}-{}-{}\Longrightarrow$}
1091 \def\wrtsymbol{$\Longrightarrow{}-{}-{}-$}
1092 \def\getcode{\codesection{\getsymbol}{Reading the short format}\getindex{1}{\the\codecount}{\subcodetitle}}
1093 \def\putcode{\codesection{\putsymbol}{Writing the short format}\putindex{1}{\the\codecount}{\subcodetitle}}
1094 \def\writecode{\codesection{\wrtsymbol}{Writing the long format}\wrtindex{1}{\the\codecount}{\subcodetitle}}
1095 \def\readcode{\codesection{\redsymbol}{Reading the long format}\redindex{1}{\the\codecount}{\subcodetitle}}
1096 \newdimen\coderule
1097 \def\codesection#1#2{%
1098 \par\ifhmode\unskip\fi% end paragraph and remove vertical space
1099 \penalty-200
1100 \vskip 0pt plus 72pt% allow some empty space at the bottom
1101 \penalty-200
1102 \vskip 0pt plus -72pt% room for stetching and a page break
1103 \vskip\abovesubsecskip% space above the subsection
1104 %\line{\setbox0=\hbox{#1}%
1105 %\coderule=\hsize\advance\coderule by -\wd0\advance\coderule by -2em%
1106 %$\vcenter{\hrule width \coderule}$\hss\box0}
1107 \line{{\it #2\/}:\hfill#1}
1108 \nobreak\vskip\belowsubsecskip\nobreak% space after subsection
1109 %\everypar{{\setbox0=\lastbox}\everypar{}}% no indentation in the next paragraph
1110 %\noindent
1111 \ignorespaces}
1112
1113 \def\hascode{\global\advance\codecount by 1%
1114 \codelabel{0}{\the\codecount}{\codetitle}}%
1115
1116
1117 %%
1118 %% Makeindex and the Index
1119 %%
1120
1121 \newwrite\@indexfile
1122
1123 % new jobname for index file
1124 \def\makeindex{
1125 \immediate\openout\@indexfile=\jobname.inx%
1126 \def\index{\@bsphack\begingroup\@sanitize\@wrindex\@indexfile}%
1127 \typeout{Writing index file \jobname.inx }%
1128 }
1129
1130 \def\@idxitem{\par\hangindent 40pt}
1131
1132 \newif\ifnextindex
1133 \nextindexfalse
1134
1135 \def\beginindex{%
1136 \ifhint\relax\else
1137 \def\page{\box255} \normalbottom
1138 \output{\ifpagesaved\normaloutput{\box\sbox}\lheader\rheader\fi
1139 \global\setbox\sbox=\page \global\pagesavedtrue}
1140 \pagesavedfalse \eject % eject the page-so-far and predecessors
1141 \setbox\sbox\vbox{\unvbox\sbox} % take it out of its box
1142 \vsize=\pageheight \advance\vsize by -\ht\sbox % the remaining height
1143 \hsize=.5\pagewidth \advance\hsize by -10pt
1144 % column width for the index (20pt between cols)
1145 \parfillskip 0pt plus .6\hsize % try to avoid almost empty lines
1146 \def\lr{L} % this tells whether the left or right column is next
1147 \output{\if L\lr\global\setbox\lbox=\page \gdef\lr{R}
1148 \else\nomarginoutput{\vbox to\pageheight{\box\sbox\vss
1149 \hbox to\pagewidth{\box\lbox\hfil\page}}}\lheader\rheader
1150 \global\nextindextrue
1151 \global\vsize\pageheight\gdef\lr{L}\global\pagesavedfalse\fi}
1152 \fi
1153 \message{Index:}
1154 \mark{{0}{0}}
1155 \noindent\par
1156 \begingroup
1157 \rightskip 0pt plus 12pt
1158 \parskip 0pt plus .5pt
1159 \hyphenpenalty 10000 \parindent0pt
1160 \small\baselineskip=11pt
1161 \def\item{\par\hangindent 40pt\relax\ifnextindex\mark{{Index}{Index}}\fi}%
1162 \def\subitem{\par\hangindent 40pt\hskip 20pt\relax}%
1163 \def\subsubitem{\par\hangindent 40pt\hskip 30pt\relax}%
1164 \def\indexspace{\par\vskip 12pt plus 6pt minus 4pt\vskip 12pt\goodbreak\vskip -12pt\relax}%
1165 \def\indexheading##1{{\tenbf ##1}\nobreak\vskip 3pt\relax}
1166 }
1167 \def\endindex{%
1168 \endgroup
1169 \vfill\eject % complete the current column.
1170 \ifhint\relax\else
1171 \if R\lr\null\vfill\eject\fi % if necessarry add a right column
1172 \fi
1173 }
1174
1175
1176 %%
1177 %% Label page, section, toccount, figure, table, code, enum
1178 %%
1179 \newcount\cdcount
1180 \cdcount=0
1181
1182 \newdimen\labelskip
1183 \def\label#1{% writes \labeldef{name}{{page}{section}{toccount}{figure}{table}{code}{enum}} to aux
1184 \ifhint
1185 \global\advance\indexcount by 1\indexdest
1186 \begingroup\@readauxfile
1187 \edef\next{\@writeaux{\string\labeldef{#1}{{\the\indexcount}%
1188 {\thesection}{\the\toccount}{\the\figcount}{\the\tabcount}{\the\cdcount}{\the\enum}}}\endgroup}%
1189 \else
1190 \begingroup\@readauxfile
1191 \edef\next{\@writeaux{\string\labeldef{#1}{{\noexpand\thepageno}%
1192 {\thesection}{\the\toccount}{\the\figcount}{\the\tabcount}{\the\cdcount}{\the\enum}}}\endgroup}%
1193 \fi
1194 \ifvmode %make \removelastskip work after \label
1195 \labelskip=\lastskip
1196 \vskip-\labelskip
1197 \next
1198 \vskip\labelskip
1199 \else
1200 \next
1201 \fi
1202 }
1203
1204
1205 \def\m@kelabel#1{label@#1}% this makes the controlseqence from the name
1206
1207 \def\labeldef#1#2{% #1 is name #2 is page section subsection figure table code
1208 \expandafter\gdef\csname\m@kelabel{#1}\endcsname{#2}}%
1209
1210 \def\@setref#1#2#3{%
1211 \ifx#1\relax
1212 \message{Undefined reference: #3}
1213 \else
1214 \expandafter#2#1%
1215 \fi}
1216
1217 \def\@iofvii#1#2#3#4#5#6#7{#1}
1218 \def\@iiofvii#1#2#3#4#5#6#7{#2}
1219 \def\@iiiofvii#1#2#3#4#5#6#7{#3}
1220 \def\@ivofvii#1#2#3#4#5#6#7{#4}
1221 \def\@vofvii#1#2#3#4#5#6#7{#5}
1222 \def\@viofvii#1#2#3#4#5#6#7{#6}
1223 \def\@viiofvii#1#2#3#4#5#6#7{#7}
1224
1225
1226 \def\pageref#1{\@readauxfile
1227 \pagelnk{\expandafter\@setref\csname\m@kelabel{#1}\endcsname\@iofvii{#1}}}
1228 \def\secref#1{\@readauxfile
1229 \sectionlink
1230 {\expandafter\@setref\csname\m@kelabel{#1}\endcsname\@iiofvii{#1}}%
1231 {\expandafter\@setref\csname\m@kelabel{#1}\endcsname\@iiiofvii{#1}}%
1232 }
1233 \def\figref#1{\@readauxfile
1234 \figlink{\expandafter\@setref\csname\m@kelabel{#1}\endcsname\@ivofvii{#1}}}
1235 \def\tabref#1{\@readauxfile
1236 \tablink{\expandafter\@setref\csname\m@kelabel{#1}\endcsname\@vofvii{#1}}}
1237 \def\cdref#1{\@readauxfile
1238 \expandafter\@setref\csname\m@kelabel{#1}\endcsname\@viofvii{#1}}
1239 \def\enumref#1{\@readauxfile
1240 \enumlink{\expandafter\@setref\csname\m@kelabel{#1}\endcsname\@viiofvii{#1}}}
1241
1242 %%
1243 %% Links and Destinations
1244 %%
1245
1246 \ifbook
1247 \def\pdflinkcolor{0 0 0} % the RGB values for hyperlink color
1248 \def\linkcolor{\Black}
1249 \def\pdflink#1#2{#1}
1250 \def\pdfnote#1.{#1}
1251 \message{No PDF Links}
1252 \else
1253 \def\pdflinkcolor{0 0 1} % the RGB values for hyperlink color
1254 \def\linkcolor{\Blue}
1255 \message{PDF Links are blue}
1256 \fi
1257
1258 \def\@esphack{\relax\ifhmode\spacefactor\@savsf
1259 {}\ifdim \@savsk >\z@ \ignorespaces
1260 \fi \fi}
1261
1262 %
1263 % Code destinations: by number
1264 %
1265
1266 %The number is set be \M and \N and stored as \secno
1267 %The destination is set in \X when we go into C mode
1268 \def\codedest{%
1269 \ifbook\else
1270 \ifhint\HINTdest num \thecode top\relax
1271 \else\ifpdf\pdfdest num \thecode fith\relax
1272 \else\relax
1273 \fi\fi\fi
1274 }
1275 \def\coderef#1{% used in \X
1276 \ifbook${}_{#1}$\else
1277 \ifhint\HINTstartlink goto num #1\lower 1.5pt\hbox{\sevenrm #1}\,\HINTendlink
1278 \else\ifpdf{\eightrm\pdfnote#1.}
1279 \else${}_{#1}$\fi\fi\fi
1280 }
1281
1282 \def\codenote#1.{% replaces \pdfnote
1283 \setbox0=\hbox{\toksA={#1.}\toksB={}\maketoks}\the\toksA}
1284 % define the following like for pdf
1285 \def\firstsecno#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}%
1286 \def\makenote{\addtokens\toksB{\the\toksC}\def\makenote{\toksD={}
1287 \toksC={}\let\space\empty}\makenote}\maketoks}}
1288 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1289 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}%
1290 \ifcat\noexpand\first0\countB=`#1\else\countB=0\fi\toksA={#2}}
1291 \def\maketoks{\expandafter\poptoks\the\toksA|ENDTOKS|%
1292 \ifnum\countB>`9 \countB=0 \fi
1293 \ifnum\countB<`0
1294 \ifnum0=\countC\else\makenote\fi
1295 \ifx\first.\let\next=\maketoksdone\else
1296 \let\next=\maketoks
1297 \addtokens\toksB{\the\toksD}
1298 \ifx\first,\addtokens\toksB{\space}\fi
1299 \fi
1300 \else \addtokens\toksC{\the\toksD}\global\countC=1\let\next=\maketoks
1301 \fi
1302 \next
1303 }
1304 \def\makenote{\addtokens\toksB
1305 {\noexpand\codelink{\the\toksC}{\romannumeral\the\toksC}}\toksC={}\global\countC=0}
1306 \def\maketoksdone{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1307
1308 \def\codelink#1#2{
1309 \ifbook#1\else
1310 \ifhint\HINTstartlink goto num #1 #1\HINTendlink
1311 \else\ifpdf\pdflink{#1}{#2}%
1312 \else#1%
1313 \fi\fi\fi}
1314
1315 %
1316 % new destinations and links: by name
1317 %
1318
1319 \def\newdest#1{% used to make a new destination
1320 %\message{New destination #1}%
1321 \ifbook
1322 \else\ifpdf
1323 \pdfdest name {#1} fith%\message{Defining pdf label #1}%
1324 \else\ifhint
1325 \HINTdest name {#1}%\message{Defining HINT label #1}%
1326 \fi\fi\fi}
1327
1328 \def\newlink#1#2{%
1329 \ifbook #2\else
1330 \ifpdf
1331 \pdfstartlink goto name {#1}\linkcolor#2\Black\pdfendlink
1332 \else\ifhint
1333 \HINTstartlink goto name {#1}#2\HINTendlink
1334 \else
1335 #2%
1336 \fi\fi\fi
1337 }
1338
1339
1340 %SC.-\the\plaincount for plain sections
1341 %SC.\thesection for regular sections, with subsections and letters for the appendix
1342
1343 \def\tocref#1#2#3#4{% depth, title, page, label used in tocline
1344 \ifbook#3\else
1345 \ifpdf
1346 \pdfstartlink goto name {SC.#4}\relax \linkcolor#3\Black\pdfendlink
1347 \ifnum#1=0\pdfoutline goto name {SC.#4} {#2}\fi
1348 \else\ifhint
1349 \HINTstartlink goto name {SC.#4}\relax $\rightarrow$\HINTendlink
1350 \HINToutline goto name {SC.#4} depth #1 {#2}%
1351 \else
1352 #3%
1353 \fi\fi\fi
1354 }%
1355
1356 %
1357 % Page references from the index
1358 %
1359
1360 % \index{keyword} -> \@wrindex{file}{keyword} writes the nectessary information
1361 % makeindex produces the index and pages are enclosed in \hyperref{pagenumber}
1362 % Problems:
1363 % pagenumbers may be roman numerals in the frontmatter
1364 % hyperpage has to cope with 6 different formats
1365 % \hyperpage{50} a single page number
1366 % \hyperpage{51, 52} two numbers
1367 % \hyperpage{53--59} a page range
1368 % \hyperpage{xi} a roman numeral
1369 % \hyperpage{xi, xii} two numbers
1370 % \hyperpage{xi--xx} a page range
1371
1372
1373 % Writing the index file: in HINT replacing the page number by the index count
1374 \newcount\indexcount
1375 \def\theindexcount{\the\indexcount}
1376
1377 \ifhint
1378 \def\@wrindex#1#2{% file, keyword
1379 \global\advance\indexcount by 1\indexdest
1380 \immediate\write#1{\string
1381 \indexentry{#2:hyperpage}{\the\indexcount}}\endgroup
1382 \if@nobreak \ifvmode\@nobreak\fi\fi\@esphack}
1383 \else
1384 \def\@wrindex#1#2{%
1385 \xdef\gtempa{\write#1{\string
1386 \indexentry{#2:hyperpage}{\noexpand\thepageno}}}\endgroup\gtempa
1387 \if@nobreak \ifvmode\@nobreak\fi\fi\@esphack}
1388 \fi
1389
1390
1391 % for HINT and PDF we used hyperrange and hypercomma to split the
1392 % arguments into index/page numbers and then use pagelink
1393 \ifbook
1394 \def\hyperpage#1{#1}\else
1395 \ifhint
1396 \def\hyperpage#1{\hyperrange#1----+\relax}
1397 \else\ifpdf
1398 \def\hyperpage#1{\hyperrange#1----+\relax}
1399 \else
1400 \def\hyperpage#1{#1}
1401 \fi\fi\fi
1402
1403 %\def\indexlink#1{#1}
1404
1405 \def\hyperrange#1--#2--#3+{%
1406 \ifx\empty#2\empty%
1407 \hypercomma#1, ,+%
1408 \else\ifhint
1409 \pagelnk{#1}--\pagelink{#2}{$\leftarrow$}%
1410 \else
1411 \pagelnk{#1}--\pagelnk{#2}%
1412 \fi\fi}
1413
1414 \def\hypercomma#1, #2,#3+{%
1415 \ifx\empty#2\empty%
1416 \pagelnk{#1}%
1417 \else\ifhint%
1418 \pagelink{#1}{$\longrightarrow$}%
1419 \else
1420 \pagelnk{#1}%
1421 % I omit the second page number \ifpdf, \pagelnk{#2}\fi
1422 \fi\fi
1423 }
1424
1425
1426 %
1427 % Labels
1428 %
1429
1430 % section references from \secref use \sectionlink
1431 % for plainsections, we display the label name because there
1432 %is no section number.
1433
1434 \def\sectionlink#1#2{% \message{Sectionlink #1 : #2}%
1435 \ifbook#1\else
1436 \ifpdf
1437 \pdfstartlink goto name {SC.#2} \linkcolor#1\Black\pdfendlink
1438 \else\ifhint
1439 \HINTstartlink goto name {SC.#2}#1\HINTendlink
1440 \else
1441 #1%
1442 \fi\fi\fi
1443 }
1444
1445
1446 % page references from \label and \pageref use \pagelink as before
1447 \def\indexdest{\newdest{page.\the\indexcount}}
1448 \def\pagelnk#1{%
1449 \ifhint
1450 \pagelink{#1}{$\rightarrow$}%
1451 \else
1452 \pagelink{#1}{#1}%
1453 \fi
1454 }
1455 \def\pagelink#1#2{\newlink{page.#1}{#2}}
1456 % For hint the destination is generated with each \index and \label
1457 % Because of the roman numerals, for pdf files
1458 % the pdf destination is generated in the header using \pagelabel
1459
1460
1461 \ifbook\let\pagelabel=\relax\else
1462 \ifpdf
1463 \def\pagelabel{%\message{pagelabel=\thepageno}
1464 \pdfdest name {page.\thepageno} fitv\relax}
1465 \else
1466 \let\pagelabel=\relax
1467 \fi\fi
1468
1469 % references to Figures, Tables, Enumerations
1470 \def\figdest{\newdest{FI.\the\figcount}}
1471 \def\figlink#1{\newlink{FI.#1}{#1}}
1472 \def\tabdest{\newdest{TA.\the\tabcount}}
1473 \def\tablink#1{\newlink{TA.#1}{#1}}
1474 \def\enumdest{\newdest{EN.\the\enum}}
1475 \def\enumlink#1{\newlink{EN.#1}{#1}}
1476
1477 %
1478 % References to the bibliography
1479 %
1480 \def\citedest#1{\newdest{CI.#1}}
1481 \def\citelink#1{%\message{Citelink #1}%
1482 \newlink{CI.#1}{#1}}
1483
1484 \def\bblhook{%defined before reading the .bbl file
1485 \def\biblabelprint##1{%
1486 \citedest{##1}%
1487 \noindent
1488 \hbox to \biblabelwidth{%
1489 \biblabelprecontents
1490 \biblabelcontents{##1}%
1491 \biblabelpostcontents
1492 }%
1493 \kern\biblabelextraspace
1494 }%
1495 }
1496 \def\@onecitation#1\@@{%called for each citation
1497 \if@notfirstcitation
1498 \printbetweencitations
1499 \fi
1500 %
1501 \expandafter \ifx \csname\@citelabel{#1}\endcsname \relax
1502 \if@citewarning
1503 \message{\@linenumber Undefined citation `#1'.}%
1504 \fi
1505 % Give it a dummy definition:
1506 \expandafter\gdef\csname\@citelabel{#1}\endcsname{%
1507 {\tt
1508 \escapechar = -1
1509 \nobreak\hskip0pt
1510 \expandafter\string\csname#1\endcsname
1511 \nobreak\hskip0pt
1512 }%
1513 }%
1514 \fi
1515 % Now produce the text, whether it was undefined or not.
1516 \citelink{\csname\@citelabel{#1}\endcsname}%
1517 \@notfirstcitationtrue
1518 }%
1519 %%
1520 %% Images
1521 %%
1522
1523 \ifbook
1524 \def\includefig#1{\leavevmode\hbox{\immediate\pdfximage{image/#1.pdf}\pdfrefximage\pdflastximage}}
1525 \else\ifpdf
1526 \def\includefig#1{\leavevmode\hbox{\immediate\pdfximage{image/#1.pdf}\pdfrefximage\pdflastximage}}
1527 \else\ifhint
1528 \def\includefig#1{\HINTimage=image/#1.png\relax}
1529 \else
1530 \input epsf.tex
1531 \def\includefig#1{\epsfbox{image/#1.eps}}% this is a \leavevmode\hbox{...}
1532 \fi\fi\fi
1533
1534 \ifhint\eject\fi% hitex will remove empty pages that were introduced by cwebmac
1535 \makeatother