PageRenderTime 96ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/js/src/ctypes/libffi/texinfo.tex

http://github.com/zpao/v8monkey
LaTeX | 7210 lines | 4102 code | 606 blank | 2502 comment | 0 complexity | 330cc83e650cc581dc85ffaa9cabb184 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-3.0, AGPL-1.0, LGPL-2.1, BSD-3-Clause, GPL-2.0, JSON, Apache-2.0, 0BSD
  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{2005-07-05.19}
  7. %
  8. % Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
  9. % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software
  10. % Foundation, Inc.
  11. %
  12. % This texinfo.tex file is free software; you can redistribute it and/or
  13. % modify it under the terms of the GNU General Public License as
  14. % published by the Free Software Foundation; either version 2, or (at
  15. % your option) any later version.
  16. %
  17. % This texinfo.tex file is distributed in the hope that it will be
  18. % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  19. % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. % General Public License for more details.
  21. %
  22. % You should have received a copy of the GNU General Public License
  23. % along with this texinfo.tex file; see the file COPYING. If not, write
  24. % to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  25. % Boston, MA 02110-1301, USA.
  26. %
  27. % As a special exception, when this file is read by TeX when processing
  28. % a Texinfo source document, you may use the result without
  29. % restriction. (This has been our intent since Texinfo was invented.)
  30. %
  31. % Please try the latest version of texinfo.tex before submitting bug
  32. % reports; you can get the latest version from:
  33. % http://www.gnu.org/software/texinfo/ (the Texinfo home page), or
  34. % ftp://tug.org/tex/texinfo.tex
  35. % (and all CTAN mirrors, see http://www.ctan.org).
  36. % The texinfo.tex in any given distribution could well be out
  37. % of date, so if that's what you're using, please check.
  38. %
  39. % Send bug reports to bug-texinfo@gnu.org. Please include including a
  40. % complete document in each bug report with which we can reproduce the
  41. % problem. Patches are, of course, greatly appreciated.
  42. %
  43. % To process a Texinfo manual with TeX, it's most reliable to use the
  44. % texi2dvi shell script that comes with the distribution. For a simple
  45. % manual foo.texi, however, you can get away with this:
  46. % tex foo.texi
  47. % texindex foo.??
  48. % tex foo.texi
  49. % tex foo.texi
  50. % dvips foo.dvi -o # or whatever; this makes foo.ps.
  51. % The extra TeX runs get the cross-reference information correct.
  52. % Sometimes one run after texindex suffices, and sometimes you need more
  53. % than two; texi2dvi does it as many times as necessary.
  54. %
  55. % It is possible to adapt texinfo.tex for other languages, to some
  56. % extent. You can get the existing language-specific files from the
  57. % full Texinfo distribution.
  58. %
  59. % The GNU Texinfo home page is http://www.gnu.org/software/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. \message{Basics,}
  67. \chardef\other=12
  68. % We never want plain's \outer definition of \+ in Texinfo.
  69. % For @tex, we can use \tabalign.
  70. \let\+ = \relax
  71. % Save some plain tex macros whose names we will redefine.
  72. \let\ptexb=\b
  73. \let\ptexbullet=\bullet
  74. \let\ptexc=\c
  75. \let\ptexcomma=\,
  76. \let\ptexdot=\.
  77. \let\ptexdots=\dots
  78. \let\ptexend=\end
  79. \let\ptexequiv=\equiv
  80. \let\ptexexclam=\!
  81. \let\ptexfootnote=\footnote
  82. \let\ptexgtr=>
  83. \let\ptexhat=^
  84. \let\ptexi=\i
  85. \let\ptexindent=\indent
  86. \let\ptexinsert=\insert
  87. \let\ptexlbrace=\{
  88. \let\ptexless=<
  89. \let\ptexnewwrite\newwrite
  90. \let\ptexnoindent=\noindent
  91. \let\ptexplus=+
  92. \let\ptexrbrace=\}
  93. \let\ptexslash=\/
  94. \let\ptexstar=\*
  95. \let\ptext=\t
  96. % If this character appears in an error message or help string, it
  97. % starts a new line in the output.
  98. \newlinechar = `^^J
  99. % Use TeX 3.0's \inputlineno to get the line number, for better error
  100. % messages, but if we're using an old version of TeX, don't do anything.
  101. %
  102. \ifx\inputlineno\thisisundefined
  103. \let\linenumber = \empty % Pre-3.0.
  104. \else
  105. \def\linenumber{l.\the\inputlineno:\space}
  106. \fi
  107. % Set up fixed words for English if not already set.
  108. \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
  109. \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
  110. \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
  111. \ifx\putwordin\undefined \gdef\putwordin{in}\fi
  112. \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
  113. \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
  114. \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
  115. \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
  116. \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
  117. \ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi
  118. \ifx\putwordof\undefined \gdef\putwordof{of}\fi
  119. \ifx\putwordon\undefined \gdef\putwordon{on}\fi
  120. \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi
  121. \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi
  122. \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi
  123. \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi
  124. \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi
  125. \ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi
  126. \ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi
  127. %
  128. \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
  129. \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
  130. \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
  131. \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
  132. \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
  133. \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
  134. \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
  135. \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
  136. \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
  137. \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
  138. \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
  139. \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
  140. %
  141. \ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi
  142. \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi
  143. \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi
  144. \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi
  145. \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi
  146. % In some macros, we cannot use the `\? notation---the left quote is
  147. % in some cases the escape char.
  148. \chardef\backChar = `\\
  149. \chardef\colonChar = `\:
  150. \chardef\commaChar = `\,
  151. \chardef\dotChar = `\.
  152. \chardef\exclamChar= `\!
  153. \chardef\plusChar = `\+
  154. \chardef\questChar = `\?
  155. \chardef\semiChar = `\;
  156. \chardef\underChar = `\_
  157. \chardef\spaceChar = `\ %
  158. \chardef\spacecat = 10
  159. \def\spaceisspace{\catcode\spaceChar=\spacecat}
  160. {% for help with debugging.
  161. % example usage: \expandafter\show\activebackslash
  162. \catcode`\! = 0 \catcode`\\ = \active
  163. !global!def!activebackslash{\}
  164. }
  165. % Ignore a token.
  166. %
  167. \def\gobble#1{}
  168. % The following is used inside several \edef's.
  169. \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
  170. % Hyphenation fixes.
  171. \hyphenation{
  172. Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
  173. ap-pen-dix bit-map bit-maps
  174. data-base data-bases eshell fall-ing half-way long-est man-u-script
  175. man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
  176. par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
  177. spell-ing spell-ings
  178. stand-alone strong-est time-stamp time-stamps which-ever white-space
  179. wide-spread wrap-around
  180. }
  181. % Margin to add to right of even pages, to left of odd pages.
  182. \newdimen\bindingoffset
  183. \newdimen\normaloffset
  184. \newdimen\pagewidth \newdimen\pageheight
  185. % For a final copy, take out the rectangles
  186. % that mark overfull boxes (in case you have decided
  187. % that the text looks ok even though it passes the margin).
  188. %
  189. \def\finalout{\overfullrule=0pt}
  190. % @| inserts a changebar to the left of the current line. It should
  191. % surround any changed text. This approach does *not* work if the
  192. % change spans more than two lines of output. To handle that, we would
  193. % have adopt a much more difficult approach (putting marks into the main
  194. % vertical list for the beginning and end of each change).
  195. %
  196. \def\|{%
  197. % \vadjust can only be used in horizontal mode.
  198. \leavevmode
  199. %
  200. % Append this vertical mode material after the current line in the output.
  201. \vadjust{%
  202. % We want to insert a rule with the height and depth of the current
  203. % leading; that is exactly what \strutbox is supposed to record.
  204. \vskip-\baselineskip
  205. %
  206. % \vadjust-items are inserted at the left edge of the type. So
  207. % the \llap here moves out into the left-hand margin.
  208. \llap{%
  209. %
  210. % For a thicker or thinner bar, change the `1pt'.
  211. \vrule height\baselineskip width1pt
  212. %
  213. % This is the space between the bar and the text.
  214. \hskip 12pt
  215. }%
  216. }%
  217. }
  218. % Sometimes it is convenient to have everything in the transcript file
  219. % and nothing on the terminal. We don't just call \tracingall here,
  220. % since that produces some useless output on the terminal. We also make
  221. % some effort to order the tracing commands to reduce output in the log
  222. % file; cf. trace.sty in LaTeX.
  223. %
  224. \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
  225. \def\loggingall{%
  226. \tracingstats2
  227. \tracingpages1
  228. \tracinglostchars2 % 2 gives us more in etex
  229. \tracingparagraphs1
  230. \tracingoutput1
  231. \tracingmacros2
  232. \tracingrestores1
  233. \showboxbreadth\maxdimen \showboxdepth\maxdimen
  234. \ifx\eTeXversion\undefined\else % etex gives us more logging
  235. \tracingscantokens1
  236. \tracingifs1
  237. \tracinggroups1
  238. \tracingnesting2
  239. \tracingassigns1
  240. \fi
  241. \tracingcommands3 % 3 gives us more in etex
  242. \errorcontextlines16
  243. }%
  244. % add check for \lastpenalty to plain's definitions. If the last thing
  245. % we did was a \nobreak, we don't want to insert more space.
  246. %
  247. \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
  248. \removelastskip\penalty-50\smallskip\fi\fi}
  249. \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
  250. \removelastskip\penalty-100\medskip\fi\fi}
  251. \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
  252. \removelastskip\penalty-200\bigskip\fi\fi}
  253. % For @cropmarks command.
  254. % Do @cropmarks to get crop marks.
  255. %
  256. \newif\ifcropmarks
  257. \let\cropmarks = \cropmarkstrue
  258. %
  259. % Dimensions to add cropmarks at corners.
  260. % Added by P. A. MacKay, 12 Nov. 1986
  261. %
  262. \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
  263. \newdimen\cornerlong \cornerlong=1pc
  264. \newdimen\cornerthick \cornerthick=.3pt
  265. \newdimen\topandbottommargin \topandbottommargin=.75in
  266. % Main output routine.
  267. \chardef\PAGE = 255
  268. \output = {\onepageout{\pagecontents\PAGE}}
  269. \newbox\headlinebox
  270. \newbox\footlinebox
  271. % \onepageout takes a vbox as an argument. Note that \pagecontents
  272. % does insertions, but you have to call it yourself.
  273. \def\onepageout#1{%
  274. \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
  275. %
  276. \ifodd\pageno \advance\hoffset by \bindingoffset
  277. \else \advance\hoffset by -\bindingoffset\fi
  278. %
  279. % Do this outside of the \shipout so @code etc. will be expanded in
  280. % the headline as they should be, not taken literally (outputting ''code).
  281. \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
  282. \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
  283. %
  284. {%
  285. % Have to do this stuff outside the \shipout because we want it to
  286. % take effect in \write's, yet the group defined by the \vbox ends
  287. % before the \shipout runs.
  288. %
  289. \indexdummies % don't expand commands in the output.
  290. \shipout\vbox{%
  291. % Do this early so pdf references go to the beginning of the page.
  292. \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
  293. %
  294. \ifcropmarks \vbox to \outervsize\bgroup
  295. \hsize = \outerhsize
  296. \vskip-\topandbottommargin
  297. \vtop to0pt{%
  298. \line{\ewtop\hfil\ewtop}%
  299. \nointerlineskip
  300. \line{%
  301. \vbox{\moveleft\cornerthick\nstop}%
  302. \hfill
  303. \vbox{\moveright\cornerthick\nstop}%
  304. }%
  305. \vss}%
  306. \vskip\topandbottommargin
  307. \line\bgroup
  308. \hfil % center the page within the outer (page) hsize.
  309. \ifodd\pageno\hskip\bindingoffset\fi
  310. \vbox\bgroup
  311. \fi
  312. %
  313. \unvbox\headlinebox
  314. \pagebody{#1}%
  315. \ifdim\ht\footlinebox > 0pt
  316. % Only leave this space if the footline is nonempty.
  317. % (We lessened \vsize for it in \oddfootingxxx.)
  318. % The \baselineskip=24pt in plain's \makefootline has no effect.
  319. \vskip 2\baselineskip
  320. \unvbox\footlinebox
  321. \fi
  322. %
  323. \ifcropmarks
  324. \egroup % end of \vbox\bgroup
  325. \hfil\egroup % end of (centering) \line\bgroup
  326. \vskip\topandbottommargin plus1fill minus1fill
  327. \boxmaxdepth = \cornerthick
  328. \vbox to0pt{\vss
  329. \line{%
  330. \vbox{\moveleft\cornerthick\nsbot}%
  331. \hfill
  332. \vbox{\moveright\cornerthick\nsbot}%
  333. }%
  334. \nointerlineskip
  335. \line{\ewbot\hfil\ewbot}%
  336. }%
  337. \egroup % \vbox from first cropmarks clause
  338. \fi
  339. }% end of \shipout\vbox
  340. }% end of group with \indexdummies
  341. \advancepageno
  342. \ifnum\outputpenalty>-20000 \else\dosupereject\fi
  343. }
  344. \newinsert\margin \dimen\margin=\maxdimen
  345. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  346. {\catcode`\@ =11
  347. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  348. % marginal hacks, juha@viisa.uucp (Juha Takala)
  349. \ifvoid\margin\else % marginal info is present
  350. \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
  351. \dimen@=\dp#1 \unvbox#1
  352. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  353. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  354. }
  355. % Here are the rules for the cropmarks. Note that they are
  356. % offset so that the space between them is truly \outerhsize or \outervsize
  357. % (P. A. MacKay, 12 November, 1986)
  358. %
  359. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  360. \def\nstop{\vbox
  361. {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  362. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  363. \def\nsbot{\vbox
  364. {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  365. % Parse an argument, then pass it to #1. The argument is the rest of
  366. % the input line (except we remove a trailing comment). #1 should be a
  367. % macro which expects an ordinary undelimited TeX argument.
  368. %
  369. \def\parsearg{\parseargusing{}}
  370. \def\parseargusing#1#2{%
  371. \def\next{#2}%
  372. \begingroup
  373. \obeylines
  374. \spaceisspace
  375. #1%
  376. \parseargline\empty% Insert the \empty token, see \finishparsearg below.
  377. }
  378. {\obeylines %
  379. \gdef\parseargline#1^^M{%
  380. \endgroup % End of the group started in \parsearg.
  381. \argremovecomment #1\comment\ArgTerm%
  382. }%
  383. }
  384. % First remove any @comment, then any @c comment.
  385. \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
  386. \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
  387. % Each occurence of `\^^M' or `<space>\^^M' is replaced by a single space.
  388. %
  389. % \argremovec might leave us with trailing space, e.g.,
  390. % @end itemize @c foo
  391. % This space token undergoes the same procedure and is eventually removed
  392. % by \finishparsearg.
  393. %
  394. \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
  395. \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
  396. \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
  397. \def\temp{#3}%
  398. \ifx\temp\empty
  399. % We cannot use \next here, as it holds the macro to run;
  400. % thus we reuse \temp.
  401. \let\temp\finishparsearg
  402. \else
  403. \let\temp\argcheckspaces
  404. \fi
  405. % Put the space token in:
  406. \temp#1 #3\ArgTerm
  407. }
  408. % If a _delimited_ argument is enclosed in braces, they get stripped; so
  409. % to get _exactly_ the rest of the line, we had to prevent such situation.
  410. % We prepended an \empty token at the very beginning and we expand it now,
  411. % just before passing the control to \next.
  412. % (Similarily, we have to think about #3 of \argcheckspacesY above: it is
  413. % either the null string, or it ends with \^^M---thus there is no danger
  414. % that a pair of braces would be stripped.
  415. %
  416. % But first, we have to remove the trailing space token.
  417. %
  418. \def\finishparsearg#1 \ArgTerm{\expandafter\next\expandafter{#1}}
  419. % \parseargdef\foo{...}
  420. % is roughly equivalent to
  421. % \def\foo{\parsearg\Xfoo}
  422. % \def\Xfoo#1{...}
  423. %
  424. % Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
  425. % favourite TeX trick. --kasal, 16nov03
  426. \def\parseargdef#1{%
  427. \expandafter \doparseargdef \csname\string#1\endcsname #1%
  428. }
  429. \def\doparseargdef#1#2{%
  430. \def#2{\parsearg#1}%
  431. \def#1##1%
  432. }
  433. % Several utility definitions with active space:
  434. {
  435. \obeyspaces
  436. \gdef\obeyedspace{ }
  437. % Make each space character in the input produce a normal interword
  438. % space in the output. Don't allow a line break at this space, as this
  439. % is used only in environments like @example, where each line of input
  440. % should produce a line of output anyway.
  441. %
  442. \gdef\sepspaces{\obeyspaces\let =\tie}
  443. % If an index command is used in an @example environment, any spaces
  444. % therein should become regular spaces in the raw index file, not the
  445. % expansion of \tie (\leavevmode \penalty \@M \ ).
  446. \gdef\unsepspaces{\let =\space}
  447. }
  448. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  449. % Define the framework for environments in texinfo.tex. It's used like this:
  450. %
  451. % \envdef\foo{...}
  452. % \def\Efoo{...}
  453. %
  454. % It's the responsibility of \envdef to insert \begingroup before the
  455. % actual body; @end closes the group after calling \Efoo. \envdef also
  456. % defines \thisenv, so the current environment is known; @end checks
  457. % whether the environment name matches. The \checkenv macro can also be
  458. % used to check whether the current environment is the one expected.
  459. %
  460. % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
  461. % are not treated as enviroments; they don't open a group. (The
  462. % implementation of @end takes care not to call \endgroup in this
  463. % special case.)
  464. % At runtime, environments start with this:
  465. \def\startenvironment#1{\begingroup\def\thisenv{#1}}
  466. % initialize
  467. \let\thisenv\empty
  468. % ... but they get defined via ``\envdef\foo{...}'':
  469. \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
  470. \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
  471. % Check whether we're in the right environment:
  472. \def\checkenv#1{%
  473. \def\temp{#1}%
  474. \ifx\thisenv\temp
  475. \else
  476. \badenverr
  477. \fi
  478. }
  479. % Evironment mismatch, #1 expected:
  480. \def\badenverr{%
  481. \errhelp = \EMsimple
  482. \errmessage{This command can appear only \inenvironment\temp,
  483. not \inenvironment\thisenv}%
  484. }
  485. \def\inenvironment#1{%
  486. \ifx#1\empty
  487. out of any environment%
  488. \else
  489. in environment \expandafter\string#1%
  490. \fi
  491. }
  492. % @end foo executes the definition of \Efoo.
  493. % But first, it executes a specialized version of \checkenv
  494. %
  495. \parseargdef\end{%
  496. \if 1\csname iscond.#1\endcsname
  497. \else
  498. % The general wording of \badenverr may not be ideal, but... --kasal, 06nov03
  499. \expandafter\checkenv\csname#1\endcsname
  500. \csname E#1\endcsname
  501. \endgroup
  502. \fi
  503. }
  504. \newhelp\EMsimple{Press RETURN to continue.}
  505. %% Simple single-character @ commands
  506. % @@ prints an @
  507. % Kludge this until the fonts are right (grr).
  508. \def\@{{\tt\char64}}
  509. % This is turned off because it was never documented
  510. % and you can use @w{...} around a quote to suppress ligatures.
  511. %% Define @` and @' to be the same as ` and '
  512. %% but suppressing ligatures.
  513. %\def\`{{`}}
  514. %\def\'{{'}}
  515. % Used to generate quoted braces.
  516. \def\mylbrace {{\tt\char123}}
  517. \def\myrbrace {{\tt\char125}}
  518. \let\{=\mylbrace
  519. \let\}=\myrbrace
  520. \begingroup
  521. % Definitions to produce \{ and \} commands for indices,
  522. % and @{ and @} for the aux/toc files.
  523. \catcode`\{ = \other \catcode`\} = \other
  524. \catcode`\[ = 1 \catcode`\] = 2
  525. \catcode`\! = 0 \catcode`\\ = \other
  526. !gdef!lbracecmd[\{]%
  527. !gdef!rbracecmd[\}]%
  528. !gdef!lbraceatcmd[@{]%
  529. !gdef!rbraceatcmd[@}]%
  530. !endgroup
  531. % @comma{} to avoid , parsing problems.
  532. \let\comma = ,
  533. % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
  534. % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
  535. \let\, = \c
  536. \let\dotaccent = \.
  537. \def\ringaccent#1{{\accent23 #1}}
  538. \let\tieaccent = \t
  539. \let\ubaraccent = \b
  540. \let\udotaccent = \d
  541. % Other special characters: @questiondown @exclamdown @ordf @ordm
  542. % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
  543. \def\questiondown{?`}
  544. \def\exclamdown{!`}
  545. \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
  546. \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
  547. % Dotless i and dotless j, used for accents.
  548. \def\imacro{i}
  549. \def\jmacro{j}
  550. \def\dotless#1{%
  551. \def\temp{#1}%
  552. \ifx\temp\imacro \ptexi
  553. \else\ifx\temp\jmacro \j
  554. \else \errmessage{@dotless can be used only with i or j}%
  555. \fi\fi
  556. }
  557. % The \TeX{} logo, as in plain, but resetting the spacing so that a
  558. % period following counts as ending a sentence. (Idea found in latex.)
  559. %
  560. \edef\TeX{\TeX \spacefactor=1000 }
  561. % @LaTeX{} logo. Not quite the same results as the definition in
  562. % latex.ltx, since we use a different font for the raised A; it's most
  563. % convenient for us to use an explicitly smaller font, rather than using
  564. % the \scriptstyle font (since we don't reset \scriptstyle and
  565. % \scriptscriptstyle).
  566. %
  567. \def\LaTeX{%
  568. L\kern-.36em
  569. {\setbox0=\hbox{T}%
  570. \vbox to \ht0{\hbox{\selectfonts\lllsize A}\vss}}%
  571. \kern-.15em
  572. \TeX
  573. }
  574. % Be sure we're in horizontal mode when doing a tie, since we make space
  575. % equivalent to this in @example-like environments. Otherwise, a space
  576. % at the beginning of a line will start with \penalty -- and
  577. % since \penalty is valid in vertical mode, we'd end up putting the
  578. % penalty on the vertical list instead of in the new paragraph.
  579. {\catcode`@ = 11
  580. % Avoid using \@M directly, because that causes trouble
  581. % if the definition is written into an index file.
  582. \global\let\tiepenalty = \@M
  583. \gdef\tie{\leavevmode\penalty\tiepenalty\ }
  584. }
  585. % @: forces normal size whitespace following.
  586. \def\:{\spacefactor=1000 }
  587. % @* forces a line break.
  588. \def\*{\hfil\break\hbox{}\ignorespaces}
  589. % @/ allows a line break.
  590. \let\/=\allowbreak
  591. % @. is an end-of-sentence period.
  592. \def\.{.\spacefactor=\endofsentencespacefactor\space}
  593. % @! is an end-of-sentence bang.
  594. \def\!{!\spacefactor=\endofsentencespacefactor\space}
  595. % @? is an end-of-sentence query.
  596. \def\?{?\spacefactor=\endofsentencespacefactor\space}
  597. % @frenchspacing on|off says whether to put extra space after punctuation.
  598. %
  599. \def\onword{on}
  600. \def\offword{off}
  601. %
  602. \parseargdef\frenchspacing{%
  603. \def\temp{#1}%
  604. \ifx\temp\onword \plainfrenchspacing
  605. \else\ifx\temp\offword \plainnonfrenchspacing
  606. \else
  607. \errhelp = \EMsimple
  608. \errmessage{Unknown @frenchspacing option `\temp', must be on/off}%
  609. \fi\fi
  610. }
  611. % @w prevents a word break. Without the \leavevmode, @w at the
  612. % beginning of a paragraph, when TeX is still in vertical mode, would
  613. % produce a whole line of output instead of starting the paragraph.
  614. \def\w#1{\leavevmode\hbox{#1}}
  615. % @group ... @end group forces ... to be all on one page, by enclosing
  616. % it in a TeX vbox. We use \vtop instead of \vbox to construct the box
  617. % to keep its height that of a normal line. According to the rules for
  618. % \topskip (p.114 of the TeXbook), the glue inserted is
  619. % max (\topskip - \ht (first item), 0). If that height is large,
  620. % therefore, no glue is inserted, and the space between the headline and
  621. % the text is small, which looks bad.
  622. %
  623. % Another complication is that the group might be very large. This can
  624. % cause the glue on the previous page to be unduly stretched, because it
  625. % does not have much material. In this case, it's better to add an
  626. % explicit \vfill so that the extra space is at the bottom. The
  627. % threshold for doing this is if the group is more than \vfilllimit
  628. % percent of a page (\vfilllimit can be changed inside of @tex).
  629. %
  630. \newbox\groupbox
  631. \def\vfilllimit{0.7}
  632. %
  633. \envdef\group{%
  634. \ifnum\catcode`\^^M=\active \else
  635. \errhelp = \groupinvalidhelp
  636. \errmessage{@group invalid in context where filling is enabled}%
  637. \fi
  638. \startsavinginserts
  639. %
  640. \setbox\groupbox = \vtop\bgroup
  641. % Do @comment since we are called inside an environment such as
  642. % @example, where each end-of-line in the input causes an
  643. % end-of-line in the output. We don't want the end-of-line after
  644. % the `@group' to put extra space in the output. Since @group
  645. % should appear on a line by itself (according to the Texinfo
  646. % manual), we don't worry about eating any user text.
  647. \comment
  648. }
  649. %
  650. % The \vtop produces a box with normal height and large depth; thus, TeX puts
  651. % \baselineskip glue before it, and (when the next line of text is done)
  652. % \lineskip glue after it. Thus, space below is not quite equal to space
  653. % above. But it's pretty close.
  654. \def\Egroup{%
  655. % To get correct interline space between the last line of the group
  656. % and the first line afterwards, we have to propagate \prevdepth.
  657. \endgraf % Not \par, as it may have been set to \lisppar.
  658. \global\dimen1 = \prevdepth
  659. \egroup % End the \vtop.
  660. % \dimen0 is the vertical size of the group's box.
  661. \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox
  662. % \dimen2 is how much space is left on the page (more or less).
  663. \dimen2 = \pageheight \advance\dimen2 by -\pagetotal
  664. % if the group doesn't fit on the current page, and it's a big big
  665. % group, force a page break.
  666. \ifdim \dimen0 > \dimen2
  667. \ifdim \pagetotal < \vfilllimit\pageheight
  668. \page
  669. \fi
  670. \fi
  671. \box\groupbox
  672. \prevdepth = \dimen1
  673. \checkinserts
  674. }
  675. %
  676. % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
  677. % message, so this ends up printing `@group can only ...'.
  678. %
  679. \newhelp\groupinvalidhelp{%
  680. group can only be used in environments such as @example,^^J%
  681. where each line of input produces a line of output.}
  682. % @need space-in-mils
  683. % forces a page break if there is not space-in-mils remaining.
  684. \newdimen\mil \mil=0.001in
  685. % Old definition--didn't work.
  686. %\parseargdef\need{\par %
  687. %% This method tries to make TeX break the page naturally
  688. %% if the depth of the box does not fit.
  689. %{\baselineskip=0pt%
  690. %\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak
  691. %\prevdepth=-1000pt
  692. %}}
  693. \parseargdef\need{%
  694. % Ensure vertical mode, so we don't make a big box in the middle of a
  695. % paragraph.
  696. \par
  697. %
  698. % If the @need value is less than one line space, it's useless.
  699. \dimen0 = #1\mil
  700. \dimen2 = \ht\strutbox
  701. \advance\dimen2 by \dp\strutbox
  702. \ifdim\dimen0 > \dimen2
  703. %
  704. % Do a \strut just to make the height of this box be normal, so the
  705. % normal leading is inserted relative to the preceding line.
  706. % And a page break here is fine.
  707. \vtop to #1\mil{\strut\vfil}%
  708. %
  709. % TeX does not even consider page breaks if a penalty added to the
  710. % main vertical list is 10000 or more. But in order to see if the
  711. % empty box we just added fits on the page, we must make it consider
  712. % page breaks. On the other hand, we don't want to actually break the
  713. % page after the empty box. So we use a penalty of 9999.
  714. %
  715. % There is an extremely small chance that TeX will actually break the
  716. % page at this \penalty, if there are no other feasible breakpoints in
  717. % sight. (If the user is using lots of big @group commands, which
  718. % almost-but-not-quite fill up a page, TeX will have a hard time doing
  719. % good page breaking, for example.) However, I could not construct an
  720. % example where a page broke at this \penalty; if it happens in a real
  721. % document, then we can reconsider our strategy.
  722. \penalty9999
  723. %
  724. % Back up by the size of the box, whether we did a page break or not.
  725. \kern -#1\mil
  726. %
  727. % Do not allow a page break right after this kern.
  728. \nobreak
  729. \fi
  730. }
  731. % @br forces paragraph break (and is undocumented).
  732. \let\br = \par
  733. % @page forces the start of a new page.
  734. %
  735. \def\page{\par\vfill\supereject}
  736. % @exdent text....
  737. % outputs text on separate line in roman font, starting at standard page margin
  738. % This records the amount of indent in the innermost environment.
  739. % That's how much \exdent should take out.
  740. \newskip\exdentamount
  741. % This defn is used inside fill environments such as @defun.
  742. \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
  743. % This defn is used inside nofill environments such as @example.
  744. \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
  745. \leftline{\hskip\leftskip{\rm#1}}}}
  746. % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
  747. % paragraph. For more general purposes, use the \margin insertion
  748. % class. WHICH is `l' or `r'.
  749. %
  750. \newskip\inmarginspacing \inmarginspacing=1cm
  751. \def\strutdepth{\dp\strutbox}
  752. %
  753. \def\doinmargin#1#2{\strut\vadjust{%
  754. \nobreak
  755. \kern-\strutdepth
  756. \vtop to \strutdepth{%
  757. \baselineskip=\strutdepth
  758. \vss
  759. % if you have multiple lines of stuff to put here, you'll need to
  760. % make the vbox yourself of the appropriate size.
  761. \ifx#1l%
  762. \llap{\ignorespaces #2\hskip\inmarginspacing}%
  763. \else
  764. \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
  765. \fi
  766. \null
  767. }%
  768. }}
  769. \def\inleftmargin{\doinmargin l}
  770. \def\inrightmargin{\doinmargin r}
  771. %
  772. % @inmargin{TEXT [, RIGHT-TEXT]}
  773. % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
  774. % else use TEXT for both).
  775. %
  776. \def\inmargin#1{\parseinmargin #1,,\finish}
  777. \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
  778. \setbox0 = \hbox{\ignorespaces #2}%
  779. \ifdim\wd0 > 0pt
  780. \def\lefttext{#1}% have both texts
  781. \def\righttext{#2}%
  782. \else
  783. \def\lefttext{#1}% have only one text
  784. \def\righttext{#1}%
  785. \fi
  786. %
  787. \ifodd\pageno
  788. \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
  789. \else
  790. \def\temp{\inleftmargin\lefttext}%
  791. \fi
  792. \temp
  793. }
  794. % @include file insert text of that file as input.
  795. %
  796. \def\include{\parseargusing\filenamecatcodes\includezzz}
  797. \def\includezzz#1{%
  798. \pushthisfilestack
  799. \def\thisfile{#1}%
  800. {%
  801. \makevalueexpandable
  802. \def\temp{\input #1 }%
  803. \expandafter
  804. }\temp
  805. \popthisfilestack
  806. }
  807. \def\filenamecatcodes{%
  808. \catcode`\\=\other
  809. \catcode`~=\other
  810. \catcode`^=\other
  811. \catcode`_=\other
  812. \catcode`|=\other
  813. \catcode`<=\other
  814. \catcode`>=\other
  815. \catcode`+=\other
  816. \catcode`-=\other
  817. }
  818. \def\pushthisfilestack{%
  819. \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
  820. }
  821. \def\pushthisfilestackX{%
  822. \expandafter\pushthisfilestackY\thisfile\StackTerm
  823. }
  824. \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
  825. \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
  826. }
  827. \def\popthisfilestack{\errthisfilestackempty}
  828. \def\errthisfilestackempty{\errmessage{Internal error:
  829. the stack of filenames is empty.}}
  830. \def\thisfile{}
  831. % @center line
  832. % outputs that line, centered.
  833. %
  834. \parseargdef\center{%
  835. \ifhmode
  836. \let\next\centerH
  837. \else
  838. \let\next\centerV
  839. \fi
  840. \next{\hfil \ignorespaces#1\unskip \hfil}%
  841. }
  842. \def\centerH#1{%
  843. {%
  844. \hfil\break
  845. \advance\hsize by -\leftskip
  846. \advance\hsize by -\rightskip
  847. \line{#1}%
  848. \break
  849. }%
  850. }
  851. \def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}}
  852. % @sp n outputs n lines of vertical space
  853. \parseargdef\sp{\vskip #1\baselineskip}
  854. % @comment ...line which is ignored...
  855. % @c is the same as @comment
  856. % @ignore ... @end ignore is another way to write a comment
  857. \def\comment{\begingroup \catcode`\^^M=\other%
  858. \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
  859. \commentxxx}
  860. {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
  861. \let\c=\comment
  862. % @paragraphindent NCHARS
  863. % We'll use ems for NCHARS, close enough.
  864. % NCHARS can also be the word `asis' or `none'.
  865. % We cannot feasibly implement @paragraphindent asis, though.
  866. %
  867. \def\asisword{asis} % no translation, these are keywords
  868. \def\noneword{none}
  869. %
  870. \parseargdef\paragraphindent{%
  871. \def\temp{#1}%
  872. \ifx\temp\asisword
  873. \else
  874. \ifx\temp\noneword
  875. \defaultparindent = 0pt
  876. \else
  877. \defaultparindent = #1em
  878. \fi
  879. \fi
  880. \parindent = \defaultparindent
  881. }
  882. % @exampleindent NCHARS
  883. % We'll use ems for NCHARS like @paragraphindent.
  884. % It seems @exampleindent asis isn't necessary, but
  885. % I preserve it to make it similar to @paragraphindent.
  886. \parseargdef\exampleindent{%
  887. \def\temp{#1}%
  888. \ifx\temp\asisword
  889. \else
  890. \ifx\temp\noneword
  891. \lispnarrowing = 0pt
  892. \else
  893. \lispnarrowing = #1em
  894. \fi
  895. \fi
  896. }
  897. % @firstparagraphindent WORD
  898. % If WORD is `none', then suppress indentation of the first paragraph
  899. % after a section heading. If WORD is `insert', then do indent at such
  900. % paragraphs.
  901. %
  902. % The paragraph indentation is suppressed or not by calling
  903. % \suppressfirstparagraphindent, which the sectioning commands do.
  904. % We switch the definition of this back and forth according to WORD.
  905. % By default, we suppress indentation.
  906. %
  907. \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
  908. \def\insertword{insert}
  909. %
  910. \parseargdef\firstparagraphindent{%
  911. \def\temp{#1}%
  912. \ifx\temp\noneword
  913. \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
  914. \else\ifx\temp\insertword
  915. \let\suppressfirstparagraphindent = \relax
  916. \else
  917. \errhelp = \EMsimple
  918. \errmessage{Unknown @firstparagraphindent option `\temp'}%
  919. \fi\fi
  920. }
  921. % Here is how we actually suppress indentation. Redefine \everypar to
  922. % \kern backwards by \parindent, and then reset itself to empty.
  923. %
  924. % We also make \indent itself not actually do anything until the next
  925. % paragraph.
  926. %
  927. \gdef\dosuppressfirstparagraphindent{%
  928. \gdef\indent{%
  929. \restorefirstparagraphindent
  930. \indent
  931. }%
  932. \gdef\noindent{%
  933. \restorefirstparagraphindent
  934. \noindent
  935. }%
  936. \global\everypar = {%
  937. \kern -\parindent
  938. \restorefirstparagraphindent
  939. }%
  940. }
  941. \gdef\restorefirstparagraphindent{%
  942. \global \let \indent = \ptexindent
  943. \global \let \noindent = \ptexnoindent
  944. \global \everypar = {}%
  945. }
  946. % @asis just yields its argument. Used with @table, for example.
  947. %
  948. \def\asis#1{#1}
  949. % @math outputs its argument in math mode.
  950. %
  951. % One complication: _ usually means subscripts, but it could also mean
  952. % an actual _ character, as in @math{@var{some_variable} + 1}. So make
  953. % _ active, and distinguish by seeing if the current family is \slfam,
  954. % which is what @var uses.
  955. {
  956. \catcode\underChar = \active
  957. \gdef\mathunderscore{%
  958. \catcode\underChar=\active
  959. \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
  960. }
  961. }
  962. % Another complication: we want \\ (and @\) to output a \ character.
  963. % FYI, plain.tex uses \\ as a temporary control sequence (why?), but
  964. % this is not advertised and we don't care. Texinfo does not
  965. % otherwise define @\.
  966. %
  967. % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
  968. \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
  969. %
  970. \def\math{%
  971. \tex
  972. \mathunderscore
  973. \let\\ = \mathbackslash
  974. \mathactive
  975. $\finishmath
  976. }
  977. \def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
  978. % Some active characters (such as <) are spaced differently in math.
  979. % We have to reset their definitions in case the @math was an argument
  980. % to a command which sets the catcodes (such as @item or @section).
  981. %
  982. {
  983. \catcode`^ = \active
  984. \catcode`< = \active
  985. \catcode`> = \active
  986. \catcode`+ = \active
  987. \gdef\mathactive{%
  988. \let^ = \ptexhat
  989. \let< = \ptexless
  990. \let> = \ptexgtr
  991. \let+ = \ptexplus
  992. }
  993. }
  994. % @bullet and @minus need the same treatment as @math, just above.
  995. \def\bullet{$\ptexbullet$}
  996. \def\minus{$-$}
  997. % @dots{} outputs an ellipsis using the current font.
  998. % We do .5em per period so that it has the same spacing in a typewriter
  999. % font as three actual period characters.
  1000. %
  1001. \def\dots{%
  1002. \leavevmode
  1003. \hbox to 1.5em{%
  1004. \hskip 0pt plus 0.25fil
  1005. .\hfil.\hfil.%
  1006. \hskip 0pt plus 0.5fil
  1007. }%
  1008. }
  1009. % @enddots{} is an end-of-sentence ellipsis.
  1010. %
  1011. \def\enddots{%
  1012. \dots
  1013. \spacefactor=\endofsentencespacefactor
  1014. }
  1015. % @comma{} is so commas can be inserted into text without messing up
  1016. % Texinfo's parsing.
  1017. %
  1018. \let\comma = ,
  1019. % @refill is a no-op.
  1020. \let\refill=\relax
  1021. % If working on a large document in chapters, it is convenient to
  1022. % be able to disable indexing, cross-referencing, and contents, for test runs.
  1023. % This is done with @novalidate (before @setfilename).
  1024. %
  1025. \newif\iflinks \linkstrue % by default we want the aux files.
  1026. \let\novalidate = \linksfalse
  1027. % @setfilename is done at the beginning of every texinfo file.
  1028. % So open here the files we need to have open while reading the input.
  1029. % This makes it possible to make a .fmt file for texinfo.
  1030. \def\setfilename{%
  1031. \fixbackslash % Turn off hack to swallow `\input texinfo'.
  1032. \iflinks
  1033. \tryauxfile
  1034. % Open the new aux file. TeX will close it automatically at exit.
  1035. \immediate\openout\auxfile=\jobname.aux
  1036. \fi % \openindices needs to do some work in any case.
  1037. \openindices
  1038. \let\setfilename=\comment % Ignore extra @setfilename cmds.
  1039. %
  1040. % If texinfo.cnf is present on the system, read it.
  1041. % Useful for site-wide @afourpaper, etc.
  1042. \openin 1 texinfo.cnf
  1043. \ifeof 1 \else \input texinfo.cnf \fi
  1044. \closein 1
  1045. %
  1046. \comment % Ignore the actual filename.
  1047. }
  1048. % Called from \setfilename.
  1049. %
  1050. \def\openindices{%
  1051. \newindex{cp}%
  1052. \newcodeindex{fn}%
  1053. \newcodeindex{vr}%
  1054. \newcodeindex{tp}%
  1055. \newcodeindex{ky}%
  1056. \newcodeindex{pg}%
  1057. }
  1058. % @bye.
  1059. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  1060. \message{pdf,}
  1061. % adobe `portable' document format
  1062. \newcount\tempnum
  1063. \newcount\lnkcount
  1064. \newtoks\filename
  1065. \newcount\filenamelength
  1066. \newcount\pgn
  1067. \newtoks\toksA
  1068. \newtoks\toksB
  1069. \newtoks\toksC
  1070. \newtoks\toksD
  1071. \newbox\boxA
  1072. \newcount\countA
  1073. \newif\ifpdf
  1074. \newif\ifpdfmakepagedest
  1075. % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
  1076. % can be set). So we test for \relax and 0 as well as \undefined,
  1077. % borrowed from ifpdf.sty.
  1078. \ifx\pdfoutput\undefined
  1079. \else
  1080. \ifx\pdfoutput\relax
  1081. \else
  1082. \ifcase\pdfoutput
  1083. \else
  1084. \pdftrue
  1085. \fi
  1086. \fi
  1087. \fi
  1088. % PDF uses PostScript string constants for the names of xref targets, to
  1089. % for display in the outlines, and in other places. Thus, we have to
  1090. % double any backslashes. Otherwise, a name like "\node" will be
  1091. % interpreted as a newline (\n), followed by o, d, e. Not good.
  1092. % http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html
  1093. % (and related messages, the final outcome is that it is up to the TeX
  1094. % user to double the backslashes and otherwise make the string valid, so
  1095. % that's we do).
  1096. % double active backslashes.
  1097. %
  1098. {\catcode`\@=0 \catcode`\\=\active
  1099. @gdef@activebackslash{@catcode`@\=@active @otherbackslash}
  1100. @gdef@activebackslashdouble{%
  1101. @catcode@backChar=@active
  1102. @let\=@doublebackslash}
  1103. }
  1104. % To handle parens, we must adopt a different approach, since parens are
  1105. % not active characters. hyperref.dtx (which has the same problem as
  1106. % us) handles it with this amazing macro to replace tokens. I've
  1107. % tinkered with it a little for texinfo, but it's definitely from there.
  1108. %
  1109. % #1 is the tokens to replace.
  1110. % #2 is the replacement.
  1111. % #3 is the control sequence with the string.
  1112. %
  1113. \def\HyPsdSubst#1#2#3{%
  1114. \def\HyPsdReplace##1#1##2\END{%
  1115. ##1%
  1116. \ifx\\##2\\%
  1117. \else
  1118. #2%
  1119. \HyReturnAfterFi{%
  1120. \HyPsdReplace##2\END
  1121. }%
  1122. \fi
  1123. }%
  1124. \xdef#3{\expandafter\HyPsdReplace#3#1\END}%
  1125. }
  1126. \long\def\HyReturnAfterFi#1\fi{\fi#1}
  1127. % #1 is a control sequence in which to do the replacements.
  1128. \def\backslashparens#1{%
  1129. \xdef#1{#1}% redefine it as its expansion; the definition is simply
  1130. % \lastnode when called from \setref -> \pdfmkdest.
  1131. \HyPsdSubst{(}{\backslashlparen}{#1}%
  1132. \HyPsdSubst{)}{\backslashrparen}{#1}%
  1133. }
  1134. {\catcode\exclamChar = 0 \catcode\backChar = \other
  1135. !gdef!backslashlparen{\(}%
  1136. !gdef!backslashrparen{\)}%
  1137. }
  1138. \ifpdf
  1139. \input pdfcolor
  1140. \pdfcatalog{/PageMode /UseOutlines}%
  1141. \def\dopdfimage#1#2#3{%
  1142. \def\imagewidth{#2}%
  1143. \def\imageheight{#3}%
  1144. % without \immediate, pdftex seg faults when the same image is
  1145. % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.)
  1146. \ifnum\pdftexversion < 14
  1147. \immediate\pdfimage
  1148. \else
  1149. \immediate\pdfximage
  1150. \fi
  1151. \ifx\empty\imagewidth\else width \imagewidth \fi
  1152. \ifx\empty\imageheight\else height \imageheight \fi
  1153. \ifnum\pdftexversion<13
  1154. #1.pdf%
  1155. \else
  1156. {#1.pdf}%
  1157. \fi
  1158. \ifnum\pdftexversion < 14 \else
  1159. \pdfrefximage \pdflastximage
  1160. \fi}
  1161. \def\pdfmkdest#1{{%
  1162. % We have to set dummies so commands such as @code, and characters
  1163. % such as \, aren't expanded when present in a section title.
  1164. \atdummies
  1165. \activebackslashdouble
  1166. \def\pdfdestname{#1}%
  1167. \backslashparens\pdfdestname
  1168. \pdfdest name{\pdfdestname} xyz%
  1169. }}%
  1170. %
  1171. % used to mark target names; must be expandable.
  1172. \def\pdfmkpgn#1{#1}%
  1173. %
  1174. \let\linkcolor = \Blue % was Cyan, but that seems light?
  1175. \def\endlink{\Black\pdfendlink}
  1176. % Adding outlines to PDF; macros for calculating structure of outlines
  1177. % come from Petr Olsak
  1178. \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
  1179. \else \csname#1\endcsname \fi}
  1180. \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
  1181. \advance\tempnum by 1
  1182. \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
  1183. %
  1184. % #1 is the section text, which is what will be displayed in the
  1185. % outline by the pdf viewer. #2 is the pdf expression for the number
  1186. % of subentries (or empty, for subsubsections). #3 is the node text,
  1187. % which might be empty if this toc entry had no corresponding node.
  1188. % #4 is the page number
  1189. %
  1190. \def\dopdfoutline#1#2#3#4{%
  1191. % Generate a link to the node text if that exists; else, use the
  1192. % page number. We could generate a destination for the section
  1193. % text in the case where a section has no node, but it doesn't
  1194. % seem worth the trouble, since most documents are normally structured.
  1195. \def\pdfoutlinedest{#3}%
  1196. \ifx\pdfoutlinedest\empty
  1197. \def\pdfoutlinedest{#4}%
  1198. \else
  1199. % Doubled backslashes in the name.
  1200. {\activebackslashdouble \xdef\pdfoutlinedest{#3}%
  1201. \backslashparens\pdfoutlinedest}%
  1202. \fi
  1203. %
  1204. % Also double the backslashes in the display string.
  1205. {\activebackslashdouble \xdef\pdfoutlinetext{#1}%
  1206. \backslashparens\pdfoutlinetext}%
  1207. %
  1208. \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
  1209. }
  1210. %
  1211. \def\pdfmakeoutlines{%
  1212. \begingroup
  1213. % Thanh's hack / proper braces in bookmarks
  1214. \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace
  1215. \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace
  1216. %
  1217. % Read toc silently, to get counts of subentries for \pdfoutline.
  1218. \def\numchapentry##1##2##3##4{%
  1219. \def\thischapnum{##2}%
  1220. \def\thissecnum{0}%
  1221. \def\thissubsecnum{0}%
  1222. }%
  1223. \def\numsecentry##1##2##3##4{%
  1224. \advancenumber{chap\thischapnum}%
  1225. \def\thissecnum{##2}%
  1226. \def\thissubsecnum{0}%
  1227. }%
  1228. \def\numsubsecentry##1##2##3##4{%
  1229. \advancenumber{sec\thissecnum}%
  1230. \def\thissubsecnum{##2}%
  1231. }%
  1232. \def\numsubsubsecentry##1##2##3##4{%
  1233. \advancenumber{subsec\thissubsecnum}%
  1234. }%
  1235. \def\thischapnum{0}%
  1236. \def\thissecnum{0}%
  1237. \def\thissubsecnum{0}%
  1238. %
  1239. % use \def rather than \let here because we redefine \chapentry et
  1240. % al. a second time, below.
  1241. \def\appentry{\numchapentry}%
  1242. \def\appsecentry{\numsecentry}%
  1243. \def\appsubsecentry{\numsubsecentry}%
  1244. \def\appsubsubsecentry{\numsubsubsecentry}%
  1245. \def\unnchapentry{\numchapentry}%
  1246. \def\unnsecentry{\numsecentry}%
  1247. \def\unnsubsecentry{\numsubsecentry}%
  1248. \def\unnsubsubsecentry{\numsubsubsecentry}%
  1249. \readdatafile{toc}%
  1250. %
  1251. % Read toc second time, this time actually producing the outlines.
  1252. % The `-' means take the \expnumber as the absolute number of
  1253. % subentries, which we calculated on our first read of the .toc above.
  1254. %
  1255. % We use the node names as the destinations.
  1256. \def\numchapentry##1##2##3##4{%
  1257. \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
  1258. \def\numsecentry##1##2##3##4{%
  1259. \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
  1260. \def\numsubsecentry##1##2##3##4{%
  1261. \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
  1262. \def\numsubsubsecentry##1##2##3##4{% count is always zero
  1263. \dopdfoutline{##1}{}{##3}{##4}}%
  1264. %
  1265. % PDF outlines are displayed using system fonts, instead of
  1266. % document fonts. Therefore we cannot use special characters,
  1267. % since the encoding is unknown. For example, the eogonek from
  1268. % Latin 2 (0xea) gets translated to a | character. Info from
  1269. % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
  1270. %
  1271. % xx to do this right, we have to translate 8-bit characters to
  1272. % their "best" equivalent, based on the @documentencoding. Right
  1273. % now, I guess we'll just let the pdf reader have its way.
  1274. \indexnofonts
  1275. \setupdatafile
  1276. \activebackslash
  1277. \input \jobname.toc
  1278. \endgroup
  1279. }
  1280. %
  1281. \def\skipspaces#1{\def\PP{#1}\def\D{|}%
  1282. \ifx\PP\D\let\nextsp\relax
  1283. \else\let\nextsp\skipspaces
  1284. \ifx\p\space\else\addtokens{\filename}{\PP}%
  1285. \advance\filenamelength by 1
  1286. \fi
  1287. \fi
  1288. \nextsp}
  1289. \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax}
  1290. \ifnum\pdftexversion < 14
  1291. \let \startlink \pdfannotlink
  1292. \else
  1293. \let \startlink \pdfstartlink
  1294. \fi
  1295. \def\pdfurl#1{%
  1296. \begingroup
  1297. \normalturnoffactive\def\@{@}%
  1298. \makevalueexpandable
  1299. \leavevmode\Red
  1300. \startlink attr{/Border [0 0 0]}%
  1301. user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
  1302. \endgroup}
  1303. \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
  1304. \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
  1305. \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
  1306. \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
  1307. \def\maketoks{%
  1308. \expandafter\poptoks\the\toksA|ENDTOKS|\relax
  1309. \ifx\first0\adn0
  1310. \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
  1311. \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
  1312. \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
  1313. \else
  1314. \ifnum0=\countA\else\makelink\fi
  1315. \ifx\first.\let\next=\done\else
  1316. \let\next=\maketoks
  1317. \addtokens{\toksB}{\the\toksD}
  1318. \ifx\first,\addtokens{\toksB}{\space}\fi
  1319. \fi
  1320. \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
  1321. \next}
  1322. \def\makelink{\addtokens{\toksB}%
  1323. {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
  1324. \def\pdflink#1{%
  1325. \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
  1326. \linkcolor #1\endlink}
  1327. \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
  1328. \else
  1329. \let\pdfmkdest = \gobble
  1330. \let\pdfurl = \gobble
  1331. \let\endlink = \relax
  1332. \let\linkcolor = \relax
  1333. \let\pdfmakeoutlines = \relax
  1334. \fi % \ifx\pdfoutput
  1335. \message{fonts,}
  1336. % Change the current font style to #1, remembering it in \curfontstyle.
  1337. % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
  1338. % italics, not bold italics.
  1339. %
  1340. \def\setfontstyle#1{%
  1341. \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
  1342. \csname ten#1\endcsname % change the current font
  1343. }
  1344. % Select #1 fonts with the current style.
  1345. %
  1346. \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
  1347. \def\rm{\fam=0 \setfontstyle{rm}}
  1348. \def\it{\fam=\itfam \setfontstyle{it}}
  1349. \def\sl{\fam=\slfam \setfontstyle{sl}}
  1350. \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
  1351. \def\tt{\fam=\ttfam \setfontstyle{tt}}
  1352. % Texinfo sort of supports the sans serif font style, which plain TeX does not.
  1353. % So we set up a \sf.
  1354. \newfam\sffam
  1355. \def\sf{\fam=\sffam \setfontstyle{sf}}
  1356. \let\li = \sf % Sometimes we call it \li, not \sf.
  1357. % We don't need math for this font style.
  1358. \def\ttsl{\setfontstyle{ttsl}}
  1359. % Default leading.
  1360. \newdimen\textleading \textleading = 13.2pt
  1361. % Set the baselineskip to #1, and the lineskip and strut size
  1362. % correspondingly. There is no deep meaning behind these magic numbers
  1363. % used as factors; they just match (closely enough) what Knuth defined.
  1364. %
  1365. \def\lineskipfactor{.08333}
  1366. \def\strutheightpercent{.70833}
  1367. \def\strutdepthpercent {.29167}
  1368. %
  1369. \def\setleading#1{%
  1370. \normalbaselineskip = #1\relax
  1371. \normallineskip = \lineskipfactor\normalbaselineskip
  1372. \normalbaselines
  1373. \setbox\strutbox =\hbox{%
  1374. \vrule width0pt height\strutheightpercent\baselineskip
  1375. depth \strutdepthpercent \baselineskip
  1376. }%
  1377. }
  1378. % Set the font macro #1 to the font named #2, adding on the
  1379. % specified font prefix (normally `cm').
  1380. % #3 is the font's design size, #4 is a scale factor
  1381. \def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4}
  1382. % Use cm as the default font prefix.
  1383. % To specify the font prefix, you must define \fontprefix
  1384. % before you read in texinfo.tex.
  1385. \ifx\fontprefix\undefined
  1386. \def\fontprefix{cm}
  1387. \fi
  1388. % Support font families that don't use the same naming scheme as CM.
  1389. \def\rmshape{r}
  1390. \def\rmbshape{bx} %where the normal face is bold
  1391. \def\bfshape{b}
  1392. \def\bxshape{bx}
  1393. \def\ttshape{tt}
  1394. \def\ttbshape{tt}
  1395. \def\ttslshape{sltt}
  1396. \def\itshape{ti}
  1397. \def\itbshape{bxti}
  1398. \def\slshape{sl}
  1399. \def\slbshape{bxsl}
  1400. \def\sfshape{ss}
  1401. \def\sfbshape{ss}
  1402. \def\scshape{csc}
  1403. \def\scbshape{csc}
  1404. % Text fonts (11.2pt, magstep1).
  1405. \def\textnominalsize{11pt}
  1406. \edef\mainmagstep{\magstephalf}
  1407. \setfont\textrm\rmshape{10}{\mainmagstep}
  1408. \setfont\texttt\ttshape{10}{\mainmagstep}
  1409. \setfont\textbf\bfshape{10}{\mainmagstep}
  1410. \setfont\textit\itshape{10}{\mainmagstep}
  1411. \setfont\textsl\slshape{10}{\mainmagstep}
  1412. \setfont\textsf\sfshape{10}{\mainmagstep}
  1413. \setfont\textsc\scshape{10}{\mainmagstep}
  1414. \setfont\textttsl\ttslshape{10}{\mainmagstep}
  1415. \font\texti=cmmi10 scaled \mainmagstep
  1416. \font\textsy=cmsy10 scaled \mainmagstep
  1417. % A few fonts for @defun names and args.
  1418. \setfont\defbf\bfshape{10}{\magstep1}
  1419. \setfont\deftt\ttshape{10}{\magstep1}
  1420. \setfont\defttsl\ttslshape{10}{\magstep1}
  1421. \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
  1422. % Fonts for indices, footnotes, small examples (9pt).
  1423. \def\smallnominalsize{9pt}
  1424. \setfont\smallrm\rmshape{9}{1000}
  1425. \setfont\smalltt\ttshape{9}{1000}
  1426. \setfont\smallbf\bfshape{10}{900}
  1427. \setfont\smallit\itshape{9}{1000}
  1428. \setfont\smallsl\slshape{9}{1000}
  1429. \setfont\smallsf\sfshape{9}{1000}
  1430. \setfont\smallsc\scshape{10}{900}
  1431. \setfont\smallttsl\ttslshape{10}{900}
  1432. \font\smalli=cmmi9
  1433. \font\smallsy=cmsy9
  1434. % Fonts for small examples (8pt).
  1435. \def\smallernominalsize{8pt}
  1436. \setfont\smallerrm\rmshape{8}{1000}
  1437. \setfont\smallertt\ttshape{8}{1000}
  1438. \setfont\smallerbf\bfshape{10}{800}
  1439. \setfont\smallerit\itshape{8}{1000}
  1440. \setfont\smallersl\slshape{8}{1000}
  1441. \setfont\smallersf\sfshape{8}{1000}
  1442. \setfont\smallersc\scshape{10}{800}
  1443. \setfont\smallerttsl\ttslshape{10}{800}
  1444. \font\smalleri=cmmi8
  1445. \font\smallersy=cmsy8
  1446. % Fonts for title page (20.4pt):
  1447. \def\titlenominalsize{20pt}
  1448. \setfont\titlerm\rmbshape{12}{\magstep3}
  1449. \setfont\titleit\itbshape{10}{\magstep4}
  1450. \setfont\titlesl\slbshape{10}{\magstep4}
  1451. \setfont\titlett\ttbshape{12}{\magstep3}
  1452. \setfont\titlettsl\ttslshape{10}{\magstep4}
  1453. \setfont\titlesf\sfbshape{17}{\magstep1}
  1454. \let\titlebf=\titlerm
  1455. \setfont\titlesc\scbshape{10}{\magstep4}
  1456. \font\titlei=cmmi12 scaled \magstep3
  1457. \font\titlesy=cmsy10 scaled \magstep4
  1458. \def\authorrm{\secrm}
  1459. \def\authortt{\sectt}
  1460. % Chapter (and unnumbered) fonts (17.28pt).
  1461. \def\chapnominalsize{17pt}
  1462. \setfont\chaprm\rmbshape{12}{\magstep2}
  1463. \setfont\chapit\itbshape{10}{\magstep3}
  1464. \setfont\chapsl\slbshape{10}{\magstep3}
  1465. \setfont\chaptt\ttbshape{12}{\magstep2}
  1466. \setfont\chapttsl\ttslshape{10}{\magstep3}
  1467. \setfont\chapsf\sfbshape{17}{1000}
  1468. \let\chapbf=\chaprm
  1469. \setfont\chapsc\scbshape{10}{\magstep3}
  1470. \font\chapi=cmmi12 scaled \magstep2
  1471. \font\chapsy=cmsy10 scaled \magstep3
  1472. % Section fonts (14.4pt).
  1473. \def\secnominalsize{14pt}
  1474. \setfont\secrm\rmbshape{12}{\magstep1}
  1475. \setfont\secit\itbshape{10}{\magstep2}
  1476. \setfont\secsl\slbshape{10}{\magstep2}
  1477. \setfont\sectt\ttbshape{12}{\magstep1}
  1478. \setfont\secttsl\ttslshape{10}{\magstep2}
  1479. \setfont\secsf\sfbshape{12}{\magstep1}
  1480. \let\secbf\secrm
  1481. \setfont\secsc\scbshape{10}{\magstep2}
  1482. \font\seci=cmmi12 scaled \magstep1
  1483. \font\secsy=cmsy10 scaled \magstep2
  1484. % Subsection fonts (13.15pt).
  1485. \def\ssecnominalsize{13pt}
  1486. \setfont\ssecrm\rmbshape{12}{\magstephalf}
  1487. \setfont\ssecit\itbshape{10}{1315}
  1488. \setfont\ssecsl\slbshape{10}{1315}
  1489. \setfont\ssectt\ttbshape{12}{\magstephalf}
  1490. \setfont\ssecttsl\ttslshape{10}{1315}
  1491. \setfont\ssecsf\sfbshape{12}{\magstephalf}
  1492. \let\ssecbf\ssecrm
  1493. \setfont\ssecsc\scbshape{10}{1315}
  1494. \font\sseci=cmmi12 scaled \magstephalf
  1495. \font\ssecsy=cmsy10 scaled 1315
  1496. % Reduced fonts for @acro in text (10pt).
  1497. \def\reducednominalsize{10pt}
  1498. \setfont\reducedrm\rmshape{10}{1000}
  1499. \setfont\reducedtt\ttshape{10}{1000}
  1500. \setfont\reducedbf\bfshape{10}{1000}
  1501. \setfont\reducedit\itshape{10}{1000}
  1502. \setfont\reducedsl\slshape{10}{1000}
  1503. \setfont\reducedsf\sfshape{10}{1000}
  1504. \setfont\reducedsc\scshape{10}{1000}
  1505. \setfont\reducedttsl\ttslshape{10}{1000}
  1506. \font\reducedi=cmmi10
  1507. \font\reducedsy=cmsy10
  1508. % In order for the font changes to affect most math symbols and letters,
  1509. % we have to define the \textfont of the standard families. Since
  1510. % texinfo doesn't allow for producing subscripts and superscripts except
  1511. % in the main text, we don't bother to reset \scriptfont and
  1512. % \scriptscriptfont (which would also require loading a lot more fonts).
  1513. %
  1514. \def\resetmathfonts{%
  1515. \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
  1516. \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
  1517. \textfont\ttfam=\tentt \textfont\sffam=\tensf
  1518. }
  1519. % The font-changing commands redefine the meanings of \tenSTYLE, instead
  1520. % of just \STYLE. We do this because \STYLE needs to also set the
  1521. % current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire
  1522. % \tenSTYLE to set the current font.
  1523. %
  1524. % Each font-changing command also sets the names \lsize (one size lower)
  1525. % and \lllsize (three sizes lower). These relative commands are used in
  1526. % the LaTeX logo and acronyms.
  1527. %
  1528. % This all needs generalizing, badly.
  1529. %
  1530. \def\textfonts{%
  1531. \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
  1532. \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
  1533. \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
  1534. \let\tenttsl=\textttsl
  1535. \def\curfontsize{text}%
  1536. \def\lsize{reduced}\def\lllsize{smaller}%
  1537. \resetmathfonts \setleading{\textleading}}
  1538. \def\titlefonts{%
  1539. \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
  1540. \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
  1541. \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
  1542. \let\tenttsl=\titlettsl
  1543. \def\curfontsize{title}%
  1544. \def\lsize{chap}\def\lllsize{subsec}%
  1545. \resetmathfonts \setleading{25pt}}
  1546. \def\titlefont#1{{\titlefonts\rm #1}}
  1547. \def\chapfonts{%
  1548. \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
  1549. \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
  1550. \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
  1551. \let\tenttsl=\chapttsl
  1552. \def\curfontsize{chap}%
  1553. \def\lsize{sec}\def\lllsize{text}%
  1554. \resetmathfonts \setleading{19pt}}
  1555. \def\secfonts{%
  1556. \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
  1557. \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
  1558. \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
  1559. \let\tenttsl=\secttsl
  1560. \def\curfontsize{sec}%
  1561. \def\lsize{subsec}\def\lllsize{reduced}%
  1562. \resetmathfonts \setleading{16pt}}
  1563. \def\subsecfonts{%
  1564. \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
  1565. \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
  1566. \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
  1567. \let\tenttsl=\ssecttsl
  1568. \def\curfontsize{ssec}%
  1569. \def\lsize{text}\def\lllsize{small}%
  1570. \resetmathfonts \setleading{15pt}}
  1571. \let\subsubsecfonts = \subsecfonts
  1572. \def\reducedfonts{%
  1573. \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl
  1574. \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc
  1575. \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy
  1576. \let\tenttsl=\reducedttsl
  1577. \def\curfontsize{reduced}%
  1578. \def\lsize{small}\def\lllsize{smaller}%
  1579. \resetmathfonts \setleading{10.5pt}}
  1580. \def\smallfonts{%
  1581. \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
  1582. \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
  1583. \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
  1584. \let\tenttsl=\smallttsl
  1585. \def\curfontsize{small}%
  1586. \def\lsize{smaller}\def\lllsize{smaller}%
  1587. \resetmathfonts \setleading{10.5pt}}
  1588. \def\smallerfonts{%
  1589. \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
  1590. \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
  1591. \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
  1592. \let\tenttsl=\smallerttsl
  1593. \def\curfontsize{smaller}%
  1594. \def\lsize{smaller}\def\lllsize{smaller}%
  1595. \resetmathfonts \setleading{9.5pt}}
  1596. % Set the fonts to use with the @small... environments.
  1597. \let\smallexamplefonts = \smallfonts
  1598. % About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample
  1599. % can fit this many characters:
  1600. % 8.5x11=86 smallbook=72 a4=90 a5=69
  1601. % If we use \scriptfonts (8pt), then we can fit this many characters:
  1602. % 8.5x11=90+ smallbook=80 a4=90+ a5=77
  1603. % For me, subjectively, the few extra characters that fit aren't worth
  1604. % the additional smallness of 8pt. So I'm making the default 9pt.
  1605. %
  1606. % By the way, for comparison, here's what fits with @example (10pt):
  1607. % 8.5x11=71 smallbook=60 a4=75 a5=58
  1608. %
  1609. % I wish the USA used A4 paper.
  1610. % --karl, 24jan03.
  1611. % Set up the default fonts, so we can use them for creating boxes.
  1612. %
  1613. \textfonts \rm
  1614. % Define these so they can be easily changed for other fonts.
  1615. \def\angleleft{$\langle$}
  1616. \def\angleright{$\rangle$}
  1617. % Count depth in font-changes, for error checks
  1618. \newcount\fontdepth \fontdepth=0
  1619. % Fonts for short table of contents.
  1620. \setfont\shortcontrm\rmshape{12}{1000}
  1621. \setfont\shortcontbf\bfshape{10}{\magstep1} % no cmb12
  1622. \setfont\shortcontsl\slshape{12}{1000}
  1623. \setfont\shortconttt\ttshape{12}{1000}
  1624. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  1625. %% serif) and @ii for TeX italic
  1626. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  1627. % unless the following character is such as not to need one.
  1628. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else
  1629. \ptexslash\fi\fi\fi}
  1630. \def\smartslanted#1{{\ifusingtt\ttsl\sl #1}\futurelet\next\smartitalicx}
  1631. \def\smartitalic#1{{\ifusingtt\ttsl\it #1}\futurelet\next\smartitalicx}
  1632. % like \smartslanted except unconditionally uses \ttsl.
  1633. % @var is set to this for defun arguments.
  1634. \def\ttslanted#1{{\ttsl #1}\futurelet\next\smartitalicx}
  1635. % like \smartslanted except unconditionally use \sl. We never want
  1636. % ttsl for book titles, do we?
  1637. \def\cite#1{{\sl #1}\futurelet\next\smartitalicx}
  1638. \let\i=\smartitalic
  1639. \let\slanted=\smartslanted
  1640. \let\var=\smartslanted
  1641. \let\dfn=\smartslanted
  1642. \let\emph=\smartitalic
  1643. % @b, explicit bold.
  1644. \def\b#1{{\bf #1}}
  1645. \let\strong=\b
  1646. % @sansserif, explicit sans.
  1647. \def\sansserif#1{{\sf #1}}
  1648. % We can't just use \exhyphenpenalty, because that only has effect at
  1649. % the end of a paragraph. Restore normal hyphenation at the end of the
  1650. % group within which \nohyphenation is presumably called.
  1651. %
  1652. \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
  1653. \def\restorehyphenation{\hyphenchar\font = `- }
  1654. % Set sfcode to normal for the chars that usually have another value.
  1655. % Can't use plain's \frenchspacing because it uses the `\x notation, and
  1656. % sometimes \x has an active definition that messes things up.
  1657. %
  1658. \catcode`@=11
  1659. \def\plainfrenchspacing{%
  1660. \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m
  1661. \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m
  1662. \def\endofsentencespacefactor{1000}% for @. and friends
  1663. }
  1664. \def\plainnonfrenchspacing{%
  1665. \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
  1666. \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
  1667. \def\endofsentencespacefactor{3000}% for @. and friends
  1668. }
  1669. \catcode`@=\other
  1670. \def\endofsentencespacefactor{3000}% default
  1671. \def\t#1{%
  1672. {\tt \rawbackslash \plainfrenchspacing #1}%
  1673. \null
  1674. }
  1675. \def\samp#1{`\tclose{#1}'\null}
  1676. \setfont\keyrm\rmshape{8}{1000}
  1677. \font\keysy=cmsy9
  1678. \def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
  1679. \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
  1680. \vbox{\hrule\kern-0.4pt
  1681. \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
  1682. \kern-0.4pt\hrule}%
  1683. \kern-.06em\raise0.4pt\hbox{\angleright}}}}
  1684. % The old definition, with no lozenge:
  1685. %\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null}
  1686. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  1687. % @file, @option are the same as @samp.
  1688. \let\file=\samp
  1689. \let\option=\samp
  1690. % @code is a modification of @t,
  1691. % which makes spaces the same size as normal in the surrounding text.
  1692. \def\tclose#1{%
  1693. {%
  1694. % Change normal interword space to be same as for the current font.
  1695. \spaceskip = \fontdimen2\font
  1696. %
  1697. % Switch to typewriter.
  1698. \tt
  1699. %
  1700. % But `\ ' produces the large typewriter interword space.
  1701. \def\ {{\spaceskip = 0pt{} }}%
  1702. %
  1703. % Turn off hyphenation.
  1704. \nohyphenation
  1705. %
  1706. \rawbackslash
  1707. \plainfrenchspacing
  1708. #1%
  1709. }%
  1710. \null
  1711. }
  1712. % We *must* turn on hyphenation at `-' and `_' in @code.
  1713. % Otherwise, it is too hard to avoid overfull hboxes
  1714. % in the Emacs manual, the Library manual, etc.
  1715. % Unfortunately, TeX uses one parameter (\hyphenchar) to control
  1716. % both hyphenation at - and hyphenation within words.
  1717. % We must therefore turn them both off (\tclose does that)
  1718. % and arrange explicitly to hyphenate at a dash.
  1719. % -- rms.
  1720. {
  1721. \catcode`\-=\active
  1722. \catcode`\_=\active
  1723. %
  1724. \global\def\code{\begingroup
  1725. \catcode`\-=\active \catcode`\_=\active
  1726. \ifallowcodebreaks
  1727. \let-\codedash
  1728. \let_\codeunder
  1729. \else
  1730. \let-\realdash
  1731. \let_\realunder
  1732. \fi
  1733. \codex
  1734. }
  1735. }
  1736. \def\realdash{-}
  1737. \def\codedash{-\discretionary{}{}{}}
  1738. \def\codeunder{%
  1739. % this is all so @math{@code{var_name}+1} can work. In math mode, _
  1740. % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
  1741. % will therefore expand the active definition of _, which is us
  1742. % (inside @code that is), therefore an endless loop.
  1743. \ifusingtt{\ifmmode
  1744. \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
  1745. \else\normalunderscore \fi
  1746. \discretionary{}{}{}}%
  1747. {\_}%
  1748. }
  1749. \def\codex #1{\tclose{#1}\endgroup}
  1750. % An additional complication: the above will allow breaks after, e.g.,
  1751. % each of the four underscores in __typeof__. This is undesirable in
  1752. % some manuals, especially if they don't have long identifiers in
  1753. % general. @allowcodebreaks provides a way to control this.
  1754. %
  1755. \newif\ifallowcodebreaks \allowcodebreakstrue
  1756. \def\keywordtrue{true}
  1757. \def\keywordfalse{false}
  1758. \parseargdef\allowcodebreaks{%
  1759. \def\txiarg{#1}%
  1760. \ifx\txiarg\keywordtrue
  1761. \allowcodebreakstrue
  1762. \else\ifx\txiarg\keywordfalse
  1763. \allowcodebreaksfalse
  1764. \else
  1765. \errhelp = \EMsimple
  1766. \errmessage{Unknown @allowcodebreaks option `\txiarg'}%
  1767. \fi\fi
  1768. }
  1769. % @kbd is like @code, except that if the argument is just one @key command,
  1770. % then @kbd has no effect.
  1771. % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
  1772. % `example' (@kbd uses ttsl only inside of @example and friends),
  1773. % or `code' (@kbd uses normal tty font always).
  1774. \parseargdef\kbdinputstyle{%
  1775. \def\txiarg{#1}%
  1776. \ifx\txiarg\worddistinct
  1777. \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
  1778. \else\ifx\txiarg\wordexample
  1779. \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
  1780. \else\ifx\txiarg\wordcode
  1781. \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
  1782. \else
  1783. \errhelp = \EMsimple
  1784. \errmessage{Unknown @kbdinputstyle option `\txiarg'}%
  1785. \fi\fi\fi
  1786. }
  1787. \def\worddistinct{distinct}
  1788. \def\wordexample{example}
  1789. \def\wordcode{code}
  1790. % Default is `distinct.'
  1791. \kbdinputstyle distinct
  1792. \def\xkey{\key}
  1793. \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
  1794. \ifx\one\xkey\ifx\threex\three \key{#2}%
  1795. \else{\tclose{\kbdfont\look}}\fi
  1796. \else{\tclose{\kbdfont\look}}\fi}
  1797. % For @indicateurl, @env, @command quotes seem unnecessary, so use \code.
  1798. \let\indicateurl=\code
  1799. \let\env=\code
  1800. \let\command=\code
  1801. % @uref (abbreviation for `urlref') takes an optional (comma-separated)
  1802. % second argument specifying the text to display and an optional third
  1803. % arg as text to display instead of (rather than in addition to) the url
  1804. % itself. First (mandatory) arg is the url. Perhaps eventually put in
  1805. % a hypertex \special here.
  1806. %
  1807. \def\uref#1{\douref #1,,,\finish}
  1808. \def\douref#1,#2,#3,#4\finish{\begingroup
  1809. \unsepspaces
  1810. \pdfurl{#1}%
  1811. \setbox0 = \hbox{\ignorespaces #3}%
  1812. \ifdim\wd0 > 0pt
  1813. \unhbox0 % third arg given, show only that
  1814. \else
  1815. \setbox0 = \hbox{\ignorespaces #2}%
  1816. \ifdim\wd0 > 0pt
  1817. \ifpdf
  1818. \unhbox0 % PDF: 2nd arg given, show only it
  1819. \else
  1820. \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
  1821. \fi
  1822. \else
  1823. \code{#1}% only url given, so show it
  1824. \fi
  1825. \fi
  1826. \endlink
  1827. \endgroup}
  1828. % @url synonym for @uref, since that's how everyone uses it.
  1829. %
  1830. \let\url=\uref
  1831. % rms does not like angle brackets --karl, 17may97.
  1832. % So now @email is just like @uref, unless we are pdf.
  1833. %
  1834. %\def\email#1{\angleleft{\tt #1}\angleright}
  1835. \ifpdf
  1836. \def\email#1{\doemail#1,,\finish}
  1837. \def\doemail#1,#2,#3\finish{\begingroup
  1838. \unsepspaces
  1839. \pdfurl{mailto:#1}%
  1840. \setbox0 = \hbox{\ignorespaces #2}%
  1841. \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
  1842. \endlink
  1843. \endgroup}
  1844. \else
  1845. \let\email=\uref
  1846. \fi
  1847. % Check if we are currently using a typewriter font. Since all the
  1848. % Computer Modern typewriter fonts have zero interword stretch (and
  1849. % shrink), and it is reasonable to expect all typewriter fonts to have
  1850. % this property, we can check that font parameter.
  1851. %
  1852. \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
  1853. % Typeset a dimension, e.g., `in' or `pt'. The only reason for the
  1854. % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
  1855. %
  1856. \def\dmn#1{\thinspace #1}
  1857. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
  1858. % @l was never documented to mean ``switch to the Lisp font'',
  1859. % and it is not used as such in any manual I can find. We need it for
  1860. % Polish suppressed-l. --karl, 22sep96.
  1861. %\def\l#1{{\li #1}\null}
  1862. % Explicit font changes: @r, @sc, undocumented @ii.
  1863. \def\r#1{{\rm #1}} % roman font
  1864. \def\sc#1{{\smallcaps#1}} % smallcaps font
  1865. \def\ii#1{{\it #1}} % italic font
  1866. % @acronym for "FBI", "NATO", and the like.
  1867. % We print this one point size smaller, since it's intended for
  1868. % all-uppercase.
  1869. %
  1870. \def\acronym#1{\doacronym #1,,\finish}
  1871. \def\doacronym#1,#2,#3\finish{%
  1872. {\selectfonts\lsize #1}%
  1873. \def\temp{#2}%
  1874. \ifx\temp\empty \else
  1875. \space ({\unsepspaces \ignorespaces \temp \unskip})%
  1876. \fi
  1877. }
  1878. % @abbr for "Comput. J." and the like.
  1879. % No font change, but don't do end-of-sentence spacing.
  1880. %
  1881. \def\abbr#1{\doabbr #1,,\finish}
  1882. \def\doabbr#1,#2,#3\finish{%
  1883. {\plainfrenchspacing #1}%
  1884. \def\temp{#2}%
  1885. \ifx\temp\empty \else
  1886. \space ({\unsepspaces \ignorespaces \temp \unskip})%
  1887. \fi
  1888. }
  1889. % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
  1890. %
  1891. \def\pounds{{\it\$}}
  1892. % @euro{} comes from a separate font, depending on the current style.
  1893. % We use the free feym* fonts from the eurosym package by Henrik
  1894. % Theiling, which support regular, slanted, bold and bold slanted (and
  1895. % "outlined" (blackboard board, sort of) versions, which we don't need).
  1896. % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
  1897. %
  1898. % Although only regular is the truly official Euro symbol, we ignore
  1899. % that. The Euro is designed to be slightly taller than the regular
  1900. % font height.
  1901. %
  1902. % feymr - regular
  1903. % feymo - slanted
  1904. % feybr - bold
  1905. % feybo - bold slanted
  1906. %
  1907. % There is no good (free) typewriter version, to my knowledge.
  1908. % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
  1909. % Hmm.
  1910. %
  1911. % Also doesn't work in math. Do we need to do math with euro symbols?
  1912. % Hope not.
  1913. %
  1914. %
  1915. \def\euro{{\eurofont e}}
  1916. \def\eurofont{%
  1917. % We set the font at each command, rather than predefining it in
  1918. % \textfonts and the other font-switching commands, so that
  1919. % installations which never need the symbol don't have to have the
  1920. % font installed.
  1921. %
  1922. % There is only one designed size (nominal 10pt), so we always scale
  1923. % that to the current nominal size.
  1924. %
  1925. % By the way, simply using "at 1em" works for cmr10 and the like, but
  1926. % does not work for cmbx10 and other extended/shrunken fonts.
  1927. %
  1928. \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
  1929. %
  1930. \ifx\curfontstyle\bfstylename
  1931. % bold:
  1932. \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
  1933. \else
  1934. % regular:
  1935. \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
  1936. \fi
  1937. \thiseurofont
  1938. }
  1939. % @registeredsymbol - R in a circle. The font for the R should really
  1940. % be smaller yet, but lllsize is the best we can do for now.
  1941. % Adapted from the plain.tex definition of \copyright.
  1942. %
  1943. \def\registeredsymbol{%
  1944. $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
  1945. \hfil\crcr\Orb}}%
  1946. }$%
  1947. }
  1948. % Laurent Siebenmann reports \Orb undefined with:
  1949. % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
  1950. % so we'll define it if necessary.
  1951. %
  1952. \ifx\Orb\undefined
  1953. \def\Orb{\mathhexbox20D}
  1954. \fi
  1955. \message{page headings,}
  1956. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  1957. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  1958. % First the title page. Must do @settitle before @titlepage.
  1959. \newif\ifseenauthor
  1960. \newif\iffinishedtitlepage
  1961. % Do an implicit @contents or @shortcontents after @end titlepage if the
  1962. % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
  1963. %
  1964. \newif\ifsetcontentsaftertitlepage
  1965. \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
  1966. \newif\ifsetshortcontentsaftertitlepage
  1967. \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
  1968. \parseargdef\shorttitlepage{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
  1969. \endgroup\page\hbox{}\page}
  1970. \envdef\titlepage{%
  1971. % Open one extra group, as we want to close it in the middle of \Etitlepage.
  1972. \begingroup
  1973. \parindent=0pt \textfonts
  1974. % Leave some space at the very top of the page.
  1975. \vglue\titlepagetopglue
  1976. % No rule at page bottom unless we print one at the top with @title.
  1977. \finishedtitlepagetrue
  1978. %
  1979. % Most title ``pages'' are actually two pages long, with space
  1980. % at the top of the second. We don't want the ragged left on the second.
  1981. \let\oldpage = \page
  1982. \def\page{%
  1983. \iffinishedtitlepage\else
  1984. \finishtitlepage
  1985. \fi
  1986. \let\page = \oldpage
  1987. \page
  1988. \null
  1989. }%
  1990. }
  1991. \def\Etitlepage{%
  1992. \iffinishedtitlepage\else
  1993. \finishtitlepage
  1994. \fi
  1995. % It is important to do the page break before ending the group,
  1996. % because the headline and footline are only empty inside the group.
  1997. % If we use the new definition of \page, we always get a blank page
  1998. % after the title page, which we certainly don't want.
  1999. \oldpage
  2000. \endgroup
  2001. %
  2002. % Need this before the \...aftertitlepage checks so that if they are
  2003. % in effect the toc pages will come out with page numbers.
  2004. \HEADINGSon
  2005. %
  2006. % If they want short, they certainly want long too.
  2007. \ifsetshortcontentsaftertitlepage
  2008. \shortcontents
  2009. \contents
  2010. \global\let\shortcontents = \relax
  2011. \global\let\contents = \relax
  2012. \fi
  2013. %
  2014. \ifsetcontentsaftertitlepage
  2015. \contents
  2016. \global\let\contents = \relax
  2017. \global\let\shortcontents = \relax
  2018. \fi
  2019. }
  2020. \def\finishtitlepage{%
  2021. \vskip4pt \hrule height 2pt width \hsize
  2022. \vskip\titlepagebottomglue
  2023. \finishedtitlepagetrue
  2024. }
  2025. %%% Macros to be used within @titlepage:
  2026. \let\subtitlerm=\tenrm
  2027. \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
  2028. \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines
  2029. \let\tt=\authortt}
  2030. \parseargdef\title{%
  2031. \checkenv\titlepage
  2032. \leftline{\titlefonts\rm #1}
  2033. % print a rule at the page bottom also.
  2034. \finishedtitlepagefalse
  2035. \vskip4pt \hrule height 4pt width \hsize \vskip4pt
  2036. }
  2037. \parseargdef\subtitle{%
  2038. \checkenv\titlepage
  2039. {\subtitlefont \rightline{#1}}%
  2040. }
  2041. % @author should come last, but may come many times.
  2042. % It can also be used inside @quotation.
  2043. %
  2044. \parseargdef\author{%
  2045. \def\temp{\quotation}%
  2046. \ifx\thisenv\temp
  2047. \def\quotationauthor{#1}% printed in \Equotation.
  2048. \else
  2049. \checkenv\titlepage
  2050. \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
  2051. {\authorfont \leftline{#1}}%
  2052. \fi
  2053. }
  2054. %%% Set up page headings and footings.
  2055. \let\thispage=\folio
  2056. \newtoks\evenheadline % headline on even pages
  2057. \newtoks\oddheadline % headline on odd pages
  2058. \newtoks\evenfootline % footline on even pages
  2059. \newtoks\oddfootline % footline on odd pages
  2060. % Now make TeX use those variables
  2061. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
  2062. \else \the\evenheadline \fi}}
  2063. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
  2064. \else \the\evenfootline \fi}\HEADINGShook}
  2065. \let\HEADINGShook=\relax
  2066. % Commands to set those variables.
  2067. % For example, this is what @headings on does
  2068. % @evenheading @thistitle|@thispage|@thischapter
  2069. % @oddheading @thischapter|@thispage|@thistitle
  2070. % @evenfooting @thisfile||
  2071. % @oddfooting ||@thisfile
  2072. \def\evenheading{\parsearg\evenheadingxxx}
  2073. \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
  2074. \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
  2075. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  2076. \def\oddheading{\parsearg\oddheadingxxx}
  2077. \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
  2078. \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
  2079. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  2080. \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
  2081. \def\evenfooting{\parsearg\evenfootingxxx}
  2082. \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
  2083. \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
  2084. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  2085. \def\oddfooting{\parsearg\oddfootingxxx}
  2086. \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
  2087. \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
  2088. \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
  2089. %
  2090. % Leave some space for the footline. Hopefully ok to assume
  2091. % @evenfooting will not be used by itself.
  2092. \global\advance\pageheight by -\baselineskip
  2093. \global\advance\vsize by -\baselineskip
  2094. }
  2095. \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
  2096. % @headings double turns headings on for double-sided printing.
  2097. % @headings single turns headings on for single-sided printing.
  2098. % @headings off turns them off.
  2099. % @headings on same as @headings double, retained for compatibility.
  2100. % @headings after turns on double-sided headings after this page.
  2101. % @headings doubleafter turns on double-sided headings after this page.
  2102. % @headings singleafter turns on single-sided headings after this page.
  2103. % By default, they are off at the start of a document,
  2104. % and turned `on' after @end titlepage.
  2105. \def\headings #1 {\csname HEADINGS#1\endcsname}
  2106. \def\HEADINGSoff{%
  2107. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  2108. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  2109. \HEADINGSoff
  2110. % When we turn headings on, set the page number to 1.
  2111. % For double-sided printing, put current file name in lower left corner,
  2112. % chapter name on inside top of right hand pages, document
  2113. % title on inside top of left hand pages, and page numbers on outside top
  2114. % edge of all pages.
  2115. \def\HEADINGSdouble{%
  2116. \global\pageno=1
  2117. \global\evenfootline={\hfil}
  2118. \global\oddfootline={\hfil}
  2119. \global\evenheadline={\line{\folio\hfil\thistitle}}
  2120. \global\oddheadline={\line{\thischapter\hfil\folio}}
  2121. \global\let\contentsalignmacro = \chapoddpage
  2122. }
  2123. \let\contentsalignmacro = \chappager
  2124. % For single-sided printing, chapter title goes across top left of page,
  2125. % page number on top right.
  2126. \def\HEADINGSsingle{%
  2127. \global\pageno=1
  2128. \global\evenfootline={\hfil}
  2129. \global\oddfootline={\hfil}
  2130. \global\evenheadline={\line{\thischapter\hfil\folio}}
  2131. \global\oddheadline={\line{\thischapter\hfil\folio}}
  2132. \global\let\contentsalignmacro = \chappager
  2133. }
  2134. \def\HEADINGSon{\HEADINGSdouble}
  2135. \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
  2136. \let\HEADINGSdoubleafter=\HEADINGSafter
  2137. \def\HEADINGSdoublex{%
  2138. \global\evenfootline={\hfil}
  2139. \global\oddfootline={\hfil}
  2140. \global\evenheadline={\line{\folio\hfil\thistitle}}
  2141. \global\oddheadline={\line{\thischapter\hfil\folio}}
  2142. \global\let\contentsalignmacro = \chapoddpage
  2143. }
  2144. \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
  2145. \def\HEADINGSsinglex{%
  2146. \global\evenfootline={\hfil}
  2147. \global\oddfootline={\hfil}
  2148. \global\evenheadline={\line{\thischapter\hfil\folio}}
  2149. \global\oddheadline={\line{\thischapter\hfil\folio}}
  2150. \global\let\contentsalignmacro = \chappager
  2151. }
  2152. % Subroutines used in generating headings
  2153. % This produces Day Month Year style of output.
  2154. % Only define if not already defined, in case a txi-??.tex file has set
  2155. % up a different format (e.g., txi-cs.tex does this).
  2156. \ifx\today\undefined
  2157. \def\today{%
  2158. \number\day\space
  2159. \ifcase\month
  2160. \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
  2161. \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
  2162. \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
  2163. \fi
  2164. \space\number\year}
  2165. \fi
  2166. % @settitle line... specifies the title of the document, for headings.
  2167. % It generates no output of its own.
  2168. \def\thistitle{\putwordNoTitle}
  2169. \def\settitle{\parsearg{\gdef\thistitle}}
  2170. \message{tables,}
  2171. % Tables -- @table, @ftable, @vtable, @item(x).
  2172. % default indentation of table text
  2173. \newdimen\tableindent \tableindent=.8in
  2174. % default indentation of @itemize and @enumerate text
  2175. \newdimen\itemindent \itemindent=.3in
  2176. % margin between end of table item and start of table text.
  2177. \newdimen\itemmargin \itemmargin=.1in
  2178. % used internally for \itemindent minus \itemmargin
  2179. \newdimen\itemmax
  2180. % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
  2181. % these defs.
  2182. % They also define \itemindex
  2183. % to index the item name in whatever manner is desired (perhaps none).
  2184. \newif\ifitemxneedsnegativevskip
  2185. \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
  2186. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  2187. \def\internalBitemx{\itemxpar \parsearg\itemzzz}
  2188. \def\itemzzz #1{\begingroup %
  2189. \advance\hsize by -\rightskip
  2190. \advance\hsize by -\tableindent
  2191. \setbox0=\hbox{\itemindicate{#1}}%
  2192. \itemindex{#1}%
  2193. \nobreak % This prevents a break before @itemx.
  2194. %
  2195. % If the item text does not fit in the space we have, put it on a line
  2196. % by itself, and do not allow a page break either before or after that
  2197. % line. We do not start a paragraph here because then if the next
  2198. % command is, e.g., @kindex, the whatsit would get put into the
  2199. % horizontal list on a line by itself, resulting in extra blank space.
  2200. \ifdim \wd0>\itemmax
  2201. %
  2202. % Make this a paragraph so we get the \parskip glue and wrapping,
  2203. % but leave it ragged-right.
  2204. \begingroup
  2205. \advance\leftskip by-\tableindent
  2206. \advance\hsize by\tableindent
  2207. \advance\rightskip by0pt plus1fil
  2208. \leavevmode\unhbox0\par
  2209. \endgroup
  2210. %
  2211. % We're going to be starting a paragraph, but we don't want the
  2212. % \parskip glue -- logically it's part of the @item we just started.
  2213. \nobreak \vskip-\parskip
  2214. %
  2215. % Stop a page break at the \parskip glue coming up. However, if
  2216. % what follows is an environment such as @example, there will be no
  2217. % \parskip glue; then the negative vskip we just inserted would
  2218. % cause the example and the item to crash together. So we use this
  2219. % bizarre value of 10001 as a signal to \aboveenvbreak to insert
  2220. % \parskip glue after all. Section titles are handled this way also.
  2221. %
  2222. \penalty 10001
  2223. \endgroup
  2224. \itemxneedsnegativevskipfalse
  2225. \else
  2226. % The item text fits into the space. Start a paragraph, so that the
  2227. % following text (if any) will end up on the same line.
  2228. \noindent
  2229. % Do this with kerns and \unhbox so that if there is a footnote in
  2230. % the item text, it can migrate to the main vertical list and
  2231. % eventually be printed.
  2232. \nobreak\kern-\tableindent
  2233. \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
  2234. \unhbox0
  2235. \nobreak\kern\dimen0
  2236. \endgroup
  2237. \itemxneedsnegativevskiptrue
  2238. \fi
  2239. }
  2240. \def\item{\errmessage{@item while not in a list environment}}
  2241. \def\itemx{\errmessage{@itemx while not in a list environment}}
  2242. % @table, @ftable, @vtable.
  2243. \envdef\table{%
  2244. \let\itemindex\gobble
  2245. \tablecheck{table}%
  2246. }
  2247. \envdef\ftable{%
  2248. \def\itemindex ##1{\doind {fn}{\code{##1}}}%
  2249. \tablecheck{ftable}%
  2250. }
  2251. \envdef\vtable{%
  2252. \def\itemindex ##1{\doind {vr}{\code{##1}}}%
  2253. \tablecheck{vtable}%
  2254. }
  2255. \def\tablecheck#1{%
  2256. \ifnum \the\catcode`\^^M=\active
  2257. \endgroup
  2258. \errmessage{This command won't work in this context; perhaps the problem is
  2259. that we are \inenvironment\thisenv}%
  2260. \def\next{\doignore{#1}}%
  2261. \else
  2262. \let\next\tablex
  2263. \fi
  2264. \next
  2265. }
  2266. \def\tablex#1{%
  2267. \def\itemindicate{#1}%
  2268. \parsearg\tabley
  2269. }
  2270. \def\tabley#1{%
  2271. {%
  2272. \makevalueexpandable
  2273. \edef\temp{\noexpand\tablez #1\space\space\space}%
  2274. \expandafter
  2275. }\temp \endtablez
  2276. }
  2277. \def\tablez #1 #2 #3 #4\endtablez{%
  2278. \aboveenvbreak
  2279. \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
  2280. \ifnum 0#2>0 \tableindent=#2\mil \fi
  2281. \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
  2282. \itemmax=\tableindent
  2283. \advance \itemmax by -\itemmargin
  2284. \advance \leftskip by \tableindent
  2285. \exdentamount=\tableindent
  2286. \parindent = 0pt
  2287. \parskip = \smallskipamount
  2288. \ifdim \parskip=0pt \parskip=2pt \fi
  2289. \let\item = \internalBitem
  2290. \let\itemx = \internalBitemx
  2291. }
  2292. \def\Etable{\endgraf\afterenvbreak}
  2293. \let\Eftable\Etable
  2294. \let\Evtable\Etable
  2295. \let\Eitemize\Etable
  2296. \let\Eenumerate\Etable
  2297. % This is the counter used by @enumerate, which is really @itemize
  2298. \newcount \itemno
  2299. \envdef\itemize{\parsearg\doitemize}
  2300. \def\doitemize#1{%
  2301. \aboveenvbreak
  2302. \itemmax=\itemindent
  2303. \advance\itemmax by -\itemmargin
  2304. \advance\leftskip by \itemindent
  2305. \exdentamount=\itemindent
  2306. \parindent=0pt
  2307. \parskip=\smallskipamount
  2308. \ifdim\parskip=0pt \parskip=2pt \fi
  2309. \def\itemcontents{#1}%
  2310. % @itemize with no arg is equivalent to @itemize @bullet.
  2311. \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
  2312. \let\item=\itemizeitem
  2313. }
  2314. % Definition of @item while inside @itemize and @enumerate.
  2315. %
  2316. \def\itemizeitem{%
  2317. \advance\itemno by 1 % for enumerations
  2318. {\let\par=\endgraf \smallbreak}% reasonable place to break
  2319. {%
  2320. % If the document has an @itemize directly after a section title, a
  2321. % \nobreak will be last on the list, and \sectionheading will have
  2322. % done a \vskip-\parskip. In that case, we don't want to zero
  2323. % parskip, or the item text will crash with the heading. On the
  2324. % other hand, when there is normal text preceding the item (as there
  2325. % usually is), we do want to zero parskip, or there would be too much
  2326. % space. In that case, we won't have a \nobreak before. At least
  2327. % that's the theory.
  2328. \ifnum\lastpenalty<10000 \parskip=0in \fi
  2329. \noindent
  2330. \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
  2331. \vadjust{\penalty 1200}}% not good to break after first line of item.
  2332. \flushcr
  2333. }
  2334. % \splitoff TOKENS\endmark defines \first to be the first token in
  2335. % TOKENS, and \rest to be the remainder.
  2336. %
  2337. \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
  2338. % Allow an optional argument of an uppercase letter, lowercase letter,
  2339. % or number, to specify the first label in the enumerated list. No
  2340. % argument is the same as `1'.
  2341. %
  2342. \envparseargdef\enumerate{\enumeratey #1 \endenumeratey}
  2343. \def\enumeratey #1 #2\endenumeratey{%
  2344. % If we were given no argument, pretend we were given `1'.
  2345. \def\thearg{#1}%
  2346. \ifx\thearg\empty \def\thearg{1}\fi
  2347. %
  2348. % Detect if the argument is a single token. If so, it might be a
  2349. % letter. Otherwise, the only valid thing it can be is a number.
  2350. % (We will always have one token, because of the test we just made.
  2351. % This is a good thing, since \splitoff doesn't work given nothing at
  2352. % all -- the first parameter is undelimited.)
  2353. \expandafter\splitoff\thearg\endmark
  2354. \ifx\rest\empty
  2355. % Only one token in the argument. It could still be anything.
  2356. % A ``lowercase letter'' is one whose \lccode is nonzero.
  2357. % An ``uppercase letter'' is one whose \lccode is both nonzero, and
  2358. % not equal to itself.
  2359. % Otherwise, we assume it's a number.
  2360. %
  2361. % We need the \relax at the end of the \ifnum lines to stop TeX from
  2362. % continuing to look for a <number>.
  2363. %
  2364. \ifnum\lccode\expandafter`\thearg=0\relax
  2365. \numericenumerate % a number (we hope)
  2366. \else
  2367. % It's a letter.
  2368. \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
  2369. \lowercaseenumerate % lowercase letter
  2370. \else
  2371. \uppercaseenumerate % uppercase letter
  2372. \fi
  2373. \fi
  2374. \else
  2375. % Multiple tokens in the argument. We hope it's a number.
  2376. \numericenumerate
  2377. \fi
  2378. }
  2379. % An @enumerate whose labels are integers. The starting integer is
  2380. % given in \thearg.
  2381. %
  2382. \def\numericenumerate{%
  2383. \itemno = \thearg
  2384. \startenumeration{\the\itemno}%
  2385. }
  2386. % The starting (lowercase) letter is in \thearg.
  2387. \def\lowercaseenumerate{%
  2388. \itemno = \expandafter`\thearg
  2389. \startenumeration{%
  2390. % Be sure we're not beyond the end of the alphabet.
  2391. \ifnum\itemno=0
  2392. \errmessage{No more lowercase letters in @enumerate; get a bigger
  2393. alphabet}%
  2394. \fi
  2395. \char\lccode\itemno
  2396. }%
  2397. }
  2398. % The starting (uppercase) letter is in \thearg.
  2399. \def\uppercaseenumerate{%
  2400. \itemno = \expandafter`\thearg
  2401. \startenumeration{%
  2402. % Be sure we're not beyond the end of the alphabet.
  2403. \ifnum\itemno=0
  2404. \errmessage{No more uppercase letters in @enumerate; get a bigger
  2405. alphabet}
  2406. \fi
  2407. \char\uccode\itemno
  2408. }%
  2409. }
  2410. % Call \doitemize, adding a period to the first argument and supplying the
  2411. % common last two arguments. Also subtract one from the initial value in
  2412. % \itemno, since @item increments \itemno.
  2413. %
  2414. \def\startenumeration#1{%
  2415. \advance\itemno by -1
  2416. \doitemize{#1.}\flushcr
  2417. }
  2418. % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
  2419. % to @enumerate.
  2420. %
  2421. \def\alphaenumerate{\enumerate{a}}
  2422. \def\capsenumerate{\enumerate{A}}
  2423. \def\Ealphaenumerate{\Eenumerate}
  2424. \def\Ecapsenumerate{\Eenumerate}
  2425. % @multitable macros
  2426. % Amy Hendrickson, 8/18/94, 3/6/96
  2427. %
  2428. % @multitable ... @end multitable will make as many columns as desired.
  2429. % Contents of each column will wrap at width given in preamble. Width
  2430. % can be specified either with sample text given in a template line,
  2431. % or in percent of \hsize, the current width of text on page.
  2432. % Table can continue over pages but will only break between lines.
  2433. % To make preamble:
  2434. %
  2435. % Either define widths of columns in terms of percent of \hsize:
  2436. % @multitable @columnfractions .25 .3 .45
  2437. % @item ...
  2438. %
  2439. % Numbers following @columnfractions are the percent of the total
  2440. % current hsize to be used for each column. You may use as many
  2441. % columns as desired.
  2442. % Or use a template:
  2443. % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
  2444. % @item ...
  2445. % using the widest term desired in each column.
  2446. % Each new table line starts with @item, each subsequent new column
  2447. % starts with @tab. Empty columns may be produced by supplying @tab's
  2448. % with nothing between them for as many times as empty columns are needed,
  2449. % ie, @tab@tab@tab will produce two empty columns.
  2450. % @item, @tab do not need to be on their own lines, but it will not hurt
  2451. % if they are.
  2452. % Sample multitable:
  2453. % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
  2454. % @item first col stuff @tab second col stuff @tab third col
  2455. % @item
  2456. % first col stuff
  2457. % @tab
  2458. % second col stuff
  2459. % @tab
  2460. % third col
  2461. % @item first col stuff @tab second col stuff
  2462. % @tab Many paragraphs of text may be used in any column.
  2463. %
  2464. % They will wrap at the width determined by the template.
  2465. % @item@tab@tab This will be in third column.
  2466. % @end multitable
  2467. % Default dimensions may be reset by user.
  2468. % @multitableparskip is vertical space between paragraphs in table.
  2469. % @multitableparindent is paragraph indent in table.
  2470. % @multitablecolmargin is horizontal space to be left between columns.
  2471. % @multitablelinespace is space to leave between table items, baseline
  2472. % to baseline.
  2473. % 0pt means it depends on current normal line spacing.
  2474. %
  2475. \newskip\multitableparskip
  2476. \newskip\multitableparindent
  2477. \newdimen\multitablecolspace
  2478. \newskip\multitablelinespace
  2479. \multitableparskip=0pt
  2480. \multitableparindent=6pt
  2481. \multitablecolspace=12pt
  2482. \multitablelinespace=0pt
  2483. % Macros used to set up halign preamble:
  2484. %
  2485. \let\endsetuptable\relax
  2486. \def\xendsetuptable{\endsetuptable}
  2487. \let\columnfractions\relax
  2488. \def\xcolumnfractions{\columnfractions}
  2489. \newif\ifsetpercent
  2490. % #1 is the @columnfraction, usually a decimal number like .5, but might
  2491. % be just 1. We just use it, whatever it is.
  2492. %
  2493. \def\pickupwholefraction#1 {%
  2494. \global\advance\colcount by 1
  2495. \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
  2496. \setuptable
  2497. }
  2498. \newcount\colcount
  2499. \def\setuptable#1{%
  2500. \def\firstarg{#1}%
  2501. \ifx\firstarg\xendsetuptable
  2502. \let\go = \relax
  2503. \else
  2504. \ifx\firstarg\xcolumnfractions
  2505. \global\setpercenttrue
  2506. \else
  2507. \ifsetpercent
  2508. \let\go\pickupwholefraction
  2509. \else
  2510. \global\advance\colcount by 1
  2511. \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
  2512. % separator; typically that is always in the input, anyway.
  2513. \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
  2514. \fi
  2515. \fi
  2516. \ifx\go\pickupwholefraction
  2517. % Put the argument back for the \pickupwholefraction call, so
  2518. % we'll always have a period there to be parsed.
  2519. \def\go{\pickupwholefraction#1}%
  2520. \else
  2521. \let\go = \setuptable
  2522. \fi%
  2523. \fi
  2524. \go
  2525. }
  2526. % multitable-only commands.
  2527. %
  2528. % @headitem starts a heading row, which we typeset in bold.
  2529. % Assignments have to be global since we are inside the implicit group
  2530. % of an alignment entry. Note that \everycr resets \everytab.
  2531. \def\headitem{\checkenv\multitable \crcr \global\everytab={\bf}\the\everytab}%
  2532. %
  2533. % A \tab used to include \hskip1sp. But then the space in a template
  2534. % line is not enough. That is bad. So let's go back to just `&' until
  2535. % we encounter the problem it was intended to solve again.
  2536. % --karl, nathan@acm.org, 20apr99.
  2537. \def\tab{\checkenv\multitable &\the\everytab}%
  2538. % @multitable ... @end multitable definitions:
  2539. %
  2540. \newtoks\everytab % insert after every tab.
  2541. %
  2542. \envdef\multitable{%
  2543. \vskip\parskip
  2544. \startsavinginserts
  2545. %
  2546. % @item within a multitable starts a normal row.
  2547. % We use \def instead of \let so that if one of the multitable entries
  2548. % contains an @itemize, we don't choke on the \item (seen as \crcr aka
  2549. % \endtemplate) expanding \doitemize.
  2550. \def\item{\crcr}%
  2551. %
  2552. \tolerance=9500
  2553. \hbadness=9500
  2554. \setmultitablespacing
  2555. \parskip=\multitableparskip
  2556. \parindent=\multitableparindent
  2557. \overfullrule=0pt
  2558. \global\colcount=0
  2559. %
  2560. \everycr = {%
  2561. \noalign{%
  2562. \global\everytab={}%
  2563. \global\colcount=0 % Reset the column counter.
  2564. % Check for saved footnotes, etc.
  2565. \checkinserts
  2566. % Keeps underfull box messages off when table breaks over pages.
  2567. %\filbreak
  2568. % Maybe so, but it also creates really weird page breaks when the
  2569. % table breaks over pages. Wouldn't \vfil be better? Wait until the
  2570. % problem manifests itself, so it can be fixed for real --karl.
  2571. }%
  2572. }%
  2573. %
  2574. \parsearg\domultitable
  2575. }
  2576. \def\domultitable#1{%
  2577. % To parse everything between @multitable and @item:
  2578. \setuptable#1 \endsetuptable
  2579. %
  2580. % This preamble sets up a generic column definition, which will
  2581. % be used as many times as user calls for columns.
  2582. % \vtop will set a single line and will also let text wrap and
  2583. % continue for many paragraphs if desired.
  2584. \halign\bgroup &%
  2585. \global\advance\colcount by 1
  2586. \multistrut
  2587. \vtop{%
  2588. % Use the current \colcount to find the correct column width:
  2589. \hsize=\expandafter\csname col\the\colcount\endcsname
  2590. %
  2591. % In order to keep entries from bumping into each other
  2592. % we will add a \leftskip of \multitablecolspace to all columns after
  2593. % the first one.
  2594. %
  2595. % If a template has been used, we will add \multitablecolspace
  2596. % to the width of each template entry.
  2597. %
  2598. % If the user has set preamble in terms of percent of \hsize we will
  2599. % use that dimension as the width of the column, and the \leftskip
  2600. % will keep entries from bumping into each other. Table will start at
  2601. % left margin and final column will justify at right margin.
  2602. %
  2603. % Make sure we don't inherit \rightskip from the outer environment.
  2604. \rightskip=0pt
  2605. \ifnum\colcount=1
  2606. % The first column will be indented with the surrounding text.
  2607. \advance\hsize by\leftskip
  2608. \else
  2609. \ifsetpercent \else
  2610. % If user has not set preamble in terms of percent of \hsize
  2611. % we will advance \hsize by \multitablecolspace.
  2612. \advance\hsize by \multitablecolspace
  2613. \fi
  2614. % In either case we will make \leftskip=\multitablecolspace:
  2615. \leftskip=\multitablecolspace
  2616. \fi
  2617. % Ignoring space at the beginning and end avoids an occasional spurious
  2618. % blank line, when TeX decides to break the line at the space before the
  2619. % box from the multistrut, so the strut ends up on a line by itself.
  2620. % For example:
  2621. % @multitable @columnfractions .11 .89
  2622. % @item @code{#}
  2623. % @tab Legal holiday which is valid in major parts of the whole country.
  2624. % Is automatically provided with highlighting sequences respectively
  2625. % marking characters.
  2626. \noindent\ignorespaces##\unskip\multistrut
  2627. }\cr
  2628. }
  2629. \def\Emultitable{%
  2630. \crcr
  2631. \egroup % end the \halign
  2632. \global\setpercentfalse
  2633. }
  2634. \def\setmultitablespacing{%
  2635. \def\multistrut{\strut}% just use the standard line spacing
  2636. %
  2637. % Compute \multitablelinespace (if not defined by user) for use in
  2638. % \multitableparskip calculation. We used define \multistrut based on
  2639. % this, but (ironically) that caused the spacing to be off.
  2640. % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
  2641. \ifdim\multitablelinespace=0pt
  2642. \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
  2643. \global\advance\multitablelinespace by-\ht0
  2644. \fi
  2645. %% Test to see if parskip is larger than space between lines of
  2646. %% table. If not, do nothing.
  2647. %% If so, set to same dimension as multitablelinespace.
  2648. \ifdim\multitableparskip>\multitablelinespace
  2649. \global\multitableparskip=\multitablelinespace
  2650. \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
  2651. %% than skip between lines in the table.
  2652. \fi%
  2653. \ifdim\multitableparskip=0pt
  2654. \global\multitableparskip=\multitablelinespace
  2655. \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
  2656. %% than skip between lines in the table.
  2657. \fi}
  2658. \message{conditionals,}
  2659. % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
  2660. % @ifnotxml always succeed. They currently do nothing; we don't
  2661. % attempt to check whether the conditionals are properly nested. But we
  2662. % have to remember that they are conditionals, so that @end doesn't
  2663. % attempt to close an environment group.
  2664. %
  2665. \def\makecond#1{%
  2666. \expandafter\let\csname #1\endcsname = \relax
  2667. \expandafter\let\csname iscond.#1\endcsname = 1
  2668. }
  2669. \makecond{iftex}
  2670. \makecond{ifnotdocbook}
  2671. \makecond{ifnothtml}
  2672. \makecond{ifnotinfo}
  2673. \makecond{ifnotplaintext}
  2674. \makecond{ifnotxml}
  2675. % Ignore @ignore, @ifhtml, @ifinfo, and the like.
  2676. %
  2677. \def\direntry{\doignore{direntry}}
  2678. \def\documentdescription{\doignore{documentdescription}}
  2679. \def\docbook{\doignore{docbook}}
  2680. \def\html{\doignore{html}}
  2681. \def\ifdocbook{\doignore{ifdocbook}}
  2682. \def\ifhtml{\doignore{ifhtml}}
  2683. \def\ifinfo{\doignore{ifinfo}}
  2684. \def\ifnottex{\doignore{ifnottex}}
  2685. \def\ifplaintext{\doignore{ifplaintext}}
  2686. \def\ifxml{\doignore{ifxml}}
  2687. \def\ignore{\doignore{ignore}}
  2688. \def\menu{\doignore{menu}}
  2689. \def\xml{\doignore{xml}}
  2690. % Ignore text until a line `@end #1', keeping track of nested conditionals.
  2691. %
  2692. % A count to remember the depth of nesting.
  2693. \newcount\doignorecount
  2694. \def\doignore#1{\begingroup
  2695. % Scan in ``verbatim'' mode:
  2696. \catcode`\@ = \other
  2697. \catcode`\{ = \other
  2698. \catcode`\} = \other
  2699. %
  2700. % Make sure that spaces turn into tokens that match what \doignoretext wants.
  2701. \spaceisspace
  2702. %
  2703. % Count number of #1's that we've seen.
  2704. \doignorecount = 0
  2705. %
  2706. % Swallow text until we reach the matching `@end #1'.
  2707. \dodoignore{#1}%
  2708. }
  2709. { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
  2710. \obeylines %
  2711. %
  2712. \gdef\dodoignore#1{%
  2713. % #1 contains the command name as a string, e.g., `ifinfo'.
  2714. %
  2715. % Define a command to find the next `@end #1', which must be on a line
  2716. % by itself.
  2717. \long\def\doignoretext##1^^M@end #1{\doignoretextyyy##1^^M@#1\_STOP_}%
  2718. % And this command to find another #1 command, at the beginning of a
  2719. % line. (Otherwise, we would consider a line `@c @ifset', for
  2720. % example, to count as an @ifset for nesting.)
  2721. \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
  2722. %
  2723. % And now expand that command.
  2724. \obeylines %
  2725. \doignoretext ^^M%
  2726. }%
  2727. }
  2728. \def\doignoreyyy#1{%
  2729. \def\temp{#1}%
  2730. \ifx\temp\empty % Nothing found.
  2731. \let\next\doignoretextzzz
  2732. \else % Found a nested condition, ...
  2733. \advance\doignorecount by 1
  2734. \let\next\doignoretextyyy % ..., look for another.
  2735. % If we're here, #1 ends with ^^M\ifinfo (for example).
  2736. \fi
  2737. \next #1% the token \_STOP_ is present just after this macro.
  2738. }
  2739. % We have to swallow the remaining "\_STOP_".
  2740. %
  2741. \def\doignoretextzzz#1{%
  2742. \ifnum\doignorecount = 0 % We have just found the outermost @end.
  2743. \let\next\enddoignore
  2744. \else % Still inside a nested condition.
  2745. \advance\doignorecount by -1
  2746. \let\next\doignoretext % Look for the next @end.
  2747. \fi
  2748. \next
  2749. }
  2750. % Finish off ignored text.
  2751. \def\enddoignore{\endgroup\ignorespaces}
  2752. % @set VAR sets the variable VAR to an empty value.
  2753. % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
  2754. %
  2755. % Since we want to separate VAR from REST-OF-LINE (which might be
  2756. % empty), we can't just use \parsearg; we have to insert a space of our
  2757. % own to delimit the rest of the line, and then take it out again if we
  2758. % didn't need it.
  2759. % We rely on the fact that \parsearg sets \catcode`\ =10.
  2760. %
  2761. \parseargdef\set{\setyyy#1 \endsetyyy}
  2762. \def\setyyy#1 #2\endsetyyy{%
  2763. {%
  2764. \makevalueexpandable
  2765. \def\temp{#2}%
  2766. \edef\next{\gdef\makecsname{SET#1}}%
  2767. \ifx\temp\empty
  2768. \next{}%
  2769. \else
  2770. \setzzz#2\endsetzzz
  2771. \fi
  2772. }%
  2773. }
  2774. % Remove the trailing space \setxxx inserted.
  2775. \def\setzzz#1 \endsetzzz{\next{#1}}
  2776. % @clear VAR clears (i.e., unsets) the variable VAR.
  2777. %
  2778. \parseargdef\clear{%
  2779. {%
  2780. \makevalueexpandable
  2781. \global\expandafter\let\csname SET#1\endcsname=\relax
  2782. }%
  2783. }
  2784. % @value{foo} gets the text saved in variable foo.
  2785. \def\value{\begingroup\makevalueexpandable\valuexxx}
  2786. \def\valuexxx#1{\expandablevalue{#1}\endgroup}
  2787. {
  2788. \catcode`\- = \active \catcode`\_ = \active
  2789. %
  2790. \gdef\makevalueexpandable{%
  2791. \let\value = \expandablevalue
  2792. % We don't want these characters active, ...
  2793. \catcode`\-=\other \catcode`\_=\other
  2794. % ..., but we might end up with active ones in the argument if
  2795. % we're called from @code, as @code{@value{foo-bar_}}, though.
  2796. % So \let them to their normal equivalents.
  2797. \let-\realdash \let_\normalunderscore
  2798. }
  2799. }
  2800. % We have this subroutine so that we can handle at least some @value's
  2801. % properly in indexes (we call \makevalueexpandable in \indexdummies).
  2802. % The command has to be fully expandable (if the variable is set), since
  2803. % the result winds up in the index file. This means that if the
  2804. % variable's value contains other Texinfo commands, it's almost certain
  2805. % it will fail (although perhaps we could fix that with sufficient work
  2806. % to do a one-level expansion on the result, instead of complete).
  2807. %
  2808. \def\expandablevalue#1{%
  2809. \expandafter\ifx\csname SET#1\endcsname\relax
  2810. {[No value for ``#1'']}%
  2811. \message{Variable `#1', used in @value, is not set.}%
  2812. \else
  2813. \csname SET#1\endcsname
  2814. \fi
  2815. }
  2816. % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
  2817. % with @set.
  2818. %
  2819. % To get special treatment of `@end ifset,' call \makeond and the redefine.
  2820. %
  2821. \makecond{ifset}
  2822. \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
  2823. \def\doifset#1#2{%
  2824. {%
  2825. \makevalueexpandable
  2826. \let\next=\empty
  2827. \expandafter\ifx\csname SET#2\endcsname\relax
  2828. #1% If not set, redefine \next.
  2829. \fi
  2830. \expandafter
  2831. }\next
  2832. }
  2833. \def\ifsetfail{\doignore{ifset}}
  2834. % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
  2835. % defined with @set, or has been undefined with @clear.
  2836. %
  2837. % The `\else' inside the `\doifset' parameter is a trick to reuse the
  2838. % above code: if the variable is not set, do nothing, if it is set,
  2839. % then redefine \next to \ifclearfail.
  2840. %
  2841. \makecond{ifclear}
  2842. \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
  2843. \def\ifclearfail{\doignore{ifclear}}
  2844. % @dircategory CATEGORY -- specify a category of the dir file
  2845. % which this file should belong to. Ignore this in TeX.
  2846. \let\dircategory=\comment
  2847. % @defininfoenclose.
  2848. \let\definfoenclose=\comment
  2849. \message{indexing,}
  2850. % Index generation facilities
  2851. % Define \newwrite to be identical to plain tex's \newwrite
  2852. % except not \outer, so it can be used within macros and \if's.
  2853. \edef\newwrite{\makecsname{ptexnewwrite}}
  2854. % \newindex {foo} defines an index named foo.
  2855. % It automatically defines \fooindex such that
  2856. % \fooindex ...rest of line... puts an entry in the index foo.
  2857. % It also defines \fooindfile to be the number of the output channel for
  2858. % the file that accumulates this index. The file's extension is foo.
  2859. % The name of an index should be no more than 2 characters long
  2860. % for the sake of vms.
  2861. %
  2862. \def\newindex#1{%
  2863. \iflinks
  2864. \expandafter\newwrite \csname#1indfile\endcsname
  2865. \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
  2866. \fi
  2867. \expandafter\xdef\csname#1index\endcsname{% % Define @#1index
  2868. \noexpand\doindex{#1}}
  2869. }
  2870. % @defindex foo == \newindex{foo}
  2871. %
  2872. \def\defindex{\parsearg\newindex}
  2873. % Define @defcodeindex, like @defindex except put all entries in @code.
  2874. %
  2875. \def\defcodeindex{\parsearg\newcodeindex}
  2876. %
  2877. \def\newcodeindex#1{%
  2878. \iflinks
  2879. \expandafter\newwrite \csname#1indfile\endcsname
  2880. \openout \csname#1indfile\endcsname \jobname.#1
  2881. \fi
  2882. \expandafter\xdef\csname#1index\endcsname{%
  2883. \noexpand\docodeindex{#1}}%
  2884. }
  2885. % @synindex foo bar makes index foo feed into index bar.
  2886. % Do this instead of @defindex foo if you don't want it as a separate index.
  2887. %
  2888. % @syncodeindex foo bar similar, but put all entries made for index foo
  2889. % inside @code.
  2890. %
  2891. \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
  2892. \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
  2893. % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
  2894. % #3 the target index (bar).
  2895. \def\dosynindex#1#2#3{%
  2896. % Only do \closeout if we haven't already done it, else we'll end up
  2897. % closing the target index.
  2898. \expandafter \ifx\csname donesynindex#2\endcsname \undefined
  2899. % The \closeout helps reduce unnecessary open files; the limit on the
  2900. % Acorn RISC OS is a mere 16 files.
  2901. \expandafter\closeout\csname#2indfile\endcsname
  2902. \expandafter\let\csname\donesynindex#2\endcsname = 1
  2903. \fi
  2904. % redefine \fooindfile:
  2905. \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
  2906. \expandafter\let\csname#2indfile\endcsname=\temp
  2907. % redefine \fooindex:
  2908. \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
  2909. }
  2910. % Define \doindex, the driver for all \fooindex macros.
  2911. % Argument #1 is generated by the calling \fooindex macro,
  2912. % and it is "foo", the name of the index.
  2913. % \doindex just uses \parsearg; it calls \doind for the actual work.
  2914. % This is because \doind is more useful to call from other macros.
  2915. % There is also \dosubind {index}{topic}{subtopic}
  2916. % which makes an entry in a two-level index such as the operation index.
  2917. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  2918. \def\singleindexer #1{\doind{\indexname}{#1}}
  2919. % like the previous two, but they put @code around the argument.
  2920. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  2921. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  2922. % Take care of Texinfo commands that can appear in an index entry.
  2923. % Since there are some commands we want to expand, and others we don't,
  2924. % we have to laboriously prevent expansion for those that we don't.
  2925. %
  2926. \def\indexdummies{%
  2927. \escapechar = `\\ % use backslash in output files.
  2928. \def\@{@}% change to @@ when we switch to @ as escape char in index files.
  2929. \def\ {\realbackslash\space }%
  2930. % Need these in case \tex is in effect and \{ is a \delimiter again.
  2931. % But can't use \lbracecmd and \rbracecmd because texindex assumes
  2932. % braces and backslashes are used only as delimiters.
  2933. \let\{ = \mylbrace
  2934. \let\} = \myrbrace
  2935. %
  2936. % Do the redefinitions.
  2937. \commondummies
  2938. }
  2939. % For the aux and toc files, @ is the escape character. So we want to
  2940. % redefine everything using @ as the escape character (instead of
  2941. % \realbackslash, still used for index files). When everything uses @,
  2942. % this will be simpler.
  2943. %
  2944. \def\atdummies{%
  2945. \def\@{@@}%
  2946. \def\ {@ }%
  2947. \let\{ = \lbraceatcmd
  2948. \let\} = \rbraceatcmd
  2949. %
  2950. % Do the redefinitions.
  2951. \commondummies
  2952. }
  2953. % Called from \indexdummies and \atdummies.
  2954. %
  2955. \def\commondummies{%
  2956. %
  2957. % \definedummyword defines \#1 as \string\#1\space, thus effectively
  2958. % preventing its expansion. This is used only for control% words,
  2959. % not control letters, because the \space would be incorrect for
  2960. % control characters, but is needed to separate the control word
  2961. % from whatever follows.
  2962. %
  2963. % For control letters, we have \definedummyletter, which omits the
  2964. % space.
  2965. %
  2966. % These can be used both for control words that take an argument and
  2967. % those that do not. If it is followed by {arg} in the input, then
  2968. % that will dutifully get written to the index (or wherever).
  2969. %
  2970. \def\definedummyword ##1{\def##1{\string##1\space}}%
  2971. \def\definedummyletter##1{\def##1{\string##1}}%
  2972. \let\definedummyaccent\definedummyletter
  2973. %
  2974. \commondummiesnofonts
  2975. %
  2976. \definedummyletter\_%
  2977. %
  2978. % Non-English letters.
  2979. \definedummyword\AA
  2980. \definedummyword\AE
  2981. \definedummyword\L
  2982. \definedummyword\OE
  2983. \definedummyword\O
  2984. \definedummyword\aa
  2985. \definedummyword\ae
  2986. \definedummyword\l
  2987. \definedummyword\oe
  2988. \definedummyword\o
  2989. \definedummyword\ss
  2990. \definedummyword\exclamdown
  2991. \definedummyword\questiondown
  2992. \definedummyword\ordf
  2993. \definedummyword\ordm
  2994. %
  2995. % Although these internal commands shouldn't show up, sometimes they do.
  2996. \definedummyword\bf
  2997. \definedummyword\gtr
  2998. \definedummyword\hat
  2999. \definedummyword\less
  3000. \definedummyword\sf
  3001. \definedummyword\sl
  3002. \definedummyword\tclose
  3003. \definedummyword\tt
  3004. %
  3005. \definedummyword\LaTeX
  3006. \definedummyword\TeX
  3007. %
  3008. % Assorted special characters.
  3009. \definedummyword\bullet
  3010. \definedummyword\comma
  3011. \definedummyword\copyright
  3012. \definedummyword\registeredsymbol
  3013. \definedummyword\dots
  3014. \definedummyword\enddots
  3015. \definedummyword\equiv
  3016. \definedummyword\error
  3017. \definedummyword\euro
  3018. \definedummyword\expansion
  3019. \definedummyword\minus
  3020. \definedummyword\pounds
  3021. \definedummyword\point
  3022. \definedummyword\print
  3023. \definedummyword\result
  3024. %
  3025. % We want to disable all macros so that they are not expanded by \write.
  3026. \macrolist
  3027. %
  3028. \normalturnoffactive
  3029. %
  3030. % Handle some cases of @value -- where it does not contain any
  3031. % (non-fully-expandable) commands.
  3032. \makevalueexpandable
  3033. }
  3034. % \commondummiesnofonts: common to \commondummies and \indexnofonts.
  3035. %
  3036. % Better have this without active chars.
  3037. {
  3038. \catcode`\~=\other
  3039. \gdef\commondummiesnofonts{%
  3040. % Control letters and accents.
  3041. \definedummyletter\!%
  3042. \definedummyaccent\"%
  3043. \definedummyaccent\'%
  3044. \definedummyletter\*%
  3045. \definedummyaccent\,%
  3046. \definedummyletter\.%
  3047. \definedummyletter\/%
  3048. \definedummyletter\:%
  3049. \definedummyaccent\=%
  3050. \definedummyletter\?%
  3051. \definedummyaccent\^%
  3052. \definedummyaccent\`%
  3053. \definedummyaccent\~%
  3054. \definedummyword\u
  3055. \definedummyword\v
  3056. \definedummyword\H
  3057. \definedummyword\dotaccent
  3058. \definedummyword\ringaccent
  3059. \definedummyword\tieaccent
  3060. \definedummyword\ubaraccent
  3061. \definedummyword\udotaccent
  3062. \definedummyword\dotless
  3063. %
  3064. % Texinfo font commands.
  3065. \definedummyword\b
  3066. \definedummyword\i
  3067. \definedummyword\r
  3068. \definedummyword\sc
  3069. \definedummyword\t
  3070. %
  3071. % Commands that take arguments.
  3072. \definedummyword\acronym
  3073. \definedummyword\cite
  3074. \definedummyword\code
  3075. \definedummyword\command
  3076. \definedummyword\dfn
  3077. \definedummyword\emph
  3078. \definedummyword\env
  3079. \definedummyword\file
  3080. \definedummyword\kbd
  3081. \definedummyword\key
  3082. \definedummyword\math
  3083. \definedummyword\option
  3084. \definedummyword\samp
  3085. \definedummyword\strong
  3086. \definedummyword\tie
  3087. \definedummyword\uref
  3088. \definedummyword\url
  3089. \definedummyword\var
  3090. \definedummyword\verb
  3091. \definedummyword\w
  3092. }
  3093. }
  3094. % \indexnofonts is used when outputting the strings to sort the index
  3095. % by, and when constructing control sequence names. It eliminates all
  3096. % control sequences and just writes whatever the best ASCII sort string
  3097. % would be for a given command (usually its argument).
  3098. %
  3099. \def\indexnofonts{%
  3100. % Accent commands should become @asis.
  3101. \def\definedummyaccent##1{\let##1\asis}%
  3102. % We can just ignore other control letters.
  3103. \def\definedummyletter##1{\let##1\empty}%
  3104. % Hopefully, all control words can become @asis.
  3105. \let\definedummyword\definedummyaccent
  3106. %
  3107. \commondummiesnofonts
  3108. %
  3109. % Don't no-op \tt, since it isn't a user-level command
  3110. % and is used in the definitions of the active chars like <, >, |, etc.
  3111. % Likewise with the other plain tex font commands.
  3112. %\let\tt=\asis
  3113. %
  3114. \def\ { }%
  3115. \def\@{@}%
  3116. % how to handle braces?
  3117. \def\_{\normalunderscore}%
  3118. %
  3119. % Non-English letters.
  3120. \def\AA{AA}%
  3121. \def\AE{AE}%
  3122. \def\L{L}%
  3123. \def\OE{OE}%
  3124. \def\O{O}%
  3125. \def\aa{aa}%
  3126. \def\ae{ae}%
  3127. \def\l{l}%
  3128. \def\oe{oe}%
  3129. \def\o{o}%
  3130. \def\ss{ss}%
  3131. \def\exclamdown{!}%
  3132. \def\questiondown{?}%
  3133. \def\ordf{a}%
  3134. \def\ordm{o}%
  3135. %
  3136. \def\LaTeX{LaTeX}%
  3137. \def\TeX{TeX}%
  3138. %
  3139. % Assorted special characters.
  3140. % (The following {} will end up in the sort string, but that's ok.)
  3141. \def\bullet{bullet}%
  3142. \def\comma{,}%
  3143. \def\copyright{copyright}%
  3144. \def\registeredsymbol{R}%
  3145. \def\dots{...}%
  3146. \def\enddots{...}%
  3147. \def\equiv{==}%
  3148. \def\error{error}%
  3149. \def\euro{euro}%
  3150. \def\expansion{==>}%
  3151. \def\minus{-}%
  3152. \def\pounds{pounds}%
  3153. \def\point{.}%
  3154. \def\print{-|}%
  3155. \def\result{=>}%
  3156. %
  3157. % We need to get rid of all macros, leaving only the arguments (if present).
  3158. % Of course this is not nearly correct, but it is the best we can do for now.
  3159. % makeinfo does not expand macros in the argument to @deffn, which ends up
  3160. % writing an index entry, and texindex isn't prepared for an index sort entry
  3161. % that starts with \.
  3162. %
  3163. % Since macro invocations are followed by braces, we can just redefine them
  3164. % to take a single TeX argument. The case of a macro invocation that
  3165. % goes to end-of-line is not handled.
  3166. %
  3167. \macrolist
  3168. }
  3169. \let\indexbackslash=0 %overridden during \printindex.
  3170. \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
  3171. % Most index entries go through here, but \dosubind is the general case.
  3172. % #1 is the index name, #2 is the entry text.
  3173. \def\doind#1#2{\dosubind{#1}{#2}{}}
  3174. % Workhorse for all \fooindexes.
  3175. % #1 is name of index, #2 is stuff to put there, #3 is subentry --
  3176. % empty if called from \doind, as we usually are (the main exception
  3177. % is with most defuns, which call us directly).
  3178. %
  3179. \def\dosubind#1#2#3{%
  3180. \iflinks
  3181. {%
  3182. % Store the main index entry text (including the third arg).
  3183. \toks0 = {#2}%
  3184. % If third arg is present, precede it with a space.
  3185. \def\thirdarg{#3}%
  3186. \ifx\thirdarg\empty \else
  3187. \toks0 = \expandafter{\the\toks0 \space #3}%
  3188. \fi
  3189. %
  3190. \edef\writeto{\csname#1indfile\endcsname}%
  3191. %
  3192. \ifvmode
  3193. \dosubindsanitize
  3194. \else
  3195. \dosubindwrite
  3196. \fi
  3197. }%
  3198. \fi
  3199. }
  3200. % Write the entry in \toks0 to the index file:
  3201. %
  3202. \def\dosubindwrite{%
  3203. % Put the index entry in the margin if desired.
  3204. \ifx\SETmarginindex\relax\else
  3205. \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
  3206. \fi
  3207. %
  3208. % Remember, we are within a group.
  3209. \indexdummies % Must do this here, since \bf, etc expand at this stage
  3210. \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
  3211. % so it will be output as is; and it will print as backslash.
  3212. %
  3213. % Process the index entry with all font commands turned off, to
  3214. % get the string to sort by.
  3215. {\indexnofonts
  3216. \edef\temp{\the\toks0}% need full expansion
  3217. \xdef\indexsorttmp{\temp}%
  3218. }%
  3219. %
  3220. % Set up the complete index entry, with both the sort key and
  3221. % the original text, including any font commands. We write
  3222. % three arguments to \entry to the .?? file (four in the
  3223. % subentry case), texindex reduces to two when writing the .??s
  3224. % sorted result.
  3225. \edef\temp{%
  3226. \write\writeto{%
  3227. \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
  3228. }%
  3229. \temp
  3230. }
  3231. % Take care of unwanted page breaks:
  3232. %
  3233. % If a skip is the last thing on the list now, preserve it
  3234. % by backing up by \lastskip, doing the \write, then inserting
  3235. % the skip again. Otherwise, the whatsit generated by the
  3236. % \write will make \lastskip zero. The result is that sequences
  3237. % like this:
  3238. % @end defun
  3239. % @tindex whatever
  3240. % @defun ...
  3241. % will have extra space inserted, because the \medbreak in the
  3242. % start of the @defun won't see the skip inserted by the @end of
  3243. % the previous defun.
  3244. %
  3245. % But don't do any of this if we're not in vertical mode. We
  3246. % don't want to do a \vskip and prematurely end a paragraph.
  3247. %
  3248. % Avoid page breaks due to these extra skips, too.
  3249. %
  3250. % But wait, there is a catch there:
  3251. % We'll have to check whether \lastskip is zero skip. \ifdim is not
  3252. % sufficient for this purpose, as it ignores stretch and shrink parts
  3253. % of the skip. The only way seems to be to check the textual
  3254. % representation of the skip.
  3255. %
  3256. % The following is almost like \def\zeroskipmacro{0.0pt} except that
  3257. % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
  3258. %
  3259. \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
  3260. %
  3261. % ..., ready, GO:
  3262. %
  3263. \def\dosubindsanitize{%
  3264. % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
  3265. \skip0 = \lastskip
  3266. \edef\lastskipmacro{\the\lastskip}%
  3267. \count255 = \lastpenalty
  3268. %
  3269. % If \lastskip is nonzero, that means the last item was a
  3270. % skip. And since a skip is discardable, that means this
  3271. % -\skip0 glue we're inserting is preceded by a
  3272. % non-discardable item, therefore it is not a potential
  3273. % breakpoint, therefore no \nobreak needed.
  3274. \ifx\lastskipmacro\zeroskipmacro
  3275. \else
  3276. \vskip-\skip0
  3277. \fi
  3278. %
  3279. \dosubindwrite
  3280. %
  3281. \ifx\lastskipmacro\zeroskipmacro
  3282. % If \lastskip was zero, perhaps the last item was a penalty, and
  3283. % perhaps it was >=10000, e.g., a \nobreak. In that case, we want
  3284. % to re-insert the same penalty (values >10000 are used for various
  3285. % signals); since we just inserted a non-discardable item, any
  3286. % following glue (such as a \parskip) would be a breakpoint. For example:
  3287. %
  3288. % @deffn deffn-whatever
  3289. % @vindex index-whatever
  3290. % Description.
  3291. % would allow a break between the index-whatever whatsit
  3292. % and the "Description." paragraph.
  3293. \ifnum\count255>9999 \penalty\count255 \fi
  3294. \else
  3295. % On the other hand, if we had a nonzero \lastskip,
  3296. % this make-up glue would be preceded by a non-discardable item
  3297. % (the whatsit from the \write), so we must insert a \nobreak.
  3298. \nobreak\vskip\skip0
  3299. \fi
  3300. }
  3301. % The index entry written in the file actually looks like
  3302. % \entry {sortstring}{page}{topic}
  3303. % or
  3304. % \entry {sortstring}{page}{topic}{subtopic}
  3305. % The texindex program reads in these files and writes files
  3306. % containing these kinds of lines:
  3307. % \initial {c}
  3308. % before the first topic whose initial is c
  3309. % \entry {topic}{pagelist}
  3310. % for a topic that is used without subtopics
  3311. % \primary {topic}
  3312. % for the beginning of a topic that is used with subtopics
  3313. % \secondary {subtopic}{pagelist}
  3314. % for each subtopic.
  3315. % Define the user-accessible indexing commands
  3316. % @findex, @vindex, @kindex, @cindex.
  3317. \def\findex {\fnindex}
  3318. \def\kindex {\kyindex}
  3319. \def\cindex {\cpindex}
  3320. \def\vindex {\vrindex}
  3321. \def\tindex {\tpindex}
  3322. \def\pindex {\pgindex}
  3323. \def\cindexsub {\begingroup\obeylines\cindexsub}
  3324. {\obeylines %
  3325. \gdef\cindexsub "#1" #2^^M{\endgroup %
  3326. \dosubind{cp}{#2}{#1}}}
  3327. % Define the macros used in formatting output of the sorted index material.
  3328. % @printindex causes a particular index (the ??s file) to get printed.
  3329. % It does not print any chapter heading (usually an @unnumbered).
  3330. %
  3331. \parseargdef\printindex{\begingroup
  3332. \dobreak \chapheadingskip{10000}%
  3333. %
  3334. \smallfonts \rm
  3335. \tolerance = 9500
  3336. \everypar = {}% don't want the \kern\-parindent from indentation suppression.
  3337. %
  3338. % See if the index file exists and is nonempty.
  3339. % Change catcode of @ here so that if the index file contains
  3340. % \initial {@}
  3341. % as its first line, TeX doesn't complain about mismatched braces
  3342. % (because it thinks @} is a control sequence).
  3343. \catcode`\@ = 11
  3344. \openin 1 \jobname.#1s
  3345. \ifeof 1
  3346. % \enddoublecolumns gets confused if there is no text in the index,
  3347. % and it loses the chapter title and the aux file entries for the
  3348. % index. The easiest way to prevent this problem is to make sure
  3349. % there is some text.
  3350. \putwordIndexNonexistent
  3351. \else
  3352. %
  3353. % If the index file exists but is empty, then \openin leaves \ifeof
  3354. % false. We have to make TeX try to read something from the file, so
  3355. % it can discover if there is anything in it.
  3356. \read 1 to \temp
  3357. \ifeof 1
  3358. \putwordIndexIsEmpty
  3359. \else
  3360. % Index files are almost Texinfo source, but we use \ as the escape
  3361. % character. It would be better to use @, but that's too big a change
  3362. % to make right now.
  3363. \def\indexbackslash{\backslashcurfont}%
  3364. \catcode`\\ = 0
  3365. \escapechar = `\\
  3366. \begindoublecolumns
  3367. \input \jobname.#1s
  3368. \enddoublecolumns
  3369. \fi
  3370. \fi
  3371. \closein 1
  3372. \endgroup}
  3373. % These macros are used by the sorted index file itself.
  3374. % Change them to control the appearance of the index.
  3375. \def\initial#1{{%
  3376. % Some minor font changes for the special characters.
  3377. \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
  3378. %
  3379. % Remove any glue we may have, we'll be inserting our own.
  3380. \removelastskip
  3381. %
  3382. % We like breaks before the index initials, so insert a bonus.
  3383. \nobreak
  3384. \vskip 0pt plus 3\baselineskip
  3385. \penalty 0
  3386. \vskip 0pt plus -3\baselineskip
  3387. %
  3388. % Typeset the initial. Making this add up to a whole number of
  3389. % baselineskips increases the chance of the dots lining up from column
  3390. % to column. It still won't often be perfect, because of the stretch
  3391. % we need before each entry, but it's better.
  3392. %
  3393. % No shrink because it confuses \balancecolumns.
  3394. \vskip 1.67\baselineskip plus .5\baselineskip
  3395. \leftline{\secbf #1}%
  3396. % Do our best not to break after the initial.
  3397. \nobreak
  3398. \vskip .33\baselineskip plus .1\baselineskip
  3399. }}
  3400. % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
  3401. % then page number (#2) flushed to the right margin. It is used for index
  3402. % and table of contents entries. The paragraph is indented by \leftskip.
  3403. %
  3404. % A straightforward implementation would start like this:
  3405. % \def\entry#1#2{...
  3406. % But this frozes the catcodes in the argument, and can cause problems to
  3407. % @code, which sets - active. This problem was fixed by a kludge---
  3408. % ``-'' was active throughout whole index, but this isn't really right.
  3409. %
  3410. % The right solution is to prevent \entry from swallowing the whole text.
  3411. % --kasal, 21nov03
  3412. \def\entry{%
  3413. \begingroup
  3414. %
  3415. % Start a new paragraph if necessary, so our assignments below can't
  3416. % affect previous text.
  3417. \par
  3418. %
  3419. % Do not fill out the last line with white space.
  3420. \parfillskip = 0in
  3421. %
  3422. % No extra space above this paragraph.
  3423. \parskip = 0in
  3424. %
  3425. % Do not prefer a separate line ending with a hyphen to fewer lines.
  3426. \finalhyphendemerits = 0
  3427. %
  3428. % \hangindent is only relevant when the entry text and page number
  3429. % don't both fit on one line. In that case, bob suggests starting the
  3430. % dots pretty far over on the line. Unfortunately, a large
  3431. % indentation looks wrong when the entry text itself is broken across
  3432. % lines. So we use a small indentation and put up with long leaders.
  3433. %
  3434. % \hangafter is reset to 1 (which is the value we want) at the start
  3435. % of each paragraph, so we need not do anything with that.
  3436. \hangindent = 2em
  3437. %
  3438. % When the entry text needs to be broken, just fill out the first line
  3439. % with blank space.
  3440. \rightskip = 0pt plus1fil
  3441. %
  3442. % A bit of stretch before each entry for the benefit of balancing
  3443. % columns.
  3444. \vskip 0pt plus1pt
  3445. %
  3446. % Swallow the left brace of the text (first parameter):
  3447. \afterassignment\doentry
  3448. \let\temp =
  3449. }
  3450. \def\doentry{%
  3451. \bgroup % Instead of the swallowed brace.
  3452. \noindent
  3453. \aftergroup\finishentry
  3454. % And now comes the text of the entry.
  3455. }
  3456. \def\finishentry#1{%
  3457. % #1 is the page number.
  3458. %
  3459. % The following is kludged to not output a line of dots in the index if
  3460. % there are no page numbers. The next person who breaks this will be
  3461. % cursed by a Unix daemon.
  3462. \def\tempa{{\rm }}%
  3463. \def\tempb{#1}%
  3464. \edef\tempc{\tempa}%
  3465. \edef\tempd{\tempb}%
  3466. \ifx\tempc\tempd
  3467. \ %
  3468. \else
  3469. %
  3470. % If we must, put the page number on a line of its own, and fill out
  3471. % this line with blank space. (The \hfil is overwhelmed with the
  3472. % fill leaders glue in \indexdotfill if the page number does fit.)
  3473. \hfil\penalty50
  3474. \null\nobreak\indexdotfill % Have leaders before the page number.
  3475. %
  3476. % The `\ ' here is removed by the implicit \unskip that TeX does as
  3477. % part of (the primitive) \par. Without it, a spurious underfull
  3478. % \hbox ensues.
  3479. \ifpdf
  3480. \pdfgettoks#1.%
  3481. \ \the\toksA
  3482. \else
  3483. \ #1%
  3484. \fi
  3485. \fi
  3486. \par
  3487. \endgroup
  3488. }
  3489. % Like \dotfill except takes at least 1 em.
  3490. \def\indexdotfill{\cleaders
  3491. \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
  3492. \def\primary #1{\line{#1\hfil}}
  3493. \newskip\secondaryindent \secondaryindent=0.5cm
  3494. \def\secondary#1#2{{%
  3495. \parfillskip=0in
  3496. \parskip=0in
  3497. \hangindent=1in
  3498. \hangafter=1
  3499. \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
  3500. \ifpdf
  3501. \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
  3502. \else
  3503. #2
  3504. \fi
  3505. \par
  3506. }}
  3507. % Define two-column mode, which we use to typeset indexes.
  3508. % Adapted from the TeXbook, page 416, which is to say,
  3509. % the manmac.tex format used to print the TeXbook itself.
  3510. \catcode`\@=11
  3511. \newbox\partialpage
  3512. \newdimen\doublecolumnhsize
  3513. \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
  3514. % Grab any single-column material above us.
  3515. \output = {%
  3516. %
  3517. % Here is a possibility not foreseen in manmac: if we accumulate a
  3518. % whole lot of material, we might end up calling this \output
  3519. % routine twice in a row (see the doublecol-lose test, which is
  3520. % essentially a couple of indexes with @setchapternewpage off). In
  3521. % that case we just ship out what is in \partialpage with the normal
  3522. % output routine. Generally, \partialpage will be empty when this
  3523. % runs and this will be a no-op. See the indexspread.tex test case.
  3524. \ifvoid\partialpage \else
  3525. \onepageout{\pagecontents\partialpage}%
  3526. \fi
  3527. %
  3528. \global\setbox\partialpage = \vbox{%
  3529. % Unvbox the main output page.
  3530. \unvbox\PAGE
  3531. \kern-\topskip \kern\baselineskip
  3532. }%
  3533. }%
  3534. \eject % run that output routine to set \partialpage
  3535. %
  3536. % Use the double-column output routine for subsequent pages.
  3537. \output = {\doublecolumnout}%
  3538. %
  3539. % Change the page size parameters. We could do this once outside this
  3540. % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
  3541. % format, but then we repeat the same computation. Repeating a couple
  3542. % of assignments once per index is clearly meaningless for the
  3543. % execution time, so we may as well do it in one place.
  3544. %
  3545. % First we halve the line length, less a little for the gutter between
  3546. % the columns. We compute the gutter based on the line length, so it
  3547. % changes automatically with the paper format. The magic constant
  3548. % below is chosen so that the gutter has the same value (well, +-<1pt)
  3549. % as it did when we hard-coded it.
  3550. %
  3551. % We put the result in a separate register, \doublecolumhsize, so we
  3552. % can restore it in \pagesofar, after \hsize itself has (potentially)
  3553. % been clobbered.
  3554. %
  3555. \doublecolumnhsize = \hsize
  3556. \advance\doublecolumnhsize by -.04154\hsize
  3557. \divide\doublecolumnhsize by 2
  3558. \hsize = \doublecolumnhsize
  3559. %
  3560. % Double the \vsize as well. (We don't need a separate register here,
  3561. % since nobody clobbers \vsize.)
  3562. \vsize = 2\vsize
  3563. }
  3564. % The double-column output routine for all double-column pages except
  3565. % the last.
  3566. %
  3567. \def\doublecolumnout{%
  3568. \splittopskip=\topskip \splitmaxdepth=\maxdepth
  3569. % Get the available space for the double columns -- the normal
  3570. % (undoubled) page height minus any material left over from the
  3571. % previous page.
  3572. \dimen@ = \vsize
  3573. \divide\dimen@ by 2
  3574. \advance\dimen@ by -\ht\partialpage
  3575. %
  3576. % box0 will be the left-hand column, box2 the right.
  3577. \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  3578. \onepageout\pagesofar
  3579. \unvbox255
  3580. \penalty\outputpenalty
  3581. }
  3582. %
  3583. % Re-output the contents of the output page -- any previous material,
  3584. % followed by the two boxes we just split, in box0 and box2.
  3585. \def\pagesofar{%
  3586. \unvbox\partialpage
  3587. %
  3588. \hsize = \doublecolumnhsize
  3589. \wd0=\hsize \wd2=\hsize
  3590. \hbox to\pagewidth{\box0\hfil\box2}%
  3591. }
  3592. %
  3593. % All done with double columns.
  3594. \def\enddoublecolumns{%
  3595. \output = {%
  3596. % Split the last of the double-column material. Leave it on the
  3597. % current page, no automatic page break.
  3598. \balancecolumns
  3599. %
  3600. % If we end up splitting too much material for the current page,
  3601. % though, there will be another page break right after this \output
  3602. % invocation ends. Having called \balancecolumns once, we do not
  3603. % want to call it again. Therefore, reset \output to its normal
  3604. % definition right away. (We hope \balancecolumns will never be
  3605. % called on to balance too much material, but if it is, this makes
  3606. % the output somewhat more palatable.)
  3607. \global\output = {\onepageout{\pagecontents\PAGE}}%
  3608. }%
  3609. \eject
  3610. \endgroup % started in \begindoublecolumns
  3611. %
  3612. % \pagegoal was set to the doubled \vsize above, since we restarted
  3613. % the current page. We're now back to normal single-column
  3614. % typesetting, so reset \pagegoal to the normal \vsize (after the
  3615. % \endgroup where \vsize got restored).
  3616. \pagegoal = \vsize
  3617. }
  3618. %
  3619. % Called at the end of the double column material.
  3620. \def\balancecolumns{%
  3621. \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
  3622. \dimen@ = \ht0
  3623. \advance\dimen@ by \topskip
  3624. \advance\dimen@ by-\baselineskip
  3625. \divide\dimen@ by 2 % target to split to
  3626. %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}%
  3627. \splittopskip = \topskip
  3628. % Loop until we get a decent breakpoint.
  3629. {%
  3630. \vbadness = 10000
  3631. \loop
  3632. \global\setbox3 = \copy0
  3633. \global\setbox1 = \vsplit3 to \dimen@
  3634. \ifdim\ht3>\dimen@
  3635. \global\advance\dimen@ by 1pt
  3636. \repeat
  3637. }%
  3638. %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
  3639. \setbox0=\vbox to\dimen@{\unvbox1}%
  3640. \setbox2=\vbox to\dimen@{\unvbox3}%
  3641. %
  3642. \pagesofar
  3643. }
  3644. \catcode`\@ = \other
  3645. \message{sectioning,}
  3646. % Chapters, sections, etc.
  3647. % \unnumberedno is an oxymoron, of course. But we count the unnumbered
  3648. % sections so that we can refer to them unambiguously in the pdf
  3649. % outlines by their "section number". We avoid collisions with chapter
  3650. % numbers by starting them at 10000. (If a document ever has 10000
  3651. % chapters, we're in trouble anyway, I'm sure.)
  3652. \newcount\unnumberedno \unnumberedno = 10000
  3653. \newcount\chapno
  3654. \newcount\secno \secno=0
  3655. \newcount\subsecno \subsecno=0
  3656. \newcount\subsubsecno \subsubsecno=0
  3657. % This counter is funny since it counts through charcodes of letters A, B, ...
  3658. \newcount\appendixno \appendixno = `\@
  3659. %
  3660. % \def\appendixletter{\char\the\appendixno}
  3661. % We do the following ugly conditional instead of the above simple
  3662. % construct for the sake of pdftex, which needs the actual
  3663. % letter in the expansion, not just typeset.
  3664. %
  3665. \def\appendixletter{%
  3666. \ifnum\appendixno=`A A%
  3667. \else\ifnum\appendixno=`B B%
  3668. \else\ifnum\appendixno=`C C%
  3669. \else\ifnum\appendixno=`D D%
  3670. \else\ifnum\appendixno=`E E%
  3671. \else\ifnum\appendixno=`F F%
  3672. \else\ifnum\appendixno=`G G%
  3673. \else\ifnum\appendixno=`H H%
  3674. \else\ifnum\appendixno=`I I%
  3675. \else\ifnum\appendixno=`J J%
  3676. \else\ifnum\appendixno=`K K%
  3677. \else\ifnum\appendixno=`L L%
  3678. \else\ifnum\appendixno=`M M%
  3679. \else\ifnum\appendixno=`N N%
  3680. \else\ifnum\appendixno=`O O%
  3681. \else\ifnum\appendixno=`P P%
  3682. \else\ifnum\appendixno=`Q Q%
  3683. \else\ifnum\appendixno=`R R%
  3684. \else\ifnum\appendixno=`S S%
  3685. \else\ifnum\appendixno=`T T%
  3686. \else\ifnum\appendixno=`U U%
  3687. \else\ifnum\appendixno=`V V%
  3688. \else\ifnum\appendixno=`W W%
  3689. \else\ifnum\appendixno=`X X%
  3690. \else\ifnum\appendixno=`Y Y%
  3691. \else\ifnum\appendixno=`Z Z%
  3692. % The \the is necessary, despite appearances, because \appendixletter is
  3693. % expanded while writing the .toc file. \char\appendixno is not
  3694. % expandable, thus it is written literally, thus all appendixes come out
  3695. % with the same letter (or @) in the toc without it.
  3696. \else\char\the\appendixno
  3697. \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
  3698. \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
  3699. % Each @chapter defines this as the name of the chapter.
  3700. % page headings and footings can use it. @section does likewise.
  3701. % However, they are not reliable, because we don't use marks.
  3702. \def\thischapter{}
  3703. \def\thissection{}
  3704. \newcount\absseclevel % used to calculate proper heading level
  3705. \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
  3706. % @raisesections: treat @section as chapter, @subsection as section, etc.
  3707. \def\raisesections{\global\advance\secbase by -1}
  3708. \let\up=\raisesections % original BFox name
  3709. % @lowersections: treat @chapter as section, @section as subsection, etc.
  3710. \def\lowersections{\global\advance\secbase by 1}
  3711. \let\down=\lowersections % original BFox name
  3712. % we only have subsub.
  3713. \chardef\maxseclevel = 3
  3714. %
  3715. % A numbered section within an unnumbered changes to unnumbered too.
  3716. % To achive this, remember the "biggest" unnum. sec. we are currently in:
  3717. \chardef\unmlevel = \maxseclevel
  3718. %
  3719. % Trace whether the current chapter is an appendix or not:
  3720. % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
  3721. \def\chapheadtype{N}
  3722. % Choose a heading macro
  3723. % #1 is heading type
  3724. % #2 is heading level
  3725. % #3 is text for heading
  3726. \def\genhead#1#2#3{%
  3727. % Compute the abs. sec. level:
  3728. \absseclevel=#2
  3729. \advance\absseclevel by \secbase
  3730. % Make sure \absseclevel doesn't fall outside the range:
  3731. \ifnum \absseclevel < 0
  3732. \absseclevel = 0
  3733. \else
  3734. \ifnum \absseclevel > 3
  3735. \absseclevel = 3
  3736. \fi
  3737. \fi
  3738. % The heading type:
  3739. \def\headtype{#1}%
  3740. \if \headtype U%
  3741. \ifnum \absseclevel < \unmlevel
  3742. \chardef\unmlevel = \absseclevel
  3743. \fi
  3744. \else
  3745. % Check for appendix sections:
  3746. \ifnum \absseclevel = 0
  3747. \edef\chapheadtype{\headtype}%
  3748. \else
  3749. \if \headtype A\if \chapheadtype N%
  3750. \errmessage{@appendix... within a non-appendix chapter}%
  3751. \fi\fi
  3752. \fi
  3753. % Check for numbered within unnumbered:
  3754. \ifnum \absseclevel > \unmlevel
  3755. \def\headtype{U}%
  3756. \else
  3757. \chardef\unmlevel = 3
  3758. \fi
  3759. \fi
  3760. % Now print the heading:
  3761. \if \headtype U%
  3762. \ifcase\absseclevel
  3763. \unnumberedzzz{#3}%
  3764. \or \unnumberedseczzz{#3}%
  3765. \or \unnumberedsubseczzz{#3}%
  3766. \or \unnumberedsubsubseczzz{#3}%
  3767. \fi
  3768. \else
  3769. \if \headtype A%
  3770. \ifcase\absseclevel
  3771. \appendixzzz{#3}%
  3772. \or \appendixsectionzzz{#3}%
  3773. \or \appendixsubseczzz{#3}%
  3774. \or \appendixsubsubseczzz{#3}%
  3775. \fi
  3776. \else
  3777. \ifcase\absseclevel
  3778. \chapterzzz{#3}%
  3779. \or \seczzz{#3}%
  3780. \or \numberedsubseczzz{#3}%
  3781. \or \numberedsubsubseczzz{#3}%
  3782. \fi
  3783. \fi
  3784. \fi
  3785. \suppressfirstparagraphindent
  3786. }
  3787. % an interface:
  3788. \def\numhead{\genhead N}
  3789. \def\apphead{\genhead A}
  3790. \def\unnmhead{\genhead U}
  3791. % @chapter, @appendix, @unnumbered. Increment top-level counter, reset
  3792. % all lower-level sectioning counters to zero.
  3793. %
  3794. % Also set \chaplevelprefix, which we prepend to @float sequence numbers
  3795. % (e.g., figures), q.v. By default (before any chapter), that is empty.
  3796. \let\chaplevelprefix = \empty
  3797. %
  3798. \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
  3799. \def\chapterzzz#1{%
  3800. % section resetting is \global in case the chapter is in a group, such
  3801. % as an @include file.
  3802. \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
  3803. \global\advance\chapno by 1
  3804. %
  3805. % Used for \float.
  3806. \gdef\chaplevelprefix{\the\chapno.}%
  3807. \resetallfloatnos
  3808. %
  3809. \message{\putwordChapter\space \the\chapno}%
  3810. %
  3811. % Write the actual heading.
  3812. \chapmacro{#1}{Ynumbered}{\the\chapno}%
  3813. %
  3814. % So @section and the like are numbered underneath this chapter.
  3815. \global\let\section = \numberedsec
  3816. \global\let\subsection = \numberedsubsec
  3817. \global\let\subsubsection = \numberedsubsubsec
  3818. }
  3819. \outer\parseargdef\appendix{\apphead0{#1}} % normally apphead0 calls appendixzzz
  3820. \def\appendixzzz#1{%
  3821. \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
  3822. \global\advance\appendixno by 1
  3823. \gdef\chaplevelprefix{\appendixletter.}%
  3824. \resetallfloatnos
  3825. %
  3826. \def\appendixnum{\putwordAppendix\space \appendixletter}%
  3827. \message{\appendixnum}%
  3828. %
  3829. \chapmacro{#1}{Yappendix}{\appendixletter}%
  3830. %
  3831. \global\let\section = \appendixsec
  3832. \global\let\subsection = \appendixsubsec
  3833. \global\let\subsubsection = \appendixsubsubsec
  3834. }
  3835. \outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
  3836. \def\unnumberedzzz#1{%
  3837. \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
  3838. \global\advance\unnumberedno by 1
  3839. %
  3840. % Since an unnumbered has no number, no prefix for figures.
  3841. \global\let\chaplevelprefix = \empty
  3842. \resetallfloatnos
  3843. %
  3844. % This used to be simply \message{#1}, but TeX fully expands the
  3845. % argument to \message. Therefore, if #1 contained @-commands, TeX
  3846. % expanded them. For example, in `@unnumbered The @cite{Book}', TeX
  3847. % expanded @cite (which turns out to cause errors because \cite is meant
  3848. % to be executed, not expanded).
  3849. %
  3850. % Anyway, we don't want the fully-expanded definition of @cite to appear
  3851. % as a result of the \message, we just want `@cite' itself. We use
  3852. % \the<toks register> to achieve this: TeX expands \the<toks> only once,
  3853. % simply yielding the contents of <toks register>. (We also do this for
  3854. % the toc entries.)
  3855. \toks0 = {#1}%
  3856. \message{(\the\toks0)}%
  3857. %
  3858. \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
  3859. %
  3860. \global\let\section = \unnumberedsec
  3861. \global\let\subsection = \unnumberedsubsec
  3862. \global\let\subsubsection = \unnumberedsubsubsec
  3863. }
  3864. % @centerchap is like @unnumbered, but the heading is centered.
  3865. \outer\parseargdef\centerchap{%
  3866. % Well, we could do the following in a group, but that would break
  3867. % an assumption that \chapmacro is called at the outermost level.
  3868. % Thus we are safer this way: --kasal, 24feb04
  3869. \let\centerparametersmaybe = \centerparameters
  3870. \unnmhead0{#1}%
  3871. \let\centerparametersmaybe = \relax
  3872. }
  3873. % @top is like @unnumbered.
  3874. \let\top\unnumbered
  3875. % Sections.
  3876. \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
  3877. \def\seczzz#1{%
  3878. \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
  3879. \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
  3880. }
  3881. \outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz
  3882. \def\appendixsectionzzz#1{%
  3883. \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
  3884. \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
  3885. }
  3886. \let\appendixsec\appendixsection
  3887. \outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz
  3888. \def\unnumberedseczzz#1{%
  3889. \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
  3890. \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
  3891. }
  3892. % Subsections.
  3893. \outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz
  3894. \def\numberedsubseczzz#1{%
  3895. \global\subsubsecno=0 \global\advance\subsecno by 1
  3896. \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
  3897. }
  3898. \outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz
  3899. \def\appendixsubseczzz#1{%
  3900. \global\subsubsecno=0 \global\advance\subsecno by 1
  3901. \sectionheading{#1}{subsec}{Yappendix}%
  3902. {\appendixletter.\the\secno.\the\subsecno}%
  3903. }
  3904. \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
  3905. \def\unnumberedsubseczzz#1{%
  3906. \global\subsubsecno=0 \global\advance\subsecno by 1
  3907. \sectionheading{#1}{subsec}{Ynothing}%
  3908. {\the\unnumberedno.\the\secno.\the\subsecno}%
  3909. }
  3910. % Subsubsections.
  3911. \outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz
  3912. \def\numberedsubsubseczzz#1{%
  3913. \global\advance\subsubsecno by 1
  3914. \sectionheading{#1}{subsubsec}{Ynumbered}%
  3915. {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
  3916. }
  3917. \outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz
  3918. \def\appendixsubsubseczzz#1{%
  3919. \global\advance\subsubsecno by 1
  3920. \sectionheading{#1}{subsubsec}{Yappendix}%
  3921. {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
  3922. }
  3923. \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
  3924. \def\unnumberedsubsubseczzz#1{%
  3925. \global\advance\subsubsecno by 1
  3926. \sectionheading{#1}{subsubsec}{Ynothing}%
  3927. {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
  3928. }
  3929. % These macros control what the section commands do, according
  3930. % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
  3931. % Define them by default for a numbered chapter.
  3932. \let\section = \numberedsec
  3933. \let\subsection = \numberedsubsec
  3934. \let\subsubsection = \numberedsubsubsec
  3935. % Define @majorheading, @heading and @subheading
  3936. % NOTE on use of \vbox for chapter headings, section headings, and such:
  3937. % 1) We use \vbox rather than the earlier \line to permit
  3938. % overlong headings to fold.
  3939. % 2) \hyphenpenalty is set to 10000 because hyphenation in a
  3940. % heading is obnoxious; this forbids it.
  3941. % 3) Likewise, headings look best if no \parindent is used, and
  3942. % if justification is not attempted. Hence \raggedright.
  3943. \def\majorheading{%
  3944. {\advance\chapheadingskip by 10pt \chapbreak }%
  3945. \parsearg\chapheadingzzz
  3946. }
  3947. \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
  3948. \def\chapheadingzzz#1{%
  3949. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  3950. \parindent=0pt\raggedright
  3951. \rm #1\hfill}}%
  3952. \bigskip \par\penalty 200\relax
  3953. \suppressfirstparagraphindent
  3954. }
  3955. % @heading, @subheading, @subsubheading.
  3956. \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
  3957. \suppressfirstparagraphindent}
  3958. \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
  3959. \suppressfirstparagraphindent}
  3960. \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
  3961. \suppressfirstparagraphindent}
  3962. % These macros generate a chapter, section, etc. heading only
  3963. % (including whitespace, linebreaking, etc. around it),
  3964. % given all the information in convenient, parsed form.
  3965. %%% Args are the skip and penalty (usually negative)
  3966. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  3967. %%% Define plain chapter starts, and page on/off switching for it
  3968. % Parameter controlling skip before chapter headings (if needed)
  3969. \newskip\chapheadingskip
  3970. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  3971. \def\chappager{\par\vfill\supereject}
  3972. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  3973. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  3974. \def\CHAPPAGoff{%
  3975. \global\let\contentsalignmacro = \chappager
  3976. \global\let\pchapsepmacro=\chapbreak
  3977. \global\let\pagealignmacro=\chappager}
  3978. \def\CHAPPAGon{%
  3979. \global\let\contentsalignmacro = \chappager
  3980. \global\let\pchapsepmacro=\chappager
  3981. \global\let\pagealignmacro=\chappager
  3982. \global\def\HEADINGSon{\HEADINGSsingle}}
  3983. \def\CHAPPAGodd{%
  3984. \global\let\contentsalignmacro = \chapoddpage
  3985. \global\let\pchapsepmacro=\chapoddpage
  3986. \global\let\pagealignmacro=\chapoddpage
  3987. \global\def\HEADINGSon{\HEADINGSdouble}}
  3988. \CHAPPAGon
  3989. % Chapter opening.
  3990. %
  3991. % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
  3992. % Yappendix, Yomitfromtoc), #3 the chapter number.
  3993. %
  3994. % To test against our argument.
  3995. \def\Ynothingkeyword{Ynothing}
  3996. \def\Yomitfromtockeyword{Yomitfromtoc}
  3997. \def\Yappendixkeyword{Yappendix}
  3998. %
  3999. \def\chapmacro#1#2#3{%
  4000. \pchapsepmacro
  4001. {%
  4002. \chapfonts \rm
  4003. %
  4004. % Have to define \thissection before calling \donoderef, because the
  4005. % xref code eventually uses it. On the other hand, it has to be called
  4006. % after \pchapsepmacro, or the headline will change too soon.
  4007. \gdef\thissection{#1}%
  4008. \gdef\thischaptername{#1}%
  4009. %
  4010. % Only insert the separating space if we have a chapter/appendix
  4011. % number, and don't print the unnumbered ``number''.
  4012. \def\temptype{#2}%
  4013. \ifx\temptype\Ynothingkeyword
  4014. \setbox0 = \hbox{}%
  4015. \def\toctype{unnchap}%
  4016. \gdef\thischapter{#1}%
  4017. \else\ifx\temptype\Yomitfromtockeyword
  4018. \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
  4019. \def\toctype{omit}%
  4020. \gdef\thischapter{}%
  4021. \else\ifx\temptype\Yappendixkeyword
  4022. \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
  4023. \def\toctype{app}%
  4024. % We don't substitute the actual chapter name into \thischapter
  4025. % because we don't want its macros evaluated now. And we don't
  4026. % use \thissection because that changes with each section.
  4027. %
  4028. \xdef\thischapter{\putwordAppendix{} \appendixletter:
  4029. \noexpand\thischaptername}%
  4030. \else
  4031. \setbox0 = \hbox{#3\enspace}%
  4032. \def\toctype{numchap}%
  4033. \xdef\thischapter{\putwordChapter{} \the\chapno:
  4034. \noexpand\thischaptername}%
  4035. \fi\fi\fi
  4036. %
  4037. % Write the toc entry for this chapter. Must come before the
  4038. % \donoderef, because we include the current node name in the toc
  4039. % entry, and \donoderef resets it to empty.
  4040. \writetocentry{\toctype}{#1}{#3}%
  4041. %
  4042. % For pdftex, we have to write out the node definition (aka, make
  4043. % the pdfdest) after any page break, but before the actual text has
  4044. % been typeset. If the destination for the pdf outline is after the
  4045. % text, then jumping from the outline may wind up with the text not
  4046. % being visible, for instance under high magnification.
  4047. \donoderef{#2}%
  4048. %
  4049. % Typeset the actual heading.
  4050. \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
  4051. \hangindent=\wd0 \centerparametersmaybe
  4052. \unhbox0 #1\par}%
  4053. }%
  4054. \nobreak\bigskip % no page break after a chapter title
  4055. \nobreak
  4056. }
  4057. % @centerchap -- centered and unnumbered.
  4058. \let\centerparametersmaybe = \relax
  4059. \def\centerparameters{%
  4060. \advance\rightskip by 3\rightskip
  4061. \leftskip = \rightskip
  4062. \parfillskip = 0pt
  4063. }
  4064. % I don't think this chapter style is supported any more, so I'm not
  4065. % updating it with the new noderef stuff. We'll see. --karl, 11aug03.
  4066. %
  4067. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  4068. %
  4069. \def\unnchfopen #1{%
  4070. \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  4071. \parindent=0pt\raggedright
  4072. \rm #1\hfill}}\bigskip \par\nobreak
  4073. }
  4074. \def\chfopen #1#2{\chapoddpage {\chapfonts
  4075. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  4076. \par\penalty 5000 %
  4077. }
  4078. \def\centerchfopen #1{%
  4079. \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  4080. \parindent=0pt
  4081. \hfill {\rm #1}\hfill}}\bigskip \par\nobreak
  4082. }
  4083. \def\CHAPFopen{%
  4084. \global\let\chapmacro=\chfopen
  4085. \global\let\centerchapmacro=\centerchfopen}
  4086. % Section titles. These macros combine the section number parts and
  4087. % call the generic \sectionheading to do the printing.
  4088. %
  4089. \newskip\secheadingskip
  4090. \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
  4091. % Subsection titles.
  4092. \newskip\subsecheadingskip
  4093. \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
  4094. % Subsubsection titles.
  4095. \def\subsubsecheadingskip{\subsecheadingskip}
  4096. \def\subsubsecheadingbreak{\subsecheadingbreak}
  4097. % Print any size, any type, section title.
  4098. %
  4099. % #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is
  4100. % the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
  4101. % section number.
  4102. %
  4103. \def\sectionheading#1#2#3#4{%
  4104. {%
  4105. % Switch to the right set of fonts.
  4106. \csname #2fonts\endcsname \rm
  4107. %
  4108. % Insert space above the heading.
  4109. \csname #2headingbreak\endcsname
  4110. %
  4111. % Only insert the space after the number if we have a section number.
  4112. \def\sectionlevel{#2}%
  4113. \def\temptype{#3}%
  4114. %
  4115. \ifx\temptype\Ynothingkeyword
  4116. \setbox0 = \hbox{}%
  4117. \def\toctype{unn}%
  4118. \gdef\thissection{#1}%
  4119. \else\ifx\temptype\Yomitfromtockeyword
  4120. % for @headings -- no section number, don't include in toc,
  4121. % and don't redefine \thissection.
  4122. \setbox0 = \hbox{}%
  4123. \def\toctype{omit}%
  4124. \let\sectionlevel=\empty
  4125. \else\ifx\temptype\Yappendixkeyword
  4126. \setbox0 = \hbox{#4\enspace}%
  4127. \def\toctype{app}%
  4128. \gdef\thissection{#1}%
  4129. \else
  4130. \setbox0 = \hbox{#4\enspace}%
  4131. \def\toctype{num}%
  4132. \gdef\thissection{#1}%
  4133. \fi\fi\fi
  4134. %
  4135. % Write the toc entry (before \donoderef). See comments in \chfplain.
  4136. \writetocentry{\toctype\sectionlevel}{#1}{#4}%
  4137. %
  4138. % Write the node reference (= pdf destination for pdftex).
  4139. % Again, see comments in \chfplain.
  4140. \donoderef{#3}%
  4141. %
  4142. % Output the actual section heading.
  4143. \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
  4144. \hangindent=\wd0 % zero if no section number
  4145. \unhbox0 #1}%
  4146. }%
  4147. % Add extra space after the heading -- half of whatever came above it.
  4148. % Don't allow stretch, though.
  4149. \kern .5 \csname #2headingskip\endcsname
  4150. %
  4151. % Do not let the kern be a potential breakpoint, as it would be if it
  4152. % was followed by glue.
  4153. \nobreak
  4154. %
  4155. % We'll almost certainly start a paragraph next, so don't let that
  4156. % glue accumulate. (Not a breakpoint because it's preceded by a
  4157. % discardable item.)
  4158. \vskip-\parskip
  4159. %
  4160. % This is purely so the last item on the list is a known \penalty >
  4161. % 10000. This is so \startdefun can avoid allowing breakpoints after
  4162. % section headings. Otherwise, it would insert a valid breakpoint between:
  4163. %
  4164. % @section sec-whatever
  4165. % @deffn def-whatever
  4166. \penalty 10001
  4167. }
  4168. \message{toc,}
  4169. % Table of contents.
  4170. \newwrite\tocfile
  4171. % Write an entry to the toc file, opening it if necessary.
  4172. % Called from @chapter, etc.
  4173. %
  4174. % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
  4175. % We append the current node name (if any) and page number as additional
  4176. % arguments for the \{chap,sec,...}entry macros which will eventually
  4177. % read this. The node name is used in the pdf outlines as the
  4178. % destination to jump to.
  4179. %
  4180. % We open the .toc file for writing here instead of at @setfilename (or
  4181. % any other fixed time) so that @contents can be anywhere in the document.
  4182. % But if #1 is `omit', then we don't do anything. This is used for the
  4183. % table of contents chapter openings themselves.
  4184. %
  4185. \newif\iftocfileopened
  4186. \def\omitkeyword{omit}%
  4187. %
  4188. \def\writetocentry#1#2#3{%
  4189. \edef\writetoctype{#1}%
  4190. \ifx\writetoctype\omitkeyword \else
  4191. \iftocfileopened\else
  4192. \immediate\openout\tocfile = \jobname.toc
  4193. \global\tocfileopenedtrue
  4194. \fi
  4195. %
  4196. \iflinks
  4197. {\atdummies
  4198. \edef\temp{%
  4199. \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
  4200. \temp
  4201. }
  4202. \fi
  4203. \fi
  4204. %
  4205. % Tell \shipout to create a pdf destination on each page, if we're
  4206. % writing pdf. These are used in the table of contents. We can't
  4207. % just write one on every page because the title pages are numbered
  4208. % 1 and 2 (the page numbers aren't printed), and so are the first
  4209. % two pages of the document. Thus, we'd have two destinations named
  4210. % `1', and two named `2'.
  4211. \ifpdf \global\pdfmakepagedesttrue \fi
  4212. }
  4213. % These characters do not print properly in the Computer Modern roman
  4214. % fonts, so we must take special care. This is more or less redundant
  4215. % with the Texinfo input format setup at the end of this file.
  4216. %
  4217. \def\activecatcodes{%
  4218. \catcode`\"=\active
  4219. \catcode`\$=\active
  4220. \catcode`\<=\active
  4221. \catcode`\>=\active
  4222. \catcode`\\=\active
  4223. \catcode`\^=\active
  4224. \catcode`\_=\active
  4225. \catcode`\|=\active
  4226. \catcode`\~=\active
  4227. }
  4228. % Read the toc file, which is essentially Texinfo input.
  4229. \def\readtocfile{%
  4230. \setupdatafile
  4231. \activecatcodes
  4232. \input \jobname.toc
  4233. }
  4234. \newskip\contentsrightmargin \contentsrightmargin=1in
  4235. \newcount\savepageno
  4236. \newcount\lastnegativepageno \lastnegativepageno = -1
  4237. % Prepare to read what we've written to \tocfile.
  4238. %
  4239. \def\startcontents#1{%
  4240. % If @setchapternewpage on, and @headings double, the contents should
  4241. % start on an odd page, unlike chapters. Thus, we maintain
  4242. % \contentsalignmacro in parallel with \pagealignmacro.
  4243. % From: Torbjorn Granlund <tege@matematik.su.se>
  4244. \contentsalignmacro
  4245. \immediate\closeout\tocfile
  4246. %
  4247. % Don't need to put `Contents' or `Short Contents' in the headline.
  4248. % It is abundantly clear what they are.
  4249. \def\thischapter{}%
  4250. \chapmacro{#1}{Yomitfromtoc}{}%
  4251. %
  4252. \savepageno = \pageno
  4253. \begingroup % Set up to handle contents files properly.
  4254. \raggedbottom % Worry more about breakpoints than the bottom.
  4255. \advance\hsize by -\contentsrightmargin % Don't use the full line length.
  4256. %
  4257. % Roman numerals for page numbers.
  4258. \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
  4259. }
  4260. % Normal (long) toc.
  4261. \def\contents{%
  4262. \startcontents{\putwordTOC}%
  4263. \openin 1 \jobname.toc
  4264. \ifeof 1 \else
  4265. \readtocfile
  4266. \fi
  4267. \vfill \eject
  4268. \contentsalignmacro % in case @setchapternewpage odd is in effect
  4269. \ifeof 1 \else
  4270. \pdfmakeoutlines
  4271. \fi
  4272. \closein 1
  4273. \endgroup
  4274. \lastnegativepageno = \pageno
  4275. \global\pageno = \savepageno
  4276. }
  4277. % And just the chapters.
  4278. \def\summarycontents{%
  4279. \startcontents{\putwordShortTOC}%
  4280. %
  4281. \let\numchapentry = \shortchapentry
  4282. \let\appentry = \shortchapentry
  4283. \let\unnchapentry = \shortunnchapentry
  4284. % We want a true roman here for the page numbers.
  4285. \secfonts
  4286. \let\rm=\shortcontrm \let\bf=\shortcontbf
  4287. \let\sl=\shortcontsl \let\tt=\shortconttt
  4288. \rm
  4289. \hyphenpenalty = 10000
  4290. \advance\baselineskip by 1pt % Open it up a little.
  4291. \def\numsecentry##1##2##3##4{}
  4292. \let\appsecentry = \numsecentry
  4293. \let\unnsecentry = \numsecentry
  4294. \let\numsubsecentry = \numsecentry
  4295. \let\appsubsecentry = \numsecentry
  4296. \let\unnsubsecentry = \numsecentry
  4297. \let\numsubsubsecentry = \numsecentry
  4298. \let\appsubsubsecentry = \numsecentry
  4299. \let\unnsubsubsecentry = \numsecentry
  4300. \openin 1 \jobname.toc
  4301. \ifeof 1 \else
  4302. \readtocfile
  4303. \fi
  4304. \closein 1
  4305. \vfill \eject
  4306. \contentsalignmacro % in case @setchapternewpage odd is in effect
  4307. \endgroup
  4308. \lastnegativepageno = \pageno
  4309. \global\pageno = \savepageno
  4310. }
  4311. \let\shortcontents = \summarycontents
  4312. % Typeset the label for a chapter or appendix for the short contents.
  4313. % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
  4314. %
  4315. \def\shortchaplabel#1{%
  4316. % This space should be enough, since a single number is .5em, and the
  4317. % widest letter (M) is 1em, at least in the Computer Modern fonts.
  4318. % But use \hss just in case.
  4319. % (This space doesn't include the extra space that gets added after
  4320. % the label; that gets put in by \shortchapentry above.)
  4321. %
  4322. % We'd like to right-justify chapter numbers, but that looks strange
  4323. % with appendix letters. And right-justifying numbers and
  4324. % left-justifying letters looks strange when there is less than 10
  4325. % chapters. Have to read the whole toc once to know how many chapters
  4326. % there are before deciding ...
  4327. \hbox to 1em{#1\hss}%
  4328. }
  4329. % These macros generate individual entries in the table of contents.
  4330. % The first argument is the chapter or section name.
  4331. % The last argument is the page number.
  4332. % The arguments in between are the chapter number, section number, ...
  4333. % Chapters, in the main contents.
  4334. \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
  4335. %
  4336. % Chapters, in the short toc.
  4337. % See comments in \dochapentry re vbox and related settings.
  4338. \def\shortchapentry#1#2#3#4{%
  4339. \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
  4340. }
  4341. % Appendices, in the main contents.
  4342. % Need the word Appendix, and a fixed-size box.
  4343. %
  4344. \def\appendixbox#1{%
  4345. % We use M since it's probably the widest letter.
  4346. \setbox0 = \hbox{\putwordAppendix{} M}%
  4347. \hbox to \wd0{\putwordAppendix{} #1\hss}}
  4348. %
  4349. \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}}
  4350. % Unnumbered chapters.
  4351. \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
  4352. \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
  4353. % Sections.
  4354. \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
  4355. \let\appsecentry=\numsecentry
  4356. \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
  4357. % Subsections.
  4358. \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
  4359. \let\appsubsecentry=\numsubsecentry
  4360. \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
  4361. % And subsubsections.
  4362. \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
  4363. \let\appsubsubsecentry=\numsubsubsecentry
  4364. \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
  4365. % This parameter controls the indentation of the various levels.
  4366. % Same as \defaultparindent.
  4367. \newdimen\tocindent \tocindent = 15pt
  4368. % Now for the actual typesetting. In all these, #1 is the text and #2 is the
  4369. % page number.
  4370. %
  4371. % If the toc has to be broken over pages, we want it to be at chapters
  4372. % if at all possible; hence the \penalty.
  4373. \def\dochapentry#1#2{%
  4374. \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
  4375. \begingroup
  4376. \chapentryfonts
  4377. \tocentry{#1}{\dopageno\bgroup#2\egroup}%
  4378. \endgroup
  4379. \nobreak\vskip .25\baselineskip plus.1\baselineskip
  4380. }
  4381. \def\dosecentry#1#2{\begingroup
  4382. \secentryfonts \leftskip=\tocindent
  4383. \tocentry{#1}{\dopageno\bgroup#2\egroup}%
  4384. \endgroup}
  4385. \def\dosubsecentry#1#2{\begingroup
  4386. \subsecentryfonts \leftskip=2\tocindent
  4387. \tocentry{#1}{\dopageno\bgroup#2\egroup}%
  4388. \endgroup}
  4389. \def\dosubsubsecentry#1#2{\begingroup
  4390. \subsubsecentryfonts \leftskip=3\tocindent
  4391. \tocentry{#1}{\dopageno\bgroup#2\egroup}%
  4392. \endgroup}
  4393. % We use the same \entry macro as for the index entries.
  4394. \let\tocentry = \entry
  4395. % Space between chapter (or whatever) number and the title.
  4396. \def\labelspace{\hskip1em \relax}
  4397. \def\dopageno#1{{\rm #1}}
  4398. \def\doshortpageno#1{{\rm #1}}
  4399. \def\chapentryfonts{\secfonts \rm}
  4400. \def\secentryfonts{\textfonts}
  4401. \def\subsecentryfonts{\textfonts}
  4402. \def\subsubsecentryfonts{\textfonts}
  4403. \message{environments,}
  4404. % @foo ... @end foo.
  4405. % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
  4406. %
  4407. % Since these characters are used in examples, it should be an even number of
  4408. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  4409. %
  4410. \def\point{$\star$}
  4411. \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
  4412. \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
  4413. \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
  4414. \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
  4415. % The @error{} command.
  4416. % Adapted from the TeXbook's \boxit.
  4417. %
  4418. \newbox\errorbox
  4419. %
  4420. {\tentt \global\dimen0 = 3em}% Width of the box.
  4421. \dimen2 = .55pt % Thickness of rules
  4422. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  4423. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  4424. %
  4425. \setbox\errorbox=\hbox to \dimen0{\hfil
  4426. \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  4427. \advance\hsize by -2\dimen2 % Rules.
  4428. \vbox{%
  4429. \hrule height\dimen2
  4430. \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
  4431. \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  4432. \kern3pt\vrule width\dimen2}% Space to right.
  4433. \hrule height\dimen2}
  4434. \hfil}
  4435. %
  4436. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  4437. % @tex ... @end tex escapes into raw Tex temporarily.
  4438. % One exception: @ is still an escape character, so that @end tex works.
  4439. % But \@ or @@ will get a plain tex @ character.
  4440. \envdef\tex{%
  4441. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  4442. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  4443. \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
  4444. \catcode `\%=14
  4445. \catcode `\+=\other
  4446. \catcode `\"=\other
  4447. \catcode `\|=\other
  4448. \catcode `\<=\other
  4449. \catcode `\>=\other
  4450. \escapechar=`\\
  4451. %
  4452. \let\b=\ptexb
  4453. \let\bullet=\ptexbullet
  4454. \let\c=\ptexc
  4455. \let\,=\ptexcomma
  4456. \let\.=\ptexdot
  4457. \let\dots=\ptexdots
  4458. \let\equiv=\ptexequiv
  4459. \let\!=\ptexexclam
  4460. \let\i=\ptexi
  4461. \let\indent=\ptexindent
  4462. \let\noindent=\ptexnoindent
  4463. \let\{=\ptexlbrace
  4464. \let\+=\tabalign
  4465. \let\}=\ptexrbrace
  4466. \let\/=\ptexslash
  4467. \let\*=\ptexstar
  4468. \let\t=\ptext
  4469. \let\frenchspacing=\plainfrenchspacing
  4470. %
  4471. \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
  4472. \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
  4473. \def\@{@}%
  4474. }
  4475. % There is no need to define \Etex.
  4476. % Define @lisp ... @end lisp.
  4477. % @lisp environment forms a group so it can rebind things,
  4478. % including the definition of @end lisp (which normally is erroneous).
  4479. % Amount to narrow the margins by for @lisp.
  4480. \newskip\lispnarrowing \lispnarrowing=0.4in
  4481. % This is the definition that ^^M gets inside @lisp, @example, and other
  4482. % such environments. \null is better than a space, since it doesn't
  4483. % have any width.
  4484. \def\lisppar{\null\endgraf}
  4485. % This space is always present above and below environments.
  4486. \newskip\envskipamount \envskipamount = 0pt
  4487. % Make spacing and below environment symmetrical. We use \parskip here
  4488. % to help in doing that, since in @example-like environments \parskip
  4489. % is reset to zero; thus the \afterenvbreak inserts no space -- but the
  4490. % start of the next paragraph will insert \parskip.
  4491. %
  4492. \def\aboveenvbreak{{%
  4493. % =10000 instead of <10000 because of a special case in \itemzzz and
  4494. % \sectionheading, q.v.
  4495. \ifnum \lastpenalty=10000 \else
  4496. \advance\envskipamount by \parskip
  4497. \endgraf
  4498. \ifdim\lastskip<\envskipamount
  4499. \removelastskip
  4500. % it's not a good place to break if the last penalty was \nobreak
  4501. % or better ...
  4502. \ifnum\lastpenalty<10000 \penalty-50 \fi
  4503. \vskip\envskipamount
  4504. \fi
  4505. \fi
  4506. }}
  4507. \let\afterenvbreak = \aboveenvbreak
  4508. % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will
  4509. % also clear it, so that its embedded environments do the narrowing again.
  4510. \let\nonarrowing=\relax
  4511. % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
  4512. % environment contents.
  4513. \font\circle=lcircle10
  4514. \newdimen\circthick
  4515. \newdimen\cartouter\newdimen\cartinner
  4516. \newskip\normbskip\newskip\normpskip\newskip\normlskip
  4517. \circthick=\fontdimen8\circle
  4518. %
  4519. \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
  4520. \def\ctr{{\hskip 6pt\circle\char'010}}
  4521. \def\cbl{{\circle\char'012\hskip -6pt}}
  4522. \def\cbr{{\hskip 6pt\circle\char'011}}
  4523. \def\carttop{\hbox to \cartouter{\hskip\lskip
  4524. \ctl\leaders\hrule height\circthick\hfil\ctr
  4525. \hskip\rskip}}
  4526. \def\cartbot{\hbox to \cartouter{\hskip\lskip
  4527. \cbl\leaders\hrule height\circthick\hfil\cbr
  4528. \hskip\rskip}}
  4529. %
  4530. \newskip\lskip\newskip\rskip
  4531. \envdef\cartouche{%
  4532. \ifhmode\par\fi % can't be in the midst of a paragraph.
  4533. \startsavinginserts
  4534. \lskip=\leftskip \rskip=\rightskip
  4535. \leftskip=0pt\rightskip=0pt % we want these *outside*.
  4536. \cartinner=\hsize \advance\cartinner by-\lskip
  4537. \advance\cartinner by-\rskip
  4538. \cartouter=\hsize
  4539. \advance\cartouter by 18.4pt % allow for 3pt kerns on either
  4540. % side, and for 6pt waste from
  4541. % each corner char, and rule thickness
  4542. \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
  4543. % Flag to tell @lisp, etc., not to narrow margin.
  4544. \let\nonarrowing = t%
  4545. \vbox\bgroup
  4546. \baselineskip=0pt\parskip=0pt\lineskip=0pt
  4547. \carttop
  4548. \hbox\bgroup
  4549. \hskip\lskip
  4550. \vrule\kern3pt
  4551. \vbox\bgroup
  4552. \kern3pt
  4553. \hsize=\cartinner
  4554. \baselineskip=\normbskip
  4555. \lineskip=\normlskip
  4556. \parskip=\normpskip
  4557. \vskip -\parskip
  4558. \comment % For explanation, see the end of \def\group.
  4559. }
  4560. \def\Ecartouche{%
  4561. \ifhmode\par\fi
  4562. \kern3pt
  4563. \egroup
  4564. \kern3pt\vrule
  4565. \hskip\rskip
  4566. \egroup
  4567. \cartbot
  4568. \egroup
  4569. \checkinserts
  4570. }
  4571. % This macro is called at the beginning of all the @example variants,
  4572. % inside a group.
  4573. \def\nonfillstart{%
  4574. \aboveenvbreak
  4575. \hfuzz = 12pt % Don't be fussy
  4576. \sepspaces % Make spaces be word-separators rather than space tokens.
  4577. \let\par = \lisppar % don't ignore blank lines
  4578. \obeylines % each line of input is a line of output
  4579. \parskip = 0pt
  4580. \parindent = 0pt
  4581. \emergencystretch = 0pt % don't try to avoid overfull boxes
  4582. \ifx\nonarrowing\relax
  4583. \advance \leftskip by \lispnarrowing
  4584. \exdentamount=\lispnarrowing
  4585. \else
  4586. \let\nonarrowing = \relax
  4587. \fi
  4588. \let\exdent=\nofillexdent
  4589. }
  4590. % If you want all examples etc. small: @set dispenvsize small.
  4591. % If you want even small examples the full size: @set dispenvsize nosmall.
  4592. % This affects the following displayed environments:
  4593. % @example, @display, @format, @lisp
  4594. %
  4595. \def\smallword{small}
  4596. \def\nosmallword{nosmall}
  4597. \let\SETdispenvsize\relax
  4598. \def\setnormaldispenv{%
  4599. \ifx\SETdispenvsize\smallword
  4600. \smallexamplefonts \rm
  4601. \fi
  4602. }
  4603. \def\setsmalldispenv{%
  4604. \ifx\SETdispenvsize\nosmallword
  4605. \else
  4606. \smallexamplefonts \rm
  4607. \fi
  4608. }
  4609. % We often define two environments, @foo and @smallfoo.
  4610. % Let's do it by one command:
  4611. \def\makedispenv #1#2{
  4612. \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}
  4613. \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}
  4614. \expandafter\let\csname E#1\endcsname \afterenvbreak
  4615. \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
  4616. }
  4617. % Define two synonyms:
  4618. \def\maketwodispenvs #1#2#3{
  4619. \makedispenv{#1}{#3}
  4620. \makedispenv{#2}{#3}
  4621. }
  4622. % @lisp: indented, narrowed, typewriter font; @example: same as @lisp.
  4623. %
  4624. % @smallexample and @smalllisp: use smaller fonts.
  4625. % Originally contributed by Pavel@xerox.
  4626. %
  4627. \maketwodispenvs {lisp}{example}{%
  4628. \nonfillstart
  4629. \tt
  4630. \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
  4631. \gobble % eat return
  4632. }
  4633. % @display/@smalldisplay: same as @lisp except keep current font.
  4634. %
  4635. \makedispenv {display}{%
  4636. \nonfillstart
  4637. \gobble
  4638. }
  4639. % @format/@smallformat: same as @display except don't narrow margins.
  4640. %
  4641. \makedispenv{format}{%
  4642. \let\nonarrowing = t%
  4643. \nonfillstart
  4644. \gobble
  4645. }
  4646. % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
  4647. \envdef\flushleft{%
  4648. \let\nonarrowing = t%
  4649. \nonfillstart
  4650. \gobble
  4651. }
  4652. \let\Eflushleft = \afterenvbreak
  4653. % @flushright.
  4654. %
  4655. \envdef\flushright{%
  4656. \let\nonarrowing = t%
  4657. \nonfillstart
  4658. \advance\leftskip by 0pt plus 1fill
  4659. \gobble
  4660. }
  4661. \let\Eflushright = \afterenvbreak
  4662. % @quotation does normal linebreaking (hence we can't use \nonfillstart)
  4663. % and narrows the margins. We keep \parskip nonzero in general, since
  4664. % we're doing normal filling. So, when using \aboveenvbreak and
  4665. % \afterenvbreak, temporarily make \parskip 0.
  4666. %
  4667. \envdef\quotation{%
  4668. {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
  4669. \parindent=0pt
  4670. %
  4671. % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
  4672. \ifx\nonarrowing\relax
  4673. \advance\leftskip by \lispnarrowing
  4674. \advance\rightskip by \lispnarrowing
  4675. \exdentamount = \lispnarrowing
  4676. \else
  4677. \let\nonarrowing = \relax
  4678. \fi
  4679. \parsearg\quotationlabel
  4680. }
  4681. % We have retained a nonzero parskip for the environment, since we're
  4682. % doing normal filling.
  4683. %
  4684. \def\Equotation{%
  4685. \par
  4686. \ifx\quotationauthor\undefined\else
  4687. % indent a bit.
  4688. \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
  4689. \fi
  4690. {\parskip=0pt \afterenvbreak}%
  4691. }
  4692. % If we're given an argument, typeset it in bold with a colon after.
  4693. \def\quotationlabel#1{%
  4694. \def\temp{#1}%
  4695. \ifx\temp\empty \else
  4696. {\bf #1: }%
  4697. \fi
  4698. }
  4699. % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
  4700. % If we want to allow any <char> as delimiter,
  4701. % we need the curly braces so that makeinfo sees the @verb command, eg:
  4702. % `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org
  4703. %
  4704. % [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
  4705. %
  4706. % [Knuth] p.344; only we need to do the other characters Texinfo sets
  4707. % active too. Otherwise, they get lost as the first character on a
  4708. % verbatim line.
  4709. \def\dospecials{%
  4710. \do\ \do\\\do\{\do\}\do\$\do\&%
  4711. \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
  4712. \do\<\do\>\do\|\do\@\do+\do\"%
  4713. }
  4714. %
  4715. % [Knuth] p. 380
  4716. \def\uncatcodespecials{%
  4717. \def\do##1{\catcode`##1=\other}\dospecials}
  4718. %
  4719. % [Knuth] pp. 380,381,391
  4720. % Disable Spanish ligatures ?` and !` of \tt font
  4721. \begingroup
  4722. \catcode`\`=\active\gdef`{\relax\lq}
  4723. \endgroup
  4724. %
  4725. % Setup for the @verb command.
  4726. %
  4727. % Eight spaces for a tab
  4728. \begingroup
  4729. \catcode`\^^I=\active
  4730. \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
  4731. \endgroup
  4732. %
  4733. \def\setupverb{%
  4734. \tt % easiest (and conventionally used) font for verbatim
  4735. \def\par{\leavevmode\endgraf}%
  4736. \catcode`\`=\active
  4737. \tabeightspaces
  4738. % Respect line breaks,
  4739. % print special symbols as themselves, and
  4740. % make each space count
  4741. % must do in this order:
  4742. \obeylines \uncatcodespecials \sepspaces
  4743. }
  4744. % Setup for the @verbatim environment
  4745. %
  4746. % Real tab expansion
  4747. \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
  4748. %
  4749. \def\starttabbox{\setbox0=\hbox\bgroup}
  4750. \begingroup
  4751. \catcode`\^^I=\active
  4752. \gdef\tabexpand{%
  4753. \catcode`\^^I=\active
  4754. \def^^I{\leavevmode\egroup
  4755. \dimen0=\wd0 % the width so far, or since the previous tab
  4756. \divide\dimen0 by\tabw
  4757. \multiply\dimen0 by\tabw % compute previous multiple of \tabw
  4758. \advance\dimen0 by\tabw % advance to next multiple of \tabw
  4759. \wd0=\dimen0 \box0 \starttabbox
  4760. }%
  4761. }
  4762. \endgroup
  4763. \def\setupverbatim{%
  4764. \let\nonarrowing = t%
  4765. \nonfillstart
  4766. % Easiest (and conventionally used) font for verbatim
  4767. \tt
  4768. \def\par{\leavevmode\egroup\box0\endgraf}%
  4769. \catcode`\`=\active
  4770. \tabexpand
  4771. % Respect line breaks,
  4772. % print special symbols as themselves, and
  4773. % make each space count
  4774. % must do in this order:
  4775. \obeylines \uncatcodespecials \sepspaces
  4776. \everypar{\starttabbox}%
  4777. }
  4778. % Do the @verb magic: verbatim text is quoted by unique
  4779. % delimiter characters. Before first delimiter expect a
  4780. % right brace, after last delimiter expect closing brace:
  4781. %
  4782. % \def\doverb'{'<char>#1<char>'}'{#1}
  4783. %
  4784. % [Knuth] p. 382; only eat outer {}
  4785. \begingroup
  4786. \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
  4787. \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
  4788. \endgroup
  4789. %
  4790. \def\verb{\begingroup\setupverb\doverb}
  4791. %
  4792. %
  4793. % Do the @verbatim magic: define the macro \doverbatim so that
  4794. % the (first) argument ends when '@end verbatim' is reached, ie:
  4795. %
  4796. % \def\doverbatim#1@end verbatim{#1}
  4797. %
  4798. % For Texinfo it's a lot easier than for LaTeX,
  4799. % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
  4800. % we need not redefine '\', '{' and '}'.
  4801. %
  4802. % Inspired by LaTeX's verbatim command set [latex.ltx]
  4803. %
  4804. \begingroup
  4805. \catcode`\ =\active
  4806. \obeylines %
  4807. % ignore everything up to the first ^^M, that's the newline at the end
  4808. % of the @verbatim input line itself. Otherwise we get an extra blank
  4809. % line in the output.
  4810. \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
  4811. % We really want {...\end verbatim} in the body of the macro, but
  4812. % without the active space; thus we have to use \xdef and \gobble.
  4813. \endgroup
  4814. %
  4815. \envdef\verbatim{%
  4816. \setupverbatim\doverbatim
  4817. }
  4818. \let\Everbatim = \afterenvbreak
  4819. % @verbatiminclude FILE - insert text of file in verbatim environment.
  4820. %
  4821. \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
  4822. %
  4823. \def\doverbatiminclude#1{%
  4824. {%
  4825. \makevalueexpandable
  4826. \setupverbatim
  4827. \input #1
  4828. \afterenvbreak
  4829. }%
  4830. }
  4831. % @copying ... @end copying.
  4832. % Save the text away for @insertcopying later.
  4833. %
  4834. % We save the uninterpreted tokens, rather than creating a box.
  4835. % Saving the text in a box would be much easier, but then all the
  4836. % typesetting commands (@smallbook, font changes, etc.) have to be done
  4837. % beforehand -- and a) we want @copying to be done first in the source
  4838. % file; b) letting users define the frontmatter in as flexible order as
  4839. % possible is very desirable.
  4840. %
  4841. \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
  4842. \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
  4843. %
  4844. \def\insertcopying{%
  4845. \begingroup
  4846. \parindent = 0pt % paragraph indentation looks wrong on title page
  4847. \scanexp\copyingtext
  4848. \endgroup
  4849. }
  4850. \message{defuns,}
  4851. % @defun etc.
  4852. \newskip\defbodyindent \defbodyindent=.4in
  4853. \newskip\defargsindent \defargsindent=50pt
  4854. \newskip\deflastargmargin \deflastargmargin=18pt
  4855. % Start the processing of @deffn:
  4856. \def\startdefun{%
  4857. \ifnum\lastpenalty<10000
  4858. \medbreak
  4859. \else
  4860. % If there are two @def commands in a row, we'll have a \nobreak,
  4861. % which is there to keep the function description together with its
  4862. % header. But if there's nothing but headers, we need to allow a
  4863. % break somewhere. Check specifically for penalty 10002, inserted
  4864. % by \defargscommonending, instead of 10000, since the sectioning
  4865. % commands also insert a nobreak penalty, and we don't want to allow
  4866. % a break between a section heading and a defun.
  4867. %
  4868. \ifnum\lastpenalty=10002 \penalty2000 \fi
  4869. %
  4870. % Similarly, after a section heading, do not allow a break.
  4871. % But do insert the glue.
  4872. \medskip % preceded by discardable penalty, so not a breakpoint
  4873. \fi
  4874. %
  4875. \parindent=0in
  4876. \advance\leftskip by \defbodyindent
  4877. \exdentamount=\defbodyindent
  4878. }
  4879. \def\dodefunx#1{%
  4880. % First, check whether we are in the right environment:
  4881. \checkenv#1%
  4882. %
  4883. % As above, allow line break if we have multiple x headers in a row.
  4884. % It's not a great place, though.
  4885. \ifnum\lastpenalty=10002 \penalty3000 \fi
  4886. %
  4887. % And now, it's time to reuse the body of the original defun:
  4888. \expandafter\gobbledefun#1%
  4889. }
  4890. \def\gobbledefun#1\startdefun{}
  4891. % \printdefunline \deffnheader{text}
  4892. %
  4893. \def\printdefunline#1#2{%
  4894. \begingroup
  4895. % call \deffnheader:
  4896. #1#2 \endheader
  4897. % common ending:
  4898. \interlinepenalty = 10000
  4899. \advance\rightskip by 0pt plus 1fil
  4900. \endgraf
  4901. \nobreak\vskip -\parskip
  4902. \penalty 10002 % signal to \startdefun and \dodefunx
  4903. % Some of the @defun-type tags do not enable magic parentheses,
  4904. % rendering the following check redundant. But we don't optimize.
  4905. \checkparencounts
  4906. \endgroup
  4907. }
  4908. \def\Edefun{\endgraf\medbreak}
  4909. % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
  4910. % the only thing remainnig is to define \deffnheader.
  4911. %
  4912. \def\makedefun#1{%
  4913. \expandafter\let\csname E#1\endcsname = \Edefun
  4914. \edef\temp{\noexpand\domakedefun
  4915. \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
  4916. \temp
  4917. }
  4918. % \domakedefun \deffn \deffnx \deffnheader
  4919. %
  4920. % Define \deffn and \deffnx, without parameters.
  4921. % \deffnheader has to be defined explicitly.
  4922. %
  4923. \def\domakedefun#1#2#3{%
  4924. \envdef#1{%
  4925. \startdefun
  4926. \parseargusing\activeparens{\printdefunline#3}%
  4927. }%
  4928. \def#2{\dodefunx#1}%
  4929. \def#3%
  4930. }
  4931. %%% Untyped functions:
  4932. % @deffn category name args
  4933. \makedefun{deffn}{\deffngeneral{}}
  4934. % @deffn category class name args
  4935. \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
  4936. % \defopon {category on}class name args
  4937. \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
  4938. % \deffngeneral {subind}category name args
  4939. %
  4940. \def\deffngeneral#1#2 #3 #4\endheader{%
  4941. % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
  4942. \dosubind{fn}{\code{#3}}{#1}%
  4943. \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
  4944. }
  4945. %%% Typed functions:
  4946. % @deftypefn category type name args
  4947. \makedefun{deftypefn}{\deftypefngeneral{}}
  4948. % @deftypeop category class type name args
  4949. \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
  4950. % \deftypeopon {category on}class type name args
  4951. \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
  4952. % \deftypefngeneral {subind}category type name args
  4953. %
  4954. \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
  4955. \dosubind{fn}{\code{#4}}{#1}%
  4956. \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
  4957. }
  4958. %%% Typed variables:
  4959. % @deftypevr category type var args
  4960. \makedefun{deftypevr}{\deftypecvgeneral{}}
  4961. % @deftypecv category class type var args
  4962. \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
  4963. % \deftypecvof {category of}class type var args
  4964. \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
  4965. % \deftypecvgeneral {subind}category type var args
  4966. %
  4967. \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
  4968. \dosubind{vr}{\code{#4}}{#1}%
  4969. \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
  4970. }
  4971. %%% Untyped variables:
  4972. % @defvr category var args
  4973. \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
  4974. % @defcv category class var args
  4975. \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
  4976. % \defcvof {category of}class var args
  4977. \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
  4978. %%% Type:
  4979. % @deftp category name args
  4980. \makedefun{deftp}#1 #2 #3\endheader{%
  4981. \doind{tp}{\code{#2}}%
  4982. \defname{#1}{}{#2}\defunargs{#3\unskip}%
  4983. }
  4984. % Remaining @defun-like shortcuts:
  4985. \makedefun{defun}{\deffnheader{\putwordDeffunc} }
  4986. \makedefun{defmac}{\deffnheader{\putwordDefmac} }
  4987. \makedefun{defspec}{\deffnheader{\putwordDefspec} }
  4988. \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
  4989. \makedefun{defvar}{\defvrheader{\putwordDefvar} }
  4990. \makedefun{defopt}{\defvrheader{\putwordDefopt} }
  4991. \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
  4992. \makedefun{defmethod}{\defopon\putwordMethodon}
  4993. \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
  4994. \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
  4995. \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
  4996. % \defname, which formats the name of the @def (not the args).
  4997. % #1 is the category, such as "Function".
  4998. % #2 is the return type, if any.
  4999. % #3 is the function name.
  5000. %
  5001. % We are followed by (but not passed) the arguments, if any.
  5002. %
  5003. \def\defname#1#2#3{%
  5004. % Get the values of \leftskip and \rightskip as they were outside the @def...
  5005. \advance\leftskip by -\defbodyindent
  5006. %
  5007. % How we'll format the type name. Putting it in brackets helps
  5008. % distinguish it from the body text that may end up on the next line
  5009. % just below it.
  5010. \def\temp{#1}%
  5011. \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
  5012. %
  5013. % Figure out line sizes for the paragraph shape.
  5014. % The first line needs space for \box0; but if \rightskip is nonzero,
  5015. % we need only space for the part of \box0 which exceeds it:
  5016. \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
  5017. % The continuations:
  5018. \dimen2=\hsize \advance\dimen2 by -\defargsindent
  5019. % (plain.tex says that \dimen1 should be used only as global.)
  5020. \parshape 2 0in \dimen0 \defargsindent \dimen2
  5021. %
  5022. % Put the type name to the right margin.
  5023. \noindent
  5024. \hbox to 0pt{%
  5025. \hfil\box0 \kern-\hsize
  5026. % \hsize has to be shortened this way:
  5027. \kern\leftskip
  5028. % Intentionally do not respect \rightskip, since we need the space.
  5029. }%
  5030. %
  5031. % Allow all lines to be underfull without complaint:
  5032. \tolerance=10000 \hbadness=10000
  5033. \exdentamount=\defbodyindent
  5034. {%
  5035. % defun fonts. We use typewriter by default (used to be bold) because:
  5036. % . we're printing identifiers, they should be in tt in principle.
  5037. % . in languages with many accents, such as Czech or French, it's
  5038. % common to leave accents off identifiers. The result looks ok in
  5039. % tt, but exceedingly strange in rm.
  5040. % . we don't want -- and --- to be treated as ligatures.
  5041. % . this still does not fix the ?` and !` ligatures, but so far no
  5042. % one has made identifiers using them :).
  5043. \df \tt
  5044. \def\temp{#2}% return value type
  5045. \ifx\temp\empty\else \tclose{\temp} \fi
  5046. #3% output function name
  5047. }%
  5048. {\rm\enskip}% hskip 0.5 em of \tenrm
  5049. %
  5050. \boldbrax
  5051. % arguments will be output next, if any.
  5052. }
  5053. % Print arguments in slanted roman (not ttsl), inconsistently with using
  5054. % tt for the name. This is because literal text is sometimes needed in
  5055. % the argument list (groff manual), and ttsl and tt are not very
  5056. % distinguishable. Prevent hyphenation at `-' chars.
  5057. %
  5058. \def\defunargs#1{%
  5059. % use sl by default (not ttsl),
  5060. % tt for the names.
  5061. \df \sl \hyphenchar\font=0
  5062. %
  5063. % On the other hand, if an argument has two dashes (for instance), we
  5064. % want a way to get ttsl. Let's try @var for that.
  5065. \let\var=\ttslanted
  5066. #1%
  5067. \sl\hyphenchar\font=45
  5068. }
  5069. % We want ()&[] to print specially on the defun line.
  5070. %
  5071. \def\activeparens{%
  5072. \catcode`\(=\active \catcode`\)=\active
  5073. \catcode`\[=\active \catcode`\]=\active
  5074. \catcode`\&=\active
  5075. }
  5076. % Make control sequences which act like normal parenthesis chars.
  5077. \let\lparen = ( \let\rparen = )
  5078. % Be sure that we always have a definition for `(', etc. For example,
  5079. % if the fn name has parens in it, \boldbrax will not be in effect yet,
  5080. % so TeX would otherwise complain about undefined control sequence.
  5081. {
  5082. \activeparens
  5083. \global\let(=\lparen \global\let)=\rparen
  5084. \global\let[=\lbrack \global\let]=\rbrack
  5085. \global\let& = \&
  5086. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  5087. \gdef\magicamp{\let&=\amprm}
  5088. }
  5089. \newcount\parencount
  5090. % If we encounter &foo, then turn on ()-hacking afterwards
  5091. \newif\ifampseen
  5092. \def\amprm#1 {\ampseentrue{\bf\&#1 }}
  5093. \def\parenfont{%
  5094. \ifampseen
  5095. % At the first level, print parens in roman,
  5096. % otherwise use the default font.
  5097. \ifnum \parencount=1 \rm \fi
  5098. \else
  5099. % The \sf parens (in \boldbrax) actually are a little bolder than
  5100. % the contained text. This is especially needed for [ and ] .
  5101. \sf
  5102. \fi
  5103. }
  5104. \def\infirstlevel#1{%
  5105. \ifampseen
  5106. \ifnum\parencount=1
  5107. #1%
  5108. \fi
  5109. \fi
  5110. }
  5111. \def\bfafterword#1 {#1 \bf}
  5112. \def\opnr{%
  5113. \global\advance\parencount by 1
  5114. {\parenfont(}%
  5115. \infirstlevel \bfafterword
  5116. }
  5117. \def\clnr{%
  5118. {\parenfont)}%
  5119. \infirstlevel \sl
  5120. \global\advance\parencount by -1
  5121. }
  5122. \newcount\brackcount
  5123. \def\lbrb{%
  5124. \global\advance\brackcount by 1
  5125. {\bf[}%
  5126. }
  5127. \def\rbrb{%
  5128. {\bf]}%
  5129. \global\advance\brackcount by -1
  5130. }
  5131. \def\checkparencounts{%
  5132. \ifnum\parencount=0 \else \badparencount \fi
  5133. \ifnum\brackcount=0 \else \badbrackcount \fi
  5134. }
  5135. \def\badparencount{%
  5136. \errmessage{Unbalanced parentheses in @def}%
  5137. \global\parencount=0
  5138. }
  5139. \def\badbrackcount{%
  5140. \errmessage{Unbalanced square braces in @def}%
  5141. \global\brackcount=0
  5142. }
  5143. \message{macros,}
  5144. % @macro.
  5145. % To do this right we need a feature of e-TeX, \scantokens,
  5146. % which we arrange to emulate with a temporary file in ordinary TeX.
  5147. \ifx\eTeXversion\undefined
  5148. \newwrite\macscribble
  5149. \def\scantokens#1{%
  5150. \toks0={#1}%
  5151. \immediate\openout\macscribble=\jobname.tmp
  5152. \immediate\write\macscribble{\the\toks0}%
  5153. \immediate\closeout\macscribble
  5154. \input \jobname.tmp
  5155. }
  5156. \fi
  5157. \def\scanmacro#1{%
  5158. \begingroup
  5159. \newlinechar`\^^M
  5160. \let\xeatspaces\eatspaces
  5161. % Undo catcode changes of \startcontents and \doprintindex
  5162. % When called from @insertcopying or (short)caption, we need active
  5163. % backslash to get it printed correctly. Previously, we had
  5164. % \catcode`\\=\other instead. We'll see whether a problem appears
  5165. % with macro expansion. --kasal, 19aug04
  5166. \catcode`\@=0 \catcode`\\=\active \escapechar=`\@
  5167. % ... and \example
  5168. \spaceisspace
  5169. %
  5170. % Append \endinput to make sure that TeX does not see the ending newline.
  5171. %
  5172. % I've verified that it is necessary both for e-TeX and for ordinary TeX
  5173. % --kasal, 29nov03
  5174. \scantokens{#1\endinput}%
  5175. \endgroup
  5176. }
  5177. \def\scanexp#1{%
  5178. \edef\temp{\noexpand\scanmacro{#1}}%
  5179. \temp
  5180. }
  5181. \newcount\paramno % Count of parameters
  5182. \newtoks\macname % Macro name
  5183. \newif\ifrecursive % Is it recursive?
  5184. % List of all defined macros in the form
  5185. % \definedummyword\macro1\definedummyword\macro2...
  5186. % Currently is also contains all @aliases; the list can be split
  5187. % if there is a need.
  5188. \def\macrolist{}
  5189. % Add the macro to \macrolist
  5190. \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
  5191. \def\addtomacrolistxxx#1{%
  5192. \toks0 = \expandafter{\macrolist\definedummyword#1}%
  5193. \xdef\macrolist{\the\toks0}%
  5194. }
  5195. % Utility routines.
  5196. % This does \let #1 = #2, with \csnames; that is,
  5197. % \let \csname#1\endcsname = \csname#2\endcsname
  5198. % (except of course we have to play expansion games).
  5199. %
  5200. \def\cslet#1#2{%
  5201. \expandafter\let
  5202. \csname#1\expandafter\endcsname
  5203. \csname#2\endcsname
  5204. }
  5205. % Trim leading and trailing spaces off a string.
  5206. % Concepts from aro-bend problem 15 (see CTAN).
  5207. {\catcode`\@=11
  5208. \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
  5209. \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
  5210. \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
  5211. \def\unbrace#1{#1}
  5212. \unbrace{\gdef\trim@@@ #1 } #2@{#1}
  5213. }
  5214. % Trim a single trailing ^^M off a string.
  5215. {\catcode`\^^M=\other \catcode`\Q=3%
  5216. \gdef\eatcr #1{\eatcra #1Q^^MQ}%
  5217. \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
  5218. \gdef\eatcrb#1Q#2Q{#1}%
  5219. }
  5220. % Macro bodies are absorbed as an argument in a context where
  5221. % all characters are catcode 10, 11 or 12, except \ which is active
  5222. % (as in normal texinfo). It is necessary to change the definition of \.
  5223. % It's necessary to have hard CRs when the macro is executed. This is
  5224. % done by making ^^M (\endlinechar) catcode 12 when reading the macro
  5225. % body, and then making it the \newlinechar in \scanmacro.
  5226. \def\scanctxt{%
  5227. \catcode`\"=\other
  5228. \catcode`\+=\other
  5229. \catcode`\<=\other
  5230. \catcode`\>=\other
  5231. \catcode`\@=\other
  5232. \catcode`\^=\other
  5233. \catcode`\_=\other
  5234. \catcode`\|=\other
  5235. \catcode`\~=\other
  5236. }
  5237. \def\scanargctxt{%
  5238. \scanctxt
  5239. \catcode`\\=\other
  5240. \catcode`\^^M=\other
  5241. }
  5242. \def\macrobodyctxt{%
  5243. \scanctxt
  5244. \catcode`\{=\other
  5245. \catcode`\}=\other
  5246. \catcode`\^^M=\other
  5247. \usembodybackslash
  5248. }
  5249. \def\macroargctxt{%
  5250. \scanctxt
  5251. \catcode`\\=\other
  5252. }
  5253. % \mbodybackslash is the definition of \ in @macro bodies.
  5254. % It maps \foo\ => \csname macarg.foo\endcsname => #N
  5255. % where N is the macro parameter number.
  5256. % We define \csname macarg.\endcsname to be \realbackslash, so
  5257. % \\ in macro replacement text gets you a backslash.
  5258. {\catcode`@=0 @catcode`@\=@active
  5259. @gdef@usembodybackslash{@let\=@mbodybackslash}
  5260. @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
  5261. }
  5262. \expandafter\def\csname macarg.\endcsname{\realbackslash}
  5263. \def\macro{\recursivefalse\parsearg\macroxxx}
  5264. \def\rmacro{\recursivetrue\parsearg\macroxxx}
  5265. \def\macroxxx#1{%
  5266. \getargs{#1}% now \macname is the macname and \argl the arglist
  5267. \ifx\argl\empty % no arguments
  5268. \paramno=0%
  5269. \else
  5270. \expandafter\parsemargdef \argl;%
  5271. \fi
  5272. \if1\csname ismacro.\the\macname\endcsname
  5273. \message{Warning: redefining \the\macname}%
  5274. \else
  5275. \expandafter\ifx\csname \the\macname\endcsname \relax
  5276. \else \errmessage{Macro name \the\macname\space already defined}\fi
  5277. \global\cslet{macsave.\the\macname}{\the\macname}%
  5278. \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
  5279. \addtomacrolist{\the\macname}%
  5280. \fi
  5281. \begingroup \macrobodyctxt
  5282. \ifrecursive \expandafter\parsermacbody
  5283. \else \expandafter\parsemacbody
  5284. \fi}
  5285. \parseargdef\unmacro{%
  5286. \if1\csname ismacro.#1\endcsname
  5287. \global\cslet{#1}{macsave.#1}%
  5288. \global\expandafter\let \csname ismacro.#1\endcsname=0%
  5289. % Remove the macro name from \macrolist:
  5290. \begingroup
  5291. \expandafter\let\csname#1\endcsname \relax
  5292. \let\definedummyword\unmacrodo
  5293. \xdef\macrolist{\macrolist}%
  5294. \endgroup
  5295. \else
  5296. \errmessage{Macro #1 not defined}%
  5297. \fi
  5298. }
  5299. % Called by \do from \dounmacro on each macro. The idea is to omit any
  5300. % macro definitions that have been changed to \relax.
  5301. %
  5302. \def\unmacrodo#1{%
  5303. \ifx #1\relax
  5304. % remove this
  5305. \else
  5306. \noexpand\definedummyword \noexpand#1%
  5307. \fi
  5308. }
  5309. % This makes use of the obscure feature that if the last token of a
  5310. % <parameter list> is #, then the preceding argument is delimited by
  5311. % an opening brace, and that opening brace is not consumed.
  5312. \def\getargs#1{\getargsxxx#1{}}
  5313. \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
  5314. \def\getmacname #1 #2\relax{\macname={#1}}
  5315. \def\getmacargs#1{\def\argl{#1}}
  5316. % Parse the optional {params} list. Set up \paramno and \paramlist
  5317. % so \defmacro knows what to do. Define \macarg.blah for each blah
  5318. % in the params list, to be ##N where N is the position in that list.
  5319. % That gets used by \mbodybackslash (above).
  5320. % We need to get `macro parameter char #' into several definitions.
  5321. % The technique used is stolen from LaTeX: let \hash be something
  5322. % unexpandable, insert that wherever you need a #, and then redefine
  5323. % it to # just before using the token list produced.
  5324. %
  5325. % The same technique is used to protect \eatspaces till just before
  5326. % the macro is used.
  5327. \def\parsemargdef#1;{\paramno=0\def\paramlist{}%
  5328. \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,}
  5329. \def\parsemargdefxxx#1,{%
  5330. \if#1;\let\next=\relax
  5331. \else \let\next=\parsemargdefxxx
  5332. \advance\paramno by 1%
  5333. \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
  5334. {\xeatspaces{\hash\the\paramno}}%
  5335. \edef\paramlist{\paramlist\hash\the\paramno,}%
  5336. \fi\next}
  5337. % These two commands read recursive and nonrecursive macro bodies.
  5338. % (They're different since rec and nonrec macros end differently.)
  5339. \long\def\parsemacbody#1@end macro%
  5340. {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
  5341. \long\def\parsermacbody#1@end rmacro%
  5342. {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
  5343. % This defines the macro itself. There are six cases: recursive and
  5344. % nonrecursive macros of zero, one, and many arguments.
  5345. % Much magic with \expandafter here.
  5346. % \xdef is used so that macro definitions will survive the file
  5347. % they're defined in; @include reads the file inside a group.
  5348. \def\defmacro{%
  5349. \let\hash=##% convert placeholders to macro parameter chars
  5350. \ifrecursive
  5351. \ifcase\paramno
  5352. % 0
  5353. \expandafter\xdef\csname\the\macname\endcsname{%
  5354. \noexpand\scanmacro{\temp}}%
  5355. \or % 1
  5356. \expandafter\xdef\csname\the\macname\endcsname{%
  5357. \bgroup\noexpand\macroargctxt
  5358. \noexpand\braceorline
  5359. \expandafter\noexpand\csname\the\macname xxx\endcsname}%
  5360. \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
  5361. \egroup\noexpand\scanmacro{\temp}}%
  5362. \else % many
  5363. \expandafter\xdef\csname\the\macname\endcsname{%
  5364. \bgroup\noexpand\macroargctxt
  5365. \noexpand\csname\the\macname xx\endcsname}%
  5366. \expandafter\xdef\csname\the\macname xx\endcsname##1{%
  5367. \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
  5368. \expandafter\expandafter
  5369. \expandafter\xdef
  5370. \expandafter\expandafter
  5371. \csname\the\macname xxx\endcsname
  5372. \paramlist{\egroup\noexpand\scanmacro{\temp}}%
  5373. \fi
  5374. \else
  5375. \ifcase\paramno
  5376. % 0
  5377. \expandafter\xdef\csname\the\macname\endcsname{%
  5378. \noexpand\norecurse{\the\macname}%
  5379. \noexpand\scanmacro{\temp}\egroup}%
  5380. \or % 1
  5381. \expandafter\xdef\csname\the\macname\endcsname{%
  5382. \bgroup\noexpand\macroargctxt
  5383. \noexpand\braceorline
  5384. \expandafter\noexpand\csname\the\macname xxx\endcsname}%
  5385. \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
  5386. \egroup
  5387. \noexpand\norecurse{\the\macname}%
  5388. \noexpand\scanmacro{\temp}\egroup}%
  5389. \else % many
  5390. \expandafter\xdef\csname\the\macname\endcsname{%
  5391. \bgroup\noexpand\macroargctxt
  5392. \expandafter\noexpand\csname\the\macname xx\endcsname}%
  5393. \expandafter\xdef\csname\the\macname xx\endcsname##1{%
  5394. \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
  5395. \expandafter\expandafter
  5396. \expandafter\xdef
  5397. \expandafter\expandafter
  5398. \csname\the\macname xxx\endcsname
  5399. \paramlist{%
  5400. \egroup
  5401. \noexpand\norecurse{\the\macname}%
  5402. \noexpand\scanmacro{\temp}\egroup}%
  5403. \fi
  5404. \fi}
  5405. \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
  5406. % \braceorline decides whether the next nonwhitespace character is a
  5407. % {. If so it reads up to the closing }, if not, it reads the whole
  5408. % line. Whatever was read is then fed to the next control sequence
  5409. % as an argument (by \parsebrace or \parsearg)
  5410. \def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx}
  5411. \def\braceorlinexxx{%
  5412. \ifx\nchar\bgroup\else
  5413. \expandafter\parsearg
  5414. \fi \next}
  5415. % @alias.
  5416. % We need some trickery to remove the optional spaces around the equal
  5417. % sign. Just make them active and then expand them all to nothing.
  5418. \def\alias{\parseargusing\obeyspaces\aliasxxx}
  5419. \def\aliasxxx #1{\aliasyyy#1\relax}
  5420. \def\aliasyyy #1=#2\relax{%
  5421. {%
  5422. \expandafter\let\obeyedspace=\empty
  5423. \addtomacrolist{#1}%
  5424. \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
  5425. }%
  5426. \next
  5427. }
  5428. \message{cross references,}
  5429. \newwrite\auxfile
  5430. \newif\ifhavexrefs % True if xref values are known.
  5431. \newif\ifwarnedxrefs % True if we warned once that they aren't known.
  5432. % @inforef is relatively simple.
  5433. \def\inforef #1{\inforefzzz #1,,,,**}
  5434. \def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
  5435. node \samp{\ignorespaces#1{}}}
  5436. % @node's only job in TeX is to define \lastnode, which is used in
  5437. % cross-references. The @node line might or might not have commas, and
  5438. % might or might not have spaces before the first comma, like:
  5439. % @node foo , bar , ...
  5440. % We don't want such trailing spaces in the node name.
  5441. %
  5442. \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
  5443. %
  5444. % also remove a trailing comma, in case of something like this:
  5445. % @node Help-Cross, , , Cross-refs
  5446. \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
  5447. \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
  5448. \let\nwnode=\node
  5449. \let\lastnode=\empty
  5450. % Write a cross-reference definition for the current node. #1 is the
  5451. % type (Ynumbered, Yappendix, Ynothing).
  5452. %
  5453. \def\donoderef#1{%
  5454. \ifx\lastnode\empty\else
  5455. \setref{\lastnode}{#1}%
  5456. \global\let\lastnode=\empty
  5457. \fi
  5458. }
  5459. % @anchor{NAME} -- define xref target at arbitrary point.
  5460. %
  5461. \newcount\savesfregister
  5462. %
  5463. \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
  5464. \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
  5465. \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
  5466. % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
  5467. % anchor), which consists of three parts:
  5468. % 1) NAME-title - the current sectioning name taken from \thissection,
  5469. % or the anchor name.
  5470. % 2) NAME-snt - section number and type, passed as the SNT arg, or
  5471. % empty for anchors.
  5472. % 3) NAME-pg - the page number.
  5473. %
  5474. % This is called from \donoderef, \anchor, and \dofloat. In the case of
  5475. % floats, there is an additional part, which is not written here:
  5476. % 4) NAME-lof - the text as it should appear in a @listoffloats.
  5477. %
  5478. \def\setref#1#2{%
  5479. \pdfmkdest{#1}%
  5480. \iflinks
  5481. {%
  5482. \atdummies % preserve commands, but don't expand them
  5483. \edef\writexrdef##1##2{%
  5484. \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
  5485. ##1}{##2}}% these are parameters of \writexrdef
  5486. }%
  5487. \toks0 = \expandafter{\thissection}%
  5488. \immediate \writexrdef{title}{\the\toks0 }%
  5489. \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
  5490. \writexrdef{pg}{\folio}% will be written later, during \shipout
  5491. }%
  5492. \fi
  5493. }
  5494. % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
  5495. % the node name, #2 the name of the Info cross-reference, #3 the printed
  5496. % node name, #4 the name of the Info file, #5 the name of the printed
  5497. % manual. All but the node name can be omitted.
  5498. %
  5499. \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
  5500. \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
  5501. \def\ref#1{\xrefX[#1,,,,,,,]}
  5502. \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
  5503. \unsepspaces
  5504. \def\printedmanual{\ignorespaces #5}%
  5505. \def\printedrefname{\ignorespaces #3}%
  5506. \setbox1=\hbox{\printedmanual\unskip}%
  5507. \setbox0=\hbox{\printedrefname\unskip}%
  5508. \ifdim \wd0 = 0pt
  5509. % No printed node name was explicitly given.
  5510. \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
  5511. % Use the node name inside the square brackets.
  5512. \def\printedrefname{\ignorespaces #1}%
  5513. \else
  5514. % Use the actual chapter/section title appear inside
  5515. % the square brackets. Use the real section title if we have it.
  5516. \ifdim \wd1 > 0pt
  5517. % It is in another manual, so we don't have it.
  5518. \def\printedrefname{\ignorespaces #1}%
  5519. \else
  5520. \ifhavexrefs
  5521. % We know the real title if we have the xref values.
  5522. \def\printedrefname{\refx{#1-title}{}}%
  5523. \else
  5524. % Otherwise just copy the Info node name.
  5525. \def\printedrefname{\ignorespaces #1}%
  5526. \fi%
  5527. \fi
  5528. \fi
  5529. \fi
  5530. %
  5531. % Make link in pdf output.
  5532. \ifpdf
  5533. \leavevmode
  5534. \getfilename{#4}%
  5535. {\turnoffactive
  5536. % See comments at \activebackslashdouble.
  5537. {\activebackslashdouble \xdef\pdfxrefdest{#1}%
  5538. \backslashparens\pdfxrefdest}%
  5539. %
  5540. \ifnum\filenamelength>0
  5541. \startlink attr{/Border [0 0 0]}%
  5542. goto file{\the\filename.pdf} name{\pdfxrefdest}%
  5543. \else
  5544. \startlink attr{/Border [0 0 0]}%
  5545. goto name{\pdfmkpgn{\pdfxrefdest}}%
  5546. \fi
  5547. }%
  5548. \linkcolor
  5549. \fi
  5550. %
  5551. % Float references are printed completely differently: "Figure 1.2"
  5552. % instead of "[somenode], p.3". We distinguish them by the
  5553. % LABEL-title being set to a magic string.
  5554. {%
  5555. % Have to otherify everything special to allow the \csname to
  5556. % include an _ in the xref name, etc.
  5557. \indexnofonts
  5558. \turnoffactive
  5559. \expandafter\global\expandafter\let\expandafter\Xthisreftitle
  5560. \csname XR#1-title\endcsname
  5561. }%
  5562. \iffloat\Xthisreftitle
  5563. % If the user specified the print name (third arg) to the ref,
  5564. % print it instead of our usual "Figure 1.2".
  5565. \ifdim\wd0 = 0pt
  5566. \refx{#1-snt}%
  5567. \else
  5568. \printedrefname
  5569. \fi
  5570. %
  5571. % if the user also gave the printed manual name (fifth arg), append
  5572. % "in MANUALNAME".
  5573. \ifdim \wd1 > 0pt
  5574. \space \putwordin{} \cite{\printedmanual}%
  5575. \fi
  5576. \else
  5577. % node/anchor (non-float) references.
  5578. %
  5579. % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
  5580. % insert empty discretionaries after hyphens, which means that it will
  5581. % not find a line break at a hyphen in a node names. Since some manuals
  5582. % are best written with fairly long node names, containing hyphens, this
  5583. % is a loss. Therefore, we give the text of the node name again, so it
  5584. % is as if TeX is seeing it for the first time.
  5585. \ifdim \wd1 > 0pt
  5586. \putwordsection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}%
  5587. \else
  5588. % _ (for example) has to be the character _ for the purposes of the
  5589. % control sequence corresponding to the node, but it has to expand
  5590. % into the usual \leavevmode...\vrule stuff for purposes of
  5591. % printing. So we \turnoffactive for the \refx-snt, back on for the
  5592. % printing, back off for the \refx-pg.
  5593. {\turnoffactive
  5594. % Only output a following space if the -snt ref is nonempty; for
  5595. % @unnumbered and @anchor, it won't be.
  5596. \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
  5597. \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
  5598. }%
  5599. % output the `[mynode]' via a macro so it can be overridden.
  5600. \xrefprintnodename\printedrefname
  5601. %
  5602. % But we always want a comma and a space:
  5603. ,\space
  5604. %
  5605. % output the `page 3'.
  5606. \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
  5607. \fi
  5608. \fi
  5609. \endlink
  5610. \endgroup}
  5611. % This macro is called from \xrefX for the `[nodename]' part of xref
  5612. % output. It's a separate macro only so it can be changed more easily,
  5613. % since square brackets don't work well in some documents. Particularly
  5614. % one that Bob is working on :).
  5615. %
  5616. \def\xrefprintnodename#1{[#1]}
  5617. % Things referred to by \setref.
  5618. %
  5619. \def\Ynothing{}
  5620. \def\Yomitfromtoc{}
  5621. \def\Ynumbered{%
  5622. \ifnum\secno=0
  5623. \putwordChapter@tie \the\chapno
  5624. \else \ifnum\subsecno=0
  5625. \putwordSection@tie \the\chapno.\the\secno
  5626. \else \ifnum\subsubsecno=0
  5627. \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
  5628. \else
  5629. \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
  5630. \fi\fi\fi
  5631. }
  5632. \def\Yappendix{%
  5633. \ifnum\secno=0
  5634. \putwordAppendix@tie @char\the\appendixno{}%
  5635. \else \ifnum\subsecno=0
  5636. \putwordSection@tie @char\the\appendixno.\the\secno
  5637. \else \ifnum\subsubsecno=0
  5638. \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
  5639. \else
  5640. \putwordSection@tie
  5641. @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
  5642. \fi\fi\fi
  5643. }
  5644. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  5645. % If its value is nonempty, SUFFIX is output afterward.
  5646. %
  5647. \def\refx#1#2{%
  5648. {%
  5649. \indexnofonts
  5650. \otherbackslash
  5651. \expandafter\global\expandafter\let\expandafter\thisrefX
  5652. \csname XR#1\endcsname
  5653. }%
  5654. \ifx\thisrefX\relax
  5655. % If not defined, say something at least.
  5656. \angleleft un\-de\-fined\angleright
  5657. \iflinks
  5658. \ifhavexrefs
  5659. \message{\linenumber Undefined cross reference `#1'.}%
  5660. \else
  5661. \ifwarnedxrefs\else
  5662. \global\warnedxrefstrue
  5663. \message{Cross reference values unknown; you must run TeX again.}%
  5664. \fi
  5665. \fi
  5666. \fi
  5667. \else
  5668. % It's defined, so just use it.
  5669. \thisrefX
  5670. \fi
  5671. #2% Output the suffix in any case.
  5672. }
  5673. % This is the macro invoked by entries in the aux file. Usually it's
  5674. % just a \def (we prepend XR to the control sequence name to avoid
  5675. % collisions). But if this is a float type, we have more work to do.
  5676. %
  5677. \def\xrdef#1#2{%
  5678. \expandafter\gdef\csname XR#1\endcsname{#2}% remember this xref value.
  5679. %
  5680. % Was that xref control sequence that we just defined for a float?
  5681. \expandafter\iffloat\csname XR#1\endcsname
  5682. % it was a float, and we have the (safe) float type in \iffloattype.
  5683. \expandafter\let\expandafter\floatlist
  5684. \csname floatlist\iffloattype\endcsname
  5685. %
  5686. % Is this the first time we've seen this float type?
  5687. \expandafter\ifx\floatlist\relax
  5688. \toks0 = {\do}% yes, so just \do
  5689. \else
  5690. % had it before, so preserve previous elements in list.
  5691. \toks0 = \expandafter{\floatlist\do}%
  5692. \fi
  5693. %
  5694. % Remember this xref in the control sequence \floatlistFLOATTYPE,
  5695. % for later use in \listoffloats.
  5696. \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0{#1}}%
  5697. \fi
  5698. }
  5699. % Read the last existing aux file, if any. No error if none exists.
  5700. %
  5701. \def\tryauxfile{%
  5702. \openin 1 \jobname.aux
  5703. \ifeof 1 \else
  5704. \readdatafile{aux}%
  5705. \global\havexrefstrue
  5706. \fi
  5707. \closein 1
  5708. }
  5709. \def\setupdatafile{%
  5710. \catcode`\^^@=\other
  5711. \catcode`\^^A=\other
  5712. \catcode`\^^B=\other
  5713. \catcode`\^^C=\other
  5714. \catcode`\^^D=\other
  5715. \catcode`\^^E=\other
  5716. \catcode`\^^F=\other
  5717. \catcode`\^^G=\other
  5718. \catcode`\^^H=\other
  5719. \catcode`\^^K=\other
  5720. \catcode`\^^L=\other
  5721. \catcode`\^^N=\other
  5722. \catcode`\^^P=\other
  5723. \catcode`\^^Q=\other
  5724. \catcode`\^^R=\other
  5725. \catcode`\^^S=\other
  5726. \catcode`\^^T=\other
  5727. \catcode`\^^U=\other
  5728. \catcode`\^^V=\other
  5729. \catcode`\^^W=\other
  5730. \catcode`\^^X=\other
  5731. \catcode`\^^Z=\other
  5732. \catcode`\^^[=\other
  5733. \catcode`\^^\=\other
  5734. \catcode`\^^]=\other
  5735. \catcode`\^^^=\other
  5736. \catcode`\^^_=\other
  5737. % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
  5738. % in xref tags, i.e., node names. But since ^^e4 notation isn't
  5739. % supported in the main text, it doesn't seem desirable. Furthermore,
  5740. % that is not enough: for node names that actually contain a ^
  5741. % character, we would end up writing a line like this: 'xrdef {'hat
  5742. % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
  5743. % argument, and \hat is not an expandable control sequence. It could
  5744. % all be worked out, but why? Either we support ^^ or we don't.
  5745. %
  5746. % The other change necessary for this was to define \auxhat:
  5747. % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
  5748. % and then to call \auxhat in \setq.
  5749. %
  5750. \catcode`\^=\other
  5751. %
  5752. % Special characters. Should be turned off anyway, but...
  5753. \catcode`\~=\other
  5754. \catcode`\[=\other
  5755. \catcode`\]=\other
  5756. \catcode`\"=\other
  5757. \catcode`\_=\other
  5758. \catcode`\|=\other
  5759. \catcode`\<=\other
  5760. \catcode`\>=\other
  5761. \catcode`\$=\other
  5762. \catcode`\#=\other
  5763. \catcode`\&=\other
  5764. \catcode`\%=\other
  5765. \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
  5766. %
  5767. % This is to support \ in node names and titles, since the \
  5768. % characters end up in a \csname. It's easier than
  5769. % leaving it active and making its active definition an actual \
  5770. % character. What I don't understand is why it works in the *value*
  5771. % of the xrdef. Seems like it should be a catcode12 \, and that
  5772. % should not typeset properly. But it works, so I'm moving on for
  5773. % now. --karl, 15jan04.
  5774. \catcode`\\=\other
  5775. %
  5776. % Make the characters 128-255 be printing characters.
  5777. {%
  5778. \count1=128
  5779. \def\loop{%
  5780. \catcode\count1=\other
  5781. \advance\count1 by 1
  5782. \ifnum \count1<256 \loop \fi
  5783. }%
  5784. }%
  5785. %
  5786. % @ is our escape character in .aux files, and we need braces.
  5787. \catcode`\{=1
  5788. \catcode`\}=2
  5789. \catcode`\@=0
  5790. }
  5791. \def\readdatafile#1{%
  5792. \begingroup
  5793. \setupdatafile
  5794. \input\jobname.#1
  5795. \endgroup}
  5796. \message{insertions,}
  5797. % including footnotes.
  5798. \newcount \footnoteno
  5799. % The trailing space in the following definition for supereject is
  5800. % vital for proper filling; pages come out unaligned when you do a
  5801. % pagealignmacro call if that space before the closing brace is
  5802. % removed. (Generally, numeric constants should always be followed by a
  5803. % space to prevent strange expansion errors.)
  5804. \def\supereject{\par\penalty -20000\footnoteno =0 }
  5805. % @footnotestyle is meaningful for info output only.
  5806. \let\footnotestyle=\comment
  5807. {\catcode `\@=11
  5808. %
  5809. % Auto-number footnotes. Otherwise like plain.
  5810. \gdef\footnote{%
  5811. \let\indent=\ptexindent
  5812. \let\noindent=\ptexnoindent
  5813. \global\advance\footnoteno by \@ne
  5814. \edef\thisfootno{$^{\the\footnoteno}$}%
  5815. %
  5816. % In case the footnote comes at the end of a sentence, preserve the
  5817. % extra spacing after we do the footnote number.
  5818. \let\@sf\empty
  5819. \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
  5820. %
  5821. % Remove inadvertent blank space before typesetting the footnote number.
  5822. \unskip
  5823. \thisfootno\@sf
  5824. \dofootnote
  5825. }%
  5826. % Don't bother with the trickery in plain.tex to not require the
  5827. % footnote text as a parameter. Our footnotes don't need to be so general.
  5828. %
  5829. % Oh yes, they do; otherwise, @ifset (and anything else that uses
  5830. % \parseargline) fails inside footnotes because the tokens are fixed when
  5831. % the footnote is read. --karl, 16nov96.
  5832. %
  5833. \gdef\dofootnote{%
  5834. \insert\footins\bgroup
  5835. % We want to typeset this text as a normal paragraph, even if the
  5836. % footnote reference occurs in (for example) a display environment.
  5837. % So reset some parameters.
  5838. \hsize=\pagewidth
  5839. \interlinepenalty\interfootnotelinepenalty
  5840. \splittopskip\ht\strutbox % top baseline for broken footnotes
  5841. \splitmaxdepth\dp\strutbox
  5842. \floatingpenalty\@MM
  5843. \leftskip\z@skip
  5844. \rightskip\z@skip
  5845. \spaceskip\z@skip
  5846. \xspaceskip\z@skip
  5847. \parindent\defaultparindent
  5848. %
  5849. \smallfonts \rm
  5850. %
  5851. % Because we use hanging indentation in footnotes, a @noindent appears
  5852. % to exdent this text, so make it be a no-op. makeinfo does not use
  5853. % hanging indentation so @noindent can still be needed within footnote
  5854. % text after an @example or the like (not that this is good style).
  5855. \let\noindent = \relax
  5856. %
  5857. % Hang the footnote text off the number. Use \everypar in case the
  5858. % footnote extends for more than one paragraph.
  5859. \everypar = {\hang}%
  5860. \textindent{\thisfootno}%
  5861. %
  5862. % Don't crash into the line above the footnote text. Since this
  5863. % expands into a box, it must come within the paragraph, lest it
  5864. % provide a place where TeX can split the footnote.
  5865. \footstrut
  5866. \futurelet\next\fo@t
  5867. }
  5868. }%end \catcode `\@=11
  5869. % In case a @footnote appears in a vbox, save the footnote text and create
  5870. % the real \insert just after the vbox finished. Otherwise, the insertion
  5871. % would be lost.
  5872. % Similarily, if a @footnote appears inside an alignment, save the footnote
  5873. % text to a box and make the \insert when a row of the table is finished.
  5874. % And the same can be done for other insert classes. --kasal, 16nov03.
  5875. % Replace the \insert primitive by a cheating macro.
  5876. % Deeper inside, just make sure that the saved insertions are not spilled
  5877. % out prematurely.
  5878. %
  5879. \def\startsavinginserts{%
  5880. \ifx \insert\ptexinsert
  5881. \let\insert\saveinsert
  5882. \else
  5883. \let\checkinserts\relax
  5884. \fi
  5885. }
  5886. % This \insert replacement works for both \insert\footins{foo} and
  5887. % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
  5888. %
  5889. \def\saveinsert#1{%
  5890. \edef\next{\noexpand\savetobox \makeSAVEname#1}%
  5891. \afterassignment\next
  5892. % swallow the left brace
  5893. \let\temp =
  5894. }
  5895. \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
  5896. \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
  5897. \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
  5898. \def\placesaveins#1{%
  5899. \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
  5900. {\box#1}%
  5901. }
  5902. % eat @SAVE -- beware, all of them have catcode \other:
  5903. {
  5904. \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-)
  5905. \gdef\gobblesave @SAVE{}
  5906. }
  5907. % initialization:
  5908. \def\newsaveins #1{%
  5909. \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
  5910. \next
  5911. }
  5912. \def\newsaveinsX #1{%
  5913. \csname newbox\endcsname #1%
  5914. \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
  5915. \checksaveins #1}%
  5916. }
  5917. % initialize:
  5918. \let\checkinserts\empty
  5919. \newsaveins\footins
  5920. \newsaveins\margin
  5921. % @image. We use the macros from epsf.tex to support this.
  5922. % If epsf.tex is not installed and @image is used, we complain.
  5923. %
  5924. % Check for and read epsf.tex up front. If we read it only at @image
  5925. % time, we might be inside a group, and then its definitions would get
  5926. % undone and the next image would fail.
  5927. \openin 1 = epsf.tex
  5928. \ifeof 1 \else
  5929. % Do not bother showing banner with epsf.tex v2.7k (available in
  5930. % doc/epsf.tex and on ctan).
  5931. \def\epsfannounce{\toks0 = }%
  5932. \input epsf.tex
  5933. \fi
  5934. \closein 1
  5935. %
  5936. % We will only complain once about lack of epsf.tex.
  5937. \newif\ifwarnednoepsf
  5938. \newhelp\noepsfhelp{epsf.tex must be installed for images to
  5939. work. It is also included in the Texinfo distribution, or you can get
  5940. it from ftp://tug.org/tex/epsf.tex.}
  5941. %
  5942. \def\image#1{%
  5943. \ifx\epsfbox\undefined
  5944. \ifwarnednoepsf \else
  5945. \errhelp = \noepsfhelp
  5946. \errmessage{epsf.tex not found, images will be ignored}%
  5947. \global\warnednoepsftrue
  5948. \fi
  5949. \else
  5950. \imagexxx #1,,,,,\finish
  5951. \fi
  5952. }
  5953. %
  5954. % Arguments to @image:
  5955. % #1 is (mandatory) image filename; we tack on .eps extension.
  5956. % #2 is (optional) width, #3 is (optional) height.
  5957. % #4 is (ignored optional) html alt text.
  5958. % #5 is (ignored optional) extension.
  5959. % #6 is just the usual extra ignored arg for parsing this stuff.
  5960. \newif\ifimagevmode
  5961. \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
  5962. \catcode`\^^M = 5 % in case we're inside an example
  5963. \normalturnoffactive % allow _ et al. in names
  5964. % If the image is by itself, center it.
  5965. \ifvmode
  5966. \imagevmodetrue
  5967. \nobreak\bigskip
  5968. % Usually we'll have text after the image which will insert
  5969. % \parskip glue, so insert it here too to equalize the space
  5970. % above and below.
  5971. \nobreak\vskip\parskip
  5972. \nobreak
  5973. \line\bgroup\hss
  5974. \fi
  5975. %
  5976. % Output the image.
  5977. \ifpdf
  5978. \dopdfimage{#1}{#2}{#3}%
  5979. \else
  5980. % \epsfbox itself resets \epsf?size at each figure.
  5981. \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
  5982. \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
  5983. \epsfbox{#1.eps}%
  5984. \fi
  5985. %
  5986. \ifimagevmode \hss \egroup \bigbreak \fi % space after the image
  5987. \endgroup}
  5988. % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
  5989. % etc. We don't actually implement floating yet, we always include the
  5990. % float "here". But it seemed the best name for the future.
  5991. %
  5992. \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
  5993. % There may be a space before second and/or third parameter; delete it.
  5994. \def\eatcommaspace#1, {#1,}
  5995. % #1 is the optional FLOATTYPE, the text label for this float, typically
  5996. % "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
  5997. % this float will not be numbered and cannot be referred to.
  5998. %
  5999. % #2 is the optional xref label. Also must be present for the float to
  6000. % be referable.
  6001. %
  6002. % #3 is the optional positioning argument; for now, it is ignored. It
  6003. % will somehow specify the positions allowed to float to (here, top, bottom).
  6004. %
  6005. % We keep a separate counter for each FLOATTYPE, which we reset at each
  6006. % chapter-level command.
  6007. \let\resetallfloatnos=\empty
  6008. %
  6009. \def\dofloat#1,#2,#3,#4\finish{%
  6010. \let\thiscaption=\empty
  6011. \let\thisshortcaption=\empty
  6012. %
  6013. % don't lose footnotes inside @float.
  6014. %
  6015. % BEWARE: when the floats start float, we have to issue warning whenever an
  6016. % insert appears inside a float which could possibly float. --kasal, 26may04
  6017. %
  6018. \startsavinginserts
  6019. %
  6020. % We can't be used inside a paragraph.
  6021. \par
  6022. %
  6023. \vtop\bgroup
  6024. \def\floattype{#1}%
  6025. \def\floatlabel{#2}%
  6026. \def\floatloc{#3}% we do nothing with this yet.
  6027. %
  6028. \ifx\floattype\empty
  6029. \let\safefloattype=\empty
  6030. \else
  6031. {%
  6032. % the floattype might have accents or other special characters,
  6033. % but we need to use it in a control sequence name.
  6034. \indexnofonts
  6035. \turnoffactive
  6036. \xdef\safefloattype{\floattype}%
  6037. }%
  6038. \fi
  6039. %
  6040. % If label is given but no type, we handle that as the empty type.
  6041. \ifx\floatlabel\empty \else
  6042. % We want each FLOATTYPE to be numbered separately (Figure 1,
  6043. % Table 1, Figure 2, ...). (And if no label, no number.)
  6044. %
  6045. \expandafter\getfloatno\csname\safefloattype floatno\endcsname
  6046. \global\advance\floatno by 1
  6047. %
  6048. {%
  6049. % This magic value for \thissection is output by \setref as the
  6050. % XREFLABEL-title value. \xrefX uses it to distinguish float
  6051. % labels (which have a completely different output format) from
  6052. % node and anchor labels. And \xrdef uses it to construct the
  6053. % lists of floats.
  6054. %
  6055. \edef\thissection{\floatmagic=\safefloattype}%
  6056. \setref{\floatlabel}{Yfloat}%
  6057. }%
  6058. \fi
  6059. %
  6060. % start with \parskip glue, I guess.
  6061. \vskip\parskip
  6062. %
  6063. % Don't suppress indentation if a float happens to start a section.
  6064. \restorefirstparagraphindent
  6065. }
  6066. % we have these possibilities:
  6067. % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
  6068. % @float Foo,lbl & no caption: Foo 1.1
  6069. % @float Foo & @caption{Cap}: Foo: Cap
  6070. % @float Foo & no caption: Foo
  6071. % @float ,lbl & Caption{Cap}: 1.1: Cap
  6072. % @float ,lbl & no caption: 1.1
  6073. % @float & @caption{Cap}: Cap
  6074. % @float & no caption:
  6075. %
  6076. \def\Efloat{%
  6077. \let\floatident = \empty
  6078. %
  6079. % In all cases, if we have a float type, it comes first.
  6080. \ifx\floattype\empty \else \def\floatident{\floattype}\fi
  6081. %
  6082. % If we have an xref label, the number comes next.
  6083. \ifx\floatlabel\empty \else
  6084. \ifx\floattype\empty \else % if also had float type, need tie first.
  6085. \appendtomacro\floatident{\tie}%
  6086. \fi
  6087. % the number.
  6088. \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
  6089. \fi
  6090. %
  6091. % Start the printed caption with what we've constructed in
  6092. % \floatident, but keep it separate; we need \floatident again.
  6093. \let\captionline = \floatident
  6094. %
  6095. \ifx\thiscaption\empty \else
  6096. \ifx\floatident\empty \else
  6097. \appendtomacro\captionline{: }% had ident, so need a colon between
  6098. \fi
  6099. %
  6100. % caption text.
  6101. \appendtomacro\captionline{\scanexp\thiscaption}%
  6102. \fi
  6103. %
  6104. % If we have anything to print, print it, with space before.
  6105. % Eventually this needs to become an \insert.
  6106. \ifx\captionline\empty \else
  6107. \vskip.5\parskip
  6108. \captionline
  6109. %
  6110. % Space below caption.
  6111. \vskip\parskip
  6112. \fi
  6113. %
  6114. % If have an xref label, write the list of floats info. Do this
  6115. % after the caption, to avoid chance of it being a breakpoint.
  6116. \ifx\floatlabel\empty \else
  6117. % Write the text that goes in the lof to the aux file as
  6118. % \floatlabel-lof. Besides \floatident, we include the short
  6119. % caption if specified, else the full caption if specified, else nothing.
  6120. {%
  6121. \atdummies
  6122. % since we read the caption text in the macro world, where ^^M
  6123. % is turned into a normal character, we have to scan it back, so
  6124. % we don't write the literal three characters "^^M" into the aux file.
  6125. \scanexp{%
  6126. \xdef\noexpand\gtemp{%
  6127. \ifx\thisshortcaption\empty
  6128. \thiscaption
  6129. \else
  6130. \thisshortcaption
  6131. \fi
  6132. }%
  6133. }%
  6134. \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
  6135. \ifx\gtemp\empty \else : \gtemp \fi}}%
  6136. }%
  6137. \fi
  6138. \egroup % end of \vtop
  6139. %
  6140. % place the captured inserts
  6141. %
  6142. % BEWARE: when the floats start float, we have to issue warning whenever an
  6143. % insert appears inside a float which could possibly float. --kasal, 26may04
  6144. %
  6145. \checkinserts
  6146. }
  6147. % Append the tokens #2 to the definition of macro #1, not expanding either.
  6148. %
  6149. \def\appendtomacro#1#2{%
  6150. \expandafter\def\expandafter#1\expandafter{#1#2}%
  6151. }
  6152. % @caption, @shortcaption
  6153. %
  6154. \def\caption{\docaption\thiscaption}
  6155. \def\shortcaption{\docaption\thisshortcaption}
  6156. \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
  6157. \def\defcaption#1#2{\egroup \def#1{#2}}
  6158. % The parameter is the control sequence identifying the counter we are
  6159. % going to use. Create it if it doesn't exist and assign it to \floatno.
  6160. \def\getfloatno#1{%
  6161. \ifx#1\relax
  6162. % Haven't seen this figure type before.
  6163. \csname newcount\endcsname #1%
  6164. %
  6165. % Remember to reset this floatno at the next chap.
  6166. \expandafter\gdef\expandafter\resetallfloatnos
  6167. \expandafter{\resetallfloatnos #1=0 }%
  6168. \fi
  6169. \let\floatno#1%
  6170. }
  6171. % \setref calls this to get the XREFLABEL-snt value. We want an @xref
  6172. % to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
  6173. % first read the @float command.
  6174. %
  6175. \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
  6176. % Magic string used for the XREFLABEL-title value, so \xrefX can
  6177. % distinguish floats from other xref types.
  6178. \def\floatmagic{!!float!!}
  6179. % #1 is the control sequence we are passed; we expand into a conditional
  6180. % which is true if #1 represents a float ref. That is, the magic
  6181. % \thissection value which we \setref above.
  6182. %
  6183. \def\iffloat#1{\expandafter\doiffloat#1==\finish}
  6184. %
  6185. % #1 is (maybe) the \floatmagic string. If so, #2 will be the
  6186. % (safe) float type for this float. We set \iffloattype to #2.
  6187. %
  6188. \def\doiffloat#1=#2=#3\finish{%
  6189. \def\temp{#1}%
  6190. \def\iffloattype{#2}%
  6191. \ifx\temp\floatmagic
  6192. }
  6193. % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
  6194. %
  6195. \parseargdef\listoffloats{%
  6196. \def\floattype{#1}% floattype
  6197. {%
  6198. % the floattype might have accents or other special characters,
  6199. % but we need to use it in a control sequence name.
  6200. \indexnofonts
  6201. \turnoffactive
  6202. \xdef\safefloattype{\floattype}%
  6203. }%
  6204. %
  6205. % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
  6206. \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
  6207. \ifhavexrefs
  6208. % if the user said @listoffloats foo but never @float foo.
  6209. \message{\linenumber No `\safefloattype' floats to list.}%
  6210. \fi
  6211. \else
  6212. \begingroup
  6213. \leftskip=\tocindent % indent these entries like a toc
  6214. \let\do=\listoffloatsdo
  6215. \csname floatlist\safefloattype\endcsname
  6216. \endgroup
  6217. \fi
  6218. }
  6219. % This is called on each entry in a list of floats. We're passed the
  6220. % xref label, in the form LABEL-title, which is how we save it in the
  6221. % aux file. We strip off the -title and look up \XRLABEL-lof, which
  6222. % has the text we're supposed to typeset here.
  6223. %
  6224. % Figures without xref labels will not be included in the list (since
  6225. % they won't appear in the aux file).
  6226. %
  6227. \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
  6228. \def\listoffloatsdoentry#1-title\finish{{%
  6229. % Can't fully expand XR#1-lof because it can contain anything. Just
  6230. % pass the control sequence. On the other hand, XR#1-pg is just the
  6231. % page number, and we want to fully expand that so we can get a link
  6232. % in pdf output.
  6233. \toksA = \expandafter{\csname XR#1-lof\endcsname}%
  6234. %
  6235. % use the same \entry macro we use to generate the TOC and index.
  6236. \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
  6237. \writeentry
  6238. }}
  6239. \message{localization,}
  6240. % and i18n.
  6241. % @documentlanguage is usually given very early, just after
  6242. % @setfilename. If done too late, it may not override everything
  6243. % properly. Single argument is the language abbreviation.
  6244. % It would be nice if we could set up a hyphenation file here.
  6245. %
  6246. \parseargdef\documentlanguage{%
  6247. \tex % read txi-??.tex file in plain TeX.
  6248. % Read the file if it exists.
  6249. \openin 1 txi-#1.tex
  6250. \ifeof 1
  6251. \errhelp = \nolanghelp
  6252. \errmessage{Cannot read language file txi-#1.tex}%
  6253. \else
  6254. \input txi-#1.tex
  6255. \fi
  6256. \closein 1
  6257. \endgroup
  6258. }
  6259. \newhelp\nolanghelp{The given language definition file cannot be found or
  6260. is empty. Maybe you need to install it? In the current directory
  6261. should work if nowhere else does.}
  6262. % @documentencoding should change something in TeX eventually, most
  6263. % likely, but for now just recognize it.
  6264. \let\documentencoding = \comment
  6265. % Page size parameters.
  6266. %
  6267. \newdimen\defaultparindent \defaultparindent = 15pt
  6268. \chapheadingskip = 15pt plus 4pt minus 2pt
  6269. \secheadingskip = 12pt plus 3pt minus 2pt
  6270. \subsecheadingskip = 9pt plus 2pt minus 2pt
  6271. % Prevent underfull vbox error messages.
  6272. \vbadness = 10000
  6273. % Don't be so finicky about underfull hboxes, either.
  6274. \hbadness = 2000
  6275. % Following George Bush, just get rid of widows and orphans.
  6276. \widowpenalty=10000
  6277. \clubpenalty=10000
  6278. % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
  6279. % using an old version of TeX, don't do anything. We want the amount of
  6280. % stretch added to depend on the line length, hence the dependence on
  6281. % \hsize. We call this whenever the paper size is set.
  6282. %
  6283. \def\setemergencystretch{%
  6284. \ifx\emergencystretch\thisisundefined
  6285. % Allow us to assign to \emergencystretch anyway.
  6286. \def\emergencystretch{\dimen0}%
  6287. \else
  6288. \emergencystretch = .15\hsize
  6289. \fi
  6290. }
  6291. % Parameters in order: 1) textheight; 2) textwidth;
  6292. % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
  6293. % 7) physical page height; 8) physical page width.
  6294. %
  6295. % We also call \setleading{\textleading}, so the caller should define
  6296. % \textleading. The caller should also set \parskip.
  6297. %
  6298. \def\internalpagesizes#1#2#3#4#5#6#7#8{%
  6299. \voffset = #3\relax
  6300. \topskip = #6\relax
  6301. \splittopskip = \topskip
  6302. %
  6303. \vsize = #1\relax
  6304. \advance\vsize by \topskip
  6305. \outervsize = \vsize
  6306. \advance\outervsize by 2\topandbottommargin
  6307. \pageheight = \vsize
  6308. %
  6309. \hsize = #2\relax
  6310. \outerhsize = \hsize
  6311. \advance\outerhsize by 0.5in
  6312. \pagewidth = \hsize
  6313. %
  6314. \normaloffset = #4\relax
  6315. \bindingoffset = #5\relax
  6316. %
  6317. \ifpdf
  6318. \pdfpageheight #7\relax
  6319. \pdfpagewidth #8\relax
  6320. \fi
  6321. %
  6322. \setleading{\textleading}
  6323. %
  6324. \parindent = \defaultparindent
  6325. \setemergencystretch
  6326. }
  6327. % @letterpaper (the default).
  6328. \def\letterpaper{{\globaldefs = 1
  6329. \parskip = 3pt plus 2pt minus 1pt
  6330. \textleading = 13.2pt
  6331. %
  6332. % If page is nothing but text, make it come out even.
  6333. \internalpagesizes{46\baselineskip}{6in}%
  6334. {\voffset}{.25in}%
  6335. {\bindingoffset}{36pt}%
  6336. {11in}{8.5in}%
  6337. }}
  6338. % Use @smallbook to reset parameters for 7x9.25 trim size.
  6339. \def\smallbook{{\globaldefs = 1
  6340. \parskip = 2pt plus 1pt
  6341. \textleading = 12pt
  6342. %
  6343. \internalpagesizes{7.5in}{5in}%
  6344. {\voffset}{.25in}%
  6345. {\bindingoffset}{16pt}%
  6346. {9.25in}{7in}%
  6347. %
  6348. \lispnarrowing = 0.3in
  6349. \tolerance = 700
  6350. \hfuzz = 1pt
  6351. \contentsrightmargin = 0pt
  6352. \defbodyindent = .5cm
  6353. }}
  6354. % Use @smallerbook to reset parameters for 6x9 trim size.
  6355. % (Just testing, parameters still in flux.)
  6356. \def\smallerbook{{\globaldefs = 1
  6357. \parskip = 1.5pt plus 1pt
  6358. \textleading = 12pt
  6359. %
  6360. \internalpagesizes{7.4in}{4.8in}%
  6361. {-.2in}{-.4in}%
  6362. {0pt}{14pt}%
  6363. {9in}{6in}%
  6364. %
  6365. \lispnarrowing = 0.25in
  6366. \tolerance = 700
  6367. \hfuzz = 1pt
  6368. \contentsrightmargin = 0pt
  6369. \defbodyindent = .4cm
  6370. }}
  6371. % Use @afourpaper to print on European A4 paper.
  6372. \def\afourpaper{{\globaldefs = 1
  6373. \parskip = 3pt plus 2pt minus 1pt
  6374. \textleading = 13.2pt
  6375. %
  6376. % Double-side printing via postscript on Laserjet 4050
  6377. % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
  6378. % To change the settings for a different printer or situation, adjust
  6379. % \normaloffset until the front-side and back-side texts align. Then
  6380. % do the same for \bindingoffset. You can set these for testing in
  6381. % your texinfo source file like this:
  6382. % @tex
  6383. % \global\normaloffset = -6mm
  6384. % \global\bindingoffset = 10mm
  6385. % @end tex
  6386. \internalpagesizes{51\baselineskip}{160mm}
  6387. {\voffset}{\hoffset}%
  6388. {\bindingoffset}{44pt}%
  6389. {297mm}{210mm}%
  6390. %
  6391. \tolerance = 700
  6392. \hfuzz = 1pt
  6393. \contentsrightmargin = 0pt
  6394. \defbodyindent = 5mm
  6395. }}
  6396. % Use @afivepaper to print on European A5 paper.
  6397. % From romildo@urano.iceb.ufop.br, 2 July 2000.
  6398. % He also recommends making @example and @lisp be small.
  6399. \def\afivepaper{{\globaldefs = 1
  6400. \parskip = 2pt plus 1pt minus 0.1pt
  6401. \textleading = 12.5pt
  6402. %
  6403. \internalpagesizes{160mm}{120mm}%
  6404. {\voffset}{\hoffset}%
  6405. {\bindingoffset}{8pt}%
  6406. {210mm}{148mm}%
  6407. %
  6408. \lispnarrowing = 0.2in
  6409. \tolerance = 800
  6410. \hfuzz = 1.2pt
  6411. \contentsrightmargin = 0pt
  6412. \defbodyindent = 2mm
  6413. \tableindent = 12mm
  6414. }}
  6415. % A specific text layout, 24x15cm overall, intended for A4 paper.
  6416. \def\afourlatex{{\globaldefs = 1
  6417. \afourpaper
  6418. \internalpagesizes{237mm}{150mm}%
  6419. {\voffset}{4.6mm}%
  6420. {\bindingoffset}{7mm}%
  6421. {297mm}{210mm}%
  6422. %
  6423. % Must explicitly reset to 0 because we call \afourpaper.
  6424. \globaldefs = 0
  6425. }}
  6426. % Use @afourwide to print on A4 paper in landscape format.
  6427. \def\afourwide{{\globaldefs = 1
  6428. \afourpaper
  6429. \internalpagesizes{241mm}{165mm}%
  6430. {\voffset}{-2.95mm}%
  6431. {\bindingoffset}{7mm}%
  6432. {297mm}{210mm}%
  6433. \globaldefs = 0
  6434. }}
  6435. % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
  6436. % Perhaps we should allow setting the margins, \topskip, \parskip,
  6437. % and/or leading, also. Or perhaps we should compute them somehow.
  6438. %
  6439. \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
  6440. \def\pagesizesyyy#1,#2,#3\finish{{%
  6441. \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
  6442. \globaldefs = 1
  6443. %
  6444. \parskip = 3pt plus 2pt minus 1pt
  6445. \setleading{\textleading}%
  6446. %
  6447. \dimen0 = #1
  6448. \advance\dimen0 by \voffset
  6449. %
  6450. \dimen2 = \hsize
  6451. \advance\dimen2 by \normaloffset
  6452. %
  6453. \internalpagesizes{#1}{\hsize}%
  6454. {\voffset}{\normaloffset}%
  6455. {\bindingoffset}{44pt}%
  6456. {\dimen0}{\dimen2}%
  6457. }}
  6458. % Set default to letter.
  6459. %
  6460. \letterpaper
  6461. \message{and turning on texinfo input format.}
  6462. % Define macros to output various characters with catcode for normal text.
  6463. \catcode`\"=\other
  6464. \catcode`\~=\other
  6465. \catcode`\^=\other
  6466. \catcode`\_=\other
  6467. \catcode`\|=\other
  6468. \catcode`\<=\other
  6469. \catcode`\>=\other
  6470. \catcode`\+=\other
  6471. \catcode`\$=\other
  6472. \def\normaldoublequote{"}
  6473. \def\normaltilde{~}
  6474. \def\normalcaret{^}
  6475. \def\normalunderscore{_}
  6476. \def\normalverticalbar{|}
  6477. \def\normalless{<}
  6478. \def\normalgreater{>}
  6479. \def\normalplus{+}
  6480. \def\normaldollar{$}%$ font-lock fix
  6481. % This macro is used to make a character print one way in \tt
  6482. % (where it can probably be output as-is), and another way in other fonts,
  6483. % where something hairier probably needs to be done.
  6484. %
  6485. % #1 is what to print if we are indeed using \tt; #2 is what to print
  6486. % otherwise. Since all the Computer Modern typewriter fonts have zero
  6487. % interword stretch (and shrink), and it is reasonable to expect all
  6488. % typewriter fonts to have this, we can check that font parameter.
  6489. %
  6490. \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
  6491. % Same as above, but check for italic font. Actually this also catches
  6492. % non-italic slanted fonts since it is impossible to distinguish them from
  6493. % italic fonts. But since this is only used by $ and it uses \sl anyway
  6494. % this is not a problem.
  6495. \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
  6496. % Turn off all special characters except @
  6497. % (and those which the user can use as if they were ordinary).
  6498. % Most of these we simply print from the \tt font, but for some, we can
  6499. % use math or other variants that look better in normal text.
  6500. \catcode`\"=\active
  6501. \def\activedoublequote{{\tt\char34}}
  6502. \let"=\activedoublequote
  6503. \catcode`\~=\active
  6504. \def~{{\tt\char126}}
  6505. \chardef\hat=`\^
  6506. \catcode`\^=\active
  6507. \def^{{\tt \hat}}
  6508. \catcode`\_=\active
  6509. \def_{\ifusingtt\normalunderscore\_}
  6510. \let\realunder=_
  6511. % Subroutine for the previous macro.
  6512. \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
  6513. \catcode`\|=\active
  6514. \def|{{\tt\char124}}
  6515. \chardef \less=`\<
  6516. \catcode`\<=\active
  6517. \def<{{\tt \less}}
  6518. \chardef \gtr=`\>
  6519. \catcode`\>=\active
  6520. \def>{{\tt \gtr}}
  6521. \catcode`\+=\active
  6522. \def+{{\tt \char 43}}
  6523. \catcode`\$=\active
  6524. \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
  6525. % If a .fmt file is being used, characters that might appear in a file
  6526. % name cannot be active until we have parsed the command line.
  6527. % So turn them off again, and have \everyjob (or @setfilename) turn them on.
  6528. % \otherifyactive is called near the end of this file.
  6529. \def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
  6530. \catcode`\@=0
  6531. % \backslashcurfont outputs one backslash character in current font,
  6532. % as in \char`\\.
  6533. \global\chardef\backslashcurfont=`\\
  6534. \global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work
  6535. % \rawbackslash defines an active \ to do \backslashcurfont.
  6536. % \otherbackslash defines an active \ to be a literal `\' character with
  6537. % catcode other.
  6538. {\catcode`\\=\active
  6539. @gdef@rawbackslash{@let\=@backslashcurfont}
  6540. @gdef@otherbackslash{@let\=@realbackslash}
  6541. }
  6542. % \realbackslash is an actual character `\' with catcode other, and
  6543. % \doublebackslash is two of them (for the pdf outlines).
  6544. {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
  6545. % \normalbackslash outputs one backslash in fixed width font.
  6546. \def\normalbackslash{{\tt\backslashcurfont}}
  6547. \catcode`\\=\active
  6548. % Used sometimes to turn off (effectively) the active characters
  6549. % even after parsing them.
  6550. @def@turnoffactive{%
  6551. @let"=@normaldoublequote
  6552. @let\=@realbackslash
  6553. @let~=@normaltilde
  6554. @let^=@normalcaret
  6555. @let_=@normalunderscore
  6556. @let|=@normalverticalbar
  6557. @let<=@normalless
  6558. @let>=@normalgreater
  6559. @let+=@normalplus
  6560. @let$=@normaldollar %$ font-lock fix
  6561. @unsepspaces
  6562. }
  6563. % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
  6564. % the literal character `\'. (Thus, \ is not expandable when this is in
  6565. % effect.)
  6566. %
  6567. @def@normalturnoffactive{@turnoffactive @let\=@normalbackslash}
  6568. % Make _ and + \other characters, temporarily.
  6569. % This is canceled by @fixbackslash.
  6570. @otherifyactive
  6571. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  6572. % That is what \eatinput is for; after that, the `\' should revert to printing
  6573. % a backslash.
  6574. %
  6575. @gdef@eatinput input texinfo{@fixbackslash}
  6576. @global@let\ = @eatinput
  6577. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  6578. % the first `\{ in the file would cause an error. This macro tries to fix
  6579. % that, assuming it is called before the first `\' could plausibly occur.
  6580. % Also turn back on active characters that might appear in the input
  6581. % file name, in case not using a pre-dumped format.
  6582. %
  6583. @gdef@fixbackslash{%
  6584. @ifx\@eatinput @let\ = @normalbackslash @fi
  6585. @catcode`+=@active
  6586. @catcode`@_=@active
  6587. }
  6588. % Say @foo, not \foo, in error messages.
  6589. @escapechar = `@@
  6590. % These look ok in all fonts, so just make them not special.
  6591. @catcode`@& = @other
  6592. @catcode`@# = @other
  6593. @catcode`@% = @other
  6594. @c Local variables:
  6595. @c eval: (add-hook 'write-file-hooks 'time-stamp)
  6596. @c page-delimiter: "^\\\\message"
  6597. @c time-stamp-start: "def\\\\texinfoversion{"
  6598. @c time-stamp-format: "%:y-%02m-%02d.%02H"
  6599. @c time-stamp-end: "}"
  6600. @c End:
  6601. @c vim:sw=2:
  6602. @ignore
  6603. arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
  6604. @end ignore