home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 106 / EnigmaAmiga106CD.iso / software / sviluppo / ahisrc / docs / texinfo.tex (.txt) < prev   
Encoding:
Texinfo Document  |  1999-01-11  |  176.1 KB  |  4,330 lines

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