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