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