home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cc-61.0.1 / cc / texinfo.tex < prev    next >
Text File  |  1991-06-03  |  91KB  |  2,850 lines

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