Oh GACK! src-clean doesn't quite work that easily since cleandist rebuilds the
[unix-history] / gnu / lib / libreadline / doc / texinfo.tex
CommitLineData
099e2042
AC
1%% TeX macros to handle texinfo files
2
3% Copyright (C) 1985, 1986, 1988, 1990, 1991 Free Software Foundation, Inc.
4
5%This texinfo.tex file is free software; you can redistribute it and/or
6%modify it under the terms of the GNU General Public License as
7%published by the Free Software Foundation; either version 1, or (at
8%your option) any later version.
9
10%This texinfo.tex file is distributed in the hope that it will be
11%useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12%of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13%General Public License for more details.
14
15%You should have received a copy of the GNU General Public License
16%along with this texinfo.tex file; see the file COPYING. If not, write
17%to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
18%USA.
19
20
21%In other words, you are welcome to use, share and improve this program.
22%You are forbidden to forbid anyone else to use, share and improve
23%what you give them. Help stamp out software-hoarding!
24
25\def\texinfoversion{2.41}
26\message{Loading texinfo package [Version \texinfoversion]:}
27\message{}
28
29% Print the version number if in a .fmt file.
30\everyjob{\message{[Texinfo version \texinfoversion]}\message{}}
31
32% Save some parts of plain tex whose names we will redefine.
33
34\let\ptexlbrace=\{
35\let\ptexrbrace=\}
36\let\ptexdots=\dots
37\let\ptexdot=\.
38\let\ptexstar=\*
39\let\ptexend=\end
40\let\ptexbullet=\bullet
41\let\ptexb=\b
42\let\ptexc=\c
43\let\ptexi=\i
44\let\ptext=\t
45\let\ptexl=\l
46\let\ptexL=\L
47
48\def\tie{\penalty 10000\ } % Save plain tex definition of ~.
49
50\message{Basics,}
51\chardef\other=12
52
53\hyphenation{ap-pen-dix}
54\hyphenation{mini-buf-fer mini-buf-fers}
55\hyphenation{eshell}
56
57% Margin to add to right of even pages, to left of odd pages.
58\newdimen \bindingoffset \bindingoffset=0pt
59\newdimen \normaloffset \normaloffset=\hoffset
60\newdimen\pagewidth \newdimen\pageheight
61\pagewidth=\hsize \pageheight=\vsize
62
63%---------------------Begin change-----------------------
64%
65% Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
66%
67\newdimen\cornerlong \newdimen\cornerthick
68\newdimen \topandbottommargin
69\newdimen \outerhsize \newdimen \outervsize
70\cornerlong=1pc\cornerthick=.3pt % These set size of cropmarks
71\outerhsize=7in
72\outervsize=9.5in
73\topandbottommargin=.75in
74%
75%---------------------End change-----------------------
76
77% \onepageout takes a vbox as an argument. Note that \pagecontents
78% does insertions itself, but you have to call it yourself.
79\chardef\PAGE=255 \output={\onepageout{\pagecontents\PAGE}}
80\def\onepageout#1{\hoffset=\normaloffset
81\ifodd\pageno \advance\hoffset by \bindingoffset
82\else \advance\hoffset by -\bindingoffset\fi
83{\escapechar=`\\\relax % makes sure backslash is used in output files.
84\shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
85{\let\hsize=\pagewidth \makefootline}}}%
86\advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
87
88
89% Here is a modification of the main output routine for Near East Publications
90% This provides right-angle cropmarks at all four corners.
91% The contents of the page are centerlined into the cropmarks,
92% and any desired binding offset is added as an \hskip on either
93% site of the centerlined box. (P. A. MacKay, 12 November, 1986)
94%
95\def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
96 \shipout
97 \vbox to \outervsize{\hsize=\outerhsize
98 \vbox{\line{\ewtop\hfill\ewtop}}
99 \nointerlineskip
100 \line{\vbox{\moveleft\cornerthick\nstop}
101 \hfill
102 \vbox{\moveright\cornerthick\nstop}}
103 \vskip \topandbottommargin
104 \centerline{\ifodd\pageno\hskip\bindingoffset\fi
105 \vbox{
106 {\let\hsize=\pagewidth \makeheadline}
107 \pagebody{#1}
108 {\let\hsize=\pagewidth \makefootline}}
109 \ifodd\pageno\else\hskip\bindingoffset\fi}
110 \vskip \topandbottommargin plus1fill minus1fill
111 \boxmaxdepth\cornerthick
112 \line{\vbox{\moveleft\cornerthick\nsbot}
113 \hfill
114 \vbox{\moveright\cornerthick\nsbot}}
115 \nointerlineskip
116 \vbox{\line{\ewbot\hfill\ewbot}}
117 }
118 \advancepageno
119 \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
120%
121% Do @cropmarks to get crop marks
122\def\cropmarks{\let\onepageout=\croppageout }
123
124\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
125{\catcode`\@ =11
126\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
127\dimen@=\dp#1 \unvbox#1
128\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
129\ifr@ggedbottom \kern-\dimen@ \vfil \fi}
130}
131
132%
133% Here are the rules for the cropmarks. Note that they are
134% offset so that the space between them is truly \outerhsize or \outervsize
135% (P. A. MacKay, 12 November, 1986)
136%
137\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
138\def\nstop{\vbox
139 {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
140\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
141\def\nsbot{\vbox
142 {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
143
144% Parse an argument, then pass it to #1.
145% The argument can be delimited with [...] or with "..." or braces
146% or it can be a whole line.
147% #1 should be a macro which expects
148% an ordinary undelimited TeX argument.
149
150\def\parsearg #1{\let\next=#1\begingroup\obeylines\futurelet\temp\parseargx}
151
152\def\parseargx{%
153\ifx \obeyedspace\temp \aftergroup\parseargdiscardspace \else%
154\aftergroup \parseargline %
155\fi \endgroup}
156
157{\obeyspaces %
158\gdef\parseargdiscardspace {\begingroup\obeylines\futurelet\temp\parseargx}}
159
160\gdef\obeyedspace{\ }
161
162\def\parseargline{\begingroup \obeylines \parsearglinex}
163{\obeylines %
164\gdef\parsearglinex #1^^M{\endgroup \next {#1}}}
165
166\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
167
168%% These are used to keep @begin/@end levels from running away
169%% Call \inENV within environments (after a \begingroup)
170\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
171\def\ENVcheck{%
172\ifENV\errmessage{Still within an environment. Type Return to continue.}
173\endgroup\fi} % This is not perfect, but it should reduce lossage
174
175% @begin foo is the same as @foo, for now.
176\newhelp\EMsimple{Type <Return> to continue}
177
178\outer\def\begin{\parsearg\beginxxx}
179
180\def\beginxxx #1{%
181\expandafter\ifx\csname #1\endcsname\relax
182{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
183\csname #1\endcsname\fi}
184
185%% @end foo executes the definition of \Efoo.
186%% foo can be delimited by doublequotes or brackets.
187
188\def\end{\parsearg\endxxx}
189
190\def\endxxx #1{%
191\expandafter\ifx\csname E#1\endcsname\relax
192\expandafter\ifx\csname #1\endcsname\relax
193\errmessage{Undefined command @end #1}\else
194\errorE{#1}\fi\fi
195\csname E#1\endcsname}
196\def\errorE#1{
197{\errhelp=\EMsimple \errmessage{@end #1 not within #1 environment}}}
198
199% Single-spacing is done by various environments.
200
201\newskip\singlespaceskip \singlespaceskip = \baselineskip
202\def\singlespace{%
203{\advance \baselineskip by -\singlespaceskip
204\kern \baselineskip}%
205\baselineskip=\singlespaceskip
206}
207
208%% Simple single-character @ commands
209
210% @@ prints an @
211% Kludge this until the fonts are right (grr).
212\def\@{{\tt \char '100}}
213
214% Define @` and @' to be the same as ` and '
215% but suppressing ligatures.
216\def\`{{`}}
217\def\'{{'}}
218
219% Used to generate quoted braces.
220
221\def\mylbrace {{\tt \char '173}}
222\def\myrbrace {{\tt \char '175}}
223\let\{=\mylbrace
224\let\}=\myrbrace
225
226% @: forces normal size whitespace following.
227\def\:{\spacefactor=1000 }
228
229% @* forces a line break.
230\def\*{\hfil\break\hbox{}\ignorespaces}
231
232% @. is an end-of-sentence period.
233\def\.{.\spacefactor=3000 }
234
235% @w prevents a word break
236\def\w #1{\hbox{#1}}
237
238% @group ... @end group forces ... to be all on one page.
239
240\def\group{\begingroup% \inENV ???
241\def \Egroup{\egroup\endgroup}
242\vbox\bgroup}
243
244% @need space-in-mils
245% forces a page break if there is not space-in-mils remaining.
246
247\newdimen\mil \mil=0.001in
248
249\def\need{\parsearg\needx}
250
251\def\needx #1{\par %
252% This method tries to make TeX break the page naturally
253% if the depth of the box does not fit.
254{\baselineskip=0pt%
255\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000
256\prevdepth=-1000pt
257}}
258
259% @br forces paragraph break
260
261\let\br = \par
262
263% @dots{} output some dots
264
265\def\dots{$\ldots$}
266
267% @page forces the start of a new page
268
269\def\page{\par\vfill\supereject}
270
271% @exdent text....
272% outputs text on separate line in roman font, starting at standard page margin
273
274\def\exdent{\errmessage{@exdent in filled text}}
275 % @lisp, etc, define \exdent locally from \internalexdent
276
277{\obeyspaces
278\gdef\internalexdent{\parsearg\exdentzzz}}
279
280\def\exdentzzz #1{{\advance \leftskip by -\lispnarrowing
281\advance \hsize by -\leftskip
282\advance \hsize by -\rightskip
283\leftline{{\rm#1}}}}
284
285% @include file insert text of that file as input.
286
287\def\include{\parsearg\includezzz}
288\def\includezzz #1{{\def\thisfile{#1}\input #1
289}}
290
291\def\thisfile{}
292
293% @center line outputs that line, centered
294
295\def\center{\parsearg\centerzzz}
296\def\centerzzz #1{{\advance\hsize by -\leftskip
297\advance\hsize by -\rightskip
298\centerline{#1}}}
299
300% @sp n outputs n lines of vertical space
301
302\def\sp{\parsearg\spxxx}
303\def\spxxx #1{\par \vskip #1\baselineskip}
304
305% @comment ...line which is ignored...
306% @c is the same as @comment
307% @ignore ... @end ignore is another way to write a comment
308
309\def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other%
310\parsearg \commentxxx}
311
312\def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 }
313
314\let\c=\comment
315
316% Prevent errors for section commands.
317% Used in @ignore and in failing conditionals.
318\def\ignoresections{%
319\let\chapter=\relax
320\let\unnumbered=\relax
321\let\top=\relax
322\let\unnumberedsec=\relax
323\let\unnumberedsection=\relax
324\let\unnumberedsubsec=\relax
325\let\unnumberedsubsection=\relax
326\let\unnumberedsubsubsec=\relax
327\let\unnumberedsubsubsection=\relax
328\let\section=\relax
329\let\subsec=\relax
330\let\subsubsec=\relax
331\let\subsection=\relax
332\let\subsubsection=\relax
333\let\appendix=\relax
334\let\appendixsec=\relax
335\let\appendixsection=\relax
336\let\appendixsubsec=\relax
337\let\appendixsubsection=\relax
338\let\appendixsubsubsec=\relax
339\let\appendixsubsubsection=\relax
340\let\contents=\relax
341\let\smallbook=\relax
342\let\titlepage=\relax
343}
344
345\def\ignore{\begingroup\ignoresections\ignorexxx}
346\long\def\ignorexxx #1\end ignore{\endgroup\ignorespaces}
347
348\def\direntry{\begingroup\direntryxxx}
349\long\def\direntryxxx #1\end direntry{\endgroup\ignorespaces}
350
351% Conditionals to test whether a flag is set.
352
353\outer\def\ifset{\begingroup\ignoresections\parsearg\ifsetxxx}
354
355\def\ifsetxxx #1{\endgroup
356\expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\ifsetfail
357\else \let\temp=\relax \fi
358\temp}
359\def\Eifset{}
360\def\ifsetfail{\begingroup\ignoresections\ifsetfailxxx}
361\long\def\ifsetfailxxx #1\end ifset{\endgroup\ignorespaces}
362
363\outer\def\ifclear{\begingroup\ignoresections\parsearg\ifclearxxx}
364
365\def\ifclearxxx #1{\endgroup
366\expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\relax
367\else \let\temp=\ifclearfail \fi
368\temp}
369\def\Eifclear{}
370\def\ifclearfail{\begingroup\ignoresections\ifclearfailxxx}
371\long\def\ifclearfailxxx #1\end ifclear{\endgroup\ignorespaces}
372
373% Some texinfo constructs that are trivial in tex
374
375\def\iftex{}
376\def\Eiftex{}
377\def\ifinfo{\begingroup\ignoresections\ifinfoxxx}
378\long\def\ifinfoxxx #1\end ifinfo{\endgroup\ignorespaces}
379
380\long\def\menu #1\end menu{}
381\def\asis#1{#1}
382
383% @math means output in math mode.
384% We don't use $'s directly in the definition of \math because control
385% sequences like \math are expanded when the toc file is written. Then,
386% we read the toc file back, the $'s will be normal characters (as they
387% should be, according to the definition of Texinfo). So we must use a
388% control sequence to switch into and out of math mode.
389%
390% This isn't quite enough for @math to work properly in indices, but it
391% seems unlikely it will ever be needed there.
392%
393\let\implicitmath = $
394\def\math#1{\implicitmath #1\implicitmath}
395
396\def\node{\ENVcheck\parsearg\nodezzz}
397\def\nodezzz#1{\nodexxx [#1,]}
398\def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
399\let\lastnode=\relax
400
401\def\donoderef{\ifx\lastnode\relax\else
402\expandafter\expandafter\expandafter\setref{\lastnode}\fi
403\let\lastnode=\relax}
404
405\def\unnumbnoderef{\ifx\lastnode\relax\else
406\expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
407\let\lastnode=\relax}
408
409\def\appendixnoderef{\ifx\lastnode\relax\else
410\expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
411\let\lastnode=\relax}
412
413\let\refill=\relax
414
415% @setfilename is done at the beginning of every texinfo file.
416% So open here the files we need to have open while reading the input.
417% This makes it possible to make a .fmt file for texinfo.
418\def\setfilename{%
419 \readauxfile
420 \opencontents
421 \openindices
422 \fixbackslash % Turn off hack to swallow `\input texinfo'.
423 \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
424 \comment % Ignore the actual filename.
425}
426
427\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
428
429\def\inforef #1{\inforefzzz #1,,,,**}
430\def\inforefzzz #1,#2,#3,#4**{See Info file \file{\losespace#3{}}, node \samp{\losespace#1{}}}
431\def\losespace #1{#1}
432
433\message{fonts,}
434
435% Font-change commands.
436
437%% Try out Computer Modern fonts at \magstephalf
438\font\tenrm=cmr10 scaled \magstephalf
439\font\tentt=cmtt10 scaled \magstephalf
440% Instead of cmb10, you many want to use cmbx10.
441% cmbx10 is a prettier font on its own, but cmb10
442% looks better when embedded in a line with cmr10.
443\font\tenbf=cmb10 scaled \magstephalf
444\font\tenit=cmti10 scaled \magstephalf
445\font\tensl=cmsl10 scaled \magstephalf
446\font\tensf=cmss10 scaled \magstephalf
447\def\li{\sf}
448\font\tensc=cmcsc10 scaled \magstephalf
449
450% Fonts for @defun, etc.
451\font\defbf=cmbx10 scaled \magstep1 %was 1314
452\font\deftt=cmtt10 scaled \magstep1
453\def\df{\let\tt=\deftt \defbf}
454
455% Fonts for indices and small examples.
456% We actually use the slanted font rather than the italic,
457% because texinfo normally uses the slanted fonts for that.
458\font\ninett=cmtt9
459\font\indit=cmsl9 \font\indrm=cmr9
460\let\indtt=\ninett
461\def\indbf{\indrm} \def\indsl{\indit}
462\def\indexfonts{\let\it=\indit \let\sl=\indsl \let\bf=\indbf \let\rm=\indrm
463\let\tt=\indtt}
464
465% Fonts for headings
466\font\chaprm=cmbx12 scaled \magstep2
467\font\chapit=cmti12 scaled \magstep2
468\font\chapsl=cmsl12 scaled \magstep2
469\font\chaptt=cmtt12 scaled \magstep2
470\font\chapsf=cmss12 scaled \magstep2
471\let\chapbf=\chaprm
472
473\font\secrm=cmbx12 scaled \magstep1
474\font\secit=cmti12 scaled \magstep1
475\font\secsl=cmsl12 scaled \magstep1
476\font\sectt=cmtt12 scaled \magstep1
477\font\secsf=cmss12 scaled \magstep1
478\font\secbf=cmbx12 scaled \magstep1
479
480% \font\ssecrm=cmbx10 scaled \magstep1 % This size an fontlooked bad.
481% \font\ssecit=cmti10 scaled \magstep1 % The letters were too crowded.
482% \font\ssecsl=cmsl10 scaled \magstep1
483% \font\ssectt=cmtt10 scaled \magstep1
484% \font\ssecsf=cmss10 scaled \magstep1
485
486%\font\ssecrm=cmb10 scaled 1315 % Note the use of cmb rather than cmbx.
487%\font\ssecit=cmti10 scaled 1315 % Also, the size is a little larger than
488%\font\ssecsl=cmsl10 scaled 1315 % being scaled magstep1.
489%\font\ssectt=cmtt10 scaled 1315
490%\font\ssecsf=cmss10 scaled 1315
491
492%\let\ssecbf=\ssecrm
493
494\font\ssecrm=cmbx12 scaled \magstephalf
495\font\ssecit=cmti12 scaled \magstephalf
496\font\ssecsl=cmsl12 scaled \magstephalf
497\font\ssectt=cmtt12 scaled \magstephalf
498\font\ssecsf=cmss12 scaled \magstephalf
499\font\ssecbf=cmbx12 scaled \magstephalf
500
501% Font for title
502% There seems to have been a confusion: two definitions of this font.
503% It is not clear why, or which one is better.
504\font\titlerm = cmbx12 scaled \magstep3
505\let\authorrm = \secrm
506
507\def\textfonts{\let\rm=\tenrm\let\it=\tenit\let\sl=\tensl\let\bf=\tenbf%
508\let\smallcaps=\tensc\let\sf=\tensf}
509\def\chapfonts{\let\rm=\chaprm\let\it=\chapit\let\sl=\chapsl\let\bf=\chapbf\let\tt=\chaptt\let\sf=\chapsf}
510\def\secfonts{\let\rm=\secrm\let\it=\secit\let\sl=\secsl\let\bf=\secbf\let\tt=\sectt\let\sf=\secsf}
511\def\subsecfonts{\let\rm=\ssecrm\let\it=\ssecit\let\sl=\ssecsl\let\bf=\ssecbf\let\tt=\ssectt\let\sf=\ssecsf}
512% Count depth in font-changes, for error checks
513\newcount\fontdepth \fontdepth=0
514
515% Fonts for short table of contents.
516\font\shortcontrm=cmr12
517\font\shortcontbf=cmbx12
518\font\shortcontsl=cmsl12
519
520%% Add scribe-like font environments, plus @l for inline lisp (usually sans
521%% serif) and @ii for TeX italic
522
523% \smartitalic{ARG} outputs arg in italics, followed by an italic correction
524% unless the following character is such as not to need one.
525\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
526\def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
527
528\let\i=\smartitalic
529\let\var=\smartitalic
530\let\dfn=\smartitalic
531\let\emph=\smartitalic
532\let\cite=\smartitalic
533
534\def\b#1{{\bf #1}}
535\let\strong=\b
536
537\def\t#1{{\tt \exhyphenpenalty=10000\rawbackslash \frenchspacing #1}\null}
538\let\ttfont = \t
539%\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
540\def\samp #1{`\tclose{#1}'\null}
541\def\key #1{{\tt \exhyphenpenalty=10000\uppercase{#1}}\null}
542\def\ctrl #1{{\tt \rawbackslash \hat}#1}
543
544\let\file=\samp
545
546% @code is a modification of @t,
547% which makes spaces the same size as normal in the surrounding text.
548\newdimen\tclosesave
549\newdimen\tcloserm
550\def\tclose#1{{\rm \tcloserm=\fontdimen2\font \tt \tclosesave=\fontdimen2\font
551\fontdimen2\font=\tcloserm
552% prevent breaking lines at hyphens.
553\exhyphenpenalty=10000
554\def\ {{\fontdimen2\font=\tclosesave{} }}%
555 \rawbackslash \frenchspacing #1\fontdimen2\font=\tclosesave}\null}
556\let\code=\tclose
557%\let\exp=\tclose %Was temporary
558
559% @kbd is like @code, except that if the argument is just one @key command,
560% then @kbd has no effect.
561
562\def\xkey{\key}
563\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
564\ifx\one\xkey\ifx\threex\three \key{#2}%
565\else\tclose{\look}\fi
566\else\tclose{\look}\fi}
567
568\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
569
570\def\l#1{{\li #1}\null} %
571
572\def\r#1{{\rm #1}} % roman font
573% Use of \lowercase was suggested.
574\def\sc#1{{\smallcaps#1}} % smallcaps font
575\def\ii#1{{\it #1}} % italic font
576
577\message{page headings,}
578
579\newskip\titlepagetopglue \titlepagetopglue = 1.5in
580\newskip\titlepagebottomglue \titlepagebottomglue = 2pc
581
582% First the title page. Must do @settitle before @titlepage.
583\def\titlefont#1{{\titlerm #1}}
584
585\newtoks\realeverypar
586\newif\ifseenauthor
587\newif\iffinishedtitlepage
588
589\def\titlepage{\begingroup \parindent=0pt \textfonts
590 \let\subtitlerm=\tenrm
591% I deinstalled the following change because \cmr12 is undefined.
592% This change was not in the ChangeLog anyway. --rms.
593% \let\subtitlerm=\cmr12
594 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
595 %
596 \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
597 %
598 % Leave some space at the very top of the page.
599 \vglue\titlepagetopglue
600 %
601 % Now you can print the title using @title.
602 \def\title{\parsearg\titlezzz}%
603 \def\titlezzz##1{\leftline{\titlefont{##1}}
604 % print a rule at the page bottom also.
605 \finishedtitlepagefalse
606 \vskip4pt \hrule height 4pt \vskip4pt}%
607 % No rule at page bottom unless we print one at the top with @title.
608 \finishedtitlepagetrue
609 %
610 % Now you can put text using @subtitle.
611 \def\subtitle{\parsearg\subtitlezzz}%
612 \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
613 %
614 % @author should come last, but may come many times.
615 \def\author{\parsearg\authorzzz}%
616 \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
617 {\authorfont \leftline{##1}}}%
618 %
619 % Most title ``pages'' are actually two pages long, with space
620 % at the top of the second. We don't want the ragged left on the second.
621 \let\oldpage = \page
622 \def\page{%
623 \iffinishedtitlepage\else
624 \finishtitlepage
625 \fi
626 \oldpage
627 \let\page = \oldpage
628 \hbox{}}%
629% \def\page{\oldpage \hbox{}}
630}
631
632\def\Etitlepage{%
633 \iffinishedtitlepage\else
634 \finishtitlepage
635 \fi
636 % It is important to do the page break before ending the group,
637 % because the headline and footline are only empty inside the group.
638 % If we use the new definition of \page, we always get a blank page
639 % after the title page, which we certainly don't want.
640 \oldpage
641 \endgroup
642 \HEADINGSon
643}
644
645\def\finishtitlepage{%
646 \vskip4pt \hrule height 2pt
647 \vskip\titlepagebottomglue
648 \finishedtitlepagetrue
649}
650
651%%% Set up page headings and footings.
652
653\let\thispage=\folio
654
655\newtoks \evenheadline % Token sequence for heading line of even pages
656\newtoks \oddheadline % Token sequence for heading line of odd pages
657\newtoks \evenfootline % Token sequence for footing line of even pages
658\newtoks \oddfootline % Token sequence for footing line of odd pages
659
660% Now make Tex use those variables
661\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline \else \the\evenheadline \fi}}
662\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline \else \the\evenfootline \fi}\HEADINGShook}
663\let\HEADINGShook=\relax
664
665% Commands to set those variables.
666% For example, this is what @headings on does
667% @evenheading @thistitle|@thispage|@thischapter
668% @oddheading @thischapter|@thispage|@thistitle
669% @evenfooting @thisfile||
670% @oddfooting ||@thisfile
671
672\def\evenheading{\parsearg\evenheadingxxx}
673\def\oddheading{\parsearg\oddheadingxxx}
674\def\everyheading{\parsearg\everyheadingxxx}
675
676\def\evenfooting{\parsearg\evenfootingxxx}
677\def\oddfooting{\parsearg\oddfootingxxx}
678\def\everyfooting{\parsearg\everyfootingxxx}
679
680{\catcode`\@=0 %
681
682\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
683\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
684\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
685
686\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
687\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
688\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
689
690\gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
691\gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
692\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
693\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
694
695\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
696\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
697\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
698
699\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
700\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
701\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
702
703\gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
704\gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
705\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
706\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
707%
708}% unbind the catcode of @.
709
710% @headings double turns headings on for double-sided printing.
711% @headings single turns headings on for single-sided printing.
712% @headings off turns them off.
713% @headings on same as @headings double, retained for compatibility.
714% @headings after turns on double-sided headings after this page.
715% @headings doubleafter turns on double-sided headings after this page.
716% @headings singleafter turns on single-sided headings after this page.
717% By default, they are off.
718
719\def\headings #1 {\csname HEADINGS#1\endcsname}
720
721\def\HEADINGSoff{
722\global\evenheadline={\hfil} \global\evenfootline={\hfil}
723\global\oddheadline={\hfil} \global\oddfootline={\hfil}}
724\HEADINGSoff
725% When we turn headings on, set the page number to 1.
726% For double-sided printing, put current file name in lower left corner,
727% chapter name on inside top of right hand pages, document
728% title on inside top of left hand pages, and page numbers on outside top
729% edge of all pages.
730\def\HEADINGSdouble{
731%\pagealignmacro
732\global\pageno=1
733\global\evenfootline={\hfil}
734\global\oddfootline={\hfil}
735\global\evenheadline={\line{\folio\hfil\thistitle}}
736\global\oddheadline={\line{\thischapter\hfil\folio}}
737}
738% For single-sided printing, chapter title goes across top left of page,
739% page number on top right.
740\def\HEADINGSsingle{
741%\pagealignmacro
742\global\pageno=1
743\global\evenfootline={\hfil}
744\global\oddfootline={\hfil}
745\global\evenheadline={\line{\thischapter\hfil\folio}}
746\global\oddheadline={\line{\thischapter\hfil\folio}}
747}
748\def\HEADINGSon{\HEADINGSdouble}
749
750\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
751\let\HEADINGSdoubleafter=\HEADINGSafter
752\def\HEADINGSdoublex{%
753\global\evenfootline={\hfil}
754\global\oddfootline={\hfil}
755\global\evenheadline={\line{\folio\hfil\thistitle}}
756\global\oddheadline={\line{\thischapter\hfil\folio}}
757}
758
759\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
760\def\HEADINGSsinglex{%
761\global\evenfootline={\hfil}
762\global\oddfootline={\hfil}
763\global\evenheadline={\line{\thischapter\hfil\folio}}
764\global\oddheadline={\line{\thischapter\hfil\folio}}
765}
766
767% Subroutines used in generating headings
768% Produces Day Month Year style of output.
769\def\today{\number\day\space
770\ifcase\month\or
771January\or February\or March\or April\or May\or June\or
772July\or August\or September\or October\or November\or December\fi
773\space\number\year}
774
775% Use this if you want the Month Day, Year style of output.
776%\def\today{\ifcase\month\or
777%January\or February\or March\or April\or May\or June\or
778%July\or August\or September\or October\or November\or December\fi
779%\space\number\day, \number\year}
780
781% @settitle line... specifies the title of the document, for headings
782% It generates no output of its own
783
784\def\thistitle{No Title}
785\def\settitle{\parsearg\settitlezzz}
786\def\settitlezzz #1{\gdef\thistitle{#1}}
787
788\message{tables,}
789
790% @tabs -- simple alignment
791
792% These don't work. For one thing, \+ is defined as outer.
793% So these macros cannot even be defined.
794
795%\def\tabs{\parsearg\tabszzz}
796%\def\tabszzz #1{\settabs\+#1\cr}
797%\def\tabline{\parsearg\tablinezzz}
798%\def\tablinezzz #1{\+#1\cr}
799%\def\&{&}
800
801% Tables -- @table, @ftable, @item(x), @kitem(x), @xitem(x).
802
803% default indentation of table text
804\newdimen\tableindent \tableindent=.8in
805% default indentation of @itemize and @enumerate text
806\newdimen\itemindent \itemindent=.3in
807% margin between end of table item and start of table text.
808\newdimen\itemmargin \itemmargin=.1in
809
810% used internally for \itemindent minus \itemmargin
811\newdimen\itemmax
812
813% Note @table and @ftable define @item, @itemx, etc., with these defs.
814% They also define \itemindex
815% to index the item name in whatever manner is desired (perhaps none).
816
817\def\internalBitem{\smallbreak \parsearg\itemzzz}
818\def\internalBitemx{\par \parsearg\itemzzz}
819
820\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
821\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz}
822
823\def\internalBkitem{\smallbreak \parsearg\kitemzzz}
824\def\internalBkitemx{\par \parsearg\kitemzzz}
825
826\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}\itemzzz {#1}}
827
828\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}\itemzzz {#1}}
829
830\def\itemzzz #1{\begingroup %
831\advance \hsize by -\rightskip %
832\advance \hsize by -\leftskip %
833\setbox0=\hbox{\itemfont{#1}}%
834\itemindex{#1}%
835\parskip=0in %
836\noindent %
837\ifdim \wd0>\itemmax %
838\vadjust{\penalty 10000}%
839\hbox to \hsize{\hskip -\tableindent\box0\hss}\ %
840\else %
841\hbox to 0pt{\hskip -\tableindent\box0\hss}%
842\fi %
843\endgroup %
844}
845
846\def\item{\errmessage{@item while not in a table}}
847\def\itemx{\errmessage{@itemx while not in a table}}
848\def\kitem{\errmessage{@kitem while not in a table}}
849\def\kitemx{\errmessage{@kitemx while not in a table}}
850\def\xitem{\errmessage{@xitem while not in a table}}
851\def\xitemx{\errmessage{@xitemx while not in a table}}
852
853%% Contains a kludge to get @end[description] to work
854\def\description{\tablez{\dontindex}{1}{}{}{}{}}
855
856\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
857{\obeylines\obeyspaces%
858\gdef\tablex #1^^M{%
859\tabley\dontindex#1 \endtabley}}
860
861\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
862{\obeylines\obeyspaces%
863\gdef\ftablex #1^^M{%
864\tabley\fnitemindex#1 \endtabley
865\def\Eftable{\endgraf\endgroup\afterenvbreak}%
866\let\Etable=\relax}}
867
868\def\dontindex #1{}
869\def\fnitemindex #1{\doind {fn}{\code{#1}}}%
870
871{\obeyspaces %
872\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
873\tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
874
875\def\tablez #1#2#3#4#5#6{%
876\aboveenvbreak %
877\begingroup %
878\def\Edescription{\Etable}% Neccessary kludge.
879\let\itemindex=#1%
880\ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
881\ifnum 0#4>0 \tableindent=#4\mil \fi %
882\ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
883\def\itemfont{#2}%
884\itemmax=\tableindent %
885\advance \itemmax by -\itemmargin %
886\advance \leftskip by \tableindent %
887\parindent = 0pt
888\parskip = \smallskipamount
889\ifdim \parskip=0pt \parskip=2pt \fi%
890\def\Etable{\endgraf\endgroup\afterenvbreak}%
891\let\item = \internalBitem %
892\let\itemx = \internalBitemx %
893\let\kitem = \internalBkitem %
894\let\kitemx = \internalBkitemx %
895\let\xitem = \internalBxitem %
896\let\xitemx = \internalBxitemx %
897}
898
899% This is the counter used by @enumerate, which is really @itemize
900
901\newcount \itemno
902
903\def\itemize{\parsearg\itemizezzz}
904
905\def\itemizezzz #1{\itemizey {#1}{\Eitemize}}
906
907\def\itemizey #1#2{%
908\aboveenvbreak %
909\begingroup %
910\itemno = 0 %
911\itemmax=\itemindent %
912\advance \itemmax by -\itemmargin %
913\advance \leftskip by \itemindent %
914\parindent = 0pt
915\parskip = \smallskipamount
916\ifdim \parskip=0pt \parskip=2pt \fi%
917\def#2{\endgraf\endgroup\afterenvbreak}%
918\def\itemcontents{#1}%
919\let\item=\itemizeitem}
920
921\def\bullet{$\ptexbullet$}
922\def\minus{$-$}
923
924% Set sfcode to normal for the chars that usually have another value.
925% These are `.?!:;,'
926\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
927 \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
928
929\def\enumerate{\itemizey{\the\itemno.}\Eenumerate\flushcr}
930
931% Definition of @item while inside @itemize.
932
933\def\itemizeitem{%
934\advance\itemno by 1
935{\let\par=\endgraf \smallbreak}%
936\ifhmode \errmessage{\in hmode at itemizeitem}\fi
937{\parskip=0in \hskip 0pt
938\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
939\vadjust{\penalty 300}}%
940\flushcr}
941
942\message{indexing,}
943% Index generation facilities
944
945% Define \newwrite to be identical to plain tex's \newwrite
946% except not \outer, so it can be used within \newindex.
947{\catcode`\@=11
948\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
949
950% \newindex {foo} defines an index named foo.
951% It automatically defines \fooindex such that
952% \fooindex ...rest of line... puts an entry in the index foo.
953% It also defines \fooindfile to be the number of the output channel for
954% the file that accumulates this index. The file's extension is foo.
955% The name of an index should be no more than 2 characters long
956% for the sake of vms.
957
958\def\newindex #1{
959\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
960\openout \csname#1indfile\endcsname \jobname.#1 % Open the file
961\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex
962\noexpand\doindex {#1}}
963}
964
965% @defindex foo == \newindex{foo}
966
967\def\defindex{\parsearg\newindex}
968
969% Define @defcodeindex, like @defindex except put all entries in @code.
970
971\def\newcodeindex #1{
972\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
973\openout \csname#1indfile\endcsname \jobname.#1 % Open the file
974\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex
975\noexpand\docodeindex {#1}}
976}
977
978\def\defcodeindex{\parsearg\newcodeindex}
979
980% @synindex foo bar makes index foo feed into index bar.
981% Do this instead of @defindex foo if you don't want it as a separate index.
982\def\synindex #1 #2 {%
983\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
984\expandafter\let\csname#1indfile\endcsname=\synindexfoo
985\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex
986\noexpand\doindex {#2}}%
987}
988
989% @syncodeindex foo bar similar, but put all entries made for index foo
990% inside @code.
991\def\syncodeindex #1 #2 {%
992\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
993\expandafter\let\csname#1indfile\endcsname=\synindexfoo
994\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex
995\noexpand\docodeindex {#2}}%
996}
997
998% Define \doindex, the driver for all \fooindex macros.
999% Argument #1 is generated by the calling \fooindex macro,
1000% and it is "foo", the name of the index.
1001
1002% \doindex just uses \parsearg; it calls \doind for the actual work.
1003% This is because \doind is more useful to call from other macros.
1004
1005% There is also \dosubind {index}{topic}{subtopic}
1006% which makes an entry in a two-level index such as the operation index.
1007
1008\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
1009\def\singleindexer #1{\doind{\indexname}{#1}}
1010
1011% like the previous two, but they put @code around the argument.
1012\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
1013\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
1014
1015\def\indexdummies{%
1016\def\_{{\realbackslash normalunderscore}}%
1017\def\w{\realbackslash w }%
1018\def\bf{\realbackslash bf }%
1019\def\rm{\realbackslash rm }%
1020\def\sl{\realbackslash sl }%
1021\def\sf{\realbackslash sf}%
1022\def\tt{\realbackslash tt}%
1023\def\gtr{\realbackslash gtr}%
1024\def\less{\realbackslash less}%
1025\def\hat{\realbackslash hat}%
1026\def\char{\realbackslash char}%
1027\def\TeX{\realbackslash TeX}%
1028\def\dots{\realbackslash dots }%
1029\def\copyright{\realbackslash copyright }%
1030\def\tclose##1{\realbackslash tclose {##1}}%
1031\def\code##1{\realbackslash code {##1}}%
1032\def\samp##1{\realbackslash samp {##1}}%
1033\def\t##1{\realbackslash r {##1}}%
1034\def\r##1{\realbackslash r {##1}}%
1035\def\i##1{\realbackslash i {##1}}%
1036\def\b##1{\realbackslash b {##1}}%
1037\def\cite##1{\realbackslash cite {##1}}%
1038\def\key##1{\realbackslash key {##1}}%
1039\def\file##1{\realbackslash file {##1}}%
1040\def\var##1{\realbackslash var {##1}}%
1041\def\kbd##1{\realbackslash kbd {##1}}%
1042}
1043
1044% \indexnofonts no-ops all font-change commands.
1045% This is used when outputting the strings to sort the index by.
1046\def\indexdummyfont#1{#1}
1047\def\indexdummytex{TeX}
1048\def\indexdummydots{...}
1049
1050\def\indexnofonts{%
1051\let\w=\indexdummyfont
1052\let\t=\indexdummyfont
1053\let\r=\indexdummyfont
1054\let\i=\indexdummyfont
1055\let\b=\indexdummyfont
1056\let\emph=\indexdummyfont
1057\let\strong=\indexdummyfont
1058\let\cite=\indexdummyfont
1059\let\sc=\indexdummyfont
1060%Don't no-op \tt, since it isn't a user-level command
1061% and is used in the definitions of the active chars like <, >, |...
1062%\let\tt=\indexdummyfont
1063\let\tclose=\indexdummyfont
1064\let\code=\indexdummyfont
1065\let\file=\indexdummyfont
1066\let\samp=\indexdummyfont
1067\let\kbd=\indexdummyfont
1068\let\key=\indexdummyfont
1069\let\var=\indexdummyfont
1070\let\TeX=\indexdummytex
1071\let\dots=\indexdummydots
1072}
1073
1074% To define \realbackslash, we must make \ not be an escape.
1075% We must first make another character (@) an escape
1076% so we do not become unable to do a definition.
1077
1078{\catcode`\@=0 \catcode`\\=\other
1079@gdef@realbackslash{\}}
1080
1081\let\indexbackslash=0 %overridden during \printindex.
1082
1083\def\doind #1#2{%
1084{\indexdummies % Must do this here, since \bf, etc expand at this stage
1085\count10=\lastpenalty %
1086\escapechar=`\\%
1087{\let\folio=0% Expand all macros now EXCEPT \folio
1088\def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
1089% so it will be output as is; and it will print as backslash in the indx.
1090%
1091% Now process the index-string once, with all font commands turned off,
1092% to get the string to sort the index by.
1093{\indexnofonts
1094\xdef\temp1{#2}%
1095}%
1096% Now produce the complete index entry. We process the index-string again,
1097% this time with font commands expanded, to get what to print in the index.
1098\edef\temp{%
1099\write \csname#1indfile\endcsname{%
1100\realbackslash entry {\temp1}{\folio}{#2}}}%
1101\temp }%
1102\penalty\count10}}
1103
1104\def\dosubind #1#2#3{%
1105{\indexdummies % Must do this here, since \bf, etc expand at this stage
1106\count10=\lastpenalty %
1107\escapechar=`\\%
1108{\let\folio=0%
1109\def\rawbackslashxx{\indexbackslash}%
1110%
1111% Now process the index-string once, with all font commands turned off,
1112% to get the string to sort the index by.
1113{\indexnofonts
1114\xdef\temp1{#2 #3}%
1115}%
1116% Now produce the complete index entry. We process the index-string again,
1117% this time with font commands expanded, to get what to print in the index.
1118\edef\temp{%
1119\write \csname#1indfile\endcsname{%
1120\realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
1121\temp }%
1122\penalty\count10}}
1123
1124% The index entry written in the file actually looks like
1125% \entry {sortstring}{page}{topic}
1126% or
1127% \entry {sortstring}{page}{topic}{subtopic}
1128% The texindex program reads in these files and writes files
1129% containing these kinds of lines:
1130% \initial {c}
1131% before the first topic whose initial is c
1132% \entry {topic}{pagelist}
1133% for a topic that is used without subtopics
1134% \primary {topic}
1135% for the beginning of a topic that is used with subtopics
1136% \secondary {subtopic}{pagelist}
1137% for each subtopic.
1138
1139% Define the user-accessible indexing commands
1140% @findex, @vindex, @kindex, @cindex.
1141
1142\def\findex {\fnindex}
1143\def\kindex {\kyindex}
1144\def\cindex {\cpindex}
1145\def\vindex {\vrindex}
1146\def\tindex {\tpindex}
1147\def\pindex {\pgindex}
1148
1149\def\cindexsub {\begingroup\obeylines\cindexsub}
1150{\obeylines %
1151\gdef\cindexsub "#1" #2^^M{\endgroup %
1152\dosubind{cp}{#2}{#1}}}
1153
1154% Define the macros used in formatting output of the sorted index material.
1155
1156% This is what you call to cause a particular index to get printed.
1157% Write
1158% @unnumbered Function Index
1159% @printindex fn
1160
1161\def\printindex{\parsearg\doprintindex}
1162
1163\def\doprintindex#1{\tex %
1164\dobreak \chapheadingskip {10000}
1165\catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
1166\catcode`\$=\other\catcode`\_=\other
1167\catcode`\~=\other
1168% The following don't help, since the chars were translated
1169% when the raw index was written, and their fonts were discarded
1170% due to \indexnofonts.
1171%\catcode`\"=\active
1172%\catcode`\^=\active
1173%\catcode`\_=\active
1174%\catcode`\|=\active
1175%\catcode`\<=\active
1176%\catcode`\>=\active
1177\def\indexbackslash{\rawbackslashxx}
1178\indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
1179\begindoublecolumns
1180\openin 1 \jobname.#1s
1181\ifeof 1
1182% \enddoublecolumns gets confused if there is no text in the index,
1183% and it loses the chapter title and the aux file entries for the index.
1184% The easiest way to prevent this problem is to make sure there is some text.
1185(Index is empty)
1186\else \closein 1 \input \jobname.#1s
1187\fi
1188\enddoublecolumns
1189\Etex}
1190
1191% These macros are used by the sorted index file itself.
1192% Change them to control the appearance of the index.
1193
1194% Same as \bigskipamount except no shrink.
1195% \balancecolumns gets confused if there is any shrink.
1196\newskip\initialskipamount \initialskipamount 12pt plus4pt
1197
1198\outer\def\initial #1{%
1199{\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
1200\ifdim\lastskip<\initialskipamount
1201\removelastskip \penalty-200 \vskip \initialskipamount\fi
1202\line{\secbf#1\hfill}\kern 2pt\penalty10000}}
1203
1204\outer\def\entry #1#2{
1205{\parfillskip=0in \parskip=0in \parindent=0in
1206\hangindent=1in \hangafter=1%
1207\noindent\hbox{#1}\indexdotfill #2\par
1208}}
1209
1210% Like \dotfill except takes at least 1 em.
1211\def\indexdotfill{\cleaders\hbox{$\mathsurround=0pt \mkern1.5mu . \mkern1.5mu$}\hskip 1em plus 1fill}
1212
1213\def\primary #1{\line{#1\hfil}}
1214
1215\newskip\secondaryindent \secondaryindent=0.5cm
1216
1217\def\secondary #1#2{
1218{\parfillskip=0in \parskip=0in
1219\hangindent =1in \hangafter=1
1220\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
1221}}
1222
1223%% Define two-column mode, which is used in indexes.
1224%% Adapted from the TeXBook, page 416
1225\catcode `\@=11
1226
1227\newbox\partialpage
1228
1229\newdimen\doublecolumnhsize \doublecolumnhsize = 3.11in
1230\newdimen\doublecolumnvsize \doublecolumnvsize = 19.1in
1231\newdimen\availdimen@
1232
1233\def\begindoublecolumns{\begingroup
1234 \output={\global\setbox\partialpage=\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}\eject
1235 \output={\doublecolumnout} \hsize=\doublecolumnhsize \vsize=\doublecolumnvsize}
1236\def\enddoublecolumns{\output={\balancecolumns}\eject
1237 \endgroup \pagegoal=\vsize}
1238
1239\def\doublecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth
1240 \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
1241 \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
1242 \onepageout\pagesofar \unvbox255 \penalty\outputpenalty}
1243\def\pagesofar{\unvbox\partialpage %
1244 \hsize=\doublecolumnhsize % have to restore this since output routine
1245% changes it to set cropmarks (P. A. MacKay, 12 Nov. 1986)
1246 \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
1247\def\balancecolumns{%
1248% Unset the glue.
1249 \setbox255=\vbox{\unvbox255}
1250 \dimen@=\ht255
1251 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
1252 \divide\dimen@ by2
1253 \availdimen@=\pageheight \advance\availdimen@ by-\ht\partialpage
1254% If the remaining data is too big for one page,
1255% output one page normally, then work with what remains.
1256 \ifdim \dimen@>\availdimen@
1257 {
1258 \splittopskip=\topskip \splitmaxdepth=\maxdepth
1259 \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
1260 \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
1261 \onepageout\pagesofar
1262 }
1263% Recompute size of what remains, in case we just output some of it.
1264 \dimen@=\ht255
1265 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
1266 \divide\dimen@ by2
1267 \fi
1268 \setbox0=\vbox{\unvbox255}
1269 \splittopskip=\topskip
1270 {\vbadness=10000 \loop \global\setbox3=\copy0
1271 \global\setbox1=\vsplit3 to\dimen@
1272 \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat}
1273 \setbox0=\vbox to\dimen@{\unvbox1} \setbox2=\vbox to\dimen@{\unvbox3}
1274 \pagesofar}
1275
1276\catcode `\@=\other
1277\message{sectioning,}
1278% Define chapters, sections, etc.
1279
1280\newcount \chapno
1281\newcount \secno
1282\newcount \subsecno
1283\newcount \subsubsecno
1284
1285% This counter is funny since it counts through charcodes of letters A, B, ...
1286\newcount \appendixno \appendixno = `\@
1287\def\appendixletter{\char\the\appendixno}
1288
1289\newwrite \contentsfile
1290% This is called from \setfilename.
1291\def\opencontents{\openout \contentsfile = \jobname.toc}
1292
1293% Each @chapter defines this as the name of the chapter.
1294% page headings and footings can use it. @section does likewise
1295
1296\def\thischapter{} \def\thissection{}
1297\def\seccheck#1{\if \pageno<0 %
1298\errmessage{@#1 not allowed after generating table of contents}\fi
1299%
1300}
1301
1302\def\chapternofonts{%
1303\let\rawbackslash=\relax%
1304\let\frenchspacing=\relax%
1305\def\TeX{\realbackslash TeX}
1306\def\dots{\realbackslash dots}
1307\def\copyright{\realbackslash copyright}
1308\def\tt{\realbackslash tt}
1309\def\bf{\realbackslash bf }
1310\def\w{\realbackslash w}
1311\def\less{\realbackslash less}
1312\def\gtr{\realbackslash gtr}
1313\def\hat{\realbackslash hat}
1314\def\char{\realbackslash char}
1315\def\tclose##1{\realbackslash tclose {##1}}
1316\def\code##1{\realbackslash code {##1}}
1317\def\samp##1{\realbackslash samp {##1}}
1318\def\r##1{\realbackslash r {##1}}
1319\def\b##1{\realbackslash b {##1}}
1320\def\key##1{\realbackslash key {##1}}
1321\def\file##1{\realbackslash file {##1}}
1322\def\kbd##1{\realbackslash kbd {##1}}
1323% These are redefined because @smartitalic wouldn't work inside xdef.
1324\def\i##1{\realbackslash i {##1}}
1325\def\cite##1{\realbackslash cite {##1}}
1326\def\var##1{\realbackslash var {##1}}
1327\def\emph##1{\realbackslash emph {##1}}
1328\def\dfn##1{\realbackslash dfn {##1}}
1329}
1330
1331\outer\def\chapter{\parsearg\chapterzzz}
1332\def\chapterzzz #1{\seccheck{chapter}%
1333\secno=0 \subsecno=0 \subsubsecno=0 \global\advance \chapno by 1 \message{Chapter \the\chapno}%
1334\chapmacro {#1}{\the\chapno}%
1335\gdef\thissection{#1}%
1336\gdef\thischaptername{#1}%
1337% We don't substitute the actual chapter name into \thischapter
1338% because we don't want its macros evaluated now.
1339\xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}%
1340{\chapternofonts%
1341\edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
1342\escapechar=`\\%
1343\write \contentsfile \temp %
1344\donoderef %
1345}}
1346
1347\outer\def\appendix{\parsearg\appendixzzz}
1348\def\appendixzzz #1{\seccheck{appendix}%
1349\secno=0 \subsecno=0 \subsubsecno=0 \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
1350\chapmacro {#1}{Appendix \appendixletter}%
1351\gdef\thissection{#1}%
1352\gdef\thischaptername{#1}%
1353\xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}%
1354{\chapternofonts%
1355\edef\temp{{\realbackslash chapentry {#1}{Appendix \appendixletter}{\noexpand\folio}}}%
1356\escapechar=`\\%
1357\write \contentsfile \temp %
1358\appendixnoderef %
1359}}
1360
1361\outer\def\top{\parsearg\unnumberedzzz}
1362\outer\def\unnumbered{\parsearg\unnumberedzzz}
1363\def\unnumberedzzz #1{\seccheck{unnumbered}%
1364\secno=0 \subsecno=0 \subsubsecno=0 \message{(#1)}
1365\unnumbchapmacro {#1}%
1366\gdef\thischapter{#1}\gdef\thissection{#1}%
1367{\chapternofonts%
1368\edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
1369\escapechar=`\\%
1370\write \contentsfile \temp %
1371\unnumbnoderef %
1372}}
1373
1374\outer\def\section{\parsearg\sectionzzz}
1375\def\sectionzzz #1{\seccheck{section}%
1376\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
1377\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
1378{\chapternofonts%
1379\edef\temp{{\realbackslash secentry %
1380{#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
1381\escapechar=`\\%
1382\write \contentsfile \temp %
1383\donoderef %
1384\penalty 10000 %
1385}}
1386
1387\outer\def\appendixsection{\parsearg\appendixsectionzzz}
1388\outer\def\appendixsec{\parsearg\appendixsectionzzz}
1389\def\appendixsectionzzz #1{\seccheck{appendixsection}%
1390\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
1391\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
1392{\chapternofonts%
1393\edef\temp{{\realbackslash secentry %
1394{#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
1395\escapechar=`\\%
1396\write \contentsfile \temp %
1397\appendixnoderef %
1398\penalty 10000 %
1399}}
1400
1401\outer\def\unnumberedsec{\parsearg\unnumberedseczzz}
1402\def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
1403\plainsecheading {#1}\gdef\thissection{#1}%
1404{\chapternofonts%
1405\edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
1406\escapechar=`\\%
1407\write \contentsfile \temp %
1408\unnumbnoderef %
1409\penalty 10000 %
1410}}
1411
1412\outer\def\subsection{\parsearg\subsectionzzz}
1413\def\subsectionzzz #1{\seccheck{subsection}%
1414\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
1415\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
1416{\chapternofonts%
1417\edef\temp{{\realbackslash subsecentry %
1418{#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
1419\escapechar=`\\%
1420\write \contentsfile \temp %
1421\donoderef %
1422\penalty 10000 %
1423}}
1424
1425\outer\def\appendixsubsec{\parsearg\appendixsubseczzz}
1426\def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
1427\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
1428\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
1429{\chapternofonts%
1430\edef\temp{{\realbackslash subsecentry %
1431{#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
1432\escapechar=`\\%
1433\write \contentsfile \temp %
1434\appendixnoderef %
1435\penalty 10000 %
1436}}
1437
1438\outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz}
1439\def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
1440\plainsecheading {#1}\gdef\thissection{#1}%
1441{\chapternofonts%
1442\edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
1443\escapechar=`\\%
1444\write \contentsfile \temp %
1445\unnumbnoderef %
1446\penalty 10000 %
1447}}
1448
1449\outer\def\subsubsection{\parsearg\subsubsectionzzz}
1450\def\subsubsectionzzz #1{\seccheck{subsubsection}%
1451\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
1452\subsubsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
1453{\chapternofonts%
1454\edef\temp{{\realbackslash subsubsecentry %
1455{#1}{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%\
1456\escapechar=`\\%
1457\write \contentsfile \temp %
1458\donoderef %
1459\penalty 10000 %
1460}}
1461
1462\outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz}
1463\def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
1464\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
1465\subsubsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
1466{\chapternofonts%
1467\edef\temp{{\realbackslash subsubsecentry{#1}%
1468{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%\
1469\escapechar=`\\%
1470\write \contentsfile \temp %
1471\appendixnoderef %
1472\penalty 10000 %
1473}}
1474
1475\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
1476\def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
1477\plainsecheading {#1}\gdef\thissection{#1}%
1478{\chapternofonts%
1479\edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
1480\escapechar=`\\%
1481\write \contentsfile \temp %
1482\unnumbnoderef %
1483\penalty 10000 %
1484}}
1485
1486% These are variants which are not "outer", so they can appear in @ifinfo.
1487\def\infotop{\parsearg\unnumberedzzz}
1488\def\infounnumbered{\parsearg\unnumberedzzz}
1489\def\infounnumberedsec{\parsearg\unnumberedseczzz}
1490\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
1491\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
1492
1493\def\infoappendix{\parsearg\appendixzzz}
1494\def\infoappendixsec{\parsearg\appendixseczzz}
1495\def\infoappendixsubsec{\parsearg\appendixsubseczzz}
1496\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
1497
1498\def\infochapter{\parsearg\chapterzzz}
1499\def\infosection{\parsearg\sectionzzz}
1500\def\infosubsection{\parsearg\subsectionzzz}
1501\def\infosubsubsection{\parsearg\subsubsectionzzz}
1502
1503% Define @majorheading, @heading and @subheading
1504
1505\def\majorheading{\parsearg\majorheadingzzz}
1506\def\majorheadingzzz #1{%
1507{\advance\chapheadingskip by 10pt \chapbreak }%
1508{\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 200}
1509
1510\def\chapheading{\parsearg\chapheadingzzz}
1511\def\chapheadingzzz #1{\chapbreak %
1512{\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 200}
1513
1514\def\heading{\parsearg\secheadingi}
1515
1516\def\subheading{\parsearg\subsecheadingi}
1517
1518\def\subsubheading{\parsearg\subsubsecheadingi}
1519
1520% These macros generate a chapter, section, etc. heading only
1521% (including whitespace, linebreaking, etc. around it),
1522% given all the information in convenient, parsed form.
1523
1524%%% Args are the skip and penalty (usually negative)
1525\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
1526
1527\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
1528
1529%%% Define plain chapter starts, and page on/off switching for it
1530% Parameter controlling skip before chapter headings (if needed)
1531
1532\newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
1533
1534\def\chapbreak{\dobreak \chapheadingskip {-4000}}
1535\def\chappager{\par\vfill\supereject}
1536\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
1537
1538\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
1539
1540\def\CHAPPAGoff{
1541\global\let\pchapsepmacro=\chapbreak
1542\global\let\pagealignmacro=\chappager}
1543
1544\def\CHAPPAGon{
1545\global\let\pchapsepmacro=\chappager
1546\global\let\pagealignmacro=\chappager
1547\global\def\HEADINGSon{\HEADINGSsingle}}
1548
1549\def\CHAPPAGodd{
1550\global\let\pchapsepmacro=\chapoddpage
1551\global\let\pagealignmacro=\chapoddpage
1552\global\def\HEADINGSon{\HEADINGSdouble}}
1553
1554\CHAPPAGon
1555
1556\def\CHAPFplain{
1557\global\let\chapmacro=\chfplain
1558\global\let\unnumbchapmacro=\unnchfplain}
1559
1560\def\chfplain #1#2{%
1561 \pchapsepmacro
1562 {%
1563 \chapfonts
1564 \leftline{\rm #2\enspace #1}%
1565 }%
1566 \bigskip
1567 \penalty5000
1568}
1569
1570\def\unnchfplain #1{%
1571\pchapsepmacro %
1572{\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 10000 %
1573}
1574\CHAPFplain % The default
1575
1576\def\unnchfopen #1{%
1577\chapoddpage {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 10000 %
1578}
1579
1580\def\chfopen #1#2{\chapoddpage {\chapfonts
1581\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
1582\par\penalty 5000 %
1583}
1584
1585\def\CHAPFopen{
1586\global\let\chapmacro=\chfopen
1587\global\let\unnumbchapmacro=\unnchfopen}
1588
1589% Parameter controlling skip before section headings.
1590
1591\newskip \subsecheadingskip \subsecheadingskip = 17pt plus 8pt minus 4pt
1592\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
1593
1594\newskip \secheadingskip \secheadingskip = 21pt plus 8pt minus 4pt
1595\def\secheadingbreak{\dobreak \secheadingskip {-1000}}
1596
1597
1598% Section fonts are the base font at magstep2, which produces
1599% a size a bit more than 14 points in the default situation.
1600
1601\def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
1602\def\plainsecheading #1{\secheadingi {#1}}
1603\def\secheadingi #1{{\advance \secheadingskip by \parskip %
1604\secheadingbreak}%
1605{\secfonts \line{\rm #1\hfill}}%
1606\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
1607
1608
1609% Subsection fonts are the base font at magstep1,
1610% which produces a size of 12 points.
1611
1612\def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}}
1613\def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip %
1614\subsecheadingbreak}%
1615{\subsecfonts \line{\rm #1\hfill}}%
1616\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
1617
1618\def\subsubsecfonts{\subsecfonts} % Maybe this should change:
1619 % Perhaps make sssec fonts scaled
1620 % magstep half
1621\def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}}
1622\def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip %
1623\subsecheadingbreak}%
1624{\subsubsecfonts \line{\rm #1\hfill}}%
1625\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
1626
1627
1628\message{toc printing,}
1629
1630% Finish up the main text and prepare to read what we've written
1631% to \contentsfile.
1632
1633\def\startcontents#1{%
1634 \ifnum \pageno>0
1635 \pagealignmacro
1636 \immediate\closeout \contentsfile
1637 \pageno = -1 % Request roman numbered pages.
1638 \fi
1639 % Don't need to put `Contents' or `Short Contents' in the headline.
1640 % It is abundantly clear what they are.
1641 \unnumbchapmacro{#1}\def\thischapter{}%
1642 \begingroup % Set up to handle contents files properly.
1643 \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11
1644 \raggedbottom % Worry more about breakpoints than the bottom.
1645 \advance\hsize by -1in % Don't use the full line length.
1646}
1647
1648
1649% Normal (long) toc.
1650\outer\def\contents{%
1651 \startcontents{Table of Contents}%
1652 \input \jobname.toc
1653 \endgroup
1654 \vfill \eject
1655}
1656
1657% And just the chapters.
1658\outer\def\summarycontents{%
1659 \startcontents{Short Contents}%
1660 %
1661 \let\chapentry = \shortchapentry
1662 \let\unnumbchapentry = \shortunnumberedentry
1663 % We want a true roman here for the page numbers.
1664 \secfonts
1665 \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
1666 \rm
1667 \advance\baselineskip by 1pt % Open it up a little.
1668 \def\secentry ##1##2##3##4{}
1669 \def\unnumbsecentry ##1##2{}
1670 \def\subsecentry ##1##2##3##4##5{}
1671 \def\unnumbsubsecentry ##1##2{}
1672 \def\subsubsecentry ##1##2##3##4##5##6{}
1673 \def\unnumbsubsubsecentry ##1##2{}
1674 \input \jobname.toc
1675 \endgroup
1676 \vfill \eject
1677}
1678\let\shortcontents = \summarycontents
1679
1680% These macros generate individual entries in the table of contents.
1681% The first argument is the chapter or section name.
1682% The last argument is the page number.
1683% The arguments in between are the chapter number, section number, ...
1684
1685% Chapter-level things, for both the long and short contents.
1686\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
1687\def\shortchapentry#1#2#3{%
1688 \line{{#2\labelspace #1}\dotfill\doshortpageno{#3}}%
1689}
1690
1691\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
1692\def\shortunnumberedentry#1#2{%
1693 \line{#1\dotfill\doshortpageno{#2}}%
1694}
1695
1696% Sections.
1697\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
1698\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
1699
1700% Subsections.
1701\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
1702\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
1703
1704% And subsubsections.
1705\def\subsubsecentry#1#2#3#4#5#6{\dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
1706\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
1707
1708
1709% This parameter controls the indentation of the various levels.
1710\newdimen\tocindent \tocindent = 3pc
1711
1712% Now for the actual typesetting. In all these, #1 is the text and #2 is the
1713% page number.
1714%
1715% If the toc has to be broken over pages, we would want to be at chapters
1716% if at all possible; hence the \penalty.
1717\def\dochapentry#1#2{%
1718 \penalty-300 \vskip\baselineskip
1719 \line{\chapentryfonts #1\dotfill \dopageno{#2}}%
1720 \nobreak\vskip .25\baselineskip
1721}
1722
1723\def\dosecentry#1#2{%
1724 \line{\secentryfonts \hskip\tocindent #1\dotfill \dopageno{#2}}%
1725}
1726
1727\def\dosubsecentry#1#2{%
1728 \line{\subsecentryfonts \hskip2\tocindent #1\dotfill \dopageno{#2}}%
1729}
1730
1731\def\dosubsubsecentry#1#2{%
1732 \line{\subsubsecentryfonts \hskip3\tocindent #1\dotfill \dopageno{#2}}%
1733}
1734
1735% Space between chapter (or whatever) number and the title.
1736\def\labelspace{\hskip1em \relax}
1737
1738\def\dopageno#1{{\rm #1}}
1739\def\doshortpageno#1{{\rm #1}}
1740
1741\def\chapentryfonts{\secfonts \rm}
1742\def\secentryfonts{\textfonts}
1743\let\subsecentryfonts = \textfonts
1744\let\subsubsecentryfonts = \textfonts
1745
1746
1747\message{environments,}
1748
1749% Since these characters are used in examples, it should be an even number of
1750% \tt widths. Each \tt character is 1en, so two makes it 1em.
1751% Furthermore, these definitions must come after we define our fonts.
1752\newbox\dblarrowbox \newbox\longdblarrowbox
1753\newbox\pushcharbox \newbox\bullbox
1754\newbox\equivbox \newbox\errorbox
1755
1756\let\ptexequiv = \equiv
1757
1758{\tentt
1759\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
1760\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
1761\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
1762\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
1763% Adapted from the manmac format (p.420 of TeXbook)
1764\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
1765 depth .1ex\hfil}
1766}
1767
1768\def\point{$\star$}
1769
1770\def\result{\leavevmode\raise.15ex\copy\dblarrowbox}
1771\def\expansion{\leavevmode\raise.1ex\copy\longdblarrowbox}
1772\def\print{\leavevmode\lower.1ex\copy\pushcharbox}
1773
1774\def\equiv{\leavevmode\lower.1ex\copy\equivbox}
1775
1776% Does anyone really want this?
1777% \def\bull{\leavevmode\copy\bullbox}
1778
1779% Adapted from the TeXbook's \boxit.
1780{\tentt \global\dimen0 = 3em}% Width of the box.
1781\dimen2 = .55pt % Thickness of rules
1782% The text. (`r' is open on the right, `e' somewhat less so on the left.)
1783\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
1784
1785\global\setbox\errorbox=\hbox to \dimen0{\hfil
1786 \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
1787 \advance\hsize by -2\dimen2 % Rules.
1788 \vbox{
1789 \hrule height\dimen2
1790 \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
1791 \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
1792 \kern3pt\vrule width\dimen2}% Space to right.
1793 \hrule height\dimen2}
1794 \hfil}
1795
1796% The @error{} command.
1797\def\error{\leavevmode\lower.7ex\copy\errorbox}
1798
1799% @tex ... @end tex escapes into raw Tex temporarily.
1800% One exception: @ is still an escape character, so that @end tex works.
1801% But \@ or @@ will get a plain tex @ character.
1802
1803\def\tex{\begingroup
1804\catcode `\\=0 \catcode `\{=1 \catcode `\}=2
1805\catcode `\$=3 \catcode `\&=4 \catcode `\#=6
1806\catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
1807\catcode `\%=14
1808\catcode 43=12
1809\catcode`\"=12
1810\catcode`\==12
1811\catcode`\|=12
1812\catcode`\<=12
1813\catcode`\>=12
1814\escapechar=`\\
1815%
1816\let\{=\ptexlbrace
1817\let\}=\ptexrbrace
1818\let\.=\ptexdot
1819\let\*=\ptexstar
1820\let\dots=\ptexdots
1821\def\@={@}%
1822\let\bullet=\ptexbullet
1823\let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
1824\let\L=\ptexL
1825%
1826\let\Etex=\endgroup}
1827
1828% Define @lisp ... @endlisp.
1829% @lisp does a \begingroup so it can rebind things,
1830% including the definition of @endlisp (which normally is erroneous).
1831
1832% Amount to narrow the margins by for @lisp.
1833\newskip\lispnarrowing \lispnarrowing=0.4in
1834
1835% This is the definition that ^M gets inside @lisp
1836% phr: changed space to \null, to avoid overfull hbox problems.
1837{\obeyspaces%
1838\gdef\lisppar{\null\endgraf}}
1839
1840% Cause \obeyspaces to make each Space cause a word-separation
1841% rather than the default which is that it acts punctuation.
1842% This is because space in tt font looks funny.
1843{\obeyspaces %
1844\gdef\sepspaces{\def {\ }}}
1845
1846\newskip\aboveenvskipamount \aboveenvskipamount= 0pt
1847\def\aboveenvbreak{{\advance\aboveenvskipamount by \parskip
1848\endgraf \ifdim\lastskip<\aboveenvskipamount
1849\removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}}
1850
1851\def\afterenvbreak{\endgraf \ifdim\lastskip<\aboveenvskipamount
1852\removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}
1853
1854\def\lisp{\aboveenvbreak\begingroup\inENV %This group ends at the end of the @lisp body
1855\hfuzz=12truept % Don't be fussy
1856% Make spaces be word-separators rather than space tokens.
1857\sepspaces %
1858% Single space lines
1859\singlespace %
1860% The following causes blank lines not to be ignored
1861% by adding a space to the end of each line.
1862\let\par=\lisppar
1863\def\Elisp{\endgroup\afterenvbreak}%
1864\parskip=0pt
1865\advance \leftskip by \lispnarrowing
1866\parindent=0pt
1867\let\exdent=\internalexdent
1868\obeyspaces \obeylines \tt \rawbackslash
1869\def\next##1{}\next}
1870
1871
1872\let\example=\lisp
1873\def\Eexample{\Elisp}
1874
1875\let\smallexample=\lisp
1876\def\Esmallexample{\Elisp}
1877
1878% Macro for 9 pt. examples, necessary to print with 5" lines.
1879% From Pavel@xerox. This is not really used unless the
1880% @smallbook command is given.
1881
1882\def\smalllispx{\aboveenvbreak\begingroup\inENV
1883% This group ends at the end of the @lisp body
1884\hfuzz=12truept % Don't be fussy
1885% Make spaces be word-separators rather than space tokens.
1886\sepspaces %
1887% Single space lines
1888\singlespace %
1889% The following causes blank lines not to be ignored
1890% by adding a space to the end of each line.
1891\let\par=\lisppar
1892\def\Esmalllisp{\endgroup\afterenvbreak}%
1893\parskip=0pt
1894\advance \leftskip by \lispnarrowing
1895\parindent=0pt
1896\let\exdent=\internalexdent
1897\obeyspaces \obeylines \ninett \indexfonts \rawbackslash
1898\def\next##1{}\next}
1899
1900% This is @display; same as @lisp except use roman font.
1901
1902\def\display{\begingroup\inENV %This group ends at the end of the @display body
1903\aboveenvbreak
1904% Make spaces be word-separators rather than space tokens.
1905\sepspaces %
1906% Single space lines
1907\singlespace %
1908% The following causes blank lines not to be ignored
1909% by adding a space to the end of each line.
1910\let\par=\lisppar
1911\def\Edisplay{\endgroup\afterenvbreak}%
1912\parskip=0pt
1913\advance \leftskip by \lispnarrowing
1914\parindent=0pt
1915\let\exdent=\internalexdent
1916\obeyspaces \obeylines
1917\def\next##1{}\next}
1918
1919% This is @format; same as @lisp except use roman font and don't narrow margins
1920
1921\def\format{\begingroup\inENV %This group ends at the end of the @format body
1922\aboveenvbreak
1923% Make spaces be word-separators rather than space tokens.
1924\sepspaces %
1925\singlespace %
1926% The following causes blank lines not to be ignored
1927% by adding a space to the end of each line.
1928\let\par=\lisppar
1929\def\Eformat{\endgroup\afterenvbreak}
1930\parskip=0pt \parindent=0pt
1931\obeyspaces \obeylines
1932\def\next##1{}\next}
1933
1934% @flushleft and @flushright
1935
1936\def\flushleft{\begingroup\inENV %This group ends at the end of the @format body
1937\aboveenvbreak
1938% Make spaces be word-separators rather than space tokens.
1939\sepspaces %
1940% The following causes blank lines not to be ignored
1941% by adding a space to the end of each line.
1942% This also causes @ to work when the directive name
1943% is terminated by end of line.
1944\let\par=\lisppar
1945\def\Eflushleft{\endgroup\afterenvbreak}%
1946\parskip=0pt \parindent=0pt
1947\obeyspaces \obeylines
1948\def\next##1{}\next}
1949
1950\def\flushright{\begingroup\inENV %This group ends at the end of the @format body
1951\aboveenvbreak
1952% Make spaces be word-separators rather than space tokens.
1953\sepspaces %
1954% The following causes blank lines not to be ignored
1955% by adding a space to the end of each line.
1956% This also causes @ to work when the directive name
1957% is terminated by end of line.
1958\let\par=\lisppar
1959\def\Eflushright{\endgroup\afterenvbreak}%
1960\parskip=0pt \parindent=0pt
1961\advance \leftskip by 0pt plus 1fill
1962\obeyspaces \obeylines
1963\def\next##1{}\next}
1964
1965% @quotation - narrow the margins.
1966
1967\def\quotation{\begingroup\inENV %This group ends at the end of the @quotation body
1968{\parskip=0pt % because we will skip by \parskip too, later
1969\aboveenvbreak}%
1970\singlespace
1971\parindent=0pt
1972\def\Equotation{\par\endgroup\afterenvbreak}%
1973\advance \rightskip by \lispnarrowing
1974\advance \leftskip by \lispnarrowing}
1975
1976\message{defuns,}
1977% Define formatter for defuns
1978% First, allow user to change definition object font (\df) internally
1979\def\setdeffont #1 {\csname DEF#1\endcsname}
1980
1981\newskip\defbodyindent \defbodyindent=.4in
1982\newskip\defargsindent \defargsindent=50pt
1983\newskip\deftypemargin \deftypemargin=12pt
1984\newskip\deflastargmargin \deflastargmargin=18pt
1985
1986\newcount\parencount
1987% define \functionparens, which makes ( and ) and & do special things.
1988% \functionparens affects the group it is contained in.
1989\def\activeparens{%
1990\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
1991\catcode`\[=\active \catcode`\]=\active}
1992{\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
1993\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
1994\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
1995
1996% Definitions of (, ) and & used in args for functions.
1997% This is the definition of ( outside of all parentheses.
1998\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
1999\global\advance\parencount by 1 }
2000%
2001% This is the definition of ( when already inside a level of parens.
2002\gdef\opnested{\char`\(\global\advance\parencount by 1 }
2003%
2004\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
2005% also in that case restore the outer-level definition of (.
2006\ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
2007\global\advance \parencount by -1 }
2008% If we encounter &foo, then turn on ()-hacking afterwards
2009\gdef\amprm#1 {{\rm\&#1}\let(=\oprm \let)=\clrm\ }
2010%
2011\gdef\normalparens{\boldbrax\let&=\ampnr}
2012} % End of definition inside \activeparens
2013%% These parens (in \boldbrax) actually are a little bolder than the
2014%% contained text. This is especially needed for [ and ]
2015\def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
2016\def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
2017
2018% First, defname, which formats the header line itself.
2019% #1 should be the function name.
2020% #2 should be the type of definition, such as "Function".
2021
2022\def\defname #1#2{%
2023% Get the values of \leftskip and \rightskip as they were
2024% outside the @def...
2025\dimen2=\leftskip
2026\advance\dimen2 by -\defbodyindent
2027\dimen3=\rightskip
2028\advance\dimen3 by -\defbodyindent
2029\noindent %
2030\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
2031\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
2032\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
2033\parshape 2 0in \dimen0 \defargsindent \dimen1 %
2034% Now output arg 2 ("Function" or some such)
2035% ending at \deftypemargin from the right margin,
2036% but stuck inside a box of width 0 so it does not interfere with linebreaking
2037{% Adjust \hsize to exclude the ambient margins,
2038% so that \rightline will obey them.
2039\advance \hsize by -\dimen2 \advance \hsize by -\dimen3
2040\rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}%
2041\tolerance=10000 \hbadness=10000 % Make all lines underfull and no complaints
2042{\df #1}\enskip % Generate function name
2043}
2044
2045% Actually process the body of a definition
2046% #1 should be the terminating control sequence, such as \Edefun.
2047% #2 should be the "another name" control sequence, such as \defunx.
2048% #3 should be the control sequence that actually processes the header,
2049% such as \defunheader.
2050
2051\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
2052\medbreak %
2053% Define the end token that this defining construct specifies
2054% so that it will exit this group.
2055\def#1{\endgraf\endgroup\medbreak}%
2056\def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
2057\parindent=0in
2058\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
2059\begingroup %
2060\catcode 61=\active %
2061\obeylines\activeparens\spacesplit#3}
2062
2063\def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
2064\medbreak %
2065% Define the end token that this defining construct specifies
2066% so that it will exit this group.
2067\def#1{\endgraf\endgroup\medbreak}%
2068\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
2069\parindent=0in
2070\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
2071\begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
2072
2073\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
2074\medbreak %
2075% Define the end token that this defining construct specifies
2076% so that it will exit this group.
2077\def#1{\endgraf\endgroup\medbreak}%
2078\def#2##1 ##2 {\def#4{##1}%
2079\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
2080\parindent=0in
2081\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
2082\begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
2083
2084% Split up #2 at the first space token.
2085% call #1 with two arguments:
2086% the first is all of #2 before the space token,
2087% the second is all of #2 after that space token.
2088% If #2 contains no space token, all of it is passed as the first arg
2089% and the second is passed as empty.
2090
2091{\obeylines
2092\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
2093\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
2094\ifx\relax #3%
2095#1{#2}{}\else #1{#2}{#3#4}\fi}}
2096
2097% So much for the things common to all kinds of definitions.
2098
2099% Define @defun.
2100
2101% First, define the processing that is wanted for arguments of \defun
2102% Use this to expand the args and terminate the paragraph they make up
2103
2104\def\defunargs #1{\functionparens \sl
2105% Expand, preventing hyphenation at `-' chars.
2106% Note that groups don't affect changes in \hyphenchar.
2107\hyphenchar\sl=0
2108#1%
2109\hyphenchar\sl=45
2110\ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
2111\interlinepenalty=10000
2112\advance\rightskip by 0pt plus 1fil
2113\endgraf\penalty 10000\vskip -\parskip\penalty 10000%
2114}
2115
2116\def\deftypefunargs #1{%
2117% Expand, preventing hyphenation at `-' chars.
2118% Note that groups don't affect changes in \hyphenchar.
2119\functionparens
2120\code{#1}%
2121\interlinepenalty=10000
2122\advance\rightskip by 0pt plus 1fil
2123\endgraf\penalty 10000\vskip -\parskip\penalty 10000%
2124}
2125
2126% Do complete processing of one @defun or @defunx line already parsed.
2127
2128% @deffn Command forward-char nchars
2129
2130\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
2131
2132\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
2133\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
2134\catcode 61=\other % Turn off change made in \defparsebody
2135}
2136
2137% @defun == @deffn Function
2138
2139\def\defun{\defparsebody\Edefun\defunx\defunheader}
2140
2141\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
2142\begingroup\defname {#1}{Function}%
2143\defunargs {#2}\endgroup %
2144\catcode 61=\other % Turn off change made in \defparsebody
2145}
2146
2147% @deftypefun int foobar (int @var{foo}, float @var{bar})
2148
2149\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
2150
2151% #1 is the data type. #2 is the name and args.
2152\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
2153% #1 is the data type, #2 the name, #3 the args.
2154\def\deftypefunheaderx #1#2 #3\relax{\doind {fn}{\code{#2}}% Make entry in function index
2155\begingroup\defname {\code{#1} #2}{Function}%
2156\deftypefunargs {#3}\endgroup %
2157\catcode 61=\other % Turn off change made in \defparsebody
2158}
2159
2160% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
2161
2162\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
2163
2164% #1 is the classification. #2 is the data type. #3 is the name and args.
2165\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
2166% #1 is the classification, #2 the data type, #3 the name, #4 the args.
2167\def\deftypefnheaderx #1#2#3 #4\relax{\doind {fn}{\code{#3}}% Make entry in function index
2168\begingroup\defname {\code{#2} #3}{#1}%
2169\deftypefunargs {#4}\endgroup %
2170\catcode 61=\other % Turn off change made in \defparsebody
2171}
2172
2173% @defmac == @deffn Macro
2174
2175\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
2176
2177\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
2178\begingroup\defname {#1}{Macro}%
2179\defunargs {#2}\endgroup %
2180\catcode 61=\other % Turn off change made in \defparsebody
2181}
2182
2183% @defspec == @deffn Special Form
2184
2185\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
2186
2187\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
2188\begingroup\defname {#1}{Special Form}%
2189\defunargs {#2}\endgroup %
2190\catcode 61=\other % Turn off change made in \defparsebody
2191}
2192
2193% This definition is run if you use @defunx
2194% anywhere other than immediately after a @defun or @defunx.
2195
2196\def\deffnx #1 {\errmessage{@deffnx in invalid context}}
2197\def\defunx #1 {\errmessage{@defunx in invalid context}}
2198\def\defmacx #1 {\errmessage{@defmacx in invalid context}}
2199\def\defspecx #1 {\errmessage{@defspecx in invalid context}}
2200\def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
2201\def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}}
2202
2203% @defmethod, and so on
2204
2205% @defop {Funny Method} foo-class frobnicate argument
2206
2207\def\defop #1 {\def\defoptype{#1}%
2208\defopparsebody\Edefop\defopx\defopheader\defoptype}
2209
2210\def\defopheader #1#2#3{\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
2211\begingroup\defname {#2}{\defoptype{} on #1}%
2212\defunargs {#3}\endgroup %
2213}
2214
2215% @defmethod == @defop Method
2216
2217\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
2218
2219\def\defmethodheader #1#2#3{\dosubind {fn}{\code{#2}}{on #1}% entry in function index
2220\begingroup\defname {#2}{Method on #1}%
2221\defunargs {#3}\endgroup %
2222}
2223
2224% @defcv {Class Option} foo-class foo-flag
2225
2226\def\defcv #1 {\def\defcvtype{#1}%
2227\defopparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
2228
2229\def\defcvarheader #1#2#3{%
2230\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
2231\begingroup\defname {#2}{\defcvtype{} of #1}%
2232\defvarargs {#3}\endgroup %
2233}
2234
2235% @defivar == @defcv {Instance Variable}
2236
2237\def\defivar{\defmethparsebody\Edefivar\defivarx\defivarheader}
2238
2239\def\defivarheader #1#2#3{%
2240\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
2241\begingroup\defname {#2}{Instance Variable of #1}%
2242\defvarargs {#3}\endgroup %
2243}
2244
2245% These definitions are run if you use @defmethodx, etc.,
2246% anywhere other than immediately after a @defmethod, etc.
2247
2248\def\defopx #1 {\errmessage{@defopx in invalid context}}
2249\def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
2250\def\defcvx #1 {\errmessage{@defcvx in invalid context}}
2251\def\defivarx #1 {\errmessage{@defivarx in invalid context}}
2252
2253% Now @defvar
2254
2255% First, define the processing that is wanted for arguments of @defvar.
2256% This is actually simple: just print them in roman.
2257% This must expand the args and terminate the paragraph they make up
2258\def\defvarargs #1{\normalparens #1%
2259\interlinepenalty=10000
2260\endgraf\penalty 10000\vskip -\parskip\penalty 10000}
2261
2262% @defvr Counter foo-count
2263
2264\def\defvr{\defmethparsebody\Edefvr\defvrx\defvrheader}
2265
2266\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
2267\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
2268
2269% @defvar == @defvr Variable
2270
2271\def\defvar{\defparsebody\Edefvar\defvarx\defvarheader}
2272
2273\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
2274\begingroup\defname {#1}{Variable}%
2275\defvarargs {#2}\endgroup %
2276}
2277
2278% @defopt == @defvr {User Option}
2279
2280\def\defopt{\defparsebody\Edefopt\defoptx\defoptheader}
2281
2282\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
2283\begingroup\defname {#1}{User Option}%
2284\defvarargs {#2}\endgroup %
2285}
2286
2287% @deftypevar int foobar
2288
2289\def\deftypevar{\defparsebody\Edeftypevar\deftypevarx\deftypevarheader}
2290
2291% #1 is the data type. #2 is the name.
2292\def\deftypevarheader #1#2{\doind {vr}{\code{#2}}% Make entry in variables index
2293\begingroup\defname {\code{#1} #2}{Variable}%
2294\interlinepenalty=10000
2295\endgraf\penalty 10000\vskip -\parskip\penalty 10000
2296\endgroup}
2297
2298% @deftypevr {Global Flag} int enable
2299
2300\def\deftypevr{\defmethparsebody\Edeftypevr\deftypevrx\deftypevrheader}
2301
2302\def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}%
2303\begingroup\defname {\code{#2} #3}{#1}
2304\interlinepenalty=10000
2305\endgraf\penalty 10000\vskip -\parskip\penalty 10000
2306\endgroup}
2307
2308% This definition is run if you use @defvarx
2309% anywhere other than immediately after a @defvar or @defvarx.
2310
2311\def\defvrx #1 {\errmessage{@defvrx in invalid context}}
2312\def\defvarx #1 {\errmessage{@defvarx in invalid context}}
2313\def\defoptx #1 {\errmessage{@defoptx in invalid context}}
2314\def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
2315\def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
2316
2317% Now define @deftp
2318% Args are printed in bold, a slight difference from @defvar.
2319
2320\def\deftpargs #1{\bf \defvarargs{#1}}
2321
2322% @deftp Class window height width ...
2323
2324\def\deftp{\defmethparsebody\Edeftp\deftpx\deftpheader}
2325
2326\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
2327\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
2328
2329% This definition is run if you use @deftpx, etc
2330% anywhere other than immediately after a @deftp, etc.
2331
2332\def\deftpx #1 {\errmessage{@deftpx in invalid context}}
2333
2334\message{cross reference,}
2335% Define cross-reference macros
2336\newwrite \auxfile
2337
2338\newif\ifhavexrefs % True if xref values are known.
2339\newif\ifwarnedxrefs % True if we warned once that they aren't known.
2340
2341% \setref{foo} defines a cross-reference point named foo.
2342
2343\def\setref#1{%
2344%\dosetq{#1-title}{Ytitle}%
2345\dosetq{#1-pg}{Ypagenumber}%
2346\dosetq{#1-snt}{Ysectionnumberandtype}}
2347
2348\def\unnumbsetref#1{%
2349%\dosetq{#1-title}{Ytitle}%
2350\dosetq{#1-pg}{Ypagenumber}%
2351\dosetq{#1-snt}{Ynothing}}
2352
2353\def\appendixsetref#1{%
2354%\dosetq{#1-title}{Ytitle}%
2355\dosetq{#1-pg}{Ypagenumber}%
2356\dosetq{#1-snt}{Yappendixletterandtype}}
2357
2358% \xref, \pxref, and \ref generate cross-references to specified points.
2359% For \xrefX, #1 is the node name, #2 the name of the Info
2360% cross-reference, #3 the printed node name, #4 the name of the Info
2361% file, #5 the name of the printed manual. All but the node name can be
2362% omitted.
2363%
2364\def\pxref#1{see \xrefX[#1,,,,,,,]}
2365\def\xref#1{See \xrefX[#1,,,,,,,]}
2366\def\ref#1{\xrefX[#1,,,,,,,]}
2367\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup%
2368\def\printedmanual{\ignorespaces #5}%
2369\def\printednodename{\ignorespaces #3}%
2370%
2371\setbox1=\hbox{\printedmanual}%
2372\setbox0=\hbox{\printednodename}%
2373\ifdim \wd0=0pt%
2374\def\printednodename{\ignorespaces #1}%
2375%%% Uncommment the following line to make the actual chapter or section title
2376%%% appear inside the square brackets.
2377%\def\printednodename{#1-title}%
2378\fi%
2379%
2380%
2381% If we use \unhbox0 and \unhbox1 to print the node names, TeX does
2382% not insert empty discretionaries after hyphens, which means that it
2383% will not find a line break at a hyphen in a node names. Since some
2384% manuals are best written with fairly long node names, containing
2385% hyphens, this is a loss. Therefore, we simply give the text of
2386% the node name again, so it is as if TeX is seeing it for the first
2387% time.
2388\ifdim \wd1>0pt
2389section ``\printednodename'' in \cite{\printedmanual}%
2390\else%
2391\turnoffactive%
2392\refx{#1-snt}{} [\printednodename], page\tie\refx{#1-pg}{}%
2393\fi
2394\endgroup}
2395
2396% \dosetq is the interface for calls from other macros
2397
2398% Use \turnoffactive so that punctuation chars such as underscore
2399% work in node names.
2400\def\dosetq #1#2{{\let\folio=0 \turnoffactive%
2401\edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
2402\next}}
2403
2404% \internalsetq {foo}{page} expands into CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
2405% When the aux file is read, ' is the escape character
2406
2407\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
2408
2409% Things to be expanded by \internalsetq
2410
2411\def\Ypagenumber{\folio}
2412
2413\def\Ytitle{\thischapter}
2414
2415\def\Ynothing{}
2416
2417\def\Ysectionnumberandtype{%
2418\ifnum\secno=0 Chapter\xreftie\the\chapno %
2419\else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno %
2420\else \ifnum \subsubsecno=0 %
2421Section\xreftie\the\chapno.\the\secno.\the\subsecno %
2422\else %
2423Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
2424\fi \fi \fi }
2425
2426\def\Yappendixletterandtype{%
2427\ifnum\secno=0 Appendix\xreftie'char\the\appendixno{}%
2428\else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno %
2429\else \ifnum \subsubsecno=0 %
2430Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
2431\else %
2432Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
2433\fi \fi \fi }
2434
2435\gdef\xreftie{'tie}
2436
2437% Use TeX 3.0's \inputlineno to get the line number, for better error
2438% messages, but if we're using an old version of TeX, don't do anything.
2439%
2440\ifx\inputlineno\thisisundefined
2441 \let\linenumber = \empty % Non-3.0.
2442\else
2443 \def\linenumber{\the\inputlineno:\space}
2444\fi
2445
2446% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
2447% If its value is nonempty, SUFFIX is output afterward.
2448
2449\def\refx#1#2{%
2450 \expandafter\ifx\csname X#1\endcsname\relax
2451 % If not defined, say something at least.
2452 $\langle$un\-de\-fined$\rangle$%
2453 \ifhavexrefs
2454 \message{\linenumber Undefined cross reference `#1'.}%
2455 \else
2456 \ifwarnedxrefs\else
2457 \global\warnedxrefstrue
2458 \message{Cross reference values unknown; you must run TeX again.}%
2459 \fi
2460 \fi
2461 \else
2462 % It's defined, so just use it.
2463 \csname X#1\endcsname
2464 \fi
2465 #2% Output the suffix in any case.
2466}
2467
2468% Read the last existing aux file, if any. No error if none exists.
2469
2470% This is the macro invoked by entries in the aux file.
2471\def\xrdef #1#2{
2472{\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
2473
2474\def\readauxfile{%
2475\begingroup
2476\catcode `\^^@=\other
2477\catcode `\\ 1=\other
2478\catcode `\\ 2=\other
2479\catcode `\^^C=\other
2480\catcode `\^^D=\other
2481\catcode `\^^E=\other
2482\catcode `\^^F=\other
2483\catcode `\^^G=\other
2484\catcode `\^^H=\other
2485\catcode `\\v=\other
2486\catcode `\^^L=\other
2487\catcode `\\ e=\other
2488\catcode `\\ f=\other
2489\catcode `\\10=\other
2490\catcode `\\11=\other
2491\catcode `\\12=\other
2492\catcode `\\13=\other
2493\catcode `\\14=\other
2494\catcode `\\15=\other
2495\catcode `\\16=\other
2496\catcode `\\17=\other
2497\catcode `\\18=\other
2498\catcode `\\19=\other
2499\catcode `\\1a=\other
2500\catcode `\^^[=\other
2501\catcode `\^^\=\other
2502\catcode `\^^]=\other
2503\catcode `\^^^=\other
2504\catcode `\^^_=\other
2505\catcode `\@=\other
2506\catcode `\^=\other
2507\catcode `\~=\other
2508\catcode `\[=\other
2509\catcode `\]=\other
2510\catcode`\"=\other
2511\catcode`\_=\other
2512\catcode`\|=\other
2513\catcode`\<=\other
2514\catcode`\>=\other
2515\catcode `\$=\other
2516\catcode `\#=\other
2517\catcode `\&=\other
2518% the aux file uses ' as the escape.
2519% Turn off \ as an escape so we do not lose on
2520% entries which were dumped with control sequences in their names.
2521% For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
2522% Reference to such entries still does not work the way one would wish,
2523% but at least they do not bomb out when the aux file is read in.
2524\catcode `\{=1 \catcode `\}=2
2525\catcode `\%=\other
2526\catcode `\'=0
2527\catcode `\\=\other
2528\openin 1 \jobname.aux
2529\ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue
2530\fi
2531% Open the new aux file. Tex will close it automatically at exit.
2532\openout \auxfile=\jobname.aux
2533\endgroup}
2534
2535
2536% Footnotes.
2537
2538\newcount \footnoteno
2539
2540\def\supereject{\par\penalty -20000\footnoteno =0 }
2541
2542\let\ptexfootnote=\footnote
2543
2544{\catcode `\@=11
2545\long\gdef\footnote #1{\global\advance \footnoteno by \@ne
2546\removelastskip
2547\edef\thisfootno{$^{\the\footnoteno}$}%
2548\let\@sf\empty
2549\ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
2550\thisfootno\@sf \footnotezzz{#1}}
2551% \parsearg\footnotezzz}
2552
2553\long\gdef\footnotezzz #1{\insert\footins{
2554\interlinepenalty\interfootnotelinepenalty
2555\splittopskip\ht\strutbox % top baseline for broken footnotes
2556\splitmaxdepth\dp\strutbox \floatingpenalty\@MM
2557\leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip
2558\footstrut\parindent=\defaultparindent\hang\textindent{\thisfootno}#1\strut}}
2559
2560}%end \catcode `\@=11
2561
2562% End of control word definitions.
2563
2564\message{and turning on texinfo input format.}
2565
2566\def\openindices{%
2567 \newindex{cp}%
2568 \newcodeindex{fn}%
2569 \newcodeindex{vr}%
2570 \newcodeindex{tp}%
2571 \newcodeindex{ky}%
2572 \newcodeindex{pg}%
2573}
2574
2575% Set some numeric style parameters, for 8.5 x 11 format.
2576
2577%\hsize = 6.5in
2578\newdimen\defaultparindent \defaultparindent = 15pt
2579\parindent = \defaultparindent
2580\parskip 18pt plus 1pt
2581\baselineskip 15pt
2582\advance\topskip by 1.2cm
2583
2584% Prevent underfull vbox error messages.
2585\vbadness=10000
2586
2587% Use TeX 3.0's \emergencystretch to help line breaking, but if we're
2588% using an old version of TeX, don't do anything. We want the amount of
2589% stretch added to depend on the line length, hence the dependence on
2590% \hsize. This makes it come to about 9pt for the 8.5x11 format.
2591%
2592\ifx\emergencystretch\thisisundefined \else
2593 \emergencystretch = \hsize
2594 \divide\emergencystretch by 45
2595\fi
2596
2597% Use @smallbook to reset parameters for 7x9.5 format
2598\def\smallbook{
2599\global\lispnarrowing = 0.3in
2600\global\baselineskip 12pt
2601\global\parskip 3pt plus 1pt
2602\global\hsize = 5in
2603\global\doublecolumnhsize=2.4in \global\doublecolumnvsize=15.0in
2604\global\vsize=7.5in
2605\global\tolerance=700
2606\global\hfuzz=1pt
2607
2608\global\pagewidth=\hsize
2609\global\pageheight=\vsize
2610
2611\global\let\smalllisp=\smalllispx
2612\global\let\smallexample=\smalllispx
2613\global\def\Esmallexample{\Esmalllisp}
2614}
2615
2616%% For a final copy, take out the rectangles
2617%% that mark overfull boxes (in case you have decided
2618%% that the text looks ok even though it passes the margin).
2619\def\finalout{\overfullrule=0pt}
2620
2621% Define macros to output various characters with catcode for normal text.
2622\catcode`\"=\other
2623\catcode`\~=\other
2624\catcode`\^=\other
2625\catcode`\_=\other
2626\catcode`\|=\other
2627\catcode`\<=\other
2628\catcode`\>=\other
2629\catcode`\+=\other
2630\def\normaldoublequote{"}
2631\def\normaltilde{~}
2632\def\normalcaret{^}
2633\def\normalunderscore{_}
2634\def\normalverticalbar{|}
2635\def\normalless{<}
2636\def\normalgreater{>}
2637\def\normalplus{+}
2638
2639% This macro is used to make a character print one way in ttfont
2640% where it can probably just be output, and another way in other fonts,
2641% where something hairier probably needs to be done.
2642%
2643% #1 is what to print if we are indeed using \tt; #2 is what to print
2644% otherwise. Since all the Computer Modern typewriter fonts have zero
2645% interword stretch (and shrink), and it is reasonable to expect all
2646% typewriter fonts to have this, we can check that font parameter.
2647%
2648\def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi}
2649
2650% Turn off all special characters except @
2651% (and those which the user can use as if they were ordinary).
2652% Most of these we simply print from the \tt font, but for some, we can
2653% use math or other variants that look better in normal text.
2654
2655\catcode`\"=\active
2656\def\activedoublequote{{\tt \char '042}}
2657\let"=\activedoublequote
2658\catcode`\~=\active
2659\def~{{\tt \char '176}}
2660\chardef\hat=`\^
2661\catcode`\^=\active
2662\def^{{\tt \hat}}
2663
2664\catcode`\_=\active
2665\def_{\ifusingtt\normalunderscore\_}
2666% Subroutine for the previous macro.
2667\def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}}
2668
2669\catcode`\|=\active
2670\def|{{\tt \char '174}}
2671\chardef \less=`\<
2672\catcode`\<=\active
2673\def<{{\tt \less}}
2674\chardef \gtr=`\>
2675\catcode`\>=\active
2676\def>{{\tt \gtr}}
2677\catcode`\+=\active
2678\def+{{\tt \char 43}}
2679%\catcode 27=\active
2680%\def^^[{$\diamondsuit$}
2681
2682% Used sometimes to turn off (effectively) the active characters
2683% even after parsing them.
2684\def\turnoffactive{\let"=\normaldoublequote
2685\let~=\normaltilde
2686\let^=\normalcaret
2687\let_=\normalunderscore
2688\let|=\normalverticalbar
2689\let<=\normalless
2690\let>=\normalgreater
2691\let+=\normalplus}
2692
2693% Set up an active definition for =, but don't enable it most of the time.
2694{\catcode`\==\active
2695\global\def={{\tt \char 61}}}
2696
2697\catcode`\@=0
2698
2699% \rawbackslashxx output one backslash character in current font
2700\global\chardef\rawbackslashxx=`\\
2701%{\catcode`\\=\other
2702%@gdef@rawbackslashxx{\}}
2703
2704% \rawbackslash redefines \ as input to do \rawbackslashxx.
2705{\catcode`\\=\active
2706@gdef@rawbackslash{@let\=@rawbackslashxx }}
2707
2708% \normalbackslash outputs one backslash in fixed width font.
2709\def\normalbackslash{{\tt\rawbackslashxx}}
2710
2711% Say @foo, not \foo, in error messages.
2712\escapechar=`\@
2713
2714% \catcode 17=0 % Define control-q
2715\catcode`\\=\active
2716
2717% If a .fmt file is being used, we don't want the `\input texinfo' to show up.
2718% That is what \eatinput is for; after that, the `\' should revert to printing
2719% a backslash.
2720%
2721@gdef@eatinput input texinfo{@fixbackslash}
2722@global@let\ = @eatinput
2723
2724% On the other hand, perhaps the file did not have a `\input texinfo'. Then
2725% the first `\{ in the file would cause an error. This macro tries to fix
2726% that, assuming it is called before the first `\' could plausibly occur.
2727%
2728@gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
2729
2730%% These look ok in all fonts, so just make them not special. The @rm below
2731%% makes sure that the current font starts out as the newly loaded cmr10
2732@catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
2733
2734@textfonts
2735@rm