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