home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / indent / texinfo.tex (.txt) < prev    next >
LaTeX Document  |  1999-05-29  |  126KB  |  3,066 lines

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