PageRenderTime 95ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/contrib/groff/doc/texinfo.tex

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