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