home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / unixtex-6.1b-bin0.lha / lib / texmf / doc / fontname / texinfo.tex < prev   
Encoding:
Text File  |  1996-10-12  |  132.3 KB  |  4,122 lines

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