OSDN Git Service

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