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