OSDN Git Service

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