]> www.ginac.de Git - ginac.git/blob - doc/tutorial/texinfo.tex
* Fix typo. (Hi Keith!)
[ginac.git] / doc / tutorial / texinfo.tex
1 % texinfo.tex -- TeX macros to handle Texinfo files.
2 %
3 % Load plain if necessary, i.e., if running under initex.
4 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5 %
6 \def\texinfoversion{1999-10-01.07}
7 %
8 % Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
9 % Free Software Foundation, Inc.
10 %
11 % This texinfo.tex file is free software; you can redistribute it and/or
12 % modify it under the terms of the GNU General Public License as
13 % published by the Free Software Foundation; either version 2, or (at
14 % your option) any later version.
15 %
16 % This texinfo.tex file is distributed in the hope that it will be
17 % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
18 % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 % General Public License for more details.
20 %
21 % You should have received a copy of the GNU General Public License
22 % along with this texinfo.tex file; see the file COPYING.  If not, write
23 % to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 % Boston, MA 02111-1307, USA.
25 %
26 % In other words, you are welcome to use, share and improve this program.
27 % You are forbidden to forbid anyone else to use, share and improve
28 % what you give them.   Help stamp out software-hoarding!
29 %
30 % Please try the latest version of texinfo.tex before submitting bug
31 % reports; you can get the latest version from:
32 %   ftp://ftp.gnu.org/gnu/texinfo.tex
33 %   (and all GNU mirrors, see http://www.gnu.org/order/ftp.html)
34 %   ftp://texinfo.org/tex/texinfo.tex
35 %   ftp://us.ctan.org/macros/texinfo/texinfo.tex
36 %   (and all CTAN mirrors, finger ctan@us.ctan.org for a list).
37 %   /home/gd/gnu/doc/texinfo.tex on the GNU machines.
38 % The texinfo.tex in any given Texinfo distribution could well be out
39 % of date, so if that's what you're using, please check.
40 % Texinfo has a small home page at http://texinfo.org/.
41 %
42 % Send bug reports to bug-texinfo@gnu.org.  Please include including a
43 % complete document in each bug report with which we can reproduce the
44 % problem.  Patches are, of course, greatly appreciated.
45 %
46 % To process a Texinfo manual with TeX, it's most reliable to use the
47 % texi2dvi shell script that comes with the distribution.  For a simple
48 % manual foo.texi, however, you can get away with this:
49 %   tex foo.texi
50 %   texindex foo.??
51 %   tex foo.texi
52 %   tex foo.texi
53 %   dvips foo.dvi -o # or whatever, to process the dvi file; this makes foo.ps.
54 % The extra runs of TeX get the cross-reference information correct.
55 % Sometimes one run after texindex suffices, and sometimes you need more
56 % than two; texi2dvi does it as many times as necessary.
57 %
58 % It is possible to adapt texinfo.tex for other languages.  You can get
59 % the existing language-specific files from ftp://ftp.gnu.org/gnu/texinfo/.
60
61 \message{Loading texinfo [version \texinfoversion]:}
62
63 % If in a .fmt file, print the version number
64 % and turn on active characters that we couldn't do earlier because
65 % they might have appeared in the input file name.
66 \everyjob{\message{[Texinfo version \texinfoversion]}%
67   \catcode`+=\active \catcode`\_=\active}
68
69 % Save some parts of plain tex whose names we will redefine.
70 \let\ptexb=\b
71 \let\ptexbullet=\bullet
72 \let\ptexc=\c
73 \let\ptexcomma=\,
74 \let\ptexdot=\.
75 \let\ptexdots=\dots
76 \let\ptexend=\end
77 \let\ptexequiv=\equiv
78 \let\ptexexclam=\!
79 \let\ptexi=\i
80 \let\ptexlbrace=\{
81 \let\ptexrbrace=\}
82 \let\ptexstar=\*
83 \let\ptext=\t
84
85 % We never want plain's outer \+ definition in Texinfo.
86 % For @tex, we can use \tabalign.
87 \let\+ = \relax
88
89 \message{Basics,}
90 \chardef\other=12
91
92 % If this character appears in an error message or help string, it
93 % starts a new line in the output.
94 \newlinechar = `^^J
95
96 % Set up fixed words for English if not already set.
97 \ifx\putwordAppendix\undefined  \gdef\putwordAppendix{Appendix}\fi
98 \ifx\putwordChapter\undefined   \gdef\putwordChapter{Chapter}\fi
99 \ifx\putwordfile\undefined      \gdef\putwordfile{file}\fi
100 \ifx\putwordin\undefined        \gdef\putwordin{in}\fi
101 \ifx\putwordIndexIsEmpty\undefined     \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
102 \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
103 \ifx\putwordInfo\undefined      \gdef\putwordInfo{Info}\fi
104 \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
105 \ifx\putwordMethodon\undefined  \gdef\putwordMethodon{Method on}\fi
106 \ifx\putwordNoTitle\undefined   \gdef\putwordNoTitle{No Title}\fi
107 \ifx\putwordof\undefined        \gdef\putwordof{of}\fi
108 \ifx\putwordon\undefined        \gdef\putwordon{on}\fi
109 \ifx\putwordpage\undefined      \gdef\putwordpage{page}\fi
110 \ifx\putwordsection\undefined   \gdef\putwordsection{section}\fi
111 \ifx\putwordSection\undefined   \gdef\putwordSection{Section}\fi
112 \ifx\putwordsee\undefined       \gdef\putwordsee{see}\fi
113 \ifx\putwordSee\undefined       \gdef\putwordSee{See}\fi
114 \ifx\putwordShortTOC\undefined  \gdef\putwordShortTOC{Short Contents}\fi
115 \ifx\putwordTOC\undefined       \gdef\putwordTOC{Table of Contents}\fi
116 %
117 \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
118 \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
119 \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
120 \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
121 \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
122 \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
123 \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
124 \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
125 \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
126 \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
127 \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
128 \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
129 %
130 \ifx\putwordDefmac\undefined    \gdef\putwordDefmac{Macro}\fi
131 \ifx\putwordDefspec\undefined   \gdef\putwordDefspec{Special Form}\fi
132 \ifx\putwordDefvar\undefined    \gdef\putwordDefvar{Variable}\fi
133 \ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
134 \ifx\putwordDeftypevar\undefined\gdef\putwordDeftypevar{Variable}\fi
135 \ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
136 \ifx\putwordDeftypefun\undefined\gdef\putwordDeftypefun{Function}\fi
137
138 % Ignore a token.
139 %
140 \def\gobble#1{}
141
142 \hyphenation{ap-pen-dix}
143 \hyphenation{mini-buf-fer mini-buf-fers}
144 \hyphenation{eshell}
145 \hyphenation{white-space}
146
147 % Margin to add to right of even pages, to left of odd pages.
148 \newdimen \bindingoffset
149 \newdimen \normaloffset
150 \newdimen\pagewidth \newdimen\pageheight
151
152 % Sometimes it is convenient to have everything in the transcript file
153 % and nothing on the terminal.  We don't just call \tracingall here,
154 % since that produces some useless output on the terminal.
155 %
156 \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
157 \ifx\eTeXversion\undefined
158 \def\loggingall{\tracingcommands2 \tracingstats2
159    \tracingpages1 \tracingoutput1 \tracinglostchars1
160    \tracingmacros2 \tracingparagraphs1 \tracingrestores1
161    \showboxbreadth\maxdimen\showboxdepth\maxdimen
162 }%
163 \else
164 \def\loggingall{\tracingcommands3 \tracingstats2
165    \tracingpages1 \tracingoutput1 \tracinglostchars1
166    \tracingmacros2 \tracingparagraphs1 \tracingrestores1
167    \tracingscantokens1 \tracingassigns1 \tracingifs1
168    \tracinggroups1 \tracingnesting2
169    \showboxbreadth\maxdimen\showboxdepth\maxdimen
170 }%
171 \fi
172
173 % For @cropmarks command.
174 % Do @cropmarks to get crop marks.
175 %
176 \newif\ifcropmarks
177 \let\cropmarks = \cropmarkstrue
178 %
179 % Dimensions to add cropmarks at corners.
180 % Added by P. A. MacKay, 12 Nov. 1986
181 %
182 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
183 \newdimen\cornerlong  \cornerlong=1pc
184 \newdimen\cornerthick \cornerthick=.3pt
185 \newdimen\topandbottommargin \topandbottommargin=.75in
186
187 % Main output routine.
188 \chardef\PAGE = 255
189 \output = {\onepageout{\pagecontents\PAGE}}
190
191 \newbox\headlinebox
192 \newbox\footlinebox
193
194 % \onepageout takes a vbox as an argument.  Note that \pagecontents
195 % does insertions, but you have to call it yourself.
196 \def\onepageout#1{%
197   \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
198   %
199   \ifodd\pageno  \advance\hoffset by \bindingoffset
200   \else \advance\hoffset by -\bindingoffset\fi
201   %
202   % Do this outside of the \shipout so @code etc. will be expanded in
203   % the headline as they should be, not taken literally (outputting ''code).
204   \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
205   \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
206   %
207   {%
208     % Have to do this stuff outside the \shipout because we want it to
209     % take effect in \write's, yet the group defined by the \vbox ends
210     % before the \shipout runs.
211     %
212     \escapechar = `\\     % use backslash in output files.
213     \indexdummies         % don't expand commands in the output.
214     \normalturnoffactive  % \ in index entries must not stay \, e.g., if
215                    % the page break happens to be in the middle of an example.
216     \shipout\vbox{%
217       \ifcropmarks \vbox to \outervsize\bgroup
218         \hsize = \outerhsize
219         \vskip-\topandbottommargin
220         \vtop to0pt{%
221           \line{\ewtop\hfil\ewtop}%
222           \nointerlineskip
223           \line{%
224             \vbox{\moveleft\cornerthick\nstop}%
225             \hfill
226             \vbox{\moveright\cornerthick\nstop}%
227           }%
228           \vss}%
229         \vskip\topandbottommargin
230         \line\bgroup
231           \hfil % center the page within the outer (page) hsize.
232           \ifodd\pageno\hskip\bindingoffset\fi
233           \vbox\bgroup
234       \fi
235       %
236       \unvbox\headlinebox
237       \pagebody{#1}%
238       \ifdim\ht\footlinebox > 0pt
239         % Only leave this space if the footline is nonempty.
240         % (We lessened \vsize for it in \oddfootingxxx.)
241         % The \baselineskip=24pt in plain's \makefootline has no effect.
242         \vskip 2\baselineskip
243         \unvbox\footlinebox
244       \fi
245       %
246       \ifpdfmakepagedest \pdfmkdest{\the\pageno} \fi
247       %
248       \ifcropmarks
249           \egroup % end of \vbox\bgroup
250         \hfil\egroup % end of (centering) \line\bgroup
251         \vskip\topandbottommargin plus1fill minus1fill
252         \boxmaxdepth = \cornerthick
253         \vbox to0pt{\vss
254           \line{%
255             \vbox{\moveleft\cornerthick\nsbot}%
256             \hfill
257             \vbox{\moveright\cornerthick\nsbot}%
258           }%
259           \nointerlineskip
260           \line{\ewbot\hfil\ewbot}%
261         }%
262       \egroup % \vbox from first cropmarks clause
263       \fi
264     }% end of \shipout\vbox
265   }% end of group with \turnoffactive
266   \advancepageno
267   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
268 }
269
270 \newinsert\margin \dimen\margin=\maxdimen
271
272 \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
273 {\catcode`\@ =11
274 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
275 % marginal hacks, juha@viisa.uucp (Juha Takala)
276 \ifvoid\margin\else % marginal info is present
277   \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
278 \dimen@=\dp#1 \unvbox#1
279 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
280 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
281 }
282
283 % Here are the rules for the cropmarks.  Note that they are
284 % offset so that the space between them is truly \outerhsize or \outervsize
285 % (P. A. MacKay, 12 November, 1986)
286 %
287 \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
288 \def\nstop{\vbox
289   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
290 \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
291 \def\nsbot{\vbox
292   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
293
294 % Parse an argument, then pass it to #1.  The argument is the rest of
295 % the input line (except we remove a trailing comment).  #1 should be a
296 % macro which expects an ordinary undelimited TeX argument.
297 %
298 \def\parsearg#1{%
299   \let\next = #1%
300   \begingroup
301     \obeylines
302     \futurelet\temp\parseargx
303 }
304
305 % If the next token is an obeyed space (from an @example environment or
306 % the like), remove it and recurse.  Otherwise, we're done.
307 \def\parseargx{%
308   % \obeyedspace is defined far below, after the definition of \sepspaces.
309   \ifx\obeyedspace\temp
310     \expandafter\parseargdiscardspace
311   \else
312     \expandafter\parseargline
313   \fi
314 }
315
316 % Remove a single space (as the delimiter token to the macro call).
317 {\obeyspaces %
318  \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
319
320 {\obeylines %
321   \gdef\parseargline#1^^M{%
322     \endgroup % End of the group started in \parsearg.
323     %
324     % First remove any @c comment, then any @comment.
325     % Result of each macro is put in \toks0.
326     \argremovec #1\c\relax %
327     \expandafter\argremovecomment \the\toks0 \comment\relax %
328     %
329     % Call the caller's macro, saved as \next in \parsearg.
330     \expandafter\next\expandafter{\the\toks0}%
331   }%
332 }
333
334 % Since all \c{,omment} does is throw away the argument, we can let TeX
335 % do that for us.  The \relax here is matched by the \relax in the call
336 % in \parseargline; it could be more or less anything, its purpose is
337 % just to delimit the argument to the \c.
338 \def\argremovec#1\c#2\relax{\toks0 = {#1}}
339 \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
340
341 % \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
342 %    @end itemize  @c foo
343 % will have two active spaces as part of the argument with the
344 % `itemize'.  Here we remove all active spaces from #1, and assign the
345 % result to \toks0.
346 %
347 % This loses if there are any *other* active characters besides spaces
348 % in the argument -- _ ^ +, for example -- since they get expanded.
349 % Fortunately, Texinfo does not define any such commands.  (If it ever
350 % does, the catcode of the characters in questionwill have to be changed
351 % here.)  But this means we cannot call \removeactivespaces as part of
352 % \argremovec{,omment}, since @c uses \parsearg, and thus the argument
353 % that \parsearg gets might well have any character at all in it.
354 %
355 \def\removeactivespaces#1{%
356   \begingroup
357     \ignoreactivespaces
358     \edef\temp{#1}%
359     \global\toks0 = \expandafter{\temp}%
360   \endgroup
361 }
362
363 % Change the active space to expand to nothing.
364 %
365 \begingroup
366   \obeyspaces
367   \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
368 \endgroup
369
370
371 \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
372
373 %% These are used to keep @begin/@end levels from running away
374 %% Call \inENV within environments (after a \begingroup)
375 \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
376 \def\ENVcheck{%
377 \ifENV\errmessage{Still within an environment; press RETURN to continue}
378 \endgroup\fi} % This is not perfect, but it should reduce lossage
379
380 % @begin foo  is the same as @foo, for now.
381 \newhelp\EMsimple{Press RETURN to continue.}
382
383 \outer\def\begin{\parsearg\beginxxx}
384
385 \def\beginxxx #1{%
386 \expandafter\ifx\csname #1\endcsname\relax
387 {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
388 \csname #1\endcsname\fi}
389
390 % @end foo executes the definition of \Efoo.
391 %
392 \def\end{\parsearg\endxxx}
393 \def\endxxx #1{%
394   \removeactivespaces{#1}%
395   \edef\endthing{\the\toks0}%
396   %
397   \expandafter\ifx\csname E\endthing\endcsname\relax
398     \expandafter\ifx\csname \endthing\endcsname\relax
399       % There's no \foo, i.e., no ``environment'' foo.
400       \errhelp = \EMsimple
401       \errmessage{Undefined command `@end \endthing'}%
402     \else
403       \unmatchedenderror\endthing
404     \fi
405   \else
406     % Everything's ok; the right environment has been started.
407     \csname E\endthing\endcsname
408   \fi
409 }
410
411 % There is an environment #1, but it hasn't been started.  Give an error.
412 %
413 \def\unmatchedenderror#1{%
414   \errhelp = \EMsimple
415   \errmessage{This `@end #1' doesn't have a matching `@#1'}%
416 }
417
418 % Define the control sequence \E#1 to give an unmatched @end error.
419 %
420 \def\defineunmatchedend#1{%
421   \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
422 }
423
424
425 % Single-spacing is done by various environments (specifically, in
426 % \nonfillstart and \quotations).
427 \newskip\singlespaceskip \singlespaceskip = 12.5pt
428 \def\singlespace{%
429   % Why was this kern here?  It messes up equalizing space above and below
430   % environments.  --karl, 6may93
431   %{\advance \baselineskip by -\singlespaceskip
432   %\kern \baselineskip}%
433   \setleading \singlespaceskip
434 }
435
436 %% Simple single-character @ commands
437
438 % @@ prints an @
439 % Kludge this until the fonts are right (grr).
440 \def\@{{\tt\char64}}
441
442 % This is turned off because it was never documented
443 % and you can use @w{...} around a quote to suppress ligatures.
444 %% Define @` and @' to be the same as ` and '
445 %% but suppressing ligatures.
446 %\def\`{{`}}
447 %\def\'{{'}}
448
449 % Used to generate quoted braces.
450 \def\mylbrace {{\tt\char123}}
451 \def\myrbrace {{\tt\char125}}
452 \let\{=\mylbrace
453 \let\}=\myrbrace
454 \begingroup
455   % Definitions to produce actual \{ & \} command in an index.
456   \catcode`\{ = 12 \catcode`\} = 12
457   \catcode`\[ = 1 \catcode`\] = 2
458   \catcode`\@ = 0 \catcode`\\ = 12
459   @gdef@lbracecmd[\{]%
460   @gdef@rbracecmd[\}]%
461 @endgroup
462
463 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
464 % Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H.
465 \let\, = \c
466 \let\dotaccent = \.
467 \def\ringaccent#1{{\accent23 #1}}
468 \let\tieaccent = \t
469 \let\ubaraccent = \b
470 \let\udotaccent = \d
471
472 % Other special characters: @questiondown @exclamdown
473 % Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss.
474 \def\questiondown{?`}
475 \def\exclamdown{!`}
476
477 % Dotless i and dotless j, used for accents.
478 \def\imacro{i}
479 \def\jmacro{j}
480 \def\dotless#1{%
481   \def\temp{#1}%
482   \ifx\temp\imacro \ptexi
483   \else\ifx\temp\jmacro \j
484   \else \errmessage{@dotless can be used only with i or j}%
485   \fi\fi
486 }
487
488 % Be sure we're in horizontal mode when doing a tie, since we make space
489 % equivalent to this in @example-like environments. Otherwise, a space
490 % at the beginning of a line will start with \penalty -- and
491 % since \penalty is valid in vertical mode, we'd end up putting the
492 % penalty on the vertical list instead of in the new paragraph.
493 {\catcode`@ = 11
494  % Avoid using \@M directly, because that causes trouble
495  % if the definition is written into an index file.
496  \global\let\tiepenalty = \@M
497  \gdef\tie{\leavevmode\penalty\tiepenalty\ }
498 }
499
500 % @: forces normal size whitespace following.
501 \def\:{\spacefactor=1000 }
502
503 % @* forces a line break.
504 \def\*{\hfil\break\hbox{}\ignorespaces}
505
506 % @. is an end-of-sentence period.
507 \def\.{.\spacefactor=3000 }
508
509 % @! is an end-of-sentence bang.
510 \def\!{!\spacefactor=3000 }
511
512 % @? is an end-of-sentence query.
513 \def\?{?\spacefactor=3000 }
514
515 % @w prevents a word break.  Without the \leavevmode, @w at the
516 % beginning of a paragraph, when TeX is still in vertical mode, would
517 % produce a whole line of output instead of starting the paragraph.
518 \def\w#1{\leavevmode\hbox{#1}}
519
520 % @group ... @end group forces ... to be all on one page, by enclosing
521 % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
522 % to keep its height that of a normal line.  According to the rules for
523 % \topskip (p.114 of the TeXbook), the glue inserted is
524 % max (\topskip - \ht (first item), 0).  If that height is large,
525 % therefore, no glue is inserted, and the space between the headline and
526 % the text is small, which looks bad.
527 %
528 \def\group{\begingroup
529   \ifnum\catcode13=\active \else
530     \errhelp = \groupinvalidhelp
531     \errmessage{@group invalid in context where filling is enabled}%
532   \fi
533   %
534   % The \vtop we start below produces a box with normal height and large
535   % depth; thus, TeX puts \baselineskip glue before it, and (when the
536   % next line of text is done) \lineskip glue after it.  (See p.82 of
537   % the TeXbook.)  Thus, space below is not quite equal to space
538   % above.  But it's pretty close.
539   \def\Egroup{%
540     \egroup           % End the \vtop.
541     \endgroup         % End the \group.
542   }%
543   %
544   \vtop\bgroup
545     % We have to put a strut on the last line in case the @group is in
546     % the midst of an example, rather than completely enclosing it.
547     % Otherwise, the interline space between the last line of the group
548     % and the first line afterwards is too small.  But we can't put the
549     % strut in \Egroup, since there it would be on a line by itself.
550     % Hence this just inserts a strut at the beginning of each line.
551     \everypar = {\strut}%
552     %
553     % Since we have a strut on every line, we don't need any of TeX's
554     % normal interline spacing.
555     \offinterlineskip
556     %
557     % OK, but now we have to do something about blank
558     % lines in the input in @example-like environments, which normally
559     % just turn into \lisppar, which will insert no space now that we've
560     % turned off the interline space.  Simplest is to make them be an
561     % empty paragraph.
562     \ifx\par\lisppar
563       \edef\par{\leavevmode \par}%
564       %
565       % Reset ^^M's definition to new definition of \par.
566       \obeylines
567     \fi
568     %
569     % Do @comment since we are called inside an environment such as
570     % @example, where each end-of-line in the input causes an
571     % end-of-line in the output.  We don't want the end-of-line after
572     % the `@group' to put extra space in the output.  Since @group
573     % should appear on a line by itself (according to the Texinfo
574     % manual), we don't worry about eating any user text.
575     \comment
576 }
577 %
578 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
579 % message, so this ends up printing `@group can only ...'.
580 %
581 \newhelp\groupinvalidhelp{%
582 group can only be used in environments such as @example,^^J%
583 where each line of input produces a line of output.}
584
585 % @need space-in-mils
586 % forces a page break if there is not space-in-mils remaining.
587
588 \newdimen\mil  \mil=0.001in
589
590 \def\need{\parsearg\needx}
591
592 % Old definition--didn't work.
593 %\def\needx #1{\par %
594 %% This method tries to make TeX break the page naturally
595 %% if the depth of the box does not fit.
596 %{\baselineskip=0pt%
597 %\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak
598 %\prevdepth=-1000pt
599 %}}
600
601 \def\needx#1{%
602   % Ensure vertical mode, so we don't make a big box in the middle of a
603   % paragraph.
604   \par
605   %
606   % If the @need value is less than one line space, it's useless.
607   \dimen0 = #1\mil
608   \dimen2 = \ht\strutbox
609   \advance\dimen2 by \dp\strutbox
610   \ifdim\dimen0 > \dimen2
611     %
612     % Do a \strut just to make the height of this box be normal, so the
613     % normal leading is inserted relative to the preceding line.
614     % And a page break here is fine.
615     \vtop to #1\mil{\strut\vfil}%
616     %
617     % TeX does not even consider page breaks if a penalty added to the
618     % main vertical list is 10000 or more.  But in order to see if the
619     % empty box we just added fits on the page, we must make it consider
620     % page breaks.  On the other hand, we don't want to actually break the
621     % page after the empty box.  So we use a penalty of 9999.
622     %
623     % There is an extremely small chance that TeX will actually break the
624     % page at this \penalty, if there are no other feasible breakpoints in
625     % sight.  (If the user is using lots of big @group commands, which
626     % almost-but-not-quite fill up a page, TeX will have a hard time doing
627     % good page breaking, for example.)  However, I could not construct an
628     % example where a page broke at this \penalty; if it happens in a real
629     % document, then we can reconsider our strategy.
630     \penalty9999
631     %
632     % Back up by the size of the box, whether we did a page break or not.
633     \kern -#1\mil
634     %
635     % Do not allow a page break right after this kern.
636     \nobreak
637   \fi
638 }
639
640 % @br   forces paragraph break
641
642 \let\br = \par
643
644 % @dots{} output an ellipsis using the current font.
645 % We do .5em per period so that it has the same spacing in a typewriter
646 % font as three actual period characters.
647 %
648 \def\dots{%
649   \leavevmode
650   \hbox to 1.5em{%
651     \hskip 0pt plus 0.25fil minus 0.25fil
652     .\hss.\hss.%
653     \hskip 0pt plus 0.5fil minus 0.5fil
654   }%
655 }
656
657 % @enddots{} is an end-of-sentence ellipsis.
658 %
659 \def\enddots{%
660   \leavevmode
661   \hbox to 2em{%
662     \hskip 0pt plus 0.25fil minus 0.25fil
663     .\hss.\hss.\hss.%
664     \hskip 0pt plus 0.5fil minus 0.5fil
665   }%
666   \spacefactor=3000
667 }
668
669
670 % @page    forces the start of a new page
671 %
672 \def\page{\par\vfill\supereject}
673
674 % @exdent text....
675 % outputs text on separate line in roman font, starting at standard page margin
676
677 % This records the amount of indent in the innermost environment.
678 % That's how much \exdent should take out.
679 \newskip\exdentamount
680
681 % This defn is used inside fill environments such as @defun.
682 \def\exdent{\parsearg\exdentyyy}
683 \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
684
685 % This defn is used inside nofill environments such as @example.
686 \def\nofillexdent{\parsearg\nofillexdentyyy}
687 \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
688 \leftline{\hskip\leftskip{\rm#1}}}}
689
690 % @inmargin{TEXT} puts TEXT in the margin next to the current paragraph.
691
692 \def\inmargin#1{%
693 \strut\vadjust{\nobreak\kern-\strutdepth
694   \vtop to \strutdepth{\baselineskip\strutdepth\vss
695   \llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}}
696 \newskip\inmarginspacing \inmarginspacing=1cm
697 \def\strutdepth{\dp\strutbox}
698
699 %\hbox{{\rm#1}}\hfil\break}}
700
701 % @include file    insert text of that file as input.
702 % Allow normal characters that  we make active in the argument (a file name).
703 \def\include{\begingroup
704   \catcode`\\=12
705   \catcode`~=12
706   \catcode`^=12
707   \catcode`_=12
708   \catcode`|=12
709   \catcode`<=12
710   \catcode`>=12
711   \catcode`+=12
712   \parsearg\includezzz}
713 % Restore active chars for included file.
714 \def\includezzz#1{\endgroup\begingroup
715   % Read the included file in a group so nested @include's work.
716   \def\thisfile{#1}%
717   \input\thisfile
718 \endgroup}
719
720 \def\thisfile{}
721
722 % @center line   outputs that line, centered
723
724 \def\center{\parsearg\centerzzz}
725 \def\centerzzz #1{{\advance\hsize by -\leftskip
726 \advance\hsize by -\rightskip
727 \centerline{#1}}}
728
729 % @sp n   outputs n lines of vertical space
730
731 \def\sp{\parsearg\spxxx}
732 \def\spxxx #1{\vskip #1\baselineskip}
733
734 % @comment ...line which is ignored...
735 % @c is the same as @comment
736 % @ignore ... @end ignore  is another way to write a comment
737
738 \def\comment{\begingroup \catcode`\^^M=\other%
739 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
740 \commentxxx}
741 {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
742
743 \let\c=\comment
744
745 % @paragraphindent NCHARS
746 % We'll use ems for NCHARS, close enough.
747 % We cannot implement @paragraphindent asis, though.
748
749 \def\asisword{asis} % no translation, these are keywords
750 \def\noneword{none}
751 %
752 \def\paragraphindent{\parsearg\doparagraphindent}
753 \def\doparagraphindent#1{%
754   \def\temp{#1}%
755   \ifx\temp\asisword
756   \else
757     \ifx\temp\noneword
758       \defaultparindent = 0pt
759     \else
760       \defaultparindent = #1em
761     \fi
762   \fi
763   \parindent = \defaultparindent
764 }
765
766 % @exampleindent NCHARS
767 % We'll use ems for NCHARS like @paragraphindent.
768 % It seems @exampleindent asis isn't necessary, but
769 % I preserve it to make it similar to @paragraphindent.
770 \def\exampleindent{\parsearg\doexampleindent}
771 \def\doexampleindent#1{%
772   \def\temp{#1}%
773   \ifx\temp\asisword
774   \else
775     \ifx\temp\noneword
776       \lispnarrowing = 0pt
777     \else
778       \lispnarrowing = #1em
779     \fi
780   \fi
781 }
782
783 % @asis just yields its argument.  Used with @table, for example.
784 %
785 \def\asis#1{#1}
786
787 % @math means output in math mode.
788 % We don't use $'s directly in the definition of \math because control
789 % sequences like \math are expanded when the toc file is written.  Then,
790 % we read the toc file back, the $'s will be normal characters (as they
791 % should be, according to the definition of Texinfo).  So we must use a
792 % control sequence to switch into and out of math mode.
793 %
794 % This isn't quite enough for @math to work properly in indices, but it
795 % seems unlikely it will ever be needed there.
796 %
797 \let\implicitmath = $
798 \def\math#1{\implicitmath #1\implicitmath}
799
800 % @bullet and @minus need the same treatment as @math, just above.
801 \def\bullet{\implicitmath\ptexbullet\implicitmath}
802 \def\minus{\implicitmath-\implicitmath}
803
804 % @refill is a no-op.
805 \let\refill=\relax
806
807 % If working on a large document in chapters, it is convenient to
808 % be able to disable indexing, cross-referencing, and contents, for test runs.
809 % This is done with @novalidate (before @setfilename).
810 %
811 \newif\iflinks \linkstrue % by default we want the aux files.
812 \let\novalidate = \linksfalse
813
814 % @setfilename is done at the beginning of every texinfo file.
815 % So open here the files we need to have open while reading the input.
816 % This makes it possible to make a .fmt file for texinfo.
817 \def\setfilename{%
818    \iflinks
819      \readauxfile
820    \fi % \openindices needs to do some work in any case.
821    \openindices
822    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
823    \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
824    %
825    % If texinfo.cnf is present on the system, read it.
826    % Useful for site-wide @afourpaper, etc.
827    % Just to be on the safe side, close the input stream before the \input.
828    \openin 1 texinfo.cnf
829    \ifeof1 \let\temp=\relax \else \def\temp{\input texinfo.cnf }\fi
830    \closein1
831    \temp
832    %
833    \comment % Ignore the actual filename.
834 }
835
836 % Called from \setfilename.
837 %
838 \def\openindices{%
839   \newindex{cp}%
840   \newcodeindex{fn}%
841   \newcodeindex{vr}%
842   \newcodeindex{tp}%
843   \newcodeindex{ky}%
844   \newcodeindex{pg}%
845 }
846
847 % @bye.
848 \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
849
850
851 \message{pdf,}
852 % adobe `portable' document format
853 \newcount\tempnum
854 \newcount\lnkcount
855 \newtoks\filename
856 \newcount\filenamelength
857 \newcount\pgn
858 \newtoks\toksA
859 \newtoks\toksB
860 \newtoks\toksC
861 \newtoks\toksD
862 \newbox\boxA
863 \newcount\countA
864 \newif\ifpdf
865 \newif\ifpdfmakepagedest
866
867 \ifx\pdfoutput\undefined
868   \pdffalse
869   \let\pdfmkdest = \gobble
870   \let\pdfurl = \gobble
871   \let\endlink = \relax
872   \let\linkcolor = \relax
873   \let\pdfmakeoutlines = \relax
874 \else
875   \pdftrue
876   \pdfoutput = 1
877   \input pdfcolor
878   \def\dopdfimage#1#2#3{%
879     \def\imagewidth{#2}%
880     \def\imageheight{#3}%
881     \ifnum\pdftexversion < 14
882       \pdfimage
883     \else
884       \pdfximage
885     \fi
886       \ifx\empty\imagewidth\else width \imagewidth \fi
887       \ifx\empty\imageheight\else height \imageheight \fi
888       {#1.pdf}%
889     \ifnum\pdftexversion < 14 \else
890       \pdfrefximage \pdflastximage
891     \fi}
892   \def\pdfmkdest#1{\pdfdest name{#1@} xyz}
893   \def\pdfmkpgn#1{#1@}
894   \let\linkcolor = \Cyan
895   \def\endlink{\Black\pdfendlink}
896   % Adding outlines to PDF; macros for calculating structure of outlines
897   % come from Petr Olsak
898   \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
899     \else \csname#1\endcsname \fi}
900   \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
901     \advance\tempnum by1
902     \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
903   \def\pdfmakeoutlines{{%
904     \openin 1 \jobname.toc
905     \ifeof 1\else\bgroup
906       \closein 1 
907       \indexnofonts
908       \def\tt{}
909       % thanh's hack / proper braces in bookmarks  
910       \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace
911       \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace
912       %
913       \def\chapentry ##1##2##3{}
914       \def\unnumbchapentry ##1##2{}
915       \def\secentry ##1##2##3##4{\advancenumber{chap##2}}
916       \def\unnumbsecentry ##1##2{}
917       \def\subsecentry ##1##2##3##4##5{\advancenumber{sec##2.##3}}
918       \def\unnumbsubsecentry ##1##2{}
919       \def\subsubsecentry ##1##2##3##4##5##6{\advancenumber{subsec##2.##3.##4}}
920       \def\unnumbsubsubsecentry ##1##2{}
921       \input \jobname.toc
922       \def\chapentry ##1##2##3{%
923         \pdfoutline goto name{\pdfmkpgn{##3}}count-\expnumber{chap##2}{##1}}
924       \def\unnumbchapentry ##1##2{%
925         \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
926       \def\secentry ##1##2##3##4{%
927         \pdfoutline goto name{\pdfmkpgn{##4}}count-\expnumber{sec##2.##3}{##1}}
928       \def\unnumbsecentry ##1##2{%
929         \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
930       \def\subsecentry ##1##2##3##4##5{%
931         \pdfoutline goto name{\pdfmkpgn{##5}}count-\expnumber{subsec##2.##3.##4}{##1}}
932       \def\unnumbsubsecentry ##1##2{%
933         \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
934       \def\subsubsecentry ##1##2##3##4##5##6{%
935         \pdfoutline goto name{\pdfmkpgn{##6}}{##1}}
936       \def\unnumbsubsubsecentry ##1##2{%
937         \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
938       \input \jobname.toc
939     \egroup\fi
940   }}
941   \def\makelinks #1,{%
942     \def\params{#1}\def\E{END}%
943     \ifx\params\E
944       \let\nextmakelinks=\relax
945     \else
946       \let\nextmakelinks=\makelinks
947       \ifnum\lnkcount>0,\fi
948       \picknum{#1}%
949       \startlink attr{/Border [0 0 0]} 
950         goto name{\pdfmkpgn{\the\pgn}}%
951       \linkcolor #1%
952       \advance\lnkcount by 1%
953       \endlink
954     \fi
955     \nextmakelinks
956   }
957   \def\picknum#1{\expandafter\pn#1}
958   \def\pn#1{%
959     \def\p{#1}%
960     \ifx\p\lbrace
961       \let\nextpn=\ppn
962     \else
963       \let\nextpn=\ppnn
964       \def\first{#1}
965     \fi
966     \nextpn
967   }
968   \def\ppn#1{\pgn=#1\gobble}
969   \def\ppnn{\pgn=\first}
970   \def\pdfmklnk#1{\lnkcount=0\makelinks #1,END,}
971   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
972   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
973     \ifx\PP\D\let\nextsp\relax
974     \else\let\nextsp\skipspaces
975       \ifx\p\space\else\addtokens{\filename}{\PP}%
976         \advance\filenamelength by 1
977       \fi
978     \fi
979     \nextsp}
980   \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax}
981   \ifnum\pdftexversion < 14
982     \let \startlink \pdfannotlink
983   \else
984     \let \startlink \pdfstartlink
985   \fi
986   \def\pdfurl#1{%
987     \begingroup
988       \normalturnoffactive\def\@{@}%
989       \leavevmode\Red
990       \startlink attr{/Border [0 0 0]}%
991         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
992         % #1
993     \endgroup}
994   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
995   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
996   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
997   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
998   \def\maketoks{%
999     \expandafter\poptoks\the\toksA|ENDTOKS|
1000     \ifx\first0\adn0
1001     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1002     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1003     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 
1004     \else
1005       \ifnum0=\countA\else\makelink\fi
1006       \ifx\first.\let\next=\done\else
1007         \let\next=\maketoks
1008         \addtokens{\toksB}{\the\toksD}
1009         \ifx\first,\addtokens{\toksB}{\space}\fi
1010       \fi
1011     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1012     \next}
1013   \def\makelink{\addtokens{\toksB}%
1014     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1015   \def\pdflink#1{%
1016     \startlink attr{/Border [0 0 0]} goto name{\mkpgn{#1}}
1017     \linkcolor #1\endlink}
1018   \def\mkpgn#1{#1@} 
1019   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1020 \fi % \ifx\pdfoutput
1021
1022
1023 \message{fonts,}
1024 % Font-change commands.
1025
1026 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
1027 % So we set up a \sf analogous to plain's \rm, etc.
1028 \newfam\sffam
1029 \def\sf{\fam=\sffam \tensf}
1030 \let\li = \sf % Sometimes we call it \li, not \sf.
1031
1032 % We don't need math for this one.
1033 \def\ttsl{\tenttsl}
1034
1035 % Use Computer Modern fonts at \magstephalf (11pt).
1036 \newcount\mainmagstep
1037 \mainmagstep=\magstephalf
1038
1039 % Set the font macro #1 to the font named #2, adding on the
1040 % specified font prefix (normally `cm').
1041 % #3 is the font's design size, #4 is a scale factor
1042 \def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4}
1043
1044 % Use cm as the default font prefix.
1045 % To specify the font prefix, you must define \fontprefix
1046 % before you read in texinfo.tex.
1047 \ifx\fontprefix\undefined
1048 \def\fontprefix{cm}
1049 \fi
1050 % Support font families that don't use the same naming scheme as CM.
1051 \def\rmshape{r}
1052 \def\rmbshape{bx}               %where the normal face is bold
1053 \def\bfshape{b}
1054 \def\bxshape{bx}
1055 \def\ttshape{tt}
1056 \def\ttbshape{tt}
1057 \def\ttslshape{sltt}
1058 \def\itshape{ti}
1059 \def\itbshape{bxti}
1060 \def\slshape{sl}
1061 \def\slbshape{bxsl}
1062 \def\sfshape{ss}
1063 \def\sfbshape{ss}
1064 \def\scshape{csc}
1065 \def\scbshape{csc}
1066
1067 \ifx\bigger\relax
1068 \let\mainmagstep=\magstep1
1069 \setfont\textrm\rmshape{12}{1000}
1070 \setfont\texttt\ttshape{12}{1000}
1071 \else
1072 \setfont\textrm\rmshape{10}{\mainmagstep}
1073 \setfont\texttt\ttshape{10}{\mainmagstep}
1074 \fi
1075 % Instead of cmb10, you many want to use cmbx10.
1076 % cmbx10 is a prettier font on its own, but cmb10
1077 % looks better when embedded in a line with cmr10.
1078 \setfont\textbf\bfshape{10}{\mainmagstep}
1079 \setfont\textit\itshape{10}{\mainmagstep}
1080 \setfont\textsl\slshape{10}{\mainmagstep}
1081 \setfont\textsf\sfshape{10}{\mainmagstep}
1082 \setfont\textsc\scshape{10}{\mainmagstep}
1083 \setfont\textttsl\ttslshape{10}{\mainmagstep}
1084 \font\texti=cmmi10 scaled \mainmagstep
1085 \font\textsy=cmsy10 scaled \mainmagstep
1086
1087 % A few fonts for @defun, etc.
1088 \setfont\defbf\bxshape{10}{\magstep1} %was 1314
1089 \setfont\deftt\ttshape{10}{\magstep1}
1090 \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
1091
1092 % Fonts for indices, footnotes, small examples (9pt).
1093 \setfont\smallrm\rmshape{9}{1000}
1094 \setfont\smalltt\ttshape{9}{1000}
1095 \setfont\smallbf\bfshape{10}{900}
1096 \setfont\smallit\itshape{9}{1000}
1097 \setfont\smallsl\slshape{9}{1000}
1098 \setfont\smallsf\sfshape{9}{1000}
1099 \setfont\smallsc\scshape{10}{900}
1100 \setfont\smallttsl\ttslshape{10}{900}
1101 \font\smalli=cmmi9
1102 \font\smallsy=cmsy9
1103
1104 % Fonts for title page:
1105 \setfont\titlerm\rmbshape{12}{\magstep3}
1106 \setfont\titleit\itbshape{10}{\magstep4}
1107 \setfont\titlesl\slbshape{10}{\magstep4}
1108 \setfont\titlett\ttbshape{12}{\magstep3}
1109 \setfont\titlettsl\ttslshape{10}{\magstep4}
1110 \setfont\titlesf\sfbshape{17}{\magstep1}
1111 \let\titlebf=\titlerm
1112 \setfont\titlesc\scbshape{10}{\magstep4}
1113 \font\titlei=cmmi12 scaled \magstep3
1114 \font\titlesy=cmsy10 scaled \magstep4
1115 \def\authorrm{\secrm}
1116
1117 % Chapter (and unnumbered) fonts (17.28pt).
1118 \setfont\chaprm\rmbshape{12}{\magstep2}
1119 \setfont\chapit\itbshape{10}{\magstep3}
1120 \setfont\chapsl\slbshape{10}{\magstep3}
1121 \setfont\chaptt\ttbshape{12}{\magstep2}
1122 \setfont\chapttsl\ttslshape{10}{\magstep3}
1123 \setfont\chapsf\sfbshape{17}{1000}
1124 \let\chapbf=\chaprm
1125 \setfont\chapsc\scbshape{10}{\magstep3}
1126 \font\chapi=cmmi12 scaled \magstep2
1127 \font\chapsy=cmsy10 scaled \magstep3
1128
1129 % Section fonts (14.4pt).
1130 \setfont\secrm\rmbshape{12}{\magstep1}
1131 \setfont\secit\itbshape{10}{\magstep2}
1132 \setfont\secsl\slbshape{10}{\magstep2}
1133 \setfont\sectt\ttbshape{12}{\magstep1}
1134 \setfont\secttsl\ttslshape{10}{\magstep2}
1135 \setfont\secsf\sfbshape{12}{\magstep1}
1136 \let\secbf\secrm
1137 \setfont\secsc\scbshape{10}{\magstep2}
1138 \font\seci=cmmi12 scaled \magstep1
1139 \font\secsy=cmsy10 scaled \magstep2
1140
1141 % \setfont\ssecrm\bxshape{10}{\magstep1}    % This size an font looked bad.
1142 % \setfont\ssecit\itshape{10}{\magstep1}    % The letters were too crowded.
1143 % \setfont\ssecsl\slshape{10}{\magstep1}
1144 % \setfont\ssectt\ttshape{10}{\magstep1}
1145 % \setfont\ssecsf\sfshape{10}{\magstep1}
1146
1147 %\setfont\ssecrm\bfshape{10}{1315}      % Note the use of cmb rather than cmbx.
1148 %\setfont\ssecit\itshape{10}{1315}      % Also, the size is a little larger than
1149 %\setfont\ssecsl\slshape{10}{1315}      % being scaled magstep1.
1150 %\setfont\ssectt\ttshape{10}{1315}
1151 %\setfont\ssecsf\sfshape{10}{1315}
1152
1153 %\let\ssecbf=\ssecrm
1154
1155 % Subsection fonts (13.15pt).
1156 \setfont\ssecrm\rmbshape{12}{\magstephalf}
1157 \setfont\ssecit\itbshape{10}{1315}
1158 \setfont\ssecsl\slbshape{10}{1315}
1159 \setfont\ssectt\ttbshape{12}{\magstephalf}
1160 \setfont\ssecttsl\ttslshape{10}{1315}
1161 \setfont\ssecsf\sfbshape{12}{\magstephalf}
1162 \let\ssecbf\ssecrm
1163 \setfont\ssecsc\scbshape{10}{\magstep1}
1164 \font\sseci=cmmi12 scaled \magstephalf
1165 \font\ssecsy=cmsy10 scaled 1315
1166 % The smallcaps and symbol fonts should actually be scaled \magstep1.5,
1167 % but that is not a standard magnification.
1168
1169 % In order for the font changes to affect most math symbols and letters,
1170 % we have to define the \textfont of the standard families.  Since
1171 % texinfo doesn't allow for producing subscripts and superscripts, we
1172 % don't bother to reset \scriptfont and \scriptscriptfont (which would
1173 % also require loading a lot more fonts).
1174 %
1175 \def\resetmathfonts{%
1176   \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
1177   \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
1178   \textfont\ttfam = \tentt \textfont\sffam = \tensf
1179 }
1180
1181
1182 % The font-changing commands redefine the meanings of \tenSTYLE, instead
1183 % of just \STYLE.  We do this so that font changes will continue to work
1184 % in math mode, where it is the current \fam that is relevant in most
1185 % cases, not the current font.  Plain TeX does \def\bf{\fam=\bffam
1186 % \tenbf}, for example.  By redefining \tenbf, we obviate the need to
1187 % redefine \bf itself.
1188 \def\textfonts{%
1189   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
1190   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
1191   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl
1192   \resetmathfonts}
1193 \def\titlefonts{%
1194   \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
1195   \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
1196   \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
1197   \let\tenttsl=\titlettsl
1198   \resetmathfonts \setleading{25pt}}
1199 \def\titlefont#1{{\titlefonts\rm #1}}
1200 \def\chapfonts{%
1201   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
1202   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
1203   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl
1204   \resetmathfonts \setleading{19pt}}
1205 \def\secfonts{%
1206   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
1207   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
1208   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl
1209   \resetmathfonts \setleading{16pt}}
1210 \def\subsecfonts{%
1211   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
1212   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
1213   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl
1214   \resetmathfonts \setleading{15pt}}
1215 \let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf?
1216 \def\smallfonts{%
1217   \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
1218   \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
1219   \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
1220   \let\tenttsl=\smallttsl
1221   \resetmathfonts \setleading{11pt}}
1222
1223 % Set up the default fonts, so we can use them for creating boxes.
1224 %
1225 \textfonts
1226
1227 % Define these so they can be easily changed for other fonts.
1228 \def\angleleft{$\langle$}
1229 \def\angleright{$\rangle$}
1230
1231 % Count depth in font-changes, for error checks
1232 \newcount\fontdepth \fontdepth=0
1233
1234 % Fonts for short table of contents.
1235 \setfont\shortcontrm\rmshape{12}{1000}
1236 \setfont\shortcontbf\bxshape{12}{1000}
1237 \setfont\shortcontsl\slshape{12}{1000}
1238
1239 %% Add scribe-like font environments, plus @l for inline lisp (usually sans
1240 %% serif) and @ii for TeX italic
1241
1242 % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
1243 % unless the following character is such as not to need one.
1244 \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
1245 \def\smartslanted#1{{\sl #1}\futurelet\next\smartitalicx}
1246 \def\smartitalic#1{{\it #1}\futurelet\next\smartitalicx}
1247
1248 \let\i=\smartitalic
1249 \let\var=\smartslanted
1250 \let\dfn=\smartslanted
1251 \let\emph=\smartitalic
1252 \let\cite=\smartslanted
1253
1254 \def\b#1{{\bf #1}}
1255 \let\strong=\b
1256
1257 % We can't just use \exhyphenpenalty, because that only has effect at
1258 % the end of a paragraph.  Restore normal hyphenation at the end of the
1259 % group within which \nohyphenation is presumably called.
1260 %
1261 \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
1262 \def\restorehyphenation{\hyphenchar\font = `- }
1263
1264 \def\t#1{%
1265   {\tt \rawbackslash \frenchspacing #1}%
1266   \null
1267 }
1268 \let\ttfont=\t
1269 \def\samp#1{`\tclose{#1}'\null}
1270 \setfont\keyrm\rmshape{8}{1000}
1271 \font\keysy=cmsy9
1272 \def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
1273   \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
1274     \vbox{\hrule\kern-0.4pt
1275      \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
1276     \kern-0.4pt\hrule}%
1277   \kern-.06em\raise0.4pt\hbox{\angleright}}}}
1278 % The old definition, with no lozenge:
1279 %\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null}
1280 \def\ctrl #1{{\tt \rawbackslash \hat}#1}
1281
1282 % @file, @option are the same as @samp.
1283 \let\file=\samp
1284 \let\option=\samp
1285
1286 % @code is a modification of @t,
1287 % which makes spaces the same size as normal in the surrounding text.
1288 \def\tclose#1{%
1289   {%
1290     % Change normal interword space to be same as for the current font.
1291     \spaceskip = \fontdimen2\font
1292     %
1293     % Switch to typewriter.
1294     \tt
1295     %
1296     % But `\ ' produces the large typewriter interword space.
1297     \def\ {{\spaceskip = 0pt{} }}%
1298     %
1299     % Turn off hyphenation.
1300     \nohyphenation
1301     %
1302     \rawbackslash
1303     \frenchspacing
1304     #1%
1305   }%
1306   \null
1307 }
1308
1309 % We *must* turn on hyphenation at `-' and `_' in \code.
1310 % Otherwise, it is too hard to avoid overfull hboxes
1311 % in the Emacs manual, the Library manual, etc.
1312
1313 % Unfortunately, TeX uses one parameter (\hyphenchar) to control
1314 % both hyphenation at - and hyphenation within words.
1315 % We must therefore turn them both off (\tclose does that)
1316 % and arrange explicitly to hyphenate at a dash.
1317 %  -- rms.
1318 {
1319   \catcode`\-=\active
1320   \catcode`\_=\active
1321   %
1322   \global\def\code{\begingroup
1323     \catcode`\-=\active \let-\codedash
1324     \catcode`\_=\active \let_\codeunder
1325     \codex
1326   }
1327   %
1328   % If we end up with any active - characters when handling the index,
1329   % just treat them as a normal -.
1330   \global\def\indexbreaks{\catcode`\-=\active \let-\realdash}
1331 }
1332
1333 \def\realdash{-}
1334 \def\codedash{-\discretionary{}{}{}}
1335 \def\codeunder{\ifusingtt{\normalunderscore\discretionary{}{}{}}{\_}}
1336 \def\codex #1{\tclose{#1}\endgroup}
1337
1338 %\let\exp=\tclose  %Was temporary
1339
1340 % @kbd is like @code, except that if the argument is just one @key command,
1341 % then @kbd has no effect.
1342
1343 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
1344 %   `example' (@kbd uses ttsl only inside of @example and friends),
1345 %   or `code' (@kbd uses normal tty font always).
1346 \def\kbdinputstyle{\parsearg\kbdinputstylexxx}
1347 \def\kbdinputstylexxx#1{%
1348   \def\arg{#1}%
1349   \ifx\arg\worddistinct
1350     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
1351   \else\ifx\arg\wordexample
1352     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
1353   \else\ifx\arg\wordcode
1354     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
1355   \fi\fi\fi
1356 }
1357 \def\worddistinct{distinct}
1358 \def\wordexample{example}
1359 \def\wordcode{code}
1360
1361 % Default is kbdinputdistinct.  (Too much of a hassle to call the macro,
1362 % the catcodes are wrong for parsearg to work.)
1363 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}
1364
1365 \def\xkey{\key}
1366 \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
1367 \ifx\one\xkey\ifx\threex\three \key{#2}%
1368 \else{\tclose{\kbdfont\look}}\fi
1369 \else{\tclose{\kbdfont\look}}\fi}
1370
1371 % For @url, @env, @command quotes seem unnecessary, so use \code.
1372 \let\url=\code
1373 \let\env=\code
1374 \let\command=\code
1375
1376 % @uref (abbreviation for `urlref') takes an optional (comma-separated)
1377 % second argument specifying the text to display and an optional third
1378 % arg as text to display instead of (rather than in addition to) the url
1379 % itself.  First (mandatory) arg is the url.  Perhaps eventually put in
1380 % a hypertex \special here.
1381 %
1382 \def\uref#1{\douref #1,,,\finish}
1383 \def\douref#1,#2,#3,#4\finish{\begingroup
1384   \unsepspaces
1385   \pdfurl{#1}%
1386   \setbox0 = \hbox{\ignorespaces #3}%
1387   \ifdim\wd0 > 0pt
1388     \unhbox0 % third arg given, show only that
1389   \else
1390     \setbox0 = \hbox{\ignorespaces #2}%
1391     \ifdim\wd0 > 0pt
1392       \ifpdf
1393         \unhbox0             % PDF: 2nd arg given, show only it
1394       \else
1395         \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
1396       \fi
1397     \else
1398       \code{#1}% only url given, so show it
1399     \fi
1400   \fi
1401   \endlink
1402 \endgroup}
1403
1404 % rms does not like angle brackets --karl, 17may97.
1405 % So now @email is just like @uref, unless we are pdf.
1406
1407 %\def\email#1{\angleleft{\tt #1}\angleright}
1408 \ifpdf
1409   \def\email#1{\doemail#1,,\finish}
1410   \def\doemail#1,#2,#3\finish{\begingroup
1411     \unsepspaces
1412     \pdfurl{mailto:#1}%
1413     \setbox0 = \hbox{\ignorespaces #2}%
1414     \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
1415     \endlink
1416   \endgroup}
1417 \else
1418   \let\email=\uref
1419 \fi
1420
1421 % Check if we are currently using a typewriter font.  Since all the
1422 % Computer Modern typewriter fonts have zero interword stretch (and
1423 % shrink), and it is reasonable to expect all typewriter fonts to have
1424 % this property, we can check that font parameter.
1425 %
1426 \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
1427
1428 % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
1429 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
1430 %
1431 \def\dmn#1{\thinspace #1}
1432
1433 \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
1434
1435 % @l was never documented to mean ``switch to the Lisp font'',
1436 % and it is not used as such in any manual I can find.  We need it for
1437 % Polish suppressed-l.  --karl, 22sep96.
1438 %\def\l#1{{\li #1}\null}
1439
1440 % Explicit font changes: @r, @sc, undocumented @ii.
1441 \def\r#1{{\rm #1}}              % roman font
1442 \def\sc#1{{\smallcaps#1}}       % smallcaps font
1443 \def\ii#1{{\it #1}}             % italic font
1444
1445 % @acronym downcases the argument and prints in smallcaps.
1446 \def\acronym#1{{\smallcaps \lowercase{#1}}}
1447
1448 % @pounds{} is a sterling sign.
1449 \def\pounds{{\it\$}}
1450
1451
1452 \message{page headings,}
1453
1454 \newskip\titlepagetopglue \titlepagetopglue = 1.5in
1455 \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
1456
1457 % First the title page.  Must do @settitle before @titlepage.
1458 \newif\ifseenauthor
1459 \newif\iffinishedtitlepage
1460
1461 % Do an implicit @contents or @shortcontents after @end titlepage if the
1462 % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
1463 %
1464 \newif\ifsetcontentsaftertitlepage
1465  \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
1466 \newif\ifsetshortcontentsaftertitlepage
1467  \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
1468
1469 \def\shorttitlepage{\parsearg\shorttitlepagezzz}
1470 \def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
1471         \endgroup\page\hbox{}\page}
1472
1473 \def\titlepage{\begingroup \parindent=0pt \textfonts
1474    \let\subtitlerm=\tenrm
1475    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
1476    %
1477    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
1478    %
1479    % Leave some space at the very top of the page.
1480    \vglue\titlepagetopglue
1481    %
1482    % Now you can print the title using @title.
1483    \def\title{\parsearg\titlezzz}%
1484    \def\titlezzz##1{\leftline{\titlefonts\rm ##1}
1485                     % print a rule at the page bottom also.
1486                     \finishedtitlepagefalse
1487                     \vskip4pt \hrule height 4pt width \hsize \vskip4pt}%
1488    % No rule at page bottom unless we print one at the top with @title.
1489    \finishedtitlepagetrue
1490    %
1491    % Now you can put text using @subtitle.
1492    \def\subtitle{\parsearg\subtitlezzz}%
1493    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
1494    %
1495    % @author should come last, but may come many times.
1496    \def\author{\parsearg\authorzzz}%
1497    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
1498       {\authorfont \leftline{##1}}}%
1499    %
1500    % Most title ``pages'' are actually two pages long, with space
1501    % at the top of the second.  We don't want the ragged left on the second.
1502    \let\oldpage = \page
1503    \def\page{%
1504       \iffinishedtitlepage\else
1505          \finishtitlepage
1506       \fi
1507       \oldpage
1508       \let\page = \oldpage
1509       \hbox{}}%
1510 %   \def\page{\oldpage \hbox{}}
1511 }
1512
1513 \def\Etitlepage{%
1514    \iffinishedtitlepage\else
1515       \finishtitlepage
1516    \fi
1517    % It is important to do the page break before ending the group,
1518    % because the headline and footline are only empty inside the group.
1519    % If we use the new definition of \page, we always get a blank page
1520    % after the title page, which we certainly don't want.
1521    \oldpage
1522    \endgroup
1523    %
1524    % If they want short, they certainly want long too.
1525    \ifsetshortcontentsaftertitlepage
1526      \shortcontents
1527      \contents
1528      \global\let\shortcontents = \relax
1529      \global\let\contents = \relax
1530    \fi
1531    %
1532    \ifsetcontentsaftertitlepage
1533      \contents
1534      \global\let\contents = \relax
1535      \global\let\shortcontents = \relax
1536    \fi
1537    %
1538    \ifpdf \pdfmakepagedesttrue \fi
1539    %
1540    \HEADINGSon
1541 }
1542
1543 \def\finishtitlepage{%
1544    \vskip4pt \hrule height 2pt width \hsize
1545    \vskip\titlepagebottomglue
1546    \finishedtitlepagetrue
1547 }
1548
1549 %%% Set up page headings and footings.
1550
1551 \let\thispage=\folio
1552
1553 \newtoks\evenheadline    % headline on even pages
1554 \newtoks\oddheadline     % headline on odd pages
1555 \newtoks\evenfootline    % footline on even pages
1556 \newtoks\oddfootline     % footline on odd pages
1557
1558 % Now make Tex use those variables
1559 \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
1560                             \else \the\evenheadline \fi}}
1561 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
1562                             \else \the\evenfootline \fi}\HEADINGShook}
1563 \let\HEADINGShook=\relax
1564
1565 % Commands to set those variables.
1566 % For example, this is what  @headings on  does
1567 % @evenheading @thistitle|@thispage|@thischapter
1568 % @oddheading @thischapter|@thispage|@thistitle
1569 % @evenfooting @thisfile||
1570 % @oddfooting ||@thisfile
1571
1572 \def\evenheading{\parsearg\evenheadingxxx}
1573 \def\oddheading{\parsearg\oddheadingxxx}
1574 \def\everyheading{\parsearg\everyheadingxxx}
1575
1576 \def\evenfooting{\parsearg\evenfootingxxx}
1577 \def\oddfooting{\parsearg\oddfootingxxx}
1578 \def\everyfooting{\parsearg\everyfootingxxx}
1579
1580 {\catcode`\@=0 %
1581
1582 \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
1583 \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
1584 \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1585
1586 \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
1587 \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
1588 \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1589
1590 \gdef\everyheadingxxx#1{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
1591
1592 \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
1593 \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
1594 \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1595
1596 \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
1597 \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
1598   \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
1599   %
1600   % Leave some space for the footline.  Hopefully ok to assume
1601   % @evenfooting will not be used by itself.
1602   \global\advance\pageheight by -\baselineskip
1603   \global\advance\vsize by -\baselineskip
1604 }
1605
1606 \gdef\everyfootingxxx#1{\oddfootingxxx{#1}\evenfootingxxx{#1}}
1607 %
1608 }% unbind the catcode of @.
1609
1610 % @headings double      turns headings on for double-sided printing.
1611 % @headings single      turns headings on for single-sided printing.
1612 % @headings off         turns them off.
1613 % @headings on          same as @headings double, retained for compatibility.
1614 % @headings after       turns on double-sided headings after this page.
1615 % @headings doubleafter turns on double-sided headings after this page.
1616 % @headings singleafter turns on single-sided headings after this page.
1617 % By default, they are off at the start of a document,
1618 % and turned `on' after @end titlepage.
1619
1620 \def\headings #1 {\csname HEADINGS#1\endcsname}
1621
1622 \def\HEADINGSoff{
1623 \global\evenheadline={\hfil} \global\evenfootline={\hfil}
1624 \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
1625 \HEADINGSoff
1626 % When we turn headings on, set the page number to 1.
1627 % For double-sided printing, put current file name in lower left corner,
1628 % chapter name on inside top of right hand pages, document
1629 % title on inside top of left hand pages, and page numbers on outside top
1630 % edge of all pages.
1631 \def\HEADINGSdouble{
1632 \global\pageno=1
1633 \global\evenfootline={\hfil}
1634 \global\oddfootline={\hfil}
1635 \global\evenheadline={\line{\folio\hfil\thistitle}}
1636 \global\oddheadline={\line{\thischapter\hfil\folio}}
1637 \global\let\contentsalignmacro = \chapoddpage
1638 }
1639 \let\contentsalignmacro = \chappager
1640
1641 % For single-sided printing, chapter title goes across top left of page,
1642 % page number on top right.
1643 \def\HEADINGSsingle{
1644 \global\pageno=1
1645 \global\evenfootline={\hfil}
1646 \global\oddfootline={\hfil}
1647 \global\evenheadline={\line{\thischapter\hfil\folio}}
1648 \global\oddheadline={\line{\thischapter\hfil\folio}}
1649 \global\let\contentsalignmacro = \chappager
1650 }
1651 \def\HEADINGSon{\HEADINGSdouble}
1652
1653 \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
1654 \let\HEADINGSdoubleafter=\HEADINGSafter
1655 \def\HEADINGSdoublex{%
1656 \global\evenfootline={\hfil}
1657 \global\oddfootline={\hfil}
1658 \global\evenheadline={\line{\folio\hfil\thistitle}}
1659 \global\oddheadline={\line{\thischapter\hfil\folio}}
1660 \global\let\contentsalignmacro = \chapoddpage
1661 }
1662
1663 \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
1664 \def\HEADINGSsinglex{%
1665 \global\evenfootline={\hfil}
1666 \global\oddfootline={\hfil}
1667 \global\evenheadline={\line{\thischapter\hfil\folio}}
1668 \global\oddheadline={\line{\thischapter\hfil\folio}}
1669 \global\let\contentsalignmacro = \chappager
1670 }
1671
1672 % Subroutines used in generating headings
1673 % Produces Day Month Year style of output.
1674 \def\today{%
1675   \number\day\space
1676   \ifcase\month
1677   \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
1678   \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
1679   \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
1680   \fi
1681   \space\number\year}
1682
1683 % @settitle line...  specifies the title of the document, for headings.
1684 % It generates no output of its own.
1685 \def\thistitle{\putwordNoTitle}
1686 \def\settitle{\parsearg\settitlezzz}
1687 \def\settitlezzz #1{\gdef\thistitle{#1}}
1688
1689
1690 \message{tables,}
1691 % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
1692
1693 % default indentation of table text
1694 \newdimen\tableindent \tableindent=.8in
1695 % default indentation of @itemize and @enumerate text
1696 \newdimen\itemindent  \itemindent=.3in
1697 % margin between end of table item and start of table text.
1698 \newdimen\itemmargin  \itemmargin=.1in
1699
1700 % used internally for \itemindent minus \itemmargin
1701 \newdimen\itemmax
1702
1703 % Note @table, @vtable, and @vtable define @item, @itemx, etc., with
1704 % these defs.
1705 % They also define \itemindex
1706 % to index the item name in whatever manner is desired (perhaps none).
1707
1708 \newif\ifitemxneedsnegativevskip
1709
1710 \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
1711
1712 \def\internalBitem{\smallbreak \parsearg\itemzzz}
1713 \def\internalBitemx{\itemxpar \parsearg\itemzzz}
1714
1715 \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
1716 \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz}
1717
1718 \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
1719 \def\internalBkitemx{\itemxpar \parsearg\kitemzzz}
1720
1721 \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
1722                  \itemzzz {#1}}
1723
1724 \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
1725                  \itemzzz {#1}}
1726
1727 \def\itemzzz #1{\begingroup %
1728   \advance\hsize by -\rightskip
1729   \advance\hsize by -\tableindent
1730   \setbox0=\hbox{\itemfont{#1}}%
1731   \itemindex{#1}%
1732   \nobreak % This prevents a break before @itemx.
1733   %
1734   % If the item text does not fit in the space we have, put it on a line
1735   % by itself, and do not allow a page break either before or after that
1736   % line.  We do not start a paragraph here because then if the next
1737   % command is, e.g., @kindex, the whatsit would get put into the
1738   % horizontal list on a line by itself, resulting in extra blank space.
1739   \ifdim \wd0>\itemmax
1740     %
1741     % Make this a paragraph so we get the \parskip glue and wrapping,
1742     % but leave it ragged-right.
1743     \begingroup
1744       \advance\leftskip by-\tableindent
1745       \advance\hsize by\tableindent
1746       \advance\rightskip by0pt plus1fil
1747       \leavevmode\unhbox0\par
1748     \endgroup
1749     %
1750     % We're going to be starting a paragraph, but we don't want the
1751     % \parskip glue -- logically it's part of the @item we just started.
1752     \nobreak \vskip-\parskip
1753     %
1754     % Stop a page break at the \parskip glue coming up.  Unfortunately
1755     % we can't prevent a possible page break at the following
1756     % \baselineskip glue.
1757     \nobreak
1758     \endgroup
1759     \itemxneedsnegativevskipfalse
1760   \else
1761     % The item text fits into the space.  Start a paragraph, so that the
1762     % following text (if any) will end up on the same line.
1763     \noindent
1764     % Do this with kerns and \unhbox so that if there is a footnote in
1765     % the item text, it can migrate to the main vertical list and
1766     % eventually be printed.
1767     \nobreak\kern-\tableindent
1768     \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
1769     \unhbox0
1770     \nobreak\kern\dimen0
1771     \endgroup
1772     \itemxneedsnegativevskiptrue
1773   \fi
1774 }
1775
1776 \def\item{\errmessage{@item while not in a table}}
1777 \def\itemx{\errmessage{@itemx while not in a table}}
1778 \def\kitem{\errmessage{@kitem while not in a table}}
1779 \def\kitemx{\errmessage{@kitemx while not in a table}}
1780 \def\xitem{\errmessage{@xitem while not in a table}}
1781 \def\xitemx{\errmessage{@xitemx while not in a table}}
1782
1783 % Contains a kludge to get @end[description] to work.
1784 \def\description{\tablez{\dontindex}{1}{}{}{}{}}
1785
1786 % @table, @ftable, @vtable.
1787 \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
1788 {\obeylines\obeyspaces%
1789 \gdef\tablex #1^^M{%
1790 \tabley\dontindex#1        \endtabley}}
1791
1792 \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
1793 {\obeylines\obeyspaces%
1794 \gdef\ftablex #1^^M{%
1795 \tabley\fnitemindex#1        \endtabley
1796 \def\Eftable{\endgraf\afterenvbreak\endgroup}%
1797 \let\Etable=\relax}}
1798
1799 \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
1800 {\obeylines\obeyspaces%
1801 \gdef\vtablex #1^^M{%
1802 \tabley\vritemindex#1        \endtabley
1803 \def\Evtable{\endgraf\afterenvbreak\endgroup}%
1804 \let\Etable=\relax}}
1805
1806 \def\dontindex #1{}
1807 \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
1808 \def\vritemindex #1{\doind {vr}{\code{#1}}}%
1809
1810 {\obeyspaces %
1811 \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
1812 \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
1813
1814 \def\tablez #1#2#3#4#5#6{%
1815 \aboveenvbreak %
1816 \begingroup %
1817 \def\Edescription{\Etable}% Necessary kludge.
1818 \let\itemindex=#1%
1819 \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
1820 \ifnum 0#4>0 \tableindent=#4\mil \fi %
1821 \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
1822 \def\itemfont{#2}%
1823 \itemmax=\tableindent %
1824 \advance \itemmax by -\itemmargin %
1825 \advance \leftskip by \tableindent %
1826 \exdentamount=\tableindent
1827 \parindent = 0pt
1828 \parskip = \smallskipamount
1829 \ifdim \parskip=0pt \parskip=2pt \fi%
1830 \def\Etable{\endgraf\afterenvbreak\endgroup}%
1831 \let\item = \internalBitem %
1832 \let\itemx = \internalBitemx %
1833 \let\kitem = \internalBkitem %
1834 \let\kitemx = \internalBkitemx %
1835 \let\xitem = \internalBxitem %
1836 \let\xitemx = \internalBxitemx %
1837 }
1838
1839 % This is the counter used by @enumerate, which is really @itemize
1840
1841 \newcount \itemno
1842
1843 \def\itemize{\parsearg\itemizezzz}
1844
1845 \def\itemizezzz #1{%
1846   \begingroup % ended by the @end itemize
1847   \itemizey {#1}{\Eitemize}
1848 }
1849
1850 \def\itemizey #1#2{%
1851 \aboveenvbreak %
1852 \itemmax=\itemindent %
1853 \advance \itemmax by -\itemmargin %
1854 \advance \leftskip by \itemindent %
1855 \exdentamount=\itemindent
1856 \parindent = 0pt %
1857 \parskip = \smallskipamount %
1858 \ifdim \parskip=0pt \parskip=2pt \fi%
1859 \def#2{\endgraf\afterenvbreak\endgroup}%
1860 \def\itemcontents{#1}%
1861 \let\item=\itemizeitem}
1862
1863 % Set sfcode to normal for the chars that usually have another value.
1864 % These are `.?!:;,'
1865 \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
1866   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
1867
1868 % \splitoff TOKENS\endmark defines \first to be the first token in
1869 % TOKENS, and \rest to be the remainder.
1870 %
1871 \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
1872
1873 % Allow an optional argument of an uppercase letter, lowercase letter,
1874 % or number, to specify the first label in the enumerated list.  No
1875 % argument is the same as `1'.
1876 %
1877 \def\enumerate{\parsearg\enumeratezzz}
1878 \def\enumeratezzz #1{\enumeratey #1  \endenumeratey}
1879 \def\enumeratey #1 #2\endenumeratey{%
1880   \begingroup % ended by the @end enumerate
1881   %
1882   % If we were given no argument, pretend we were given `1'.
1883   \def\thearg{#1}%
1884   \ifx\thearg\empty \def\thearg{1}\fi
1885   %
1886   % Detect if the argument is a single token.  If so, it might be a
1887   % letter.  Otherwise, the only valid thing it can be is a number.
1888   % (We will always have one token, because of the test we just made.
1889   % This is a good thing, since \splitoff doesn't work given nothing at
1890   % all -- the first parameter is undelimited.)
1891   \expandafter\splitoff\thearg\endmark
1892   \ifx\rest\empty
1893     % Only one token in the argument.  It could still be anything.
1894     % A ``lowercase letter'' is one whose \lccode is nonzero.
1895     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
1896     %   not equal to itself.
1897     % Otherwise, we assume it's a number.
1898     %
1899     % We need the \relax at the end of the \ifnum lines to stop TeX from
1900     % continuing to look for a <number>.
1901     %
1902     \ifnum\lccode\expandafter`\thearg=0\relax
1903       \numericenumerate % a number (we hope)
1904     \else
1905       % It's a letter.
1906       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
1907         \lowercaseenumerate % lowercase letter
1908       \else
1909         \uppercaseenumerate % uppercase letter
1910       \fi
1911     \fi
1912   \else
1913     % Multiple tokens in the argument.  We hope it's a number.
1914     \numericenumerate
1915   \fi
1916 }
1917
1918 % An @enumerate whose labels are integers.  The starting integer is
1919 % given in \thearg.
1920 %
1921 \def\numericenumerate{%
1922   \itemno = \thearg
1923   \startenumeration{\the\itemno}%
1924 }
1925
1926 % The starting (lowercase) letter is in \thearg.
1927 \def\lowercaseenumerate{%
1928   \itemno = \expandafter`\thearg
1929   \startenumeration{%
1930     % Be sure we're not beyond the end of the alphabet.
1931     \ifnum\itemno=0
1932       \errmessage{No more lowercase letters in @enumerate; get a bigger
1933                   alphabet}%
1934     \fi
1935     \char\lccode\itemno
1936   }%
1937 }
1938
1939 % The starting (uppercase) letter is in \thearg.
1940 \def\uppercaseenumerate{%
1941   \itemno = \expandafter`\thearg
1942   \startenumeration{%
1943     % Be sure we're not beyond the end of the alphabet.
1944     \ifnum\itemno=0
1945       \errmessage{No more uppercase letters in @enumerate; get a bigger
1946                   alphabet}
1947     \fi
1948     \char\uccode\itemno
1949   }%
1950 }
1951
1952 % Call itemizey, adding a period to the first argument and supplying the
1953 % common last two arguments.  Also subtract one from the initial value in
1954 % \itemno, since @item increments \itemno.
1955 %
1956 \def\startenumeration#1{%
1957   \advance\itemno by -1
1958   \itemizey{#1.}\Eenumerate\flushcr
1959 }
1960
1961 % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
1962 % to @enumerate.
1963 %
1964 \def\alphaenumerate{\enumerate{a}}
1965 \def\capsenumerate{\enumerate{A}}
1966 \def\Ealphaenumerate{\Eenumerate}
1967 \def\Ecapsenumerate{\Eenumerate}
1968
1969 % Definition of @item while inside @itemize.
1970
1971 \def\itemizeitem{%
1972 \advance\itemno by 1
1973 {\let\par=\endgraf \smallbreak}%
1974 \ifhmode \errmessage{In hmode at itemizeitem}\fi
1975 {\parskip=0in \hskip 0pt
1976 \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
1977 \vadjust{\penalty 1200}}%
1978 \flushcr}
1979
1980 % @multitable macros
1981 % Amy Hendrickson, 8/18/94, 3/6/96
1982 %
1983 % @multitable ... @end multitable will make as many columns as desired.
1984 % Contents of each column will wrap at width given in preamble.  Width
1985 % can be specified either with sample text given in a template line,
1986 % or in percent of \hsize, the current width of text on page.
1987
1988 % Table can continue over pages but will only break between lines.
1989
1990 % To make preamble:
1991 %
1992 % Either define widths of columns in terms of percent of \hsize:
1993 %   @multitable @columnfractions .25 .3 .45
1994 %   @item ...
1995 %
1996 %   Numbers following @columnfractions are the percent of the total
1997 %   current hsize to be used for each column. You may use as many
1998 %   columns as desired.
1999
2000
2001 % Or use a template:
2002 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
2003 %   @item ...
2004 %   using the widest term desired in each column.
2005 %
2006 % For those who want to use more than one line's worth of words in
2007 % the preamble, break the line within one argument and it
2008 % will parse correctly, i.e.,
2009 %
2010 %     @multitable {Column 1 template} {Column 2 template} {Column 3
2011 %      template}
2012 % Not:
2013 %     @multitable {Column 1 template} {Column 2 template}
2014 %      {Column 3 template}
2015
2016 % Each new table line starts with @item, each subsequent new column
2017 % starts with @tab. Empty columns may be produced by supplying @tab's
2018 % with nothing between them for as many times as empty columns are needed,
2019 % ie, @tab@tab@tab will produce two empty columns.
2020
2021 % @item, @tab, @multitable or @end multitable do not need to be on their
2022 % own lines, but it will not hurt if they are.
2023
2024 % Sample multitable:
2025
2026 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
2027 %   @item first col stuff @tab second col stuff @tab third col
2028 %   @item
2029 %   first col stuff
2030 %   @tab
2031 %   second col stuff
2032 %   @tab
2033 %   third col
2034 %   @item first col stuff @tab second col stuff
2035 %   @tab Many paragraphs of text may be used in any column.
2036 %
2037 %         They will wrap at the width determined by the template.
2038 %   @item@tab@tab This will be in third column.
2039 %   @end multitable
2040
2041 % Default dimensions may be reset by user.
2042 % @multitableparskip is vertical space between paragraphs in table.
2043 % @multitableparindent is paragraph indent in table.
2044 % @multitablecolmargin is horizontal space to be left between columns.
2045 % @multitablelinespace is space to leave between table items, baseline
2046 %                                                            to baseline.
2047 %   0pt means it depends on current normal line spacing.
2048 %
2049 \newskip\multitableparskip
2050 \newskip\multitableparindent
2051 \newdimen\multitablecolspace
2052 \newskip\multitablelinespace
2053 \multitableparskip=0pt
2054 \multitableparindent=6pt
2055 \multitablecolspace=12pt
2056 \multitablelinespace=0pt
2057
2058 % Macros used to set up halign preamble:
2059 %
2060 \let\endsetuptable\relax
2061 \def\xendsetuptable{\endsetuptable}
2062 \let\columnfractions\relax
2063 \def\xcolumnfractions{\columnfractions}
2064 \newif\ifsetpercent
2065
2066 % #1 is the part of the @columnfraction before the decimal point, which
2067 % is presumably either 0 or the empty string (but we don't check, we
2068 % just throw it away).  #2 is the decimal part, which we use as the
2069 % percent of \hsize for this column.
2070 \def\pickupwholefraction#1.#2 {%
2071   \global\advance\colcount by 1
2072   \expandafter\xdef\csname col\the\colcount\endcsname{.#2\hsize}%
2073   \setuptable
2074 }
2075
2076 \newcount\colcount
2077 \def\setuptable#1{%
2078   \def\firstarg{#1}%
2079   \ifx\firstarg\xendsetuptable
2080     \let\go = \relax
2081   \else
2082     \ifx\firstarg\xcolumnfractions
2083       \global\setpercenttrue
2084     \else
2085       \ifsetpercent
2086          \let\go\pickupwholefraction
2087       \else
2088          \global\advance\colcount by 1
2089          \setbox0=\hbox{#1\unskip }% Add a normal word space as a separator;
2090                             % typically that is always in the input, anyway.
2091          \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
2092       \fi
2093     \fi
2094     \ifx\go\pickupwholefraction
2095       % Put the argument back for the \pickupwholefraction call, so
2096       % we'll always have a period there to be parsed.
2097       \def\go{\pickupwholefraction#1}%
2098     \else
2099       \let\go = \setuptable
2100     \fi%
2101   \fi
2102   \go
2103 }
2104
2105 % This used to have \hskip1sp.  But then the space in a template line is
2106 % not enough.  That is bad.  So let's go back to just & until we
2107 % encounter the problem it was intended to solve again.
2108 % --karl, nathan@acm.org, 20apr99.
2109 \def\tab{&}
2110
2111 % @multitable ... @end multitable definitions:
2112 %
2113 \def\multitable{\parsearg\dotable}
2114 \def\dotable#1{\bgroup
2115   \vskip\parskip
2116   \let\item\crcr
2117   \tolerance=9500
2118   \hbadness=9500
2119   \setmultitablespacing
2120   \parskip=\multitableparskip
2121   \parindent=\multitableparindent
2122   \overfullrule=0pt
2123   \global\colcount=0
2124   \def\Emultitable{\global\setpercentfalse\cr\egroup\egroup}%
2125   %
2126   % To parse everything between @multitable and @item:
2127   \setuptable#1 \endsetuptable
2128   %
2129   % \everycr will reset column counter, \colcount, at the end of
2130   % each line. Every column entry will cause \colcount to advance by one.
2131   % The table preamble
2132   % looks at the current \colcount to find the correct column width.
2133   \everycr{\noalign{%
2134   %
2135   % \filbreak%% keeps underfull box messages off when table breaks over pages.
2136   % Maybe so, but it also creates really weird page breaks when the table
2137   % breaks over pages. Wouldn't \vfil be better?  Wait until the problem
2138   % manifests itself, so it can be fixed for real --karl.
2139     \global\colcount=0\relax}}%
2140   %
2141   % This preamble sets up a generic column definition, which will
2142   % be used as many times as user calls for columns.
2143   % \vtop will set a single line and will also let text wrap and
2144   % continue for many paragraphs if desired.
2145   \halign\bgroup&\global\advance\colcount by 1\relax
2146     \multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname
2147   %
2148   % In order to keep entries from bumping into each other
2149   % we will add a \leftskip of \multitablecolspace to all columns after
2150   % the first one.
2151   %
2152   % If a template has been used, we will add \multitablecolspace
2153   % to the width of each template entry.
2154   %
2155   % If the user has set preamble in terms of percent of \hsize we will
2156   % use that dimension as the width of the column, and the \leftskip
2157   % will keep entries from bumping into each other.  Table will start at
2158   % left margin and final column will justify at right margin.
2159   %
2160   % Make sure we don't inherit \rightskip from the outer environment.
2161   \rightskip=0pt
2162   \ifnum\colcount=1
2163     % The first column will be indented with the surrounding text.
2164     \advance\hsize by\leftskip
2165   \else
2166     \ifsetpercent \else
2167       % If user has not set preamble in terms of percent of \hsize
2168       % we will advance \hsize by \multitablecolspace.
2169       \advance\hsize by \multitablecolspace
2170     \fi
2171    % In either case we will make \leftskip=\multitablecolspace:
2172   \leftskip=\multitablecolspace
2173   \fi
2174   % Ignoring space at the beginning and end avoids an occasional spurious
2175   % blank line, when TeX decides to break the line at the space before the
2176   % box from the multistrut, so the strut ends up on a line by itself.
2177   % For example:
2178   % @multitable @columnfractions .11 .89
2179   % @item @code{#}
2180   % @tab Legal holiday which is valid in major parts of the whole country.
2181   % Is automatically provided with highlighting sequences respectively marking
2182   % characters.
2183   \noindent\ignorespaces##\unskip\multistrut}\cr
2184 }
2185
2186 \def\setmultitablespacing{% test to see if user has set \multitablelinespace.
2187 % If so, do nothing. If not, give it an appropriate dimension based on
2188 % current baselineskip.
2189 \ifdim\multitablelinespace=0pt
2190 \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
2191 \global\advance\multitablelinespace by-\ht0
2192 %% strut to put in table in case some entry doesn't have descenders,
2193 %% to keep lines equally spaced
2194 \let\multistrut = \strut
2195 \else
2196 %% FIXME: what is \box0 supposed to be?
2197 \gdef\multistrut{\vrule height\multitablelinespace depth\dp0
2198 width0pt\relax} \fi
2199 %% Test to see if parskip is larger than space between lines of
2200 %% table. If not, do nothing.
2201 %%        If so, set to same dimension as multitablelinespace.
2202 \ifdim\multitableparskip>\multitablelinespace
2203 \global\multitableparskip=\multitablelinespace
2204 \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
2205                                       %% than skip between lines in the table.
2206 \fi%
2207 \ifdim\multitableparskip=0pt
2208 \global\multitableparskip=\multitablelinespace
2209 \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
2210                                       %% than skip between lines in the table.
2211 \fi}
2212
2213
2214 \message{conditionals,}
2215 % Prevent errors for section commands.
2216 % Used in @ignore and in failing conditionals.
2217 \def\ignoresections{%
2218   \let\chapter=\relax
2219   \let\unnumbered=\relax
2220   \let\top=\relax
2221   \let\unnumberedsec=\relax
2222   \let\unnumberedsection=\relax
2223   \let\unnumberedsubsec=\relax
2224   \let\unnumberedsubsection=\relax
2225   \let\unnumberedsubsubsec=\relax
2226   \let\unnumberedsubsubsection=\relax
2227   \let\section=\relax
2228   \let\subsec=\relax
2229   \let\subsubsec=\relax
2230   \let\subsection=\relax
2231   \let\subsubsection=\relax
2232   \let\appendix=\relax
2233   \let\appendixsec=\relax
2234   \let\appendixsection=\relax
2235   \let\appendixsubsec=\relax
2236   \let\appendixsubsection=\relax
2237   \let\appendixsubsubsec=\relax
2238   \let\appendixsubsubsection=\relax
2239   \let\contents=\relax
2240   \let\smallbook=\relax
2241   \let\titlepage=\relax
2242 }
2243
2244 % Used in nested conditionals, where we have to parse the Texinfo source
2245 % and so want to turn off most commands, in case they are used
2246 % incorrectly.
2247 %
2248 \def\ignoremorecommands{%
2249   \let\defcodeindex = \relax
2250   \let\defcv = \relax
2251   \let\deffn = \relax
2252   \let\deffnx = \relax
2253   \let\defindex = \relax
2254   \let\defivar = \relax
2255   \let\defmac = \relax
2256   \let\defmethod = \relax
2257   \let\defop = \relax
2258   \let\defopt = \relax
2259   \let\defspec = \relax
2260   \let\deftp = \relax
2261   \let\deftypefn = \relax
2262   \let\deftypefun = \relax
2263   \let\deftypeivar = \relax
2264   \let\deftypeop = \relax
2265   \let\deftypevar = \relax
2266   \let\deftypevr = \relax
2267   \let\defun = \relax
2268   \let\defvar = \relax
2269   \let\defvr = \relax
2270   \let\ref = \relax
2271   \let\xref = \relax
2272   \let\printindex = \relax
2273   \let\pxref = \relax
2274   \let\settitle = \relax
2275   \let\setchapternewpage = \relax
2276   \let\setchapterstyle = \relax
2277   \let\everyheading = \relax
2278   \let\evenheading = \relax
2279   \let\oddheading = \relax
2280   \let\everyfooting = \relax
2281   \let\evenfooting = \relax
2282   \let\oddfooting = \relax
2283   \let\headings = \relax
2284   \let\include = \relax
2285   \let\lowersections = \relax
2286   \let\down = \relax
2287   \let\raisesections = \relax
2288   \let\up = \relax
2289   \let\set = \relax
2290   \let\clear = \relax
2291   \let\item = \relax
2292 }
2293
2294 % Ignore @ignore ... @end ignore.
2295 %
2296 \def\ignore{\doignore{ignore}}
2297
2298 % Ignore @ifinfo, @ifhtml, @ifnottex, @html, @menu, and @direntry text.
2299 %
2300 \def\ifinfo{\doignore{ifinfo}}
2301 \def\ifhtml{\doignore{ifhtml}}
2302 \def\ifnottex{\doignore{ifnottex}}
2303 \def\html{\doignore{html}}
2304 \def\menu{\doignore{menu}}
2305 \def\direntry{\doignore{direntry}}
2306
2307 % @dircategory CATEGORY  -- specify a category of the dir file
2308 % which this file should belong to.  Ignore this in TeX.
2309 \let\dircategory = \comment
2310
2311 % Ignore text until a line `@end #1'.
2312 %
2313 \def\doignore#1{\begingroup
2314   % Don't complain about control sequences we have declared \outer.
2315   \ignoresections
2316   %
2317   % Define a command to swallow text until we reach `@end #1'.
2318   % This @ is a catcode 12 token (that is the normal catcode of @ in
2319   % this texinfo.tex file).  We change the catcode of @ below to match.
2320   \long\def\doignoretext##1@end #1{\enddoignore}%
2321   %
2322   % Make sure that spaces turn into tokens that match what \doignoretext wants.
2323   \catcode32 = 10
2324   %
2325   % Ignore braces, too, so mismatched braces don't cause trouble.
2326   \catcode`\{ = 9
2327   \catcode`\} = 9
2328   %
2329   % We must not have @c interpreted as a control sequence.
2330   \catcode`\@ = 12
2331   %
2332   % Make the letter c a comment character so that the rest of the line
2333   % will be ignored. This way, the document can have (for example)
2334   %   @c @end ifinfo
2335   % and the @end ifinfo will be properly ignored.
2336   % (We've just changed @ to catcode 12.)
2337   \catcode`\c = 14
2338   %
2339   % And now expand that command.
2340   \doignoretext
2341 }
2342
2343 % What we do to finish off ignored text.
2344 %
2345 \def\enddoignore{\endgroup\ignorespaces}%
2346
2347 \newif\ifwarnedobs\warnedobsfalse
2348 \def\obstexwarn{%
2349   \ifwarnedobs\relax\else
2350   % We need to warn folks that they may have trouble with TeX 3.0.
2351   % This uses \immediate\write16 rather than \message to get newlines.
2352     \immediate\write16{}
2353     \immediate\write16{WARNING: for users of Unix TeX 3.0!}
2354     \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
2355     \immediate\write16{If you are running another version of TeX, relax.}
2356     \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
2357     \immediate\write16{  Then upgrade your TeX installation if you can.}
2358     \immediate\write16{  (See ftp://ftp.gnu.org/pub/gnu/TeX.README.)}
2359     \immediate\write16{If you are stuck with version 3.0, run the}
2360     \immediate\write16{  script ``tex3patch'' from the Texinfo distribution}
2361     \immediate\write16{  to use a workaround.}
2362     \immediate\write16{}
2363     \global\warnedobstrue
2364     \fi
2365 }
2366
2367 % **In TeX 3.0, setting text in \nullfont hangs tex.  For a
2368 % workaround (which requires the file ``dummy.tfm'' to be installed),
2369 % uncomment the following line:
2370 %%%%%\font\nullfont=dummy\let\obstexwarn=\relax
2371
2372 % Ignore text, except that we keep track of conditional commands for
2373 % purposes of nesting, up to an `@end #1' command.
2374 %
2375 \def\nestedignore#1{%
2376   \obstexwarn
2377   % We must actually expand the ignored text to look for the @end
2378   % command, so that nested ignore constructs work.  Thus, we put the
2379   % text into a \vbox and then do nothing with the result.  To minimize
2380   % the change of memory overflow, we follow the approach outlined on
2381   % page 401 of the TeXbook: make the current font be a dummy font.
2382   %
2383   \setbox0 = \vbox\bgroup
2384     % Don't complain about control sequences we have declared \outer.
2385     \ignoresections
2386     %
2387     % Define `@end #1' to end the box, which will in turn undefine the
2388     % @end command again.
2389     \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
2390     %
2391     % We are going to be parsing Texinfo commands.  Most cause no
2392     % trouble when they are used incorrectly, but some commands do
2393     % complicated argument parsing or otherwise get confused, so we
2394     % undefine them.
2395     %
2396     % We can't do anything about stray @-signs, unfortunately;
2397     % they'll produce `undefined control sequence' errors.
2398     \ignoremorecommands
2399     %
2400     % Set the current font to be \nullfont, a TeX primitive, and define
2401     % all the font commands to also use \nullfont.  We don't use
2402     % dummy.tfm, as suggested in the TeXbook, because not all sites
2403     % might have that installed.  Therefore, math mode will still
2404     % produce output, but that should be an extremely small amount of
2405     % stuff compared to the main input.
2406     %
2407     \nullfont
2408     \let\tenrm=\nullfont \let\tenit=\nullfont \let\tensl=\nullfont
2409     \let\tenbf=\nullfont \let\tentt=\nullfont \let\smallcaps=\nullfont
2410     \let\tensf=\nullfont
2411     % Similarly for index fonts (mostly for their use in smallexample).
2412     \let\smallrm=\nullfont \let\smallit=\nullfont \let\smallsl=\nullfont
2413     \let\smallbf=\nullfont \let\smalltt=\nullfont \let\smallsc=\nullfont
2414     \let\smallsf=\nullfont
2415     %
2416     % Don't complain when characters are missing from the fonts.
2417     \tracinglostchars = 0
2418     %
2419     % Don't bother to do space factor calculations.
2420     \frenchspacing
2421     %
2422     % Don't report underfull hboxes.
2423     \hbadness = 10000
2424     %
2425     % Do minimal line-breaking.
2426     \pretolerance = 10000
2427     %
2428     % Do not execute instructions in @tex
2429     \def\tex{\doignore{tex}}%
2430     % Do not execute macro definitions.
2431     % `c' is a comment character, so the word `macro' will get cut off.
2432     \def\macro{\doignore{ma}}%
2433 }
2434
2435 % @set VAR sets the variable VAR to an empty value.
2436 % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
2437 %
2438 % Since we want to separate VAR from REST-OF-LINE (which might be
2439 % empty), we can't just use \parsearg; we have to insert a space of our
2440 % own to delimit the rest of the line, and then take it out again if we
2441 % didn't need it.  Make sure the catcode of space is correct to avoid
2442 % losing inside @example, for instance.
2443 %
2444 \def\set{\begingroup\catcode` =10
2445   \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR.
2446   \parsearg\setxxx}
2447 \def\setxxx#1{\setyyy#1 \endsetyyy}
2448 \def\setyyy#1 #2\endsetyyy{%
2449   \def\temp{#2}%
2450   \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
2451   \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
2452   \fi
2453   \endgroup
2454 }
2455 % Can't use \xdef to pre-expand #2 and save some time, since \temp or
2456 % \next or other control sequences that we've defined might get us into
2457 % an infinite loop. Consider `@set foo @cite{bar}'.
2458 \def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}}
2459
2460 % @clear VAR clears (i.e., unsets) the variable VAR.
2461 %
2462 \def\clear{\parsearg\clearxxx}
2463 \def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax}
2464
2465 % @value{foo} gets the text saved in variable foo.
2466 {
2467   \catcode`\_ = \active
2468   %
2469   % We might end up with active _ or - characters in the argument if
2470   % we're called from @code, as @code{@value{foo-bar_}}.  So \let any
2471   % such active characters to their normal equivalents.
2472   \gdef\value{\begingroup
2473     \catcode`\-=12 \catcode`\_=12
2474     \indexbreaks \let_\normalunderscore
2475     \valuexxx}
2476 }
2477 \def\valuexxx#1{\expandablevalue{#1}\endgroup}
2478
2479 % We have this subroutine so that we can handle at least some @value's
2480 % properly in indexes (we \let\value to this in \indexdummies).  Ones
2481 % whose names contain - or _ still won't work, but we can't do anything
2482 % about that.  The command has to be fully expandable, since the result
2483 % winds up in the index file.  This means that if the variable's value
2484 % contains other Texinfo commands, it's almost certain it will fail
2485 % (although perhaps we could fix that with sufficient work to do a
2486 % one-level expansion on the result, instead of complete).
2487 %
2488 \def\expandablevalue#1{%
2489   \expandafter\ifx\csname SET#1\endcsname\relax
2490     {[No value for ``#1'']}%
2491   \else
2492     \csname SET#1\endcsname
2493   \fi
2494 }
2495
2496 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
2497 % with @set.
2498 %
2499 \def\ifset{\parsearg\ifsetxxx}
2500 \def\ifsetxxx #1{%
2501   \expandafter\ifx\csname SET#1\endcsname\relax
2502     \expandafter\ifsetfail
2503   \else
2504     \expandafter\ifsetsucceed
2505   \fi
2506 }
2507 \def\ifsetsucceed{\conditionalsucceed{ifset}}
2508 \def\ifsetfail{\nestedignore{ifset}}
2509 \defineunmatchedend{ifset}
2510
2511 % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
2512 % defined with @set, or has been undefined with @clear.
2513 %
2514 \def\ifclear{\parsearg\ifclearxxx}
2515 \def\ifclearxxx #1{%
2516   \expandafter\ifx\csname SET#1\endcsname\relax
2517     \expandafter\ifclearsucceed
2518   \else
2519     \expandafter\ifclearfail
2520   \fi
2521 }
2522 \def\ifclearsucceed{\conditionalsucceed{ifclear}}
2523 \def\ifclearfail{\nestedignore{ifclear}}
2524 \defineunmatchedend{ifclear}
2525
2526 % @iftex, @ifnothtml, @ifnotinfo always succeed; we read the text
2527 % following, through the first @end iftex (etc.).  Make `@end iftex'
2528 % (etc.) valid only after an @iftex.
2529 %
2530 \def\iftex{\conditionalsucceed{iftex}}
2531 \def\ifnothtml{\conditionalsucceed{ifnothtml}}
2532 \def\ifnotinfo{\conditionalsucceed{ifnotinfo}}
2533 \defineunmatchedend{iftex}
2534 \defineunmatchedend{ifnothtml}
2535 \defineunmatchedend{ifnotinfo}
2536
2537 % We can't just want to start a group at @iftex (for example) and end it
2538 % at @end iftex, since then @set commands inside the conditional have no
2539 % effect (they'd get reverted at the end of the group).  So we must
2540 % define \Eiftex to redefine itself to be its previous value.  (We can't
2541 % just define it to fail again with an ``unmatched end'' error, since
2542 % the @ifset might be nested.)
2543 %
2544 \def\conditionalsucceed#1{%
2545   \edef\temp{%
2546     % Remember the current value of \E#1.
2547     \let\nece{prevE#1} = \nece{E#1}%
2548     %
2549     % At the `@end #1', redefine \E#1 to be its previous value.
2550     \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
2551   }%
2552   \temp
2553 }
2554
2555 % We need to expand lots of \csname's, but we don't want to expand the
2556 % control sequences after we've constructed them.
2557 %
2558 \def\nece#1{\expandafter\noexpand\csname#1\endcsname}
2559
2560 % @defininfoenclose.
2561 \let\definfoenclose=\comment
2562
2563
2564 \message{indexing,}
2565 % Index generation facilities
2566
2567 % Define \newwrite to be identical to plain tex's \newwrite
2568 % except not \outer, so it can be used within \newindex.
2569 {\catcode`\@=11
2570 \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
2571
2572 % \newindex {foo} defines an index named foo.
2573 % It automatically defines \fooindex such that
2574 % \fooindex ...rest of line... puts an entry in the index foo.
2575 % It also defines \fooindfile to be the number of the output channel for
2576 % the file that accumulates this index.  The file's extension is foo.
2577 % The name of an index should be no more than 2 characters long
2578 % for the sake of vms.
2579 %
2580 \def\newindex#1{%
2581   \iflinks
2582     \expandafter\newwrite \csname#1indfile\endcsname
2583     \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
2584   \fi
2585   \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
2586     \noexpand\doindex{#1}}
2587 }
2588
2589 % @defindex foo  ==  \newindex{foo}
2590
2591 \def\defindex{\parsearg\newindex}
2592
2593 % Define @defcodeindex, like @defindex except put all entries in @code.
2594
2595 \def\newcodeindex#1{%
2596   \iflinks
2597     \expandafter\newwrite \csname#1indfile\endcsname
2598     \openout \csname#1indfile\endcsname \jobname.#1
2599   \fi
2600   \expandafter\xdef\csname#1index\endcsname{%
2601     \noexpand\docodeindex{#1}}
2602 }
2603
2604 \def\defcodeindex{\parsearg\newcodeindex}
2605
2606 % @synindex foo bar    makes index foo feed into index bar.
2607 % Do this instead of @defindex foo if you don't want it as a separate index.
2608 % The \closeout helps reduce unnecessary open files; the limit on the
2609 % Acorn RISC OS is a mere 16 files.
2610 \def\synindex#1 #2 {%
2611   \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
2612   \expandafter\closeout\csname#1indfile\endcsname
2613   \expandafter\let\csname#1indfile\endcsname=\synindexfoo
2614   \expandafter\xdef\csname#1index\endcsname{% define \xxxindex
2615     \noexpand\doindex{#2}}%
2616 }
2617
2618 % @syncodeindex foo bar   similar, but put all entries made for index foo
2619 % inside @code.
2620 \def\syncodeindex#1 #2 {%
2621   \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
2622   \expandafter\closeout\csname#1indfile\endcsname
2623   \expandafter\let\csname#1indfile\endcsname=\synindexfoo
2624   \expandafter\xdef\csname#1index\endcsname{% define \xxxindex
2625     \noexpand\docodeindex{#2}}%
2626 }
2627
2628 % Define \doindex, the driver for all \fooindex macros.
2629 % Argument #1 is generated by the calling \fooindex macro,
2630 %  and it is "foo", the name of the index.
2631
2632 % \doindex just uses \parsearg; it calls \doind for the actual work.
2633 % This is because \doind is more useful to call from other macros.
2634
2635 % There is also \dosubind {index}{topic}{subtopic}
2636 % which makes an entry in a two-level index such as the operation index.
2637
2638 \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
2639 \def\singleindexer #1{\doind{\indexname}{#1}}
2640
2641 % like the previous two, but they put @code around the argument.
2642 \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
2643 \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
2644
2645 \def\indexdummies{%
2646 \def\ { }%
2647 % Take care of the plain tex accent commands.
2648 \def\"{\realbackslash "}%
2649 \def\`{\realbackslash `}%
2650 \def\'{\realbackslash '}%
2651 \def\^{\realbackslash ^}%
2652 \def\~{\realbackslash ~}%
2653 \def\={\realbackslash =}%
2654 \def\b{\realbackslash b}%
2655 \def\c{\realbackslash c}%
2656 \def\d{\realbackslash d}%
2657 \def\u{\realbackslash u}%
2658 \def\v{\realbackslash v}%
2659 \def\H{\realbackslash H}%
2660 % Take care of the plain tex special European modified letters.
2661 \def\oe{\realbackslash oe}%
2662 \def\ae{\realbackslash ae}%
2663 \def\aa{\realbackslash aa}%
2664 \def\OE{\realbackslash OE}%
2665 \def\AE{\realbackslash AE}%
2666 \def\AA{\realbackslash AA}%
2667 \def\o{\realbackslash o}%
2668 \def\O{\realbackslash O}%
2669 \def\l{\realbackslash l}%
2670 \def\L{\realbackslash L}%
2671 \def\ss{\realbackslash ss}%
2672 % Take care of texinfo commands likely to appear in an index entry.
2673 % (Must be a way to avoid doing expansion at all, and thus not have to
2674 % laboriously list every single command here.)
2675 \def\@{@}% will be @@ when we switch to @ as escape char.
2676 % Need these in case \tex is in effect and \{ is a \delimiter again.
2677 % But can't use \lbracecmd and \rbracecmd because texindex assumes
2678 % braces and backslashes are used only as delimiters.  
2679 \let\{ = \mylbrace
2680 \let\} = \myrbrace
2681 \def\_{{\realbackslash _}}%
2682 \def\w{\realbackslash w }%
2683 \def\bf{\realbackslash bf }%
2684 %\def\rm{\realbackslash rm }%
2685 \def\sl{\realbackslash sl }%
2686 \def\sf{\realbackslash sf}%
2687 \def\tt{\realbackslash tt}%
2688 \def\gtr{\realbackslash gtr}%
2689 \def\less{\realbackslash less}%
2690 \def\hat{\realbackslash hat}%
2691 \def\TeX{\realbackslash TeX}%
2692 \def\dots{\realbackslash dots }%
2693 \def\result{\realbackslash result}%
2694 \def\equiv{\realbackslash equiv}%
2695 \def\expansion{\realbackslash expansion}%
2696 \def\print{\realbackslash print}%
2697 \def\error{\realbackslash error}%
2698 \def\point{\realbackslash point}%
2699 \def\copyright{\realbackslash copyright}%
2700 \def\tclose##1{\realbackslash tclose {##1}}%
2701 \def\code##1{\realbackslash code {##1}}%
2702 \def\uref##1{\realbackslash uref {##1}}%
2703 \def\url##1{\realbackslash url {##1}}%
2704 \def\env##1{\realbackslash env {##1}}%
2705 \def\command##1{\realbackslash command {##1}}%
2706 \def\option##1{\realbackslash option {##1}}%
2707 \def\dotless##1{\realbackslash dotless {##1}}%
2708 \def\samp##1{\realbackslash samp {##1}}%
2709 \def\,##1{\realbackslash ,{##1}}%
2710 \def\t##1{\realbackslash t {##1}}%
2711 \def\r##1{\realbackslash r {##1}}%
2712 \def\i##1{\realbackslash i {##1}}%
2713 \def\b##1{\realbackslash b {##1}}%
2714 \def\sc##1{\realbackslash sc {##1}}%
2715 \def\cite##1{\realbackslash cite {##1}}%
2716 \def\key##1{\realbackslash key {##1}}%
2717 \def\file##1{\realbackslash file {##1}}%
2718 \def\var##1{\realbackslash var {##1}}%
2719 \def\kbd##1{\realbackslash kbd {##1}}%
2720 \def\dfn##1{\realbackslash dfn {##1}}%
2721 \def\emph##1{\realbackslash emph {##1}}%
2722 \def\acronym##1{\realbackslash acronym {##1}}%
2723 %
2724 % Handle some cases of @value -- where the variable name does not
2725 % contain - or _, and the value does not contain any
2726 % (non-fully-expandable) commands.
2727 \let\value = \expandablevalue
2728 %
2729 \unsepspaces
2730 % Turn off macro expansion
2731 \turnoffmacros
2732 }
2733
2734 % If an index command is used in an @example environment, any spaces
2735 % therein should become regular spaces in the raw index file, not the
2736 % expansion of \tie (\\leavevmode \penalty \@M \ ).
2737 {\obeyspaces
2738  \gdef\unsepspaces{\obeyspaces\let =\space}}
2739
2740 % \indexnofonts no-ops all font-change commands.
2741 % This is used when outputting the strings to sort the index by.
2742 \def\indexdummyfont#1{#1}
2743 \def\indexdummytex{TeX}
2744 \def\indexdummydots{...}
2745
2746 \def\indexnofonts{%
2747 % Just ignore accents.
2748 \let\,=\indexdummyfont
2749 \let\"=\indexdummyfont
2750 \let\`=\indexdummyfont
2751 \let\'=\indexdummyfont
2752 \let\^=\indexdummyfont
2753 \let\~=\indexdummyfont
2754 \let\==\indexdummyfont
2755 \let\b=\indexdummyfont
2756 \let\c=\indexdummyfont
2757 \let\d=\indexdummyfont
2758 \let\u=\indexdummyfont
2759 \let\v=\indexdummyfont
2760 \let\H=\indexdummyfont
2761 \let\dotless=\indexdummyfont
2762 % Take care of the plain tex special European modified letters.
2763 \def\oe{oe}%
2764 \def\ae{ae}%
2765 \def\aa{aa}%
2766 \def\OE{OE}%
2767 \def\AE{AE}%
2768 \def\AA{AA}%
2769 \def\o{o}%
2770 \def\O{O}%
2771 \def\l{l}%
2772 \def\L{L}%
2773 \def\ss{ss}%
2774 \let\w=\indexdummyfont
2775 \let\t=\indexdummyfont
2776 \let\r=\indexdummyfont
2777 \let\i=\indexdummyfont
2778 \let\b=\indexdummyfont
2779 \let\emph=\indexdummyfont
2780 \let\strong=\indexdummyfont
2781 \let\cite=\indexdummyfont
2782 \let\sc=\indexdummyfont
2783 %Don't no-op \tt, since it isn't a user-level command
2784 % and is used in the definitions of the active chars like <, >, |...
2785 %\let\tt=\indexdummyfont
2786 \let\tclose=\indexdummyfont
2787 \let\code=\indexdummyfont
2788 \let\url=\indexdummyfont
2789 \let\uref=\indexdummyfont
2790 \let\env=\indexdummyfont
2791 \let\acronym=\indexdummyfont
2792 \let\command=\indexdummyfont
2793 \let\option=\indexdummyfont
2794 \let\file=\indexdummyfont
2795 \let\samp=\indexdummyfont
2796 \let\kbd=\indexdummyfont
2797 \let\key=\indexdummyfont
2798 \let\var=\indexdummyfont
2799 \let\TeX=\indexdummytex
2800 \let\dots=\indexdummydots
2801 \def\@{@}%
2802 }
2803
2804 % To define \realbackslash, we must make \ not be an escape.
2805 % We must first make another character (@) an escape
2806 % so we do not become unable to do a definition.
2807
2808 {\catcode`\@=0 \catcode`\\=\other
2809  @gdef@realbackslash{\}}
2810
2811 \let\indexbackslash=0  %overridden during \printindex.
2812 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
2813
2814 % For \ifx comparisons.
2815 \def\emptymacro{\empty}
2816
2817 % Most index entries go through here, but \dosubind is the general case.
2818 %
2819 \def\doind#1#2{\dosubind{#1}{#2}\empty}
2820
2821 % Workhorse for all \fooindexes.
2822 % #1 is name of index, #2 is stuff to put there, #3 is subentry --
2823 % \empty if called from \doind, as we usually are.  The main exception
2824 % is with defuns, which call us directly.
2825 %
2826 \def\dosubind#1#2#3{%
2827   % Put the index entry in the margin if desired.
2828   \ifx\SETmarginindex\relax\else
2829     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}%
2830   \fi
2831   {%
2832     \count255=\lastpenalty
2833     {%
2834       \indexdummies % Must do this here, since \bf, etc expand at this stage
2835       \escapechar=`\\
2836       {%
2837         \let\folio = 0% We will expand all macros now EXCEPT \folio.
2838         \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
2839         % so it will be output as is; and it will print as backslash.
2840         %
2841         \def\thirdarg{#3}%
2842         %
2843         % If third arg is present, precede it with space in sort key.
2844         \ifx\thirdarg\emptymacro
2845           \let\subentry = \empty
2846         \else
2847           \def\subentry{ #3}%
2848         \fi
2849         %
2850         % First process the index entry with all font commands turned
2851         % off to get the string to sort by.
2852         {\indexnofonts \xdef\indexsorttmp{#2\subentry}}%
2853         %
2854         % Now the real index entry with the fonts.
2855         \toks0 = {#2}%
2856         %
2857         % If third (subentry) arg is present, add it to the index
2858         % string.  And include a space.
2859         \ifx\thirdarg\emptymacro \else
2860           \toks0 = \expandafter{\the\toks0 \space #3}%
2861         \fi
2862         %
2863         % Set up the complete index entry, with both the sort key
2864         % and the original text, including any font commands.  We write
2865         % three arguments to \entry to the .?? file, texindex reduces to
2866         % two when writing the .??s sorted result.
2867         \edef\temp{%
2868           \write\csname#1indfile\endcsname{%
2869             \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}%
2870         }%
2871         %
2872         % If a skip is the last thing on the list now, preserve it
2873         % by backing up by \lastskip, doing the \write, then inserting
2874         % the skip again.  Otherwise, the whatsit generated by the
2875         % \write will make \lastskip zero.  The result is that sequences
2876         % like this:
2877         % @end defun
2878         % @tindex whatever
2879         % @defun ...
2880         % will have extra space inserted, because the \medbreak in the
2881         % start of the @defun won't see the skip inserted by the @end of
2882         % the previous defun.
2883         %
2884         % But don't do any of this if we're not in vertical mode.  We
2885         % don't want to do a \vskip and prematurely end a paragraph.
2886         %
2887         % Avoid page breaks due to these extra skips, too.
2888         %
2889         \iflinks
2890           \ifvmode
2891             \skip0 = \lastskip
2892             \ifdim\lastskip = 0pt \else \nobreak\vskip-\lastskip \fi
2893           \fi
2894           %
2895           \temp % do the write
2896           %
2897           %
2898           \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi
2899         \fi
2900       }%
2901     }%
2902     \penalty\count255
2903   }%
2904 }
2905
2906 % The index entry written in the file actually looks like
2907 %  \entry {sortstring}{page}{topic}
2908 % or
2909 %  \entry {sortstring}{page}{topic}{subtopic}
2910 % The texindex program reads in these files and writes files
2911 % containing these kinds of lines:
2912 %  \initial {c}
2913 %     before the first topic whose initial is c
2914 %  \entry {topic}{pagelist}
2915 %     for a topic that is used without subtopics
2916 %  \primary {topic}
2917 %     for the beginning of a topic that is used with subtopics
2918 %  \secondary {subtopic}{pagelist}
2919 %     for each subtopic.
2920
2921 % Define the user-accessible indexing commands
2922 % @findex, @vindex, @kindex, @cindex.
2923
2924 \def\findex {\fnindex}
2925 \def\kindex {\kyindex}
2926 \def\cindex {\cpindex}
2927 \def\vindex {\vrindex}
2928 \def\tindex {\tpindex}
2929 \def\pindex {\pgindex}
2930
2931 \def\cindexsub {\begingroup\obeylines\cindexsub}
2932 {\obeylines %
2933 \gdef\cindexsub "#1" #2^^M{\endgroup %
2934 \dosubind{cp}{#2}{#1}}}
2935
2936 % Define the macros used in formatting output of the sorted index material.
2937
2938 % @printindex causes a particular index (the ??s file) to get printed.
2939 % It does not print any chapter heading (usually an @unnumbered).
2940 %
2941 \def\printindex{\parsearg\doprintindex}
2942 \def\doprintindex#1{\begingroup
2943   \dobreak \chapheadingskip{10000}%
2944   %
2945   \smallfonts \rm
2946   \tolerance = 9500
2947   \indexbreaks
2948   %
2949   % See if the index file exists and is nonempty.
2950   % Change catcode of @ here so that if the index file contains
2951   % \initial {@}
2952   % as its first line, TeX doesn't complain about mismatched braces
2953   % (because it thinks @} is a control sequence).
2954   \catcode`\@ = 11
2955   \openin 1 \jobname.#1s
2956   \ifeof 1
2957     % \enddoublecolumns gets confused if there is no text in the index,
2958     % and it loses the chapter title and the aux file entries for the
2959     % index.  The easiest way to prevent this problem is to make sure
2960     % there is some text.
2961     \putwordIndexNonexistent
2962   \else
2963     %
2964     % If the index file exists but is empty, then \openin leaves \ifeof
2965     % false.  We have to make TeX try to read something from the file, so
2966     % it can discover if there is anything in it.
2967     \read 1 to \temp
2968     \ifeof 1
2969       \putwordIndexIsEmpty
2970     \else
2971       % Index files are almost Texinfo source, but we use \ as the escape
2972       % character.  It would be better to use @, but that's too big a change
2973       % to make right now.
2974       \def\indexbackslash{\rawbackslashxx}%
2975       \catcode`\\ = 0
2976       \escapechar = `\\
2977       \begindoublecolumns
2978       \input \jobname.#1s
2979       \enddoublecolumns
2980     \fi
2981   \fi
2982   \closein 1
2983 \endgroup}
2984
2985 % These macros are used by the sorted index file itself.
2986 % Change them to control the appearance of the index.
2987
2988 \def\initial#1{{%
2989   % Some minor font changes for the special characters.
2990   \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
2991   %
2992   % Remove any glue we may have, we'll be inserting our own.
2993   \removelastskip
2994   %
2995   % We like breaks before the index initials, so insert a bonus.
2996   \penalty -300
2997   %
2998   % Typeset the initial.  Making this add up to a whole number of
2999   % baselineskips increases the chance of the dots lining up from column
3000   % to column.  It still won't often be perfect, because of the stretch
3001   % we need before each entry, but it's better.
3002   %
3003   % No shrink because it confuses \balancecolumns.
3004   \vskip 1.67\baselineskip plus .5\baselineskip
3005   \leftline{\secbf #1}%
3006   \vskip .33\baselineskip plus .1\baselineskip
3007   %
3008   % Do our best not to break after the initial.
3009   \nobreak
3010 }}
3011
3012 % This typesets a paragraph consisting of #1, dot leaders, and then #2
3013 % flush to the right margin.  It is used for index and table of contents
3014 % entries.  The paragraph is indented by \leftskip.
3015 %
3016 \def\entry#1#2{\begingroup
3017   %
3018   % Start a new paragraph if necessary, so our assignments below can't
3019   % affect previous text.
3020   \par
3021   %
3022   % Do not fill out the last line with white space.
3023   \parfillskip = 0in
3024   %
3025   % No extra space above this paragraph.
3026   \parskip = 0in
3027   %
3028   % Do not prefer a separate line ending with a hyphen to fewer lines.
3029   \finalhyphendemerits = 0
3030   %
3031   % \hangindent is only relevant when the entry text and page number
3032   % don't both fit on one line.  In that case, bob suggests starting the
3033   % dots pretty far over on the line.  Unfortunately, a large
3034   % indentation looks wrong when the entry text itself is broken across
3035   % lines.  So we use a small indentation and put up with long leaders.
3036   %
3037   % \hangafter is reset to 1 (which is the value we want) at the start
3038   % of each paragraph, so we need not do anything with that.
3039   \hangindent = 2em
3040   %
3041   % When the entry text needs to be broken, just fill out the first line
3042   % with blank space.
3043   \rightskip = 0pt plus1fil
3044   %
3045   % A bit of stretch before each entry for the benefit of balancing columns.
3046   \vskip 0pt plus1pt
3047   %
3048   % Start a ``paragraph'' for the index entry so the line breaking
3049   % parameters we've set above will have an effect.
3050   \noindent
3051   %
3052   % Insert the text of the index entry.  TeX will do line-breaking on it.
3053   #1%
3054   % The following is kludged to not output a line of dots in the index if
3055   % there are no page numbers.  The next person who breaks this will be
3056   % cursed by a Unix daemon.
3057   \def\tempa{{\rm }}%
3058   \def\tempb{#2}%
3059   \edef\tempc{\tempa}%
3060   \edef\tempd{\tempb}%
3061   \ifx\tempc\tempd\ \else%
3062     %
3063     % If we must, put the page number on a line of its own, and fill out
3064     % this line with blank space.  (The \hfil is overwhelmed with the
3065     % fill leaders glue in \indexdotfill if the page number does fit.)
3066     \hfil\penalty50
3067     \null\nobreak\indexdotfill % Have leaders before the page number.
3068     %
3069     % The `\ ' here is removed by the implicit \unskip that TeX does as
3070     % part of (the primitive) \par.  Without it, a spurious underfull
3071     % \hbox ensues.
3072     \ifpdf
3073       \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
3074     \else
3075       \ #2% The page number ends the paragraph.
3076     \fi
3077   \fi%
3078   \par
3079 \endgroup}
3080
3081 % Like \dotfill except takes at least 1 em.
3082 \def\indexdotfill{\cleaders
3083   \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
3084
3085 \def\primary #1{\line{#1\hfil}}
3086
3087 \newskip\secondaryindent \secondaryindent=0.5cm
3088
3089 \def\secondary #1#2{
3090 {\parfillskip=0in \parskip=0in
3091 \hangindent =1in \hangafter=1
3092 \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
3093 }}
3094
3095 % Define two-column mode, which we use to typeset indexes.
3096 % Adapted from the TeXbook, page 416, which is to say,
3097 % the manmac.tex format used to print the TeXbook itself.
3098 \catcode`\@=11
3099
3100 \newbox\partialpage
3101 \newdimen\doublecolumnhsize
3102
3103 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
3104   % Grab any single-column material above us.
3105   \output = {%
3106     %
3107     % Here is a possibility not foreseen in manmac: if we accumulate a
3108     % whole lot of material, we might end up calling this \output
3109     % routine twice in a row (see the doublecol-lose test, which is
3110     % essentially a couple of indexes with @setchapternewpage off).  In
3111     % that case we just ship out what is in \partialpage with the normal
3112     % output routine.  Generally, \partialpage will be empty when this
3113     % runs and this will be a no-op.  See the indexspread.tex test case.
3114     \ifvoid\partialpage \else
3115       \onepageout{\pagecontents\partialpage}%
3116     \fi
3117     %
3118     \global\setbox\partialpage = \vbox{%
3119       % Unvbox the main output page.
3120       \unvbox\PAGE
3121       \kern-\topskip \kern\baselineskip
3122     }%
3123   }%
3124   \eject % run that output routine to set \partialpage
3125   %
3126   % Use the double-column output routine for subsequent pages.
3127   \output = {\doublecolumnout}%
3128   %
3129   % Change the page size parameters.  We could do this once outside this
3130   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
3131   % format, but then we repeat the same computation.  Repeating a couple
3132   % of assignments once per index is clearly meaningless for the
3133   % execution time, so we may as well do it in one place.
3134   %
3135   % First we halve the line length, less a little for the gutter between
3136   % the columns.  We compute the gutter based on the line length, so it
3137   % changes automatically with the paper format.  The magic constant
3138   % below is chosen so that the gutter has the same value (well, +-<1pt)
3139   % as it did when we hard-coded it.
3140   %
3141   % We put the result in a separate register, \doublecolumhsize, so we
3142   % can restore it in \pagesofar, after \hsize itself has (potentially)
3143   % been clobbered.
3144   %
3145   \doublecolumnhsize = \hsize
3146     \advance\doublecolumnhsize by -.04154\hsize
3147     \divide\doublecolumnhsize by 2
3148   \hsize = \doublecolumnhsize
3149   %
3150   % Double the \vsize as well.  (We don't need a separate register here,
3151   % since nobody clobbers \vsize.)
3152   \advance\vsize by -\ht\partialpage
3153   \vsize = 2\vsize
3154 }
3155
3156 % The double-column output routine for all double-column pages except
3157 % the last.
3158 %
3159 \def\doublecolumnout{%
3160   \splittopskip=\topskip \splitmaxdepth=\maxdepth
3161   % Get the available space for the double columns -- the normal
3162   % (undoubled) page height minus any material left over from the
3163   % previous page.
3164   \dimen@ = \vsize
3165   \divide\dimen@ by 2
3166   %
3167   % box0 will be the left-hand column, box2 the right.
3168   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
3169   \onepageout\pagesofar
3170   \unvbox255
3171   \penalty\outputpenalty
3172 }
3173 \def\pagesofar{%
3174   % Re-output the contents of the output page -- any previous material,
3175   % followed by the two boxes we just split, in box0 and box2.
3176   \unvbox\partialpage
3177   %
3178   \hsize = \doublecolumnhsize
3179   \wd0=\hsize \wd2=\hsize
3180   \hbox to\pagewidth{\box0\hfil\box2}%
3181 }
3182 \def\enddoublecolumns{%
3183   \output = {%
3184     % Split the last of the double-column material.  Leave it on the
3185     % current page, no automatic page break.
3186     \balancecolumns
3187     %
3188     % If we end up splitting too much material for the current page,
3189     % though, there will be another page break right after this \output
3190     % invocation ends.  Having called \balancecolumns once, we do not
3191     % want to call it again.  Therefore, reset \output to its normal
3192     % definition right away.  (We hope \balancecolumns will never be
3193     % called on to balance too much material, but if it is, this makes
3194     % the output somewhat more palatable.)
3195     \global\output = {\onepageout{\pagecontents\PAGE}}%
3196   }%
3197   \eject
3198   \endgroup % started in \begindoublecolumns
3199   %
3200   % \pagegoal was set to the doubled \vsize above, since we restarted
3201   % the current page.  We're now back to normal single-column
3202   % typesetting, so reset \pagegoal to the normal \vsize (after the
3203   % \endgroup where \vsize got restored).
3204   \pagegoal = \vsize
3205 }
3206 \def\balancecolumns{%
3207   % Called at the end of the double column material.
3208   \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
3209   \dimen@ = \ht0
3210   \advance\dimen@ by \topskip
3211   \advance\dimen@ by-\baselineskip
3212   \divide\dimen@ by 2 % target to split to
3213   %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}%
3214   \splittopskip = \topskip
3215   % Loop until we get a decent breakpoint.
3216   {%
3217     \vbadness = 10000
3218     \loop
3219       \global\setbox3 = \copy0
3220       \global\setbox1 = \vsplit3 to \dimen@
3221     \ifdim\ht3>\dimen@
3222       \global\advance\dimen@ by 1pt
3223     \repeat
3224   }%
3225   %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
3226   \setbox0=\vbox to\dimen@{\unvbox1}%
3227   \setbox2=\vbox to\dimen@{\unvbox3}%
3228   %
3229   \pagesofar
3230 }
3231 \catcode`\@ = \other
3232
3233
3234 \message{sectioning,}
3235 % Chapters, sections, etc.
3236
3237 \newcount\chapno
3238 \newcount\secno        \secno=0
3239 \newcount\subsecno     \subsecno=0
3240 \newcount\subsubsecno  \subsubsecno=0
3241
3242 % This counter is funny since it counts through charcodes of letters A, B, ...
3243 \newcount\appendixno  \appendixno = `\@
3244 % \def\appendixletter{\char\the\appendixno}
3245 % We do the following for the sake of pdftex, which needs the actual
3246 % letter in the expansion, not just typeset.
3247 \def\appendixletter{%
3248   \ifnum\appendixno=`A A%
3249   \else\ifnum\appendixno=`B B%
3250   \else\ifnum\appendixno=`C C%
3251   \else\ifnum\appendixno=`D D%
3252   \else\ifnum\appendixno=`E E%
3253   \else\ifnum\appendixno=`F F%
3254   \else\ifnum\appendixno=`G G%
3255   \else\ifnum\appendixno=`H H%
3256   \else\ifnum\appendixno=`I I%
3257   \else\ifnum\appendixno=`J J%
3258   \else\ifnum\appendixno=`K K%
3259   \else\ifnum\appendixno=`L L%
3260   \else\ifnum\appendixno=`M M%
3261   \else\ifnum\appendixno=`N N%
3262   \else\ifnum\appendixno=`O O%
3263   \else\ifnum\appendixno=`P P%
3264   \else\ifnum\appendixno=`Q Q%
3265   \else\ifnum\appendixno=`R R%
3266   \else\ifnum\appendixno=`S S%
3267   \else\ifnum\appendixno=`T T%
3268   \else\ifnum\appendixno=`U U%
3269   \else\ifnum\appendixno=`V V%
3270   \else\ifnum\appendixno=`W W%
3271   \else\ifnum\appendixno=`X X%
3272   \else\ifnum\appendixno=`Y Y%
3273   \else\ifnum\appendixno=`Z Z%
3274   % The \the is necessary, despite appearances, because \appendixletter is
3275   % expanded while writing the .toc file.  \char\appendixno is not
3276   % expandable, thus it is written literally, thus all appendixes come out
3277   % with the same letter (or @) in the toc without it.
3278   \else\char\the\appendixno
3279   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
3280   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
3281
3282 % Each @chapter defines this as the name of the chapter.
3283 % page headings and footings can use it.  @section does likewise.
3284 \def\thischapter{}
3285 \def\thissection{}
3286
3287 \newcount\absseclevel % used to calculate proper heading level
3288 \newcount\secbase\secbase=0 % @raise/lowersections modify this count
3289
3290 % @raisesections: treat @section as chapter, @subsection as section, etc.
3291 \def\raisesections{\global\advance\secbase by -1}
3292 \let\up=\raisesections % original BFox name
3293
3294 % @lowersections: treat @chapter as section, @section as subsection, etc.
3295 \def\lowersections{\global\advance\secbase by 1}
3296 \let\down=\lowersections % original BFox name
3297
3298 % Choose a numbered-heading macro
3299 % #1 is heading level if unmodified by @raisesections or @lowersections
3300 % #2 is text for heading
3301 \def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
3302 \ifcase\absseclevel
3303   \chapterzzz{#2}
3304 \or
3305   \seczzz{#2}
3306 \or
3307   \numberedsubseczzz{#2}
3308 \or
3309   \numberedsubsubseczzz{#2}
3310 \else
3311   \ifnum \absseclevel<0
3312     \chapterzzz{#2}
3313   \else
3314     \numberedsubsubseczzz{#2}
3315   \fi
3316 \fi
3317 }
3318
3319 % like \numhead, but chooses appendix heading levels
3320 \def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
3321 \ifcase\absseclevel
3322   \appendixzzz{#2}
3323 \or
3324   \appendixsectionzzz{#2}
3325 \or
3326   \appendixsubseczzz{#2}
3327 \or
3328   \appendixsubsubseczzz{#2}
3329 \else
3330   \ifnum \absseclevel<0
3331     \appendixzzz{#2}
3332   \else
3333     \appendixsubsubseczzz{#2}
3334   \fi
3335 \fi
3336 }
3337
3338 % like \numhead, but chooses numberless heading levels
3339 \def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
3340 \ifcase\absseclevel
3341   \unnumberedzzz{#2}
3342 \or
3343   \unnumberedseczzz{#2}
3344 \or
3345   \unnumberedsubseczzz{#2}
3346 \or
3347   \unnumberedsubsubseczzz{#2}
3348 \else
3349   \ifnum \absseclevel<0
3350     \unnumberedzzz{#2}
3351   \else
3352     \unnumberedsubsubseczzz{#2}
3353   \fi
3354 \fi
3355 }
3356
3357 % @chapter, @appendix, @unnumbered.
3358 \def\thischaptername{No Chapter Title}
3359 \outer\def\chapter{\parsearg\chapteryyy}
3360 \def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
3361 \def\chapterzzz #1{%
3362 \secno=0 \subsecno=0 \subsubsecno=0
3363 \global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}%
3364 \chapmacro {#1}{\the\chapno}%
3365 \gdef\thissection{#1}%
3366 \gdef\thischaptername{#1}%
3367 % We don't substitute the actual chapter name into \thischapter
3368 % because we don't want its macros evaluated now.
3369 \xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
3370 \toks0 = {#1}%
3371 \edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
3372                                   {\the\chapno}}}%
3373 \temp
3374 \donoderef
3375 \global\let\section = \numberedsec
3376 \global\let\subsection = \numberedsubsec
3377 \global\let\subsubsection = \numberedsubsubsec
3378 }
3379
3380 \outer\def\appendix{\parsearg\appendixyyy}
3381 \def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
3382 \def\appendixzzz #1{%
3383 \secno=0 \subsecno=0 \subsubsecno=0
3384 \global\advance \appendixno by 1
3385 \message{\putwordAppendix\space \appendixletter}%
3386 \chapmacro {#1}{\putwordAppendix{} \appendixletter}%
3387 \gdef\thissection{#1}%
3388 \gdef\thischaptername{#1}%
3389 \xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
3390 \toks0 = {#1}%
3391 \edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
3392                        {\putwordAppendix{} \appendixletter}}}%
3393 \temp
3394 \appendixnoderef
3395 \global\let\section = \appendixsec
3396 \global\let\subsection = \appendixsubsec
3397 \global\let\subsubsection = \appendixsubsubsec
3398 }
3399
3400 % @centerchap is like @unnumbered, but the heading is centered.
3401 \outer\def\centerchap{\parsearg\centerchapyyy}
3402 \def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}}
3403
3404 % @top is like @unnumbered.
3405 \outer\def\top{\parsearg\unnumberedyyy}
3406
3407 \outer\def\unnumbered{\parsearg\unnumberedyyy}
3408 \def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
3409 \def\unnumberedzzz #1{%
3410 \secno=0 \subsecno=0 \subsubsecno=0
3411 %
3412 % This used to be simply \message{#1}, but TeX fully expands the
3413 % argument to \message.  Therefore, if #1 contained @-commands, TeX
3414 % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
3415 % expanded @cite (which turns out to cause errors because \cite is meant
3416 % to be executed, not expanded).
3417 %
3418 % Anyway, we don't want the fully-expanded definition of @cite to appear
3419 % as a result of the \message, we just want `@cite' itself.  We use
3420 % \the<toks register> to achieve this: TeX expands \the<toks> only once,
3421 % simply yielding the contents of <toks register>.  (We also do this for
3422 % the toc entries.)
3423 \toks0 = {#1}\message{(\the\toks0)}%
3424 %
3425 \unnumbchapmacro {#1}%
3426 \gdef\thischapter{#1}\gdef\thissection{#1}%
3427 \toks0 = {#1}%
3428 \edef\temp{\noexpand\writetocentry{\realbackslash unnumbchapentry{\the\toks0}}}%
3429 \temp
3430 \unnumbnoderef
3431 \global\let\section = \unnumberedsec
3432 \global\let\subsection = \unnumberedsubsec
3433 \global\let\subsubsection = \unnumberedsubsubsec
3434 }
3435
3436 % Sections.
3437 \outer\def\numberedsec{\parsearg\secyyy}
3438 \def\secyyy #1{\numhead1{#1}} % normally calls seczzz
3439 \def\seczzz #1{%
3440 \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
3441 \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
3442 \toks0 = {#1}%
3443 \edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
3444                                   {\the\chapno}{\the\secno}}}%
3445 \temp
3446 \donoderef
3447 \nobreak
3448 }
3449
3450 \outer\def\appendixsection{\parsearg\appendixsecyyy}
3451 \outer\def\appendixsec{\parsearg\appendixsecyyy}
3452 \def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
3453 \def\appendixsectionzzz #1{%
3454 \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
3455 \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
3456 \toks0 = {#1}%
3457 \edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
3458                                   {\appendixletter}{\the\secno}}}%
3459 \temp
3460 \appendixnoderef
3461 \nobreak
3462 }
3463
3464 \outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
3465 \def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
3466 \def\unnumberedseczzz #1{%
3467 \plainsecheading {#1}\gdef\thissection{#1}%
3468 \toks0 = {#1}%
3469 \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsecentry{\the\toks0}}}%
3470 \temp
3471 \unnumbnoderef
3472 \nobreak
3473 }
3474
3475 % Subsections.
3476 \outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
3477 \def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
3478 \def\numberedsubseczzz #1{%
3479 \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
3480 \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
3481 \toks0 = {#1}%
3482 \edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
3483                                     {\the\chapno}{\the\secno}{\the\subsecno}}}%
3484 \temp
3485 \donoderef
3486 \nobreak
3487 }
3488
3489 \outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
3490 \def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
3491 \def\appendixsubseczzz #1{%
3492 \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
3493 \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
3494 \toks0 = {#1}%
3495 \edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
3496                                 {\appendixletter}{\the\secno}{\the\subsecno}}}%
3497 \temp
3498 \appendixnoderef
3499 \nobreak
3500 }
3501
3502 \outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
3503 \def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
3504 \def\unnumberedsubseczzz #1{%
3505 \plainsubsecheading {#1}\gdef\thissection{#1}%
3506 \toks0 = {#1}%
3507 \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsecentry%
3508                                     {\the\toks0}}}%
3509 \temp
3510 \unnumbnoderef
3511 \nobreak
3512 }
3513
3514 % Subsubsections.
3515 \outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
3516 \def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
3517 \def\numberedsubsubseczzz #1{%
3518 \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
3519 \subsubsecheading {#1}
3520   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
3521 \toks0 = {#1}%
3522 \edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
3523   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
3524 \temp
3525 \donoderef
3526 \nobreak
3527 }
3528
3529 \outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
3530 \def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
3531 \def\appendixsubsubseczzz #1{%
3532 \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
3533 \subsubsecheading {#1}
3534   {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
3535 \toks0 = {#1}%
3536 \edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
3537   {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
3538 \temp
3539 \appendixnoderef
3540 \nobreak
3541 }
3542
3543 \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
3544 \def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
3545 \def\unnumberedsubsubseczzz #1{%
3546 \plainsubsubsecheading {#1}\gdef\thissection{#1}%
3547 \toks0 = {#1}%
3548 \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsubsecentry%
3549                                     {\the\toks0}}}%
3550 \temp
3551 \unnumbnoderef
3552 \nobreak
3553 }
3554
3555 % These are variants which are not "outer", so they can appear in @ifinfo.
3556 % Actually, they should now be obsolete; ordinary section commands should work.
3557 \def\infotop{\parsearg\unnumberedzzz}
3558 \def\infounnumbered{\parsearg\unnumberedzzz}
3559 \def\infounnumberedsec{\parsearg\unnumberedseczzz}
3560 \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
3561 \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
3562
3563 \def\infoappendix{\parsearg\appendixzzz}
3564 \def\infoappendixsec{\parsearg\appendixseczzz}
3565 \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
3566 \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
3567
3568 \def\infochapter{\parsearg\chapterzzz}
3569 \def\infosection{\parsearg\sectionzzz}
3570 \def\infosubsection{\parsearg\subsectionzzz}
3571 \def\infosubsubsection{\parsearg\subsubsectionzzz}
3572
3573 % These macros control what the section commands do, according
3574 % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
3575 % Define them by default for a numbered chapter.
3576 \global\let\section = \numberedsec
3577 \global\let\subsection = \numberedsubsec
3578 \global\let\subsubsection = \numberedsubsubsec
3579
3580 % Define @majorheading, @heading and @subheading
3581
3582 % NOTE on use of \vbox for chapter headings, section headings, and such:
3583 %       1) We use \vbox rather than the earlier \line to permit
3584 %          overlong headings to fold.
3585 %       2) \hyphenpenalty is set to 10000 because hyphenation in a
3586 %          heading is obnoxious; this forbids it.
3587 %       3) Likewise, headings look best if no \parindent is used, and
3588 %          if justification is not attempted.  Hence \raggedright.
3589
3590
3591 \def\majorheading{\parsearg\majorheadingzzz}
3592 \def\majorheadingzzz #1{%
3593 {\advance\chapheadingskip by 10pt \chapbreak }%
3594 {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3595                   \parindent=0pt\raggedright
3596                   \rm #1\hfill}}\bigskip \par\penalty 200}
3597
3598 \def\chapheading{\parsearg\chapheadingzzz}
3599 \def\chapheadingzzz #1{\chapbreak %
3600 {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3601                   \parindent=0pt\raggedright
3602                   \rm #1\hfill}}\bigskip \par\penalty 200}
3603
3604 % @heading, @subheading, @subsubheading.
3605 \def\heading{\parsearg\plainsecheading}
3606 \def\subheading{\parsearg\plainsubsecheading}
3607 \def\subsubheading{\parsearg\plainsubsubsecheading}
3608
3609 % These macros generate a chapter, section, etc. heading only
3610 % (including whitespace, linebreaking, etc. around it),
3611 % given all the information in convenient, parsed form.
3612
3613 %%% Args are the skip and penalty (usually negative)
3614 \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
3615
3616 \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
3617
3618 %%% Define plain chapter starts, and page on/off switching for it
3619 % Parameter controlling skip before chapter headings (if needed)
3620
3621 \newskip\chapheadingskip
3622
3623 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
3624 \def\chappager{\par\vfill\supereject}
3625 \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
3626
3627 \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
3628
3629 \def\CHAPPAGoff{%
3630 \global\let\contentsalignmacro = \chappager
3631 \global\let\pchapsepmacro=\chapbreak
3632 \global\let\pagealignmacro=\chappager}
3633
3634 \def\CHAPPAGon{%
3635 \global\let\contentsalignmacro = \chappager
3636 \global\let\pchapsepmacro=\chappager
3637 \global\let\pagealignmacro=\chappager
3638 \global\def\HEADINGSon{\HEADINGSsingle}}
3639
3640 \def\CHAPPAGodd{
3641 \global\let\contentsalignmacro = \chapoddpage
3642 \global\let\pchapsepmacro=\chapoddpage
3643 \global\let\pagealignmacro=\chapoddpage
3644 \global\def\HEADINGSon{\HEADINGSdouble}}
3645
3646 \CHAPPAGon
3647
3648 \def\CHAPFplain{
3649 \global\let\chapmacro=\chfplain
3650 \global\let\unnumbchapmacro=\unnchfplain
3651 \global\let\centerchapmacro=\centerchfplain}
3652
3653 % Plain chapter opening.
3654 % #1 is the text, #2 the chapter number or empty if unnumbered.
3655 \def\chfplain#1#2{%
3656   \pchapsepmacro
3657   {%
3658     \chapfonts \rm
3659     \def\chapnum{#2}%
3660     \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}%
3661     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
3662           \hangindent = \wd0 \centerparametersmaybe
3663           \unhbox0 #1\par}%
3664   }%
3665   \nobreak\bigskip % no page break after a chapter title
3666   \nobreak
3667 }
3668
3669 % Plain opening for unnumbered.
3670 \def\unnchfplain#1{\chfplain{#1}{}}
3671
3672 % @centerchap -- centered and unnumbered.
3673 \let\centerparametersmaybe = \relax
3674 \def\centerchfplain#1{{%
3675   \def\centerparametersmaybe{%
3676     \advance\rightskip by 3\rightskip
3677     \leftskip = \rightskip
3678     \parfillskip = 0pt
3679   }%
3680   \chfplain{#1}{}%
3681 }}
3682
3683 \CHAPFplain % The default
3684
3685 \def\unnchfopen #1{%
3686 \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3687                        \parindent=0pt\raggedright
3688                        \rm #1\hfill}}\bigskip \par\nobreak
3689 }
3690
3691 \def\chfopen #1#2{\chapoddpage {\chapfonts
3692 \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
3693 \par\penalty 5000 %
3694 }
3695
3696 \def\centerchfopen #1{%
3697 \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3698                        \parindent=0pt
3699                        \hfill {\rm #1}\hfill}}\bigskip \par\nobreak
3700 }
3701
3702 \def\CHAPFopen{
3703 \global\let\chapmacro=\chfopen
3704 \global\let\unnumbchapmacro=\unnchfopen
3705 \global\let\centerchapmacro=\centerchfopen}
3706
3707
3708 % Section titles.
3709 \newskip\secheadingskip
3710 \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
3711 \def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}}
3712 \def\plainsecheading#1{\sectionheading{sec}{}{#1}}
3713
3714 % Subsection titles.
3715 \newskip \subsecheadingskip
3716 \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
3717 \def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}}
3718 \def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}}
3719
3720 % Subsubsection titles.
3721 \let\subsubsecheadingskip = \subsecheadingskip
3722 \let\subsubsecheadingbreak = \subsecheadingbreak
3723 \def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}}
3724 \def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}}
3725
3726
3727 % Print any size section title.
3728 %
3729 % #1 is the section type (sec/subsec/subsubsec), #2 is the section
3730 % number (maybe empty), #3 the text.
3731 \def\sectionheading#1#2#3{%
3732   {%
3733     \expandafter\advance\csname #1headingskip\endcsname by \parskip
3734     \csname #1headingbreak\endcsname
3735   }%
3736   {%
3737     % Switch to the right set of fonts.
3738     \csname #1fonts\endcsname \rm
3739     %
3740     % Only insert the separating space if we have a section number.
3741     \def\secnum{#2}%
3742     \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}%
3743     %
3744     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
3745           \hangindent = \wd0 % zero if no section number
3746           \unhbox0 #3}%
3747   }%
3748   \ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak
3749 }
3750
3751
3752 \message{toc,}
3753 % Table of contents.
3754 \newwrite\tocfile
3755
3756 % Write an entry to the toc file, opening it if necessary.
3757 % Called from @chapter, etc.  We supply {\folio} at the end of the
3758 % argument, which will end up as the last argument to the \...entry macro.
3759 %
3760 % We open the .toc file here instead of at @setfilename or any other
3761 % given time so that @contents can be put in the document anywhere.
3762 %
3763 \newif\iftocfileopened
3764 \def\writetocentry#1{%
3765   \iftocfileopened\else
3766     \immediate\openout\tocfile = \jobname.toc
3767     \global\tocfileopenedtrue
3768   \fi
3769   \iflinks \write\tocfile{#1{\folio}}\fi
3770 }
3771
3772 \newskip\contentsrightmargin \contentsrightmargin=1in
3773 \newcount\savepageno
3774 \newcount\lastnegativepageno \lastnegativepageno = -1
3775
3776 % Finish up the main text and prepare to read what we've written
3777 % to \tocfile.
3778 %
3779 \def\startcontents#1{%
3780    % If @setchapternewpage on, and @headings double, the contents should
3781    % start on an odd page, unlike chapters.  Thus, we maintain
3782    % \contentsalignmacro in parallel with \pagealignmacro.
3783    % From: Torbjorn Granlund <tege@matematik.su.se>
3784    \contentsalignmacro
3785    \immediate\closeout\tocfile
3786    %
3787    % Don't need to put `Contents' or `Short Contents' in the headline.
3788    % It is abundantly clear what they are.
3789    \unnumbchapmacro{#1}\def\thischapter{}%
3790    \savepageno = \pageno