You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4585 lines
149 KiB

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