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