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.

5994 lines
196 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
  1. % texinfo.tex -- TeX macros to handle Texinfo files.
  2. %
  3. % Load plain if necessary, i.e., if running under initex.
  4. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
  5. %
  6. \def\texinfoversion{1999-10-01.07}
  7. %
  8. % Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
  9. % Free Software Foundation, Inc.
  10. %
  11. % This texinfo.tex file is free software; you can redistribute it and/or
  12. % modify it under the terms of the GNU General Public License as
  13. % published by the Free Software Foundation; either version 2, or (at
  14. % your option) any later version.
  15. %
  16. % This texinfo.tex file is distributed in the hope that it will be
  17. % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  18. % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. % General Public License for more details.
  20. %
  21. % You should have received a copy of the GNU General Public License
  22. % along with this texinfo.tex file; see the file COPYING. If not, write
  23. % to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  24. % Boston, MA 02110-1301, USA.
  25. %
  26. % In other words, you are welcome to use, share and improve this program.
  27. % You are forbidden to forbid anyone else to use, share and improve
  28. % what you give them. Help stamp out software-hoarding!
  29. %
  30. % Please try the latest version of texinfo.tex before submitting bug
  31. % reports; you can get the latest version from:
  32. % ftp://ftp.gnu.org/gnu/texinfo.tex
  33. % (and all GNU mirrors, see http://www.gnu.org/order/ftp.html)
  34. % ftp://texinfo.org/tex/texinfo.tex
  35. % ftp://us.ctan.org/macros/texinfo/texinfo.tex
  36. % (and all CTAN mirrors, finger ctan@us.ctan.org for a list).
  37. % /home/gd/gnu/doc/texinfo.tex on the GNU machines.
  38. % The texinfo.tex in any given Texinfo distribution could well be out
  39. % of date, so if that's what you're using, please check.
  40. % Texinfo has a small home page at http://texinfo.org/.
  41. %
  42. % Send bug reports to bug-texinfo@gnu.org. Please include including a
  43. % complete document in each bug report with which we can reproduce the
  44. % problem. Patches are, of course, greatly appreciated.
  45. %
  46. % To process a Texinfo manual with TeX, it's most reliable to use the
  47. % texi2dvi shell script that comes with the distribution. For a simple
  48. % manual foo.texi, however, you can get away with this:
  49. % tex foo.texi
  50. % texindex foo.??
  51. % tex foo.texi
  52. % tex foo.texi
  53. % dvips foo.dvi -o # or whatever, to process the dvi file; this makes foo.ps.
  54. % The extra runs of TeX get the cross-reference information correct.
  55. % Sometimes one run after texindex suffices, and sometimes you need more
  56. % than two; texi2dvi does it as many times as necessary.
  57. %
  58. % It is possible to adapt texinfo.tex for other languages. You can get
  59. % the existing language-specific files from ftp://ftp.gnu.org/gnu/texinfo/.
  60. \message{Loading texinfo [version \texinfoversion]:}
  61. % If in a .fmt file, print the version number
  62. % and turn on active characters that we couldn't do earlier because
  63. % they might have appeared in the input file name.
  64. \everyjob{\message{[Texinfo version \texinfoversion]}%
  65. \catcode`+=\active \catcode`\_=\active}
  66. % Save some parts of plain tex whose names we will redefine.
  67. \let\ptexb=\b
  68. \let\ptexbullet=\bullet
  69. \let\ptexc=\c
  70. \let\ptexcomma=\,
  71. \let\ptexdot=\.
  72. \let\ptexdots=\dots
  73. \let\ptexend=\end
  74. \let\ptexequiv=\equiv
  75. \let\ptexexclam=\!
  76. \let\ptexi=\i
  77. \let\ptexlbrace=\{
  78. \let\ptexrbrace=\}
  79. \let\ptexstar=\*
  80. \let\ptext=\t
  81. % We never want plain's outer \+ definition in Texinfo.
  82. % For @tex, we can use \tabalign.
  83. \let\+ = \relax
  84. \message{Basics,}
  85. \chardef\other=12
  86. % If this character appears in an error message or help string, it
  87. % starts a new line in the output.
  88. \newlinechar = `^^J
  89. % Set up fixed words for English if not already set.
  90. \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
  91. \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
  92. \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
  93. \ifx\putwordin\undefined \gdef\putwordin{in}\fi
  94. \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
  95. \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
  96. \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
  97. \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
  98. \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
  99. \ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi
  100. \ifx\putwordof\undefined \gdef\putwordof{of}\fi
  101. \ifx\putwordon\undefined \gdef\putwordon{on}\fi
  102. \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi
  103. \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi
  104. \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi
  105. \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi
  106. \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi
  107. \ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi
  108. \ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi
  109. %
  110. \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
  111. \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
  112. \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
  113. \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
  114. \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
  115. \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
  116. \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
  117. \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
  118. \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
  119. \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
  120. \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
  121. \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
  122. %
  123. \ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi
  124. \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi
  125. \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi
  126. \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi
  127. \ifx\putwordDeftypevar\undefined\gdef\putwordDeftypevar{Variable}\fi
  128. \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi
  129. \ifx\putwordDeftypefun\undefined\gdef\putwordDeftypefun{Function}\fi
  130. % Ignore a token.
  131. %
  132. \def\gobble#1{}
  133. \hyphenation{ap-pen-dix}
  134. \hyphenation{mini-buf-fer mini-buf-fers}
  135. \hyphenation{eshell}
  136. \hyphenation{white-space}
  137. % Margin to add to right of even pages, to left of odd pages.
  138. \newdimen \bindingoffset
  139. \newdimen \normaloffset
  140. \newdimen\pagewidth \newdimen\pageheight
  141. % Sometimes it is convenient to have everything in the transcript file
  142. % and nothing on the terminal. We don't just call \tracingall here,
  143. % since that produces some useless output on the terminal.
  144. %
  145. \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
  146. \ifx\eTeXversion\undefined
  147. \def\loggingall{\tracingcommands2 \tracingstats2
  148. \tracingpages1 \tracingoutput1 \tracinglostchars1
  149. \tracingmacros2 \tracingparagraphs1 \tracingrestores1
  150. \showboxbreadth\maxdimen\showboxdepth\maxdimen
  151. }%
  152. \else
  153. \def\loggingall{\tracingcommands3 \tracingstats2
  154. \tracingpages1 \tracingoutput1 \tracinglostchars1
  155. \tracingmacros2 \tracingparagraphs1 \tracingrestores1
  156. \tracingscantokens1 \tracingassigns1 \tracingifs1
  157. \tracinggroups1 \tracingnesting2
  158. \showboxbreadth\maxdimen\showboxdepth\maxdimen
  159. }%
  160. \fi
  161. % For @cropmarks command.
  162. % Do @cropmarks to get crop marks.
  163. %
  164. \newif\ifcropmarks
  165. \let\cropmarks = \cropmarkstrue
  166. %
  167. % Dimensions to add cropmarks at corners.
  168. % Added by P. A. MacKay, 12 Nov. 1986
  169. %
  170. \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
  171. \newdimen\cornerlong \cornerlong=1pc
  172. \newdimen\cornerthick \cornerthick=.3pt
  173. \newdimen\topandbottommargin \topandbottommargin=.75in
  174. % Main output routine.
  175. \chardef\PAGE = 255
  176. \output = {\onepageout{\pagecontents\PAGE}}
  177. \newbox\headlinebox
  178. \newbox\footlinebox
  179. % \onepageout takes a vbox as an argument. Note that \pagecontents
  180. % does insertions, but you have to call it yourself.
  181. \def\onepageout#1{%
  182. \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
  183. %
  184. \ifodd\pageno \advance\hoffset by \bindingoffset
  185. \else \advance\hoffset by -\bindingoffset\fi
  186. %
  187. % Do this outside of the \shipout so @code etc. will be expanded in
  188. % the headline as they should be, not taken literally (outputting ''code).
  189. \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
  190. \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
  191. %
  192. {%
  193. % Have to do this stuff outside the \shipout because we want it to
  194. % take effect in \write's, yet the group defined by the \vbox ends
  195. % before the \shipout runs.
  196. %
  197. \escapechar = `\\ % use backslash in output files.
  198. \indexdummies % don't expand commands in the output.
  199. \normalturnoffactive % \ in index entries must not stay \, e.g., if
  200. % the page break happens to be in the middle of an example.
  201. \shipout\vbox{%
  202. \ifcropmarks \vbox to \outervsize\bgroup
  203. \hsize = \outerhsize
  204. \vskip-\topandbottommargin
  205. \vtop to0pt{%
  206. \line{\ewtop\hfil\ewtop}%
  207. \nointerlineskip
  208. \line{%
  209. \vbox{\moveleft\cornerthick\nstop}%
  210. \hfill
  211. \vbox{\moveright\cornerthick\nstop}%
  212. }%
  213. \vss}%
  214. \vskip\topandbottommargin
  215. \line\bgroup
  216. \hfil % center the page within the outer (page) hsize.
  217. \ifodd\pageno\hskip\bindingoffset\fi
  218. \vbox\bgroup
  219. \fi
  220. %
  221. \unvbox\headlinebox
  222. \pagebody{#1}%
  223. \ifdim\ht\footlinebox > 0pt
  224. % Only leave this space if the footline is nonempty.
  225. % (We lessened \vsize for it in \oddfootingxxx.)
  226. % The \baselineskip=24pt in plain's \makefootline has no effect.
  227. \vskip 2\baselineskip
  228. \unvbox\footlinebox
  229. \fi
  230. %
  231. \ifpdfmakepagedest \pdfmkdest{\the\pageno} \fi
  232. %
  233. \ifcropmarks
  234. \egroup % end of \vbox\bgroup
  235. \hfil\egroup % end of (centering) \line\bgroup
  236. \vskip\topandbottommargin plus1fill minus1fill
  237. \boxmaxdepth = \cornerthick
  238. \vbox to0pt{\vss
  239. \line{%
  240. \vbox{\moveleft\cornerthick\nsbot}%
  241. \hfill
  242. \vbox{\moveright\cornerthick\nsbot}%
  243. }%
  244. \nointerlineskip
  245. \line{\ewbot\hfil\ewbot}%
  246. }%
  247. \egroup % \vbox from first cropmarks clause
  248. \fi
  249. }% end of \shipout\vbox
  250. }% end of group with \turnoffactive
  251. \advancepageno
  252. \ifnum\outputpenalty>-20000 \else\dosupereject\fi
  253. }
  254. \newinsert\margin \dimen\margin=\maxdimen
  255. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  256. {\catcode`\@ =11
  257. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  258. % marginal hacks, juha@viisa.uucp (Juha Takala)
  259. \ifvoid\margin\else % marginal info is present
  260. \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
  261. \dimen@=\dp#1 \unvbox#1
  262. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  263. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  264. }
  265. % Here are the rules for the cropmarks. Note that they are
  266. % offset so that the space between them is truly \outerhsize or \outervsize
  267. % (P. A. MacKay, 12 November, 1986)
  268. %
  269. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  270. \def\nstop{\vbox
  271. {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  272. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  273. \def\nsbot{\vbox
  274. {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  275. % Parse an argument, then pass it to #1. The argument is the rest of
  276. % the input line (except we remove a trailing comment). #1 should be a
  277. % macro which expects an ordinary undelimited TeX argument.
  278. %
  279. \def\parsearg#1{%
  280. \let\next = #1%
  281. \begingroup
  282. \obeylines
  283. \futurelet\temp\parseargx
  284. }
  285. % If the next token is an obeyed space (from an @example environment or
  286. % the like), remove it and recurse. Otherwise, we're done.
  287. \def\parseargx{%
  288. % \obeyedspace is defined far below, after the definition of \sepspaces.
  289. \ifx\obeyedspace\temp
  290. \expandafter\parseargdiscardspace
  291. \else
  292. \expandafter\parseargline
  293. \fi
  294. }
  295. % Remove a single space (as the delimiter token to the macro call).
  296. {\obeyspaces %
  297. \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
  298. {\obeylines %
  299. \gdef\parseargline#1^^M{%
  300. \endgroup % End of the group started in \parsearg.
  301. %
  302. % First remove any @c comment, then any @comment.
  303. % Result of each macro is put in \toks0.
  304. \argremovec #1\c\relax %
  305. \expandafter\argremovecomment \the\toks0 \comment\relax %
  306. %
  307. % Call the caller's macro, saved as \next in \parsearg.
  308. \expandafter\next\expandafter{\the\toks0}%
  309. }%
  310. }
  311. % Since all \c{,omment} does is throw away the argument, we can let TeX
  312. % do that for us. The \relax here is matched by the \relax in the call
  313. % in \parseargline; it could be more or less anything, its purpose is
  314. % just to delimit the argument to the \c.
  315. \def\argremovec#1\c#2\relax{\toks0 = {#1}}
  316. \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
  317. % \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
  318. % @end itemize @c foo
  319. % will have two active spaces as part of the argument with the
  320. % `itemize'. Here we remove all active spaces from #1, and assign the
  321. % result to \toks0.
  322. %
  323. % This loses if there are any *other* active characters besides spaces
  324. % in the argument -- _ ^ +, for example -- since they get expanded.
  325. % Fortunately, Texinfo does not define any such commands. (If it ever
  326. % does, the catcode of the characters in questionwill have to be changed
  327. % here.) But this means we cannot call \removeactivespaces as part of
  328. % \argremovec{,omment}, since @c uses \parsearg, and thus the argument
  329. % that \parsearg gets might well have any character at all in it.
  330. %
  331. \def\removeactivespaces#1{%
  332. \begingroup
  333. \ignoreactivespaces
  334. \edef\temp{#1}%
  335. \global\toks0 = \expandafter{\temp}%
  336. \endgroup
  337. }
  338. % Change the active space to expand to nothing.
  339. %
  340. \begingroup
  341. \obeyspaces
  342. \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
  343. \endgroup
  344. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  345. %% These are used to keep @begin/@end levels from running away
  346. %% Call \inENV within environments (after a \begingroup)
  347. \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
  348. \def\ENVcheck{%
  349. \ifENV\errmessage{Still within an environment; press RETURN to continue}
  350. \endgroup\fi} % This is not perfect, but it should reduce lossage
  351. % @begin foo is the same as @foo, for now.
  352. \newhelp\EMsimple{Press RETURN to continue.}
  353. \outer\def\begin{\parsearg\beginxxx}
  354. \def\beginxxx #1{%
  355. \expandafter\ifx\csname #1\endcsname\relax
  356. {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
  357. \csname #1\endcsname\fi}
  358. % @end foo executes the definition of \Efoo.
  359. %
  360. \def\end{\parsearg\endxxx}
  361. \def\endxxx #1{%
  362. \removeactivespaces{#1}%
  363. \edef\endthing{\the\toks0}%
  364. %
  365. \expandafter\ifx\csname E\endthing\endcsname\relax
  366. \expandafter\ifx\csname \endthing\endcsname\relax
  367. % There's no \foo, i.e., no ``environment'' foo.
  368. \errhelp = \EMsimple
  369. \errmessage{Undefined command `@end \endthing'}%
  370. \else
  371. \unmatchedenderror\endthing
  372. \fi
  373. \else
  374. % Everything's ok; the right environment has been started.
  375. \csname E\endthing\endcsname
  376. \fi
  377. }
  378. % There is an environment #1, but it hasn't been started. Give an error.
  379. %
  380. \def\unmatchedenderror#1{%
  381. \errhelp = \EMsimple
  382. \errmessage{This `@end #1' doesn't have a matching `@#1'}%
  383. }
  384. % Define the control sequence \E#1 to give an unmatched @end error.
  385. %
  386. \def\defineunmatchedend#1{%
  387. \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
  388. }
  389. % Single-spacing is done by various environments (specifically, in
  390. % \nonfillstart and \quotations).
  391. \newskip\singlespaceskip \singlespaceskip = 12.5pt
  392. \def\singlespace{%
  393. % Why was this kern here? It messes up equalizing space above and below
  394. % environments. --karl, 6may93
  395. %{\advance \baselineskip by -\singlespaceskip
  396. %\kern \baselineskip}%
  397. \setleading \singlespaceskip
  398. }
  399. %% Simple single-character @ commands
  400. % @@ prints an @
  401. % Kludge this until the fonts are right (grr).
  402. \def\@{{\tt\char64}}
  403. % This is turned off because it was never documented
  404. % and you can use @w{...} around a quote to suppress ligatures.
  405. %% Define @` and @' to be the same as ` and '
  406. %% but suppressing ligatures.
  407. %\def\`{{`}}
  408. %\def\'{{'}}
  409. % Used to generate quoted braces.
  410. \def\mylbrace {{\tt\char123}}
  411. \def\myrbrace {{\tt\char125}}
  412. \let\{=\mylbrace
  413. \let\}=\myrbrace
  414. \begingroup
  415. % Definitions to produce actual \{ & \} command in an index.
  416. \catcode`\{ = 12 \catcode`\} = 12
  417. \catcode`\[ = 1 \catcode`\] = 2
  418. \catcode`\@ = 0 \catcode`\\ = 12
  419. @gdef@lbracecmd[\{]%
  420. @gdef@rbracecmd[\}]%
  421. @endgroup
  422. % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
  423. % Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H.
  424. \let\, = \c
  425. \let\dotaccent = \.
  426. \def\ringaccent#1{{\accent23 #1}}
  427. \let\tieaccent = \t
  428. \let\ubaraccent = \b
  429. \let\udotaccent = \d
  430. % Other special characters: @questiondown @exclamdown
  431. % Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss.
  432. \def\questiondown{?`}
  433. \def\exclamdown{!`}
  434. % Dotless i and dotless j, used for accents.
  435. \def\imacro{i}
  436. \def\jmacro{j}
  437. \def\dotless#1{%
  438. \def\temp{#1}%
  439. \ifx\temp\imacro \ptexi
  440. \else\ifx\temp\jmacro \j
  441. \else \errmessage{@dotless can be used only with i or j}%
  442. \fi\fi
  443. }
  444. % Be sure we're in horizontal mode when doing a tie, since we make space
  445. % equivalent to this in @example-like environments. Otherwise, a space
  446. % at the beginning of a line will start with \penalty -- and
  447. % since \penalty is valid in vertical mode, we'd end up putting the
  448. % penalty on the vertical list instead of in the new paragraph.
  449. {\catcode`@ = 11
  450. % Avoid using \@M directly, because that causes trouble
  451. % if the definition is written into an index file.
  452. \global\let\tiepenalty = \@M
  453. \gdef\tie{\leavevmode\penalty\tiepenalty\ }
  454. }
  455. % @: forces normal size whitespace following.
  456. \def\:{\spacefactor=1000 }
  457. % @* forces a line break.
  458. \def\*{\hfil\break\hbox{}\ignorespaces}
  459. % @. is an end-of-sentence period.
  460. \def\.{.\spacefactor=3000 }
  461. % @! is an end-of-sentence bang.
  462. \def\!{!\spacefactor=3000 }
  463. % @? is an end-of-sentence query.
  464. \def\?{?\spacefactor=3000 }
  465. % @w prevents a word break. Without the \leavevmode, @w at the
  466. % beginning of a paragraph, when TeX is still in vertical mode, would
  467. % produce a whole line of output instead of starting the paragraph.
  468. \def\w#1{\leavevmode\hbox{#1}}
  469. % @group ... @end group forces ... to be all on one page, by enclosing
  470. % it in a TeX vbox. We use \vtop instead of \vbox to construct the box
  471. % to keep its height that of a normal line. According to the rules for
  472. % \topskip (p.114 of the TeXbook), the glue inserted is
  473. % max (\topskip - \ht (first item), 0). If that height is large,
  474. % therefore, no glue is inserted, and the space between the headline and
  475. % the text is small, which looks bad.
  476. %
  477. \def\group{\begingroup
  478. \ifnum\catcode13=\active \else
  479. \errhelp = \groupinvalidhelp
  480. \errmessage{@group invalid in context where filling is enabled}%
  481. \fi
  482. %
  483. % The \vtop we start below produces a box with normal height and large
  484. % depth; thus, TeX puts \baselineskip glue before it, and (when the
  485. % next line of text is done) \lineskip glue after it. (See p.82 of
  486. % the TeXbook.) Thus, space below is not quite equal to space
  487. % above. But it's pretty close.
  488. \def\Egroup{%
  489. \egroup % End the \vtop.
  490. \endgroup % End the \group.
  491. }%
  492. %
  493. \vtop\bgroup
  494. % We have to put a strut on the last line in case the @group is in
  495. % the midst of an example, rather than completely enclosing it.
  496. % Otherwise, the interline space between the last line of the group
  497. % and the first line afterwards is too small. But we can't put the
  498. % strut in \Egroup, since there it would be on a line by itself.
  499. % Hence this just inserts a strut at the beginning of each line.
  500. \everypar = {\strut}%
  501. %
  502. % Since we have a strut on every line, we don't need any of TeX's
  503. % normal interline spacing.
  504. \offinterlineskip
  505. %
  506. % OK, but now we have to do something about blank
  507. % lines in the input in @example-like environments, which normally
  508. % just turn into \lisppar, which will insert no space now that we've
  509. % turned off the interline space. Simplest is to make them be an
  510. % empty paragraph.
  511. \ifx\par\lisppar
  512. \edef\par{\leavevmode \par}%
  513. %
  514. % Reset ^^M's definition to new definition of \par.
  515. \obeylines
  516. \fi
  517. %
  518. % Do @comment since we are called inside an environment such as
  519. % @example, where each end-of-line in the input causes an
  520. % end-of-line in the output. We don't want the end-of-line after
  521. % the `@group' to put extra space in the output. Since @group
  522. % should appear on a line by itself (according to the Texinfo
  523. % manual), we don't worry about eating any user text.
  524. \comment
  525. }
  526. %
  527. % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
  528. % message, so this ends up printing `@group can only ...'.
  529. %
  530. \newhelp\groupinvalidhelp{%
  531. group can only be used in environments such as @example,^^J%
  532. where each line of input produces a line of output.}
  533. % @need space-in-mils
  534. % forces a page break if there is not space-in-mils remaining.
  535. \newdimen\mil \mil=0.001in
  536. \def\need{\parsearg\needx}
  537. % Old definition--didn't work.
  538. %\def\needx #1{\par %
  539. %% This method tries to make TeX break the page naturally
  540. %% if the depth of the box does not fit.
  541. %{\baselineskip=0pt%
  542. %\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak
  543. %\prevdepth=-1000pt
  544. %}}
  545. \def\needx#1{%
  546. % Ensure vertical mode, so we don't make a big box in the middle of a
  547. % paragraph.
  548. \par
  549. %
  550. % If the @need value is less than one line space, it's useless.
  551. \dimen0 = #1\mil
  552. \dimen2 = \ht\strutbox
  553. \advance\dimen2 by \dp\strutbox
  554. \ifdim\dimen0 > \dimen2
  555. %
  556. % Do a \strut just to make the height of this box be normal, so the
  557. % normal leading is inserted relative to the preceding line.
  558. % And a page break here is fine.
  559. \vtop to #1\mil{\strut\vfil}%
  560. %
  561. % TeX does not even consider page breaks if a penalty added to the
  562. % main vertical list is 10000 or more. But in order to see if the
  563. % empty box we just added fits on the page, we must make it consider
  564. % page breaks. On the other hand, we don't want to actually break the
  565. % page after the empty box. So we use a penalty of 9999.
  566. %
  567. % There is an extremely small chance that TeX will actually break the
  568. % page at this \penalty, if there are no other feasible breakpoints in
  569. % sight. (If the user is using lots of big @group commands, which
  570. % almost-but-not-quite fill up a page, TeX will have a hard time doing
  571. % good page breaking, for example.) However, I could not construct an
  572. % example where a page broke at this \penalty; if it happens in a real
  573. % document, then we can reconsider our strategy.
  574. \penalty9999
  575. %
  576. % Back up by the size of the box, whether we did a page break or not.
  577. \kern -#1\mil
  578. %
  579. % Do not allow a page break right after this kern.
  580. \nobreak
  581. \fi
  582. }
  583. % @br forces paragraph break
  584. \let\br = \par
  585. % @dots{} output an ellipsis using the current font.
  586. % We do .5em per period so that it has the same spacing in a typewriter
  587. % font as three actual period characters.
  588. %
  589. \def\dots{%
  590. \leavevmode
  591. \hbox to 1.5em{%
  592. \hskip 0pt plus 0.25fil minus 0.25fil
  593. .\hss.\hss.%
  594. \hskip 0pt plus 0.5fil minus 0.5fil
  595. }%
  596. }
  597. % @enddots{} is an end-of-sentence ellipsis.
  598. %
  599. \def\enddots{%
  600. \leavevmode
  601. \hbox to 2em{%
  602. \hskip 0pt plus 0.25fil minus 0.25fil
  603. .\hss.\hss.\hss.%
  604. \hskip 0pt plus 0.5fil minus 0.5fil
  605. }%
  606. \spacefactor=3000
  607. }
  608. % @page forces the start of a new page
  609. %
  610. \def\page{\par\vfill\supereject}
  611. % @exdent text....
  612. % outputs text on separate line in roman font, starting at standard page margin
  613. % This records the amount of indent in the innermost environment.
  614. % That's how much \exdent should take out.
  615. \newskip\exdentamount
  616. % This defn is used inside fill environments such as @defun.
  617. \def\exdent{\parsearg\exdentyyy}
  618. \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
  619. % This defn is used inside nofill environments such as @example.
  620. \def\nofillexdent{\parsearg\nofillexdentyyy}
  621. \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
  622. \leftline{\hskip\leftskip{\rm#1}}}}
  623. % @inmargin{TEXT} puts TEXT in the margin next to the current paragraph.
  624. \def\inmargin#1{%
  625. \strut\vadjust{\nobreak\kern-\strutdepth
  626. \vtop to \strutdepth{\baselineskip\strutdepth\vss
  627. \llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}}
  628. \newskip\inmarginspacing \inmarginspacing=1cm
  629. \def\strutdepth{\dp\strutbox}
  630. %\hbox{{\rm#1}}\hfil\break}}
  631. % @include file insert text of that file as input.
  632. % Allow normal characters that we make active in the argument (a file name).
  633. \def\include{\begingroup
  634. \catcode`\\=12
  635. \catcode`~=12
  636. \catcode`^=12
  637. \catcode`_=12
  638. \catcode`|=12
  639. \catcode`<=12
  640. \catcode`>=12
  641. \catcode`+=12
  642. \parsearg\includezzz}
  643. % Restore active chars for included file.
  644. \def\includezzz#1{\endgroup\begingroup
  645. % Read the included file in a group so nested @include's work.
  646. \def\thisfile{#1}%
  647. \input\thisfile
  648. \endgroup}
  649. \def\thisfile{}
  650. % @center line outputs that line, centered
  651. \def\center{\parsearg\centerzzz}
  652. \def\centerzzz #1{{\advance\hsize by -\leftskip
  653. \advance\hsize by -\rightskip
  654. \centerline{#1}}}
  655. % @sp n outputs n lines of vertical space
  656. \def\sp{\parsearg\spxxx}
  657. \def\spxxx #1{\vskip #1\baselineskip}
  658. % @comment ...line which is ignored...
  659. % @c is the same as @comment
  660. % @ignore ... @end ignore is another way to write a comment
  661. \def\comment{\begingroup \catcode`\^^M=\other%
  662. \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
  663. \commentxxx}
  664. {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
  665. \let\c=\comment
  666. % @paragraphindent NCHARS
  667. % We'll use ems for NCHARS, close enough.
  668. % We cannot implement @paragraphindent asis, though.
  669. %
  670. \def\asisword{asis} % no translation, these are keywords
  671. \def\noneword{none}
  672. %
  673. \def\paragraphindent{\parsearg\doparagraphindent}
  674. \def\doparagraphindent#1{%
  675. \def\temp{#1}%
  676. \ifx\temp\asisword
  677. \else
  678. \ifx\temp\noneword
  679. \defaultparindent = 0pt
  680. \else
  681. \defaultparindent = #1em
  682. \fi
  683. \fi
  684. \parindent = \defaultparindent
  685. }
  686. % @exampleindent NCHARS
  687. % We'll use ems for NCHARS like @paragraphindent.
  688. % It seems @exampleindent asis isn't necessary, but
  689. % I preserve it to make it similar to @paragraphindent.
  690. \def\exampleindent{\parsearg\doexampleindent}
  691. \def\doexampleindent#1{%
  692. \def\temp{#1}%
  693. \ifx\temp\asisword
  694. \else
  695. \ifx\temp\noneword
  696. \lispnarrowing = 0pt
  697. \else
  698. \lispnarrowing = #1em
  699. \fi
  700. \fi
  701. }
  702. % @asis just yields its argument. Used with @table, for example.
  703. %
  704. \def\asis#1{#1}
  705. % @math means output in math mode.
  706. % We don't use $'s directly in the definition of \math because control
  707. % sequences like \math are expanded when the toc file is written. Then,
  708. % we read the toc file back, the $'s will be normal characters (as they
  709. % should be, according to the definition of Texinfo). So we must use a
  710. % control sequence to switch into and out of math mode.
  711. %
  712. % This isn't quite enough for @math to work properly in indices, but it
  713. % seems unlikely it will ever be needed there.
  714. %
  715. \let\implicitmath = $
  716. \def\math#1{\implicitmath #1\implicitmath}
  717. % @bullet and @minus need the same treatment as @math, just above.
  718. \def\bullet{\implicitmath\ptexbullet\implicitmath}
  719. \def\minus{\implicitmath-\implicitmath}
  720. % @refill is a no-op.
  721. \let\refill=\relax
  722. % If working on a large document in chapters, it is convenient to
  723. % be able to disable indexing, cross-referencing, and contents, for test runs.
  724. % This is done with @novalidate (before @setfilename).
  725. %
  726. \newif\iflinks \linkstrue % by default we want the aux files.
  727. \let\novalidate = \linksfalse
  728. % @setfilename is done at the beginning of every texinfo file.
  729. % So open here the files we need to have open while reading the input.
  730. % This makes it possible to make a .fmt file for texinfo.
  731. \def\setfilename{%
  732. \iflinks
  733. \readauxfile
  734. \fi % \openindices needs to do some work in any case.
  735. \openindices
  736. \fixbackslash % Turn off hack to swallow `\input texinfo'.
  737. \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
  738. %
  739. % If texinfo.cnf is present on the system, read it.
  740. % Useful for site-wide @afourpaper, etc.
  741. % Just to be on the safe side, close the input stream before the \input.
  742. \openin 1 texinfo.cnf
  743. \ifeof1 \let\temp=\relax \else \def\temp{\input texinfo.cnf }\fi
  744. \closein1
  745. \temp
  746. %
  747. \comment % Ignore the actual filename.
  748. }
  749. % Called from \setfilename.
  750. %
  751. \def\openindices{%
  752. \newindex{cp}%
  753. \newcodeindex{fn}%
  754. \newcodeindex{vr}%
  755. \newcodeindex{tp}%
  756. \newcodeindex{ky}%
  757. \newcodeindex{pg}%
  758. }
  759. % @bye.
  760. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  761. \message{pdf,}
  762. % adobe `portable' document format
  763. \newcount\tempnum
  764. \newcount\lnkcount
  765. \newtoks\filename
  766. \newcount\filenamelength
  767. \newcount\pgn
  768. \newtoks\toksA
  769. \newtoks\toksB
  770. \newtoks\toksC
  771. \newtoks\toksD
  772. \newbox\boxA
  773. \newcount\countA
  774. \newif\ifpdf
  775. \newif\ifpdfmakepagedest
  776. \ifx\pdfoutput\undefined
  777. \pdffalse
  778. \let\pdfmkdest = \gobble
  779. \let\pdfurl = \gobble
  780. \let\endlink = \relax
  781. \let\linkcolor = \relax
  782. \let\pdfmakeoutlines = \relax
  783. \else
  784. \pdftrue
  785. \pdfoutput = 1
  786. \input pdfcolor
  787. \def\dopdfimage#1#2#3{%
  788. \def\imagewidth{#2}%
  789. \def\imageheight{#3}%
  790. \ifnum\pdftexversion < 14
  791. \pdfimage
  792. \else
  793. \pdfximage
  794. \fi
  795. \ifx\empty\imagewidth\else width \imagewidth \fi
  796. \ifx\empty\imageheight\else height \imageheight \fi
  797. {#1.pdf}%
  798. \ifnum\pdftexversion < 14 \else
  799. \pdfrefximage \pdflastximage
  800. \fi}
  801. \def\pdfmkdest#1{\pdfdest name{#1@} xyz}
  802. \def\pdfmkpgn#1{#1@}
  803. \let\linkcolor = \Cyan
  804. \def\endlink{\Black\pdfendlink}
  805. % Adding outlines to PDF; macros for calculating structure of outlines
  806. % come from Petr Olsak
  807. \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
  808. \else \csname#1\endcsname \fi}
  809. \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
  810. \advance\tempnum by1
  811. \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
  812. \def\pdfmakeoutlines{{%
  813. \openin 1 \jobname.toc
  814. \ifeof 1\else\bgroup
  815. \closein 1
  816. \indexnofonts
  817. \def\tt{}
  818. % thanh's hack / proper braces in bookmarks
  819. \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace
  820. \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace
  821. %
  822. \def\chapentry ##1##2##3{}
  823. \def\unnumbchapentry ##1##2{}
  824. \def\secentry ##1##2##3##4{\advancenumber{chap##2}}
  825. \def\unnumbsecentry ##1##2{}
  826. \def\subsecentry ##1##2##3##4##5{\advancenumber{sec##2.##3}}
  827. \def\unnumbsubsecentry ##1##2{}
  828. \def\subsubsecentry ##1##2##3##4##5##6{\advancenumber{subsec##2.##3.##4}}
  829. \def\unnumbsubsubsecentry ##1##2{}
  830. \input \jobname.toc
  831. \def\chapentry ##1##2##3{%
  832. \pdfoutline goto name{\pdfmkpgn{##3}}count-\expnumber{chap##2}{##1}}
  833. \def\unnumbchapentry ##1##2{%
  834. \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
  835. \def\secentry ##1##2##3##4{%
  836. \pdfoutline goto name{\pdfmkpgn{##4}}count-\expnumber{sec##2.##3}{##1}}
  837. \def\unnumbsecentry ##1##2{%
  838. \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
  839. \def\subsecentry ##1##2##3##4##5{%
  840. \pdfoutline goto name{\pdfmkpgn{##5}}count-\expnumber{subsec##2.##3.##4}{##1}}
  841. \def\unnumbsubsecentry ##1##2{%
  842. \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
  843. \def\subsubsecentry ##1##2##3##4##5##6{%
  844. \pdfoutline goto name{\pdfmkpgn{##6}}{##1}}
  845. \def\unnumbsubsubsecentry ##1##2{%
  846. \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
  847. \input \jobname.toc
  848. \egroup\fi
  849. }}
  850. \def\makelinks #1,{%
  851. \def\params{#1}\def\E{END}%
  852. \ifx\params\E
  853. \let\nextmakelinks=\relax
  854. \else
  855. \let\nextmakelinks=\makelinks
  856. \ifnum\lnkcount>0,\fi
  857. \picknum{#1}%
  858. \startlink attr{/Border [0 0 0]}
  859. goto name{\pdfmkpgn{\the\pgn}}%
  860. \linkcolor #1%
  861. \advance\lnkcount by 1%
  862. \endlink
  863. \fi
  864. \nextmakelinks
  865. }
  866. \def\picknum#1{\expandafter\pn#1}
  867. \def\pn#1{%
  868. \def\p{#1}%
  869. \ifx\p\lbrace
  870. \let\nextpn=\ppn
  871. \else
  872. \let\nextpn=\ppnn
  873. \def\first{#1}
  874. \fi
  875. \nextpn
  876. }
  877. \def\ppn#1{\pgn=#1\gobble}
  878. \def\ppnn{\pgn=\first}
  879. \def\pdfmklnk#1{\lnkcount=0\makelinks #1,END,}
  880. \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
  881. \def\skipspaces#1{\def\PP{#1}\def\D{|}%
  882. \ifx\PP\D\let\nextsp\relax
  883. \else\let\nextsp\skipspaces
  884. \ifx\p\space\else\addtokens{\filename}{\PP}%
  885. \advance\filenamelength by 1
  886. \fi
  887. \fi
  888. \nextsp}
  889. \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax}
  890. \ifnum\pdftexversion < 14
  891. \let \startlink \pdfannotlink
  892. \else
  893. \let \startlink \pdfstartlink
  894. \fi
  895. \def\pdfurl#1{%
  896. \begingroup
  897. \normalturnoffactive\def\@{@}%
  898. \leavevmode\Red
  899. \startlink attr{/Border [0 0 0]}%
  900. user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
  901. % #1
  902. \endgroup}
  903. \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
  904. \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
  905. \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
  906. \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
  907. \def\maketoks{%
  908. \expandafter\poptoks\the\toksA|ENDTOKS|
  909. \ifx\first0\adn0
  910. \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
  911. \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
  912. \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
  913. \else
  914. \ifnum0=\countA\else\makelink\fi
  915. \ifx\first.\let\next=\done\else
  916. \let\next=\maketoks
  917. \addtokens{\toksB}{\the\toksD}
  918. \ifx\first,\addtokens{\toksB}{\space}\fi
  919. \fi
  920. \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
  921. \next}
  922. \def\makelink{\addtokens{\toksB}%
  923. {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
  924. \def\pdflink#1{%
  925. \startlink attr{/Border [0 0 0]} goto name{\mkpgn{#1}}
  926. \linkcolor #1\endlink}
  927. \def\mkpgn#1{#1@}
  928. \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
  929. \fi % \ifx\pdfoutput
  930. \message{fonts,}
  931. % Font-change commands.
  932. % Texinfo sort of supports the sans serif font style, which plain TeX does not.
  933. % So we set up a \sf analogous to plain's \rm, etc.
  934. \newfam\sffam
  935. \def\sf{\fam=\sffam \tensf}
  936. \let\li = \sf % Sometimes we call it \li, not \sf.
  937. % We don't need math for this one.
  938. \def\ttsl{\tenttsl}
  939. % Use Computer Modern fonts at \magstephalf (11pt).
  940. \newcount\mainmagstep
  941. \mainmagstep=\magstephalf
  942. % Set the font macro #1 to the font named #2, adding on the
  943. % specified font prefix (normally `cm').
  944. % #3 is the font's design size, #4 is a scale factor
  945. \def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4}
  946. % Use cm as the default font prefix.
  947. % To specify the font prefix, you must define \fontprefix
  948. % before you read in texinfo.tex.
  949. \ifx\fontprefix\undefined
  950. \def\fontprefix{cm}
  951. \fi
  952. % Support font families that don't use the same naming scheme as CM.
  953. \def\rmshape{r}
  954. \def\rmbshape{bx} %where the normal face is bold
  955. \def\bfshape{b}
  956. \def\bxshape{bx}
  957. \def\ttshape{tt}
  958. \def\ttbshape{tt}
  959. \def\ttslshape{sltt}
  960. \def\itshape{ti}
  961. \def\itbshape{bxti}
  962. \def\slshape{sl}
  963. \def\slbshape{bxsl}
  964. \def\sfshape{ss}
  965. \def\sfbshape{ss}
  966. \def\scshape{csc}
  967. \def\scbshape{csc}
  968. \ifx\bigger\relax
  969. \let\mainmagstep=\magstep1
  970. \setfont\textrm\rmshape{12}{1000}
  971. \setfont\texttt\ttshape{12}{1000}
  972. \else
  973. \setfont\textrm\rmshape{10}{\mainmagstep}
  974. \setfont\texttt\ttshape{10}{\mainmagstep}
  975. \fi
  976. % Instead of cmb10, you many want to use cmbx10.
  977. % cmbx10 is a prettier font on its own, but cmb10
  978. % looks better when embedded in a line with cmr10.
  979. \setfont\textbf\bfshape{10}{\mainmagstep}
  980. \setfont\textit\itshape{10}{\mainmagstep}
  981. \setfont\textsl\slshape{10}{\mainmagstep}
  982. \setfont\textsf\sfshape{10}{\mainmagstep}
  983. \setfont\textsc\scshape{10}{\mainmagstep}
  984. \setfont\textttsl\ttslshape{10}{\mainmagstep}
  985. \font\texti=cmmi10 scaled \mainmagstep
  986. \font\textsy=cmsy10 scaled \mainmagstep
  987. % A few fonts for @defun, etc.
  988. \setfont\defbf\bxshape{10}{\magstep1} %was 1314
  989. \setfont\deftt\ttshape{10}{\magstep1}
  990. \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
  991. % Fonts for indices, footnotes, small examples (9pt).
  992. \setfont\smallrm\rmshape{9}{1000}
  993. \setfont\smalltt\ttshape{9}{1000}
  994. \setfont\smallbf\bfshape{10}{900}
  995. \setfont\smallit\itshape{9}{1000}
  996. \setfont\smallsl\slshape{9}{1000}
  997. \setfont\smallsf\sfshape{9}{1000}
  998. \setfont\smallsc\scshape{10}{900}
  999. \setfont\smallttsl\ttslshape{10}{900}
  1000. \font\smalli=cmmi9
  1001. \font\smallsy=cmsy9
  1002. % Fonts for title page:
  1003. \setfont\titlerm\rmbshape{12}{\magstep3}
  1004. \setfont\titleit\itbshape{10}{\magstep4}
  1005. \setfont\titlesl\slbshape{10}{\magstep4}
  1006. \setfont\titlett\ttbshape{12}{\magstep3}
  1007. \setfont\titlettsl\ttslshape{10}{\magstep4}
  1008. \setfont\titlesf\sfbshape{17}{\magstep1}
  1009. \let\titlebf=\titlerm
  1010. \setfont\titlesc\scbshape{10}{\magstep4}
  1011. \font\titlei=cmmi12 scaled \magstep3
  1012. \font\titlesy=cmsy10 scaled \magstep4
  1013. \def\authorrm{\secrm}
  1014. % Chapter (and unnumbered) fonts (17.28pt).
  1015. \setfont\chaprm\rmbshape{12}{\magstep2}
  1016. \setfont\chapit\itbshape{10}{\magstep3}
  1017. \setfont\chapsl\slbshape{10}{\magstep3}
  1018. \setfont\chaptt\ttbshape{12}{\magstep2}
  1019. \setfont\chapttsl\ttslshape{10}{\magstep3}
  1020. \setfont\chapsf\sfbshape{17}{1000}
  1021. \let\chapbf=\chaprm
  1022. \setfont\chapsc\scbshape{10}{\magstep3}
  1023. \font\chapi=cmmi12 scaled \magstep2
  1024. \font\chapsy=cmsy10 scaled \magstep3
  1025. % Section fonts (14.4pt).
  1026. \setfont\secrm\rmbshape{12}{\magstep1}
  1027. \setfont\secit\itbshape{10}{\magstep2}
  1028. \setfont\secsl\slbshape{10}{\magstep2}
  1029. \setfont\sectt\ttbshape{12}{\magstep1}
  1030. \setfont\secttsl\ttslshape{10}{\magstep2}
  1031. \setfont\secsf\sfbshape{12}{\magstep1}
  1032. \let\secbf\secrm
  1033. \setfont\secsc\scbshape{10}{\magstep2}
  1034. \font\seci=cmmi12 scaled \magstep1
  1035. \font\secsy=cmsy10 scaled \magstep2
  1036. % \setfont\ssecrm\bxshape{10}{\magstep1} % This size an font looked bad.
  1037. % \setfont\ssecit\itshape{10}{\magstep1} % The letters were too crowded.
  1038. % \setfont\ssecsl\slshape{10}{\magstep1}
  1039. % \setfont\ssectt\ttshape{10}{\magstep1}
  1040. % \setfont\ssecsf\sfshape{10}{\magstep1}
  1041. %\setfont\ssecrm\bfshape{10}{1315} % Note the use of cmb rather than cmbx.
  1042. %\setfont\ssecit\itshape{10}{1315} % Also, the size is a little larger than
  1043. %\setfont\ssecsl\slshape{10}{1315} % being scaled magstep1.
  1044. %\setfont\ssectt\ttshape{10}{1315}
  1045. %\setfont\ssecsf\sfshape{10}{1315}
  1046. %\let\ssecbf=\ssecrm
  1047. % Subsection fonts (13.15pt).
  1048. \setfont\ssecrm\rmbshape{12}{\magstephalf}
  1049. \setfont\ssecit\itbshape{10}{1315}
  1050. \setfont\ssecsl\slbshape{10}{1315}
  1051. \setfont\ssectt\ttbshape{12}{\magstephalf}
  1052. \setfont\ssecttsl\ttslshape{10}{1315}
  1053. \setfont\ssecsf\sfbshape{12}{\magstephalf}
  1054. \let\ssecbf\ssecrm
  1055. \setfont\ssecsc\scbshape{10}{\magstep1}
  1056. \font\sseci=cmmi12 scaled \magstephalf
  1057. \font\ssecsy=cmsy10 scaled 1315
  1058. % The smallcaps and symbol fonts should actually be scaled \magstep1.5,
  1059. % but that is not a standard magnification.
  1060. % In order for the font changes to affect most math symbols and letters,
  1061. % we have to define the \textfont of the standard families. Since
  1062. % texinfo doesn't allow for producing subscripts and superscripts, we
  1063. % don't bother to reset \scriptfont and \scriptscriptfont (which would
  1064. % also require loading a lot more fonts).
  1065. %
  1066. \def\resetmathfonts{%
  1067. \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
  1068. \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
  1069. \textfont\ttfam = \tentt \textfont\sffam = \tensf
  1070. }
  1071. % The font-changing commands redefine the meanings of \tenSTYLE, instead
  1072. % of just \STYLE. We do this so that font changes will continue to work
  1073. % in math mode, where it is the current \fam that is relevant in most
  1074. % cases, not the current font. Plain TeX does \def\bf{\fam=\bffam
  1075. % \tenbf}, for example. By redefining \tenbf, we obviate the need to
  1076. % redefine \bf itself.
  1077. \def\textfonts{%
  1078. \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
  1079. \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
  1080. \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl
  1081. \resetmathfonts}
  1082. \def\titlefonts{%
  1083. \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
  1084. \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
  1085. \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
  1086. \let\tenttsl=\titlettsl
  1087. \resetmathfonts \setleading{25pt}}
  1088. \def\titlefont#1{{\titlefonts\rm #1}}
  1089. \def\chapfonts{%
  1090. \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
  1091. \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
  1092. \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl
  1093. \resetmathfonts \setleading{19pt}}
  1094. \def\secfonts{%
  1095. \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
  1096. \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
  1097. \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl
  1098. \resetmathfonts \setleading{16pt}}
  1099. \def\subsecfonts{%
  1100. \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
  1101. \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
  1102. \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl
  1103. \resetmathfonts \setleading{15pt}}
  1104. \let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf?
  1105. \def\smallfonts{%
  1106. \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
  1107. \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
  1108. \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
  1109. \let\tenttsl=\smallttsl
  1110. \resetmathfonts \setleading{11pt}}
  1111. % Set up the default fonts, so we can use them for creating boxes.
  1112. %
  1113. \textfonts
  1114. % Define these so they can be easily changed for other fonts.
  1115. \def\angleleft{$\langle$}
  1116. \def\angleright{$\rangle$}
  1117. % Count depth in font-changes, for error checks
  1118. \newcount\fontdepth \fontdepth=0
  1119. % Fonts for short table of contents.
  1120. \setfont\shortcontrm\rmshape{12}{1000}
  1121. \setfont\shortcontbf\bxshape{12}{1000}
  1122. \setfont\shortcontsl\slshape{12}{1000}
  1123. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  1124. %% serif) and @ii for TeX italic
  1125. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  1126. % unless the following character is such as not to need one.
  1127. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
  1128. \def\smartslanted#1{{\sl #1}\futurelet\next\smartitalicx}
  1129. \def\smartitalic#1{{\it #1}\futurelet\next\smartitalicx}
  1130. \let\i=\smartitalic
  1131. \let\var=\smartslanted
  1132. \let\dfn=\smartslanted
  1133. \let\emph=\smartitalic
  1134. \let\cite=\smartslanted
  1135. \def\b#1{{\bf #1}}
  1136. \let\strong=\b
  1137. % We can't just use \exhyphenpenalty, because that only has effect at
  1138. % the end of a paragraph. Restore normal hyphenation at the end of the
  1139. % group within which \nohyphenation is presumably called.
  1140. %
  1141. \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
  1142. \def\restorehyphenation{\hyphenchar\font = `- }
  1143. \def\t#1{%
  1144. {\tt \rawbackslash \frenchspacing #1}%
  1145. \null
  1146. }
  1147. \let\ttfont=\t
  1148. \def\samp#1{`\tclose{#1}'\null}
  1149. \setfont\keyrm\rmshape{8}{1000}
  1150. \font\keysy=cmsy9
  1151. \def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
  1152. \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
  1153. \vbox{\hrule\kern-0.4pt
  1154. \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
  1155. \kern-0.4pt\hrule}%
  1156. \kern-.06em\raise0.4pt\hbox{\angleright}}}}
  1157. % The old definition, with no lozenge:
  1158. %\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null}
  1159. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  1160. % @file, @option are the same as @samp.
  1161. \let\file=\samp
  1162. \let\option=\samp
  1163. % @code is a modification of @t,
  1164. % which makes spaces the same size as normal in the surrounding text.
  1165. \def\tclose#1{%
  1166. {%
  1167. % Change normal interword space to be same as for the current font.
  1168. \spaceskip = \fontdimen2\font
  1169. %
  1170. % Switch to typewriter.
  1171. \tt
  1172. %
  1173. % But `\ ' produces the large typewriter interword space.
  1174. \def\ {{\spaceskip = 0pt{} }}%
  1175. %
  1176. % Turn off hyphenation.
  1177. \nohyphenation
  1178. %
  1179. \rawbackslash
  1180. \frenchspacing
  1181. #1%
  1182. }%
  1183. \null
  1184. }
  1185. % We *must* turn on hyphenation at `-' and `_' in \code.
  1186. % Otherwise, it is too hard to avoid overfull hboxes
  1187. % in the Emacs manual, the Library manual, etc.
  1188. % Unfortunately, TeX uses one parameter (\hyphenchar) to control
  1189. % both hyphenation at - and hyphenation within words.
  1190. % We must therefore turn them both off (\tclose does that)
  1191. % and arrange explicitly to hyphenate at a dash.
  1192. % -- rms.
  1193. {
  1194. \catcode`\-=\active
  1195. \catcode`\_=\active
  1196. %
  1197. \global\def\code{\begingroup
  1198. \catcode`\-=\active \let-\codedash
  1199. \catcode`\_=\active \let_\codeunder
  1200. \codex
  1201. }
  1202. %
  1203. % If we end up with any active - characters when handling the index,
  1204. % just treat them as a normal -.
  1205. \global\def\indexbreaks{\catcode`\-=\active \let-\realdash}
  1206. }
  1207. \def\realdash{-}
  1208. \def\codedash{-\discretionary{}{}{}}
  1209. \def\codeunder{\ifusingtt{\normalunderscore\discretionary{}{}{}}{\_}}
  1210. \def\codex #1{\tclose{#1}\endgroup}
  1211. %\let\exp=\tclose %Was temporary
  1212. % @kbd is like @code, except that if the argument is just one @key command,
  1213. % then @kbd has no effect.
  1214. % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
  1215. % `example' (@kbd uses ttsl only inside of @example and friends),
  1216. % or `code' (@kbd uses normal tty font always).
  1217. \def\kbdinputstyle{\parsearg\kbdinputstylexxx}
  1218. \def\kbdinputstylexxx#1{%
  1219. \def\arg{#1}%
  1220. \ifx\arg\worddistinct
  1221. \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
  1222. \else\ifx\arg\wordexample
  1223. \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
  1224. \else\ifx\arg\wordcode
  1225. \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
  1226. \fi\fi\fi
  1227. }
  1228. \def\worddistinct{distinct}
  1229. \def\wordexample{example}
  1230. \def\wordcode{code}
  1231. % Default is kbdinputdistinct. (Too much of a hassle to call the macro,
  1232. % the catcodes are wrong for parsearg to work.)
  1233. \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}
  1234. \def\xkey{\key}
  1235. \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
  1236. \ifx\one\xkey\ifx\threex\three \key{#2}%
  1237. \else{\tclose{\kbdfont\look}}\fi
  1238. \else{\tclose{\kbdfont\look}}\fi}
  1239. % For @url, @env, @command quotes seem unnecessary, so use \code.
  1240. \let\url=\code
  1241. \let\env=\code
  1242. \let\command=\code
  1243. % @uref (abbreviation for `urlref') takes an optional (comma-separated)
  1244. % second argument specifying the text to display and an optional third
  1245. % arg as text to display instead of (rather than in addition to) the url
  1246. % itself. First (mandatory) arg is the url. Perhaps eventually put in
  1247. % a hypertex \special here.
  1248. %
  1249. \def\uref#1{\douref #1,,,\finish}
  1250. \def\douref#1,#2,#3,#4\finish{\begingroup
  1251. \unsepspaces
  1252. \pdfurl{#1}%
  1253. \setbox0 = \hbox{\ignorespaces #3}%
  1254. \ifdim\wd0 > 0pt
  1255. \unhbox0 % third arg given, show only that
  1256. \else
  1257. \setbox0 = \hbox{\ignorespaces #2}%
  1258. \ifdim\wd0 > 0pt
  1259. \ifpdf
  1260. \unhbox0 % PDF: 2nd arg given, show only it
  1261. \else
  1262. \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
  1263. \fi
  1264. \else
  1265. \code{#1}% only url given, so show it
  1266. \fi
  1267. \fi
  1268. \endlink
  1269. \endgroup}
  1270. % rms does not like angle brackets --karl, 17may97.
  1271. % So now @email is just like @uref, unless we are pdf.
  1272. %
  1273. %\def\email#1{\angleleft{\tt #1}\angleright}
  1274. \ifpdf
  1275. \def\email#1{\doemail#1,,\finish}
  1276. \def\doemail#1,#2,#3\finish{\begingroup
  1277. \unsepspaces
  1278. \pdfurl{mailto:#1}%
  1279. \setbox0 = \hbox{\ignorespaces #2}%
  1280. \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
  1281. \endlink
  1282. \endgroup}
  1283. \else
  1284. \let\email=\uref
  1285. \fi
  1286. % Check if we are currently using a typewriter font. Since all the
  1287. % Computer Modern typewriter fonts have zero interword stretch (and
  1288. % shrink), and it is reasonable to expect all typewriter fonts to have
  1289. % this property, we can check that font parameter.
  1290. %
  1291. \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
  1292. % Typeset a dimension, e.g., `in' or `pt'. The only reason for the
  1293. % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
  1294. %
  1295. \def\dmn#1{\thinspace #1}
  1296. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
  1297. % @l was never documented to mean ``switch to the Lisp font'',
  1298. % and it is not used as such in any manual I can find. We need it for
  1299. % Polish suppressed-l. --karl, 22sep96.
  1300. %\def\l#1{{\li #1}\null}
  1301. % Explicit font changes: @r, @sc, undocumented @ii.
  1302. \def\r#1{{\rm #1}} % roman font
  1303. \def\sc#1{{\smallcaps#1}} % smallcaps font
  1304. \def\ii#1{{\it #1}} % italic font
  1305. % @acronym downcases the argument and prints in smallcaps.
  1306. \def\acronym#1{{\smallcaps \lowercase{#1}}}
  1307. % @pounds{} is a sterling sign.
  1308. \def\pounds{{\it\$}}
  1309. \message{page headings,}
  1310. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  1311. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  1312. % First the title page. Must do @settitle before @titlepage.
  1313. \newif\ifseenauthor
  1314. \newif\iffinishedtitlepage
  1315. % Do an implicit @contents or @shortcontents after @end titlepage if the
  1316. % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
  1317. %
  1318. \newif\ifsetcontentsaftertitlepage
  1319. \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
  1320. \newif\ifsetshortcontentsaftertitlepage
  1321. \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
  1322. \def\shorttitlepage{\parsearg\shorttitlepagezzz}
  1323. \def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
  1324. \endgroup\page\hbox{}\page}
  1325. \def\titlepage{\begingroup \parindent=0pt \textfonts
  1326. \let\subtitlerm=\tenrm
  1327. \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
  1328. %
  1329. \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
  1330. %
  1331. % Leave some space at the very top of the page.
  1332. \vglue\titlepagetopglue
  1333. %
  1334. % Now you can print the title using @title.
  1335. \def\title{\parsearg\titlezzz}%
  1336. \def\titlezzz##1{\leftline{\titlefonts\rm ##1}
  1337. % print a rule at the page bottom also.
  1338. \finishedtitlepagefalse
  1339. \vskip4pt \hrule height 4pt width \hsize \vskip4pt}%
  1340. % No rule at page bottom unless we print one at the top with @title.
  1341. \finishedtitlepagetrue
  1342. %
  1343. % Now you can put text using @subtitle.
  1344. \def\subtitle{\parsearg\subtitlezzz}%
  1345. \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
  1346. %
  1347. % @author should come last, but may come many times.
  1348. \def\author{\parsearg\authorzzz}%
  1349. \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
  1350. {\authorfont \leftline{##1}}}%
  1351. %
  1352. % Most title ``pages'' are actually two pages long, with space
  1353. % at the top of the second. We don't want the ragged left on the second.
  1354. \let\oldpage = \page
  1355. \def\page{%
  1356. \iffinishedtitlepage\else
  1357. \finishtitlepage
  1358. \fi
  1359. \oldpage
  1360. \let\page = \oldpage
  1361. \hbox{}}%
  1362. % \def\page{\oldpage \hbox{}}
  1363. }
  1364. \def\Etitlepage{%
  1365. \iffinishedtitlepage\else
  1366. \finishtitlepage
  1367. \fi
  1368. % It is important to do the page break before ending the group,
  1369. % because the headline and footline are only empty inside the group.
  1370. % If we use the new definition of \page, we always get a blank page
  1371. % after the title page, which we certainly don't want.
  1372. \oldpage
  1373. \endgroup
  1374. %
  1375. % If they want short, they certainly want long too.
  1376. \ifsetshortcontentsaftertitlepage
  1377. \shortcontents
  1378. \contents
  1379. \global\let\shortcontents = \relax
  1380. \global\let\contents = \relax
  1381. \fi
  1382. %
  1383. \ifsetcontentsaftertitlepage
  1384. \contents
  1385. \global\let\contents = \relax
  1386. \global\let\shortcontents = \relax
  1387. \fi
  1388. %
  1389. \ifpdf \pdfmakepagedesttrue \fi
  1390. %
  1391. \HEADINGSon
  1392. }
  1393. \def\finishtitlepage{%
  1394. \vskip4pt \hrule height 2pt width \hsize
  1395. \vskip\titlepagebottomglue
  1396. \finishedtitlepagetrue
  1397. }
  1398. %%% Set up page headings and footings.
  1399. \let\thispage=\folio
  1400. \newtoks\evenheadline % headline on even pages
  1401. \newtoks\oddheadline % headline on odd pages
  1402. \newtoks\evenfootline % footline on even pages
  1403. \newtoks\oddfootline % footline on odd pages
  1404. % Now make Tex use those variables
  1405. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
  1406. \else \the\evenheadline \fi}}
  1407. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
  1408. \else \the\evenfootline \fi}\HEADINGShook}
  1409. \let\HEADINGShook=\relax
  1410. % Commands to set those variables.
  1411. % For example, this is what @headings on does
  1412. % @evenheading @thistitle|@thispage|@thischapter
  1413. % @oddheading @thischapter|@thispage|@thistitle
  1414. % @evenfooting @thisfile||
  1415. % @oddfooting ||@thisfile
  1416. \def\evenheading{\parsearg\evenheadingxxx}
  1417. \def\oddheading{\parsearg\oddheadingxxx}
  1418. \def\everyheading{\parsearg\everyheadingxxx}
  1419. \def\evenfooting{\parsearg\evenfootingxxx}
  1420. \def\oddfooting{\parsearg\oddfootingxxx}
  1421. \def\everyfooting{\parsearg\everyfootingxxx}
  1422. {\catcode`\@=0 %
  1423. \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
  1424. \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
  1425. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1426. \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
  1427. \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
  1428. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1429. \gdef\everyheadingxxx#1{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
  1430. \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
  1431. \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
  1432. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1433. \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
  1434. \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
  1435. \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
  1436. %
  1437. % Leave some space for the footline. Hopefully ok to assume
  1438. % @evenfooting will not be used by itself.
  1439. \global\advance\pageheight by -\baselineskip
  1440. \global\advance\vsize by -\baselineskip
  1441. }
  1442. \gdef\everyfootingxxx#1{\oddfootingxxx{#1}\evenfootingxxx{#1}}
  1443. %
  1444. }% unbind the catcode of @.
  1445. % @headings double turns headings on for double-sided printing.
  1446. % @headings single turns headings on for single-sided printing.
  1447. % @headings off turns them off.
  1448. % @headings on same as @headings double, retained for compatibility.
  1449. % @headings after turns on double-sided headings after this page.
  1450. % @headings doubleafter turns on double-sided headings after this page.
  1451. % @headings singleafter turns on single-sided headings after this page.
  1452. % By default, they are off at the start of a document,
  1453. % and turned `on' after @end titlepage.
  1454. \def\headings #1 {\csname HEADINGS#1\endcsname}
  1455. \def\HEADINGSoff{
  1456. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  1457. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  1458. \HEADINGSoff
  1459. % When we turn headings on, set the page number to 1.
  1460. % For double-sided printing, put current file name in lower left corner,
  1461. % chapter name on inside top of right hand pages, document
  1462. % title on inside top of left hand pages, and page numbers on outside top
  1463. % edge of all pages.
  1464. \def\HEADINGSdouble{
  1465. \global\pageno=1
  1466. \global\evenfootline={\hfil}
  1467. \global\oddfootline={\hfil}
  1468. \global\evenheadline={\line{\folio\hfil\thistitle}}
  1469. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1470. \global\let\contentsalignmacro = \chapoddpage
  1471. }
  1472. \let\contentsalignmacro = \chappager
  1473. % For single-sided printing, chapter title goes across top left of page,
  1474. % page number on top right.
  1475. \def\HEADINGSsingle{
  1476. \global\pageno=1
  1477. \global\evenfootline={\hfil}
  1478. \global\oddfootline={\hfil}
  1479. \global\evenheadline={\line{\thischapter\hfil\folio}}
  1480. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1481. \global\let\contentsalignmacro = \chappager
  1482. }
  1483. \def\HEADINGSon{\HEADINGSdouble}
  1484. \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
  1485. \let\HEADINGSdoubleafter=\HEADINGSafter
  1486. \def\HEADINGSdoublex{%
  1487. \global\evenfootline={\hfil}
  1488. \global\oddfootline={\hfil}
  1489. \global\evenheadline={\line{\folio\hfil\thistitle}}
  1490. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1491. \global\let\contentsalignmacro = \chapoddpage
  1492. }
  1493. \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
  1494. \def\HEADINGSsinglex{%
  1495. \global\evenfootline={\hfil}
  1496. \global\oddfootline={\hfil}
  1497. \global\evenheadline={\line{\thischapter\hfil\folio}}
  1498. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1499. \global\let\contentsalignmacro = \chappager
  1500. }
  1501. % Subroutines used in generating headings
  1502. % Produces Day Month Year style of output.
  1503. \def\today{%
  1504. \number\day\space
  1505. \ifcase\month
  1506. \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
  1507. \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
  1508. \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
  1509. \fi
  1510. \space\number\year}
  1511. % @settitle line... specifies the title of the document, for headings.
  1512. % It generates no output of its own.
  1513. \def\thistitle{\putwordNoTitle}
  1514. \def\settitle{\parsearg\settitlezzz}
  1515. \def\settitlezzz #1{\gdef\thistitle{#1}}
  1516. \message{tables,}
  1517. % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
  1518. % default indentation of table text
  1519. \newdimen\tableindent \tableindent=.8in
  1520. % default indentation of @itemize and @enumerate text
  1521. \newdimen\itemindent \itemindent=.3in
  1522. % margin between end of table item and start of table text.
  1523. \newdimen\itemmargin \itemmargin=.1in
  1524. % used internally for \itemindent minus \itemmargin
  1525. \newdimen\itemmax
  1526. % Note @table, @vtable, and @vtable define @item, @itemx, etc., with
  1527. % these defs.
  1528. % They also define \itemindex
  1529. % to index the item name in whatever manner is desired (perhaps none).
  1530. \newif\ifitemxneedsnegativevskip
  1531. \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
  1532. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  1533. \def\internalBitemx{\itemxpar \parsearg\itemzzz}
  1534. \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
  1535. \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz}
  1536. \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
  1537. \def\internalBkitemx{\itemxpar \parsearg\kitemzzz}
  1538. \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
  1539. \itemzzz {#1}}
  1540. \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
  1541. \itemzzz {#1}}
  1542. \def\itemzzz #1{\begingroup %
  1543. \advance\hsize by -\rightskip
  1544. \advance\hsize by -\tableindent
  1545. \setbox0=\hbox{\itemfont{#1}}%
  1546. \itemindex{#1}%
  1547. \nobreak % This prevents a break before @itemx.
  1548. %
  1549. % If the item text does not fit in the space we have, put it on a line
  1550. % by itself, and do not allow a page break either before or after that
  1551. % line. We do not start a paragraph here because then if the next
  1552. % command is, e.g., @kindex, the whatsit would get put into the
  1553. % horizontal list on a line by itself, resulting in extra blank space.
  1554. \ifdim \wd0>\itemmax
  1555. %
  1556. % Make this a paragraph so we get the \parskip glue and wrapping,
  1557. % but leave it ragged-right.
  1558. \begingroup
  1559. \advance\leftskip by-\tableindent
  1560. \advance\hsize by\tableindent
  1561. \advance\rightskip by0pt plus1fil
  1562. \leavevmode\unhbox0\par
  1563. \endgroup
  1564. %
  1565. % We're going to be starting a paragraph, but we don't want the
  1566. % \parskip glue -- logically it's part of the @item we just started.
  1567. \nobreak \vskip-\parskip
  1568. %
  1569. % Stop a page break at the \parskip glue coming up. Unfortunately
  1570. % we can't prevent a possible page break at the following
  1571. % \baselineskip glue.
  1572. \nobreak
  1573. \endgroup
  1574. \itemxneedsnegativevskipfalse
  1575. \else
  1576. % The item text fits into the space. Start a paragraph, so that the
  1577. % following text (if any) will end up on the same line.
  1578. \noindent
  1579. % Do this with kerns and \unhbox so that if there is a footnote in
  1580. % the item text, it can migrate to the main vertical list and
  1581. % eventually be printed.
  1582. \nobreak\kern-\tableindent
  1583. \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
  1584. \unhbox0
  1585. \nobreak\kern\dimen0
  1586. \endgroup
  1587. \itemxneedsnegativevskiptrue
  1588. \fi
  1589. }
  1590. \def\item{\errmessage{@item while not in a table}}
  1591. \def\itemx{\errmessage{@itemx while not in a table}}
  1592. \def\kitem{\errmessage{@kitem while not in a table}}
  1593. \def\kitemx{\errmessage{@kitemx while not in a table}}
  1594. \def\xitem{\errmessage{@xitem while not in a table}}
  1595. \def\xitemx{\errmessage{@xitemx while not in a table}}
  1596. % Contains a kludge to get @end[description] to work.
  1597. \def\description{\tablez{\dontindex}{1}{}{}{}{}}
  1598. % @table, @ftable, @vtable.
  1599. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
  1600. {\obeylines\obeyspaces%
  1601. \gdef\tablex #1^^M{%
  1602. \tabley\dontindex#1 \endtabley}}
  1603. \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
  1604. {\obeylines\obeyspaces%
  1605. \gdef\ftablex #1^^M{%
  1606. \tabley\fnitemindex#1 \endtabley
  1607. \def\Eftable{\endgraf\afterenvbreak\endgroup}%
  1608. \let\Etable=\relax}}
  1609. \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
  1610. {\obeylines\obeyspaces%
  1611. \gdef\vtablex #1^^M{%
  1612. \tabley\vritemindex#1 \endtabley
  1613. \def\Evtable{\endgraf\afterenvbreak\endgroup}%
  1614. \let\Etable=\relax}}
  1615. \def\dontindex #1{}
  1616. \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
  1617. \def\vritemindex #1{\doind {vr}{\code{#1}}}%
  1618. {\obeyspaces %
  1619. \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
  1620. \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
  1621. \def\tablez #1#2#3#4#5#6{%
  1622. \aboveenvbreak %
  1623. \begingroup %
  1624. \def\Edescription{\Etable}% Necessary kludge.
  1625. \let\itemindex=#1%
  1626. \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
  1627. \ifnum 0#4>0 \tableindent=#4\mil \fi %
  1628. \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
  1629. \def\itemfont{#2}%
  1630. \itemmax=\tableindent %
  1631. \advance \itemmax by -\itemmargin %
  1632. \advance \leftskip by \tableindent %
  1633. \exdentamount=\tableindent
  1634. \parindent = 0pt
  1635. \parskip = \smallskipamount
  1636. \ifdim \parskip=0pt \parskip=2pt \fi%
  1637. \def\Etable{\endgraf\afterenvbreak\endgroup}%
  1638. \let\item = \internalBitem %
  1639. \let\itemx = \internalBitemx %
  1640. \let\kitem = \internalBkitem %
  1641. \let\kitemx = \internalBkitemx %
  1642. \let\xitem = \internalBxitem %
  1643. \let\xitemx = \internalBxitemx %
  1644. }
  1645. % This is the counter used by @enumerate, which is really @itemize
  1646. \newcount \itemno
  1647. \def\itemize{\parsearg\itemizezzz}
  1648. \def\itemizezzz #1{%
  1649. \begingroup % ended by the @end itemize
  1650. \itemizey {#1}{\Eitemize}
  1651. }
  1652. \def\itemizey #1#2{%
  1653. \aboveenvbreak %
  1654. \itemmax=\itemindent %
  1655. \advance \itemmax by -\itemmargin %
  1656. \advance \leftskip by \itemindent %
  1657. \exdentamount=\itemindent
  1658. \parindent = 0pt %
  1659. \parskip = \smallskipamount %
  1660. \ifdim \parskip=0pt \parskip=2pt \fi%
  1661. \def#2{\endgraf\afterenvbreak\endgroup}%
  1662. \def\itemcontents{#1}%
  1663. \let\item=\itemizeitem}
  1664. % Set sfcode to normal for the chars that usually have another value.
  1665. % These are `.?!:;,'
  1666. \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
  1667. \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
  1668. % \splitoff TOKENS\endmark defines \first to be the first token in
  1669. % TOKENS, and \rest to be the remainder.
  1670. %
  1671. \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
  1672. % Allow an optional argument of an uppercase letter, lowercase letter,
  1673. % or number, to specify the first label in the enumerated list. No
  1674. % argument is the same as `1'.
  1675. %
  1676. \def\enumerate{\parsearg\enumeratezzz}
  1677. \def\enumeratezzz #1{\enumeratey #1 \endenumeratey}
  1678. \def\enumeratey #1 #2\endenumeratey{%
  1679. \begingroup % ended by the @end enumerate
  1680. %
  1681. % If we were given no argument, pretend we were given `1'.
  1682. \def\thearg{#1}%
  1683. \ifx\thearg\empty \def\thearg{1}\fi
  1684. %
  1685. % Detect if the argument is a single token. If so, it might be a
  1686. % letter. Otherwise, the only valid thing it can be is a number.
  1687. % (We will always have one token, because of the test we just made.
  1688. % This is a good thing, since \splitoff doesn't work given nothing at
  1689. % all -- the first parameter is undelimited.)
  1690. \expandafter\splitoff\thearg\endmark
  1691. \ifx\rest\empty
  1692. % Only one token in the argument. It could still be anything.
  1693. % A ``lowercase letter'' is one whose \lccode is nonzero.
  1694. % An ``uppercase letter'' is one whose \lccode is both nonzero, and
  1695. % not equal to itself.
  1696. % Otherwise, we assume it's a number.
  1697. %
  1698. % We need the \relax at the end of the \ifnum lines to stop TeX from
  1699. % continuing to look for a <number>.
  1700. %
  1701. \ifnum\lccode\expandafter`\thearg=0\relax
  1702. \numericenumerate % a number (we hope)
  1703. \else
  1704. % It's a letter.
  1705. \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
  1706. \lowercaseenumerate % lowercase letter
  1707. \else
  1708. \uppercaseenumerate % uppercase letter
  1709. \fi
  1710. \fi
  1711. \else
  1712. % Multiple tokens in the argument. We hope it's a number.
  1713. \numericenumerate
  1714. \fi
  1715. }
  1716. % An @enumerate whose labels are integers. The starting integer is
  1717. % given in \thearg.
  1718. %
  1719. \def\numericenumerate{%
  1720. \itemno = \thearg
  1721. \startenumeration{\the\itemno}%
  1722. }
  1723. % The starting (lowercase) letter is in \thearg.
  1724. \def\lowercaseenumerate{%
  1725. \itemno = \expandafter`\thearg
  1726. \startenumeration{%
  1727. % Be sure we're not beyond the end of the alphabet.
  1728. \ifnum\itemno=0
  1729. \errmessage{No more lowercase letters in @enumerate; get a bigger
  1730. alphabet}%
  1731. \fi
  1732. \char\lccode\itemno
  1733. }%
  1734. }
  1735. % The starting (uppercase) letter is in \thearg.
  1736. \def\uppercaseenumerate{%
  1737. \itemno = \expandafter`\thearg
  1738. \startenumeration{%
  1739. % Be sure we're not beyond the end of the alphabet.
  1740. \ifnum\itemno=0
  1741. \errmessage{No more uppercase letters in @enumerate; get a bigger
  1742. alphabet}
  1743. \fi
  1744. \char\uccode\itemno
  1745. }%
  1746. }
  1747. % Call itemizey, adding a period to the first argument and supplying the
  1748. % common last two arguments. Also subtract one from the initial value in
  1749. % \itemno, since @item increments \itemno.
  1750. %
  1751. \def\startenumeration#1{%
  1752. \advance\itemno by -1
  1753. \itemizey{#1.}\Eenumerate\flushcr
  1754. }
  1755. % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
  1756. % to @enumerate.
  1757. %
  1758. \def\alphaenumerate{\enumerate{a}}
  1759. \def\capsenumerate{\enumerate{A}}
  1760. \def\Ealphaenumerate{\Eenumerate}
  1761. \def\Ecapsenumerate{\Eenumerate}
  1762. % Definition of @item while inside @itemize.
  1763. \def\itemizeitem{%
  1764. \advance\itemno by 1
  1765. {\let\par=\endgraf \smallbreak}%
  1766. \ifhmode \errmessage{In hmode at itemizeitem}\fi
  1767. {\parskip=0in \hskip 0pt
  1768. \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
  1769. \vadjust{\penalty 1200}}%
  1770. \flushcr}
  1771. % @multitable macros
  1772. % Amy Hendrickson, 8/18/94, 3/6/96
  1773. %
  1774. % @multitable ... @end multitable will make as many columns as desired.
  1775. % Contents of each column will wrap at width given in preamble. Width
  1776. % can be specified either with sample text given in a template line,
  1777. % or in percent of \hsize, the current width of text on page.
  1778. % Table can continue over pages but will only break between lines.
  1779. % To make preamble:
  1780. %
  1781. % Either define widths of columns in terms of percent of \hsize:
  1782. % @multitable @columnfractions .25 .3 .45
  1783. % @item ...
  1784. %
  1785. % Numbers following @columnfractions are the percent of the total
  1786. % current hsize to be used for each column. You may use as many
  1787. % columns as desired.
  1788. % Or use a template:
  1789. % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
  1790. % @item ...
  1791. % using the widest term desired in each column.
  1792. %
  1793. % For those who want to use more than one line's worth of words in
  1794. % the preamble, break the line within one argument and it
  1795. % will parse correctly, i.e.,
  1796. %
  1797. % @multitable {Column 1 template} {Column 2 template} {Column 3
  1798. % template}
  1799. % Not:
  1800. % @multitable {Column 1 template} {Column 2 template}
  1801. % {Column 3 template}
  1802. % Each new table line starts with @item, each subsequent new column
  1803. % starts with @tab. Empty columns may be produced by supplying @tab's
  1804. % with nothing between them for as many times as empty columns are needed,
  1805. % ie, @tab@tab@tab will produce two empty columns.
  1806. % @item, @tab, @multitable or @end multitable do not need to be on their
  1807. % own lines, but it will not hurt if they are.
  1808. % Sample multitable:
  1809. % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
  1810. % @item first col stuff @tab second col stuff @tab third col
  1811. % @item
  1812. % first col stuff
  1813. % @tab
  1814. % second col stuff
  1815. % @tab
  1816. % third col
  1817. % @item first col stuff @tab second col stuff
  1818. % @tab Many paragraphs of text may be used in any column.
  1819. %
  1820. % They will wrap at the width determined by the template.
  1821. % @item@tab@tab This will be in third column.
  1822. % @end multitable
  1823. % Default dimensions may be reset by user.
  1824. % @multitableparskip is vertical space between paragraphs in table.
  1825. % @multitableparindent is paragraph indent in table.
  1826. % @multitablecolmargin is horizontal space to be left between columns.
  1827. % @multitablelinespace is space to leave between table items, baseline
  1828. % to baseline.
  1829. % 0pt means it depends on current normal line spacing.
  1830. %
  1831. \newskip\multitableparskip
  1832. \newskip\multitableparindent
  1833. \newdimen\multitablecolspace
  1834. \newskip\multitablelinespace
  1835. \multitableparskip=0pt
  1836. \multitableparindent=6pt
  1837. \multitablecolspace=12pt
  1838. \multitablelinespace=0pt
  1839. % Macros used to set up halign preamble:
  1840. %
  1841. \let\endsetuptable\relax
  1842. \def\xendsetuptable{\endsetuptable}
  1843. \let\columnfractions\relax
  1844. \def\xcolumnfractions{\columnfractions}
  1845. \newif\ifsetpercent
  1846. % #1 is the part of the @columnfraction before the decimal point, which
  1847. % is presumably either 0 or the empty string (but we don't check, we
  1848. % just throw it away). #2 is the decimal part, which we use as the
  1849. % percent of \hsize for this column.
  1850. \def\pickupwholefraction#1.#2 {%
  1851. \global\advance\colcount by 1
  1852. \expandafter\xdef\csname col\the\colcount\endcsname{.#2\hsize}%
  1853. \setuptable
  1854. }
  1855. \newcount\colcount
  1856. \def\setuptable#1{%
  1857. \def\firstarg{#1}%
  1858. \ifx\firstarg\xendsetuptable
  1859. \let\go = \relax
  1860. \else
  1861. \ifx\firstarg\xcolumnfractions
  1862. \global\setpercenttrue
  1863. \else
  1864. \ifsetpercent
  1865. \let\go\pickupwholefraction
  1866. \else
  1867. \global\advance\colcount by 1
  1868. \setbox0=\hbox{#1\unskip }% Add a normal word space as a separator;
  1869. % typically that is always in the input, anyway.
  1870. \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
  1871. \fi
  1872. \fi
  1873. \ifx\go\pickupwholefraction
  1874. % Put the argument back for the \pickupwholefraction call, so
  1875. % we'll always have a period there to be parsed.
  1876. \def\go{\pickupwholefraction#1}%
  1877. \else
  1878. \let\go = \setuptable
  1879. \fi%
  1880. \fi
  1881. \go
  1882. }
  1883. % This used to have \hskip1sp. But then the space in a template line is
  1884. % not enough. That is bad. So let's go back to just & until we
  1885. % encounter the problem it was intended to solve again.
  1886. % --karl, nathan@acm.org, 20apr99.
  1887. \def\tab{&}
  1888. % @multitable ... @end multitable definitions:
  1889. %
  1890. \def\multitable{\parsearg\dotable}
  1891. \def\dotable#1{\bgroup
  1892. \vskip\parskip
  1893. \let\item\crcr
  1894. \tolerance=9500
  1895. \hbadness=9500
  1896. \setmultitablespacing
  1897. \parskip=\multitableparskip
  1898. \parindent=\multitableparindent
  1899. \overfullrule=0pt
  1900. \global\colcount=0
  1901. \def\Emultitable{\global\setpercentfalse\cr\egroup\egroup}%
  1902. %
  1903. % To parse everything between @multitable and @item:
  1904. \setuptable#1 \endsetuptable
  1905. %
  1906. % \everycr will reset column counter, \colcount, at the end of
  1907. % each line. Every column entry will cause \colcount to advance by one.
  1908. % The table preamble
  1909. % looks at the current \colcount to find the correct column width.
  1910. \everycr{\noalign{%
  1911. %
  1912. % \filbreak%% keeps underfull box messages off when table breaks over pages.
  1913. % Maybe so, but it also creates really weird page breaks when the table
  1914. % breaks over pages. Wouldn't \vfil be better? Wait until the problem
  1915. % manifests itself, so it can be fixed for real --karl.
  1916. \global\colcount=0\relax}}%
  1917. %
  1918. % This preamble sets up a generic column definition, which will
  1919. % be used as many times as user calls for columns.
  1920. % \vtop will set a single line and will also let text wrap and
  1921. % continue for many paragraphs if desired.
  1922. \halign\bgroup&\global\advance\colcount by 1\relax
  1923. \multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname
  1924. %
  1925. % In order to keep entries from bumping into each other
  1926. % we will add a \leftskip of \multitablecolspace to all columns after
  1927. % the first one.
  1928. %
  1929. % If a template has been used, we will add \multitablecolspace
  1930. % to the width of each template entry.
  1931. %
  1932. % If the user has set preamble in terms of percent of \hsize we will
  1933. % use that dimension as the width of the column, and the \leftskip
  1934. % will keep entries from bumping into each other. Table will start at
  1935. % left margin and final column will justify at right margin.
  1936. %
  1937. % Make sure we don't inherit \rightskip from the outer environment.
  1938. \rightskip=0pt
  1939. \ifnum\colcount=1
  1940. % The first column will be indented with the surrounding text.
  1941. \advance\hsize by\leftskip
  1942. \else
  1943. \ifsetpercent \else
  1944. % If user has not set preamble in terms of percent of \hsize
  1945. % we will advance \hsize by \multitablecolspace.
  1946. \advance\hsize by \multitablecolspace
  1947. \fi
  1948. % In either case we will make \leftskip=\multitablecolspace:
  1949. \leftskip=\multitablecolspace
  1950. \fi
  1951. % Ignoring space at the beginning and end avoids an occasional spurious
  1952. % blank line, when TeX decides to break the line at the space before the
  1953. % box from the multistrut, so the strut ends up on a line by itself.
  1954. % For example:
  1955. % @multitable @columnfractions .11 .89
  1956. % @item @code{#}
  1957. % @tab Legal holiday which is valid in major parts of the whole country.
  1958. % Is automatically provided with highlighting sequences respectively marking
  1959. % characters.
  1960. \noindent\ignorespaces##\unskip\multistrut}\cr
  1961. }
  1962. \def\setmultitablespacing{% test to see if user has set \multitablelinespace.
  1963. % If so, do nothing. If not, give it an appropriate dimension based on
  1964. % current baselineskip.
  1965. \ifdim\multitablelinespace=0pt
  1966. \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
  1967. \global\advance\multitablelinespace by-\ht0
  1968. %% strut to put in table in case some entry doesn't have descenders,
  1969. %% to keep lines equally spaced
  1970. \let\multistrut = \strut
  1971. \else
  1972. %% FIXME: what is \box0 supposed to be?
  1973. \gdef\multistrut{\vrule height\multitablelinespace depth\dp0
  1974. width0pt\relax} \fi
  1975. %% Test to see if parskip is larger than space between lines of
  1976. %% table. If not, do nothing.
  1977. %% If so, set to same dimension as multitablelinespace.
  1978. \ifdim\multitableparskip>\multitablelinespace
  1979. \global\multitableparskip=\multitablelinespace
  1980. \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
  1981. %% than skip between lines in the table.
  1982. \fi%
  1983. \ifdim\multitableparskip=0pt
  1984. \global\multitableparskip=\multitablelinespace
  1985. \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
  1986. %% than skip between lines in the table.
  1987. \fi}
  1988. \message{conditionals,}
  1989. % Prevent errors for section commands.
  1990. % Used in @ignore and in failing conditionals.
  1991. \def\ignoresections{%
  1992. \let\chapter=\relax
  1993. \let\unnumbered=\relax
  1994. \let\top=\relax
  1995. \let\unnumberedsec=\relax
  1996. \let\unnumberedsection=\relax
  1997. \let\unnumberedsubsec=\relax
  1998. \let\unnumberedsubsection=\relax
  1999. \let\unnumberedsubsubsec=\relax
  2000. \let\unnumberedsubsubsection=\relax
  2001. \let\section=\relax
  2002. \let\subsec=\relax
  2003. \let\subsubsec=\relax
  2004. \let\subsection=\relax
  2005. \let\subsubsection=\relax
  2006. \let\appendix=\relax
  2007. \let\appendixsec=\relax
  2008. \let\appendixsection=\relax
  2009. \let\appendixsubsec=\relax
  2010. \let\appendixsubsection=\relax
  2011. \let\appendixsubsubsec=\relax
  2012. \let\appendixsubsubsection=\relax
  2013. \let\contents=\relax
  2014. \let\smallbook=\relax
  2015. \let\titlepage=\relax
  2016. }
  2017. % Used in nested conditionals, where we have to parse the Texinfo source
  2018. % and so want to turn off most commands, in case they are used
  2019. % incorrectly.
  2020. %
  2021. \def\ignoremorecommands{%
  2022. \let\defcodeindex = \relax
  2023. \let\defcv = \relax
  2024. \let\deffn = \relax
  2025. \let\deffnx = \relax
  2026. \let\defindex = \relax
  2027. \let\defivar = \relax
  2028. \let\defmac = \relax
  2029. \let\defmethod = \relax
  2030. \let\defop = \relax
  2031. \let\defopt = \relax
  2032. \let\defspec = \relax
  2033. \let\deftp = \relax
  2034. \let\deftypefn = \relax
  2035. \let\deftypefun = \relax
  2036. \let\deftypeivar = \relax
  2037. \let\deftypeop = \relax
  2038. \let\deftypevar = \relax
  2039. \let\deftypevr = \relax
  2040. \let\defun = \relax
  2041. \let\defvar = \relax
  2042. \let\defvr = \relax
  2043. \let\ref = \relax
  2044. \let\xref = \relax
  2045. \let\printindex = \relax
  2046. \let\pxref = \relax
  2047. \let\settitle = \relax
  2048. \let\setchapternewpage = \relax
  2049. \let\setchapterstyle = \relax
  2050. \let\everyheading = \relax
  2051. \let\evenheading = \relax
  2052. \let\oddheading = \relax
  2053. \let\everyfooting = \relax
  2054. \let\evenfooting = \relax
  2055. \let\oddfooting = \relax
  2056. \let\headings = \relax
  2057. \let\include = \relax
  2058. \let\lowersections = \relax
  2059. \let\down = \relax
  2060. \let\raisesections = \relax
  2061. \let\up = \relax
  2062. \let\set = \relax
  2063. \let\clear = \relax
  2064. \let\item = \relax
  2065. }
  2066. % Ignore @ignore ... @end ignore.
  2067. %
  2068. \def\ignore{\doignore{ignore}}
  2069. % Ignore @ifinfo, @ifhtml, @ifnottex, @html, @menu, and @direntry text.
  2070. %
  2071. \def\ifinfo{\doignore{ifinfo}}
  2072. \def\ifhtml{\doignore{ifhtml}}
  2073. \def\ifnottex{\doignore{ifnottex}}
  2074. \def\html{\doignore{html}}
  2075. \def\menu{\doignore{menu}}
  2076. \def\direntry{\doignore{direntry}}
  2077. % @dircategory CATEGORY -- specify a category of the dir file
  2078. % which this file should belong to. Ignore this in TeX.
  2079. \let\dircategory = \comment
  2080. % Ignore text until a line `@end #1'.
  2081. %
  2082. \def\doignore#1{\begingroup
  2083. % Don't complain about control sequences we have declared \outer.
  2084. \ignoresections
  2085. %
  2086. % Define a command to swallow text until we reach `@end #1'.
  2087. % This @ is a catcode 12 token (that is the normal catcode of @ in
  2088. % this texinfo.tex file). We change the catcode of @ below to match.
  2089. \long\def\doignoretext##1@end #1{\enddoignore}%
  2090. %
  2091. % Make sure that spaces turn into tokens that match what \doignoretext wants.
  2092. \catcode32 = 10
  2093. %
  2094. % Ignore braces, too, so mismatched braces don't cause trouble.
  2095. \catcode`\{ = 9
  2096. \catcode`\} = 9
  2097. %
  2098. % We must not have @c interpreted as a control sequence.
  2099. \catcode`\@ = 12
  2100. %
  2101. % Make the letter c a comment character so that the rest of the line
  2102. % will be ignored. This way, the document can have (for example)
  2103. % @c @end ifinfo
  2104. % and the @end ifinfo will be properly ignored.
  2105. % (We've just changed @ to catcode 12.)
  2106. \catcode`\c = 14
  2107. %
  2108. % And now expand that command.
  2109. \doignoretext
  2110. }
  2111. % What we do to finish off ignored text.
  2112. %
  2113. \def\enddoignore{\endgroup\ignorespaces}%
  2114. \newif\ifwarnedobs\warnedobsfalse
  2115. \def\obstexwarn{%
  2116. \ifwarnedobs\relax\else
  2117. % We need to warn folks that they may have trouble with TeX 3.0.
  2118. % This uses \immediate\write16 rather than \message to get newlines.
  2119. \immediate\write16{}
  2120. \immediate\write16{WARNING: for users of Unix TeX 3.0!}
  2121. \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
  2122. \immediate\write16{If you are running another version of TeX, relax.}
  2123. \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
  2124. \immediate\write16{ Then upgrade your TeX installation if you can.}
  2125. \immediate\write16{ (See ftp://ftp.gnu.org/pub/gnu/TeX.README.)}
  2126. \immediate\write16{If you are stuck with version 3.0, run the}
  2127. \immediate\write16{ script ``tex3patch'' from the Texinfo distribution}
  2128. \immediate\write16{ to use a workaround.}
  2129. \immediate\write16{}
  2130. \global\warnedobstrue
  2131. \fi
  2132. }
  2133. % **In TeX 3.0, setting text in \nullfont hangs tex. For a
  2134. % workaround (which requires the file ``dummy.tfm'' to be installed),
  2135. % uncomment the following line:
  2136. %%%%%\font\nullfont=dummy\let\obstexwarn=\relax
  2137. % Ignore text, except that we keep track of conditional commands for
  2138. % purposes of nesting, up to an `@end #1' command.
  2139. %
  2140. \def\nestedignore#1{%
  2141. \obstexwarn
  2142. % We must actually expand the ignored text to look for the @end
  2143. % command, so that nested ignore constructs work. Thus, we put the
  2144. % text into a \vbox and then do nothing with the result. To minimize
  2145. % the change of memory overflow, we follow the approach outlined on
  2146. % page 401 of the TeXbook: make the current font be a dummy font.
  2147. %
  2148. \setbox0 = \vbox\bgroup
  2149. % Don't complain about control sequences we have declared \outer.
  2150. \ignoresections
  2151. %
  2152. % Define `@end #1' to end the box, which will in turn undefine the
  2153. % @end command again.
  2154. \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
  2155. %
  2156. % We are going to be parsing Texinfo commands. Most cause no
  2157. % trouble when they are used incorrectly, but some commands do
  2158. % complicated argument parsing or otherwise get confused, so we
  2159. % undefine them.
  2160. %
  2161. % We can't do anything about stray @-signs, unfortunately;
  2162. % they'll produce `undefined control sequence' errors.
  2163. \ignoremorecommands
  2164. %
  2165. % Set the current font to be \nullfont, a TeX primitive, and define
  2166. % all the font commands to also use \nullfont. We don't use
  2167. % dummy.tfm, as suggested in the TeXbook, because not all sites
  2168. % might have that installed. Therefore, math mode will still
  2169. % produce output, but that should be an extremely small amount of
  2170. % stuff compared to the main input.
  2171. %
  2172. \nullfont
  2173. \let\tenrm=\nullfont \let\tenit=\nullfont \let\tensl=\nullfont
  2174. \let\tenbf=\nullfont \let\tentt=\nullfont \let\smallcaps=\nullfont
  2175. \let\tensf=\nullfont
  2176. % Similarly for index fonts (mostly for their use in smallexample).
  2177. \let\smallrm=\nullfont \let\smallit=\nullfont \let\smallsl=\nullfont
  2178. \let\smallbf=\nullfont \let\smalltt=\nullfont \let\smallsc=\nullfont
  2179. \let\smallsf=\nullfont
  2180. %
  2181. % Don't complain when characters are missing from the fonts.
  2182. \tracinglostchars = 0
  2183. %
  2184. % Don't bother to do space factor calculations.
  2185. \frenchspacing
  2186. %
  2187. % Don't report underfull hboxes.
  2188. \hbadness = 10000
  2189. %
  2190. % Do minimal line-breaking.
  2191. \pretolerance = 10000
  2192. %
  2193. % Do not execute instructions in @tex
  2194. \def\tex{\doignore{tex}}%
  2195. % Do not execute macro definitions.
  2196. % `c' is a comment character, so the word `macro' will get cut off.
  2197. \def\macro{\doignore{ma}}%
  2198. }
  2199. % @set VAR sets the variable VAR to an empty value.
  2200. % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
  2201. %
  2202. % Since we want to separate VAR from REST-OF-LINE (which might be
  2203. % empty), we can't just use \parsearg; we have to insert a space of our
  2204. % own to delimit the rest of the line, and then take it out again if we
  2205. % didn't need it. Make sure the catcode of space is correct to avoid
  2206. % losing inside @example, for instance.
  2207. %
  2208. \def\set{\begingroup\catcode` =10
  2209. \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR.
  2210. \parsearg\setxxx}
  2211. \def\setxxx#1{\setyyy#1 \endsetyyy}
  2212. \def\setyyy#1 #2\endsetyyy{%
  2213. \def\temp{#2}%
  2214. \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
  2215. \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
  2216. \fi
  2217. \endgroup
  2218. }
  2219. % Can't use \xdef to pre-expand #2 and save some time, since \temp or
  2220. % \next or other control sequences that we've defined might get us into
  2221. % an infinite loop. Consider `@set foo @cite{bar}'.
  2222. \def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}}
  2223. % @clear VAR clears (i.e., unsets) the variable VAR.
  2224. %
  2225. \def\clear{\parsearg\clearxxx}
  2226. \def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax}
  2227. % @value{foo} gets the text saved in variable foo.
  2228. {
  2229. \catcode`\_ = \active
  2230. %
  2231. % We might end up with active _ or - characters in the argument if
  2232. % we're called from @code, as @code{@value{foo-bar_}}. So \let any
  2233. % such active characters to their normal equivalents.
  2234. \gdef\value{\begingroup
  2235. \catcode`\-=12 \catcode`\_=12
  2236. \indexbreaks \let_\normalunderscore
  2237. \valuexxx}
  2238. }
  2239. \def\valuexxx#1{\expandablevalue{#1}\endgroup}
  2240. % We have this subroutine so that we can handle at least some @value's
  2241. % properly in indexes (we \let\value to this in \indexdummies). Ones
  2242. % whose names contain - or _ still won't work, but we can't do anything
  2243. % about that. The command has to be fully expandable, since the result
  2244. % winds up in the index file. This means that if the variable's value
  2245. % contains other Texinfo commands, it's almost certain it will fail
  2246. % (although perhaps we could fix that with sufficient work to do a
  2247. % one-level expansion on the result, instead of complete).
  2248. %
  2249. \def\expandablevalue#1{%
  2250. \expandafter\ifx\csname SET#1\endcsname\relax
  2251. {[No value for ``#1'']}%
  2252. \else
  2253. \csname SET#1\endcsname
  2254. \fi
  2255. }
  2256. % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
  2257. % with @set.
  2258. %
  2259. \def\ifset{\parsearg\ifsetxxx}
  2260. \def\ifsetxxx #1{%
  2261. \expandafter\ifx\csname SET#1\endcsname\relax
  2262. \expandafter\ifsetfail
  2263. \else
  2264. \expandafter\ifsetsucceed
  2265. \fi
  2266. }
  2267. \def\ifsetsucceed{\conditionalsucceed{ifset}}
  2268. \def\ifsetfail{\nestedignore{ifset}}
  2269. \defineunmatchedend{ifset}
  2270. % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
  2271. % defined with @set, or has been undefined with @clear.
  2272. %
  2273. \def\ifclear{\parsearg\ifclearxxx}
  2274. \def\ifclearxxx #1{%
  2275. \expandafter\ifx\csname SET#1\endcsname\relax
  2276. \expandafter\ifclearsucceed
  2277. \else
  2278. \expandafter\ifclearfail
  2279. \fi
  2280. }
  2281. \def\ifclearsucceed{\conditionalsucceed{ifclear}}
  2282. \def\ifclearfail{\nestedignore{ifclear}}
  2283. \defineunmatchedend{ifclear}
  2284. % @iftex, @ifnothtml, @ifnotinfo always succeed; we read the text
  2285. % following, through the first @end iftex (etc.). Make `@end iftex'
  2286. % (etc.) valid only after an @iftex.
  2287. %
  2288. \def\iftex{\conditionalsucceed{iftex}}
  2289. \def\ifnothtml{\conditionalsucceed{ifnothtml}}
  2290. \def\ifnotinfo{\conditionalsucceed{ifnotinfo}}
  2291. \defineunmatchedend{iftex}
  2292. \defineunmatchedend{ifnothtml}
  2293. \defineunmatchedend{ifnotinfo}
  2294. % We can't just want to start a group at @iftex (for example) and end it
  2295. % at @end iftex, since then @set commands inside the conditional have no
  2296. % effect (they'd get reverted at the end of the group). So we must
  2297. % define \Eiftex to redefine itself to be its previous value. (We can't
  2298. % just define it to fail again with an ``unmatched end'' error, since
  2299. % the @ifset might be nested.)
  2300. %
  2301. \def\conditionalsucceed#1{%
  2302. \edef\temp{%
  2303. % Remember the current value of \E#1.
  2304. \let\nece{prevE#1} = \nece{E#1}%
  2305. %
  2306. % At the `@end #1', redefine \E#1 to be its previous value.
  2307. \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
  2308. }%
  2309. \temp
  2310. }
  2311. % We need to expand lots of \csname's, but we don't want to expand the
  2312. % control sequences after we've constructed them.
  2313. %
  2314. \def\nece#1{\expandafter\noexpand\csname#1\endcsname}
  2315. % @defininfoenclose.
  2316. \let\definfoenclose=\comment
  2317. \message{indexing,}
  2318. % Index generation facilities
  2319. % Define \newwrite to be identical to plain tex's \newwrite
  2320. % except not \outer, so it can be used within \newindex.
  2321. {\catcode`\@=11
  2322. \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
  2323. % \newindex {foo} defines an index named foo.
  2324. % It automatically defines \fooindex such that
  2325. % \fooindex ...rest of line... puts an entry in the index foo.
  2326. % It also defines \fooindfile to be the number of the output channel for
  2327. % the file that accumulates this index. The file's extension is foo.
  2328. % The name of an index should be no more than 2 characters long
  2329. % for the sake of vms.
  2330. %
  2331. \def\newindex#1{%
  2332. \iflinks
  2333. \expandafter\newwrite \csname#1indfile\endcsname
  2334. \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
  2335. \fi
  2336. \expandafter\xdef\csname#1index\endcsname{% % Define @#1index
  2337. \noexpand\doindex{#1}}
  2338. }
  2339. % @defindex foo == \newindex{foo}
  2340. \def\defindex{\parsearg\newindex}
  2341. % Define @defcodeindex, like @defindex except put all entries in @code.
  2342. \def\newcodeindex#1{%
  2343. \iflinks
  2344. \expandafter\newwrite \csname#1indfile\endcsname
  2345. \openout \csname#1indfile\endcsname \jobname.#1
  2346. \fi
  2347. \expandafter\xdef\csname#1index\endcsname{%
  2348. \noexpand\docodeindex{#1}}
  2349. }
  2350. \def\defcodeindex{\parsearg\newcodeindex}
  2351. % @synindex foo bar makes index foo feed into index bar.
  2352. % Do this instead of @defindex foo if you don't want it as a separate index.
  2353. % The \closeout helps reduce unnecessary open files; the limit on the
  2354. % Acorn RISC OS is a mere 16 files.
  2355. \def\synindex#1 #2 {%
  2356. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  2357. \expandafter\closeout\csname#1indfile\endcsname
  2358. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  2359. \expandafter\xdef\csname#1index\endcsname{% define \xxxindex
  2360. \noexpand\doindex{#2}}%
  2361. }
  2362. % @syncodeindex foo bar similar, but put all entries made for index foo
  2363. % inside @code.
  2364. \def\syncodeindex#1 #2 {%
  2365. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  2366. \expandafter\closeout\csname#1indfile\endcsname
  2367. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  2368. \expandafter\xdef\csname#1index\endcsname{% define \xxxindex
  2369. \noexpand\docodeindex{#2}}%
  2370. }
  2371. % Define \doindex, the driver for all \fooindex macros.
  2372. % Argument #1 is generated by the calling \fooindex macro,
  2373. % and it is "foo", the name of the index.
  2374. % \doindex just uses \parsearg; it calls \doind for the actual work.
  2375. % This is because \doind is more useful to call from other macros.
  2376. % There is also \dosubind {index}{topic}{subtopic}
  2377. % which makes an entry in a two-level index such as the operation index.
  2378. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  2379. \def\singleindexer #1{\doind{\indexname}{#1}}
  2380. % like the previous two, but they put @code around the argument.
  2381. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  2382. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  2383. \def\indexdummies{%
  2384. \def\ { }%
  2385. % Take care of the plain tex accent commands.
  2386. \def\"{\realbackslash "}%
  2387. \def\`{\realbackslash `}%
  2388. \def\'{\realbackslash '}%
  2389. \def\^{\realbackslash ^}%
  2390. \def\~{\realbackslash ~}%
  2391. \def\={\realbackslash =}%
  2392. \def\b{\realbackslash b}%
  2393. \def\c{\realbackslash c}%
  2394. \def\d{\realbackslash d}%
  2395. \def\u{\realbackslash u}%
  2396. \def\v{\realbackslash v}%
  2397. \def\H{\realbackslash H}%
  2398. % Take care of the plain tex special European modified letters.
  2399. \def\oe{\realbackslash oe}%
  2400. \def\ae{\realbackslash ae}%
  2401. \def\aa{\realbackslash aa}%
  2402. \def\OE{\realbackslash OE}%
  2403. \def\AE{\realbackslash AE}%
  2404. \def\AA{\realbackslash AA}%
  2405. \def\o{\realbackslash o}%
  2406. \def\O{\realbackslash O}%
  2407. \def\l{\realbackslash l}%
  2408. \def\L{\realbackslash L}%
  2409. \def\ss{\realbackslash ss}%
  2410. % Take care of texinfo commands likely to appear in an index entry.
  2411. % (Must be a way to avoid doing expansion at all, and thus not have to
  2412. % laboriously list every single command here.)
  2413. \def\@{@}% will be @@ when we switch to @ as escape char.
  2414. % Need these in case \tex is in effect and \{ is a \delimiter again.
  2415. % But can't use \lbracecmd and \rbracecmd because texindex assumes
  2416. % braces and backslashes are used only as delimiters.
  2417. \let\{ = \mylbrace
  2418. \let\} = \myrbrace
  2419. \def\_{{\realbackslash _}}%
  2420. \def\w{\realbackslash w }%
  2421. \def\bf{\realbackslash bf }%
  2422. %\def\rm{\realbackslash rm }%
  2423. \def\sl{\realbackslash sl }%
  2424. \def\sf{\realbackslash sf}%
  2425. \def\tt{\realbackslash tt}%
  2426. \def\gtr{\realbackslash gtr}%
  2427. \def\less{\realbackslash less}%
  2428. \def\hat{\realbackslash hat}%
  2429. \def\TeX{\realbackslash TeX}%
  2430. \def\dots{\realbackslash dots }%
  2431. \def\result{\realbackslash result}%
  2432. \def\equiv{\realbackslash equiv}%
  2433. \def\expansion{\realbackslash expansion}%
  2434. \def\print{\realbackslash print}%
  2435. \def\error{\realbackslash error}%
  2436. \def\point{\realbackslash point}%
  2437. \def\copyright{\realbackslash copyright}%
  2438. \def\tclose##1{\realbackslash tclose {##1}}%
  2439. \def\code##1{\realbackslash code {##1}}%
  2440. \def\uref##1{\realbackslash uref {##1}}%
  2441. \def\url##1{\realbackslash url {##1}}%
  2442. \def\env##1{\realbackslash env {##1}}%
  2443. \def\command##1{\realbackslash command {##1}}%
  2444. \def\option##1{\realbackslash option {##1}}%
  2445. \def\dotless##1{\realbackslash dotless {##1}}%
  2446. \def\samp##1{\realbackslash samp {##1}}%
  2447. \def\,##1{\realbackslash ,{##1}}%
  2448. \def\t##1{\realbackslash t {##1}}%
  2449. \def\r##1{\realbackslash r {##1}}%
  2450. \def\i##1{\realbackslash i {##1}}%
  2451. \def\b##1{\realbackslash b {##1}}%
  2452. \def\sc##1{\realbackslash sc {##1}}%
  2453. \def\cite##1{\realbackslash cite {##1}}%
  2454. \def\key##1{\realbackslash key {##1}}%
  2455. \def\file##1{\realbackslash file {##1}}%
  2456. \def\var##1{\realbackslash var {##1}}%
  2457. \def\kbd##1{\realbackslash kbd {##1}}%
  2458. \def\dfn##1{\realbackslash dfn {##1}}%
  2459. \def\emph##1{\realbackslash emph {##1}}%
  2460. \def\acronym##1{\realbackslash acronym {##1}}%
  2461. %
  2462. % Handle some cases of @value -- where the variable name does not
  2463. % contain - or _, and the value does not contain any
  2464. % (non-fully-expandable) commands.
  2465. \let\value = \expandablevalue
  2466. %
  2467. \unsepspaces
  2468. % Turn off macro expansion
  2469. \turnoffmacros
  2470. }
  2471. % If an index command is used in an @example environment, any spaces
  2472. % therein should become regular spaces in the raw index file, not the
  2473. % expansion of \tie (\\leavevmode \penalty \@M \ ).
  2474. {\obeyspaces
  2475. \gdef\unsepspaces{\obeyspaces\let =\space}}
  2476. % \indexnofonts no-ops all font-change commands.
  2477. % This is used when outputting the strings to sort the index by.
  2478. \def\indexdummyfont#1{#1}
  2479. \def\indexdummytex{TeX}
  2480. \def\indexdummydots{...}
  2481. \def\indexnofonts{%
  2482. % Just ignore accents.
  2483. \let\,=\indexdummyfont
  2484. \let\"=\indexdummyfont
  2485. \let\`=\indexdummyfont
  2486. \let\'=\indexdummyfont
  2487. \let\^=\indexdummyfont
  2488. \let\~=\indexdummyfont
  2489. \let\==\indexdummyfont
  2490. \let\b=\indexdummyfont
  2491. \let\c=\indexdummyfont
  2492. \let\d=\indexdummyfont
  2493. \let\u=\indexdummyfont
  2494. \let\v=\indexdummyfont
  2495. \let\H=\indexdummyfont
  2496. \let\dotless=\indexdummyfont
  2497. % Take care of the plain tex special European modified letters.
  2498. \def\oe{oe}%
  2499. \def\ae{ae}%
  2500. \def\aa{aa}%
  2501. \def\OE{OE}%
  2502. \def\AE{AE}%
  2503. \def\AA{AA}%
  2504. \def\o{o}%
  2505. \def\O{O}%
  2506. \def\l{l}%
  2507. \def\L{L}%
  2508. \def\ss{ss}%
  2509. \let\w=\indexdummyfont
  2510. \let\t=\indexdummyfont
  2511. \let\r=\indexdummyfont
  2512. \let\i=\indexdummyfont
  2513. \let\b=\indexdummyfont
  2514. \let\emph=\indexdummyfont
  2515. \let\strong=\indexdummyfont
  2516. \let\cite=\indexdummyfont
  2517. \let\sc=\indexdummyfont
  2518. %Don't no-op \tt, since it isn't a user-level command
  2519. % and is used in the definitions of the active chars like <, >, |...
  2520. %\let\tt=\indexdummyfont
  2521. \let\tclose=\indexdummyfont
  2522. \let\code=\indexdummyfont
  2523. \let\url=\indexdummyfont
  2524. \let\uref=\indexdummyfont
  2525. \let\env=\indexdummyfont
  2526. \let\acronym=\indexdummyfont
  2527. \let\command=\indexdummyfont
  2528. \let\option=\indexdummyfont
  2529. \let\file=\indexdummyfont
  2530. \let\samp=\indexdummyfont
  2531. \let\kbd=\indexdummyfont
  2532. \let\key=\indexdummyfont
  2533. \let\var=\indexdummyfont
  2534. \let\TeX=\indexdummytex
  2535. \let\dots=\indexdummydots
  2536. \def\@{@}%
  2537. }
  2538. % To define \realbackslash, we must make \ not be an escape.
  2539. % We must first make another character (@) an escape
  2540. % so we do not become unable to do a definition.
  2541. {\catcode`\@=0 \catcode`\\=\other
  2542. @gdef@realbackslash{\}}
  2543. \let\indexbackslash=0 %overridden during \printindex.
  2544. \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
  2545. % For \ifx comparisons.
  2546. \def\emptymacro{\empty}
  2547. % Most index entries go through here, but \dosubind is the general case.
  2548. %
  2549. \def\doind#1#2{\dosubind{#1}{#2}\empty}
  2550. % Workhorse for all \fooindexes.
  2551. % #1 is name of index, #2 is stuff to put there, #3 is subentry --
  2552. % \empty if called from \doind, as we usually are. The main exception
  2553. % is with defuns, which call us directly.
  2554. %
  2555. \def\dosubind#1#2#3{%
  2556. % Put the index entry in the margin if desired.
  2557. \ifx\SETmarginindex\relax\else
  2558. \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}%
  2559. \fi
  2560. {%
  2561. \count255=\lastpenalty
  2562. {%
  2563. \indexdummies % Must do this here, since \bf, etc expand at this stage
  2564. \escapechar=`\\
  2565. {%
  2566. \let\folio = 0% We will expand all macros now EXCEPT \folio.
  2567. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
  2568. % so it will be output as is; and it will print as backslash.
  2569. %
  2570. \def\thirdarg{#3}%
  2571. %
  2572. % If third arg is present, precede it with space in sort key.
  2573. \ifx\thirdarg\emptymacro
  2574. \let\subentry = \empty
  2575. \else
  2576. \def\subentry{ #3}%
  2577. \fi
  2578. %
  2579. % First process the index entry with all font commands turned
  2580. % off to get the string to sort by.
  2581. {\indexnofonts \xdef\indexsorttmp{#2\subentry}}%
  2582. %
  2583. % Now the real index entry with the fonts.
  2584. \toks0 = {#2}%
  2585. %
  2586. % If third (subentry) arg is present, add it to the index
  2587. % string. And include a space.
  2588. \ifx\thirdarg\emptymacro \else
  2589. \toks0 = \expandafter{\the\toks0 \space #3}%
  2590. \fi
  2591. %
  2592. % Set up the complete index entry, with both the sort key
  2593. % and the original text, including any font commands. We write
  2594. % three arguments to \entry to the .?? file, texindex reduces to
  2595. % two when writing the .??s sorted result.
  2596. \edef\temp{%
  2597. \write\csname#1indfile\endcsname{%
  2598. \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}%
  2599. }%
  2600. %
  2601. % If a skip is the last thing on the list now, preserve it
  2602. % by backing up by \lastskip, doing the \write, then inserting
  2603. % the skip again. Otherwise, the whatsit generated by the
  2604. % \write will make \lastskip zero. The result is that sequences
  2605. % like this:
  2606. % @end defun
  2607. % @tindex whatever
  2608. % @defun ...
  2609. % will have extra space inserted, because the \medbreak in the
  2610. % start of the @defun won't see the skip inserted by the @end of
  2611. % the previous defun.
  2612. %
  2613. % But don't do any of this if we're not in vertical mode. We
  2614. % don't want to do a \vskip and prematurely end a paragraph.
  2615. %
  2616. % Avoid page breaks due to these extra skips, too.
  2617. %
  2618. \iflinks
  2619. \ifvmode
  2620. \skip0 = \lastskip
  2621. \ifdim\lastskip = 0pt \else \nobreak\vskip-\lastskip \fi
  2622. \fi
  2623. %
  2624. \temp % do the write
  2625. %
  2626. %
  2627. \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi
  2628. \fi
  2629. }%
  2630. }%
  2631. \penalty\count255
  2632. }%
  2633. }
  2634. % The index entry written in the file actually looks like
  2635. % \entry {sortstring}{page}{topic}
  2636. % or
  2637. % \entry {sortstring}{page}{topic}{subtopic}
  2638. % The texindex program reads in these files and writes files
  2639. % containing these kinds of lines:
  2640. % \initial {c}
  2641. % before the first topic whose initial is c
  2642. % \entry {topic}{pagelist}
  2643. % for a topic that is used without subtopics
  2644. % \primary {topic}
  2645. % for the beginning of a topic that is used with subtopics
  2646. % \secondary {subtopic}{pagelist}
  2647. % for each subtopic.
  2648. % Define the user-accessible indexing commands
  2649. % @findex, @vindex, @kindex, @cindex.
  2650. \def\findex {\fnindex}
  2651. \def\kindex {\kyindex}
  2652. \def\cindex {\cpindex}
  2653. \def\vindex {\vrindex}
  2654. \def\tindex {\tpindex}
  2655. \def\pindex {\pgindex}
  2656. \def\cindexsub {\begingroup\obeylines\cindexsub}
  2657. {\obeylines %
  2658. \gdef\cindexsub "#1" #2^^M{\endgroup %
  2659. \dosubind{cp}{#2}{#1}}}
  2660. % Define the macros used in formatting output of the sorted index material.
  2661. % @printindex causes a particular index (the ??s file) to get printed.
  2662. % It does not print any chapter heading (usually an @unnumbered).
  2663. %
  2664. \def\printindex{\parsearg\doprintindex}
  2665. \def\doprintindex#1{\begingroup
  2666. \dobreak \chapheadingskip{10000}%
  2667. %
  2668. \smallfonts \rm
  2669. \tolerance = 9500
  2670. \indexbreaks
  2671. %
  2672. % See if the index file exists and is nonempty.
  2673. % Change catcode of @ here so that if the index file contains
  2674. % \initial {@}
  2675. % as its first line, TeX doesn't complain about mismatched braces
  2676. % (because it thinks @} is a control sequence).
  2677. \catcode`\@ = 11
  2678. \openin 1 \jobname.#1s
  2679. \ifeof 1
  2680. % \enddoublecolumns gets confused if there is no text in the index,
  2681. % and it loses the chapter title and the aux file entries for the
  2682. % index. The easiest way to prevent this problem is to make sure
  2683. % there is some text.
  2684. \putwordIndexNonexistent
  2685. \else
  2686. %
  2687. % If the index file exists but is empty, then \openin leaves \ifeof
  2688. % false. We have to make TeX try to read something from the file, so
  2689. % it can discover if there is anything in it.
  2690. \read 1 to \temp
  2691. \ifeof 1
  2692. \putwordIndexIsEmpty
  2693. \else
  2694. % Index files are almost Texinfo source, but we use \ as the escape
  2695. % character. It would be better to use @, but that's too big a change
  2696. % to make right now.
  2697. \def\indexbackslash{\rawbackslashxx}%
  2698. \catcode`\\ = 0
  2699. \escapechar = `\\
  2700. \begindoublecolumns
  2701. \input \jobname.#1s
  2702. \enddoublecolumns
  2703. \fi
  2704. \fi
  2705. \closein 1
  2706. \endgroup}
  2707. % These macros are used by the sorted index file itself.
  2708. % Change them to control the appearance of the index.
  2709. \def\initial#1{{%
  2710. % Some minor font changes for the special characters.
  2711. \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
  2712. %
  2713. % Remove any glue we may have, we'll be inserting our own.
  2714. \removelastskip
  2715. %
  2716. % We like breaks before the index initials, so insert a bonus.
  2717. \penalty -300
  2718. %
  2719. % Typeset the initial. Making this add up to a whole number of
  2720. % baselineskips increases the chance of the dots lining up from column
  2721. % to column. It still won't often be perfect, because of the stretch
  2722. % we need before each entry, but it's better.
  2723. %
  2724. % No shrink because it confuses \balancecolumns.
  2725. \vskip 1.67\baselineskip plus .5\baselineskip
  2726. \leftline{\secbf #1}%
  2727. \vskip .33\baselineskip plus .1\baselineskip
  2728. %
  2729. % Do our best not to break after the initial.
  2730. \nobreak
  2731. }}
  2732. % This typesets a paragraph consisting of #1, dot leaders, and then #2
  2733. % flush to the right margin. It is used for index and table of contents
  2734. % entries. The paragraph is indented by \leftskip.
  2735. %
  2736. \def\entry#1#2{\begingroup
  2737. %
  2738. % Start a new paragraph if necessary, so our assignments below can't
  2739. % affect previous text.
  2740. \par
  2741. %
  2742. % Do not fill out the last line with white space.
  2743. \parfillskip = 0in
  2744. %
  2745. % No extra space above this paragraph.
  2746. \parskip = 0in
  2747. %
  2748. % Do not prefer a separate line ending with a hyphen to fewer lines.
  2749. \finalhyphendemerits = 0
  2750. %
  2751. % \hangindent is only relevant when the entry text and page number
  2752. % don't both fit on one line. In that case, bob suggests starting the
  2753. % dots pretty far over on the line. Unfortunately, a large
  2754. % indentation looks wrong when the entry text itself is broken across
  2755. % lines. So we use a small indentation and put up with long leaders.
  2756. %
  2757. % \hangafter is reset to 1 (which is the value we want) at the start
  2758. % of each paragraph, so we need not do anything with that.
  2759. \hangindent = 2em
  2760. %
  2761. % When the entry text needs to be broken, just fill out the first line
  2762. % with blank space.
  2763. \rightskip = 0pt plus1fil
  2764. %
  2765. % A bit of stretch before each entry for the benefit of balancing columns.
  2766. \vskip 0pt plus1pt
  2767. %
  2768. % Start a ``paragraph'' for the index entry so the line breaking
  2769. % parameters we've set above will have an effect.
  2770. \noindent
  2771. %
  2772. % Insert the text of the index entry. TeX will do line-breaking on it.
  2773. #1%
  2774. % The following is kludged to not output a line of dots in the index if
  2775. % there are no page numbers. The next person who breaks this will be
  2776. % cursed by a Unix daemon.
  2777. \def\tempa{{\rm }}%
  2778. \def\tempb{#2}%
  2779. \edef\tempc{\tempa}%
  2780. \edef\tempd{\tempb}%
  2781. \ifx\tempc\tempd\ \else%
  2782. %
  2783. % If we must, put the page number on a line of its own, and fill out
  2784. % this line with blank space. (The \hfil is overwhelmed with the
  2785. % fill leaders glue in \indexdotfill if the page number does fit.)
  2786. \hfil\penalty50
  2787. \null\nobreak\indexdotfill % Have leaders before the page number.
  2788. %
  2789. % The `\ ' here is removed by the implicit \unskip that TeX does as
  2790. % part of (the primitive) \par. Without it, a spurious underfull
  2791. % \hbox ensues.
  2792. \ifpdf
  2793. \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
  2794. \else
  2795. \ #2% The page number ends the paragraph.
  2796. \fi
  2797. \fi%
  2798. \par
  2799. \endgroup}
  2800. % Like \dotfill except takes at least 1 em.
  2801. \def\indexdotfill{\cleaders
  2802. \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
  2803. \def\primary #1{\line{#1\hfil}}
  2804. \newskip\secondaryindent \secondaryindent=0.5cm
  2805. \def\secondary #1#2{
  2806. {\parfillskip=0in \parskip=0in
  2807. \hangindent =1in \hangafter=1
  2808. \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
  2809. }}
  2810. % Define two-column mode, which we use to typeset indexes.
  2811. % Adapted from the TeXbook, page 416, which is to say,
  2812. % the manmac.tex format used to print the TeXbook itself.
  2813. \catcode`\@=11
  2814. \newbox\partialpage
  2815. \newdimen\doublecolumnhsize
  2816. \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
  2817. % Grab any single-column material above us.
  2818. \output = {%
  2819. %
  2820. % Here is a possibility not foreseen in manmac: if we accumulate a
  2821. % whole lot of material, we might end up calling this \output
  2822. % routine twice in a row (see the doublecol-lose test, which is
  2823. % essentially a couple of indexes with @setchapternewpage off). In
  2824. % that case we just ship out what is in \partialpage with the normal
  2825. % output routine. Generally, \partialpage will be empty when this
  2826. % runs and this will be a no-op. See the indexspread.tex test case.
  2827. \ifvoid\partialpage \else
  2828. \onepageout{\pagecontents\partialpage}%
  2829. \fi
  2830. %
  2831. \global\setbox\partialpage = \vbox{%
  2832. % Unvbox the main output page.
  2833. \unvbox\PAGE
  2834. \kern-\topskip \kern\baselineskip
  2835. }%
  2836. }%
  2837. \eject % run that output routine to set \partialpage
  2838. %
  2839. % Use the double-column output routine for subsequent pages.
  2840. \output = {\doublecolumnout}%
  2841. %
  2842. % Change the page size parameters. We could do this once outside this
  2843. % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
  2844. % format, but then we repeat the same computation. Repeating a couple
  2845. % of assignments once per index is clearly meaningless for the
  2846. % execution time, so we may as well do it in one place.
  2847. %
  2848. % First we halve the line length, less a little for the gutter between
  2849. % the columns. We compute the gutter based on the line length, so it
  2850. % changes automatically with the paper format. The magic constant
  2851. % below is chosen so that the gutter has the same value (well, +-<1pt)
  2852. % as it did when we hard-coded it.
  2853. %
  2854. % We put the result in a separate register, \doublecolumhsize, so we
  2855. % can restore it in \pagesofar, after \hsize itself has (potentially)
  2856. % been clobbered.
  2857. %
  2858. \doublecolumnhsize = \hsize
  2859. \advance\doublecolumnhsize by -.04154\hsize
  2860. \divide\doublecolumnhsize by 2
  2861. \hsize = \doublecolumnhsize
  2862. %
  2863. % Double the \vsize as well. (We don't need a separate register here,
  2864. % since nobody clobbers \vsize.)
  2865. \advance\vsize by -\ht\partialpage
  2866. \vsize = 2\vsize
  2867. }
  2868. % The double-column output routine for all double-column pages except
  2869. % the last.
  2870. %
  2871. \def\doublecolumnout{%
  2872. \splittopskip=\topskip \splitmaxdepth=\maxdepth
  2873. % Get the available space for the double columns -- the normal
  2874. % (undoubled) page height minus any material left over from the
  2875. % previous page.
  2876. \dimen@ = \vsize
  2877. \divide\dimen@ by 2
  2878. %
  2879. % box0 will be the left-hand column, box2 the right.
  2880. \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  2881. \onepageout\pagesofar
  2882. \unvbox255
  2883. \penalty\outputpenalty
  2884. }
  2885. \def\pagesofar{%
  2886. % Re-output the contents of the output page -- any previous material,
  2887. % followed by the two boxes we just split, in box0 and box2.
  2888. \unvbox\partialpage
  2889. %
  2890. \hsize = \doublecolumnhsize
  2891. \wd0=\hsize \wd2=\hsize
  2892. \hbox to\pagewidth{\box0\hfil\box2}%
  2893. }
  2894. \def\enddoublecolumns{%
  2895. \output = {%
  2896. % Split the last of the double-column material. Leave it on the
  2897. % current page, no automatic page break.
  2898. \balancecolumns
  2899. %
  2900. % If we end up splitting too much material for the current page,
  2901. % though, there will be another page break right after this \output
  2902. % invocation ends. Having called \balancecolumns once, we do not
  2903. % want to call it again. Therefore, reset \output to its normal
  2904. % definition right away. (We hope \balancecolumns will never be
  2905. % called on to balance too much material, but if it is, this makes
  2906. % the output somewhat more palatable.)
  2907. \global\output = {\onepageout{\pagecontents\PAGE}}%
  2908. }%
  2909. \eject
  2910. \endgroup % started in \begindoublecolumns
  2911. %
  2912. % \pagegoal was set to the doubled \vsize above, since we restarted
  2913. % the current page. We're now back to normal single-column
  2914. % typesetting, so reset \pagegoal to the normal \vsize (after the
  2915. % \endgroup where \vsize got restored).
  2916. \pagegoal = \vsize
  2917. }
  2918. \def\balancecolumns{%
  2919. % Called at the end of the double column material.
  2920. \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
  2921. \dimen@ = \ht0
  2922. \advance\dimen@ by \topskip
  2923. \advance\dimen@ by-\baselineskip
  2924. \divide\dimen@ by 2 % target to split to
  2925. %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}%
  2926. \splittopskip = \topskip
  2927. % Loop until we get a decent breakpoint.
  2928. {%
  2929. \vbadness = 10000
  2930. \loop
  2931. \global\setbox3 = \copy0
  2932. \global\setbox1 = \vsplit3 to \dimen@
  2933. \ifdim\ht3>\dimen@
  2934. \global\advance\dimen@ by 1pt
  2935. \repeat
  2936. }%
  2937. %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
  2938. \setbox0=\vbox to\dimen@{\unvbox1}%
  2939. \setbox2=\vbox to\dimen@{\unvbox3}%
  2940. %
  2941. \pagesofar
  2942. }
  2943. \catcode`\@ = \other
  2944. \message{sectioning,}
  2945. % Chapters, sections, etc.
  2946. \newcount\chapno
  2947. \newcount\secno \secno=0
  2948. \newcount\subsecno \subsecno=0
  2949. \newcount\subsubsecno \subsubsecno=0
  2950. % This counter is funny since it counts through charcodes of letters A, B, ...
  2951. \newcount\appendixno \appendixno = `\@
  2952. % \def\appendixletter{\char\the\appendixno}
  2953. % We do the following for the sake of pdftex, which needs the actual
  2954. % letter in the expansion, not just typeset.
  2955. \def\appendixletter{%
  2956. \ifnum\appendixno=`A A%
  2957. \else\ifnum\appendixno=`B B%
  2958. \else\ifnum\appendixno=`C C%
  2959. \else\ifnum\appendixno=`D D%
  2960. \else\ifnum\appendixno=`E E%
  2961. \else\ifnum\appendixno=`F F%
  2962. \else\ifnum\appendixno=`G G%
  2963. \else\ifnum\appendixno=`H H%
  2964. \else\ifnum\appendixno=`I I%
  2965. \else\ifnum\appendixno=`J J%
  2966. \else\ifnum\appendixno=`K K%
  2967. \else\ifnum\appendixno=`L L%
  2968. \else\ifnum\appendixno=`M M%
  2969. \else\ifnum\appendixno=`N N%
  2970. \else\ifnum\appendixno=`O O%
  2971. \else\ifnum\appendixno=`P P%
  2972. \else\ifnum\appendixno=`Q Q%
  2973. \else\ifnum\appendixno=`R R%
  2974. \else\ifnum\appendixno=`S S%
  2975. \else\ifnum\appendixno=`T T%
  2976. \else\ifnum\appendixno=`U U%
  2977. \else\ifnum\appendixno=`V V%
  2978. \else\ifnum\appendixno=`W W%
  2979. \else\ifnum\appendixno=`X X%
  2980. \else\ifnum\appendixno=`Y Y%
  2981. \else\ifnum\appendixno=`Z Z%
  2982. % The \the is necessary, despite appearances, because \appendixletter is
  2983. % expanded while writing the .toc file. \char\appendixno is not
  2984. % expandable, thus it is written literally, thus all appendixes come out
  2985. % with the same letter (or @) in the toc without it.
  2986. \else\char\the\appendixno
  2987. \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
  2988. \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
  2989. % Each @chapter defines this as the name of the chapter.
  2990. % page headings and footings can use it. @section does likewise.
  2991. \def\thischapter{}
  2992. \def\thissection{}
  2993. \newcount\absseclevel % used to calculate proper heading level
  2994. \newcount\secbase\secbase=0 % @raise/lowersections modify this count
  2995. % @raisesections: treat @section as chapter, @subsection as section, etc.
  2996. \def\raisesections{\global\advance\secbase by -1}
  2997. \let\up=\raisesections % original BFox name
  2998. % @lowersections: treat @chapter as section, @section as subsection, etc.
  2999. \def\lowersections{\global\advance\secbase by 1}
  3000. \let\down=\lowersections % original BFox name
  3001. % Choose a numbered-heading macro
  3002. % #1 is heading level if unmodified by @raisesections or @lowersections
  3003. % #2 is text for heading
  3004. \def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
  3005. \ifcase\absseclevel
  3006. \chapterzzz{#2}
  3007. \or
  3008. \seczzz{#2}
  3009. \or
  3010. \numberedsubseczzz{#2}
  3011. \or
  3012. \numberedsubsubseczzz{#2}
  3013. \else
  3014. \ifnum \absseclevel<0
  3015. \chapterzzz{#2}
  3016. \else
  3017. \numberedsubsubseczzz{#2}
  3018. \fi
  3019. \fi
  3020. }
  3021. % like \numhead, but chooses appendix heading levels
  3022. \def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
  3023. \ifcase\absseclevel
  3024. \appendixzzz{#2}
  3025. \or
  3026. \appendixsectionzzz{#2}
  3027. \or
  3028. \appendixsubseczzz{#2}
  3029. \or
  3030. \appendixsubsubseczzz{#2}
  3031. \else
  3032. \ifnum \absseclevel<0
  3033. \appendixzzz{#2}
  3034. \else
  3035. \appendixsubsubseczzz{#2}
  3036. \fi
  3037. \fi
  3038. }
  3039. % like \numhead, but chooses numberless heading levels
  3040. \def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
  3041. \ifcase\absseclevel
  3042. \unnumberedzzz{#2}
  3043. \or
  3044. \unnumberedseczzz{#2}
  3045. \or
  3046. \unnumberedsubseczzz{#2}
  3047. \or
  3048. \unnumberedsubsubseczzz{#2}
  3049. \else
  3050. \ifnum \absseclevel<0
  3051. \unnumberedzzz{#2}
  3052. \else
  3053. \unnumberedsubsubseczzz{#2}
  3054. \fi
  3055. \fi
  3056. }
  3057. % @chapter, @appendix, @unnumbered.
  3058. \def\thischaptername{No Chapter Title}
  3059. \outer\def\chapter{\parsearg\chapteryyy}
  3060. \def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
  3061. \def\chapterzzz #1{%
  3062. \secno=0 \subsecno=0 \subsubsecno=0
  3063. \global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}%
  3064. \chapmacro {#1}{\the\chapno}%
  3065. \gdef\thissection{#1}%
  3066. \gdef\thischaptername{#1}%
  3067. % We don't substitute the actual chapter name into \thischapter
  3068. % because we don't want its macros evaluated now.
  3069. \xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
  3070. \toks0 = {#1}%
  3071. \edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
  3072. {\the\chapno}}}%
  3073. \temp
  3074. \donoderef
  3075. \global\let\section = \numberedsec
  3076. \global\let\subsection = \numberedsubsec
  3077. \global\let\subsubsection = \numberedsubsubsec
  3078. }
  3079. \outer\def\appendix{\parsearg\appendixyyy}
  3080. \def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
  3081. \def\appendixzzz #1{%
  3082. \secno=0 \subsecno=0 \subsubsecno=0
  3083. \global\advance \appendixno by 1
  3084. \message{\putwordAppendix\space \appendixletter}%
  3085. \chapmacro {#1}{\putwordAppendix{} \appendixletter}%
  3086. \gdef\thissection{#1}%
  3087. \gdef\thischaptername{#1}%
  3088. \xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
  3089. \toks0 = {#1}%
  3090. \edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
  3091. {\putwordAppendix{} \appendixletter}}}%
  3092. \temp
  3093. \appendixnoderef
  3094. \global\let\section = \appendixsec
  3095. \global\let\subsection = \appendixsubsec
  3096. \global\let\subsubsection = \appendixsubsubsec
  3097. }
  3098. % @centerchap is like @unnumbered, but the heading is centered.
  3099. \outer\def\centerchap{\parsearg\centerchapyyy}
  3100. \def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}}
  3101. % @top is like @unnumbered.
  3102. \outer\def\top{\parsearg\unnumberedyyy}
  3103. \outer\def\unnumbered{\parsearg\unnumberedyyy}
  3104. \def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
  3105. \def\unnumberedzzz #1{%
  3106. \secno=0 \subsecno=0 \subsubsecno=0
  3107. %
  3108. % This used to be simply \message{#1}, but TeX fully expands the
  3109. % argument to \message. Therefore, if #1 contained @-commands, TeX
  3110. % expanded them. For example, in `@unnumbered The @cite{Book}', TeX
  3111. % expanded @cite (which turns out to cause errors because \cite is meant
  3112. % to be executed, not expanded).
  3113. %
  3114. % Anyway, we don't want the fully-expanded definition of @cite to appear
  3115. % as a result of the \message, we just want `@cite' itself. We use
  3116. % \the<toks register> to achieve this: TeX expands \the<toks> only once,
  3117. % simply yielding the contents of <toks register>. (We also do this for
  3118. % the toc entries.)
  3119. \toks0 = {#1}\message{(\the\toks0)}%
  3120. %
  3121. \unnumbchapmacro {#1}%
  3122. \gdef\thischapter{#1}\gdef\thissection{#1}%
  3123. \toks0 = {#1}%
  3124. \edef\temp{\noexpand\writetocentry{\realbackslash unnumbchapentry{\the\toks0}}}%
  3125. \temp
  3126. \unnumbnoderef
  3127. \global\let\section = \unnumberedsec
  3128. \global\let\subsection = \unnumberedsubsec
  3129. \global\let\subsubsection = \unnumberedsubsubsec
  3130. }
  3131. % Sections.
  3132. \outer\def\numberedsec{\parsearg\secyyy}
  3133. \def\secyyy #1{\numhead1{#1}} % normally calls seczzz
  3134. \def\seczzz #1{%
  3135. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  3136. \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
  3137. \toks0 = {#1}%
  3138. \edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
  3139. {\the\chapno}{\the\secno}}}%
  3140. \temp
  3141. \donoderef
  3142. \nobreak
  3143. }
  3144. \outer\def\appendixsection{\parsearg\appendixsecyyy}
  3145. \outer\def\appendixsec{\parsearg\appendixsecyyy}
  3146. \def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
  3147. \def\appendixsectionzzz #1{%
  3148. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  3149. \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
  3150. \toks0 = {#1}%
  3151. \edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
  3152. {\appendixletter}{\the\secno}}}%
  3153. \temp
  3154. \appendixnoderef
  3155. \nobreak
  3156. }
  3157. \outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
  3158. \def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
  3159. \def\unnumberedseczzz #1{%
  3160. \plainsecheading {#1}\gdef\thissection{#1}%
  3161. \toks0 = {#1}%
  3162. \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsecentry{\the\toks0}}}%
  3163. \temp
  3164. \unnumbnoderef
  3165. \nobreak
  3166. }
  3167. % Subsections.
  3168. \outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
  3169. \def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
  3170. \def\numberedsubseczzz #1{%
  3171. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  3172. \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
  3173. \toks0 = {#1}%
  3174. \edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
  3175. {\the\chapno}{\the\secno}{\the\subsecno}}}%
  3176. \temp
  3177. \donoderef
  3178. \nobreak
  3179. }
  3180. \outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
  3181. \def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
  3182. \def\appendixsubseczzz #1{%
  3183. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  3184. \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
  3185. \toks0 = {#1}%
  3186. \edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
  3187. {\appendixletter}{\the\secno}{\the\subsecno}}}%
  3188. \temp
  3189. \appendixnoderef
  3190. \nobreak
  3191. }
  3192. \outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
  3193. \def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
  3194. \def\unnumberedsubseczzz #1{%
  3195. \plainsubsecheading {#1}\gdef\thissection{#1}%
  3196. \toks0 = {#1}%
  3197. \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsecentry%
  3198. {\the\toks0}}}%
  3199. \temp
  3200. \unnumbnoderef
  3201. \nobreak
  3202. }
  3203. % Subsubsections.
  3204. \outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
  3205. \def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
  3206. \def\numberedsubsubseczzz #1{%
  3207. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  3208. \subsubsecheading {#1}
  3209. {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  3210. \toks0 = {#1}%
  3211. \edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
  3212. {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
  3213. \temp
  3214. \donoderef
  3215. \nobreak
  3216. }
  3217. \outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
  3218. \def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
  3219. \def\appendixsubsubseczzz #1{%
  3220. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  3221. \subsubsecheading {#1}
  3222. {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  3223. \toks0 = {#1}%
  3224. \edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
  3225. {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
  3226. \temp
  3227. \appendixnoderef
  3228. \nobreak
  3229. }
  3230. \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
  3231. \def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
  3232. \def\unnumberedsubsubseczzz #1{%
  3233. \plainsubsubsecheading {#1}\gdef\thissection{#1}%
  3234. \toks0 = {#1}%
  3235. \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsubsecentry%
  3236. {\the\toks0}}}%
  3237. \temp
  3238. \unnumbnoderef
  3239. \nobreak
  3240. }
  3241. % These are variants which are not "outer", so they can appear in @ifinfo.
  3242. % Actually, they should now be obsolete; ordinary section commands should work.
  3243. \def\infotop{\parsearg\unnumberedzzz}
  3244. \def\infounnumbered{\parsearg\unnumberedzzz}
  3245. \def\infounnumberedsec{\parsearg\unnumberedseczzz}
  3246. \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
  3247. \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  3248. \def\infoappendix{\parsearg\appendixzzz}
  3249. \def\infoappendixsec{\parsearg\appendixseczzz}
  3250. \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
  3251. \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
  3252. \def\infochapter{\parsearg\chapterzzz}
  3253. \def\infosection{\parsearg\sectionzzz}
  3254. \def\infosubsection{\parsearg\subsectionzzz}
  3255. \def\infosubsubsection{\parsearg\subsubsectionzzz}
  3256. % These macros control what the section commands do, according
  3257. % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
  3258. % Define them by default for a numbered chapter.
  3259. \global\let\section = \numberedsec
  3260. \global\let\subsection = \numberedsubsec
  3261. \global\let\subsubsection = \numberedsubsubsec
  3262. % Define @majorheading, @heading and @subheading
  3263. % NOTE on use of \vbox for chapter headings, section headings, and such:
  3264. % 1) We use \vbox rather than the earlier \line to permit
  3265. % overlong headings to fold.
  3266. % 2) \hyphenpenalty is set to 10000 because hyphenation in a
  3267. % heading is obnoxious; this forbids it.
  3268. % 3) Likewise, headings look best if no \parindent is used, and
  3269. % if justification is not attempted. Hence \raggedright.
  3270. \def\majorheading{\parsearg\majorheadingzzz}
  3271. \def\majorheadingzzz #1{%
  3272. {\advance\chapheadingskip by 10pt \chapbreak }%
  3273. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  3274. \parindent=0pt\raggedright
  3275. \rm #1\hfill}}\bigskip \par\penalty 200}
  3276. \def\chapheading{\parsearg\chapheadingzzz}
  3277. \def\chapheadingzzz #1{\chapbreak %
  3278. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  3279. \parindent=0pt\raggedright
  3280. \rm #1\hfill}}\bigskip \par\penalty 200}
  3281. % @heading, @subheading, @subsubheading.
  3282. \def\heading{\parsearg\plainsecheading}
  3283. \def\subheading{\parsearg\plainsubsecheading}
  3284. \def\subsubheading{\parsearg\plainsubsubsecheading}
  3285. % These macros generate a chapter, section, etc. heading only
  3286. % (including whitespace, linebreaking, etc. around it),
  3287. % given all the information in convenient, parsed form.
  3288. %%% Args are the skip and penalty (usually negative)
  3289. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  3290. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  3291. %%% Define plain chapter starts, and page on/off switching for it
  3292. % Parameter controlling skip before chapter headings (if needed)
  3293. \newskip\chapheadingskip
  3294. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  3295. \def\chappager{\par\vfill\supereject}
  3296. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  3297. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  3298. \def\CHAPPAGoff{%
  3299. \global\let\contentsalignmacro = \chappager
  3300. \global\let\pchapsepmacro=\chapbreak
  3301. \global\let\pagealignmacro=\chappager}
  3302. \def\CHAPPAGon{%
  3303. \global\let\contentsalignmacro = \chappager
  3304. \global\let\pchapsepmacro=\chappager
  3305. \global\let\pagealignmacro=\chappager
  3306. \global\def\HEADINGSon{\HEADINGSsingle}}
  3307. \def\CHAPPAGodd{
  3308. \global\let\contentsalignmacro = \chapoddpage
  3309. \global\let\pchapsepmacro=\chapoddpage
  3310. \global\let\pagealignmacro=\chapoddpage
  3311. \global\def\HEADINGSon{\HEADINGSdouble}}
  3312. \CHAPPAGon
  3313. \def\CHAPFplain{
  3314. \global\let\chapmacro=\chfplain
  3315. \global\let\unnumbchapmacro=\unnchfplain
  3316. \global\let\centerchapmacro=\centerchfplain}
  3317. % Plain chapter opening.
  3318. % #1 is the text, #2 the chapter number or empty if unnumbered.
  3319. \def\chfplain#1#2{%
  3320. \pchapsepmacro
  3321. {%
  3322. \chapfonts \rm
  3323. \def\chapnum{#2}%
  3324. \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}%
  3325. \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
  3326. \hangindent = \wd0 \centerparametersmaybe
  3327. \unhbox0 #1\par}%
  3328. }%
  3329. \nobreak\bigskip % no page break after a chapter title
  3330. \nobreak
  3331. }
  3332. % Plain opening for unnumbered.
  3333. \def\unnchfplain#1{\chfplain{#1}{}}
  3334. % @centerchap -- centered and unnumbered.
  3335. \let\centerparametersmaybe = \relax
  3336. \def\centerchfplain#1{{%
  3337. \def\centerparametersmaybe{%
  3338. \advance\rightskip by 3\rightskip
  3339. \leftskip = \rightskip
  3340. \parfillskip = 0pt
  3341. }%
  3342. \chfplain{#1}{}%
  3343. }}
  3344. \CHAPFplain % The default
  3345. \def\unnchfopen #1{%
  3346. \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  3347. \parindent=0pt\raggedright
  3348. \rm #1\hfill}}\bigskip \par\nobreak
  3349. }
  3350. \def\chfopen #1#2{\chapoddpage {\chapfonts
  3351. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  3352. \par\penalty 5000 %
  3353. }
  3354. \def\centerchfopen #1{%
  3355. \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  3356. \parindent=0pt
  3357. \hfill {\rm #1}\hfill}}\bigskip \par\nobreak
  3358. }
  3359. \def\CHAPFopen{
  3360. \global\let\chapmacro=\chfopen
  3361. \global\let\unnumbchapmacro=\unnchfopen
  3362. \global\let\centerchapmacro=\centerchfopen}
  3363. % Section titles.
  3364. \newskip\secheadingskip
  3365. \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
  3366. \def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}}
  3367. \def\plainsecheading#1{\sectionheading{sec}{}{#1}}
  3368. % Subsection titles.
  3369. \newskip \subsecheadingskip
  3370. \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
  3371. \def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}}
  3372. \def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}}
  3373. % Subsubsection titles.
  3374. \let\subsubsecheadingskip = \subsecheadingskip
  3375. \let\subsubsecheadingbreak = \subsecheadingbreak
  3376. \def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}}
  3377. \def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}}
  3378. % Print any size section title.
  3379. %
  3380. % #1 is the section type (sec/subsec/subsubsec), #2 is the section
  3381. % number (maybe empty), #3 the text.
  3382. \def\sectionheading#1#2#3{%
  3383. {%
  3384. \expandafter\advance\csname #1headingskip\endcsname by \parskip
  3385. \csname #1headingbreak\endcsname
  3386. }%
  3387. {%
  3388. % Switch to the right set of fonts.
  3389. \csname #1fonts\endcsname \rm
  3390. %
  3391. % Only insert the separating space if we have a section number.
  3392. \def\secnum{#2}%
  3393. \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}%
  3394. %
  3395. \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
  3396. \hangindent = \wd0 % zero if no section number
  3397. \unhbox0 #3}%
  3398. }%
  3399. \ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak
  3400. }
  3401. \message{toc,}
  3402. % Table of contents.
  3403. \newwrite\tocfile
  3404. % Write an entry to the toc file, opening it if necessary.
  3405. % Called from @chapter, etc. We supply {\folio} at the end of the
  3406. % argument, which will end up as the last argument to the \...entry macro.
  3407. %
  3408. % We open the .toc file here instead of at @setfilename or any other
  3409. % given time so that @contents can be put in the document anywhere.
  3410. %
  3411. \newif\iftocfileopened
  3412. \def\writetocentry#1{%
  3413. \iftocfileopened\else
  3414. \immediate\openout\tocfile = \jobname.toc
  3415. \global\tocfileopenedtrue
  3416. \fi
  3417. \iflinks \write\tocfile{#1{\folio}}\fi
  3418. }
  3419. \newskip\contentsrightmargin \contentsrightmargin=1in
  3420. \newcount\savepageno
  3421. \newcount\lastnegativepageno \lastnegativepageno = -1
  3422. % Finish up the main text and prepare to read what we've written
  3423. % to \tocfile.
  3424. %
  3425. \def\startcontents#1{%
  3426. % If @setchapternewpage on, and @headings double, the contents should
  3427. % start on an odd page, unlike chapters. Thus, we maintain
  3428. % \contentsalignmacro in parallel with \pagealignmacro.
  3429. % From: Torbjorn Granlund <tege@matematik.su.se>
  3430. \contentsalignmacro
  3431. \immediate\closeout\tocfile
  3432. %
  3433. % Don't need to put `Contents' or `Short Contents' in the headline.
  3434. % It is abundantly clear what they are.
  3435. \unnumbchapmacro{#1}\def\thischapter{}%
  3436. \savepageno = \pageno
  3437. \begingroup % Set up to handle contents files properly.
  3438. \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11
  3439. % We can't do this, because then an actual ^ in a section
  3440. % title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97.
  3441. %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi
  3442. \raggedbottom % Worry more about breakpoints than the bottom.
  3443. \advance\hsize by -\contentsrightmargin % Don't use the full line length.
  3444. %
  3445. % Roman numerals for page numbers.
  3446. \ifnum \pageno>0 \pageno = \lastnegativepageno \fi
  3447. }
  3448. % Normal (long) toc.
  3449. \def\contents{%
  3450. \startcontents{\putwordTOC}%
  3451. \openin 1 \jobname.toc
  3452. \ifeof 1 \else
  3453. \closein 1
  3454. \input \jobname.toc
  3455. \fi
  3456. \vfill \eject
  3457. \contentsalignmacro % in case @setchapternewpage odd is in effect
  3458. \pdfmakeoutlines
  3459. \endgroup
  3460. \lastnegativepageno = \pageno
  3461. \pageno = \savepageno
  3462. }
  3463. % And just the chapters.
  3464. \def\summarycontents{%
  3465. \startcontents{\putwordShortTOC}%
  3466. %
  3467. \let\chapentry = \shortchapentry
  3468. \let\unnumbchapentry = \shortunnumberedentry
  3469. % We want a true roman here for the page numbers.
  3470. \secfonts
  3471. \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
  3472. \rm
  3473. \hyphenpenalty = 10000
  3474. \advance\baselineskip by 1pt % Open it up a little.
  3475. \def\secentry ##1##2##3##4{}
  3476. \def\unnumbsecentry ##1##2{}
  3477. \def\subsecentry ##1##2##3##4##5{}
  3478. \def\unnumbsubsecentry ##1##2{}
  3479. \def\subsubsecentry ##1##2##3##4##5##6{}
  3480. \def\unnumbsubsubsecentry ##1##2{}
  3481. \openin 1 \jobname.toc
  3482. \ifeof 1 \else
  3483. \closein 1
  3484. \input \jobname.toc
  3485. \fi
  3486. \vfill \eject
  3487. \contentsalignmacro % in case @setchapternewpage odd is in effect
  3488. \endgroup
  3489. \lastnegativepageno = \pageno
  3490. \pageno = \savepageno
  3491. }
  3492. \let\shortcontents = \summarycontents
  3493. \ifpdf
  3494. \pdfcatalog{/PageMode /UseOutlines}%
  3495. \fi
  3496. % These macros generate individual entries in the table of contents.
  3497. % The first argument is the chapter or section name.
  3498. % The last argument is the page number.
  3499. % The arguments in between are the chapter number, section number, ...
  3500. % Chapter-level things, for both the long and short contents.
  3501. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
  3502. % See comments in \dochapentry re vbox and related settings
  3503. \def\shortchapentry#1#2#3{%
  3504. \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#3\egroup}%
  3505. }
  3506. % Typeset the label for a chapter or appendix for the short contents.
  3507. % The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
  3508. % We could simplify the code here by writing out an \appendixentry
  3509. % command in the toc file for appendices, instead of using \chapentry
  3510. % for both, but it doesn't seem worth it.
  3511. %
  3512. \newdimen\shortappendixwidth
  3513. %
  3514. \def\shortchaplabel#1{%
  3515. % Compute width of word "Appendix", may change with language.
  3516. \setbox0 = \hbox{\shortcontrm \putwordAppendix}%
  3517. \shortappendixwidth = \wd0
  3518. %
  3519. % We typeset #1 in a box of constant width, regardless of the text of
  3520. % #1, so the chapter titles will come out aligned.
  3521. \setbox0 = \hbox{#1}%
  3522. \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
  3523. %
  3524. % This space should be plenty, since a single number is .5em, and the
  3525. % widest letter (M) is 1em, at least in the Computer Modern fonts.
  3526. % (This space doesn't include the extra space that gets added after
  3527. % the label; that gets put in by \shortchapentry above.)
  3528. \advance\dimen0 by 1.1em
  3529. \hbox to \dimen0{#1\hfil}%
  3530. }
  3531. \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
  3532. \def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno\bgroup#2\egroup}}
  3533. % Sections.
  3534. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
  3535. \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
  3536. % Subsections.
  3537. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
  3538. \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
  3539. % And subsubsections.
  3540. \def\subsubsecentry#1#2#3#4#5#6{%
  3541. \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
  3542. \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
  3543. % This parameter controls the indentation of the various levels.
  3544. \newdimen\tocindent \tocindent = 3pc
  3545. % Now for the actual typesetting. In all these, #1 is the text and #2 is the
  3546. % page number.
  3547. %
  3548. % If the toc has to be broken over pages, we want it to be at chapters
  3549. % if at all possible; hence the \penalty.
  3550. \def\dochapentry#1#2{%
  3551. \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
  3552. \begingroup
  3553. \chapentryfonts
  3554. \tocentry{#1}{\dopageno\bgroup#2\egroup}%
  3555. \endgroup
  3556. \nobreak\vskip .25\baselineskip plus.1\baselineskip
  3557. }
  3558. \def\dosecentry#1#2{\begingroup
  3559. \secentryfonts \leftskip=\tocindent
  3560. \tocentry{#1}{\dopageno\bgroup#2\egroup}%
  3561. \endgroup}
  3562. \def\dosubsecentry#1#2{\begingroup
  3563. \subsecentryfonts \leftskip=2\tocindent
  3564. \tocentry{#1}{\dopageno\bgroup#2\egroup}%
  3565. \endgroup}
  3566. \def\dosubsubsecentry#1#2{\begingroup
  3567. \subsubsecentryfonts \leftskip=3\tocindent
  3568. \tocentry{#1}{\dopageno\bgroup#2\egroup}%
  3569. \endgroup}
  3570. % Final typesetting of a toc entry; we use the same \entry macro as for
  3571. % the index entries, but we want to suppress hyphenation here. (We
  3572. % can't do that in the \entry macro, since index entries might consist
  3573. % of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
  3574. \def\tocentry#1#2{\begingroup
  3575. \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks
  3576. % Do not use \turnoffactive in these arguments. Since the toc is
  3577. % typeset in cmr, so characters such as _ would come out wrong; we
  3578. % have to do the usual translation tricks.
  3579. \entry{#1}{#2}%
  3580. \endgroup}
  3581. % Space between chapter (or whatever) number and the title.
  3582. \def\labelspace{\hskip1em \relax}
  3583. \def\dopageno#1{{\rm #1}}
  3584. \def\doshortpageno#1{{\rm #1}}
  3585. \def\chapentryfonts{\secfonts \rm}
  3586. \def\secentryfonts{\textfonts}
  3587. \let\subsecentryfonts = \textfonts
  3588. \let\subsubsecentryfonts = \textfonts
  3589. \message{environments,}
  3590. % @foo ... @end foo.
  3591. % Since these characters are used in examples, it should be an even number of
  3592. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  3593. % Furthermore, these definitions must come after we define our fonts.
  3594. \newbox\dblarrowbox \newbox\longdblarrowbox
  3595. \newbox\pushcharbox \newbox\bullbox
  3596. \newbox\equivbox \newbox\errorbox
  3597. %{\tentt
  3598. %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
  3599. %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
  3600. %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
  3601. %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
  3602. % Adapted from the manmac format (p.420 of TeXbook)
  3603. %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
  3604. % depth .1ex\hfil}
  3605. %}
  3606. % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
  3607. \def\point{$\star$}
  3608. \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
  3609. \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
  3610. \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
  3611. \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
  3612. % Adapted from the TeXbook's \boxit.
  3613. {\tentt \global\dimen0 = 3em}% Width of the box.
  3614. \dimen2 = .55pt % Thickness of rules
  3615. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  3616. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  3617. \global\setbox\errorbox=\hbox to \dimen0{\hfil
  3618. \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  3619. \advance\hsize by -2\dimen2 % Rules.
  3620. \vbox{
  3621. \hrule height\dimen2
  3622. \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
  3623. \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  3624. \kern3pt\vrule width\dimen2}% Space to right.
  3625. \hrule height\dimen2}
  3626. \hfil}
  3627. % The @error{} command.
  3628. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  3629. % @tex ... @end tex escapes into raw Tex temporarily.
  3630. % One exception: @ is still an escape character, so that @end tex works.
  3631. % But \@ or @@ will get a plain tex @ character.
  3632. \def\tex{\begingroup
  3633. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  3634. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  3635. \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
  3636. \catcode `\%=14
  3637. \catcode 43=12 % plus
  3638. \catcode`\"=12
  3639. \catcode`\==12
  3640. \catcode`\|=12
  3641. \catcode`\<=12
  3642. \catcode`\>=12
  3643. \escapechar=`\\
  3644. %
  3645. \let\b=\ptexb
  3646. \let\bullet=\ptexbullet
  3647. \let\c=\ptexc
  3648. \let\,=\ptexcomma
  3649. \let\.=\ptexdot
  3650. \let\dots=\ptexdots
  3651. \let\equiv=\ptexequiv
  3652. \let\!=\ptexexclam
  3653. \let\i=\ptexi
  3654. \let\{=\ptexlbrace
  3655. \let\+=\tabalign
  3656. \let\}=\ptexrbrace
  3657. \let\*=\ptexstar
  3658. \let\t=\ptext
  3659. %
  3660. \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
  3661. \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
  3662. \def\@{@}%
  3663. \let\Etex=\endgroup}
  3664. % Define @lisp ... @endlisp.
  3665. % @lisp does a \begingroup so it can rebind things,
  3666. % including the definition of @endlisp (which normally is erroneous).
  3667. % Amount to narrow the margins by for @lisp.
  3668. \newskip\lispnarrowing \lispnarrowing=0.4in
  3669. % This is the definition that ^^M gets inside @lisp, @example, and other
  3670. % such environments. \null is better than a space, since it doesn't
  3671. % have any width.
  3672. \def\lisppar{\null\endgraf}
  3673. % Make each space character in the input produce a normal interword
  3674. % space in the output. Don't allow a line break at this space, as this
  3675. % is used only in environments like @example, where each line of input
  3676. % should produce a line of output anyway.
  3677. %
  3678. {\obeyspaces %
  3679. \gdef\sepspaces{\obeyspaces\let =\tie}}
  3680. % Define \obeyedspace to be our active space, whatever it is. This is
  3681. % for use in \parsearg.
  3682. {\sepspaces%
  3683. \global\let\obeyedspace= }
  3684. % This space is always present above and below environments.
  3685. \newskip\envskipamount \envskipamount = 0pt
  3686. % Make spacing and below environment symmetrical. We use \parskip here
  3687. % to help in doing that, since in @example-like environments \parskip
  3688. % is reset to zero; thus the \afterenvbreak inserts no space -- but the
  3689. % start of the next paragraph will insert \parskip
  3690. %
  3691. \def\aboveenvbreak{{\advance\envskipamount by \parskip
  3692. \endgraf \ifdim\lastskip<\envskipamount
  3693. \removelastskip \penalty-50 \vskip\envskipamount \fi}}
  3694. \let\afterenvbreak = \aboveenvbreak
  3695. % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins.
  3696. \let\nonarrowing=\relax
  3697. % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
  3698. % environment contents.
  3699. \font\circle=lcircle10
  3700. \newdimen\circthick
  3701. \newdimen\cartouter\newdimen\cartinner
  3702. \newskip\normbskip\newskip\normpskip\newskip\normlskip
  3703. \circthick=\fontdimen8\circle
  3704. %
  3705. \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
  3706. \def\ctr{{\hskip 6pt\circle\char'010}}
  3707. \def\cbl{{\circle\char'012\hskip -6pt}}
  3708. \def\cbr{{\hskip 6pt\circle\char'011}}
  3709. \def\carttop{\hbox to \cartouter{\hskip\lskip
  3710. \ctl\leaders\hrule height\circthick\hfil\ctr
  3711. \hskip\rskip}}
  3712. \def\cartbot{\hbox to \cartouter{\hskip\lskip
  3713. \cbl\leaders\hrule height\circthick\hfil\cbr
  3714. \hskip\rskip}}
  3715. %
  3716. \newskip\lskip\newskip\rskip
  3717. \long\def\cartouche{%
  3718. \begingroup
  3719. \lskip=\leftskip \rskip=\rightskip
  3720. \leftskip=0pt\rightskip=0pt %we want these *outside*.
  3721. \cartinner=\hsize \advance\cartinner by-\lskip
  3722. \advance\cartinner by-\rskip
  3723. \cartouter=\hsize
  3724. \advance\cartouter by 18.4pt % allow for 3pt kerns on either
  3725. % side, and for 6pt waste from
  3726. % each corner char, and rule thickness
  3727. \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
  3728. % Flag to tell @lisp, etc., not to narrow margin.
  3729. \let\nonarrowing=\comment
  3730. \vbox\bgroup
  3731. \baselineskip=0pt\parskip=0pt\lineskip=0pt
  3732. \carttop
  3733. \hbox\bgroup
  3734. \hskip\lskip
  3735. \vrule\kern3pt
  3736. \vbox\bgroup
  3737. \hsize=\cartinner
  3738. \kern3pt
  3739. \begingroup
  3740. \baselineskip=\normbskip
  3741. \lineskip=\normlskip
  3742. \parskip=\normpskip
  3743. \vskip -\parskip
  3744. \def\Ecartouche{%
  3745. \endgroup
  3746. \kern3pt
  3747. \egroup
  3748. \kern3pt\vrule
  3749. \hskip\rskip
  3750. \egroup
  3751. \cartbot
  3752. \egroup
  3753. \endgroup
  3754. }}
  3755. % This macro is called at the beginning of all the @example variants,
  3756. % inside a group.
  3757. \def\nonfillstart{%
  3758. \aboveenvbreak
  3759. \inENV % This group ends at the end of the body
  3760. \hfuzz = 12pt % Don't be fussy
  3761. \sepspaces % Make spaces be word-separators rather than space tokens.
  3762. \singlespace
  3763. \let\par = \lisppar % don't ignore blank lines
  3764. \obeylines % each line of input is a line of output
  3765. \parskip = 0pt
  3766. \parindent = 0pt
  3767. \emergencystretch = 0pt % don't try to avoid overfull boxes
  3768. % @cartouche defines \nonarrowing to inhibit narrowing
  3769. % at next level down.
  3770. \ifx\nonarrowing\relax
  3771. \advance \leftskip by \lispnarrowing
  3772. \exdentamount=\lispnarrowing
  3773. \let\exdent=\nofillexdent
  3774. \let\nonarrowing=\relax
  3775. \fi
  3776. }
  3777. % Define the \E... control sequence only if we are inside the particular
  3778. % environment, so the error checking in \end will work.
  3779. %
  3780. % To end an @example-like environment, we first end the paragraph (via
  3781. % \afterenvbreak's vertical glue), and then the group. That way we keep
  3782. % the zero \parskip that the environments set -- \parskip glue will be
  3783. % inserted at the beginning of the next paragraph in the document, after
  3784. % the environment.
  3785. %
  3786. \def\nonfillfinish{\afterenvbreak\endgroup}
  3787. % @lisp: indented, narrowed, typewriter font.
  3788. \def\lisp{\begingroup
  3789. \nonfillstart
  3790. \let\Elisp = \nonfillfinish
  3791. \tt
  3792. \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
  3793. \gobble % eat return
  3794. }
  3795. % @example: Same as @lisp.
  3796. \def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp}
  3797. % @small... is usually equivalent to the non-small (@smallbook
  3798. % redefines). We must call \example (or whatever) last in the
  3799. % definition, since it reads the return following the @example (or
  3800. % whatever) command.
  3801. %
  3802. % This actually allows (for example) @end display inside an
  3803. % @smalldisplay. Too bad, but makeinfo will catch the error anyway.
  3804. %
  3805. \def\smalldisplay{\begingroup\def\Esmalldisplay{\nonfillfinish\endgroup}\display}
  3806. \def\smallexample{\begingroup\def\Esmallexample{\nonfillfinish\endgroup}\lisp}
  3807. \def\smallformat{\begingroup\def\Esmallformat{\nonfillfinish\endgroup}\format}
  3808. \def\smalllisp{\begingroup\def\Esmalllisp{\nonfillfinish\endgroup}\lisp}
  3809. % Real @smallexample and @smalllisp (when @smallbook): use smaller fonts.
  3810. % Originally contributed by Pavel@xerox.
  3811. \def\smalllispx{\begingroup
  3812. \def\Esmalllisp{\nonfillfinish\endgroup}%
  3813. \def\Esmallexample{\nonfillfinish\endgroup}%
  3814. \smallfonts
  3815. \lisp
  3816. }
  3817. % @display: same as @lisp except keep current font.
  3818. %
  3819. \def\display{\begingroup
  3820. \nonfillstart
  3821. \let\Edisplay = \nonfillfinish
  3822. \gobble
  3823. }
  3824. % @smalldisplay (when @smallbook): @display plus smaller fonts.
  3825. %
  3826. \def\smalldisplayx{\begingroup
  3827. \def\Esmalldisplay{\nonfillfinish\endgroup}%
  3828. \smallfonts \rm
  3829. \display
  3830. }
  3831. % @format: same as @display except don't narrow margins.
  3832. %
  3833. \def\format{\begingroup
  3834. \let\nonarrowing = t
  3835. \nonfillstart
  3836. \let\Eformat = \nonfillfinish
  3837. \gobble
  3838. }
  3839. % @smallformat (when @smallbook): @format plus smaller fonts.
  3840. %
  3841. \def\smallformatx{\begingroup
  3842. \def\Esmallformat{\nonfillfinish\endgroup}%
  3843. \smallfonts \rm
  3844. \format
  3845. }
  3846. % @flushleft (same as @format).
  3847. %
  3848. \def\flushleft{\begingroup \def\Eflushleft{\nonfillfinish\endgroup}\format}
  3849. % @flushright.
  3850. %
  3851. \def\flushright{\begingroup
  3852. \let\nonarrowing = t
  3853. \nonfillstart
  3854. \let\Eflushright = \nonfillfinish
  3855. \advance\leftskip by 0pt plus 1fill
  3856. \gobble
  3857. }
  3858. % @quotation does normal linebreaking (hence we can't use \nonfillstart)
  3859. % and narrows the margins.
  3860. %
  3861. \def\quotation{%
  3862. \begingroup\inENV %This group ends at the end of the @quotation body
  3863. {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
  3864. \singlespace
  3865. \parindent=0pt
  3866. % We have retained a nonzero parskip for the environment, since we're
  3867. % doing normal filling. So to avoid extra space below the environment...
  3868. \def\Equotation{\parskip = 0pt \nonfillfinish}%
  3869. %
  3870. % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
  3871. \ifx\nonarrowing\relax
  3872. \advance\leftskip by \lispnarrowing
  3873. \advance\rightskip by \lispnarrowing
  3874. \exdentamount = \lispnarrowing
  3875. \let\nonarrowing = \relax
  3876. \fi
  3877. }
  3878. \message{defuns,}
  3879. % @defun etc.
  3880. % Allow user to change definition object font (\df) internally
  3881. \def\setdeffont #1 {\csname DEF#1\endcsname}
  3882. \newskip\defbodyindent \defbodyindent=.4in
  3883. \newskip\defargsindent \defargsindent=50pt
  3884. \newskip\deftypemargin \deftypemargin=12pt
  3885. \newskip\deflastargmargin \deflastargmargin=18pt
  3886. \newcount\parencount
  3887. % define \functionparens, which makes ( and ) and & do special things.
  3888. % \functionparens affects the group it is contained in.
  3889. \def\activeparens{%
  3890. \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
  3891. \catcode`\[=\active \catcode`\]=\active}
  3892. % Make control sequences which act like normal parenthesis chars.
  3893. \let\lparen = ( \let\rparen = )
  3894. {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
  3895. % Be sure that we always have a definition for `(', etc. For example,
  3896. % if the fn name has parens in it, \boldbrax will not be in effect yet,
  3897. % so TeX would otherwise complain about undefined control sequence.
  3898. \global\let(=\lparen \global\let)=\rparen
  3899. \global\let[=\lbrack \global\let]=\rbrack
  3900. \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
  3901. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  3902. % This is used to turn on special parens
  3903. % but make & act ordinary (given that it's active).
  3904. \gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr}
  3905. % Definitions of (, ) and & used in args for functions.
  3906. % This is the definition of ( outside of all parentheses.
  3907. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested
  3908. \global\advance\parencount by 1
  3909. }
  3910. %
  3911. % This is the definition of ( when already inside a level of parens.
  3912. \gdef\opnested{\char`\(\global\advance\parencount by 1 }
  3913. %
  3914. \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
  3915. % also in that case restore the outer-level definition of (.
  3916. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
  3917. \global\advance \parencount by -1 }
  3918. % If we encounter &foo, then turn on ()-hacking afterwards
  3919. \gdef\amprm#1 {{\rm\&#1}\let(=\oprm \let)=\clrm\ }
  3920. %
  3921. \gdef\normalparens{\boldbrax\let&=\ampnr}
  3922. } % End of definition inside \activeparens
  3923. %% These parens (in \boldbrax) actually are a little bolder than the
  3924. %% contained text. This is especially needed for [ and ]
  3925. \def\opnr{{\sf\char`\(}\global\advance\parencount by 1 }
  3926. \def\clnr{{\sf\char`\)}\global\advance\parencount by -1 }
  3927. \let\ampnr = \&
  3928. \def\lbrb{{\bf\char`\[}}
  3929. \def\rbrb{{\bf\char`\]}}
  3930. % Active &'s sneak into the index arguments, so make sure it's defined.
  3931. {
  3932. \catcode`& = 13
  3933. \global\let& = \ampnr
  3934. }
  3935. % First, defname, which formats the header line itself.
  3936. % #1 should be the function name.
  3937. % #2 should be the type of definition, such as "Function".
  3938. \def\defname #1#2{%
  3939. % Get the values of \leftskip and \rightskip as they were
  3940. % outside the @def...
  3941. \dimen2=\leftskip
  3942. \advance\dimen2 by -\defbodyindent
  3943. \noindent
  3944. \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
  3945. \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
  3946. \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
  3947. \parshape 2 0in \dimen0 \defargsindent \dimen1
  3948. % Now output arg 2 ("Function" or some such)
  3949. % ending at \deftypemargin from the right margin,
  3950. % but stuck inside a box of width 0 so it does not interfere with linebreaking
  3951. {% Adjust \hsize to exclude the ambient margins,
  3952. % so that \rightline will obey them.
  3953. \advance \hsize by -\dimen2
  3954. \rlap{\rightline{{\rm #2}\hskip -1.25pc }}}%
  3955. % Make all lines underfull and no complaints:
  3956. \tolerance=10000 \hbadness=10000
  3957. \advance\leftskip by -\defbodyindent
  3958. \exdentamount=\defbodyindent
  3959. {\df #1}\enskip % Generate function name
  3960. }
  3961. % Actually process the body of a definition
  3962. % #1 should be the terminating control sequence, such as \Edefun.
  3963. % #2 should be the "another name" control sequence, such as \defunx.
  3964. % #3 should be the control sequence that actually processes the header,
  3965. % such as \defunheader.
  3966. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  3967. \medbreak %
  3968. % Define the end token that this defining construct specifies
  3969. % so that it will exit this group.
  3970. \def#1{\endgraf\endgroup\medbreak}%
  3971. \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
  3972. \parindent=0in
  3973. \advance\leftskip by \defbodyindent
  3974. \exdentamount=\defbodyindent
  3975. \begingroup %
  3976. \catcode 61=\active % 61 is `='
  3977. \obeylines\activeparens\spacesplit#3}
  3978. % #1 is the \E... control sequence to end the definition (which we define).
  3979. % #2 is the \...x control sequence for consecutive fns (which we define).
  3980. % #3 is the control sequence to call to resume processing.
  3981. % #4, delimited by the space, is the class name.
  3982. %
  3983. \def\defmethparsebody#1#2#3#4 {\begingroup\inENV %
  3984. \medbreak %
  3985. % Define the end token that this defining construct specifies
  3986. % so that it will exit this group.
  3987. \def#1{\endgraf\endgroup\medbreak}%
  3988. \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
  3989. \parindent=0in
  3990. \advance\leftskip by \defbodyindent
  3991. \exdentamount=\defbodyindent
  3992. \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
  3993. % Used for @deftypemethod and @deftypeivar.
  3994. % #1 is the \E... control sequence to end the definition (which we define).
  3995. % #2 is the \...x control sequence for consecutive fns (which we define).
  3996. % #3 is the control sequence to call to resume processing.
  3997. % #4, delimited by a space, is the class name.
  3998. % #5 is the method's return type.
  3999. %
  4000. \def\deftypemethparsebody#1#2#3#4 #5 {\begingroup\inENV
  4001. \medbreak
  4002. \def#1{\endgraf\endgroup\medbreak}%
  4003. \def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}%
  4004. \parindent=0in
  4005. \advance\leftskip by \defbodyindent
  4006. \exdentamount=\defbodyindent
  4007. \begingroup\obeylines\activeparens\spacesplit{#3{#4}{#5}}}
  4008. % Used for @deftypeop. The change from \deftypemethparsebody is an
  4009. % extra argument at the beginning which is the `category', instead of it
  4010. % being the hardwired string `Method' or `Instance Variable'. We have
  4011. % to account for this both in the \...x definition and in parsing the
  4012. % input at hand. Thus also need a control sequence (passed as #5) for
  4013. % the \E... definition to assign the category name to.
  4014. %
  4015. \def\deftypeopparsebody#1#2#3#4#5 #6 {\begingroup\inENV
  4016. \medbreak
  4017. \def#1{\endgraf\endgroup\medbreak}%
  4018. \def#2##1 ##2 ##3 {%
  4019. \def#4{##1}%
  4020. \begingroup\obeylines\activeparens\spacesplit{#3{##2}{##3}}}%
  4021. \parindent=0in
  4022. \advance\leftskip by \defbodyindent
  4023. \exdentamount=\defbodyindent
  4024. \begingroup\obeylines\activeparens\spacesplit{#3{#5}{#6}}}
  4025. \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
  4026. \medbreak %
  4027. % Define the end token that this defining construct specifies
  4028. % so that it will exit this group.
  4029. \def#1{\endgraf\endgroup\medbreak}%
  4030. \def#2##1 ##2 {\def#4{##1}%
  4031. \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
  4032. \parindent=0in
  4033. \advance\leftskip by \defbodyindent
  4034. \exdentamount=\defbodyindent
  4035. \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
  4036. % These parsing functions are similar to the preceding ones
  4037. % except that they do not make parens into active characters.
  4038. % These are used for "variables" since they have no arguments.
  4039. \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  4040. \medbreak %
  4041. % Define the end token that this defining construct specifies
  4042. % so that it will exit this group.
  4043. \def#1{\endgraf\endgroup\medbreak}%
  4044. \def#2{\begingroup\obeylines\spacesplit#3}%
  4045. \parindent=0in
  4046. \advance\leftskip by \defbodyindent
  4047. \exdentamount=\defbodyindent
  4048. \begingroup %
  4049. \catcode 61=\active %
  4050. \obeylines\spacesplit#3}
  4051. % This is used for \def{tp,vr}parsebody. It could probably be used for
  4052. % some of the others, too, with some judicious conditionals.
  4053. %
  4054. \def\parsebodycommon#1#2#3{%
  4055. \begingroup\inENV %
  4056. \medbreak %
  4057. % Define the end token that this defining construct specifies
  4058. % so that it will exit this group.
  4059. \def#1{\endgraf\endgroup\medbreak}%
  4060. \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
  4061. \parindent=0in
  4062. \advance\leftskip by \defbodyindent
  4063. \exdentamount=\defbodyindent
  4064. \begingroup\obeylines
  4065. }
  4066. \def\defvrparsebody#1#2#3#4 {%
  4067. \parsebodycommon{#1}{#2}{#3}%
  4068. \spacesplit{#3{#4}}%
  4069. }
  4070. % This loses on `@deftp {Data Type} {struct termios}' -- it thinks the
  4071. % type is just `struct', because we lose the braces in `{struct
  4072. % termios}' when \spacesplit reads its undelimited argument. Sigh.
  4073. % \let\deftpparsebody=\defvrparsebody
  4074. %
  4075. % So, to get around this, we put \empty in with the type name. That
  4076. % way, TeX won't find exactly `{...}' as an undelimited argument, and
  4077. % won't strip off the braces.
  4078. %
  4079. \def\deftpparsebody #1#2#3#4 {%
  4080. \parsebodycommon{#1}{#2}{#3}%
  4081. \spacesplit{\parsetpheaderline{#3{#4}}}\empty
  4082. }
  4083. % Fine, but then we have to eventually remove the \empty *and* the
  4084. % braces (if any). That's what this does.
  4085. %
  4086. \def\removeemptybraces\empty#1\relax{#1}
  4087. % After \spacesplit has done its work, this is called -- #1 is the final
  4088. % thing to call, #2 the type name (which starts with \empty), and #3
  4089. % (which might be empty) the arguments.
  4090. %
  4091. \def\parsetpheaderline#1#2#3{%
  4092. #1{\removeemptybraces#2\relax}{#3}%
  4093. }%
  4094. \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
  4095. \medbreak %
  4096. % Define the end token that this defining construct specifies
  4097. % so that it will exit this group.
  4098. \def#1{\endgraf\endgroup\medbreak}%
  4099. \def#2##1 ##2 {\def#4{##1}%
  4100. \begingroup\obeylines\spacesplit{#3{##2}}}%
  4101. \parindent=0in
  4102. \advance\leftskip by \defbodyindent
  4103. \exdentamount=\defbodyindent
  4104. \begingroup\obeylines\spacesplit{#3{#5}}}
  4105. % Split up #2 at the first space token.
  4106. % call #1 with two arguments:
  4107. % the first is all of #2 before the space token,
  4108. % the second is all of #2 after that space token.
  4109. % If #2 contains no space token, all of it is passed as the first arg
  4110. % and the second is passed as empty.
  4111. {\obeylines
  4112. \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
  4113. \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
  4114. \ifx\relax #3%
  4115. #1{#2}{}\else #1{#2}{#3#4}\fi}}
  4116. % So much for the things common to all kinds of definitions.
  4117. % Define @defun.
  4118. % First, define the processing that is wanted for arguments of \defun
  4119. % Use this to expand the args and terminate the paragraph they make up
  4120. \def\defunargs#1{\functionparens \sl
  4121. % Expand, preventing hyphenation at `-' chars.
  4122. % Note that groups don't affect changes in \hyphenchar.
  4123. % Set the font temporarily and use \font in case \setfont made \tensl a macro.
  4124. {\tensl\hyphenchar\font=0}%
  4125. #1%
  4126. {\tensl\hyphenchar\font=45}%
  4127. \ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi%
  4128. \interlinepenalty=10000
  4129. \advance\rightskip by 0pt plus 1fil
  4130. \endgraf\nobreak\vskip -\parskip\nobreak
  4131. }
  4132. \def\deftypefunargs #1{%
  4133. % Expand, preventing hyphenation at `-' chars.
  4134. % Note that groups don't affect changes in \hyphenchar.
  4135. % Use \boldbraxnoamp, not \functionparens, so that & is not special.
  4136. \boldbraxnoamp
  4137. \tclose{#1}% avoid \code because of side effects on active chars
  4138. \interlinepenalty=10000
  4139. \advance\rightskip by 0pt plus 1fil
  4140. \endgraf\nobreak\vskip -\parskip\nobreak
  4141. }
  4142. % Do complete processing of one @defun or @defunx line already parsed.
  4143. % @deffn Command forward-char nchars
  4144. \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
  4145. \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
  4146. \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
  4147. \catcode 61=\other % Turn off change made in \defparsebody
  4148. }
  4149. % @defun == @deffn Function
  4150. \def\defun{\defparsebody\Edefun\defunx\defunheader}
  4151. \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  4152. \begingroup\defname {#1}{\putwordDeffunc}%
  4153. \defunargs {#2}\endgroup %
  4154. \catcode 61=\other % Turn off change made in \defparsebody
  4155. }
  4156. % @deftypefun int foobar (int @var{foo}, float @var{bar})
  4157. \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
  4158. % #1 is the data type. #2 is the name and args.
  4159. \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
  4160. % #1 is the data type, #2 the name, #3 the args.
  4161. \def\deftypefunheaderx #1#2 #3\relax{%
  4162. \doind {fn}{\code{#2}}% Make entry in function index
  4163. \begingroup\defname {\defheaderxcond#1\relax$$$#2}{\putwordDeftypefun}%
  4164. \deftypefunargs {#3}\endgroup %
  4165. \catcode 61=\other % Turn off change made in \defparsebody
  4166. }
  4167. % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
  4168. \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
  4169. % \defheaderxcond#1\relax$$$
  4170. % puts #1 in @code, followed by a space, but does nothing if #1 is null.
  4171. \def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi}
  4172. % #1 is the classification. #2 is the data type. #3 is the name and args.
  4173. \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
  4174. % #1 is the classification, #2 the data type, #3 the name, #4 the args.
  4175. \def\deftypefnheaderx #1#2#3 #4\relax{%
  4176. \doind {fn}{\code{#3}}% Make entry in function index
  4177. \begingroup
  4178. \normalparens % notably, turn off `&' magic, which prevents
  4179. % at least some C++ text from working
  4180. \defname {\defheaderxcond#2\relax$$$#3}{#1}%
  4181. \deftypefunargs {#4}\endgroup %
  4182. \catcode 61=\other % Turn off change made in \defparsebody
  4183. }
  4184. % @defmac == @deffn Macro
  4185. \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
  4186. \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  4187. \begingroup\defname {#1}{\putwordDefmac}%
  4188. \defunargs {#2}\endgroup %
  4189. \catcode 61=\other % Turn off change made in \defparsebody
  4190. }
  4191. % @defspec == @deffn Special Form
  4192. \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
  4193. \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  4194. \begingroup\defname {#1}{\putwordDefspec}%
  4195. \defunargs {#2}\endgroup %
  4196. \catcode 61=\other % Turn off change made in \defparsebody
  4197. }
  4198. % @defop CATEGORY CLASS OPERATION ARG...
  4199. %
  4200. \def\defop #1 {\def\defoptype{#1}%
  4201. \defopparsebody\Edefop\defopx\defopheader\defoptype}
  4202. %
  4203. \def\defopheader#1#2#3{%
  4204. \dosubind {fn}{\code{#2}}{\putwordon\ #1}% Make entry in function index
  4205. \begingroup\defname {#2}{\defoptype\ \putwordon\ #1}%
  4206. \defunargs {#3}\endgroup %
  4207. }
  4208. % @deftypeop CATEGORY CLASS TYPE OPERATION ARG...
  4209. %
  4210. \def\deftypeop #1 {\def\deftypeopcategory{#1}%
  4211. \deftypeopparsebody\Edeftypeop\deftypeopx\deftypeopheader
  4212. \deftypeopcategory}
  4213. %
  4214. % #1 is the class name, #2 the data type, #3 the operation name, #4 the args.
  4215. \def\deftypeopheader#1#2#3#4{%
  4216. \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
  4217. \begingroup
  4218. \defname{\defheaderxcond#2\relax$$$#3}
  4219. {\deftypeopcategory\ \putwordon\ \code{#1}}%
  4220. \deftypefunargs{#4}%
  4221. \endgroup
  4222. }
  4223. % @deftypemethod CLASS TYPE METHOD ARG...
  4224. %
  4225. \def\deftypemethod{%
  4226. \deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader}
  4227. %
  4228. % #1 is the class name, #2 the data type, #3 the method name, #4 the args.
  4229. \def\deftypemethodheader#1#2#3#4{%
  4230. \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
  4231. \begingroup
  4232. \defname{\defheaderxcond#2\relax$$$#3}{\putwordMethodon\ \code{#1}}%
  4233. \deftypefunargs{#4}%
  4234. \endgroup
  4235. }
  4236. % @deftypeivar CLASS TYPE VARNAME
  4237. %
  4238. \def\deftypeivar{%
  4239. \deftypemethparsebody\Edeftypeivar\deftypeivarx\deftypeivarheader}
  4240. %
  4241. % #1 is the class name, #2 the data type, #3 the variable name.
  4242. \def\deftypeivarheader#1#2#3{%
  4243. \dosubind{vr}{\code{#3}}{\putwordof\ \code{#1}}% entry in variable index
  4244. \begingroup
  4245. \defname{#3}{\putwordInstanceVariableof\ \code{#1}}%
  4246. \defvarargs{#3}%
  4247. \endgroup
  4248. }
  4249. % @defmethod == @defop Method
  4250. %
  4251. \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
  4252. %
  4253. % #1 is the class name, #2 the method name, #3 the args.
  4254. \def\defmethodheader#1#2#3{%
  4255. \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index
  4256. \begingroup
  4257. \defname{#2}{\putwordMethodon\ \code{#1}}%
  4258. \defunargs{#3}%
  4259. \endgroup
  4260. }
  4261. % @defcv {Class Option} foo-class foo-flag
  4262. \def\defcv #1 {\def\defcvtype{#1}%
  4263. \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
  4264. \def\defcvarheader #1#2#3{%
  4265. \dosubind {vr}{\code{#2}}{\putwordof\ #1}% Make entry in var index
  4266. \begingroup\defname {#2}{\defcvtype\ \putwordof\ #1}%
  4267. \defvarargs {#3}\endgroup %
  4268. }
  4269. % @defivar CLASS VARNAME == @defcv {Instance Variable} CLASS VARNAME
  4270. %
  4271. \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
  4272. %
  4273. \def\defivarheader#1#2#3{%
  4274. \dosubind {vr}{\code{#2}}{\putwordof\ #1}% entry in var index
  4275. \begingroup
  4276. \defname{#2}{\putwordInstanceVariableof\ #1}%
  4277. \defvarargs{#3}%
  4278. \endgroup
  4279. }
  4280. % @defvar
  4281. % First, define the processing that is wanted for arguments of @defvar.
  4282. % This is actually simple: just print them in roman.
  4283. % This must expand the args and terminate the paragraph they make up
  4284. \def\defvarargs #1{\normalparens #1%
  4285. \interlinepenalty=10000
  4286. \endgraf\nobreak\vskip -\parskip\nobreak}
  4287. % @defvr Counter foo-count
  4288. \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
  4289. \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
  4290. \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
  4291. % @defvar == @defvr Variable
  4292. \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
  4293. \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  4294. \begingroup\defname {#1}{\putwordDefvar}%
  4295. \defvarargs {#2}\endgroup %
  4296. }
  4297. % @defopt == @defvr {User Option}
  4298. \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
  4299. \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  4300. \begingroup\defname {#1}{\putwordDefopt}%
  4301. \defvarargs {#2}\endgroup %
  4302. }
  4303. % @deftypevar int foobar
  4304. \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
  4305. % #1 is the data type. #2 is the name, perhaps followed by text that
  4306. % is actually part of the data type, which should not be put into the index.
  4307. \def\deftypevarheader #1#2{%
  4308. \dovarind#2 \relax% Make entry in variables index
  4309. \begingroup\defname {\defheaderxcond#1\relax$$$#2}{\putwordDeftypevar}%
  4310. \interlinepenalty=10000
  4311. \endgraf\nobreak\vskip -\parskip\nobreak
  4312. \endgroup}
  4313. \def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}}
  4314. % @deftypevr {Global Flag} int enable
  4315. \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
  4316. \def\deftypevrheader #1#2#3{\dovarind#3 \relax%
  4317. \begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1}
  4318. \interlinepenalty=10000
  4319. \endgraf\nobreak\vskip -\parskip\nobreak
  4320. \endgroup}
  4321. % Now define @deftp
  4322. % Args are printed in bold, a slight difference from @defvar.
  4323. \def\deftpargs #1{\bf \defvarargs{#1}}
  4324. % @deftp Class window height width ...
  4325. \def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
  4326. \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
  4327. \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
  4328. % These definitions are used if you use @defunx (etc.)
  4329. % anywhere other than immediately after a @defun or @defunx.
  4330. %
  4331. \def\defcvx#1 {\errmessage{@defcvx in invalid context}}
  4332. \def\deffnx#1 {\errmessage{@deffnx in invalid context}}
  4333. \def\defivarx#1 {\errmessage{@defivarx in invalid context}}
  4334. \def\defmacx#1 {\errmessage{@defmacx in invalid context}}
  4335. \def\defmethodx#1 {\errmessage{@defmethodx in invalid context}}
  4336. \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
  4337. \def\defopx#1 {\errmessage{@defopx in invalid context}}
  4338. \def\defspecx#1 {\errmessage{@defspecx in invalid context}}
  4339. \def\deftpx#1 {\errmessage{@deftpx in invalid context}}
  4340. \def\deftypefnx#1 {\errmessage{@deftypefnx in invalid context}}
  4341. \def\deftypefunx#1 {\errmessage{@deftypefunx in invalid context}}
  4342. \def\deftypeivarx#1 {\errmessage{@deftypeivarx in invalid context}}
  4343. \def\deftypemethodx#1 {\errmessage{@deftypemethodx in invalid context}}
  4344. \def\deftypeopx#1 {\errmessage{@deftypeopx in invalid context}}
  4345. \def\deftypevarx#1 {\errmessage{@deftypevarx in invalid context}}
  4346. \def\deftypevrx#1 {\errmessage{@deftypevrx in invalid context}}
  4347. \def\defunx#1 {\errmessage{@defunx in invalid context}}
  4348. \def\defvarx#1 {\errmessage{@defvarx in invalid context}}
  4349. \def\defvrx#1 {\errmessage{@defvrx in invalid context}}
  4350. \message{macros,}
  4351. % @macro.
  4352. % To do this right we need a feature of e-TeX, \scantokens,
  4353. % which we arrange to emulate with a temporary file in ordinary TeX.
  4354. \ifx\eTeXversion\undefined
  4355. \newwrite\macscribble
  4356. \def\scanmacro#1{%
  4357. \begingroup \newlinechar`\^^M
  4358. % Undo catcode changes of \startcontents and \doprintindex
  4359. \catcode`\@=0 \catcode`\\=12 \escapechar=`\@
  4360. % Append \endinput to make sure that TeX does not see the ending newline.
  4361. \toks0={#1\endinput}%
  4362. \immediate\openout\macscribble=\jobname.tmp
  4363. \immediate\write\macscribble{\the\toks0}%
  4364. \immediate\closeout\macscribble
  4365. \let\xeatspaces\eatspaces
  4366. \input \jobname.tmp
  4367. \endgroup
  4368. }
  4369. \else
  4370. \def\scanmacro#1{%
  4371. \begingroup \newlinechar`\^^M
  4372. % Undo catcode changes of \startcontents and \doprintindex
  4373. \catcode`\@=0 \catcode`\\=12 \escapechar=`\@
  4374. \let\xeatspaces\eatspaces\scantokens{#1\endinput}\endgroup}
  4375. \fi
  4376. \newcount\paramno % Count of parameters
  4377. \newtoks\macname % Macro name
  4378. \newif\ifrecursive % Is it recursive?
  4379. \def\macrolist{} % List of all defined macros in the form
  4380. % \do\macro1\do\macro2...
  4381. % Utility routines.
  4382. % Thisdoes \let #1 = #2, except with \csnames.
  4383. \def\cslet#1#2{%
  4384. \expandafter\expandafter
  4385. \expandafter\let
  4386. \expandafter\expandafter
  4387. \csname#1\endcsname
  4388. \csname#2\endcsname}
  4389. % Trim leading and trailing spaces off a string.
  4390. % Concepts from aro-bend problem 15 (see CTAN).
  4391. {\catcode`\@=11
  4392. \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
  4393. \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
  4394. \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
  4395. \def\unbrace#1{#1}
  4396. \unbrace{\gdef\trim@@@ #1 } #2@{#1}
  4397. }
  4398. % Trim a single trailing ^^M off a string.
  4399. {\catcode`\^^M=12\catcode`\Q=3%
  4400. \gdef\eatcr #1{\eatcra #1Q^^MQ}%
  4401. \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
  4402. \gdef\eatcrb#1Q#2Q{#1}%
  4403. }
  4404. % Macro bodies are absorbed as an argument in a context where
  4405. % all characters are catcode 10, 11 or 12, except \ which is active
  4406. % (as in normal texinfo). It is necessary to change the definition of \.
  4407. % It's necessary to have hard CRs when the macro is executed. This is
  4408. % done by making ^^M (\endlinechar) catcode 12 when reading the macro
  4409. % body, and then making it the \newlinechar in \scanmacro.
  4410. \def\macrobodyctxt{%
  4411. \catcode`\~=12
  4412. \catcode`\^=12
  4413. \catcode`\_=12
  4414. \catcode`\|=12
  4415. \catcode`\<=12
  4416. \catcode`\>=12
  4417. \catcode`\+=12
  4418. \catcode`\{=12
  4419. \catcode`\}=12
  4420. \catcode`\@=12
  4421. \catcode`\^^M=12
  4422. \usembodybackslash}
  4423. \def\macroargctxt{%
  4424. \catcode`\~=12
  4425. \catcode`\^=12
  4426. \catcode`\_=12
  4427. \catcode`\|=12
  4428. \catcode`\<=12
  4429. \catcode`\>=12
  4430. \catcode`\+=12
  4431. \catcode`\@=12
  4432. \catcode`\\=12}
  4433. % \mbodybackslash is the definition of \ in @macro bodies.
  4434. % It maps \foo\ => \csname macarg.foo\endcsname => #N
  4435. % where N is the macro parameter number.
  4436. % We define \csname macarg.\endcsname to be \realbackslash, so
  4437. % \\ in macro replacement text gets you a backslash.
  4438. {\catcode`@=0 @catcode`@\=@active
  4439. @gdef@usembodybackslash{@let\=@mbodybackslash}
  4440. @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
  4441. }
  4442. \expandafter\def\csname macarg.\endcsname{\realbackslash}
  4443. \def\macro{\recursivefalse\parsearg\macroxxx}
  4444. \def\rmacro{\recursivetrue\parsearg\macroxxx}
  4445. \def\macroxxx#1{%
  4446. \getargs{#1}% now \macname is the macname and \argl the arglist
  4447. \ifx\argl\empty % no arguments
  4448. \paramno=0%
  4449. \else
  4450. \expandafter\parsemargdef \argl;%
  4451. \fi
  4452. \if1\csname ismacro.\the\macname\endcsname
  4453. \message{Warning: redefining \the\macname}%
  4454. \else
  4455. \expandafter\ifx\csname \the\macname\endcsname \relax
  4456. \else \errmessage{The name \the\macname\space is reserved}\fi
  4457. \global\cslet{macsave.\the\macname}{\the\macname}%
  4458. \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
  4459. % Add the macroname to \macrolist
  4460. \toks0 = \expandafter{\macrolist\do}%
  4461. \xdef\macrolist{\the\toks0
  4462. \expandafter\noexpand\csname\the\macname\endcsname}%
  4463. \fi
  4464. \begingroup \macrobodyctxt
  4465. \ifrecursive \expandafter\parsermacbody
  4466. \else \expandafter\parsemacbody
  4467. \fi}
  4468. \def\unmacro{\parsearg\unmacroxxx}
  4469. \def\unmacroxxx#1{%
  4470. \if1\csname ismacro.#1\endcsname
  4471. \global\cslet{#1}{macsave.#1}%
  4472. \global\expandafter\let \csname ismacro.#1\endcsname=0%
  4473. % Remove the macro name from \macrolist
  4474. \begingroup
  4475. \edef\tempa{\expandafter\noexpand\csname#1\endcsname}%
  4476. \def\do##1{%
  4477. \def\tempb{##1}%
  4478. \ifx\tempa\tempb
  4479. % remove this
  4480. \else
  4481. \toks0 = \expandafter{\newmacrolist\do}%
  4482. \edef\newmacrolist{\the\toks0\expandafter\noexpand\tempa}%
  4483. \fi}%
  4484. \def\newmacrolist{}%
  4485. % Execute macro list to define \newmacrolist
  4486. \macrolist
  4487. \global\let\macrolist\newmacrolist
  4488. \endgroup
  4489. \else
  4490. \errmessage{Macro #1 not defined}%
  4491. \fi
  4492. }
  4493. % This makes use of the obscure feature that if the last token of a
  4494. % <parameter list> is #, then the preceding argument is delimited by
  4495. % an opening brace, and that opening brace is not consumed.
  4496. \def\getargs#1{\getargsxxx#1{}}
  4497. \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
  4498. \def\getmacname #1 #2\relax{\macname={#1}}
  4499. \def\getmacargs#1{\def\argl{#1}}
  4500. % Parse the optional {params} list. Set up \paramno and \paramlist
  4501. % so \defmacro knows what to do. Define \macarg.blah for each blah
  4502. % in the params list, to be ##N where N is the position in that list.
  4503. % That gets used by \mbodybackslash (above).
  4504. % We need to get `macro parameter char #' into several definitions.
  4505. % The technique used is stolen from LaTeX: let \hash be something
  4506. % unexpandable, insert that wherever you need a #, and then redefine
  4507. % it to # just before using the token list produced.
  4508. %
  4509. % The same technique is used to protect \eatspaces till just before
  4510. % the macro is used.
  4511. \def\parsemargdef#1;{\paramno=0\def\paramlist{}%
  4512. \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,}
  4513. \def\parsemargdefxxx#1,{%
  4514. \if#1;\let\next=\relax
  4515. \else \let\next=\parsemargdefxxx
  4516. \advance\paramno by 1%
  4517. \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
  4518. {\xeatspaces{\hash\the\paramno}}%
  4519. \edef\paramlist{\paramlist\hash\the\paramno,}%
  4520. \fi\next}
  4521. % These two commands read recursive and nonrecursive macro bodies.
  4522. % (They're different since rec and nonrec macros end differently.)
  4523. \long\def\parsemacbody#1@end macro%
  4524. {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
  4525. \long\def\parsermacbody#1@end rmacro%
  4526. {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
  4527. % This defines the macro itself. There are six cases: recursive and
  4528. % nonrecursive macros of zero, one, and many arguments.
  4529. % Much magic with \expandafter here.
  4530. % \xdef is used so that macro definitions will survive the file
  4531. % they're defined in; @include reads the file inside a group.
  4532. \def\defmacro{%
  4533. \let\hash=##% convert placeholders to macro parameter chars
  4534. \ifrecursive
  4535. \ifcase\paramno
  4536. % 0
  4537. \expandafter\xdef\csname\the\macname\endcsname{%
  4538. \noexpand\scanmacro{\temp}}%
  4539. \or % 1
  4540. \expandafter\xdef\csname\the\macname\endcsname{%
  4541. \bgroup\noexpand\macroargctxt
  4542. \noexpand\braceorline
  4543. \expandafter\noexpand\csname\the\macname xxx\endcsname}%
  4544. \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
  4545. \egroup\noexpand\scanmacro{\temp}}%
  4546. \else % many
  4547. \expandafter\xdef\csname\the\macname\endcsname{%
  4548. \bgroup\noexpand\macroargctxt
  4549. \noexpand\csname\the\macname xx\endcsname}%
  4550. \expandafter\xdef\csname\the\macname xx\endcsname##1{%
  4551. \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
  4552. \expandafter\expandafter
  4553. \expandafter\xdef
  4554. \expandafter\expandafter
  4555. \csname\the\macname xxx\endcsname
  4556. \paramlist{\egroup\noexpand\scanmacro{\temp}}%
  4557. \fi
  4558. \else
  4559. \ifcase\paramno
  4560. % 0
  4561. \expandafter\xdef\csname\the\macname\endcsname{%
  4562. \noexpand\norecurse{\the\macname}%
  4563. \noexpand\scanmacro{\temp}\egroup}%
  4564. \or % 1
  4565. \expandafter\xdef\csname\the\macname\endcsname{%
  4566. \bgroup\noexpand\macroargctxt
  4567. \noexpand\braceorline
  4568. \expandafter\noexpand\csname\the\macname xxx\endcsname}%
  4569. \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
  4570. \egroup
  4571. \noexpand\norecurse{\the\macname}%
  4572. \noexpand\scanmacro{\temp}\egroup}%
  4573. \else % many
  4574. \expandafter\xdef\csname\the\macname\endcsname{%
  4575. \bgroup\noexpand\macroargctxt
  4576. \expandafter\noexpand\csname\the\macname xx\endcsname}%
  4577. \expandafter\xdef\csname\the\macname xx\endcsname##1{%
  4578. \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
  4579. \expandafter\expandafter
  4580. \expandafter\xdef
  4581. \expandafter\expandafter
  4582. \csname\the\macname xxx\endcsname
  4583. \paramlist{%
  4584. \egroup
  4585. \noexpand\norecurse{\the\macname}%
  4586. \noexpand\scanmacro{\temp}\egroup}%
  4587. \fi
  4588. \fi}
  4589. \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
  4590. % \braceorline decides whether the next nonwhitespace character is a
  4591. % {. If so it reads up to the closing }, if not, it reads the whole
  4592. % line. Whatever was read is then fed to the next control sequence
  4593. % as an argument (by \parsebrace or \parsearg)
  4594. \def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx}
  4595. \def\braceorlinexxx{%
  4596. \ifx\nchar\bgroup\else
  4597. \expandafter\parsearg
  4598. \fi \next}
  4599. % We mant to disable all macros during \shipout so that they are not
  4600. % expanded by \write.
  4601. \def\turnoffmacros{\begingroup \def\do##1{\let\noexpand##1=\relax}%
  4602. \edef\next{\macrolist}\expandafter\endgroup\next}
  4603. % @alias.
  4604. % We need some trickery to remove the optional spaces around the equal
  4605. % sign. Just make them active and then expand them all to nothing.
  4606. \def\alias{\begingroup\obeyspaces\parsearg\aliasxxx}
  4607. \def\aliasxxx #1{\aliasyyy#1\relax}
  4608. \def\aliasyyy #1=#2\relax{\ignoreactivespaces
  4609. \edef\next{\global\let\expandafter\noexpand\csname#1\endcsname=%
  4610. \expandafter\noexpand\csname#2\endcsname}%
  4611. \expandafter\endgroup\next}
  4612. \message{cross references,}
  4613. % @xref etc.
  4614. \newwrite\auxfile
  4615. \newif\ifhavexrefs % True if xref values are known.
  4616. \newif\ifwarnedxrefs % True if we warned once that they aren't known.
  4617. % @inforef is relatively simple.
  4618. \def\inforef #1{\inforefzzz #1,,,,**}
  4619. \def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
  4620. node \samp{\ignorespaces#1{}}}
  4621. % @node's job is to define \lastnode.
  4622. \def\node{\ENVcheck\parsearg\nodezzz}
  4623. \def\nodezzz#1{\nodexxx [#1,]}
  4624. \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
  4625. \let\nwnode=\node
  4626. \let\lastnode=\relax
  4627. % The sectioning commands (@chapter, etc.) call these.
  4628. \def\donoderef{%
  4629. \ifx\lastnode\relax\else
  4630. \expandafter\expandafter\expandafter\setref{\lastnode}%
  4631. {Ysectionnumberandtype}%
  4632. \global\let\lastnode=\relax
  4633. \fi
  4634. }
  4635. \def\unnumbnoderef{%
  4636. \ifx\lastnode\relax\else
  4637. \expandafter\expandafter\expandafter\setref{\lastnode}{Ynothing}%
  4638. \global\let\lastnode=\relax
  4639. \fi
  4640. }
  4641. \def\appendixnoderef{%
  4642. \ifx\lastnode\relax\else
  4643. \expandafter\expandafter\expandafter\setref{\lastnode}%
  4644. {Yappendixletterandtype}%
  4645. \global\let\lastnode=\relax
  4646. \fi
  4647. }
  4648. % @anchor{NAME} -- define xref target at arbitrary point.
  4649. %
  4650. \newcount\savesfregister
  4651. \gdef\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
  4652. \gdef\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
  4653. \gdef\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
  4654. % \setref{NAME}{SNT} defines a cross-reference point NAME, namely
  4655. % NAME-title, NAME-pg, and NAME-SNT. Called from \foonoderef. We have
  4656. % to set \indexdummies so commands such as @code in a section title
  4657. % aren't expanded. It would be nicer not to expand the titles in the
  4658. % first place, but there's so many layers that that is hard to do.
  4659. %
  4660. \def\setref#1#2{{%
  4661. \indexdummies
  4662. \pdfmkdest{#1}%
  4663. \dosetq{#1-title}{Ytitle}%
  4664. \dosetq{#1-pg}{Ypagenumber}%
  4665. \dosetq{#1-snt}{#2}%
  4666. }}
  4667. % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
  4668. % the node name, #2 the name of the Info cross-reference, #3 the printed
  4669. % node name, #4 the name of the Info file, #5 the name of the printed
  4670. % manual. All but the node name can be omitted.
  4671. %
  4672. \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
  4673. \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
  4674. \def\ref#1{\xrefX[#1,,,,,,,]}
  4675. \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
  4676. \unsepspaces
  4677. \def\printedmanual{\ignorespaces #5}%
  4678. \def\printednodename{\ignorespaces #3}%
  4679. \setbox1=\hbox{\printedmanual}%
  4680. \setbox0=\hbox{\printednodename}%
  4681. \ifdim \wd0 = 0pt
  4682. % No printed node name was explicitly given.
  4683. \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
  4684. % Use the node name inside the square brackets.
  4685. \def\printednodename{\ignorespaces #1}%
  4686. \else
  4687. % Use the actual chapter/section title appear inside
  4688. % the square brackets. Use the real section title if we have it.
  4689. \ifdim \wd1 > 0pt
  4690. % It is in another manual, so we don't have it.
  4691. \def\printednodename{\ignorespaces #1}%
  4692. \else
  4693. \ifhavexrefs
  4694. % We know the real title if we have the xref values.
  4695. \def\printednodename{\refx{#1-title}{}}%
  4696. \else
  4697. % Otherwise just copy the Info node name.
  4698. \def\printednodename{\ignorespaces #1}%
  4699. \fi%
  4700. \fi
  4701. \fi
  4702. \fi
  4703. %
  4704. % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
  4705. % insert empty discretionaries after hyphens, which means that it will
  4706. % not find a line break at a hyphen in a node names. Since some manuals
  4707. % are best written with fairly long node names, containing hyphens, this
  4708. % is a loss. Therefore, we give the text of the node name again, so it
  4709. % is as if TeX is seeing it for the first time.
  4710. \ifpdf
  4711. \leavevmode
  4712. \getfilename{#4}%
  4713. \ifnum\filenamelength>0
  4714. \startlink attr{/Border [0 0 0]}%
  4715. goto file{\the\filename.pdf} name{#1@}%
  4716. \else
  4717. \startlink attr{/Border [0 0 0]}%
  4718. goto name{#1@}%
  4719. \fi
  4720. \linkcolor
  4721. \fi
  4722. %
  4723. \ifdim \wd1 > 0pt
  4724. \putwordsection{} ``\printednodename'' \putwordin{} \cite{\printedmanual}%
  4725. \else
  4726. % _ (for example) has to be the character _ for the purposes of the
  4727. % control sequence corresponding to the node, but it has to expand
  4728. % into the usual \leavevmode...\vrule stuff for purposes of
  4729. % printing. So we \turnoffactive for the \refx-snt, back on for the
  4730. % printing, back off for the \refx-pg.
  4731. {\normalturnoffactive
  4732. % Only output a following space if the -snt ref is nonempty; for
  4733. % @unnumbered and @anchor, it won't be.
  4734. \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
  4735. \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
  4736. }%
  4737. % [mynode],
  4738. [\printednodename],\space
  4739. % page 3
  4740. \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
  4741. \fi
  4742. \endlink
  4743. \endgroup}
  4744. % \dosetq is the interface for calls from other macros
  4745. % Use \normalturnoffactive so that punctuation chars such as underscore
  4746. % and backslash work in node names. (\turnoffactive doesn't do \.)
  4747. \def\dosetq#1#2{%
  4748. {\let\folio=0%
  4749. \normalturnoffactive
  4750. \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}%
  4751. \iflinks
  4752. \next
  4753. \fi
  4754. }%
  4755. }
  4756. % \internalsetq {foo}{page} expands into
  4757. % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
  4758. % When the aux file is read, ' is the escape character
  4759. \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
  4760. % Things to be expanded by \internalsetq
  4761. \def\Ypagenumber{\folio}
  4762. \def\Ytitle{\thissection}
  4763. \def\Ynothing{}
  4764. \def\Ysectionnumberandtype{%
  4765. \ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
  4766. \else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
  4767. \else \ifnum \subsubsecno=0 %
  4768. \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
  4769. \else %
  4770. \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
  4771. \fi \fi \fi }
  4772. \def\Yappendixletterandtype{%
  4773. \ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
  4774. \else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
  4775. \else \ifnum \subsubsecno=0 %
  4776. \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
  4777. \else %
  4778. \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
  4779. \fi \fi \fi }
  4780. \gdef\xreftie{'tie}
  4781. % Use TeX 3.0's \inputlineno to get the line number, for better error
  4782. % messages, but if we're using an old version of TeX, don't do anything.
  4783. %
  4784. \ifx\inputlineno\thisisundefined
  4785. \let\linenumber = \empty % Non-3.0.
  4786. \else
  4787. \def\linenumber{\the\inputlineno:\space}
  4788. \fi
  4789. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  4790. % If its value is nonempty, SUFFIX is output afterward.
  4791. \def\refx#1#2{%
  4792. \expandafter\ifx\csname X#1\endcsname\relax
  4793. % If not defined, say something at least.
  4794. \angleleft un\-de\-fined\angleright
  4795. \iflinks
  4796. \ifhavexrefs
  4797. \message{\linenumber Undefined cross reference `#1'.}%
  4798. \else
  4799. \ifwarnedxrefs\else
  4800. \global\warnedxrefstrue
  4801. \message{Cross reference values unknown; you must run TeX again.}%
  4802. \fi
  4803. \fi
  4804. \fi
  4805. \else
  4806. % It's defined, so just use it.
  4807. \csname X#1\endcsname
  4808. \fi
  4809. #2% Output the suffix in any case.
  4810. }
  4811. % This is the macro invoked by entries in the aux file.
  4812. %
  4813. \def\xrdef#1{\begingroup
  4814. % Reenable \ as an escape while reading the second argument.
  4815. \catcode`\\ = 0
  4816. \afterassignment\endgroup
  4817. \expandafter\gdef\csname X#1\endcsname
  4818. }
  4819. % Read the last existing aux file, if any. No error if none exists.
  4820. \def\readauxfile{\begingroup
  4821. \catcode`\^^@=\other
  4822. \catcode`\^^A=\other
  4823. \catcode`\^^B=\other
  4824. \catcode`\^^C=\other
  4825. \catcode`\^^D=\other
  4826. \catcode`\^^E=\other
  4827. \catcode`\^^F=\other
  4828. \catcode`\^^G=\other
  4829. \catcode`\^^H=\other
  4830. \catcode`\^^K=\other
  4831. \catcode`\^^L=\other
  4832. \catcode`\^^N=\other
  4833. \catcode`\^^P=\other
  4834. \catcode`\^^Q=\other
  4835. \catcode`\^^R=\other
  4836. \catcode`\^^S=\other
  4837. \catcode`\^^T=\other
  4838. \catcode`\^^U=\other
  4839. \catcode`\^^V=\other
  4840. \catcode`\^^W=\other
  4841. \catcode`\^^X=\other
  4842. \catcode`\^^Z=\other
  4843. \catcode`\^^[=\other
  4844. \catcode`\^^\=\other
  4845. \catcode`\^^]=\other
  4846. \catcode`\^^^=\other
  4847. \catcode`\^^_=\other
  4848. \catcode`\@=\other
  4849. \catcode`\^=\other
  4850. % It was suggested to define this as 7, which would allow ^^e4 etc.
  4851. % in xref tags, i.e., node names. But since ^^e4 notation isn't
  4852. % supported in the main text, it doesn't seem desirable. Furthermore,
  4853. % that is not enough: for node names that actually contain a ^
  4854. % character, we would end up writing a line like this: 'xrdef {'hat
  4855. % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
  4856. % argument, and \hat is not an expandable control sequence. It could
  4857. % all be worked out, but why? Either we support ^^ or we don't.
  4858. %
  4859. % The other change necessary for this was to define \auxhat:
  4860. % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
  4861. % and then to call \auxhat in \setq.
  4862. %
  4863. \catcode`\~=\other
  4864. \catcode`\[=\other
  4865. \catcode`\]=\other
  4866. \catcode`\"=\other
  4867. \catcode`\_=\other
  4868. \catcode`\|=\other
  4869. \catcode`\<=\other
  4870. \catcode`\>=\other
  4871. \catcode`\$=\other
  4872. \catcode`\#=\other
  4873. \catcode`\&=\other
  4874. \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
  4875. % Make the characters 128-255 be printing characters
  4876. {%
  4877. \count 1=128
  4878. \def\loop{%
  4879. \catcode\count 1=\other
  4880. \advance\count 1 by 1
  4881. \ifnum \count 1<256 \loop \fi
  4882. }%
  4883. }%
  4884. % The aux file uses ' as the escape (for now).
  4885. % Turn off \ as an escape so we do not lose on
  4886. % entries which were dumped with control sequences in their names.
  4887. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
  4888. % Reference to such entries still does not work the way one would wish,
  4889. % but at least they do not bomb out when the aux file is read in.
  4890. \catcode`\{=1
  4891. \catcode`\}=2
  4892. \catcode`\%=\other
  4893. \catcode`\'=0
  4894. \catcode`\\=\other
  4895. %
  4896. \openin 1 \jobname.aux
  4897. \ifeof 1 \else
  4898. \closein 1
  4899. \input \jobname.aux
  4900. \global\havexrefstrue
  4901. \global\warnedobstrue
  4902. \fi
  4903. % Open the new aux file. TeX will close it automatically at exit.
  4904. \openout\auxfile=\jobname.aux
  4905. \endgroup}
  4906. % Footnotes.
  4907. \newcount \footnoteno
  4908. % The trailing space in the following definition for supereject is
  4909. % vital for proper filling; pages come out unaligned when you do a
  4910. % pagealignmacro call if that space before the closing brace is
  4911. % removed. (Generally, numeric constants should always be followed by a
  4912. % space to prevent strange expansion errors.)
  4913. \def\supereject{\par\penalty -20000\footnoteno =0 }
  4914. % @footnotestyle is meaningful for info output only.
  4915. \let\footnotestyle=\comment
  4916. \let\ptexfootnote=\footnote
  4917. {\catcode `\@=11
  4918. %
  4919. % Auto-number footnotes. Otherwise like plain.
  4920. \gdef\footnote{%
  4921. \global\advance\footnoteno by \@ne
  4922. \edef\thisfootno{$^{\the\footnoteno}$}%
  4923. %
  4924. % In case the footnote comes at the end of a sentence, preserve the
  4925. % extra spacing after we do the footnote number.
  4926. \let\@sf\empty
  4927. \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  4928. %
  4929. % Remove inadvertent blank space before typesetting the footnote number.
  4930. \unskip
  4931. \thisfootno\@sf
  4932. \footnotezzz
  4933. }%
  4934. % Don't bother with the trickery in plain.tex to not require the
  4935. % footnote text as a parameter. Our footnotes don't need to be so general.
  4936. %
  4937. % Oh yes, they do; otherwise, @ifset and anything else that uses
  4938. % \parseargline fail inside footnotes because the tokens are fixed when
  4939. % the footnote is read. --karl, 16nov96.
  4940. %
  4941. \long\gdef\footnotezzz{\insert\footins\bgroup
  4942. % We want to typeset this text as a normal paragraph, even if the
  4943. % footnote reference occurs in (for example) a display environment.
  4944. % So reset some parameters.
  4945. \interlinepenalty\interfootnotelinepenalty
  4946. \splittopskip\ht\strutbox % top baseline for broken footnotes
  4947. \splitmaxdepth\dp\strutbox
  4948. \floatingpenalty\@MM
  4949. \leftskip\z@skip
  4950. \rightskip\z@skip
  4951. \spaceskip\z@skip
  4952. \xspaceskip\z@skip
  4953. \parindent\defaultparindent
  4954. %
  4955. \smallfonts \rm
  4956. %
  4957. % Hang the footnote text off the number.
  4958. \hang
  4959. \textindent{\thisfootno}%
  4960. %
  4961. % Don't crash into the line above the footnote text. Since this
  4962. % expands into a box, it must come within the paragraph, lest it
  4963. % provide a place where TeX can split the footnote.
  4964. \footstrut
  4965. \futurelet\next\fo@t
  4966. }
  4967. \def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t
  4968. \else\let\next\f@t\fi \next}
  4969. \def\f@@t{\bgroup\aftergroup\@foot\let\next}
  4970. \def\f@t#1{#1\@foot}
  4971. \def\@foot{\strut\par\egroup}
  4972. }%end \catcode `\@=11
  4973. % Set the baselineskip to #1, and the lineskip and strut size
  4974. % correspondingly. There is no deep meaning behind these magic numbers
  4975. % used as factors; they just match (closely enough) what Knuth defined.
  4976. %
  4977. \def\lineskipfactor{.08333}
  4978. \def\strutheightpercent{.70833}
  4979. \def\strutdepthpercent {.29167}
  4980. %
  4981. \def\setleading#1{%
  4982. \normalbaselineskip = #1\relax
  4983. \normallineskip = \lineskipfactor\normalbaselineskip
  4984. \normalbaselines
  4985. \setbox\strutbox =\hbox{%
  4986. \vrule width0pt height\strutheightpercent\baselineskip
  4987. depth \strutdepthpercent \baselineskip
  4988. }%
  4989. }
  4990. % @| inserts a changebar to the left of the current line. It should
  4991. % surround any changed text. This approach does *not* work if the
  4992. % change spans more than two lines of output. To handle that, we would
  4993. % have adopt a much more difficult approach (putting marks into the main
  4994. % vertical list for the beginning and end of each change).
  4995. %
  4996. \def\|{%
  4997. % \vadjust can only be used in horizontal mode.
  4998. \leavevmode
  4999. %
  5000. % Append this vertical mode material after the current line in the output.
  5001. \vadjust{%
  5002. % We want to insert a rule with the height and depth of the current
  5003. % leading; that is exactly what \strutbox is supposed to record.
  5004. \vskip-\baselineskip
  5005. %
  5006. % \vadjust-items are inserted at the left edge of the type. So
  5007. % the \llap here moves out into the left-hand margin.
  5008. \llap{%
  5009. %
  5010. % For a thicker or thinner bar, change the `1pt'.
  5011. \vrule height\baselineskip width1pt
  5012. %
  5013. % This is the space between the bar and the text.
  5014. \hskip 12pt
  5015. }%
  5016. }%
  5017. }
  5018. % For a final copy, take out the rectangles
  5019. % that mark overfull boxes (in case you have decided
  5020. % that the text looks ok even though it passes the margin).
  5021. %
  5022. \def\finalout{\overfullrule=0pt}
  5023. % @image. We use the macros from epsf.tex to support this.
  5024. % If epsf.tex is not installed and @image is used, we complain.
  5025. %
  5026. % Check for and read epsf.tex up front. If we read it only at @image
  5027. % time, we might be inside a group, and then its definitions would get
  5028. % undone and the next image would fail.
  5029. \openin 1 = epsf.tex
  5030. \ifeof 1 \else
  5031. \closein 1
  5032. % Do not bother showing banner with post-v2.7 epsf.tex (available in
  5033. % doc/epsf.tex until it shows up on ctan).
  5034. \def\epsfannounce{\toks0 = }%
  5035. \input epsf.tex
  5036. \fi
  5037. %
  5038. % We will only complain once about lack of epsf.tex.
  5039. \newif\ifwarnednoepsf
  5040. \newhelp\noepsfhelp{epsf.tex must be installed for images to
  5041. work. It is also included in the Texinfo distribution, or you can get
  5042. it from ftp://tug.org/tex/epsf.tex.}
  5043. %
  5044. \def\image#1{%
  5045. \ifx\epsfbox\undefined
  5046. \ifwarnednoepsf \else
  5047. \errhelp = \noepsfhelp
  5048. \errmessage{epsf.tex not found, images will be ignored}%
  5049. \global\warnednoepsftrue
  5050. \fi
  5051. \else
  5052. \imagexxx #1,,,\finish
  5053. \fi
  5054. }
  5055. %
  5056. % Arguments to @image:
  5057. % #1 is (mandatory) image filename; we tack on .eps extension.
  5058. % #2 is (optional) width, #3 is (optional) height.
  5059. % #4 is just the usual extra ignored arg for parsing this stuff.
  5060. \def\imagexxx#1,#2,#3,#4\finish{%
  5061. \ifpdf
  5062. \centerline{\dopdfimage{#1}{#2}{#3}}%
  5063. \else
  5064. % \epsfbox itself resets \epsf?size at each figure.
  5065. \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
  5066. \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
  5067. \begingroup
  5068. \catcode`\^^M = 5 % in case we're inside an example
  5069. % If the image is by itself, center it.
  5070. \ifvmode
  5071. \nobreak\bigskip
  5072. % Usually we'll have text after the image which will insert
  5073. % \parskip glue, so insert it here too to equalize the space
  5074. % above and below.
  5075. \nobreak\vskip\parskip
  5076. \nobreak
  5077. \centerline{\epsfbox{#1.eps}}%
  5078. \bigbreak
  5079. \else
  5080. % In the middle of a paragraph, no extra space.
  5081. \epsfbox{#1.eps}%
  5082. \fi
  5083. \endgroup
  5084. \fi
  5085. }
  5086. \message{localization,}
  5087. % and i18n.
  5088. % @documentlanguage is usually given very early, just after
  5089. % @setfilename. If done too late, it may not override everything
  5090. % properly. Single argument is the language abbreviation.
  5091. % It would be nice if we could set up a hyphenation file here.
  5092. %
  5093. \def\documentlanguage{\parsearg\dodocumentlanguage}
  5094. \def\dodocumentlanguage#1{%
  5095. \tex % read txi-??.tex file in plain TeX.
  5096. % Read the file if it exists.
  5097. \openin 1 txi-#1.tex
  5098. \ifeof1
  5099. \errhelp = \nolanghelp
  5100. \errmessage{Cannot read language file txi-#1.tex}%
  5101. \let\temp = \relax
  5102. \else
  5103. \def\temp{\input txi-#1.tex }%
  5104. \fi
  5105. \temp
  5106. \endgroup
  5107. }
  5108. \newhelp\nolanghelp{The given language definition file cannot be found or
  5109. is empty. Maybe you need to install it? In the current directory
  5110. should work if nowhere else does.}
  5111. % @documentencoding should change something in TeX eventually, most
  5112. % likely, but for now just recognize it.
  5113. \let\documentencoding = \comment
  5114. % Page size parameters.
  5115. %
  5116. \newdimen\defaultparindent \defaultparindent = 15pt
  5117. \chapheadingskip = 15pt plus 4pt minus 2pt
  5118. \secheadingskip = 12pt plus 3pt minus 2pt
  5119. \subsecheadingskip = 9pt plus 2pt minus 2pt
  5120. % Prevent underfull vbox error messages.
  5121. \vbadness = 10000
  5122. % Don't be so finicky about underfull hboxes, either.
  5123. \hbadness = 2000
  5124. % Following George Bush, just get rid of widows and orphans.
  5125. \widowpenalty=10000
  5126. \clubpenalty=10000
  5127. % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
  5128. % using an old version of TeX, don't do anything. We want the amount of
  5129. % stretch added to depend on the line length, hence the dependence on
  5130. % \hsize. We call this whenever the paper size is set.
  5131. %
  5132. \def\setemergencystretch{%
  5133. \ifx\emergencystretch\thisisundefined
  5134. % Allow us to assign to \emergencystretch anyway.
  5135. \def\emergencystretch{\dimen0}%
  5136. \else
  5137. \emergencystretch = .15\hsize
  5138. \fi
  5139. }
  5140. % Parameters in order: 1) textheight; 2) textwidth; 3) voffset;
  5141. % 4) hoffset; 5) binding offset; 6) topskip. Then whoever calls us can
  5142. % set \parskip and call \setleading for \baselineskip.
  5143. %
  5144. \def\internalpagesizes#1#2#3#4#5#6{%
  5145. \voffset = #3\relax
  5146. \topskip = #6\relax
  5147. \splittopskip = \topskip
  5148. %
  5149. \vsize = #1\relax
  5150. \advance\vsize by \topskip
  5151. \outervsize = \vsize
  5152. \advance\outervsize by 2\topandbottommargin
  5153. \pageheight = \vsize
  5154. % CLN wants a little wider page, hence we enlarge the width by 0.6in...
  5155. \hsize = #2\relax
  5156. \outerhsize = \hsize
  5157. \advance\outerhsize by 0.5in
  5158. \advance\hsize by 0.6in
  5159. \pagewidth = \hsize
  5160. % ...wich also calls for a change in the hoffset.
  5161. \normaloffset = #4\relax
  5162. \advance\normaloffset by -0.3in
  5163. \bindingoffset = #5\relax
  5164. %
  5165. \parindent = \defaultparindent
  5166. \setemergencystretch
  5167. }
  5168. % @letterpaper (the default).
  5169. \def\letterpaper{{\globaldefs = 1
  5170. \parskip = 3pt plus 2pt minus 1pt
  5171. \setleading{13.2pt}%
  5172. %
  5173. % If page is nothing but text, make it come out even.
  5174. \internalpagesizes{46\baselineskip}{6in}{\voffset}{.25in}{\bindingoffset}{36pt}%
  5175. }}
  5176. % Use @smallbook to reset parameters for 7x9.5 (or so) format.
  5177. \def\smallbook{{\globaldefs = 1
  5178. \parskip = 2pt plus 1pt
  5179. \setleading{12pt}%
  5180. %
  5181. \internalpagesizes{7.5in}{5.in}{\voffset}{.25in}{\bindingoffset}{16pt}%
  5182. %
  5183. \lispnarrowing = 0.3in
  5184. \tolerance = 700
  5185. \hfuzz = 1pt
  5186. \contentsrightmargin = 0pt
  5187. \deftypemargin = 0pt
  5188. \defbodyindent = .5cm
  5189. %
  5190. \let\smalldisplay = \smalldisplayx
  5191. \let\smallexample = \smalllispx
  5192. \let\smallformat = \smallformatx
  5193. \let\smalllisp = \smalllispx
  5194. }}
  5195. % Use @afourpaper to print on European A4 paper.
  5196. \def\afourpaper{{\globaldefs = 1
  5197. \setleading{12pt}%
  5198. \parskip = 3pt plus 2pt minus 1pt
  5199. %
  5200. \internalpagesizes{53\baselineskip}{160mm}{\voffset}{4mm}{\bindingoffset}{44pt}%
  5201. %
  5202. \tolerance = 700
  5203. \hfuzz = 1pt
  5204. }}
  5205. % A specific text layout, 24x15cm overall, intended for A4 paper. Top margin
  5206. % 29mm, hence bottom margin 28mm, nominal side margin 3cm.
  5207. \def\afourlatex{{\globaldefs = 1
  5208. \setleading{13.6pt}%
  5209. %
  5210. \afourpaper
  5211. \internalpagesizes{237mm}{150mm}{3.6mm}{3.6mm}{3mm}{7mm}%
  5212. %
  5213. \globaldefs = 0
  5214. }}
  5215. % Use @afourwide to print on European A4 paper in wide format.
  5216. \def\afourwide{%
  5217. \afourpaper
  5218. \internalpagesizes{6.5in}{9.5in}{\hoffset}{\normaloffset}{\bindingoffset}{7mm}%
  5219. %
  5220. \globaldefs = 0
  5221. }
  5222. % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
  5223. % Perhaps we should allow setting the margins, \topskip, \parskip,
  5224. % and/or leading, also. Or perhaps we should compute them somehow.
  5225. %
  5226. \def\pagesizes{\parsearg\pagesizesxxx}
  5227. \def\pagesizesxxx#1{\pagesizesyyy #1,,\finish}
  5228. \def\pagesizesyyy#1,#2,#3\finish{{%
  5229. \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
  5230. \globaldefs = 1
  5231. %
  5232. \parskip = 3pt plus 2pt minus 1pt
  5233. \setleading{13.2pt}%
  5234. %
  5235. \internalpagesizes{#1}{\hsize}{\voffset}{\normaloffset}{\bindingoffset}{44pt}%
  5236. }}
  5237. % Set default to letter.
  5238. %
  5239. \letterpaper
  5240. \message{and turning on texinfo input format.}
  5241. % Define macros to output various characters with catcode for normal text.
  5242. \catcode`\"=\other
  5243. \catcode`\~=\other
  5244. \catcode`\^=\other
  5245. \catcode`\_=\other
  5246. \catcode`\|=\other
  5247. \catcode`\<=\other
  5248. \catcode`\>=\other
  5249. \catcode`\+=\other
  5250. \catcode`\$=\other
  5251. \def\normaldoublequote{"}
  5252. \def\normaltilde{~}
  5253. \def\normalcaret{^}
  5254. \def\normalunderscore{_}
  5255. \def\normalverticalbar{|}
  5256. \def\normalless{<}
  5257. \def\normalgreater{>}
  5258. \def\normalplus{+}
  5259. \def\normaldollar{$}
  5260. % This macro is used to make a character print one way in ttfont
  5261. % where it can probably just be output, and another way in other fonts,
  5262. % where something hairier probably needs to be done.
  5263. %
  5264. % #1 is what to print if we are indeed using \tt; #2 is what to print
  5265. % otherwise. Since all the Computer Modern typewriter fonts have zero
  5266. % interword stretch (and shrink), and it is reasonable to expect all
  5267. % typewriter fonts to have this, we can check that font parameter.
  5268. %
  5269. \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
  5270. % Same as above, but check for italic font. Actually this also catches
  5271. % non-italic slanted fonts since it is impossible to distinguish them from
  5272. % italic fonts. But since this is only used by $ and it uses \sl anyway
  5273. % this is not a problem.
  5274. \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
  5275. % Turn off all special characters except @
  5276. % (and those which the user can use as if they were ordinary).
  5277. % Most of these we simply print from the \tt font, but for some, we can
  5278. % use math or other variants that look better in normal text.
  5279. \catcode`\"=\active
  5280. \def\activedoublequote{{\tt\char34}}
  5281. \let"=\activedoublequote
  5282. \catcode`\~=\active
  5283. \def~{{\tt\char126}}
  5284. \chardef\hat=`\^
  5285. \catcode`\^=\active
  5286. \def^{{\tt \hat}}
  5287. \catcode`\_=\active
  5288. \def_{\ifusingtt\normalunderscore\_}
  5289. % Subroutine for the previous macro.
  5290. \def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}}
  5291. \catcode`\|=\active
  5292. \def|{{\tt\char124}}
  5293. \chardef \less=`\<
  5294. \catcode`\<=\active
  5295. \def<{{\tt \less}}
  5296. \chardef \gtr=`\>
  5297. \catcode`\>=\active
  5298. \def>{{\tt \gtr}}
  5299. \catcode`\+=\active
  5300. \def+{{\tt \char 43}}
  5301. \catcode`\$=\active
  5302. \def${\ifusingit{{\sl\$}}\normaldollar}
  5303. %\catcode 27=\active
  5304. %\def^^[{$\diamondsuit$}
  5305. % Set up an active definition for =, but don't enable it most of the time.
  5306. {\catcode`\==\active
  5307. \global\def={{\tt \char 61}}}
  5308. \catcode`+=\active
  5309. \catcode`\_=\active
  5310. % If a .fmt file is being used, characters that might appear in a file
  5311. % name cannot be active until we have parsed the command line.
  5312. % So turn them off again, and have \everyjob (or @setfilename) turn them on.
  5313. % \otherifyactive is called near the end of this file.
  5314. \def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
  5315. \catcode`\@=0
  5316. % \rawbackslashxx output one backslash character in current font
  5317. \global\chardef\rawbackslashxx=`\\
  5318. %{\catcode`\\=\other
  5319. %@gdef@rawbackslashxx{\}}
  5320. % \rawbackslash redefines \ as input to do \rawbackslashxx.
  5321. {\catcode`\\=\active
  5322. @gdef@rawbackslash{@let\=@rawbackslashxx }}
  5323. % \normalbackslash outputs one backslash in fixed width font.
  5324. \def\normalbackslash{{\tt\rawbackslashxx}}
  5325. % \catcode 17=0 % Define control-q
  5326. \catcode`\\=\active
  5327. % Used sometimes to turn off (effectively) the active characters
  5328. % even after parsing them.
  5329. @def@turnoffactive{@let"=@normaldoublequote
  5330. @let\=@realbackslash
  5331. @let~=@normaltilde
  5332. @let^=@normalcaret
  5333. @let_=@normalunderscore
  5334. @let|=@normalverticalbar
  5335. @let<=@normalless
  5336. @let>=@normalgreater
  5337. @let+=@normalplus
  5338. @let$=@normaldollar}
  5339. @def@normalturnoffactive{@let"=@normaldoublequote
  5340. @let\=@normalbackslash
  5341. @let~=@normaltilde
  5342. @let^=@normalcaret
  5343. @let_=@normalunderscore
  5344. @let|=@normalverticalbar
  5345. @let<=@normalless
  5346. @let>=@normalgreater
  5347. @let+=@normalplus
  5348. @let$=@normaldollar}
  5349. % Make _ and + \other characters, temporarily.
  5350. % This is canceled by @fixbackslash.
  5351. @otherifyactive
  5352. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  5353. % That is what \eatinput is for; after that, the `\' should revert to printing
  5354. % a backslash.
  5355. %
  5356. @gdef@eatinput input texinfo{@fixbackslash}
  5357. @global@let\ = @eatinput
  5358. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  5359. % the first `\{ in the file would cause an error. This macro tries to fix
  5360. % that, assuming it is called before the first `\' could plausibly occur.
  5361. % Also back turn on active characters that might appear in the input
  5362. % file name, in case not using a pre-dumped format.
  5363. %
  5364. @gdef@fixbackslash{%
  5365. @ifx\@eatinput @let\ = @normalbackslash @fi
  5366. @catcode`+=@active
  5367. @catcode`@_=@active
  5368. }
  5369. % Say @foo, not \foo, in error messages.
  5370. @escapechar = `@@
  5371. % These look ok in all fonts, so just make them not special.
  5372. @catcode`@& = @other
  5373. @catcode`@# = @other
  5374. @catcode`@% = @other
  5375. @c Set initial fonts.
  5376. @textfonts
  5377. @rm
  5378. @c Local variables:
  5379. @c eval: (add-hook 'write-file-hooks 'time-stamp)
  5380. @c page-delimiter: "^\\\\message"
  5381. @c time-stamp-start: "def\\\\texinfoversion{"
  5382. @c time-stamp-format: "%:y-%02m-%02d.%02H"
  5383. @c time-stamp-end: "}"
  5384. @c End: