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

7226 lines
226 KiB

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