update from texinfo
[pspp] / config / 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{2002-10-30.16}
7 %
8 % Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
9 % 1996, 1997, 1998, 1999, 2000, 2001, 2002 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/texinfo/texinfo.tex
35 %   ftp://tug.org/tex/texinfo.tex
36 %     (and all CTAN mirrors, see http://www.ctan.org),
37 %   and /home/gd/gnu/doc/texinfo.tex on the GNU machines.
38
39 % The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
40
41 % The texinfo.tex in any given Texinfo distribution could well be out
42 % of date, so if that's what you're using, please check.
43
44 % Send bug reports to bug-texinfo@gnu.org.  Please include including a
45 % complete document in each bug report with which we can reproduce the
46 % problem.  Patches are, of course, greatly appreciated.
47 %
48 % To process a Texinfo manual with TeX, it's most reliable to use the
49 % texi2dvi shell script that comes with the distribution.  For a simple
50 % manual foo.texi, however, you can get away with this:
51 %   tex foo.texi
52 %   texindex foo.??
53 %   tex foo.texi
54 %   tex foo.texi
55 %   dvips foo.dvi -o  # or whatever; this makes foo.ps.
56 % The extra TeX runs get the cross-reference information correct.
57 % Sometimes one run after texindex suffices, and sometimes you need more
58 % than two; texi2dvi does it as many times as necessary.
59 %
60 % It is possible to adapt texinfo.tex for other languages.  You can get
61 % the existing language-specific files from the full Texinfo distribution.
62
63 \message{Loading texinfo [version \texinfoversion]:}
64
65 % If in a .fmt file, print the version number
66 % and turn on active characters that we couldn't do earlier because
67 % they might have appeared in the input file name.
68 \everyjob{\message{[Texinfo version \texinfoversion]}%
69   \catcode`+=\active \catcode`\_=\active}
70
71 % Save some parts of plain tex whose names we will redefine.
72 \let\ptexb=\b
73 \let\ptexbullet=\bullet
74 \let\ptexc=\c
75 \let\ptexcomma=\,
76 \let\ptexdot=\.
77 \let\ptexdots=\dots
78 \let\ptexend=\end
79 \let\ptexequiv=\equiv
80 \let\ptexexclam=\!
81 \let\ptexi=\i
82 \let\ptexlbrace=\{
83 \let\ptexrbrace=\}
84 \let\ptexstar=\*
85 \let\ptext=\t
86
87 % We never want plain's outer \+ definition in Texinfo.
88 % For @tex, we can use \tabalign.
89 \let\+ = \relax
90
91 \message{Basics,}
92 \chardef\other=12
93
94 % If this character appears in an error message or help string, it
95 % starts a new line in the output.
96 \newlinechar = `^^J
97
98 % Set up fixed words for English if not already set.
99 \ifx\putwordAppendix\undefined  \gdef\putwordAppendix{Appendix}\fi
100 \ifx\putwordChapter\undefined   \gdef\putwordChapter{Chapter}\fi
101 \ifx\putwordfile\undefined      \gdef\putwordfile{file}\fi
102 \ifx\putwordin\undefined        \gdef\putwordin{in}\fi
103 \ifx\putwordIndexIsEmpty\undefined     \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
104 \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
105 \ifx\putwordInfo\undefined      \gdef\putwordInfo{Info}\fi
106 \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
107 \ifx\putwordMethodon\undefined  \gdef\putwordMethodon{Method on}\fi
108 \ifx\putwordNoTitle\undefined   \gdef\putwordNoTitle{No Title}\fi
109 \ifx\putwordof\undefined        \gdef\putwordof{of}\fi
110 \ifx\putwordon\undefined        \gdef\putwordon{on}\fi
111 \ifx\putwordpage\undefined      \gdef\putwordpage{page}\fi
112 \ifx\putwordsection\undefined   \gdef\putwordsection{section}\fi
113 \ifx\putwordSection\undefined   \gdef\putwordSection{Section}\fi
114 \ifx\putwordsee\undefined       \gdef\putwordsee{see}\fi
115 \ifx\putwordSee\undefined       \gdef\putwordSee{See}\fi
116 \ifx\putwordShortTOC\undefined  \gdef\putwordShortTOC{Short Contents}\fi
117 \ifx\putwordTOC\undefined       \gdef\putwordTOC{Table of Contents}\fi
118 %
119 \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
120 \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
121 \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
122 \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
123 \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
124 \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
125 \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
126 \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
127 \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
128 \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
129 \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
130 \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
131 %
132 \ifx\putwordDefmac\undefined    \gdef\putwordDefmac{Macro}\fi
133 \ifx\putwordDefspec\undefined   \gdef\putwordDefspec{Special Form}\fi
134 \ifx\putwordDefvar\undefined    \gdef\putwordDefvar{Variable}\fi
135 \ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
136 \ifx\putwordDeftypevar\undefined\gdef\putwordDeftypevar{Variable}\fi
137 \ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
138 \ifx\putwordDeftypefun\undefined\gdef\putwordDeftypefun{Function}\fi
139
140 % Ignore a token.
141 %
142 \def\gobble#1{}
143
144 % True if #1 is the empty string, i.e., called like `\ifempty{}'.
145 %
146 \def\ifempty#1{\ifemptyx #1\emptymarkA\emptymarkB}%
147 \def\ifemptyx#1#2\emptymarkB{\ifx #1\emptymarkA}%
148
149 % Hyphenation fixes.
150 \hyphenation{ap-pen-dix}
151 \hyphenation{mini-buf-fer mini-buf-fers}
152 \hyphenation{eshell}
153 \hyphenation{white-space}
154
155 % Margin to add to right of even pages, to left of odd pages.
156 \newdimen\bindingoffset
157 \newdimen\normaloffset
158 \newdimen\pagewidth \newdimen\pageheight
159
160 % Sometimes it is convenient to have everything in the transcript file
161 % and nothing on the terminal.  We don't just call \tracingall here,
162 % since that produces some useless output on the terminal.  We also make
163 % some effort to order the tracing commands to reduce output in the log
164 % file; cf. trace.sty in LaTeX.
165 %
166 \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
167 \def\loggingall{%
168   \tracingstats2
169   \tracingpages1
170   \tracinglostchars2  % 2 gives us more in etex
171   \tracingparagraphs1
172   \tracingoutput1
173   \tracingmacros2
174   \tracingrestores1
175   \showboxbreadth\maxdimen \showboxdepth\maxdimen
176   \ifx\eTeXversion\undefined\else % etex gives us more logging
177     \tracingscantokens1
178     \tracingifs1
179     \tracinggroups1
180     \tracingnesting2
181     \tracingassigns1
182   \fi
183   \tracingcommands3  % 3 gives us more in etex
184   \errorcontextlines\maxdimen
185 }%
186
187 % add check for \lastpenalty to plain's definitions.  If the last thing
188 % we did was a \nobreak, we don't want to insert more space.
189
190 \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
191   \removelastskip\penalty-50\smallskip\fi\fi}
192 \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
193   \removelastskip\penalty-100\medskip\fi\fi}
194 \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
195   \removelastskip\penalty-200\bigskip\fi\fi}
196
197 % For @cropmarks command.
198 % Do @cropmarks to get crop marks.
199 %
200 \newif\ifcropmarks
201 \let\cropmarks = \cropmarkstrue
202 %
203 % Dimensions to add cropmarks at corners.
204 % Added by P. A. MacKay, 12 Nov. 1986
205 %
206 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
207 \newdimen\cornerlong  \cornerlong=1pc
208 \newdimen\cornerthick \cornerthick=.3pt
209 \newdimen\topandbottommargin \topandbottommargin=.75in
210
211 % Main output routine.
212 \chardef\PAGE = 255
213 \output = {\onepageout{\pagecontents\PAGE}}
214
215 \newbox\headlinebox
216 \newbox\footlinebox
217
218 % \onepageout takes a vbox as an argument.  Note that \pagecontents
219 % does insertions, but you have to call it yourself.
220 \def\onepageout#1{%
221   \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
222   %
223   \ifodd\pageno  \advance\hoffset by \bindingoffset
224   \else \advance\hoffset by -\bindingoffset\fi
225   %
226   % Do this outside of the \shipout so @code etc. will be expanded in
227   % the headline as they should be, not taken literally (outputting ''code).
228   \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
229   \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
230   %
231   {%
232     % Have to do this stuff outside the \shipout because we want it to
233     % take effect in \write's, yet the group defined by the \vbox ends
234     % before the \shipout runs.
235     %
236     \escapechar = `\\     % use backslash in output files.
237     \indexdummies         % don't expand commands in the output.
238     \normalturnoffactive  % \ in index entries must not stay \, e.g., if
239                    % the page break happens to be in the middle of an example.
240     \shipout\vbox{%
241       % Do this early so pdf references go to the beginning of the page.
242       \ifpdfmakepagedest \pdfmkdest{\the\pageno} \fi
243       %
244       \ifcropmarks \vbox to \outervsize\bgroup
245         \hsize = \outerhsize
246         \vskip-\topandbottommargin
247         \vtop to0pt{%
248           \line{\ewtop\hfil\ewtop}%
249           \nointerlineskip
250           \line{%
251             \vbox{\moveleft\cornerthick\nstop}%
252             \hfill
253             \vbox{\moveright\cornerthick\nstop}%
254           }%
255           \vss}%
256         \vskip\topandbottommargin
257         \line\bgroup
258           \hfil % center the page within the outer (page) hsize.
259           \ifodd\pageno\hskip\bindingoffset\fi
260           \vbox\bgroup
261       \fi
262       %
263       \unvbox\headlinebox
264       \pagebody{#1}%
265       \ifdim\ht\footlinebox > 0pt
266         % Only leave this space if the footline is nonempty.
267         % (We lessened \vsize for it in \oddfootingxxx.)
268         % The \baselineskip=24pt in plain's \makefootline has no effect.
269         \vskip 2\baselineskip
270         \unvbox\footlinebox
271       \fi
272       %
273       \ifcropmarks
274           \egroup % end of \vbox\bgroup
275         \hfil\egroup % end of (centering) \line\bgroup
276         \vskip\topandbottommargin plus1fill minus1fill
277         \boxmaxdepth = \cornerthick
278         \vbox to0pt{\vss
279           \line{%
280             \vbox{\moveleft\cornerthick\nsbot}%
281             \hfill
282             \vbox{\moveright\cornerthick\nsbot}%
283           }%
284           \nointerlineskip
285           \line{\ewbot\hfil\ewbot}%
286         }%
287       \egroup % \vbox from first cropmarks clause
288       \fi
289     }% end of \shipout\vbox
290   }% end of group with \turnoffactive
291   \advancepageno
292   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
293 }
294
295 \newinsert\margin \dimen\margin=\maxdimen
296
297 \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
298 {\catcode`\@ =11
299 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
300 % marginal hacks, juha@viisa.uucp (Juha Takala)
301 \ifvoid\margin\else % marginal info is present
302   \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
303 \dimen@=\dp#1 \unvbox#1
304 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
305 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
306 }
307
308 % Here are the rules for the cropmarks.  Note that they are
309 % offset so that the space between them is truly \outerhsize or \outervsize
310 % (P. A. MacKay, 12 November, 1986)
311 %
312 \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
313 \def\nstop{\vbox
314   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
315 \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
316 \def\nsbot{\vbox
317   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
318
319 % Parse an argument, then pass it to #1.  The argument is the rest of
320 % the input line (except we remove a trailing comment).  #1 should be a
321 % macro which expects an ordinary undelimited TeX argument.
322 %
323 \def\parsearg#1{%
324   \let\next = #1%
325   \begingroup
326     \obeylines
327     \futurelet\temp\parseargx
328 }
329
330 % If the next token is an obeyed space (from an @example environment or
331 % the like), remove it and recurse.  Otherwise, we're done.
332 \def\parseargx{%
333   % \obeyedspace is defined far below, after the definition of \sepspaces.
334   \ifx\obeyedspace\temp
335     \expandafter\parseargdiscardspace
336   \else
337     \expandafter\parseargline
338   \fi
339 }
340
341 % Remove a single space (as the delimiter token to the macro call).
342 {\obeyspaces %
343  \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
344
345 {\obeylines %
346   \gdef\parseargline#1^^M{%
347     \endgroup % End of the group started in \parsearg.
348     %
349     % First remove any @c comment, then any @comment.
350     % Result of each macro is put in \toks0.
351     \argremovec #1\c\relax %
352     \expandafter\argremovecomment \the\toks0 \comment\relax %
353     %
354     % Call the caller's macro, saved as \next in \parsearg.
355     \expandafter\next\expandafter{\the\toks0}%
356   }%
357 }
358
359 % Since all \c{,omment} does is throw away the argument, we can let TeX
360 % do that for us.  The \relax here is matched by the \relax in the call
361 % in \parseargline; it could be more or less anything, its purpose is
362 % just to delimit the argument to the \c.
363 \def\argremovec#1\c#2\relax{\toks0 = {#1}}
364 \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
365
366 % \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
367 %    @end itemize  @c foo
368 % will have two active spaces as part of the argument with the
369 % `itemize'.  Here we remove all active spaces from #1, and assign the
370 % result to \toks0.
371 %
372 % This loses if there are any *other* active characters besides spaces
373 % in the argument -- _ ^ +, for example -- since they get expanded.
374 % Fortunately, Texinfo does not define any such commands.  (If it ever
375 % does, the catcode of the characters in questionwill have to be changed
376 % here.)  But this means we cannot call \removeactivespaces as part of
377 % \argremovec{,omment}, since @c uses \parsearg, and thus the argument
378 % that \parsearg gets might well have any character at all in it.
379 %
380 \def\removeactivespaces#1{%
381   \begingroup
382     \ignoreactivespaces
383     \edef\temp{#1}%
384     \global\toks0 = \expandafter{\temp}%
385   \endgroup
386 }
387
388 % Change the active space to expand to nothing.
389 %
390 \begingroup
391   \obeyspaces
392   \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
393 \endgroup
394
395
396 \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
397
398 %% These are used to keep @begin/@end levels from running away
399 %% Call \inENV within environments (after a \begingroup)
400 \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
401 \def\ENVcheck{%
402 \ifENV\errmessage{Still within an environment; press RETURN to continue}
403 \endgroup\fi} % This is not perfect, but it should reduce lossage
404
405 % @begin foo  is the same as @foo, for now.
406 \newhelp\EMsimple{Press RETURN to continue.}
407
408 \outer\def\begin{\parsearg\beginxxx}
409
410 \def\beginxxx #1{%
411 \expandafter\ifx\csname #1\endcsname\relax
412 {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
413 \csname #1\endcsname\fi}
414
415 % @end foo executes the definition of \Efoo.
416 %
417 \def\end{\parsearg\endxxx}
418 \def\endxxx #1{%
419   \removeactivespaces{#1}%
420   \edef\endthing{\the\toks0}%
421   %
422   \expandafter\ifx\csname E\endthing\endcsname\relax
423     \expandafter\ifx\csname \endthing\endcsname\relax
424       % There's no \foo, i.e., no ``environment'' foo.
425       \errhelp = \EMsimple
426       \errmessage{Undefined command `@end \endthing'}%
427     \else
428       \unmatchedenderror\endthing
429     \fi
430   \else
431     % Everything's ok; the right environment has been started.
432     \csname E\endthing\endcsname
433   \fi
434 }
435
436 % There is an environment #1, but it hasn't been started.  Give an error.
437 %
438 \def\unmatchedenderror#1{%
439   \errhelp = \EMsimple
440   \errmessage{This `@end #1' doesn't have a matching `@#1'}%
441 }
442
443 % Define the control sequence \E#1 to give an unmatched @end error.
444 %
445 \def\defineunmatchedend#1{%
446   \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
447 }
448
449
450 %% Simple single-character @ commands
451
452 % @@ prints an @
453 % Kludge this until the fonts are right (grr).
454 \def\@{{\tt\char64}}
455
456 % This is turned off because it was never documented
457 % and you can use @w{...} around a quote to suppress ligatures.
458 %% Define @` and @' to be the same as ` and '
459 %% but suppressing ligatures.
460 %\def\`{{`}}
461 %\def\'{{'}}
462
463 % Used to generate quoted braces.
464 \def\mylbrace {{\tt\char123}}
465 \def\myrbrace {{\tt\char125}}
466 \let\{=\mylbrace
467 \let\}=\myrbrace
468 \begingroup
469   % Definitions to produce actual \{ & \} command in an index.
470   \catcode`\{ = 12 \catcode`\} = 12
471   \catcode`\[ = 1 \catcode`\] = 2
472   \catcode`\@ = 0 \catcode`\\ = 12
473   @gdef@lbracecmd[\{]%
474   @gdef@rbracecmd[\}]%
475 @endgroup
476
477 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
478 % Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H.
479 \let\, = \c
480 \let\dotaccent = \.
481 \def\ringaccent#1{{\accent23 #1}}
482 \let\tieaccent = \t
483 \let\ubaraccent = \b
484 \let\udotaccent = \d
485
486 % Other special characters: @questiondown @exclamdown
487 % Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss.
488 \def\questiondown{?`}
489 \def\exclamdown{!`}
490
491 % Dotless i and dotless j, used for accents.
492 \def\imacro{i}
493 \def\jmacro{j}
494 \def\dotless#1{%
495   \def\temp{#1}%
496   \ifx\temp\imacro \ptexi
497   \else\ifx\temp\jmacro \j
498   \else \errmessage{@dotless can be used only with i or j}%
499   \fi\fi
500 }
501
502 % Be sure we're in horizontal mode when doing a tie, since we make space
503 % equivalent to this in @example-like environments. Otherwise, a space
504 % at the beginning of a line will start with \penalty -- and
505 % since \penalty is valid in vertical mode, we'd end up putting the
506 % penalty on the vertical list instead of in the new paragraph.
507 {\catcode`@ = 11
508  % Avoid using \@M directly, because that causes trouble
509  % if the definition is written into an index file.
510  \global\let\tiepenalty = \@M
511  \gdef\tie{\leavevmode\penalty\tiepenalty\ }
512 }
513
514 % @: forces normal size whitespace following.
515 \def\:{\spacefactor=1000 }
516
517 % @* forces a line break.
518 \def\*{\hfil\break\hbox{}\ignorespaces}
519
520 % @. is an end-of-sentence period.
521 \def\.{.\spacefactor=3000 }
522
523 % @! is an end-of-sentence bang.
524 \def\!{!\spacefactor=3000 }
525
526 % @? is an end-of-sentence query.
527 \def\?{?\spacefactor=3000 }
528
529 % @w prevents a word break.  Without the \leavevmode, @w at the
530 % beginning of a paragraph, when TeX is still in vertical mode, would
531 % produce a whole line of output instead of starting the paragraph.
532 \def\w#1{\leavevmode\hbox{#1}}
533
534 % @group ... @end group forces ... to be all on one page, by enclosing
535 % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
536 % to keep its height that of a normal line.  According to the rules for
537 % \topskip (p.114 of the TeXbook), the glue inserted is
538 % max (\topskip - \ht (first item), 0).  If that height is large,
539 % therefore, no glue is inserted, and the space between the headline and
540 % the text is small, which looks bad.
541 %
542 \def\group{\begingroup
543   \ifnum\catcode13=\active \else
544     \errhelp = \groupinvalidhelp
545     \errmessage{@group invalid in context where filling is enabled}%
546   \fi
547   %
548   % The \vtop we start below produces a box with normal height and large
549   % depth; thus, TeX puts \baselineskip glue before it, and (when the
550   % next line of text is done) \lineskip glue after it.  (See p.82 of
551   % the TeXbook.)  Thus, space below is not quite equal to space
552   % above.  But it's pretty close.
553   \def\Egroup{%
554     \egroup           % End the \vtop.
555     \endgroup         % End the \group.
556   }%
557   %
558   \vtop\bgroup
559     % We have to put a strut on the last line in case the @group is in
560     % the midst of an example, rather than completely enclosing it.
561     % Otherwise, the interline space between the last line of the group
562     % and the first line afterwards is too small.  But we can't put the
563     % strut in \Egroup, since there it would be on a line by itself.
564     % Hence this just inserts a strut at the beginning of each line.
565     \everypar = {\strut}%
566     %
567     % Since we have a strut on every line, we don't need any of TeX's
568     % normal interline spacing.
569     \offinterlineskip
570     %
571     % OK, but now we have to do something about blank
572     % lines in the input in @example-like environments, which normally
573     % just turn into \lisppar, which will insert no space now that we've
574     % turned off the interline space.  Simplest is to make them be an
575     % empty paragraph.
576     \ifx\par\lisppar
577       \edef\par{\leavevmode \par}%
578       %
579       % Reset ^^M's definition to new definition of \par.
580       \obeylines
581     \fi
582     %
583     % Do @comment since we are called inside an environment such as
584     % @example, where each end-of-line in the input causes an
585     % end-of-line in the output.  We don't want the end-of-line after
586     % the `@group' to put extra space in the output.  Since @group
587     % should appear on a line by itself (according to the Texinfo
588     % manual), we don't worry about eating any user text.
589     \comment
590 }
591 %
592 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
593 % message, so this ends up printing `@group can only ...'.
594 %
595 \newhelp\groupinvalidhelp{%
596 group can only be used in environments such as @example,^^J%
597 where each line of input produces a line of output.}
598
599 % @need space-in-mils
600 % forces a page break if there is not space-in-mils remaining.
601
602 \newdimen\mil  \mil=0.001in
603
604 \def\need{\parsearg\needx}
605
606 % Old definition--didn't work.
607 %\def\needx #1{\par %
608 %% This method tries to make TeX break the page naturally
609 %% if the depth of the box does not fit.
610 %{\baselineskip=0pt%
611 %\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak
612 %\prevdepth=-1000pt
613 %}}
614
615 \def\needx#1{%
616   % Ensure vertical mode, so we don't make a big box in the middle of a
617   % paragraph.
618   \par
619   %
620   % If the @need value is less than one line space, it's useless.
621   \dimen0 = #1\mil
622   \dimen2 = \ht\strutbox
623   \advance\dimen2 by \dp\strutbox
624   \ifdim\dimen0 > \dimen2
625     %
626     % Do a \strut just to make the height of this box be normal, so the
627     % normal leading is inserted relative to the preceding line.
628     % And a page break here is fine.
629     \vtop to #1\mil{\strut\vfil}%
630     %
631     % TeX does not even consider page breaks if a penalty added to the
632     % main vertical list is 10000 or more.  But in order to see if the
633     % empty box we just added fits on the page, we must make it consider
634     % page breaks.  On the other hand, we don't want to actually break the
635     % page after the empty box.  So we use a penalty of 9999.
636     %
637     % There is an extremely small chance that TeX will actually break the
638     % page at this \penalty, if there are no other feasible breakpoints in
639     % sight.  (If the user is using lots of big @group commands, which
640     % almost-but-not-quite fill up a page, TeX will have a hard time doing
641     % good page breaking, for example.)  However, I could not construct an
642     % example where a page broke at this \penalty; if it happens in a real
643     % document, then we can reconsider our strategy.
644     \penalty9999
645     %
646     % Back up by the size of the box, whether we did a page break or not.
647     \kern -#1\mil
648     %
649     % Do not allow a page break right after this kern.
650     \nobreak
651   \fi
652 }
653
654 % @br   forces paragraph break
655
656 \let\br = \par
657
658 % @dots{} output an ellipsis using the current font.
659 % We do .5em per period so that it has the same spacing in a typewriter
660 % font as three actual period characters.
661 %
662 \def\dots{%
663   \leavevmode
664   \hbox to 1.5em{%
665     \hskip 0pt plus 0.25fil minus 0.25fil
666     .\hss.\hss.%
667     \hskip 0pt plus 0.5fil minus 0.5fil
668   }%
669 }
670
671 % @enddots{} is an end-of-sentence ellipsis.
672 %
673 \def\enddots{%
674   \leavevmode
675   \hbox to 2em{%
676     \hskip 0pt plus 0.25fil minus 0.25fil
677     .\hss.\hss.\hss.%
678     \hskip 0pt plus 0.5fil minus 0.5fil
679   }%
680   \spacefactor=3000
681 }
682
683
684 % @page    forces the start of a new page
685 %
686 \def\page{\par\vfill\supereject}
687
688 % @exdent text....
689 % outputs text on separate line in roman font, starting at standard page margin
690
691 % This records the amount of indent in the innermost environment.
692 % That's how much \exdent should take out.
693 \newskip\exdentamount
694
695 % This defn is used inside fill environments such as @defun.
696 \def\exdent{\parsearg\exdentyyy}
697 \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
698
699 % This defn is used inside nofill environments such as @example.
700 \def\nofillexdent{\parsearg\nofillexdentyyy}
701 \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
702 \leftline{\hskip\leftskip{\rm#1}}}}
703
704 % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
705 % paragraph.  For more general purposes, use the \margin insertion
706 % class.  WHICH is `l' or `r'.
707 %
708 \newskip\inmarginspacing \inmarginspacing=1cm
709 \def\strutdepth{\dp\strutbox}
710 %
711 \def\doinmargin#1#2{\strut\vadjust{%
712   \nobreak
713   \kern-\strutdepth
714   \vtop to \strutdepth{%
715     \baselineskip=\strutdepth
716     \vss
717     % if you have multiple lines of stuff to put here, you'll need to
718     % make the vbox yourself of the appropriate size.
719     \ifx#1l%
720       \llap{\ignorespaces #2\hskip\inmarginspacing}%
721     \else
722       \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
723     \fi
724     \null
725   }%
726 }}
727 \def\inleftmargin{\doinmargin l}
728 \def\inrightmargin{\doinmargin r}
729 %
730 % @inmargin{TEXT [, RIGHT-TEXT]}
731 % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
732 % else use TEXT for both).
733
734 \def\inmargin#1{\parseinmargin #1,,\finish}
735 \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
736   \setbox0 = \hbox{\ignorespaces #2}% 
737   \ifdim\wd0 > 0pt
738     \def\lefttext{#1}%  have both texts
739     \def\righttext{#2}%
740   \else
741     \def\lefttext{#1}%  have only one text
742     \def\righttext{#1}%
743   \fi
744   %
745   \ifodd\pageno
746     \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
747   \else
748     \def\temp{\inleftmargin\lefttext}%
749   \fi
750   \temp
751 }
752
753 % @include file    insert text of that file as input.
754 % Allow normal characters that  we make active in the argument (a file name).
755 \def\include{\begingroup
756   \catcode`\\=12
757   \catcode`~=12
758   \catcode`^=12
759   \catcode`_=12
760   \catcode`|=12
761   \catcode`<=12
762   \catcode`>=12
763   \catcode`+=12
764   \parsearg\includezzz}
765 % Restore active chars for included file.
766 \def\includezzz#1{\endgroup\begingroup
767   % Read the included file in a group so nested @include's work.
768   \def\thisfile{#1}%
769   \input\thisfile
770 \endgroup}
771
772 \def\thisfile{}
773
774 % @center line   outputs that line, centered
775
776 \def\center{\parsearg\centerzzz}
777 \def\centerzzz #1{{\advance\hsize by -\leftskip
778 \advance\hsize by -\rightskip
779 \centerline{#1}}}
780
781 % @sp n   outputs n lines of vertical space
782
783 \def\sp{\parsearg\spxxx}
784 \def\spxxx #1{\vskip #1\baselineskip}
785
786 % @comment ...line which is ignored...
787 % @c is the same as @comment
788 % @ignore ... @end ignore  is another way to write a comment
789
790 \def\comment{\begingroup \catcode`\^^M=\other%
791 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
792 \commentxxx}
793 {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
794
795 \let\c=\comment
796
797 % @paragraphindent NCHARS
798 % We'll use ems for NCHARS, close enough.
799 % We cannot implement @paragraphindent asis, though.
800
801 \def\asisword{asis} % no translation, these are keywords
802 \def\noneword{none}
803 %
804 \def\paragraphindent{\parsearg\doparagraphindent}
805 \def\doparagraphindent#1{%
806   \def\temp{#1}%
807   \ifx\temp\asisword
808   \else
809     \ifx\temp\noneword
810       \defaultparindent = 0pt
811     \else
812       \defaultparindent = #1em
813     \fi
814   \fi
815   \parindent = \defaultparindent
816 }
817
818 % @exampleindent NCHARS
819 % We'll use ems for NCHARS like @paragraphindent.
820 % It seems @exampleindent asis isn't necessary, but
821 % I preserve it to make it similar to @paragraphindent.
822 \def\exampleindent{\parsearg\doexampleindent}
823 \def\doexampleindent#1{%
824   \def\temp{#1}%
825   \ifx\temp\asisword
826   \else
827     \ifx\temp\noneword
828       \lispnarrowing = 0pt
829     \else
830       \lispnarrowing = #1em
831     \fi
832   \fi
833 }
834
835 % @asis just yields its argument.  Used with @table, for example.
836 %
837 \def\asis#1{#1}
838
839 % @math outputs its argument in math mode.
840 % We don't use $'s directly in the definition of \math because we need
841 % to set catcodes according to plain TeX first, to allow for subscripts,
842 % superscripts, special math chars, etc.
843
844 % @math does not do math typesetting in section titles, index
845 % entries, and other such contexts where the catcodes are set before
846 % @math gets a chance to work.  This could perhaps be fixed, but for now
847 % at least we can have real math in the main text, where it's needed most.
848 %
849 \let\implicitmath = $%$ font-lock fix
850 %
851 % One complication: _ usually means subscripts, but it could also mean
852 % an actual _ character, as in @math{@var{some_variable} + 1}.  So make
853 % _ within @math be active (mathcode "8000), and distinguish by seeing
854 % if the current family is \slfam, which is what @var uses.
855
856 {\catcode95 = \active  % 95 = _
857 \gdef\mathunderscore{%
858   \catcode95=\active
859   \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
860 }}
861 %
862 % Another complication: we want \\ (and @\) to output a \ character.
863 % FYI, plain.tex uses \\ as a temporary control sequence (why?), but
864 % this is not advertised and we don't care.  Texinfo does not
865 % otherwise define @\.
866
867 % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
868 \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
869 %
870 \def\math{%
871   \tex
872   \mathcode`\_="8000 \mathunderscore
873   \let\\ = \mathbackslash
874   \implicitmath\finishmath}
875 \def\finishmath#1{#1\implicitmath\Etex}
876
877 % @bullet and @minus need the same treatment as @math, just above.
878 \def\bullet{\implicitmath\ptexbullet\implicitmath}
879 \def\minus{\implicitmath-\implicitmath}
880
881 % @refill is a no-op.
882 \let\refill=\relax
883
884 % If working on a large document in chapters, it is convenient to
885 % be able to disable indexing, cross-referencing, and contents, for test runs.
886 % This is done with @novalidate (before @setfilename).
887 %
888 \newif\iflinks \linkstrue % by default we want the aux files.
889 \let\novalidate = \linksfalse
890
891 % @setfilename is done at the beginning of every texinfo file.
892 % So open here the files we need to have open while reading the input.
893 % This makes it possible to make a .fmt file for texinfo.
894 \def\setfilename{%
895    \iflinks
896      \readauxfile
897    \fi % \openindices needs to do some work in any case.
898    \openindices
899    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
900    \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
901    %
902    % If texinfo.cnf is present on the system, read it.
903    % Useful for site-wide @afourpaper, etc.
904    % Just to be on the safe side, close the input stream before the \input.
905    \openin 1 texinfo.cnf
906    \ifeof1 \let\temp=\relax \else \def\temp{\input texinfo.cnf }\fi
907    \closein1
908    \temp
909    %
910    \comment % Ignore the actual filename.
911 }
912
913 % Called from \setfilename.
914 %
915 \def\openindices{%
916   \newindex{cp}%
917   \newcodeindex{fn}%
918   \newcodeindex{vr}%
919   \newcodeindex{tp}%
920   \newcodeindex{ky}%
921   \newcodeindex{pg}%
922 }
923
924 % @bye.
925 \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
926
927
928 \message{pdf,}
929 % adobe `portable' document format
930 \newcount\tempnum
931 \newcount\lnkcount
932 \newtoks\filename
933 \newcount\filenamelength
934 \newcount\pgn
935 \newtoks\toksA
936 \newtoks\toksB
937 \newtoks\toksC
938 \newtoks\toksD
939 \newbox\boxA
940 \newcount\countA
941 \newif\ifpdf
942 \newif\ifpdfmakepagedest
943
944 \ifx\pdfoutput\undefined
945   \pdffalse
946   \let\pdfmkdest = \gobble
947   \let\pdfurl = \gobble
948   \let\endlink = \relax
949   \let\linkcolor = \relax
950   \let\pdfmakeoutlines = \relax
951 \else
952   \pdftrue
953   \pdfoutput = 1
954   \input pdfcolor
955   \def\dopdfimage#1#2#3{%
956     \def\imagewidth{#2}%
957     \def\imageheight{#3}%
958     % without \immediate, pdftex seg faults when the same image is
959     % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
960     \ifnum\pdftexversion < 14
961       \immediate\pdfimage
962     \else
963       \immediate\pdfximage
964     \fi
965       \ifx\empty\imagewidth\else width \imagewidth \fi
966       \ifx\empty\imageheight\else height \imageheight \fi
967       \ifnum\pdftexversion<13
968          #1.pdf%
969        \else
970          {#1.pdf}%
971        \fi
972     \ifnum\pdftexversion < 14 \else
973       \pdfrefximage \pdflastximage
974     \fi}
975   \def\pdfmkdest#1{{\normalturnoffactive \pdfdest name{#1} xyz}}
976   \def\pdfmkpgn#1{#1}
977   \let\linkcolor = \Blue  % was Cyan, but that seems light?
978   \def\endlink{\Black\pdfendlink}
979   % Adding outlines to PDF; macros for calculating structure of outlines
980   % come from Petr Olsak
981   \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
982     \else \csname#1\endcsname \fi}
983   \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
984     \advance\tempnum by1
985     \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
986   \def\pdfmakeoutlines{{%
987     \openin 1 \jobname.toc
988     \ifeof 1\else\begingroup
989       \closein 1 
990       % Thanh's hack / proper braces in bookmarks  
991       \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace
992       \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace
993       %
994       \def\chapentry ##1##2##3{}
995       \def\secentry ##1##2##3##4{\advancenumber{chap##2}}
996       \def\subsecentry ##1##2##3##4##5{\advancenumber{sec##2.##3}}
997       \def\subsubsecentry ##1##2##3##4##5##6{\advancenumber{subsec##2.##3.##4}}
998       \let\appendixentry = \chapentry
999       \let\unnumbchapentry = \chapentry
1000       \let\unnumbsecentry = \secentry
1001       \let\unnumbsubsecentry = \subsecentry
1002       \let\unnumbsubsubsecentry = \subsubsecentry
1003       \input \jobname.toc
1004       \def\chapentry ##1##2##3{%
1005         \pdfoutline goto name{\pdfmkpgn{##3}}count-\expnumber{chap##2}{##1}}
1006       \def\secentry ##1##2##3##4{%
1007         \pdfoutline goto name{\pdfmkpgn{##4}}count-\expnumber{sec##2.##3}{##1}}
1008       \def\subsecentry ##1##2##3##4##5{%
1009         \pdfoutline goto name{\pdfmkpgn{##5}}count-\expnumber{subsec##2.##3.##4}{##1}}
1010       \def\subsubsecentry ##1##2##3##4##5##6{%
1011         \pdfoutline goto name{\pdfmkpgn{##6}}{##1}}
1012       \let\appendixentry = \chapentry
1013       \let\unnumbchapentry = \chapentry
1014       \let\unnumbsecentry = \secentry
1015       \let\unnumbsubsecentry = \subsecentry
1016       \let\unnumbsubsubsecentry = \subsubsecentry
1017       %
1018       % Make special characters normal for writing to the pdf file.
1019       % 
1020       \indexnofonts
1021       \let\tt=\relax
1022       \turnoffactive
1023       \input \jobname.toc
1024     \endgroup\fi
1025   }}
1026   \def\makelinks #1,{%
1027     \def\params{#1}\def\E{END}%
1028     \ifx\params\E
1029       \let\nextmakelinks=\relax
1030     \else
1031       \let\nextmakelinks=\makelinks
1032       \ifnum\lnkcount>0,\fi
1033       \picknum{#1}%
1034       \startlink attr{/Border [0 0 0]} 
1035         goto name{\pdfmkpgn{\the\pgn}}%
1036       \linkcolor #1%
1037       \advance\lnkcount by 1%
1038       \endlink
1039     \fi
1040     \nextmakelinks
1041   }
1042   \def\picknum#1{\expandafter\pn#1}
1043   \def\pn#1{%
1044     \def\p{#1}%
1045     \ifx\p\lbrace
1046       \let\nextpn=\ppn
1047     \else
1048       \let\nextpn=\ppnn
1049       \def\first{#1}
1050     \fi
1051     \nextpn
1052   }
1053   \def\ppn#1{\pgn=#1\gobble}
1054   \def\ppnn{\pgn=\first}
1055   \def\pdfmklnk#1{\lnkcount=0\makelinks #1,END,}
1056   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1057   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1058     \ifx\PP\D\let\nextsp\relax
1059     \else\let\nextsp\skipspaces
1060       \ifx\p\space\else\addtokens{\filename}{\PP}%
1061         \advance\filenamelength by 1
1062       \fi
1063     \fi
1064     \nextsp}
1065   \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax}
1066   \ifnum\pdftexversion < 14
1067     \let \startlink \pdfannotlink
1068   \else
1069     \let \startlink \pdfstartlink
1070   \fi
1071   \def\pdfurl#1{%
1072     \begingroup
1073       \normalturnoffactive\def\@{@}%
1074       \let\value=\expandablevalue
1075       \leavevmode\Red
1076       \startlink attr{/Border [0 0 0]}%
1077         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1078         % #1
1079     \endgroup}
1080   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1081   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1082   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1083   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1084   \def\maketoks{%
1085     \expandafter\poptoks\the\toksA|ENDTOKS|
1086     \ifx\first0\adn0
1087     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1088     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1089     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 
1090     \else
1091       \ifnum0=\countA\else\makelink\fi
1092       \ifx\first.\let\next=\done\else
1093         \let\next=\maketoks
1094         \addtokens{\toksB}{\the\toksD}
1095         \ifx\first,\addtokens{\toksB}{\space}\fi
1096       \fi
1097     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1098     \next}
1099   \def\makelink{\addtokens{\toksB}%
1100     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1101   \def\pdflink#1{%
1102     \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1103     \linkcolor #1\endlink}
1104   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1105 \fi % \ifx\pdfoutput
1106
1107
1108 \message{fonts,}
1109 % Font-change commands.
1110
1111 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
1112 % So we set up a \sf analogous to plain's \rm, etc.
1113 \newfam\sffam
1114 \def\sf{\fam=\sffam \tensf}
1115 \let\li = \sf % Sometimes we call it \li, not \sf.
1116
1117 % We don't need math for this one.
1118 \def\ttsl{\tenttsl}
1119
1120 % Default leading.
1121 \newdimen\textleading  \textleading = 13.2pt
1122
1123 % Set the baselineskip to #1, and the lineskip and strut size
1124 % correspondingly.  There is no deep meaning behind these magic numbers
1125 % used as factors; they just match (closely enough) what Knuth defined.
1126 %
1127 \def\lineskipfactor{.08333}
1128 \def\strutheightpercent{.70833}
1129 \def\strutdepthpercent {.29167}
1130 %
1131 \def\setleading#1{%
1132   \normalbaselineskip = #1\relax
1133   \normallineskip = \lineskipfactor\normalbaselineskip
1134   \normalbaselines
1135   \setbox\strutbox =\hbox{%
1136     \vrule width0pt height\strutheightpercent\baselineskip
1137                     depth \strutdepthpercent \baselineskip
1138   }%
1139 }
1140
1141 % Set the font macro #1 to the font named #2, adding on the
1142 % specified font prefix (normally `cm').
1143 % #3 is the font's design size, #4 is a scale factor
1144 \def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4}
1145
1146 % Use cm as the default font prefix.
1147 % To specify the font prefix, you must define \fontprefix
1148 % before you read in texinfo.tex.
1149 \ifx\fontprefix\undefined
1150 \def\fontprefix{cm}
1151 \fi
1152 % Support font families that don't use the same naming scheme as CM.
1153 \def\rmshape{r}
1154 \def\rmbshape{bx}               %where the normal face is bold
1155 \def\bfshape{b}
1156 \def\bxshape{bx}
1157 \def\ttshape{tt}
1158 \def\ttbshape{tt}
1159 \def\ttslshape{sltt}
1160 \def\itshape{ti}
1161 \def\itbshape{bxti}
1162 \def\slshape{sl}
1163 \def\slbshape{bxsl}
1164 \def\sfshape{ss}
1165 \def\sfbshape{ss}
1166 \def\scshape{csc}
1167 \def\scbshape{csc}
1168
1169 \newcount\mainmagstep
1170 \ifx\bigger\relax
1171   % not really supported.
1172   \mainmagstep=\magstep1
1173   \setfont\textrm\rmshape{12}{1000}
1174   \setfont\texttt\ttshape{12}{1000}
1175 \else
1176   \mainmagstep=\magstephalf
1177   \setfont\textrm\rmshape{10}{\mainmagstep}
1178   \setfont\texttt\ttshape{10}{\mainmagstep}
1179 \fi
1180 % Instead of cmb10, you many want to use cmbx10.
1181 % cmbx10 is a prettier font on its own, but cmb10
1182 % looks better when embedded in a line with cmr10.
1183 \setfont\textbf\bfshape{10}{\mainmagstep}
1184 \setfont\textit\itshape{10}{\mainmagstep}
1185 \setfont\textsl\slshape{10}{\mainmagstep}
1186 \setfont\textsf\sfshape{10}{\mainmagstep}
1187 \setfont\textsc\scshape{10}{\mainmagstep}
1188 \setfont\textttsl\ttslshape{10}{\mainmagstep}
1189 \font\texti=cmmi10 scaled \mainmagstep
1190 \font\textsy=cmsy10 scaled \mainmagstep
1191
1192 % A few fonts for @defun, etc.
1193 \setfont\defbf\bxshape{10}{\magstep1} %was 1314
1194 \setfont\deftt\ttshape{10}{\magstep1}
1195 \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
1196
1197 % Fonts for indices, footnotes, small examples (9pt).
1198 \setfont\smallrm\rmshape{9}{1000}
1199 \setfont\smalltt\ttshape{9}{1000}
1200 \setfont\smallbf\bfshape{10}{900}
1201 \setfont\smallit\itshape{9}{1000}
1202 \setfont\smallsl\slshape{9}{1000}
1203 \setfont\smallsf\sfshape{9}{1000}
1204 \setfont\smallsc\scshape{10}{900}
1205 \setfont\smallttsl\ttslshape{10}{900}
1206 \font\smalli=cmmi9
1207 \font\smallsy=cmsy9
1208
1209 % Fonts for small examples (8pt).
1210 \setfont\smallerrm\rmshape{8}{1000}
1211 \setfont\smallertt\ttshape{8}{1000}
1212 \setfont\smallerbf\bfshape{10}{800}
1213 \setfont\smallerit\itshape{8}{1000}
1214 \setfont\smallersl\slshape{8}{1000}
1215 \setfont\smallersf\sfshape{8}{1000}
1216 \setfont\smallersc\scshape{10}{800}
1217 \setfont\smallerttsl\ttslshape{10}{800}
1218 \font\smalleri=cmmi8
1219 \font\smallersy=cmsy8
1220
1221 % Fonts for title page:
1222 \setfont\titlerm\rmbshape{12}{\magstep3}
1223 \setfont\titleit\itbshape{10}{\magstep4}
1224 \setfont\titlesl\slbshape{10}{\magstep4}
1225 \setfont\titlett\ttbshape{12}{\magstep3}
1226 \setfont\titlettsl\ttslshape{10}{\magstep4}
1227 \setfont\titlesf\sfbshape{17}{\magstep1}
1228 \let\titlebf=\titlerm
1229 \setfont\titlesc\scbshape{10}{\magstep4}
1230 \font\titlei=cmmi12 scaled \magstep3
1231 \font\titlesy=cmsy10 scaled \magstep4
1232 \def\authorrm{\secrm}
1233 \def\authortt{\sectt}
1234
1235 % Chapter (and unnumbered) fonts (17.28pt).
1236 \setfont\chaprm\rmbshape{12}{\magstep2}
1237 \setfont\chapit\itbshape{10}{\magstep3}
1238 \setfont\chapsl\slbshape{10}{\magstep3}
1239 \setfont\chaptt\ttbshape{12}{\magstep2}
1240 \setfont\chapttsl\ttslshape{10}{\magstep3}
1241 \setfont\chapsf\sfbshape{17}{1000}
1242 \let\chapbf=\chaprm
1243 \setfont\chapsc\scbshape{10}{\magstep3}
1244 \font\chapi=cmmi12 scaled \magstep2
1245 \font\chapsy=cmsy10 scaled \magstep3
1246
1247 % Section fonts (14.4pt).
1248 \setfont\secrm\rmbshape{12}{\magstep1}
1249 \setfont\secit\itbshape{10}{\magstep2}
1250 \setfont\secsl\slbshape{10}{\magstep2}
1251 \setfont\sectt\ttbshape{12}{\magstep1}
1252 \setfont\secttsl\ttslshape{10}{\magstep2}
1253 \setfont\secsf\sfbshape{12}{\magstep1}
1254 \let\secbf\secrm
1255 \setfont\secsc\scbshape{10}{\magstep2}
1256 \font\seci=cmmi12 scaled \magstep1
1257 \font\secsy=cmsy10 scaled \magstep2
1258
1259 % Subsection fonts (13.15pt).
1260 \setfont\ssecrm\rmbshape{12}{\magstephalf}
1261 \setfont\ssecit\itbshape{10}{1315}
1262 \setfont\ssecsl\slbshape{10}{1315}
1263 \setfont\ssectt\ttbshape{12}{\magstephalf}
1264 \setfont\ssecttsl\ttslshape{10}{1315}
1265 \setfont\ssecsf\sfbshape{12}{\magstephalf}
1266 \let\ssecbf\ssecrm
1267 \setfont\ssecsc\scbshape{10}{\magstep1}
1268 \font\sseci=cmmi12 scaled \magstephalf
1269 \font\ssecsy=cmsy10 scaled 1315
1270 % The smallcaps and symbol fonts should actually be scaled \magstep1.5,
1271 % but that is not a standard magnification.
1272
1273 % In order for the font changes to affect most math symbols and letters,
1274 % we have to define the \textfont of the standard families.  Since
1275 % texinfo doesn't allow for producing subscripts and superscripts except
1276 % in the main text, we don't bother to reset \scriptfont and
1277 % \scriptscriptfont (which would also require loading a lot more fonts).
1278 %
1279 \def\resetmathfonts{%
1280   \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
1281   \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
1282   \textfont\ttfam=\tentt \textfont\sffam=\tensf
1283 }
1284
1285 % The font-changing commands redefine the meanings of \tenSTYLE, instead
1286 % of just \STYLE.  We do this so that font changes will continue to work
1287 % in math mode, where it is the current \fam that is relevant in most
1288 % cases, not the current font.  Plain TeX does \def\bf{\fam=\bffam
1289 % \tenbf}, for example.  By redefining \tenbf, we obviate the need to
1290 % redefine \bf itself.
1291 \def\textfonts{%
1292   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
1293   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
1294   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl
1295   \resetmathfonts \setleading{\textleading}}
1296 \def\titlefonts{%
1297   \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
1298   \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
1299   \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
1300   \let\tenttsl=\titlettsl
1301   \resetmathfonts \setleading{25pt}}
1302 \def\titlefont#1{{\titlefonts\rm #1}}
1303 \def\chapfonts{%
1304   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
1305   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
1306   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl
1307   \resetmathfonts \setleading{19pt}}
1308 \def\secfonts{%
1309   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
1310   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
1311   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl
1312   \resetmathfonts \setleading{16pt}}
1313 \def\subsecfonts{%
1314   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
1315   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
1316   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl
1317   \resetmathfonts \setleading{15pt}}
1318 \let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf?
1319 \def\smallfonts{%
1320   \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
1321   \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
1322   \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
1323   \let\tenttsl=\smallttsl
1324   \resetmathfonts \setleading{10.5pt}}
1325 \def\smallerfonts{%
1326   \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
1327   \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
1328   \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
1329   \let\tenttsl=\smallerttsl
1330   \resetmathfonts \setleading{9.5pt}}
1331 \let\smallexamplefonts = \smallerfonts
1332
1333 % Set up the default fonts, so we can use them for creating boxes.
1334 %
1335 \textfonts
1336
1337 % Define these so they can be easily changed for other fonts.
1338 \def\angleleft{$\langle$}
1339 \def\angleright{$\rangle$}
1340
1341 % Count depth in font-changes, for error checks
1342 \newcount\fontdepth \fontdepth=0
1343
1344 % Fonts for short table of contents.
1345 \setfont\shortcontrm\rmshape{12}{1000}
1346 \setfont\shortcontbf\bxshape{12}{1000}
1347 \setfont\shortcontsl\slshape{12}{1000}
1348 \setfont\shortconttt\ttshape{12}{1000}
1349
1350 %% Add scribe-like font environments, plus @l for inline lisp (usually sans
1351 %% serif) and @ii for TeX italic
1352
1353 % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
1354 % unless the following character is such as not to need one.
1355 \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
1356 \def\smartslanted#1{{\ifusingtt\ttsl\sl #1}\futurelet\next\smartitalicx}
1357 \def\smartitalic#1{{\ifusingtt\ttsl\it #1}\futurelet\next\smartitalicx}
1358
1359 \let\i=\smartitalic
1360 \let\var=\smartslanted
1361 \let\dfn=\smartslanted
1362 \let\emph=\smartitalic
1363 \let\cite=\smartslanted
1364
1365 \def\b#1{{\bf #1}}
1366 \let\strong=\b
1367
1368 % We can't just use \exhyphenpenalty, because that only has effect at
1369 % the end of a paragraph.  Restore normal hyphenation at the end of the
1370 % group within which \nohyphenation is presumably called.
1371 %
1372 \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
1373 \def\restorehyphenation{\hyphenchar\font = `- }
1374
1375 \def\t#1{%
1376   {\tt \rawbackslash \frenchspacing #1}%
1377   \null
1378 }
1379 \let\ttfont=\t
1380 \def\samp#1{`\tclose{#1}'\null}
1381 \setfont\keyrm\rmshape{8}{1000}
1382 \font\keysy=cmsy9
1383 \def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
1384   \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
1385     \vbox{\hrule\kern-0.4pt
1386      \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
1387     \kern-0.4pt\hrule}%
1388   \kern-.06em\raise0.4pt\hbox{\angleright}}}}
1389 % The old definition, with no lozenge:
1390 %\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null}
1391 \def\ctrl #1{{\tt \rawbackslash \hat}#1}
1392
1393 % @file, @option are the same as @samp.
1394 \let\file=\samp
1395 \let\option=\samp
1396
1397 % @code is a modification of @t,
1398 % which makes spaces the same size as normal in the surrounding text.
1399 \def\tclose#1{%
1400   {%
1401     % Change normal interword space to be same as for the current font.
1402     \spaceskip = \fontdimen2\font
1403     %
1404     % Switch to typewriter.
1405     \tt
1406     %
1407     % But `\ ' produces the large typewriter interword space.
1408     \def\ {{\spaceskip = 0pt{} }}%
1409     %
1410     % Turn off hyphenation.
1411     \nohyphenation
1412     %
1413     \rawbackslash
1414     \frenchspacing
1415     #1%
1416   }%
1417   \null
1418 }
1419
1420 % We *must* turn on hyphenation at `-' and `_' in \code.
1421 % Otherwise, it is too hard to avoid overfull hboxes
1422 % in the Emacs manual, the Library manual, etc.
1423
1424 % Unfortunately, TeX uses one parameter (\hyphenchar) to control
1425 % both hyphenation at - and hyphenation within words.
1426 % We must therefore turn them both off (\tclose does that)
1427 % and arrange explicitly to hyphenate at a dash.
1428 %  -- rms.
1429 {
1430   \catcode`\-=\active
1431   \catcode`\_=\active
1432   %
1433   \global\def\code{\begingroup
1434     \catcode`\-=\active \let-\codedash
1435     \catcode`\_=\active \let_\codeunder
1436     \codex
1437   }
1438   %
1439   % If we end up with any active - characters when handling the index,
1440   % just treat them as a normal -.
1441   \global\def\indexbreaks{\catcode`\-=\active \let-\realdash}
1442 }
1443
1444 \def\realdash{-}
1445 \def\codedash{-\discretionary{}{}{}}
1446 \def\codeunder{%
1447   % this is all so @math{@code{var_name}+1} can work.  In math mode, _
1448   % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
1449   % will therefore expand the active definition of _, which is us
1450   % (inside @code that is), therefore an endless loop.
1451   \ifusingtt{\ifmmode
1452                \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
1453              \else\normalunderscore \fi
1454              \discretionary{}{}{}}%
1455             {\_}%
1456 }
1457 \def\codex #1{\tclose{#1}\endgroup}
1458
1459 % @kbd is like @code, except that if the argument is just one @key command,
1460 % then @kbd has no effect.
1461
1462 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
1463 %   `example' (@kbd uses ttsl only inside of @example and friends),
1464 %   or `code' (@kbd uses normal tty font always).
1465 \def\kbdinputstyle{\parsearg\kbdinputstylexxx}
1466 \def\kbdinputstylexxx#1{%
1467   \def\arg{#1}%
1468   \ifx\arg\worddistinct
1469     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
1470   \else\ifx\arg\wordexample
1471     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
1472   \else\ifx\arg\wordcode
1473     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
1474   \fi\fi\fi
1475 }
1476 \def\worddistinct{distinct}
1477 \def\wordexample{example}
1478 \def\wordcode{code}
1479
1480 % Default is kbdinputdistinct.  (Too much of a hassle to call the macro,
1481 % the catcodes are wrong for parsearg to work.)
1482 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}
1483
1484 \def\xkey{\key}
1485 \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
1486 \ifx\one\xkey\ifx\threex\three \key{#2}%
1487 \else{\tclose{\kbdfont\look}}\fi
1488 \else{\tclose{\kbdfont\look}}\fi}
1489
1490 % For @url, @env, @command quotes seem unnecessary, so use \code.
1491 \let\url=\code
1492 \let\env=\code
1493 \let\command=\code
1494
1495 % @uref (abbreviation for `urlref') takes an optional (comma-separated)
1496 % second argument specifying the text to display and an optional third
1497 % arg as text to display instead of (rather than in addition to) the url
1498 % itself.  First (mandatory) arg is the url.  Perhaps eventually put in
1499 % a hypertex \special here.
1500 %
1501 \def\uref#1{\douref #1,,,\finish}
1502 \def\douref#1,#2,#3,#4\finish{\begingroup
1503   \unsepspaces
1504   \pdfurl{#1}%
1505   \setbox0 = \hbox{\ignorespaces #3}%
1506   \ifdim\wd0 > 0pt
1507     \unhbox0 % third arg given, show only that
1508   \else
1509     \setbox0 = \hbox{\ignorespaces #2}%
1510     \ifdim\wd0 > 0pt
1511       \ifpdf
1512         \unhbox0             % PDF: 2nd arg given, show only it
1513       \else
1514         \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
1515       \fi
1516     \else
1517       \code{#1}% only url given, so show it
1518     \fi
1519   \fi
1520   \endlink
1521 \endgroup}
1522
1523 % rms does not like angle brackets --karl, 17may97.
1524 % So now @email is just like @uref, unless we are pdf.
1525
1526 %\def\email#1{\angleleft{\tt #1}\angleright}
1527 \ifpdf
1528   \def\email#1{\doemail#1,,\finish}
1529   \def\doemail#1,#2,#3\finish{\begingroup
1530     \unsepspaces
1531     \pdfurl{mailto:#1}%
1532     \setbox0 = \hbox{\ignorespaces #2}%
1533     \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
1534     \endlink
1535   \endgroup}
1536 \else
1537   \let\email=\uref
1538 \fi
1539
1540 % Check if we are currently using a typewriter font.  Since all the
1541 % Computer Modern typewriter fonts have zero interword stretch (and
1542 % shrink), and it is reasonable to expect all typewriter fonts to have
1543 % this property, we can check that font parameter.
1544 %
1545 \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
1546
1547 % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
1548 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
1549 %
1550 \def\dmn#1{\thinspace #1}
1551
1552 \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
1553
1554 % @l was never documented to mean ``switch to the Lisp font'',
1555 % and it is not used as such in any manual I can find.  We need it for
1556 % Polish suppressed-l.  --karl, 22sep96.
1557 %\def\l#1{{\li #1}\null}
1558
1559 % Explicit font changes: @r, @sc, undocumented @ii.
1560 \def\r#1{{\rm #1}}              % roman font
1561 \def\sc#1{{\smallcaps#1}}       % smallcaps font
1562 \def\ii#1{{\it #1}}             % italic font
1563
1564 % @acronym downcases the argument and prints in smallcaps.
1565 \def\acronym#1{{\smallcaps \lowercase{#1}}}
1566
1567 % @pounds{} is a sterling sign.
1568 \def\pounds{{\it\$}}
1569
1570
1571 \message{page headings,}
1572
1573 \newskip\titlepagetopglue \titlepagetopglue = 1.5in
1574 \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
1575
1576 % First the title page.  Must do @settitle before @titlepage.
1577 \newif\ifseenauthor
1578 \newif\iffinishedtitlepage
1579
1580 % Do an implicit @contents or @shortcontents after @end titlepage if the
1581 % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
1582 %
1583 \newif\ifsetcontentsaftertitlepage
1584  \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
1585 \newif\ifsetshortcontentsaftertitlepage
1586  \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
1587
1588 \def\shorttitlepage{\parsearg\shorttitlepagezzz}
1589 \def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
1590         \endgroup\page\hbox{}\page}
1591
1592 \def\titlepage{\begingroup \parindent=0pt \textfonts
1593    \let\subtitlerm=\tenrm
1594    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
1595    %
1596    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines
1597                    \let\tt=\authortt}%
1598    %
1599    % Leave some space at the very top of the page.
1600    \vglue\titlepagetopglue
1601    %
1602    % Now you can print the title using @title.
1603    \def\title{\parsearg\titlezzz}%
1604    \def\titlezzz##1{\leftline{\titlefonts\rm ##1}
1605                     % print a rule at the page bottom also.
1606                     \finishedtitlepagefalse
1607                     \vskip4pt \hrule height 4pt width \hsize \vskip4pt}%
1608    % No rule at page bottom unless we print one at the top with @title.
1609    \finishedtitlepagetrue
1610    %
1611    % Now you can put text using @subtitle.
1612    \def\subtitle{\parsearg\subtitlezzz}%
1613    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
1614    %
1615    % @author should come last, but may come many times.
1616    \def\author{\parsearg\authorzzz}%
1617    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
1618       {\authorfont \leftline{##1}}}%
1619    %
1620    % Most title ``pages'' are actually two pages long, with space
1621    % at the top of the second.  We don't want the ragged left on the second.
1622    \let\oldpage = \page
1623    \def\page{%
1624       \iffinishedtitlepage\else
1625          \finishtitlepage
1626       \fi
1627       \oldpage
1628       \let\page = \oldpage
1629       \hbox{}}%
1630 %   \def\page{\oldpage \hbox{}}
1631 }
1632
1633 \def\Etitlepage{%
1634    \iffinishedtitlepage\else
1635       \finishtitlepage
1636    \fi
1637    % It is important to do the page break before ending the group,
1638    % because the headline and footline are only empty inside the group.
1639    % If we use the new definition of \page, we always get a blank page
1640    % after the title page, which we certainly don't want.
1641    \oldpage
1642    \endgroup
1643    %
1644    % Need this before the \...aftertitlepage checks so that if they are
1645    % in effect the toc pages will come out with page numbers.
1646    \HEADINGSon
1647    %
1648    % If they want short, they certainly want long too.
1649    \ifsetshortcontentsaftertitlepage
1650      \shortcontents
1651      \contents
1652      \global\let\shortcontents = \relax
1653      \global\let\contents = \relax
1654    \fi
1655    %
1656    \ifsetcontentsaftertitlepage
1657      \contents
1658      \global\let\contents = \relax
1659      \global\let\shortcontents = \relax
1660    \fi
1661 }
1662
1663 \def\finishtitlepage{%
1664    \vskip4pt \hrule height 2pt width \hsize
1665    \vskip\titlepagebottomglue
1666    \finishedtitlepagetrue
1667 }
1668
1669 %%% Set up page headings and footings.
1670
1671 \let\thispage=\folio
1672
1673 \newtoks\evenheadline    % headline on even pages
1674 \newtoks\oddheadline     % headline on odd pages
1675 \newtoks\evenfootline    % footline on even pages
1676 \newtoks\oddfootline     % footline on odd pages
1677
1678 % Now make Tex use those variables
1679 \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
1680                             \else \the\evenheadline \fi}}
1681 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
1682                             \else \the\evenfootline \fi}\HEADINGShook}
1683 \let\HEADINGShook=\relax
1684
1685 % Commands to set those variables.
1686 % For example, this is what  @headings on  does
1687 % @evenheading @thistitle|@thispage|@thischapter
1688 % @oddheading @thischapter|@thispage|@thistitle
1689 % @evenfooting @thisfile||
1690 % @oddfooting ||@thisfile
1691
1692 \def\evenheading{\parsearg\evenheadingxxx}
1693 \def\oddheading{\parsearg\oddheadingxxx}
1694 \def\everyheading{\parsearg\everyheadingxxx}
1695
1696 \def\evenfooting{\parsearg\evenfootingxxx}
1697 \def\oddfooting{\parsearg\oddfootingxxx}
1698 \def\everyfooting{\parsearg\everyfootingxxx}
1699
1700 {\catcode`\@=0 %
1701
1702 \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
1703 \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
1704 \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1705
1706 \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
1707 \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
1708 \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1709
1710 \gdef\everyheadingxxx#1{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
1711
1712 \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
1713 \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
1714 \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1715
1716 \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
1717 \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
1718   \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
1719   %
1720   % Leave some space for the footline.  Hopefully ok to assume
1721   % @evenfooting will not be used by itself.
1722   \global\advance\pageheight by -\baselineskip
1723   \global\advance\vsize by -\baselineskip
1724 }
1725
1726 \gdef\everyfootingxxx#1{\oddfootingxxx{#1}\evenfootingxxx{#1}}
1727 %
1728 }% unbind the catcode of @.
1729
1730 % @headings double      turns headings on for double-sided printing.
1731 % @headings single      turns headings on for single-sided printing.
1732 % @headings off         turns them off.
1733 % @headings on          same as @headings double, retained for compatibility.
1734 % @headings after       turns on double-sided headings after this page.
1735 % @headings doubleafter turns on double-sided headings after this page.
1736 % @headings singleafter turns on single-sided headings after this page.
1737 % By default, they are off at the start of a document,
1738 % and turned `on' after @end titlepage.
1739
1740 \def\headings #1 {\csname HEADINGS#1\endcsname}
1741
1742 \def\HEADINGSoff{
1743 \global\evenheadline={\hfil} \global\evenfootline={\hfil}
1744 \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
1745 \HEADINGSoff
1746 % When we turn headings on, set the page number to 1.
1747 % For double-sided printing, put current file name in lower left corner,
1748 % chapter name on inside top of right hand pages, document
1749 % title on inside top of left hand pages, and page numbers on outside top
1750 % edge of all pages.
1751 \def\HEADINGSdouble{
1752 \global\pageno=1
1753 \global\evenfootline={\hfil}
1754 \global\oddfootline={\hfil}
1755 \global\evenheadline={\line{\folio\hfil\thistitle}}
1756 \global\oddheadline={\line{\thischapter\hfil\folio}}
1757 \global\let\contentsalignmacro = \chapoddpage
1758 }
1759 \let\contentsalignmacro = \chappager
1760
1761 % For single-sided printing, chapter title goes across top left of page,
1762 % page number on top right.
1763 \def\HEADINGSsingle{
1764 \global\pageno=1
1765 \global\evenfootline={\hfil}
1766 \global\oddfootline={\hfil}
1767 \global\evenheadline={\line{\thischapter\hfil\folio}}
1768 \global\oddheadline={\line{\thischapter\hfil\folio}}
1769 \global\let\contentsalignmacro = \chappager
1770 }
1771 \def\HEADINGSon{\HEADINGSdouble}
1772
1773 \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
1774 \let\HEADINGSdoubleafter=\HEADINGSafter
1775 \def\HEADINGSdoublex{%
1776 \global\evenfootline={\hfil}
1777 \global\oddfootline={\hfil}
1778 \global\evenheadline={\line{\folio\hfil\thistitle}}
1779 \global\oddheadline={\line{\thischapter\hfil\folio}}
1780 \global\let\contentsalignmacro = \chapoddpage
1781 }
1782
1783 \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
1784 \def\HEADINGSsinglex{%
1785 \global\evenfootline={\hfil}
1786 \global\oddfootline={\hfil}
1787 \global\evenheadline={\line{\thischapter\hfil\folio}}
1788 \global\oddheadline={\line{\thischapter\hfil\folio}}
1789 \global\let\contentsalignmacro = \chappager
1790 }
1791
1792 % Subroutines used in generating headings
1793 % This produces Day Month Year style of output.
1794 % Only define if not already defined, in case a txi-??.tex file has set
1795 % up a different format (e.g., txi-cs.tex does this).
1796 \ifx\today\undefined
1797 \def\today{%
1798   \number\day\space
1799   \ifcase\month
1800   \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
1801   \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
1802   \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
1803   \fi
1804   \space\number\year}
1805 \fi
1806
1807 % @settitle line...  specifies the title of the document, for headings.
1808 % It generates no output of its own.
1809 \def\thistitle{\putwordNoTitle}
1810 \def\settitle{\parsearg\settitlezzz}
1811 \def\settitlezzz #1{\gdef\thistitle{#1}}
1812
1813
1814 \message{tables,}
1815 % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
1816
1817 % default indentation of table text
1818 \newdimen\tableindent \tableindent=.8in
1819 % default indentation of @itemize and @enumerate text
1820 \newdimen\itemindent  \itemindent=.3in
1821 % margin between end of table item and start of table text.
1822 \newdimen\itemmargin  \itemmargin=.1in
1823
1824 % used internally for \itemindent minus \itemmargin
1825 \newdimen\itemmax
1826
1827 % Note @table, @vtable, and @vtable define @item, @itemx, etc., with
1828 % these defs.
1829 % They also define \itemindex
1830 % to index the item name in whatever manner is desired (perhaps none).
1831
1832 \newif\ifitemxneedsnegativevskip
1833
1834 \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
1835
1836 \def\internalBitem{\smallbreak \parsearg\itemzzz}
1837 \def\internalBitemx{\itemxpar \parsearg\itemzzz}
1838
1839 \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
1840 \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz}
1841
1842 \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
1843 \def\internalBkitemx{\itemxpar \parsearg\kitemzzz}
1844
1845 \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
1846                  \itemzzz {#1}}
1847
1848 \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
1849                  \itemzzz {#1}}
1850
1851 \def\itemzzz #1{\begingroup %
1852   \advance\hsize by -\rightskip
1853   \advance\hsize by -\tableindent
1854   \setbox0=\hbox{\itemfont{#1}}%
1855   \itemindex{#1}%
1856   \nobreak % This prevents a break before @itemx.
1857   %
1858   % If the item text does not fit in the space we have, put it on a line
1859   % by itself, and do not allow a page break either before or after that
1860   % line.  We do not start a paragraph here because then if the next
1861   % command is, e.g., @kindex, the whatsit would get put into the
1862   % horizontal list on a line by itself, resulting in extra blank space.
1863   \ifdim \wd0>\itemmax
1864     %
1865     % Make this a paragraph so we get the \parskip glue and wrapping,
1866     % but leave it ragged-right.
1867     \begingroup
1868       \advance\leftskip by-\tableindent
1869       \advance\hsize by\tableindent
1870       \advance\rightskip by0pt plus1fil
1871       \leavevmode\unhbox0\par
1872     \endgroup
1873     %
1874     % We're going to be starting a paragraph, but we don't want the
1875     % \parskip glue -- logically it's part of the @item we just started.
1876     \nobreak \vskip-\parskip
1877     %
1878     % Stop a page break at the \parskip glue coming up.  Unfortunately
1879     % we can't prevent a possible page break at the following
1880     % \baselineskip glue.
1881     \nobreak
1882     \endgroup
1883     \itemxneedsnegativevskipfalse
1884   \else
1885     % The item text fits into the space.  Start a paragraph, so that the
1886     % following text (if any) will end up on the same line.
1887     \noindent
1888     % Do this with kerns and \unhbox so that if there is a footnote in
1889     % the item text, it can migrate to the main vertical list and
1890     % eventually be printed.
1891     \nobreak\kern-\tableindent
1892     \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
1893     \unhbox0
1894     \nobreak\kern\dimen0
1895     \endgroup
1896     \itemxneedsnegativevskiptrue
1897   \fi
1898 }
1899
1900 \def\item{\errmessage{@item while not in a table}}
1901 \def\itemx{\errmessage{@itemx while not in a table}}
1902 \def\kitem{\errmessage{@kitem while not in a table}}
1903 \def\kitemx{\errmessage{@kitemx while not in a table}}
1904 \def\xitem{\errmessage{@xitem while not in a table}}
1905 \def\xitemx{\errmessage{@xitemx while not in a table}}
1906
1907 % Contains a kludge to get @end[description] to work.
1908 \def\description{\tablez{\dontindex}{1}{}{}{}{}}
1909
1910 % @table, @ftable, @vtable.
1911 \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
1912 {\obeylines\obeyspaces%
1913 \gdef\tablex #1^^M{%
1914 \tabley\dontindex#1        \endtabley}}
1915
1916 \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
1917 {\obeylines\obeyspaces%
1918 \gdef\ftablex #1^^M{%
1919 \tabley\fnitemindex#1        \endtabley
1920 \def\Eftable{\endgraf\afterenvbreak\endgroup}%
1921 \let\Etable=\relax}}
1922
1923 \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
1924 {\obeylines\obeyspaces%
1925 \gdef\vtablex #1^^M{%
1926 \tabley\vritemindex#1        \endtabley
1927 \def\Evtable{\endgraf\afterenvbreak\endgroup}%
1928 \let\Etable=\relax}}
1929
1930 \def\dontindex #1{}
1931 \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
1932 \def\vritemindex #1{\doind {vr}{\code{#1}}}%
1933
1934 {\obeyspaces %
1935 \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
1936 \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
1937
1938 \def\tablez #1#2#3#4#5#6{%
1939 \aboveenvbreak %
1940 \begingroup %
1941 \def\Edescription{\Etable}% Necessary kludge.
1942 \let\itemindex=#1%
1943 \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
1944 \ifnum 0#4>0 \tableindent=#4\mil \fi %
1945 \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
1946 \def\itemfont{#2}%
1947 \itemmax=\tableindent %
1948 \advance \itemmax by -\itemmargin %
1949 \advance \leftskip by \tableindent %
1950 \exdentamount=\tableindent
1951 \parindent = 0pt
1952 \parskip = \smallskipamount
1953 \ifdim \parskip=0pt \parskip=2pt \fi%
1954 \def\Etable{\endgraf\afterenvbreak\endgroup}%
1955 \let\item = \internalBitem %
1956 \let\itemx = \internalBitemx %
1957 \let\kitem = \internalBkitem %
1958 \let\kitemx = \internalBkitemx %
1959 \let\xitem = \internalBxitem %
1960 \let\xitemx = \internalBxitemx %
1961 }
1962
1963 % This is the counter used by @enumerate, which is really @itemize
1964
1965 \newcount \itemno
1966
1967 \def\itemize{\parsearg\itemizezzz}
1968
1969 \def\itemizezzz #1{%
1970   \begingroup % ended by the @end itemize
1971   \itemizey {#1}{\Eitemize}
1972 }
1973
1974 \def\itemizey #1#2{%
1975 \aboveenvbreak %
1976 \itemmax=\itemindent %
1977 \advance \itemmax by -\itemmargin %
1978 \advance \leftskip by \itemindent %
1979 \exdentamount=\itemindent
1980 \parindent = 0pt %
1981 \parskip = \smallskipamount %
1982 \ifdim \parskip=0pt \parskip=2pt \fi%
1983 \def#2{\endgraf\afterenvbreak\endgroup}%
1984 \def\itemcontents{#1}%
1985 \let\item=\itemizeitem}
1986
1987 % Set sfcode to normal for the chars that usually have another value.
1988 % These are `.?!:;,'
1989 \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
1990   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
1991
1992 % \splitoff TOKENS\endmark defines \first to be the first token in
1993 % TOKENS, and \rest to be the remainder.
1994 %
1995 \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
1996
1997 % Allow an optional argument of an uppercase letter, lowercase letter,
1998 % or number, to specify the first label in the enumerated list.  No
1999 % argument is the same as `1'.
2000 %
2001 \def\enumerate{\parsearg\enumeratezzz}
2002 \def\enumeratezzz #1{\enumeratey #1  \endenumeratey}
2003 \def\enumeratey #1 #2\endenumeratey{%
2004   \begingroup % ended by the @end enumerate
2005   %
2006   % If we were given no argument, pretend we were given `1'.
2007   \def\thearg{#1}%
2008   \ifx\thearg\empty \def\thearg{1}\fi
2009   %
2010   % Detect if the argument is a single token.  If so, it might be a
2011   % letter.  Otherwise, the only valid thing it can be is a number.
2012   % (We will always have one token, because of the test we just made.
2013   % This is a good thing, since \splitoff doesn't work given nothing at
2014   % all -- the first parameter is undelimited.)
2015   \expandafter\splitoff\thearg\endmark
2016   \ifx\rest\empty
2017     % Only one token in the argument.  It could still be anything.
2018     % A ``lowercase letter'' is one whose \lccode is nonzero.
2019     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
2020     %   not equal to itself.
2021     % Otherwise, we assume it's a number.
2022     %
2023     % We need the \relax at the end of the \ifnum lines to stop TeX from
2024     % continuing to look for a <number>.
2025     %
2026     \ifnum\lccode\expandafter`\thearg=0\relax
2027       \numericenumerate % a number (we hope)
2028     \else
2029       % It's a letter.
2030       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
2031         \lowercaseenumerate % lowercase letter
2032       \else
2033         \uppercaseenumerate % uppercase letter
2034       \fi
2035     \fi
2036   \else
2037     % Multiple tokens in the argument.  We hope it's a number.
2038     \numericenumerate
2039   \fi
2040 }
2041
2042 % An @enumerate whose labels are integers.  The starting integer is
2043 % given in \thearg.
2044 %
2045 \def\numericenumerate{%
2046   \itemno = \thearg
2047   \startenumeration{\the\itemno}%
2048 }
2049
2050 % The starting (lowercase) letter is in \thearg.
2051 \def\lowercaseenumerate{%
2052   \itemno = \expandafter`\thearg
2053   \startenumeration{%
2054     % Be sure we're not beyond the end of the alphabet.
2055     \ifnum\itemno=0
2056       \errmessage{No more lowercase letters in @enumerate; get a bigger
2057                   alphabet}%
2058     \fi
2059     \char\lccode\itemno
2060   }%
2061 }
2062
2063 % The starting (uppercase) letter is in \thearg.
2064 \def\uppercaseenumerate{%
2065   \itemno = \expandafter`\thearg
2066   \startenumeration{%
2067     % Be sure we're not beyond the end of the alphabet.
2068     \ifnum\itemno=0
2069       \errmessage{No more uppercase letters in @enumerate; get a bigger
2070                   alphabet}
2071     \fi
2072     \char\uccode\itemno
2073   }%
2074 }
2075
2076 % Call itemizey, adding a period to the first argument and supplying the
2077 % common last two arguments.  Also subtract one from the initial value in
2078 % \itemno, since @item increments \itemno.
2079 %
2080 \def\startenumeration#1{%
2081   \advance\itemno by -1
2082   \itemizey{#1.}\Eenumerate\flushcr
2083 }
2084
2085 % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
2086 % to @enumerate.
2087 %
2088 \def\alphaenumerate{\enumerate{a}}
2089 \def\capsenumerate{\enumerate{A}}
2090 \def\Ealphaenumerate{\Eenumerate}
2091 \def\Ecapsenumerate{\Eenumerate}
2092
2093 % Definition of @item while inside @itemize.
2094
2095 \def\itemizeitem{%
2096 \advance\itemno by 1
2097 {\let\par=\endgraf \smallbreak}%
2098 \ifhmode \errmessage{In hmode at itemizeitem}\fi
2099 {\parskip=0in \hskip 0pt
2100 \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
2101 \vadjust{\penalty 1200}}%
2102 \flushcr}
2103
2104 % @multitable macros
2105 % Amy Hendrickson, 8/18/94, 3/6/96
2106 %
2107 % @multitable ... @end multitable will make as many columns as desired.
2108 % Contents of each column will wrap at width given in preamble.  Width
2109 % can be specified either with sample text given in a template line,
2110 % or in percent of \hsize, the current width of text on page.
2111
2112 % Table can continue over pages but will only break between lines.
2113
2114 % To make preamble:
2115 %
2116 % Either define widths of columns in terms of percent of \hsize:
2117 %   @multitable @columnfractions .25 .3 .45
2118 %   @item ...
2119 %
2120 %   Numbers following @columnfractions are the percent of the total
2121 %   current hsize to be used for each column. You may use as many
2122 %   columns as desired.
2123
2124
2125 % Or use a template:
2126 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
2127 %   @item ...
2128 %   using the widest term desired in each column.
2129 %
2130 % For those who want to use more than one line's worth of words in
2131 % the preamble, break the line within one argument and it
2132 % will parse correctly, i.e.,
2133 %
2134 %     @multitable {Column 1 template} {Column 2 template} {Column 3
2135 %      template}
2136 % Not:
2137 %     @multitable {Column 1 template} {Column 2 template}
2138 %      {Column 3 template}
2139
2140 % Each new table line starts with @item, each subsequent new column
2141 % starts with @tab. Empty columns may be produced by supplying @tab's
2142 % with nothing between them for as many times as empty columns are needed,
2143 % ie, @tab@tab@tab will produce two empty columns.
2144
2145 % @item, @tab, @multitable or @end multitable do not need to be on their
2146 % own lines, but it will not hurt if they are.
2147
2148 % Sample multitable:
2149
2150 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
2151 %   @item first col stuff @tab second col stuff @tab third col
2152 %   @item
2153 %   first col stuff
2154 %   @tab
2155 %   second col stuff
2156 %   @tab
2157 %   third col
2158 %   @item first col stuff @tab second col stuff
2159 %   @tab Many paragraphs of text may be used in any column.
2160 %
2161 %         They will wrap at the width determined by the template.
2162 %   @item@tab@tab This will be in third column.
2163 %   @end multitable
2164
2165 % Default dimensions may be reset by user.
2166 % @multitableparskip is vertical space between paragraphs in table.
2167 % @multitableparindent is paragraph indent in table.
2168 % @multitablecolmargin is horizontal space to be left between columns.
2169 % @multitablelinespace is space to leave between table items, baseline
2170 %                                                            to baseline.
2171 %   0pt means it depends on current normal line spacing.
2172 %
2173 \newskip\multitableparskip
2174 \newskip\multitableparindent
2175 \newdimen\multitablecolspace
2176 \newskip\multitablelinespace
2177 \multitableparskip=0pt
2178 \multitableparindent=6pt
2179 \multitablecolspace=12pt
2180 \multitablelinespace=0pt
2181
2182 % Macros used to set up halign preamble:
2183 %
2184 \let\endsetuptable\relax
2185 \def\xendsetuptable{\endsetuptable}
2186 \let\columnfractions\relax
2187 \def\xcolumnfractions{\columnfractions}
2188 \newif\ifsetpercent
2189
2190 % #1 is the part of the @columnfraction before the decimal point, which
2191 % is presumably either 0 or the empty string (but we don't check, we
2192 % just throw it away).  #2 is the decimal part, which we use as the
2193 % percent of \hsize for this column.
2194 \def\pickupwholefraction#1.#2 {%
2195   \global\advance\colcount by 1
2196   \expandafter\xdef\csname col\the\colcount\endcsname{.#2\hsize}%
2197   \setuptable
2198 }
2199
2200 \newcount\colcount
2201 \def\setuptable#1{%
2202   \def\firstarg{#1}%
2203   \ifx\firstarg\xendsetuptable
2204     \let\go = \relax
2205   \else
2206     \ifx\firstarg\xcolumnfractions
2207       \global\setpercenttrue
2208     \else
2209       \ifsetpercent
2210          \let\go\pickupwholefraction
2211       \else
2212          \global\advance\colcount by 1
2213          \setbox0=\hbox{#1\unskip }% Add a normal word space as a separator;
2214                             % typically that is always in the input, anyway.
2215          \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
2216       \fi
2217     \fi
2218     \ifx\go\pickupwholefraction
2219       % Put the argument back for the \pickupwholefraction call, so
2220       % we'll always have a period there to be parsed.
2221       \def\go{\pickupwholefraction#1}%
2222     \else
2223       \let\go = \setuptable
2224     \fi%
2225   \fi
2226   \go
2227 }
2228
2229 % This used to have \hskip1sp.  But then the space in a template line is
2230 % not enough.  That is bad.  So let's go back to just & until we
2231 % encounter the problem it was intended to solve again.
2232 % --karl, nathan@acm.org, 20apr99.
2233 \def\tab{&}
2234
2235 % @multitable ... @end multitable definitions:
2236 %
2237 \def\multitable{\parsearg\dotable}
2238 \def\dotable#1{\bgroup
2239   \vskip\parskip
2240   \let\item\crcr
2241   \tolerance=9500
2242   \hbadness=9500
2243   \setmultitablespacing
2244   \parskip=\multitableparskip
2245   \parindent=\multitableparindent
2246   \overfullrule=0pt
2247   \global\colcount=0
2248   \def\Emultitable{\global\setpercentfalse\cr\egroup\egroup}%
2249   %
2250   % To parse everything between @multitable and @item:
2251   \setuptable#1 \endsetuptable
2252   %
2253   % \everycr will reset column counter, \colcount, at the end of
2254   % each line. Every column entry will cause \colcount to advance by one.
2255   % The table preamble
2256   % looks at the current \colcount to find the correct column width.
2257   \everycr{\noalign{%
2258   %
2259   % \filbreak%% keeps underfull box messages off when table breaks over pages.
2260   % Maybe so, but it also creates really weird page breaks when the table
2261   % breaks over pages. Wouldn't \vfil be better?  Wait until the problem
2262   % manifests itself, so it can be fixed for real --karl.
2263     \global\colcount=0\relax}}%
2264   %
2265   % This preamble sets up a generic column definition, which will
2266   % be used as many times as user calls for columns.
2267   % \vtop will set a single line and will also let text wrap and
2268   % continue for many paragraphs if desired.
2269   \halign\bgroup&\global\advance\colcount by 1\relax
2270     \multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname
2271   %
2272   % In order to keep entries from bumping into each other
2273   % we will add a \leftskip of \multitablecolspace to all columns after
2274   % the first one.
2275   %
2276   % If a template has been used, we will add \multitablecolspace
2277   % to the width of each template entry.
2278   %
2279   % If the user has set preamble in terms of percent of \hsize we will
2280   % use that dimension as the width of the column, and the \leftskip
2281   % will keep entries from bumping into each other.  Table will start at
2282   % left margin and final column will justify at right margin.
2283   %
2284   % Make sure we don't inherit \rightskip from the outer environment.
2285   \rightskip=0pt
2286   \ifnum\colcount=1
2287     % The first column will be indented with the surrounding text.
2288     \advance\hsize by\leftskip
2289   \else
2290     \ifsetpercent \else
2291       % If user has not set preamble in terms of percent of \hsize
2292       % we will advance \hsize by \multitablecolspace.
2293       \advance\hsize by \multitablecolspace
2294     \fi
2295    % In either case we will make \leftskip=\multitablecolspace:
2296   \leftskip=\multitablecolspace
2297   \fi
2298   % Ignoring space at the beginning and end avoids an occasional spurious
2299   % blank line, when TeX decides to break the line at the space before the
2300   % box from the multistrut, so the strut ends up on a line by itself.
2301   % For example:
2302   % @multitable @columnfractions .11 .89
2303   % @item @code{#}
2304   % @tab Legal holiday which is valid in major parts of the whole country.
2305   % Is automatically provided with highlighting sequences respectively marking
2306   % characters.
2307   \noindent\ignorespaces##\unskip\multistrut}\cr
2308 }
2309
2310 \def\setmultitablespacing{% test to see if user has set \multitablelinespace.
2311 % If so, do nothing. If not, give it an appropriate dimension based on
2312 % current baselineskip.
2313 \ifdim\multitablelinespace=0pt
2314 \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
2315 \global\advance\multitablelinespace by-\ht0
2316 %% strut to put in table in case some entry doesn't have descenders,
2317 %% to keep lines equally spaced
2318 \let\multistrut = \strut
2319 \else
2320 %% FIXME: what is \box0 supposed to be?
2321 \gdef\multistrut{\vrule height\multitablelinespace depth\dp0
2322 width0pt\relax} \fi
2323 %% Test to see if parskip is larger than space between lines of
2324 %% table. If not, do nothing.
2325 %%        If so, set to same dimension as multitablelinespace.
2326 \ifdim\multitableparskip>\multitablelinespace
2327 \global\multitableparskip=\multitablelinespace
2328 \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
2329                                       %% than skip between lines in the table.
2330 \fi%
2331 \ifdim\multitableparskip=0pt
2332 \global\multitableparskip=\multitablelinespace
2333 \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
2334                                       %% than skip between lines in the table.
2335 \fi}
2336
2337
2338 \message{conditionals,}
2339 % Prevent errors for section commands.
2340 % Used in @ignore and in failing conditionals.
2341 \def\ignoresections{%
2342   \let\chapter=\relax
2343   \let\unnumbered=\relax
2344   \let\top=\relax
2345   \let\unnumberedsec=\relax
2346   \let\unnumberedsection=\relax
2347   \let\unnumberedsubsec=\relax
2348   \let\unnumberedsubsection=\relax
2349   \let\unnumberedsubsubsec=\relax
2350   \let\unnumberedsubsubsection=\relax
2351   \let\section=\relax
2352   \let\subsec=\relax
2353   \let\subsubsec=\relax
2354   \let\subsection=\relax
2355   \let\subsubsection=\relax
2356   \let\appendix=\relax
2357   \let\appendixsec=\relax
2358   \let\appendixsection=\relax
2359   \let\appendixsubsec=\relax
2360   \let\appendixsubsection=\relax
2361   \let\appendixsubsubsec=\relax
2362   \let\appendixsubsubsection=\relax
2363   \let\contents=\relax
2364   \let\smallbook=\relax
2365   \let\titlepage=\relax
2366 }
2367
2368 % Used in nested conditionals, where we have to parse the Texinfo source
2369 % and so want to turn off most commands, in case they are used
2370 % incorrectly.
2371 %
2372 \def\ignoremorecommands{%
2373   \let\defcodeindex = \relax
2374   \let\defcv = \relax
2375   \let\deffn = \relax
2376   \let\deffnx = \relax
2377   \let\defindex = \relax
2378   \let\defivar = \relax
2379   \let\defmac = \relax
2380   \let\defmethod = \relax
2381   \let\defop = \relax
2382   \let\defopt = \relax
2383   \let\defspec = \relax
2384   \let\deftp = \relax
2385   \let\deftypefn = \relax
2386   \let\deftypefun = \relax
2387   \let\deftypeivar = \relax
2388   \let\deftypeop = \relax
2389   \let\deftypevar = \relax
2390   \let\deftypevr = \relax
2391   \let\defun = \relax
2392   \let\defvar = \relax
2393   \let\defvr = \relax
2394   \let\ref = \relax
2395   \let\xref = \relax
2396   \let\printindex = \relax
2397   \let\pxref = \relax
2398   \let\settitle = \relax
2399   \let\setchapternewpage = \relax
2400   \let\setchapterstyle = \relax
2401   \let\everyheading = \relax
2402   \let\evenheading = \relax
2403   \let\oddheading = \relax
2404   \let\everyfooting = \relax
2405   \let\evenfooting = \relax
2406   \let\oddfooting = \relax
2407   \let\headings = \relax
2408   \let\include = \relax
2409   \let\lowersections = \relax
2410   \let\down = \relax
2411   \let\raisesections = \relax
2412   \let\up = \relax
2413   \let\set = \relax
2414   \let\clear = \relax
2415   \let\item = \relax
2416 }
2417
2418 % Ignore @ignore, @ifhtml, @ifinfo, and the like.
2419 %
2420 \def\direntry{\doignore{direntry}}
2421 \def\documentdescriptionword{documentdescription}
2422 \def\documentdescription{\doignore{documentdescription}}
2423 \def\html{\doignore{html}}
2424 \def\ifhtml{\doignore{ifhtml}}
2425 \def\ifinfo{\doignore{ifinfo}}
2426 \def\ifnottex{\doignore{ifnottex}}
2427 \def\ifplaintext{\doignore{ifplaintext}}
2428 \def\ifxml{\doignore{ifxml}}
2429 \def\ignore{\doignore{ignore}}
2430 \def\menu{\doignore{menu}}
2431 \def\xml{\doignore{xml}}
2432
2433 % @dircategory CATEGORY  -- specify a category of the dir file
2434 % which this file should belong to.  Ignore this in TeX.
2435 \let\dircategory = \comment
2436
2437 % Ignore text until a line `@end #1'.
2438 %
2439 \def\doignore#1{\begingroup
2440   % Don't complain about control sequences we have declared \outer.
2441   \ignoresections
2442   %
2443   % Define a command to swallow text until we reach `@end #1'.
2444   % This @ is a catcode 12 token (that is the normal catcode of @ in
2445   % this texinfo.tex file).  We change the catcode of @ below to match.
2446   \long\def\doignoretext##1@end #1{\enddoignore}%
2447   %
2448   % Make sure that spaces turn into tokens that match what \doignoretext wants.
2449   \catcode32 = 10
2450   %
2451   % Ignore braces, too, so mismatched braces don't cause trouble.
2452   \catcode`\{ = 9
2453   \catcode`\} = 9
2454   %
2455   % We must not have @c interpreted as a control sequence.
2456   \catcode`\@ = 12
2457   %
2458   \def\ignoreword{#1}%
2459   \ifx\ignoreword\documentdescriptionword
2460     % The c kludge breaks documentdescription, since
2461     % `documentdescription' contains a `c'.  Means not everything will
2462     % be ignored inside @documentdescription, but oh well...
2463   \else
2464     % Make the letter c a comment character so that the rest of the line
2465     % will be ignored. This way, the document can have (for example)
2466     %   @c @end ifinfo
2467     % and the @end ifinfo will be properly ignored.
2468     % (We've just changed @ to catcode 12.)
2469     \catcode`\c = 14
2470   \fi
2471   %
2472   % And now expand the command defined above.
2473   \doignoretext
2474 }
2475
2476 % What we do to finish off ignored text.
2477 %
2478 \def\enddoignore{\endgroup\ignorespaces}%
2479
2480 \newif\ifwarnedobs\warnedobsfalse
2481 \def\obstexwarn{%
2482   \ifwarnedobs\relax\else
2483   % We need to warn folks that they may have trouble with TeX 3.0.
2484   % This uses \immediate\write16 rather than \message to get newlines.
2485     \immediate\write16{}
2486     \immediate\write16{WARNING: for users of Unix TeX 3.0!}
2487     \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
2488     \immediate\write16{If you are running another version of TeX, relax.}
2489     \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
2490     \immediate\write16{  Then upgrade your TeX installation if you can.}
2491     \immediate\write16{  (See ftp://ftp.gnu.org/pub/gnu/TeX.README.)}
2492     \immediate\write16{If you are stuck with version 3.0, run the}
2493     \immediate\write16{  script ``tex3patch'' from the Texinfo distribution}
2494     \immediate\write16{  to use a workaround.}
2495     \immediate\write16{}
2496     \global\warnedobstrue
2497     \fi
2498 }
2499
2500 % **In TeX 3.0, setting text in \nullfont hangs tex.  For a
2501 % workaround (which requires the file ``dummy.tfm'' to be installed),
2502 % uncomment the following line:
2503 %%%%%\font\nullfont=dummy\let\obstexwarn=\relax
2504
2505 % Ignore text, except that we keep track of conditional commands for
2506 % purposes of nesting, up to an `@end #1' command.
2507 %
2508 \def\nestedignore#1{%
2509   \obstexwarn
2510   % We must actually expand the ignored text to look for the @end
2511   % command, so that nested ignore constructs work.  Thus, we put the
2512   % text into a \vbox and then do nothing with the result.  To minimize
2513   % the chance of memory overflow, we follow the approach outlined on
2514   % page 401 of the TeXbook: make the current font be a dummy font.
2515   %
2516   \setbox0 = \vbox\bgroup
2517     % Don't complain about control sequences we have declared \outer.
2518     \ignoresections
2519     %
2520     % Define `@end #1' to end the box, which will in turn undefine the
2521     % @end command again.
2522     \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
2523     %
2524     % We are going to be parsing Texinfo commands.  Most cause no
2525     % trouble when they are used incorrectly, but some commands do
2526     % complicated argument parsing or otherwise get confused, so we
2527     % undefine them.
2528     %
2529     % We can't do anything about stray @-signs, unfortunately;
2530     % they'll produce `undefined control sequence' errors.
2531     \ignoremorecommands
2532     %
2533     % Set the current font to be \nullfont, a TeX primitive, and define
2534     % all the font commands to also use \nullfont.  We don't use
2535     % dummy.tfm, as suggested in the TeXbook, because not all sites
2536     % might have that installed.  Therefore, math mode will still
2537     % produce output, but that should be an extremely small amount of
2538     % stuff compared to the main input.
2539     %
2540     \nullfont
2541     \let\tenrm=\nullfont \let\tenit=\nullfont \let\tensl=\nullfont
2542     \let\tenbf=\nullfont \let\tentt=\nullfont \let\smallcaps=\nullfont
2543     \let\tensf=\nullfont
2544     % Similarly for index fonts.
2545     \let\smallrm=\nullfont \let\smallit=\nullfont \let\smallsl=\nullfont
2546     \let\smallbf=\nullfont \let\smalltt=\nullfont \let\smallsc=\nullfont
2547     \let\smallsf=\nullfont
2548     % Similarly for smallexample fonts.
2549     \let\smallerrm=\nullfont \let\smallerit=\nullfont \let\smallersl=\nullfont
2550     \let\smallerbf=\nullfont \let\smallertt=\nullfont \let\smallersc=\nullfont
2551     \let\smallersf=\nullfont
2552     %
2553     % Don't complain when characters are missing from the fonts.
2554     \tracinglostchars = 0
2555     %
2556     % Don't bother to do space factor calculations.
2557     \frenchspacing
2558     %
2559     % Don't report underfull hboxes.
2560     \hbadness = 10000
2561     %
2562     % Do minimal line-breaking.
2563     \pretolerance = 10000
2564     %
2565     % Do not execute instructions in @tex.
2566     \def\tex{\doignore{tex}}%
2567     % Do not execute macro definitions.
2568     % `c' is a comment character, so the word `macro' will get cut off.
2569     \def\macro{\doignore{ma}}%
2570 }
2571
2572 % @set VAR sets the variable VAR to an empty value.
2573 % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
2574 %
2575 % Since we want to separate VAR from REST-OF-LINE (which might be
2576 % empty), we can't just use \parsearg; we have to insert a space of our
2577 % own to delimit the rest of the line, and then take it out again if we
2578 % didn't need it.  Make sure the catcode of space is correct to avoid
2579 % losing inside @example, for instance.
2580 %
2581 \def\set{\begingroup\catcode` =10
2582   \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR.
2583   \parsearg\setxxx}
2584 \def\setxxx#1{\setyyy#1 \endsetyyy}
2585 \def\setyyy#1 #2\endsetyyy{%
2586   \def\temp{#2}%
2587   \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
2588   \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
2589   \fi
2590   \endgroup
2591 }
2592 % Can't use \xdef to pre-expand #2 and save some time, since \temp or
2593 % \next or other control sequences that we've defined might get us into
2594 % an infinite loop. Consider `@set foo @cite{bar}'.
2595 \def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}}
2596
2597 % @clear VAR clears (i.e., unsets) the variable VAR.
2598 %
2599 \def\clear{\parsearg\clearxxx}
2600 \def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax}
2601
2602 % @value{foo} gets the text saved in variable foo.
2603 {
2604   \catcode`\_ = \active
2605   %
2606   % We might end up with active _ or - characters in the argument if
2607   % we're called from @code, as @code{@value{foo-bar_}}.  So \let any
2608   % such active characters to their normal equivalents.
2609   \gdef\value{\begingroup
2610     \catcode`\-=12 \catcode`\_=12
2611     \indexbreaks \let_\normalunderscore
2612     \valuexxx}
2613 }
2614 \def\valuexxx#1{\expandablevalue{#1}\endgroup}
2615
2616 % We have this subroutine so that we can handle at least some @value's
2617 % properly in indexes (we \let\value to this in \indexdummies).  Ones
2618 % whose names contain - or _ still won't work, but we can't do anything
2619 % about that.  The command has to be fully expandable, since the result
2620 % winds up in the index file.  This means that if the variable's value
2621 % contains other Texinfo commands, it's almost certain it will fail
2622 % (although perhaps we could fix that with sufficient work to do a
2623 % one-level expansion on the result, instead of complete).
2624 %
2625 \def\expandablevalue#1{%
2626   \expandafter\ifx\csname SET#1\endcsname\relax
2627     {[No value for ``#1'']}%
2628   \else
2629     \csname SET#1\endcsname
2630   \fi
2631 }
2632
2633 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
2634 % with @set.
2635 %
2636 \def\ifset{\parsearg\ifsetxxx}
2637 \def\ifsetxxx #1{%
2638   \expandafter\ifx\csname SET#1\endcsname\relax
2639     \expandafter\ifsetfail
2640   \else
2641     \expandafter\ifsetsucceed
2642   \fi
2643 }
2644 \def\ifsetsucceed{\conditionalsucceed{ifset}}
2645 \def\ifsetfail{\nestedignore{ifset}}
2646 \defineunmatchedend{ifset}
2647
2648 % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
2649 % defined with @set, or has been undefined with @clear.
2650 %
2651 \def\ifclear{\parsearg\ifclearxxx}
2652 \def\ifclearxxx #1{%
2653   \expandafter\ifx\csname SET#1\endcsname\relax
2654     \expandafter\ifclearsucceed
2655   \else
2656     \expandafter\ifclearfail
2657   \fi
2658 }
2659 \def\ifclearsucceed{\conditionalsucceed{ifclear}}
2660 \def\ifclearfail{\nestedignore{ifclear}}
2661 \defineunmatchedend{ifclear}
2662
2663 % @iftex, @ifnothtml, @ifnotinfo, @ifnotplaintext always succeed; we
2664 % read the text following, through the first @end iftex (etc.).  Make
2665 % `@end iftex' (etc.) valid only after an @iftex.
2666 %
2667 \def\iftex{\conditionalsucceed{iftex}}
2668 \def\ifnothtml{\conditionalsucceed{ifnothtml}}
2669 \def\ifnotinfo{\conditionalsucceed{ifnotinfo}}
2670 \def\ifnotplaintext{\conditionalsucceed{ifnotplaintext}}
2671 \defineunmatchedend{iftex}
2672 \defineunmatchedend{ifnothtml}
2673 \defineunmatchedend{ifnotinfo}
2674 \defineunmatchedend{ifnotplaintext}
2675
2676 % We can't just want to start a group at @iftex (etc.) and end it at
2677 % @end iftex, since then @set commands inside the conditional have no
2678 % effect (they'd get reverted at the end of the group).  So we must
2679 % define \Eiftex to redefine itself to be its previous value.  (We can't
2680 % just define it to fail again with an ``unmatched end'' error, since
2681 % the @ifset might be nested.)
2682 %
2683 \def\conditionalsucceed#1{%
2684   \edef\temp{%
2685     % Remember the current value of \E#1.
2686     \let\nece{prevE#1} = \nece{E#1}%
2687     %
2688     % At the `@end #1', redefine \E#1 to be its previous value.
2689     \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
2690   }%
2691   \temp
2692 }
2693
2694 % We need to expand lots of \csname's, but we don't want to expand the
2695 % control sequences after we've constructed them.
2696 %
2697 \def\nece#1{\expandafter\noexpand\csname#1\endcsname}
2698
2699 % @defininfoenclose.
2700 \let\definfoenclose=\comment
2701
2702
2703 \message{indexing,}
2704 % Index generation facilities
2705
2706 % Define \newwrite to be identical to plain tex's \newwrite
2707 % except not \outer, so it can be used within \newindex.
2708 {\catcode`\@=11
2709 \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
2710
2711 % \newindex {foo} defines an index named foo.
2712 % It automatically defines \fooindex such that
2713 % \fooindex ...rest of line... puts an entry in the index foo.
2714 % It also defines \fooindfile to be the number of the output channel for
2715 % the file that accumulates this index.  The file's extension is foo.
2716 % The name of an index should be no more than 2 characters long
2717 % for the sake of vms.
2718 %
2719 \def\newindex#1{%
2720   \iflinks
2721     \expandafter\newwrite \csname#1indfile\endcsname
2722     \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
2723   \fi
2724   \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
2725     \noexpand\doindex{#1}}
2726 }
2727
2728 % @defindex foo  ==  \newindex{foo}
2729 %
2730 \def\defindex{\parsearg\newindex}
2731
2732 % Define @defcodeindex, like @defindex except put all entries in @code.
2733 %
2734 \def\defcodeindex{\parsearg\newcodeindex}
2735 %
2736 \def\newcodeindex#1{%
2737   \iflinks
2738     \expandafter\newwrite \csname#1indfile\endcsname
2739     \openout \csname#1indfile\endcsname \jobname.#1
2740   \fi
2741   \expandafter\xdef\csname#1index\endcsname{%
2742     \noexpand\docodeindex{#1}}%
2743 }
2744
2745
2746 % @synindex foo bar    makes index foo feed into index bar.
2747 % Do this instead of @defindex foo if you don't want it as a separate index.
2748
2749 % @syncodeindex foo bar   similar, but put all entries made for index foo
2750 % inside @code.
2751
2752 \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
2753 \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
2754
2755 % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
2756 % #3 the target index (bar).
2757 \def\dosynindex#1#2#3{%
2758   % Only do \closeout if we haven't already done it, else we'll end up
2759   % closing the target index.
2760   \expandafter \ifx\csname donesynindex#2\endcsname \undefined
2761     % The \closeout helps reduce unnecessary open files; the limit on the
2762     % Acorn RISC OS is a mere 16 files.
2763     \expandafter\closeout\csname#2indfile\endcsname
2764     \expandafter\let\csname\donesynindex#2\endcsname = 1
2765   \fi
2766   % redefine \fooindfile:
2767   \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
2768   \expandafter\let\csname#2indfile\endcsname=\temp
2769   % redefine \fooindex:
2770   \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
2771 }
2772
2773 % Define \doindex, the driver for all \fooindex macros.
2774 % Argument #1 is generated by the calling \fooindex macro,
2775 %  and it is "foo", the name of the index.
2776
2777 % \doindex just uses \parsearg; it calls \doind for the actual work.
2778 % This is because \doind is more useful to call from other macros.
2779
2780 % There is also \dosubind {index}{topic}{subtopic}
2781 % which makes an entry in a two-level index such as the operation index.
2782
2783 \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
2784 \def\singleindexer #1{\doind{\indexname}{#1}}
2785
2786 % like the previous two, but they put @code around the argument.
2787 \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
2788 \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
2789
2790 % Take care of texinfo commands likely to appear in an index entry.
2791 % (Must be a way to avoid doing expansion at all, and thus not have to
2792 % laboriously list every single command here.)
2793
2794 \def\indexdummies{%
2795 \def\ { }%
2796 \def\@{@}% change to @@ when we switch to @ as escape char in aux files.
2797 % Need these in case \tex is in effect and \{ is a \delimiter again.
2798 % But can't use \lbracecmd and \rbracecmd because texindex assumes
2799 % braces and backslashes are used only as delimiters.  
2800 \let\{ = \mylbrace
2801 \let\} = \myrbrace
2802 \def\_{{\realbackslash _}}%
2803 \normalturnoffactive
2804 %
2805 % Take care of the plain tex accent commands.
2806 \def\,##1{\realbackslash ,{##1}}%
2807 \def\"{\realbackslash "}%
2808 \def\`{\realbackslash `}%
2809 \def\'{\realbackslash '}%
2810 \def\^{\realbackslash ^}%
2811 \def\~{\realbackslash ~}%
2812 \def\={\realbackslash =}%
2813 \def\b{\realbackslash b}%
2814 \def\c{\realbackslash c}%
2815 \def\d{\realbackslash d}%
2816 \def\u{\realbackslash u}%
2817 \def\v{\realbackslash v}%
2818 \def\H{\realbackslash H}%
2819 \def\dotless##1{\realbackslash dotless {##1}}%
2820 % Take care of the plain tex special European modified letters.
2821 \def\AA{\realbackslash AA}%
2822 \def\AE{\realbackslash AE}%
2823 \def\L{\realbackslash L}%
2824 \def\OE{\realbackslash OE}%
2825 \def\O{\realbackslash O}%
2826 \def\aa{\realbackslash aa}%
2827 \def\ae{\realbackslash ae}%
2828 \def\l{\realbackslash l}%
2829 \def\oe{\realbackslash oe}%
2830 \def\o{\realbackslash o}%
2831 \def\ss{\realbackslash ss}%
2832 %
2833 % Although these internals commands shouldn't show up, sometimes they do.
2834 \def\bf{\realbackslash bf }%
2835 \def\gtr{\realbackslash gtr}%
2836 \def\hat{\realbackslash hat}%
2837 \def\less{\realbackslash less}%
2838 %\def\rm{\realbackslash rm }%
2839 \def\sf{\realbackslash sf}%
2840 \def\sl{\realbackslash sl }%
2841 \def\tclose##1{\realbackslash tclose {##1}}%
2842 \def\tt{\realbackslash tt}%
2843 %
2844 \def\b##1{\realbackslash b {##1}}%
2845 \def\i##1{\realbackslash i {##1}}%
2846 \def\sc##1{\realbackslash sc {##1}}%
2847 \def\t##1{\realbackslash t {##1}}%
2848 \def\r##1{\realbackslash r {##1}}%
2849 %
2850 \def\TeX{\realbackslash TeX}%
2851 \def\acronym##1{\realbackslash acronym {##1}}%
2852 \def\cite##1{\realbackslash cite {##1}}%
2853 \def\code##1{\realbackslash code {##1}}%
2854 \def\command##1{\realbackslash command {##1}}%
2855 \def\dfn##1{\realbackslash dfn {##1}}%
2856 \def\dots{\realbackslash dots }%
2857 \def\emph##1{\realbackslash emph {##1}}%
2858 \def\env##1{\realbackslash env {##1}}%
2859 \def\file##1{\realbackslash file {##1}}%
2860 \def\kbd##1{\realbackslash kbd {##1}}%
2861 \def\key##1{\realbackslash key {##1}}%
2862 \def\math##1{\realbackslash math {##1}}%
2863 \def\option##1{\realbackslash option {##1}}%
2864 \def\samp##1{\realbackslash samp {##1}}%
2865 \def\strong##1{\realbackslash strong {##1}}%
2866 \def\uref##1{\realbackslash uref {##1}}%
2867 \def\url##1{\realbackslash url {##1}}%
2868 \def\var##1{\realbackslash var {##1}}%
2869 \def\w{\realbackslash w }%
2870 %
2871 % These math commands don't seem likely to be used in index entries.
2872 \def\copyright{\realbackslash copyright}%
2873 \def\equiv{\realbackslash equiv}%
2874 \def\error{\realbackslash error}%
2875 \def\expansion{\realbackslash expansion}%
2876 \def\point{\realbackslash point}%
2877 \def\print{\realbackslash print}%
2878 \def\result{\realbackslash result}%
2879 %
2880 % Handle some cases of @value -- where the variable name does not
2881 % contain - or _, and the value does not contain any
2882 % (non-fully-expandable) commands.
2883 \let\value = \expandablevalue
2884 %
2885 \unsepspaces
2886 % Turn off macro expansion
2887 \turnoffmacros
2888 }
2889
2890 % If an index command is used in an @example environment, any spaces
2891 % therein should become regular spaces in the raw index file, not the
2892 % expansion of \tie (\leavevmode \penalty \@M \ ).
2893 {\obeyspaces
2894  \gdef\unsepspaces{\obeyspaces\let =\space}}
2895
2896 % \indexnofonts no-ops all font-change commands.
2897 % This is used when outputting the strings to sort the index by.
2898 \def\indexdummyfont#1{#1}
2899 \def\indexdummytex{TeX}
2900 \def\indexdummydots{...}
2901
2902 \def\indexnofonts{%
2903 \def\@{@}%
2904 % how to handle braces?
2905 \def\_{\normalunderscore}%
2906 %
2907 \let\,=\indexdummyfont
2908 \let\"=\indexdummyfont
2909 \let\`=\indexdummyfont
2910 \let\'=\indexdummyfont
2911 \let\^=\indexdummyfont
2912 \let\~=\indexdummyfont
2913 \let\==\indexdummyfont
2914 \let\b=\indexdummyfont
2915 \let\c=\indexdummyfont
2916 \let\d=\indexdummyfont
2917 \let\u=\indexdummyfont
2918 \let\v=\indexdummyfont
2919 \let\H=\indexdummyfont
2920 \let\dotless=\indexdummyfont
2921 % Take care of the plain tex special European modified letters.
2922 \def\AA{AA}%
2923 \def\AE{AE}%
2924 \def\L{L}%
2925 \def\OE{OE}%
2926 \def\O{O}%
2927 \def\aa{aa}%
2928 \def\ae{ae}%
2929 \def\l{l}%
2930 \def\oe{oe}%
2931 \def\o{o}%
2932 \def\ss{ss}%
2933 %
2934 % Don't no-op \tt, since it isn't a user-level command
2935 % and is used in the definitions of the active chars like <, >, |, etc.
2936 % Likewise with the other plain tex font commands.
2937 %\let\tt=\indexdummyfont
2938 %
2939 \let\b=\indexdummyfont
2940 \let\i=\indexdummyfont
2941 \let\r=\indexdummyfont
2942 \let\sc=\indexdummyfont
2943 \let\t=\indexdummyfont
2944 %
2945 \let\TeX=\indexdummytex
2946 \let\acronym=\indexdummyfont
2947 \let\cite=\indexdummyfont
2948 \let\code=\indexdummyfont
2949 \let\command=\indexdummyfont
2950 \let\dfn=\indexdummyfont
2951 \let\dots=\indexdummydots
2952 \let\emph=\indexdummyfont
2953 \let\env=\indexdummyfont
2954 \let\file=\indexdummyfont
2955 \let\kbd=\indexdummyfont
2956 \let\key=\indexdummyfont
2957 \let\math=\indexdummyfont
2958 \let\option=\indexdummyfont
2959 \let\samp=\indexdummyfont
2960 \let\strong=\indexdummyfont
2961 \let\uref=\indexdummyfont
2962 \let\url=\indexdummyfont
2963 \let\var=\indexdummyfont
2964 \let\w=\indexdummyfont
2965 }
2966
2967 % To define \realbackslash, we must make \ not be an escape.
2968 % We must first make another character (@) an escape
2969 % so we do not become unable to do a definition.
2970
2971 {\catcode`\@=0 \catcode`\\=\other
2972  @gdef@realbackslash{\}}
2973
2974 \let\indexbackslash=0  %overridden during \printindex.
2975 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
2976
2977 % For \ifx comparisons.
2978 \def\emptymacro{\empty}
2979
2980 % Most index entries go through here, but \dosubind is the general case.
2981 %
2982 \def\doind#1#2{\dosubind{#1}{#2}\empty}
2983
2984 % Workhorse for all \fooindexes.
2985 % #1 is name of index, #2 is stuff to put there, #3 is subentry --
2986 % \empty if called from \doind, as we usually are.  The main exception
2987 % is with defuns, which call us directly.
2988 %
2989 \def\dosubind#1#2#3{%
2990   % Put the index entry in the margin if desired.
2991   \ifx\SETmarginindex\relax\else
2992     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}%
2993   \fi
2994   {%
2995     \count255=\lastpenalty
2996     {%
2997       \indexdummies % Must do this here, since \bf, etc expand at this stage
2998       \escapechar=`\\
2999       {%
3000         \let\folio = 0% We will expand all macros now EXCEPT \folio.
3001         \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
3002         % so it will be output as is; and it will print as backslash.
3003         %
3004         \def\thirdarg{#3}%
3005         %
3006         % If third arg is present, precede it with space in sort key.
3007         \ifx\thirdarg\emptymacro
3008           \let\subentry = \empty
3009         \else
3010           \def\subentry{ #3}%
3011         \fi
3012         %
3013         % First process the index entry with all font commands turned
3014         % off to get the string to sort by.
3015         {\indexnofonts \xdef\indexsorttmp{#2\subentry}}%
3016         %
3017         % Now the real index entry with the fonts.
3018         \toks0 = {#2}%
3019         %
3020         % If the third (subentry) arg is present, add it to the index
3021         % line to write.
3022         \ifx\thirdarg\emptymacro \else
3023           \toks0 = \expandafter{\the\toks0{#3}}%
3024         \fi
3025         %
3026         % Set up the complete index entry, with both the sort key and
3027         % the original text, including any font commands.  We write
3028         % three arguments to \entry to the .?? file (four in the
3029         % subentry case), texindex reduces to two when writing the .??s
3030         % sorted result.
3031         \edef\temp{%
3032           \write\csname#1indfile\endcsname{%
3033             \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}%
3034         }%
3035         %
3036         % If a skip is the last thing on the list now, preserve it
3037         % by backing up by \lastskip, doing the \write, then inserting
3038         % the skip again.  Otherwise, the whatsit generated by the
3039         % \write will make \lastskip zero.  The result is that sequences
3040         % like this:
3041         % @end defun
3042         % @tindex whatever
3043         % @defun ...
3044         % will have extra space inserted, because the \medbreak in the
3045         % start of the @defun won't see the skip inserted by the @end of
3046         % the previous defun.
3047         %
3048         % But don't do any of this if we're not in vertical mode.  We
3049         % don't want to do a \vskip and prematurely end a paragraph.
3050         %
3051         % Avoid page breaks due to these extra skips, too.
3052         %
3053         \iflinks
3054           \ifvmode
3055             \skip0 = \lastskip
3056             \ifdim\lastskip = 0pt \else \nobreak\vskip-\lastskip \fi
3057           \fi
3058           %
3059           \temp % do the write
3060           %
3061           %
3062           \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi
3063         \fi
3064       }%
3065     }%
3066     \penalty\count255
3067   }%
3068 }
3069
3070 % The index entry written in the file actually looks like
3071 %  \entry {sortstring}{page}{topic}
3072 % or
3073 %  \entry {sortstring}{page}{topic}{subtopic}
3074 % The texindex program reads in these files and writes files
3075 % containing these kinds of lines:
3076 %  \initial {c}
3077 %     before the first topic whose initial is c
3078 %  \entry {topic}{pagelist}
3079 %     for a topic that is used without subtopics
3080 %  \primary {topic}
3081 %     for the beginning of a topic that is used with subtopics
3082 %  \secondary {subtopic}{pagelist}
3083 %     for each subtopic.
3084
3085 % Define the user-accessible indexing commands
3086 % @findex, @vindex, @kindex, @cindex.
3087
3088 \def\findex {\fnindex}
3089 \def\kindex {\kyindex}
3090 \def\cindex {\cpindex}
3091 \def\vindex {\vrindex}
3092 \def\tindex {\tpindex}
3093 \def\pindex {\pgindex}
3094
3095 \def\cindexsub {\begingroup\obeylines\cindexsub}
3096 {\obeylines %
3097 \gdef\cindexsub "#1" #2^^M{\endgroup %
3098 \dosubind{cp}{#2}{#1}}}
3099
3100 % Define the macros used in formatting output of the sorted index material.
3101
3102 % @printindex causes a particular index (the ??s file) to get printed.
3103 % It does not print any chapter heading (usually an @unnumbered).
3104 %
3105 \def\printindex{\parsearg\doprintindex}
3106 \def\doprintindex#1{\begingroup
3107   \dobreak \chapheadingskip{10000}%
3108   %
3109   \smallfonts \rm
3110   \tolerance = 9500
3111   \indexbreaks
3112   %
3113   % See if the index file exists and is nonempty.
3114   % Change catcode of @ here so that if the index file contains
3115   % \initial {@}
3116   % as its first line, TeX doesn't complain about mismatched braces
3117   % (because it thinks @} is a control sequence).
3118   \catcode`\@ = 11
3119   \openin 1 \jobname.#1s
3120   \ifeof 1
3121     % \enddoublecolumns gets confused if there is no text in the index,
3122     % and it loses the chapter title and the aux file entries for the
3123     % index.  The easiest way to prevent this problem is to make sure
3124     % there is some text.
3125     \putwordIndexNonexistent
3126   \else
3127     %
3128     % If the index file exists but is empty, then \openin leaves \ifeof
3129     % false.  We have to make TeX try to read something from the file, so
3130     % it can discover if there is anything in it.
3131     \read 1 to \temp
3132     \ifeof 1
3133       \putwordIndexIsEmpty
3134     \else
3135       % Index files are almost Texinfo source, but we use \ as the escape
3136       % character.  It would be better to use @, but that's too big a change
3137       % to make right now.
3138       \def\indexbackslash{\rawbackslashxx}%
3139       \catcode`\\ = 0
3140       \escapechar = `\\
3141       \begindoublecolumns
3142       \input \jobname.#1s
3143       \enddoublecolumns
3144     \fi
3145   \fi
3146   \closein 1
3147 \endgroup}
3148
3149 % These macros are used by the sorted index file itself.
3150 % Change them to control the appearance of the index.
3151
3152 \def\initial#1{{%
3153   % Some minor font changes for the special characters.
3154   \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
3155   %
3156   % Remove any glue we may have, we'll be inserting our own.
3157   \removelastskip
3158   %
3159   % We like breaks before the index initials, so insert a bonus.
3160   \penalty -300
3161   %
3162   % Typeset the initial.  Making this add up to a whole number of
3163   % baselineskips increases the chance of the dots lining up from column
3164   % to column.  It still won't often be perfect, because of the stretch
3165   % we need before each entry, but it's better.
3166   %
3167   % No shrink because it confuses \balancecolumns.
3168   \vskip 1.67\baselineskip plus .5\baselineskip
3169   \leftline{\secbf #1}%
3170   \vskip .33\baselineskip plus .1\baselineskip
3171   %
3172   % Do our best not to break after the initial.
3173   \nobreak
3174 }}
3175
3176 % This typesets a paragraph consisting of #1, dot leaders, and then #2
3177 % flush to the right margin.  It is used for index and table of contents
3178 % entries.  The paragraph is indented by \leftskip.
3179 %
3180 \def\entry#1#2{\begingroup
3181   %
3182   % Start a new paragraph if necessary, so our assignments below can't
3183   % affect previous text.
3184   \par
3185   %
3186   % Do not fill out the last line with white space.
3187   \parfillskip = 0in
3188   %
3189   % No extra space above this paragraph.
3190   \parskip = 0in
3191   %
3192   % Do not prefer a separate line ending with a hyphen to fewer lines.
3193   \finalhyphendemerits = 0
3194   %
3195   % \hangindent is only relevant when the entry text and page number
3196   % don't both fit on one line.  In that case, bob suggests starting the
3197   % dots pretty far over on the line.  Unfortunately, a large
3198   % indentation looks wrong when the entry text itself is broken across
3199   % lines.  So we use a small indentation and put up with long leaders.
3200   %
3201   % \hangafter is reset to 1 (which is the value we want) at the start
3202   % of each paragraph, so we need not do anything with that.
3203   \hangindent = 2em
3204   %
3205   % When the entry text needs to be broken, just fill out the first line
3206   % with blank space.
3207   \rightskip = 0pt plus1fil
3208   %
3209   % A bit of stretch before each entry for the benefit of balancing columns.
3210   \vskip 0pt plus1pt
3211   %
3212   % Start a ``paragraph'' for the index entry so the line breaking
3213   % parameters we've set above will have an effect.
3214   \noindent
3215   %
3216   % Insert the text of the index entry.  TeX will do line-breaking on it.
3217   #1%
3218   % The following is kludged to not output a line of dots in the index if
3219   % there are no page numbers.  The next person who breaks this will be
3220   % cursed by a Unix daemon.
3221   \def\tempa{{\rm }}%
3222   \def\tempb{#2}%
3223   \edef\tempc{\tempa}%
3224   \edef\tempd{\tempb}%
3225   \ifx\tempc\tempd\ \else%
3226     %
3227     % If we must, put the page number on a line of its own, and fill out
3228     % this line with blank space.  (The \hfil is overwhelmed with the
3229     % fill leaders glue in \indexdotfill if the page number does fit.)
3230     \hfil\penalty50
3231     \null\nobreak\indexdotfill % Have leaders before the page number.
3232     %
3233     % The `\ ' here is removed by the implicit \unskip that TeX does as
3234     % part of (the primitive) \par.  Without it, a spurious underfull
3235     % \hbox ensues.
3236     \ifpdf
3237       \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
3238     \else
3239       \ #2% The page number ends the paragraph.
3240     \fi
3241   \fi%
3242   \par
3243 \endgroup}
3244
3245 % Like \dotfill except takes at least 1 em.
3246 \def\indexdotfill{\cleaders
3247   \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
3248
3249 \def\primary #1{\line{#1\hfil}}
3250
3251 \newskip\secondaryindent \secondaryindent=0.5cm
3252 \def\secondary#1#2{{%
3253   \parfillskip=0in
3254   \parskip=0in
3255   \hangindent=1in
3256   \hangafter=1
3257   \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
3258   \ifpdf
3259     \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
3260   \else
3261     #2
3262   \fi
3263   \par
3264 }}
3265
3266 % Define two-column mode, which we use to typeset indexes.
3267 % Adapted from the TeXbook, page 416, which is to say,
3268 % the manmac.tex format used to print the TeXbook itself.
3269 \catcode`\@=11
3270
3271 \newbox\partialpage
3272 \newdimen\doublecolumnhsize
3273
3274 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
3275   % Grab any single-column material above us.
3276   \output = {%
3277     %
3278     % Here is a possibility not foreseen in manmac: if we accumulate a
3279     % whole lot of material, we might end up calling this \output
3280     % routine twice in a row (see the doublecol-lose test, which is
3281     % essentially a couple of indexes with @setchapternewpage off).  In
3282     % that case we just ship out what is in \partialpage with the normal
3283     % output routine.  Generally, \partialpage will be empty when this
3284     % runs and this will be a no-op.  See the indexspread.tex test case.
3285     \ifvoid\partialpage \else
3286       \onepageout{\pagecontents\partialpage}%
3287     \fi
3288     %
3289     \global\setbox\partialpage = \vbox{%
3290       % Unvbox the main output page.
3291       \unvbox\PAGE
3292       \kern-\topskip \kern\baselineskip
3293     }%
3294   }%
3295   \eject % run that output routine to set \partialpage
3296   %
3297   % Use the double-column output routine for subsequent pages.
3298   \output = {\doublecolumnout}%
3299   %
3300   % Change the page size parameters.  We could do this once outside this
3301   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
3302   % format, but then we repeat the same computation.  Repeating a couple
3303   % of assignments once per index is clearly meaningless for the
3304   % execution time, so we may as well do it in one place.
3305   %
3306   % First we halve the line length, less a little for the gutter between
3307   % the columns.  We compute the gutter based on the line length, so it
3308   % changes automatically with the paper format.  The magic constant
3309   % below is chosen so that the gutter has the same value (well, +-<1pt)
3310   % as it did when we hard-coded it.
3311   %
3312   % We put the result in a separate register, \doublecolumhsize, so we
3313   % can restore it in \pagesofar, after \hsize itself has (potentially)
3314   % been clobbered.
3315   %
3316   \doublecolumnhsize = \hsize
3317     \advance\doublecolumnhsize by -.04154\hsize
3318     \divide\doublecolumnhsize by 2
3319   \hsize = \doublecolumnhsize
3320   %
3321   % Double the \vsize as well.  (We don't need a separate register here,
3322   % since nobody clobbers \vsize.)
3323   \vsize = 2\vsize
3324 }
3325
3326 % The double-column output routine for all double-column pages except
3327 % the last.
3328 %
3329 \def\doublecolumnout{%
3330   \splittopskip=\topskip \splitmaxdepth=\maxdepth
3331   % Get the available space for the double columns -- the normal
3332   % (undoubled) page height minus any material left over from the
3333   % previous page.
3334   \dimen@ = \vsize
3335   \divide\dimen@ by 2
3336   \advance\dimen@ by -\ht\partialpage
3337   %
3338   % box0 will be the left-hand column, box2 the right.
3339   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
3340   \onepageout\pagesofar
3341   \unvbox255
3342   \penalty\outputpenalty
3343 }
3344 %
3345 % Re-output the contents of the output page -- any previous material,
3346 % followed by the two boxes we just split, in box0 and box2.
3347 \def\pagesofar{%
3348   \unvbox\partialpage
3349   %
3350   \hsize = \doublecolumnhsize
3351   \wd0=\hsize \wd2=\hsize
3352   \hbox to\pagewidth{\box0\hfil\box2}%
3353 }
3354
3355 % All done with double columns.
3356 \def\enddoublecolumns{%
3357   \output = {%
3358     % Split the last of the double-column material.  Leave it on the
3359     % current page, no automatic page break.
3360     \balancecolumns
3361     %
3362     % If we end up splitting too much material for the current page,
3363     % though, there will be another page break right after this \output
3364     % invocation ends.  Having called \balancecolumns once, we do not
3365     % want to call it again.  Therefore, reset \output to its normal
3366     % definition right away.  (We hope \balancecolumns will never be
3367     % called on to balance too much material, but if it is, this makes
3368     % the output somewhat more palatable.)
3369     \global\output = {\onepageout{\pagecontents\PAGE}}%
3370   }%
3371   \eject
3372   \endgroup % started in \begindoublecolumns
3373   %
3374   % \pagegoal was set to the doubled \vsize above, since we restarted
3375   % the current page.  We're now back to normal single-column
3376   % typesetting, so reset \pagegoal to the normal \vsize (after the
3377   % \endgroup where \vsize got restored).
3378   \pagegoal = \vsize
3379 }
3380 %
3381 % Called at the end of the double column material.
3382 \def\balancecolumns{%
3383   \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
3384   \dimen@ = \ht0
3385   \advance\dimen@ by \topskip
3386   \advance\dimen@ by-\baselineskip
3387   \divide\dimen@ by 2 % target to split to
3388   %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}%
3389   \splittopskip = \topskip
3390   % Loop until we get a decent breakpoint.
3391   {%
3392     \vbadness = 10000
3393     \loop
3394       \global\setbox3 = \copy0
3395       \global\setbox1 = \vsplit3 to \dimen@
3396     \ifdim\ht3>\dimen@
3397       \global\advance\dimen@ by 1pt
3398     \repeat
3399   }%
3400   %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
3401   \setbox0=\vbox to\dimen@{\unvbox1}%
3402   \setbox2=\vbox to\dimen@{\unvbox3}%
3403   %
3404   \pagesofar
3405 }
3406 \catcode`\@ = \other
3407
3408
3409 \message{sectioning,}
3410 % Chapters, sections, etc.
3411
3412 \newcount\chapno
3413 \newcount\secno        \secno=0
3414 \newcount\subsecno     \subsecno=0
3415 \newcount\subsubsecno  \subsubsecno=0
3416
3417 % This counter is funny since it counts through charcodes of letters A, B, ...
3418 \newcount\appendixno  \appendixno = `\@
3419 % \def\appendixletter{\char\the\appendixno}
3420 % We do the following for the sake of pdftex, which needs the actual
3421 % letter in the expansion, not just typeset.
3422 \def\appendixletter{%
3423   \ifnum\appendixno=`A A%
3424   \else\ifnum\appendixno=`B B%
3425   \else\ifnum\appendixno=`C C%
3426   \else\ifnum\appendixno=`D D%
3427   \else\ifnum\appendixno=`E E%
3428   \else\ifnum\appendixno=`F F%
3429   \else\ifnum\appendixno=`G G%
3430   \else\ifnum\appendixno=`H H%
3431   \else\ifnum\appendixno=`I I%
3432   \else\ifnum\appendixno=`J J%
3433   \else\ifnum\appendixno=`K K%
3434   \else\ifnum\appendixno=`L L%
3435   \else\ifnum\appendixno=`M M%
3436   \else\ifnum\appendixno=`N N%
3437   \else\ifnum\appendixno=`O O%
3438   \else\ifnum\appendixno=`P P%
3439   \else\ifnum\appendixno=`Q Q%
3440   \else\ifnum\appendixno=`R R%
3441   \else\ifnum\appendixno=`S S%
3442   \else\ifnum\appendixno=`T T%
3443   \else\ifnum\appendixno=`U U%
3444   \else\ifnum\appendixno=`V V%
3445   \else\ifnum\appendixno=`W W%
3446   \else\ifnum\appendixno=`X X%
3447   \else\ifnum\appendixno=`Y Y%
3448   \else\ifnum\appendixno=`Z Z%
3449   % The \the is necessary, despite appearances, because \appendixletter is
3450   % expanded while writing the .toc file.  \char\appendixno is not
3451   % expandable, thus it is written literally, thus all appendixes come out
3452   % with the same letter (or @) in the toc without it.
3453   \else\char\the\appendixno
3454   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
3455   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
3456
3457 % Each @chapter defines this as the name of the chapter.
3458 % page headings and footings can use it.  @section does likewise.
3459 \def\thischapter{}
3460 \def\thissection{}
3461
3462 \newcount\absseclevel % used to calculate proper heading level
3463 \newcount\secbase\secbase=0 % @raise/lowersections modify this count
3464
3465 % @raisesections: treat @section as chapter, @subsection as section, etc.
3466 \def\raisesections{\global\advance\secbase by -1}
3467 \let\up=\raisesections % original BFox name
3468
3469 % @lowersections: treat @chapter as section, @section as subsection, etc.
3470 \def\lowersections{\global\advance\secbase by 1}
3471 \let\down=\lowersections % original BFox name
3472
3473 % Choose a numbered-heading macro
3474 % #1 is heading level if unmodified by @raisesections or @lowersections
3475 % #2 is text for heading
3476 \def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
3477 \ifcase\absseclevel
3478   \chapterzzz{#2}
3479 \or
3480   \seczzz{#2}
3481 \or
3482   \numberedsubseczzz{#2}
3483 \or
3484   \numberedsubsubseczzz{#2}
3485 \else
3486   \ifnum \absseclevel<0
3487     \chapterzzz{#2}
3488   \else
3489     \numberedsubsubseczzz{#2}
3490   \fi
3491 \fi
3492 }
3493
3494 % like \numhead, but chooses appendix heading levels
3495 \def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
3496 \ifcase\absseclevel
3497   \appendixzzz{#2}
3498 \or
3499   \appendixsectionzzz{#2}
3500 \or
3501   \appendixsubseczzz{#2}
3502 \or
3503   \appendixsubsubseczzz{#2}
3504 \else
3505   \ifnum \absseclevel<0
3506     \appendixzzz{#2}
3507   \else
3508     \appendixsubsubseczzz{#2}
3509   \fi
3510 \fi
3511 }
3512
3513 % like \numhead, but chooses numberless heading levels
3514 \def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
3515 \ifcase\absseclevel
3516   \unnumberedzzz{#2}
3517 \or
3518   \unnumberedseczzz{#2}
3519 \or
3520   \unnumberedsubseczzz{#2}
3521 \or
3522   \unnumberedsubsubseczzz{#2}
3523 \else
3524   \ifnum \absseclevel<0
3525     \unnumberedzzz{#2}
3526   \else
3527     \unnumberedsubsubseczzz{#2}
3528   \fi
3529 \fi
3530 }
3531
3532 % @chapter, @appendix, @unnumbered.
3533 \def\thischaptername{No Chapter Title}
3534 \outer\def\chapter{\parsearg\chapteryyy}
3535 \def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
3536 \def\chapterzzz #1{%
3537 \secno=0 \subsecno=0 \subsubsecno=0
3538 \global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}%
3539 \chapmacro {#1}{\the\chapno}%
3540 \gdef\thissection{#1}%
3541 \gdef\thischaptername{#1}%
3542 % We don't substitute the actual chapter name into \thischapter
3543 % because we don't want its macros evaluated now.
3544 \xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
3545 \toks0 = {#1}%
3546 \edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
3547                                   {\the\chapno}}}%
3548 \temp
3549 \donoderef
3550 \global\let\section = \numberedsec
3551 \global\let\subsection = \numberedsubsec
3552 \global\let\subsubsection = \numberedsubsubsec
3553 }
3554
3555 % we use \chapno to avoid indenting back
3556 \def\appendixbox#1{%
3557   \setbox0 = \hbox{\putwordAppendix{} \the\chapno}%
3558   \hbox to \wd0{#1\hss}}
3559
3560 \outer\def\appendix{\parsearg\appendixyyy}
3561 \def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
3562 \def\appendixzzz #1{%
3563 \secno=0 \subsecno=0 \subsubsecno=0
3564 \global\advance \appendixno by 1
3565 \message{\putwordAppendix\space \appendixletter}%
3566 \chapmacro {#1}{\appendixbox{\putwordAppendix{} \appendixletter}}%
3567 \gdef\thissection{#1}%
3568 \gdef\thischaptername{#1}%
3569 \xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
3570 \toks0 = {#1}%
3571 \edef\temp{\noexpand\writetocentry{\realbackslash appendixentry{\the\toks0}%
3572                        {\appendixletter}}}%
3573 \temp
3574 \appendixnoderef
3575 \global\let\section = \appendixsec
3576 \global\let\subsection = \appendixsubsec
3577 \global\let\subsubsection = \appendixsubsubsec
3578 }
3579
3580 % @centerchap is like @unnumbered, but the heading is centered.
3581 \outer\def\centerchap{\parsearg\centerchapyyy}
3582 \def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}}
3583
3584 % @top is like @unnumbered.
3585 \outer\def\top{\parsearg\unnumberedyyy}
3586
3587 \outer\def\unnumbered{\parsearg\unnumberedyyy}
3588 \def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
3589 \def\unnumberedzzz #1{%
3590 \secno=0 \subsecno=0 \subsubsecno=0
3591 %
3592 % This used to be simply \message{#1}, but TeX fully expands the
3593 % argument to \message.  Therefore, if #1 contained @-commands, TeX
3594 % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
3595 % expanded @cite (which turns out to cause errors because \cite is meant
3596 % to be executed, not expanded).
3597 %
3598 % Anyway, we don't want the fully-expanded definition of @cite to appear
3599 % as a result of the \message, we just want `@cite' itself.  We use
3600 % \the<toks register> to achieve this: TeX expands \the<toks> only once,
3601 % simply yielding the contents of <toks register>.  (We also do this for
3602 % the toc entries.)
3603 \toks0 = {#1}\message{(\the\toks0)}%
3604 %
3605 \unnumbchapmacro {#1}%
3606 \gdef\thischapter{#1}\gdef\thissection{#1}%
3607 \toks0 = {#1}%
3608 \edef\temp{\noexpand\writetocentry{\realbackslash unnumbchapentry{\the\toks0}{\the\chapno}}}%
3609 \temp
3610 \unnumbnoderef
3611 \global\let\section = \unnumberedsec
3612 \global\let\subsection = \unnumberedsubsec
3613 \global\let\subsubsection = \unnumberedsubsubsec
3614 }
3615
3616 % Sections.
3617 \outer\def\numberedsec{\parsearg\secyyy}
3618 \def\secyyy #1{\numhead1{#1}} % normally calls seczzz
3619 \def\seczzz #1{%
3620 \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
3621 \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
3622 \toks0 = {#1}%
3623 \edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
3624                                   {\the\chapno}{\the\secno}}}%
3625 \temp
3626 \donoderef
3627 \nobreak
3628 }
3629
3630 \outer\def\appendixsection{\parsearg\appendixsecyyy}
3631 \outer\def\appendixsec{\parsearg\appendixsecyyy}
3632 \def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
3633 \def\appendixsectionzzz #1{%
3634 \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
3635 \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
3636 \toks0 = {#1}%
3637 \edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
3638                                   {\appendixletter}{\the\secno}}}%
3639 \temp
3640 \appendixnoderef
3641 \nobreak
3642 }
3643
3644 \outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
3645 \def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
3646 \def\unnumberedseczzz #1{%
3647 \plainsecheading {#1}\gdef\thissection{#1}%
3648 \toks0 = {#1}%
3649 \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsecentry%
3650   {\the\toks0}{\the\chapno}{\the\secno}}}%
3651 \temp
3652 \unnumbnoderef
3653 \nobreak
3654 }
3655
3656 % Subsections.
3657 \outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
3658 \def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
3659 \def\numberedsubseczzz #1{%
3660 \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
3661 \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
3662 \toks0 = {#1}%
3663 \edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
3664                                     {\the\chapno}{\the\secno}{\the\subsecno}}}%
3665 \temp
3666 \donoderef
3667 \nobreak
3668 }
3669
3670 \outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
3671 \def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
3672 \def\appendixsubseczzz #1{%
3673 \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
3674 \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
3675 \toks0 = {#1}%
3676 \edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
3677                                 {\appendixletter}{\the\secno}{\the\subsecno}}}%
3678 \temp
3679 \appendixnoderef
3680 \nobreak
3681 }
3682
3683 \outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
3684 \def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
3685 \def\unnumberedsubseczzz #1{%
3686 \plainsubsecheading {#1}\gdef\thissection{#1}%
3687 \toks0 = {#1}%
3688 \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsecentry%
3689   {\the\toks0}{\the\chapno}{\the\secno}{\the\subsecno}}}%
3690 \temp
3691 \unnumbnoderef
3692 \nobreak
3693 }
3694
3695 % Subsubsections.
3696 \outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
3697 \def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
3698 \def\numberedsubsubseczzz #1{%
3699 \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
3700 \subsubsecheading {#1}
3701   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
3702 \toks0 = {#1}%
3703 \edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
3704   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
3705 \temp
3706 \donoderef
3707 \nobreak
3708 }
3709
3710 \outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
3711 \def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
3712 \def\appendixsubsubseczzz #1{%
3713 \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
3714 \subsubsecheading {#1}
3715   {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
3716 \toks0 = {#1}%
3717 \edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
3718   {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
3719 \temp
3720 \appendixnoderef
3721 \nobreak
3722 }
3723
3724 \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
3725 \def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
3726 \def\unnumberedsubsubseczzz #1{%
3727 \plainsubsubsecheading {#1}\gdef\thissection{#1}%
3728 \toks0 = {#1}%
3729 \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsubsecentry%
3730   {\the\toks0}{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
3731 \temp
3732 \unnumbnoderef
3733 \nobreak
3734 }
3735
3736 % These are variants which are not "outer", so they can appear in @ifinfo.
3737 % Actually, they should now be obsolete; ordinary section commands should work.
3738 \def\infotop{\parsearg\unnumberedzzz}
3739 \def\infounnumbered{\parsearg\unnumberedzzz}
3740 \def\infounnumberedsec{\parsearg\unnumberedseczzz}
3741 \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
3742 \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
3743
3744 \def\infoappendix{\parsearg\appendixzzz}
3745 \def\infoappendixsec{\parsearg\appendixseczzz}
3746 \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
3747 \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
3748
3749 \def\infochapter{\parsearg\chapterzzz}
3750 \def\infosection{\parsearg\sectionzzz}
3751 \def\infosubsection{\parsearg\subsectionzzz}
3752 \def\infosubsubsection{\parsearg\subsubsectionzzz}
3753
3754 % These macros control what the section commands do, according
3755 % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
3756 % Define them by default for a numbered chapter.
3757 \global\let\section = \numberedsec
3758 \global\let\subsection = \numberedsubsec
3759 \global\let\subsubsection = \numberedsubsubsec
3760
3761 % Define @majorheading, @heading and @subheading
3762
3763 % NOTE on use of \vbox for chapter headings, section headings, and such:
3764 %       1) We use \vbox rather than the earlier \line to permit
3765 %          overlong headings to fold.
3766 %       2) \hyphenpenalty is set to 10000 because hyphenation in a
3767 %          heading is obnoxious; this forbids it.
3768 %       3) Likewise, headings look best if no \parindent is used, and
3769 %          if justification is not attempted.  Hence \raggedright.
3770
3771
3772 \def\majorheading{\parsearg\majorheadingzzz}
3773 \def\majorheadingzzz #1{%
3774 {\advance\chapheadingskip by 10pt \chapbreak }%
3775 {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3776                   \parindent=0pt\raggedright
3777                   \rm #1\hfill}}\bigskip \par\penalty 200}
3778
3779 \def\chapheading{\parsearg\chapheadingzzz}
3780 \def\chapheadingzzz #1{\chapbreak %
3781 {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3782                   \parindent=0pt\raggedright
3783                   \rm #1\hfill}}\bigskip \par\penalty 200}
3784
3785 % @heading, @subheading, @subsubheading.
3786 \def\heading{\parsearg\plainsecheading}
3787 \def\subheading{\parsearg\plainsubsecheading}
3788 \def\subsubheading{\parsearg\plainsubsubsecheading}
3789
3790 % These macros generate a chapter, section, etc. heading only
3791 % (including whitespace, linebreaking, etc. around it),
3792 % given all the information in convenient, parsed form.
3793
3794 %%% Args are the skip and penalty (usually negative)
3795 \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
3796
3797 \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
3798
3799 %%% Define plain chapter starts, and page on/off switching for it
3800 % Parameter controlling skip before chapter headings (if needed)
3801
3802 \newskip\chapheadingskip
3803
3804 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
3805 \def\chappager{\par\vfill\supereject}
3806 \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
3807
3808 \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
3809
3810 \def\CHAPPAGoff{%
3811 \global\let\contentsalignmacro = \chappager
3812 \global\let\pchapsepmacro=\chapbreak
3813 \global\let\pagealignmacro=\chappager}
3814
3815 \def\CHAPPAGon{%
3816 \global\let\contentsalignmacro = \chappager
3817 \global\let\pchapsepmacro=\chappager
3818 \global\let\pagealignmacro=\chappager
3819 \global\def\HEADINGSon{\HEADINGSsingle}}
3820
3821 \def\CHAPPAGodd{
3822 \global\let\contentsalignmacro = \chapoddpage
3823 \global\let\pchapsepmacro=\chapoddpage
3824 \global\let\pagealignmacro=\chapoddpage
3825 \global\def\HEADINGSon{\HEADINGSdouble}}
3826
3827 \CHAPPAGon
3828
3829 \def\CHAPFplain{
3830 \global\let\chapmacro=\chfplain
3831 \global\let\unnumbchapmacro=\unnchfplain
3832 \global\let\centerchapmacro=\centerchfplain}
3833
3834 % Plain chapter opening.
3835 % #1 is the text, #2 the chapter number or empty if unnumbered.
3836 \def\chfplain#1#2{%
3837   \pchapsepmacro
3838   {%
3839     \chapfonts \rm
3840     \def\chapnum{#2}%
3841     \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}%
3842     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
3843           \hangindent = \wd0 \centerparametersmaybe
3844           \unhbox0 #1\par}%
3845   }%
3846   \nobreak\bigskip % no page break after a chapter title
3847   \nobreak
3848 }
3849
3850 % Plain opening for unnumbered.
3851 \def\unnchfplain#1{\chfplain{#1}{}}
3852
3853 % @centerchap -- centered and unnumbered.
3854 \let\centerparametersmaybe = \relax
3855 \def\centerchfplain#1{{%
3856   \def\centerparametersmaybe{%
3857     \advance\rightskip by 3\rightskip
3858     \leftskip = \rightskip
3859     \parfillskip = 0pt
3860   }%
3861   \chfplain{#1}{}%
3862 }}
3863
3864 \CHAPFplain % The default
3865
3866 \def\unnchfopen #1{%
3867 \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3868                        \parindent=0pt\raggedright
3869                        \rm #1\hfill}}\bigskip \par\nobreak
3870 }
3871
3872 \def\chfopen #1#2{\chapoddpage {\chapfonts
3873 \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
3874 \par\penalty 5000 %
3875 }
3876
3877 \def\centerchfopen #1{%
3878 \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3879                        \parindent=0pt
3880                        \hfill {\rm #1}\hfill}}\bigskip \par\nobreak
3881 }
3882
3883 \def\CHAPFopen{
3884 \global\let\chapmacro=\chfopen
3885 \global\let\unnumbchapmacro=\unnchfopen
3886 \global\let\centerchapmacro=\centerchfopen}
3887
3888
3889 % Section titles.
3890 \newskip\secheadingskip
3891 \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
3892 \def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}}
3893 \def\plainsecheading#1{\sectionheading{sec}{}{#1}}
3894
3895 % Subsection titles.
3896 \newskip \subsecheadingskip
3897 \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
3898 \def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}}
3899 \def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}}
3900
3901 % Subsubsection titles.
3902 \let\subsubsecheadingskip = \subsecheadingskip
3903 \let\subsubsecheadingbreak = \subsecheadingbreak
3904 \def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}}
3905 \def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}}
3906
3907
3908 % Print any size section title.
3909 %
3910 % #1 is the section type (sec/subsec/subsubsec), #2 is the section
3911 % number (maybe empty), #3 the text.
3912 \def\sectionheading#1#2#3{%
3913   {%
3914     \expandafter\advance\csname #1headingskip\endcsname by \parskip
3915     \csname #1headingbreak\endcsname
3916   }%
3917   {%
3918     % Switch to the right set of fonts.
3919     \csname #1fonts\endcsname \rm
3920     %
3921     % Only insert the separating space if we have a section number.
3922     \def\secnum{#2}%
3923     \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}%
3924     %
3925     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
3926           \hangindent = \wd0 % zero if no section number
3927           \unhbox0 #3}%
3928   }%
3929   % Add extra space after the heading -- either a line space or a
3930   % paragraph space, whichever is more.  (Some people like to set
3931   % \parskip to large values for some reason.)
3932   \nobreak
3933   \ifdim\parskip>\normalbaselineskip
3934     \kern\parskip
3935   \else
3936     \kern\normalbaselineskip
3937   \fi
3938   \nobreak
3939 }
3940
3941
3942 \message{toc,}
3943 % Table of contents.
3944 \newwrite\tocfile
3945
3946 % Write an entry to the toc file, opening it if necessary.
3947 % Called from @chapter, etc.  We supply {\folio} at the end of the
3948 % argument, which will end up as the last argument to the \...entry macro.
3949 %
3950 % We open the .toc file here instead of at @setfilename or any other
3951 % fixed time so that @contents can be put in the document anywhere.
3952 %
3953 \newif\iftocfileopened
3954 \def\writetocentry#1{%
3955   \iftocfileopened\else
3956     \immediate\openout\tocfile = \jobname.toc
3957     \global\tocfileopenedtrue
3958   \fi
3959   \iflinks \write\tocfile{#1{\folio}}\fi
3960   %
3961   % Tell \shipout to create a page destination if we're doing pdf, which
3962   % will be the target of the links in the table of contents.  We can't
3963   % just do it on every page because the title pages are numbered 1 and
3964   % 2 (the page numbers aren't printed), and so are the first two pages
3965   % of the document.  Thus, we'd have two destinations named `1', and
3966   % two named `2'.
3967   \ifpdf \pdfmakepagedesttrue \fi
3968 }
3969
3970 \newskip\contentsrightmargin \contentsrightmargin=1in
3971 \newcount\savepageno
3972 \newcount\lastnegativepageno \lastnegativepageno = -1
3973
3974 % Finish up the main text and prepare to read what we've written
3975 % to \tocfile.
3976 %
3977 \def\startcontents#1{%
3978    % If @setchapternewpage on, and @headings double, the contents should
3979    % start on an odd page, unlike chapters.  Thus, we maintain
3980    % \contentsalignmacro in parallel with \pagealignmacro.
3981    % From: Torbjorn Granlund <tege@matematik.su.se>
3982    \contentsalignmacro
3983    \immediate\closeout\tocfile
3984    %
3985    % Don't need to put `Contents' or `Short Contents' in the headline.
3986    % It is abundantly clear what they are.
3987    \unnumbchapmacro{#1}\def\thischapter{}%
3988    \savepageno = \pageno
3989    \begingroup                  % Set up to handle contents files properly.
3990       \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
3991       % We can't do this, because then an actual ^ in a section
3992       % title fails, e.g., @chapter ^ -- exponentiation.  --karl, 9jul97.
3993       %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi
3994       \raggedbottom             % Worry more about breakpoints than the bottom.
3995       \advance\hsize by -\contentsrightmargin % Don't use the full line length.
3996       %
3997       % Roman numerals for page numbers.
3998       \ifnum \pageno>0 \pageno = \lastnegativepageno \fi
3999 }
4000
4001
4002 % Normal (long) toc.
4003 \def\contents{%
4004    \startcontents{\putwordTOC}%
4005      \openin 1 \jobname.toc
4006      \ifeof 1 \else
4007        \closein 1
4008        \input \jobname.toc
4009      \fi
4010      \vfill \eject
4011      \contentsalignmacro % in case @setchapternewpage odd is in effect
4012      \pdfmakeoutlines
4013    \endgroup
4014    \lastnegativepageno = \pageno
4015    \pageno = \savepageno
4016 }
4017
4018 % And just the chapters.
4019 \def\summarycontents{%
4020    \startcontents{\putwordShortTOC}%
4021       %
4022       \let\chapentry = \shortchapentry
4023       \let\appendixentry = \shortappendixentry
4024       \let\unnumbchapentry = \shortunnumberedentry
4025       % We want a true roman here for the page numbers.
4026       \secfonts
4027       \let\rm=\shortcontrm \let\bf=\shortcontbf
4028       \let\sl=\shortcontsl \let\tt=\shortconttt
4029       \rm
4030       \hyphenpenalty = 10000
4031       \advance\baselineskip by 1pt % Open it up a little.
4032       \def\secentry ##1##2##3##4{}
4033       \def\subsecentry ##1##2##3##4##5{}
4034       \def\subsubsecentry ##1##2##3##4##5##6{}
4035       \let\unnumbsecentry = \secentry
4036       \let\unnumbsubsecentry = \subsecentry
4037       \let\unnumbsubsubsecentry = \subsubsecentry
4038       \openin 1 \jobname.toc
4039       \ifeof 1 \else
4040         \closein 1
4041         \input \jobname.toc
4042       \fi
4043      \vfill \eject
4044      \contentsalignmacro % in case @setchapternewpage odd is in effect
4045    \endgroup
4046    \lastnegativepageno = \pageno
4047    \pageno = \savepageno
4048 }
4049 \let\shortcontents = \summarycontents
4050
4051 \ifpdf
4052   \pdfcatalog{/PageMode /UseOutlines}%
4053 \fi
4054
4055 % These macros generate individual entries in the table of contents.
4056 % The first argument is the chapter or section name.
4057 % The last argument is the page number.
4058 % The arguments in between are the chapter number, section number, ...
4059
4060 % Chapters, in the main contents.
4061 \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
4062 %
4063 % Chapters, in the short toc.
4064 % See comments in \dochapentry re vbox and related settings.
4065 \def\shortchapentry#1#2#3{%
4066   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#3\egroup}%
4067 }
4068
4069 % Appendices, in the main contents.
4070 \def\appendixentry#1#2#3{%
4071   \dochapentry{\appendixbox{\putwordAppendix{} #2}\labelspace#1}{#3}}
4072 %
4073 % Appendices, in the short toc.
4074 \let\shortappendixentry = \shortchapentry
4075
4076 % Typeset the label for a chapter or appendix for the short contents.
4077 % The arg is, e.g., `Appendix A' for an appendix, or `3' for a chapter.
4078 % We could simplify the code here by writing out an \appendixentry
4079 % command in the toc file for appendices, instead of using \chapentry
4080 % for both, but it doesn't seem worth it.
4081 %
4082 \newdimen\shortappendixwidth
4083 %
4084 \def\shortchaplabel#1{%
4085   % This space should be enough, since a single number is .5em, and the
4086   % widest letter (M) is 1em, at least in the Computer Modern fonts.
4087   % But use \hss just in case.
4088   % (This space doesn't include the extra space that gets added after
4089   % the label; that gets put in by \shortchapentry above.)
4090   \dimen0 = 1em
4091   \hbox to \dimen0{#1\hss}%
4092 }
4093
4094 % Unnumbered chapters.
4095 \def\unnumbchapentry#1#2#3{\dochapentry{#1}{#3}}
4096 \def\shortunnumberedentry#1#2#3{\tocentry{#1}{\doshortpageno\bgroup#3\egroup}}
4097
4098 % Sections.
4099 \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
4100 \def\unnumbsecentry#1#2#3#4{\dosecentry{#1}{#4}}
4101
4102 % Subsections.
4103 \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
4104 \def\unnumbsubsecentry#1#2#3#4#5{\dosubsecentry{#1}{#5}}
4105
4106 % And subsubsections.
4107 \def\subsubsecentry#1#2#3#4#5#6{%
4108   \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
4109 \def\unnumbsubsubsecentry#1#2#3#4#5#6{\dosubsubsecentry{#1}{#6}}
4110
4111 % This parameter controls the indentation of the various levels.
4112 \newdimen\tocindent \tocindent = 3pc
4113
4114 % Now for the actual typesetting. In all these, #1 is the text and #2 is the
4115 % page number.
4116 %
4117 % If the toc has to be broken over pages, we want it to be at chapters
4118 % if at all possible; hence the \penalty.
4119 \def\dochapentry#1#2{%
4120    \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
4121    \begingroup
4122      \chapentryfonts
4123      \tocentry{#1}{\dopageno\bgroup#2\egroup}%
4124    \endgroup
4125    \nobreak\vskip .25\baselineskip plus.1\baselineskip
4126 }
4127
4128 \def\dosecentry#1#2{\begingroup
4129   \secentryfonts \leftskip=\tocindent
4130   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
4131 \endgroup}
4132
4133 \def\dosubsecentry#1#2{\begingroup
4134   \subsecentryfonts \leftskip=2\tocindent
4135   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
4136 \endgroup}
4137
4138 \def\dosubsubsecentry#1#2{\begingroup
4139   \subsubsecentryfonts \leftskip=3\tocindent
4140   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
4141 \endgroup}
4142
4143 % Final typesetting of a toc entry; we use the same \entry macro as for
4144 % the index entries, but we want to suppress hyphenation here.  (We
4145 % can't do that in the \entry macro, since index entries might consist
4146 % of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
4147 \def\tocentry#1#2{\begingroup
4148   \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks
4149   % Do not use \turnoffactive in these arguments.  Since the toc is
4150   % typeset in cmr, characters such as _ would come out wrong; we
4151   % have to do the usual translation tricks.
4152   \entry{#1}{#2}%
4153 \endgroup}
4154
4155 % Space between chapter (or whatever) number and the title.
4156 \def\labelspace{\hskip1em \relax}
4157
4158 \def\dopageno#1{{\rm #1}}
4159 \def\doshortpageno#1{{\rm #1}}
4160
4161 \def\chapentryfonts{\secfonts \rm}
4162 \def\secentryfonts{\textfonts}
4163 \let\subsecentryfonts = \textfonts
4164 \let\subsubsecentryfonts = \textfonts
4165
4166
4167 \message{environments,}
4168 % @foo ... @end foo.
4169
4170 % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
4171
4172 % Since these characters are used in examples, it should be an even number of
4173 % \tt widths. Each \tt character is 1en, so two makes it 1em.
4174 %
4175 \def\point{$\star$}
4176 \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
4177 \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
4178 \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
4179 \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
4180
4181 % The @error{} command.
4182 % Adapted from the TeXbook's \boxit.
4183
4184 \newbox\errorbox
4185 %
4186 {\tentt \global\dimen0 = 3em}% Width of the box.
4187 \dimen2 = .55pt % Thickness of rules
4188 % The text. (`r' is open on the right, `e' somewhat less so on the left.)
4189 \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
4190 %
4191 \global\setbox\errorbox=\hbox to \dimen0{\hfil
4192    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
4193    \advance\hsize by -2\dimen2 % Rules.
4194    \vbox{
4195       \hrule height\dimen2
4196       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
4197          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
4198          \kern3pt\vrule width\dimen2}% Space to right.
4199       \hrule height\dimen2}
4200     \hfil}
4201 %
4202 \def\error{\leavevmode\lower.7ex\copy\errorbox}
4203
4204 % @tex ... @end tex    escapes into raw Tex temporarily.
4205 % One exception: @ is still an escape character, so that @end tex works.
4206 % But \@ or @@ will get a plain tex @ character.
4207
4208 \def\tex{\begingroup
4209   \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
4210   \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
4211   \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
4212   \catcode `\%=14
4213   \catcode 43=12 % plus
4214   \catcode`\"=12
4215   \catcode`\==12
4216   \catcode`\|=12
4217   \catcode`\<=12
4218   \catcode`\>=12
4219   \escapechar=`\\
4220   %
4221   \let\b=\ptexb
4222   \let\bullet=\ptexbullet
4223   \let\c=\ptexc
4224   \let\,=\ptexcomma
4225   \let\.=\ptexdot
4226   \let\dots=\ptexdots
4227   \let\equiv=\ptexequiv
4228   \let\!=\ptexexclam
4229   \let\i=\ptexi
4230   \let\{=\ptexlbrace
4231   \let\+=\tabalign
4232   \let\}=\ptexrbrace
4233   \let\*=\ptexstar
4234   \let\t=\ptext
4235   %
4236   \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
4237   \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
4238   \def\@{@}%
4239 \let\Etex=\endgroup}
4240
4241 % Define @lisp ... @end lisp.
4242 % @lisp does a \begingroup so it can rebind things,
4243 % including the definition of @end lisp (which normally is erroneous).
4244
4245 % Amount to narrow the margins by for @lisp.
4246 \newskip\lispnarrowing \lispnarrowing=0.4in
4247
4248 % This is the definition that ^^M gets inside @lisp, @example, and other
4249 % such environments.  \null is better than a space, since it doesn't
4250 % have any width.
4251 \def\lisppar{\null\endgraf}
4252
4253 % Make each space character in the input produce a normal interword
4254 % space in the output.  Don't allow a line break at this space, as this
4255 % is used only in environments like @example, where each line of input
4256 % should produce a line of output anyway.
4257 %
4258 {\obeyspaces %
4259 \gdef\sepspaces{\obeyspaces\let =\tie}}
4260
4261 % Define \obeyedspace to be our active space, whatever it is.  This is
4262 % for use in \parsearg.
4263 {\sepspaces%
4264 \global\let\obeyedspace= }
4265
4266 % This space is always present above and below environments.
4267 \newskip\envskipamount \envskipamount = 0pt
4268
4269 % Make spacing and below environment symmetrical.  We use \parskip here
4270 % to help in doing that, since in @example-like environments \parskip
4271 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
4272 % start of the next paragraph will insert \parskip.
4273 %
4274 \def\aboveenvbreak{{%
4275   \ifnum\lastpenalty < 10000
4276     \advance\envskipamount by \parskip
4277     \endgraf
4278     \ifdim\lastskip<\envskipamount
4279       \removelastskip
4280       \penalty-50
4281       \vskip\envskipamount
4282     \fi
4283   \fi
4284 }}
4285
4286 \let\afterenvbreak = \aboveenvbreak
4287
4288 % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins.
4289 \let\nonarrowing=\relax
4290
4291 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
4292 % environment contents.
4293 \font\circle=lcircle10
4294 \newdimen\circthick
4295 \newdimen\cartouter\newdimen\cartinner
4296 \newskip\normbskip\newskip\normpskip\newskip\normlskip
4297 \circthick=\fontdimen8\circle
4298 %
4299 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
4300 \def\ctr{{\hskip 6pt\circle\char'010}}
4301 \def\cbl{{\circle\char'012\hskip -6pt}}
4302 \def\cbr{{\hskip 6pt\circle\char'011}}
4303 \def\carttop{\hbox to \cartouter{\hskip\lskip
4304         \ctl\leaders\hrule height\circthick\hfil\ctr
4305         \hskip\rskip}}
4306 \def\cartbot{\hbox to \cartouter{\hskip\lskip
4307         \cbl\leaders\hrule height\circthick\hfil\cbr
4308         \hskip\rskip}}
4309 %
4310 \newskip\lskip\newskip\rskip
4311
4312 \long\def\cartouche{%
4313 \begingroup
4314         \lskip=\leftskip \rskip=\rightskip
4315         \leftskip=0pt\rightskip=0pt %we want these *outside*.
4316         \cartinner=\hsize \advance\cartinner by-\lskip
4317                           \advance\cartinner by-\rskip
4318         \cartouter=\hsize
4319         \advance\cartouter by 18.4pt % allow for 3pt kerns on either
4320 %                                    side, and for 6pt waste from
4321 %                                    each corner char, and rule thickness
4322         \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
4323         % Flag to tell @lisp, etc., not to narrow margin.
4324         \let\nonarrowing=\comment
4325         \vbox\bgroup
4326                 \baselineskip=0pt\parskip=0pt\lineskip=0pt
4327                 \carttop
4328                 \hbox\bgroup
4329                         \hskip\lskip
4330                         \vrule\kern3pt
4331                         \vbox\bgroup
4332                                 \hsize=\cartinner
4333                                 \kern3pt
4334                                 \begingroup
4335                                         \baselineskip=\normbskip
4336                                         \lineskip=\normlskip
4337                                         \parskip=\normpskip
4338                                         \vskip -\parskip
4339 \def\Ecartouche{%
4340                                 \endgroup
4341                                 \kern3pt
4342                         \egroup
4343                         \kern3pt\vrule
4344                         \hskip\rskip
4345                 \egroup
4346                 \cartbot
4347         \egroup
4348 \endgroup
4349 }}
4350
4351
4352 % This macro is called at the beginning of all the @example variants,
4353 % inside a group.
4354 \def\nonfillstart{%
4355   \aboveenvbreak
4356   \inENV % This group ends at the end of the body
4357   \hfuzz = 12pt % Don't be fussy
4358   \sepspaces % Make spaces be word-separators rather than space tokens.
4359   \let\par = \lisppar % don't ignore blank lines
4360   \obeylines % each line of input is a line of output
4361   \parskip = 0pt
4362   \parindent = 0pt
4363   \emergencystretch = 0pt % don't try to avoid overfull boxes
4364   % @cartouche defines \nonarrowing to inhibit narrowing
4365   % at next level down.
4366   \ifx\nonarrowing\relax
4367     \advance \leftskip by \lispnarrowing
4368     \exdentamount=\lispnarrowing
4369     \let\exdent=\nofillexdent
4370     \let\nonarrowing=\relax
4371   \fi
4372 }
4373
4374 % Define the \E... control sequence only if we are inside the particular
4375 % environment, so the error checking in \end will work.
4376 %
4377 % To end an @example-like environment, we first end the paragraph (via
4378 % \afterenvbreak's vertical glue), and then the group.  That way we keep
4379 % the zero \parskip that the environments set -- \parskip glue will be
4380 % inserted at the beginning of the next paragraph in the document, after
4381 % the environment.
4382 %
4383 \def\nonfillfinish{\afterenvbreak\endgroup}
4384
4385 % @lisp: indented, narrowed, typewriter font.
4386 \def\lisp{\begingroup
4387   \nonfillstart
4388   \let\Elisp = \nonfillfinish
4389   \tt
4390   \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
4391   \gobble       % eat return
4392 }
4393
4394 % @example: Same as @lisp.
4395 \def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp}
4396
4397 % @small... is usually equivalent to the non-small (@smallbook
4398 % redefines).  We must call \example (or whatever) last in the
4399 % definition, since it reads the return following the @example (or
4400 % whatever) command.
4401 %
4402 % This actually allows (for example) @end display inside an
4403 % @smalldisplay.  Too bad, but makeinfo will catch the error anyway.
4404 %
4405 \def\smalldisplay{\begingroup\def\Esmalldisplay{\nonfillfinish\endgroup}\display}
4406 \def\smallexample{\begingroup\def\Esmallexample{\nonfillfinish\endgroup}\lisp}
4407 \def\smallformat{\begingroup\def\Esmallformat{\nonfillfinish\endgroup}\format}
4408 \def\smalllisp{\begingroup\def\Esmalllisp{\nonfillfinish\endgroup}\lisp}
4409
4410 % Real @smallexample and @smalllisp (when @smallbook): use smaller fonts.
4411 % Originally contributed by Pavel@xerox.
4412 \def\smalllispx{\begingroup
4413   \def\Esmalllisp{\nonfillfinish\endgroup}%
4414   \def\Esmallexample{\nonfillfinish\endgroup}%
4415   \smallexamplefonts
4416   \lisp
4417 }
4418
4419 % @display: same as @lisp except keep current font.
4420 %
4421 \def\display{\begingroup
4422   \nonfillstart
4423   \let\Edisplay = \nonfillfinish
4424   \gobble
4425 }
4426 %
4427 % @smalldisplay (when @smallbook): @display plus smaller fonts.
4428 %
4429 \def\smalldisplayx{\begingroup
4430   \def\Esmalldisplay{\nonfillfinish\endgroup}%
4431   \smallexamplefonts \rm
4432   \display
4433 }
4434
4435 % @format: same as @display except don't narrow margins.
4436 %
4437 \def\format{\begingroup
4438   \let\nonarrowing = t
4439   \nonfillstart
4440   \let\Eformat = \nonfillfinish
4441   \gobble
4442 }
4443 %
4444 % @smallformat (when @smallbook): @format plus smaller fonts.
4445 %
4446 \def\smallformatx{\begingroup
4447   \def\Esmallformat{\nonfillfinish\endgroup}%
4448   \smallexamplefonts \rm
4449   \format
4450 }
4451
4452 % @flushleft (same as @format).
4453 %
4454 \def\flushleft{\begingroup \def\Eflushleft{\nonfillfinish\endgroup}\format}
4455
4456 % @flushright.
4457 %
4458 \def\flushright{\begingroup
4459   \let\nonarrowing = t
4460   \nonfillstart
4461   \let\Eflushright = \nonfillfinish
4462   \advance\leftskip by 0pt plus 1fill
4463   \gobble
4464 }
4465
4466
4467 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
4468 % and narrows the margins.
4469 %
4470 \def\quotation{%
4471   \begingroup\inENV %This group ends at the end of the @quotation body
4472   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
4473   \parindent=0pt
4474   % We have retained a nonzero parskip for the environment, since we're
4475   % doing normal filling. So to avoid extra space below the environment...
4476   \def\Equotation{\parskip = 0pt \nonfillfinish}%
4477   %
4478   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
4479   \ifx\nonarrowing\relax
4480     \advance\leftskip by \lispnarrowing
4481     \advance\rightskip by \lispnarrowing
4482     \exdentamount = \lispnarrowing
4483     \let\nonarrowing = \relax
4484   \fi
4485 }
4486
4487
4488 % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
4489 % If we want to allow any <char> as delimiter, 
4490 % we need the curly braces so that makeinfo sees the @verb command, eg:
4491 % `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
4492 %
4493 % [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
4494 %
4495 % [Knuth] p. 344; only we need to do '@' too
4496 \def\dospecials{%
4497   \do\ \do\\\do\@\do\{\do\}\do\$\do\&%
4498   \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~}
4499 %
4500 % [Knuth] p. 380
4501 \def\uncatcodespecials{%
4502   \def\do##1{\catcode`##1=12}\dospecials}
4503 %
4504 % [Knuth] pp. 380,381,391
4505 % Disable Spanish ligatures ?` and !` of \tt font
4506 \begingroup
4507   \catcode`\`=\active\gdef`{\relax\lq}
4508 \endgroup
4509 %
4510 % Setup for the @verb command.
4511 %
4512 % Eight spaces for a tab
4513 \begingroup
4514   \catcode`\^^I=\active
4515   \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
4516 \endgroup
4517 %
4518 \def\setupverb{%
4519   \tt  % easiest (and conventionally used) font for verbatim
4520   \def\par{\leavevmode\endgraf}%
4521   \catcode`\`=\active
4522   \tabeightspaces
4523   % Respect line breaks,
4524   % print special symbols as themselves, and
4525   % make each space count
4526   % must do in this order:
4527   \obeylines \uncatcodespecials \sepspaces
4528 }
4529
4530 % Setup for the @verbatim environment
4531 %
4532 % Real tab expansion
4533 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
4534 %
4535 \def\starttabbox{\setbox0=\hbox\bgroup}
4536 \begingroup
4537   \catcode`\^^I=\active
4538   \gdef\tabexpand{%
4539     \catcode`\^^I=\active
4540     \def^^I{\leavevmode\egroup
4541       \dimen0=\wd0 % the width so far, or since the previous tab
4542       \divide\dimen0 by\tabw
4543       \multiply\dimen0 by\tabw % compute previous multiple of \tabw
4544       \advance\dimen0 by\tabw  % advance to next multiple of \tabw
4545       \wd0=\dimen0 \box0 \starttabbox
4546     }%
4547   }
4548 \endgroup
4549 \def\setupverbatim{%
4550   % Easiest (and conventionally used) font for verbatim
4551   \tt
4552   \def\par{\leavevmode\egroup\box0\endgraf}%
4553   \catcode`\`=\active
4554   \tabexpand
4555   % Respect line breaks,
4556   % print special symbols as themselves, and
4557   % make each space count
4558   % must do in this order:
4559   \obeylines \uncatcodespecials \sepspaces
4560   \everypar{\starttabbox}%
4561 }
4562
4563 % Do the @verb magic: verbatim text is quoted by unique 
4564 % delimiter characters.  Before first delimiter expect a 
4565 % right brace, after last delimiter expect closing brace:
4566 %
4567 %    \def\doverb'{'<char>#1<char>'}'{#1}
4568 %
4569 % [Knuth] p. 382; only eat outer {}
4570 \begingroup
4571   \catcode`[=1\catcode`]=2\catcode`\{=12\catcode`\}=12
4572   \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
4573 \endgroup
4574 %
4575 \def\verb{\begingroup\setupverb\doverb}
4576 %
4577 %
4578 % Do the @verbatim magic: define the macro \doverbatim so that
4579 % the (first) argument ends when '@end verbatim' is reached, ie:
4580 %
4581 %     \def\doverbatim#1@end verbatim{#1}
4582 %
4583 % For Texinfo it's a lot easier than for LaTeX, 
4584 % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
4585 % we need not redefine '\', '{' and '}'
4586 %
4587 % Inspired by LaTeX's verbatim command set [latex.ltx]
4588 %% Include LaTeX hack for completeness -- never know
4589 %% \begingroup
4590 %% \catcode`|=0 \catcode`[=1
4591 %% \catcode`]=2\catcode`\{=12\catcode`\}=12\catcode`\ =\active
4592 %% \catcode`\\=12|gdef|doverbatim#1@end verbatim[
4593 %% #1|endgroup|def|Everbatim[]|end[verbatim]]
4594 %% |endgroup
4595 \begingroup
4596   \catcode`\ =\active
4597   \gdef\doverbatim#1@end verbatim{#1\end{verbatim}}
4598 \endgroup
4599 %
4600 \def\verbatim{%
4601   \def\Everbatim{\nonfillfinish\endgroup}%
4602   \begingroup
4603     \nonfillstart
4604     \advance\leftskip by -\defbodyindent
4605     \begingroup\setupverbatim\doverbatim
4606 }
4607
4608 % @verbatiminclude FILE - insert text of file in verbatim environment.
4609 %
4610 % Allow normal characters that we make active in the argument (a file name).
4611 \def\verbatiminclude{%
4612   \begingroup
4613     \catcode`\\=12
4614     \catcode`~=12
4615     \catcode`^=12
4616     \catcode`_=12
4617     \catcode`|=12
4618     \catcode`<=12
4619     \catcode`>=12
4620     \catcode`+=12
4621     \parsearg\doverbatiminclude
4622 }
4623 \def\setupverbatiminclude{%
4624   \begingroup
4625     \nonfillstart
4626     \advance\leftskip by -\defbodyindent
4627     \begingroup\setupverbatim
4628 }
4629 %
4630 \def\doverbatiminclude#1{%
4631      % Restore active chars for included file.
4632   \endgroup
4633   \begingroup
4634   \def\thisfile{#1}%
4635   \expandafter\expandafter\setupverbatiminclude\input\thisfile
4636   \endgroup\nonfillfinish\endgroup
4637 }
4638
4639 % @copying ... @end copying.
4640 % Save the text away for @insertcopying later.  Many commands won't be
4641 % allowed in this context, but that's ok.
4642
4643 % We save the uninterpreted tokens, rather than creating a box.
4644 % Saving the text in a box would be much easier, but then all the
4645 % typesetting commands (@smallbook, font changes, etc.) have to be done
4646 % beforehand -- and a) we want @copying to be done first in the source
4647 % file; b) letting users define the frontmatter in as flexible order as
4648 % possible is very desirable.
4649
4650 \def\copying{\begingroup
4651   % Define a command to swallow text until we reach `@end copying'.
4652   % \ is the escape char in this texinfo.tex file, so it is the
4653   % delimiter for the command; @ will be the escape char when we read
4654   % it, but that doesn't matter.
4655   \long\def\docopying##1\end copying{\gdef\copyingtext{##1}\enddocopying}%
4656   %
4657   % We must preserve ^^M's in the input file; see \insertcopying below.
4658   \catcode`\^^M = \active
4659   \docopying
4660 }
4661
4662 % What we do to finish off the copying text.
4663 %
4664 \def\enddocopying{\endgroup\ignorespaces}
4665
4666 % @insertcopying.  Here we must play games with ^^M's.  On the one hand,
4667 % we need them to delimit commands such as `@end quotation', so they
4668 % must be active.  On the other hand, we certainly don't want every
4669 % end-of-line to be a \par, as would happen with the normal active
4670 % definition of ^^M.  On the third hand, two ^^M's in a row should still
4671 % generate a \par.
4672
4673 % Our approach is to make ^^M insert a space and a penalty1 normally;
4674 % then it can also check if \lastpenalty=1.  If it does, then manually
4675 % do \par.
4676
4677 % Seems pretty fragile, but for the limited use of getting the copying
4678 % text (which should be quite simple) inserted, we can hope it's ok.
4679 % % 
4680 {\catcode`\^^M=\active %
4681 \gdef\insertcopying{\begingroup %
4682   \parindent = 0pt  % looks wrong on title page
4683   \def^^M{%
4684     \ifnum \lastpenalty=1 %
4685       \par %
4686     \else %
4687       \space \penalty 1 %
4688     \fi %
4689   }%
4690   \copyingtext %
4691 \endgroup}%
4692 }
4693
4694 \message{defuns,}
4695 % @defun etc.
4696
4697 % Allow user to change definition object font (\df) internally
4698 \def\setdeffont#1 {\csname DEF#1\endcsname}
4699
4700 \newskip\defbodyindent \defbodyindent=.4in
4701 \newskip\defargsindent \defargsindent=50pt
4702 \newskip\deflastargmargin \deflastargmargin=18pt
4703
4704 \newcount\parencount
4705
4706 % We want ()&[] to print specially on the defun line.
4707
4708 \def\activeparens{%
4709   \catcode`\(=\active \catcode`\)=\active
4710   \catcode`\&=\active
4711   \catcode`\[=\active \catcode`\]=\active
4712 }
4713
4714 % Make control sequences which act like normal parenthesis chars.
4715 \let\lparen = ( \let\rparen = )
4716
4717 {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
4718
4719 % Be sure that we always have a definition for `(', etc.  For example,
4720 % if the fn name has parens in it, \boldbrax will not be in effect yet,
4721 % so TeX would otherwise complain about undefined control sequence.
4722 \global\let(=\lparen \global\let)=\rparen
4723 \global\let[=\lbrack \global\let]=\rbrack
4724
4725 \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
4726 \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
4727 % This is used to turn on special parens
4728 % but make & act ordinary (given that it's active).
4729 \gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr}
4730
4731 % Definitions of (, ) and & used in args for functions.
4732 % This is the definition of ( outside of all parentheses.
4733 \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested
4734   \global\advance\parencount by 1
4735 }
4736 %
4737 % This is the definition of ( when already inside a level of parens.
4738 \gdef\opnested{\char`\(\global\advance\parencount by 1 }
4739 %
4740 \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
4741   % also in that case restore the outer-level definition of (.
4742   \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
4743   \global\advance \parencount by -1 }
4744 % If we encounter &foo, then turn on ()-hacking afterwards
4745 \gdef\amprm#1 {{\rm\&#1}\let(=\oprm \let)=\clrm\ }
4746 %
4747 \gdef\normalparens{\boldbrax\let&=\ampnr}
4748 } % End of definition inside \activeparens
4749 %% These parens (in \boldbrax) actually are a little bolder than the
4750 %% contained text.  This is especially needed for [ and ]
4751 \def\opnr{{\sf\char`\(}\global\advance\parencount by 1 }
4752 \def\clnr{{\sf\char`\)}\global\advance\parencount by -1 }
4753 \let\ampnr = \&
4754 \def\lbrb{{\bf\char`\[}}
4755 \def\rbrb{{\bf\char`\]}}
4756
4757 % Active &'s sneak into the index arguments, so make sure it's defined.
4758 {
4759   \catcode`& = 13
4760   \global\let& = \ampnr
4761 }
4762
4763 % \defname, which formats the name of the @def (not the args).
4764 % #1 is the function name.
4765 % #2 is the type of definition, such as "Function".
4766 %
4767 \def\defname#1#2{%
4768   % How we'll output the type name.  Putting it in brackets helps
4769   % distinguish it from the body text that may end up on the next line
4770   % just below it.
4771   \ifempty{#2}%
4772     \def\defnametype{}%
4773   \else
4774     \def\defnametype{[\rm #2]}%
4775   \fi
4776   %
4777   % Get the values of \leftskip and \rightskip as they were outside the @def...
4778   \dimen2=\leftskip
4779   \advance\dimen2 by -\defbodyindent
4780   %
4781   % Figure out values for the paragraph shape.
4782   \setbox0=\hbox{\hskip \deflastargmargin{\defnametype}}%
4783   \dimen0=\hsize \advance \dimen0 by -\wd0  % compute size for first line
4784   \dimen1=\hsize \advance \dimen1 by -\defargsindent  % size for continuations
4785   \parshape 2 0in \dimen0 \defargsindent \dimen1
4786   %
4787   % Output arg 2 ("Function" or some such) but stuck inside a box of
4788   % width 0 so it does not interfere with linebreaking.
4789   \noindent
4790   %
4791   {% Adjust \hsize to exclude the ambient margins,
4792    % so that \rightline will obey them.
4793    \advance \hsize by -\dimen2
4794    \dimen3 = 0pt  % was -1.25pc
4795    \rlap{\rightline{\defnametype\kern\dimen3}}%
4796   }%
4797   %
4798   % Allow all lines to be underfull without complaint:
4799   \tolerance=10000 \hbadness=10000
4800   \advance\leftskip by -\defbodyindent
4801   \exdentamount=\defbodyindent
4802   {\df #1}\enskip        % output function name
4803   % \defunargs will be called next to output the arguments, if any.
4804 }
4805
4806 % Common pieces to start any @def...
4807 % #1 is the \E... control sequence to end the definition (which we define).
4808 % #2 is the \...x control sequence (which our caller defines).
4809 % #3 is the control sequence to process the header, such as \defunheader.
4810
4811 \def\parsebodycommon#1#2#3{%
4812   \begingroup\inENV
4813   % If there are two @def commands in a row, we'll have a \nobreak,
4814   % which is there to keep the function description together with its
4815   % header.  But if there's nothing but headers, we want to allow a
4816   % break after all.
4817   \ifnum\lastpenalty=10000 \penalty0 \fi
4818   \medbreak
4819   %
4820   % Define the \E... end token that this defining construct specifies
4821   % so that it will exit this group.
4822   \def#1{\endgraf\endgroup\medbreak}%
4823   %
4824   \parindent=0in
4825   \advance\leftskip by \defbodyindent
4826   \exdentamount=\defbodyindent
4827 }
4828
4829 % Common part of the \...x definitions.
4830
4831 \def\defxbodycommon{%
4832   % As with \parsebodycommon above, allow line break if we have multiple
4833   % x headers in a row.  It's not a great place, though.
4834   \ifnum\lastpenalty=10000 \penalty1000 \fi
4835   %
4836   \begingroup\obeylines
4837 }
4838
4839 % Process body of @defun, @deffn, @defmac, etc.
4840 %
4841 \def\defparsebody#1#2#3{%
4842   \parsebodycommon{#1}{#2}{#3}%
4843   \def#2{\defxbodycommon \activeparens \spacesplit#3}%
4844   \catcode61=\active % 61 is `='
4845   \begingroup\obeylines\activeparens
4846   \spacesplit#3%
4847 }
4848
4849 % #1, #2, #3 are the common arguments (see \parsebodycommon above).
4850 % #4, delimited by the space, is the class name.
4851 %
4852 \def\defmethparsebody#1#2#3#4 {%
4853   \parsebodycommon{#1}{#2}{#3}%
4854   \def#2##1 {\defxbodycommon \activeparens \spacesplit{#3{##1}}}%
4855   \begingroup\obeylines\activeparens
4856   % The \empty here prevents misinterpretation of a construct such as
4857   %   @deffn {whatever} {Enharmonic comma}
4858   % See comments at \deftpparsebody, although in our case we don't have
4859   % to remove the \empty afterwards, since it is empty.
4860   \spacesplit{#3{#4}}\empty
4861 }
4862
4863 % Used for @deftypemethod and @deftypeivar.
4864 % #1, #2, #3 are the common arguments (see \defparsebody).
4865 % #4, delimited by a space, is the class name.
4866 % #5 is the method's return type.
4867 %
4868 \def\deftypemethparsebody#1#2#3#4 #5 {%
4869   \parsebodycommon{#1}{#2}{#3}%
4870   \def#2##1 ##2 {\defxbodycommon \activeparens \spacesplit{#3{##1}{##2}}}%
4871   \begingroup\obeylines\activeparens
4872   \spacesplit{#3{#4}{#5}}%
4873 }
4874
4875 % Used for @deftypeop.  The change from \deftypemethparsebody is an
4876 % extra argument at the beginning which is the `category', instead of it
4877 % being the hardwired string `Method' or `Instance Variable'.  We have
4878 % to account for this both in the \...x definition and in parsing the
4879 % input at hand.  Thus also need a control sequence (passed as #5) for
4880 % the \E... definition to assign the category name to.
4881
4882 \def\deftypeopparsebody#1#2#3#4#5 #6 {%
4883   \parsebodycommon{#1}{#2}{#3}%
4884   \def#2##1 ##2 ##3 {\def#4{##1}%
4885     \defxbodycommon \activeparens \spacesplit{#3{##2}{##3}}}%
4886   \begingroup\obeylines\activeparens
4887   \spacesplit{#3{#5}{#6}}%
4888 }
4889
4890 % For @defop.
4891 \def\defopparsebody #1#2#3#4#5 {%
4892   \parsebodycommon{#1}{#2}{#3}%
4893   \def#2##1 ##2 {\def#4{##1}%
4894     \defxbodycommon \activeparens \spacesplit{#3{##2}}}%
4895   \begingroup\obeylines\activeparens
4896   \spacesplit{#3{#5}}%
4897 }
4898
4899 % These parsing functions are similar to the preceding ones
4900 % except that they do not make parens into active characters.
4901 % These are used for "variables" since they have no arguments.
4902 %
4903 \def\defvarparsebody #1#2#3{%
4904   \parsebodycommon{#1}{#2}{#3}%
4905   \def#2{\defxbodycommon \spacesplit#3}%
4906   \catcode61=\active %
4907   \begingroup\obeylines
4908   \spacesplit#3%
4909 }
4910
4911 % @defopvar.
4912 \def\defopvarparsebody #1#2#3#4#5 {%
4913   \parsebodycommon{#1}{#2}{#3}%
4914   \def#2##1 ##2 {\def#4{##1}%
4915     \defxbodycommon \spacesplit{#3{##2}}}%
4916   \begingroup\obeylines
4917   \spacesplit{#3{#5}}%
4918 }
4919
4920 \def\defvrparsebody#1#2#3#4 {%
4921   \parsebodycommon{#1}{#2}{#3}%
4922   \def#2##1 {\defxbodycommon \spacesplit{#3{##1}}}%
4923   \begingroup\obeylines
4924   \spacesplit{#3{#4}}%
4925 }
4926
4927 % This loses on `@deftp {Data Type} {struct termios}' -- it thinks the
4928 % type is just `struct', because we lose the braces in `{struct
4929 % termios}' when \spacesplit reads its undelimited argument.  Sigh.
4930 % \let\deftpparsebody=\defvrparsebody
4931 %
4932 % So, to get around this, we put \empty in with the type name.  That
4933 % way, TeX won't find exactly `{...}' as an undelimited argument, and
4934 % won't strip off the braces.
4935 %
4936 \def\deftpparsebody #1#2#3#4 {%
4937   \parsebodycommon{#1}{#2}{#3}%
4938   \def#2##1 {\defxbodycommon \spacesplit{#3{##1}}}%
4939   \begingroup\obeylines
4940   \spacesplit{\parsetpheaderline{#3{#4}}}\empty
4941 }
4942
4943 % Fine, but then we have to eventually remove the \empty *and* the
4944 % braces (if any).  That's what this does.
4945 %
4946 \def\removeemptybraces\empty#1\relax{#1}
4947
4948 % After \spacesplit has done its work, this is called -- #1 is the final
4949 % thing to call, #2 the type name (which starts with \empty), and #3
4950 % (which might be empty) the arguments.
4951 %
4952 \def\parsetpheaderline#1#2#3{%
4953   #1{\removeemptybraces#2\relax}{#3}%
4954 }%
4955
4956 % Split up #2 (the rest of the input line) at the first space token.
4957 % call #1 with two arguments:
4958 %  the first is all of #2 before the space token,
4959 %  the second is all of #2 after that space token.
4960 % If #2 contains no space token, all of it is passed as the first arg
4961 % and the second is passed as empty.
4962 %
4963 {\obeylines %
4964  \gdef\spacesplit#1#2^^M{\endgroup\spacesplitx{#1}#2 \relax\spacesplitx}%
4965  \long\gdef\spacesplitx#1#2 #3#4\spacesplitx{%
4966    \ifx\relax #3%
4967      #1{#2}{}%
4968    \else %
4969      #1{#2}{#3#4}%
4970    \fi}%
4971 }
4972
4973 % Define @defun.
4974
4975 % First, define the processing that is wanted for arguments of \defun
4976 % Use this to expand the args and terminate the paragraph they make up
4977
4978 \def\defunargs#1{\functionparens \sl
4979 % Expand, preventing hyphenation at `-' chars.
4980 % Note that groups don't affect changes in \hyphenchar.
4981 % Set the font temporarily and use \font in case \setfont made \tensl a macro.
4982 {\tensl\hyphenchar\font=0}%
4983 #1%
4984 {\tensl\hyphenchar\font=45}%
4985 \ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi%
4986 \interlinepenalty=10000
4987 \advance\rightskip by 0pt plus 1fil
4988 \endgraf\nobreak\vskip -\parskip\nobreak
4989 }
4990
4991 \def\deftypefunargs #1{%
4992 % Expand, preventing hyphenation at `-' chars.
4993 % Note that groups don't affect changes in \hyphenchar.
4994 % Use \boldbraxnoamp, not \functionparens, so that & is not special.
4995 \boldbraxnoamp
4996 \tclose{#1}% avoid \code because of side effects on active chars
4997 \interlinepenalty=10000
4998 \advance\rightskip by 0pt plus 1fil
4999 \endgraf\nobreak\vskip -\parskip\nobreak
5000 }
5001
5002 % Do complete processing of one @defun or @defunx line already parsed.
5003
5004 % @deffn Command forward-char nchars
5005
5006 \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
5007
5008 \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
5009 \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
5010 \catcode 61=\other % Turn off change made in \defparsebody
5011 }
5012
5013 % @defun == @deffn Function
5014
5015 \def\defun{\defparsebody\Edefun\defunx\defunheader}
5016
5017 \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
5018 \begingroup\defname {#1}{\putwordDeffunc}%
5019 \defunargs {#2}\endgroup %
5020 \catcode 61=\other % Turn off change made in \defparsebody
5021 }
5022
5023 % @deftypefun int foobar (int @var{foo}, float @var{bar})
5024
5025 \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
5026
5027 % #1 is the data type.  #2 is the name and args.
5028 \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
5029 % #1 is the data type, #2 the name, #3 the args.
5030 \def\deftypefunheaderx #1#2 #3\relax{%
5031 \doind {fn}{\code{#2}}% Make entry in function index
5032 \begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypefun}%
5033 \deftypefunargs {#3}\endgroup %
5034 \catcode 61=\other % Turn off change made in \defparsebody
5035 }
5036
5037 % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
5038
5039 \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
5040
5041 % \defheaderxcond#1\relax$.$
5042 % puts #1 in @code, followed by a space, but does nothing if #1 is null.
5043 \def\defheaderxcond#1#2$.${\ifx#1\relax\else\code{#1#2} \fi}
5044
5045 % #1 is the classification.  #2 is the data type.  #3 is the name and args.
5046 \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
5047 % #1 is the classification, #2 the data type, #3 the name, #4 the args.
5048 \def\deftypefnheaderx #1#2#3 #4\relax{%
5049 \doind {fn}{\code{#3}}% Make entry in function index
5050 \begingroup
5051 \normalparens % notably, turn off `&' magic, which prevents
5052 %               at least some C++ text from working
5053 \defname {\defheaderxcond#2\relax$.$#3}{#1}%
5054 \deftypefunargs {#4}\endgroup %
5055 \catcode 61=\other % Turn off change made in \defparsebody
5056 }
5057
5058 % @defmac == @deffn Macro
5059
5060 \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
5061
5062 \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
5063 \begingroup\defname {#1}{\putwordDefmac}%
5064 \defunargs {#2}\endgroup %
5065 \catcode 61=\other % Turn off change made in \defparsebody
5066 }
5067
5068 % @defspec == @deffn Special Form
5069
5070 \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
5071
5072 \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
5073 \begingroup\defname {#1}{\putwordDefspec}%
5074 \defunargs {#2}\endgroup %
5075 \catcode 61=\other % Turn off change made in \defparsebody
5076 }
5077
5078 % @defop CATEGORY CLASS OPERATION ARG...
5079 %
5080 \def\defop #1 {\def\defoptype{#1}%
5081 \defopparsebody\Edefop\defopx\defopheader\defoptype}
5082 %
5083 \def\defopheader#1#2#3{%
5084 \dosubind {fn}{\code{#2}}{\putwordon\ #1}% Make entry in function index
5085 \begingroup\defname {#2}{\defoptype\ \putwordon\ #1}%
5086 \defunargs {#3}\endgroup %
5087 }
5088
5089 % @deftypeop CATEGORY CLASS TYPE OPERATION ARG...
5090 %
5091 \def\deftypeop #1 {\def\deftypeopcategory{#1}%
5092   \deftypeopparsebody\Edeftypeop\deftypeopx\deftypeopheader
5093                        \deftypeopcategory}
5094 %
5095 % #1 is the class name, #2 the data type, #3 the operation name, #4 the args.
5096 \def\deftypeopheader#1#2#3#4{%
5097   \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
5098   \begingroup
5099     \defname{\defheaderxcond#2\relax$.$#3}
5100             {\deftypeopcategory\ \putwordon\ \code{#1}}%
5101     \deftypefunargs{#4}%
5102   \endgroup
5103 }
5104
5105 % @deftypemethod CLASS TYPE METHOD ARG...
5106 %
5107 \def\deftypemethod{%
5108   \deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader}
5109 %
5110 % #1 is the class name, #2 the data type, #3 the method name, #4 the args.
5111 \def\deftypemethodheader#1#2#3#4{%
5112   \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
5113   \begingroup
5114     \defname{\defheaderxcond#2\relax$.$#3}{\putwordMethodon\ \code{#1}}%
5115     \deftypefunargs{#4}%
5116   \endgroup
5117 }
5118
5119 % @deftypeivar CLASS TYPE VARNAME
5120 %
5121 \def\deftypeivar{%
5122   \deftypemethparsebody\Edeftypeivar\deftypeivarx\deftypeivarheader}
5123 %
5124 % #1 is the class name, #2 the data type, #3 the variable name.
5125 \def\deftypeivarheader#1#2#3{%
5126   \dosubind{vr}{\code{#3}}{\putwordof\ \code{#1}}% entry in variable index
5127   \begingroup
5128     \defname{\defheaderxcond#2\relax$.$#3}
5129             {\putwordInstanceVariableof\ \code{#1}}%
5130     \defvarargs{#3}%
5131   \endgroup
5132 }
5133
5134 % @defmethod == @defop Method
5135 %
5136 \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
5137 %
5138 % #1 is the class name, #2 the method name, #3 the args.
5139 \def\defmethodheader#1#2#3{%
5140   \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index
5141   \begingroup
5142     \defname{#2}{\putwordMethodon\ \code{#1}}%
5143     \defunargs{#3}%
5144   \endgroup
5145 }
5146
5147 % @defcv {Class Option} foo-class foo-flag
5148
5149 \def\defcv #1 {\def\defcvtype{#1}%
5150 \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
5151
5152 \def\defcvarheader #1#2#3{%
5153 \dosubind {vr}{\code{#2}}{\putwordof\ #1}% Make entry in var index
5154 \begingroup\defname {#2}{\defcvtype\ \putwordof\ #1}%
5155 \defvarargs {#3}\endgroup %
5156 }
5157
5158 % @defivar CLASS VARNAME == @defcv {Instance Variable} CLASS VARNAME
5159 %
5160 \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
5161 %
5162 \def\defivarheader#1#2#3{%
5163   \dosubind {vr}{\code{#2}}{\putwordof\ #1}% entry in var index
5164   \begingroup
5165     \defname{#2}{\putwordInstanceVariableof\ #1}%
5166     \defvarargs{#3}%
5167   \endgroup
5168 }
5169
5170 % @defvar
5171 % First, define the processing that is wanted for arguments of @defvar.
5172 % This is actually simple: just print them in roman.
5173 % This must expand the args and terminate the paragraph they make up
5174 \def\defvarargs #1{\normalparens #1%
5175 \interlinepenalty=10000
5176 \endgraf\nobreak\vskip -\parskip\nobreak}
5177
5178 % @defvr Counter foo-count
5179
5180 \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
5181
5182 \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
5183 \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
5184
5185 % @defvar == @defvr Variable
5186
5187 \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
5188
5189 \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
5190 \begingroup\defname {#1}{\putwordDefvar}%
5191 \defvarargs {#2}\endgroup %
5192 }
5193
5194 % @defopt == @defvr {User Option}
5195
5196 \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
5197
5198 \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
5199 \begingroup\defname {#1}{\putwordDefopt}%
5200 \defvarargs {#2}\endgroup %
5201 }
5202
5203 % @deftypevar int foobar
5204
5205 \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
5206
5207 % #1 is the data type.  #2 is the name, perhaps followed by text that
5208 % is actually part of the data type, which should not be put into the index.
5209 \def\deftypevarheader #1#2{%
5210 \dovarind#2 \relax% Make entry in variables index
5211 \begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypevar}%
5212 \interlinepenalty=10000
5213 \endgraf\nobreak\vskip -\parskip\nobreak
5214 \endgroup}
5215 \def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}}
5216
5217 % @deftypevr {Global Flag} int enable
5218
5219 \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
5220
5221 \def\deftypevrheader #1#2#3{\dovarind#3 \relax%
5222 \begingroup\defname {\defheaderxcond#2\relax$.$#3}{#1}
5223 \interlinepenalty=10000
5224 \endgraf\nobreak\vskip -\parskip\nobreak
5225 \endgroup}
5226
5227 % Now define @deftp
5228 % Args are printed in bold, a slight difference from @defvar.
5229
5230 \def\deftpargs #1{\bf \defvarargs{#1}}
5231
5232 % @deftp Class window height width ...
5233
5234 \def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
5235
5236 \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
5237 \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
5238
5239 % These definitions are used if you use @defunx (etc.)
5240 % anywhere other than immediately after a @defun or @defunx.
5241
5242 \def\defcvx#1 {\errmessage{@defcvx in invalid context}}
5243 \def\deffnx#1 {\errmessage{@deffnx in invalid context}}
5244 \def\defivarx#1 {\errmessage{@defivarx in invalid context}}
5245 \def\defmacx#1 {\errmessage{@defmacx in invalid context}}
5246 \def\defmethodx#1 {\errmessage{@defmethodx in invalid context}}
5247 \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
5248 \def\defopx#1 {\errmessage{@defopx in invalid context}}
5249 \def\defspecx#1 {\errmessage{@defspecx in invalid context}}
5250 \def\deftpx#1 {\errmessage{@deftpx in invalid context}}
5251 \def\deftypefnx#1 {\errmessage{@deftypefnx in invalid context}}
5252 \def\deftypefunx#1 {\errmessage{@deftypefunx in invalid context}}
5253 \def\deftypeivarx#1 {\errmessage{@deftypeivarx in invalid context}}
5254 \def\deftypemethodx#1 {\errmessage{@deftypemethodx in invalid context}}
5255 \def\deftypeopx#1 {\errmessage{@deftypeopx in invalid context}}
5256 \def\deftypevarx#1 {\errmessage{@deftypevarx in invalid context}}
5257 \def\deftypevrx#1 {\errmessage{@deftypevrx in invalid context}}
5258 \def\defunx#1 {\errmessage{@defunx in invalid context}}
5259 \def\defvarx#1 {\errmessage{@defvarx in invalid context}}
5260 \def\defvrx#1 {\errmessage{@defvrx in invalid context}}
5261
5262
5263 \message{macros,}
5264 % @macro.
5265
5266 % To do this right we need a feature of e-TeX, \scantokens,
5267 % which we arrange to emulate with a temporary file in ordinary TeX.
5268 \ifx\eTeXversion\undefined
5269  \newwrite\macscribble
5270  \def\scanmacro#1{%
5271    \begingroup \newlinechar`\^^M
5272    % Undo catcode changes of \startcontents and \doprintindex
5273    \catcode`\@=0 \catcode`\\=12 \escapechar=`\@
5274    % Append \endinput to make sure that TeX does not see the ending newline.
5275    \toks0={#1\endinput}%
5276    \immediate\openout\macscribble=\jobname.tmp
5277    \immediate\write\macscribble{\the\toks0}%
5278    \immediate\closeout\macscribble
5279    \let\xeatspaces\eatspaces
5280    \input \jobname.tmp
5281    \endgroup
5282 }
5283 \else
5284 \def\scanmacro#1{%
5285 \begingroup \newlinechar`\^^M
5286 % Undo catcode changes of \startcontents and \doprintindex
5287 \catcode`\@=0 \catcode`\\=12 \escapechar=`\@
5288 \let\xeatspaces\eatspaces\scantokens{#1\endinput}\endgroup}
5289 \fi
5290
5291 \newcount\paramno   % Count of parameters
5292 \newtoks\macname    % Macro name
5293 \newif\ifrecursive  % Is it recursive?
5294 \def\macrolist{}    % List of all defined macros in the form
5295                     % \do\macro1\do\macro2...
5296
5297 % Utility routines.
5298 % Thisdoes \let #1 = #2, except with \csnames.
5299 \def\cslet#1#2{%
5300 \expandafter\expandafter
5301 \expandafter\let
5302 \expandafter\expandafter
5303 \csname#1\endcsname
5304 \csname#2\endcsname}
5305
5306 % Trim leading and trailing spaces off a string.
5307 % Concepts from aro-bend problem 15 (see CTAN).
5308 {\catcode`\@=11
5309 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
5310 \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
5311 \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
5312 \def\unbrace#1{#1}
5313 \unbrace{\gdef\trim@@@ #1 } #2@{#1}
5314 }
5315
5316 % Trim a single trailing ^^M off a string.
5317 {\catcode`\^^M=12\catcode`\Q=3%
5318 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
5319 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
5320 \gdef\eatcrb#1Q#2Q{#1}%
5321 }
5322
5323 % Macro bodies are absorbed as an argument in a context where
5324 % all characters are catcode 10, 11 or 12, except \ which is active
5325 % (as in normal texinfo). It is necessary to change the definition of \.
5326
5327 % It's necessary to have hard CRs when the macro is executed. This is
5328 % done by  making ^^M (\endlinechar) catcode 12 when reading the macro
5329 % body, and then making it the \newlinechar in \scanmacro.
5330
5331 \def\macrobodyctxt{%
5332   \catcode`\~=12
5333   \catcode`\^=12
5334   \catcode`\_=12
5335   \catcode`\|=12
5336   \catcode`\<=12
5337   \catcode`\>=12
5338   \catcode`\+=12
5339   \catcode`\{=12
5340   \catcode`\}=12
5341   \catcode`\@=12
5342   \catcode`\^^M=12
5343   \usembodybackslash}
5344
5345 \def\macroargctxt{%
5346   \catcode`\~=12
5347   \catcode`\^=12
5348   \catcode`\_=12
5349   \catcode`\|=12
5350   \catcode`\<=12
5351   \catcode`\>=12
5352   \catcode`\+=12
5353   \catcode`\@=12
5354   \catcode`\\=12}
5355
5356 % \mbodybackslash is the definition of \ in @macro bodies.
5357 % It maps \foo\ => \csname macarg.foo\endcsname => #N
5358 % where N is the macro parameter number.
5359 % We define \csname macarg.\endcsname to be \realbackslash, so
5360 % \\ in macro replacement text gets you a backslash.
5361
5362 {\catcode`@=0 @catcode`@\=@active
5363  @gdef@usembodybackslash{@let\=@mbodybackslash}
5364  @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
5365 }
5366 \expandafter\def\csname macarg.\endcsname{\realbackslash}
5367
5368 \def\macro{\recursivefalse\parsearg\macroxxx}
5369 \def\rmacro{\recursivetrue\parsearg\macroxxx}
5370
5371 \def\macroxxx#1{%
5372   \getargs{#1}%           now \macname is the macname and \argl the arglist
5373   \ifx\argl\empty       % no arguments
5374      \paramno=0%
5375   \else
5376      \expandafter\parsemargdef \argl;%
5377   \fi
5378   \if1\csname ismacro.\the\macname\endcsname
5379      \message{Warning: redefining \the\macname}%
5380   \else
5381      \expandafter\ifx\csname \the\macname\endcsname \relax
5382      \else \errmessage{Macro name \the\macname\space already defined}\fi
5383      \global\cslet{macsave.\the\macname}{\the\macname}%
5384      \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
5385      % Add the macroname to \macrolist
5386      \toks0 = \expandafter{\macrolist\do}%
5387      \xdef\macrolist{\the\toks0
5388        \expandafter\noexpand\csname\the\macname\endcsname}%
5389   \fi
5390   \begingroup \macrobodyctxt
5391   \ifrecursive \expandafter\parsermacbody
5392   \else \expandafter\parsemacbody
5393   \fi}
5394
5395 \def\unmacro{\parsearg\unmacroxxx}
5396 \def\unmacroxxx#1{%
5397   \if1\csname ismacro.#1\endcsname
5398     \global\cslet{#1}{macsave.#1}%
5399     \global\expandafter\let \csname ismacro.#1\endcsname=0%
5400     % Remove the macro name from \macrolist
5401     \begingroup
5402       \edef\tempa{\expandafter\noexpand\csname#1\endcsname}%
5403       \def\do##1{%
5404         \def\tempb{##1}%
5405         \ifx\tempa\tempb
5406           % remove this
5407         \else
5408           \toks0 = \expandafter{\newmacrolist\do}%
5409           \edef\newmacrolist{\the\toks0\expandafter\noexpand\tempa}%
5410         \fi}%
5411       \def\newmacrolist{}%
5412       % Execute macro list to define \newmacrolist
5413       \macrolist
5414       \global\let\macrolist\newmacrolist
5415     \endgroup
5416   \else
5417     \errmessage{Macro #1 not defined}%
5418   \fi
5419 }
5420
5421 % This makes use of the obscure feature that if the last token of a
5422 % <parameter list> is #, then the preceding argument is delimited by
5423 % an opening brace, and that opening brace is not consumed.
5424 \def\getargs#1{\getargsxxx#1{}}
5425 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
5426 \def\getmacname #1 #2\relax{\macname={#1}}
5427 \def\getmacargs#1{\def\argl{#1}}
5428
5429 % Parse the optional {params} list.  Set up \paramno and \paramlist
5430 % so \defmacro knows what to do.  Define \macarg.blah for each blah
5431 % in the params list, to be ##N where N is the position in that list.
5432 % That gets used by \mbodybackslash (above).
5433
5434 % We need to get `macro parameter char #' into several definitions.
5435 % The technique used is stolen from LaTeX:  let \hash be something
5436 % unexpandable, insert that wherever you need a #, and then redefine
5437 % it to # just before using the token list produced.
5438 %
5439 % The same technique is used to protect \eatspaces till just before
5440 % the macro is used.
5441
5442 \def\parsemargdef#1;{\paramno=0\def\paramlist{}%
5443         \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,}
5444 \def\parsemargdefxxx#1,{%
5445   \if#1;\let\next=\relax
5446   \else \let\next=\parsemargdefxxx
5447     \advance\paramno by 1%
5448     \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
5449         {\xeatspaces{\hash\the\paramno}}%
5450     \edef\paramlist{\paramlist\hash\the\paramno,}%
5451   \fi\next}
5452
5453 % These two commands read recursive and nonrecursive macro bodies.
5454 % (They're different since rec and nonrec macros end differently.)
5455
5456 \long\def\parsemacbody#1@end macro%
5457 {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
5458 \long\def\parsermacbody#1@end rmacro%
5459 {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
5460
5461 % This defines the macro itself. There are six cases: recursive and
5462 % nonrecursive macros of zero, one, and many arguments.
5463 % Much magic with \expandafter here.
5464 % \xdef is used so that macro definitions will survive the file
5465 % they're defined in; @include reads the file inside a group.
5466 \def\defmacro{%
5467   \let\hash=##% convert placeholders to macro parameter chars
5468   \ifrecursive
5469     \ifcase\paramno
5470     % 0
5471       \expandafter\xdef\csname\the\macname\endcsname{%
5472         \noexpand\scanmacro{\temp}}%
5473     \or % 1
5474       \expandafter\xdef\csname\the\macname\endcsname{%
5475          \bgroup\noexpand\macroargctxt
5476          \noexpand\braceorline
5477          \expandafter\noexpand\csname\the\macname xxx\endcsname}%
5478       \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
5479          \egroup\noexpand\scanmacro{\temp}}%
5480     \else % many
5481       \expandafter\xdef\csname\the\macname\endcsname{%
5482          \bgroup\noexpand\macroargctxt
5483          \noexpand\csname\the\macname xx\endcsname}%
5484       \expandafter\xdef\csname\the\macname xx\endcsname##1{%
5485           \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
5486       \expandafter\expandafter
5487       \expandafter\xdef
5488       \expandafter\expandafter
5489         \csname\the\macname xxx\endcsname
5490           \paramlist{\egroup\noexpand\scanmacro{\temp}}%
5491     \fi
5492   \else
5493     \ifcase\paramno
5494     % 0
5495       \expandafter\xdef\csname\the\macname\endcsname{%
5496         \noexpand\norecurse{\the\macname}%
5497         \noexpand\scanmacro{\temp}\egroup}%
5498     \or % 1
5499       \expandafter\xdef\csname\the\macname\endcsname{%
5500          \bgroup\noexpand\macroargctxt
5501          \noexpand\braceorline
5502          \expandafter\noexpand\csname\the\macname xxx\endcsname}%
5503       \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
5504         \egroup
5505         \noexpand\norecurse{\the\macname}%
5506         \noexpand\scanmacro{\temp}\egroup}%
5507     \else % many
5508       \expandafter\xdef\csname\the\macname\endcsname{%
5509          \bgroup\noexpand\macroargctxt
5510          \expandafter\noexpand\csname\the\macname xx\endcsname}%
5511       \expandafter\xdef\csname\the\macname xx\endcsname##1{%
5512           \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
5513       \expandafter\expandafter
5514       \expandafter\xdef
5515       \expandafter\expandafter
5516       \csname\the\macname xxx\endcsname
5517       \paramlist{%
5518           \egroup
5519           \noexpand\norecurse{\the\macname}%
5520           \noexpand\scanmacro{\temp}\egroup}%
5521     \fi
5522   \fi}
5523
5524 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
5525
5526 % \braceorline decides whether the next nonwhitespace character is a
5527 % {.  If so it reads up to the closing }, if not, it reads the whole
5528 % line.  Whatever was read is then fed to the next control sequence
5529 % as an argument (by \parsebrace or \parsearg)
5530 \def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx}
5531 \def\braceorlinexxx{%
5532   \ifx\nchar\bgroup\else
5533     \expandafter\parsearg
5534   \fi \next}
5535
5536 % We mant to disable all macros during \shipout so that they are not
5537 % expanded by \write.
5538 \def\turnoffmacros{\begingroup \def\do##1{\let\noexpand##1=\relax}%
5539   \edef\next{\macrolist}\expandafter\endgroup\next}
5540
5541
5542 % @alias.
5543 % We need some trickery to remove the optional spaces around the equal
5544 % sign.  Just make them active and then expand them all to nothing.
5545 \def\alias{\begingroup\obeyspaces\parsearg\aliasxxx}
5546 \def\aliasxxx #1{\aliasyyy#1\relax}
5547 \def\aliasyyy #1=#2\relax{\ignoreactivespaces
5548 \edef\next{\global\let\expandafter\noexpand\csname#1\endcsname=%
5549            \expandafter\noexpand\csname#2\endcsname}%
5550 \expandafter\endgroup\next}
5551
5552
5553 \message{cross references,}
5554 % @xref etc.
5555
5556 \newwrite\auxfile
5557
5558 \newif\ifhavexrefs    % True if xref values are known.
5559 \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
5560
5561 % @inforef is relatively simple.
5562 \def\inforef #1{\inforefzzz #1,,,,**}
5563 \def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
5564   node \samp{\ignorespaces#1{}}}
5565
5566 % @node's job is to define \lastnode.
5567 \def\node{\ENVcheck\parsearg\nodezzz}
5568 \def\nodezzz#1{\nodexxx [#1,]}
5569 \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
5570 \let\nwnode=\node
5571 \let\lastnode=\relax
5572
5573 % The sectioning commands (@chapter, etc.) call these.
5574 \def\donoderef{%
5575   \ifx\lastnode\relax\else
5576     \expandafter\expandafter\expandafter\setref{\lastnode}%
5577       {Ysectionnumberandtype}%
5578     \global\let\lastnode=\relax
5579   \fi
5580 }
5581 \def\unnumbnoderef{%
5582   \ifx\lastnode\relax\else
5583     \expandafter\expandafter\expandafter\setref{\lastnode}{Ynothing}%
5584     \global\let\lastnode=\relax
5585   \fi
5586 }
5587 \def\appendixnoderef{%
5588   \ifx\lastnode\relax\else
5589     \expandafter\expandafter\expandafter\setref{\lastnode}%
5590       {Yappendixletterandtype}%
5591     \global\let\lastnode=\relax
5592   \fi
5593 }
5594
5595
5596 % @anchor{NAME} -- define xref target at arbitrary point.
5597 %
5598 \newcount\savesfregister
5599 \gdef\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
5600 \gdef\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
5601 \gdef\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
5602
5603 % \setref{NAME}{SNT} defines a cross-reference point NAME, namely
5604 % NAME-title, NAME-pg, and NAME-SNT.  Called from \foonoderef.  We have
5605 % to set \indexdummies so commands such as @code in a section title
5606 % aren't expanded.  It would be nicer not to expand the titles in the
5607 % first place, but there's so many layers that that is hard to do.
5608 %
5609 \def\setref#1#2{{%
5610   \indexdummies
5611   \pdfmkdest{#1}%
5612   \dosetq{#1-title}{Ytitle}%
5613   \dosetq{#1-pg}{Ypagenumber}%
5614   \dosetq{#1-snt}{#2}%
5615 }}
5616
5617 % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
5618 % the node name, #2 the name of the Info cross-reference, #3 the printed
5619 % node name, #4 the name of the Info file, #5 the name of the printed
5620 % manual.  All but the node name can be omitted.
5621 %
5622 \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
5623 \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
5624 \def\ref#1{\xrefX[#1,,,,,,,]}
5625 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
5626   \unsepspaces
5627   \def\printedmanual{\ignorespaces #5}%
5628   \def\printednodename{\ignorespaces #3}%
5629   \setbox1=\hbox{\printedmanual}%
5630   \setbox0=\hbox{\printednodename}%
5631   \ifdim \wd0 = 0pt
5632     % No printed node name was explicitly given.
5633     \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
5634       % Use the node name inside the square brackets.
5635       \def\printednodename{\ignorespaces #1}%
5636     \else
5637       % Use the actual chapter/section title appear inside
5638       % the square brackets.  Use the real section title if we have it.
5639       \ifdim \wd1 > 0pt
5640         % It is in another manual, so we don't have it.
5641         \def\printednodename{\ignorespaces #1}%
5642       \else
5643         \ifhavexrefs
5644           % We know the real title if we have the xref values.
5645           \def\printednodename{\refx{#1-title}{}}%
5646         \else
5647           % Otherwise just copy the Info node name.
5648           \def\printednodename{\ignorespaces #1}%
5649         \fi%
5650       \fi
5651     \fi
5652   \fi
5653   %
5654   % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
5655   % insert empty discretionaries after hyphens, which means that it will
5656   % not find a line break at a hyphen in a node names.  Since some manuals
5657   % are best written with fairly long node names, containing hyphens, this
5658   % is a loss.  Therefore, we give the text of the node name again, so it
5659   % is as if TeX is seeing it for the first time.
5660   \ifpdf
5661     \leavevmode
5662     \getfilename{#4}%
5663     {\normalturnoffactive
5664      \ifnum\filenamelength>0
5665        \startlink attr{/Border [0 0 0]}%
5666          goto file{\the\filename.pdf} name{#1}%
5667      \else
5668        \startlink attr{/Border [0 0 0]}%
5669          goto name{#1}%
5670      \fi
5671     }%
5672     \linkcolor
5673   \fi
5674   %
5675   \ifdim \wd1 > 0pt
5676     \putwordsection{} ``\printednodename'' \putwordin{} \cite{\printedmanual}%
5677   \else
5678     % _ (for example) has to be the character _ for the purposes of the
5679     % control sequence corresponding to the node, but it has to expand
5680     % into the usual \leavevmode...\vrule stuff for purposes of
5681     % printing. So we \turnoffactive for the \refx-snt, back on for the
5682     % printing, back off for the \refx-pg.
5683     {\normalturnoffactive
5684      % Only output a following space if the -snt ref is nonempty; for
5685      % @unnumbered and @anchor, it won't be.
5686      \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
5687      \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
5688     }%
5689     % [mynode],
5690     [\printednodename],\space
5691     % page 3
5692     \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
5693   \fi
5694   \endlink
5695 \endgroup}
5696
5697 % \dosetq is the interface for calls from other macros
5698
5699 % Use \normalturnoffactive so that punctuation chars such as underscore
5700 % and backslash work in node names.  (\turnoffactive doesn't do \.)
5701 \def\dosetq#1#2{%
5702   {\let\folio=0%
5703    \normalturnoffactive
5704    \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}%
5705    \iflinks
5706      \next
5707    \fi
5708   }%
5709 }
5710
5711 % \internalsetq {foo}{page} expands into
5712 % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
5713 % When the aux file is read, ' is the escape character
5714
5715 \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
5716
5717 % Things to be expanded by \internalsetq
5718
5719 \def\Ypagenumber{\folio}
5720
5721 \def\Ytitle{\thissection}
5722
5723 \def\Ynothing{}
5724
5725 \def\Ysectionnumberandtype{%
5726 \ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
5727 \else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
5728 \else \ifnum \subsubsecno=0 %
5729 \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
5730 \else %
5731 \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
5732 \fi \fi \fi }
5733
5734 \def\Yappendixletterandtype{%
5735 \ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
5736 \else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
5737 \else \ifnum \subsubsecno=0 %
5738 \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
5739 \else %
5740 \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
5741 \fi \fi \fi }
5742
5743 \gdef\xreftie{'tie}
5744
5745 % Use TeX 3.0's \inputlineno to get the line number, for better error
5746 % messages, but if we're using an old version of TeX, don't do anything.
5747 %
5748 \ifx\inputlineno\thisisundefined
5749   \let\linenumber = \empty % Non-3.0.
5750 \else
5751   \def\linenumber{\the\inputlineno:\space}
5752 \fi
5753
5754 % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
5755 % If its value is nonempty, SUFFIX is output afterward.
5756
5757 \def\refx#1#2{%
5758   \expandafter\ifx\csname X#1\endcsname\relax
5759     % If not defined, say something at least.
5760     \angleleft un\-de\-fined\angleright
5761     \iflinks
5762       \ifhavexrefs
5763         \message{\linenumber Undefined cross reference `#1'.}%
5764       \else
5765         \ifwarnedxrefs\else
5766           \global\warnedxrefstrue
5767           \message{Cross reference values unknown; you must run TeX again.}%
5768         \fi
5769       \fi
5770     \fi
5771   \else
5772     % It's defined, so just use it.
5773     \csname X#1\endcsname
5774   \fi
5775   #2% Output the suffix in any case.
5776 }
5777
5778 % This is the macro invoked by entries in the aux file.
5779 %
5780 \def\xrdef#1{\begingroup
5781   % Reenable \ as an escape while reading the second argument.
5782   \catcode`\\ = 0
5783   \afterassignment\endgroup
5784   \expandafter\gdef\csname X#1\endcsname
5785 }
5786
5787 % Read the last existing aux file, if any.  No error if none exists.
5788 \def\readauxfile{\begingroup
5789   \catcode`\^^@=\other
5790   \catcode`\^^A=\other
5791   \catcode`\^^B=\other
5792   \catcode`\^^C=\other
5793   \catcode`\^^D=\other
5794   \catcode`\^^E=\other
5795   \catcode`\^^F=\other
5796   \catcode`\^^G=\other
5797   \catcode`\^^H=\other
5798   \catcode`\^^K=\other
5799   \catcode`\^^L=\other
5800   \catcode`\^^N=\other
5801   \catcode`\^^P=\other
5802   \catcode`\^^Q=\other
5803   \catcode`\^^R=\other
5804   \catcode`\^^S=\other
5805   \catcode`\^^T=\other
5806   \catcode`\^^U=\other
5807   \catcode`\^^V=\other
5808   \catcode`\^^W=\other
5809   \catcode`\^^X=\other
5810   \catcode`\^^Z=\other
5811   \catcode`\^^[=\other
5812   \catcode`\^^\=\other
5813   \catcode`\^^]=\other
5814   \catcode`\^^^=\other
5815   \catcode`\^^_=\other
5816   \catcode`\@=\other
5817   \catcode`\^=\other
5818   % It was suggested to define this as 7, which would allow ^^e4 etc.
5819   % in xref tags, i.e., node names.  But since ^^e4 notation isn't
5820   % supported in the main text, it doesn't seem desirable.  Furthermore,
5821   % that is not enough: for node names that actually contain a ^
5822   % character, we would end up writing a line like this: 'xrdef {'hat
5823   % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
5824   % argument, and \hat is not an expandable control sequence.  It could
5825   % all be worked out, but why?  Either we support ^^ or we don't.
5826   %
5827   % The other change necessary for this was to define \auxhat:
5828   % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
5829   % and then to call \auxhat in \setq.
5830   %
5831   \catcode`\~=\other
5832   \catcode`\[=\other
5833   \catcode`\]=\other
5834   \catcode`\"=\other
5835   \catcode`\_=\other
5836   \catcode`\|=\other
5837   \catcode`\<=\other
5838   \catcode`\>=\other
5839   \catcode`\$=\other
5840   \catcode`\#=\other
5841   \catcode`\&=\other
5842   \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
5843   % Make the characters 128-255 be printing characters
5844   {%
5845     \count 1=128
5846     \def\loop{%
5847       \catcode\count 1=\other
5848       \advance\count 1 by 1
5849       \ifnum \count 1<256 \loop \fi
5850     }%
5851   }%
5852   % The aux file uses ' as the escape (for now).
5853   % Turn off \ as an escape so we do not lose on
5854   % entries which were dumped with control sequences in their names.
5855   % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
5856   % Reference to such entries still does not work the way one would wish,
5857   % but at least they do not bomb out when the aux file is read in.
5858   \catcode`\{=1
5859   \catcode`\}=2
5860   \catcode`\%=\other
5861   \catcode`\'=0
5862   \catcode`\\=\other
5863   %
5864   \openin 1 \jobname.aux
5865   \ifeof 1 \else
5866     \closein 1
5867     \input \jobname.aux
5868     \global\havexrefstrue
5869     \global\warnedobstrue
5870   \fi
5871   % Open the new aux file.  TeX will close it automatically at exit.
5872   \openout\auxfile=\jobname.aux
5873 \endgroup}
5874
5875
5876 % Footnotes.
5877
5878 \newcount \footnoteno
5879
5880 % The trailing space in the following definition for supereject is
5881 % vital for proper filling; pages come out unaligned when you do a
5882 % pagealignmacro call if that space before the closing brace is
5883 % removed. (Generally, numeric constants should always be followed by a
5884 % space to prevent strange expansion errors.)
5885 \def\supereject{\par\penalty -20000\footnoteno =0 }
5886
5887 % @footnotestyle is meaningful for info output only.
5888 \let\footnotestyle=\comment
5889
5890 \let\ptexfootnote=\footnote
5891
5892 {\catcode `\@=11
5893 %
5894 % Auto-number footnotes.  Otherwise like plain.
5895 \gdef\footnote{%
5896   \global\advance\footnoteno by \@ne
5897   \edef\thisfootno{$^{\the\footnoteno}$}%
5898   %
5899   % In case the footnote comes at the end of a sentence, preserve the
5900   % extra spacing after we do the footnote number.
5901   \let\@sf\empty
5902   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
5903   %
5904   % Remove inadvertent blank space before typesetting the footnote number.
5905   \unskip
5906   \thisfootno\@sf
5907   \footnotezzz
5908 }%
5909
5910 % Don't bother with the trickery in plain.tex to not require the
5911 % footnote text as a parameter.  Our footnotes don't need to be so general.
5912 %
5913 % Oh yes, they do; otherwise, @ifset and anything else that uses
5914 % \parseargline fail inside footnotes because the tokens are fixed when
5915 % the footnote is read.  --karl, 16nov96.
5916 %
5917 \long\gdef\footnotezzz{\insert\footins\bgroup
5918   % We want to typeset this text as a normal paragraph, even if the
5919   % footnote reference occurs in (for example) a display environment.
5920   % So reset some parameters.
5921   \interlinepenalty\interfootnotelinepenalty
5922   \splittopskip\ht\strutbox % top baseline for broken footnotes
5923   \splitmaxdepth\dp\strutbox
5924   \floatingpenalty\@MM
5925   \leftskip\z@skip
5926   \rightskip\z@skip
5927   \spaceskip\z@skip
5928   \xspaceskip\z@skip
5929   \parindent\defaultparindent
5930   %
5931   \smallfonts \rm
5932   %
5933   % Because we use hanging indentation in footnotes, a @noindent appears
5934   % to exdent this text, so make it be a no-op.  makeinfo does not use
5935   % hanging indentation so @noindent can still be needed within footnote
5936   % text after an @example or the like (not that this is good style).
5937   \let\noindent = \relax
5938   %
5939   % Hang the footnote text off the number.  Use \everypar in case the
5940   % footnote extends for more than one paragraph.
5941   \everypar = {\hang}%
5942   \textindent{\thisfootno}%
5943   %
5944   % Don't crash into the line above the footnote text.  Since this
5945   % expands into a box, it must come within the paragraph, lest it
5946   % provide a place where TeX can split the footnote.
5947   \footstrut
5948   \futurelet\next\fo@t
5949 }
5950 \def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t
5951   \else\let\next\f@t\fi \next}
5952 \def\f@@t{\bgroup\aftergroup\@foot\let\next}
5953 \def\f@t#1{#1\@foot}
5954 \def\@foot{\strut\par\egroup}
5955
5956 }%end \catcode `\@=11
5957
5958 % @| inserts a changebar to the left of the current line.  It should
5959 % surround any changed text.  This approach does *not* work if the
5960 % change spans more than two lines of output.  To handle that, we would
5961 % have adopt a much more difficult approach (putting marks into the main
5962 % vertical list for the beginning and end of each change).
5963 %
5964 \def\|{%
5965   % \vadjust can only be used in horizontal mode.
5966   \leavevmode
5967   %
5968   % Append this vertical mode material after the current line in the output.
5969   \vadjust{%
5970     % We want to insert a rule with the height and depth of the current
5971     % leading; that is exactly what \strutbox is supposed to record.
5972     \vskip-\baselineskip
5973     %
5974     % \vadjust-items are inserted at the left edge of the type.  So
5975     % the \llap here moves out into the left-hand margin.
5976     \llap{%
5977       %
5978       % For a thicker or thinner bar, change the `1pt'.
5979       \vrule height\baselineskip width1pt
5980       %
5981       % This is the space between the bar and the text.
5982       \hskip 12pt
5983     }%
5984   }%
5985 }
5986
5987 % For a final copy, take out the rectangles
5988 % that mark overfull boxes (in case you have decided
5989 % that the text looks ok even though it passes the margin).
5990 %
5991 \def\finalout{\overfullrule=0pt}
5992
5993 % @image.  We use the macros from epsf.tex to support this.
5994 % If epsf.tex is not installed and @image is used, we complain.
5995 %
5996 % Check for and read epsf.tex up front.  If we read it only at @image
5997 % time, we might be inside a group, and then its definitions would get
5998 % undone and the next image would fail.
5999 \openin 1 = epsf.tex
6000 \ifeof 1 \else
6001   \closein 1
6002   % Do not bother showing banner with post-v2.7 epsf.tex (available in
6003   % doc/epsf.tex until it shows up on ctan).
6004   \def\epsfannounce{\toks0 = }%
6005   \input epsf.tex
6006 \fi
6007 %
6008 % We will only complain once about lack of epsf.tex.
6009 \newif\ifwarnednoepsf
6010 \newhelp\noepsfhelp{epsf.tex must be installed for images to
6011   work.  It is also included in the Texinfo distribution, or you can get
6012   it from ftp://tug.org/tex/epsf.tex.}
6013 %
6014 \def\image#1{%
6015   \ifx\epsfbox\undefined
6016     \ifwarnednoepsf \else
6017       \errhelp = \noepsfhelp
6018       \errmessage{epsf.tex not found, images will be ignored}%
6019       \global\warnednoepsftrue
6020     \fi
6021   \else
6022     \imagexxx #1,,,,,\finish
6023   \fi
6024 }
6025 %
6026 % Arguments to @image:
6027 % #1 is (mandatory) image filename; we tack on .eps extension.
6028 % #2 is (optional) width, #3 is (optional) height.
6029 % #4 is (ignored optional) html alt text.
6030 % #5 is (ignored optional) extension.
6031 % #6 is just the usual extra ignored arg for parsing this stuff.
6032 \newif\ifimagevmode
6033 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
6034   \catcode`\^^M = 5     % in case we're inside an example
6035   \normalturnoffactive  % allow _ et al. in names
6036   % If the image is by itself, center it.
6037   \ifvmode
6038     \imagevmodetrue
6039     \nobreak\bigskip
6040     % Usually we'll have text after the image which will insert
6041     % \parskip glue, so insert it here too to equalize the space
6042     % above and below. 
6043     \nobreak\vskip\parskip
6044     \nobreak
6045     \line\bgroup\hss
6046   \fi
6047   %
6048   % Output the image.
6049   \ifpdf
6050     \dopdfimage{#1}{#2}{#3}%
6051   \else
6052     % \epsfbox itself resets \epsf?size at each figure.
6053     \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
6054     \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
6055     \epsfbox{#1.eps}%
6056   \fi
6057   %
6058   \ifimagevmode \hss \egroup \bigbreak \fi  % space after the image
6059 \endgroup}
6060
6061
6062 \message{localization,}
6063 % and i18n.
6064
6065 % @documentlanguage is usually given very early, just after
6066 % @setfilename.  If done too late, it may not override everything
6067 % properly.  Single argument is the language abbreviation.
6068 % It would be nice if we could set up a hyphenation file here.
6069 %
6070 \def\documentlanguage{\parsearg\dodocumentlanguage}
6071 \def\dodocumentlanguage#1{%
6072   \tex % read txi-??.tex file in plain TeX.
6073   % Read the file if it exists.
6074   \openin 1 txi-#1.tex
6075   \ifeof1
6076     \errhelp = \nolanghelp
6077     \errmessage{Cannot read language file txi-#1.tex}%
6078     \let\temp = \relax
6079   \else
6080     \def\temp{\input txi-#1.tex }%
6081   \fi
6082   \temp
6083   \endgroup
6084 }
6085 \newhelp\nolanghelp{The given language definition file cannot be found or
6086 is empty.  Maybe you need to install it?  In the current directory
6087 should work if nowhere else does.}
6088
6089
6090 % @documentencoding should change something in TeX eventually, most
6091 % likely, but for now just recognize it.
6092 \let\documentencoding = \comment
6093
6094
6095 % Page size parameters.
6096 %
6097 \newdimen\defaultparindent \defaultparindent = 15pt
6098
6099 \chapheadingskip = 15pt plus 4pt minus 2pt
6100 \secheadingskip = 12pt plus 3pt minus 2pt
6101 \subsecheadingskip = 9pt plus 2pt minus 2pt
6102
6103 % Prevent underfull vbox error messages.
6104 \vbadness = 10000
6105
6106 % Don't be so finicky about underfull hboxes, either.
6107 \hbadness = 2000
6108
6109 % Following George Bush, just get rid of widows and orphans.
6110 \widowpenalty=10000
6111 \clubpenalty=10000
6112
6113 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
6114 % using an old version of TeX, don't do anything.  We want the amount of
6115 % stretch added to depend on the line length, hence the dependence on
6116 % \hsize.  We call this whenever the paper size is set.
6117 %
6118 \def\setemergencystretch{%
6119   \ifx\emergencystretch\thisisundefined
6120     % Allow us to assign to \emergencystretch anyway.
6121     \def\emergencystretch{\dimen0}%
6122   \else
6123     \emergencystretch = .15\hsize
6124   \fi
6125 }
6126
6127 % Parameters in order: 1) textheight; 2) textwidth; 3) voffset;
6128 % 4) hoffset; 5) binding offset; 6) topskip; 7) physical page height; 8)
6129 % physical page width.
6130
6131 % We also call \setleading{\textleading}, so the caller should define
6132 % \textleading.  The caller should also set \parskip.
6133 %
6134 \def\internalpagesizes#1#2#3#4#5#6#7#8{%
6135   \voffset = #3\relax
6136   \topskip = #6\relax
6137   \splittopskip = \topskip
6138   %
6139   \vsize = #1\relax
6140   \advance\vsize by \topskip
6141   \outervsize = \vsize
6142   \advance\outervsize by 2\topandbottommargin
6143   \pageheight = \vsize
6144   %
6145   \hsize = #2\relax
6146   \outerhsize = \hsize
6147   \advance\outerhsize by 0.5in
6148   \pagewidth = \hsize
6149   %
6150   \normaloffset = #4\relax
6151   \bindingoffset = #5\relax
6152   %
6153   \ifpdf
6154     \pdfpageheight #7\relax
6155     \pdfpagewidth #8\relax
6156   \fi
6157   %
6158   \setleading{\textleading}
6159   %
6160   \parindent = \defaultparindent
6161   \setemergencystretch
6162 }
6163
6164 % Use `small' versions.
6165
6166 \def\smallenvironments{%
6167   \let\smalldisplay = \smalldisplayx
6168   \let\smallexample = \smalllispx
6169   \let\smallformat = \smallformatx
6170   \let\smalllisp = \smalllispx
6171 }
6172
6173 % @letterpaper (the default).
6174 \def\letterpaper{{\globaldefs = 1
6175   \parskip = 3pt plus 2pt minus 1pt
6176   \textleading = 13.2pt
6177   %
6178   % If page is nothing but text, make it come out even.
6179   \internalpagesizes{46\baselineskip}{6in}%
6180                     {\voffset}{.25in}%
6181                     {\bindingoffset}{36pt}%
6182                     {11in}{8.5in}%
6183 }}
6184
6185 % Use @smallbook to reset parameters for 7x9.5 (or so) format.
6186 \def\smallbook{{\globaldefs = 1
6187   \parskip = 2pt plus 1pt
6188   \textleading = 12pt
6189   %
6190   \internalpagesizes{7.5in}{5in}%
6191                     {\voffset}{.25in}%
6192                     {\bindingoffset}{16pt}%
6193                     {9.25in}{7in}%
6194   %
6195   \lispnarrowing = 0.3in
6196   \tolerance = 700
6197   \hfuzz = 1pt
6198   \contentsrightmargin = 0pt
6199   \defbodyindent = .5cm
6200   \smallenvironments
6201 }}
6202
6203 % Use @afourpaper to print on European A4 paper.
6204 \def\afourpaper{{\globaldefs = 1
6205   \parskip = 3pt plus 2pt minus 1pt
6206   \textleading = 13.2pt
6207   %
6208   % Double-side printing via postscript on Laserjet 4050 
6209   % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
6210   % To change the settings for a different printer or situation, adjust
6211   % \normaloffset until the front-side and back-side texts align.  Then
6212   % do the same for \bindingoffset.  You can set these for testing in
6213   % your texinfo source file like this:
6214   % @tex
6215   % \global\normaloffset = -6mm
6216   % \global\bindingoffset = 10mm
6217   % @end tex
6218   \internalpagesizes{51\baselineskip}{160mm}
6219                     {\voffset}{\hoffset}%
6220                     {\bindingoffset}{44pt}%
6221                     {297mm}{210mm}%
6222   %
6223   \tolerance = 700
6224   \hfuzz = 1pt
6225   \contentsrightmargin = 0pt
6226   \defbodyindent = 5mm
6227 }}
6228
6229 % Use @afivepaper to print on European A5 paper.
6230 % From romildo@urano.iceb.ufop.br, 2 July 2000.
6231 % He also recommends making @example and @lisp be small.
6232 \def\afivepaper{{\globaldefs = 1
6233   \parskip = 2pt plus 1pt minus 0.1pt
6234   \textleading = 12.5pt
6235   %
6236   \internalpagesizes{160mm}{120mm}%
6237                     {\voffset}{\hoffset}%
6238                     {\bindingoffset}{8pt}%
6239                     {210mm}{148mm}%
6240   %
6241   \lispnarrowing = 0.2in
6242   \tolerance = 800
6243   \hfuzz = 1.2pt
6244   \contentsrightmargin = 0pt
6245   \defbodyindent = 2mm
6246   \tableindent = 12mm
6247   %
6248   \smallenvironments
6249 }}
6250
6251 % A specific text layout, 24x15cm overall, intended for A4 paper.  
6252 \def\afourlatex{{\globaldefs = 1
6253   \afourpaper
6254   \internalpagesizes{237mm}{150mm}%
6255                     {\voffset}{4.6mm}%
6256                     {\bindingoffset}{7mm}%
6257                     {297mm}{210mm}%
6258   %
6259   % Must explicitly reset to 0 because we call \afourpaper.
6260   \globaldefs = 0
6261 }}
6262
6263 % Use @afourwide to print on A4 paper in landscape format.
6264 \def\afourwide{{\globaldefs = 1
6265   \afourpaper
6266   \internalpagesizes{241mm}{165mm}%
6267                     {\voffset}{-2.95mm}%
6268                     {\bindingoffset}{7mm}%
6269                     {297mm}{210mm}%
6270   \globaldefs = 0
6271 }}
6272
6273 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
6274 % Perhaps we should allow setting the margins, \topskip, \parskip,
6275 % and/or leading, also. Or perhaps we should compute them somehow.
6276 %
6277 \def\pagesizes{\parsearg\pagesizesxxx}
6278 \def\pagesizesxxx#1{\pagesizesyyy #1,,\finish}
6279 \def\pagesizesyyy#1,#2,#3\finish{{%
6280   \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
6281   \globaldefs = 1
6282   %
6283   \parskip = 3pt plus 2pt minus 1pt
6284   \setleading{\textleading}%
6285   %
6286   \dimen0 = #1
6287   \advance\dimen0 by \voffset
6288   %
6289   \dimen2 = \hsize
6290   \advance\dimen2 by \normaloffset
6291   %
6292   \internalpagesizes{#1}{\hsize}%
6293                     {\voffset}{\normaloffset}%
6294                     {\bindingoffset}{44pt}%
6295                     {\dimen0}{\dimen2}%
6296 }}
6297
6298 % Set default to letter.
6299 %
6300 \letterpaper
6301
6302
6303 \message{and turning on texinfo input format.}
6304
6305 % Define macros to output various characters with catcode for normal text.
6306 \catcode`\"=\other
6307 \catcode`\~=\other
6308 \catcode`\^=\other
6309 \catcode`\_=\other
6310 \catcode`\|=\other
6311 \catcode`\<=\other
6312 \catcode`\>=\other
6313 \catcode`\+=\other
6314 \catcode`\$=\other
6315 \def\normaldoublequote{"}
6316 \def\normaltilde{~}
6317 \def\normalcaret{^}
6318 \def\normalunderscore{_}
6319 \def\normalverticalbar{|}
6320 \def\normalless{<}
6321 \def\normalgreater{>}
6322 \def\normalplus{+}
6323 \def\normaldollar{$}%$ font-lock fix
6324
6325 % This macro is used to make a character print one way in ttfont
6326 % where it can probably just be output, and another way in other fonts,
6327 % where something hairier probably needs to be done.
6328 %
6329 % #1 is what to print if we are indeed using \tt; #2 is what to print
6330 % otherwise.  Since all the Computer Modern typewriter fonts have zero
6331 % interword stretch (and shrink), and it is reasonable to expect all
6332 % typewriter fonts to have this, we can check that font parameter.
6333 %
6334 \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
6335
6336 % Same as above, but check for italic font.  Actually this also catches
6337 % non-italic slanted fonts since it is impossible to distinguish them from
6338 % italic fonts.  But since this is only used by $ and it uses \sl anyway
6339 % this is not a problem.
6340 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
6341
6342 % Turn off all special characters except @
6343 % (and those which the user can use as if they were ordinary).
6344 % Most of these we simply print from the \tt font, but for some, we can
6345 % use math or other variants that look better in normal text.
6346
6347 \catcode`\"=\active
6348 \def\activedoublequote{{\tt\char34}}
6349 \let"=\activedoublequote
6350 \catcode`\~=\active
6351 \def~{{\tt\char126}}
6352 \chardef\hat=`\^
6353 \catcode`\^=\active
6354 \def^{{\tt \hat}}
6355
6356 \catcode`\_=\active
6357 \def_{\ifusingtt\normalunderscore\_}
6358 % Subroutine for the previous macro.
6359 \def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}}
6360
6361 \catcode`\|=\active
6362 \def|{{\tt\char124}}
6363 \chardef \less=`\<
6364 \catcode`\<=\active
6365 \def<{{\tt \less}}
6366 \chardef \gtr=`\>
6367 \catcode`\>=\active
6368 \def>{{\tt \gtr}}
6369 \catcode`\+=\active
6370 \def+{{\tt \char 43}}
6371 \catcode`\$=\active
6372 \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
6373 %\catcode 27=\active
6374 %\def^^[{$\diamondsuit$}
6375
6376 % Set up an active definition for =, but don't enable it most of the time.
6377 {\catcode`\==\active
6378 \global\def={{\tt \char 61}}}
6379
6380 \catcode`+=\active
6381 \catcode`\_=\active
6382
6383 % If a .fmt file is being used, characters that might appear in a file
6384 % name cannot be active until we have parsed the command line.
6385 % So turn them off again, and have \everyjob (or @setfilename) turn them on.
6386 % \otherifyactive is called near the end of this file.
6387 \def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
6388
6389 \catcode`\@=0
6390
6391 % \rawbackslashxx output one backslash character in current font
6392 \global\chardef\rawbackslashxx=`\\
6393 %{\catcode`\\=\other
6394 %@gdef@rawbackslashxx{\}}
6395
6396 % \rawbackslash redefines \ as input to do \rawbackslashxx.
6397 {\catcode`\\=\active
6398 @gdef@rawbackslash{@let\=@rawbackslashxx }}
6399
6400 % \normalbackslash outputs one backslash in fixed width font.
6401 \def\normalbackslash{{\tt\rawbackslashxx}}
6402
6403 % \catcode 17=0   % Define control-q
6404 \catcode`\\=\active
6405
6406 % Used sometimes to turn off (effectively) the active characters
6407 % even after parsing them.
6408 @def@turnoffactive{@let"=@normaldoublequote
6409 @let\=@realbackslash
6410 @let~=@normaltilde
6411 @let^=@normalcaret
6412 @let_=@normalunderscore
6413 @let|=@normalverticalbar
6414 @let<=@normalless
6415 @let>=@normalgreater
6416 @let+=@normalplus
6417 @let$=@normaldollar}%$ font-lock fix
6418
6419 % Same as @turnoffactive except for \.
6420 @def@normalturnoffactive{@turnoffactive @let\=@normalbackslash}
6421
6422 % Make _ and + \other characters, temporarily.
6423 % This is canceled by @fixbackslash.
6424 @otherifyactive
6425
6426 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
6427 % That is what \eatinput is for; after that, the `\' should revert to printing
6428 % a backslash.
6429 %
6430 @gdef@eatinput input texinfo{@fixbackslash}
6431 @global@let\ = @eatinput
6432
6433 % On the other hand, perhaps the file did not have a `\input texinfo'. Then
6434 % the first `\{ in the file would cause an error. This macro tries to fix
6435 % that, assuming it is called before the first `\' could plausibly occur.
6436 % Also back turn on active characters that might appear in the input
6437 % file name, in case not using a pre-dumped format.
6438 %
6439 @gdef@fixbackslash{%
6440   @ifx\@eatinput @let\ = @normalbackslash @fi
6441   @catcode`+=@active
6442   @catcode`@_=@active
6443 }
6444
6445 % Say @foo, not \foo, in error messages.
6446 @escapechar = `@@
6447
6448 % These look ok in all fonts, so just make them not special.  
6449 @catcode`@& = @other
6450 @catcode`@# = @other
6451 @catcode`@% = @other
6452
6453 @c Set initial fonts.
6454 @textfonts
6455 @rm
6456
6457
6458 @c Local variables:
6459 @c eval: (add-hook 'write-file-hooks 'time-stamp)
6460 @c page-delimiter: "^\\\\message"
6461 @c time-stamp-start: "def\\\\texinfoversion{"
6462 @c time-stamp-format: "%:y-%02m-%02d.%02H"
6463 @c time-stamp-end: "}"
6464 @c End: