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