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