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