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