OSDN Git Service

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