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