OSDN Git Service

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