source: git/doc/texinfo.tex @ 33471f8

spielwiese
Last change on this file since 33471f8 was 6593402, checked in by Kai Krüger <krueger@…>, 26 years ago
edited front-page and texinfo.tex git-svn-id: file:///usr/local/Singular/svn/trunk@2214 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 156.7 KB
Line 
1%% TeX macros to handle Texinfo files.
2%% $Id: texinfo.tex,v 1.3 1998-06-19 13:09:19 krueger Exp $
3
4%  Copyright (C) 1985, 86, 88, 90, 91, 92, 93,
5%                94, 95, 96, 97 Free Software Foundation, Inc.
6
7%This texinfo.tex file is free software; you can redistribute it and/or
8%modify it under the terms of the GNU General Public License as
9%published by the Free Software Foundation; either version 2, or (at
10%your option) any later version.
11
12%This texinfo.tex file is distributed in the hope that it will be
13%useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14%of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15%General Public License for more details.
16
17%You should have received a copy of the GNU General Public License
18%along with this texinfo.tex file; see the file COPYING.  If not, write
19%to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20%Boston, MA 02111-1307, USA.
21
22
23%In other words, you are welcome to use, share and improve this program.
24%You are forbidden to forbid anyone else to use, share and improve
25%what you give them.   Help stamp out software-hoarding!
26
27
28% Send bug reports to bug-texinfo@prep.ai.mit.edu.
29% Please include a *precise* test case in each bug report.
30
31
32% Make it possible to create a .fmt file just by loading this file:
33% if the underlying format is not loaded, start by loading it now.
34% Added by gildea November 1993.
35\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
36
37% This automatically updates the version number based on RCS.
38\def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}}
39\deftexinfoversion$Revision: 1.3 $
40\message{Loading texinfo package [Version \texinfoversion]:}
41
42% If in a .fmt file, print the version number
43% and turn on active characters that we couldn't do earlier because
44% they might have appeared in the input file name.
45\everyjob{\message{[Texinfo version \texinfoversion]}\message{}
46  \catcode`+=\active \catcode`\_=\active}
47
48% Save some parts of plain tex whose names we will redefine.
49
50\let\ptexb=\b
51\let\ptexbullet=\bullet
52\let\ptexc=\c
53\let\ptexcomma=\,
54\let\ptexdot=\.
55\let\ptexdots=\dots
56\let\ptexend=\end
57\let\ptexequiv = \equiv
58\let\ptexi=\i
59\let\ptexlbrace=\{
60\let\ptexrbrace=\}
61\let\ptexstar=\*
62\let\ptext=\t
63
64% Be sure we're in horizontal mode when doing a tie, since we make space
65% equivalent to this in @example-like environments. Otherwise, a space
66% at the beginning of a line will start with \penalty -- and
67% since \penalty is valid in vertical mode, we'd end up putting the
68% penalty on the vertical list instead of in the new paragraph.
69{\catcode`@ = 11
70 % Avoid using \@M directly, because that causes trouble
71 % if the definition is written into an index file.
72 \global\let\tiepenalty = \@M
73 \gdef\tie{\leavevmode\penalty\tiepenalty\ }
74}
75
76
77\message{Basics,}
78\chardef\other=12
79
80% If this character appears in an error message or help string, it
81% starts a new line in the output.
82\newlinechar = `^^J
83
84% Set up fixed words for English.
85\ifx\putwordChapter\undefined{\gdef\putwordChapter{Chapter}}\fi%
86\def\putwordInfo{Info}%
87\ifx\putwordSee\undefined{\gdef\putwordSee{See}}\fi%
88\ifx\putwordsee\undefined{\gdef\putwordsee{see}}\fi%
89\ifx\putwordfile\undefined{\gdef\putwordfile{file}}\fi%
90\ifx\putwordpage\undefined{\gdef\putwordpage{page}}\fi%
91\ifx\putwordsection\undefined{\gdef\putwordsection{section}}\fi%
92\ifx\putwordSection\undefined{\gdef\putwordSection{Section}}\fi%
93\ifx\putwordTableofContents\undefined{\gdef\putwordTableofContents{Table of Contents}}\fi%
94\ifx\putwordShortContents\undefined{\gdef\putwordShortContents{Short Contents}}\fi%
95\ifx\putwordAppendix\undefined{\gdef\putwordAppendix{Appendix}}\fi%
96
97% Ignore a token.
98%
99\def\gobble#1{}
100
101\hyphenation{ap-pen-dix}
102\hyphenation{mini-buf-fer mini-buf-fers}
103\hyphenation{eshell}
104
105% Margin to add to right of even pages, to left of odd pages.
106\newdimen \bindingoffset
107\newdimen \normaloffset
108\newdimen\pagewidth \newdimen\pageheight
109
110% Sometimes it is convenient to have everything in the transcript file
111% and nothing on the terminal.  We don't just call \tracingall here,
112% since that produces some useless output on the terminal.
113%
114\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
115\def\loggingall{\tracingcommands2 \tracingstats2
116   \tracingpages1 \tracingoutput1 \tracinglostchars1
117   \tracingmacros2 \tracingparagraphs1 \tracingrestores1
118   \showboxbreadth\maxdimen\showboxdepth\maxdimen
119}%
120
121%---------------------Begin change-----------------------
122%
123%%%% For @cropmarks command.
124% Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
125%
126\newdimen\cornerlong \newdimen\cornerthick
127\newdimen \topandbottommargin
128\newdimen \outerhsize \newdimen \outervsize
129\cornerlong=1pc\cornerthick=.3pt        % These set size of cropmarks
130\outerhsize=7in
131%\outervsize=9.5in
132% Alternative @smallbook page size is 9.25in
133\outervsize=9.25in
134\topandbottommargin=.75in
135%
136%---------------------End change-----------------------
137
138% Main output routine.
139\chardef\PAGE = 255
140\output = {\onepageout{\pagecontents\PAGE}}
141
142\newbox\headlinebox  \newbox\footlinebox
143
144% \onepageout takes a vbox as an argument.  Note that \pagecontents
145% does insertions, but you have to call it yourself.
146\def\onepageout#1{%
147  \hoffset=\normaloffset
148  \ifodd\pageno  \advance\hoffset by \bindingoffset
149  \else \advance\hoffset by -\bindingoffset\fi
150  %
151  % Do this outside of the \shipout so @code etc. will be expanded in
152  % the headline as they should be, not taken literally (outputting ''code).
153  \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
154  \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
155  %
156  {%
157    % Have to do this stuff outside the \shipout because we want it to
158    % take effect in \write's, yet the group defined by the \vbox ends
159    % before the \shipout runs.
160    %
161    \escapechar = `\\     % use backslash in output files.
162    \indexdummies         % don't expand commands in the output.
163    \normalturnoffactive  % \ in index entries must not stay \, e.g., if
164                   % the page break happens to be in the middle of an example.
165    \shipout\vbox{%
166      \unvbox\headlinebox
167      \pagebody{#1}%
168      \unvbox\footlinebox
169    }%
170    }%
171  \advancepageno
172  \ifnum\outputpenalty>-20000 \else\dosupereject\fi
173}
174
175%%%% For @cropmarks command %%%%
176
177% Here is a modification of the main output routine for Near East Publications
178% This provides right-angle cropmarks at all four corners.
179% The contents of the page are centerlined into the cropmarks,
180% and any desired binding offset is added as an \hskip on either
181% site of the centerlined box.  (P. A. MacKay, 12 November, 1986)
182%
183\def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
184{\escapechar=`\\\relax % makes sure backslash is used in output files.
185                 \shipout
186                 \vbox to \outervsize{\hsize=\outerhsize
187                 \vbox{\line{\ewtop\hfill\ewtop}}
188                 \nointerlineskip
189                 \line{\vbox{\moveleft\cornerthick\nstop}
190                       \hfill
191                       \vbox{\moveright\cornerthick\nstop}}
192                 \vskip \topandbottommargin
193                 \centerline{\ifodd\pageno\hskip\bindingoffset\fi
194                        \vbox{
195                        {\let\hsize=\pagewidth \makeheadline}
196                        \pagebody{#1}
197                        {\let\hsize=\pagewidth \makefootline}}
198                        \ifodd\pageno\else\hskip\bindingoffset\fi}
199                 \vskip \topandbottommargin plus1fill minus1fill
200                 \boxmaxdepth\cornerthick
201                 \line{\vbox{\moveleft\cornerthick\nsbot}
202                       \hfill
203                       \vbox{\moveright\cornerthick\nsbot}}
204                 \nointerlineskip
205                 \vbox{\line{\ewbot\hfill\ewbot}}
206        }}
207  \advancepageno
208  \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
209%
210% Do @cropmarks to get crop marks
211\def\cropmarks{\let\onepageout=\croppageout }
212
213\newinsert\margin \dimen\margin=\maxdimen
214
215\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
216{\catcode`\@ =11
217\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
218% marginal hacks, juha@viisa.uucp (Juha Takala)
219\ifvoid\margin\else % marginal info is present
220  \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
221\dimen@=\dp#1 \unvbox#1
222\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
223\ifr@ggedbottom \kern-\dimen@ \vfil \fi}
224}
225
226%
227% Here are the rules for the cropmarks.  Note that they are
228% offset so that the space between them is truly \outerhsize or \outervsize
229% (P. A. MacKay, 12 November, 1986)
230%
231\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
232\def\nstop{\vbox
233  {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
234\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
235\def\nsbot{\vbox
236  {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
237
238% Parse an argument, then pass it to #1.  The argument is the rest of
239% the input line (except we remove a trailing comment).  #1 should be a
240% macro which expects an ordinary undelimited TeX argument.
241%
242\def\parsearg#1{%
243  \let\next = #1%
244  \begingroup
245    \obeylines
246    \futurelet\temp\parseargx
247}
248
249% If the next token is an obeyed space (from an @example environment or
250% the like), remove it and recurse.  Otherwise, we're done.
251\def\parseargx{%
252  % \obeyedspace is defined far below, after the definition of \sepspaces.
253  \ifx\obeyedspace\temp
254    \expandafter\parseargdiscardspace
255  \else
256    \expandafter\parseargline
257  \fi
258}
259
260% Remove a single space (as the delimiter token to the macro call).
261{\obeyspaces %
262 \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
263
264{\obeylines %
265  \gdef\parseargline#1^^M{%
266    \endgroup % End of the group started in \parsearg.
267    %
268    % First remove any @c comment, then any @comment.
269    % Result of each macro is put in \toks0.
270    \argremovec #1\c\relax %
271    \expandafter\argremovecomment \the\toks0 \comment\relax %
272    %
273    % Call the caller's macro, saved as \next in \parsearg.
274    \expandafter\next\expandafter{\the\toks0}%
275  }%
276}
277
278% Since all \c{,omment} does is throw away the argument, we can let TeX
279% do that for us.  The \relax here is matched by the \relax in the call
280% in \parseargline; it could be more or less anything, its purpose is
281% just to delimit the argument to the \c.
282\def\argremovec#1\c#2\relax{\toks0 = {#1}}
283\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
284
285% \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
286%    @end itemize  @c foo
287% will have two active spaces as part of the argument with the
288% `itemize'.  Here we remove all active spaces from #1, and assign the
289% result to \toks0.
290%
291% This loses if there are any *other* active characters besides spaces
292% in the argument -- _ ^ +, for example -- since they get expanded.
293% Fortunately, Texinfo does not define any such commands.  (If it ever
294% does, the catcode of the characters in questionwill have to be changed
295% here.)  But this means we cannot call \removeactivespaces as part of
296% \argremovec{,omment}, since @c uses \parsearg, and thus the argument
297% that \parsearg gets might well have any character at all in it.
298%
299\def\removeactivespaces#1{%
300  \begingroup
301    \ignoreactivespaces
302    \edef\temp{#1}%
303    \global\toks0 = \expandafter{\temp}%
304  \endgroup
305}
306
307% Change the active space to expand to nothing.
308%
309\begingroup
310  \obeyspaces
311  \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
312\endgroup
313
314
315\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
316
317%% These are used to keep @begin/@end levels from running away
318%% Call \inENV within environments (after a \begingroup)
319\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
320\def\ENVcheck{%
321\ifENV\errmessage{Still within an environment.  Type Return to continue.}
322\endgroup\fi} % This is not perfect, but it should reduce lossage
323
324% @begin foo  is the same as @foo, for now.
325\newhelp\EMsimple{Type <Return> to continue.}
326
327\outer\def\begin{\parsearg\beginxxx}
328
329\def\beginxxx #1{%
330\expandafter\ifx\csname #1\endcsname\relax
331{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
332\csname #1\endcsname\fi}
333
334% @end foo executes the definition of \Efoo.
335%
336\def\end{\parsearg\endxxx}
337\def\endxxx #1{%
338  \removeactivespaces{#1}%
339  \edef\endthing{\the\toks0}%
340  %
341  \expandafter\ifx\csname E\endthing\endcsname\relax
342    \expandafter\ifx\csname \endthing\endcsname\relax
343      % There's no \foo, i.e., no ``environment'' foo.
344      \errhelp = \EMsimple
345      \errmessage{Undefined command `@end \endthing'}%
346    \else
347      \unmatchedenderror\endthing
348    \fi
349  \else
350    % Everything's ok; the right environment has been started.
351    \csname E\endthing\endcsname
352  \fi
353}
354
355% There is an environment #1, but it hasn't been started.  Give an error.
356%
357\def\unmatchedenderror#1{%
358  \errhelp = \EMsimple
359  \errmessage{This `@end #1' doesn't have a matching `@#1'}%
360}
361
362% Define the control sequence \E#1 to give an unmatched @end error.
363%
364\def\defineunmatchedend#1{%
365  \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
366}
367
368
369% Single-spacing is done by various environments (specifically, in
370% \nonfillstart and \quotations).
371\newskip\singlespaceskip \singlespaceskip = 12.5pt
372\def\singlespace{%
373  % Why was this kern here?  It messes up equalizing space above and below
374  % environments.  --karl, 6may93
375  %{\advance \baselineskip by -\singlespaceskip
376  %\kern \baselineskip}%
377  \setleading \singlespaceskip
378}
379
380%% Simple single-character @ commands
381
382% @@ prints an @
383% Kludge this until the fonts are right (grr).
384\def\@{{\tt \char '100}}
385
386% This is turned off because it was never documented
387% and you can use @w{...} around a quote to suppress ligatures.
388%% Define @` and @' to be the same as ` and '
389%% but suppressing ligatures.
390%\def\`{{`}}
391%\def\'{{'}}
392
393% Used to generate quoted braces.
394\def\mylbrace {{\tt \char '173}}
395\def\myrbrace {{\tt \char '175}}
396\let\{=\mylbrace
397\let\}=\myrbrace
398\begingroup
399  % Definitions to produce actual \{ & \} command in an index.
400  \catcode`\{ = 12 \catcode`\} = 12
401  \catcode`\[ = 1 \catcode`\] = 2
402  \catcode`\@ = 0 \catcode`\\ = 12
403  @gdef@lbracecmd[\{]%
404  @gdef@rbracecmd[\}]%
405@endgroup
406
407% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
408% Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H.
409\let\, = \c
410\let\dotaccent = \.
411\def\ringaccent#1{{\accent23 #1}}
412\let\tieaccent = \t
413\let\ubaraccent = \b
414\let\udotaccent = \d
415
416% Other special characters: @questiondown @exclamdown
417% Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss.
418\def\questiondown{?`}
419\def\exclamdown{!`}
420
421% Dotless i and dotless j, used for accents.
422\def\imacro{i}
423\def\jmacro{j}
424\def\dotless#1{%
425  \def\temp{#1}%
426  \ifx\temp\imacro \ptexi
427  \else\ifx\temp\jmacro \j
428  \else \errmessage{@dotless can be used only with i or j}%
429  \fi\fi
430}
431
432% @: forces normal size whitespace following.
433\def\:{\spacefactor=1000 }
434
435% @* forces a line break.
436\def\*{\hfil\break\hbox{}\ignorespaces}
437
438% @. is an end-of-sentence period.
439\def\.{.\spacefactor=3000 }
440
441% @enddots{} is an end-of-sentence ellipsis.
442\gdef\enddots{$\mathinner{\ldotp\ldotp\ldotp\ldotp}$\spacefactor=3000}
443
444% @! is an end-of-sentence bang.
445\gdef\!{!\spacefactor=3000 }
446
447% @? is an end-of-sentence query.
448\gdef\?{?\spacefactor=3000 }
449
450% @w prevents a word break.  Without the \leavevmode, @w at the
451% beginning of a paragraph, when TeX is still in vertical mode, would
452% produce a whole line of output instead of starting the paragraph.
453\def\w#1{\leavevmode\hbox{#1}}
454
455% @group ... @end group forces ... to be all on one page, by enclosing
456% it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
457% to keep its height that of a normal line.  According to the rules for
458% \topskip (p.114 of the TeXbook), the glue inserted is
459% max (\topskip - \ht (first item), 0).  If that height is large,
460% therefore, no glue is inserted, and the space between the headline and
461% the text is small, which looks bad.
462%
463\def\group{\begingroup
464  \ifnum\catcode13=\active \else
465    \errhelp = \groupinvalidhelp
466    \errmessage{@group invalid in context where filling is enabled}%
467  \fi
468  %
469  % The \vtop we start below produces a box with normal height and large
470  % depth; thus, TeX puts \baselineskip glue before it, and (when the
471  % next line of text is done) \lineskip glue after it.  (See p.82 of
472  % the TeXbook.)  Thus, space below is not quite equal to space
473  % above.  But it's pretty close.
474  \def\Egroup{%
475    \egroup           % End the \vtop.
476    \endgroup         % End the \group.
477  }%
478  %
479  \vtop\bgroup
480    % We have to put a strut on the last line in case the @group is in
481    % the midst of an example, rather than completely enclosing it.
482    % Otherwise, the interline space between the last line of the group
483    % and the first line afterwards is too small.  But we can't put the
484    % strut in \Egroup, since there it would be on a line by itself.
485    % Hence this just inserts a strut at the beginning of each line.
486    \everypar = {\strut}%
487    %
488    % Since we have a strut on every line, we don't need any of TeX's
489    % normal interline spacing.
490    \offinterlineskip
491    %
492    % OK, but now we have to do something about blank
493    % lines in the input in @example-like environments, which normally
494    % just turn into \lisppar, which will insert no space now that we've
495    % turned off the interline space.  Simplest is to make them be an
496    % empty paragraph.
497    \ifx\par\lisppar
498      \edef\par{\leavevmode \par}%
499      %
500      % Reset ^^M's definition to new definition of \par.
501      \obeylines
502    \fi
503    %
504    % Do @comment since we are called inside an environment such as
505    % @example, where each end-of-line in the input causes an
506    % end-of-line in the output.  We don't want the end-of-line after
507    % the `@group' to put extra space in the output.  Since @group
508    % should appear on a line by itself (according to the Texinfo
509    % manual), we don't worry about eating any user text.
510    \comment
511}
512%
513% TeX puts in an \escapechar (i.e., `@') at the beginning of the help
514% message, so this ends up printing `@group can only ...'.
515%
516\newhelp\groupinvalidhelp{%
517group can only be used in environments such as @example,^^J%
518where each line of input produces a line of output.}
519
520% @need space-in-mils
521% forces a page break if there is not space-in-mils remaining.
522
523\newdimen\mil  \mil=0.001in
524
525\def\need{\parsearg\needx}
526
527% Old definition--didn't work.
528%\def\needx #1{\par %
529%% This method tries to make TeX break the page naturally
530%% if the depth of the box does not fit.
531%{\baselineskip=0pt%
532%\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000
533%\prevdepth=-1000pt
534%}}
535
536\def\needx#1{%
537  % Go into vertical mode, so we don't make a big box in the middle of a
538  % paragraph.
539  \par
540  %
541  % Don't add any leading before our big empty box, but allow a page
542  % break, since the best break might be right here.
543  \allowbreak
544  \nointerlineskip
545  \vtop to #1\mil{\vfil}%
546  %
547  % TeX does not even consider page breaks if a penalty added to the
548  % main vertical list is 10000 or more.  But in order to see if the
549  % empty box we just added fits on the page, we must make it consider
550  % page breaks.  On the other hand, we don't want to actually break the
551  % page after the empty box.  So we use a penalty of 9999.
552  %
553  % There is an extremely small chance that TeX will actually break the
554  % page at this \penalty, if there are no other feasible breakpoints in
555  % sight.  (If the user is using lots of big @group commands, which
556  % almost-but-not-quite fill up a page, TeX will have a hard time doing
557  % good page breaking, for example.)  However, I could not construct an
558  % example where a page broke at this \penalty; if it happens in a real
559  % document, then we can reconsider our strategy.
560  \penalty9999
561  %
562  % Back up by the size of the box, whether we did a page break or not.
563  \kern -#1\mil
564  %
565  % Do not allow a page break right after this kern.
566  \nobreak
567}
568
569% @br   forces paragraph break
570
571\let\br = \par
572
573% @dots{}  output some dots
574
575\def\dots{$\ldots$}
576
577% @page    forces the start of a new page
578
579\def\page{\par\vfill\supereject}
580
581% @exdent text....
582% outputs text on separate line in roman font, starting at standard page margin
583
584% This records the amount of indent in the innermost environment.
585% That's how much \exdent should take out.
586\newskip\exdentamount
587
588% This defn is used inside fill environments such as @defun.
589\def\exdent{\parsearg\exdentyyy}
590\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
591
592% This defn is used inside nofill environments such as @example.
593\def\nofillexdent{\parsearg\nofillexdentyyy}
594\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
595\leftline{\hskip\leftskip{\rm#1}}}}
596
597% @inmargin{TEXT} puts TEXT in the margin next to the current paragraph.
598
599\def\inmargin#1{%
600\strut\vadjust{\nobreak\kern-\strutdepth
601  \vtop to \strutdepth{\baselineskip\strutdepth\vss
602  \llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}}
603\newskip\inmarginspacing \inmarginspacing=1cm
604\def\strutdepth{\dp\strutbox}
605
606%\hbox{{\rm#1}}\hfil\break}}
607
608% @include file    insert text of that file as input.
609% Allow normal characters that  we make active in the argument (a file name).
610\def\include{\begingroup
611  \catcode`\\=12
612  \catcode`~=12
613  \catcode`^=12
614  \catcode`_=12
615  \catcode`|=12
616  \catcode`<=12
617  \catcode`>=12
618  \catcode`+=12
619  \parsearg\includezzz}
620% Restore active chars for included file.
621\def\includezzz#1{\endgroup\begingroup
622  % Read the included file in a group so nested @include's work.
623  \def\thisfile{#1}%
624  \input\thisfile
625\endgroup}
626
627\def\thisfile{}
628
629% @center line   outputs that line, centered
630
631\def\center{\parsearg\centerzzz}
632\def\centerzzz #1{{\advance\hsize by -\leftskip
633\advance\hsize by -\rightskip
634\centerline{#1}}}
635
636% @sp n   outputs n lines of vertical space
637
638\def\sp{\parsearg\spxxx}
639\def\spxxx #1{\vskip #1\baselineskip}
640
641% @comment ...line which is ignored...
642% @c is the same as @comment
643% @ignore ... @end ignore  is another way to write a comment
644
645\def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other%
646\parsearg \commentxxx}
647
648\def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 }
649
650\let\c=\comment
651
652% @paragraphindent  is defined for the Info formatting commands only.
653\let\paragraphindent=\comment
654
655% Prevent errors for section commands.
656% Used in @ignore and in failing conditionals.
657\def\ignoresections{%
658\let\chapter=\relax
659\let\unnumbered=\relax
660\let\top=\relax
661\let\unnumberedsec=\relax
662\let\unnumberedsection=\relax
663\let\unnumberedsubsec=\relax
664\let\unnumberedsubsection=\relax
665\let\unnumberedsubsubsec=\relax
666\let\unnumberedsubsubsection=\relax
667\let\section=\relax
668\let\subsec=\relax
669\let\subsubsec=\relax
670\let\subsection=\relax
671\let\subsubsection=\relax
672\let\appendix=\relax
673\let\appendixsec=\relax
674\let\appendixsection=\relax
675\let\appendixsubsec=\relax
676\let\appendixsubsection=\relax
677\let\appendixsubsubsec=\relax
678\let\appendixsubsubsection=\relax
679\let\contents=\relax
680\let\smallbook=\relax
681\let\titlepage=\relax
682}
683
684% Used in nested conditionals, where we have to parse the Texinfo source
685% and so want to turn off most commands, in case they are used
686% incorrectly.
687%
688\def\ignoremorecommands{%
689  \let\defcodeindex = \relax
690  \let\defcv = \relax
691  \let\deffn = \relax
692  \let\deffnx = \relax
693  \let\defindex = \relax
694  \let\defivar = \relax
695  \let\defmac = \relax
696  \let\defmethod = \relax
697  \let\defop = \relax
698  \let\defopt = \relax
699  \let\defspec = \relax
700  \let\deftp = \relax
701  \let\deftypefn = \relax
702  \let\deftypefun = \relax
703  \let\deftypevar = \relax
704  \let\deftypevr = \relax
705  \let\defun = \relax
706  \let\defvar = \relax
707  \let\defvr = \relax
708  \let\ref = \relax
709  \let\xref = \relax
710  \let\printindex = \relax
711  \let\pxref = \relax
712  \let\settitle = \relax
713  \let\setchapternewpage = \relax
714  \let\setchapterstyle = \relax
715  \let\everyheading = \relax
716  \let\evenheading = \relax
717  \let\oddheading = \relax
718  \let\everyfooting = \relax
719  \let\evenfooting = \relax
720  \let\oddfooting = \relax
721  \let\headings = \relax
722  \let\include = \relax
723  \let\lowersections = \relax
724  \let\down = \relax
725  \let\raisesections = \relax
726  \let\up = \relax
727  \let\set = \relax
728  \let\clear = \relax
729  \let\item = \relax
730}
731
732% Ignore @ignore ... @end ignore.
733%
734\def\ignore{\doignore{ignore}}
735
736% Also ignore @ifinfo, @ifhtml, @html, @menu, and @direntry text.
737%
738\def\ifinfo{\doignore{ifinfo}}
739\def\ifhtml{\doignore{ifhtml}}
740\def\ifnottex{\doignore{ifnottex}}
741\def\html{\doignore{html}}
742\def\menu{\doignore{menu}}
743\def\direntry{\doignore{direntry}}
744
745% Also ignore @macro ... @end macro.  The user must run texi2dvi,
746% which runs makeinfo to do macro expansion.  Ignore @unmacro, too.
747\def\macro{\doignore{macro}}
748\let\unmacro = \comment
749
750
751% @dircategory CATEGORY  -- specify a category of the dir file
752% which this file should belong to.  Ignore this in TeX.
753\let\dircategory = \comment
754
755% Ignore text until a line `@end #1'.
756%
757\def\doignore#1{\begingroup
758  % Don't complain about control sequences we have declared \outer.
759  \ignoresections
760  %
761  % Define a command to swallow text until we reach `@end #1'.
762  \long\def\doignoretext##1\end #1{\enddoignore}%
763  %
764  % Make sure that spaces turn into tokens that match what \doignoretext wants.
765  \catcode32 = 10
766  %
767  % And now expand that command.
768  \doignoretext
769}
770
771% What we do to finish off ignored text.
772%
773\def\enddoignore{\endgroup\ignorespaces}%
774
775\newif\ifwarnedobs\warnedobsfalse
776\def\obstexwarn{%
777  \ifwarnedobs\relax\else
778  % We need to warn folks that they may have trouble with TeX 3.0.
779  % This uses \immediate\write16 rather than \message to get newlines.
780    \immediate\write16{}
781    \immediate\write16{***WARNING*** for users of Unix TeX 3.0!}
782    \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
783    \immediate\write16{If you are running another version of TeX, relax.}
784    \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
785    \immediate\write16{  Then upgrade your TeX installation if you can.}
786    \immediate\write16{  (See ftp://ftp.gnu.ai.mit.edu/pub/gnu/TeX.README.)}
787    \immediate\write16{If you are stuck with version 3.0, run the}
788    \immediate\write16{  script ``tex3patch'' from the Texinfo distribution}
789    \immediate\write16{  to use a workaround.}
790    \immediate\write16{}
791    \global\warnedobstrue
792    \fi
793}
794
795% **In TeX 3.0, setting text in \nullfont hangs tex.  For a
796% workaround (which requires the file ``dummy.tfm'' to be installed),
797% uncomment the following line:
798%%%%%\font\nullfont=dummy\let\obstexwarn=\relax
799
800% Ignore text, except that we keep track of conditional commands for
801% purposes of nesting, up to an `@end #1' command.
802%
803\def\nestedignore#1{%
804  \obstexwarn
805  % We must actually expand the ignored text to look for the @end
806  % command, so that nested ignore constructs work.  Thus, we put the
807  % text into a \vbox and then do nothing with the result.  To minimize
808  % the change of memory overflow, we follow the approach outlined on
809  % page 401 of the TeXbook: make the current font be a dummy font.
810  %
811  \setbox0 = \vbox\bgroup
812    % Don't complain about control sequences we have declared \outer.
813    \ignoresections
814    %
815    % Define `@end #1' to end the box, which will in turn undefine the
816    % @end command again.
817    \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
818    %
819    % We are going to be parsing Texinfo commands.  Most cause no
820    % trouble when they are used incorrectly, but some commands do
821    % complicated argument parsing or otherwise get confused, so we
822    % undefine them.
823    %
824    % We can't do anything about stray @-signs, unfortunately;
825    % they'll produce `undefined control sequence' errors.
826    \ignoremorecommands
827    %
828    % Set the current font to be \nullfont, a TeX primitive, and define
829    % all the font commands to also use \nullfont.  We don't use
830    % dummy.tfm, as suggested in the TeXbook, because not all sites
831    % might have that installed.  Therefore, math mode will still
832    % produce output, but that should be an extremely small amount of
833    % stuff compared to the main input.
834    %
835    \nullfont
836    \let\tenrm = \nullfont  \let\tenit = \nullfont  \let\tensl = \nullfont
837    \let\tenbf = \nullfont  \let\tentt = \nullfont  \let\smallcaps = \nullfont
838    \let\tensf = \nullfont
839    % Similarly for index fonts (mostly for their use in
840    % smallexample)
841    \let\indrm = \nullfont  \let\indit = \nullfont  \let\indsl = \nullfont
842    \let\indbf = \nullfont  \let\indtt = \nullfont  \let\indsc = \nullfont
843    \let\indsf = \nullfont
844    %
845    % Don't complain when characters are missing from the fonts.
846    \tracinglostchars = 0
847    %
848    % Don't bother to do space factor calculations.
849    \frenchspacing
850    %
851    % Don't report underfull hboxes.
852    \hbadness = 10000
853    %
854    % Do minimal line-breaking.
855    \pretolerance = 10000
856    %
857    % Do not execute instructions in @tex
858    \def\tex{\doignore{tex}}
859}
860
861% @set VAR sets the variable VAR to an empty value.
862% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
863%
864% Since we want to separate VAR from REST-OF-LINE (which might be
865% empty), we can't just use \parsearg; we have to insert a space of our
866% own to delimit the rest of the line, and then take it out again if we
867% didn't need it.  Make sure the catcode of space is correct to avoid
868% losing inside @example, for instance.
869%
870\def\set{\begingroup\catcode` =10
871  \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR.
872  \parsearg\setxxx}
873\def\setxxx#1{\setyyy#1 \endsetyyy}
874\def\setyyy#1 #2\endsetyyy{%
875  \def\temp{#2}%
876  \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
877  \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
878  \fi
879  \endgroup
880}
881% Can't use \xdef to pre-expand #2 and save some time, since \temp or
882% \next or other control sequences that we've defined might get us into
883% an infinite loop. Consider `@set foo @cite{bar}'.
884\def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}}
885
886% @clear VAR clears (i.e., unsets) the variable VAR.
887%
888\def\clear{\parsearg\clearxxx}
889\def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax}
890
891% @value{foo} gets the text saved in variable foo.
892%
893\def\value{\begingroup
894  \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR.
895  \valuexxx}
896\def\valuexxx#1{%
897  \expandafter\ifx\csname SET#1\endcsname\relax
898    {\{No value for ``#1''\}}%
899  \else
900    \csname SET#1\endcsname
901  \fi
902\endgroup}
903
904% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
905% with @set.
906%
907\def\ifset{\parsearg\ifsetxxx}
908\def\ifsetxxx #1{%
909  \expandafter\ifx\csname SET#1\endcsname\relax
910    \expandafter\ifsetfail
911  \else
912    \expandafter\ifsetsucceed
913  \fi
914}
915\def\ifsetsucceed{\conditionalsucceed{ifset}}
916\def\ifsetfail{\nestedignore{ifset}}
917\defineunmatchedend{ifset}
918
919% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
920% defined with @set, or has been undefined with @clear.
921%
922\def\ifclear{\parsearg\ifclearxxx}
923\def\ifclearxxx #1{%
924  \expandafter\ifx\csname SET#1\endcsname\relax
925    \expandafter\ifclearsucceed
926  \else
927    \expandafter\ifclearfail
928  \fi
929}
930\def\ifclearsucceed{\conditionalsucceed{ifclear}}
931\def\ifclearfail{\nestedignore{ifclear}}
932\defineunmatchedend{ifclear}
933
934% @iftex always succeeds; we read the text following, through @end
935% iftex).  But `@end iftex' should be valid only after an @iftex.
936%
937\def\iftex{\conditionalsucceed{iftex}}
938\def\ifnothtml{\conditionalsucceed{ifnothtml}}
939\def\ifnotinfo{\conditionalsucceed{ifnotinfo}}
940\defineunmatchedend{iftex}
941\defineunmatchedend{ifnothtml}
942\defineunmatchedend{ifnotinfo}
943
944% We can't just want to start a group at @iftex (for example) and end it
945% at @end iftex, since then @set commands inside the conditional have no
946% effect (they'd get reverted at the end of the group).  So we must
947% define \Eiftex to redefine itself to be its previous value.  (We can't
948% just define it to fail again with an ``unmatched end'' error, since
949% the @ifset might be nested.)
950%
951\def\conditionalsucceed#1{%
952  \edef\temp{%
953    % Remember the current value of \E#1.
954    \let\nece{prevE#1} = \nece{E#1}%
955    %
956    % At the `@end #1', redefine \E#1 to be its previous value.
957    \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
958  }%
959  \temp
960}
961
962% We need to expand lots of \csname's, but we don't want to expand the
963% control sequences after we've constructed them.
964%
965\def\nece#1{\expandafter\noexpand\csname#1\endcsname}
966
967% @asis just yields its argument.  Used with @table, for example.
968%
969\def\asis#1{#1}
970
971% @math means output in math mode.
972% We don't use $'s directly in the definition of \math because control
973% sequences like \math are expanded when the toc file is written.  Then,
974% we read the toc file back, the $'s will be normal characters (as they
975% should be, according to the definition of Texinfo).  So we must use a
976% control sequence to switch into and out of math mode.
977%
978% This isn't quite enough for @math to work properly in indices, but it
979% seems unlikely it will ever be needed there.
980%
981\let\implicitmath = $
982\def\math#1{\implicitmath #1\implicitmath}
983
984% @bullet and @minus need the same treatment as @math, just above.
985\def\bullet{\implicitmath\ptexbullet\implicitmath}
986\def\minus{\implicitmath-\implicitmath}
987
988\def\node{\ENVcheck\parsearg\nodezzz}
989\def\nodezzz#1{\nodexxx [#1,]}
990\def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
991\let\nwnode=\node
992\let\lastnode=\relax
993
994\def\donoderef{\ifx\lastnode\relax\else
995\expandafter\expandafter\expandafter\setref{\lastnode}\fi
996\global\let\lastnode=\relax}
997
998\def\unnumbnoderef{\ifx\lastnode\relax\else
999\expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
1000\global\let\lastnode=\relax}
1001
1002\def\appendixnoderef{\ifx\lastnode\relax\else
1003\expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
1004\global\let\lastnode=\relax}
1005
1006% @refill is a no-op.
1007\let\refill=\relax
1008
1009% @setfilename is done at the beginning of every texinfo file.
1010% So open here the files we need to have open while reading the input.
1011% This makes it possible to make a .fmt file for texinfo.
1012\def\setfilename{%
1013   \readauxfile
1014   \opencontents
1015   \openindices
1016   \fixbackslash  % Turn off hack to swallow `\input texinfo'.
1017   \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
1018   \comment % Ignore the actual filename.
1019}
1020
1021% @bye.
1022\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
1023
1024% \def\macro#1{\begingroup\ignoresections\catcode`\#=6\def\macrotemp{#1}\parsearg\macroxxx}
1025% \def\macroxxx#1#2 \end macro{%
1026% \expandafter\gdef\macrotemp#1{#2}%
1027% \endgroup}
1028
1029%\def\linemacro#1{\begingroup\ignoresections\catcode`\#=6\def\macrotemp{#1}\parsearg\linemacroxxx}
1030%\def\linemacroxxx#1#2 \end linemacro{%
1031%\let\parsearg=\relax
1032%\edef\macrotempx{\csname M\butfirst\expandafter\string\macrotemp\endcsname}%
1033%\expandafter\xdef\macrotemp{\parsearg\macrotempx}%
1034%\expandafter\gdef\macrotempx#1{#2}%
1035%\endgroup}
1036
1037%\def\butfirst#1{}
1038
1039
1040\message{fonts,}
1041
1042% Font-change commands.
1043
1044% Texinfo supports the sans serif font style, which plain TeX does not.
1045% So we set up a \sf analogous to plain's \rm, etc.
1046\newfam\sffam
1047\def\sf{\fam=\sffam \tensf}
1048\let\li = \sf % Sometimes we call it \li, not \sf.
1049
1050% We don't need math for this one.
1051\def\ttsl{\tenttsl}
1052
1053%% Try out Computer Modern fonts at \magstephalf
1054\let\mainmagstep=\magstephalf
1055
1056% Set the font macro #1 to the font named #2, adding on the
1057% specified font prefix (normally `cm').
1058% #3 is the font's design size, #4 is a scale factor
1059\def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4}
1060
1061% Use cm as the default font prefix.
1062% To specify the font prefix, you must define \fontprefix
1063% before you read in texinfo.tex.
1064\ifx\fontprefix\undefined
1065\def\fontprefix{cm}
1066\fi
1067% Support font families that don't use the same naming scheme as CM.
1068\def\rmshape{r}
1069\def\rmbshape{bx}               %where the normal face is bold
1070\def\bfshape{b}
1071\def\bxshape{bx}
1072\def\ttshape{tt}
1073\def\ttbshape{tt}
1074\def\ttslshape{sltt}
1075\def\itshape{ti}
1076\def\itbshape{bxti}
1077\def\slshape{sl}
1078\def\slbshape{bxsl}
1079\def\sfshape{ss}
1080\def\sfbshape{ss}
1081\def\scshape{csc}
1082\def\scbshape{csc}
1083
1084\ifx\bigger\relax
1085\let\mainmagstep=\magstep1
1086\setfont\textrm\rmshape{12}{1000}
1087\setfont\texttt\ttshape{12}{1000}
1088\else
1089\setfont\textrm\rmshape{10}{\mainmagstep}
1090\setfont\texttt\ttshape{10}{\mainmagstep}
1091\fi
1092% Instead of cmb10, you many want to use cmbx10.
1093% cmbx10 is a prettier font on its own, but cmb10
1094% looks better when embedded in a line with cmr10.
1095\setfont\textbf\bfshape{10}{\mainmagstep}
1096\setfont\textit\itshape{10}{\mainmagstep}
1097\setfont\textsl\slshape{10}{\mainmagstep}
1098\setfont\textsf\sfshape{10}{\mainmagstep}
1099\setfont\textsc\scshape{10}{\mainmagstep}
1100\setfont\textttsl\ttslshape{10}{\mainmagstep}
1101\font\texti=cmmi10 scaled \mainmagstep
1102\font\textsy=cmsy10 scaled \mainmagstep
1103
1104% A few fonts for @defun, etc.
1105\setfont\defbf\bxshape{10}{\magstep1} %was 1314
1106\setfont\deftt\ttshape{10}{\magstep1}
1107\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
1108
1109% Fonts for indices and small examples (9pt).
1110% We actually use the slanted font rather than the italic,
1111% because texinfo normally uses the slanted fonts for that.
1112% Do not make many font distinctions in general in the index, since they
1113% aren't very useful.
1114\setfont\ninett\ttshape{9}{1000}
1115\setfont\indrm\rmshape{9}{1000}
1116\setfont\indit\slshape{9}{1000}
1117\let\indsl=\indit
1118\let\indtt=\ninett
1119\let\indttsl=\ninett
1120\let\indsf=\indrm
1121\let\indbf=\indrm
1122\setfont\indsc\scshape{10}{900}
1123\font\indi=cmmi9
1124\font\indsy=cmsy9
1125
1126% Chapter (and unnumbered) fonts (17.28pt).
1127\setfont\chaprm\rmbshape{12}{\magstep2}
1128\setfont\chapit\itbshape{10}{\magstep3}
1129\setfont\chapsl\slbshape{10}{\magstep3}
1130\setfont\chaptt\ttbshape{12}{\magstep2}
1131\setfont\chapttsl\ttslshape{10}{\magstep3}
1132\setfont\chapsf\sfbshape{12}{\magstep2}
1133\let\chapbf=\chaprm
1134\setfont\chapsc\scbshape{10}{\magstep3}
1135\font\chapi=cmmi12 scaled \magstep2
1136\font\chapsy=cmsy10 scaled \magstep3
1137
1138% Section fonts (14.4pt).
1139\setfont\secrm\rmbshape{12}{\magstep1}
1140\setfont\secit\itbshape{10}{\magstep2}
1141\setfont\secsl\slbshape{10}{\magstep2}
1142\setfont\sectt\ttbshape{12}{\magstep1}
1143\setfont\secttsl\ttslshape{10}{\magstep2}
1144\setfont\secsf\sfbshape{12}{\magstep1}
1145\let\secbf\secrm
1146\setfont\secsc\scbshape{10}{\magstep2}
1147\font\seci=cmmi12 scaled \magstep1
1148\font\secsy=cmsy10 scaled \magstep2
1149
1150% \setfont\ssecrm\bxshape{10}{\magstep1}    % This size an font looked bad.
1151% \setfont\ssecit\itshape{10}{\magstep1}    % The letters were too crowded.
1152% \setfont\ssecsl\slshape{10}{\magstep1}
1153% \setfont\ssectt\ttshape{10}{\magstep1}
1154% \setfont\ssecsf\sfshape{10}{\magstep1}
1155
1156%\setfont\ssecrm\bfshape{10}{1315}      % Note the use of cmb rather than cmbx.
1157%\setfont\ssecit\itshape{10}{1315}      % Also, the size is a little larger than
1158%\setfont\ssecsl\slshape{10}{1315}      % being scaled magstep1.
1159%\setfont\ssectt\ttshape{10}{1315}
1160%\setfont\ssecsf\sfshape{10}{1315}
1161
1162%\let\ssecbf=\ssecrm
1163
1164% Subsection fonts (13.15pt).
1165\setfont\ssecrm\rmbshape{12}{\magstephalf}
1166\setfont\ssecit\itbshape{10}{1315}
1167\setfont\ssecsl\slbshape{10}{1315}
1168\setfont\ssectt\ttbshape{12}{\magstephalf}
1169\setfont\ssecttsl\ttslshape{10}{\magstep1}
1170\setfont\ssecsf\sfbshape{12}{\magstephalf}
1171\let\ssecbf\ssecrm
1172\setfont\ssecsc\scbshape{10}{\magstep1}
1173\font\sseci=cmmi12 scaled \magstephalf
1174\font\ssecsy=cmsy10 scaled \magstep1
1175% The smallcaps and symbol fonts should actually be scaled \magstep1.5,
1176% but that is not a standard magnification.
1177
1178% Fonts for title page:
1179\setfont\titlerm\rmbshape{12}{\magstep3}
1180\let\authorrm = \secrm
1181
1182% In order for the font changes to affect most math symbols and letters,
1183% we have to define the \textfont of the standard families.  Since
1184% texinfo doesn't allow for producing subscripts and superscripts, we
1185% don't bother to reset \scriptfont and \scriptscriptfont (which would
1186% also require loading a lot more fonts).
1187%
1188\def\resetmathfonts{%
1189  \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
1190  \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
1191  \textfont\ttfam = \tentt \textfont\sffam = \tensf
1192}
1193
1194
1195% The font-changing commands redefine the meanings of \tenSTYLE, instead
1196% of just \STYLE.  We do this so that font changes will continue to work
1197% in math mode, where it is the current \fam that is relevant in most
1198% cases, not the current font.  Plain TeX does \def\bf{\fam=\bffam
1199% \tenbf}, for example.  By redefining \tenbf, we obviate the need to
1200% redefine \bf itself.
1201\def\textfonts{%
1202  \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
1203  \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
1204  \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl
1205  \resetmathfonts}
1206\def\chapfonts{%
1207  \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
1208  \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
1209  \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl
1210  \resetmathfonts \setleading{19pt}}
1211\def\secfonts{%
1212  \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
1213  \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
1214  \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl
1215  \resetmathfonts \setleading{16pt}}
1216\def\subsecfonts{%
1217  \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
1218  \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
1219  \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl
1220  \resetmathfonts \setleading{15pt}}
1221\let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf?
1222\def\indexfonts{%
1223  \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl
1224  \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc
1225  \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy \let\tenttsl=\indttsl
1226  \resetmathfonts \setleading{12pt}}
1227
1228% Set up the default fonts, so we can use them for creating boxes.
1229%
1230\textfonts
1231
1232% Count depth in font-changes, for error checks
1233\newcount\fontdepth \fontdepth=0
1234
1235% Fonts for short table of contents.
1236\setfont\shortcontrm\rmshape{12}{1000}
1237\setfont\shortcontbf\bxshape{12}{1000}
1238\setfont\shortcontsl\slshape{12}{1000}
1239
1240%% Add scribe-like font environments, plus @l for inline lisp (usually sans
1241%% serif) and @ii for TeX italic
1242
1243% \smartitalic{ARG} outputs arg in italics, followed by an italic correction
1244% unless the following character is such as not to need one.
1245\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
1246\def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
1247
1248\let\i=\smartitalic
1249\let\var=\smartitalic
1250\let\dfn=\smartitalic
1251\let\emph=\smartitalic
1252\let\cite=\smartitalic
1253
1254\def\b#1{{\bf #1}}
1255\let\strong=\b
1256
1257% We can't just use \exhyphenpenalty, because that only has effect at
1258% the end of a paragraph.  Restore normal hyphenation at the end of the
1259% group within which \nohyphenation is presumably called.
1260%
1261\def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
1262\def\restorehyphenation{\hyphenchar\font = `- }
1263
1264\def\t#1{%
1265  {\tt \rawbackslash \frenchspacing #1}%
1266  \null
1267}
1268\let\ttfont=\t
1269\def\samp #1{`\tclose{#1}'\null}
1270\setfont\smallrm\rmshape{8}{1000}
1271\font\smallsy=cmsy9
1272\def\key#1{{\smallrm\textfont2=\smallsy \leavevmode\hbox{%
1273  \raise0.4pt\hbox{$\langle$}\kern-.08em\vtop{%
1274    \vbox{\hrule\kern-0.4pt
1275     \hbox{\raise0.4pt\hbox{\vphantom{$\langle$}}#1}}%
1276    \kern-0.4pt\hrule}%
1277  \kern-.06em\raise0.4pt\hbox{$\rangle$}}}}
1278% The old definition, with no lozenge:
1279%\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null}
1280\def\ctrl #1{{\tt \rawbackslash \hat}#1}
1281
1282\let\file=\samp
1283%\let\url=\samp % perhaps include a hypertex \special eventually
1284%\def\email#1{$\langle${\tt #1}$\rangle$}
1285
1286% @code is a modification of @t,
1287% which makes spaces the same size as normal in the surrounding text.
1288\def\tclose#1{%
1289  {%
1290    % Change normal interword space to be same as for the current font.
1291    \spaceskip = \fontdimen2\font
1292    %
1293    % Switch to typewriter.
1294    \tt
1295    %
1296    % But `\ ' produces the large typewriter interword space.
1297    \def\ {{\spaceskip = 0pt{} }}%
1298    %
1299    % Turn off hyphenation.
1300    \nohyphenation
1301    %
1302    \rawbackslash
1303    \frenchspacing
1304    #1%
1305  }%
1306  \null
1307}
1308
1309% We *must* turn on hyphenation at `-' and `_' in \code.
1310% Otherwise, it is too hard to avoid overfull hboxes
1311% in the Emacs manual, the Library manual, etc.
1312
1313% Unfortunately, TeX uses one parameter (\hyphenchar) to control
1314% both hyphenation at - and hyphenation within words.
1315% We must therefore turn them both off (\tclose does that)
1316% and arrange explicitly to hyphenate at a dash.
1317%  -- rms.
1318{
1319\catcode`\-=\active
1320\catcode`\_=\active
1321\catcode`\|=\active
1322\global\def\code{\begingroup \catcode`\-=\active \let-\codedash \catcode`\_=\active \let_\codeunder \codex}
1323% The following is used by \doprintindex to insure that long function names
1324% wrap around.  It is necessary for - and _ to be active before the index is
1325% read from the file, as \entry parses the arguments long before \code is
1326% ever called.  -- mycroft
1327% _ is always active; and it shouldn't be \let = to an _ that is a
1328% subscript character anyway. Then, @cindex @samp{_} (for example)
1329% fails.  --karl
1330\global\def\indexbreaks{%
1331  \catcode`\-=\active \let-\realdash
1332}
1333}
1334
1335\def\realdash{-}
1336\def\codedash{-\discretionary{}{}{}}
1337\def\codeunder{\normalunderscore\discretionary{}{}{}}
1338\def\codex #1{\tclose{#1}\endgroup}
1339
1340%\let\exp=\tclose  %Was temporary
1341
1342% @kbd is like @code, except that if the argument is just one @key command,
1343% then @kbd has no effect.
1344%
1345\def\xkey{\key}
1346\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
1347\ifx\one\xkey\ifx\threex\three \key{#2}%
1348\else{\tclose{\ttsl\look}}\fi
1349\else{\tclose{\ttsl\look}}\fi}
1350
1351% @url.  Quotes do not seem necessary, so use \code.
1352\let\url=\code
1353
1354% @uref (abbreviation for `urlref') takes an optional second argument
1355% specifying the text to display.  First (mandatory) arg is the url.
1356% Perhaps eventually put in a hypertex \special here.
1357%
1358\def\uref#1{\urefxxx #1,,\finish}
1359\def\urefxxx#1,#2,#3\finish{%
1360  \setbox0 = \hbox{\ignorespaces #2}%
1361  \ifdim\wd0 > 0pt
1362    \unhbox0\ (\code{#1})%
1363  \else
1364    \code{#1}%
1365  \fi
1366}
1367
1368% rms does not like the angle brackets --karl, 17may97.
1369% So now @email is just like @uref.
1370%\def\email#1{\angleleft{\tt #1}\angleright}
1371\let\email=\uref
1372
1373% Check if we are currently using a typewriter font.  Since all the
1374% Computer Modern typewriter fonts have zero interword stretch (and
1375% shrink), and it is reasonable to expect all typewriter fonts to have
1376% this property, we can check that font parameter.
1377%
1378\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
1379
1380% Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
1381% argument is to make the input look right: @dmn{pt} instead of
1382% @dmn{}pt.
1383%
1384\def\dmn#1{\thinspace #1}
1385
1386\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
1387
1388% @l was never documented to mean ``switch to the Lisp font'',
1389% and it is not used as such in any manual I can find.  We need it for
1390% Polish suppressed-l.  --karl, 22sep96.
1391%\def\l#1{{\li #1}\null}
1392
1393\def\r#1{{\rm #1}}              % roman font
1394% Use of \lowercase was suggested.
1395\def\sc#1{{\smallcaps#1}}       % smallcaps font
1396\def\ii#1{{\it #1}}             % italic font
1397
1398% @pounds{} is a sterling sign.
1399\def\pounds{{\it\$}}
1400
1401
1402\message{page headings,}
1403
1404\newskip\titlepagetopglue \titlepagetopglue = 1.5in
1405\newskip\titlepagebottomglue \titlepagebottomglue = 2pc
1406
1407% First the title page.  Must do @settitle before @titlepage.
1408\def\titlefont#1{{\titlerm #1}}
1409
1410\newif\ifseenauthor
1411\newif\iffinishedtitlepage
1412
1413\def\shorttitlepage{\parsearg\shorttitlepagezzz}
1414\def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
1415        \endgroup\page\hbox{}\page}
1416
1417\def\titlepage{\begingroup \parindent=0pt \textfonts
1418   \let\subtitlerm=\tenrm
1419% I deinstalled the following change because \cmr12 is undefined.
1420% This change was not in the ChangeLog anyway.  --rms.
1421%   \let\subtitlerm=\cmr12
1422   \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
1423   %
1424   \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
1425   %
1426   % Leave some space at the very top of the page.
1427   \vglue\titlepagetopglue
1428   %
1429   % Now you can print the title using @title.
1430   \def\title{\parsearg\titlezzz}%
1431   \def\titlezzz##1{\leftline{\titlefont{##1}}
1432                    % print a rule at the page bottom also.
1433                    \finishedtitlepagefalse
1434                    \vskip4pt \hrule height 4pt width \hsize \vskip4pt}%
1435   % No rule at page bottom unless we print one at the top with @title.
1436   \finishedtitlepagetrue
1437   %
1438   % Now you can put text using @subtitle.
1439   \def\subtitle{\parsearg\subtitlezzz}%
1440   \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
1441   %
1442   % @author should come last, but may come many times.
1443   \def\author{\parsearg\authorzzz}%
1444   \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
1445      {\authorfont \leftline{##1}}}%
1446   %
1447   % Most title ``pages'' are actually two pages long, with space
1448   % at the top of the second.  We don't want the ragged left on the second.
1449   \let\oldpage = \page
1450   \def\page{%
1451      \iffinishedtitlepage\else
1452         \finishtitlepage
1453      \fi
1454      \oldpage
1455      \let\page = \oldpage
1456      \hbox{}}%
1457%   \def\page{\oldpage \hbox{}}
1458}
1459
1460\def\Etitlepage{%
1461   \iffinishedtitlepage\else
1462      \finishtitlepage
1463   \fi
1464   % It is important to do the page break before ending the group,
1465   % because the headline and footline are only empty inside the group.
1466   % If we use the new definition of \page, we always get a blank page
1467   % after the title page, which we certainly don't want.
1468   \oldpage
1469   \endgroup
1470   \HEADINGSon
1471}
1472
1473\def\finishtitlepage{%
1474   \vskip4pt \hrule height 2pt width \hsize
1475   \vskip\titlepagebottomglue
1476   \finishedtitlepagetrue
1477}
1478
1479%%% Set up page headings and footings.
1480
1481\let\thispage=\folio
1482
1483\newtoks \evenheadline    % Token sequence for heading line of even pages
1484\newtoks \oddheadline     % Token sequence for heading line of odd pages
1485\newtoks \evenfootline    % Token sequence for footing line of even pages
1486\newtoks \oddfootline     % Token sequence for footing line of odd pages
1487
1488% Now make Tex use those variables
1489\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
1490                            \else \the\evenheadline \fi}}
1491\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
1492                            \else \the\evenfootline \fi}\HEADINGShook}
1493\let\HEADINGShook=\relax
1494
1495% Commands to set those variables.
1496% For example, this is what  @headings on  does
1497% @evenheading @thistitle|@thispage|@thischapter
1498% @oddheading @thischapter|@thispage|@thistitle
1499% @evenfooting @thisfile||
1500% @oddfooting ||@thisfile
1501
1502\def\evenheading{\parsearg\evenheadingxxx}
1503\def\oddheading{\parsearg\oddheadingxxx}
1504\def\everyheading{\parsearg\everyheadingxxx}
1505
1506\def\evenfooting{\parsearg\evenfootingxxx}
1507\def\oddfooting{\parsearg\oddfootingxxx}
1508\def\everyfooting{\parsearg\everyfootingxxx}
1509
1510{\catcode`\@=0 %
1511
1512\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
1513\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
1514\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1515
1516\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
1517\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
1518\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1519
1520\gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
1521\gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
1522\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
1523\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1524
1525\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
1526\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
1527\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1528
1529\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
1530\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
1531\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1532
1533\gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
1534\gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
1535\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
1536\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1537%
1538}% unbind the catcode of @.
1539
1540% @headings double      turns headings on for double-sided printing.
1541% @headings single      turns headings on for single-sided printing.
1542% @headings off         turns them off.
1543% @headings on          same as @headings double, retained for compatibility.
1544% @headings after       turns on double-sided headings after this page.
1545% @headings doubleafter turns on double-sided headings after this page.
1546% @headings singleafter turns on single-sided headings after this page.
1547% By default, they are off at the start of a document,
1548% and turned `on' after @end titlepage.
1549
1550\def\headings #1 {\csname HEADINGS#1\endcsname}
1551
1552\def\HEADINGSoff{
1553\global\evenheadline={\hfil} \global\evenfootline={\hfil}
1554\global\oddheadline={\hfil} \global\oddfootline={\hfil}}
1555\HEADINGSoff
1556% When we turn headings on, set the page number to 1.
1557% For double-sided printing, put current file name in lower left corner,
1558% chapter name on inside top of right hand pages, document
1559% title on inside top of left hand pages, and page numbers on outside top
1560% edge of all pages.
1561\def\HEADINGSdouble{
1562\global\pageno=1
1563\global\evenfootline={\hfil}
1564\global\oddfootline={\hfil}
1565\global\evenheadline={\line{\folio\hfil\thistitle}}
1566\global\oddheadline={\line{\thischapter\hfil\folio}}
1567\global\let\contentsalignmacro = \chapoddpage
1568}
1569\let\contentsalignmacro = \chappager
1570
1571% For single-sided printing, chapter title goes across top left of page,
1572% page number on top right.
1573\def\HEADINGSsingle{
1574\global\pageno=1
1575\global\evenfootline={\hfil}
1576\global\oddfootline={\hfil}
1577\global\evenheadline={\line{\thischapter\hfil\folio}}
1578\global\oddheadline={\line{\thischapter\hfil\folio}}
1579\global\let\contentsalignmacro = \chappager
1580}
1581\def\HEADINGSon{\HEADINGSdouble}
1582
1583\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
1584\let\HEADINGSdoubleafter=\HEADINGSafter
1585\def\HEADINGSdoublex{%
1586\global\evenfootline={\hfil}
1587\global\oddfootline={\hfil}
1588\global\evenheadline={\line{\folio\hfil\thistitle}}
1589\global\oddheadline={\line{\thischapter\hfil\folio}}
1590\global\let\contentsalignmacro = \chapoddpage
1591}
1592
1593\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
1594\def\HEADINGSsinglex{%
1595\global\evenfootline={\hfil}
1596\global\oddfootline={\hfil}
1597\global\evenheadline={\line{\thischapter\hfil\folio}}
1598\global\oddheadline={\line{\thischapter\hfil\folio}}
1599\global\let\contentsalignmacro = \chappager
1600}
1601
1602% Subroutines used in generating headings
1603% Produces Day Month Year style of output.
1604\def\today{\number\day\space
1605\ifcase\month\or
1606January\or February\or March\or April\or May\or June\or
1607July\or August\or September\or October\or November\or December\fi
1608\space\number\year}
1609
1610% Use this if you want the Month Day, Year style of output.
1611%\def\today{\ifcase\month\or
1612%January\or February\or March\or April\or May\or June\or
1613%July\or August\or September\or October\or November\or December\fi
1614%\space\number\day, \number\year}
1615
1616% @settitle line...  specifies the title of the document, for headings
1617% It generates no output of its own
1618
1619\def\thistitle{No Title}
1620\def\settitle{\parsearg\settitlezzz}
1621\def\settitlezzz #1{\gdef\thistitle{#1}}
1622
1623
1624\message{tables,}
1625
1626% @tabs -- simple alignment
1627
1628% These don't work.  For one thing, \+ is defined as outer.
1629% So these macros cannot even be defined.
1630
1631%\def\tabs{\parsearg\tabszzz}
1632%\def\tabszzz #1{\settabs\+#1\cr}
1633%\def\tabline{\parsearg\tablinezzz}
1634%\def\tablinezzz #1{\+#1\cr}
1635%\def\&{&}
1636
1637% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
1638
1639% default indentation of table text
1640\newdimen\tableindent \tableindent=.8in
1641% default indentation of @itemize and @enumerate text
1642\newdimen\itemindent  \itemindent=.3in
1643% margin between end of table item and start of table text.
1644\newdimen\itemmargin  \itemmargin=.1in
1645
1646% used internally for \itemindent minus \itemmargin
1647\newdimen\itemmax
1648
1649% Note @table, @vtable, and @vtable define @item, @itemx, etc., with
1650% these defs.
1651% They also define \itemindex
1652% to index the item name in whatever manner is desired (perhaps none).
1653
1654\newif\ifitemxneedsnegativevskip
1655
1656\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
1657
1658\def\internalBitem{\smallbreak \parsearg\itemzzz}
1659\def\internalBitemx{\itemxpar \parsearg\itemzzz}
1660
1661\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
1662\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz}
1663
1664\def\internalBkitem{\smallbreak \parsearg\kitemzzz}
1665\def\internalBkitemx{\itemxpar \parsearg\kitemzzz}
1666
1667\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
1668                 \itemzzz {#1}}
1669
1670\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
1671                 \itemzzz {#1}}
1672
1673\def\itemzzz #1{\begingroup %
1674  \advance\hsize by -\rightskip
1675  \advance\hsize by -\tableindent
1676  \setbox0=\hbox{\itemfont{#1}}%
1677  \itemindex{#1}%
1678  \nobreak % This prevents a break before @itemx.
1679  %
1680  % Be sure we are not still in the middle of a paragraph.
1681  %{\parskip = 0in
1682  %\par
1683  %}%
1684  %
1685  % If the item text does not fit in the space we have, put it on a line
1686  % by itself, and do not allow a page break either before or after that
1687  % line.  We do not start a paragraph here because then if the next
1688  % command is, e.g., @kindex, the whatsit would get put into the
1689  % horizontal list on a line by itself, resulting in extra blank space.
1690  \ifdim \wd0>\itemmax
1691    %
1692    % Make this a paragraph so we get the \parskip glue and wrapping,
1693    % but leave it ragged-right.
1694    \begingroup
1695      \advance\leftskip by-\tableindent
1696      \advance\hsize by\tableindent
1697      \advance\rightskip by0pt plus1fil
1698      \leavevmode\unhbox0\par
1699    \endgroup
1700    %
1701    % We're going to be starting a paragraph, but we don't want the
1702    % \parskip glue -- logically it's part of the @item we just started.
1703    \nobreak \vskip-\parskip
1704    %
1705    % Stop a page break at the \parskip glue coming up.  Unfortunately
1706    % we can't prevent a possible page break at the following
1707    % \baselineskip glue.
1708    \nobreak
1709    \endgroup
1710    \itemxneedsnegativevskipfalse
1711  \else
1712    % The item text fits into the space.  Start a paragraph, so that the
1713    % following text (if any) will end up on the same line.  Since that
1714    % text will be indented by \tableindent, we make the item text be in
1715    % a zero-width box.
1716    \noindent
1717    \rlap{\hskip -\tableindent\box0}\ignorespaces%
1718    \endgroup%
1719    \itemxneedsnegativevskiptrue%
1720  \fi
1721}
1722
1723\def\item{\errmessage{@item while not in a table}}
1724\def\itemx{\errmessage{@itemx while not in a table}}
1725\def\kitem{\errmessage{@kitem while not in a table}}
1726\def\kitemx{\errmessage{@kitemx while not in a table}}
1727\def\xitem{\errmessage{@xitem while not in a table}}
1728\def\xitemx{\errmessage{@xitemx while not in a table}}
1729
1730%% Contains a kludge to get @end[description] to work
1731\def\description{\tablez{\dontindex}{1}{}{}{}{}}
1732
1733\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
1734{\obeylines\obeyspaces%
1735\gdef\tablex #1^^M{%
1736\tabley\dontindex#1        \endtabley}}
1737
1738\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
1739{\obeylines\obeyspaces%
1740\gdef\ftablex #1^^M{%
1741\tabley\fnitemindex#1        \endtabley
1742\def\Eftable{\endgraf\afterenvbreak\endgroup}%
1743\let\Etable=\relax}}
1744
1745\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
1746{\obeylines\obeyspaces%
1747\gdef\vtablex #1^^M{%
1748\tabley\vritemindex#1        \endtabley
1749\def\Evtable{\endgraf\afterenvbreak\endgroup}%
1750\let\Etable=\relax}}
1751
1752\def\dontindex #1{}
1753\def\fnitemindex #1{\doind {fn}{\code{#1}}}%
1754\def\vritemindex #1{\doind {vr}{\code{#1}}}%
1755
1756{\obeyspaces %
1757\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
1758\tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
1759
1760\def\tablez #1#2#3#4#5#6{%
1761\aboveenvbreak %
1762\begingroup %
1763\def\Edescription{\Etable}% Necessary kludge.
1764\let\itemindex=#1%
1765\ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
1766\ifnum 0#4>0 \tableindent=#4\mil \fi %
1767\ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
1768\def\itemfont{#2}%
1769\itemmax=\tableindent %
1770\advance \itemmax by -\itemmargin %
1771\advance \leftskip by \tableindent %
1772\exdentamount=\tableindent
1773\parindent = 0pt
1774\parskip = \smallskipamount
1775\ifdim \parskip=0pt \parskip=2pt \fi%
1776\def\Etable{\endgraf\afterenvbreak\endgroup}%
1777\let\item = \internalBitem %
1778\let\itemx = \internalBitemx %
1779\let\kitem = \internalBkitem %
1780\let\kitemx = \internalBkitemx %
1781\let\xitem = \internalBxitem %
1782\let\xitemx = \internalBxitemx %
1783}
1784
1785% This is the counter used by @enumerate, which is really @itemize
1786
1787\newcount \itemno
1788
1789\def\itemize{\parsearg\itemizezzz}
1790
1791\def\itemizezzz #1{%
1792  \begingroup % ended by the @end itemsize
1793  \itemizey {#1}{\Eitemize}
1794}
1795
1796\def\itemizey #1#2{%
1797\aboveenvbreak %
1798\itemmax=\itemindent %
1799\advance \itemmax by -\itemmargin %
1800\advance \leftskip by \itemindent %
1801\exdentamount=\itemindent
1802\parindent = 0pt %
1803\parskip = \smallskipamount %
1804\ifdim \parskip=0pt \parskip=2pt \fi%
1805\def#2{\endgraf\afterenvbreak\endgroup}%
1806\def\itemcontents{#1}%
1807\let\item=\itemizeitem}
1808
1809% Set sfcode to normal for the chars that usually have another value.
1810% These are `.?!:;,'
1811\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
1812  \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
1813
1814% \splitoff TOKENS\endmark defines \first to be the first token in
1815% TOKENS, and \rest to be the remainder.
1816%
1817\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
1818
1819% Allow an optional argument of an uppercase letter, lowercase letter,
1820% or number, to specify the first label in the enumerated list.  No
1821% argument is the same as `1'.
1822%
1823\def\enumerate{\parsearg\enumeratezzz}
1824\def\enumeratezzz #1{\enumeratey #1  \endenumeratey}
1825\def\enumeratey #1 #2\endenumeratey{%
1826  \begingroup % ended by the @end enumerate
1827  %
1828  % If we were given no argument, pretend we were given `1'.
1829  \def\thearg{#1}%
1830  \ifx\thearg\empty \def\thearg{1}\fi
1831  %
1832  % Detect if the argument is a single token.  If so, it might be a
1833  % letter.  Otherwise, the only valid thing it can be is a number.
1834  % (We will always have one token, because of the test we just made.
1835  % This is a good thing, since \splitoff doesn't work given nothing at
1836  % all -- the first parameter is undelimited.)
1837  \expandafter\splitoff\thearg\endmark
1838  \ifx\rest\empty
1839    % Only one token in the argument.  It could still be anything.
1840    % A ``lowercase letter'' is one whose \lccode is nonzero.
1841    % An ``uppercase letter'' is one whose \lccode is both nonzero, and
1842    %   not equal to itself.
1843    % Otherwise, we assume it's a number.
1844    %
1845    % We need the \relax at the end of the \ifnum lines to stop TeX from
1846    % continuing to look for a <number>.
1847    %
1848    \ifnum\lccode\expandafter`\thearg=0\relax
1849      \numericenumerate % a number (we hope)
1850    \else
1851      % It's a letter.
1852      \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
1853        \lowercaseenumerate % lowercase letter
1854      \else
1855        \uppercaseenumerate % uppercase letter
1856      \fi
1857    \fi
1858  \else
1859    % Multiple tokens in the argument.  We hope it's a number.
1860    \numericenumerate
1861  \fi
1862}
1863
1864% An @enumerate whose labels are integers.  The starting integer is
1865% given in \thearg.
1866%
1867\def\numericenumerate{%
1868  \itemno = \thearg
1869  \startenumeration{\the\itemno}%
1870}
1871
1872% The starting (lowercase) letter is in \thearg.
1873\def\lowercaseenumerate{%
1874  \itemno = \expandafter`\thearg
1875  \startenumeration{%
1876    % Be sure we're not beyond the end of the alphabet.
1877    \ifnum\itemno=0
1878      \errmessage{No more lowercase letters in @enumerate; get a bigger
1879                  alphabet}%
1880    \fi
1881    \char\lccode\itemno
1882  }%
1883}
1884
1885% The starting (uppercase) letter is in \thearg.
1886\def\uppercaseenumerate{%
1887  \itemno = \expandafter`\thearg
1888  \startenumeration{%
1889    % Be sure we're not beyond the end of the alphabet.
1890    \ifnum\itemno=0
1891      \errmessage{No more uppercase letters in @enumerate; get a bigger
1892                  alphabet}
1893    \fi
1894    \char\uccode\itemno
1895  }%
1896}
1897
1898% Call itemizey, adding a period to the first argument and supplying the
1899% common last two arguments.  Also subtract one from the initial value in
1900% \itemno, since @item increments \itemno.
1901%
1902\def\startenumeration#1{%
1903  \advance\itemno by -1
1904  \itemizey{#1.}\Eenumerate\flushcr
1905}
1906
1907% @alphaenumerate and @capsenumerate are abbreviations for giving an arg
1908% to @enumerate.
1909%
1910\def\alphaenumerate{\enumerate{a}}
1911\def\capsenumerate{\enumerate{A}}
1912\def\Ealphaenumerate{\Eenumerate}
1913\def\Ecapsenumerate{\Eenumerate}
1914
1915% Definition of @item while inside @itemize.
1916
1917\def\itemizeitem{%
1918\advance\itemno by 1
1919{\let\par=\endgraf \smallbreak}%
1920\ifhmode \errmessage{\in hmode at itemizeitem}\fi
1921{\parskip=0in \hskip 0pt
1922\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
1923\vadjust{\penalty 1200}}%
1924\flushcr}
1925
1926% @multitable macros
1927% Amy Hendrickson, 8/18/94, 3/6/96
1928%
1929% @multitable ... @end multitable will make as many columns as desired.
1930% Contents of each column will wrap at width given in preamble.  Width
1931% can be specified either with sample text given in a template line,
1932% or in percent of \hsize, the current width of text on page.
1933
1934% Table can continue over pages but will only break between lines.
1935
1936% To make preamble:
1937%
1938% Either define widths of columns in terms of percent of \hsize:
1939%   @multitable @columnfractions .25 .3 .45
1940%   @item ...
1941%
1942%   Numbers following @columnfractions are the percent of the total
1943%   current hsize to be used for each column. You may use as many
1944%   columns as desired.
1945
1946
1947% Or use a template:
1948%   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
1949%   @item ...
1950%   using the widest term desired in each column.
1951%
1952% For those who want to use more than one line's worth of words in
1953% the preamble, break the line within one argument and it
1954% will parse correctly, i.e.,
1955%
1956%     @multitable {Column 1 template} {Column 2 template} {Column 3
1957%      template}
1958% Not:
1959%     @multitable {Column 1 template} {Column 2 template}
1960%      {Column 3 template}
1961
1962% Each new table line starts with @item, each subsequent new column
1963% starts with @tab. Empty columns may be produced by supplying @tab's
1964% with nothing between them for as many times as empty columns are needed,
1965% ie, @tab@tab@tab will produce two empty columns.
1966
1967% @item, @tab, @multitable or @end multitable do not need to be on their
1968% own lines, but it will not hurt if they are.
1969
1970% Sample multitable:
1971
1972%   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
1973%   @item first col stuff @tab second col stuff @tab third col
1974%   @item
1975%   first col stuff
1976%   @tab
1977%   second col stuff
1978%   @tab
1979%   third col
1980%   @item first col stuff @tab second col stuff
1981%   @tab Many paragraphs of text may be used in any column.
1982%
1983%         They will wrap at the width determined by the template.
1984%   @item@tab@tab This will be in third column.
1985%   @end multitable
1986
1987% Default dimensions may be reset by user.
1988% @multitableparskip is vertical space between paragraphs in table.
1989% @multitableparindent is paragraph indent in table.
1990% @multitablecolmargin is horizontal space to be left between columns.
1991% @multitablelinespace is space to leave between table items, baseline
1992%                                                            to baseline.
1993%   0pt means it depends on current normal line spacing.
1994
1995%%%%
1996% Dimensions
1997
1998\newskip\multitableparskip
1999\newskip\multitableparindent
2000\newdimen\multitablecolspace
2001\newskip\multitablelinespace
2002\multitableparskip=0pt
2003\multitableparindent=6pt
2004\multitablecolspace=12pt
2005\multitablelinespace=0pt
2006
2007%%%%
2008% Macros used to set up halign preamble:
2009\let\endsetuptable\relax
2010\def\xendsetuptable{\endsetuptable}
2011\let\columnfractions\relax
2012\def\xcolumnfractions{\columnfractions}
2013\newif\ifsetpercent
2014
2015%% 2/1/96, to allow fractions to be given with more than one digit.
2016\def\pickupwholefraction#1 {\global\advance\colcount by1 %
2017\expandafter\xdef\csname col\the\colcount\endcsname{.#1\hsize}%
2018\setuptable}
2019
2020\newcount\colcount
2021\def\setuptable#1{\def\firstarg{#1}%
2022\ifx\firstarg\xendsetuptable\let\go\relax%
2023\else
2024  \ifx\firstarg\xcolumnfractions\global\setpercenttrue%
2025  \else
2026    \ifsetpercent
2027       \let\go\pickupwholefraction   % In this case arg of setuptable
2028                                     % is the decimal point before the
2029                                     % number given in percent of hsize.
2030                                     % We don't need this so we don't use it.
2031    \else
2032       \global\advance\colcount by1
2033       \setbox0=\hbox{#1 }% Add a normal word space as a separator;
2034                          % typically that is always in the input, anyway.
2035       \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
2036    \fi%
2037  \fi%
2038\ifx\go\pickupwholefraction\else\let\go\setuptable\fi%
2039\fi\go}
2040
2041%%%%
2042% multitable syntax
2043\def\tab{&\hskip1sp\relax} % 2/2/96
2044                           % tiny skip here makes sure this column space is
2045                           % maintained, even if it is never used.
2046
2047
2048%%%%
2049% @multitable ... @end multitable definitions:
2050
2051\def\multitable{\parsearg\dotable}
2052
2053\def\dotable#1{\bgroup
2054\let\item\cr
2055\tolerance=9500
2056\hbadness=9500
2057\setmultitablespacing
2058\parskip=\multitableparskip
2059\parindent=\multitableparindent
2060\overfullrule=0pt
2061\global\colcount=0\relax%
2062\def\Emultitable{\global\setpercentfalse\global\everycr{}\cr\egroup\egroup}%
2063 % To parse everything between @multitable and @item :
2064\setuptable#1 \endsetuptable
2065 % Need to reset this to 0 after \setuptable.
2066\global\colcount=0\relax%
2067 %
2068 % This preamble sets up a generic column definition, which will
2069 % be used as many times as user calls for columns.
2070 % \vtop will set a single line and will also let text wrap and
2071 % continue for many paragraphs if desired.
2072\halign\bgroup&\global\advance\colcount by 1\relax%
2073\multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname
2074 % In order to keep entries from bumping into each other
2075 % we will add a \leftskip of \multitablecolspace to all columns after
2076 % the first one.
2077 %  If a template has been used, we will add \multitablecolspace
2078 % to the width of each template entry.
2079 %  If user has set preamble in terms of percent of \hsize
2080 % we will use that dimension as the width of the column, and
2081 % the \leftskip will keep entries from bumping into each other.
2082 % Table will start at left margin and final column will justify at
2083 % right margin.
2084\ifnum\colcount=1
2085\else
2086  \ifsetpercent
2087  \else
2088   % If user has <not> set preamble in terms of percent of \hsize
2089   % we will advance \hsize by \multitablecolspace
2090  \advance\hsize by \multitablecolspace
2091  \fi
2092 % In either case we will make \leftskip=\multitablecolspace:
2093\leftskip=\multitablecolspace
2094\fi
2095 % Ignoring space at the beginning and end avoids an occasional spurious
2096 % blank line, when TeX decides to break the line at the space before the
2097 % box from the multistrut, so the strut ends up on a line by itself.
2098 % For example:
2099 % @multitable @columnfractions .11 .89
2100 % @item @code{#}
2101 % @tab Legal holiday which is valid in major parts of the whole country.
2102 % Is automatically provided with highlighting sequences respectively marking
2103 % characters.
2104 \noindent\ignorespaces##\unskip\multistrut}\cr
2105 % \everycr will reset column counter, \colcount, at the end of
2106 % each line. Every column  entry will cause \colcount to advance by one.
2107 % The table preamble
2108 % looks at the current \colcount to find the correct column width.
2109\global\everycr{\noalign{%
2110% \filbreak%% keeps underfull box messages off when table breaks over pages.
2111% Maybe so, but it also creates really weird page breaks when the table
2112% breaks over pages Wouldn't \vfil be better?  Wait until the problem
2113% manifests itself, so it can be fixed for real --karl.
2114\global\colcount=0\relax}}
2115}
2116
2117\def\setmultitablespacing{% test to see if user has set \multitablelinespace.
2118% If so, do nothing. If not, give it an appropriate dimension based on
2119% current baselineskip.
2120\ifdim\multitablelinespace=0pt
2121%% strut to put in table in case some entry doesn't have descenders,
2122%% to keep lines equally spaced
2123\let\multistrut = \strut
2124%% Test to see if parskip is larger than space between lines of
2125%% table. If not, do nothing.
2126%%        If so, set to same dimension as multitablelinespace.
2127\else
2128\gdef\multistrut{\vrule height\multitablelinespace depth\dp0
2129width0pt\relax} \fi
2130\ifdim\multitableparskip>\multitablelinespace
2131\global\multitableparskip=\multitablelinespace
2132\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
2133                                      %% than skip between lines in the table.
2134\fi%
2135\ifdim\multitableparskip=0pt
2136\global\multitableparskip=\multitablelinespace
2137\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
2138                                      %% than skip between lines in the table.
2139\fi}
2140
2141
2142\message{indexing,}
2143% Index generation facilities
2144
2145% Define \newwrite to be identical to plain tex's \newwrite
2146% except not \outer, so it can be used within \newindex.
2147{\catcode`\@=11
2148\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
2149
2150% \newindex {foo} defines an index named foo.
2151% It automatically defines \fooindex such that
2152% \fooindex ...rest of line... puts an entry in the index foo.
2153% It also defines \fooindfile to be the number of the output channel for
2154% the file that accumulates this index.  The file's extension is foo.
2155% The name of an index should be no more than 2 characters long
2156% for the sake of vms.
2157
2158\def\newindex #1{
2159\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
2160\openout \csname#1indfile\endcsname \jobname.#1 % Open the file
2161\expandafter\xdef\csname#1index\endcsname{%     % Define \xxxindex
2162\noexpand\doindex {#1}}
2163}
2164
2165% @defindex foo  ==  \newindex{foo}
2166
2167\def\defindex{\parsearg\newindex}
2168
2169% Define @defcodeindex, like @defindex except put all entries in @code.
2170
2171\def\newcodeindex #1{
2172\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
2173\openout \csname#1indfile\endcsname \jobname.#1 % Open the file
2174\expandafter\xdef\csname#1index\endcsname{%     % Define \xxxindex
2175\noexpand\docodeindex {#1}}
2176}
2177
2178\def\defcodeindex{\parsearg\newcodeindex}
2179
2180% @synindex foo bar    makes index foo feed into index bar.
2181% Do this instead of @defindex foo if you don't want it as a separate index.
2182\def\synindex #1 #2 {%
2183\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
2184\expandafter\let\csname#1indfile\endcsname=\synindexfoo
2185\expandafter\xdef\csname#1index\endcsname{%     % Define \xxxindex
2186\noexpand\doindex {#2}}%
2187}
2188
2189% @syncodeindex foo bar   similar, but put all entries made for index foo
2190% inside @code.
2191\def\syncodeindex #1 #2 {%
2192\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
2193\expandafter\let\csname#1indfile\endcsname=\synindexfoo
2194\expandafter\xdef\csname#1index\endcsname{%     % Define \xxxindex
2195\noexpand\docodeindex {#2}}%
2196}
2197
2198% Define \doindex, the driver for all \fooindex macros.
2199% Argument #1 is generated by the calling \fooindex macro,
2200%  and it is "foo", the name of the index.
2201
2202% \doindex just uses \parsearg; it calls \doind for the actual work.
2203% This is because \doind is more useful to call from other macros.
2204
2205% There is also \dosubind {index}{topic}{subtopic}
2206% which makes an entry in a two-level index such as the operation index.
2207
2208\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
2209\def\singleindexer #1{\doind{\indexname}{#1}}
2210
2211% like the previous two, but they put @code around the argument.
2212\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
2213\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
2214
2215\def\indexdummies{%
2216% Take care of the plain tex accent commands.
2217\def\"{\realbackslash "}%
2218\def\`{\realbackslash `}%
2219\def\'{\realbackslash '}%
2220\def\^{\realbackslash ^}%
2221\def\~{\realbackslash ~}%
2222\def\={\realbackslash =}%
2223\def\b{\realbackslash b}%
2224\def\c{\realbackslash c}%
2225\def\d{\realbackslash d}%
2226\def\u{\realbackslash u}%
2227\def\v{\realbackslash v}%
2228\def\H{\realbackslash H}%
2229% Take care of the plain tex special European modified letters.
2230\def\oe{\realbackslash oe}%
2231\def\ae{\realbackslash ae}%
2232\def\aa{\realbackslash aa}%
2233\def\OE{\realbackslash OE}%
2234\def\AE{\realbackslash AE}%
2235\def\AA{\realbackslash AA}%
2236\def\o{\realbackslash o}%
2237\def\O{\realbackslash O}%
2238\def\l{\realbackslash l}%
2239\def\L{\realbackslash L}%
2240\def\ss{\realbackslash ss}%
2241% Take care of texinfo commands likely to appear in an index entry.
2242% (Must be a way to avoid doing expansion at all, and thus not have to
2243% laboriously list every single command here.)
2244\def\@{@}% will be @@ when we switch to @ as escape char.
2245%\let\{ = \lbracecmd
2246%\let\} = \rbracecmd
2247\def\_{{\realbackslash _}}%
2248\def\w{\realbackslash w }%
2249\def\bf{\realbackslash bf }%
2250%\def\rm{\realbackslash rm }%
2251\def\sl{\realbackslash sl }%
2252\def\sf{\realbackslash sf}%
2253\def\tt{\realbackslash tt}%
2254\def\gtr{\realbackslash gtr}%
2255\def\less{\realbackslash less}%
2256\def\hat{\realbackslash hat}%
2257%\def\char{\realbackslash char}%
2258\def\TeX{\realbackslash TeX}%
2259\def\dots{\realbackslash dots }%
2260\def\copyright{\realbackslash copyright }%
2261\def\tclose##1{\realbackslash tclose {##1}}%
2262\def\code##1{\realbackslash code {##1}}%
2263\def\dotless##1{\realbackslash dotless {##1}}%
2264\def\samp##1{\realbackslash samp {##1}}%
2265\def\,##1{\realbackslash ,{##1}}%
2266\def\t##1{\realbackslash t {##1}}%
2267\def\r##1{\realbackslash r {##1}}%
2268\def\i##1{\realbackslash i {##1}}%
2269\def\b##1{\realbackslash b {##1}}%
2270\def\cite##1{\realbackslash cite {##1}}%
2271\def\key##1{\realbackslash key {##1}}%
2272\def\file##1{\realbackslash file {##1}}%
2273\def\var##1{\realbackslash var {##1}}%
2274\def\kbd##1{\realbackslash kbd {##1}}%
2275\def\dfn##1{\realbackslash dfn {##1}}%
2276\def\emph##1{\realbackslash emph {##1}}%
2277\unsepspaces
2278}
2279
2280% If an index command is used in an @example environment, any spaces
2281% therein should become regular spaces in the raw index file, not the
2282% expansion of \tie (\\leavevmode \penalty \@M \ ).
2283{\obeyspaces
2284 \gdef\unsepspaces{\obeyspaces\let =\space}}
2285
2286% \indexnofonts no-ops all font-change commands.
2287% This is used when outputting the strings to sort the index by.
2288\def\indexdummyfont#1{#1}
2289\def\indexdummytex{TeX}
2290\def\indexdummydots{...}
2291
2292\def\indexnofonts{%
2293% Just ignore accents.
2294\let\,=\indexdummyfont
2295\let\"=\indexdummyfont
2296\let\`=\indexdummyfont
2297\let\'=\indexdummyfont
2298\let\^=\indexdummyfont
2299\let\~=\indexdummyfont
2300\let\==\indexdummyfont
2301\let\b=\indexdummyfont
2302\let\c=\indexdummyfont
2303\let\d=\indexdummyfont
2304\let\u=\indexdummyfont
2305\let\v=\indexdummyfont
2306\let\H=\indexdummyfont
2307\let\dotless=\indexdummyfont
2308% Take care of the plain tex special European modified letters.
2309\def\oe{oe}%
2310\def\ae{ae}%
2311\def\aa{aa}%
2312\def\OE{OE}%
2313\def\AE{AE}%
2314\def\AA{AA}%
2315\def\o{o}%
2316\def\O{O}%
2317\def\l{l}%
2318\def\L{L}%
2319\def\ss{ss}%
2320\let\w=\indexdummyfont
2321\let\t=\indexdummyfont
2322\let\r=\indexdummyfont
2323\let\i=\indexdummyfont
2324\let\b=\indexdummyfont
2325\let\emph=\indexdummyfont
2326\let\strong=\indexdummyfont
2327\let\cite=\indexdummyfont
2328\let\sc=\indexdummyfont
2329%Don't no-op \tt, since it isn't a user-level command
2330% and is used in the definitions of the active chars like <, >, |...
2331%\let\tt=\indexdummyfont
2332\let\tclose=\indexdummyfont
2333\let\code=\indexdummyfont
2334\let\file=\indexdummyfont
2335\let\samp=\indexdummyfont
2336\let\kbd=\indexdummyfont
2337\let\key=\indexdummyfont
2338\let\var=\indexdummyfont
2339\let\TeX=\indexdummytex
2340\let\dots=\indexdummydots
2341\def\@{@}%
2342}
2343
2344% To define \realbackslash, we must make \ not be an escape.
2345% We must first make another character (@) an escape
2346% so we do not become unable to do a definition.
2347
2348{\catcode`\@=0 \catcode`\\=\other
2349@gdef@realbackslash{\}}
2350
2351\let\indexbackslash=0  %overridden during \printindex.
2352
2353\let\SETmarginindex=\relax %initialize!
2354% workhorse for all \fooindexes
2355% #1 is name of index, #2 is stuff to put there
2356\def\doind #1#2{%
2357  % Put the index entry in the margin if desired.
2358  \ifx\SETmarginindex\relax\else
2359    \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}%
2360  \fi
2361  {%
2362    \count255=\lastpenalty
2363    {%
2364      \indexdummies % Must do this here, since \bf, etc expand at this stage
2365      \escapechar=`\\
2366      {%
2367        \let\folio=0% We will expand all macros now EXCEPT \folio.
2368        \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
2369        % so it will be output as is; and it will print as backslash.
2370        %
2371        % First process the index-string with all font commands turned off
2372        % to get the string to sort by.
2373        {\indexnofonts \xdef\indexsorttmp{#2}}%
2374        %
2375        % Now produce the complete index entry, with both the sort key and the
2376        % original text, including any font commands.
2377        \toks0 = {#2}%
2378        \edef\temp{%
2379          \write\csname#1indfile\endcsname{%
2380            \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}%
2381        }%
2382        \temp
2383      }%
2384    }%
2385    \penalty\count255
2386  }%
2387}
2388
2389\def\dosubind #1#2#3{%
2390{\count10=\lastpenalty %
2391{\indexdummies % Must do this here, since \bf, etc expand at this stage
2392\escapechar=`\\%
2393{\let\folio=0%
2394\def\rawbackslashxx{\indexbackslash}%
2395%
2396% Now process the index-string once, with all font commands turned off,
2397% to get the string to sort the index by.
2398{\indexnofonts
2399\xdef\temp1{#2 #3}%
2400}%
2401% Now produce the complete index entry.  We process the index-string again,
2402% this time with font commands expanded, to get what to print in the index.
2403\edef\temp{%
2404\write \csname#1indfile\endcsname{%
2405\realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
2406\temp }%
2407}\penalty\count10}}
2408
2409% The index entry written in the file actually looks like
2410%  \entry {sortstring}{page}{topic}
2411% or
2412%  \entry {sortstring}{page}{topic}{subtopic}
2413% The texindex program reads in these files and writes files
2414% containing these kinds of lines:
2415%  \initial {c}
2416%     before the first topic whose initial is c
2417%  \entry {topic}{pagelist}
2418%     for a topic that is used without subtopics
2419%  \primary {topic}
2420%     for the beginning of a topic that is used with subtopics
2421%  \secondary {subtopic}{pagelist}
2422%     for each subtopic.
2423
2424% Define the user-accessible indexing commands
2425% @findex, @vindex, @kindex, @cindex.
2426
2427\def\findex {\fnindex}
2428\def\kindex {\kyindex}
2429\def\cindex {\cpindex}
2430\def\vindex {\vrindex}
2431\def\tindex {\tpindex}
2432\def\pindex {\pgindex}
2433
2434\def\cindexsub {\begingroup\obeylines\cindexsub}
2435{\obeylines %
2436\gdef\cindexsub "#1" #2^^M{\endgroup %
2437\dosubind{cp}{#2}{#1}}}
2438
2439% Define the macros used in formatting output of the sorted index material.
2440
2441% This is what you call to cause a particular index to get printed.
2442% Write
2443% @unnumbered Function Index
2444% @printindex fn
2445
2446\def\printindex{\parsearg\doprintindex}
2447
2448\def\doprintindex#1{\begingroup
2449  \dobreak \chapheadingskip{10000}%
2450  %
2451  \indexfonts \rm
2452  \tolerance = 9500
2453  \indexbreaks
2454  \def\indexbackslash{\rawbackslashxx}%
2455  % Index files are almost Texinfo source, but we use \ as the escape
2456  % character.  It would be better to use @, but that's too big a change
2457  % to make right now.
2458  \catcode`\\ = 0
2459  \catcode`\@ = 11
2460  \escapechar = `\\
2461  \begindoublecolumns
2462  %
2463  % See if the index file exists and is nonempty.
2464  \openin 1 \jobname.#1s
2465  \ifeof 1
2466    % \enddoublecolumns gets confused if there is no text in the index,
2467    % and it loses the chapter title and the aux file entries for the
2468    % index.  The easiest way to prevent this problem is to make sure
2469    % there is some text.
2470    (Index is nonexistent)
2471  \else
2472    %
2473    % If the index file exists but is empty, then \openin leaves \ifeof
2474    % false.  We have to make TeX try to read something from the file, so
2475    % it can discover if there is anything in it.
2476    \read 1 to \temp
2477    \ifeof 1
2478      (Index is empty)
2479    \else
2480      \input \jobname.#1s
2481    \fi
2482  \fi
2483  \closein 1
2484  \enddoublecolumns
2485\endgroup}
2486
2487% These macros are used by the sorted index file itself.
2488% Change them to control the appearance of the index.
2489
2490% Same as \bigskipamount except no shrink.
2491% \balancecolumns gets confused if there is any shrink.
2492\newskip\initialskipamount \initialskipamount 12pt plus4pt
2493
2494\def\initial #1{%
2495{\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
2496\ifdim\lastskip<\initialskipamount
2497\removelastskip \penalty-200 \vskip \initialskipamount\fi
2498\line{\secbf#1\hfill}\kern 2pt\penalty10000}}
2499
2500% This typesets a paragraph consisting of #1, dot leaders, and then #2
2501% flush to the right margin.  It is used for index and table of contents
2502% entries.  The paragraph is indented by \leftskip.
2503%
2504\def\entry #1#2{\begingroup
2505  %
2506  % Start a new paragraph if necessary, so our assignments below can't
2507  % affect previous text.
2508  \par
2509  %
2510  % Do not fill out the last line with white space.
2511  \parfillskip = 0in
2512  %
2513  % No extra space above this paragraph.
2514  \parskip = 0in
2515  %
2516  % Do not prefer a separate line ending with a hyphen to fewer lines.
2517  \finalhyphendemerits = 0
2518  %
2519  % \hangindent is only relevant when the entry text and page number
2520  % don't both fit on one line.  In that case, bob suggests starting the
2521  % dots pretty far over on the line.  Unfortunately, a large
2522  % indentation looks wrong when the entry text itself is broken across
2523  % lines.  So we use a small indentation and put up with long leaders.
2524  %
2525  % \hangafter is reset to 1 (which is the value we want) at the start
2526  % of each paragraph, so we need not do anything with that.
2527  \hangindent=2em
2528  %
2529  % When the entry text needs to be broken, just fill out the first line
2530  % with blank space.
2531  \rightskip = 0pt plus1fil
2532  %
2533  % Start a ``paragraph'' for the index entry so the line breaking
2534  % parameters we've set above will have an effect.
2535  \noindent
2536  %
2537  % Insert the text of the index entry.  TeX will do line-breaking on it.
2538  #1%
2539  % The following is kludged to not output a line of dots in the index if
2540  % there are no page numbers.  The next person who breaks this will be
2541  % cursed by a Unix daemon.
2542  \def\tempa{{\rm }}%
2543  \def\tempb{#2}%
2544  \edef\tempc{\tempa}%
2545  \edef\tempd{\tempb}%
2546  \ifx\tempc\tempd\ \else%
2547    %
2548    % If we must, put the page number on a line of its own, and fill out
2549    % this line with blank space.  (The \hfil is overwhelmed with the
2550    % fill leaders glue in \indexdotfill if the page number does fit.)
2551    \hfil\penalty50
2552    \null\nobreak\indexdotfill % Have leaders before the page number.
2553    %
2554    % The `\ ' here is removed by the implicit \unskip that TeX does as
2555    % part of (the primitive) \par.  Without it, a spurious underfull
2556    % \hbox ensues.
2557    \ #2% The page number ends the paragraph.
2558  \fi%
2559  \par
2560\endgroup}
2561
2562% Like \dotfill except takes at least 1 em.
2563\def\indexdotfill{\cleaders
2564  \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
2565
2566\def\primary #1{\line{#1\hfil}}
2567
2568\newskip\secondaryindent \secondaryindent=0.5cm
2569
2570\def\secondary #1#2{
2571{\parfillskip=0in \parskip=0in
2572\hangindent =1in \hangafter=1
2573\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
2574}}
2575
2576% Define two-column mode, which we use to typeset indexes.
2577% Adapted from the TeXbook, page 416, which is to say,
2578% the manmac.tex format used to print the TeXbook itself.
2579\catcode`\@=11
2580
2581\newbox\partialpage
2582\newdimen\doublecolumnhsize
2583
2584\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
2585  % Grab any single-column material above us.
2586  \output = {\global\setbox\partialpage
2587    =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}%
2588  \eject
2589  %
2590  % Now switch to the double-column output routine.
2591  \output={\doublecolumnout}%
2592  %
2593  % Change the page size parameters.  We could do this once outside this
2594  % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
2595  % format, but then we repeat the same computation.  Repeating a couple
2596  % of assignments once per index is clearly meaningless for the
2597  % execution time, so we may as well do it once.
2598  %
2599  % First we halve the line length, less a little for the gutter between
2600  % the columns.  We compute the gutter based on the line length, so it
2601  % changes automatically with the paper format.  The magic constant
2602  % below is chosen so that the gutter has the same value (well, +- <
2603  % 1pt) as it did when we hard-coded it.
2604  %
2605  % We put the result in a separate register, \doublecolumhsize, so we
2606  % can restore it in \pagesofar, after \hsize itself has (potentially)
2607  % been clobbered.
2608  %
2609  \doublecolumnhsize = \hsize
2610    \advance\doublecolumnhsize by -.04154\hsize
2611    \divide\doublecolumnhsize by 2
2612  \hsize = \doublecolumnhsize
2613  %
2614  % Double the \vsize as well.  (We don't need a separate register here,
2615  % since nobody clobbers \vsize.)
2616  \vsize = 2\vsize
2617}
2618\def\doublecolumnout{%
2619  \splittopskip=\topskip \splitmaxdepth=\maxdepth
2620  % Get the available space for the double columns -- the normal
2621  % (undoubled) page height minus any material left over from the
2622  % previous page.
2623  \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
2624  % box0 will be the left-hand column, box1 the right.
2625  \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
2626  \onepageout\pagesofar
2627  \unvbox255 \penalty\outputpenalty
2628}
2629\def\pagesofar{%
2630  % The contents of the output page -- any previous material,
2631  % followed by the two boxes we just split.
2632  \unvbox\partialpage
2633  \hsize = \doublecolumnhsize
2634  \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}%
2635}
2636\def\enddoublecolumns{%
2637  \output={\balancecolumns}\eject % split what we have
2638  \endgroup
2639  % Back to normal single-column typesetting, but take account of the
2640  % fact that we just accumulated some stuff on the output page.
2641  \pagegoal=\vsize
2642}
2643\def\balancecolumns{%
2644  % Called on the last page of the double column material.
2645  \setbox0=\vbox{\unvbox255}%
2646  \dimen@ = \ht0
2647  \advance\dimen@ by \topskip
2648  \advance\dimen@ by-\baselineskip
2649  \divide\dimen@ by 2
2650  \splittopskip = \topskip
2651  % Loop until we get a decent breakpoint.
2652  {\vbadness=10000 \loop \global\setbox3=\copy0
2653    \global\setbox1=\vsplit3 to\dimen@
2654    \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat}%
2655  \setbox0=\vbox to\dimen@{\unvbox1}%
2656  \setbox2=\vbox to\dimen@{\unvbox3}%
2657  \pagesofar
2658}
2659\catcode `\@=\other
2660
2661
2662\message{sectioning,}
2663% Define chapters, sections, etc.
2664
2665\newcount \chapno
2666\newcount \secno        \secno=0
2667\newcount \subsecno     \subsecno=0
2668\newcount \subsubsecno  \subsubsecno=0
2669
2670% This counter is funny since it counts through charcodes of letters A, B, ...
2671\newcount \appendixno  \appendixno = `\@
2672\def\appendixletter{\char\the\appendixno}
2673
2674\newwrite \contentsfile
2675% This is called from \setfilename.
2676\def\opencontents{\openout \contentsfile = \jobname.toc}
2677
2678% Each @chapter defines this as the name of the chapter.
2679% page headings and footings can use it.  @section does likewise
2680
2681\def\thischapter{} \def\thissection{}
2682\def\seccheck#1{\if \pageno<0 %
2683\errmessage{@#1 not allowed after generating table of contents}\fi
2684%
2685}
2686
2687\def\chapternofonts{%
2688\let\rawbackslash=\relax%
2689\let\frenchspacing=\relax%
2690\def\result{\realbackslash result}
2691\def\equiv{\realbackslash equiv}
2692\def\expansion{\realbackslash expansion}
2693\def\print{\realbackslash print}
2694\def\TeX{\realbackslash TeX}
2695\def\dots{\realbackslash dots}
2696\def\copyright{\realbackslash copyright}
2697\def\tt{\realbackslash tt}
2698\def\bf{\realbackslash bf }
2699\def\w{\realbackslash w}
2700\def\less{\realbackslash less}
2701\def\gtr{\realbackslash gtr}
2702\def\hat{\realbackslash hat}
2703\def\char{\realbackslash char}
2704\def\tclose##1{\realbackslash tclose {##1}}
2705\def\code##1{\realbackslash code {##1}}
2706\def\samp##1{\realbackslash samp {##1}}
2707\def\r##1{\realbackslash r {##1}}
2708\def\b##1{\realbackslash b {##1}}
2709\def\key##1{\realbackslash key {##1}}
2710\def\file##1{\realbackslash file {##1}}
2711\def\kbd##1{\realbackslash kbd {##1}}
2712% These are redefined because @smartitalic wouldn't work inside xdef.
2713\def\i##1{\realbackslash i {##1}}
2714\def\cite##1{\realbackslash cite {##1}}
2715\def\var##1{\realbackslash var {##1}}
2716\def\emph##1{\realbackslash emph {##1}}
2717\def\dfn##1{\realbackslash dfn {##1}}
2718}
2719
2720\newcount\absseclevel % used to calculate proper heading level
2721\newcount\secbase\secbase=0 % @raise/lowersections modify this count
2722
2723% @raisesections: treat @section as chapter, @subsection as section, etc.
2724\def\raisesections{\global\advance\secbase by -1}
2725\let\up=\raisesections % original BFox name
2726
2727% @lowersections: treat @chapter as section, @section as subsection, etc.
2728\def\lowersections{\global\advance\secbase by 1}
2729\let\down=\lowersections % original BFox name
2730
2731% Choose a numbered-heading macro
2732% #1 is heading level if unmodified by @raisesections or @lowersections
2733% #2 is text for heading
2734\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
2735\ifcase\absseclevel
2736  \chapterzzz{#2}
2737\or
2738  \seczzz{#2}
2739\or
2740  \numberedsubseczzz{#2}
2741\or
2742  \numberedsubsubseczzz{#2}
2743\else
2744  \ifnum \absseclevel<0
2745    \chapterzzz{#2}
2746  \else
2747    \numberedsubsubseczzz{#2}
2748  \fi
2749\fi
2750}
2751
2752% like \numhead, but chooses appendix heading levels
2753\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
2754\ifcase\absseclevel
2755  \appendixzzz{#2}
2756\or
2757  \appendixsectionzzz{#2}
2758\or
2759  \appendixsubseczzz{#2}
2760\or
2761  \appendixsubsubseczzz{#2}
2762\else
2763  \ifnum \absseclevel<0
2764    \appendixzzz{#2}
2765  \else
2766    \appendixsubsubseczzz{#2}
2767  \fi
2768\fi
2769}
2770
2771% like \numhead, but chooses numberless heading levels
2772\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
2773\ifcase\absseclevel
2774  \unnumberedzzz{#2}
2775\or
2776  \unnumberedseczzz{#2}
2777\or
2778  \unnumberedsubseczzz{#2}
2779\or
2780  \unnumberedsubsubseczzz{#2}
2781\else
2782  \ifnum \absseclevel<0
2783    \unnumberedzzz{#2}
2784  \else
2785    \unnumberedsubsubseczzz{#2}
2786  \fi
2787\fi
2788}
2789
2790
2791\def\thischaptername{No Chapter Title}
2792\outer\def\chapter{\parsearg\chapteryyy}
2793\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
2794\def\chapterzzz #1{\seccheck{chapter}%
2795\secno=0 \subsecno=0 \subsubsecno=0
2796\global\advance \chapno by 1 \message{\putwordChapter \the\chapno}%
2797\chapmacro {#1}{\the\chapno}%
2798\gdef\thissection{#1}%
2799\gdef\thischaptername{#1}%
2800% We don't substitute the actual chapter name into \thischapter
2801% because we don't want its macros evaluated now.
2802\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
2803{\chapternofonts%
2804\edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
2805\escapechar=`\\%
2806\write \contentsfile \temp  %
2807\donoderef %
2808\global\let\section = \numberedsec
2809\global\let\subsection = \numberedsubsec
2810\global\let\subsubsection = \numberedsubsubsec
2811}}
2812
2813\outer\def\appendix{\parsearg\appendixyyy}
2814\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
2815\def\appendixzzz #1{\seccheck{appendix}%
2816\secno=0 \subsecno=0 \subsubsecno=0
2817\global\advance \appendixno by 1 \message{Appendix \appendixletter}%
2818\chapmacro {#1}{\putwordAppendix{} \appendixletter}%
2819\gdef\thissection{#1}%
2820\gdef\thischaptername{#1}%
2821\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
2822{\chapternofonts%
2823\edef\temp{{\realbackslash chapentry
2824  {#1}{\putwordAppendix{} \appendixletter}{\noexpand\folio}}}%
2825\escapechar=`\\%
2826\write \contentsfile \temp  %
2827\appendixnoderef %
2828\global\let\section = \appendixsec
2829\global\let\subsection = \appendixsubsec
2830\global\let\subsubsection = \appendixsubsubsec
2831}}
2832
2833% @centerchap is like @unnumbered, but the heading is centered.
2834\outer\def\centerchap{\parsearg\centerchapyyy}
2835\def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}}
2836
2837\outer\def\top{\parsearg\unnumberedyyy}
2838\outer\def\unnumbered{\parsearg\unnumberedyyy}
2839\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
2840\def\unnumberedzzz #1{\seccheck{unnumbered}%
2841\secno=0 \subsecno=0 \subsubsecno=0
2842%
2843% This used to be simply \message{#1}, but TeX fully expands the
2844% argument to \message.  Therefore, if #1 contained @-commands, TeX
2845% expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
2846% expanded @cite (which turns out to cause errors because \cite is meant
2847% to be executed, not expanded).
2848%
2849% Anyway, we don't want the fully-expanded definition of @cite to appear
2850% as a result of the \message, we just want `@cite' itself.  We use
2851% \the<toks register> to achieve this: TeX expands \the<toks> only once,
2852% simply yielding the contents of the <toks register>.
2853\toks0 = {#1}\message{(\the\toks0)}%
2854%
2855\unnumbchapmacro {#1}%
2856\gdef\thischapter{#1}\gdef\thissection{#1}%
2857{\chapternofonts%
2858\edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
2859\escapechar=`\\%
2860\write \contentsfile \temp  %
2861\unnumbnoderef %
2862\global\let\section = \unnumberedsec
2863\global\let\subsection = \unnumberedsubsec
2864\global\let\subsubsection = \unnumberedsubsubsec
2865}}
2866
2867\outer\def\numberedsec{\parsearg\secyyy}
2868\def\secyyy #1{\numhead1{#1}} % normally calls seczzz
2869\def\seczzz #1{\seccheck{section}%
2870\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
2871\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
2872{\chapternofonts%
2873\edef\temp{{\realbackslash secentry %
2874{#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
2875\escapechar=`\\%
2876\write \contentsfile \temp %
2877\donoderef %
2878\penalty 10000 %
2879}}
2880
2881\outer\def\appendixsection{\parsearg\appendixsecyyy}
2882\outer\def\appendixsec{\parsearg\appendixsecyyy}
2883\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
2884\def\appendixsectionzzz #1{\seccheck{appendixsection}%
2885\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
2886\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
2887{\chapternofonts%
2888\edef\temp{{\realbackslash secentry %
2889{#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
2890\escapechar=`\\%
2891\write \contentsfile \temp %
2892\appendixnoderef %
2893\penalty 10000 %
2894}}
2895
2896\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
2897\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
2898\def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
2899\plainsecheading {#1}\gdef\thissection{#1}%
2900{\chapternofonts%
2901\edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
2902\escapechar=`\\%
2903\write \contentsfile \temp %
2904\unnumbnoderef %
2905\penalty 10000 %
2906}}
2907
2908\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
2909\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
2910\def\numberedsubseczzz #1{\seccheck{subsection}%
2911\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
2912\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
2913{\chapternofonts%
2914\edef\temp{{\realbackslash subsecentry %
2915{#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
2916\escapechar=`\\%
2917\write \contentsfile \temp %
2918\donoderef %
2919\penalty 10000 %
2920}}
2921
2922\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
2923\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
2924\def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
2925\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
2926\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
2927{\chapternofonts%
2928\edef\temp{{\realbackslash subsecentry %
2929{#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
2930\escapechar=`\\%
2931\write \contentsfile \temp %
2932\appendixnoderef %
2933\penalty 10000 %
2934}}
2935
2936\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
2937\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
2938\def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
2939\plainsubsecheading {#1}\gdef\thissection{#1}%
2940{\chapternofonts%
2941\edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
2942\escapechar=`\\%
2943\write \contentsfile \temp %
2944\unnumbnoderef %
2945\penalty 10000 %
2946}}
2947
2948\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
2949\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
2950\def\numberedsubsubseczzz #1{\seccheck{subsubsection}%
2951\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
2952\subsubsecheading {#1}
2953  {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
2954{\chapternofonts%
2955\edef\temp{{\realbackslash subsubsecentry %
2956  {#1}
2957  {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}
2958  {\noexpand\folio}}}%
2959\escapechar=`\\%
2960\write \contentsfile \temp %
2961\donoderef %
2962\penalty 10000 %
2963}}
2964
2965\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
2966\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
2967\def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
2968\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
2969\subsubsecheading {#1}
2970  {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
2971{\chapternofonts%
2972\edef\temp{{\realbackslash subsubsecentry{#1}%
2973  {\appendixletter}
2974  {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%
2975\escapechar=`\\%
2976\write \contentsfile \temp %
2977\appendixnoderef %
2978\penalty 10000 %
2979}}
2980
2981\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
2982\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
2983\def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
2984\plainsubsubsecheading {#1}\gdef\thissection{#1}%
2985{\chapternofonts%
2986\edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
2987\escapechar=`\\%
2988\write \contentsfile \temp %
2989\unnumbnoderef %
2990\penalty 10000 %
2991}}
2992
2993% These are variants which are not "outer", so they can appear in @ifinfo.
2994% Actually, they should now be obsolete; ordinary section commands should work.
2995\def\infotop{\parsearg\unnumberedzzz}
2996\def\infounnumbered{\parsearg\unnumberedzzz}
2997\def\infounnumberedsec{\parsearg\unnumberedseczzz}
2998\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
2999\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
3000
3001\def\infoappendix{\parsearg\appendixzzz}
3002\def\infoappendixsec{\parsearg\appendixseczzz}
3003\def\infoappendixsubsec{\parsearg\appendixsubseczzz}
3004\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
3005
3006\def\infochapter{\parsearg\chapterzzz}
3007\def\infosection{\parsearg\sectionzzz}
3008\def\infosubsection{\parsearg\subsectionzzz}
3009\def\infosubsubsection{\parsearg\subsubsectionzzz}
3010
3011% These macros control what the section commands do, according
3012% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
3013% Define them by default for a numbered chapter.
3014\global\let\section = \numberedsec
3015\global\let\subsection = \numberedsubsec
3016\global\let\subsubsection = \numberedsubsubsec
3017
3018% Define @majorheading, @heading and @subheading
3019
3020% NOTE on use of \vbox for chapter headings, section headings, and
3021% such:
3022%       1) We use \vbox rather than the earlier \line to permit
3023%          overlong headings to fold.
3024%       2) \hyphenpenalty is set to 10000 because hyphenation in a
3025%          heading is obnoxious; this forbids it.
3026%       3) Likewise, headings look best if no \parindent is used, and
3027%          if justification is not attempted.  Hence \raggedright.
3028
3029
3030\def\majorheading{\parsearg\majorheadingzzz}
3031\def\majorheadingzzz #1{%
3032{\advance\chapheadingskip by 10pt \chapbreak }%
3033{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3034                  \parindent=0pt\raggedright
3035                  \rm #1\hfill}}\bigskip \par\penalty 200}
3036
3037\def\chapheading{\parsearg\chapheadingzzz}
3038\def\chapheadingzzz #1{\chapbreak %
3039{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3040                  \parindent=0pt\raggedright
3041                  \rm #1\hfill}}\bigskip \par\penalty 200}
3042
3043% @heading, @subheading, @subsubheading.
3044\def\heading{\parsearg\plainsecheading}
3045\def\subheading{\parsearg\plainsubsecheading}
3046\def\subsubheading{\parsearg\plainsubsubsecheading}
3047
3048% These macros generate a chapter, section, etc. heading only
3049% (including whitespace, linebreaking, etc. around it),
3050% given all the information in convenient, parsed form.
3051
3052%%% Args are the skip and penalty (usually negative)
3053\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
3054
3055\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
3056
3057%%% Define plain chapter starts, and page on/off switching for it
3058% Parameter controlling skip before chapter headings (if needed)
3059
3060\newskip\chapheadingskip
3061
3062\def\chapbreak{\dobreak \chapheadingskip {-4000}}
3063\def\chappager{\par\vfill\supereject}
3064\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
3065
3066\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
3067
3068\def\CHAPPAGoff{
3069\global\let\contentsalignmacro = \chappager
3070\global\let\pchapsepmacro=\chapbreak
3071\global\let\pagealignmacro=\chappager}
3072
3073\def\CHAPPAGon{
3074\global\let\contentsalignmacro = \chappager
3075\global\let\pchapsepmacro=\chappager
3076\global\let\pagealignmacro=\chappager
3077\global\def\HEADINGSon{\HEADINGSsingle}}
3078
3079\def\CHAPPAGodd{
3080\global\let\contentsalignmacro = \chapoddpage
3081\global\let\pchapsepmacro=\chapoddpage
3082\global\let\pagealignmacro=\chapoddpage
3083\global\def\HEADINGSon{\HEADINGSdouble}}
3084
3085\CHAPPAGon
3086
3087\def\CHAPFplain{
3088\global\let\chapmacro=\chfplain
3089\global\let\unnumbchapmacro=\unnchfplain
3090\global\let\centerchapmacro=\centerchfplain}
3091
3092% Plain chapter opening.
3093% #1 is the text, #2 the chapter number or empty if unnumbered.
3094\def\chfplain#1#2{%
3095  \pchapsepmacro
3096  {%
3097    \chapfonts \rm
3098    \def\chapnum{#2}%
3099    \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}%
3100    \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
3101          \hangindent = \wd0 \centerparametersmaybe
3102          \unhbox0 #1\par}%
3103  }%
3104  \nobreak\bigskip % no page break after a chapter title
3105  \nobreak
3106}
3107
3108% Plain opening for unnumbered.
3109\def\unnchfplain#1{\chfplain{#1}{}}
3110
3111% @centerchap -- centered and unnumbered.
3112\let\centerparametersmaybe = \relax
3113\def\centerchfplain#1{{%
3114  \def\centerparametersmaybe{%
3115    \advance\rightskip by 3\rightskip
3116    \leftskip = \rightskip
3117    \parfillskip = 0pt
3118  }%
3119  \chfplain{#1}{}%
3120}}
3121
3122\CHAPFplain % The default
3123
3124\def\unnchfopen #1{%
3125\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3126                       \parindent=0pt\raggedright
3127                       \rm #1\hfill}}\bigskip \par\penalty 10000 %
3128}
3129
3130\def\chfopen #1#2{\chapoddpage {\chapfonts
3131\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
3132\par\penalty 5000 %
3133}
3134
3135\def\centerchfopen #1{%
3136\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3137                       \parindent=0pt
3138                       \hfill {\rm #1}\hfill}}\bigskip \par\penalty 10000 %
3139}
3140
3141\def\CHAPFopen{
3142\global\let\chapmacro=\chfopen
3143\global\let\unnumbchapmacro=\unnchfopen
3144\global\let\centerchapmacro=\centerchfopen}
3145
3146
3147% Section titles.
3148\newskip\secheadingskip
3149\def\secheadingbreak{\dobreak \secheadingskip {-1000}}
3150\def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}}
3151\def\plainsecheading#1{\sectionheading{sec}{}{#1}}
3152
3153% Subsection titles.
3154\newskip \subsecheadingskip
3155\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
3156\def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}}
3157\def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}}
3158
3159% Subsubsection titles.
3160\let\subsubsecheadingskip = \subsecheadingskip
3161\let\subsubsecheadingbreak = \subsecheadingbreak
3162\def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}}
3163\def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}}
3164
3165
3166% Print any size section title.
3167%
3168% #1 is the section type (sec/subsec/subsubsec), #2 is the section
3169% number (maybe empty), #3 the text.
3170\def\sectionheading#1#2#3{%
3171  {%
3172    \expandafter\advance\csname #1headingskip\endcsname by \parskip
3173    \csname #1headingbreak\endcsname
3174  }%
3175  {%
3176    % Switch to the right set of fonts.
3177    \csname #1fonts\endcsname \rm
3178    %
3179    % Only insert the separating space if we have a section number.
3180    \def\secnum{#2}%
3181    \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}%
3182    %
3183    \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
3184          \hangindent = \wd0 % zero if no section number
3185          \unhbox0 #3}%
3186  }%
3187  \ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak
3188}
3189
3190
3191\message{toc printing,}
3192% Finish up the main text and prepare to read what we've written
3193% to \contentsfile.
3194
3195\newskip\contentsrightmargin \contentsrightmargin=1in
3196\def\startcontents#1{%
3197   % If @setchapternewpage on, and @headings double, the contents should
3198   % start on an odd page, unlike chapters.  Thus, we maintain
3199   % \contentsalignmacro in parallel with \pagealignmacro.
3200   % From: Torbjorn Granlund <tege@matematik.su.se>
3201   \contentsalignmacro
3202   \immediate\closeout \contentsfile
3203   \ifnum \pageno>0
3204      \pageno = -1              % Request roman numbered pages.
3205   \fi
3206   % Don't need to put `Contents' or `Short Contents' in the headline.
3207   % It is abundantly clear what they are.
3208   \unnumbchapmacro{#1}\def\thischapter{}%
3209   \begingroup                  % Set up to handle contents files properly.
3210      \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
3211      \catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi
3212      \raggedbottom             % Worry more about breakpoints than the bottom.
3213      \advance\hsize by -\contentsrightmargin % Don't use the full line length.
3214}
3215
3216
3217% Normal (long) toc.
3218\outer\def\contents{%
3219   \startcontents{\putwordTableofContents}%
3220      \input \jobname.toc
3221   \endgroup
3222   \vfill \eject
3223}
3224
3225% And just the chapters.
3226\outer\def\summarycontents{%
3227   \startcontents{\putwordShortContents}%
3228      %
3229      \let\chapentry = \shortchapentry
3230      \let\unnumbchapentry = \shortunnumberedentry
3231      % We want a true roman here for the page numbers.
3232      \secfonts
3233      \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
3234      \rm
3235      \hyphenpenalty = 10000
3236      \advance\baselineskip by 1pt % Open it up a little.
3237      \def\secentry ##1##2##3##4{}
3238      \def\unnumbsecentry ##1##2{}
3239      \def\subsecentry ##1##2##3##4##5{}
3240      \def\unnumbsubsecentry ##1##2{}
3241      \def\subsubsecentry ##1##2##3##4##5##6{}
3242      \def\unnumbsubsubsecentry ##1##2{}
3243      \input \jobname.toc
3244   \endgroup
3245   \vfill \eject
3246}
3247\let\shortcontents = \summarycontents
3248
3249% These macros generate individual entries in the table of contents.
3250% The first argument is the chapter or section name.
3251% The last argument is the page number.
3252% The arguments in between are the chapter number, section number, ...
3253
3254% Chapter-level things, for both the long and short contents.
3255\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
3256
3257% See comments in \dochapentry re vbox and related settings
3258\def\shortchapentry#1#2#3{%
3259  \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}%
3260}
3261
3262% Typeset the label for a chapter or appendix for the short contents.
3263% The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
3264% We could simplify the code here by writing out an \appendixentry
3265% command in the toc file for appendices, instead of using \chapentry
3266% for both, but it doesn't seem worth it.
3267\setbox0 = \hbox{\shortcontrm \putwordAppendix }
3268\newdimen\shortappendixwidth \shortappendixwidth = \wd0
3269
3270\def\shortchaplabel#1{%
3271  % We typeset #1 in a box of constant width, regardless of the text of
3272  % #1, so the chapter titles will come out aligned.
3273  \setbox0 = \hbox{#1}%
3274  \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
3275  %
3276  % This space should be plenty, since a single number is .5em, and the
3277  % widest letter (M) is 1em, at least in the Computer Modern fonts.
3278  % (This space doesn't include the extra space that gets added after
3279  % the label; that gets put in by \shortchapentry above.)
3280  \advance\dimen0 by 1.1em
3281  \hbox to \dimen0{#1\hfil}%
3282}
3283
3284\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
3285\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}}
3286
3287% Sections.
3288\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
3289\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
3290
3291% Subsections.
3292\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
3293\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
3294
3295% And subsubsections.
3296\def\subsubsecentry#1#2#3#4#5#6{%
3297  \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
3298\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
3299
3300% This parameter controls the indentation of the various levels.
3301\newdimen\tocindent \tocindent = 3pc
3302
3303% Now for the actual typesetting. In all these, #1 is the text and #2 is the
3304% page number.
3305%
3306% If the toc has to be broken over pages, we want it to be at chapters
3307% if at all possible; hence the \penalty.
3308\def\dochapentry#1#2{%
3309   \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
3310   \begingroup
3311     \chapentryfonts
3312     \tocentry{#1}{\dopageno{#2}}%
3313   \endgroup
3314   \nobreak\vskip .25\baselineskip plus.1\baselineskip
3315}
3316
3317\def\dosecentry#1#2{\begingroup
3318  \secentryfonts \leftskip=\tocindent
3319  \tocentry{#1}{\dopageno{#2}}%
3320\endgroup}
3321
3322\def\dosubsecentry#1#2{\begingroup
3323  \subsecentryfonts \leftskip=2\tocindent
3324  \tocentry{#1}{\dopageno{#2}}%
3325\endgroup}
3326
3327\def\dosubsubsecentry#1#2{\begingroup
3328  \subsubsecentryfonts \leftskip=3\tocindent
3329  \tocentry{#1}{\dopageno{#2}}%
3330\endgroup}
3331
3332% Final typesetting of a toc entry; we use the same \entry macro as for
3333% the index entries, but we want to suppress hyphenation here.  (We
3334% can't do that in the \entry macro, since index entries might consist
3335% of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
3336%
3337% \turnoffactive is for the sake of @" used for umlauts.
3338\def\tocentry#1#2{\begingroup
3339  \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks
3340  \entry{\turnoffactive #1}{\turnoffactive #2}%
3341\endgroup}
3342
3343% Space between chapter (or whatever) number and the title.
3344\def\labelspace{\hskip1em \relax}
3345
3346\def\dopageno#1{{\rm #1}}
3347\def\doshortpageno#1{{\rm #1}}
3348
3349\def\chapentryfonts{\secfonts \rm}
3350\def\secentryfonts{\textfonts}
3351\let\subsecentryfonts = \textfonts
3352\let\subsubsecentryfonts = \textfonts
3353
3354
3355\message{environments,}
3356
3357% Since these characters are used in examples, it should be an even number of
3358% \tt widths. Each \tt character is 1en, so two makes it 1em.
3359% Furthermore, these definitions must come after we define our fonts.
3360\newbox\dblarrowbox    \newbox\longdblarrowbox
3361\newbox\pushcharbox    \newbox\bullbox
3362\newbox\equivbox       \newbox\errorbox
3363
3364%{\tentt
3365%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
3366%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
3367%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
3368%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
3369% Adapted from the manmac format (p.420 of TeXbook)
3370%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
3371%                                      depth .1ex\hfil}
3372%}
3373
3374% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3375\def\point{$\star$}
3376\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3377\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
3378\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3379\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3380
3381% Adapted from the TeXbook's \boxit.
3382{\tentt \global\dimen0 = 3em}% Width of the box.
3383\dimen2 = .55pt % Thickness of rules
3384% The text. (`r' is open on the right, `e' somewhat less so on the left.)
3385\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
3386
3387\global\setbox\errorbox=\hbox to \dimen0{\hfil
3388   \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3389   \advance\hsize by -2\dimen2 % Rules.
3390   \vbox{
3391      \hrule height\dimen2
3392      \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
3393         \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3394         \kern3pt\vrule width\dimen2}% Space to right.
3395      \hrule height\dimen2}
3396    \hfil}
3397
3398% The @error{} command.
3399\def\error{\leavevmode\lower.7ex\copy\errorbox}
3400
3401% @tex ... @end tex    escapes into raw Tex temporarily.
3402% One exception: @ is still an escape character, so that @end tex works.
3403% But \@ or @@ will get a plain tex @ character.
3404
3405\def\tex{\begingroup
3406\catcode `\\=0 \catcode `\{=1 \catcode `\}=2
3407\catcode `\$=3 \catcode `\&=4 \catcode `\#=6
3408\catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
3409\catcode `\%=14
3410\catcode 43=12 % plus
3411\catcode`\"=12
3412\catcode`\==12
3413\catcode`\|=12
3414\catcode`\<=12
3415\catcode`\>=12
3416\escapechar=`\\
3417%
3418\let\,=\ptexcomma
3419\let\{=\ptexlbrace
3420\let\}=\ptexrbrace
3421\let\.=\ptexdot
3422\let\*=\ptexstar
3423\let\dots=\ptexdots
3424\def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
3425\def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
3426\def\@{@}%
3427\let\bullet=\ptexbullet
3428\let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext
3429%
3430\let\Etex=\endgroup}
3431
3432% Define @lisp ... @endlisp.
3433% @lisp does a \begingroup so it can rebind things,
3434% including the definition of @endlisp (which normally is erroneous).
3435
3436% Amount to narrow the margins by for @lisp.
3437\newskip\lispnarrowing \lispnarrowing=0.4in
3438
3439% This is the definition that ^^M gets inside @lisp, @example, and other
3440% such environments.  \null is better than a space, since it doesn't
3441% have any width.
3442\def\lisppar{\null\endgraf}
3443
3444% Make each space character in the input produce a normal interword
3445% space in the output.  Don't allow a line break at this space, as this
3446% is used only in environments like @example, where each line of input
3447% should produce a line of output anyway.
3448%
3449{\obeyspaces %
3450\gdef\sepspaces{\obeyspaces\let =\tie}}
3451
3452% Define \obeyedspace to be our active space, whatever it is.  This is
3453% for use in \parsearg.
3454{\sepspaces%
3455\global\let\obeyedspace= }
3456
3457% This space is always present above and below environments.
3458\newskip\envskipamount \envskipamount = 0pt
3459
3460% Make spacing and below environment symmetrical.  We use \parskip here
3461% to help in doing that, since in @example-like environments \parskip
3462% is reset to zero; thus the \afterenvbreak inserts no space -- but the
3463% start of the next paragraph will insert \parskip
3464%
3465\def\aboveenvbreak{{\advance\envskipamount by \parskip
3466\endgraf \ifdim\lastskip<\envskipamount
3467\removelastskip \penalty-50 \vskip\envskipamount \fi}}
3468
3469\let\afterenvbreak = \aboveenvbreak
3470
3471% \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins.
3472\let\nonarrowing=\relax
3473
3474%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3475% \cartouche: draw rectangle w/rounded corners around argument
3476\font\circle=lcircle10
3477\newdimen\circthick
3478\newdimen\cartouter\newdimen\cartinner
3479\newskip\normbskip\newskip\normpskip\newskip\normlskip
3480\circthick=\fontdimen8\circle
3481%
3482\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
3483\def\ctr{{\hskip 6pt\circle\char'010}}
3484\def\cbl{{\circle\char'012\hskip -6pt}}
3485\def\cbr{{\hskip 6pt\circle\char'011}}
3486\def\carttop{\hbox to \cartouter{\hskip\lskip
3487        \ctl\leaders\hrule height\circthick\hfil\ctr
3488        \hskip\rskip}}
3489\def\cartbot{\hbox to \cartouter{\hskip\lskip
3490        \cbl\leaders\hrule height\circthick\hfil\cbr
3491        \hskip\rskip}}
3492%
3493\newskip\lskip\newskip\rskip
3494
3495\long\def\cartouche{%
3496\begingroup
3497        \lskip=\leftskip \rskip=\rightskip
3498        \leftskip=0pt\rightskip=0pt %we want these *outside*.
3499        \cartinner=\hsize \advance\cartinner by-\lskip
3500                          \advance\cartinner by-\rskip
3501        \cartouter=\hsize
3502        \advance\cartouter by 18pt % allow for 3pt kerns on either
3503%                                    side, and for 6pt waste from
3504%                                    each corner char
3505        \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
3506        % Flag to tell @lisp, etc., not to narrow margin.
3507        \let\nonarrowing=\comment
3508        \vbox\bgroup
3509                \baselineskip=0pt\parskip=0pt\lineskip=0pt
3510                \carttop
3511                \hbox\bgroup
3512                        \hskip\lskip
3513                        \vrule\kern3pt
3514                        \vbox\bgroup
3515                                \hsize=\cartinner
3516                                \kern3pt
3517                                \begingroup
3518                                        \baselineskip=\normbskip
3519                                        \lineskip=\normlskip
3520                                        \parskip=\normpskip
3521                                        \vskip -\parskip
3522\def\Ecartouche{%
3523                                \endgroup
3524                                \kern3pt
3525                        \egroup
3526                        \kern3pt\vrule
3527                        \hskip\rskip
3528                \egroup
3529                \cartbot
3530        \egroup
3531\endgroup
3532}}
3533
3534
3535% This macro is called at the beginning of all the @example variants,
3536% inside a group.
3537\def\nonfillstart{%
3538  \aboveenvbreak
3539  \inENV % This group ends at the end of the body
3540  \hfuzz = 12pt % Don't be fussy
3541  \sepspaces % Make spaces be word-separators rather than space tokens.
3542  \singlespace
3543  \let\par = \lisppar % don't ignore blank lines
3544  \obeylines % each line of input is a line of output
3545  \parskip = 0pt
3546  \parindent = 0pt
3547  \emergencystretch = 0pt % don't try to avoid overfull boxes
3548  % @cartouche defines \nonarrowing to inhibit narrowing
3549  % at next level down.
3550  \ifx\nonarrowing\relax
3551    \advance \leftskip by \lispnarrowing
3552    \exdentamount=\lispnarrowing
3553    \let\exdent=\nofillexdent
3554    \let\nonarrowing=\relax
3555  \fi
3556}
3557
3558% To ending an @example-like environment, we first end the paragraph
3559% (via \afterenvbreak's vertical glue), and then the group.  That way we
3560% keep the zero \parskip that the environments set -- \parskip glue
3561% will be inserted at the beginning of the next paragraph in the
3562% document, after the environment.
3563%
3564\def\nonfillfinish{\afterenvbreak\endgroup}%
3565
3566% This macro is
3567\def\lisp{\begingroup
3568  \nonfillstart
3569  \let\Elisp = \nonfillfinish
3570  \tt
3571  \rawbackslash % have \ input char produce \ char from current font
3572  \gobble
3573}
3574
3575% Define the \E... control sequence only if we are inside the
3576% environment, so the error checking in \end will work.
3577%
3578% We must call \lisp last in the definition, since it reads the
3579% return following the @example (or whatever) command.
3580%
3581\def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp}
3582\def\smallexample{\begingroup \def\Esmallexample{\nonfillfinish\endgroup}\lisp}
3583\def\smalllisp{\begingroup \def\Esmalllisp{\nonfillfinish\endgroup}\lisp}
3584
3585% @smallexample and @smalllisp.  This is not used unless the @smallbook
3586% command is given.  Originally contributed by Pavel@xerox.
3587%
3588\def\smalllispx{\begingroup
3589  \nonfillstart
3590  \let\Esmalllisp = \nonfillfinish
3591  \let\Esmallexample = \nonfillfinish
3592  %
3593  % Smaller fonts for small examples.
3594  \indexfonts \tt
3595  \rawbackslash % make \ output the \ character from the current font (tt)
3596  \gobble
3597}
3598
3599% This is @display; same as @lisp except use roman font.
3600%
3601\def\display{\begingroup
3602  \nonfillstart
3603  \let\Edisplay = \nonfillfinish
3604  \gobble
3605}
3606
3607% This is @format; same as @display except don't narrow margins.
3608%
3609\def\format{\begingroup
3610  \let\nonarrowing = t
3611  \nonfillstart
3612  \let\Eformat = \nonfillfinish
3613  \gobble
3614}
3615
3616% @flushleft (same as @format) and @flushright.
3617%
3618\def\flushleft{\begingroup
3619  \let\nonarrowing = t
3620  \nonfillstart
3621  \let\Eflushleft = \nonfillfinish
3622  \gobble
3623}
3624\def\flushright{\begingroup
3625  \let\nonarrowing = t
3626  \nonfillstart
3627  \let\Eflushright = \nonfillfinish
3628  \advance\leftskip by 0pt plus 1fill
3629  \gobble}
3630
3631% @quotation does normal linebreaking (hence we can't use \nonfillstart)
3632% and narrows the margins.
3633%
3634\def\quotation{%
3635  \begingroup\inENV %This group ends at the end of the @quotation body
3636  {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
3637  \singlespace
3638  \parindent=0pt
3639  % We have retained a nonzero parskip for the environment, since we're
3640  % doing normal filling. So to avoid extra space below the environment...
3641  \def\Equotation{\parskip = 0pt \nonfillfinish}%
3642  %
3643  % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
3644  \ifx\nonarrowing\relax
3645    \advance\leftskip by \lispnarrowing
3646    \advance\rightskip by \lispnarrowing
3647    \exdentamount = \lispnarrowing
3648    \let\nonarrowing = \relax
3649  \fi
3650}
3651
3652\message{defuns,}
3653% Define formatter for defuns
3654% First, allow user to change definition object font (\df) internally
3655\def\setdeffont #1 {\csname DEF#1\endcsname}
3656
3657\newskip\defbodyindent \defbodyindent=.4in
3658\newskip\defargsindent \defargsindent=50pt
3659\newskip\deftypemargin \deftypemargin=12pt
3660\newskip\deflastargmargin \deflastargmargin=18pt
3661
3662\newcount\parencount
3663% define \functionparens, which makes ( and ) and & do special things.
3664% \functionparens affects the group it is contained in.
3665\def\activeparens{%
3666\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
3667\catcode`\[=\active \catcode`\]=\active}
3668
3669% Make control sequences which act like normal parenthesis chars.
3670\let\lparen = ( \let\rparen = )
3671
3672{\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
3673
3674% Be sure that we always have a definition for `(', etc.  For example,
3675% if the fn name has parens in it, \boldbrax will not be in effect yet,
3676% so TeX would otherwise complain about undefined control sequence.
3677\global\let(=\lparen \global\let)=\rparen
3678\global\let[=\lbrack \global\let]=\rbrack
3679
3680\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
3681\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
3682% This is used to turn on special parens
3683% but make & act ordinary (given that it's active).
3684\gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr}
3685
3686% Definitions of (, ) and & used in args for functions.
3687% This is the definition of ( outside of all parentheses.
3688\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
3689\global\advance\parencount by 1 }
3690%
3691% This is the definition of ( when already inside a level of parens.
3692\gdef\opnested{\char`\(\global\advance\parencount by 1 }
3693%
3694\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
3695% also in that case restore the outer-level definition of (.
3696\ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
3697\global\advance \parencount by -1 }
3698% If we encounter &foo, then turn on ()-hacking afterwards
3699\gdef\amprm#1 {{\rm\&#1}\let(=\oprm \let)=\clrm\ }
3700%
3701\gdef\normalparens{\boldbrax\let&=\ampnr}
3702} % End of definition inside \activeparens
3703%% These parens (in \boldbrax) actually are a little bolder than the
3704%% contained text.  This is especially needed for [ and ]
3705\def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
3706\def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
3707
3708% First, defname, which formats the header line itself.
3709% #1 should be the function name.
3710% #2 should be the type of definition, such as "Function".
3711
3712\def\defname #1#2{%
3713% Get the values of \leftskip and \rightskip as they were
3714% outside the @def...
3715\dimen2=\leftskip
3716\advance\dimen2 by -\defbodyindent
3717\dimen3=\rightskip
3718\advance\dimen3 by -\defbodyindent
3719\noindent        %
3720\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
3721\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
3722\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
3723\parshape 2 0in \dimen0 \defargsindent \dimen1     %
3724% Now output arg 2 ("Function" or some such)
3725% ending at \deftypemargin from the right margin,
3726% but stuck inside a box of width 0 so it does not interfere with linebreaking
3727{% Adjust \hsize to exclude the ambient margins,
3728% so that \rightline will obey them.
3729\advance \hsize by -\dimen2 \advance \hsize by -\dimen3
3730\rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}%
3731% Make all lines underfull and no complaints:
3732\tolerance=10000 \hbadness=10000
3733\advance\leftskip by -\defbodyindent
3734\exdentamount=\defbodyindent
3735{\df #1}\enskip        % Generate function name
3736}
3737
3738% Actually process the body of a definition
3739% #1 should be the terminating control sequence, such as \Edefun.
3740% #2 should be the "another name" control sequence, such as \defunx.
3741% #3 should be the control sequence that actually processes the header,
3742%    such as \defunheader.
3743
3744\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
3745\medbreak %
3746% Define the end token that this defining construct specifies
3747% so that it will exit this group.
3748\def#1{\endgraf\endgroup\medbreak}%
3749\def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
3750\parindent=0in
3751\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3752\exdentamount=\defbodyindent
3753\begingroup %
3754\catcode 61=\active % 61 is `='
3755\obeylines\activeparens\spacesplit#3}
3756
3757\def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
3758\medbreak %
3759% Define the end token that this defining construct specifies
3760% so that it will exit this group.
3761\def#1{\endgraf\endgroup\medbreak}%
3762\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
3763\parindent=0in
3764\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3765\exdentamount=\defbodyindent
3766\begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
3767
3768\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
3769\medbreak %
3770% Define the end token that this defining construct specifies
3771% so that it will exit this group.
3772\def#1{\endgraf\endgroup\medbreak}%
3773\def#2##1 ##2 {\def#4{##1}%
3774\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
3775\parindent=0in
3776\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3777\exdentamount=\defbodyindent
3778\begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
3779
3780% These parsing functions are similar to the preceding ones
3781% except that they do not make parens into active characters.
3782% These are used for "variables" since they have no arguments.
3783
3784\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
3785\medbreak %
3786% Define the end token that this defining construct specifies
3787% so that it will exit this group.
3788\def#1{\endgraf\endgroup\medbreak}%
3789\def#2{\begingroup\obeylines\spacesplit#3}%
3790\parindent=0in
3791\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3792\exdentamount=\defbodyindent
3793\begingroup %
3794\catcode 61=\active %
3795\obeylines\spacesplit#3}
3796
3797% This is used for \def{tp,vr}parsebody.  It could probably be used for
3798% some of the others, too, with some judicious conditionals.
3799%
3800\def\parsebodycommon#1#2#3{%
3801  \begingroup\inENV %
3802  \medbreak %
3803  % Define the end token that this defining construct specifies
3804  % so that it will exit this group.
3805  \def#1{\endgraf\endgroup\medbreak}%
3806  \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
3807  \parindent=0in
3808  \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3809  \exdentamount=\defbodyindent
3810  \begingroup\obeylines
3811}
3812
3813\def\defvrparsebody#1#2#3#4 {%
3814  \parsebodycommon{#1}{#2}{#3}%
3815  \spacesplit{#3{#4}}%
3816}
3817
3818% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the
3819% type is just `struct', because we lose the braces in `{struct
3820% termios}' when \spacesplit reads its undelimited argument.  Sigh.
3821% \let\deftpparsebody=\defvrparsebody
3822%
3823% So, to get around this, we put \empty in with the type name.  That
3824% way, TeX won't find exactly `{...}' as an undelimited argument, and
3825% won't strip off the braces.
3826%
3827\def\deftpparsebody #1#2#3#4 {%
3828  \parsebodycommon{#1}{#2}{#3}%
3829  \spacesplit{\parsetpheaderline{#3{#4}}}\empty
3830}
3831
3832% Fine, but then we have to eventually remove the \empty *and* the
3833% braces (if any).  That's what this does.
3834%
3835\def\removeemptybraces\empty#1\relax{#1}
3836
3837% After \spacesplit has done its work, this is called -- #1 is the final
3838% thing to call, #2 the type name (which starts with \empty), and #3
3839% (which might be empty) the arguments.
3840%
3841\def\parsetpheaderline#1#2#3{%
3842  #1{\removeemptybraces#2\relax}{#3}%
3843}%
3844
3845\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
3846\medbreak %
3847% Define the end token that this defining construct specifies
3848% so that it will exit this group.
3849\def#1{\endgraf\endgroup\medbreak}%
3850\def#2##1 ##2 {\def#4{##1}%
3851\begingroup\obeylines\spacesplit{#3{##2}}}%
3852\parindent=0in
3853\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3854\exdentamount=\defbodyindent
3855\begingroup\obeylines\spacesplit{#3{#5}}}
3856
3857% Split up #2 at the first space token.
3858% call #1 with two arguments:
3859%  the first is all of #2 before the space token,
3860%  the second is all of #2 after that space token.
3861% If #2 contains no space token, all of it is passed as the first arg
3862% and the second is passed as empty.
3863
3864{\obeylines
3865\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
3866\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
3867\ifx\relax #3%
3868#1{#2}{}\else #1{#2}{#3#4}\fi}}
3869
3870% So much for the things common to all kinds of definitions.
3871
3872% Define @defun.
3873
3874% First, define the processing that is wanted for arguments of \defun
3875% Use this to expand the args and terminate the paragraph they make up
3876
3877\def\defunargs #1{\functionparens \sl
3878% Expand, preventing hyphenation at `-' chars.
3879% Note that groups don't affect changes in \hyphenchar.
3880\hyphenchar\tensl=0
3881#1%
3882\hyphenchar\tensl=45
3883\ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
3884\interlinepenalty=10000
3885\advance\rightskip by 0pt plus 1fil
3886\endgraf\penalty 10000\vskip -\parskip\penalty 10000%
3887}
3888
3889\def\deftypefunargs #1{%
3890% Expand, preventing hyphenation at `-' chars.
3891% Note that groups don't affect changes in \hyphenchar.
3892% Use \boldbraxnoamp, not \functionparens, so that & is not special.
3893\boldbraxnoamp
3894\tclose{#1}% avoid \code because of side effects on active chars
3895\interlinepenalty=10000
3896\advance\rightskip by 0pt plus 1fil
3897\endgraf\penalty 10000\vskip -\parskip\penalty 10000%
3898}
3899
3900% Do complete processing of one @defun or @defunx line already parsed.
3901
3902% @deffn Command forward-char nchars
3903
3904\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
3905
3906\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
3907\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
3908\catcode 61=\other % Turn off change made in \defparsebody
3909}
3910
3911% @defun == @deffn Function
3912
3913\def\defun{\defparsebody\Edefun\defunx\defunheader}
3914
3915\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
3916\begingroup\defname {#1}{Function}%
3917\defunargs {#2}\endgroup %
3918\catcode 61=\other % Turn off change made in \defparsebody
3919}
3920
3921% @deftypefun int foobar (int @var{foo}, float @var{bar})
3922
3923\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
3924
3925% #1 is the data type.  #2 is the name and args.
3926\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
3927% #1 is the data type, #2 the name, #3 the args.
3928\def\deftypefunheaderx #1#2 #3\relax{%
3929\doind {fn}{\code{#2}}% Make entry in function index
3930\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Function}%
3931\deftypefunargs {#3}\endgroup %
3932\catcode 61=\other % Turn off change made in \defparsebody
3933}
3934
3935% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
3936
3937\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
3938
3939% \defheaderxcond#1\relax$$$
3940% puts #1 in @code, followed by a space, but does nothing if #1 is null.
3941\def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi}
3942
3943% #1 is the classification.  #2 is the data type.  #3 is the name and args.
3944\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
3945% #1 is the classification, #2 the data type, #3 the name, #4 the args.
3946\def\deftypefnheaderx #1#2#3 #4\relax{%
3947\doind {fn}{\code{#3}}% Make entry in function index
3948\begingroup
3949\normalparens % notably, turn off `&' magic, which prevents
3950%               at least some C++ text from working
3951\defname {\defheaderxcond#2\relax$$$#3}{#1}%
3952\deftypefunargs {#4}\endgroup %
3953\catcode 61=\other % Turn off change made in \defparsebody
3954}
3955
3956% @defmac == @deffn Macro
3957
3958\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
3959
3960\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
3961\begingroup\defname {#1}{Macro}%
3962\defunargs {#2}\endgroup %
3963\catcode 61=\other % Turn off change made in \defparsebody
3964}
3965
3966% @defspec == @deffn Special Form
3967
3968\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
3969
3970\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
3971\begingroup\defname {#1}{Special Form}%
3972\defunargs {#2}\endgroup %
3973\catcode 61=\other % Turn off change made in \defparsebody
3974}
3975
3976% This definition is run if you use @defunx
3977% anywhere other than immediately after a @defun or @defunx.
3978
3979\def\deffnx #1 {\errmessage{@deffnx in invalid context}}
3980\def\defunx #1 {\errmessage{@defunx in invalid context}}
3981\def\defmacx #1 {\errmessage{@defmacx in invalid context}}
3982\def\defspecx #1 {\errmessage{@defspecx in invalid context}}
3983\def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
3984\def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}}
3985
3986% @defmethod, and so on
3987
3988% @defop {Funny Method} foo-class frobnicate argument
3989
3990\def\defop #1 {\def\defoptype{#1}%
3991\defopparsebody\Edefop\defopx\defopheader\defoptype}
3992
3993\def\defopheader #1#2#3{%
3994\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
3995\begingroup\defname {#2}{\defoptype{} on #1}%
3996\defunargs {#3}\endgroup %
3997}
3998
3999% @defmethod == @defop Method
4000
4001\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
4002
4003\def\defmethodheader #1#2#3{%
4004\dosubind {fn}{\code{#2}}{on #1}% entry in function index
4005\begingroup\defname {#2}{Method on #1}%
4006\defunargs {#3}\endgroup %
4007}
4008
4009% @defcv {Class Option} foo-class foo-flag
4010
4011\def\defcv #1 {\def\defcvtype{#1}%
4012\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
4013
4014\def\defcvarheader #1#2#3{%
4015\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
4016\begingroup\defname {#2}{\defcvtype{} of #1}%
4017\defvarargs {#3}\endgroup %
4018}
4019
4020% @defivar == @defcv {Instance Variable}
4021
4022\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
4023
4024\def\defivarheader #1#2#3{%
4025\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
4026\begingroup\defname {#2}{Instance Variable of #1}%
4027\defvarargs {#3}\endgroup %
4028}
4029
4030% These definitions are run if you use @defmethodx, etc.,
4031% anywhere other than immediately after a @defmethod, etc.
4032
4033\def\defopx #1 {\errmessage{@defopx in invalid context}}
4034\def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
4035\def\defcvx #1 {\errmessage{@defcvx in invalid context}}
4036\def\defivarx #1 {\errmessage{@defivarx in invalid context}}
4037
4038% Now @defvar
4039
4040% First, define the processing that is wanted for arguments of @defvar.
4041% This is actually simple: just print them in roman.
4042% This must expand the args and terminate the paragraph they make up
4043\def\defvarargs #1{\normalparens #1%
4044\interlinepenalty=10000
4045\endgraf\penalty 10000\vskip -\parskip\penalty 10000}
4046
4047% @defvr Counter foo-count
4048
4049\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
4050
4051\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
4052\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
4053
4054% @defvar == @defvr Variable
4055
4056\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
4057
4058\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
4059\begingroup\defname {#1}{Variable}%
4060\defvarargs {#2}\endgroup %
4061}
4062
4063% @defopt == @defvr {User Option}
4064
4065\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
4066
4067\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
4068\begingroup\defname {#1}{User Option}%
4069\defvarargs {#2}\endgroup %
4070}
4071
4072% @deftypevar int foobar
4073
4074\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
4075
4076% #1 is the data type.  #2 is the name, perhaps followed by text that
4077% is actually part of the data type, which should not be put into the index.
4078\def\deftypevarheader #1#2{%
4079\dovarind#2 \relax% Make entry in variables index
4080\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Variable}%
4081\interlinepenalty=10000
4082\endgraf\penalty 10000\vskip -\parskip\penalty 10000
4083\endgroup}
4084\def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}}
4085
4086% @deftypevr {Global Flag} int enable
4087
4088\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
4089
4090\def\deftypevrheader #1#2#3{\dovarind#3 \relax%
4091\begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1}
4092\interlinepenalty=10000
4093\endgraf\penalty 10000\vskip -\parskip\penalty 10000
4094\endgroup}
4095
4096% This definition is run if you use @defvarx
4097% anywhere other than immediately after a @defvar or @defvarx.
4098
4099\def\defvrx #1 {\errmessage{@defvrx in invalid context}}
4100\def\defvarx #1 {\errmessage{@defvarx in invalid context}}
4101\def\defoptx #1 {\errmessage{@defoptx in invalid context}}
4102\def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
4103\def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
4104
4105% Now define @deftp
4106% Args are printed in bold, a slight difference from @defvar.
4107
4108\def\deftpargs #1{\bf \defvarargs{#1}}
4109
4110% @deftp Class window height width ...
4111
4112\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
4113
4114\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
4115\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
4116
4117% This definition is run if you use @deftpx, etc
4118% anywhere other than immediately after a @deftp, etc.
4119
4120\def\deftpx #1 {\errmessage{@deftpx in invalid context}}
4121
4122
4123\message{cross reference,}
4124% Define cross-reference macros
4125\newwrite \auxfile
4126
4127\newif\ifhavexrefs  % True if xref values are known.
4128\newif\ifwarnedxrefs  % True if we warned once that they aren't known.
4129
4130% @inforef is simple.
4131\def\inforef #1{\inforefzzz #1,,,,**}
4132\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
4133  node \samp{\ignorespaces#1{}}}
4134
4135% \setref{foo} defines a cross-reference point named foo.
4136
4137\def\setref#1{%
4138\dosetq{#1-title}{Ytitle}%
4139\dosetq{#1-pg}{Ypagenumber}%
4140\dosetq{#1-snt}{Ysectionnumberandtype}}
4141
4142\def\unnumbsetref#1{%
4143\dosetq{#1-title}{Ytitle}%
4144\dosetq{#1-pg}{Ypagenumber}%
4145\dosetq{#1-snt}{Ynothing}}
4146
4147\def\appendixsetref#1{%
4148\dosetq{#1-title}{Ytitle}%
4149\dosetq{#1-pg}{Ypagenumber}%
4150\dosetq{#1-snt}{Yappendixletterandtype}}
4151
4152% \xref, \pxref, and \ref generate cross-references to specified points.
4153% For \xrefX, #1 is the node name, #2 the name of the Info
4154% cross-reference, #3 the printed node name, #4 the name of the Info
4155% file, #5 the name of the printed manual.  All but the node name can be
4156% omitted.
4157%
4158\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
4159\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
4160\def\ref#1{\xrefX[#1,,,,,,,]}
4161\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
4162  \def\printedmanual{\ignorespaces #5}%
4163  \def\printednodename{\ignorespaces #3}%
4164  \setbox1=\hbox{\printedmanual}%
4165  \setbox0=\hbox{\printednodename}%
4166  \ifdim \wd0 = 0pt
4167    % No printed node name was explicitly given.
4168    \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
4169      % Use the node name inside the square brackets.
4170      \def\printednodename{\ignorespaces #1}%
4171    \else
4172      % Use the actual chapter/section title appear inside
4173      % the square brackets.  Use the real section title if we have it.
4174      \ifdim \wd1>0pt%
4175        % It is in another manual, so we don't have it.
4176        \def\printednodename{\ignorespaces #1}%
4177      \else
4178        \ifhavexrefs
4179          % We know the real title if we have the xref values.
4180          \def\printednodename{\refx{#1-title}{}}%
4181        \else
4182          % Otherwise just copy the Info node name.
4183          \def\printednodename{\ignorespaces #1}%
4184        \fi%
4185      \fi
4186    \fi
4187  \fi
4188  %
4189  % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
4190  % insert empty discretionaries after hyphens, which means that it will
4191  % not find a line break at a hyphen in a node names.  Since some manuals
4192  % are best written with fairly long node names, containing hyphens, this
4193  % is a loss.  Therefore, we give the text of the node name again, so it
4194  % is as if TeX is seeing it for the first time.
4195  \ifdim \wd1 > 0pt
4196    \putwordsection{} ``\printednodename'' in \cite{\printedmanual}%
4197  \else
4198    % _ (for example) has to be the character _ for the purposes of the
4199    % control sequence corresponding to the node, but it has to expand
4200    % into the usual \leavevmode...\vrule stuff for purposes of
4201    % printing. So we \turnoffactive for the \refx-snt, back on for the
4202    % printing, back off for the \refx-pg.
4203    {\turnoffactive \refx{#1-snt}{}}%
4204    \space [\printednodename],\space
4205    \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
4206  \fi
4207\endgroup}
4208
4209% \dosetq is the interface for calls from other macros
4210
4211% Use \turnoffactive so that punctuation chars such as underscore
4212% work in node names.
4213\def\dosetq #1#2{{\let\folio=0 \turnoffactive
4214\edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
4215\next}}
4216
4217% \internalsetq {foo}{page} expands into
4218% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
4219% When the aux file is read, ' is the escape character
4220
4221\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
4222
4223% Things to be expanded by \internalsetq
4224
4225\def\Ypagenumber{\folio}
4226
4227\def\Ytitle{\thissection}
4228
4229\def\Ynothing{}
4230
4231\def\Ysectionnumberandtype{%
4232\ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
4233\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
4234\else \ifnum \subsubsecno=0 %
4235\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
4236\else %
4237\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
4238\fi \fi \fi }
4239
4240\def\Yappendixletterandtype{%
4241\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
4242\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
4243\else \ifnum \subsubsecno=0 %
4244\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
4245\else %
4246\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
4247\fi \fi \fi }
4248
4249\gdef\xreftie{'tie}
4250
4251% Use TeX 3.0's \inputlineno to get the line number, for better error
4252% messages, but if we're using an old version of TeX, don't do anything.
4253%
4254\ifx\inputlineno\thisisundefined
4255  \let\linenumber = \empty % Non-3.0.
4256\else
4257  \def\linenumber{\the\inputlineno:\space}
4258\fi
4259
4260% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
4261% If its value is nonempty, SUFFIX is output afterward.
4262
4263\def\refx#1#2{%
4264  \expandafter\ifx\csname X#1\endcsname\relax
4265    % If not defined, say something at least.
4266    $\langle$un\-de\-fined$\rangle$%
4267    \ifhavexrefs
4268      \message{\linenumber Undefined cross reference `#1'.}%
4269    \else
4270      \ifwarnedxrefs\else
4271        \global\warnedxrefstrue
4272        \message{Cross reference values unknown; you must run TeX again.}%
4273      \fi
4274    \fi
4275  \else
4276    % It's defined, so just use it.
4277    \csname X#1\endcsname
4278  \fi
4279  #2% Output the suffix in any case.
4280}
4281
4282% This is the macro invoked by entries in the aux file.
4283\def\xrdef #1#2{{%
4284  \catcode`\'=\other
4285  \expandafter\gdef\csname X#1\endcsname{#2}%
4286}}
4287
4288% Read the last existing aux file, if any.  No error if none exists.
4289\def\readauxfile{\begingroup
4290  \catcode`\^^@=\other
4291  \catcode`\=\other
4292  \catcode`\=\other
4293  \catcode`\^^C=\other
4294  \catcode`\^^D=\other
4295  \catcode`\^^E=\other
4296  \catcode`\^^F=\other
4297  \catcode`\^^G=\other
4298  \catcode`\^^H=\other
4299  \catcode`\=\other
4300  \catcode`\^^L=\other
4301  \catcode`\=\other
4302  \catcode`\=\other
4303  \catcode`\=\other
4304  \catcode`\=\other
4305  \catcode`\=\other
4306  \catcode`\=\other
4307  \catcode`\=\other
4308  \catcode`\=\other
4309  \catcode`\=\other
4310  \catcode`\=\other
4311  \catcode`\=\other
4312  \catcode`\=\other
4313  \catcode26=\other
4314  \catcode`\^^[=\other
4315  \catcode`\^^\=\other
4316  \catcode`\^^]=\other
4317  \catcode`\^^^=\other
4318  \catcode`\^^_=\other
4319  \catcode`\@=\other
4320  \catcode`\^=\other
4321  % It was suggested to define this as 7, which would allow ^^e4 etc.
4322  % in xref tags, i.e., node names.  But since ^^e4 notation isn't
4323  % supported in the main text, it doesn't seem desirable.  Furthermore,
4324  % that is not enough: for node names that actually contain a ^
4325  % character, we would end up writing a line like this: 'xrdef {'hat
4326  % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
4327  % argument, and \hat is not an expandable control sequence.  It could
4328  % all be worked out, but why?  Either we support ^^ or we don't.
4329  %
4330  % The other change necessary for this was to define \auxhat:
4331  % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
4332  % and then to call \auxhat in \setq.
4333  %
4334  \catcode`\~=\other
4335  \catcode`\[=\other
4336  \catcode`\]=\other
4337  \catcode`\"=\other
4338  \catcode`\_=\other
4339  \catcode`\|=\other
4340  \catcode`\<=\other
4341  \catcode`\>=\other
4342  \catcode`\$=\other
4343  \catcode`\#=\other
4344  \catcode`\&=\other
4345  % `\+ does not work, so use 43.
4346  \catcode43=\other
4347  % Make the characters 128-255 be printing characters
4348  {%
4349    \count 1=128
4350    \def\loop{%
4351      \catcode\count 1=\other
4352      \advance\count 1 by 1
4353      \ifnum \count 1<256 \loop \fi
4354    }%
4355  }%
4356  % The aux file uses ' as the escape (for now).
4357  % Turn off \ as an escape so we do not lose on
4358  % entries which were dumped with control sequences in their names.
4359  % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
4360  % Reference to such entries still does not work the way one would wish,
4361  % but at least they do not bomb out when the aux file is read in.
4362  \catcode`\{=1
4363  \catcode`\}=2
4364  \catcode`\%=\other
4365  \catcode`\'=0
4366  \catcode`\\=\other
4367  %
4368  \openin 1 \jobname.aux
4369  \ifeof 1 \else
4370    \closein 1
4371    \input \jobname.aux
4372    \global\havexrefstrue
4373    \global\warnedobstrue
4374  \fi
4375  % Open the new aux file.  TeX will close it automatically at exit.
4376  \openout\auxfile=\jobname.aux
4377\endgroup}
4378
4379
4380% Footnotes.
4381
4382\newcount \footnoteno
4383
4384% The trailing space in the following definition for supereject is
4385% vital for proper filling; pages come out unaligned when you do a
4386% pagealignmacro call if that space before the closing brace is
4387% removed. (Generally, numeric constants should always be followed by a
4388% space to prevent strange expansion errors.)
4389\def\supereject{\par\penalty -20000\footnoteno =0 }
4390
4391% @footnotestyle is meaningful for info output only..
4392\let\footnotestyle=\comment
4393
4394\let\ptexfootnote=\footnote
4395
4396{\catcode `\@=11
4397%
4398% Auto-number footnotes.  Otherwise like plain.
4399\gdef\footnote{%
4400  \global\advance\footnoteno by \@ne
4401  \edef\thisfootno{$^{\the\footnoteno}$}%
4402  %
4403  % In case the footnote comes at the end of a sentence, preserve the
4404  % extra spacing after we do the footnote number.
4405  \let\@sf\empty
4406  \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
4407  %
4408  % Remove inadvertent blank space before typesetting the footnote number.
4409  \unskip
4410  \thisfootno\@sf
4411  \footnotezzz
4412}%
4413
4414% Don't bother with the trickery in plain.tex to not require the
4415% footnote text as a parameter.  Our footnotes don't need to be so general.
4416%
4417% Oh yes, they do; otherwise, @ifset and anything else that uses
4418% \parseargline fail inside footnotes because the tokens are fixed when
4419% the footnote is read.  --karl, 16nov96.
4420%
4421\long\gdef\footnotezzz{\insert\footins\bgroup
4422  % We want to typeset this text as a normal paragraph, even if the
4423  % footnote reference occurs in (for example) a display environment.
4424  % So reset some parameters.
4425  \interlinepenalty\interfootnotelinepenalty
4426  \splittopskip\ht\strutbox % top baseline for broken footnotes
4427  \splitmaxdepth\dp\strutbox
4428  \floatingpenalty\@MM
4429  \leftskip\z@skip
4430  \rightskip\z@skip
4431  \spaceskip\z@skip
4432  \xspaceskip\z@skip
4433  \parindent\defaultparindent
4434  %
4435  % Hang the footnote text off the number.
4436  \hang
4437  \textindent{\thisfootno}%
4438  %
4439  % Don't crash into the line above the footnote text.  Since this
4440  % expands into a box, it must come within the paragraph, lest it
4441  % provide a place where TeX can split the footnote.
4442  \footstrut
4443  \futurelet\next\fo@t
4444}
4445\def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t
4446  \else\let\next\f@t\fi \next}
4447\def\f@@t{\bgroup\aftergroup\@foot\let\next}
4448\def\f@t#1{#1\@foot}
4449\def\@foot{\strut\egroup}
4450
4451}%end \catcode `\@=11
4452
4453% Set the baselineskip to #1, and the lineskip and strut size
4454% correspondingly.  There is no deep meaning behind these magic numbers
4455% used as factors; they just match (closely enough) what Knuth defined.
4456%
4457\def\lineskipfactor{.08333}
4458\def\strutheightpercent{.70833}
4459\def\strutdepthpercent {.29167}
4460%
4461\def\setleading#1{%
4462  \normalbaselineskip = #1\relax
4463  \normallineskip = \lineskipfactor\normalbaselineskip
4464  \normalbaselines
4465  \setbox\strutbox =\hbox{%
4466    \vrule width0pt height\strutheightpercent\baselineskip
4467                    depth \strutdepthpercent \baselineskip
4468  }%
4469}
4470
4471% @| inserts a changebar to the left of the current line.  It should
4472% surround any changed text.  This approach does *not* work if the
4473% change spans more than two lines of output.  To handle that, we would
4474% have adopt a much more difficult approach (putting marks into the main
4475% vertical list for the beginning and end of each change).
4476%
4477\def\|{%
4478  % \vadjust can only be used in horizontal mode.
4479  \leavevmode
4480  %
4481  % Append this vertical mode material after the current line in the output.
4482  \vadjust{%
4483    % We want to insert a rule with the height and depth of the current
4484    % leading; that is exactly what \strutbox is supposed to record.
4485    \vskip-\baselineskip
4486    %
4487    % \vadjust-items are inserted at the left edge of the type.  So
4488    % the \llap here moves out into the left-hand margin.
4489    \llap{%
4490      %
4491      % For a thicker or thinner bar, change the `1pt'.
4492      \vrule height\baselineskip width1pt
4493      %
4494      % This is the space between the bar and the text.
4495      \hskip 12pt
4496    }%
4497  }%
4498}
4499
4500% For a final copy, take out the rectangles
4501% that mark overfull boxes (in case you have decided
4502% that the text looks ok even though it passes the margin).
4503%
4504\def\finalout{\overfullrule=0pt}
4505
4506
4507% End of control word definitions.
4508
4509\message{and turning on texinfo input format.}
4510
4511\def\openindices{%
4512   \newindex{cp}%
4513   \newcodeindex{fn}%
4514   \newcodeindex{vr}%
4515   \newcodeindex{tp}%
4516   \newcodeindex{ky}%
4517   \newcodeindex{pg}%
4518}
4519
4520% Set some numeric style parameters, for 8.5 x 11 format.
4521
4522\hsize = 6in
4523\hoffset = .25in
4524\newdimen\defaultparindent \defaultparindent = 15pt
4525\parindent = \defaultparindent
4526\parskip 3pt plus 2pt minus 1pt
4527\setleading{13.2pt}
4528\advance\topskip by 1.2cm
4529
4530\chapheadingskip = 15pt plus 4pt minus 2pt
4531\secheadingskip = 12pt plus 3pt minus 2pt
4532\subsecheadingskip = 9pt plus 2pt minus 2pt
4533
4534% Prevent underfull vbox error messages.
4535\vbadness=10000
4536
4537% Following George Bush, just get rid of widows and orphans.
4538\widowpenalty=10000
4539\clubpenalty=10000
4540
4541% Use TeX 3.0's \emergencystretch to help line breaking, but if we're
4542% using an old version of TeX, don't do anything.  We want the amount of
4543% stretch added to depend on the line length, hence the dependence on
4544% \hsize.  This makes it come to about 9pt for the 8.5x11 format.
4545%
4546\ifx\emergencystretch\thisisundefined
4547  % Allow us to assign to \emergencystretch anyway.
4548  \def\emergencystretch{\dimen0}%
4549\else
4550  \emergencystretch = \hsize
4551  \divide\emergencystretch by 45
4552\fi
4553
4554% Use @smallbook to reset parameters for 7x9.5 format  (or else 7x9.25)
4555\def\smallbook{
4556  \global\chapheadingskip = 15pt plus 4pt minus 2pt
4557  \global\secheadingskip = 12pt plus 3pt minus 2pt
4558  \global\subsecheadingskip = 9pt plus 2pt minus 2pt
4559  %
4560  \global\lispnarrowing = 0.3in
4561  \setleading{12pt}
4562  \advance\topskip by -1cm
4563  \global\parskip 2pt plus 1pt
4564  \global\hsize = 5in
4565  \global\vsize=7.5in
4566  \global\tolerance=700
4567  \global\hfuzz=1pt
4568  \global\contentsrightmargin=0pt
4569  \global\deftypemargin=0pt
4570  \global\defbodyindent=.5cm
4571  %
4572  \global\pagewidth=\hsize
4573  \global\pageheight=\vsize
4574  %
4575  \global\let\smalllisp=\smalllispx
4576  \global\let\smallexample=\smalllispx
4577  \global\def\Esmallexample{\Esmalllisp}
4578}
4579
4580% Use @afourpaper to print on European A4 paper.
4581\def\afourpaper{
4582\global\tolerance=700
4583\global\hfuzz=1pt
4584\setleading{12pt}
4585\global\parskip 15pt plus 1pt
4586
4587\global\vsize= 53\baselineskip
4588\advance\vsize by \topskip
4589%\global\hsize=   5.85in     % A4 wide 10pt
4590\global\hsize=  6.5in
4591\global\outerhsize=\hsize
4592\global\advance\outerhsize by 0.5in
4593\global\outervsize=\vsize
4594\global\advance\outervsize by 0.6in
4595
4596\global\pagewidth=\hsize
4597\global\pageheight=\vsize
4598}
4599
4600\bindingoffset=0pt
4601\normaloffset=\hoffset
4602\pagewidth=\hsize
4603\pageheight=\vsize
4604
4605% Allow control of the text dimensions.  Parameters in order: textheight;
4606% textwidth; voffset; hoffset; binding offset; topskip.
4607% All require a dimension;
4608% header is additional; added length extends the bottom of the page.
4609
4610\def\changepagesizes#1#2#3#4#5#6{
4611 \global\vsize= #1
4612 \global\topskip= #6
4613 \advance\vsize by \topskip
4614 \global\voffset= #3
4615 \global\hsize= #2
4616 \global\outerhsize=\hsize
4617 \global\advance\outerhsize by 0.5in
4618 \global\outervsize=\vsize
4619 \global\advance\outervsize by 0.6in
4620 \global\pagewidth=\hsize
4621 \global\pageheight=\vsize
4622 \global\normaloffset= #4
4623 \global\bindingoffset= #5}
4624
4625% A specific text layout, 24x15cm overall, intended for A4 paper.  Top margin
4626% 29mm, hence bottom margin 28mm, nominal side margin 3cm.
4627\def\afourlatex
4628        {\global\tolerance=700
4629        \global\hfuzz=1pt
4630        \setleading{12pt}
4631        \global\parskip 15pt plus 1pt
4632        \advance\baselineskip by 1.6pt
4633        \changepagesizes{237mm}{150mm}{3.6mm}{3.6mm}{3mm}{7mm}
4634        }
4635
4636% Use @afourwide to print on European A4 paper in wide format.
4637\def\afourwide{\afourpaper
4638\changepagesizes{9.5in}{6.5in}{\hoffset}{\normaloffset}{\bindingoffset}{7mm}}
4639
4640% Define macros to output various characters with catcode for normal text.
4641\catcode`\"=\other
4642\catcode`\~=\other
4643\catcode`\^=\other
4644\catcode`\_=\other
4645\catcode`\|=\other
4646\catcode`\<=\other
4647\catcode`\>=\other
4648\catcode`\+=\other
4649\def\normaldoublequote{"}
4650\def\normaltilde{~}
4651\def\normalcaret{^}
4652\def\normalunderscore{_}
4653\def\normalverticalbar{|}
4654\def\normalless{<}
4655\def\normalgreater{>}
4656\def\normalplus{+}
4657
4658% This macro is used to make a character print one way in ttfont
4659% where it can probably just be output, and another way in other fonts,
4660% where something hairier probably needs to be done.
4661%
4662% #1 is what to print if we are indeed using \tt; #2 is what to print
4663% otherwise.  Since all the Computer Modern typewriter fonts have zero
4664% interword stretch (and shrink), and it is reasonable to expect all
4665% typewriter fonts to have this, we can check that font parameter.
4666%
4667\def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi}
4668
4669% Turn off all special characters except @
4670% (and those which the user can use as if they were ordinary).
4671% Most of these we simply print from the \tt font, but for some, we can
4672% use math or other variants that look better in normal text.
4673
4674\catcode`\"=\active
4675\def\activedoublequote{{\tt \char '042}}
4676\let"=\activedoublequote
4677\catcode`\~=\active
4678\def~{{\tt \char '176}}
4679\chardef\hat=`\^
4680\catcode`\^=\active
4681\def^{{\tt \hat}}
4682
4683\catcode`\_=\active
4684\def_{\ifusingtt\normalunderscore\_}
4685% Subroutine for the previous macro.
4686\def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}}
4687
4688\catcode`\|=\active
4689\def|{{\tt \char '174}}
4690\chardef \less=`\<
4691\catcode`\<=\active
4692\def<{{\tt \less}}
4693\chardef \gtr=`\>
4694\catcode`\>=\active
4695\def>{{\tt \gtr}}
4696\catcode`\+=\active
4697\def+{{\tt \char 43}}
4698%\catcode 27=\active
4699%\def^^[{$\diamondsuit$}
4700
4701% Set up an active definition for =, but don't enable it most of the time.
4702{\catcode`\==\active
4703\global\def={{\tt \char 61}}}
4704
4705\catcode`+=\active
4706\catcode`\_=\active
4707
4708% If a .fmt file is being used, characters that might appear in a file
4709% name cannot be active until we have parsed the command line.
4710% So turn them off again, and have \everyjob (or @setfilename) turn them on.
4711% \otherifyactive is called near the end of this file.
4712\def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
4713
4714\catcode`\@=0
4715
4716% \rawbackslashxx output one backslash character in current font
4717\global\chardef\rawbackslashxx=`\\
4718%{\catcode`\\=\other
4719%@gdef@rawbackslashxx{\}}
4720
4721% \rawbackslash redefines \ as input to do \rawbackslashxx.
4722{\catcode`\\=\active
4723@gdef@rawbackslash{@let\=@rawbackslashxx }}
4724
4725% \normalbackslash outputs one backslash in fixed width font.
4726\def\normalbackslash{{\tt\rawbackslashxx}}
4727
4728% Say @foo, not \foo, in error messages.
4729\escapechar=`\@
4730
4731% \catcode 17=0   % Define control-q
4732\catcode`\\=\active
4733
4734% Used sometimes to turn off (effectively) the active characters
4735% even after parsing them.
4736@def@turnoffactive{@let"=@normaldoublequote
4737@let\=@realbackslash
4738@let~=@normaltilde
4739@let^=@normalcaret
4740@let_=@normalunderscore
4741@let|=@normalverticalbar
4742@let<=@normalless
4743@let>=@normalgreater
4744@let+=@normalplus}
4745
4746@def@normalturnoffactive{@let"=@normaldoublequote
4747@let\=@normalbackslash
4748@let~=@normaltilde
4749@let^=@normalcaret
4750@let_=@normalunderscore
4751@let|=@normalverticalbar
4752@let<=@normalless
4753@let>=@normalgreater
4754@let+=@normalplus}
4755
4756% Make _ and + \other characters, temporarily.
4757% This is canceled by @fixbackslash.
4758@otherifyactive
4759
4760% If a .fmt file is being used, we don't want the `\input texinfo' to show up.
4761% That is what \eatinput is for; after that, the `\' should revert to printing
4762% a backslash.
4763%
4764@gdef@eatinput input texinfo{@fixbackslash}
4765@global@let\ = @eatinput
4766
4767% On the other hand, perhaps the file did not have a `\input texinfo'. Then
4768% the first `\{ in the file would cause an error. This macro tries to fix
4769% that, assuming it is called before the first `\' could plausibly occur.
4770% Also back turn on active characters that might appear in the input
4771% file name, in case not using a pre-dumped format.
4772%
4773@gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi
4774  @catcode`+=@active @catcode`@_=@active}
4775
4776%% These look ok in all fonts, so just make them not special.  The @rm below
4777%% makes sure that the current font starts out as the newly loaded cmr10
4778@catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
4779
4780@textfonts
4781@rm
4782
4783@c Local variables:
4784@c page-delimiter: "^\\\\message"
4785@c End:
Note: See TracBrowser for help on using the repository browser.