OSDN Git Service

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