annotate src/fftw-3.3.5/doc/texinfo.tex @ 42:2cd0e3b3e1fd

Current fftw source
author Chris Cannam
date Tue, 18 Oct 2016 13:40:26 +0100
parents
children
rev   line source
Chris@42 1 % texinfo.tex -- TeX macros to handle Texinfo files.
Chris@42 2 %
Chris@42 3 % Load plain if necessary, i.e., if running under initex.
Chris@42 4 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
Chris@42 5 %
Chris@42 6 \def\texinfoversion{2013-02-01.11}
Chris@42 7 %
Chris@42 8 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
Chris@42 9 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
Chris@42 10 % 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
Chris@42 11 %
Chris@42 12 % This texinfo.tex file is free software: you can redistribute it and/or
Chris@42 13 % modify it under the terms of the GNU General Public License as
Chris@42 14 % published by the Free Software Foundation, either version 3 of the
Chris@42 15 % License, or (at your option) any later version.
Chris@42 16 %
Chris@42 17 % This texinfo.tex file is distributed in the hope that it will be
Chris@42 18 % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
Chris@42 19 % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Chris@42 20 % General Public License for more details.
Chris@42 21 %
Chris@42 22 % You should have received a copy of the GNU General Public License
Chris@42 23 % along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@42 24 %
Chris@42 25 % As a special exception, when this file is read by TeX when processing
Chris@42 26 % a Texinfo source document, you may use the result without
Chris@42 27 % restriction. This Exception is an additional permission under section 7
Chris@42 28 % of the GNU General Public License, version 3 ("GPLv3").
Chris@42 29 %
Chris@42 30 % Please try the latest version of texinfo.tex before submitting bug
Chris@42 31 % reports; you can get the latest version from:
Chris@42 32 % http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
Chris@42 33 % http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
Chris@42 34 % http://www.gnu.org/software/texinfo/ (the Texinfo home page)
Chris@42 35 % The texinfo.tex in any given distribution could well be out
Chris@42 36 % of date, so if that's what you're using, please check.
Chris@42 37 %
Chris@42 38 % Send bug reports to bug-texinfo@gnu.org. Please include including a
Chris@42 39 % complete document in each bug report with which we can reproduce the
Chris@42 40 % problem. Patches are, of course, greatly appreciated.
Chris@42 41 %
Chris@42 42 % To process a Texinfo manual with TeX, it's most reliable to use the
Chris@42 43 % texi2dvi shell script that comes with the distribution. For a simple
Chris@42 44 % manual foo.texi, however, you can get away with this:
Chris@42 45 % tex foo.texi
Chris@42 46 % texindex foo.??
Chris@42 47 % tex foo.texi
Chris@42 48 % tex foo.texi
Chris@42 49 % dvips foo.dvi -o # or whatever; this makes foo.ps.
Chris@42 50 % The extra TeX runs get the cross-reference information correct.
Chris@42 51 % Sometimes one run after texindex suffices, and sometimes you need more
Chris@42 52 % than two; texi2dvi does it as many times as necessary.
Chris@42 53 %
Chris@42 54 % It is possible to adapt texinfo.tex for other languages, to some
Chris@42 55 % extent. You can get the existing language-specific files from the
Chris@42 56 % full Texinfo distribution.
Chris@42 57 %
Chris@42 58 % The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
Chris@42 59
Chris@42 60
Chris@42 61 \message{Loading texinfo [version \texinfoversion]:}
Chris@42 62
Chris@42 63 % If in a .fmt file, print the version number
Chris@42 64 % and turn on active characters that we couldn't do earlier because
Chris@42 65 % they might have appeared in the input file name.
Chris@42 66 \everyjob{\message{[Texinfo version \texinfoversion]}%
Chris@42 67 \catcode`+=\active \catcode`\_=\active}
Chris@42 68
Chris@42 69 \chardef\other=12
Chris@42 70
Chris@42 71 % We never want plain's \outer definition of \+ in Texinfo.
Chris@42 72 % For @tex, we can use \tabalign.
Chris@42 73 \let\+ = \relax
Chris@42 74
Chris@42 75 % Save some plain tex macros whose names we will redefine.
Chris@42 76 \let\ptexb=\b
Chris@42 77 \let\ptexbullet=\bullet
Chris@42 78 \let\ptexc=\c
Chris@42 79 \let\ptexcomma=\,
Chris@42 80 \let\ptexdot=\.
Chris@42 81 \let\ptexdots=\dots
Chris@42 82 \let\ptexend=\end
Chris@42 83 \let\ptexequiv=\equiv
Chris@42 84 \let\ptexexclam=\!
Chris@42 85 \let\ptexfootnote=\footnote
Chris@42 86 \let\ptexgtr=>
Chris@42 87 \let\ptexhat=^
Chris@42 88 \let\ptexi=\i
Chris@42 89 \let\ptexindent=\indent
Chris@42 90 \let\ptexinsert=\insert
Chris@42 91 \let\ptexlbrace=\{
Chris@42 92 \let\ptexless=<
Chris@42 93 \let\ptexnewwrite\newwrite
Chris@42 94 \let\ptexnoindent=\noindent
Chris@42 95 \let\ptexplus=+
Chris@42 96 \let\ptexraggedright=\raggedright
Chris@42 97 \let\ptexrbrace=\}
Chris@42 98 \let\ptexslash=\/
Chris@42 99 \let\ptexstar=\*
Chris@42 100 \let\ptext=\t
Chris@42 101 \let\ptextop=\top
Chris@42 102 {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
Chris@42 103
Chris@42 104 % If this character appears in an error message or help string, it
Chris@42 105 % starts a new line in the output.
Chris@42 106 \newlinechar = `^^J
Chris@42 107
Chris@42 108 % Use TeX 3.0's \inputlineno to get the line number, for better error
Chris@42 109 % messages, but if we're using an old version of TeX, don't do anything.
Chris@42 110 %
Chris@42 111 \ifx\inputlineno\thisisundefined
Chris@42 112 \let\linenumber = \empty % Pre-3.0.
Chris@42 113 \else
Chris@42 114 \def\linenumber{l.\the\inputlineno:\space}
Chris@42 115 \fi
Chris@42 116
Chris@42 117 % Set up fixed words for English if not already set.
Chris@42 118 \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
Chris@42 119 \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
Chris@42 120 \ifx\putworderror\undefined \gdef\putworderror{error}\fi
Chris@42 121 \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
Chris@42 122 \ifx\putwordin\undefined \gdef\putwordin{in}\fi
Chris@42 123 \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
Chris@42 124 \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
Chris@42 125 \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
Chris@42 126 \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
Chris@42 127 \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
Chris@42 128 \ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi
Chris@42 129 \ifx\putwordof\undefined \gdef\putwordof{of}\fi
Chris@42 130 \ifx\putwordon\undefined \gdef\putwordon{on}\fi
Chris@42 131 \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi
Chris@42 132 \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi
Chris@42 133 \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi
Chris@42 134 \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi
Chris@42 135 \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi
Chris@42 136 \ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi
Chris@42 137 \ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi
Chris@42 138 %
Chris@42 139 \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
Chris@42 140 \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
Chris@42 141 \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
Chris@42 142 \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
Chris@42 143 \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
Chris@42 144 \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
Chris@42 145 \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
Chris@42 146 \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
Chris@42 147 \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
Chris@42 148 \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
Chris@42 149 \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
Chris@42 150 \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
Chris@42 151 %
Chris@42 152 \ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi
Chris@42 153 \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi
Chris@42 154 \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi
Chris@42 155 \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi
Chris@42 156 \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi
Chris@42 157
Chris@42 158 % Since the category of space is not known, we have to be careful.
Chris@42 159 \chardef\spacecat = 10
Chris@42 160 \def\spaceisspace{\catcode`\ =\spacecat}
Chris@42 161
Chris@42 162 % sometimes characters are active, so we need control sequences.
Chris@42 163 \chardef\ampChar = `\&
Chris@42 164 \chardef\colonChar = `\:
Chris@42 165 \chardef\commaChar = `\,
Chris@42 166 \chardef\dashChar = `\-
Chris@42 167 \chardef\dotChar = `\.
Chris@42 168 \chardef\exclamChar= `\!
Chris@42 169 \chardef\hashChar = `\#
Chris@42 170 \chardef\lquoteChar= `\`
Chris@42 171 \chardef\questChar = `\?
Chris@42 172 \chardef\rquoteChar= `\'
Chris@42 173 \chardef\semiChar = `\;
Chris@42 174 \chardef\slashChar = `\/
Chris@42 175 \chardef\underChar = `\_
Chris@42 176
Chris@42 177 % Ignore a token.
Chris@42 178 %
Chris@42 179 \def\gobble#1{}
Chris@42 180
Chris@42 181 % The following is used inside several \edef's.
Chris@42 182 \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
Chris@42 183
Chris@42 184 % Hyphenation fixes.
Chris@42 185 \hyphenation{
Chris@42 186 Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
Chris@42 187 ap-pen-dix bit-map bit-maps
Chris@42 188 data-base data-bases eshell fall-ing half-way long-est man-u-script
Chris@42 189 man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
Chris@42 190 par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
Chris@42 191 spell-ing spell-ings
Chris@42 192 stand-alone strong-est time-stamp time-stamps which-ever white-space
Chris@42 193 wide-spread wrap-around
Chris@42 194 }
Chris@42 195
Chris@42 196 % Margin to add to right of even pages, to left of odd pages.
Chris@42 197 \newdimen\bindingoffset
Chris@42 198 \newdimen\normaloffset
Chris@42 199 \newdimen\pagewidth \newdimen\pageheight
Chris@42 200
Chris@42 201 % For a final copy, take out the rectangles
Chris@42 202 % that mark overfull boxes (in case you have decided
Chris@42 203 % that the text looks ok even though it passes the margin).
Chris@42 204 %
Chris@42 205 \def\finalout{\overfullrule=0pt }
Chris@42 206
Chris@42 207 % Sometimes it is convenient to have everything in the transcript file
Chris@42 208 % and nothing on the terminal. We don't just call \tracingall here,
Chris@42 209 % since that produces some useless output on the terminal. We also make
Chris@42 210 % some effort to order the tracing commands to reduce output in the log
Chris@42 211 % file; cf. trace.sty in LaTeX.
Chris@42 212 %
Chris@42 213 \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
Chris@42 214 \def\loggingall{%
Chris@42 215 \tracingstats2
Chris@42 216 \tracingpages1
Chris@42 217 \tracinglostchars2 % 2 gives us more in etex
Chris@42 218 \tracingparagraphs1
Chris@42 219 \tracingoutput1
Chris@42 220 \tracingmacros2
Chris@42 221 \tracingrestores1
Chris@42 222 \showboxbreadth\maxdimen \showboxdepth\maxdimen
Chris@42 223 \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
Chris@42 224 \tracingscantokens1
Chris@42 225 \tracingifs1
Chris@42 226 \tracinggroups1
Chris@42 227 \tracingnesting2
Chris@42 228 \tracingassigns1
Chris@42 229 \fi
Chris@42 230 \tracingcommands3 % 3 gives us more in etex
Chris@42 231 \errorcontextlines16
Chris@42 232 }%
Chris@42 233
Chris@42 234 % @errormsg{MSG}. Do the index-like expansions on MSG, but if things
Chris@42 235 % aren't perfect, it's not the end of the world, being an error message,
Chris@42 236 % after all.
Chris@42 237 %
Chris@42 238 \def\errormsg{\begingroup \indexnofonts \doerrormsg}
Chris@42 239 \def\doerrormsg#1{\errmessage{#1}}
Chris@42 240
Chris@42 241 % add check for \lastpenalty to plain's definitions. If the last thing
Chris@42 242 % we did was a \nobreak, we don't want to insert more space.
Chris@42 243 %
Chris@42 244 \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
Chris@42 245 \removelastskip\penalty-50\smallskip\fi\fi}
Chris@42 246 \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
Chris@42 247 \removelastskip\penalty-100\medskip\fi\fi}
Chris@42 248 \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
Chris@42 249 \removelastskip\penalty-200\bigskip\fi\fi}
Chris@42 250
Chris@42 251 % Do @cropmarks to get crop marks.
Chris@42 252 %
Chris@42 253 \newif\ifcropmarks
Chris@42 254 \let\cropmarks = \cropmarkstrue
Chris@42 255 %
Chris@42 256 % Dimensions to add cropmarks at corners.
Chris@42 257 % Added by P. A. MacKay, 12 Nov. 1986
Chris@42 258 %
Chris@42 259 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
Chris@42 260 \newdimen\cornerlong \cornerlong=1pc
Chris@42 261 \newdimen\cornerthick \cornerthick=.3pt
Chris@42 262 \newdimen\topandbottommargin \topandbottommargin=.75in
Chris@42 263
Chris@42 264 % Output a mark which sets \thischapter, \thissection and \thiscolor.
Chris@42 265 % We dump everything together because we only have one kind of mark.
Chris@42 266 % This works because we only use \botmark / \topmark, not \firstmark.
Chris@42 267 %
Chris@42 268 % A mark contains a subexpression of the \ifcase ... \fi construct.
Chris@42 269 % \get*marks macros below extract the needed part using \ifcase.
Chris@42 270 %
Chris@42 271 % Another complication is to let the user choose whether \thischapter
Chris@42 272 % (\thissection) refers to the chapter (section) in effect at the top
Chris@42 273 % of a page, or that at the bottom of a page. The solution is
Chris@42 274 % described on page 260 of The TeXbook. It involves outputting two
Chris@42 275 % marks for the sectioning macros, one before the section break, and
Chris@42 276 % one after. I won't pretend I can describe this better than DEK...
Chris@42 277 \def\domark{%
Chris@42 278 \toks0=\expandafter{\lastchapterdefs}%
Chris@42 279 \toks2=\expandafter{\lastsectiondefs}%
Chris@42 280 \toks4=\expandafter{\prevchapterdefs}%
Chris@42 281 \toks6=\expandafter{\prevsectiondefs}%
Chris@42 282 \toks8=\expandafter{\lastcolordefs}%
Chris@42 283 \mark{%
Chris@42 284 \the\toks0 \the\toks2
Chris@42 285 \noexpand\or \the\toks4 \the\toks6
Chris@42 286 \noexpand\else \the\toks8
Chris@42 287 }%
Chris@42 288 }
Chris@42 289 % \topmark doesn't work for the very first chapter (after the title
Chris@42 290 % page or the contents), so we use \firstmark there -- this gets us
Chris@42 291 % the mark with the chapter defs, unless the user sneaks in, e.g.,
Chris@42 292 % @setcolor (or @url, or @link, etc.) between @contents and the very
Chris@42 293 % first @chapter.
Chris@42 294 \def\gettopheadingmarks{%
Chris@42 295 \ifcase0\topmark\fi
Chris@42 296 \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
Chris@42 297 }
Chris@42 298 \def\getbottomheadingmarks{\ifcase1\botmark\fi}
Chris@42 299 \def\getcolormarks{\ifcase2\topmark\fi}
Chris@42 300
Chris@42 301 % Avoid "undefined control sequence" errors.
Chris@42 302 \def\lastchapterdefs{}
Chris@42 303 \def\lastsectiondefs{}
Chris@42 304 \def\prevchapterdefs{}
Chris@42 305 \def\prevsectiondefs{}
Chris@42 306 \def\lastcolordefs{}
Chris@42 307
Chris@42 308 % Main output routine.
Chris@42 309 \chardef\PAGE = 255
Chris@42 310 \output = {\onepageout{\pagecontents\PAGE}}
Chris@42 311
Chris@42 312 \newbox\headlinebox
Chris@42 313 \newbox\footlinebox
Chris@42 314
Chris@42 315 % \onepageout takes a vbox as an argument. Note that \pagecontents
Chris@42 316 % does insertions, but you have to call it yourself.
Chris@42 317 \def\onepageout#1{%
Chris@42 318 \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
Chris@42 319 %
Chris@42 320 \ifodd\pageno \advance\hoffset by \bindingoffset
Chris@42 321 \else \advance\hoffset by -\bindingoffset\fi
Chris@42 322 %
Chris@42 323 % Do this outside of the \shipout so @code etc. will be expanded in
Chris@42 324 % the headline as they should be, not taken literally (outputting ''code).
Chris@42 325 \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
Chris@42 326 \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
Chris@42 327 \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
Chris@42 328 \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
Chris@42 329 %
Chris@42 330 {%
Chris@42 331 % Have to do this stuff outside the \shipout because we want it to
Chris@42 332 % take effect in \write's, yet the group defined by the \vbox ends
Chris@42 333 % before the \shipout runs.
Chris@42 334 %
Chris@42 335 \indexdummies % don't expand commands in the output.
Chris@42 336 \normalturnoffactive % \ in index entries must not stay \, e.g., if
Chris@42 337 % the page break happens to be in the middle of an example.
Chris@42 338 % We don't want .vr (or whatever) entries like this:
Chris@42 339 % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
Chris@42 340 % "\acronym" won't work when it's read back in;
Chris@42 341 % it needs to be
Chris@42 342 % {\code {{\tt \backslashcurfont }acronym}
Chris@42 343 \shipout\vbox{%
Chris@42 344 % Do this early so pdf references go to the beginning of the page.
Chris@42 345 \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
Chris@42 346 %
Chris@42 347 \ifcropmarks \vbox to \outervsize\bgroup
Chris@42 348 \hsize = \outerhsize
Chris@42 349 \vskip-\topandbottommargin
Chris@42 350 \vtop to0pt{%
Chris@42 351 \line{\ewtop\hfil\ewtop}%
Chris@42 352 \nointerlineskip
Chris@42 353 \line{%
Chris@42 354 \vbox{\moveleft\cornerthick\nstop}%
Chris@42 355 \hfill
Chris@42 356 \vbox{\moveright\cornerthick\nstop}%
Chris@42 357 }%
Chris@42 358 \vss}%
Chris@42 359 \vskip\topandbottommargin
Chris@42 360 \line\bgroup
Chris@42 361 \hfil % center the page within the outer (page) hsize.
Chris@42 362 \ifodd\pageno\hskip\bindingoffset\fi
Chris@42 363 \vbox\bgroup
Chris@42 364 \fi
Chris@42 365 %
Chris@42 366 \unvbox\headlinebox
Chris@42 367 \pagebody{#1}%
Chris@42 368 \ifdim\ht\footlinebox > 0pt
Chris@42 369 % Only leave this space if the footline is nonempty.
Chris@42 370 % (We lessened \vsize for it in \oddfootingyyy.)
Chris@42 371 % The \baselineskip=24pt in plain's \makefootline has no effect.
Chris@42 372 \vskip 24pt
Chris@42 373 \unvbox\footlinebox
Chris@42 374 \fi
Chris@42 375 %
Chris@42 376 \ifcropmarks
Chris@42 377 \egroup % end of \vbox\bgroup
Chris@42 378 \hfil\egroup % end of (centering) \line\bgroup
Chris@42 379 \vskip\topandbottommargin plus1fill minus1fill
Chris@42 380 \boxmaxdepth = \cornerthick
Chris@42 381 \vbox to0pt{\vss
Chris@42 382 \line{%
Chris@42 383 \vbox{\moveleft\cornerthick\nsbot}%
Chris@42 384 \hfill
Chris@42 385 \vbox{\moveright\cornerthick\nsbot}%
Chris@42 386 }%
Chris@42 387 \nointerlineskip
Chris@42 388 \line{\ewbot\hfil\ewbot}%
Chris@42 389 }%
Chris@42 390 \egroup % \vbox from first cropmarks clause
Chris@42 391 \fi
Chris@42 392 }% end of \shipout\vbox
Chris@42 393 }% end of group with \indexdummies
Chris@42 394 \advancepageno
Chris@42 395 \ifnum\outputpenalty>-20000 \else\dosupereject\fi
Chris@42 396 }
Chris@42 397
Chris@42 398 \newinsert\margin \dimen\margin=\maxdimen
Chris@42 399
Chris@42 400 \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
Chris@42 401 {\catcode`\@ =11
Chris@42 402 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
Chris@42 403 % marginal hacks, juha@viisa.uucp (Juha Takala)
Chris@42 404 \ifvoid\margin\else % marginal info is present
Chris@42 405 \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
Chris@42 406 \dimen@=\dp#1\relax \unvbox#1\relax
Chris@42 407 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
Chris@42 408 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
Chris@42 409 }
Chris@42 410
Chris@42 411 % Here are the rules for the cropmarks. Note that they are
Chris@42 412 % offset so that the space between them is truly \outerhsize or \outervsize
Chris@42 413 % (P. A. MacKay, 12 November, 1986)
Chris@42 414 %
Chris@42 415 \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
Chris@42 416 \def\nstop{\vbox
Chris@42 417 {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
Chris@42 418 \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
Chris@42 419 \def\nsbot{\vbox
Chris@42 420 {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
Chris@42 421
Chris@42 422 % Parse an argument, then pass it to #1. The argument is the rest of
Chris@42 423 % the input line (except we remove a trailing comment). #1 should be a
Chris@42 424 % macro which expects an ordinary undelimited TeX argument.
Chris@42 425 %
Chris@42 426 \def\parsearg{\parseargusing{}}
Chris@42 427 \def\parseargusing#1#2{%
Chris@42 428 \def\argtorun{#2}%
Chris@42 429 \begingroup
Chris@42 430 \obeylines
Chris@42 431 \spaceisspace
Chris@42 432 #1%
Chris@42 433 \parseargline\empty% Insert the \empty token, see \finishparsearg below.
Chris@42 434 }
Chris@42 435
Chris@42 436 {\obeylines %
Chris@42 437 \gdef\parseargline#1^^M{%
Chris@42 438 \endgroup % End of the group started in \parsearg.
Chris@42 439 \argremovecomment #1\comment\ArgTerm%
Chris@42 440 }%
Chris@42 441 }
Chris@42 442
Chris@42 443 % First remove any @comment, then any @c comment.
Chris@42 444 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
Chris@42 445 \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
Chris@42 446
Chris@42 447 % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
Chris@42 448 %
Chris@42 449 % \argremovec might leave us with trailing space, e.g.,
Chris@42 450 % @end itemize @c foo
Chris@42 451 % This space token undergoes the same procedure and is eventually removed
Chris@42 452 % by \finishparsearg.
Chris@42 453 %
Chris@42 454 \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
Chris@42 455 \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
Chris@42 456 \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
Chris@42 457 \def\temp{#3}%
Chris@42 458 \ifx\temp\empty
Chris@42 459 % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
Chris@42 460 \let\temp\finishparsearg
Chris@42 461 \else
Chris@42 462 \let\temp\argcheckspaces
Chris@42 463 \fi
Chris@42 464 % Put the space token in:
Chris@42 465 \temp#1 #3\ArgTerm
Chris@42 466 }
Chris@42 467
Chris@42 468 % If a _delimited_ argument is enclosed in braces, they get stripped; so
Chris@42 469 % to get _exactly_ the rest of the line, we had to prevent such situation.
Chris@42 470 % We prepended an \empty token at the very beginning and we expand it now,
Chris@42 471 % just before passing the control to \argtorun.
Chris@42 472 % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
Chris@42 473 % either the null string, or it ends with \^^M---thus there is no danger
Chris@42 474 % that a pair of braces would be stripped.
Chris@42 475 %
Chris@42 476 % But first, we have to remove the trailing space token.
Chris@42 477 %
Chris@42 478 \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
Chris@42 479
Chris@42 480 % \parseargdef\foo{...}
Chris@42 481 % is roughly equivalent to
Chris@42 482 % \def\foo{\parsearg\Xfoo}
Chris@42 483 % \def\Xfoo#1{...}
Chris@42 484 %
Chris@42 485 % Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
Chris@42 486 % favourite TeX trick. --kasal, 16nov03
Chris@42 487
Chris@42 488 \def\parseargdef#1{%
Chris@42 489 \expandafter \doparseargdef \csname\string#1\endcsname #1%
Chris@42 490 }
Chris@42 491 \def\doparseargdef#1#2{%
Chris@42 492 \def#2{\parsearg#1}%
Chris@42 493 \def#1##1%
Chris@42 494 }
Chris@42 495
Chris@42 496 % Several utility definitions with active space:
Chris@42 497 {
Chris@42 498 \obeyspaces
Chris@42 499 \gdef\obeyedspace{ }
Chris@42 500
Chris@42 501 % Make each space character in the input produce a normal interword
Chris@42 502 % space in the output. Don't allow a line break at this space, as this
Chris@42 503 % is used only in environments like @example, where each line of input
Chris@42 504 % should produce a line of output anyway.
Chris@42 505 %
Chris@42 506 \gdef\sepspaces{\obeyspaces\let =\tie}
Chris@42 507
Chris@42 508 % If an index command is used in an @example environment, any spaces
Chris@42 509 % therein should become regular spaces in the raw index file, not the
Chris@42 510 % expansion of \tie (\leavevmode \penalty \@M \ ).
Chris@42 511 \gdef\unsepspaces{\let =\space}
Chris@42 512 }
Chris@42 513
Chris@42 514
Chris@42 515 \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
Chris@42 516
Chris@42 517 % Define the framework for environments in texinfo.tex. It's used like this:
Chris@42 518 %
Chris@42 519 % \envdef\foo{...}
Chris@42 520 % \def\Efoo{...}
Chris@42 521 %
Chris@42 522 % It's the responsibility of \envdef to insert \begingroup before the
Chris@42 523 % actual body; @end closes the group after calling \Efoo. \envdef also
Chris@42 524 % defines \thisenv, so the current environment is known; @end checks
Chris@42 525 % whether the environment name matches. The \checkenv macro can also be
Chris@42 526 % used to check whether the current environment is the one expected.
Chris@42 527 %
Chris@42 528 % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
Chris@42 529 % are not treated as environments; they don't open a group. (The
Chris@42 530 % implementation of @end takes care not to call \endgroup in this
Chris@42 531 % special case.)
Chris@42 532
Chris@42 533
Chris@42 534 % At run-time, environments start with this:
Chris@42 535 \def\startenvironment#1{\begingroup\def\thisenv{#1}}
Chris@42 536 % initialize
Chris@42 537 \let\thisenv\empty
Chris@42 538
Chris@42 539 % ... but they get defined via ``\envdef\foo{...}'':
Chris@42 540 \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
Chris@42 541 \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
Chris@42 542
Chris@42 543 % Check whether we're in the right environment:
Chris@42 544 \def\checkenv#1{%
Chris@42 545 \def\temp{#1}%
Chris@42 546 \ifx\thisenv\temp
Chris@42 547 \else
Chris@42 548 \badenverr
Chris@42 549 \fi
Chris@42 550 }
Chris@42 551
Chris@42 552 % Environment mismatch, #1 expected:
Chris@42 553 \def\badenverr{%
Chris@42 554 \errhelp = \EMsimple
Chris@42 555 \errmessage{This command can appear only \inenvironment\temp,
Chris@42 556 not \inenvironment\thisenv}%
Chris@42 557 }
Chris@42 558 \def\inenvironment#1{%
Chris@42 559 \ifx#1\empty
Chris@42 560 outside of any environment%
Chris@42 561 \else
Chris@42 562 in environment \expandafter\string#1%
Chris@42 563 \fi
Chris@42 564 }
Chris@42 565
Chris@42 566 % @end foo executes the definition of \Efoo.
Chris@42 567 % But first, it executes a specialized version of \checkenv
Chris@42 568 %
Chris@42 569 \parseargdef\end{%
Chris@42 570 \if 1\csname iscond.#1\endcsname
Chris@42 571 \else
Chris@42 572 % The general wording of \badenverr may not be ideal.
Chris@42 573 \expandafter\checkenv\csname#1\endcsname
Chris@42 574 \csname E#1\endcsname
Chris@42 575 \endgroup
Chris@42 576 \fi
Chris@42 577 }
Chris@42 578
Chris@42 579 \newhelp\EMsimple{Press RETURN to continue.}
Chris@42 580
Chris@42 581
Chris@42 582 % Be sure we're in horizontal mode when doing a tie, since we make space
Chris@42 583 % equivalent to this in @example-like environments. Otherwise, a space
Chris@42 584 % at the beginning of a line will start with \penalty -- and
Chris@42 585 % since \penalty is valid in vertical mode, we'd end up putting the
Chris@42 586 % penalty on the vertical list instead of in the new paragraph.
Chris@42 587 {\catcode`@ = 11
Chris@42 588 % Avoid using \@M directly, because that causes trouble
Chris@42 589 % if the definition is written into an index file.
Chris@42 590 \global\let\tiepenalty = \@M
Chris@42 591 \gdef\tie{\leavevmode\penalty\tiepenalty\ }
Chris@42 592 }
Chris@42 593
Chris@42 594 % @: forces normal size whitespace following.
Chris@42 595 \def\:{\spacefactor=1000 }
Chris@42 596
Chris@42 597 % @* forces a line break.
Chris@42 598 \def\*{\unskip\hfil\break\hbox{}\ignorespaces}
Chris@42 599
Chris@42 600 % @/ allows a line break.
Chris@42 601 \let\/=\allowbreak
Chris@42 602
Chris@42 603 % @. is an end-of-sentence period.
Chris@42 604 \def\.{.\spacefactor=\endofsentencespacefactor\space}
Chris@42 605
Chris@42 606 % @! is an end-of-sentence bang.
Chris@42 607 \def\!{!\spacefactor=\endofsentencespacefactor\space}
Chris@42 608
Chris@42 609 % @? is an end-of-sentence query.
Chris@42 610 \def\?{?\spacefactor=\endofsentencespacefactor\space}
Chris@42 611
Chris@42 612 % @frenchspacing on|off says whether to put extra space after punctuation.
Chris@42 613 %
Chris@42 614 \def\onword{on}
Chris@42 615 \def\offword{off}
Chris@42 616 %
Chris@42 617 \parseargdef\frenchspacing{%
Chris@42 618 \def\temp{#1}%
Chris@42 619 \ifx\temp\onword \plainfrenchspacing
Chris@42 620 \else\ifx\temp\offword \plainnonfrenchspacing
Chris@42 621 \else
Chris@42 622 \errhelp = \EMsimple
Chris@42 623 \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
Chris@42 624 \fi\fi
Chris@42 625 }
Chris@42 626
Chris@42 627 % @w prevents a word break. Without the \leavevmode, @w at the
Chris@42 628 % beginning of a paragraph, when TeX is still in vertical mode, would
Chris@42 629 % produce a whole line of output instead of starting the paragraph.
Chris@42 630 \def\w#1{\leavevmode\hbox{#1}}
Chris@42 631
Chris@42 632 % @group ... @end group forces ... to be all on one page, by enclosing
Chris@42 633 % it in a TeX vbox. We use \vtop instead of \vbox to construct the box
Chris@42 634 % to keep its height that of a normal line. According to the rules for
Chris@42 635 % \topskip (p.114 of the TeXbook), the glue inserted is
Chris@42 636 % max (\topskip - \ht (first item), 0). If that height is large,
Chris@42 637 % therefore, no glue is inserted, and the space between the headline and
Chris@42 638 % the text is small, which looks bad.
Chris@42 639 %
Chris@42 640 % Another complication is that the group might be very large. This can
Chris@42 641 % cause the glue on the previous page to be unduly stretched, because it
Chris@42 642 % does not have much material. In this case, it's better to add an
Chris@42 643 % explicit \vfill so that the extra space is at the bottom. The
Chris@42 644 % threshold for doing this is if the group is more than \vfilllimit
Chris@42 645 % percent of a page (\vfilllimit can be changed inside of @tex).
Chris@42 646 %
Chris@42 647 \newbox\groupbox
Chris@42 648 \def\vfilllimit{0.7}
Chris@42 649 %
Chris@42 650 \envdef\group{%
Chris@42 651 \ifnum\catcode`\^^M=\active \else
Chris@42 652 \errhelp = \groupinvalidhelp
Chris@42 653 \errmessage{@group invalid in context where filling is enabled}%
Chris@42 654 \fi
Chris@42 655 \startsavinginserts
Chris@42 656 %
Chris@42 657 \setbox\groupbox = \vtop\bgroup
Chris@42 658 % Do @comment since we are called inside an environment such as
Chris@42 659 % @example, where each end-of-line in the input causes an
Chris@42 660 % end-of-line in the output. We don't want the end-of-line after
Chris@42 661 % the `@group' to put extra space in the output. Since @group
Chris@42 662 % should appear on a line by itself (according to the Texinfo
Chris@42 663 % manual), we don't worry about eating any user text.
Chris@42 664 \comment
Chris@42 665 }
Chris@42 666 %
Chris@42 667 % The \vtop produces a box with normal height and large depth; thus, TeX puts
Chris@42 668 % \baselineskip glue before it, and (when the next line of text is done)
Chris@42 669 % \lineskip glue after it. Thus, space below is not quite equal to space
Chris@42 670 % above. But it's pretty close.
Chris@42 671 \def\Egroup{%
Chris@42 672 % To get correct interline space between the last line of the group
Chris@42 673 % and the first line afterwards, we have to propagate \prevdepth.
Chris@42 674 \endgraf % Not \par, as it may have been set to \lisppar.
Chris@42 675 \global\dimen1 = \prevdepth
Chris@42 676 \egroup % End the \vtop.
Chris@42 677 % \dimen0 is the vertical size of the group's box.
Chris@42 678 \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox
Chris@42 679 % \dimen2 is how much space is left on the page (more or less).
Chris@42 680 \dimen2 = \pageheight \advance\dimen2 by -\pagetotal
Chris@42 681 % if the group doesn't fit on the current page, and it's a big big
Chris@42 682 % group, force a page break.
Chris@42 683 \ifdim \dimen0 > \dimen2
Chris@42 684 \ifdim \pagetotal < \vfilllimit\pageheight
Chris@42 685 \page
Chris@42 686 \fi
Chris@42 687 \fi
Chris@42 688 \box\groupbox
Chris@42 689 \prevdepth = \dimen1
Chris@42 690 \checkinserts
Chris@42 691 }
Chris@42 692 %
Chris@42 693 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
Chris@42 694 % message, so this ends up printing `@group can only ...'.
Chris@42 695 %
Chris@42 696 \newhelp\groupinvalidhelp{%
Chris@42 697 group can only be used in environments such as @example,^^J%
Chris@42 698 where each line of input produces a line of output.}
Chris@42 699
Chris@42 700 % @need space-in-mils
Chris@42 701 % forces a page break if there is not space-in-mils remaining.
Chris@42 702
Chris@42 703 \newdimen\mil \mil=0.001in
Chris@42 704
Chris@42 705 \parseargdef\need{%
Chris@42 706 % Ensure vertical mode, so we don't make a big box in the middle of a
Chris@42 707 % paragraph.
Chris@42 708 \par
Chris@42 709 %
Chris@42 710 % If the @need value is less than one line space, it's useless.
Chris@42 711 \dimen0 = #1\mil
Chris@42 712 \dimen2 = \ht\strutbox
Chris@42 713 \advance\dimen2 by \dp\strutbox
Chris@42 714 \ifdim\dimen0 > \dimen2
Chris@42 715 %
Chris@42 716 % Do a \strut just to make the height of this box be normal, so the
Chris@42 717 % normal leading is inserted relative to the preceding line.
Chris@42 718 % And a page break here is fine.
Chris@42 719 \vtop to #1\mil{\strut\vfil}%
Chris@42 720 %
Chris@42 721 % TeX does not even consider page breaks if a penalty added to the
Chris@42 722 % main vertical list is 10000 or more. But in order to see if the
Chris@42 723 % empty box we just added fits on the page, we must make it consider
Chris@42 724 % page breaks. On the other hand, we don't want to actually break the
Chris@42 725 % page after the empty box. So we use a penalty of 9999.
Chris@42 726 %
Chris@42 727 % There is an extremely small chance that TeX will actually break the
Chris@42 728 % page at this \penalty, if there are no other feasible breakpoints in
Chris@42 729 % sight. (If the user is using lots of big @group commands, which
Chris@42 730 % almost-but-not-quite fill up a page, TeX will have a hard time doing
Chris@42 731 % good page breaking, for example.) However, I could not construct an
Chris@42 732 % example where a page broke at this \penalty; if it happens in a real
Chris@42 733 % document, then we can reconsider our strategy.
Chris@42 734 \penalty9999
Chris@42 735 %
Chris@42 736 % Back up by the size of the box, whether we did a page break or not.
Chris@42 737 \kern -#1\mil
Chris@42 738 %
Chris@42 739 % Do not allow a page break right after this kern.
Chris@42 740 \nobreak
Chris@42 741 \fi
Chris@42 742 }
Chris@42 743
Chris@42 744 % @br forces paragraph break (and is undocumented).
Chris@42 745
Chris@42 746 \let\br = \par
Chris@42 747
Chris@42 748 % @page forces the start of a new page.
Chris@42 749 %
Chris@42 750 \def\page{\par\vfill\supereject}
Chris@42 751
Chris@42 752 % @exdent text....
Chris@42 753 % outputs text on separate line in roman font, starting at standard page margin
Chris@42 754
Chris@42 755 % This records the amount of indent in the innermost environment.
Chris@42 756 % That's how much \exdent should take out.
Chris@42 757 \newskip\exdentamount
Chris@42 758
Chris@42 759 % This defn is used inside fill environments such as @defun.
Chris@42 760 \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
Chris@42 761
Chris@42 762 % This defn is used inside nofill environments such as @example.
Chris@42 763 \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
Chris@42 764 \leftline{\hskip\leftskip{\rm#1}}}}
Chris@42 765
Chris@42 766 % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
Chris@42 767 % paragraph. For more general purposes, use the \margin insertion
Chris@42 768 % class. WHICH is `l' or `r'. Not documented, written for gawk manual.
Chris@42 769 %
Chris@42 770 \newskip\inmarginspacing \inmarginspacing=1cm
Chris@42 771 \def\strutdepth{\dp\strutbox}
Chris@42 772 %
Chris@42 773 \def\doinmargin#1#2{\strut\vadjust{%
Chris@42 774 \nobreak
Chris@42 775 \kern-\strutdepth
Chris@42 776 \vtop to \strutdepth{%
Chris@42 777 \baselineskip=\strutdepth
Chris@42 778 \vss
Chris@42 779 % if you have multiple lines of stuff to put here, you'll need to
Chris@42 780 % make the vbox yourself of the appropriate size.
Chris@42 781 \ifx#1l%
Chris@42 782 \llap{\ignorespaces #2\hskip\inmarginspacing}%
Chris@42 783 \else
Chris@42 784 \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
Chris@42 785 \fi
Chris@42 786 \null
Chris@42 787 }%
Chris@42 788 }}
Chris@42 789 \def\inleftmargin{\doinmargin l}
Chris@42 790 \def\inrightmargin{\doinmargin r}
Chris@42 791 %
Chris@42 792 % @inmargin{TEXT [, RIGHT-TEXT]}
Chris@42 793 % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
Chris@42 794 % else use TEXT for both).
Chris@42 795 %
Chris@42 796 \def\inmargin#1{\parseinmargin #1,,\finish}
Chris@42 797 \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
Chris@42 798 \setbox0 = \hbox{\ignorespaces #2}%
Chris@42 799 \ifdim\wd0 > 0pt
Chris@42 800 \def\lefttext{#1}% have both texts
Chris@42 801 \def\righttext{#2}%
Chris@42 802 \else
Chris@42 803 \def\lefttext{#1}% have only one text
Chris@42 804 \def\righttext{#1}%
Chris@42 805 \fi
Chris@42 806 %
Chris@42 807 \ifodd\pageno
Chris@42 808 \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
Chris@42 809 \else
Chris@42 810 \def\temp{\inleftmargin\lefttext}%
Chris@42 811 \fi
Chris@42 812 \temp
Chris@42 813 }
Chris@42 814
Chris@42 815 % @| inserts a changebar to the left of the current line. It should
Chris@42 816 % surround any changed text. This approach does *not* work if the
Chris@42 817 % change spans more than two lines of output. To handle that, we would
Chris@42 818 % have adopt a much more difficult approach (putting marks into the main
Chris@42 819 % vertical list for the beginning and end of each change). This command
Chris@42 820 % is not documented, not supported, and doesn't work.
Chris@42 821 %
Chris@42 822 \def\|{%
Chris@42 823 % \vadjust can only be used in horizontal mode.
Chris@42 824 \leavevmode
Chris@42 825 %
Chris@42 826 % Append this vertical mode material after the current line in the output.
Chris@42 827 \vadjust{%
Chris@42 828 % We want to insert a rule with the height and depth of the current
Chris@42 829 % leading; that is exactly what \strutbox is supposed to record.
Chris@42 830 \vskip-\baselineskip
Chris@42 831 %
Chris@42 832 % \vadjust-items are inserted at the left edge of the type. So
Chris@42 833 % the \llap here moves out into the left-hand margin.
Chris@42 834 \llap{%
Chris@42 835 %
Chris@42 836 % For a thicker or thinner bar, change the `1pt'.
Chris@42 837 \vrule height\baselineskip width1pt
Chris@42 838 %
Chris@42 839 % This is the space between the bar and the text.
Chris@42 840 \hskip 12pt
Chris@42 841 }%
Chris@42 842 }%
Chris@42 843 }
Chris@42 844
Chris@42 845 % @include FILE -- \input text of FILE.
Chris@42 846 %
Chris@42 847 \def\include{\parseargusing\filenamecatcodes\includezzz}
Chris@42 848 \def\includezzz#1{%
Chris@42 849 \pushthisfilestack
Chris@42 850 \def\thisfile{#1}%
Chris@42 851 {%
Chris@42 852 \makevalueexpandable % we want to expand any @value in FILE.
Chris@42 853 \turnoffactive % and allow special characters in the expansion
Chris@42 854 \indexnofonts % Allow `@@' and other weird things in file names.
Chris@42 855 \wlog{texinfo.tex: doing @include of #1^^J}%
Chris@42 856 \edef\temp{\noexpand\input #1 }%
Chris@42 857 %
Chris@42 858 % This trickery is to read FILE outside of a group, in case it makes
Chris@42 859 % definitions, etc.
Chris@42 860 \expandafter
Chris@42 861 }\temp
Chris@42 862 \popthisfilestack
Chris@42 863 }
Chris@42 864 \def\filenamecatcodes{%
Chris@42 865 \catcode`\\=\other
Chris@42 866 \catcode`~=\other
Chris@42 867 \catcode`^=\other
Chris@42 868 \catcode`_=\other
Chris@42 869 \catcode`|=\other
Chris@42 870 \catcode`<=\other
Chris@42 871 \catcode`>=\other
Chris@42 872 \catcode`+=\other
Chris@42 873 \catcode`-=\other
Chris@42 874 \catcode`\`=\other
Chris@42 875 \catcode`\'=\other
Chris@42 876 }
Chris@42 877
Chris@42 878 \def\pushthisfilestack{%
Chris@42 879 \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
Chris@42 880 }
Chris@42 881 \def\pushthisfilestackX{%
Chris@42 882 \expandafter\pushthisfilestackY\thisfile\StackTerm
Chris@42 883 }
Chris@42 884 \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
Chris@42 885 \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
Chris@42 886 }
Chris@42 887
Chris@42 888 \def\popthisfilestack{\errthisfilestackempty}
Chris@42 889 \def\errthisfilestackempty{\errmessage{Internal error:
Chris@42 890 the stack of filenames is empty.}}
Chris@42 891 %
Chris@42 892 \def\thisfile{}
Chris@42 893
Chris@42 894 % @center line
Chris@42 895 % outputs that line, centered.
Chris@42 896 %
Chris@42 897 \parseargdef\center{%
Chris@42 898 \ifhmode
Chris@42 899 \let\centersub\centerH
Chris@42 900 \else
Chris@42 901 \let\centersub\centerV
Chris@42 902 \fi
Chris@42 903 \centersub{\hfil \ignorespaces#1\unskip \hfil}%
Chris@42 904 \let\centersub\relax % don't let the definition persist, just in case
Chris@42 905 }
Chris@42 906 \def\centerH#1{{%
Chris@42 907 \hfil\break
Chris@42 908 \advance\hsize by -\leftskip
Chris@42 909 \advance\hsize by -\rightskip
Chris@42 910 \line{#1}%
Chris@42 911 \break
Chris@42 912 }}
Chris@42 913 %
Chris@42 914 \newcount\centerpenalty
Chris@42 915 \def\centerV#1{%
Chris@42 916 % The idea here is the same as in \startdefun, \cartouche, etc.: if
Chris@42 917 % @center is the first thing after a section heading, we need to wipe
Chris@42 918 % out the negative parskip inserted by \sectionheading, but still
Chris@42 919 % prevent a page break here.
Chris@42 920 \centerpenalty = \lastpenalty
Chris@42 921 \ifnum\centerpenalty>10000 \vskip\parskip \fi
Chris@42 922 \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
Chris@42 923 \line{\kern\leftskip #1\kern\rightskip}%
Chris@42 924 }
Chris@42 925
Chris@42 926 % @sp n outputs n lines of vertical space
Chris@42 927 %
Chris@42 928 \parseargdef\sp{\vskip #1\baselineskip}
Chris@42 929
Chris@42 930 % @comment ...line which is ignored...
Chris@42 931 % @c is the same as @comment
Chris@42 932 % @ignore ... @end ignore is another way to write a comment
Chris@42 933 %
Chris@42 934 \def\comment{\begingroup \catcode`\^^M=\other%
Chris@42 935 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
Chris@42 936 \commentxxx}
Chris@42 937 {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
Chris@42 938 %
Chris@42 939 \let\c=\comment
Chris@42 940
Chris@42 941 % @paragraphindent NCHARS
Chris@42 942 % We'll use ems for NCHARS, close enough.
Chris@42 943 % NCHARS can also be the word `asis' or `none'.
Chris@42 944 % We cannot feasibly implement @paragraphindent asis, though.
Chris@42 945 %
Chris@42 946 \def\asisword{asis} % no translation, these are keywords
Chris@42 947 \def\noneword{none}
Chris@42 948 %
Chris@42 949 \parseargdef\paragraphindent{%
Chris@42 950 \def\temp{#1}%
Chris@42 951 \ifx\temp\asisword
Chris@42 952 \else
Chris@42 953 \ifx\temp\noneword
Chris@42 954 \defaultparindent = 0pt
Chris@42 955 \else
Chris@42 956 \defaultparindent = #1em
Chris@42 957 \fi
Chris@42 958 \fi
Chris@42 959 \parindent = \defaultparindent
Chris@42 960 }
Chris@42 961
Chris@42 962 % @exampleindent NCHARS
Chris@42 963 % We'll use ems for NCHARS like @paragraphindent.
Chris@42 964 % It seems @exampleindent asis isn't necessary, but
Chris@42 965 % I preserve it to make it similar to @paragraphindent.
Chris@42 966 \parseargdef\exampleindent{%
Chris@42 967 \def\temp{#1}%
Chris@42 968 \ifx\temp\asisword
Chris@42 969 \else
Chris@42 970 \ifx\temp\noneword
Chris@42 971 \lispnarrowing = 0pt
Chris@42 972 \else
Chris@42 973 \lispnarrowing = #1em
Chris@42 974 \fi
Chris@42 975 \fi
Chris@42 976 }
Chris@42 977
Chris@42 978 % @firstparagraphindent WORD
Chris@42 979 % If WORD is `none', then suppress indentation of the first paragraph
Chris@42 980 % after a section heading. If WORD is `insert', then do indent at such
Chris@42 981 % paragraphs.
Chris@42 982 %
Chris@42 983 % The paragraph indentation is suppressed or not by calling
Chris@42 984 % \suppressfirstparagraphindent, which the sectioning commands do.
Chris@42 985 % We switch the definition of this back and forth according to WORD.
Chris@42 986 % By default, we suppress indentation.
Chris@42 987 %
Chris@42 988 \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
Chris@42 989 \def\insertword{insert}
Chris@42 990 %
Chris@42 991 \parseargdef\firstparagraphindent{%
Chris@42 992 \def\temp{#1}%
Chris@42 993 \ifx\temp\noneword
Chris@42 994 \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
Chris@42 995 \else\ifx\temp\insertword
Chris@42 996 \let\suppressfirstparagraphindent = \relax
Chris@42 997 \else
Chris@42 998 \errhelp = \EMsimple
Chris@42 999 \errmessage{Unknown @firstparagraphindent option `\temp'}%
Chris@42 1000 \fi\fi
Chris@42 1001 }
Chris@42 1002
Chris@42 1003 % Here is how we actually suppress indentation. Redefine \everypar to
Chris@42 1004 % \kern backwards by \parindent, and then reset itself to empty.
Chris@42 1005 %
Chris@42 1006 % We also make \indent itself not actually do anything until the next
Chris@42 1007 % paragraph.
Chris@42 1008 %
Chris@42 1009 \gdef\dosuppressfirstparagraphindent{%
Chris@42 1010 \gdef\indent{%
Chris@42 1011 \restorefirstparagraphindent
Chris@42 1012 \indent
Chris@42 1013 }%
Chris@42 1014 \gdef\noindent{%
Chris@42 1015 \restorefirstparagraphindent
Chris@42 1016 \noindent
Chris@42 1017 }%
Chris@42 1018 \global\everypar = {%
Chris@42 1019 \kern -\parindent
Chris@42 1020 \restorefirstparagraphindent
Chris@42 1021 }%
Chris@42 1022 }
Chris@42 1023
Chris@42 1024 \gdef\restorefirstparagraphindent{%
Chris@42 1025 \global \let \indent = \ptexindent
Chris@42 1026 \global \let \noindent = \ptexnoindent
Chris@42 1027 \global \everypar = {}%
Chris@42 1028 }
Chris@42 1029
Chris@42 1030
Chris@42 1031 % @refill is a no-op.
Chris@42 1032 \let\refill=\relax
Chris@42 1033
Chris@42 1034 % If working on a large document in chapters, it is convenient to
Chris@42 1035 % be able to disable indexing, cross-referencing, and contents, for test runs.
Chris@42 1036 % This is done with @novalidate (before @setfilename).
Chris@42 1037 %
Chris@42 1038 \newif\iflinks \linkstrue % by default we want the aux files.
Chris@42 1039 \let\novalidate = \linksfalse
Chris@42 1040
Chris@42 1041 % @setfilename is done at the beginning of every texinfo file.
Chris@42 1042 % So open here the files we need to have open while reading the input.
Chris@42 1043 % This makes it possible to make a .fmt file for texinfo.
Chris@42 1044 \def\setfilename{%
Chris@42 1045 \fixbackslash % Turn off hack to swallow `\input texinfo'.
Chris@42 1046 \iflinks
Chris@42 1047 \tryauxfile
Chris@42 1048 % Open the new aux file. TeX will close it automatically at exit.
Chris@42 1049 \immediate\openout\auxfile=\jobname.aux
Chris@42 1050 \fi % \openindices needs to do some work in any case.
Chris@42 1051 \openindices
Chris@42 1052 \let\setfilename=\comment % Ignore extra @setfilename cmds.
Chris@42 1053 %
Chris@42 1054 % If texinfo.cnf is present on the system, read it.
Chris@42 1055 % Useful for site-wide @afourpaper, etc.
Chris@42 1056 \openin 1 texinfo.cnf
Chris@42 1057 \ifeof 1 \else \input texinfo.cnf \fi
Chris@42 1058 \closein 1
Chris@42 1059 %
Chris@42 1060 \comment % Ignore the actual filename.
Chris@42 1061 }
Chris@42 1062
Chris@42 1063 % Called from \setfilename.
Chris@42 1064 %
Chris@42 1065 \def\openindices{%
Chris@42 1066 \newindex{cp}%
Chris@42 1067 \newcodeindex{fn}%
Chris@42 1068 \newcodeindex{vr}%
Chris@42 1069 \newcodeindex{tp}%
Chris@42 1070 \newcodeindex{ky}%
Chris@42 1071 \newcodeindex{pg}%
Chris@42 1072 }
Chris@42 1073
Chris@42 1074 % @bye.
Chris@42 1075 \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
Chris@42 1076
Chris@42 1077
Chris@42 1078 \message{pdf,}
Chris@42 1079 % adobe `portable' document format
Chris@42 1080 \newcount\tempnum
Chris@42 1081 \newcount\lnkcount
Chris@42 1082 \newtoks\filename
Chris@42 1083 \newcount\filenamelength
Chris@42 1084 \newcount\pgn
Chris@42 1085 \newtoks\toksA
Chris@42 1086 \newtoks\toksB
Chris@42 1087 \newtoks\toksC
Chris@42 1088 \newtoks\toksD
Chris@42 1089 \newbox\boxA
Chris@42 1090 \newcount\countA
Chris@42 1091 \newif\ifpdf
Chris@42 1092 \newif\ifpdfmakepagedest
Chris@42 1093
Chris@42 1094 % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
Chris@42 1095 % can be set). So we test for \relax and 0 as well as being undefined.
Chris@42 1096 \ifx\pdfoutput\thisisundefined
Chris@42 1097 \else
Chris@42 1098 \ifx\pdfoutput\relax
Chris@42 1099 \else
Chris@42 1100 \ifcase\pdfoutput
Chris@42 1101 \else
Chris@42 1102 \pdftrue
Chris@42 1103 \fi
Chris@42 1104 \fi
Chris@42 1105 \fi
Chris@42 1106
Chris@42 1107 % PDF uses PostScript string constants for the names of xref targets,
Chris@42 1108 % for display in the outlines, and in other places. Thus, we have to
Chris@42 1109 % double any backslashes. Otherwise, a name like "\node" will be
Chris@42 1110 % interpreted as a newline (\n), followed by o, d, e. Not good.
Chris@42 1111 %
Chris@42 1112 % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
Chris@42 1113 % related messages. The final outcome is that it is up to the TeX user
Chris@42 1114 % to double the backslashes and otherwise make the string valid, so
Chris@42 1115 % that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to
Chris@42 1116 % do this reliably, so we use it.
Chris@42 1117
Chris@42 1118 % #1 is a control sequence in which to do the replacements,
Chris@42 1119 % which we \xdef.
Chris@42 1120 \def\txiescapepdf#1{%
Chris@42 1121 \ifx\pdfescapestring\thisisundefined
Chris@42 1122 % No primitive available; should we give a warning or log?
Chris@42 1123 % Many times it won't matter.
Chris@42 1124 \else
Chris@42 1125 % The expandable \pdfescapestring primitive escapes parentheses,
Chris@42 1126 % backslashes, and other special chars.
Chris@42 1127 \xdef#1{\pdfescapestring{#1}}%
Chris@42 1128 \fi
Chris@42 1129 }
Chris@42 1130
Chris@42 1131 \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
Chris@42 1132 with PDF output, and none of those formats could be found. (.eps cannot
Chris@42 1133 be supported due to the design of the PDF format; use regular TeX (DVI
Chris@42 1134 output) for that.)}
Chris@42 1135
Chris@42 1136 \ifpdf
Chris@42 1137 %
Chris@42 1138 % Color manipulation macros based on pdfcolor.tex,
Chris@42 1139 % except using rgb instead of cmyk; the latter is said to render as a
Chris@42 1140 % very dark gray on-screen and a very dark halftone in print, instead
Chris@42 1141 % of actual black.
Chris@42 1142 \def\rgbDarkRed{0.50 0.09 0.12}
Chris@42 1143 \def\rgbBlack{0 0 0}
Chris@42 1144 %
Chris@42 1145 % k sets the color for filling (usual text, etc.);
Chris@42 1146 % K sets the color for stroking (thin rules, e.g., normal _'s).
Chris@42 1147 \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}}
Chris@42 1148 %
Chris@42 1149 % Set color, and create a mark which defines \thiscolor accordingly,
Chris@42 1150 % so that \makeheadline knows which color to restore.
Chris@42 1151 \def\setcolor#1{%
Chris@42 1152 \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
Chris@42 1153 \domark
Chris@42 1154 \pdfsetcolor{#1}%
Chris@42 1155 }
Chris@42 1156 %
Chris@42 1157 \def\maincolor{\rgbBlack}
Chris@42 1158 \pdfsetcolor{\maincolor}
Chris@42 1159 \edef\thiscolor{\maincolor}
Chris@42 1160 \def\lastcolordefs{}
Chris@42 1161 %
Chris@42 1162 \def\makefootline{%
Chris@42 1163 \baselineskip24pt
Chris@42 1164 \line{\pdfsetcolor{\maincolor}\the\footline}%
Chris@42 1165 }
Chris@42 1166 %
Chris@42 1167 \def\makeheadline{%
Chris@42 1168 \vbox to 0pt{%
Chris@42 1169 \vskip-22.5pt
Chris@42 1170 \line{%
Chris@42 1171 \vbox to8.5pt{}%
Chris@42 1172 % Extract \thiscolor definition from the marks.
Chris@42 1173 \getcolormarks
Chris@42 1174 % Typeset the headline with \maincolor, then restore the color.
Chris@42 1175 \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
Chris@42 1176 }%
Chris@42 1177 \vss
Chris@42 1178 }%
Chris@42 1179 \nointerlineskip
Chris@42 1180 }
Chris@42 1181 %
Chris@42 1182 %
Chris@42 1183 \pdfcatalog{/PageMode /UseOutlines}
Chris@42 1184 %
Chris@42 1185 % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
Chris@42 1186 \def\dopdfimage#1#2#3{%
Chris@42 1187 \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
Chris@42 1188 \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
Chris@42 1189 %
Chris@42 1190 % pdftex (and the PDF format) support .pdf, .png, .jpg (among
Chris@42 1191 % others). Let's try in that order, PDF first since if
Chris@42 1192 % someone has a scalable image, presumably better to use that than a
Chris@42 1193 % bitmap.
Chris@42 1194 \let\pdfimgext=\empty
Chris@42 1195 \begingroup
Chris@42 1196 \openin 1 #1.pdf \ifeof 1
Chris@42 1197 \openin 1 #1.PDF \ifeof 1
Chris@42 1198 \openin 1 #1.png \ifeof 1
Chris@42 1199 \openin 1 #1.jpg \ifeof 1
Chris@42 1200 \openin 1 #1.jpeg \ifeof 1
Chris@42 1201 \openin 1 #1.JPG \ifeof 1
Chris@42 1202 \errhelp = \nopdfimagehelp
Chris@42 1203 \errmessage{Could not find image file #1 for pdf}%
Chris@42 1204 \else \gdef\pdfimgext{JPG}%
Chris@42 1205 \fi
Chris@42 1206 \else \gdef\pdfimgext{jpeg}%
Chris@42 1207 \fi
Chris@42 1208 \else \gdef\pdfimgext{jpg}%
Chris@42 1209 \fi
Chris@42 1210 \else \gdef\pdfimgext{png}%
Chris@42 1211 \fi
Chris@42 1212 \else \gdef\pdfimgext{PDF}%
Chris@42 1213 \fi
Chris@42 1214 \else \gdef\pdfimgext{pdf}%
Chris@42 1215 \fi
Chris@42 1216 \closein 1
Chris@42 1217 \endgroup
Chris@42 1218 %
Chris@42 1219 % without \immediate, ancient pdftex seg faults when the same image is
Chris@42 1220 % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.)
Chris@42 1221 \ifnum\pdftexversion < 14
Chris@42 1222 \immediate\pdfimage
Chris@42 1223 \else
Chris@42 1224 \immediate\pdfximage
Chris@42 1225 \fi
Chris@42 1226 \ifdim \wd0 >0pt width \pdfimagewidth \fi
Chris@42 1227 \ifdim \wd2 >0pt height \pdfimageheight \fi
Chris@42 1228 \ifnum\pdftexversion<13
Chris@42 1229 #1.\pdfimgext
Chris@42 1230 \else
Chris@42 1231 {#1.\pdfimgext}%
Chris@42 1232 \fi
Chris@42 1233 \ifnum\pdftexversion < 14 \else
Chris@42 1234 \pdfrefximage \pdflastximage
Chris@42 1235 \fi}
Chris@42 1236 %
Chris@42 1237 \def\pdfmkdest#1{{%
Chris@42 1238 % We have to set dummies so commands such as @code, and characters
Chris@42 1239 % such as \, aren't expanded when present in a section title.
Chris@42 1240 \indexnofonts
Chris@42 1241 \turnoffactive
Chris@42 1242 \makevalueexpandable
Chris@42 1243 \def\pdfdestname{#1}%
Chris@42 1244 \txiescapepdf\pdfdestname
Chris@42 1245 \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
Chris@42 1246 }}
Chris@42 1247 %
Chris@42 1248 % used to mark target names; must be expandable.
Chris@42 1249 \def\pdfmkpgn#1{#1}
Chris@42 1250 %
Chris@42 1251 % by default, use a color that is dark enough to print on paper as
Chris@42 1252 % nearly black, but still distinguishable for online viewing.
Chris@42 1253 \def\urlcolor{\rgbDarkRed}
Chris@42 1254 \def\linkcolor{\rgbDarkRed}
Chris@42 1255 \def\endlink{\setcolor{\maincolor}\pdfendlink}
Chris@42 1256 %
Chris@42 1257 % Adding outlines to PDF; macros for calculating structure of outlines
Chris@42 1258 % come from Petr Olsak
Chris@42 1259 \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
Chris@42 1260 \else \csname#1\endcsname \fi}
Chris@42 1261 \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
Chris@42 1262 \advance\tempnum by 1
Chris@42 1263 \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
Chris@42 1264 %
Chris@42 1265 % #1 is the section text, which is what will be displayed in the
Chris@42 1266 % outline by the pdf viewer. #2 is the pdf expression for the number
Chris@42 1267 % of subentries (or empty, for subsubsections). #3 is the node text,
Chris@42 1268 % which might be empty if this toc entry had no corresponding node.
Chris@42 1269 % #4 is the page number
Chris@42 1270 %
Chris@42 1271 \def\dopdfoutline#1#2#3#4{%
Chris@42 1272 % Generate a link to the node text if that exists; else, use the
Chris@42 1273 % page number. We could generate a destination for the section
Chris@42 1274 % text in the case where a section has no node, but it doesn't
Chris@42 1275 % seem worth the trouble, since most documents are normally structured.
Chris@42 1276 \edef\pdfoutlinedest{#3}%
Chris@42 1277 \ifx\pdfoutlinedest\empty
Chris@42 1278 \def\pdfoutlinedest{#4}%
Chris@42 1279 \else
Chris@42 1280 \txiescapepdf\pdfoutlinedest
Chris@42 1281 \fi
Chris@42 1282 %
Chris@42 1283 % Also escape PDF chars in the display string.
Chris@42 1284 \edef\pdfoutlinetext{#1}%
Chris@42 1285 \txiescapepdf\pdfoutlinetext
Chris@42 1286 %
Chris@42 1287 \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
Chris@42 1288 }
Chris@42 1289 %
Chris@42 1290 \def\pdfmakeoutlines{%
Chris@42 1291 \begingroup
Chris@42 1292 % Read toc silently, to get counts of subentries for \pdfoutline.
Chris@42 1293 \def\partentry##1##2##3##4{}% ignore parts in the outlines
Chris@42 1294 \def\numchapentry##1##2##3##4{%
Chris@42 1295 \def\thischapnum{##2}%
Chris@42 1296 \def\thissecnum{0}%
Chris@42 1297 \def\thissubsecnum{0}%
Chris@42 1298 }%
Chris@42 1299 \def\numsecentry##1##2##3##4{%
Chris@42 1300 \advancenumber{chap\thischapnum}%
Chris@42 1301 \def\thissecnum{##2}%
Chris@42 1302 \def\thissubsecnum{0}%
Chris@42 1303 }%
Chris@42 1304 \def\numsubsecentry##1##2##3##4{%
Chris@42 1305 \advancenumber{sec\thissecnum}%
Chris@42 1306 \def\thissubsecnum{##2}%
Chris@42 1307 }%
Chris@42 1308 \def\numsubsubsecentry##1##2##3##4{%
Chris@42 1309 \advancenumber{subsec\thissubsecnum}%
Chris@42 1310 }%
Chris@42 1311 \def\thischapnum{0}%
Chris@42 1312 \def\thissecnum{0}%
Chris@42 1313 \def\thissubsecnum{0}%
Chris@42 1314 %
Chris@42 1315 % use \def rather than \let here because we redefine \chapentry et
Chris@42 1316 % al. a second time, below.
Chris@42 1317 \def\appentry{\numchapentry}%
Chris@42 1318 \def\appsecentry{\numsecentry}%
Chris@42 1319 \def\appsubsecentry{\numsubsecentry}%
Chris@42 1320 \def\appsubsubsecentry{\numsubsubsecentry}%
Chris@42 1321 \def\unnchapentry{\numchapentry}%
Chris@42 1322 \def\unnsecentry{\numsecentry}%
Chris@42 1323 \def\unnsubsecentry{\numsubsecentry}%
Chris@42 1324 \def\unnsubsubsecentry{\numsubsubsecentry}%
Chris@42 1325 \readdatafile{toc}%
Chris@42 1326 %
Chris@42 1327 % Read toc second time, this time actually producing the outlines.
Chris@42 1328 % The `-' means take the \expnumber as the absolute number of
Chris@42 1329 % subentries, which we calculated on our first read of the .toc above.
Chris@42 1330 %
Chris@42 1331 % We use the node names as the destinations.
Chris@42 1332 \def\numchapentry##1##2##3##4{%
Chris@42 1333 \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
Chris@42 1334 \def\numsecentry##1##2##3##4{%
Chris@42 1335 \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
Chris@42 1336 \def\numsubsecentry##1##2##3##4{%
Chris@42 1337 \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
Chris@42 1338 \def\numsubsubsecentry##1##2##3##4{% count is always zero
Chris@42 1339 \dopdfoutline{##1}{}{##3}{##4}}%
Chris@42 1340 %
Chris@42 1341 % PDF outlines are displayed using system fonts, instead of
Chris@42 1342 % document fonts. Therefore we cannot use special characters,
Chris@42 1343 % since the encoding is unknown. For example, the eogonek from
Chris@42 1344 % Latin 2 (0xea) gets translated to a | character. Info from
Chris@42 1345 % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
Chris@42 1346 %
Chris@42 1347 % TODO this right, we have to translate 8-bit characters to
Chris@42 1348 % their "best" equivalent, based on the @documentencoding. Too
Chris@42 1349 % much work for too little return. Just use the ASCII equivalents
Chris@42 1350 % we use for the index sort strings.
Chris@42 1351 %
Chris@42 1352 \indexnofonts
Chris@42 1353 \setupdatafile
Chris@42 1354 % We can have normal brace characters in the PDF outlines, unlike
Chris@42 1355 % Texinfo index files. So set that up.
Chris@42 1356 \def\{{\lbracecharliteral}%
Chris@42 1357 \def\}{\rbracecharliteral}%
Chris@42 1358 \catcode`\\=\active \otherbackslash
Chris@42 1359 \input \tocreadfilename
Chris@42 1360 \endgroup
Chris@42 1361 }
Chris@42 1362 {\catcode`[=1 \catcode`]=2
Chris@42 1363 \catcode`{=\other \catcode`}=\other
Chris@42 1364 \gdef\lbracecharliteral[{]%
Chris@42 1365 \gdef\rbracecharliteral[}]%
Chris@42 1366 ]
Chris@42 1367 %
Chris@42 1368 \def\skipspaces#1{\def\PP{#1}\def\D{|}%
Chris@42 1369 \ifx\PP\D\let\nextsp\relax
Chris@42 1370 \else\let\nextsp\skipspaces
Chris@42 1371 \addtokens{\filename}{\PP}%
Chris@42 1372 \advance\filenamelength by 1
Chris@42 1373 \fi
Chris@42 1374 \nextsp}
Chris@42 1375 \def\getfilename#1{%
Chris@42 1376 \filenamelength=0
Chris@42 1377 % If we don't expand the argument now, \skipspaces will get
Chris@42 1378 % snagged on things like "@value{foo}".
Chris@42 1379 \edef\temp{#1}%
Chris@42 1380 \expandafter\skipspaces\temp|\relax
Chris@42 1381 }
Chris@42 1382 \ifnum\pdftexversion < 14
Chris@42 1383 \let \startlink \pdfannotlink
Chris@42 1384 \else
Chris@42 1385 \let \startlink \pdfstartlink
Chris@42 1386 \fi
Chris@42 1387 % make a live url in pdf output.
Chris@42 1388 \def\pdfurl#1{%
Chris@42 1389 \begingroup
Chris@42 1390 % it seems we really need yet another set of dummies; have not
Chris@42 1391 % tried to figure out what each command should do in the context
Chris@42 1392 % of @url. for now, just make @/ a no-op, that's the only one
Chris@42 1393 % people have actually reported a problem with.
Chris@42 1394 %
Chris@42 1395 \normalturnoffactive
Chris@42 1396 \def\@{@}%
Chris@42 1397 \let\/=\empty
Chris@42 1398 \makevalueexpandable
Chris@42 1399 % do we want to go so far as to use \indexnofonts instead of just
Chris@42 1400 % special-casing \var here?
Chris@42 1401 \def\var##1{##1}%
Chris@42 1402 %
Chris@42 1403 \leavevmode\setcolor{\urlcolor}%
Chris@42 1404 \startlink attr{/Border [0 0 0]}%
Chris@42 1405 user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
Chris@42 1406 \endgroup}
Chris@42 1407 \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
Chris@42 1408 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
Chris@42 1409 \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
Chris@42 1410 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
Chris@42 1411 \def\maketoks{%
Chris@42 1412 \expandafter\poptoks\the\toksA|ENDTOKS|\relax
Chris@42 1413 \ifx\first0\adn0
Chris@42 1414 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
Chris@42 1415 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
Chris@42 1416 \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
Chris@42 1417 \else
Chris@42 1418 \ifnum0=\countA\else\makelink\fi
Chris@42 1419 \ifx\first.\let\next=\done\else
Chris@42 1420 \let\next=\maketoks
Chris@42 1421 \addtokens{\toksB}{\the\toksD}
Chris@42 1422 \ifx\first,\addtokens{\toksB}{\space}\fi
Chris@42 1423 \fi
Chris@42 1424 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
Chris@42 1425 \next}
Chris@42 1426 \def\makelink{\addtokens{\toksB}%
Chris@42 1427 {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
Chris@42 1428 \def\pdflink#1{%
Chris@42 1429 \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
Chris@42 1430 \setcolor{\linkcolor}#1\endlink}
Chris@42 1431 \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
Chris@42 1432 \else
Chris@42 1433 % non-pdf mode
Chris@42 1434 \let\pdfmkdest = \gobble
Chris@42 1435 \let\pdfurl = \gobble
Chris@42 1436 \let\endlink = \relax
Chris@42 1437 \let\setcolor = \gobble
Chris@42 1438 \let\pdfsetcolor = \gobble
Chris@42 1439 \let\pdfmakeoutlines = \relax
Chris@42 1440 \fi % \ifx\pdfoutput
Chris@42 1441
Chris@42 1442
Chris@42 1443 \message{fonts,}
Chris@42 1444
Chris@42 1445 % Change the current font style to #1, remembering it in \curfontstyle.
Chris@42 1446 % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
Chris@42 1447 % italics, not bold italics.
Chris@42 1448 %
Chris@42 1449 \def\setfontstyle#1{%
Chris@42 1450 \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
Chris@42 1451 \csname ten#1\endcsname % change the current font
Chris@42 1452 }
Chris@42 1453
Chris@42 1454 % Select #1 fonts with the current style.
Chris@42 1455 %
Chris@42 1456 \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
Chris@42 1457
Chris@42 1458 \def\rm{\fam=0 \setfontstyle{rm}}
Chris@42 1459 \def\it{\fam=\itfam \setfontstyle{it}}
Chris@42 1460 \def\sl{\fam=\slfam \setfontstyle{sl}}
Chris@42 1461 \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
Chris@42 1462 \def\tt{\fam=\ttfam \setfontstyle{tt}}
Chris@42 1463
Chris@42 1464 % Unfortunately, we have to override this for titles and the like, since
Chris@42 1465 % in those cases "rm" is bold. Sigh.
Chris@42 1466 \def\rmisbold{\rm\def\curfontstyle{bf}}
Chris@42 1467
Chris@42 1468 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
Chris@42 1469 % So we set up a \sf.
Chris@42 1470 \newfam\sffam
Chris@42 1471 \def\sf{\fam=\sffam \setfontstyle{sf}}
Chris@42 1472 \let\li = \sf % Sometimes we call it \li, not \sf.
Chris@42 1473
Chris@42 1474 % We don't need math for this font style.
Chris@42 1475 \def\ttsl{\setfontstyle{ttsl}}
Chris@42 1476
Chris@42 1477
Chris@42 1478 % Set the baselineskip to #1, and the lineskip and strut size
Chris@42 1479 % correspondingly. There is no deep meaning behind these magic numbers
Chris@42 1480 % used as factors; they just match (closely enough) what Knuth defined.
Chris@42 1481 %
Chris@42 1482 \def\lineskipfactor{.08333}
Chris@42 1483 \def\strutheightpercent{.70833}
Chris@42 1484 \def\strutdepthpercent {.29167}
Chris@42 1485 %
Chris@42 1486 % can get a sort of poor man's double spacing by redefining this.
Chris@42 1487 \def\baselinefactor{1}
Chris@42 1488 %
Chris@42 1489 \newdimen\textleading
Chris@42 1490 \def\setleading#1{%
Chris@42 1491 \dimen0 = #1\relax
Chris@42 1492 \normalbaselineskip = \baselinefactor\dimen0
Chris@42 1493 \normallineskip = \lineskipfactor\normalbaselineskip
Chris@42 1494 \normalbaselines
Chris@42 1495 \setbox\strutbox =\hbox{%
Chris@42 1496 \vrule width0pt height\strutheightpercent\baselineskip
Chris@42 1497 depth \strutdepthpercent \baselineskip
Chris@42 1498 }%
Chris@42 1499 }
Chris@42 1500
Chris@42 1501 % PDF CMaps. See also LaTeX's t1.cmap.
Chris@42 1502 %
Chris@42 1503 % do nothing with this by default.
Chris@42 1504 \expandafter\let\csname cmapOT1\endcsname\gobble
Chris@42 1505 \expandafter\let\csname cmapOT1IT\endcsname\gobble
Chris@42 1506 \expandafter\let\csname cmapOT1TT\endcsname\gobble
Chris@42 1507
Chris@42 1508 % if we are producing pdf, and we have \pdffontattr, then define cmaps.
Chris@42 1509 % (\pdffontattr was introduced many years ago, but people still run
Chris@42 1510 % older pdftex's; it's easy to conditionalize, so we do.)
Chris@42 1511 \ifpdf \ifx\pdffontattr\thisisundefined \else
Chris@42 1512 \begingroup
Chris@42 1513 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
Chris@42 1514 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
Chris@42 1515 %%DocumentNeededResources: ProcSet (CIDInit)
Chris@42 1516 %%IncludeResource: ProcSet (CIDInit)
Chris@42 1517 %%BeginResource: CMap (TeX-OT1-0)
Chris@42 1518 %%Title: (TeX-OT1-0 TeX OT1 0)
Chris@42 1519 %%Version: 1.000
Chris@42 1520 %%EndComments
Chris@42 1521 /CIDInit /ProcSet findresource begin
Chris@42 1522 12 dict begin
Chris@42 1523 begincmap
Chris@42 1524 /CIDSystemInfo
Chris@42 1525 << /Registry (TeX)
Chris@42 1526 /Ordering (OT1)
Chris@42 1527 /Supplement 0
Chris@42 1528 >> def
Chris@42 1529 /CMapName /TeX-OT1-0 def
Chris@42 1530 /CMapType 2 def
Chris@42 1531 1 begincodespacerange
Chris@42 1532 <00> <7F>
Chris@42 1533 endcodespacerange
Chris@42 1534 8 beginbfrange
Chris@42 1535 <00> <01> <0393>
Chris@42 1536 <09> <0A> <03A8>
Chris@42 1537 <23> <26> <0023>
Chris@42 1538 <28> <3B> <0028>
Chris@42 1539 <3F> <5B> <003F>
Chris@42 1540 <5D> <5E> <005D>
Chris@42 1541 <61> <7A> <0061>
Chris@42 1542 <7B> <7C> <2013>
Chris@42 1543 endbfrange
Chris@42 1544 40 beginbfchar
Chris@42 1545 <02> <0398>
Chris@42 1546 <03> <039B>
Chris@42 1547 <04> <039E>
Chris@42 1548 <05> <03A0>
Chris@42 1549 <06> <03A3>
Chris@42 1550 <07> <03D2>
Chris@42 1551 <08> <03A6>
Chris@42 1552 <0B> <00660066>
Chris@42 1553 <0C> <00660069>
Chris@42 1554 <0D> <0066006C>
Chris@42 1555 <0E> <006600660069>
Chris@42 1556 <0F> <00660066006C>
Chris@42 1557 <10> <0131>
Chris@42 1558 <11> <0237>
Chris@42 1559 <12> <0060>
Chris@42 1560 <13> <00B4>
Chris@42 1561 <14> <02C7>
Chris@42 1562 <15> <02D8>
Chris@42 1563 <16> <00AF>
Chris@42 1564 <17> <02DA>
Chris@42 1565 <18> <00B8>
Chris@42 1566 <19> <00DF>
Chris@42 1567 <1A> <00E6>
Chris@42 1568 <1B> <0153>
Chris@42 1569 <1C> <00F8>
Chris@42 1570 <1D> <00C6>
Chris@42 1571 <1E> <0152>
Chris@42 1572 <1F> <00D8>
Chris@42 1573 <21> <0021>
Chris@42 1574 <22> <201D>
Chris@42 1575 <27> <2019>
Chris@42 1576 <3C> <00A1>
Chris@42 1577 <3D> <003D>
Chris@42 1578 <3E> <00BF>
Chris@42 1579 <5C> <201C>
Chris@42 1580 <5F> <02D9>
Chris@42 1581 <60> <2018>
Chris@42 1582 <7D> <02DD>
Chris@42 1583 <7E> <007E>
Chris@42 1584 <7F> <00A8>
Chris@42 1585 endbfchar
Chris@42 1586 endcmap
Chris@42 1587 CMapName currentdict /CMap defineresource pop
Chris@42 1588 end
Chris@42 1589 end
Chris@42 1590 %%EndResource
Chris@42 1591 %%EOF
Chris@42 1592 }\endgroup
Chris@42 1593 \expandafter\edef\csname cmapOT1\endcsname#1{%
Chris@42 1594 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
Chris@42 1595 }%
Chris@42 1596 %
Chris@42 1597 % \cmapOT1IT
Chris@42 1598 \begingroup
Chris@42 1599 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
Chris@42 1600 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
Chris@42 1601 %%DocumentNeededResources: ProcSet (CIDInit)
Chris@42 1602 %%IncludeResource: ProcSet (CIDInit)
Chris@42 1603 %%BeginResource: CMap (TeX-OT1IT-0)
Chris@42 1604 %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
Chris@42 1605 %%Version: 1.000
Chris@42 1606 %%EndComments
Chris@42 1607 /CIDInit /ProcSet findresource begin
Chris@42 1608 12 dict begin
Chris@42 1609 begincmap
Chris@42 1610 /CIDSystemInfo
Chris@42 1611 << /Registry (TeX)
Chris@42 1612 /Ordering (OT1IT)
Chris@42 1613 /Supplement 0
Chris@42 1614 >> def
Chris@42 1615 /CMapName /TeX-OT1IT-0 def
Chris@42 1616 /CMapType 2 def
Chris@42 1617 1 begincodespacerange
Chris@42 1618 <00> <7F>
Chris@42 1619 endcodespacerange
Chris@42 1620 8 beginbfrange
Chris@42 1621 <00> <01> <0393>
Chris@42 1622 <09> <0A> <03A8>
Chris@42 1623 <25> <26> <0025>
Chris@42 1624 <28> <3B> <0028>
Chris@42 1625 <3F> <5B> <003F>
Chris@42 1626 <5D> <5E> <005D>
Chris@42 1627 <61> <7A> <0061>
Chris@42 1628 <7B> <7C> <2013>
Chris@42 1629 endbfrange
Chris@42 1630 42 beginbfchar
Chris@42 1631 <02> <0398>
Chris@42 1632 <03> <039B>
Chris@42 1633 <04> <039E>
Chris@42 1634 <05> <03A0>
Chris@42 1635 <06> <03A3>
Chris@42 1636 <07> <03D2>
Chris@42 1637 <08> <03A6>
Chris@42 1638 <0B> <00660066>
Chris@42 1639 <0C> <00660069>
Chris@42 1640 <0D> <0066006C>
Chris@42 1641 <0E> <006600660069>
Chris@42 1642 <0F> <00660066006C>
Chris@42 1643 <10> <0131>
Chris@42 1644 <11> <0237>
Chris@42 1645 <12> <0060>
Chris@42 1646 <13> <00B4>
Chris@42 1647 <14> <02C7>
Chris@42 1648 <15> <02D8>
Chris@42 1649 <16> <00AF>
Chris@42 1650 <17> <02DA>
Chris@42 1651 <18> <00B8>
Chris@42 1652 <19> <00DF>
Chris@42 1653 <1A> <00E6>
Chris@42 1654 <1B> <0153>
Chris@42 1655 <1C> <00F8>
Chris@42 1656 <1D> <00C6>
Chris@42 1657 <1E> <0152>
Chris@42 1658 <1F> <00D8>
Chris@42 1659 <21> <0021>
Chris@42 1660 <22> <201D>
Chris@42 1661 <23> <0023>
Chris@42 1662 <24> <00A3>
Chris@42 1663 <27> <2019>
Chris@42 1664 <3C> <00A1>
Chris@42 1665 <3D> <003D>
Chris@42 1666 <3E> <00BF>
Chris@42 1667 <5C> <201C>
Chris@42 1668 <5F> <02D9>
Chris@42 1669 <60> <2018>
Chris@42 1670 <7D> <02DD>
Chris@42 1671 <7E> <007E>
Chris@42 1672 <7F> <00A8>
Chris@42 1673 endbfchar
Chris@42 1674 endcmap
Chris@42 1675 CMapName currentdict /CMap defineresource pop
Chris@42 1676 end
Chris@42 1677 end
Chris@42 1678 %%EndResource
Chris@42 1679 %%EOF
Chris@42 1680 }\endgroup
Chris@42 1681 \expandafter\edef\csname cmapOT1IT\endcsname#1{%
Chris@42 1682 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
Chris@42 1683 }%
Chris@42 1684 %
Chris@42 1685 % \cmapOT1TT
Chris@42 1686 \begingroup
Chris@42 1687 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
Chris@42 1688 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
Chris@42 1689 %%DocumentNeededResources: ProcSet (CIDInit)
Chris@42 1690 %%IncludeResource: ProcSet (CIDInit)
Chris@42 1691 %%BeginResource: CMap (TeX-OT1TT-0)
Chris@42 1692 %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
Chris@42 1693 %%Version: 1.000
Chris@42 1694 %%EndComments
Chris@42 1695 /CIDInit /ProcSet findresource begin
Chris@42 1696 12 dict begin
Chris@42 1697 begincmap
Chris@42 1698 /CIDSystemInfo
Chris@42 1699 << /Registry (TeX)
Chris@42 1700 /Ordering (OT1TT)
Chris@42 1701 /Supplement 0
Chris@42 1702 >> def
Chris@42 1703 /CMapName /TeX-OT1TT-0 def
Chris@42 1704 /CMapType 2 def
Chris@42 1705 1 begincodespacerange
Chris@42 1706 <00> <7F>
Chris@42 1707 endcodespacerange
Chris@42 1708 5 beginbfrange
Chris@42 1709 <00> <01> <0393>
Chris@42 1710 <09> <0A> <03A8>
Chris@42 1711 <21> <26> <0021>
Chris@42 1712 <28> <5F> <0028>
Chris@42 1713 <61> <7E> <0061>
Chris@42 1714 endbfrange
Chris@42 1715 32 beginbfchar
Chris@42 1716 <02> <0398>
Chris@42 1717 <03> <039B>
Chris@42 1718 <04> <039E>
Chris@42 1719 <05> <03A0>
Chris@42 1720 <06> <03A3>
Chris@42 1721 <07> <03D2>
Chris@42 1722 <08> <03A6>
Chris@42 1723 <0B> <2191>
Chris@42 1724 <0C> <2193>
Chris@42 1725 <0D> <0027>
Chris@42 1726 <0E> <00A1>
Chris@42 1727 <0F> <00BF>
Chris@42 1728 <10> <0131>
Chris@42 1729 <11> <0237>
Chris@42 1730 <12> <0060>
Chris@42 1731 <13> <00B4>
Chris@42 1732 <14> <02C7>
Chris@42 1733 <15> <02D8>
Chris@42 1734 <16> <00AF>
Chris@42 1735 <17> <02DA>
Chris@42 1736 <18> <00B8>
Chris@42 1737 <19> <00DF>
Chris@42 1738 <1A> <00E6>
Chris@42 1739 <1B> <0153>
Chris@42 1740 <1C> <00F8>
Chris@42 1741 <1D> <00C6>
Chris@42 1742 <1E> <0152>
Chris@42 1743 <1F> <00D8>
Chris@42 1744 <20> <2423>
Chris@42 1745 <27> <2019>
Chris@42 1746 <60> <2018>
Chris@42 1747 <7F> <00A8>
Chris@42 1748 endbfchar
Chris@42 1749 endcmap
Chris@42 1750 CMapName currentdict /CMap defineresource pop
Chris@42 1751 end
Chris@42 1752 end
Chris@42 1753 %%EndResource
Chris@42 1754 %%EOF
Chris@42 1755 }\endgroup
Chris@42 1756 \expandafter\edef\csname cmapOT1TT\endcsname#1{%
Chris@42 1757 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
Chris@42 1758 }%
Chris@42 1759 \fi\fi
Chris@42 1760
Chris@42 1761
Chris@42 1762 % Set the font macro #1 to the font named \fontprefix#2.
Chris@42 1763 % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
Chris@42 1764 % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
Chris@42 1765 % Example:
Chris@42 1766 % #1 = \textrm
Chris@42 1767 % #2 = \rmshape
Chris@42 1768 % #3 = 10
Chris@42 1769 % #4 = \mainmagstep
Chris@42 1770 % #5 = OT1
Chris@42 1771 %
Chris@42 1772 \def\setfont#1#2#3#4#5{%
Chris@42 1773 \font#1=\fontprefix#2#3 scaled #4
Chris@42 1774 \csname cmap#5\endcsname#1%
Chris@42 1775 }
Chris@42 1776 % This is what gets called when #5 of \setfont is empty.
Chris@42 1777 \let\cmap\gobble
Chris@42 1778 %
Chris@42 1779 % (end of cmaps)
Chris@42 1780
Chris@42 1781 % Use cm as the default font prefix.
Chris@42 1782 % To specify the font prefix, you must define \fontprefix
Chris@42 1783 % before you read in texinfo.tex.
Chris@42 1784 \ifx\fontprefix\thisisundefined
Chris@42 1785 \def\fontprefix{cm}
Chris@42 1786 \fi
Chris@42 1787 % Support font families that don't use the same naming scheme as CM.
Chris@42 1788 \def\rmshape{r}
Chris@42 1789 \def\rmbshape{bx} % where the normal face is bold
Chris@42 1790 \def\bfshape{b}
Chris@42 1791 \def\bxshape{bx}
Chris@42 1792 \def\ttshape{tt}
Chris@42 1793 \def\ttbshape{tt}
Chris@42 1794 \def\ttslshape{sltt}
Chris@42 1795 \def\itshape{ti}
Chris@42 1796 \def\itbshape{bxti}
Chris@42 1797 \def\slshape{sl}
Chris@42 1798 \def\slbshape{bxsl}
Chris@42 1799 \def\sfshape{ss}
Chris@42 1800 \def\sfbshape{ss}
Chris@42 1801 \def\scshape{csc}
Chris@42 1802 \def\scbshape{csc}
Chris@42 1803
Chris@42 1804 % Definitions for a main text size of 11pt. (The default in Texinfo.)
Chris@42 1805 %
Chris@42 1806 \def\definetextfontsizexi{%
Chris@42 1807 % Text fonts (11.2pt, magstep1).
Chris@42 1808 \def\textnominalsize{11pt}
Chris@42 1809 \edef\mainmagstep{\magstephalf}
Chris@42 1810 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
Chris@42 1811 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
Chris@42 1812 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
Chris@42 1813 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
Chris@42 1814 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
Chris@42 1815 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
Chris@42 1816 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
Chris@42 1817 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
Chris@42 1818 \font\texti=cmmi10 scaled \mainmagstep
Chris@42 1819 \font\textsy=cmsy10 scaled \mainmagstep
Chris@42 1820 \def\textecsize{1095}
Chris@42 1821
Chris@42 1822 % A few fonts for @defun names and args.
Chris@42 1823 \setfont\defbf\bfshape{10}{\magstep1}{OT1}
Chris@42 1824 \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
Chris@42 1825 \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
Chris@42 1826 \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
Chris@42 1827
Chris@42 1828 % Fonts for indices, footnotes, small examples (9pt).
Chris@42 1829 \def\smallnominalsize{9pt}
Chris@42 1830 \setfont\smallrm\rmshape{9}{1000}{OT1}
Chris@42 1831 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
Chris@42 1832 \setfont\smallbf\bfshape{10}{900}{OT1}
Chris@42 1833 \setfont\smallit\itshape{9}{1000}{OT1IT}
Chris@42 1834 \setfont\smallsl\slshape{9}{1000}{OT1}
Chris@42 1835 \setfont\smallsf\sfshape{9}{1000}{OT1}
Chris@42 1836 \setfont\smallsc\scshape{10}{900}{OT1}
Chris@42 1837 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
Chris@42 1838 \font\smalli=cmmi9
Chris@42 1839 \font\smallsy=cmsy9
Chris@42 1840 \def\smallecsize{0900}
Chris@42 1841
Chris@42 1842 % Fonts for small examples (8pt).
Chris@42 1843 \def\smallernominalsize{8pt}
Chris@42 1844 \setfont\smallerrm\rmshape{8}{1000}{OT1}
Chris@42 1845 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
Chris@42 1846 \setfont\smallerbf\bfshape{10}{800}{OT1}
Chris@42 1847 \setfont\smallerit\itshape{8}{1000}{OT1IT}
Chris@42 1848 \setfont\smallersl\slshape{8}{1000}{OT1}
Chris@42 1849 \setfont\smallersf\sfshape{8}{1000}{OT1}
Chris@42 1850 \setfont\smallersc\scshape{10}{800}{OT1}
Chris@42 1851 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
Chris@42 1852 \font\smalleri=cmmi8
Chris@42 1853 \font\smallersy=cmsy8
Chris@42 1854 \def\smallerecsize{0800}
Chris@42 1855
Chris@42 1856 % Fonts for title page (20.4pt):
Chris@42 1857 \def\titlenominalsize{20pt}
Chris@42 1858 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
Chris@42 1859 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
Chris@42 1860 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
Chris@42 1861 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
Chris@42 1862 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
Chris@42 1863 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
Chris@42 1864 \let\titlebf=\titlerm
Chris@42 1865 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
Chris@42 1866 \font\titlei=cmmi12 scaled \magstep3
Chris@42 1867 \font\titlesy=cmsy10 scaled \magstep4
Chris@42 1868 \def\titleecsize{2074}
Chris@42 1869
Chris@42 1870 % Chapter (and unnumbered) fonts (17.28pt).
Chris@42 1871 \def\chapnominalsize{17pt}
Chris@42 1872 \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
Chris@42 1873 \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
Chris@42 1874 \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
Chris@42 1875 \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
Chris@42 1876 \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
Chris@42 1877 \setfont\chapsf\sfbshape{17}{1000}{OT1}
Chris@42 1878 \let\chapbf=\chaprm
Chris@42 1879 \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
Chris@42 1880 \font\chapi=cmmi12 scaled \magstep2
Chris@42 1881 \font\chapsy=cmsy10 scaled \magstep3
Chris@42 1882 \def\chapecsize{1728}
Chris@42 1883
Chris@42 1884 % Section fonts (14.4pt).
Chris@42 1885 \def\secnominalsize{14pt}
Chris@42 1886 \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
Chris@42 1887 \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
Chris@42 1888 \setfont\secsl\slbshape{10}{\magstep2}{OT1}
Chris@42 1889 \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
Chris@42 1890 \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
Chris@42 1891 \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
Chris@42 1892 \let\secbf\secrm
Chris@42 1893 \setfont\secsc\scbshape{10}{\magstep2}{OT1}
Chris@42 1894 \font\seci=cmmi12 scaled \magstep1
Chris@42 1895 \font\secsy=cmsy10 scaled \magstep2
Chris@42 1896 \def\sececsize{1440}
Chris@42 1897
Chris@42 1898 % Subsection fonts (13.15pt).
Chris@42 1899 \def\ssecnominalsize{13pt}
Chris@42 1900 \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
Chris@42 1901 \setfont\ssecit\itbshape{10}{1315}{OT1IT}
Chris@42 1902 \setfont\ssecsl\slbshape{10}{1315}{OT1}
Chris@42 1903 \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
Chris@42 1904 \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
Chris@42 1905 \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
Chris@42 1906 \let\ssecbf\ssecrm
Chris@42 1907 \setfont\ssecsc\scbshape{10}{1315}{OT1}
Chris@42 1908 \font\sseci=cmmi12 scaled \magstephalf
Chris@42 1909 \font\ssecsy=cmsy10 scaled 1315
Chris@42 1910 \def\ssececsize{1200}
Chris@42 1911
Chris@42 1912 % Reduced fonts for @acro in text (10pt).
Chris@42 1913 \def\reducednominalsize{10pt}
Chris@42 1914 \setfont\reducedrm\rmshape{10}{1000}{OT1}
Chris@42 1915 \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
Chris@42 1916 \setfont\reducedbf\bfshape{10}{1000}{OT1}
Chris@42 1917 \setfont\reducedit\itshape{10}{1000}{OT1IT}
Chris@42 1918 \setfont\reducedsl\slshape{10}{1000}{OT1}
Chris@42 1919 \setfont\reducedsf\sfshape{10}{1000}{OT1}
Chris@42 1920 \setfont\reducedsc\scshape{10}{1000}{OT1}
Chris@42 1921 \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
Chris@42 1922 \font\reducedi=cmmi10
Chris@42 1923 \font\reducedsy=cmsy10
Chris@42 1924 \def\reducedecsize{1000}
Chris@42 1925
Chris@42 1926 \textleading = 13.2pt % line spacing for 11pt CM
Chris@42 1927 \textfonts % reset the current fonts
Chris@42 1928 \rm
Chris@42 1929 } % end of 11pt text font size definitions, \definetextfontsizexi
Chris@42 1930
Chris@42 1931
Chris@42 1932 % Definitions to make the main text be 10pt Computer Modern, with
Chris@42 1933 % section, chapter, etc., sizes following suit. This is for the GNU
Chris@42 1934 % Press printing of the Emacs 22 manual. Maybe other manuals in the
Chris@42 1935 % future. Used with @smallbook, which sets the leading to 12pt.
Chris@42 1936 %
Chris@42 1937 \def\definetextfontsizex{%
Chris@42 1938 % Text fonts (10pt).
Chris@42 1939 \def\textnominalsize{10pt}
Chris@42 1940 \edef\mainmagstep{1000}
Chris@42 1941 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
Chris@42 1942 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
Chris@42 1943 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
Chris@42 1944 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
Chris@42 1945 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
Chris@42 1946 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
Chris@42 1947 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
Chris@42 1948 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
Chris@42 1949 \font\texti=cmmi10 scaled \mainmagstep
Chris@42 1950 \font\textsy=cmsy10 scaled \mainmagstep
Chris@42 1951 \def\textecsize{1000}
Chris@42 1952
Chris@42 1953 % A few fonts for @defun names and args.
Chris@42 1954 \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
Chris@42 1955 \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
Chris@42 1956 \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
Chris@42 1957 \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
Chris@42 1958
Chris@42 1959 % Fonts for indices, footnotes, small examples (9pt).
Chris@42 1960 \def\smallnominalsize{9pt}
Chris@42 1961 \setfont\smallrm\rmshape{9}{1000}{OT1}
Chris@42 1962 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
Chris@42 1963 \setfont\smallbf\bfshape{10}{900}{OT1}
Chris@42 1964 \setfont\smallit\itshape{9}{1000}{OT1IT}
Chris@42 1965 \setfont\smallsl\slshape{9}{1000}{OT1}
Chris@42 1966 \setfont\smallsf\sfshape{9}{1000}{OT1}
Chris@42 1967 \setfont\smallsc\scshape{10}{900}{OT1}
Chris@42 1968 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
Chris@42 1969 \font\smalli=cmmi9
Chris@42 1970 \font\smallsy=cmsy9
Chris@42 1971 \def\smallecsize{0900}
Chris@42 1972
Chris@42 1973 % Fonts for small examples (8pt).
Chris@42 1974 \def\smallernominalsize{8pt}
Chris@42 1975 \setfont\smallerrm\rmshape{8}{1000}{OT1}
Chris@42 1976 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
Chris@42 1977 \setfont\smallerbf\bfshape{10}{800}{OT1}
Chris@42 1978 \setfont\smallerit\itshape{8}{1000}{OT1IT}
Chris@42 1979 \setfont\smallersl\slshape{8}{1000}{OT1}
Chris@42 1980 \setfont\smallersf\sfshape{8}{1000}{OT1}
Chris@42 1981 \setfont\smallersc\scshape{10}{800}{OT1}
Chris@42 1982 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
Chris@42 1983 \font\smalleri=cmmi8
Chris@42 1984 \font\smallersy=cmsy8
Chris@42 1985 \def\smallerecsize{0800}
Chris@42 1986
Chris@42 1987 % Fonts for title page (20.4pt):
Chris@42 1988 \def\titlenominalsize{20pt}
Chris@42 1989 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
Chris@42 1990 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
Chris@42 1991 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
Chris@42 1992 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
Chris@42 1993 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
Chris@42 1994 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
Chris@42 1995 \let\titlebf=\titlerm
Chris@42 1996 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
Chris@42 1997 \font\titlei=cmmi12 scaled \magstep3
Chris@42 1998 \font\titlesy=cmsy10 scaled \magstep4
Chris@42 1999 \def\titleecsize{2074}
Chris@42 2000
Chris@42 2001 % Chapter fonts (14.4pt).
Chris@42 2002 \def\chapnominalsize{14pt}
Chris@42 2003 \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
Chris@42 2004 \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
Chris@42 2005 \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
Chris@42 2006 \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
Chris@42 2007 \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
Chris@42 2008 \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
Chris@42 2009 \let\chapbf\chaprm
Chris@42 2010 \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
Chris@42 2011 \font\chapi=cmmi12 scaled \magstep1
Chris@42 2012 \font\chapsy=cmsy10 scaled \magstep2
Chris@42 2013 \def\chapecsize{1440}
Chris@42 2014
Chris@42 2015 % Section fonts (12pt).
Chris@42 2016 \def\secnominalsize{12pt}
Chris@42 2017 \setfont\secrm\rmbshape{12}{1000}{OT1}
Chris@42 2018 \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
Chris@42 2019 \setfont\secsl\slbshape{10}{\magstep1}{OT1}
Chris@42 2020 \setfont\sectt\ttbshape{12}{1000}{OT1TT}
Chris@42 2021 \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
Chris@42 2022 \setfont\secsf\sfbshape{12}{1000}{OT1}
Chris@42 2023 \let\secbf\secrm
Chris@42 2024 \setfont\secsc\scbshape{10}{\magstep1}{OT1}
Chris@42 2025 \font\seci=cmmi12
Chris@42 2026 \font\secsy=cmsy10 scaled \magstep1
Chris@42 2027 \def\sececsize{1200}
Chris@42 2028
Chris@42 2029 % Subsection fonts (10pt).
Chris@42 2030 \def\ssecnominalsize{10pt}
Chris@42 2031 \setfont\ssecrm\rmbshape{10}{1000}{OT1}
Chris@42 2032 \setfont\ssecit\itbshape{10}{1000}{OT1IT}
Chris@42 2033 \setfont\ssecsl\slbshape{10}{1000}{OT1}
Chris@42 2034 \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
Chris@42 2035 \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
Chris@42 2036 \setfont\ssecsf\sfbshape{10}{1000}{OT1}
Chris@42 2037 \let\ssecbf\ssecrm
Chris@42 2038 \setfont\ssecsc\scbshape{10}{1000}{OT1}
Chris@42 2039 \font\sseci=cmmi10
Chris@42 2040 \font\ssecsy=cmsy10
Chris@42 2041 \def\ssececsize{1000}
Chris@42 2042
Chris@42 2043 % Reduced fonts for @acro in text (9pt).
Chris@42 2044 \def\reducednominalsize{9pt}
Chris@42 2045 \setfont\reducedrm\rmshape{9}{1000}{OT1}
Chris@42 2046 \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
Chris@42 2047 \setfont\reducedbf\bfshape{10}{900}{OT1}
Chris@42 2048 \setfont\reducedit\itshape{9}{1000}{OT1IT}
Chris@42 2049 \setfont\reducedsl\slshape{9}{1000}{OT1}
Chris@42 2050 \setfont\reducedsf\sfshape{9}{1000}{OT1}
Chris@42 2051 \setfont\reducedsc\scshape{10}{900}{OT1}
Chris@42 2052 \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
Chris@42 2053 \font\reducedi=cmmi9
Chris@42 2054 \font\reducedsy=cmsy9
Chris@42 2055 \def\reducedecsize{0900}
Chris@42 2056
Chris@42 2057 \divide\parskip by 2 % reduce space between paragraphs
Chris@42 2058 \textleading = 12pt % line spacing for 10pt CM
Chris@42 2059 \textfonts % reset the current fonts
Chris@42 2060 \rm
Chris@42 2061 } % end of 10pt text font size definitions, \definetextfontsizex
Chris@42 2062
Chris@42 2063
Chris@42 2064 % We provide the user-level command
Chris@42 2065 % @fonttextsize 10
Chris@42 2066 % (or 11) to redefine the text font size. pt is assumed.
Chris@42 2067 %
Chris@42 2068 \def\xiword{11}
Chris@42 2069 \def\xword{10}
Chris@42 2070 \def\xwordpt{10pt}
Chris@42 2071 %
Chris@42 2072 \parseargdef\fonttextsize{%
Chris@42 2073 \def\textsizearg{#1}%
Chris@42 2074 %\wlog{doing @fonttextsize \textsizearg}%
Chris@42 2075 %
Chris@42 2076 % Set \globaldefs so that documents can use this inside @tex, since
Chris@42 2077 % makeinfo 4.8 does not support it, but we need it nonetheless.
Chris@42 2078 %
Chris@42 2079 \begingroup \globaldefs=1
Chris@42 2080 \ifx\textsizearg\xword \definetextfontsizex
Chris@42 2081 \else \ifx\textsizearg\xiword \definetextfontsizexi
Chris@42 2082 \else
Chris@42 2083 \errhelp=\EMsimple
Chris@42 2084 \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
Chris@42 2085 \fi\fi
Chris@42 2086 \endgroup
Chris@42 2087 }
Chris@42 2088
Chris@42 2089
Chris@42 2090 % In order for the font changes to affect most math symbols and letters,
Chris@42 2091 % we have to define the \textfont of the standard families. Since
Chris@42 2092 % texinfo doesn't allow for producing subscripts and superscripts except
Chris@42 2093 % in the main text, we don't bother to reset \scriptfont and
Chris@42 2094 % \scriptscriptfont (which would also require loading a lot more fonts).
Chris@42 2095 %
Chris@42 2096 \def\resetmathfonts{%
Chris@42 2097 \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
Chris@42 2098 \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
Chris@42 2099 \textfont\ttfam=\tentt \textfont\sffam=\tensf
Chris@42 2100 }
Chris@42 2101
Chris@42 2102 % The font-changing commands redefine the meanings of \tenSTYLE, instead
Chris@42 2103 % of just \STYLE. We do this because \STYLE needs to also set the
Chris@42 2104 % current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire
Chris@42 2105 % \tenSTYLE to set the current font.
Chris@42 2106 %
Chris@42 2107 % Each font-changing command also sets the names \lsize (one size lower)
Chris@42 2108 % and \lllsize (three sizes lower). These relative commands are used in
Chris@42 2109 % the LaTeX logo and acronyms.
Chris@42 2110 %
Chris@42 2111 % This all needs generalizing, badly.
Chris@42 2112 %
Chris@42 2113 \def\textfonts{%
Chris@42 2114 \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
Chris@42 2115 \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
Chris@42 2116 \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
Chris@42 2117 \let\tenttsl=\textttsl
Chris@42 2118 \def\curfontsize{text}%
Chris@42 2119 \def\lsize{reduced}\def\lllsize{smaller}%
Chris@42 2120 \resetmathfonts \setleading{\textleading}}
Chris@42 2121 \def\titlefonts{%
Chris@42 2122 \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
Chris@42 2123 \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
Chris@42 2124 \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
Chris@42 2125 \let\tenttsl=\titlettsl
Chris@42 2126 \def\curfontsize{title}%
Chris@42 2127 \def\lsize{chap}\def\lllsize{subsec}%
Chris@42 2128 \resetmathfonts \setleading{27pt}}
Chris@42 2129 \def\titlefont#1{{\titlefonts\rmisbold #1}}
Chris@42 2130 \def\chapfonts{%
Chris@42 2131 \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
Chris@42 2132 \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
Chris@42 2133 \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
Chris@42 2134 \let\tenttsl=\chapttsl
Chris@42 2135 \def\curfontsize{chap}%
Chris@42 2136 \def\lsize{sec}\def\lllsize{text}%
Chris@42 2137 \resetmathfonts \setleading{19pt}}
Chris@42 2138 \def\secfonts{%
Chris@42 2139 \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
Chris@42 2140 \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
Chris@42 2141 \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
Chris@42 2142 \let\tenttsl=\secttsl
Chris@42 2143 \def\curfontsize{sec}%
Chris@42 2144 \def\lsize{subsec}\def\lllsize{reduced}%
Chris@42 2145 \resetmathfonts \setleading{16pt}}
Chris@42 2146 \def\subsecfonts{%
Chris@42 2147 \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
Chris@42 2148 \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
Chris@42 2149 \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
Chris@42 2150 \let\tenttsl=\ssecttsl
Chris@42 2151 \def\curfontsize{ssec}%
Chris@42 2152 \def\lsize{text}\def\lllsize{small}%
Chris@42 2153 \resetmathfonts \setleading{15pt}}
Chris@42 2154 \let\subsubsecfonts = \subsecfonts
Chris@42 2155 \def\reducedfonts{%
Chris@42 2156 \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl
Chris@42 2157 \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc
Chris@42 2158 \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy
Chris@42 2159 \let\tenttsl=\reducedttsl
Chris@42 2160 \def\curfontsize{reduced}%
Chris@42 2161 \def\lsize{small}\def\lllsize{smaller}%
Chris@42 2162 \resetmathfonts \setleading{10.5pt}}
Chris@42 2163 \def\smallfonts{%
Chris@42 2164 \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
Chris@42 2165 \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
Chris@42 2166 \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
Chris@42 2167 \let\tenttsl=\smallttsl
Chris@42 2168 \def\curfontsize{small}%
Chris@42 2169 \def\lsize{smaller}\def\lllsize{smaller}%
Chris@42 2170 \resetmathfonts \setleading{10.5pt}}
Chris@42 2171 \def\smallerfonts{%
Chris@42 2172 \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
Chris@42 2173 \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
Chris@42 2174 \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
Chris@42 2175 \let\tenttsl=\smallerttsl
Chris@42 2176 \def\curfontsize{smaller}%
Chris@42 2177 \def\lsize{smaller}\def\lllsize{smaller}%
Chris@42 2178 \resetmathfonts \setleading{9.5pt}}
Chris@42 2179
Chris@42 2180 % Fonts for short table of contents.
Chris@42 2181 \setfont\shortcontrm\rmshape{12}{1000}{OT1}
Chris@42 2182 \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12
Chris@42 2183 \setfont\shortcontsl\slshape{12}{1000}{OT1}
Chris@42 2184 \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
Chris@42 2185
Chris@42 2186 % Define these just so they can be easily changed for other fonts.
Chris@42 2187 \def\angleleft{$\langle$}
Chris@42 2188 \def\angleright{$\rangle$}
Chris@42 2189
Chris@42 2190 % Set the fonts to use with the @small... environments.
Chris@42 2191 \let\smallexamplefonts = \smallfonts
Chris@42 2192
Chris@42 2193 % About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample
Chris@42 2194 % can fit this many characters:
Chris@42 2195 % 8.5x11=86 smallbook=72 a4=90 a5=69
Chris@42 2196 % If we use \scriptfonts (8pt), then we can fit this many characters:
Chris@42 2197 % 8.5x11=90+ smallbook=80 a4=90+ a5=77
Chris@42 2198 % For me, subjectively, the few extra characters that fit aren't worth
Chris@42 2199 % the additional smallness of 8pt. So I'm making the default 9pt.
Chris@42 2200 %
Chris@42 2201 % By the way, for comparison, here's what fits with @example (10pt):
Chris@42 2202 % 8.5x11=71 smallbook=60 a4=75 a5=58
Chris@42 2203 % --karl, 24jan03.
Chris@42 2204
Chris@42 2205 % Set up the default fonts, so we can use them for creating boxes.
Chris@42 2206 %
Chris@42 2207 \definetextfontsizexi
Chris@42 2208
Chris@42 2209
Chris@42 2210 \message{markup,}
Chris@42 2211
Chris@42 2212 % Check if we are currently using a typewriter font. Since all the
Chris@42 2213 % Computer Modern typewriter fonts have zero interword stretch (and
Chris@42 2214 % shrink), and it is reasonable to expect all typewriter fonts to have
Chris@42 2215 % this property, we can check that font parameter.
Chris@42 2216 %
Chris@42 2217 \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
Chris@42 2218
Chris@42 2219 % Markup style infrastructure. \defmarkupstylesetup\INITMACRO will
Chris@42 2220 % define and register \INITMACRO to be called on markup style changes.
Chris@42 2221 % \INITMACRO can check \currentmarkupstyle for the innermost
Chris@42 2222 % style and the set of \ifmarkupSTYLE switches for all styles
Chris@42 2223 % currently in effect.
Chris@42 2224 \newif\ifmarkupvar
Chris@42 2225 \newif\ifmarkupsamp
Chris@42 2226 \newif\ifmarkupkey
Chris@42 2227 %\newif\ifmarkupfile % @file == @samp.
Chris@42 2228 %\newif\ifmarkupoption % @option == @samp.
Chris@42 2229 \newif\ifmarkupcode
Chris@42 2230 \newif\ifmarkupkbd
Chris@42 2231 %\newif\ifmarkupenv % @env == @code.
Chris@42 2232 %\newif\ifmarkupcommand % @command == @code.
Chris@42 2233 \newif\ifmarkuptex % @tex (and part of @math, for now).
Chris@42 2234 \newif\ifmarkupexample
Chris@42 2235 \newif\ifmarkupverb
Chris@42 2236 \newif\ifmarkupverbatim
Chris@42 2237
Chris@42 2238 \let\currentmarkupstyle\empty
Chris@42 2239
Chris@42 2240 \def\setupmarkupstyle#1{%
Chris@42 2241 \csname markup#1true\endcsname
Chris@42 2242 \def\currentmarkupstyle{#1}%
Chris@42 2243 \markupstylesetup
Chris@42 2244 }
Chris@42 2245
Chris@42 2246 \let\markupstylesetup\empty
Chris@42 2247
Chris@42 2248 \def\defmarkupstylesetup#1{%
Chris@42 2249 \expandafter\def\expandafter\markupstylesetup
Chris@42 2250 \expandafter{\markupstylesetup #1}%
Chris@42 2251 \def#1%
Chris@42 2252 }
Chris@42 2253
Chris@42 2254 % Markup style setup for left and right quotes.
Chris@42 2255 \defmarkupstylesetup\markupsetuplq{%
Chris@42 2256 \expandafter\let\expandafter \temp
Chris@42 2257 \csname markupsetuplq\currentmarkupstyle\endcsname
Chris@42 2258 \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
Chris@42 2259 }
Chris@42 2260
Chris@42 2261 \defmarkupstylesetup\markupsetuprq{%
Chris@42 2262 \expandafter\let\expandafter \temp
Chris@42 2263 \csname markupsetuprq\currentmarkupstyle\endcsname
Chris@42 2264 \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
Chris@42 2265 }
Chris@42 2266
Chris@42 2267 {
Chris@42 2268 \catcode`\'=\active
Chris@42 2269 \catcode`\`=\active
Chris@42 2270
Chris@42 2271 \gdef\markupsetuplqdefault{\let`\lq}
Chris@42 2272 \gdef\markupsetuprqdefault{\let'\rq}
Chris@42 2273
Chris@42 2274 \gdef\markupsetcodequoteleft{\let`\codequoteleft}
Chris@42 2275 \gdef\markupsetcodequoteright{\let'\codequoteright}
Chris@42 2276 }
Chris@42 2277
Chris@42 2278 \let\markupsetuplqcode \markupsetcodequoteleft
Chris@42 2279 \let\markupsetuprqcode \markupsetcodequoteright
Chris@42 2280 %
Chris@42 2281 \let\markupsetuplqexample \markupsetcodequoteleft
Chris@42 2282 \let\markupsetuprqexample \markupsetcodequoteright
Chris@42 2283 %
Chris@42 2284 \let\markupsetuplqkbd \markupsetcodequoteleft
Chris@42 2285 \let\markupsetuprqkbd \markupsetcodequoteright
Chris@42 2286 %
Chris@42 2287 \let\markupsetuplqsamp \markupsetcodequoteleft
Chris@42 2288 \let\markupsetuprqsamp \markupsetcodequoteright
Chris@42 2289 %
Chris@42 2290 \let\markupsetuplqverb \markupsetcodequoteleft
Chris@42 2291 \let\markupsetuprqverb \markupsetcodequoteright
Chris@42 2292 %
Chris@42 2293 \let\markupsetuplqverbatim \markupsetcodequoteleft
Chris@42 2294 \let\markupsetuprqverbatim \markupsetcodequoteright
Chris@42 2295
Chris@42 2296 % Allow an option to not use regular directed right quote/apostrophe
Chris@42 2297 % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
Chris@42 2298 % The undirected quote is ugly, so don't make it the default, but it
Chris@42 2299 % works for pasting with more pdf viewers (at least evince), the
Chris@42 2300 % lilypond developers report. xpdf does work with the regular 0x27.
Chris@42 2301 %
Chris@42 2302 \def\codequoteright{%
Chris@42 2303 \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
Chris@42 2304 \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
Chris@42 2305 '%
Chris@42 2306 \else \char'15 \fi
Chris@42 2307 \else \char'15 \fi
Chris@42 2308 }
Chris@42 2309 %
Chris@42 2310 % and a similar option for the left quote char vs. a grave accent.
Chris@42 2311 % Modern fonts display ASCII 0x60 as a grave accent, so some people like
Chris@42 2312 % the code environments to do likewise.
Chris@42 2313 %
Chris@42 2314 \def\codequoteleft{%
Chris@42 2315 \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
Chris@42 2316 \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
Chris@42 2317 % [Knuth] pp. 380,381,391
Chris@42 2318 % \relax disables Spanish ligatures ?` and !` of \tt font.
Chris@42 2319 \relax`%
Chris@42 2320 \else \char'22 \fi
Chris@42 2321 \else \char'22 \fi
Chris@42 2322 }
Chris@42 2323
Chris@42 2324 % Commands to set the quote options.
Chris@42 2325 %
Chris@42 2326 \parseargdef\codequoteundirected{%
Chris@42 2327 \def\temp{#1}%
Chris@42 2328 \ifx\temp\onword
Chris@42 2329 \expandafter\let\csname SETtxicodequoteundirected\endcsname
Chris@42 2330 = t%
Chris@42 2331 \else\ifx\temp\offword
Chris@42 2332 \expandafter\let\csname SETtxicodequoteundirected\endcsname
Chris@42 2333 = \relax
Chris@42 2334 \else
Chris@42 2335 \errhelp = \EMsimple
Chris@42 2336 \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
Chris@42 2337 \fi\fi
Chris@42 2338 }
Chris@42 2339 %
Chris@42 2340 \parseargdef\codequotebacktick{%
Chris@42 2341 \def\temp{#1}%
Chris@42 2342 \ifx\temp\onword
Chris@42 2343 \expandafter\let\csname SETtxicodequotebacktick\endcsname
Chris@42 2344 = t%
Chris@42 2345 \else\ifx\temp\offword
Chris@42 2346 \expandafter\let\csname SETtxicodequotebacktick\endcsname
Chris@42 2347 = \relax
Chris@42 2348 \else
Chris@42 2349 \errhelp = \EMsimple
Chris@42 2350 \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
Chris@42 2351 \fi\fi
Chris@42 2352 }
Chris@42 2353
Chris@42 2354 % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
Chris@42 2355 \def\noligaturesquoteleft{\relax\lq}
Chris@42 2356
Chris@42 2357 % Count depth in font-changes, for error checks
Chris@42 2358 \newcount\fontdepth \fontdepth=0
Chris@42 2359
Chris@42 2360 % Font commands.
Chris@42 2361
Chris@42 2362 % #1 is the font command (\sl or \it), #2 is the text to slant.
Chris@42 2363 % If we are in a monospaced environment, however, 1) always use \ttsl,
Chris@42 2364 % and 2) do not add an italic correction.
Chris@42 2365 \def\dosmartslant#1#2{%
Chris@42 2366 \ifusingtt
Chris@42 2367 {{\ttsl #2}\let\next=\relax}%
Chris@42 2368 {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
Chris@42 2369 \next
Chris@42 2370 }
Chris@42 2371 \def\smartslanted{\dosmartslant\sl}
Chris@42 2372 \def\smartitalic{\dosmartslant\it}
Chris@42 2373
Chris@42 2374 % Output an italic correction unless \next (presumed to be the following
Chris@42 2375 % character) is such as not to need one.
Chris@42 2376 \def\smartitaliccorrection{%
Chris@42 2377 \ifx\next,%
Chris@42 2378 \else\ifx\next-%
Chris@42 2379 \else\ifx\next.%
Chris@42 2380 \else\ptexslash
Chris@42 2381 \fi\fi\fi
Chris@42 2382 \aftersmartic
Chris@42 2383 }
Chris@42 2384
Chris@42 2385 % Unconditional use \ttsl, and no ic. @var is set to this for defuns.
Chris@42 2386 \def\ttslanted#1{{\ttsl #1}}
Chris@42 2387
Chris@42 2388 % @cite is like \smartslanted except unconditionally use \sl. We never want
Chris@42 2389 % ttsl for book titles, do we?
Chris@42 2390 \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
Chris@42 2391
Chris@42 2392 \def\aftersmartic{}
Chris@42 2393 \def\var#1{%
Chris@42 2394 \let\saveaftersmartic = \aftersmartic
Chris@42 2395 \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
Chris@42 2396 \smartslanted{#1}%
Chris@42 2397 }
Chris@42 2398
Chris@42 2399 \let\i=\smartitalic
Chris@42 2400 \let\slanted=\smartslanted
Chris@42 2401 \let\dfn=\smartslanted
Chris@42 2402 \let\emph=\smartitalic
Chris@42 2403
Chris@42 2404 % Explicit font changes: @r, @sc, undocumented @ii.
Chris@42 2405 \def\r#1{{\rm #1}} % roman font
Chris@42 2406 \def\sc#1{{\smallcaps#1}} % smallcaps font
Chris@42 2407 \def\ii#1{{\it #1}} % italic font
Chris@42 2408
Chris@42 2409 % @b, explicit bold. Also @strong.
Chris@42 2410 \def\b#1{{\bf #1}}
Chris@42 2411 \let\strong=\b
Chris@42 2412
Chris@42 2413 % @sansserif, explicit sans.
Chris@42 2414 \def\sansserif#1{{\sf #1}}
Chris@42 2415
Chris@42 2416 % We can't just use \exhyphenpenalty, because that only has effect at
Chris@42 2417 % the end of a paragraph. Restore normal hyphenation at the end of the
Chris@42 2418 % group within which \nohyphenation is presumably called.
Chris@42 2419 %
Chris@42 2420 \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
Chris@42 2421 \def\restorehyphenation{\hyphenchar\font = `- }
Chris@42 2422
Chris@42 2423 % Set sfcode to normal for the chars that usually have another value.
Chris@42 2424 % Can't use plain's \frenchspacing because it uses the `\x notation, and
Chris@42 2425 % sometimes \x has an active definition that messes things up.
Chris@42 2426 %
Chris@42 2427 \catcode`@=11
Chris@42 2428 \def\plainfrenchspacing{%
Chris@42 2429 \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m
Chris@42 2430 \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m
Chris@42 2431 \def\endofsentencespacefactor{1000}% for @. and friends
Chris@42 2432 }
Chris@42 2433 \def\plainnonfrenchspacing{%
Chris@42 2434 \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
Chris@42 2435 \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
Chris@42 2436 \def\endofsentencespacefactor{3000}% for @. and friends
Chris@42 2437 }
Chris@42 2438 \catcode`@=\other
Chris@42 2439 \def\endofsentencespacefactor{3000}% default
Chris@42 2440
Chris@42 2441 % @t, explicit typewriter.
Chris@42 2442 \def\t#1{%
Chris@42 2443 {\tt \rawbackslash \plainfrenchspacing #1}%
Chris@42 2444 \null
Chris@42 2445 }
Chris@42 2446
Chris@42 2447 % @samp.
Chris@42 2448 \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
Chris@42 2449
Chris@42 2450 % @indicateurl is \samp, that is, with quotes.
Chris@42 2451 \let\indicateurl=\samp
Chris@42 2452
Chris@42 2453 % @code (and similar) prints in typewriter, but with spaces the same
Chris@42 2454 % size as normal in the surrounding text, without hyphenation, etc.
Chris@42 2455 % This is a subroutine for that.
Chris@42 2456 \def\tclose#1{%
Chris@42 2457 {%
Chris@42 2458 % Change normal interword space to be same as for the current font.
Chris@42 2459 \spaceskip = \fontdimen2\font
Chris@42 2460 %
Chris@42 2461 % Switch to typewriter.
Chris@42 2462 \tt
Chris@42 2463 %
Chris@42 2464 % But `\ ' produces the large typewriter interword space.
Chris@42 2465 \def\ {{\spaceskip = 0pt{} }}%
Chris@42 2466 %
Chris@42 2467 % Turn off hyphenation.
Chris@42 2468 \nohyphenation
Chris@42 2469 %
Chris@42 2470 \rawbackslash
Chris@42 2471 \plainfrenchspacing
Chris@42 2472 #1%
Chris@42 2473 }%
Chris@42 2474 \null % reset spacefactor to 1000
Chris@42 2475 }
Chris@42 2476
Chris@42 2477 % We *must* turn on hyphenation at `-' and `_' in @code.
Chris@42 2478 % Otherwise, it is too hard to avoid overfull hboxes
Chris@42 2479 % in the Emacs manual, the Library manual, etc.
Chris@42 2480 %
Chris@42 2481 % Unfortunately, TeX uses one parameter (\hyphenchar) to control
Chris@42 2482 % both hyphenation at - and hyphenation within words.
Chris@42 2483 % We must therefore turn them both off (\tclose does that)
Chris@42 2484 % and arrange explicitly to hyphenate at a dash.
Chris@42 2485 % -- rms.
Chris@42 2486 {
Chris@42 2487 \catcode`\-=\active \catcode`\_=\active
Chris@42 2488 \catcode`\'=\active \catcode`\`=\active
Chris@42 2489 \global\let'=\rq \global\let`=\lq % default definitions
Chris@42 2490 %
Chris@42 2491 \global\def\code{\begingroup
Chris@42 2492 \setupmarkupstyle{code}%
Chris@42 2493 % The following should really be moved into \setupmarkupstyle handlers.
Chris@42 2494 \catcode\dashChar=\active \catcode\underChar=\active
Chris@42 2495 \ifallowcodebreaks
Chris@42 2496 \let-\codedash
Chris@42 2497 \let_\codeunder
Chris@42 2498 \else
Chris@42 2499 \let-\normaldash
Chris@42 2500 \let_\realunder
Chris@42 2501 \fi
Chris@42 2502 \codex
Chris@42 2503 }
Chris@42 2504 }
Chris@42 2505
Chris@42 2506 \def\codex #1{\tclose{#1}\endgroup}
Chris@42 2507
Chris@42 2508 \def\normaldash{-}
Chris@42 2509 \def\codedash{-\discretionary{}{}{}}
Chris@42 2510 \def\codeunder{%
Chris@42 2511 % this is all so @math{@code{var_name}+1} can work. In math mode, _
Chris@42 2512 % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
Chris@42 2513 % will therefore expand the active definition of _, which is us
Chris@42 2514 % (inside @code that is), therefore an endless loop.
Chris@42 2515 \ifusingtt{\ifmmode
Chris@42 2516 \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
Chris@42 2517 \else\normalunderscore \fi
Chris@42 2518 \discretionary{}{}{}}%
Chris@42 2519 {\_}%
Chris@42 2520 }
Chris@42 2521
Chris@42 2522 % An additional complication: the above will allow breaks after, e.g.,
Chris@42 2523 % each of the four underscores in __typeof__. This is bad.
Chris@42 2524 % @allowcodebreaks provides a document-level way to turn breaking at -
Chris@42 2525 % and _ on and off.
Chris@42 2526 %
Chris@42 2527 \newif\ifallowcodebreaks \allowcodebreakstrue
Chris@42 2528
Chris@42 2529 \def\keywordtrue{true}
Chris@42 2530 \def\keywordfalse{false}
Chris@42 2531
Chris@42 2532 \parseargdef\allowcodebreaks{%
Chris@42 2533 \def\txiarg{#1}%
Chris@42 2534 \ifx\txiarg\keywordtrue
Chris@42 2535 \allowcodebreakstrue
Chris@42 2536 \else\ifx\txiarg\keywordfalse
Chris@42 2537 \allowcodebreaksfalse
Chris@42 2538 \else
Chris@42 2539 \errhelp = \EMsimple
Chris@42 2540 \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
Chris@42 2541 \fi\fi
Chris@42 2542 }
Chris@42 2543
Chris@42 2544 % For @command, @env, @file, @option quotes seem unnecessary,
Chris@42 2545 % so use \code rather than \samp.
Chris@42 2546 \let\command=\code
Chris@42 2547 \let\env=\code
Chris@42 2548 \let\file=\code
Chris@42 2549 \let\option=\code
Chris@42 2550
Chris@42 2551 % @uref (abbreviation for `urlref') takes an optional (comma-separated)
Chris@42 2552 % second argument specifying the text to display and an optional third
Chris@42 2553 % arg as text to display instead of (rather than in addition to) the url
Chris@42 2554 % itself. First (mandatory) arg is the url.
Chris@42 2555 % (This \urefnobreak definition isn't used now, leaving it for a while
Chris@42 2556 % for comparison.)
Chris@42 2557 \def\urefnobreak#1{\dourefnobreak #1,,,\finish}
Chris@42 2558 \def\dourefnobreak#1,#2,#3,#4\finish{\begingroup
Chris@42 2559 \unsepspaces
Chris@42 2560 \pdfurl{#1}%
Chris@42 2561 \setbox0 = \hbox{\ignorespaces #3}%
Chris@42 2562 \ifdim\wd0 > 0pt
Chris@42 2563 \unhbox0 % third arg given, show only that
Chris@42 2564 \else
Chris@42 2565 \setbox0 = \hbox{\ignorespaces #2}%
Chris@42 2566 \ifdim\wd0 > 0pt
Chris@42 2567 \ifpdf
Chris@42 2568 \unhbox0 % PDF: 2nd arg given, show only it
Chris@42 2569 \else
Chris@42 2570 \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
Chris@42 2571 \fi
Chris@42 2572 \else
Chris@42 2573 \code{#1}% only url given, so show it
Chris@42 2574 \fi
Chris@42 2575 \fi
Chris@42 2576 \endlink
Chris@42 2577 \endgroup}
Chris@42 2578
Chris@42 2579 % This \urefbreak definition is the active one.
Chris@42 2580 \def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
Chris@42 2581 \let\uref=\urefbreak
Chris@42 2582 \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
Chris@42 2583 \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
Chris@42 2584 \unsepspaces
Chris@42 2585 \pdfurl{#1}%
Chris@42 2586 \setbox0 = \hbox{\ignorespaces #3}%
Chris@42 2587 \ifdim\wd0 > 0pt
Chris@42 2588 \unhbox0 % third arg given, show only that
Chris@42 2589 \else
Chris@42 2590 \setbox0 = \hbox{\ignorespaces #2}%
Chris@42 2591 \ifdim\wd0 > 0pt
Chris@42 2592 \ifpdf
Chris@42 2593 \unhbox0 % PDF: 2nd arg given, show only it
Chris@42 2594 \else
Chris@42 2595 \unhbox0\ (\urefcode{#1})% DVI: 2nd arg given, show both it and url
Chris@42 2596 \fi
Chris@42 2597 \else
Chris@42 2598 \urefcode{#1}% only url given, so show it
Chris@42 2599 \fi
Chris@42 2600 \fi
Chris@42 2601 \endlink
Chris@42 2602 \endgroup}
Chris@42 2603
Chris@42 2604 % Allow line breaks around only a few characters (only).
Chris@42 2605 \def\urefcatcodes{%
Chris@42 2606 \catcode\ampChar=\active \catcode\dotChar=\active
Chris@42 2607 \catcode\hashChar=\active \catcode\questChar=\active
Chris@42 2608 \catcode\slashChar=\active
Chris@42 2609 }
Chris@42 2610 {
Chris@42 2611 \urefcatcodes
Chris@42 2612 %
Chris@42 2613 \global\def\urefcode{\begingroup
Chris@42 2614 \setupmarkupstyle{code}%
Chris@42 2615 \urefcatcodes
Chris@42 2616 \let&\urefcodeamp
Chris@42 2617 \let.\urefcodedot
Chris@42 2618 \let#\urefcodehash
Chris@42 2619 \let?\urefcodequest
Chris@42 2620 \let/\urefcodeslash
Chris@42 2621 \codex
Chris@42 2622 }
Chris@42 2623 %
Chris@42 2624 % By default, they are just regular characters.
Chris@42 2625 \global\def&{\normalamp}
Chris@42 2626 \global\def.{\normaldot}
Chris@42 2627 \global\def#{\normalhash}
Chris@42 2628 \global\def?{\normalquest}
Chris@42 2629 \global\def/{\normalslash}
Chris@42 2630 }
Chris@42 2631
Chris@42 2632 % we put a little stretch before and after the breakable chars, to help
Chris@42 2633 % line breaking of long url's. The unequal skips make look better in
Chris@42 2634 % cmtt at least, especially for dots.
Chris@42 2635 \def\urefprestretch{\urefprebreak \hskip0pt plus.13em }
Chris@42 2636 \def\urefpoststretch{\urefpostbreak \hskip0pt plus.1em }
Chris@42 2637 %
Chris@42 2638 \def\urefcodeamp{\urefprestretch \&\urefpoststretch}
Chris@42 2639 \def\urefcodedot{\urefprestretch .\urefpoststretch}
Chris@42 2640 \def\urefcodehash{\urefprestretch \#\urefpoststretch}
Chris@42 2641 \def\urefcodequest{\urefprestretch ?\urefpoststretch}
Chris@42 2642 \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
Chris@42 2643 {
Chris@42 2644 \catcode`\/=\active
Chris@42 2645 \global\def\urefcodeslashfinish{%
Chris@42 2646 \urefprestretch \slashChar
Chris@42 2647 % Allow line break only after the final / in a sequence of
Chris@42 2648 % slashes, to avoid line break between the slashes in http://.
Chris@42 2649 \ifx\next/\else \urefpoststretch \fi
Chris@42 2650 }
Chris@42 2651 }
Chris@42 2652
Chris@42 2653 % One more complication: by default we'll break after the special
Chris@42 2654 % characters, but some people like to break before the special chars, so
Chris@42 2655 % allow that. Also allow no breaking at all, for manual control.
Chris@42 2656 %
Chris@42 2657 \parseargdef\urefbreakstyle{%
Chris@42 2658 \def\txiarg{#1}%
Chris@42 2659 \ifx\txiarg\wordnone
Chris@42 2660 \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
Chris@42 2661 \else\ifx\txiarg\wordbefore
Chris@42 2662 \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
Chris@42 2663 \else\ifx\txiarg\wordafter
Chris@42 2664 \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
Chris@42 2665 \else
Chris@42 2666 \errhelp = \EMsimple
Chris@42 2667 \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
Chris@42 2668 \fi\fi\fi
Chris@42 2669 }
Chris@42 2670 \def\wordafter{after}
Chris@42 2671 \def\wordbefore{before}
Chris@42 2672 \def\wordnone{none}
Chris@42 2673
Chris@42 2674 \urefbreakstyle after
Chris@42 2675
Chris@42 2676 % @url synonym for @uref, since that's how everyone uses it.
Chris@42 2677 %
Chris@42 2678 \let\url=\uref
Chris@42 2679
Chris@42 2680 % rms does not like angle brackets --karl, 17may97.
Chris@42 2681 % So now @email is just like @uref, unless we are pdf.
Chris@42 2682 %
Chris@42 2683 %\def\email#1{\angleleft{\tt #1}\angleright}
Chris@42 2684 \ifpdf
Chris@42 2685 \def\email#1{\doemail#1,,\finish}
Chris@42 2686 \def\doemail#1,#2,#3\finish{\begingroup
Chris@42 2687 \unsepspaces
Chris@42 2688 \pdfurl{mailto:#1}%
Chris@42 2689 \setbox0 = \hbox{\ignorespaces #2}%
Chris@42 2690 \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
Chris@42 2691 \endlink
Chris@42 2692 \endgroup}
Chris@42 2693 \else
Chris@42 2694 \let\email=\uref
Chris@42 2695 \fi
Chris@42 2696
Chris@42 2697 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
Chris@42 2698 % `example' (@kbd uses ttsl only inside of @example and friends),
Chris@42 2699 % or `code' (@kbd uses normal tty font always).
Chris@42 2700 \parseargdef\kbdinputstyle{%
Chris@42 2701 \def\txiarg{#1}%
Chris@42 2702 \ifx\txiarg\worddistinct
Chris@42 2703 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
Chris@42 2704 \else\ifx\txiarg\wordexample
Chris@42 2705 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
Chris@42 2706 \else\ifx\txiarg\wordcode
Chris@42 2707 \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
Chris@42 2708 \else
Chris@42 2709 \errhelp = \EMsimple
Chris@42 2710 \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
Chris@42 2711 \fi\fi\fi
Chris@42 2712 }
Chris@42 2713 \def\worddistinct{distinct}
Chris@42 2714 \def\wordexample{example}
Chris@42 2715 \def\wordcode{code}
Chris@42 2716
Chris@42 2717 % Default is `distinct'.
Chris@42 2718 \kbdinputstyle distinct
Chris@42 2719
Chris@42 2720 % @kbd is like @code, except that if the argument is just one @key command,
Chris@42 2721 % then @kbd has no effect.
Chris@42 2722 \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
Chris@42 2723
Chris@42 2724 \def\xkey{\key}
Chris@42 2725 \def\kbdsub#1#2#3\par{%
Chris@42 2726 \def\one{#1}\def\three{#3}\def\threex{??}%
Chris@42 2727 \ifx\one\xkey\ifx\threex\three \key{#2}%
Chris@42 2728 \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
Chris@42 2729 \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
Chris@42 2730 }
Chris@42 2731
Chris@42 2732 % definition of @key that produces a lozenge. Doesn't adjust to text size.
Chris@42 2733 %\setfont\keyrm\rmshape{8}{1000}{OT1}
Chris@42 2734 %\font\keysy=cmsy9
Chris@42 2735 %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
Chris@42 2736 % \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
Chris@42 2737 % \vbox{\hrule\kern-0.4pt
Chris@42 2738 % \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
Chris@42 2739 % \kern-0.4pt\hrule}%
Chris@42 2740 % \kern-.06em\raise0.4pt\hbox{\angleright}}}}
Chris@42 2741
Chris@42 2742 % definition of @key with no lozenge. If the current font is already
Chris@42 2743 % monospace, don't change it; that way, we respect @kbdinputstyle. But
Chris@42 2744 % if it isn't monospace, then use \tt.
Chris@42 2745 %
Chris@42 2746 \def\key#1{{\setupmarkupstyle{key}%
Chris@42 2747 \nohyphenation
Chris@42 2748 \ifmonospace\else\tt\fi
Chris@42 2749 #1}\null}
Chris@42 2750
Chris@42 2751 % @clicksequence{File @click{} Open ...}
Chris@42 2752 \def\clicksequence#1{\begingroup #1\endgroup}
Chris@42 2753
Chris@42 2754 % @clickstyle @arrow (by default)
Chris@42 2755 \parseargdef\clickstyle{\def\click{#1}}
Chris@42 2756 \def\click{\arrow}
Chris@42 2757
Chris@42 2758 % Typeset a dimension, e.g., `in' or `pt'. The only reason for the
Chris@42 2759 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
Chris@42 2760 %
Chris@42 2761 \def\dmn#1{\thinspace #1}
Chris@42 2762
Chris@42 2763 % @l was never documented to mean ``switch to the Lisp font'',
Chris@42 2764 % and it is not used as such in any manual I can find. We need it for
Chris@42 2765 % Polish suppressed-l. --karl, 22sep96.
Chris@42 2766 %\def\l#1{{\li #1}\null}
Chris@42 2767
Chris@42 2768 % @acronym for "FBI", "NATO", and the like.
Chris@42 2769 % We print this one point size smaller, since it's intended for
Chris@42 2770 % all-uppercase.
Chris@42 2771 %
Chris@42 2772 \def\acronym#1{\doacronym #1,,\finish}
Chris@42 2773 \def\doacronym#1,#2,#3\finish{%
Chris@42 2774 {\selectfonts\lsize #1}%
Chris@42 2775 \def\temp{#2}%
Chris@42 2776 \ifx\temp\empty \else
Chris@42 2777 \space ({\unsepspaces \ignorespaces \temp \unskip})%
Chris@42 2778 \fi
Chris@42 2779 \null % reset \spacefactor=1000
Chris@42 2780 }
Chris@42 2781
Chris@42 2782 % @abbr for "Comput. J." and the like.
Chris@42 2783 % No font change, but don't do end-of-sentence spacing.
Chris@42 2784 %
Chris@42 2785 \def\abbr#1{\doabbr #1,,\finish}
Chris@42 2786 \def\doabbr#1,#2,#3\finish{%
Chris@42 2787 {\plainfrenchspacing #1}%
Chris@42 2788 \def\temp{#2}%
Chris@42 2789 \ifx\temp\empty \else
Chris@42 2790 \space ({\unsepspaces \ignorespaces \temp \unskip})%
Chris@42 2791 \fi
Chris@42 2792 \null % reset \spacefactor=1000
Chris@42 2793 }
Chris@42 2794
Chris@42 2795 % @asis just yields its argument. Used with @table, for example.
Chris@42 2796 %
Chris@42 2797 \def\asis#1{#1}
Chris@42 2798
Chris@42 2799 % @math outputs its argument in math mode.
Chris@42 2800 %
Chris@42 2801 % One complication: _ usually means subscripts, but it could also mean
Chris@42 2802 % an actual _ character, as in @math{@var{some_variable} + 1}. So make
Chris@42 2803 % _ active, and distinguish by seeing if the current family is \slfam,
Chris@42 2804 % which is what @var uses.
Chris@42 2805 {
Chris@42 2806 \catcode`\_ = \active
Chris@42 2807 \gdef\mathunderscore{%
Chris@42 2808 \catcode`\_=\active
Chris@42 2809 \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
Chris@42 2810 }
Chris@42 2811 }
Chris@42 2812 % Another complication: we want \\ (and @\) to output a math (or tt) \.
Chris@42 2813 % FYI, plain.tex uses \\ as a temporary control sequence (for no
Chris@42 2814 % particular reason), but this is not advertised and we don't care.
Chris@42 2815 %
Chris@42 2816 % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
Chris@42 2817 \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
Chris@42 2818 %
Chris@42 2819 \def\math{%
Chris@42 2820 \tex
Chris@42 2821 \mathunderscore
Chris@42 2822 \let\\ = \mathbackslash
Chris@42 2823 \mathactive
Chris@42 2824 % make the texinfo accent commands work in math mode
Chris@42 2825 \let\"=\ddot
Chris@42 2826 \let\'=\acute
Chris@42 2827 \let\==\bar
Chris@42 2828 \let\^=\hat
Chris@42 2829 \let\`=\grave
Chris@42 2830 \let\u=\breve
Chris@42 2831 \let\v=\check
Chris@42 2832 \let\~=\tilde
Chris@42 2833 \let\dotaccent=\dot
Chris@42 2834 $\finishmath
Chris@42 2835 }
Chris@42 2836 \def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
Chris@42 2837
Chris@42 2838 % Some active characters (such as <) are spaced differently in math.
Chris@42 2839 % We have to reset their definitions in case the @math was an argument
Chris@42 2840 % to a command which sets the catcodes (such as @item or @section).
Chris@42 2841 %
Chris@42 2842 {
Chris@42 2843 \catcode`^ = \active
Chris@42 2844 \catcode`< = \active
Chris@42 2845 \catcode`> = \active
Chris@42 2846 \catcode`+ = \active
Chris@42 2847 \catcode`' = \active
Chris@42 2848 \gdef\mathactive{%
Chris@42 2849 \let^ = \ptexhat
Chris@42 2850 \let< = \ptexless
Chris@42 2851 \let> = \ptexgtr
Chris@42 2852 \let+ = \ptexplus
Chris@42 2853 \let' = \ptexquoteright
Chris@42 2854 }
Chris@42 2855 }
Chris@42 2856
Chris@42 2857 % ctrl is no longer a Texinfo command, but leave this definition for fun.
Chris@42 2858 \def\ctrl #1{{\tt \rawbackslash \hat}#1}
Chris@42 2859
Chris@42 2860 % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
Chris@42 2861 % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
Chris@42 2862 % except specified as a normal braced arg, so no newlines to worry about.
Chris@42 2863 %
Chris@42 2864 \def\outfmtnametex{tex}
Chris@42 2865 %
Chris@42 2866 \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
Chris@42 2867 \long\def\doinlinefmt#1,#2,\finish{%
Chris@42 2868 \def\inlinefmtname{#1}%
Chris@42 2869 \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
Chris@42 2870 }
Chris@42 2871 % For raw, must switch into @tex before parsing the argument, to avoid
Chris@42 2872 % setting catcodes prematurely. Doing it this way means that, for
Chris@42 2873 % example, @inlineraw{html, foo{bar} gets a parse error instead of being
Chris@42 2874 % ignored. But this isn't important because if people want a literal
Chris@42 2875 % *right* brace they would have to use a command anyway, so they may as
Chris@42 2876 % well use a command to get a left brace too. We could re-use the
Chris@42 2877 % delimiter character idea from \verb, but it seems like overkill.
Chris@42 2878 %
Chris@42 2879 \long\def\inlineraw{\tex \doinlineraw}
Chris@42 2880 \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
Chris@42 2881 \def\doinlinerawtwo#1,#2,\finish{%
Chris@42 2882 \def\inlinerawname{#1}%
Chris@42 2883 \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
Chris@42 2884 \endgroup % close group opened by \tex.
Chris@42 2885 }
Chris@42 2886
Chris@42 2887
Chris@42 2888 \message{glyphs,}
Chris@42 2889 % and logos.
Chris@42 2890
Chris@42 2891 % @@ prints an @, as does @atchar{}.
Chris@42 2892 \def\@{\char64 }
Chris@42 2893 \let\atchar=\@
Chris@42 2894
Chris@42 2895 % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
Chris@42 2896 % Unless we're in typewriter, use \ecfont because the CM text fonts do
Chris@42 2897 % not have braces, and we don't want to switch into math.
Chris@42 2898 \def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}}
Chris@42 2899 \def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}}
Chris@42 2900 \let\{=\mylbrace \let\lbracechar=\{
Chris@42 2901 \let\}=\myrbrace \let\rbracechar=\}
Chris@42 2902 \begingroup
Chris@42 2903 % Definitions to produce \{ and \} commands for indices,
Chris@42 2904 % and @{ and @} for the aux/toc files.
Chris@42 2905 \catcode`\{ = \other \catcode`\} = \other
Chris@42 2906 \catcode`\[ = 1 \catcode`\] = 2
Chris@42 2907 \catcode`\! = 0 \catcode`\\ = \other
Chris@42 2908 !gdef!lbracecmd[\{]%
Chris@42 2909 !gdef!rbracecmd[\}]%
Chris@42 2910 !gdef!lbraceatcmd[@{]%
Chris@42 2911 !gdef!rbraceatcmd[@}]%
Chris@42 2912 !endgroup
Chris@42 2913
Chris@42 2914 % @comma{} to avoid , parsing problems.
Chris@42 2915 \let\comma = ,
Chris@42 2916
Chris@42 2917 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
Chris@42 2918 % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
Chris@42 2919 \let\, = \ptexc
Chris@42 2920 \let\dotaccent = \ptexdot
Chris@42 2921 \def\ringaccent#1{{\accent23 #1}}
Chris@42 2922 \let\tieaccent = \ptext
Chris@42 2923 \let\ubaraccent = \ptexb
Chris@42 2924 \let\udotaccent = \d
Chris@42 2925
Chris@42 2926 % Other special characters: @questiondown @exclamdown @ordf @ordm
Chris@42 2927 % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
Chris@42 2928 \def\questiondown{?`}
Chris@42 2929 \def\exclamdown{!`}
Chris@42 2930 \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
Chris@42 2931 \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
Chris@42 2932
Chris@42 2933 % Dotless i and dotless j, used for accents.
Chris@42 2934 \def\imacro{i}
Chris@42 2935 \def\jmacro{j}
Chris@42 2936 \def\dotless#1{%
Chris@42 2937 \def\temp{#1}%
Chris@42 2938 \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
Chris@42 2939 \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
Chris@42 2940 \else \errmessage{@dotless can be used only with i or j}%
Chris@42 2941 \fi\fi
Chris@42 2942 }
Chris@42 2943
Chris@42 2944 % The \TeX{} logo, as in plain, but resetting the spacing so that a
Chris@42 2945 % period following counts as ending a sentence. (Idea found in latex.)
Chris@42 2946 %
Chris@42 2947 \edef\TeX{\TeX \spacefactor=1000 }
Chris@42 2948
Chris@42 2949 % @LaTeX{} logo. Not quite the same results as the definition in
Chris@42 2950 % latex.ltx, since we use a different font for the raised A; it's most
Chris@42 2951 % convenient for us to use an explicitly smaller font, rather than using
Chris@42 2952 % the \scriptstyle font (since we don't reset \scriptstyle and
Chris@42 2953 % \scriptscriptstyle).
Chris@42 2954 %
Chris@42 2955 \def\LaTeX{%
Chris@42 2956 L\kern-.36em
Chris@42 2957 {\setbox0=\hbox{T}%
Chris@42 2958 \vbox to \ht0{\hbox{%
Chris@42 2959 \ifx\textnominalsize\xwordpt
Chris@42 2960 % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX.
Chris@42 2961 % Revert to plain's \scriptsize, which is 7pt.
Chris@42 2962 \count255=\the\fam $\fam\count255 \scriptstyle A$%
Chris@42 2963 \else
Chris@42 2964 % For 11pt, we can use our lllsize.
Chris@42 2965 \selectfonts\lllsize A%
Chris@42 2966 \fi
Chris@42 2967 }%
Chris@42 2968 \vss
Chris@42 2969 }}%
Chris@42 2970 \kern-.15em
Chris@42 2971 \TeX
Chris@42 2972 }
Chris@42 2973
Chris@42 2974 % Some math mode symbols.
Chris@42 2975 \def\bullet{$\ptexbullet$}
Chris@42 2976 \def\geq{\ifmmode \ge\else $\ge$\fi}
Chris@42 2977 \def\leq{\ifmmode \le\else $\le$\fi}
Chris@42 2978 \def\minus{\ifmmode -\else $-$\fi}
Chris@42 2979
Chris@42 2980 % @dots{} outputs an ellipsis using the current font.
Chris@42 2981 % We do .5em per period so that it has the same spacing in the cm
Chris@42 2982 % typewriter fonts as three actual period characters; on the other hand,
Chris@42 2983 % in other typewriter fonts three periods are wider than 1.5em. So do
Chris@42 2984 % whichever is larger.
Chris@42 2985 %
Chris@42 2986 \def\dots{%
Chris@42 2987 \leavevmode
Chris@42 2988 \setbox0=\hbox{...}% get width of three periods
Chris@42 2989 \ifdim\wd0 > 1.5em
Chris@42 2990 \dimen0 = \wd0
Chris@42 2991 \else
Chris@42 2992 \dimen0 = 1.5em
Chris@42 2993 \fi
Chris@42 2994 \hbox to \dimen0{%
Chris@42 2995 \hskip 0pt plus.25fil
Chris@42 2996 .\hskip 0pt plus1fil
Chris@42 2997 .\hskip 0pt plus1fil
Chris@42 2998 .\hskip 0pt plus.5fil
Chris@42 2999 }%
Chris@42 3000 }
Chris@42 3001
Chris@42 3002 % @enddots{} is an end-of-sentence ellipsis.
Chris@42 3003 %
Chris@42 3004 \def\enddots{%
Chris@42 3005 \dots
Chris@42 3006 \spacefactor=\endofsentencespacefactor
Chris@42 3007 }
Chris@42 3008
Chris@42 3009 % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
Chris@42 3010 %
Chris@42 3011 % Since these characters are used in examples, they should be an even number of
Chris@42 3012 % \tt widths. Each \tt character is 1en, so two makes it 1em.
Chris@42 3013 %
Chris@42 3014 \def\point{$\star$}
Chris@42 3015 \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
Chris@42 3016 \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
Chris@42 3017 \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
Chris@42 3018 \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
Chris@42 3019 \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
Chris@42 3020
Chris@42 3021 % The @error{} command.
Chris@42 3022 % Adapted from the TeXbook's \boxit.
Chris@42 3023 %
Chris@42 3024 \newbox\errorbox
Chris@42 3025 %
Chris@42 3026 {\tentt \global\dimen0 = 3em}% Width of the box.
Chris@42 3027 \dimen2 = .55pt % Thickness of rules
Chris@42 3028 % The text. (`r' is open on the right, `e' somewhat less so on the left.)
Chris@42 3029 \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
Chris@42 3030 %
Chris@42 3031 \setbox\errorbox=\hbox to \dimen0{\hfil
Chris@42 3032 \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
Chris@42 3033 \advance\hsize by -2\dimen2 % Rules.
Chris@42 3034 \vbox{%
Chris@42 3035 \hrule height\dimen2
Chris@42 3036 \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
Chris@42 3037 \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
Chris@42 3038 \kern3pt\vrule width\dimen2}% Space to right.
Chris@42 3039 \hrule height\dimen2}
Chris@42 3040 \hfil}
Chris@42 3041 %
Chris@42 3042 \def\error{\leavevmode\lower.7ex\copy\errorbox}
Chris@42 3043
Chris@42 3044 % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
Chris@42 3045 %
Chris@42 3046 \def\pounds{{\it\$}}
Chris@42 3047
Chris@42 3048 % @euro{} comes from a separate font, depending on the current style.
Chris@42 3049 % We use the free feym* fonts from the eurosym package by Henrik
Chris@42 3050 % Theiling, which support regular, slanted, bold and bold slanted (and
Chris@42 3051 % "outlined" (blackboard board, sort of) versions, which we don't need).
Chris@42 3052 % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
Chris@42 3053 %
Chris@42 3054 % Although only regular is the truly official Euro symbol, we ignore
Chris@42 3055 % that. The Euro is designed to be slightly taller than the regular
Chris@42 3056 % font height.
Chris@42 3057 %
Chris@42 3058 % feymr - regular
Chris@42 3059 % feymo - slanted
Chris@42 3060 % feybr - bold
Chris@42 3061 % feybo - bold slanted
Chris@42 3062 %
Chris@42 3063 % There is no good (free) typewriter version, to my knowledge.
Chris@42 3064 % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
Chris@42 3065 % Hmm.
Chris@42 3066 %
Chris@42 3067 % Also doesn't work in math. Do we need to do math with euro symbols?
Chris@42 3068 % Hope not.
Chris@42 3069 %
Chris@42 3070 %
Chris@42 3071 \def\euro{{\eurofont e}}
Chris@42 3072 \def\eurofont{%
Chris@42 3073 % We set the font at each command, rather than predefining it in
Chris@42 3074 % \textfonts and the other font-switching commands, so that
Chris@42 3075 % installations which never need the symbol don't have to have the
Chris@42 3076 % font installed.
Chris@42 3077 %
Chris@42 3078 % There is only one designed size (nominal 10pt), so we always scale
Chris@42 3079 % that to the current nominal size.
Chris@42 3080 %
Chris@42 3081 % By the way, simply using "at 1em" works for cmr10 and the like, but
Chris@42 3082 % does not work for cmbx10 and other extended/shrunken fonts.
Chris@42 3083 %
Chris@42 3084 \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
Chris@42 3085 %
Chris@42 3086 \ifx\curfontstyle\bfstylename
Chris@42 3087 % bold:
Chris@42 3088 \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
Chris@42 3089 \else
Chris@42 3090 % regular:
Chris@42 3091 \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
Chris@42 3092 \fi
Chris@42 3093 \thiseurofont
Chris@42 3094 }
Chris@42 3095
Chris@42 3096 % Glyphs from the EC fonts. We don't use \let for the aliases, because
Chris@42 3097 % sometimes we redefine the original macro, and the alias should reflect
Chris@42 3098 % the redefinition.
Chris@42 3099 %
Chris@42 3100 % Use LaTeX names for the Icelandic letters.
Chris@42 3101 \def\DH{{\ecfont \char"D0}} % Eth
Chris@42 3102 \def\dh{{\ecfont \char"F0}} % eth
Chris@42 3103 \def\TH{{\ecfont \char"DE}} % Thorn
Chris@42 3104 \def\th{{\ecfont \char"FE}} % thorn
Chris@42 3105 %
Chris@42 3106 \def\guillemetleft{{\ecfont \char"13}}
Chris@42 3107 \def\guillemotleft{\guillemetleft}
Chris@42 3108 \def\guillemetright{{\ecfont \char"14}}
Chris@42 3109 \def\guillemotright{\guillemetright}
Chris@42 3110 \def\guilsinglleft{{\ecfont \char"0E}}
Chris@42 3111 \def\guilsinglright{{\ecfont \char"0F}}
Chris@42 3112 \def\quotedblbase{{\ecfont \char"12}}
Chris@42 3113 \def\quotesinglbase{{\ecfont \char"0D}}
Chris@42 3114 %
Chris@42 3115 % This positioning is not perfect (see the ogonek LaTeX package), but
Chris@42 3116 % we have the precomposed glyphs for the most common cases. We put the
Chris@42 3117 % tests to use those glyphs in the single \ogonek macro so we have fewer
Chris@42 3118 % dummy definitions to worry about for index entries, etc.
Chris@42 3119 %
Chris@42 3120 % ogonek is also used with other letters in Lithuanian (IOU), but using
Chris@42 3121 % the precomposed glyphs for those is not so easy since they aren't in
Chris@42 3122 % the same EC font.
Chris@42 3123 \def\ogonek#1{{%
Chris@42 3124 \def\temp{#1}%
Chris@42 3125 \ifx\temp\macrocharA\Aogonek
Chris@42 3126 \else\ifx\temp\macrochara\aogonek
Chris@42 3127 \else\ifx\temp\macrocharE\Eogonek
Chris@42 3128 \else\ifx\temp\macrochare\eogonek
Chris@42 3129 \else
Chris@42 3130 \ecfont \setbox0=\hbox{#1}%
Chris@42 3131 \ifdim\ht0=1ex\accent"0C #1%
Chris@42 3132 \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
Chris@42 3133 \fi
Chris@42 3134 \fi\fi\fi\fi
Chris@42 3135 }%
Chris@42 3136 }
Chris@42 3137 \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
Chris@42 3138 \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
Chris@42 3139 \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
Chris@42 3140 \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
Chris@42 3141 %
Chris@42 3142 % Use the ec* fonts (cm-super in outline format) for non-CM glyphs.
Chris@42 3143 \def\ecfont{%
Chris@42 3144 % We can't distinguish serif/sans and italic/slanted, but this
Chris@42 3145 % is used for crude hacks anyway (like adding French and German
Chris@42 3146 % quotes to documents typeset with CM, where we lose kerning), so
Chris@42 3147 % hopefully nobody will notice/care.
Chris@42 3148 \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
Chris@42 3149 \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
Chris@42 3150 \ifmonospace
Chris@42 3151 % typewriter:
Chris@42 3152 \font\thisecfont = ectt\ecsize \space at \nominalsize
Chris@42 3153 \else
Chris@42 3154 \ifx\curfontstyle\bfstylename
Chris@42 3155 % bold:
Chris@42 3156 \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize
Chris@42 3157 \else
Chris@42 3158 % regular:
Chris@42 3159 \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize
Chris@42 3160 \fi
Chris@42 3161 \fi
Chris@42 3162 \thisecfont
Chris@42 3163 }
Chris@42 3164
Chris@42 3165 % @registeredsymbol - R in a circle. The font for the R should really
Chris@42 3166 % be smaller yet, but lllsize is the best we can do for now.
Chris@42 3167 % Adapted from the plain.tex definition of \copyright.
Chris@42 3168 %
Chris@42 3169 \def\registeredsymbol{%
Chris@42 3170 $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
Chris@42 3171 \hfil\crcr\Orb}}%
Chris@42 3172 }$%
Chris@42 3173 }
Chris@42 3174
Chris@42 3175 % @textdegree - the normal degrees sign.
Chris@42 3176 %
Chris@42 3177 \def\textdegree{$^\circ$}
Chris@42 3178
Chris@42 3179 % Laurent Siebenmann reports \Orb undefined with:
Chris@42 3180 % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
Chris@42 3181 % so we'll define it if necessary.
Chris@42 3182 %
Chris@42 3183 \ifx\Orb\thisisundefined
Chris@42 3184 \def\Orb{\mathhexbox20D}
Chris@42 3185 \fi
Chris@42 3186
Chris@42 3187 % Quotes.
Chris@42 3188 \chardef\quotedblleft="5C
Chris@42 3189 \chardef\quotedblright=`\"
Chris@42 3190 \chardef\quoteleft=`\`
Chris@42 3191 \chardef\quoteright=`\'
Chris@42 3192
Chris@42 3193
Chris@42 3194 \message{page headings,}
Chris@42 3195
Chris@42 3196 \newskip\titlepagetopglue \titlepagetopglue = 1.5in
Chris@42 3197 \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
Chris@42 3198
Chris@42 3199 % First the title page. Must do @settitle before @titlepage.
Chris@42 3200 \newif\ifseenauthor
Chris@42 3201 \newif\iffinishedtitlepage
Chris@42 3202
Chris@42 3203 % Do an implicit @contents or @shortcontents after @end titlepage if the
Chris@42 3204 % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
Chris@42 3205 %
Chris@42 3206 \newif\ifsetcontentsaftertitlepage
Chris@42 3207 \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
Chris@42 3208 \newif\ifsetshortcontentsaftertitlepage
Chris@42 3209 \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
Chris@42 3210
Chris@42 3211 \parseargdef\shorttitlepage{%
Chris@42 3212 \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
Chris@42 3213 \endgroup\page\hbox{}\page}
Chris@42 3214
Chris@42 3215 \envdef\titlepage{%
Chris@42 3216 % Open one extra group, as we want to close it in the middle of \Etitlepage.
Chris@42 3217 \begingroup
Chris@42 3218 \parindent=0pt \textfonts
Chris@42 3219 % Leave some space at the very top of the page.
Chris@42 3220 \vglue\titlepagetopglue
Chris@42 3221 % No rule at page bottom unless we print one at the top with @title.
Chris@42 3222 \finishedtitlepagetrue
Chris@42 3223 %
Chris@42 3224 % Most title ``pages'' are actually two pages long, with space
Chris@42 3225 % at the top of the second. We don't want the ragged left on the second.
Chris@42 3226 \let\oldpage = \page
Chris@42 3227 \def\page{%
Chris@42 3228 \iffinishedtitlepage\else
Chris@42 3229 \finishtitlepage
Chris@42 3230 \fi
Chris@42 3231 \let\page = \oldpage
Chris@42 3232 \page
Chris@42 3233 \null
Chris@42 3234 }%
Chris@42 3235 }
Chris@42 3236
Chris@42 3237 \def\Etitlepage{%
Chris@42 3238 \iffinishedtitlepage\else
Chris@42 3239 \finishtitlepage
Chris@42 3240 \fi
Chris@42 3241 % It is important to do the page break before ending the group,
Chris@42 3242 % because the headline and footline are only empty inside the group.
Chris@42 3243 % If we use the new definition of \page, we always get a blank page
Chris@42 3244 % after the title page, which we certainly don't want.
Chris@42 3245 \oldpage
Chris@42 3246 \endgroup
Chris@42 3247 %
Chris@42 3248 % Need this before the \...aftertitlepage checks so that if they are
Chris@42 3249 % in effect the toc pages will come out with page numbers.
Chris@42 3250 \HEADINGSon
Chris@42 3251 %
Chris@42 3252 % If they want short, they certainly want long too.
Chris@42 3253 \ifsetshortcontentsaftertitlepage
Chris@42 3254 \shortcontents
Chris@42 3255 \contents
Chris@42 3256 \global\let\shortcontents = \relax
Chris@42 3257 \global\let\contents = \relax
Chris@42 3258 \fi
Chris@42 3259 %
Chris@42 3260 \ifsetcontentsaftertitlepage
Chris@42 3261 \contents
Chris@42 3262 \global\let\contents = \relax
Chris@42 3263 \global\let\shortcontents = \relax
Chris@42 3264 \fi
Chris@42 3265 }
Chris@42 3266
Chris@42 3267 \def\finishtitlepage{%
Chris@42 3268 \vskip4pt \hrule height 2pt width \hsize
Chris@42 3269 \vskip\titlepagebottomglue
Chris@42 3270 \finishedtitlepagetrue
Chris@42 3271 }
Chris@42 3272
Chris@42 3273 % Settings used for typesetting titles: no hyphenation, no indentation,
Chris@42 3274 % don't worry much about spacing, ragged right. This should be used
Chris@42 3275 % inside a \vbox, and fonts need to be set appropriately first. Because
Chris@42 3276 % it is always used for titles, nothing else, we call \rmisbold. \par
Chris@42 3277 % should be specified before the end of the \vbox, since a vbox is a group.
Chris@42 3278 %
Chris@42 3279 \def\raggedtitlesettings{%
Chris@42 3280 \rmisbold
Chris@42 3281 \hyphenpenalty=10000
Chris@42 3282 \parindent=0pt
Chris@42 3283 \tolerance=5000
Chris@42 3284 \ptexraggedright
Chris@42 3285 }
Chris@42 3286
Chris@42 3287 % Macros to be used within @titlepage:
Chris@42 3288
Chris@42 3289 \let\subtitlerm=\tenrm
Chris@42 3290 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
Chris@42 3291
Chris@42 3292 \parseargdef\title{%
Chris@42 3293 \checkenv\titlepage
Chris@42 3294 \vbox{\titlefonts \raggedtitlesettings #1\par}%
Chris@42 3295 % print a rule at the page bottom also.
Chris@42 3296 \finishedtitlepagefalse
Chris@42 3297 \vskip4pt \hrule height 4pt width \hsize \vskip4pt
Chris@42 3298 }
Chris@42 3299
Chris@42 3300 \parseargdef\subtitle{%
Chris@42 3301 \checkenv\titlepage
Chris@42 3302 {\subtitlefont \rightline{#1}}%
Chris@42 3303 }
Chris@42 3304
Chris@42 3305 % @author should come last, but may come many times.
Chris@42 3306 % It can also be used inside @quotation.
Chris@42 3307 %
Chris@42 3308 \parseargdef\author{%
Chris@42 3309 \def\temp{\quotation}%
Chris@42 3310 \ifx\thisenv\temp
Chris@42 3311 \def\quotationauthor{#1}% printed in \Equotation.
Chris@42 3312 \else
Chris@42 3313 \checkenv\titlepage
Chris@42 3314 \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
Chris@42 3315 {\secfonts\rmisbold \leftline{#1}}%
Chris@42 3316 \fi
Chris@42 3317 }
Chris@42 3318
Chris@42 3319
Chris@42 3320 % Set up page headings and footings.
Chris@42 3321
Chris@42 3322 \let\thispage=\folio
Chris@42 3323
Chris@42 3324 \newtoks\evenheadline % headline on even pages
Chris@42 3325 \newtoks\oddheadline % headline on odd pages
Chris@42 3326 \newtoks\evenfootline % footline on even pages
Chris@42 3327 \newtoks\oddfootline % footline on odd pages
Chris@42 3328
Chris@42 3329 % Now make TeX use those variables
Chris@42 3330 \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
Chris@42 3331 \else \the\evenheadline \fi}}
Chris@42 3332 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
Chris@42 3333 \else \the\evenfootline \fi}\HEADINGShook}
Chris@42 3334 \let\HEADINGShook=\relax
Chris@42 3335
Chris@42 3336 % Commands to set those variables.
Chris@42 3337 % For example, this is what @headings on does
Chris@42 3338 % @evenheading @thistitle|@thispage|@thischapter
Chris@42 3339 % @oddheading @thischapter|@thispage|@thistitle
Chris@42 3340 % @evenfooting @thisfile||
Chris@42 3341 % @oddfooting ||@thisfile
Chris@42 3342
Chris@42 3343
Chris@42 3344 \def\evenheading{\parsearg\evenheadingxxx}
Chris@42 3345 \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
Chris@42 3346 \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
Chris@42 3347 \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
Chris@42 3348
Chris@42 3349 \def\oddheading{\parsearg\oddheadingxxx}
Chris@42 3350 \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
Chris@42 3351 \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
Chris@42 3352 \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
Chris@42 3353
Chris@42 3354 \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
Chris@42 3355
Chris@42 3356 \def\evenfooting{\parsearg\evenfootingxxx}
Chris@42 3357 \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
Chris@42 3358 \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
Chris@42 3359 \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
Chris@42 3360
Chris@42 3361 \def\oddfooting{\parsearg\oddfootingxxx}
Chris@42 3362 \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
Chris@42 3363 \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
Chris@42 3364 \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
Chris@42 3365 %
Chris@42 3366 % Leave some space for the footline. Hopefully ok to assume
Chris@42 3367 % @evenfooting will not be used by itself.
Chris@42 3368 \global\advance\pageheight by -12pt
Chris@42 3369 \global\advance\vsize by -12pt
Chris@42 3370 }
Chris@42 3371
Chris@42 3372 \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
Chris@42 3373
Chris@42 3374 % @evenheadingmarks top \thischapter <- chapter at the top of a page
Chris@42 3375 % @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page
Chris@42 3376 %
Chris@42 3377 % The same set of arguments for:
Chris@42 3378 %
Chris@42 3379 % @oddheadingmarks
Chris@42 3380 % @evenfootingmarks
Chris@42 3381 % @oddfootingmarks
Chris@42 3382 % @everyheadingmarks
Chris@42 3383 % @everyfootingmarks
Chris@42 3384
Chris@42 3385 \def\evenheadingmarks{\headingmarks{even}{heading}}
Chris@42 3386 \def\oddheadingmarks{\headingmarks{odd}{heading}}
Chris@42 3387 \def\evenfootingmarks{\headingmarks{even}{footing}}
Chris@42 3388 \def\oddfootingmarks{\headingmarks{odd}{footing}}
Chris@42 3389 \def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1}
Chris@42 3390 \headingmarks{odd}{heading}{#1} }
Chris@42 3391 \def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1}
Chris@42 3392 \headingmarks{odd}{footing}{#1} }
Chris@42 3393 % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
Chris@42 3394 \def\headingmarks#1#2#3 {%
Chris@42 3395 \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
Chris@42 3396 \global\expandafter\let\csname get#1#2marks\endcsname \temp
Chris@42 3397 }
Chris@42 3398
Chris@42 3399 \everyheadingmarks bottom
Chris@42 3400 \everyfootingmarks bottom
Chris@42 3401
Chris@42 3402 % @headings double turns headings on for double-sided printing.
Chris@42 3403 % @headings single turns headings on for single-sided printing.
Chris@42 3404 % @headings off turns them off.
Chris@42 3405 % @headings on same as @headings double, retained for compatibility.
Chris@42 3406 % @headings after turns on double-sided headings after this page.
Chris@42 3407 % @headings doubleafter turns on double-sided headings after this page.
Chris@42 3408 % @headings singleafter turns on single-sided headings after this page.
Chris@42 3409 % By default, they are off at the start of a document,
Chris@42 3410 % and turned `on' after @end titlepage.
Chris@42 3411
Chris@42 3412 \def\headings #1 {\csname HEADINGS#1\endcsname}
Chris@42 3413
Chris@42 3414 \def\headingsoff{% non-global headings elimination
Chris@42 3415 \evenheadline={\hfil}\evenfootline={\hfil}%
Chris@42 3416 \oddheadline={\hfil}\oddfootline={\hfil}%
Chris@42 3417 }
Chris@42 3418
Chris@42 3419 \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
Chris@42 3420 \HEADINGSoff % it's the default
Chris@42 3421
Chris@42 3422 % When we turn headings on, set the page number to 1.
Chris@42 3423 % For double-sided printing, put current file name in lower left corner,
Chris@42 3424 % chapter name on inside top of right hand pages, document
Chris@42 3425 % title on inside top of left hand pages, and page numbers on outside top
Chris@42 3426 % edge of all pages.
Chris@42 3427 \def\HEADINGSdouble{%
Chris@42 3428 \global\pageno=1
Chris@42 3429 \global\evenfootline={\hfil}
Chris@42 3430 \global\oddfootline={\hfil}
Chris@42 3431 \global\evenheadline={\line{\folio\hfil\thistitle}}
Chris@42 3432 \global\oddheadline={\line{\thischapter\hfil\folio}}
Chris@42 3433 \global\let\contentsalignmacro = \chapoddpage
Chris@42 3434 }
Chris@42 3435 \let\contentsalignmacro = \chappager
Chris@42 3436
Chris@42 3437 % For single-sided printing, chapter title goes across top left of page,
Chris@42 3438 % page number on top right.
Chris@42 3439 \def\HEADINGSsingle{%
Chris@42 3440 \global\pageno=1
Chris@42 3441 \global\evenfootline={\hfil}
Chris@42 3442 \global\oddfootline={\hfil}
Chris@42 3443 \global\evenheadline={\line{\thischapter\hfil\folio}}
Chris@42 3444 \global\oddheadline={\line{\thischapter\hfil\folio}}
Chris@42 3445 \global\let\contentsalignmacro = \chappager
Chris@42 3446 }
Chris@42 3447 \def\HEADINGSon{\HEADINGSdouble}
Chris@42 3448
Chris@42 3449 \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
Chris@42 3450 \let\HEADINGSdoubleafter=\HEADINGSafter
Chris@42 3451 \def\HEADINGSdoublex{%
Chris@42 3452 \global\evenfootline={\hfil}
Chris@42 3453 \global\oddfootline={\hfil}
Chris@42 3454 \global\evenheadline={\line{\folio\hfil\thistitle}}
Chris@42 3455 \global\oddheadline={\line{\thischapter\hfil\folio}}
Chris@42 3456 \global\let\contentsalignmacro = \chapoddpage
Chris@42 3457 }
Chris@42 3458
Chris@42 3459 \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
Chris@42 3460 \def\HEADINGSsinglex{%
Chris@42 3461 \global\evenfootline={\hfil}
Chris@42 3462 \global\oddfootline={\hfil}
Chris@42 3463 \global\evenheadline={\line{\thischapter\hfil\folio}}
Chris@42 3464 \global\oddheadline={\line{\thischapter\hfil\folio}}
Chris@42 3465 \global\let\contentsalignmacro = \chappager
Chris@42 3466 }
Chris@42 3467
Chris@42 3468 % Subroutines used in generating headings
Chris@42 3469 % This produces Day Month Year style of output.
Chris@42 3470 % Only define if not already defined, in case a txi-??.tex file has set
Chris@42 3471 % up a different format (e.g., txi-cs.tex does this).
Chris@42 3472 \ifx\today\thisisundefined
Chris@42 3473 \def\today{%
Chris@42 3474 \number\day\space
Chris@42 3475 \ifcase\month
Chris@42 3476 \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
Chris@42 3477 \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
Chris@42 3478 \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
Chris@42 3479 \fi
Chris@42 3480 \space\number\year}
Chris@42 3481 \fi
Chris@42 3482
Chris@42 3483 % @settitle line... specifies the title of the document, for headings.
Chris@42 3484 % It generates no output of its own.
Chris@42 3485 \def\thistitle{\putwordNoTitle}
Chris@42 3486 \def\settitle{\parsearg{\gdef\thistitle}}
Chris@42 3487
Chris@42 3488
Chris@42 3489 \message{tables,}
Chris@42 3490 % Tables -- @table, @ftable, @vtable, @item(x).
Chris@42 3491
Chris@42 3492 % default indentation of table text
Chris@42 3493 \newdimen\tableindent \tableindent=.8in
Chris@42 3494 % default indentation of @itemize and @enumerate text
Chris@42 3495 \newdimen\itemindent \itemindent=.3in
Chris@42 3496 % margin between end of table item and start of table text.
Chris@42 3497 \newdimen\itemmargin \itemmargin=.1in
Chris@42 3498
Chris@42 3499 % used internally for \itemindent minus \itemmargin
Chris@42 3500 \newdimen\itemmax
Chris@42 3501
Chris@42 3502 % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
Chris@42 3503 % these defs.
Chris@42 3504 % They also define \itemindex
Chris@42 3505 % to index the item name in whatever manner is desired (perhaps none).
Chris@42 3506
Chris@42 3507 \newif\ifitemxneedsnegativevskip
Chris@42 3508
Chris@42 3509 \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
Chris@42 3510
Chris@42 3511 \def\internalBitem{\smallbreak \parsearg\itemzzz}
Chris@42 3512 \def\internalBitemx{\itemxpar \parsearg\itemzzz}
Chris@42 3513
Chris@42 3514 \def\itemzzz #1{\begingroup %
Chris@42 3515 \advance\hsize by -\rightskip
Chris@42 3516 \advance\hsize by -\tableindent
Chris@42 3517 \setbox0=\hbox{\itemindicate{#1}}%
Chris@42 3518 \itemindex{#1}%
Chris@42 3519 \nobreak % This prevents a break before @itemx.
Chris@42 3520 %
Chris@42 3521 % If the item text does not fit in the space we have, put it on a line
Chris@42 3522 % by itself, and do not allow a page break either before or after that
Chris@42 3523 % line. We do not start a paragraph here because then if the next
Chris@42 3524 % command is, e.g., @kindex, the whatsit would get put into the
Chris@42 3525 % horizontal list on a line by itself, resulting in extra blank space.
Chris@42 3526 \ifdim \wd0>\itemmax
Chris@42 3527 %
Chris@42 3528 % Make this a paragraph so we get the \parskip glue and wrapping,
Chris@42 3529 % but leave it ragged-right.
Chris@42 3530 \begingroup
Chris@42 3531 \advance\leftskip by-\tableindent
Chris@42 3532 \advance\hsize by\tableindent
Chris@42 3533 \advance\rightskip by0pt plus1fil\relax
Chris@42 3534 \leavevmode\unhbox0\par
Chris@42 3535 \endgroup
Chris@42 3536 %
Chris@42 3537 % We're going to be starting a paragraph, but we don't want the
Chris@42 3538 % \parskip glue -- logically it's part of the @item we just started.
Chris@42 3539 \nobreak \vskip-\parskip
Chris@42 3540 %
Chris@42 3541 % Stop a page break at the \parskip glue coming up. However, if
Chris@42 3542 % what follows is an environment such as @example, there will be no
Chris@42 3543 % \parskip glue; then the negative vskip we just inserted would
Chris@42 3544 % cause the example and the item to crash together. So we use this
Chris@42 3545 % bizarre value of 10001 as a signal to \aboveenvbreak to insert
Chris@42 3546 % \parskip glue after all. Section titles are handled this way also.
Chris@42 3547 %
Chris@42 3548 \penalty 10001
Chris@42 3549 \endgroup
Chris@42 3550 \itemxneedsnegativevskipfalse
Chris@42 3551 \else
Chris@42 3552 % The item text fits into the space. Start a paragraph, so that the
Chris@42 3553 % following text (if any) will end up on the same line.
Chris@42 3554 \noindent
Chris@42 3555 % Do this with kerns and \unhbox so that if there is a footnote in
Chris@42 3556 % the item text, it can migrate to the main vertical list and
Chris@42 3557 % eventually be printed.
Chris@42 3558 \nobreak\kern-\tableindent
Chris@42 3559 \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
Chris@42 3560 \unhbox0
Chris@42 3561 \nobreak\kern\dimen0
Chris@42 3562 \endgroup
Chris@42 3563 \itemxneedsnegativevskiptrue
Chris@42 3564 \fi
Chris@42 3565 }
Chris@42 3566
Chris@42 3567 \def\item{\errmessage{@item while not in a list environment}}
Chris@42 3568 \def\itemx{\errmessage{@itemx while not in a list environment}}
Chris@42 3569
Chris@42 3570 % @table, @ftable, @vtable.
Chris@42 3571 \envdef\table{%
Chris@42 3572 \let\itemindex\gobble
Chris@42 3573 \tablecheck{table}%
Chris@42 3574 }
Chris@42 3575 \envdef\ftable{%
Chris@42 3576 \def\itemindex ##1{\doind {fn}{\code{##1}}}%
Chris@42 3577 \tablecheck{ftable}%
Chris@42 3578 }
Chris@42 3579 \envdef\vtable{%
Chris@42 3580 \def\itemindex ##1{\doind {vr}{\code{##1}}}%
Chris@42 3581 \tablecheck{vtable}%
Chris@42 3582 }
Chris@42 3583 \def\tablecheck#1{%
Chris@42 3584 \ifnum \the\catcode`\^^M=\active
Chris@42 3585 \endgroup
Chris@42 3586 \errmessage{This command won't work in this context; perhaps the problem is
Chris@42 3587 that we are \inenvironment\thisenv}%
Chris@42 3588 \def\next{\doignore{#1}}%
Chris@42 3589 \else
Chris@42 3590 \let\next\tablex
Chris@42 3591 \fi
Chris@42 3592 \next
Chris@42 3593 }
Chris@42 3594 \def\tablex#1{%
Chris@42 3595 \def\itemindicate{#1}%
Chris@42 3596 \parsearg\tabley
Chris@42 3597 }
Chris@42 3598 \def\tabley#1{%
Chris@42 3599 {%
Chris@42 3600 \makevalueexpandable
Chris@42 3601 \edef\temp{\noexpand\tablez #1\space\space\space}%
Chris@42 3602 \expandafter
Chris@42 3603 }\temp \endtablez
Chris@42 3604 }
Chris@42 3605 \def\tablez #1 #2 #3 #4\endtablez{%
Chris@42 3606 \aboveenvbreak
Chris@42 3607 \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
Chris@42 3608 \ifnum 0#2>0 \tableindent=#2\mil \fi
Chris@42 3609 \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
Chris@42 3610 \itemmax=\tableindent
Chris@42 3611 \advance \itemmax by -\itemmargin
Chris@42 3612 \advance \leftskip by \tableindent
Chris@42 3613 \exdentamount=\tableindent
Chris@42 3614 \parindent = 0pt
Chris@42 3615 \parskip = \smallskipamount
Chris@42 3616 \ifdim \parskip=0pt \parskip=2pt \fi
Chris@42 3617 \let\item = \internalBitem
Chris@42 3618 \let\itemx = \internalBitemx
Chris@42 3619 }
Chris@42 3620 \def\Etable{\endgraf\afterenvbreak}
Chris@42 3621 \let\Eftable\Etable
Chris@42 3622 \let\Evtable\Etable
Chris@42 3623 \let\Eitemize\Etable
Chris@42 3624 \let\Eenumerate\Etable
Chris@42 3625
Chris@42 3626 % This is the counter used by @enumerate, which is really @itemize
Chris@42 3627
Chris@42 3628 \newcount \itemno
Chris@42 3629
Chris@42 3630 \envdef\itemize{\parsearg\doitemize}
Chris@42 3631
Chris@42 3632 \def\doitemize#1{%
Chris@42 3633 \aboveenvbreak
Chris@42 3634 \itemmax=\itemindent
Chris@42 3635 \advance\itemmax by -\itemmargin
Chris@42 3636 \advance\leftskip by \itemindent
Chris@42 3637 \exdentamount=\itemindent
Chris@42 3638 \parindent=0pt
Chris@42 3639 \parskip=\smallskipamount
Chris@42 3640 \ifdim\parskip=0pt \parskip=2pt \fi
Chris@42 3641 %
Chris@42 3642 % Try typesetting the item mark that if the document erroneously says
Chris@42 3643 % something like @itemize @samp (intending @table), there's an error
Chris@42 3644 % right away at the @itemize. It's not the best error message in the
Chris@42 3645 % world, but it's better than leaving it to the @item. This means if
Chris@42 3646 % the user wants an empty mark, they have to say @w{} not just @w.
Chris@42 3647 \def\itemcontents{#1}%
Chris@42 3648 \setbox0 = \hbox{\itemcontents}%
Chris@42 3649 %
Chris@42 3650 % @itemize with no arg is equivalent to @itemize @bullet.
Chris@42 3651 \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
Chris@42 3652 %
Chris@42 3653 \let\item=\itemizeitem
Chris@42 3654 }
Chris@42 3655
Chris@42 3656 % Definition of @item while inside @itemize and @enumerate.
Chris@42 3657 %
Chris@42 3658 \def\itemizeitem{%
Chris@42 3659 \advance\itemno by 1 % for enumerations
Chris@42 3660 {\let\par=\endgraf \smallbreak}% reasonable place to break
Chris@42 3661 {%
Chris@42 3662 % If the document has an @itemize directly after a section title, a
Chris@42 3663 % \nobreak will be last on the list, and \sectionheading will have
Chris@42 3664 % done a \vskip-\parskip. In that case, we don't want to zero
Chris@42 3665 % parskip, or the item text will crash with the heading. On the
Chris@42 3666 % other hand, when there is normal text preceding the item (as there
Chris@42 3667 % usually is), we do want to zero parskip, or there would be too much
Chris@42 3668 % space. In that case, we won't have a \nobreak before. At least
Chris@42 3669 % that's the theory.
Chris@42 3670 \ifnum\lastpenalty<10000 \parskip=0in \fi
Chris@42 3671 \noindent
Chris@42 3672 \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
Chris@42 3673 %
Chris@42 3674 \vadjust{\penalty 1200}}% not good to break after first line of item.
Chris@42 3675 \flushcr
Chris@42 3676 }
Chris@42 3677
Chris@42 3678 % \splitoff TOKENS\endmark defines \first to be the first token in
Chris@42 3679 % TOKENS, and \rest to be the remainder.
Chris@42 3680 %
Chris@42 3681 \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
Chris@42 3682
Chris@42 3683 % Allow an optional argument of an uppercase letter, lowercase letter,
Chris@42 3684 % or number, to specify the first label in the enumerated list. No
Chris@42 3685 % argument is the same as `1'.
Chris@42 3686 %
Chris@42 3687 \envparseargdef\enumerate{\enumeratey #1 \endenumeratey}
Chris@42 3688 \def\enumeratey #1 #2\endenumeratey{%
Chris@42 3689 % If we were given no argument, pretend we were given `1'.
Chris@42 3690 \def\thearg{#1}%
Chris@42 3691 \ifx\thearg\empty \def\thearg{1}\fi
Chris@42 3692 %
Chris@42 3693 % Detect if the argument is a single token. If so, it might be a
Chris@42 3694 % letter. Otherwise, the only valid thing it can be is a number.
Chris@42 3695 % (We will always have one token, because of the test we just made.
Chris@42 3696 % This is a good thing, since \splitoff doesn't work given nothing at
Chris@42 3697 % all -- the first parameter is undelimited.)
Chris@42 3698 \expandafter\splitoff\thearg\endmark
Chris@42 3699 \ifx\rest\empty
Chris@42 3700 % Only one token in the argument. It could still be anything.
Chris@42 3701 % A ``lowercase letter'' is one whose \lccode is nonzero.
Chris@42 3702 % An ``uppercase letter'' is one whose \lccode is both nonzero, and
Chris@42 3703 % not equal to itself.
Chris@42 3704 % Otherwise, we assume it's a number.
Chris@42 3705 %
Chris@42 3706 % We need the \relax at the end of the \ifnum lines to stop TeX from
Chris@42 3707 % continuing to look for a <number>.
Chris@42 3708 %
Chris@42 3709 \ifnum\lccode\expandafter`\thearg=0\relax
Chris@42 3710 \numericenumerate % a number (we hope)
Chris@42 3711 \else
Chris@42 3712 % It's a letter.
Chris@42 3713 \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
Chris@42 3714 \lowercaseenumerate % lowercase letter
Chris@42 3715 \else
Chris@42 3716 \uppercaseenumerate % uppercase letter
Chris@42 3717 \fi
Chris@42 3718 \fi
Chris@42 3719 \else
Chris@42 3720 % Multiple tokens in the argument. We hope it's a number.
Chris@42 3721 \numericenumerate
Chris@42 3722 \fi
Chris@42 3723 }
Chris@42 3724
Chris@42 3725 % An @enumerate whose labels are integers. The starting integer is
Chris@42 3726 % given in \thearg.
Chris@42 3727 %
Chris@42 3728 \def\numericenumerate{%
Chris@42 3729 \itemno = \thearg
Chris@42 3730 \startenumeration{\the\itemno}%
Chris@42 3731 }
Chris@42 3732
Chris@42 3733 % The starting (lowercase) letter is in \thearg.
Chris@42 3734 \def\lowercaseenumerate{%
Chris@42 3735 \itemno = \expandafter`\thearg
Chris@42 3736 \startenumeration{%
Chris@42 3737 % Be sure we're not beyond the end of the alphabet.
Chris@42 3738 \ifnum\itemno=0
Chris@42 3739 \errmessage{No more lowercase letters in @enumerate; get a bigger
Chris@42 3740 alphabet}%
Chris@42 3741 \fi
Chris@42 3742 \char\lccode\itemno
Chris@42 3743 }%
Chris@42 3744 }
Chris@42 3745
Chris@42 3746 % The starting (uppercase) letter is in \thearg.
Chris@42 3747 \def\uppercaseenumerate{%
Chris@42 3748 \itemno = \expandafter`\thearg
Chris@42 3749 \startenumeration{%
Chris@42 3750 % Be sure we're not beyond the end of the alphabet.
Chris@42 3751 \ifnum\itemno=0
Chris@42 3752 \errmessage{No more uppercase letters in @enumerate; get a bigger
Chris@42 3753 alphabet}
Chris@42 3754 \fi
Chris@42 3755 \char\uccode\itemno
Chris@42 3756 }%
Chris@42 3757 }
Chris@42 3758
Chris@42 3759 % Call \doitemize, adding a period to the first argument and supplying the
Chris@42 3760 % common last two arguments. Also subtract one from the initial value in
Chris@42 3761 % \itemno, since @item increments \itemno.
Chris@42 3762 %
Chris@42 3763 \def\startenumeration#1{%
Chris@42 3764 \advance\itemno by -1
Chris@42 3765 \doitemize{#1.}\flushcr
Chris@42 3766 }
Chris@42 3767
Chris@42 3768 % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
Chris@42 3769 % to @enumerate.
Chris@42 3770 %
Chris@42 3771 \def\alphaenumerate{\enumerate{a}}
Chris@42 3772 \def\capsenumerate{\enumerate{A}}
Chris@42 3773 \def\Ealphaenumerate{\Eenumerate}
Chris@42 3774 \def\Ecapsenumerate{\Eenumerate}
Chris@42 3775
Chris@42 3776
Chris@42 3777 % @multitable macros
Chris@42 3778 % Amy Hendrickson, 8/18/94, 3/6/96
Chris@42 3779 %
Chris@42 3780 % @multitable ... @end multitable will make as many columns as desired.
Chris@42 3781 % Contents of each column will wrap at width given in preamble. Width
Chris@42 3782 % can be specified either with sample text given in a template line,
Chris@42 3783 % or in percent of \hsize, the current width of text on page.
Chris@42 3784
Chris@42 3785 % Table can continue over pages but will only break between lines.
Chris@42 3786
Chris@42 3787 % To make preamble:
Chris@42 3788 %
Chris@42 3789 % Either define widths of columns in terms of percent of \hsize:
Chris@42 3790 % @multitable @columnfractions .25 .3 .45
Chris@42 3791 % @item ...
Chris@42 3792 %
Chris@42 3793 % Numbers following @columnfractions are the percent of the total
Chris@42 3794 % current hsize to be used for each column. You may use as many
Chris@42 3795 % columns as desired.
Chris@42 3796
Chris@42 3797
Chris@42 3798 % Or use a template:
Chris@42 3799 % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
Chris@42 3800 % @item ...
Chris@42 3801 % using the widest term desired in each column.
Chris@42 3802
Chris@42 3803 % Each new table line starts with @item, each subsequent new column
Chris@42 3804 % starts with @tab. Empty columns may be produced by supplying @tab's
Chris@42 3805 % with nothing between them for as many times as empty columns are needed,
Chris@42 3806 % ie, @tab@tab@tab will produce two empty columns.
Chris@42 3807
Chris@42 3808 % @item, @tab do not need to be on their own lines, but it will not hurt
Chris@42 3809 % if they are.
Chris@42 3810
Chris@42 3811 % Sample multitable:
Chris@42 3812
Chris@42 3813 % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
Chris@42 3814 % @item first col stuff @tab second col stuff @tab third col
Chris@42 3815 % @item
Chris@42 3816 % first col stuff
Chris@42 3817 % @tab
Chris@42 3818 % second col stuff
Chris@42 3819 % @tab
Chris@42 3820 % third col
Chris@42 3821 % @item first col stuff @tab second col stuff
Chris@42 3822 % @tab Many paragraphs of text may be used in any column.
Chris@42 3823 %
Chris@42 3824 % They will wrap at the width determined by the template.
Chris@42 3825 % @item@tab@tab This will be in third column.
Chris@42 3826 % @end multitable
Chris@42 3827
Chris@42 3828 % Default dimensions may be reset by user.
Chris@42 3829 % @multitableparskip is vertical space between paragraphs in table.
Chris@42 3830 % @multitableparindent is paragraph indent in table.
Chris@42 3831 % @multitablecolmargin is horizontal space to be left between columns.
Chris@42 3832 % @multitablelinespace is space to leave between table items, baseline
Chris@42 3833 % to baseline.
Chris@42 3834 % 0pt means it depends on current normal line spacing.
Chris@42 3835 %
Chris@42 3836 \newskip\multitableparskip
Chris@42 3837 \newskip\multitableparindent
Chris@42 3838 \newdimen\multitablecolspace
Chris@42 3839 \newskip\multitablelinespace
Chris@42 3840 \multitableparskip=0pt
Chris@42 3841 \multitableparindent=6pt
Chris@42 3842 \multitablecolspace=12pt
Chris@42 3843 \multitablelinespace=0pt
Chris@42 3844
Chris@42 3845 % Macros used to set up halign preamble:
Chris@42 3846 %
Chris@42 3847 \let\endsetuptable\relax
Chris@42 3848 \def\xendsetuptable{\endsetuptable}
Chris@42 3849 \let\columnfractions\relax
Chris@42 3850 \def\xcolumnfractions{\columnfractions}
Chris@42 3851 \newif\ifsetpercent
Chris@42 3852
Chris@42 3853 % #1 is the @columnfraction, usually a decimal number like .5, but might
Chris@42 3854 % be just 1. We just use it, whatever it is.
Chris@42 3855 %
Chris@42 3856 \def\pickupwholefraction#1 {%
Chris@42 3857 \global\advance\colcount by 1
Chris@42 3858 \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
Chris@42 3859 \setuptable
Chris@42 3860 }
Chris@42 3861
Chris@42 3862 \newcount\colcount
Chris@42 3863 \def\setuptable#1{%
Chris@42 3864 \def\firstarg{#1}%
Chris@42 3865 \ifx\firstarg\xendsetuptable
Chris@42 3866 \let\go = \relax
Chris@42 3867 \else
Chris@42 3868 \ifx\firstarg\xcolumnfractions
Chris@42 3869 \global\setpercenttrue
Chris@42 3870 \else
Chris@42 3871 \ifsetpercent
Chris@42 3872 \let\go\pickupwholefraction
Chris@42 3873 \else
Chris@42 3874 \global\advance\colcount by 1
Chris@42 3875 \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
Chris@42 3876 % separator; typically that is always in the input, anyway.
Chris@42 3877 \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
Chris@42 3878 \fi
Chris@42 3879 \fi
Chris@42 3880 \ifx\go\pickupwholefraction
Chris@42 3881 % Put the argument back for the \pickupwholefraction call, so
Chris@42 3882 % we'll always have a period there to be parsed.
Chris@42 3883 \def\go{\pickupwholefraction#1}%
Chris@42 3884 \else
Chris@42 3885 \let\go = \setuptable
Chris@42 3886 \fi%
Chris@42 3887 \fi
Chris@42 3888 \go
Chris@42 3889 }
Chris@42 3890
Chris@42 3891 % multitable-only commands.
Chris@42 3892 %
Chris@42 3893 % @headitem starts a heading row, which we typeset in bold.
Chris@42 3894 % Assignments have to be global since we are inside the implicit group
Chris@42 3895 % of an alignment entry. \everycr resets \everytab so we don't have to
Chris@42 3896 % undo it ourselves.
Chris@42 3897 \def\headitemfont{\b}% for people to use in the template row; not changeable
Chris@42 3898 \def\headitem{%
Chris@42 3899 \checkenv\multitable
Chris@42 3900 \crcr
Chris@42 3901 \global\everytab={\bf}% can't use \headitemfont since the parsing differs
Chris@42 3902 \the\everytab % for the first item
Chris@42 3903 }%
Chris@42 3904 %
Chris@42 3905 % A \tab used to include \hskip1sp. But then the space in a template
Chris@42 3906 % line is not enough. That is bad. So let's go back to just `&' until
Chris@42 3907 % we again encounter the problem the 1sp was intended to solve.
Chris@42 3908 % --karl, nathan@acm.org, 20apr99.
Chris@42 3909 \def\tab{\checkenv\multitable &\the\everytab}%
Chris@42 3910
Chris@42 3911 % @multitable ... @end multitable definitions:
Chris@42 3912 %
Chris@42 3913 \newtoks\everytab % insert after every tab.
Chris@42 3914 %
Chris@42 3915 \envdef\multitable{%
Chris@42 3916 \vskip\parskip
Chris@42 3917 \startsavinginserts
Chris@42 3918 %
Chris@42 3919 % @item within a multitable starts a normal row.
Chris@42 3920 % We use \def instead of \let so that if one of the multitable entries
Chris@42 3921 % contains an @itemize, we don't choke on the \item (seen as \crcr aka
Chris@42 3922 % \endtemplate) expanding \doitemize.
Chris@42 3923 \def\item{\crcr}%
Chris@42 3924 %
Chris@42 3925 \tolerance=9500
Chris@42 3926 \hbadness=9500
Chris@42 3927 \setmultitablespacing
Chris@42 3928 \parskip=\multitableparskip
Chris@42 3929 \parindent=\multitableparindent
Chris@42 3930 \overfullrule=0pt
Chris@42 3931 \global\colcount=0
Chris@42 3932 %
Chris@42 3933 \everycr = {%
Chris@42 3934 \noalign{%
Chris@42 3935 \global\everytab={}%
Chris@42 3936 \global\colcount=0 % Reset the column counter.
Chris@42 3937 % Check for saved footnotes, etc.
Chris@42 3938 \checkinserts
Chris@42 3939 % Keeps underfull box messages off when table breaks over pages.
Chris@42 3940 %\filbreak
Chris@42 3941 % Maybe so, but it also creates really weird page breaks when the
Chris@42 3942 % table breaks over pages. Wouldn't \vfil be better? Wait until the
Chris@42 3943 % problem manifests itself, so it can be fixed for real --karl.
Chris@42 3944 }%
Chris@42 3945 }%
Chris@42 3946 %
Chris@42 3947 \parsearg\domultitable
Chris@42 3948 }
Chris@42 3949 \def\domultitable#1{%
Chris@42 3950 % To parse everything between @multitable and @item:
Chris@42 3951 \setuptable#1 \endsetuptable
Chris@42 3952 %
Chris@42 3953 % This preamble sets up a generic column definition, which will
Chris@42 3954 % be used as many times as user calls for columns.
Chris@42 3955 % \vtop will set a single line and will also let text wrap and
Chris@42 3956 % continue for many paragraphs if desired.
Chris@42 3957 \halign\bgroup &%
Chris@42 3958 \global\advance\colcount by 1
Chris@42 3959 \multistrut
Chris@42 3960 \vtop{%
Chris@42 3961 % Use the current \colcount to find the correct column width:
Chris@42 3962 \hsize=\expandafter\csname col\the\colcount\endcsname
Chris@42 3963 %
Chris@42 3964 % In order to keep entries from bumping into each other
Chris@42 3965 % we will add a \leftskip of \multitablecolspace to all columns after
Chris@42 3966 % the first one.
Chris@42 3967 %
Chris@42 3968 % If a template has been used, we will add \multitablecolspace
Chris@42 3969 % to the width of each template entry.
Chris@42 3970 %
Chris@42 3971 % If the user has set preamble in terms of percent of \hsize we will
Chris@42 3972 % use that dimension as the width of the column, and the \leftskip
Chris@42 3973 % will keep entries from bumping into each other. Table will start at
Chris@42 3974 % left margin and final column will justify at right margin.
Chris@42 3975 %
Chris@42 3976 % Make sure we don't inherit \rightskip from the outer environment.
Chris@42 3977 \rightskip=0pt
Chris@42 3978 \ifnum\colcount=1
Chris@42 3979 % The first column will be indented with the surrounding text.
Chris@42 3980 \advance\hsize by\leftskip
Chris@42 3981 \else
Chris@42 3982 \ifsetpercent \else
Chris@42 3983 % If user has not set preamble in terms of percent of \hsize
Chris@42 3984 % we will advance \hsize by \multitablecolspace.
Chris@42 3985 \advance\hsize by \multitablecolspace
Chris@42 3986 \fi
Chris@42 3987 % In either case we will make \leftskip=\multitablecolspace:
Chris@42 3988 \leftskip=\multitablecolspace
Chris@42 3989 \fi
Chris@42 3990 % Ignoring space at the beginning and end avoids an occasional spurious
Chris@42 3991 % blank line, when TeX decides to break the line at the space before the
Chris@42 3992 % box from the multistrut, so the strut ends up on a line by itself.
Chris@42 3993 % For example:
Chris@42 3994 % @multitable @columnfractions .11 .89
Chris@42 3995 % @item @code{#}
Chris@42 3996 % @tab Legal holiday which is valid in major parts of the whole country.
Chris@42 3997 % Is automatically provided with highlighting sequences respectively
Chris@42 3998 % marking characters.
Chris@42 3999 \noindent\ignorespaces##\unskip\multistrut
Chris@42 4000 }\cr
Chris@42 4001 }
Chris@42 4002 \def\Emultitable{%
Chris@42 4003 \crcr
Chris@42 4004 \egroup % end the \halign
Chris@42 4005 \global\setpercentfalse
Chris@42 4006 }
Chris@42 4007
Chris@42 4008 \def\setmultitablespacing{%
Chris@42 4009 \def\multistrut{\strut}% just use the standard line spacing
Chris@42 4010 %
Chris@42 4011 % Compute \multitablelinespace (if not defined by user) for use in
Chris@42 4012 % \multitableparskip calculation. We used define \multistrut based on
Chris@42 4013 % this, but (ironically) that caused the spacing to be off.
Chris@42 4014 % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
Chris@42 4015 \ifdim\multitablelinespace=0pt
Chris@42 4016 \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
Chris@42 4017 \global\advance\multitablelinespace by-\ht0
Chris@42 4018 \fi
Chris@42 4019 % Test to see if parskip is larger than space between lines of
Chris@42 4020 % table. If not, do nothing.
Chris@42 4021 % If so, set to same dimension as multitablelinespace.
Chris@42 4022 \ifdim\multitableparskip>\multitablelinespace
Chris@42 4023 \global\multitableparskip=\multitablelinespace
Chris@42 4024 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
Chris@42 4025 % than skip between lines in the table.
Chris@42 4026 \fi%
Chris@42 4027 \ifdim\multitableparskip=0pt
Chris@42 4028 \global\multitableparskip=\multitablelinespace
Chris@42 4029 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
Chris@42 4030 % than skip between lines in the table.
Chris@42 4031 \fi}
Chris@42 4032
Chris@42 4033
Chris@42 4034 \message{conditionals,}
Chris@42 4035
Chris@42 4036 % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
Chris@42 4037 % @ifnotxml always succeed. They currently do nothing; we don't
Chris@42 4038 % attempt to check whether the conditionals are properly nested. But we
Chris@42 4039 % have to remember that they are conditionals, so that @end doesn't
Chris@42 4040 % attempt to close an environment group.
Chris@42 4041 %
Chris@42 4042 \def\makecond#1{%
Chris@42 4043 \expandafter\let\csname #1\endcsname = \relax
Chris@42 4044 \expandafter\let\csname iscond.#1\endcsname = 1
Chris@42 4045 }
Chris@42 4046 \makecond{iftex}
Chris@42 4047 \makecond{ifnotdocbook}
Chris@42 4048 \makecond{ifnothtml}
Chris@42 4049 \makecond{ifnotinfo}
Chris@42 4050 \makecond{ifnotplaintext}
Chris@42 4051 \makecond{ifnotxml}
Chris@42 4052
Chris@42 4053 % Ignore @ignore, @ifhtml, @ifinfo, and the like.
Chris@42 4054 %
Chris@42 4055 \def\direntry{\doignore{direntry}}
Chris@42 4056 \def\documentdescription{\doignore{documentdescription}}
Chris@42 4057 \def\docbook{\doignore{docbook}}
Chris@42 4058 \def\html{\doignore{html}}
Chris@42 4059 \def\ifdocbook{\doignore{ifdocbook}}
Chris@42 4060 \def\ifhtml{\doignore{ifhtml}}
Chris@42 4061 \def\ifinfo{\doignore{ifinfo}}
Chris@42 4062 \def\ifnottex{\doignore{ifnottex}}
Chris@42 4063 \def\ifplaintext{\doignore{ifplaintext}}
Chris@42 4064 \def\ifxml{\doignore{ifxml}}
Chris@42 4065 \def\ignore{\doignore{ignore}}
Chris@42 4066 \def\menu{\doignore{menu}}
Chris@42 4067 \def\xml{\doignore{xml}}
Chris@42 4068
Chris@42 4069 % Ignore text until a line `@end #1', keeping track of nested conditionals.
Chris@42 4070 %
Chris@42 4071 % A count to remember the depth of nesting.
Chris@42 4072 \newcount\doignorecount
Chris@42 4073
Chris@42 4074 \def\doignore#1{\begingroup
Chris@42 4075 % Scan in ``verbatim'' mode:
Chris@42 4076 \obeylines
Chris@42 4077 \catcode`\@ = \other
Chris@42 4078 \catcode`\{ = \other
Chris@42 4079 \catcode`\} = \other
Chris@42 4080 %
Chris@42 4081 % Make sure that spaces turn into tokens that match what \doignoretext wants.
Chris@42 4082 \spaceisspace
Chris@42 4083 %
Chris@42 4084 % Count number of #1's that we've seen.
Chris@42 4085 \doignorecount = 0
Chris@42 4086 %
Chris@42 4087 % Swallow text until we reach the matching `@end #1'.
Chris@42 4088 \dodoignore{#1}%
Chris@42 4089 }
Chris@42 4090
Chris@42 4091 { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
Chris@42 4092 \obeylines %
Chris@42 4093 %
Chris@42 4094 \gdef\dodoignore#1{%
Chris@42 4095 % #1 contains the command name as a string, e.g., `ifinfo'.
Chris@42 4096 %
Chris@42 4097 % Define a command to find the next `@end #1'.
Chris@42 4098 \long\def\doignoretext##1^^M@end #1{%
Chris@42 4099 \doignoretextyyy##1^^M@#1\_STOP_}%
Chris@42 4100 %
Chris@42 4101 % And this command to find another #1 command, at the beginning of a
Chris@42 4102 % line. (Otherwise, we would consider a line `@c @ifset', for
Chris@42 4103 % example, to count as an @ifset for nesting.)
Chris@42 4104 \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
Chris@42 4105 %
Chris@42 4106 % And now expand that command.
Chris@42 4107 \doignoretext ^^M%
Chris@42 4108 }%
Chris@42 4109 }
Chris@42 4110
Chris@42 4111 \def\doignoreyyy#1{%
Chris@42 4112 \def\temp{#1}%
Chris@42 4113 \ifx\temp\empty % Nothing found.
Chris@42 4114 \let\next\doignoretextzzz
Chris@42 4115 \else % Found a nested condition, ...
Chris@42 4116 \advance\doignorecount by 1
Chris@42 4117 \let\next\doignoretextyyy % ..., look for another.
Chris@42 4118 % If we're here, #1 ends with ^^M\ifinfo (for example).
Chris@42 4119 \fi
Chris@42 4120 \next #1% the token \_STOP_ is present just after this macro.
Chris@42 4121 }
Chris@42 4122
Chris@42 4123 % We have to swallow the remaining "\_STOP_".
Chris@42 4124 %
Chris@42 4125 \def\doignoretextzzz#1{%
Chris@42 4126 \ifnum\doignorecount = 0 % We have just found the outermost @end.
Chris@42 4127 \let\next\enddoignore
Chris@42 4128 \else % Still inside a nested condition.
Chris@42 4129 \advance\doignorecount by -1
Chris@42 4130 \let\next\doignoretext % Look for the next @end.
Chris@42 4131 \fi
Chris@42 4132 \next
Chris@42 4133 }
Chris@42 4134
Chris@42 4135 % Finish off ignored text.
Chris@42 4136 { \obeylines%
Chris@42 4137 % Ignore anything after the last `@end #1'; this matters in verbatim
Chris@42 4138 % environments, where otherwise the newline after an ignored conditional
Chris@42 4139 % would result in a blank line in the output.
Chris@42 4140 \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
Chris@42 4141 }
Chris@42 4142
Chris@42 4143
Chris@42 4144 % @set VAR sets the variable VAR to an empty value.
Chris@42 4145 % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
Chris@42 4146 %
Chris@42 4147 % Since we want to separate VAR from REST-OF-LINE (which might be
Chris@42 4148 % empty), we can't just use \parsearg; we have to insert a space of our
Chris@42 4149 % own to delimit the rest of the line, and then take it out again if we
Chris@42 4150 % didn't need it.
Chris@42 4151 % We rely on the fact that \parsearg sets \catcode`\ =10.
Chris@42 4152 %
Chris@42 4153 \parseargdef\set{\setyyy#1 \endsetyyy}
Chris@42 4154 \def\setyyy#1 #2\endsetyyy{%
Chris@42 4155 {%
Chris@42 4156 \makevalueexpandable
Chris@42 4157 \def\temp{#2}%
Chris@42 4158 \edef\next{\gdef\makecsname{SET#1}}%
Chris@42 4159 \ifx\temp\empty
Chris@42 4160 \next{}%
Chris@42 4161 \else
Chris@42 4162 \setzzz#2\endsetzzz
Chris@42 4163 \fi
Chris@42 4164 }%
Chris@42 4165 }
Chris@42 4166 % Remove the trailing space \setxxx inserted.
Chris@42 4167 \def\setzzz#1 \endsetzzz{\next{#1}}
Chris@42 4168
Chris@42 4169 % @clear VAR clears (i.e., unsets) the variable VAR.
Chris@42 4170 %
Chris@42 4171 \parseargdef\clear{%
Chris@42 4172 {%
Chris@42 4173 \makevalueexpandable
Chris@42 4174 \global\expandafter\let\csname SET#1\endcsname=\relax
Chris@42 4175 }%
Chris@42 4176 }
Chris@42 4177
Chris@42 4178 % @value{foo} gets the text saved in variable foo.
Chris@42 4179 \def\value{\begingroup\makevalueexpandable\valuexxx}
Chris@42 4180 \def\valuexxx#1{\expandablevalue{#1}\endgroup}
Chris@42 4181 {
Chris@42 4182 \catcode`\- = \active \catcode`\_ = \active
Chris@42 4183 %
Chris@42 4184 \gdef\makevalueexpandable{%
Chris@42 4185 \let\value = \expandablevalue
Chris@42 4186 % We don't want these characters active, ...
Chris@42 4187 \catcode`\-=\other \catcode`\_=\other
Chris@42 4188 % ..., but we might end up with active ones in the argument if
Chris@42 4189 % we're called from @code, as @code{@value{foo-bar_}}, though.
Chris@42 4190 % So \let them to their normal equivalents.
Chris@42 4191 \let-\normaldash \let_\normalunderscore
Chris@42 4192 }
Chris@42 4193 }
Chris@42 4194
Chris@42 4195 % We have this subroutine so that we can handle at least some @value's
Chris@42 4196 % properly in indexes (we call \makevalueexpandable in \indexdummies).
Chris@42 4197 % The command has to be fully expandable (if the variable is set), since
Chris@42 4198 % the result winds up in the index file. This means that if the
Chris@42 4199 % variable's value contains other Texinfo commands, it's almost certain
Chris@42 4200 % it will fail (although perhaps we could fix that with sufficient work
Chris@42 4201 % to do a one-level expansion on the result, instead of complete).
Chris@42 4202 %
Chris@42 4203 \def\expandablevalue#1{%
Chris@42 4204 \expandafter\ifx\csname SET#1\endcsname\relax
Chris@42 4205 {[No value for ``#1'']}%
Chris@42 4206 \message{Variable `#1', used in @value, is not set.}%
Chris@42 4207 \else
Chris@42 4208 \csname SET#1\endcsname
Chris@42 4209 \fi
Chris@42 4210 }
Chris@42 4211
Chris@42 4212 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
Chris@42 4213 % with @set.
Chris@42 4214 %
Chris@42 4215 % To get special treatment of `@end ifset,' call \makeond and the redefine.
Chris@42 4216 %
Chris@42 4217 \makecond{ifset}
Chris@42 4218 \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
Chris@42 4219 \def\doifset#1#2{%
Chris@42 4220 {%
Chris@42 4221 \makevalueexpandable
Chris@42 4222 \let\next=\empty
Chris@42 4223 \expandafter\ifx\csname SET#2\endcsname\relax
Chris@42 4224 #1% If not set, redefine \next.
Chris@42 4225 \fi
Chris@42 4226 \expandafter
Chris@42 4227 }\next
Chris@42 4228 }
Chris@42 4229 \def\ifsetfail{\doignore{ifset}}
Chris@42 4230
Chris@42 4231 % @ifclear VAR ... @end executes the `...' iff VAR has never been
Chris@42 4232 % defined with @set, or has been undefined with @clear.
Chris@42 4233 %
Chris@42 4234 % The `\else' inside the `\doifset' parameter is a trick to reuse the
Chris@42 4235 % above code: if the variable is not set, do nothing, if it is set,
Chris@42 4236 % then redefine \next to \ifclearfail.
Chris@42 4237 %
Chris@42 4238 \makecond{ifclear}
Chris@42 4239 \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
Chris@42 4240 \def\ifclearfail{\doignore{ifclear}}
Chris@42 4241
Chris@42 4242 % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
Chris@42 4243 % without the @) is in fact defined. We can only feasibly check at the
Chris@42 4244 % TeX level, so something like `mathcode' is going to considered
Chris@42 4245 % defined even though it is not a Texinfo command.
Chris@42 4246 %
Chris@42 4247 \makecond{ifcommanddefined}
Chris@42 4248 \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
Chris@42 4249 %
Chris@42 4250 \def\doifcmddefined#1#2{{%
Chris@42 4251 \makevalueexpandable
Chris@42 4252 \let\next=\empty
Chris@42 4253 \expandafter\ifx\csname #2\endcsname\relax
Chris@42 4254 #1% If not defined, \let\next as above.
Chris@42 4255 \fi
Chris@42 4256 \expandafter
Chris@42 4257 }\next
Chris@42 4258 }
Chris@42 4259 \def\ifcmddefinedfail{\doignore{ifcommanddefined}}
Chris@42 4260
Chris@42 4261 % @ifcommandnotdefined CMD ... handled similar to @ifclear above.
Chris@42 4262 \makecond{ifcommandnotdefined}
Chris@42 4263 \def\ifcommandnotdefined{%
Chris@42 4264 \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
Chris@42 4265 \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
Chris@42 4266
Chris@42 4267 % Set the `txicommandconditionals' variable, so documents have a way to
Chris@42 4268 % test if the @ifcommand...defined conditionals are available.
Chris@42 4269 \set txicommandconditionals
Chris@42 4270
Chris@42 4271 % @dircategory CATEGORY -- specify a category of the dir file
Chris@42 4272 % which this file should belong to. Ignore this in TeX.
Chris@42 4273 \let\dircategory=\comment
Chris@42 4274
Chris@42 4275 % @defininfoenclose.
Chris@42 4276 \let\definfoenclose=\comment
Chris@42 4277
Chris@42 4278
Chris@42 4279 \message{indexing,}
Chris@42 4280 % Index generation facilities
Chris@42 4281
Chris@42 4282 % Define \newwrite to be identical to plain tex's \newwrite
Chris@42 4283 % except not \outer, so it can be used within macros and \if's.
Chris@42 4284 \edef\newwrite{\makecsname{ptexnewwrite}}
Chris@42 4285
Chris@42 4286 % \newindex {foo} defines an index named foo.
Chris@42 4287 % It automatically defines \fooindex such that
Chris@42 4288 % \fooindex ...rest of line... puts an entry in the index foo.
Chris@42 4289 % It also defines \fooindfile to be the number of the output channel for
Chris@42 4290 % the file that accumulates this index. The file's extension is foo.
Chris@42 4291 % The name of an index should be no more than 2 characters long
Chris@42 4292 % for the sake of vms.
Chris@42 4293 %
Chris@42 4294 \def\newindex#1{%
Chris@42 4295 \iflinks
Chris@42 4296 \expandafter\newwrite \csname#1indfile\endcsname
Chris@42 4297 \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
Chris@42 4298 \fi
Chris@42 4299 \expandafter\xdef\csname#1index\endcsname{% % Define @#1index
Chris@42 4300 \noexpand\doindex{#1}}
Chris@42 4301 }
Chris@42 4302
Chris@42 4303 % @defindex foo == \newindex{foo}
Chris@42 4304 %
Chris@42 4305 \def\defindex{\parsearg\newindex}
Chris@42 4306
Chris@42 4307 % Define @defcodeindex, like @defindex except put all entries in @code.
Chris@42 4308 %
Chris@42 4309 \def\defcodeindex{\parsearg\newcodeindex}
Chris@42 4310 %
Chris@42 4311 \def\newcodeindex#1{%
Chris@42 4312 \iflinks
Chris@42 4313 \expandafter\newwrite \csname#1indfile\endcsname
Chris@42 4314 \openout \csname#1indfile\endcsname \jobname.#1
Chris@42 4315 \fi
Chris@42 4316 \expandafter\xdef\csname#1index\endcsname{%
Chris@42 4317 \noexpand\docodeindex{#1}}%
Chris@42 4318 }
Chris@42 4319
Chris@42 4320
Chris@42 4321 % @synindex foo bar makes index foo feed into index bar.
Chris@42 4322 % Do this instead of @defindex foo if you don't want it as a separate index.
Chris@42 4323 %
Chris@42 4324 % @syncodeindex foo bar similar, but put all entries made for index foo
Chris@42 4325 % inside @code.
Chris@42 4326 %
Chris@42 4327 \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
Chris@42 4328 \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
Chris@42 4329
Chris@42 4330 % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
Chris@42 4331 % #3 the target index (bar).
Chris@42 4332 \def\dosynindex#1#2#3{%
Chris@42 4333 % Only do \closeout if we haven't already done it, else we'll end up
Chris@42 4334 % closing the target index.
Chris@42 4335 \expandafter \ifx\csname donesynindex#2\endcsname \relax
Chris@42 4336 % The \closeout helps reduce unnecessary open files; the limit on the
Chris@42 4337 % Acorn RISC OS is a mere 16 files.
Chris@42 4338 \expandafter\closeout\csname#2indfile\endcsname
Chris@42 4339 \expandafter\let\csname donesynindex#2\endcsname = 1
Chris@42 4340 \fi
Chris@42 4341 % redefine \fooindfile:
Chris@42 4342 \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
Chris@42 4343 \expandafter\let\csname#2indfile\endcsname=\temp
Chris@42 4344 % redefine \fooindex:
Chris@42 4345 \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
Chris@42 4346 }
Chris@42 4347
Chris@42 4348 % Define \doindex, the driver for all \fooindex macros.
Chris@42 4349 % Argument #1 is generated by the calling \fooindex macro,
Chris@42 4350 % and it is "foo", the name of the index.
Chris@42 4351
Chris@42 4352 % \doindex just uses \parsearg; it calls \doind for the actual work.
Chris@42 4353 % This is because \doind is more useful to call from other macros.
Chris@42 4354
Chris@42 4355 % There is also \dosubind {index}{topic}{subtopic}
Chris@42 4356 % which makes an entry in a two-level index such as the operation index.
Chris@42 4357
Chris@42 4358 \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
Chris@42 4359 \def\singleindexer #1{\doind{\indexname}{#1}}
Chris@42 4360
Chris@42 4361 % like the previous two, but they put @code around the argument.
Chris@42 4362 \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
Chris@42 4363 \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
Chris@42 4364
Chris@42 4365 % Take care of Texinfo commands that can appear in an index entry.
Chris@42 4366 % Since there are some commands we want to expand, and others we don't,
Chris@42 4367 % we have to laboriously prevent expansion for those that we don't.
Chris@42 4368 %
Chris@42 4369 \def\indexdummies{%
Chris@42 4370 \escapechar = `\\ % use backslash in output files.
Chris@42 4371 \def\@{@}% change to @@ when we switch to @ as escape char in index files.
Chris@42 4372 \def\ {\realbackslash\space }%
Chris@42 4373 %
Chris@42 4374 % Need these unexpandable (because we define \tt as a dummy)
Chris@42 4375 % definitions when @{ or @} appear in index entry text. Also, more
Chris@42 4376 % complicated, when \tex is in effect and \{ is a \delimiter again.
Chris@42 4377 % We can't use \lbracecmd and \rbracecmd because texindex assumes
Chris@42 4378 % braces and backslashes are used only as delimiters. Perhaps we
Chris@42 4379 % should define @lbrace and @rbrace commands a la @comma.
Chris@42 4380 \def\{{{\tt\char123}}%
Chris@42 4381 \def\}{{\tt\char125}}%
Chris@42 4382 %
Chris@42 4383 % I don't entirely understand this, but when an index entry is
Chris@42 4384 % generated from a macro call, the \endinput which \scanmacro inserts
Chris@42 4385 % causes processing to be prematurely terminated. This is,
Chris@42 4386 % apparently, because \indexsorttmp is fully expanded, and \endinput
Chris@42 4387 % is an expandable command. The redefinition below makes \endinput
Chris@42 4388 % disappear altogether for that purpose -- although logging shows that
Chris@42 4389 % processing continues to some further point. On the other hand, it
Chris@42 4390 % seems \endinput does not hurt in the printed index arg, since that
Chris@42 4391 % is still getting written without apparent harm.
Chris@42 4392 %
Chris@42 4393 % Sample source (mac-idx3.tex, reported by Graham Percival to
Chris@42 4394 % help-texinfo, 22may06):
Chris@42 4395 % @macro funindex {WORD}
Chris@42 4396 % @findex xyz
Chris@42 4397 % @end macro
Chris@42 4398 % ...
Chris@42 4399 % @funindex commtest
Chris@42 4400 %
Chris@42 4401 % The above is not enough to reproduce the bug, but it gives the flavor.
Chris@42 4402 %
Chris@42 4403 % Sample whatsit resulting:
Chris@42 4404 % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}}
Chris@42 4405 %
Chris@42 4406 % So:
Chris@42 4407 \let\endinput = \empty
Chris@42 4408 %
Chris@42 4409 % Do the redefinitions.
Chris@42 4410 \commondummies
Chris@42 4411 }
Chris@42 4412
Chris@42 4413 % For the aux and toc files, @ is the escape character. So we want to
Chris@42 4414 % redefine everything using @ as the escape character (instead of
Chris@42 4415 % \realbackslash, still used for index files). When everything uses @,
Chris@42 4416 % this will be simpler.
Chris@42 4417 %
Chris@42 4418 \def\atdummies{%
Chris@42 4419 \def\@{@@}%
Chris@42 4420 \def\ {@ }%
Chris@42 4421 \let\{ = \lbraceatcmd
Chris@42 4422 \let\} = \rbraceatcmd
Chris@42 4423 %
Chris@42 4424 % Do the redefinitions.
Chris@42 4425 \commondummies
Chris@42 4426 \otherbackslash
Chris@42 4427 }
Chris@42 4428
Chris@42 4429 % Called from \indexdummies and \atdummies.
Chris@42 4430 %
Chris@42 4431 \def\commondummies{%
Chris@42 4432 %
Chris@42 4433 % \definedummyword defines \#1 as \string\#1\space, thus effectively
Chris@42 4434 % preventing its expansion. This is used only for control words,
Chris@42 4435 % not control letters, because the \space would be incorrect for
Chris@42 4436 % control characters, but is needed to separate the control word
Chris@42 4437 % from whatever follows.
Chris@42 4438 %
Chris@42 4439 % For control letters, we have \definedummyletter, which omits the
Chris@42 4440 % space.
Chris@42 4441 %
Chris@42 4442 % These can be used both for control words that take an argument and
Chris@42 4443 % those that do not. If it is followed by {arg} in the input, then
Chris@42 4444 % that will dutifully get written to the index (or wherever).
Chris@42 4445 %
Chris@42 4446 \def\definedummyword ##1{\def##1{\string##1\space}}%
Chris@42 4447 \def\definedummyletter##1{\def##1{\string##1}}%
Chris@42 4448 \let\definedummyaccent\definedummyletter
Chris@42 4449 %
Chris@42 4450 \commondummiesnofonts
Chris@42 4451 %
Chris@42 4452 \definedummyletter\_%
Chris@42 4453 \definedummyletter\-%
Chris@42 4454 %
Chris@42 4455 % Non-English letters.
Chris@42 4456 \definedummyword\AA
Chris@42 4457 \definedummyword\AE
Chris@42 4458 \definedummyword\DH
Chris@42 4459 \definedummyword\L
Chris@42 4460 \definedummyword\O
Chris@42 4461 \definedummyword\OE
Chris@42 4462 \definedummyword\TH
Chris@42 4463 \definedummyword\aa
Chris@42 4464 \definedummyword\ae
Chris@42 4465 \definedummyword\dh
Chris@42 4466 \definedummyword\exclamdown
Chris@42 4467 \definedummyword\l
Chris@42 4468 \definedummyword\o
Chris@42 4469 \definedummyword\oe
Chris@42 4470 \definedummyword\ordf
Chris@42 4471 \definedummyword\ordm
Chris@42 4472 \definedummyword\questiondown
Chris@42 4473 \definedummyword\ss
Chris@42 4474 \definedummyword\th
Chris@42 4475 %
Chris@42 4476 % Although these internal commands shouldn't show up, sometimes they do.
Chris@42 4477 \definedummyword\bf
Chris@42 4478 \definedummyword\gtr
Chris@42 4479 \definedummyword\hat
Chris@42 4480 \definedummyword\less
Chris@42 4481 \definedummyword\sf
Chris@42 4482 \definedummyword\sl
Chris@42 4483 \definedummyword\tclose
Chris@42 4484 \definedummyword\tt
Chris@42 4485 %
Chris@42 4486 \definedummyword\LaTeX
Chris@42 4487 \definedummyword\TeX
Chris@42 4488 %
Chris@42 4489 % Assorted special characters.
Chris@42 4490 \definedummyword\arrow
Chris@42 4491 \definedummyword\bullet
Chris@42 4492 \definedummyword\comma
Chris@42 4493 \definedummyword\copyright
Chris@42 4494 \definedummyword\registeredsymbol
Chris@42 4495 \definedummyword\dots
Chris@42 4496 \definedummyword\enddots
Chris@42 4497 \definedummyword\entrybreak
Chris@42 4498 \definedummyword\equiv
Chris@42 4499 \definedummyword\error
Chris@42 4500 \definedummyword\euro
Chris@42 4501 \definedummyword\expansion
Chris@42 4502 \definedummyword\geq
Chris@42 4503 \definedummyword\guillemetleft
Chris@42 4504 \definedummyword\guillemetright
Chris@42 4505 \definedummyword\guilsinglleft
Chris@42 4506 \definedummyword\guilsinglright
Chris@42 4507 \definedummyword\lbracechar
Chris@42 4508 \definedummyword\leq
Chris@42 4509 \definedummyword\minus
Chris@42 4510 \definedummyword\ogonek
Chris@42 4511 \definedummyword\pounds
Chris@42 4512 \definedummyword\point
Chris@42 4513 \definedummyword\print
Chris@42 4514 \definedummyword\quotedblbase
Chris@42 4515 \definedummyword\quotedblleft
Chris@42 4516 \definedummyword\quotedblright
Chris@42 4517 \definedummyword\quoteleft
Chris@42 4518 \definedummyword\quoteright
Chris@42 4519 \definedummyword\quotesinglbase
Chris@42 4520 \definedummyword\rbracechar
Chris@42 4521 \definedummyword\result
Chris@42 4522 \definedummyword\textdegree
Chris@42 4523 %
Chris@42 4524 % We want to disable all macros so that they are not expanded by \write.
Chris@42 4525 \macrolist
Chris@42 4526 %
Chris@42 4527 \normalturnoffactive
Chris@42 4528 %
Chris@42 4529 % Handle some cases of @value -- where it does not contain any
Chris@42 4530 % (non-fully-expandable) commands.
Chris@42 4531 \makevalueexpandable
Chris@42 4532 }
Chris@42 4533
Chris@42 4534 % \commondummiesnofonts: common to \commondummies and \indexnofonts.
Chris@42 4535 %
Chris@42 4536 \def\commondummiesnofonts{%
Chris@42 4537 % Control letters and accents.
Chris@42 4538 \definedummyletter\!%
Chris@42 4539 \definedummyaccent\"%
Chris@42 4540 \definedummyaccent\'%
Chris@42 4541 \definedummyletter\*%
Chris@42 4542 \definedummyaccent\,%
Chris@42 4543 \definedummyletter\.%
Chris@42 4544 \definedummyletter\/%
Chris@42 4545 \definedummyletter\:%
Chris@42 4546 \definedummyaccent\=%
Chris@42 4547 \definedummyletter\?%
Chris@42 4548 \definedummyaccent\^%
Chris@42 4549 \definedummyaccent\`%
Chris@42 4550 \definedummyaccent\~%
Chris@42 4551 \definedummyword\u
Chris@42 4552 \definedummyword\v
Chris@42 4553 \definedummyword\H
Chris@42 4554 \definedummyword\dotaccent
Chris@42 4555 \definedummyword\ogonek
Chris@42 4556 \definedummyword\ringaccent
Chris@42 4557 \definedummyword\tieaccent
Chris@42 4558 \definedummyword\ubaraccent
Chris@42 4559 \definedummyword\udotaccent
Chris@42 4560 \definedummyword\dotless
Chris@42 4561 %
Chris@42 4562 % Texinfo font commands.
Chris@42 4563 \definedummyword\b
Chris@42 4564 \definedummyword\i
Chris@42 4565 \definedummyword\r
Chris@42 4566 \definedummyword\sansserif
Chris@42 4567 \definedummyword\sc
Chris@42 4568 \definedummyword\slanted
Chris@42 4569 \definedummyword\t
Chris@42 4570 %
Chris@42 4571 % Commands that take arguments.
Chris@42 4572 \definedummyword\abbr
Chris@42 4573 \definedummyword\acronym
Chris@42 4574 \definedummyword\anchor
Chris@42 4575 \definedummyword\cite
Chris@42 4576 \definedummyword\code
Chris@42 4577 \definedummyword\command
Chris@42 4578 \definedummyword\dfn
Chris@42 4579 \definedummyword\dmn
Chris@42 4580 \definedummyword\email
Chris@42 4581 \definedummyword\emph
Chris@42 4582 \definedummyword\env
Chris@42 4583 \definedummyword\file
Chris@42 4584 \definedummyword\image
Chris@42 4585 \definedummyword\indicateurl
Chris@42 4586 \definedummyword\inforef
Chris@42 4587 \definedummyword\kbd
Chris@42 4588 \definedummyword\key
Chris@42 4589 \definedummyword\math
Chris@42 4590 \definedummyword\option
Chris@42 4591 \definedummyword\pxref
Chris@42 4592 \definedummyword\ref
Chris@42 4593 \definedummyword\samp
Chris@42 4594 \definedummyword\strong
Chris@42 4595 \definedummyword\tie
Chris@42 4596 \definedummyword\uref
Chris@42 4597 \definedummyword\url
Chris@42 4598 \definedummyword\var
Chris@42 4599 \definedummyword\verb
Chris@42 4600 \definedummyword\w
Chris@42 4601 \definedummyword\xref
Chris@42 4602 }
Chris@42 4603
Chris@42 4604 % \indexnofonts is used when outputting the strings to sort the index
Chris@42 4605 % by, and when constructing control sequence names. It eliminates all
Chris@42 4606 % control sequences and just writes whatever the best ASCII sort string
Chris@42 4607 % would be for a given command (usually its argument).
Chris@42 4608 %
Chris@42 4609 \def\indexnofonts{%
Chris@42 4610 % Accent commands should become @asis.
Chris@42 4611 \def\definedummyaccent##1{\let##1\asis}%
Chris@42 4612 % We can just ignore other control letters.
Chris@42 4613 \def\definedummyletter##1{\let##1\empty}%
Chris@42 4614 % All control words become @asis by default; overrides below.
Chris@42 4615 \let\definedummyword\definedummyaccent
Chris@42 4616 %
Chris@42 4617 \commondummiesnofonts
Chris@42 4618 %
Chris@42 4619 % Don't no-op \tt, since it isn't a user-level command
Chris@42 4620 % and is used in the definitions of the active chars like <, >, |, etc.
Chris@42 4621 % Likewise with the other plain tex font commands.
Chris@42 4622 %\let\tt=\asis
Chris@42 4623 %
Chris@42 4624 \def\ { }%
Chris@42 4625 \def\@{@}%
Chris@42 4626 \def\_{\normalunderscore}%
Chris@42 4627 \def\-{}% @- shouldn't affect sorting
Chris@42 4628 %
Chris@42 4629 % Unfortunately, texindex is not prepared to handle braces in the
Chris@42 4630 % content at all. So for index sorting, we map @{ and @} to strings
Chris@42 4631 % starting with |, since that ASCII character is between ASCII { and }.
Chris@42 4632 \def\{{|a}%
Chris@42 4633 \def\lbracechar{|a}%
Chris@42 4634 %
Chris@42 4635 \def\}{|b}%
Chris@42 4636 \def\rbracechar{|b}%
Chris@42 4637 %
Chris@42 4638 % Non-English letters.
Chris@42 4639 \def\AA{AA}%
Chris@42 4640 \def\AE{AE}%
Chris@42 4641 \def\DH{DZZ}%
Chris@42 4642 \def\L{L}%
Chris@42 4643 \def\OE{OE}%
Chris@42 4644 \def\O{O}%
Chris@42 4645 \def\TH{ZZZ}%
Chris@42 4646 \def\aa{aa}%
Chris@42 4647 \def\ae{ae}%
Chris@42 4648 \def\dh{dzz}%
Chris@42 4649 \def\exclamdown{!}%
Chris@42 4650 \def\l{l}%
Chris@42 4651 \def\oe{oe}%
Chris@42 4652 \def\ordf{a}%
Chris@42 4653 \def\ordm{o}%
Chris@42 4654 \def\o{o}%
Chris@42 4655 \def\questiondown{?}%
Chris@42 4656 \def\ss{ss}%
Chris@42 4657 \def\th{zzz}%
Chris@42 4658 %
Chris@42 4659 \def\LaTeX{LaTeX}%
Chris@42 4660 \def\TeX{TeX}%
Chris@42 4661 %
Chris@42 4662 % Assorted special characters.
Chris@42 4663 % (The following {} will end up in the sort string, but that's ok.)
Chris@42 4664 \def\arrow{->}%
Chris@42 4665 \def\bullet{bullet}%
Chris@42 4666 \def\comma{,}%
Chris@42 4667 \def\copyright{copyright}%
Chris@42 4668 \def\dots{...}%
Chris@42 4669 \def\enddots{...}%
Chris@42 4670 \def\equiv{==}%
Chris@42 4671 \def\error{error}%
Chris@42 4672 \def\euro{euro}%
Chris@42 4673 \def\expansion{==>}%
Chris@42 4674 \def\geq{>=}%
Chris@42 4675 \def\guillemetleft{<<}%
Chris@42 4676 \def\guillemetright{>>}%
Chris@42 4677 \def\guilsinglleft{<}%
Chris@42 4678 \def\guilsinglright{>}%
Chris@42 4679 \def\leq{<=}%
Chris@42 4680 \def\minus{-}%
Chris@42 4681 \def\point{.}%
Chris@42 4682 \def\pounds{pounds}%
Chris@42 4683 \def\print{-|}%
Chris@42 4684 \def\quotedblbase{"}%
Chris@42 4685 \def\quotedblleft{"}%
Chris@42 4686 \def\quotedblright{"}%
Chris@42 4687 \def\quoteleft{`}%
Chris@42 4688 \def\quoteright{'}%
Chris@42 4689 \def\quotesinglbase{,}%
Chris@42 4690 \def\registeredsymbol{R}%
Chris@42 4691 \def\result{=>}%
Chris@42 4692 \def\textdegree{o}%
Chris@42 4693 %
Chris@42 4694 \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax
Chris@42 4695 \else \indexlquoteignore \fi
Chris@42 4696 %
Chris@42 4697 % We need to get rid of all macros, leaving only the arguments (if present).
Chris@42 4698 % Of course this is not nearly correct, but it is the best we can do for now.
Chris@42 4699 % makeinfo does not expand macros in the argument to @deffn, which ends up
Chris@42 4700 % writing an index entry, and texindex isn't prepared for an index sort entry
Chris@42 4701 % that starts with \.
Chris@42 4702 %
Chris@42 4703 % Since macro invocations are followed by braces, we can just redefine them
Chris@42 4704 % to take a single TeX argument. The case of a macro invocation that
Chris@42 4705 % goes to end-of-line is not handled.
Chris@42 4706 %
Chris@42 4707 \macrolist
Chris@42 4708 }
Chris@42 4709
Chris@42 4710 % Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us
Chris@42 4711 % ignore left quotes in the sort term.
Chris@42 4712 {\catcode`\`=\active
Chris@42 4713 \gdef\indexlquoteignore{\let`=\empty}}
Chris@42 4714
Chris@42 4715 \let\indexbackslash=0 %overridden during \printindex.
Chris@42 4716 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
Chris@42 4717
Chris@42 4718 % Most index entries go through here, but \dosubind is the general case.
Chris@42 4719 % #1 is the index name, #2 is the entry text.
Chris@42 4720 \def\doind#1#2{\dosubind{#1}{#2}{}}
Chris@42 4721
Chris@42 4722 % Workhorse for all \fooindexes.
Chris@42 4723 % #1 is name of index, #2 is stuff to put there, #3 is subentry --
Chris@42 4724 % empty if called from \doind, as we usually are (the main exception
Chris@42 4725 % is with most defuns, which call us directly).
Chris@42 4726 %
Chris@42 4727 \def\dosubind#1#2#3{%
Chris@42 4728 \iflinks
Chris@42 4729 {%
Chris@42 4730 % Store the main index entry text (including the third arg).
Chris@42 4731 \toks0 = {#2}%
Chris@42 4732 % If third arg is present, precede it with a space.
Chris@42 4733 \def\thirdarg{#3}%
Chris@42 4734 \ifx\thirdarg\empty \else
Chris@42 4735 \toks0 = \expandafter{\the\toks0 \space #3}%
Chris@42 4736 \fi
Chris@42 4737 %
Chris@42 4738 \edef\writeto{\csname#1indfile\endcsname}%
Chris@42 4739 %
Chris@42 4740 \safewhatsit\dosubindwrite
Chris@42 4741 }%
Chris@42 4742 \fi
Chris@42 4743 }
Chris@42 4744
Chris@42 4745 % Write the entry in \toks0 to the index file:
Chris@42 4746 %
Chris@42 4747 \def\dosubindwrite{%
Chris@42 4748 % Put the index entry in the margin if desired.
Chris@42 4749 \ifx\SETmarginindex\relax\else
Chris@42 4750 \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
Chris@42 4751 \fi
Chris@42 4752 %
Chris@42 4753 % Remember, we are within a group.
Chris@42 4754 \indexdummies % Must do this here, since \bf, etc expand at this stage
Chris@42 4755 \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
Chris@42 4756 % so it will be output as is; and it will print as backslash.
Chris@42 4757 %
Chris@42 4758 % Process the index entry with all font commands turned off, to
Chris@42 4759 % get the string to sort by.
Chris@42 4760 {\indexnofonts
Chris@42 4761 \edef\temp{\the\toks0}% need full expansion
Chris@42 4762 \xdef\indexsorttmp{\temp}%
Chris@42 4763 }%
Chris@42 4764 %
Chris@42 4765 % Set up the complete index entry, with both the sort key and
Chris@42 4766 % the original text, including any font commands. We write
Chris@42 4767 % three arguments to \entry to the .?? file (four in the
Chris@42 4768 % subentry case), texindex reduces to two when writing the .??s
Chris@42 4769 % sorted result.
Chris@42 4770 \edef\temp{%
Chris@42 4771 \write\writeto{%
Chris@42 4772 \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
Chris@42 4773 }%
Chris@42 4774 \temp
Chris@42 4775 }
Chris@42 4776
Chris@42 4777 % Take care of unwanted page breaks/skips around a whatsit:
Chris@42 4778 %
Chris@42 4779 % If a skip is the last thing on the list now, preserve it
Chris@42 4780 % by backing up by \lastskip, doing the \write, then inserting
Chris@42 4781 % the skip again. Otherwise, the whatsit generated by the
Chris@42 4782 % \write or \pdfdest will make \lastskip zero. The result is that
Chris@42 4783 % sequences like this:
Chris@42 4784 % @end defun
Chris@42 4785 % @tindex whatever
Chris@42 4786 % @defun ...
Chris@42 4787 % will have extra space inserted, because the \medbreak in the
Chris@42 4788 % start of the @defun won't see the skip inserted by the @end of
Chris@42 4789 % the previous defun.
Chris@42 4790 %
Chris@42 4791 % But don't do any of this if we're not in vertical mode. We
Chris@42 4792 % don't want to do a \vskip and prematurely end a paragraph.
Chris@42 4793 %
Chris@42 4794 % Avoid page breaks due to these extra skips, too.
Chris@42 4795 %
Chris@42 4796 % But wait, there is a catch there:
Chris@42 4797 % We'll have to check whether \lastskip is zero skip. \ifdim is not
Chris@42 4798 % sufficient for this purpose, as it ignores stretch and shrink parts
Chris@42 4799 % of the skip. The only way seems to be to check the textual
Chris@42 4800 % representation of the skip.
Chris@42 4801 %
Chris@42 4802 % The following is almost like \def\zeroskipmacro{0.0pt} except that
Chris@42 4803 % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
Chris@42 4804 %
Chris@42 4805 \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
Chris@42 4806 %
Chris@42 4807 \newskip\whatsitskip
Chris@42 4808 \newcount\whatsitpenalty
Chris@42 4809 %
Chris@42 4810 % ..., ready, GO:
Chris@42 4811 %
Chris@42 4812 \def\safewhatsit#1{\ifhmode
Chris@42 4813 #1%
Chris@42 4814 \else
Chris@42 4815 % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
Chris@42 4816 \whatsitskip = \lastskip
Chris@42 4817 \edef\lastskipmacro{\the\lastskip}%
Chris@42 4818 \whatsitpenalty = \lastpenalty
Chris@42 4819 %
Chris@42 4820 % If \lastskip is nonzero, that means the last item was a
Chris@42 4821 % skip. And since a skip is discardable, that means this
Chris@42 4822 % -\whatsitskip glue we're inserting is preceded by a
Chris@42 4823 % non-discardable item, therefore it is not a potential
Chris@42 4824 % breakpoint, therefore no \nobreak needed.
Chris@42 4825 \ifx\lastskipmacro\zeroskipmacro
Chris@42 4826 \else
Chris@42 4827 \vskip-\whatsitskip
Chris@42 4828 \fi
Chris@42 4829 %
Chris@42 4830 #1%
Chris@42 4831 %
Chris@42 4832 \ifx\lastskipmacro\zeroskipmacro
Chris@42 4833 % If \lastskip was zero, perhaps the last item was a penalty, and
Chris@42 4834 % perhaps it was >=10000, e.g., a \nobreak. In that case, we want
Chris@42 4835 % to re-insert the same penalty (values >10000 are used for various
Chris@42 4836 % signals); since we just inserted a non-discardable item, any
Chris@42 4837 % following glue (such as a \parskip) would be a breakpoint. For example:
Chris@42 4838 % @deffn deffn-whatever
Chris@42 4839 % @vindex index-whatever
Chris@42 4840 % Description.
Chris@42 4841 % would allow a break between the index-whatever whatsit
Chris@42 4842 % and the "Description." paragraph.
Chris@42 4843 \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
Chris@42 4844 \else
Chris@42 4845 % On the other hand, if we had a nonzero \lastskip,
Chris@42 4846 % this make-up glue would be preceded by a non-discardable item
Chris@42 4847 % (the whatsit from the \write), so we must insert a \nobreak.
Chris@42 4848 \nobreak\vskip\whatsitskip
Chris@42 4849 \fi
Chris@42 4850 \fi}
Chris@42 4851
Chris@42 4852 % The index entry written in the file actually looks like
Chris@42 4853 % \entry {sortstring}{page}{topic}
Chris@42 4854 % or
Chris@42 4855 % \entry {sortstring}{page}{topic}{subtopic}
Chris@42 4856 % The texindex program reads in these files and writes files
Chris@42 4857 % containing these kinds of lines:
Chris@42 4858 % \initial {c}
Chris@42 4859 % before the first topic whose initial is c
Chris@42 4860 % \entry {topic}{pagelist}
Chris@42 4861 % for a topic that is used without subtopics
Chris@42 4862 % \primary {topic}
Chris@42 4863 % for the beginning of a topic that is used with subtopics
Chris@42 4864 % \secondary {subtopic}{pagelist}
Chris@42 4865 % for each subtopic.
Chris@42 4866
Chris@42 4867 % Define the user-accessible indexing commands
Chris@42 4868 % @findex, @vindex, @kindex, @cindex.
Chris@42 4869
Chris@42 4870 \def\findex {\fnindex}
Chris@42 4871 \def\kindex {\kyindex}
Chris@42 4872 \def\cindex {\cpindex}
Chris@42 4873 \def\vindex {\vrindex}
Chris@42 4874 \def\tindex {\tpindex}
Chris@42 4875 \def\pindex {\pgindex}
Chris@42 4876
Chris@42 4877 \def\cindexsub {\begingroup\obeylines\cindexsub}
Chris@42 4878 {\obeylines %
Chris@42 4879 \gdef\cindexsub "#1" #2^^M{\endgroup %
Chris@42 4880 \dosubind{cp}{#2}{#1}}}
Chris@42 4881
Chris@42 4882 % Define the macros used in formatting output of the sorted index material.
Chris@42 4883
Chris@42 4884 % @printindex causes a particular index (the ??s file) to get printed.
Chris@42 4885 % It does not print any chapter heading (usually an @unnumbered).
Chris@42 4886 %
Chris@42 4887 \parseargdef\printindex{\begingroup
Chris@42 4888 \dobreak \chapheadingskip{10000}%
Chris@42 4889 %
Chris@42 4890 \smallfonts \rm
Chris@42 4891 \tolerance = 9500
Chris@42 4892 \plainfrenchspacing
Chris@42 4893 \everypar = {}% don't want the \kern\-parindent from indentation suppression.
Chris@42 4894 %
Chris@42 4895 % See if the index file exists and is nonempty.
Chris@42 4896 % Change catcode of @ here so that if the index file contains
Chris@42 4897 % \initial {@}
Chris@42 4898 % as its first line, TeX doesn't complain about mismatched braces
Chris@42 4899 % (because it thinks @} is a control sequence).
Chris@42 4900 \catcode`\@ = 11
Chris@42 4901 \openin 1 \jobname.#1s
Chris@42 4902 \ifeof 1
Chris@42 4903 % \enddoublecolumns gets confused if there is no text in the index,
Chris@42 4904 % and it loses the chapter title and the aux file entries for the
Chris@42 4905 % index. The easiest way to prevent this problem is to make sure
Chris@42 4906 % there is some text.
Chris@42 4907 \putwordIndexNonexistent
Chris@42 4908 \else
Chris@42 4909 %
Chris@42 4910 % If the index file exists but is empty, then \openin leaves \ifeof
Chris@42 4911 % false. We have to make TeX try to read something from the file, so
Chris@42 4912 % it can discover if there is anything in it.
Chris@42 4913 \read 1 to \temp
Chris@42 4914 \ifeof 1
Chris@42 4915 \putwordIndexIsEmpty
Chris@42 4916 \else
Chris@42 4917 % Index files are almost Texinfo source, but we use \ as the escape
Chris@42 4918 % character. It would be better to use @, but that's too big a change
Chris@42 4919 % to make right now.
Chris@42 4920 \def\indexbackslash{\backslashcurfont}%
Chris@42 4921 \catcode`\\ = 0
Chris@42 4922 \escapechar = `\\
Chris@42 4923 \begindoublecolumns
Chris@42 4924 \input \jobname.#1s
Chris@42 4925 \enddoublecolumns
Chris@42 4926 \fi
Chris@42 4927 \fi
Chris@42 4928 \closein 1
Chris@42 4929 \endgroup}
Chris@42 4930
Chris@42 4931 % These macros are used by the sorted index file itself.
Chris@42 4932 % Change them to control the appearance of the index.
Chris@42 4933
Chris@42 4934 \def\initial#1{{%
Chris@42 4935 % Some minor font changes for the special characters.
Chris@42 4936 \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
Chris@42 4937 %
Chris@42 4938 % Remove any glue we may have, we'll be inserting our own.
Chris@42 4939 \removelastskip
Chris@42 4940 %
Chris@42 4941 % We like breaks before the index initials, so insert a bonus.
Chris@42 4942 \nobreak
Chris@42 4943 \vskip 0pt plus 3\baselineskip
Chris@42 4944 \penalty 0
Chris@42 4945 \vskip 0pt plus -3\baselineskip
Chris@42 4946 %
Chris@42 4947 % Typeset the initial. Making this add up to a whole number of
Chris@42 4948 % baselineskips increases the chance of the dots lining up from column
Chris@42 4949 % to column. It still won't often be perfect, because of the stretch
Chris@42 4950 % we need before each entry, but it's better.
Chris@42 4951 %
Chris@42 4952 % No shrink because it confuses \balancecolumns.
Chris@42 4953 \vskip 1.67\baselineskip plus .5\baselineskip
Chris@42 4954 \leftline{\secbf #1}%
Chris@42 4955 % Do our best not to break after the initial.
Chris@42 4956 \nobreak
Chris@42 4957 \vskip .33\baselineskip plus .1\baselineskip
Chris@42 4958 }}
Chris@42 4959
Chris@42 4960 % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
Chris@42 4961 % then page number (#2) flushed to the right margin. It is used for index
Chris@42 4962 % and table of contents entries. The paragraph is indented by \leftskip.
Chris@42 4963 %
Chris@42 4964 % A straightforward implementation would start like this:
Chris@42 4965 % \def\entry#1#2{...
Chris@42 4966 % But this freezes the catcodes in the argument, and can cause problems to
Chris@42 4967 % @code, which sets - active. This problem was fixed by a kludge---
Chris@42 4968 % ``-'' was active throughout whole index, but this isn't really right.
Chris@42 4969 % The right solution is to prevent \entry from swallowing the whole text.
Chris@42 4970 % --kasal, 21nov03
Chris@42 4971 \def\entry{%
Chris@42 4972 \begingroup
Chris@42 4973 %
Chris@42 4974 % Start a new paragraph if necessary, so our assignments below can't
Chris@42 4975 % affect previous text.
Chris@42 4976 \par
Chris@42 4977 %
Chris@42 4978 % Do not fill out the last line with white space.
Chris@42 4979 \parfillskip = 0in
Chris@42 4980 %
Chris@42 4981 % No extra space above this paragraph.
Chris@42 4982 \parskip = 0in
Chris@42 4983 %
Chris@42 4984 % Do not prefer a separate line ending with a hyphen to fewer lines.
Chris@42 4985 \finalhyphendemerits = 0
Chris@42 4986 %
Chris@42 4987 % \hangindent is only relevant when the entry text and page number
Chris@42 4988 % don't both fit on one line. In that case, bob suggests starting the
Chris@42 4989 % dots pretty far over on the line. Unfortunately, a large
Chris@42 4990 % indentation looks wrong when the entry text itself is broken across
Chris@42 4991 % lines. So we use a small indentation and put up with long leaders.
Chris@42 4992 %
Chris@42 4993 % \hangafter is reset to 1 (which is the value we want) at the start
Chris@42 4994 % of each paragraph, so we need not do anything with that.
Chris@42 4995 \hangindent = 2em
Chris@42 4996 %
Chris@42 4997 % When the entry text needs to be broken, just fill out the first line
Chris@42 4998 % with blank space.
Chris@42 4999 \rightskip = 0pt plus1fil
Chris@42 5000 %
Chris@42 5001 % A bit of stretch before each entry for the benefit of balancing
Chris@42 5002 % columns.
Chris@42 5003 \vskip 0pt plus1pt
Chris@42 5004 %
Chris@42 5005 % When reading the text of entry, convert explicit line breaks
Chris@42 5006 % from @* into spaces. The user might give these in long section
Chris@42 5007 % titles, for instance.
Chris@42 5008 \def\*{\unskip\space\ignorespaces}%
Chris@42 5009 \def\entrybreak{\hfil\break}%
Chris@42 5010 %
Chris@42 5011 % Swallow the left brace of the text (first parameter):
Chris@42 5012 \afterassignment\doentry
Chris@42 5013 \let\temp =
Chris@42 5014 }
Chris@42 5015 \def\entrybreak{\unskip\space\ignorespaces}%
Chris@42 5016 \def\doentry{%
Chris@42 5017 \bgroup % Instead of the swallowed brace.
Chris@42 5018 \noindent
Chris@42 5019 \aftergroup\finishentry
Chris@42 5020 % And now comes the text of the entry.
Chris@42 5021 }
Chris@42 5022 \def\finishentry#1{%
Chris@42 5023 % #1 is the page number.
Chris@42 5024 %
Chris@42 5025 % The following is kludged to not output a line of dots in the index if
Chris@42 5026 % there are no page numbers. The next person who breaks this will be
Chris@42 5027 % cursed by a Unix daemon.
Chris@42 5028 \setbox\boxA = \hbox{#1}%
Chris@42 5029 \ifdim\wd\boxA = 0pt
Chris@42 5030 \ %
Chris@42 5031 \else
Chris@42 5032 %
Chris@42 5033 % If we must, put the page number on a line of its own, and fill out
Chris@42 5034 % this line with blank space. (The \hfil is overwhelmed with the
Chris@42 5035 % fill leaders glue in \indexdotfill if the page number does fit.)
Chris@42 5036 \hfil\penalty50
Chris@42 5037 \null\nobreak\indexdotfill % Have leaders before the page number.
Chris@42 5038 %
Chris@42 5039 % The `\ ' here is removed by the implicit \unskip that TeX does as
Chris@42 5040 % part of (the primitive) \par. Without it, a spurious underfull
Chris@42 5041 % \hbox ensues.
Chris@42 5042 \ifpdf
Chris@42 5043 \pdfgettoks#1.%
Chris@42 5044 \ \the\toksA
Chris@42 5045 \else
Chris@42 5046 \ #1%
Chris@42 5047 \fi
Chris@42 5048 \fi
Chris@42 5049 \par
Chris@42 5050 \endgroup
Chris@42 5051 }
Chris@42 5052
Chris@42 5053 % Like plain.tex's \dotfill, except uses up at least 1 em.
Chris@42 5054 \def\indexdotfill{\cleaders
Chris@42 5055 \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill}
Chris@42 5056
Chris@42 5057 \def\primary #1{\line{#1\hfil}}
Chris@42 5058
Chris@42 5059 \newskip\secondaryindent \secondaryindent=0.5cm
Chris@42 5060 \def\secondary#1#2{{%
Chris@42 5061 \parfillskip=0in
Chris@42 5062 \parskip=0in
Chris@42 5063 \hangindent=1in
Chris@42 5064 \hangafter=1
Chris@42 5065 \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
Chris@42 5066 \ifpdf
Chris@42 5067 \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
Chris@42 5068 \else
Chris@42 5069 #2
Chris@42 5070 \fi
Chris@42 5071 \par
Chris@42 5072 }}
Chris@42 5073
Chris@42 5074 % Define two-column mode, which we use to typeset indexes.
Chris@42 5075 % Adapted from the TeXbook, page 416, which is to say,
Chris@42 5076 % the manmac.tex format used to print the TeXbook itself.
Chris@42 5077 \catcode`\@=11
Chris@42 5078
Chris@42 5079 \newbox\partialpage
Chris@42 5080 \newdimen\doublecolumnhsize
Chris@42 5081
Chris@42 5082 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
Chris@42 5083 % Grab any single-column material above us.
Chris@42 5084 \output = {%
Chris@42 5085 %
Chris@42 5086 % Here is a possibility not foreseen in manmac: if we accumulate a
Chris@42 5087 % whole lot of material, we might end up calling this \output
Chris@42 5088 % routine twice in a row (see the doublecol-lose test, which is
Chris@42 5089 % essentially a couple of indexes with @setchapternewpage off). In
Chris@42 5090 % that case we just ship out what is in \partialpage with the normal
Chris@42 5091 % output routine. Generally, \partialpage will be empty when this
Chris@42 5092 % runs and this will be a no-op. See the indexspread.tex test case.
Chris@42 5093 \ifvoid\partialpage \else
Chris@42 5094 \onepageout{\pagecontents\partialpage}%
Chris@42 5095 \fi
Chris@42 5096 %
Chris@42 5097 \global\setbox\partialpage = \vbox{%
Chris@42 5098 % Unvbox the main output page.
Chris@42 5099 \unvbox\PAGE
Chris@42 5100 \kern-\topskip \kern\baselineskip
Chris@42 5101 }%
Chris@42 5102 }%
Chris@42 5103 \eject % run that output routine to set \partialpage
Chris@42 5104 %
Chris@42 5105 % Use the double-column output routine for subsequent pages.
Chris@42 5106 \output = {\doublecolumnout}%
Chris@42 5107 %
Chris@42 5108 % Change the page size parameters. We could do this once outside this
Chris@42 5109 % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
Chris@42 5110 % format, but then we repeat the same computation. Repeating a couple
Chris@42 5111 % of assignments once per index is clearly meaningless for the
Chris@42 5112 % execution time, so we may as well do it in one place.
Chris@42 5113 %
Chris@42 5114 % First we halve the line length, less a little for the gutter between
Chris@42 5115 % the columns. We compute the gutter based on the line length, so it
Chris@42 5116 % changes automatically with the paper format. The magic constant
Chris@42 5117 % below is chosen so that the gutter has the same value (well, +-<1pt)
Chris@42 5118 % as it did when we hard-coded it.
Chris@42 5119 %
Chris@42 5120 % We put the result in a separate register, \doublecolumhsize, so we
Chris@42 5121 % can restore it in \pagesofar, after \hsize itself has (potentially)
Chris@42 5122 % been clobbered.
Chris@42 5123 %
Chris@42 5124 \doublecolumnhsize = \hsize
Chris@42 5125 \advance\doublecolumnhsize by -.04154\hsize
Chris@42 5126 \divide\doublecolumnhsize by 2
Chris@42 5127 \hsize = \doublecolumnhsize
Chris@42 5128 %
Chris@42 5129 % Double the \vsize as well. (We don't need a separate register here,
Chris@42 5130 % since nobody clobbers \vsize.)
Chris@42 5131 \vsize = 2\vsize
Chris@42 5132 }
Chris@42 5133
Chris@42 5134 % The double-column output routine for all double-column pages except
Chris@42 5135 % the last.
Chris@42 5136 %
Chris@42 5137 \def\doublecolumnout{%
Chris@42 5138 \splittopskip=\topskip \splitmaxdepth=\maxdepth
Chris@42 5139 % Get the available space for the double columns -- the normal
Chris@42 5140 % (undoubled) page height minus any material left over from the
Chris@42 5141 % previous page.
Chris@42 5142 \dimen@ = \vsize
Chris@42 5143 \divide\dimen@ by 2
Chris@42 5144 \advance\dimen@ by -\ht\partialpage
Chris@42 5145 %
Chris@42 5146 % box0 will be the left-hand column, box2 the right.
Chris@42 5147 \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
Chris@42 5148 \onepageout\pagesofar
Chris@42 5149 \unvbox255
Chris@42 5150 \penalty\outputpenalty
Chris@42 5151 }
Chris@42 5152 %
Chris@42 5153 % Re-output the contents of the output page -- any previous material,
Chris@42 5154 % followed by the two boxes we just split, in box0 and box2.
Chris@42 5155 \def\pagesofar{%
Chris@42 5156 \unvbox\partialpage
Chris@42 5157 %
Chris@42 5158 \hsize = \doublecolumnhsize
Chris@42 5159 \wd0=\hsize \wd2=\hsize
Chris@42 5160 \hbox to\pagewidth{\box0\hfil\box2}%
Chris@42 5161 }
Chris@42 5162 %
Chris@42 5163 % All done with double columns.
Chris@42 5164 \def\enddoublecolumns{%
Chris@42 5165 % The following penalty ensures that the page builder is exercised
Chris@42 5166 % _before_ we change the output routine. This is necessary in the
Chris@42 5167 % following situation:
Chris@42 5168 %
Chris@42 5169 % The last section of the index consists only of a single entry.
Chris@42 5170 % Before this section, \pagetotal is less than \pagegoal, so no
Chris@42 5171 % break occurs before the last section starts. However, the last
Chris@42 5172 % section, consisting of \initial and the single \entry, does not
Chris@42 5173 % fit on the page and has to be broken off. Without the following
Chris@42 5174 % penalty the page builder will not be exercised until \eject
Chris@42 5175 % below, and by that time we'll already have changed the output
Chris@42 5176 % routine to the \balancecolumns version, so the next-to-last
Chris@42 5177 % double-column page will be processed with \balancecolumns, which
Chris@42 5178 % is wrong: The two columns will go to the main vertical list, with
Chris@42 5179 % the broken-off section in the recent contributions. As soon as
Chris@42 5180 % the output routine finishes, TeX starts reconsidering the page
Chris@42 5181 % break. The two columns and the broken-off section both fit on the
Chris@42 5182 % page, because the two columns now take up only half of the page
Chris@42 5183 % goal. When TeX sees \eject from below which follows the final
Chris@42 5184 % section, it invokes the new output routine that we've set after
Chris@42 5185 % \balancecolumns below; \onepageout will try to fit the two columns
Chris@42 5186 % and the final section into the vbox of \pageheight (see
Chris@42 5187 % \pagebody), causing an overfull box.
Chris@42 5188 %
Chris@42 5189 % Note that glue won't work here, because glue does not exercise the
Chris@42 5190 % page builder, unlike penalties (see The TeXbook, pp. 280-281).
Chris@42 5191 \penalty0
Chris@42 5192 %
Chris@42 5193 \output = {%
Chris@42 5194 % Split the last of the double-column material. Leave it on the
Chris@42 5195 % current page, no automatic page break.
Chris@42 5196 \balancecolumns
Chris@42 5197 %
Chris@42 5198 % If we end up splitting too much material for the current page,
Chris@42 5199 % though, there will be another page break right after this \output
Chris@42 5200 % invocation ends. Having called \balancecolumns once, we do not
Chris@42 5201 % want to call it again. Therefore, reset \output to its normal
Chris@42 5202 % definition right away. (We hope \balancecolumns will never be
Chris@42 5203 % called on to balance too much material, but if it is, this makes
Chris@42 5204 % the output somewhat more palatable.)
Chris@42 5205 \global\output = {\onepageout{\pagecontents\PAGE}}%
Chris@42 5206 }%
Chris@42 5207 \eject
Chris@42 5208 \endgroup % started in \begindoublecolumns
Chris@42 5209 %
Chris@42 5210 % \pagegoal was set to the doubled \vsize above, since we restarted
Chris@42 5211 % the current page. We're now back to normal single-column
Chris@42 5212 % typesetting, so reset \pagegoal to the normal \vsize (after the
Chris@42 5213 % \endgroup where \vsize got restored).
Chris@42 5214 \pagegoal = \vsize
Chris@42 5215 }
Chris@42 5216 %
Chris@42 5217 % Called at the end of the double column material.
Chris@42 5218 \def\balancecolumns{%
Chris@42 5219 \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
Chris@42 5220 \dimen@ = \ht0
Chris@42 5221 \advance\dimen@ by \topskip
Chris@42 5222 \advance\dimen@ by-\baselineskip
Chris@42 5223 \divide\dimen@ by 2 % target to split to
Chris@42 5224 %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}%
Chris@42 5225 \splittopskip = \topskip
Chris@42 5226 % Loop until we get a decent breakpoint.
Chris@42 5227 {%
Chris@42 5228 \vbadness = 10000
Chris@42 5229 \loop
Chris@42 5230 \global\setbox3 = \copy0
Chris@42 5231 \global\setbox1 = \vsplit3 to \dimen@
Chris@42 5232 \ifdim\ht3>\dimen@
Chris@42 5233 \global\advance\dimen@ by 1pt
Chris@42 5234 \repeat
Chris@42 5235 }%
Chris@42 5236 %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
Chris@42 5237 \setbox0=\vbox to\dimen@{\unvbox1}%
Chris@42 5238 \setbox2=\vbox to\dimen@{\unvbox3}%
Chris@42 5239 %
Chris@42 5240 \pagesofar
Chris@42 5241 }
Chris@42 5242 \catcode`\@ = \other
Chris@42 5243
Chris@42 5244
Chris@42 5245 \message{sectioning,}
Chris@42 5246 % Chapters, sections, etc.
Chris@42 5247
Chris@42 5248 % Let's start with @part.
Chris@42 5249 \outer\parseargdef\part{\partzzz{#1}}
Chris@42 5250 \def\partzzz#1{%
Chris@42 5251 \chapoddpage
Chris@42 5252 \null
Chris@42 5253 \vskip.3\vsize % move it down on the page a bit
Chris@42 5254 \begingroup
Chris@42 5255 \noindent \titlefonts\rmisbold #1\par % the text
Chris@42 5256 \let\lastnode=\empty % no node to associate with
Chris@42 5257 \writetocentry{part}{#1}{}% but put it in the toc
Chris@42 5258 \headingsoff % no headline or footline on the part page
Chris@42 5259 \chapoddpage
Chris@42 5260 \endgroup
Chris@42 5261 }
Chris@42 5262
Chris@42 5263 % \unnumberedno is an oxymoron. But we count the unnumbered
Chris@42 5264 % sections so that we can refer to them unambiguously in the pdf
Chris@42 5265 % outlines by their "section number". We avoid collisions with chapter
Chris@42 5266 % numbers by starting them at 10000. (If a document ever has 10000
Chris@42 5267 % chapters, we're in trouble anyway, I'm sure.)
Chris@42 5268 \newcount\unnumberedno \unnumberedno = 10000
Chris@42 5269 \newcount\chapno
Chris@42 5270 \newcount\secno \secno=0
Chris@42 5271 \newcount\subsecno \subsecno=0
Chris@42 5272 \newcount\subsubsecno \subsubsecno=0
Chris@42 5273
Chris@42 5274 % This counter is funny since it counts through charcodes of letters A, B, ...
Chris@42 5275 \newcount\appendixno \appendixno = `\@
Chris@42 5276 %
Chris@42 5277 % \def\appendixletter{\char\the\appendixno}
Chris@42 5278 % We do the following ugly conditional instead of the above simple
Chris@42 5279 % construct for the sake of pdftex, which needs the actual
Chris@42 5280 % letter in the expansion, not just typeset.
Chris@42 5281 %
Chris@42 5282 \def\appendixletter{%
Chris@42 5283 \ifnum\appendixno=`A A%
Chris@42 5284 \else\ifnum\appendixno=`B B%
Chris@42 5285 \else\ifnum\appendixno=`C C%
Chris@42 5286 \else\ifnum\appendixno=`D D%
Chris@42 5287 \else\ifnum\appendixno=`E E%
Chris@42 5288 \else\ifnum\appendixno=`F F%
Chris@42 5289 \else\ifnum\appendixno=`G G%
Chris@42 5290 \else\ifnum\appendixno=`H H%
Chris@42 5291 \else\ifnum\appendixno=`I I%
Chris@42 5292 \else\ifnum\appendixno=`J J%
Chris@42 5293 \else\ifnum\appendixno=`K K%
Chris@42 5294 \else\ifnum\appendixno=`L L%
Chris@42 5295 \else\ifnum\appendixno=`M M%
Chris@42 5296 \else\ifnum\appendixno=`N N%
Chris@42 5297 \else\ifnum\appendixno=`O O%
Chris@42 5298 \else\ifnum\appendixno=`P P%
Chris@42 5299 \else\ifnum\appendixno=`Q Q%
Chris@42 5300 \else\ifnum\appendixno=`R R%
Chris@42 5301 \else\ifnum\appendixno=`S S%
Chris@42 5302 \else\ifnum\appendixno=`T T%
Chris@42 5303 \else\ifnum\appendixno=`U U%
Chris@42 5304 \else\ifnum\appendixno=`V V%
Chris@42 5305 \else\ifnum\appendixno=`W W%
Chris@42 5306 \else\ifnum\appendixno=`X X%
Chris@42 5307 \else\ifnum\appendixno=`Y Y%
Chris@42 5308 \else\ifnum\appendixno=`Z Z%
Chris@42 5309 % The \the is necessary, despite appearances, because \appendixletter is
Chris@42 5310 % expanded while writing the .toc file. \char\appendixno is not
Chris@42 5311 % expandable, thus it is written literally, thus all appendixes come out
Chris@42 5312 % with the same letter (or @) in the toc without it.
Chris@42 5313 \else\char\the\appendixno
Chris@42 5314 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
Chris@42 5315 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
Chris@42 5316
Chris@42 5317 % Each @chapter defines these (using marks) as the number+name, number
Chris@42 5318 % and name of the chapter. Page headings and footings can use
Chris@42 5319 % these. @section does likewise.
Chris@42 5320 \def\thischapter{}
Chris@42 5321 \def\thischapternum{}
Chris@42 5322 \def\thischaptername{}
Chris@42 5323 \def\thissection{}
Chris@42 5324 \def\thissectionnum{}
Chris@42 5325 \def\thissectionname{}
Chris@42 5326
Chris@42 5327 \newcount\absseclevel % used to calculate proper heading level
Chris@42 5328 \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
Chris@42 5329
Chris@42 5330 % @raisesections: treat @section as chapter, @subsection as section, etc.
Chris@42 5331 \def\raisesections{\global\advance\secbase by -1}
Chris@42 5332 \let\up=\raisesections % original BFox name
Chris@42 5333
Chris@42 5334 % @lowersections: treat @chapter as section, @section as subsection, etc.
Chris@42 5335 \def\lowersections{\global\advance\secbase by 1}
Chris@42 5336 \let\down=\lowersections % original BFox name
Chris@42 5337
Chris@42 5338 % we only have subsub.
Chris@42 5339 \chardef\maxseclevel = 3
Chris@42 5340 %
Chris@42 5341 % A numbered section within an unnumbered changes to unnumbered too.
Chris@42 5342 % To achieve this, remember the "biggest" unnum. sec. we are currently in:
Chris@42 5343 \chardef\unnlevel = \maxseclevel
Chris@42 5344 %
Chris@42 5345 % Trace whether the current chapter is an appendix or not:
Chris@42 5346 % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
Chris@42 5347 \def\chapheadtype{N}
Chris@42 5348
Chris@42 5349 % Choose a heading macro
Chris@42 5350 % #1 is heading type
Chris@42 5351 % #2 is heading level
Chris@42 5352 % #3 is text for heading
Chris@42 5353 \def\genhead#1#2#3{%
Chris@42 5354 % Compute the abs. sec. level:
Chris@42 5355 \absseclevel=#2
Chris@42 5356 \advance\absseclevel by \secbase
Chris@42 5357 % Make sure \absseclevel doesn't fall outside the range:
Chris@42 5358 \ifnum \absseclevel < 0
Chris@42 5359 \absseclevel = 0
Chris@42 5360 \else
Chris@42 5361 \ifnum \absseclevel > 3
Chris@42 5362 \absseclevel = 3
Chris@42 5363 \fi
Chris@42 5364 \fi
Chris@42 5365 % The heading type:
Chris@42 5366 \def\headtype{#1}%
Chris@42 5367 \if \headtype U%
Chris@42 5368 \ifnum \absseclevel < \unnlevel
Chris@42 5369 \chardef\unnlevel = \absseclevel
Chris@42 5370 \fi
Chris@42 5371 \else
Chris@42 5372 % Check for appendix sections:
Chris@42 5373 \ifnum \absseclevel = 0
Chris@42 5374 \edef\chapheadtype{\headtype}%
Chris@42 5375 \else
Chris@42 5376 \if \headtype A\if \chapheadtype N%
Chris@42 5377 \errmessage{@appendix... within a non-appendix chapter}%
Chris@42 5378 \fi\fi
Chris@42 5379 \fi
Chris@42 5380 % Check for numbered within unnumbered:
Chris@42 5381 \ifnum \absseclevel > \unnlevel
Chris@42 5382 \def\headtype{U}%
Chris@42 5383 \else
Chris@42 5384 \chardef\unnlevel = 3
Chris@42 5385 \fi
Chris@42 5386 \fi
Chris@42 5387 % Now print the heading:
Chris@42 5388 \if \headtype U%
Chris@42 5389 \ifcase\absseclevel
Chris@42 5390 \unnumberedzzz{#3}%
Chris@42 5391 \or \unnumberedseczzz{#3}%
Chris@42 5392 \or \unnumberedsubseczzz{#3}%
Chris@42 5393 \or \unnumberedsubsubseczzz{#3}%
Chris@42 5394 \fi
Chris@42 5395 \else
Chris@42 5396 \if \headtype A%
Chris@42 5397 \ifcase\absseclevel
Chris@42 5398 \appendixzzz{#3}%
Chris@42 5399 \or \appendixsectionzzz{#3}%
Chris@42 5400 \or \appendixsubseczzz{#3}%
Chris@42 5401 \or \appendixsubsubseczzz{#3}%
Chris@42 5402 \fi
Chris@42 5403 \else
Chris@42 5404 \ifcase\absseclevel
Chris@42 5405 \chapterzzz{#3}%
Chris@42 5406 \or \seczzz{#3}%
Chris@42 5407 \or \numberedsubseczzz{#3}%
Chris@42 5408 \or \numberedsubsubseczzz{#3}%
Chris@42 5409 \fi
Chris@42 5410 \fi
Chris@42 5411 \fi
Chris@42 5412 \suppressfirstparagraphindent
Chris@42 5413 }
Chris@42 5414
Chris@42 5415 % an interface:
Chris@42 5416 \def\numhead{\genhead N}
Chris@42 5417 \def\apphead{\genhead A}
Chris@42 5418 \def\unnmhead{\genhead U}
Chris@42 5419
Chris@42 5420 % @chapter, @appendix, @unnumbered. Increment top-level counter, reset
Chris@42 5421 % all lower-level sectioning counters to zero.
Chris@42 5422 %
Chris@42 5423 % Also set \chaplevelprefix, which we prepend to @float sequence numbers
Chris@42 5424 % (e.g., figures), q.v. By default (before any chapter), that is empty.
Chris@42 5425 \let\chaplevelprefix = \empty
Chris@42 5426 %
Chris@42 5427 \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
Chris@42 5428 \def\chapterzzz#1{%
Chris@42 5429 % section resetting is \global in case the chapter is in a group, such
Chris@42 5430 % as an @include file.
Chris@42 5431 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
Chris@42 5432 \global\advance\chapno by 1
Chris@42 5433 %
Chris@42 5434 % Used for \float.
Chris@42 5435 \gdef\chaplevelprefix{\the\chapno.}%
Chris@42 5436 \resetallfloatnos
Chris@42 5437 %
Chris@42 5438 % \putwordChapter can contain complex things in translations.
Chris@42 5439 \toks0=\expandafter{\putwordChapter}%
Chris@42 5440 \message{\the\toks0 \space \the\chapno}%
Chris@42 5441 %
Chris@42 5442 % Write the actual heading.
Chris@42 5443 \chapmacro{#1}{Ynumbered}{\the\chapno}%
Chris@42 5444 %
Chris@42 5445 % So @section and the like are numbered underneath this chapter.
Chris@42 5446 \global\let\section = \numberedsec
Chris@42 5447 \global\let\subsection = \numberedsubsec
Chris@42 5448 \global\let\subsubsection = \numberedsubsubsec
Chris@42 5449 }
Chris@42 5450
Chris@42 5451 \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
Chris@42 5452 %
Chris@42 5453 \def\appendixzzz#1{%
Chris@42 5454 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
Chris@42 5455 \global\advance\appendixno by 1
Chris@42 5456 \gdef\chaplevelprefix{\appendixletter.}%
Chris@42 5457 \resetallfloatnos
Chris@42 5458 %
Chris@42 5459 % \putwordAppendix can contain complex things in translations.
Chris@42 5460 \toks0=\expandafter{\putwordAppendix}%
Chris@42 5461 \message{\the\toks0 \space \appendixletter}%
Chris@42 5462 %
Chris@42 5463 \chapmacro{#1}{Yappendix}{\appendixletter}%
Chris@42 5464 %
Chris@42 5465 \global\let\section = \appendixsec
Chris@42 5466 \global\let\subsection = \appendixsubsec
Chris@42 5467 \global\let\subsubsection = \appendixsubsubsec
Chris@42 5468 }
Chris@42 5469
Chris@42 5470 % normally unnmhead0 calls unnumberedzzz:
Chris@42 5471 \outer\parseargdef\unnumbered{\unnmhead0{#1}}
Chris@42 5472 \def\unnumberedzzz#1{%
Chris@42 5473 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
Chris@42 5474 \global\advance\unnumberedno by 1
Chris@42 5475 %
Chris@42 5476 % Since an unnumbered has no number, no prefix for figures.
Chris@42 5477 \global\let\chaplevelprefix = \empty
Chris@42 5478 \resetallfloatnos
Chris@42 5479 %
Chris@42 5480 % This used to be simply \message{#1}, but TeX fully expands the
Chris@42 5481 % argument to \message. Therefore, if #1 contained @-commands, TeX
Chris@42 5482 % expanded them. For example, in `@unnumbered The @cite{Book}', TeX
Chris@42 5483 % expanded @cite (which turns out to cause errors because \cite is meant
Chris@42 5484 % to be executed, not expanded).
Chris@42 5485 %
Chris@42 5486 % Anyway, we don't want the fully-expanded definition of @cite to appear
Chris@42 5487 % as a result of the \message, we just want `@cite' itself. We use
Chris@42 5488 % \the<toks register> to achieve this: TeX expands \the<toks> only once,
Chris@42 5489 % simply yielding the contents of <toks register>. (We also do this for
Chris@42 5490 % the toc entries.)
Chris@42 5491 \toks0 = {#1}%
Chris@42 5492 \message{(\the\toks0)}%
Chris@42 5493 %
Chris@42 5494 \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
Chris@42 5495 %
Chris@42 5496 \global\let\section = \unnumberedsec
Chris@42 5497 \global\let\subsection = \unnumberedsubsec
Chris@42 5498 \global\let\subsubsection = \unnumberedsubsubsec
Chris@42 5499 }
Chris@42 5500
Chris@42 5501 % @centerchap is like @unnumbered, but the heading is centered.
Chris@42 5502 \outer\parseargdef\centerchap{%
Chris@42 5503 % Well, we could do the following in a group, but that would break
Chris@42 5504 % an assumption that \chapmacro is called at the outermost level.
Chris@42 5505 % Thus we are safer this way: --kasal, 24feb04
Chris@42 5506 \let\centerparametersmaybe = \centerparameters
Chris@42 5507 \unnmhead0{#1}%
Chris@42 5508 \let\centerparametersmaybe = \relax
Chris@42 5509 }
Chris@42 5510
Chris@42 5511 % @top is like @unnumbered.
Chris@42 5512 \let\top\unnumbered
Chris@42 5513
Chris@42 5514 % Sections.
Chris@42 5515 %
Chris@42 5516 \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
Chris@42 5517 \def\seczzz#1{%
Chris@42 5518 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
Chris@42 5519 \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
Chris@42 5520 }
Chris@42 5521
Chris@42 5522 % normally calls appendixsectionzzz:
Chris@42 5523 \outer\parseargdef\appendixsection{\apphead1{#1}}
Chris@42 5524 \def\appendixsectionzzz#1{%
Chris@42 5525 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
Chris@42 5526 \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
Chris@42 5527 }
Chris@42 5528 \let\appendixsec\appendixsection
Chris@42 5529
Chris@42 5530 % normally calls unnumberedseczzz:
Chris@42 5531 \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
Chris@42 5532 \def\unnumberedseczzz#1{%
Chris@42 5533 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
Chris@42 5534 \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
Chris@42 5535 }
Chris@42 5536
Chris@42 5537 % Subsections.
Chris@42 5538 %
Chris@42 5539 % normally calls numberedsubseczzz:
Chris@42 5540 \outer\parseargdef\numberedsubsec{\numhead2{#1}}
Chris@42 5541 \def\numberedsubseczzz#1{%
Chris@42 5542 \global\subsubsecno=0 \global\advance\subsecno by 1
Chris@42 5543 \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
Chris@42 5544 }
Chris@42 5545
Chris@42 5546 % normally calls appendixsubseczzz:
Chris@42 5547 \outer\parseargdef\appendixsubsec{\apphead2{#1}}
Chris@42 5548 \def\appendixsubseczzz#1{%
Chris@42 5549 \global\subsubsecno=0 \global\advance\subsecno by 1
Chris@42 5550 \sectionheading{#1}{subsec}{Yappendix}%
Chris@42 5551 {\appendixletter.\the\secno.\the\subsecno}%
Chris@42 5552 }
Chris@42 5553
Chris@42 5554 % normally calls unnumberedsubseczzz:
Chris@42 5555 \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
Chris@42 5556 \def\unnumberedsubseczzz#1{%
Chris@42 5557 \global\subsubsecno=0 \global\advance\subsecno by 1
Chris@42 5558 \sectionheading{#1}{subsec}{Ynothing}%
Chris@42 5559 {\the\unnumberedno.\the\secno.\the\subsecno}%
Chris@42 5560 }
Chris@42 5561
Chris@42 5562 % Subsubsections.
Chris@42 5563 %
Chris@42 5564 % normally numberedsubsubseczzz:
Chris@42 5565 \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
Chris@42 5566 \def\numberedsubsubseczzz#1{%
Chris@42 5567 \global\advance\subsubsecno by 1
Chris@42 5568 \sectionheading{#1}{subsubsec}{Ynumbered}%
Chris@42 5569 {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
Chris@42 5570 }
Chris@42 5571
Chris@42 5572 % normally appendixsubsubseczzz:
Chris@42 5573 \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
Chris@42 5574 \def\appendixsubsubseczzz#1{%
Chris@42 5575 \global\advance\subsubsecno by 1
Chris@42 5576 \sectionheading{#1}{subsubsec}{Yappendix}%
Chris@42 5577 {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
Chris@42 5578 }
Chris@42 5579
Chris@42 5580 % normally unnumberedsubsubseczzz:
Chris@42 5581 \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
Chris@42 5582 \def\unnumberedsubsubseczzz#1{%
Chris@42 5583 \global\advance\subsubsecno by 1
Chris@42 5584 \sectionheading{#1}{subsubsec}{Ynothing}%
Chris@42 5585 {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
Chris@42 5586 }
Chris@42 5587
Chris@42 5588 % These macros control what the section commands do, according
Chris@42 5589 % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
Chris@42 5590 % Define them by default for a numbered chapter.
Chris@42 5591 \let\section = \numberedsec
Chris@42 5592 \let\subsection = \numberedsubsec
Chris@42 5593 \let\subsubsection = \numberedsubsubsec
Chris@42 5594
Chris@42 5595 % Define @majorheading, @heading and @subheading
Chris@42 5596
Chris@42 5597 \def\majorheading{%
Chris@42 5598 {\advance\chapheadingskip by 10pt \chapbreak }%
Chris@42 5599 \parsearg\chapheadingzzz
Chris@42 5600 }
Chris@42 5601
Chris@42 5602 \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
Chris@42 5603 \def\chapheadingzzz#1{%
Chris@42 5604 \vbox{\chapfonts \raggedtitlesettings #1\par}%
Chris@42 5605 \nobreak\bigskip \nobreak
Chris@42 5606 \suppressfirstparagraphindent
Chris@42 5607 }
Chris@42 5608
Chris@42 5609 % @heading, @subheading, @subsubheading.
Chris@42 5610 \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
Chris@42 5611 \suppressfirstparagraphindent}
Chris@42 5612 \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
Chris@42 5613 \suppressfirstparagraphindent}
Chris@42 5614 \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
Chris@42 5615 \suppressfirstparagraphindent}
Chris@42 5616
Chris@42 5617 % These macros generate a chapter, section, etc. heading only
Chris@42 5618 % (including whitespace, linebreaking, etc. around it),
Chris@42 5619 % given all the information in convenient, parsed form.
Chris@42 5620
Chris@42 5621 % Args are the skip and penalty (usually negative)
Chris@42 5622 \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
Chris@42 5623
Chris@42 5624 % Parameter controlling skip before chapter headings (if needed)
Chris@42 5625 \newskip\chapheadingskip
Chris@42 5626
Chris@42 5627 % Define plain chapter starts, and page on/off switching for it.
Chris@42 5628 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
Chris@42 5629 \def\chappager{\par\vfill\supereject}
Chris@42 5630 % Because \domark is called before \chapoddpage, the filler page will
Chris@42 5631 % get the headings for the next chapter, which is wrong. But we don't
Chris@42 5632 % care -- we just disable all headings on the filler page.
Chris@42 5633 \def\chapoddpage{%
Chris@42 5634 \chappager
Chris@42 5635 \ifodd\pageno \else
Chris@42 5636 \begingroup
Chris@42 5637 \headingsoff
Chris@42 5638 \null
Chris@42 5639 \chappager
Chris@42 5640 \endgroup
Chris@42 5641 \fi
Chris@42 5642 }
Chris@42 5643
Chris@42 5644 \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
Chris@42 5645
Chris@42 5646 \def\CHAPPAGoff{%
Chris@42 5647 \global\let\contentsalignmacro = \chappager
Chris@42 5648 \global\let\pchapsepmacro=\chapbreak
Chris@42 5649 \global\let\pagealignmacro=\chappager}
Chris@42 5650
Chris@42 5651 \def\CHAPPAGon{%
Chris@42 5652 \global\let\contentsalignmacro = \chappager
Chris@42 5653 \global\let\pchapsepmacro=\chappager
Chris@42 5654 \global\let\pagealignmacro=\chappager
Chris@42 5655 \global\def\HEADINGSon{\HEADINGSsingle}}
Chris@42 5656
Chris@42 5657 \def\CHAPPAGodd{%
Chris@42 5658 \global\let\contentsalignmacro = \chapoddpage
Chris@42 5659 \global\let\pchapsepmacro=\chapoddpage
Chris@42 5660 \global\let\pagealignmacro=\chapoddpage
Chris@42 5661 \global\def\HEADINGSon{\HEADINGSdouble}}
Chris@42 5662
Chris@42 5663 \CHAPPAGon
Chris@42 5664
Chris@42 5665 % Chapter opening.
Chris@42 5666 %
Chris@42 5667 % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
Chris@42 5668 % Yappendix, Yomitfromtoc), #3 the chapter number.
Chris@42 5669 %
Chris@42 5670 % To test against our argument.
Chris@42 5671 \def\Ynothingkeyword{Ynothing}
Chris@42 5672 \def\Yomitfromtockeyword{Yomitfromtoc}
Chris@42 5673 \def\Yappendixkeyword{Yappendix}
Chris@42 5674 %
Chris@42 5675 \def\chapmacro#1#2#3{%
Chris@42 5676 % Insert the first mark before the heading break (see notes for \domark).
Chris@42 5677 \let\prevchapterdefs=\lastchapterdefs
Chris@42 5678 \let\prevsectiondefs=\lastsectiondefs
Chris@42 5679 \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
Chris@42 5680 \gdef\thissection{}}%
Chris@42 5681 %
Chris@42 5682 \def\temptype{#2}%
Chris@42 5683 \ifx\temptype\Ynothingkeyword
Chris@42 5684 \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
Chris@42 5685 \gdef\thischapter{\thischaptername}}%
Chris@42 5686 \else\ifx\temptype\Yomitfromtockeyword
Chris@42 5687 \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
Chris@42 5688 \gdef\thischapter{}}%
Chris@42 5689 \else\ifx\temptype\Yappendixkeyword
Chris@42 5690 \toks0={#1}%
Chris@42 5691 \xdef\lastchapterdefs{%
Chris@42 5692 \gdef\noexpand\thischaptername{\the\toks0}%
Chris@42 5693 \gdef\noexpand\thischapternum{\appendixletter}%
Chris@42 5694 % \noexpand\putwordAppendix avoids expanding indigestible
Chris@42 5695 % commands in some of the translations.
Chris@42 5696 \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
Chris@42 5697 \noexpand\thischapternum:
Chris@42 5698 \noexpand\thischaptername}%
Chris@42 5699 }%
Chris@42 5700 \else
Chris@42 5701 \toks0={#1}%
Chris@42 5702 \xdef\lastchapterdefs{%
Chris@42 5703 \gdef\noexpand\thischaptername{\the\toks0}%
Chris@42 5704 \gdef\noexpand\thischapternum{\the\chapno}%
Chris@42 5705 % \noexpand\putwordChapter avoids expanding indigestible
Chris@42 5706 % commands in some of the translations.
Chris@42 5707 \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
Chris@42 5708 \noexpand\thischapternum:
Chris@42 5709 \noexpand\thischaptername}%
Chris@42 5710 }%
Chris@42 5711 \fi\fi\fi
Chris@42 5712 %
Chris@42 5713 % Output the mark. Pass it through \safewhatsit, to take care of
Chris@42 5714 % the preceding space.
Chris@42 5715 \safewhatsit\domark
Chris@42 5716 %
Chris@42 5717 % Insert the chapter heading break.
Chris@42 5718 \pchapsepmacro
Chris@42 5719 %
Chris@42 5720 % Now the second mark, after the heading break. No break points
Chris@42 5721 % between here and the heading.
Chris@42 5722 \let\prevchapterdefs=\lastchapterdefs
Chris@42 5723 \let\prevsectiondefs=\lastsectiondefs
Chris@42 5724 \domark
Chris@42 5725 %
Chris@42 5726 {%
Chris@42 5727 \chapfonts \rmisbold
Chris@42 5728 %
Chris@42 5729 % Have to define \lastsection before calling \donoderef, because the
Chris@42 5730 % xref code eventually uses it. On the other hand, it has to be called
Chris@42 5731 % after \pchapsepmacro, or the headline will change too soon.
Chris@42 5732 \gdef\lastsection{#1}%
Chris@42 5733 %
Chris@42 5734 % Only insert the separating space if we have a chapter/appendix
Chris@42 5735 % number, and don't print the unnumbered ``number''.
Chris@42 5736 \ifx\temptype\Ynothingkeyword
Chris@42 5737 \setbox0 = \hbox{}%
Chris@42 5738 \def\toctype{unnchap}%
Chris@42 5739 \else\ifx\temptype\Yomitfromtockeyword
Chris@42 5740 \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
Chris@42 5741 \def\toctype{omit}%
Chris@42 5742 \else\ifx\temptype\Yappendixkeyword
Chris@42 5743 \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
Chris@42 5744 \def\toctype{app}%
Chris@42 5745 \else
Chris@42 5746 \setbox0 = \hbox{#3\enspace}%
Chris@42 5747 \def\toctype{numchap}%
Chris@42 5748 \fi\fi\fi
Chris@42 5749 %
Chris@42 5750 % Write the toc entry for this chapter. Must come before the
Chris@42 5751 % \donoderef, because we include the current node name in the toc
Chris@42 5752 % entry, and \donoderef resets it to empty.
Chris@42 5753 \writetocentry{\toctype}{#1}{#3}%
Chris@42 5754 %
Chris@42 5755 % For pdftex, we have to write out the node definition (aka, make
Chris@42 5756 % the pdfdest) after any page break, but before the actual text has
Chris@42 5757 % been typeset. If the destination for the pdf outline is after the
Chris@42 5758 % text, then jumping from the outline may wind up with the text not
Chris@42 5759 % being visible, for instance under high magnification.
Chris@42 5760 \donoderef{#2}%
Chris@42 5761 %
Chris@42 5762 % Typeset the actual heading.
Chris@42 5763 \nobreak % Avoid page breaks at the interline glue.
Chris@42 5764 \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
Chris@42 5765 \unhbox0 #1\par}%
Chris@42 5766 }%
Chris@42 5767 \nobreak\bigskip % no page break after a chapter title
Chris@42 5768 \nobreak
Chris@42 5769 }
Chris@42 5770
Chris@42 5771 % @centerchap -- centered and unnumbered.
Chris@42 5772 \let\centerparametersmaybe = \relax
Chris@42 5773 \def\centerparameters{%
Chris@42 5774 \advance\rightskip by 3\rightskip
Chris@42 5775 \leftskip = \rightskip
Chris@42 5776 \parfillskip = 0pt
Chris@42 5777 }
Chris@42 5778
Chris@42 5779
Chris@42 5780 % I don't think this chapter style is supported any more, so I'm not
Chris@42 5781 % updating it with the new noderef stuff. We'll see. --karl, 11aug03.
Chris@42 5782 %
Chris@42 5783 \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
Chris@42 5784 %
Chris@42 5785 \def\unnchfopen #1{%
Chris@42 5786 \chapoddpage
Chris@42 5787 \vbox{\chapfonts \raggedtitlesettings #1\par}%
Chris@42 5788 \nobreak\bigskip\nobreak
Chris@42 5789 }
Chris@42 5790 \def\chfopen #1#2{\chapoddpage {\chapfonts
Chris@42 5791 \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
Chris@42 5792 \par\penalty 5000 %
Chris@42 5793 }
Chris@42 5794 \def\centerchfopen #1{%
Chris@42 5795 \chapoddpage
Chris@42 5796 \vbox{\chapfonts \raggedtitlesettings \hfill #1\hfill}%
Chris@42 5797 \nobreak\bigskip \nobreak
Chris@42 5798 }
Chris@42 5799 \def\CHAPFopen{%
Chris@42 5800 \global\let\chapmacro=\chfopen
Chris@42 5801 \global\let\centerchapmacro=\centerchfopen}
Chris@42 5802
Chris@42 5803
Chris@42 5804 % Section titles. These macros combine the section number parts and
Chris@42 5805 % call the generic \sectionheading to do the printing.
Chris@42 5806 %
Chris@42 5807 \newskip\secheadingskip
Chris@42 5808 \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
Chris@42 5809
Chris@42 5810 % Subsection titles.
Chris@42 5811 \newskip\subsecheadingskip
Chris@42 5812 \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
Chris@42 5813
Chris@42 5814 % Subsubsection titles.
Chris@42 5815 \def\subsubsecheadingskip{\subsecheadingskip}
Chris@42 5816 \def\subsubsecheadingbreak{\subsecheadingbreak}
Chris@42 5817
Chris@42 5818
Chris@42 5819 % Print any size, any type, section title.
Chris@42 5820 %
Chris@42 5821 % #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is
Chris@42 5822 % the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
Chris@42 5823 % section number.
Chris@42 5824 %
Chris@42 5825 \def\seckeyword{sec}
Chris@42 5826 %
Chris@42 5827 \def\sectionheading#1#2#3#4{%
Chris@42 5828 {%
Chris@42 5829 \checkenv{}% should not be in an environment.
Chris@42 5830 %
Chris@42 5831 % Switch to the right set of fonts.
Chris@42 5832 \csname #2fonts\endcsname \rmisbold
Chris@42 5833 %
Chris@42 5834 \def\sectionlevel{#2}%
Chris@42 5835 \def\temptype{#3}%
Chris@42 5836 %
Chris@42 5837 % Insert first mark before the heading break (see notes for \domark).
Chris@42 5838 \let\prevsectiondefs=\lastsectiondefs
Chris@42 5839 \ifx\temptype\Ynothingkeyword
Chris@42 5840 \ifx\sectionlevel\seckeyword
Chris@42 5841 \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
Chris@42 5842 \gdef\thissection{\thissectionname}}%
Chris@42 5843 \fi
Chris@42 5844 \else\ifx\temptype\Yomitfromtockeyword
Chris@42 5845 % Don't redefine \thissection.
Chris@42 5846 \else\ifx\temptype\Yappendixkeyword
Chris@42 5847 \ifx\sectionlevel\seckeyword
Chris@42 5848 \toks0={#1}%
Chris@42 5849 \xdef\lastsectiondefs{%
Chris@42 5850 \gdef\noexpand\thissectionname{\the\toks0}%
Chris@42 5851 \gdef\noexpand\thissectionnum{#4}%
Chris@42 5852 % \noexpand\putwordSection avoids expanding indigestible
Chris@42 5853 % commands in some of the translations.
Chris@42 5854 \gdef\noexpand\thissection{\noexpand\putwordSection{}
Chris@42 5855 \noexpand\thissectionnum:
Chris@42 5856 \noexpand\thissectionname}%
Chris@42 5857 }%
Chris@42 5858 \fi
Chris@42 5859 \else
Chris@42 5860 \ifx\sectionlevel\seckeyword
Chris@42 5861 \toks0={#1}%
Chris@42 5862 \xdef\lastsectiondefs{%
Chris@42 5863 \gdef\noexpand\thissectionname{\the\toks0}%
Chris@42 5864 \gdef\noexpand\thissectionnum{#4}%
Chris@42 5865 % \noexpand\putwordSection avoids expanding indigestible
Chris@42 5866 % commands in some of the translations.
Chris@42 5867 \gdef\noexpand\thissection{\noexpand\putwordSection{}
Chris@42 5868 \noexpand\thissectionnum:
Chris@42 5869 \noexpand\thissectionname}%
Chris@42 5870 }%
Chris@42 5871 \fi
Chris@42 5872 \fi\fi\fi
Chris@42 5873 %
Chris@42 5874 % Go into vertical mode. Usually we'll already be there, but we
Chris@42 5875 % don't want the following whatsit to end up in a preceding paragraph
Chris@42 5876 % if the document didn't happen to have a blank line.
Chris@42 5877 \par
Chris@42 5878 %
Chris@42 5879 % Output the mark. Pass it through \safewhatsit, to take care of
Chris@42 5880 % the preceding space.
Chris@42 5881 \safewhatsit\domark
Chris@42 5882 %
Chris@42 5883 % Insert space above the heading.
Chris@42 5884 \csname #2headingbreak\endcsname
Chris@42 5885 %
Chris@42 5886 % Now the second mark, after the heading break. No break points
Chris@42 5887 % between here and the heading.
Chris@42 5888 \let\prevsectiondefs=\lastsectiondefs
Chris@42 5889 \domark
Chris@42 5890 %
Chris@42 5891 % Only insert the space after the number if we have a section number.
Chris@42 5892 \ifx\temptype\Ynothingkeyword
Chris@42 5893 \setbox0 = \hbox{}%
Chris@42 5894 \def\toctype{unn}%
Chris@42 5895 \gdef\lastsection{#1}%
Chris@42 5896 \else\ifx\temptype\Yomitfromtockeyword
Chris@42 5897 % for @headings -- no section number, don't include in toc,
Chris@42 5898 % and don't redefine \lastsection.
Chris@42 5899 \setbox0 = \hbox{}%
Chris@42 5900 \def\toctype{omit}%
Chris@42 5901 \let\sectionlevel=\empty
Chris@42 5902 \else\ifx\temptype\Yappendixkeyword
Chris@42 5903 \setbox0 = \hbox{#4\enspace}%
Chris@42 5904 \def\toctype{app}%
Chris@42 5905 \gdef\lastsection{#1}%
Chris@42 5906 \else
Chris@42 5907 \setbox0 = \hbox{#4\enspace}%
Chris@42 5908 \def\toctype{num}%
Chris@42 5909 \gdef\lastsection{#1}%
Chris@42 5910 \fi\fi\fi
Chris@42 5911 %
Chris@42 5912 % Write the toc entry (before \donoderef). See comments in \chapmacro.
Chris@42 5913 \writetocentry{\toctype\sectionlevel}{#1}{#4}%
Chris@42 5914 %
Chris@42 5915 % Write the node reference (= pdf destination for pdftex).
Chris@42 5916 % Again, see comments in \chapmacro.
Chris@42 5917 \donoderef{#3}%
Chris@42 5918 %
Chris@42 5919 % Interline glue will be inserted when the vbox is completed.
Chris@42 5920 % That glue will be a valid breakpoint for the page, since it'll be
Chris@42 5921 % preceded by a whatsit (usually from the \donoderef, or from the
Chris@42 5922 % \writetocentry if there was no node). We don't want to allow that
Chris@42 5923 % break, since then the whatsits could end up on page n while the
Chris@42 5924 % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000.
Chris@42 5925 \nobreak
Chris@42 5926 %
Chris@42 5927 % Output the actual section heading.
Chris@42 5928 \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
Chris@42 5929 \hangindent=\wd0 % zero if no section number
Chris@42 5930 \unhbox0 #1}%
Chris@42 5931 }%
Chris@42 5932 % Add extra space after the heading -- half of whatever came above it.
Chris@42 5933 % Don't allow stretch, though.
Chris@42 5934 \kern .5 \csname #2headingskip\endcsname
Chris@42 5935 %
Chris@42 5936 % Do not let the kern be a potential breakpoint, as it would be if it
Chris@42 5937 % was followed by glue.
Chris@42 5938 \nobreak
Chris@42 5939 %
Chris@42 5940 % We'll almost certainly start a paragraph next, so don't let that
Chris@42 5941 % glue accumulate. (Not a breakpoint because it's preceded by a
Chris@42 5942 % discardable item.) However, when a paragraph is not started next
Chris@42 5943 % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
Chris@42 5944 % or the negative glue will cause weirdly wrong output, typically
Chris@42 5945 % obscuring the section heading with something else.
Chris@42 5946 \vskip-\parskip
Chris@42 5947 %
Chris@42 5948 % This is so the last item on the main vertical list is a known
Chris@42 5949 % \penalty > 10000, so \startdefun, etc., can recognize the situation
Chris@42 5950 % and do the needful.
Chris@42 5951 \penalty 10001
Chris@42 5952 }
Chris@42 5953
Chris@42 5954
Chris@42 5955 \message{toc,}
Chris@42 5956 % Table of contents.
Chris@42 5957 \newwrite\tocfile
Chris@42 5958
Chris@42 5959 % Write an entry to the toc file, opening it if necessary.
Chris@42 5960 % Called from @chapter, etc.
Chris@42 5961 %
Chris@42 5962 % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
Chris@42 5963 % We append the current node name (if any) and page number as additional
Chris@42 5964 % arguments for the \{chap,sec,...}entry macros which will eventually
Chris@42 5965 % read this. The node name is used in the pdf outlines as the
Chris@42 5966 % destination to jump to.
Chris@42 5967 %
Chris@42 5968 % We open the .toc file for writing here instead of at @setfilename (or
Chris@42 5969 % any other fixed time) so that @contents can be anywhere in the document.
Chris@42 5970 % But if #1 is `omit', then we don't do anything. This is used for the
Chris@42 5971 % table of contents chapter openings themselves.
Chris@42 5972 %
Chris@42 5973 \newif\iftocfileopened
Chris@42 5974 \def\omitkeyword{omit}%
Chris@42 5975 %
Chris@42 5976 \def\writetocentry#1#2#3{%
Chris@42 5977 \edef\writetoctype{#1}%
Chris@42 5978 \ifx\writetoctype\omitkeyword \else
Chris@42 5979 \iftocfileopened\else
Chris@42 5980 \immediate\openout\tocfile = \jobname.toc
Chris@42 5981 \global\tocfileopenedtrue
Chris@42 5982 \fi
Chris@42 5983 %
Chris@42 5984 \iflinks
Chris@42 5985 {\atdummies
Chris@42 5986 \edef\temp{%
Chris@42 5987 \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
Chris@42 5988 \temp
Chris@42 5989 }%
Chris@42 5990 \fi
Chris@42 5991 \fi
Chris@42 5992 %
Chris@42 5993 % Tell \shipout to create a pdf destination on each page, if we're
Chris@42 5994 % writing pdf. These are used in the table of contents. We can't
Chris@42 5995 % just write one on every page because the title pages are numbered
Chris@42 5996 % 1 and 2 (the page numbers aren't printed), and so are the first
Chris@42 5997 % two pages of the document. Thus, we'd have two destinations named
Chris@42 5998 % `1', and two named `2'.
Chris@42 5999 \ifpdf \global\pdfmakepagedesttrue \fi
Chris@42 6000 }
Chris@42 6001
Chris@42 6002
Chris@42 6003 % These characters do not print properly in the Computer Modern roman
Chris@42 6004 % fonts, so we must take special care. This is more or less redundant
Chris@42 6005 % with the Texinfo input format setup at the end of this file.
Chris@42 6006 %
Chris@42 6007 \def\activecatcodes{%
Chris@42 6008 \catcode`\"=\active
Chris@42 6009 \catcode`\$=\active
Chris@42 6010 \catcode`\<=\active
Chris@42 6011 \catcode`\>=\active
Chris@42 6012 \catcode`\\=\active
Chris@42 6013 \catcode`\^=\active
Chris@42 6014 \catcode`\_=\active
Chris@42 6015 \catcode`\|=\active
Chris@42 6016 \catcode`\~=\active
Chris@42 6017 }
Chris@42 6018
Chris@42 6019
Chris@42 6020 % Read the toc file, which is essentially Texinfo input.
Chris@42 6021 \def\readtocfile{%
Chris@42 6022 \setupdatafile
Chris@42 6023 \activecatcodes
Chris@42 6024 \input \tocreadfilename
Chris@42 6025 }
Chris@42 6026
Chris@42 6027 \newskip\contentsrightmargin \contentsrightmargin=1in
Chris@42 6028 \newcount\savepageno
Chris@42 6029 \newcount\lastnegativepageno \lastnegativepageno = -1
Chris@42 6030
Chris@42 6031 % Prepare to read what we've written to \tocfile.
Chris@42 6032 %
Chris@42 6033 \def\startcontents#1{%
Chris@42 6034 % If @setchapternewpage on, and @headings double, the contents should
Chris@42 6035 % start on an odd page, unlike chapters. Thus, we maintain
Chris@42 6036 % \contentsalignmacro in parallel with \pagealignmacro.
Chris@42 6037 % From: Torbjorn Granlund <tege@matematik.su.se>
Chris@42 6038 \contentsalignmacro
Chris@42 6039 \immediate\closeout\tocfile
Chris@42 6040 %
Chris@42 6041 % Don't need to put `Contents' or `Short Contents' in the headline.
Chris@42 6042 % It is abundantly clear what they are.
Chris@42 6043 \chapmacro{#1}{Yomitfromtoc}{}%
Chris@42 6044 %
Chris@42 6045 \savepageno = \pageno
Chris@42 6046 \begingroup % Set up to handle contents files properly.
Chris@42 6047 \raggedbottom % Worry more about breakpoints than the bottom.
Chris@42 6048 \advance\hsize by -\contentsrightmargin % Don't use the full line length.
Chris@42 6049 %
Chris@42 6050 % Roman numerals for page numbers.
Chris@42 6051 \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
Chris@42 6052 }
Chris@42 6053
Chris@42 6054 % redefined for the two-volume lispref. We always output on
Chris@42 6055 % \jobname.toc even if this is redefined.
Chris@42 6056 %
Chris@42 6057 \def\tocreadfilename{\jobname.toc}
Chris@42 6058
Chris@42 6059 % Normal (long) toc.
Chris@42 6060 %
Chris@42 6061 \def\contents{%
Chris@42 6062 \startcontents{\putwordTOC}%
Chris@42 6063 \openin 1 \tocreadfilename\space
Chris@42 6064 \ifeof 1 \else
Chris@42 6065 \readtocfile
Chris@42 6066 \fi
Chris@42 6067 \vfill \eject
Chris@42 6068 \contentsalignmacro % in case @setchapternewpage odd is in effect
Chris@42 6069 \ifeof 1 \else
Chris@42 6070 \pdfmakeoutlines
Chris@42 6071 \fi
Chris@42 6072 \closein 1
Chris@42 6073 \endgroup
Chris@42 6074 \lastnegativepageno = \pageno
Chris@42 6075 \global\pageno = \savepageno
Chris@42 6076 }
Chris@42 6077
Chris@42 6078 % And just the chapters.
Chris@42 6079 \def\summarycontents{%
Chris@42 6080 \startcontents{\putwordShortTOC}%
Chris@42 6081 %
Chris@42 6082 \let\partentry = \shortpartentry
Chris@42 6083 \let\numchapentry = \shortchapentry
Chris@42 6084 \let\appentry = \shortchapentry
Chris@42 6085 \let\unnchapentry = \shortunnchapentry
Chris@42 6086 % We want a true roman here for the page numbers.
Chris@42 6087 \secfonts
Chris@42 6088 \let\rm=\shortcontrm \let\bf=\shortcontbf
Chris@42 6089 \let\sl=\shortcontsl \let\tt=\shortconttt
Chris@42 6090 \rm
Chris@42 6091 \hyphenpenalty = 10000
Chris@42 6092 \advance\baselineskip by 1pt % Open it up a little.
Chris@42 6093 \def\numsecentry##1##2##3##4{}
Chris@42 6094 \let\appsecentry = \numsecentry
Chris@42 6095 \let\unnsecentry = \numsecentry
Chris@42 6096 \let\numsubsecentry = \numsecentry
Chris@42 6097 \let\appsubsecentry = \numsecentry
Chris@42 6098 \let\unnsubsecentry = \numsecentry
Chris@42 6099 \let\numsubsubsecentry = \numsecentry
Chris@42 6100 \let\appsubsubsecentry = \numsecentry
Chris@42 6101 \let\unnsubsubsecentry = \numsecentry
Chris@42 6102 \openin 1 \tocreadfilename\space
Chris@42 6103 \ifeof 1 \else
Chris@42 6104 \readtocfile
Chris@42 6105 \fi
Chris@42 6106 \closein 1
Chris@42 6107 \vfill \eject
Chris@42 6108 \contentsalignmacro % in case @setchapternewpage odd is in effect
Chris@42 6109 \endgroup
Chris@42 6110 \lastnegativepageno = \pageno
Chris@42 6111 \global\pageno = \savepageno
Chris@42 6112 }
Chris@42 6113 \let\shortcontents = \summarycontents
Chris@42 6114
Chris@42 6115 % Typeset the label for a chapter or appendix for the short contents.
Chris@42 6116 % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
Chris@42 6117 %
Chris@42 6118 \def\shortchaplabel#1{%
Chris@42 6119 % This space should be enough, since a single number is .5em, and the
Chris@42 6120 % widest letter (M) is 1em, at least in the Computer Modern fonts.
Chris@42 6121 % But use \hss just in case.
Chris@42 6122 % (This space doesn't include the extra space that gets added after
Chris@42 6123 % the label; that gets put in by \shortchapentry above.)
Chris@42 6124 %
Chris@42 6125 % We'd like to right-justify chapter numbers, but that looks strange
Chris@42 6126 % with appendix letters. And right-justifying numbers and
Chris@42 6127 % left-justifying letters looks strange when there is less than 10
Chris@42 6128 % chapters. Have to read the whole toc once to know how many chapters
Chris@42 6129 % there are before deciding ...
Chris@42 6130 \hbox to 1em{#1\hss}%
Chris@42 6131 }
Chris@42 6132
Chris@42 6133 % These macros generate individual entries in the table of contents.
Chris@42 6134 % The first argument is the chapter or section name.
Chris@42 6135 % The last argument is the page number.
Chris@42 6136 % The arguments in between are the chapter number, section number, ...
Chris@42 6137
Chris@42 6138 % Parts, in the main contents. Replace the part number, which doesn't
Chris@42 6139 % exist, with an empty box. Let's hope all the numbers have the same width.
Chris@42 6140 % Also ignore the page number, which is conventionally not printed.
Chris@42 6141 \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
Chris@42 6142 \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}}
Chris@42 6143 %
Chris@42 6144 % Parts, in the short toc.
Chris@42 6145 \def\shortpartentry#1#2#3#4{%
Chris@42 6146 \penalty-300
Chris@42 6147 \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
Chris@42 6148 \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
Chris@42 6149 }
Chris@42 6150
Chris@42 6151 % Chapters, in the main contents.
Chris@42 6152 \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
Chris@42 6153 %
Chris@42 6154 % Chapters, in the short toc.
Chris@42 6155 % See comments in \dochapentry re vbox and related settings.
Chris@42 6156 \def\shortchapentry#1#2#3#4{%
Chris@42 6157 \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
Chris@42 6158 }
Chris@42 6159
Chris@42 6160 % Appendices, in the main contents.
Chris@42 6161 % Need the word Appendix, and a fixed-size box.
Chris@42 6162 %
Chris@42 6163 \def\appendixbox#1{%
Chris@42 6164 % We use M since it's probably the widest letter.
Chris@42 6165 \setbox0 = \hbox{\putwordAppendix{} M}%
Chris@42 6166 \hbox to \wd0{\putwordAppendix{} #1\hss}}
Chris@42 6167 %
Chris@42 6168 \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}}
Chris@42 6169
Chris@42 6170 % Unnumbered chapters.
Chris@42 6171 \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
Chris@42 6172 \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
Chris@42 6173
Chris@42 6174 % Sections.
Chris@42 6175 \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
Chris@42 6176 \let\appsecentry=\numsecentry
Chris@42 6177 \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
Chris@42 6178
Chris@42 6179 % Subsections.
Chris@42 6180 \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
Chris@42 6181 \let\appsubsecentry=\numsubsecentry
Chris@42 6182 \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
Chris@42 6183
Chris@42 6184 % And subsubsections.
Chris@42 6185 \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
Chris@42 6186 \let\appsubsubsecentry=\numsubsubsecentry
Chris@42 6187 \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
Chris@42 6188
Chris@42 6189 % This parameter controls the indentation of the various levels.
Chris@42 6190 % Same as \defaultparindent.
Chris@42 6191 \newdimen\tocindent \tocindent = 15pt
Chris@42 6192
Chris@42 6193 % Now for the actual typesetting. In all these, #1 is the text and #2 is the
Chris@42 6194 % page number.
Chris@42 6195 %
Chris@42 6196 % If the toc has to be broken over pages, we want it to be at chapters
Chris@42 6197 % if at all possible; hence the \penalty.
Chris@42 6198 \def\dochapentry#1#2{%
Chris@42 6199 \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
Chris@42 6200 \begingroup
Chris@42 6201 \chapentryfonts
Chris@42 6202 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
Chris@42 6203 \endgroup
Chris@42 6204 \nobreak\vskip .25\baselineskip plus.1\baselineskip
Chris@42 6205 }
Chris@42 6206
Chris@42 6207 \def\dosecentry#1#2{\begingroup
Chris@42 6208 \secentryfonts \leftskip=\tocindent
Chris@42 6209 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
Chris@42 6210 \endgroup}
Chris@42 6211
Chris@42 6212 \def\dosubsecentry#1#2{\begingroup
Chris@42 6213 \subsecentryfonts \leftskip=2\tocindent
Chris@42 6214 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
Chris@42 6215 \endgroup}
Chris@42 6216
Chris@42 6217 \def\dosubsubsecentry#1#2{\begingroup
Chris@42 6218 \subsubsecentryfonts \leftskip=3\tocindent
Chris@42 6219 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
Chris@42 6220 \endgroup}
Chris@42 6221
Chris@42 6222 % We use the same \entry macro as for the index entries.
Chris@42 6223 \let\tocentry = \entry
Chris@42 6224
Chris@42 6225 % Space between chapter (or whatever) number and the title.
Chris@42 6226 \def\labelspace{\hskip1em \relax}
Chris@42 6227
Chris@42 6228 \def\dopageno#1{{\rm #1}}
Chris@42 6229 \def\doshortpageno#1{{\rm #1}}
Chris@42 6230
Chris@42 6231 \def\chapentryfonts{\secfonts \rm}
Chris@42 6232 \def\secentryfonts{\textfonts}
Chris@42 6233 \def\subsecentryfonts{\textfonts}
Chris@42 6234 \def\subsubsecentryfonts{\textfonts}
Chris@42 6235
Chris@42 6236
Chris@42 6237 \message{environments,}
Chris@42 6238 % @foo ... @end foo.
Chris@42 6239
Chris@42 6240 % @tex ... @end tex escapes into raw TeX temporarily.
Chris@42 6241 % One exception: @ is still an escape character, so that @end tex works.
Chris@42 6242 % But \@ or @@ will get a plain @ character.
Chris@42 6243
Chris@42 6244 \envdef\tex{%
Chris@42 6245 \setupmarkupstyle{tex}%
Chris@42 6246 \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
Chris@42 6247 \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
Chris@42 6248 \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
Chris@42 6249 \catcode `\%=14
Chris@42 6250 \catcode `\+=\other
Chris@42 6251 \catcode `\"=\other
Chris@42 6252 \catcode `\|=\other
Chris@42 6253 \catcode `\<=\other
Chris@42 6254 \catcode `\>=\other
Chris@42 6255 \catcode`\`=\other
Chris@42 6256 \catcode`\'=\other
Chris@42 6257 \escapechar=`\\
Chris@42 6258 %
Chris@42 6259 % ' is active in math mode (mathcode"8000). So reset it, and all our
Chris@42 6260 % other math active characters (just in case), to plain's definitions.
Chris@42 6261 \mathactive
Chris@42 6262 %
Chris@42 6263 \let\b=\ptexb
Chris@42 6264 \let\bullet=\ptexbullet
Chris@42 6265 \let\c=\ptexc
Chris@42 6266 \let\,=\ptexcomma
Chris@42 6267 \let\.=\ptexdot
Chris@42 6268 \let\dots=\ptexdots
Chris@42 6269 \let\equiv=\ptexequiv
Chris@42 6270 \let\!=\ptexexclam
Chris@42 6271 \let\i=\ptexi
Chris@42 6272 \let\indent=\ptexindent
Chris@42 6273 \let\noindent=\ptexnoindent
Chris@42 6274 \let\{=\ptexlbrace
Chris@42 6275 \let\+=\tabalign
Chris@42 6276 \let\}=\ptexrbrace
Chris@42 6277 \let\/=\ptexslash
Chris@42 6278 \let\*=\ptexstar
Chris@42 6279 \let\t=\ptext
Chris@42 6280 \expandafter \let\csname top\endcsname=\ptextop % outer
Chris@42 6281 \let\frenchspacing=\plainfrenchspacing
Chris@42 6282 %
Chris@42 6283 \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
Chris@42 6284 \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
Chris@42 6285 \def\@{@}%
Chris@42 6286 }
Chris@42 6287 % There is no need to define \Etex.
Chris@42 6288
Chris@42 6289 % Define @lisp ... @end lisp.
Chris@42 6290 % @lisp environment forms a group so it can rebind things,
Chris@42 6291 % including the definition of @end lisp (which normally is erroneous).
Chris@42 6292
Chris@42 6293 % Amount to narrow the margins by for @lisp.
Chris@42 6294 \newskip\lispnarrowing \lispnarrowing=0.4in
Chris@42 6295
Chris@42 6296 % This is the definition that ^^M gets inside @lisp, @example, and other
Chris@42 6297 % such environments. \null is better than a space, since it doesn't
Chris@42 6298 % have any width.
Chris@42 6299 \def\lisppar{\null\endgraf}
Chris@42 6300
Chris@42 6301 % This space is always present above and below environments.
Chris@42 6302 \newskip\envskipamount \envskipamount = 0pt
Chris@42 6303
Chris@42 6304 % Make spacing and below environment symmetrical. We use \parskip here
Chris@42 6305 % to help in doing that, since in @example-like environments \parskip
Chris@42 6306 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
Chris@42 6307 % start of the next paragraph will insert \parskip.
Chris@42 6308 %
Chris@42 6309 \def\aboveenvbreak{{%
Chris@42 6310 % =10000 instead of <10000 because of a special case in \itemzzz and
Chris@42 6311 % \sectionheading, q.v.
Chris@42 6312 \ifnum \lastpenalty=10000 \else
Chris@42 6313 \advance\envskipamount by \parskip
Chris@42 6314 \endgraf
Chris@42 6315 \ifdim\lastskip<\envskipamount
Chris@42 6316 \removelastskip
Chris@42 6317 % it's not a good place to break if the last penalty was \nobreak
Chris@42 6318 % or better ...
Chris@42 6319 \ifnum\lastpenalty<10000 \penalty-50 \fi
Chris@42 6320 \vskip\envskipamount
Chris@42 6321 \fi
Chris@42 6322 \fi
Chris@42 6323 }}
Chris@42 6324
Chris@42 6325 \let\afterenvbreak = \aboveenvbreak
Chris@42 6326
Chris@42 6327 % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will
Chris@42 6328 % also clear it, so that its embedded environments do the narrowing again.
Chris@42 6329 \let\nonarrowing=\relax
Chris@42 6330
Chris@42 6331 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
Chris@42 6332 % environment contents.
Chris@42 6333 \font\circle=lcircle10
Chris@42 6334 \newdimen\circthick
Chris@42 6335 \newdimen\cartouter\newdimen\cartinner
Chris@42 6336 \newskip\normbskip\newskip\normpskip\newskip\normlskip
Chris@42 6337 \circthick=\fontdimen8\circle
Chris@42 6338 %
Chris@42 6339 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
Chris@42 6340 \def\ctr{{\hskip 6pt\circle\char'010}}
Chris@42 6341 \def\cbl{{\circle\char'012\hskip -6pt}}
Chris@42 6342 \def\cbr{{\hskip 6pt\circle\char'011}}
Chris@42 6343 \def\carttop{\hbox to \cartouter{\hskip\lskip
Chris@42 6344 \ctl\leaders\hrule height\circthick\hfil\ctr
Chris@42 6345 \hskip\rskip}}
Chris@42 6346 \def\cartbot{\hbox to \cartouter{\hskip\lskip
Chris@42 6347 \cbl\leaders\hrule height\circthick\hfil\cbr
Chris@42 6348 \hskip\rskip}}
Chris@42 6349 %
Chris@42 6350 \newskip\lskip\newskip\rskip
Chris@42 6351
Chris@42 6352 \envdef\cartouche{%
Chris@42 6353 \ifhmode\par\fi % can't be in the midst of a paragraph.
Chris@42 6354 \startsavinginserts
Chris@42 6355 \lskip=\leftskip \rskip=\rightskip
Chris@42 6356 \leftskip=0pt\rightskip=0pt % we want these *outside*.
Chris@42 6357 \cartinner=\hsize \advance\cartinner by-\lskip
Chris@42 6358 \advance\cartinner by-\rskip
Chris@42 6359 \cartouter=\hsize
Chris@42 6360 \advance\cartouter by 18.4pt % allow for 3pt kerns on either
Chris@42 6361 % side, and for 6pt waste from
Chris@42 6362 % each corner char, and rule thickness
Chris@42 6363 \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
Chris@42 6364 % Flag to tell @lisp, etc., not to narrow margin.
Chris@42 6365 \let\nonarrowing = t%
Chris@42 6366 %
Chris@42 6367 % If this cartouche directly follows a sectioning command, we need the
Chris@42 6368 % \parskip glue (backspaced over by default) or the cartouche can
Chris@42 6369 % collide with the section heading.
Chris@42 6370 \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
Chris@42 6371 %
Chris@42 6372 \vbox\bgroup
Chris@42 6373 \baselineskip=0pt\parskip=0pt\lineskip=0pt
Chris@42 6374 \carttop
Chris@42 6375 \hbox\bgroup
Chris@42 6376 \hskip\lskip
Chris@42 6377 \vrule\kern3pt
Chris@42 6378 \vbox\bgroup
Chris@42 6379 \kern3pt
Chris@42 6380 \hsize=\cartinner
Chris@42 6381 \baselineskip=\normbskip
Chris@42 6382 \lineskip=\normlskip
Chris@42 6383 \parskip=\normpskip
Chris@42 6384 \vskip -\parskip
Chris@42 6385 \comment % For explanation, see the end of def\group.
Chris@42 6386 }
Chris@42 6387 \def\Ecartouche{%
Chris@42 6388 \ifhmode\par\fi
Chris@42 6389 \kern3pt
Chris@42 6390 \egroup
Chris@42 6391 \kern3pt\vrule
Chris@42 6392 \hskip\rskip
Chris@42 6393 \egroup
Chris@42 6394 \cartbot
Chris@42 6395 \egroup
Chris@42 6396 \checkinserts
Chris@42 6397 }
Chris@42 6398
Chris@42 6399
Chris@42 6400 % This macro is called at the beginning of all the @example variants,
Chris@42 6401 % inside a group.
Chris@42 6402 \newdimen\nonfillparindent
Chris@42 6403 \def\nonfillstart{%
Chris@42 6404 \aboveenvbreak
Chris@42 6405 \hfuzz = 12pt % Don't be fussy
Chris@42 6406 \sepspaces % Make spaces be word-separators rather than space tokens.
Chris@42 6407 \let\par = \lisppar % don't ignore blank lines
Chris@42 6408 \obeylines % each line of input is a line of output
Chris@42 6409 \parskip = 0pt
Chris@42 6410 % Turn off paragraph indentation but redefine \indent to emulate
Chris@42 6411 % the normal \indent.
Chris@42 6412 \nonfillparindent=\parindent
Chris@42 6413 \parindent = 0pt
Chris@42 6414 \let\indent\nonfillindent
Chris@42 6415 %
Chris@42 6416 \emergencystretch = 0pt % don't try to avoid overfull boxes
Chris@42 6417 \ifx\nonarrowing\relax
Chris@42 6418 \advance \leftskip by \lispnarrowing
Chris@42 6419 \exdentamount=\lispnarrowing
Chris@42 6420 \else
Chris@42 6421 \let\nonarrowing = \relax
Chris@42 6422 \fi
Chris@42 6423 \let\exdent=\nofillexdent
Chris@42 6424 }
Chris@42 6425
Chris@42 6426 \begingroup
Chris@42 6427 \obeyspaces
Chris@42 6428 % We want to swallow spaces (but not other tokens) after the fake
Chris@42 6429 % @indent in our nonfill-environments, where spaces are normally
Chris@42 6430 % active and set to @tie, resulting in them not being ignored after
Chris@42 6431 % @indent.
Chris@42 6432 \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
Chris@42 6433 \gdef\nonfillindentcheck{%
Chris@42 6434 \ifx\temp %
Chris@42 6435 \expandafter\nonfillindentgobble%
Chris@42 6436 \else%
Chris@42 6437 \leavevmode\nonfillindentbox%
Chris@42 6438 \fi%
Chris@42 6439 }%
Chris@42 6440 \endgroup
Chris@42 6441 \def\nonfillindentgobble#1{\nonfillindent}
Chris@42 6442 \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
Chris@42 6443
Chris@42 6444 % If you want all examples etc. small: @set dispenvsize small.
Chris@42 6445 % If you want even small examples the full size: @set dispenvsize nosmall.
Chris@42 6446 % This affects the following displayed environments:
Chris@42 6447 % @example, @display, @format, @lisp
Chris@42 6448 %
Chris@42 6449 \def\smallword{small}
Chris@42 6450 \def\nosmallword{nosmall}
Chris@42 6451 \let\SETdispenvsize\relax
Chris@42 6452 \def\setnormaldispenv{%
Chris@42 6453 \ifx\SETdispenvsize\smallword
Chris@42 6454 % end paragraph for sake of leading, in case document has no blank
Chris@42 6455 % line. This is redundant with what happens in \aboveenvbreak, but
Chris@42 6456 % we need to do it before changing the fonts, and it's inconvenient
Chris@42 6457 % to change the fonts afterward.
Chris@42 6458 \ifnum \lastpenalty=10000 \else \endgraf \fi
Chris@42 6459 \smallexamplefonts \rm
Chris@42 6460 \fi
Chris@42 6461 }
Chris@42 6462 \def\setsmalldispenv{%
Chris@42 6463 \ifx\SETdispenvsize\nosmallword
Chris@42 6464 \else
Chris@42 6465 \ifnum \lastpenalty=10000 \else \endgraf \fi
Chris@42 6466 \smallexamplefonts \rm
Chris@42 6467 \fi
Chris@42 6468 }
Chris@42 6469
Chris@42 6470 % We often define two environments, @foo and @smallfoo.
Chris@42 6471 % Let's do it in one command. #1 is the env name, #2 the definition.
Chris@42 6472 \def\makedispenvdef#1#2{%
Chris@42 6473 \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
Chris@42 6474 \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
Chris@42 6475 \expandafter\let\csname E#1\endcsname \afterenvbreak
Chris@42 6476 \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
Chris@42 6477 }
Chris@42 6478
Chris@42 6479 % Define two environment synonyms (#1 and #2) for an environment.
Chris@42 6480 \def\maketwodispenvdef#1#2#3{%
Chris@42 6481 \makedispenvdef{#1}{#3}%
Chris@42 6482 \makedispenvdef{#2}{#3}%
Chris@42 6483 }
Chris@42 6484 %
Chris@42 6485 % @lisp: indented, narrowed, typewriter font;
Chris@42 6486 % @example: same as @lisp.
Chris@42 6487 %
Chris@42 6488 % @smallexample and @smalllisp: use smaller fonts.
Chris@42 6489 % Originally contributed by Pavel@xerox.
Chris@42 6490 %
Chris@42 6491 \maketwodispenvdef{lisp}{example}{%
Chris@42 6492 \nonfillstart
Chris@42 6493 \tt\setupmarkupstyle{example}%
Chris@42 6494 \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
Chris@42 6495 \gobble % eat return
Chris@42 6496 }
Chris@42 6497 % @display/@smalldisplay: same as @lisp except keep current font.
Chris@42 6498 %
Chris@42 6499 \makedispenvdef{display}{%
Chris@42 6500 \nonfillstart
Chris@42 6501 \gobble
Chris@42 6502 }
Chris@42 6503
Chris@42 6504 % @format/@smallformat: same as @display except don't narrow margins.
Chris@42 6505 %
Chris@42 6506 \makedispenvdef{format}{%
Chris@42 6507 \let\nonarrowing = t%
Chris@42 6508 \nonfillstart
Chris@42 6509 \gobble
Chris@42 6510 }
Chris@42 6511
Chris@42 6512 % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
Chris@42 6513 \envdef\flushleft{%
Chris@42 6514 \let\nonarrowing = t%
Chris@42 6515 \nonfillstart
Chris@42 6516 \gobble
Chris@42 6517 }
Chris@42 6518 \let\Eflushleft = \afterenvbreak
Chris@42 6519
Chris@42 6520 % @flushright.
Chris@42 6521 %
Chris@42 6522 \envdef\flushright{%
Chris@42 6523 \let\nonarrowing = t%
Chris@42 6524 \nonfillstart
Chris@42 6525 \advance\leftskip by 0pt plus 1fill\relax
Chris@42 6526 \gobble
Chris@42 6527 }
Chris@42 6528 \let\Eflushright = \afterenvbreak
Chris@42 6529
Chris@42 6530
Chris@42 6531 % @raggedright does more-or-less normal line breaking but no right
Chris@42 6532 % justification. From plain.tex.
Chris@42 6533 \envdef\raggedright{%
Chris@42 6534 \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax
Chris@42 6535 }
Chris@42 6536 \let\Eraggedright\par
Chris@42 6537
Chris@42 6538 \envdef\raggedleft{%
Chris@42 6539 \parindent=0pt \leftskip0pt plus2em
Chris@42 6540 \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
Chris@42 6541 \hbadness=10000 % Last line will usually be underfull, so turn off
Chris@42 6542 % badness reporting.
Chris@42 6543 }
Chris@42 6544 \let\Eraggedleft\par
Chris@42 6545
Chris@42 6546 \envdef\raggedcenter{%
Chris@42 6547 \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
Chris@42 6548 \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
Chris@42 6549 \hbadness=10000 % Last line will usually be underfull, so turn off
Chris@42 6550 % badness reporting.
Chris@42 6551 }
Chris@42 6552 \let\Eraggedcenter\par
Chris@42 6553
Chris@42 6554
Chris@42 6555 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
Chris@42 6556 % and narrows the margins. We keep \parskip nonzero in general, since
Chris@42 6557 % we're doing normal filling. So, when using \aboveenvbreak and
Chris@42 6558 % \afterenvbreak, temporarily make \parskip 0.
Chris@42 6559 %
Chris@42 6560 \makedispenvdef{quotation}{\quotationstart}
Chris@42 6561 %
Chris@42 6562 \def\quotationstart{%
Chris@42 6563 \indentedblockstart % same as \indentedblock, but increase right margin too.
Chris@42 6564 \ifx\nonarrowing\relax
Chris@42 6565 \advance\rightskip by \lispnarrowing
Chris@42 6566 \fi
Chris@42 6567 \parsearg\quotationlabel
Chris@42 6568 }
Chris@42 6569
Chris@42 6570 % We have retained a nonzero parskip for the environment, since we're
Chris@42 6571 % doing normal filling.
Chris@42 6572 %
Chris@42 6573 \def\Equotation{%
Chris@42 6574 \par
Chris@42 6575 \ifx\quotationauthor\thisisundefined\else
Chris@42 6576 % indent a bit.
Chris@42 6577 \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
Chris@42 6578 \fi
Chris@42 6579 {\parskip=0pt \afterenvbreak}%
Chris@42 6580 }
Chris@42 6581 \def\Esmallquotation{\Equotation}
Chris@42 6582
Chris@42 6583 % If we're given an argument, typeset it in bold with a colon after.
Chris@42 6584 \def\quotationlabel#1{%
Chris@42 6585 \def\temp{#1}%
Chris@42 6586 \ifx\temp\empty \else
Chris@42 6587 {\bf #1: }%
Chris@42 6588 \fi
Chris@42 6589 }
Chris@42 6590
Chris@42 6591 % @indentedblock is like @quotation, but indents only on the left and
Chris@42 6592 % has no optional argument.
Chris@42 6593 %
Chris@42 6594 \makedispenvdef{indentedblock}{\indentedblockstart}
Chris@42 6595 %
Chris@42 6596 \def\indentedblockstart{%
Chris@42 6597 {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
Chris@42 6598 \parindent=0pt
Chris@42 6599 %
Chris@42 6600 % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
Chris@42 6601 \ifx\nonarrowing\relax
Chris@42 6602 \advance\leftskip by \lispnarrowing
Chris@42 6603 \exdentamount = \lispnarrowing
Chris@42 6604 \else
Chris@42 6605 \let\nonarrowing = \relax
Chris@42 6606 \fi
Chris@42 6607 }
Chris@42 6608
Chris@42 6609 % Keep a nonzero parskip for the environment, since we're doing normal filling.
Chris@42 6610 %
Chris@42 6611 \def\Eindentedblock{%
Chris@42 6612 \par
Chris@42 6613 {\parskip=0pt \afterenvbreak}%
Chris@42 6614 }
Chris@42 6615 \def\Esmallindentedblock{\Eindentedblock}
Chris@42 6616
Chris@42 6617
Chris@42 6618 % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
Chris@42 6619 % If we want to allow any <char> as delimiter,
Chris@42 6620 % we need the curly braces so that makeinfo sees the @verb command, eg:
Chris@42 6621 % `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org
Chris@42 6622 %
Chris@42 6623 % [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
Chris@42 6624 %
Chris@42 6625 % [Knuth] p.344; only we need to do the other characters Texinfo sets
Chris@42 6626 % active too. Otherwise, they get lost as the first character on a
Chris@42 6627 % verbatim line.
Chris@42 6628 \def\dospecials{%
Chris@42 6629 \do\ \do\\\do\{\do\}\do\$\do\&%
Chris@42 6630 \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
Chris@42 6631 \do\<\do\>\do\|\do\@\do+\do\"%
Chris@42 6632 % Don't do the quotes -- if we do, @set txicodequoteundirected and
Chris@42 6633 % @set txicodequotebacktick will not have effect on @verb and
Chris@42 6634 % @verbatim, and ?` and !` ligatures won't get disabled.
Chris@42 6635 %\do\`\do\'%
Chris@42 6636 }
Chris@42 6637 %
Chris@42 6638 % [Knuth] p. 380
Chris@42 6639 \def\uncatcodespecials{%
Chris@42 6640 \def\do##1{\catcode`##1=\other}\dospecials}
Chris@42 6641 %
Chris@42 6642 % Setup for the @verb command.
Chris@42 6643 %
Chris@42 6644 % Eight spaces for a tab
Chris@42 6645 \begingroup
Chris@42 6646 \catcode`\^^I=\active
Chris@42 6647 \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
Chris@42 6648 \endgroup
Chris@42 6649 %
Chris@42 6650 \def\setupverb{%
Chris@42 6651 \tt % easiest (and conventionally used) font for verbatim
Chris@42 6652 \def\par{\leavevmode\endgraf}%
Chris@42 6653 \setupmarkupstyle{verb}%
Chris@42 6654 \tabeightspaces
Chris@42 6655 % Respect line breaks,
Chris@42 6656 % print special symbols as themselves, and
Chris@42 6657 % make each space count
Chris@42 6658 % must do in this order:
Chris@42 6659 \obeylines \uncatcodespecials \sepspaces
Chris@42 6660 }
Chris@42 6661
Chris@42 6662 % Setup for the @verbatim environment
Chris@42 6663 %
Chris@42 6664 % Real tab expansion.
Chris@42 6665 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
Chris@42 6666 %
Chris@42 6667 % We typeset each line of the verbatim in an \hbox, so we can handle
Chris@42 6668 % tabs. The \global is in case the verbatim line starts with an accent,
Chris@42 6669 % or some other command that starts with a begin-group. Otherwise, the
Chris@42 6670 % entire \verbbox would disappear at the corresponding end-group, before
Chris@42 6671 % it is typeset. Meanwhile, we can't have nested verbatim commands
Chris@42 6672 % (can we?), so the \global won't be overwriting itself.
Chris@42 6673 \newbox\verbbox
Chris@42 6674 \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
Chris@42 6675 %
Chris@42 6676 \begingroup
Chris@42 6677 \catcode`\^^I=\active
Chris@42 6678 \gdef\tabexpand{%
Chris@42 6679 \catcode`\^^I=\active
Chris@42 6680 \def^^I{\leavevmode\egroup
Chris@42 6681 \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
Chris@42 6682 \divide\dimen\verbbox by\tabw
Chris@42 6683 \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
Chris@42 6684 \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw
Chris@42 6685 \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
Chris@42 6686 }%
Chris@42 6687 }
Chris@42 6688 \endgroup
Chris@42 6689
Chris@42 6690 % start the verbatim environment.
Chris@42 6691 \def\setupverbatim{%
Chris@42 6692 \let\nonarrowing = t%
Chris@42 6693 \nonfillstart
Chris@42 6694 \tt % easiest (and conventionally used) font for verbatim
Chris@42 6695 % The \leavevmode here is for blank lines. Otherwise, we would
Chris@42 6696 % never \starttabox and the \egroup would end verbatim mode.
Chris@42 6697 \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
Chris@42 6698 \tabexpand
Chris@42 6699 \setupmarkupstyle{verbatim}%
Chris@42 6700 % Respect line breaks,
Chris@42 6701 % print special symbols as themselves, and
Chris@42 6702 % make each space count.
Chris@42 6703 % Must do in this order:
Chris@42 6704 \obeylines \uncatcodespecials \sepspaces
Chris@42 6705 \everypar{\starttabbox}%
Chris@42 6706 }
Chris@42 6707
Chris@42 6708 % Do the @verb magic: verbatim text is quoted by unique
Chris@42 6709 % delimiter characters. Before first delimiter expect a
Chris@42 6710 % right brace, after last delimiter expect closing brace:
Chris@42 6711 %
Chris@42 6712 % \def\doverb'{'<char>#1<char>'}'{#1}
Chris@42 6713 %
Chris@42 6714 % [Knuth] p. 382; only eat outer {}
Chris@42 6715 \begingroup
Chris@42 6716 \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
Chris@42 6717 \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
Chris@42 6718 \endgroup
Chris@42 6719 %
Chris@42 6720 \def\verb{\begingroup\setupverb\doverb}
Chris@42 6721 %
Chris@42 6722 %
Chris@42 6723 % Do the @verbatim magic: define the macro \doverbatim so that
Chris@42 6724 % the (first) argument ends when '@end verbatim' is reached, ie:
Chris@42 6725 %
Chris@42 6726 % \def\doverbatim#1@end verbatim{#1}
Chris@42 6727 %
Chris@42 6728 % For Texinfo it's a lot easier than for LaTeX,
Chris@42 6729 % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
Chris@42 6730 % we need not redefine '\', '{' and '}'.
Chris@42 6731 %
Chris@42 6732 % Inspired by LaTeX's verbatim command set [latex.ltx]
Chris@42 6733 %
Chris@42 6734 \begingroup
Chris@42 6735 \catcode`\ =\active
Chris@42 6736 \obeylines %
Chris@42 6737 % ignore everything up to the first ^^M, that's the newline at the end
Chris@42 6738 % of the @verbatim input line itself. Otherwise we get an extra blank
Chris@42 6739 % line in the output.
Chris@42 6740 \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
Chris@42 6741 % We really want {...\end verbatim} in the body of the macro, but
Chris@42 6742 % without the active space; thus we have to use \xdef and \gobble.
Chris@42 6743 \endgroup
Chris@42 6744 %
Chris@42 6745 \envdef\verbatim{%
Chris@42 6746 \setupverbatim\doverbatim
Chris@42 6747 }
Chris@42 6748 \let\Everbatim = \afterenvbreak
Chris@42 6749
Chris@42 6750
Chris@42 6751 % @verbatiminclude FILE - insert text of file in verbatim environment.
Chris@42 6752 %
Chris@42 6753 \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
Chris@42 6754 %
Chris@42 6755 \def\doverbatiminclude#1{%
Chris@42 6756 {%
Chris@42 6757 \makevalueexpandable
Chris@42 6758 \setupverbatim
Chris@42 6759 \indexnofonts % Allow `@@' and other weird things in file names.
Chris@42 6760 \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
Chris@42 6761 \input #1
Chris@42 6762 \afterenvbreak
Chris@42 6763 }%
Chris@42 6764 }
Chris@42 6765
Chris@42 6766 % @copying ... @end copying.
Chris@42 6767 % Save the text away for @insertcopying later.
Chris@42 6768 %
Chris@42 6769 % We save the uninterpreted tokens, rather than creating a box.
Chris@42 6770 % Saving the text in a box would be much easier, but then all the
Chris@42 6771 % typesetting commands (@smallbook, font changes, etc.) have to be done
Chris@42 6772 % beforehand -- and a) we want @copying to be done first in the source
Chris@42 6773 % file; b) letting users define the frontmatter in as flexible order as
Chris@42 6774 % possible is very desirable.
Chris@42 6775 %
Chris@42 6776 \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
Chris@42 6777 \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
Chris@42 6778 %
Chris@42 6779 \def\insertcopying{%
Chris@42 6780 \begingroup
Chris@42 6781 \parindent = 0pt % paragraph indentation looks wrong on title page
Chris@42 6782 \scanexp\copyingtext
Chris@42 6783 \endgroup
Chris@42 6784 }
Chris@42 6785
Chris@42 6786
Chris@42 6787 \message{defuns,}
Chris@42 6788 % @defun etc.
Chris@42 6789
Chris@42 6790 \newskip\defbodyindent \defbodyindent=.4in
Chris@42 6791 \newskip\defargsindent \defargsindent=50pt
Chris@42 6792 \newskip\deflastargmargin \deflastargmargin=18pt
Chris@42 6793 \newcount\defunpenalty
Chris@42 6794
Chris@42 6795 % Start the processing of @deffn:
Chris@42 6796 \def\startdefun{%
Chris@42 6797 \ifnum\lastpenalty<10000
Chris@42 6798 \medbreak
Chris@42 6799 \defunpenalty=10003 % Will keep this @deffn together with the
Chris@42 6800 % following @def command, see below.
Chris@42 6801 \else
Chris@42 6802 % If there are two @def commands in a row, we'll have a \nobreak,
Chris@42 6803 % which is there to keep the function description together with its
Chris@42 6804 % header. But if there's nothing but headers, we need to allow a
Chris@42 6805 % break somewhere. Check specifically for penalty 10002, inserted
Chris@42 6806 % by \printdefunline, instead of 10000, since the sectioning
Chris@42 6807 % commands also insert a nobreak penalty, and we don't want to allow
Chris@42 6808 % a break between a section heading and a defun.
Chris@42 6809 %
Chris@42 6810 % As a further refinement, we avoid "club" headers by signalling
Chris@42 6811 % with penalty of 10003 after the very first @deffn in the
Chris@42 6812 % sequence (see above), and penalty of 10002 after any following
Chris@42 6813 % @def command.
Chris@42 6814 \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
Chris@42 6815 %
Chris@42 6816 % Similarly, after a section heading, do not allow a break.
Chris@42 6817 % But do insert the glue.
Chris@42 6818 \medskip % preceded by discardable penalty, so not a breakpoint
Chris@42 6819 \fi
Chris@42 6820 %
Chris@42 6821 \parindent=0in
Chris@42 6822 \advance\leftskip by \defbodyindent
Chris@42 6823 \exdentamount=\defbodyindent
Chris@42 6824 }
Chris@42 6825
Chris@42 6826 \def\dodefunx#1{%
Chris@42 6827 % First, check whether we are in the right environment:
Chris@42 6828 \checkenv#1%
Chris@42 6829 %
Chris@42 6830 % As above, allow line break if we have multiple x headers in a row.
Chris@42 6831 % It's not a great place, though.
Chris@42 6832 \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
Chris@42 6833 %
Chris@42 6834 % And now, it's time to reuse the body of the original defun:
Chris@42 6835 \expandafter\gobbledefun#1%
Chris@42 6836 }
Chris@42 6837 \def\gobbledefun#1\startdefun{}
Chris@42 6838
Chris@42 6839 % \printdefunline \deffnheader{text}
Chris@42 6840 %
Chris@42 6841 \def\printdefunline#1#2{%
Chris@42 6842 \begingroup
Chris@42 6843 % call \deffnheader:
Chris@42 6844 #1#2 \endheader
Chris@42 6845 % common ending:
Chris@42 6846 \interlinepenalty = 10000
Chris@42 6847 \advance\rightskip by 0pt plus 1fil\relax
Chris@42 6848 \endgraf
Chris@42 6849 \nobreak\vskip -\parskip
Chris@42 6850 \penalty\defunpenalty % signal to \startdefun and \dodefunx
Chris@42 6851 % Some of the @defun-type tags do not enable magic parentheses,
Chris@42 6852 % rendering the following check redundant. But we don't optimize.
Chris@42 6853 \checkparencounts
Chris@42 6854 \endgroup
Chris@42 6855 }
Chris@42 6856
Chris@42 6857 \def\Edefun{\endgraf\medbreak}
Chris@42 6858
Chris@42 6859 % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
Chris@42 6860 % the only thing remaining is to define \deffnheader.
Chris@42 6861 %
Chris@42 6862 \def\makedefun#1{%
Chris@42 6863 \expandafter\let\csname E#1\endcsname = \Edefun
Chris@42 6864 \edef\temp{\noexpand\domakedefun
Chris@42 6865 \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
Chris@42 6866 \temp
Chris@42 6867 }
Chris@42 6868
Chris@42 6869 % \domakedefun \deffn \deffnx \deffnheader
Chris@42 6870 %
Chris@42 6871 % Define \deffn and \deffnx, without parameters.
Chris@42 6872 % \deffnheader has to be defined explicitly.
Chris@42 6873 %
Chris@42 6874 \def\domakedefun#1#2#3{%
Chris@42 6875 \envdef#1{%
Chris@42 6876 \startdefun
Chris@42 6877 \doingtypefnfalse % distinguish typed functions from all else
Chris@42 6878 \parseargusing\activeparens{\printdefunline#3}%
Chris@42 6879 }%
Chris@42 6880 \def#2{\dodefunx#1}%
Chris@42 6881 \def#3%
Chris@42 6882 }
Chris@42 6883
Chris@42 6884 \newif\ifdoingtypefn % doing typed function?
Chris@42 6885 \newif\ifrettypeownline % typeset return type on its own line?
Chris@42 6886
Chris@42 6887 % @deftypefnnewline on|off says whether the return type of typed functions
Chris@42 6888 % are printed on their own line. This affects @deftypefn, @deftypefun,
Chris@42 6889 % @deftypeop, and @deftypemethod.
Chris@42 6890 %
Chris@42 6891 \parseargdef\deftypefnnewline{%
Chris@42 6892 \def\temp{#1}%
Chris@42 6893 \ifx\temp\onword
Chris@42 6894 \expandafter\let\csname SETtxideftypefnnl\endcsname
Chris@42 6895 = \empty
Chris@42 6896 \else\ifx\temp\offword
Chris@42 6897 \expandafter\let\csname SETtxideftypefnnl\endcsname
Chris@42 6898 = \relax
Chris@42 6899 \else
Chris@42 6900 \errhelp = \EMsimple
Chris@42 6901 \errmessage{Unknown @txideftypefnnl value `\temp',
Chris@42 6902 must be on|off}%
Chris@42 6903 \fi\fi
Chris@42 6904 }
Chris@42 6905
Chris@42 6906 % Untyped functions:
Chris@42 6907
Chris@42 6908 % @deffn category name args
Chris@42 6909 \makedefun{deffn}{\deffngeneral{}}
Chris@42 6910
Chris@42 6911 % @deffn category class name args
Chris@42 6912 \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
Chris@42 6913
Chris@42 6914 % \defopon {category on}class name args
Chris@42 6915 \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
Chris@42 6916
Chris@42 6917 % \deffngeneral {subind}category name args
Chris@42 6918 %
Chris@42 6919 \def\deffngeneral#1#2 #3 #4\endheader{%
Chris@42 6920 % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
Chris@42 6921 \dosubind{fn}{\code{#3}}{#1}%
Chris@42 6922 \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
Chris@42 6923 }
Chris@42 6924
Chris@42 6925 % Typed functions:
Chris@42 6926
Chris@42 6927 % @deftypefn category type name args
Chris@42 6928 \makedefun{deftypefn}{\deftypefngeneral{}}
Chris@42 6929
Chris@42 6930 % @deftypeop category class type name args
Chris@42 6931 \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
Chris@42 6932
Chris@42 6933 % \deftypeopon {category on}class type name args
Chris@42 6934 \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
Chris@42 6935
Chris@42 6936 % \deftypefngeneral {subind}category type name args
Chris@42 6937 %
Chris@42 6938 \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
Chris@42 6939 \dosubind{fn}{\code{#4}}{#1}%
Chris@42 6940 \doingtypefntrue
Chris@42 6941 \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
Chris@42 6942 }
Chris@42 6943
Chris@42 6944 % Typed variables:
Chris@42 6945
Chris@42 6946 % @deftypevr category type var args
Chris@42 6947 \makedefun{deftypevr}{\deftypecvgeneral{}}
Chris@42 6948
Chris@42 6949 % @deftypecv category class type var args
Chris@42 6950 \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
Chris@42 6951
Chris@42 6952 % \deftypecvof {category of}class type var args
Chris@42 6953 \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
Chris@42 6954
Chris@42 6955 % \deftypecvgeneral {subind}category type var args
Chris@42 6956 %
Chris@42 6957 \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
Chris@42 6958 \dosubind{vr}{\code{#4}}{#1}%
Chris@42 6959 \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
Chris@42 6960 }
Chris@42 6961
Chris@42 6962 % Untyped variables:
Chris@42 6963
Chris@42 6964 % @defvr category var args
Chris@42 6965 \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
Chris@42 6966
Chris@42 6967 % @defcv category class var args
Chris@42 6968 \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
Chris@42 6969
Chris@42 6970 % \defcvof {category of}class var args
Chris@42 6971 \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
Chris@42 6972
Chris@42 6973 % Types:
Chris@42 6974
Chris@42 6975 % @deftp category name args
Chris@42 6976 \makedefun{deftp}#1 #2 #3\endheader{%
Chris@42 6977 \doind{tp}{\code{#2}}%
Chris@42 6978 \defname{#1}{}{#2}\defunargs{#3\unskip}%
Chris@42 6979 }
Chris@42 6980
Chris@42 6981 % Remaining @defun-like shortcuts:
Chris@42 6982 \makedefun{defun}{\deffnheader{\putwordDeffunc} }
Chris@42 6983 \makedefun{defmac}{\deffnheader{\putwordDefmac} }
Chris@42 6984 \makedefun{defspec}{\deffnheader{\putwordDefspec} }
Chris@42 6985 \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
Chris@42 6986 \makedefun{defvar}{\defvrheader{\putwordDefvar} }
Chris@42 6987 \makedefun{defopt}{\defvrheader{\putwordDefopt} }
Chris@42 6988 \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
Chris@42 6989 \makedefun{defmethod}{\defopon\putwordMethodon}
Chris@42 6990 \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
Chris@42 6991 \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
Chris@42 6992 \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
Chris@42 6993
Chris@42 6994 % \defname, which formats the name of the @def (not the args).
Chris@42 6995 % #1 is the category, such as "Function".
Chris@42 6996 % #2 is the return type, if any.
Chris@42 6997 % #3 is the function name.
Chris@42 6998 %
Chris@42 6999 % We are followed by (but not passed) the arguments, if any.
Chris@42 7000 %
Chris@42 7001 \def\defname#1#2#3{%
Chris@42 7002 \par
Chris@42 7003 % Get the values of \leftskip and \rightskip as they were outside the @def...
Chris@42 7004 \advance\leftskip by -\defbodyindent
Chris@42 7005 %
Chris@42 7006 % Determine if we are typesetting the return type of a typed function
Chris@42 7007 % on a line by itself.
Chris@42 7008 \rettypeownlinefalse
Chris@42 7009 \ifdoingtypefn % doing a typed function specifically?
Chris@42 7010 % then check user option for putting return type on its own line:
Chris@42 7011 \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
Chris@42 7012 \rettypeownlinetrue
Chris@42 7013 \fi
Chris@42 7014 \fi
Chris@42 7015 %
Chris@42 7016 % How we'll format the category name. Putting it in brackets helps
Chris@42 7017 % distinguish it from the body text that may end up on the next line
Chris@42 7018 % just below it.
Chris@42 7019 \def\temp{#1}%
Chris@42 7020 \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
Chris@42 7021 %
Chris@42 7022 % Figure out line sizes for the paragraph shape. We'll always have at
Chris@42 7023 % least two.
Chris@42 7024 \tempnum = 2
Chris@42 7025 %
Chris@42 7026 % The first line needs space for \box0; but if \rightskip is nonzero,
Chris@42 7027 % we need only space for the part of \box0 which exceeds it:
Chris@42 7028 \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
Chris@42 7029 %
Chris@42 7030 % If doing a return type on its own line, we'll have another line.
Chris@42 7031 \ifrettypeownline
Chris@42 7032 \advance\tempnum by 1
Chris@42 7033 \def\maybeshapeline{0in \hsize}%
Chris@42 7034 \else
Chris@42 7035 \def\maybeshapeline{}%
Chris@42 7036 \fi
Chris@42 7037 %
Chris@42 7038 % The continuations:
Chris@42 7039 \dimen2=\hsize \advance\dimen2 by -\defargsindent
Chris@42 7040 %
Chris@42 7041 % The final paragraph shape:
Chris@42 7042 \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2
Chris@42 7043 %
Chris@42 7044 % Put the category name at the right margin.
Chris@42 7045 \noindent
Chris@42 7046 \hbox to 0pt{%
Chris@42 7047 \hfil\box0 \kern-\hsize
Chris@42 7048 % \hsize has to be shortened this way:
Chris@42 7049 \kern\leftskip
Chris@42 7050 % Intentionally do not respect \rightskip, since we need the space.
Chris@42 7051 }%
Chris@42 7052 %
Chris@42 7053 % Allow all lines to be underfull without complaint:
Chris@42 7054 \tolerance=10000 \hbadness=10000
Chris@42 7055 \exdentamount=\defbodyindent
Chris@42 7056 {%
Chris@42 7057 % defun fonts. We use typewriter by default (used to be bold) because:
Chris@42 7058 % . we're printing identifiers, they should be in tt in principle.
Chris@42 7059 % . in languages with many accents, such as Czech or French, it's
Chris@42 7060 % common to leave accents off identifiers. The result looks ok in
Chris@42 7061 % tt, but exceedingly strange in rm.
Chris@42 7062 % . we don't want -- and --- to be treated as ligatures.
Chris@42 7063 % . this still does not fix the ?` and !` ligatures, but so far no
Chris@42 7064 % one has made identifiers using them :).
Chris@42 7065 \df \tt
Chris@42 7066 \def\temp{#2}% text of the return type
Chris@42 7067 \ifx\temp\empty\else
Chris@42 7068 \tclose{\temp}% typeset the return type
Chris@42 7069 \ifrettypeownline
Chris@42 7070 % put return type on its own line; prohibit line break following:
Chris@42 7071 \hfil\vadjust{\nobreak}\break
Chris@42 7072 \else
Chris@42 7073 \space % type on same line, so just followed by a space
Chris@42 7074 \fi
Chris@42 7075 \fi % no return type
Chris@42 7076 #3% output function name
Chris@42 7077 }%
Chris@42 7078 {\rm\enskip}% hskip 0.5 em of \tenrm
Chris@42 7079 %
Chris@42 7080 \boldbrax
Chris@42 7081 % arguments will be output next, if any.
Chris@42 7082 }
Chris@42 7083
Chris@42 7084 % Print arguments in slanted roman (not ttsl), inconsistently with using
Chris@42 7085 % tt for the name. This is because literal text is sometimes needed in
Chris@42 7086 % the argument list (groff manual), and ttsl and tt are not very
Chris@42 7087 % distinguishable. Prevent hyphenation at `-' chars.
Chris@42 7088 %
Chris@42 7089 \def\defunargs#1{%
Chris@42 7090 % use sl by default (not ttsl),
Chris@42 7091 % tt for the names.
Chris@42 7092 \df \sl \hyphenchar\font=0
Chris@42 7093 %
Chris@42 7094 % On the other hand, if an argument has two dashes (for instance), we
Chris@42 7095 % want a way to get ttsl. We used to recommend @var for that, so
Chris@42 7096 % leave the code in, but it's strange for @var to lead to typewriter.
Chris@42 7097 % Nowadays we recommend @code, since the difference between a ttsl hyphen
Chris@42 7098 % and a tt hyphen is pretty tiny. @code also disables ?` !`.
Chris@42 7099 \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
Chris@42 7100 #1%
Chris@42 7101 \sl\hyphenchar\font=45
Chris@42 7102 }
Chris@42 7103
Chris@42 7104 % We want ()&[] to print specially on the defun line.
Chris@42 7105 %
Chris@42 7106 \def\activeparens{%
Chris@42 7107 \catcode`\(=\active \catcode`\)=\active
Chris@42 7108 \catcode`\[=\active \catcode`\]=\active
Chris@42 7109 \catcode`\&=\active
Chris@42 7110 }
Chris@42 7111
Chris@42 7112 % Make control sequences which act like normal parenthesis chars.
Chris@42 7113 \let\lparen = ( \let\rparen = )
Chris@42 7114
Chris@42 7115 % Be sure that we always have a definition for `(', etc. For example,
Chris@42 7116 % if the fn name has parens in it, \boldbrax will not be in effect yet,
Chris@42 7117 % so TeX would otherwise complain about undefined control sequence.
Chris@42 7118 {
Chris@42 7119 \activeparens
Chris@42 7120 \global\let(=\lparen \global\let)=\rparen
Chris@42 7121 \global\let[=\lbrack \global\let]=\rbrack
Chris@42 7122 \global\let& = \&
Chris@42 7123
Chris@42 7124 \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
Chris@42 7125 \gdef\magicamp{\let&=\amprm}
Chris@42 7126 }
Chris@42 7127
Chris@42 7128 \newcount\parencount
Chris@42 7129
Chris@42 7130 % If we encounter &foo, then turn on ()-hacking afterwards
Chris@42 7131 \newif\ifampseen
Chris@42 7132 \def\amprm#1 {\ampseentrue{\bf\&#1 }}
Chris@42 7133
Chris@42 7134 \def\parenfont{%
Chris@42 7135 \ifampseen
Chris@42 7136 % At the first level, print parens in roman,
Chris@42 7137 % otherwise use the default font.
Chris@42 7138 \ifnum \parencount=1 \rm \fi
Chris@42 7139 \else
Chris@42 7140 % The \sf parens (in \boldbrax) actually are a little bolder than
Chris@42 7141 % the contained text. This is especially needed for [ and ] .
Chris@42 7142 \sf
Chris@42 7143 \fi
Chris@42 7144 }
Chris@42 7145 \def\infirstlevel#1{%
Chris@42 7146 \ifampseen
Chris@42 7147 \ifnum\parencount=1
Chris@42 7148 #1%
Chris@42 7149 \fi
Chris@42 7150 \fi
Chris@42 7151 }
Chris@42 7152 \def\bfafterword#1 {#1 \bf}
Chris@42 7153
Chris@42 7154 \def\opnr{%
Chris@42 7155 \global\advance\parencount by 1
Chris@42 7156 {\parenfont(}%
Chris@42 7157 \infirstlevel \bfafterword
Chris@42 7158 }
Chris@42 7159 \def\clnr{%
Chris@42 7160 {\parenfont)}%
Chris@42 7161 \infirstlevel \sl
Chris@42 7162 \global\advance\parencount by -1
Chris@42 7163 }
Chris@42 7164
Chris@42 7165 \newcount\brackcount
Chris@42 7166 \def\lbrb{%
Chris@42 7167 \global\advance\brackcount by 1
Chris@42 7168 {\bf[}%
Chris@42 7169 }
Chris@42 7170 \def\rbrb{%
Chris@42 7171 {\bf]}%
Chris@42 7172 \global\advance\brackcount by -1
Chris@42 7173 }
Chris@42 7174
Chris@42 7175 \def\checkparencounts{%
Chris@42 7176 \ifnum\parencount=0 \else \badparencount \fi
Chris@42 7177 \ifnum\brackcount=0 \else \badbrackcount \fi
Chris@42 7178 }
Chris@42 7179 % these should not use \errmessage; the glibc manual, at least, actually
Chris@42 7180 % has such constructs (when documenting function pointers).
Chris@42 7181 \def\badparencount{%
Chris@42 7182 \message{Warning: unbalanced parentheses in @def...}%
Chris@42 7183 \global\parencount=0
Chris@42 7184 }
Chris@42 7185 \def\badbrackcount{%
Chris@42 7186 \message{Warning: unbalanced square brackets in @def...}%
Chris@42 7187 \global\brackcount=0
Chris@42 7188 }
Chris@42 7189
Chris@42 7190
Chris@42 7191 \message{macros,}
Chris@42 7192 % @macro.
Chris@42 7193
Chris@42 7194 % To do this right we need a feature of e-TeX, \scantokens,
Chris@42 7195 % which we arrange to emulate with a temporary file in ordinary TeX.
Chris@42 7196 \ifx\eTeXversion\thisisundefined
Chris@42 7197 \newwrite\macscribble
Chris@42 7198 \def\scantokens#1{%
Chris@42 7199 \toks0={#1}%
Chris@42 7200 \immediate\openout\macscribble=\jobname.tmp
Chris@42 7201 \immediate\write\macscribble{\the\toks0}%
Chris@42 7202 \immediate\closeout\macscribble
Chris@42 7203 \input \jobname.tmp
Chris@42 7204 }
Chris@42 7205 \fi
Chris@42 7206
Chris@42 7207 \def\scanmacro#1{\begingroup
Chris@42 7208 \newlinechar`\^^M
Chris@42 7209 \let\xeatspaces\eatspaces
Chris@42 7210 %
Chris@42 7211 % Undo catcode changes of \startcontents and \doprintindex
Chris@42 7212 % When called from @insertcopying or (short)caption, we need active
Chris@42 7213 % backslash to get it printed correctly. Previously, we had
Chris@42 7214 % \catcode`\\=\other instead. We'll see whether a problem appears
Chris@42 7215 % with macro expansion. --kasal, 19aug04
Chris@42 7216 \catcode`\@=0 \catcode`\\=\active \escapechar=`\@
Chris@42 7217 %
Chris@42 7218 % ... and for \example:
Chris@42 7219 \spaceisspace
Chris@42 7220 %
Chris@42 7221 % The \empty here causes a following catcode 5 newline to be eaten as
Chris@42 7222 % part of reading whitespace after a control sequence. It does not
Chris@42 7223 % eat a catcode 13 newline. There's no good way to handle the two
Chris@42 7224 % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX
Chris@42 7225 % would then have different behavior). See the Macro Details node in
Chris@42 7226 % the manual for the workaround we recommend for macros and
Chris@42 7227 % line-oriented commands.
Chris@42 7228 %
Chris@42 7229 \scantokens{#1\empty}%
Chris@42 7230 \endgroup}
Chris@42 7231
Chris@42 7232 \def\scanexp#1{%
Chris@42 7233 \edef\temp{\noexpand\scanmacro{#1}}%
Chris@42 7234 \temp
Chris@42 7235 }
Chris@42 7236
Chris@42 7237 \newcount\paramno % Count of parameters
Chris@42 7238 \newtoks\macname % Macro name
Chris@42 7239 \newif\ifrecursive % Is it recursive?
Chris@42 7240
Chris@42 7241 % List of all defined macros in the form
Chris@42 7242 % \definedummyword\macro1\definedummyword\macro2...
Chris@42 7243 % Currently is also contains all @aliases; the list can be split
Chris@42 7244 % if there is a need.
Chris@42 7245 \def\macrolist{}
Chris@42 7246
Chris@42 7247 % Add the macro to \macrolist
Chris@42 7248 \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
Chris@42 7249 \def\addtomacrolistxxx#1{%
Chris@42 7250 \toks0 = \expandafter{\macrolist\definedummyword#1}%
Chris@42 7251 \xdef\macrolist{\the\toks0}%
Chris@42 7252 }
Chris@42 7253
Chris@42 7254 % Utility routines.
Chris@42 7255 % This does \let #1 = #2, with \csnames; that is,
Chris@42 7256 % \let \csname#1\endcsname = \csname#2\endcsname
Chris@42 7257 % (except of course we have to play expansion games).
Chris@42 7258 %
Chris@42 7259 \def\cslet#1#2{%
Chris@42 7260 \expandafter\let
Chris@42 7261 \csname#1\expandafter\endcsname
Chris@42 7262 \csname#2\endcsname
Chris@42 7263 }
Chris@42 7264
Chris@42 7265 % Trim leading and trailing spaces off a string.
Chris@42 7266 % Concepts from aro-bend problem 15 (see CTAN).
Chris@42 7267 {\catcode`\@=11
Chris@42 7268 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
Chris@42 7269 \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
Chris@42 7270 \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
Chris@42 7271 \def\unbrace#1{#1}
Chris@42 7272 \unbrace{\gdef\trim@@@ #1 } #2@{#1}
Chris@42 7273 }
Chris@42 7274
Chris@42 7275 % Trim a single trailing ^^M off a string.
Chris@42 7276 {\catcode`\^^M=\other \catcode`\Q=3%
Chris@42 7277 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
Chris@42 7278 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
Chris@42 7279 \gdef\eatcrb#1Q#2Q{#1}%
Chris@42 7280 }
Chris@42 7281
Chris@42 7282 % Macro bodies are absorbed as an argument in a context where
Chris@42 7283 % all characters are catcode 10, 11 or 12, except \ which is active
Chris@42 7284 % (as in normal texinfo). It is necessary to change the definition of \
Chris@42 7285 % to recognize macro arguments; this is the job of \mbodybackslash.
Chris@42 7286 %
Chris@42 7287 % Non-ASCII encodings make 8-bit characters active, so un-activate
Chris@42 7288 % them to avoid their expansion. Must do this non-globally, to
Chris@42 7289 % confine the change to the current group.
Chris@42 7290 %
Chris@42 7291 % It's necessary to have hard CRs when the macro is executed. This is
Chris@42 7292 % done by making ^^M (\endlinechar) catcode 12 when reading the macro
Chris@42 7293 % body, and then making it the \newlinechar in \scanmacro.
Chris@42 7294 %
Chris@42 7295 \def\scanctxt{% used as subroutine
Chris@42 7296 \catcode`\"=\other
Chris@42 7297 \catcode`\+=\other
Chris@42 7298 \catcode`\<=\other
Chris@42 7299 \catcode`\>=\other
Chris@42 7300 \catcode`\@=\other
Chris@42 7301 \catcode`\^=\other
Chris@42 7302 \catcode`\_=\other
Chris@42 7303 \catcode`\|=\other
Chris@42 7304 \catcode`\~=\other
Chris@42 7305 \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi
Chris@42 7306 }
Chris@42 7307
Chris@42 7308 \def\scanargctxt{% used for copying and captions, not macros.
Chris@42 7309 \scanctxt
Chris@42 7310 \catcode`\\=\other
Chris@42 7311 \catcode`\^^M=\other
Chris@42 7312 }
Chris@42 7313
Chris@42 7314 \def\macrobodyctxt{% used for @macro definitions
Chris@42 7315 \scanctxt
Chris@42 7316 \catcode`\{=\other
Chris@42 7317 \catcode`\}=\other
Chris@42 7318 \catcode`\^^M=\other
Chris@42 7319 \usembodybackslash
Chris@42 7320 }
Chris@42 7321
Chris@42 7322 \def\macroargctxt{% used when scanning invocations
Chris@42 7323 \scanctxt
Chris@42 7324 \catcode`\\=0
Chris@42 7325 }
Chris@42 7326 % why catcode 0 for \ in the above? To recognize \\ \{ \} as "escapes"
Chris@42 7327 % for the single characters \ { }. Thus, we end up with the "commands"
Chris@42 7328 % that would be written @\ @{ @} in a Texinfo document.
Chris@42 7329 %
Chris@42 7330 % We already have @{ and @}. For @\, we define it here, and only for
Chris@42 7331 % this purpose, to produce a typewriter backslash (so, the @\ that we
Chris@42 7332 % define for @math can't be used with @macro calls):
Chris@42 7333 %
Chris@42 7334 \def\\{\normalbackslash}%
Chris@42 7335 %
Chris@42 7336 % We would like to do this for \, too, since that is what makeinfo does.
Chris@42 7337 % But it is not possible, because Texinfo already has a command @, for a
Chris@42 7338 % cedilla accent. Documents must use @comma{} instead.
Chris@42 7339 %
Chris@42 7340 % \anythingelse will almost certainly be an error of some kind.
Chris@42 7341
Chris@42 7342
Chris@42 7343 % \mbodybackslash is the definition of \ in @macro bodies.
Chris@42 7344 % It maps \foo\ => \csname macarg.foo\endcsname => #N
Chris@42 7345 % where N is the macro parameter number.
Chris@42 7346 % We define \csname macarg.\endcsname to be \realbackslash, so
Chris@42 7347 % \\ in macro replacement text gets you a backslash.
Chris@42 7348 %
Chris@42 7349 {\catcode`@=0 @catcode`@\=@active
Chris@42 7350 @gdef@usembodybackslash{@let\=@mbodybackslash}
Chris@42 7351 @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
Chris@42 7352 }
Chris@42 7353 \expandafter\def\csname macarg.\endcsname{\realbackslash}
Chris@42 7354
Chris@42 7355 \def\margbackslash#1{\char`\#1 }
Chris@42 7356
Chris@42 7357 \def\macro{\recursivefalse\parsearg\macroxxx}
Chris@42 7358 \def\rmacro{\recursivetrue\parsearg\macroxxx}
Chris@42 7359
Chris@42 7360 \def\macroxxx#1{%
Chris@42 7361 \getargs{#1}% now \macname is the macname and \argl the arglist
Chris@42 7362 \ifx\argl\empty % no arguments
Chris@42 7363 \paramno=0\relax
Chris@42 7364 \else
Chris@42 7365 \expandafter\parsemargdef \argl;%
Chris@42 7366 \if\paramno>256\relax
Chris@42 7367 \ifx\eTeXversion\thisisundefined
Chris@42 7368 \errhelp = \EMsimple
Chris@42 7369 \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
Chris@42 7370 \fi
Chris@42 7371 \fi
Chris@42 7372 \fi
Chris@42 7373 \if1\csname ismacro.\the\macname\endcsname
Chris@42 7374 \message{Warning: redefining \the\macname}%
Chris@42 7375 \else
Chris@42 7376 \expandafter\ifx\csname \the\macname\endcsname \relax
Chris@42 7377 \else \errmessage{Macro name \the\macname\space already defined}\fi
Chris@42 7378 \global\cslet{macsave.\the\macname}{\the\macname}%
Chris@42 7379 \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
Chris@42 7380 \addtomacrolist{\the\macname}%
Chris@42 7381 \fi
Chris@42 7382 \begingroup \macrobodyctxt
Chris@42 7383 \ifrecursive \expandafter\parsermacbody
Chris@42 7384 \else \expandafter\parsemacbody
Chris@42 7385 \fi}
Chris@42 7386
Chris@42 7387 \parseargdef\unmacro{%
Chris@42 7388 \if1\csname ismacro.#1\endcsname
Chris@42 7389 \global\cslet{#1}{macsave.#1}%
Chris@42 7390 \global\expandafter\let \csname ismacro.#1\endcsname=0%
Chris@42 7391 % Remove the macro name from \macrolist:
Chris@42 7392 \begingroup
Chris@42 7393 \expandafter\let\csname#1\endcsname \relax
Chris@42 7394 \let\definedummyword\unmacrodo
Chris@42 7395 \xdef\macrolist{\macrolist}%
Chris@42 7396 \endgroup
Chris@42 7397 \else
Chris@42 7398 \errmessage{Macro #1 not defined}%
Chris@42 7399 \fi
Chris@42 7400 }
Chris@42 7401
Chris@42 7402 % Called by \do from \dounmacro on each macro. The idea is to omit any
Chris@42 7403 % macro definitions that have been changed to \relax.
Chris@42 7404 %
Chris@42 7405 \def\unmacrodo#1{%
Chris@42 7406 \ifx #1\relax
Chris@42 7407 % remove this
Chris@42 7408 \else
Chris@42 7409 \noexpand\definedummyword \noexpand#1%
Chris@42 7410 \fi
Chris@42 7411 }
Chris@42 7412
Chris@42 7413 % This makes use of the obscure feature that if the last token of a
Chris@42 7414 % <parameter list> is #, then the preceding argument is delimited by
Chris@42 7415 % an opening brace, and that opening brace is not consumed.
Chris@42 7416 \def\getargs#1{\getargsxxx#1{}}
Chris@42 7417 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
Chris@42 7418 \def\getmacname#1 #2\relax{\macname={#1}}
Chris@42 7419 \def\getmacargs#1{\def\argl{#1}}
Chris@42 7420
Chris@42 7421 % For macro processing make @ a letter so that we can make Texinfo private macro names.
Chris@42 7422 \edef\texiatcatcode{\the\catcode`\@}
Chris@42 7423 \catcode `@=11\relax
Chris@42 7424
Chris@42 7425 % Parse the optional {params} list. Set up \paramno and \paramlist
Chris@42 7426 % so \defmacro knows what to do. Define \macarg.BLAH for each BLAH
Chris@42 7427 % in the params list to some hook where the argument si to be expanded. If
Chris@42 7428 % there are less than 10 arguments that hook is to be replaced by ##N where N
Chris@42 7429 % is the position in that list, that is to say the macro arguments are to be
Chris@42 7430 % defined `a la TeX in the macro body.
Chris@42 7431 %
Chris@42 7432 % That gets used by \mbodybackslash (above).
Chris@42 7433 %
Chris@42 7434 % We need to get `macro parameter char #' into several definitions.
Chris@42 7435 % The technique used is stolen from LaTeX: let \hash be something
Chris@42 7436 % unexpandable, insert that wherever you need a #, and then redefine
Chris@42 7437 % it to # just before using the token list produced.
Chris@42 7438 %
Chris@42 7439 % The same technique is used to protect \eatspaces till just before
Chris@42 7440 % the macro is used.
Chris@42 7441 %
Chris@42 7442 % If there are 10 or more arguments, a different technique is used, where the
Chris@42 7443 % hook remains in the body, and when macro is to be expanded the body is
Chris@42 7444 % processed again to replace the arguments.
Chris@42 7445 %
Chris@42 7446 % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
Chris@42 7447 % argument N value and then \edef the body (nothing else will expand because of
Chris@42 7448 % the catcode regime underwhich the body was input).
Chris@42 7449 %
Chris@42 7450 % If you compile with TeX (not eTeX), and you have macros with 10 or more
Chris@42 7451 % arguments, you need that no macro has more than 256 arguments, otherwise an
Chris@42 7452 % error is produced.
Chris@42 7453 \def\parsemargdef#1;{%
Chris@42 7454 \paramno=0\def\paramlist{}%
Chris@42 7455 \let\hash\relax
Chris@42 7456 \let\xeatspaces\relax
Chris@42 7457 \parsemargdefxxx#1,;,%
Chris@42 7458 % In case that there are 10 or more arguments we parse again the arguments
Chris@42 7459 % list to set new definitions for the \macarg.BLAH macros corresponding to
Chris@42 7460 % each BLAH argument. It was anyhow needed to parse already once this list
Chris@42 7461 % in order to count the arguments, and as macros with at most 9 arguments
Chris@42 7462 % are by far more frequent than macro with 10 or more arguments, defining
Chris@42 7463 % twice the \macarg.BLAH macros does not cost too much processing power.
Chris@42 7464 \ifnum\paramno<10\relax\else
Chris@42 7465 \paramno0\relax
Chris@42 7466 \parsemmanyargdef@@#1,;,% 10 or more arguments
Chris@42 7467 \fi
Chris@42 7468 }
Chris@42 7469 \def\parsemargdefxxx#1,{%
Chris@42 7470 \if#1;\let\next=\relax
Chris@42 7471 \else \let\next=\parsemargdefxxx
Chris@42 7472 \advance\paramno by 1
Chris@42 7473 \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
Chris@42 7474 {\xeatspaces{\hash\the\paramno}}%
Chris@42 7475 \edef\paramlist{\paramlist\hash\the\paramno,}%
Chris@42 7476 \fi\next}
Chris@42 7477
Chris@42 7478 \def\parsemmanyargdef@@#1,{%
Chris@42 7479 \if#1;\let\next=\relax
Chris@42 7480 \else
Chris@42 7481 \let\next=\parsemmanyargdef@@
Chris@42 7482 \edef\tempb{\eatspaces{#1}}%
Chris@42 7483 \expandafter\def\expandafter\tempa
Chris@42 7484 \expandafter{\csname macarg.\tempb\endcsname}%
Chris@42 7485 % Note that we need some extra \noexpand\noexpand, this is because we
Chris@42 7486 % don't want \the to be expanded in the \parsermacbody as it uses an
Chris@42 7487 % \xdef .
Chris@42 7488 \expandafter\edef\tempa
Chris@42 7489 {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
Chris@42 7490 \advance\paramno by 1\relax
Chris@42 7491 \fi\next}
Chris@42 7492
Chris@42 7493 % These two commands read recursive and nonrecursive macro bodies.
Chris@42 7494 % (They're different since rec and nonrec macros end differently.)
Chris@42 7495 %
Chris@42 7496
Chris@42 7497 \catcode `\@\texiatcatcode
Chris@42 7498 \long\def\parsemacbody#1@end macro%
Chris@42 7499 {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
Chris@42 7500 \long\def\parsermacbody#1@end rmacro%
Chris@42 7501 {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
Chris@42 7502 \catcode `\@=11\relax
Chris@42 7503
Chris@42 7504 \let\endargs@\relax
Chris@42 7505 \let\nil@\relax
Chris@42 7506 \def\nilm@{\nil@}%
Chris@42 7507 \long\def\nillm@{\nil@}%
Chris@42 7508
Chris@42 7509 % This macro is expanded during the Texinfo macro expansion, not during its
Chris@42 7510 % definition. It gets all the arguments values and assigns them to macros
Chris@42 7511 % macarg.ARGNAME
Chris@42 7512 %
Chris@42 7513 % #1 is the macro name
Chris@42 7514 % #2 is the list of argument names
Chris@42 7515 % #3 is the list of argument values
Chris@42 7516 \def\getargvals@#1#2#3{%
Chris@42 7517 \def\macargdeflist@{}%
Chris@42 7518 \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
Chris@42 7519 \def\paramlist{#2,\nil@}%
Chris@42 7520 \def\macroname{#1}%
Chris@42 7521 \begingroup
Chris@42 7522 \macroargctxt
Chris@42 7523 \def\argvaluelist{#3,\nil@}%
Chris@42 7524 \def\@tempa{#3}%
Chris@42 7525 \ifx\@tempa\empty
Chris@42 7526 \setemptyargvalues@
Chris@42 7527 \else
Chris@42 7528 \getargvals@@
Chris@42 7529 \fi
Chris@42 7530 }
Chris@42 7531
Chris@42 7532 %
Chris@42 7533 \def\getargvals@@{%
Chris@42 7534 \ifx\paramlist\nilm@
Chris@42 7535 % Some sanity check needed here that \argvaluelist is also empty.
Chris@42 7536 \ifx\argvaluelist\nillm@
Chris@42 7537 \else
Chris@42 7538 \errhelp = \EMsimple
Chris@42 7539 \errmessage{Too many arguments in macro `\macroname'!}%
Chris@42 7540 \fi
Chris@42 7541 \let\next\macargexpandinbody@
Chris@42 7542 \else
Chris@42 7543 \ifx\argvaluelist\nillm@
Chris@42 7544 % No more arguments values passed to macro. Set remaining named-arg
Chris@42 7545 % macros to empty.
Chris@42 7546 \let\next\setemptyargvalues@
Chris@42 7547 \else
Chris@42 7548 % pop current arg name into \@tempb
Chris@42 7549 \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
Chris@42 7550 \expandafter\@tempa\expandafter{\paramlist}%
Chris@42 7551 % pop current argument value into \@tempc
Chris@42 7552 \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
Chris@42 7553 \expandafter\@tempa\expandafter{\argvaluelist}%
Chris@42 7554 % Here \@tempb is the current arg name and \@tempc is the current arg value.
Chris@42 7555 % First place the new argument macro definition into \@tempd
Chris@42 7556 \expandafter\macname\expandafter{\@tempc}%
Chris@42 7557 \expandafter\let\csname macarg.\@tempb\endcsname\relax
Chris@42 7558 \expandafter\def\expandafter\@tempe\expandafter{%
Chris@42 7559 \csname macarg.\@tempb\endcsname}%
Chris@42 7560 \edef\@tempd{\long\def\@tempe{\the\macname}}%
Chris@42 7561 \push@\@tempd\macargdeflist@
Chris@42 7562 \let\next\getargvals@@
Chris@42 7563 \fi
Chris@42 7564 \fi
Chris@42 7565 \next
Chris@42 7566 }
Chris@42 7567
Chris@42 7568 \def\push@#1#2{%
Chris@42 7569 \expandafter\expandafter\expandafter\def
Chris@42 7570 \expandafter\expandafter\expandafter#2%
Chris@42 7571 \expandafter\expandafter\expandafter{%
Chris@42 7572 \expandafter#1#2}%
Chris@42 7573 }
Chris@42 7574
Chris@42 7575 % Replace arguments by their values in the macro body, and place the result
Chris@42 7576 % in macro \@tempa
Chris@42 7577 \def\macvalstoargs@{%
Chris@42 7578 % To do this we use the property that token registers that are \the'ed
Chris@42 7579 % within an \edef expand only once. So we are going to place all argument
Chris@42 7580 % values into respective token registers.
Chris@42 7581 %
Chris@42 7582 % First we save the token context, and initialize argument numbering.
Chris@42 7583 \begingroup
Chris@42 7584 \paramno0\relax
Chris@42 7585 % Then, for each argument number #N, we place the corresponding argument
Chris@42 7586 % value into a new token list register \toks#N
Chris@42 7587 \expandafter\putargsintokens@\saveparamlist@,;,%
Chris@42 7588 % Then, we expand the body so that argument are replaced by their
Chris@42 7589 % values. The trick for values not to be expanded themselves is that they
Chris@42 7590 % are within tokens and that tokens expand only once in an \edef .
Chris@42 7591 \edef\@tempc{\csname mac.\macroname .body\endcsname}%
Chris@42 7592 % Now we restore the token stack pointer to free the token list registers
Chris@42 7593 % which we have used, but we make sure that expanded body is saved after
Chris@42 7594 % group.
Chris@42 7595 \expandafter
Chris@42 7596 \endgroup
Chris@42 7597 \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
Chris@42 7598 }
Chris@42 7599
Chris@42 7600 \def\macargexpandinbody@{%
Chris@42 7601 %% Define the named-macro outside of this group and then close this group.
Chris@42 7602 \expandafter
Chris@42 7603 \endgroup
Chris@42 7604 \macargdeflist@
Chris@42 7605 % First the replace in body the macro arguments by their values, the result
Chris@42 7606 % is in \@tempa .
Chris@42 7607 \macvalstoargs@
Chris@42 7608 % Then we point at the \norecurse or \gobble (for recursive) macro value
Chris@42 7609 % with \@tempb .
Chris@42 7610 \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
Chris@42 7611 % Depending on whether it is recursive or not, we need some tailing
Chris@42 7612 % \egroup .
Chris@42 7613 \ifx\@tempb\gobble
Chris@42 7614 \let\@tempc\relax
Chris@42 7615 \else
Chris@42 7616 \let\@tempc\egroup
Chris@42 7617 \fi
Chris@42 7618 % And now we do the real job:
Chris@42 7619 \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
Chris@42 7620 \@tempd
Chris@42 7621 }
Chris@42 7622
Chris@42 7623 \def\putargsintokens@#1,{%
Chris@42 7624 \if#1;\let\next\relax
Chris@42 7625 \else
Chris@42 7626 \let\next\putargsintokens@
Chris@42 7627 % First we allocate the new token list register, and give it a temporary
Chris@42 7628 % alias \@tempb .
Chris@42 7629 \toksdef\@tempb\the\paramno
Chris@42 7630 % Then we place the argument value into that token list register.
Chris@42 7631 \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
Chris@42 7632 \expandafter\@tempb\expandafter{\@tempa}%
Chris@42 7633 \advance\paramno by 1\relax
Chris@42 7634 \fi
Chris@42 7635 \next
Chris@42 7636 }
Chris@42 7637
Chris@42 7638 % Save the token stack pointer into macro #1
Chris@42 7639 \def\texisavetoksstackpoint#1{\edef#1{\the\@cclvi}}
Chris@42 7640 % Restore the token stack pointer from number in macro #1
Chris@42 7641 \def\texirestoretoksstackpoint#1{\expandafter\mathchardef\expandafter\@cclvi#1\relax}
Chris@42 7642 % newtoks that can be used non \outer .
Chris@42 7643 \def\texinonouternewtoks{\alloc@ 5\toks \toksdef \@cclvi}
Chris@42 7644
Chris@42 7645 % Tailing missing arguments are set to empty
Chris@42 7646 \def\setemptyargvalues@{%
Chris@42 7647 \ifx\paramlist\nilm@
Chris@42 7648 \let\next\macargexpandinbody@
Chris@42 7649 \else
Chris@42 7650 \expandafter\setemptyargvaluesparser@\paramlist\endargs@
Chris@42 7651 \let\next\setemptyargvalues@
Chris@42 7652 \fi
Chris@42 7653 \next
Chris@42 7654 }
Chris@42 7655
Chris@42 7656 \def\setemptyargvaluesparser@#1,#2\endargs@{%
Chris@42 7657 \expandafter\def\expandafter\@tempa\expandafter{%
Chris@42 7658 \expandafter\def\csname macarg.#1\endcsname{}}%
Chris@42 7659 \push@\@tempa\macargdeflist@
Chris@42 7660 \def\paramlist{#2}%
Chris@42 7661 }
Chris@42 7662
Chris@42 7663 % #1 is the element target macro
Chris@42 7664 % #2 is the list macro
Chris@42 7665 % #3,#4\endargs@ is the list value
Chris@42 7666 \def\pop@#1#2#3,#4\endargs@{%
Chris@42 7667 \def#1{#3}%
Chris@42 7668 \def#2{#4}%
Chris@42 7669 }
Chris@42 7670 \long\def\longpop@#1#2#3,#4\endargs@{%
Chris@42 7671 \long\def#1{#3}%
Chris@42 7672 \long\def#2{#4}%
Chris@42 7673 }
Chris@42 7674
Chris@42 7675 % This defines a Texinfo @macro. There are eight cases: recursive and
Chris@42 7676 % nonrecursive macros of zero, one, up to nine, and many arguments.
Chris@42 7677 % Much magic with \expandafter here.
Chris@42 7678 % \xdef is used so that macro definitions will survive the file
Chris@42 7679 % they're defined in; @include reads the file inside a group.
Chris@42 7680 %
Chris@42 7681 \def\defmacro{%
Chris@42 7682 \let\hash=##% convert placeholders to macro parameter chars
Chris@42 7683 \ifrecursive
Chris@42 7684 \ifcase\paramno
Chris@42 7685 % 0
Chris@42 7686 \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42 7687 \noexpand\scanmacro{\temp}}%
Chris@42 7688 \or % 1
Chris@42 7689 \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42 7690 \bgroup\noexpand\macroargctxt
Chris@42 7691 \noexpand\braceorline
Chris@42 7692 \expandafter\noexpand\csname\the\macname xxx\endcsname}%
Chris@42 7693 \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
Chris@42 7694 \egroup\noexpand\scanmacro{\temp}}%
Chris@42 7695 \else
Chris@42 7696 \ifnum\paramno<10\relax % at most 9
Chris@42 7697 \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42 7698 \bgroup\noexpand\macroargctxt
Chris@42 7699 \noexpand\csname\the\macname xx\endcsname}%
Chris@42 7700 \expandafter\xdef\csname\the\macname xx\endcsname##1{%
Chris@42 7701 \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
Chris@42 7702 \expandafter\expandafter
Chris@42 7703 \expandafter\xdef
Chris@42 7704 \expandafter\expandafter
Chris@42 7705 \csname\the\macname xxx\endcsname
Chris@42 7706 \paramlist{\egroup\noexpand\scanmacro{\temp}}%
Chris@42 7707 \else % 10 or more
Chris@42 7708 \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42 7709 \noexpand\getargvals@{\the\macname}{\argl}%
Chris@42 7710 }%
Chris@42 7711 \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp
Chris@42 7712 \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
Chris@42 7713 \fi
Chris@42 7714 \fi
Chris@42 7715 \else
Chris@42 7716 \ifcase\paramno
Chris@42 7717 % 0
Chris@42 7718 \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42 7719 \noexpand\norecurse{\the\macname}%
Chris@42 7720 \noexpand\scanmacro{\temp}\egroup}%
Chris@42 7721 \or % 1
Chris@42 7722 \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42 7723 \bgroup\noexpand\macroargctxt
Chris@42 7724 \noexpand\braceorline
Chris@42 7725 \expandafter\noexpand\csname\the\macname xxx\endcsname}%
Chris@42 7726 \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
Chris@42 7727 \egroup
Chris@42 7728 \noexpand\norecurse{\the\macname}%
Chris@42 7729 \noexpand\scanmacro{\temp}\egroup}%
Chris@42 7730 \else % at most 9
Chris@42 7731 \ifnum\paramno<10\relax
Chris@42 7732 \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42 7733 \bgroup\noexpand\macroargctxt
Chris@42 7734 \expandafter\noexpand\csname\the\macname xx\endcsname}%
Chris@42 7735 \expandafter\xdef\csname\the\macname xx\endcsname##1{%
Chris@42 7736 \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
Chris@42 7737 \expandafter\expandafter
Chris@42 7738 \expandafter\xdef
Chris@42 7739 \expandafter\expandafter
Chris@42 7740 \csname\the\macname xxx\endcsname
Chris@42 7741 \paramlist{%
Chris@42 7742 \egroup
Chris@42 7743 \noexpand\norecurse{\the\macname}%
Chris@42 7744 \noexpand\scanmacro{\temp}\egroup}%
Chris@42 7745 \else % 10 or more:
Chris@42 7746 \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42 7747 \noexpand\getargvals@{\the\macname}{\argl}%
Chris@42 7748 }%
Chris@42 7749 \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp
Chris@42 7750 \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse
Chris@42 7751 \fi
Chris@42 7752 \fi
Chris@42 7753 \fi}
Chris@42 7754
Chris@42 7755 \catcode `\@\texiatcatcode\relax
Chris@42 7756
Chris@42 7757 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
Chris@42 7758
Chris@42 7759 % \braceorline decides whether the next nonwhitespace character is a
Chris@42 7760 % {. If so it reads up to the closing }, if not, it reads the whole
Chris@42 7761 % line. Whatever was read is then fed to the next control sequence
Chris@42 7762 % as an argument (by \parsebrace or \parsearg).
Chris@42 7763 %
Chris@42 7764 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
Chris@42 7765 \def\braceorlinexxx{%
Chris@42 7766 \ifx\nchar\bgroup\else
Chris@42 7767 \expandafter\parsearg
Chris@42 7768 \fi \macnamexxx}
Chris@42 7769
Chris@42 7770
Chris@42 7771 % @alias.
Chris@42 7772 % We need some trickery to remove the optional spaces around the equal
Chris@42 7773 % sign. Make them active and then expand them all to nothing.
Chris@42 7774 %
Chris@42 7775 \def\alias{\parseargusing\obeyspaces\aliasxxx}
Chris@42 7776 \def\aliasxxx #1{\aliasyyy#1\relax}
Chris@42 7777 \def\aliasyyy #1=#2\relax{%
Chris@42 7778 {%
Chris@42 7779 \expandafter\let\obeyedspace=\empty
Chris@42 7780 \addtomacrolist{#1}%
Chris@42 7781 \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
Chris@42 7782 }%
Chris@42 7783 \next
Chris@42 7784 }
Chris@42 7785
Chris@42 7786
Chris@42 7787 \message{cross references,}
Chris@42 7788
Chris@42 7789 \newwrite\auxfile
Chris@42 7790 \newif\ifhavexrefs % True if xref values are known.
Chris@42 7791 \newif\ifwarnedxrefs % True if we warned once that they aren't known.
Chris@42 7792
Chris@42 7793 % @inforef is relatively simple.
Chris@42 7794 \def\inforef #1{\inforefzzz #1,,,,**}
Chris@42 7795 \def\inforefzzz #1,#2,#3,#4**{%
Chris@42 7796 \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
Chris@42 7797 node \samp{\ignorespaces#1{}}}
Chris@42 7798
Chris@42 7799 % @node's only job in TeX is to define \lastnode, which is used in
Chris@42 7800 % cross-references. The @node line might or might not have commas, and
Chris@42 7801 % might or might not have spaces before the first comma, like:
Chris@42 7802 % @node foo , bar , ...
Chris@42 7803 % We don't want such trailing spaces in the node name.
Chris@42 7804 %
Chris@42 7805 \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
Chris@42 7806 %
Chris@42 7807 % also remove a trailing comma, in case of something like this:
Chris@42 7808 % @node Help-Cross, , , Cross-refs
Chris@42 7809 \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
Chris@42 7810 \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
Chris@42 7811
Chris@42 7812 \let\nwnode=\node
Chris@42 7813 \let\lastnode=\empty
Chris@42 7814
Chris@42 7815 % Write a cross-reference definition for the current node. #1 is the
Chris@42 7816 % type (Ynumbered, Yappendix, Ynothing).
Chris@42 7817 %
Chris@42 7818 \def\donoderef#1{%
Chris@42 7819 \ifx\lastnode\empty\else
Chris@42 7820 \setref{\lastnode}{#1}%
Chris@42 7821 \global\let\lastnode=\empty
Chris@42 7822 \fi
Chris@42 7823 }
Chris@42 7824
Chris@42 7825 % @anchor{NAME} -- define xref target at arbitrary point.
Chris@42 7826 %
Chris@42 7827 \newcount\savesfregister
Chris@42 7828 %
Chris@42 7829 \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
Chris@42 7830 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
Chris@42 7831 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
Chris@42 7832
Chris@42 7833 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
Chris@42 7834 % anchor), which consists of three parts:
Chris@42 7835 % 1) NAME-title - the current sectioning name taken from \lastsection,
Chris@42 7836 % or the anchor name.
Chris@42 7837 % 2) NAME-snt - section number and type, passed as the SNT arg, or
Chris@42 7838 % empty for anchors.
Chris@42 7839 % 3) NAME-pg - the page number.
Chris@42 7840 %
Chris@42 7841 % This is called from \donoderef, \anchor, and \dofloat. In the case of
Chris@42 7842 % floats, there is an additional part, which is not written here:
Chris@42 7843 % 4) NAME-lof - the text as it should appear in a @listoffloats.
Chris@42 7844 %
Chris@42 7845 \def\setref#1#2{%
Chris@42 7846 \pdfmkdest{#1}%
Chris@42 7847 \iflinks
Chris@42 7848 {%
Chris@42 7849 \atdummies % preserve commands, but don't expand them
Chris@42 7850 \edef\writexrdef##1##2{%
Chris@42 7851 \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
Chris@42 7852 ##1}{##2}}% these are parameters of \writexrdef
Chris@42 7853 }%
Chris@42 7854 \toks0 = \expandafter{\lastsection}%
Chris@42 7855 \immediate \writexrdef{title}{\the\toks0 }%
Chris@42 7856 \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
Chris@42 7857 \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
Chris@42 7858 }%
Chris@42 7859 \fi
Chris@42 7860 }
Chris@42 7861
Chris@42 7862 % @xrefautosectiontitle on|off says whether @section(ing) names are used
Chris@42 7863 % automatically in xrefs, if the third arg is not explicitly specified.
Chris@42 7864 % This was provided as a "secret" @set xref-automatic-section-title
Chris@42 7865 % variable, now it's official.
Chris@42 7866 %
Chris@42 7867 \parseargdef\xrefautomaticsectiontitle{%
Chris@42 7868 \def\temp{#1}%
Chris@42 7869 \ifx\temp\onword
Chris@42 7870 \expandafter\let\csname SETxref-automatic-section-title\endcsname
Chris@42 7871 = \empty
Chris@42 7872 \else\ifx\temp\offword
Chris@42 7873 \expandafter\let\csname SETxref-automatic-section-title\endcsname
Chris@42 7874 = \relax
Chris@42 7875 \else
Chris@42 7876 \errhelp = \EMsimple
Chris@42 7877 \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
Chris@42 7878 must be on|off}%
Chris@42 7879 \fi\fi
Chris@42 7880 }
Chris@42 7881
Chris@42 7882 %
Chris@42 7883 % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
Chris@42 7884 % the node name, #2 the name of the Info cross-reference, #3 the printed
Chris@42 7885 % node name, #4 the name of the Info file, #5 the name of the printed
Chris@42 7886 % manual. All but the node name can be omitted.
Chris@42 7887 %
Chris@42 7888 \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
Chris@42 7889 \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
Chris@42 7890 \def\ref#1{\xrefX[#1,,,,,,,]}
Chris@42 7891 %
Chris@42 7892 \newbox\toprefbox
Chris@42 7893 \newbox\printedrefnamebox
Chris@42 7894 \newbox\infofilenamebox
Chris@42 7895 \newbox\printedmanualbox
Chris@42 7896 %
Chris@42 7897 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
Chris@42 7898 \unsepspaces
Chris@42 7899 %
Chris@42 7900 % Get args without leading/trailing spaces.
Chris@42 7901 \def\printedrefname{\ignorespaces #3}%
Chris@42 7902 \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
Chris@42 7903 %
Chris@42 7904 \def\infofilename{\ignorespaces #4}%
Chris@42 7905 \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
Chris@42 7906 %
Chris@42 7907 \def\printedmanual{\ignorespaces #5}%
Chris@42 7908 \setbox\printedmanualbox = \hbox{\printedmanual\unskip}%
Chris@42 7909 %
Chris@42 7910 % If the printed reference name (arg #3) was not explicitly given in
Chris@42 7911 % the @xref, figure out what we want to use.
Chris@42 7912 \ifdim \wd\printedrefnamebox = 0pt
Chris@42 7913 % No printed node name was explicitly given.
Chris@42 7914 \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
Chris@42 7915 % Not auto section-title: use node name inside the square brackets.
Chris@42 7916 \def\printedrefname{\ignorespaces #1}%
Chris@42 7917 \else
Chris@42 7918 % Auto section-title: use chapter/section title inside
Chris@42 7919 % the square brackets if we have it.
Chris@42 7920 \ifdim \wd\printedmanualbox > 0pt
Chris@42 7921 % It is in another manual, so we don't have it; use node name.
Chris@42 7922 \def\printedrefname{\ignorespaces #1}%
Chris@42 7923 \else
Chris@42 7924 \ifhavexrefs
Chris@42 7925 % We (should) know the real title if we have the xref values.
Chris@42 7926 \def\printedrefname{\refx{#1-title}{}}%
Chris@42 7927 \else
Chris@42 7928 % Otherwise just copy the Info node name.
Chris@42 7929 \def\printedrefname{\ignorespaces #1}%
Chris@42 7930 \fi%
Chris@42 7931 \fi
Chris@42 7932 \fi
Chris@42 7933 \fi
Chris@42 7934 %
Chris@42 7935 % Make link in pdf output.
Chris@42 7936 \ifpdf
Chris@42 7937 {\indexnofonts
Chris@42 7938 \turnoffactive
Chris@42 7939 \makevalueexpandable
Chris@42 7940 % This expands tokens, so do it after making catcode changes, so _
Chris@42 7941 % etc. don't get their TeX definitions. This ignores all spaces in
Chris@42 7942 % #4, including (wrongly) those in the middle of the filename.
Chris@42 7943 \getfilename{#4}%
Chris@42 7944 %
Chris@42 7945 % This (wrongly) does not take account of leading or trailing
Chris@42 7946 % spaces in #1, which should be ignored.
Chris@42 7947 \edef\pdfxrefdest{#1}%
Chris@42 7948 \ifx\pdfxrefdest\empty
Chris@42 7949 \def\pdfxrefdest{Top}% no empty targets
Chris@42 7950 \else
Chris@42 7951 \txiescapepdf\pdfxrefdest % escape PDF special chars
Chris@42 7952 \fi
Chris@42 7953 %
Chris@42 7954 \leavevmode
Chris@42 7955 \startlink attr{/Border [0 0 0]}%
Chris@42 7956 \ifnum\filenamelength>0
Chris@42 7957 goto file{\the\filename.pdf} name{\pdfxrefdest}%
Chris@42 7958 \else
Chris@42 7959 goto name{\pdfmkpgn{\pdfxrefdest}}%
Chris@42 7960 \fi
Chris@42 7961 }%
Chris@42 7962 \setcolor{\linkcolor}%
Chris@42 7963 \fi
Chris@42 7964 %
Chris@42 7965 % Float references are printed completely differently: "Figure 1.2"
Chris@42 7966 % instead of "[somenode], p.3". We distinguish them by the
Chris@42 7967 % LABEL-title being set to a magic string.
Chris@42 7968 {%
Chris@42 7969 % Have to otherify everything special to allow the \csname to
Chris@42 7970 % include an _ in the xref name, etc.
Chris@42 7971 \indexnofonts
Chris@42 7972 \turnoffactive
Chris@42 7973 \expandafter\global\expandafter\let\expandafter\Xthisreftitle
Chris@42 7974 \csname XR#1-title\endcsname
Chris@42 7975 }%
Chris@42 7976 \iffloat\Xthisreftitle
Chris@42 7977 % If the user specified the print name (third arg) to the ref,
Chris@42 7978 % print it instead of our usual "Figure 1.2".
Chris@42 7979 \ifdim\wd\printedrefnamebox = 0pt
Chris@42 7980 \refx{#1-snt}{}%
Chris@42 7981 \else
Chris@42 7982 \printedrefname
Chris@42 7983 \fi
Chris@42 7984 %
Chris@42 7985 % If the user also gave the printed manual name (fifth arg), append
Chris@42 7986 % "in MANUALNAME".
Chris@42 7987 \ifdim \wd\printedmanualbox > 0pt
Chris@42 7988 \space \putwordin{} \cite{\printedmanual}%
Chris@42 7989 \fi
Chris@42 7990 \else
Chris@42 7991 % node/anchor (non-float) references.
Chris@42 7992 %
Chris@42 7993 % If we use \unhbox to print the node names, TeX does not insert
Chris@42 7994 % empty discretionaries after hyphens, which means that it will not
Chris@42 7995 % find a line break at a hyphen in a node names. Since some manuals
Chris@42 7996 % are best written with fairly long node names, containing hyphens,
Chris@42 7997 % this is a loss. Therefore, we give the text of the node name
Chris@42 7998 % again, so it is as if TeX is seeing it for the first time.
Chris@42 7999 %
Chris@42 8000 \ifdim \wd\printedmanualbox > 0pt
Chris@42 8001 % Cross-manual reference with a printed manual name.
Chris@42 8002 %
Chris@42 8003 \crossmanualxref{\cite{\printedmanual\unskip}}%
Chris@42 8004 %
Chris@42 8005 \else\ifdim \wd\infofilenamebox > 0pt
Chris@42 8006 % Cross-manual reference with only an info filename (arg 4), no
Chris@42 8007 % printed manual name (arg 5). This is essentially the same as
Chris@42 8008 % the case above; we output the filename, since we have nothing else.
Chris@42 8009 %
Chris@42 8010 \crossmanualxref{\code{\infofilename\unskip}}%
Chris@42 8011 %
Chris@42 8012 \else
Chris@42 8013 % Reference within this manual.
Chris@42 8014 %
Chris@42 8015 % _ (for example) has to be the character _ for the purposes of the
Chris@42 8016 % control sequence corresponding to the node, but it has to expand
Chris@42 8017 % into the usual \leavevmode...\vrule stuff for purposes of
Chris@42 8018 % printing. So we \turnoffactive for the \refx-snt, back on for the
Chris@42 8019 % printing, back off for the \refx-pg.
Chris@42 8020 {\turnoffactive
Chris@42 8021 % Only output a following space if the -snt ref is nonempty; for
Chris@42 8022 % @unnumbered and @anchor, it won't be.
Chris@42 8023 \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
Chris@42 8024 \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
Chris@42 8025 }%
Chris@42 8026 % output the `[mynode]' via the macro below so it can be overridden.
Chris@42 8027 \xrefprintnodename\printedrefname
Chris@42 8028 %
Chris@42 8029 % But we always want a comma and a space:
Chris@42 8030 ,\space
Chris@42 8031 %
Chris@42 8032 % output the `page 3'.
Chris@42 8033 \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
Chris@42 8034 \fi\fi
Chris@42 8035 \fi
Chris@42 8036 \endlink
Chris@42 8037 \endgroup}
Chris@42 8038
Chris@42 8039 % Output a cross-manual xref to #1. Used just above (twice).
Chris@42 8040 %
Chris@42 8041 % Only include the text "Section ``foo'' in" if the foo is neither
Chris@42 8042 % missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply
Chris@42 8043 % "see The Foo Manual", the idea being to refer to the whole manual.
Chris@42 8044 %
Chris@42 8045 % But, this being TeX, we can't easily compare our node name against the
Chris@42 8046 % string "Top" while ignoring the possible spaces before and after in
Chris@42 8047 % the input. By adding the arbitrary 7sp below, we make it much less
Chris@42 8048 % likely that a real node name would have the same width as "Top" (e.g.,
Chris@42 8049 % in a monospaced font). Hopefully it will never happen in practice.
Chris@42 8050 %
Chris@42 8051 % For the same basic reason, we retypeset the "Top" at every
Chris@42 8052 % reference, since the current font is indeterminate.
Chris@42 8053 %
Chris@42 8054 \def\crossmanualxref#1{%
Chris@42 8055 \setbox\toprefbox = \hbox{Top\kern7sp}%
Chris@42 8056 \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
Chris@42 8057 \ifdim \wd2 > 7sp % nonempty?
Chris@42 8058 \ifdim \wd2 = \wd\toprefbox \else % same as Top?
Chris@42 8059 \putwordSection{} ``\printedrefname'' \putwordin{}\space
Chris@42 8060 \fi
Chris@42 8061 \fi
Chris@42 8062 #1%
Chris@42 8063 }
Chris@42 8064
Chris@42 8065 % This macro is called from \xrefX for the `[nodename]' part of xref
Chris@42 8066 % output. It's a separate macro only so it can be changed more easily,
Chris@42 8067 % since square brackets don't work well in some documents. Particularly
Chris@42 8068 % one that Bob is working on :).
Chris@42 8069 %
Chris@42 8070 \def\xrefprintnodename#1{[#1]}
Chris@42 8071
Chris@42 8072 % Things referred to by \setref.
Chris@42 8073 %
Chris@42 8074 \def\Ynothing{}
Chris@42 8075 \def\Yomitfromtoc{}
Chris@42 8076 \def\Ynumbered{%
Chris@42 8077 \ifnum\secno=0
Chris@42 8078 \putwordChapter@tie \the\chapno
Chris@42 8079 \else \ifnum\subsecno=0
Chris@42 8080 \putwordSection@tie \the\chapno.\the\secno
Chris@42 8081 \else \ifnum\subsubsecno=0
Chris@42 8082 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
Chris@42 8083 \else
Chris@42 8084 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
Chris@42 8085 \fi\fi\fi
Chris@42 8086 }
Chris@42 8087 \def\Yappendix{%
Chris@42 8088 \ifnum\secno=0
Chris@42 8089 \putwordAppendix@tie @char\the\appendixno{}%
Chris@42 8090 \else \ifnum\subsecno=0
Chris@42 8091 \putwordSection@tie @char\the\appendixno.\the\secno
Chris@42 8092 \else \ifnum\subsubsecno=0
Chris@42 8093 \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
Chris@42 8094 \else
Chris@42 8095 \putwordSection@tie
Chris@42 8096 @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
Chris@42 8097 \fi\fi\fi
Chris@42 8098 }
Chris@42 8099
Chris@42 8100 % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
Chris@42 8101 % If its value is nonempty, SUFFIX is output afterward.
Chris@42 8102 %
Chris@42 8103 \def\refx#1#2{%
Chris@42 8104 {%
Chris@42 8105 \indexnofonts
Chris@42 8106 \otherbackslash
Chris@42 8107 \expandafter\global\expandafter\let\expandafter\thisrefX
Chris@42 8108 \csname XR#1\endcsname
Chris@42 8109 }%
Chris@42 8110 \ifx\thisrefX\relax
Chris@42 8111 % If not defined, say something at least.
Chris@42 8112 \angleleft un\-de\-fined\angleright
Chris@42 8113 \iflinks
Chris@42 8114 \ifhavexrefs
Chris@42 8115 {\toks0 = {#1}% avoid expansion of possibly-complex value
Chris@42 8116 \message{\linenumber Undefined cross reference `\the\toks0'.}}%
Chris@42 8117 \else
Chris@42 8118 \ifwarnedxrefs\else
Chris@42 8119 \global\warnedxrefstrue
Chris@42 8120 \message{Cross reference values unknown; you must run TeX again.}%
Chris@42 8121 \fi
Chris@42 8122 \fi
Chris@42 8123 \fi
Chris@42 8124 \else
Chris@42 8125 % It's defined, so just use it.
Chris@42 8126 \thisrefX
Chris@42 8127 \fi
Chris@42 8128 #2% Output the suffix in any case.
Chris@42 8129 }
Chris@42 8130
Chris@42 8131 % This is the macro invoked by entries in the aux file. Usually it's
Chris@42 8132 % just a \def (we prepend XR to the control sequence name to avoid
Chris@42 8133 % collisions). But if this is a float type, we have more work to do.
Chris@42 8134 %
Chris@42 8135 \def\xrdef#1#2{%
Chris@42 8136 {% The node name might contain 8-bit characters, which in our current
Chris@42 8137 % implementation are changed to commands like @'e. Don't let these
Chris@42 8138 % mess up the control sequence name.
Chris@42 8139 \indexnofonts
Chris@42 8140 \turnoffactive
Chris@42 8141 \xdef\safexrefname{#1}%
Chris@42 8142 }%
Chris@42 8143 %
Chris@42 8144 \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref
Chris@42 8145 %
Chris@42 8146 % Was that xref control sequence that we just defined for a float?
Chris@42 8147 \expandafter\iffloat\csname XR\safexrefname\endcsname
Chris@42 8148 % it was a float, and we have the (safe) float type in \iffloattype.
Chris@42 8149 \expandafter\let\expandafter\floatlist
Chris@42 8150 \csname floatlist\iffloattype\endcsname
Chris@42 8151 %
Chris@42 8152 % Is this the first time we've seen this float type?
Chris@42 8153 \expandafter\ifx\floatlist\relax
Chris@42 8154 \toks0 = {\do}% yes, so just \do
Chris@42 8155 \else
Chris@42 8156 % had it before, so preserve previous elements in list.
Chris@42 8157 \toks0 = \expandafter{\floatlist\do}%
Chris@42 8158 \fi
Chris@42 8159 %
Chris@42 8160 % Remember this xref in the control sequence \floatlistFLOATTYPE,
Chris@42 8161 % for later use in \listoffloats.
Chris@42 8162 \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
Chris@42 8163 {\safexrefname}}%
Chris@42 8164 \fi
Chris@42 8165 }
Chris@42 8166
Chris@42 8167 % Read the last existing aux file, if any. No error if none exists.
Chris@42 8168 %
Chris@42 8169 \def\tryauxfile{%
Chris@42 8170 \openin 1 \jobname.aux
Chris@42 8171 \ifeof 1 \else
Chris@42 8172 \readdatafile{aux}%
Chris@42 8173 \global\havexrefstrue
Chris@42 8174 \fi
Chris@42 8175 \closein 1
Chris@42 8176 }
Chris@42 8177
Chris@42 8178 \def\setupdatafile{%
Chris@42 8179 \catcode`\^^@=\other
Chris@42 8180 \catcode`\^^A=\other
Chris@42 8181 \catcode`\^^B=\other
Chris@42 8182 \catcode`\^^C=\other
Chris@42 8183 \catcode`\^^D=\other
Chris@42 8184 \catcode`\^^E=\other
Chris@42 8185 \catcode`\^^F=\other
Chris@42 8186 \catcode`\^^G=\other
Chris@42 8187 \catcode`\^^H=\other
Chris@42 8188 \catcode`\^^K=\other
Chris@42 8189 \catcode`\^^L=\other
Chris@42 8190 \catcode`\^^N=\other
Chris@42 8191 \catcode`\^^P=\other
Chris@42 8192 \catcode`\^^Q=\other
Chris@42 8193 \catcode`\^^R=\other
Chris@42 8194 \catcode`\^^S=\other
Chris@42 8195 \catcode`\^^T=\other
Chris@42 8196 \catcode`\^^U=\other
Chris@42 8197 \catcode`\^^V=\other
Chris@42 8198 \catcode`\^^W=\other
Chris@42 8199 \catcode`\^^X=\other
Chris@42 8200 \catcode`\^^Z=\other
Chris@42 8201 \catcode`\^^[=\other
Chris@42 8202 \catcode`\^^\=\other
Chris@42 8203 \catcode`\^^]=\other
Chris@42 8204 \catcode`\^^^=\other
Chris@42 8205 \catcode`\^^_=\other
Chris@42 8206 % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
Chris@42 8207 % in xref tags, i.e., node names. But since ^^e4 notation isn't
Chris@42 8208 % supported in the main text, it doesn't seem desirable. Furthermore,
Chris@42 8209 % that is not enough: for node names that actually contain a ^
Chris@42 8210 % character, we would end up writing a line like this: 'xrdef {'hat
Chris@42 8211 % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
Chris@42 8212 % argument, and \hat is not an expandable control sequence. It could
Chris@42 8213 % all be worked out, but why? Either we support ^^ or we don't.
Chris@42 8214 %
Chris@42 8215 % The other change necessary for this was to define \auxhat:
Chris@42 8216 % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
Chris@42 8217 % and then to call \auxhat in \setq.
Chris@42 8218 %
Chris@42 8219 \catcode`\^=\other
Chris@42 8220 %
Chris@42 8221 % Special characters. Should be turned off anyway, but...
Chris@42 8222 \catcode`\~=\other
Chris@42 8223 \catcode`\[=\other
Chris@42 8224 \catcode`\]=\other
Chris@42 8225 \catcode`\"=\other
Chris@42 8226 \catcode`\_=\other
Chris@42 8227 \catcode`\|=\other
Chris@42 8228 \catcode`\<=\other
Chris@42 8229 \catcode`\>=\other
Chris@42 8230 \catcode`\$=\other
Chris@42 8231 \catcode`\#=\other
Chris@42 8232 \catcode`\&=\other
Chris@42 8233 \catcode`\%=\other
Chris@42 8234 \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
Chris@42 8235 %
Chris@42 8236 % This is to support \ in node names and titles, since the \
Chris@42 8237 % characters end up in a \csname. It's easier than
Chris@42 8238 % leaving it active and making its active definition an actual \
Chris@42 8239 % character. What I don't understand is why it works in the *value*
Chris@42 8240 % of the xrdef. Seems like it should be a catcode12 \, and that
Chris@42 8241 % should not typeset properly. But it works, so I'm moving on for
Chris@42 8242 % now. --karl, 15jan04.
Chris@42 8243 \catcode`\\=\other
Chris@42 8244 %
Chris@42 8245 % Make the characters 128-255 be printing characters.
Chris@42 8246 {%
Chris@42 8247 \count1=128
Chris@42 8248 \def\loop{%
Chris@42 8249 \catcode\count1=\other
Chris@42 8250 \advance\count1 by 1
Chris@42 8251 \ifnum \count1<256 \loop \fi
Chris@42 8252 }%
Chris@42 8253 }%
Chris@42 8254 %
Chris@42 8255 % @ is our escape character in .aux files, and we need braces.
Chris@42 8256 \catcode`\{=1
Chris@42 8257 \catcode`\}=2
Chris@42 8258 \catcode`\@=0
Chris@42 8259 }
Chris@42 8260
Chris@42 8261 \def\readdatafile#1{%
Chris@42 8262 \begingroup
Chris@42 8263 \setupdatafile
Chris@42 8264 \input\jobname.#1
Chris@42 8265 \endgroup}
Chris@42 8266
Chris@42 8267
Chris@42 8268 \message{insertions,}
Chris@42 8269 % including footnotes.
Chris@42 8270
Chris@42 8271 \newcount \footnoteno
Chris@42 8272
Chris@42 8273 % The trailing space in the following definition for supereject is
Chris@42 8274 % vital for proper filling; pages come out unaligned when you do a
Chris@42 8275 % pagealignmacro call if that space before the closing brace is
Chris@42 8276 % removed. (Generally, numeric constants should always be followed by a
Chris@42 8277 % space to prevent strange expansion errors.)
Chris@42 8278 \def\supereject{\par\penalty -20000\footnoteno =0 }
Chris@42 8279
Chris@42 8280 % @footnotestyle is meaningful for Info output only.
Chris@42 8281 \let\footnotestyle=\comment
Chris@42 8282
Chris@42 8283 {\catcode `\@=11
Chris@42 8284 %
Chris@42 8285 % Auto-number footnotes. Otherwise like plain.
Chris@42 8286 \gdef\footnote{%
Chris@42 8287 \let\indent=\ptexindent
Chris@42 8288 \let\noindent=\ptexnoindent
Chris@42 8289 \global\advance\footnoteno by \@ne
Chris@42 8290 \edef\thisfootno{$^{\the\footnoteno}$}%
Chris@42 8291 %
Chris@42 8292 % In case the footnote comes at the end of a sentence, preserve the
Chris@42 8293 % extra spacing after we do the footnote number.
Chris@42 8294 \let\@sf\empty
Chris@42 8295 \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
Chris@42 8296 %
Chris@42 8297 % Remove inadvertent blank space before typesetting the footnote number.
Chris@42 8298 \unskip
Chris@42 8299 \thisfootno\@sf
Chris@42 8300 \dofootnote
Chris@42 8301 }%
Chris@42 8302
Chris@42 8303 % Don't bother with the trickery in plain.tex to not require the
Chris@42 8304 % footnote text as a parameter. Our footnotes don't need to be so general.
Chris@42 8305 %
Chris@42 8306 % Oh yes, they do; otherwise, @ifset (and anything else that uses
Chris@42 8307 % \parseargline) fails inside footnotes because the tokens are fixed when
Chris@42 8308 % the footnote is read. --karl, 16nov96.
Chris@42 8309 %
Chris@42 8310 \gdef\dofootnote{%
Chris@42 8311 \insert\footins\bgroup
Chris@42 8312 % We want to typeset this text as a normal paragraph, even if the
Chris@42 8313 % footnote reference occurs in (for example) a display environment.
Chris@42 8314 % So reset some parameters.
Chris@42 8315 \hsize=\pagewidth
Chris@42 8316 \interlinepenalty\interfootnotelinepenalty
Chris@42 8317 \splittopskip\ht\strutbox % top baseline for broken footnotes
Chris@42 8318 \splitmaxdepth\dp\strutbox
Chris@42 8319 \floatingpenalty\@MM
Chris@42 8320 \leftskip\z@skip
Chris@42 8321 \rightskip\z@skip
Chris@42 8322 \spaceskip\z@skip
Chris@42 8323 \xspaceskip\z@skip
Chris@42 8324 \parindent\defaultparindent
Chris@42 8325 %
Chris@42 8326 \smallfonts \rm
Chris@42 8327 %
Chris@42 8328 % Because we use hanging indentation in footnotes, a @noindent appears
Chris@42 8329 % to exdent this text, so make it be a no-op. makeinfo does not use
Chris@42 8330 % hanging indentation so @noindent can still be needed within footnote
Chris@42 8331 % text after an @example or the like (not that this is good style).
Chris@42 8332 \let\noindent = \relax
Chris@42 8333 %
Chris@42 8334 % Hang the footnote text off the number. Use \everypar in case the
Chris@42 8335 % footnote extends for more than one paragraph.
Chris@42 8336 \everypar = {\hang}%
Chris@42 8337 \textindent{\thisfootno}%
Chris@42 8338 %
Chris@42 8339 % Don't crash into the line above the footnote text. Since this
Chris@42 8340 % expands into a box, it must come within the paragraph, lest it
Chris@42 8341 % provide a place where TeX can split the footnote.
Chris@42 8342 \footstrut
Chris@42 8343 %
Chris@42 8344 % Invoke rest of plain TeX footnote routine.
Chris@42 8345 \futurelet\next\fo@t
Chris@42 8346 }
Chris@42 8347 }%end \catcode `\@=11
Chris@42 8348
Chris@42 8349 % In case a @footnote appears in a vbox, save the footnote text and create
Chris@42 8350 % the real \insert just after the vbox finished. Otherwise, the insertion
Chris@42 8351 % would be lost.
Chris@42 8352 % Similarly, if a @footnote appears inside an alignment, save the footnote
Chris@42 8353 % text to a box and make the \insert when a row of the table is finished.
Chris@42 8354 % And the same can be done for other insert classes. --kasal, 16nov03.
Chris@42 8355
Chris@42 8356 % Replace the \insert primitive by a cheating macro.
Chris@42 8357 % Deeper inside, just make sure that the saved insertions are not spilled
Chris@42 8358 % out prematurely.
Chris@42 8359 %
Chris@42 8360 \def\startsavinginserts{%
Chris@42 8361 \ifx \insert\ptexinsert
Chris@42 8362 \let\insert\saveinsert
Chris@42 8363 \else
Chris@42 8364 \let\checkinserts\relax
Chris@42 8365 \fi
Chris@42 8366 }
Chris@42 8367
Chris@42 8368 % This \insert replacement works for both \insert\footins{foo} and
Chris@42 8369 % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
Chris@42 8370 %
Chris@42 8371 \def\saveinsert#1{%
Chris@42 8372 \edef\next{\noexpand\savetobox \makeSAVEname#1}%
Chris@42 8373 \afterassignment\next
Chris@42 8374 % swallow the left brace
Chris@42 8375 \let\temp =
Chris@42 8376 }
Chris@42 8377 \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
Chris@42 8378 \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
Chris@42 8379
Chris@42 8380 \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
Chris@42 8381
Chris@42 8382 \def\placesaveins#1{%
Chris@42 8383 \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
Chris@42 8384 {\box#1}%
Chris@42 8385 }
Chris@42 8386
Chris@42 8387 % eat @SAVE -- beware, all of them have catcode \other:
Chris@42 8388 {
Chris@42 8389 \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-)
Chris@42 8390 \gdef\gobblesave @SAVE{}
Chris@42 8391 }
Chris@42 8392
Chris@42 8393 % initialization:
Chris@42 8394 \def\newsaveins #1{%
Chris@42 8395 \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
Chris@42 8396 \next
Chris@42 8397 }
Chris@42 8398 \def\newsaveinsX #1{%
Chris@42 8399 \csname newbox\endcsname #1%
Chris@42 8400 \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
Chris@42 8401 \checksaveins #1}%
Chris@42 8402 }
Chris@42 8403
Chris@42 8404 % initialize:
Chris@42 8405 \let\checkinserts\empty
Chris@42 8406 \newsaveins\footins
Chris@42 8407 \newsaveins\margin
Chris@42 8408
Chris@42 8409
Chris@42 8410 % @image. We use the macros from epsf.tex to support this.
Chris@42 8411 % If epsf.tex is not installed and @image is used, we complain.
Chris@42 8412 %
Chris@42 8413 % Check for and read epsf.tex up front. If we read it only at @image
Chris@42 8414 % time, we might be inside a group, and then its definitions would get
Chris@42 8415 % undone and the next image would fail.
Chris@42 8416 \openin 1 = epsf.tex
Chris@42 8417 \ifeof 1 \else
Chris@42 8418 % Do not bother showing banner with epsf.tex v2.7k (available in
Chris@42 8419 % doc/epsf.tex and on ctan).
Chris@42 8420 \def\epsfannounce{\toks0 = }%
Chris@42 8421 \input epsf.tex
Chris@42 8422 \fi
Chris@42 8423 \closein 1
Chris@42 8424 %
Chris@42 8425 % We will only complain once about lack of epsf.tex.
Chris@42 8426 \newif\ifwarnednoepsf
Chris@42 8427 \newhelp\noepsfhelp{epsf.tex must be installed for images to
Chris@42 8428 work. It is also included in the Texinfo distribution, or you can get
Chris@42 8429 it from ftp://tug.org/tex/epsf.tex.}
Chris@42 8430 %
Chris@42 8431 \def\image#1{%
Chris@42 8432 \ifx\epsfbox\thisisundefined
Chris@42 8433 \ifwarnednoepsf \else
Chris@42 8434 \errhelp = \noepsfhelp
Chris@42 8435 \errmessage{epsf.tex not found, images will be ignored}%
Chris@42 8436 \global\warnednoepsftrue
Chris@42 8437 \fi
Chris@42 8438 \else
Chris@42 8439 \imagexxx #1,,,,,\finish
Chris@42 8440 \fi
Chris@42 8441 }
Chris@42 8442 %
Chris@42 8443 % Arguments to @image:
Chris@42 8444 % #1 is (mandatory) image filename; we tack on .eps extension.
Chris@42 8445 % #2 is (optional) width, #3 is (optional) height.
Chris@42 8446 % #4 is (ignored optional) html alt text.
Chris@42 8447 % #5 is (ignored optional) extension.
Chris@42 8448 % #6 is just the usual extra ignored arg for parsing stuff.
Chris@42 8449 \newif\ifimagevmode
Chris@42 8450 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
Chris@42 8451 \catcode`\^^M = 5 % in case we're inside an example
Chris@42 8452 \normalturnoffactive % allow _ et al. in names
Chris@42 8453 % If the image is by itself, center it.
Chris@42 8454 \ifvmode
Chris@42 8455 \imagevmodetrue
Chris@42 8456 \else \ifx\centersub\centerV
Chris@42 8457 % for @center @image, we need a vbox so we can have our vertical space
Chris@42 8458 \imagevmodetrue
Chris@42 8459 \vbox\bgroup % vbox has better behavior than vtop herev
Chris@42 8460 \fi\fi
Chris@42 8461 %
Chris@42 8462 \ifimagevmode
Chris@42 8463 \nobreak\medskip
Chris@42 8464 % Usually we'll have text after the image which will insert
Chris@42 8465 % \parskip glue, so insert it here too to equalize the space
Chris@42 8466 % above and below.
Chris@42 8467 \nobreak\vskip\parskip
Chris@42 8468 \nobreak
Chris@42 8469 \fi
Chris@42 8470 %
Chris@42 8471 % Leave vertical mode so that indentation from an enclosing
Chris@42 8472 % environment such as @quotation is respected.
Chris@42 8473 % However, if we're at the top level, we don't want the
Chris@42 8474 % normal paragraph indentation.
Chris@42 8475 % On the other hand, if we are in the case of @center @image, we don't
Chris@42 8476 % want to start a paragraph, which will create a hsize-width box and
Chris@42 8477 % eradicate the centering.
Chris@42 8478 \ifx\centersub\centerV\else \noindent \fi
Chris@42 8479 %
Chris@42 8480 % Output the image.
Chris@42 8481 \ifpdf
Chris@42 8482 \dopdfimage{#1}{#2}{#3}%
Chris@42 8483 \else
Chris@42 8484 % \epsfbox itself resets \epsf?size at each figure.
Chris@42 8485 \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
Chris@42 8486 \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
Chris@42 8487 \epsfbox{#1.eps}%
Chris@42 8488 \fi
Chris@42 8489 %
Chris@42 8490 \ifimagevmode
Chris@42 8491 \medskip % space after a standalone image
Chris@42 8492 \fi
Chris@42 8493 \ifx\centersub\centerV \egroup \fi
Chris@42 8494 \endgroup}
Chris@42 8495
Chris@42 8496
Chris@42 8497 % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
Chris@42 8498 % etc. We don't actually implement floating yet, we always include the
Chris@42 8499 % float "here". But it seemed the best name for the future.
Chris@42 8500 %
Chris@42 8501 \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
Chris@42 8502
Chris@42 8503 % There may be a space before second and/or third parameter; delete it.
Chris@42 8504 \def\eatcommaspace#1, {#1,}
Chris@42 8505
Chris@42 8506 % #1 is the optional FLOATTYPE, the text label for this float, typically
Chris@42 8507 % "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
Chris@42 8508 % this float will not be numbered and cannot be referred to.
Chris@42 8509 %
Chris@42 8510 % #2 is the optional xref label. Also must be present for the float to
Chris@42 8511 % be referable.
Chris@42 8512 %
Chris@42 8513 % #3 is the optional positioning argument; for now, it is ignored. It
Chris@42 8514 % will somehow specify the positions allowed to float to (here, top, bottom).
Chris@42 8515 %
Chris@42 8516 % We keep a separate counter for each FLOATTYPE, which we reset at each
Chris@42 8517 % chapter-level command.
Chris@42 8518 \let\resetallfloatnos=\empty
Chris@42 8519 %
Chris@42 8520 \def\dofloat#1,#2,#3,#4\finish{%
Chris@42 8521 \let\thiscaption=\empty
Chris@42 8522 \let\thisshortcaption=\empty
Chris@42 8523 %
Chris@42 8524 % don't lose footnotes inside @float.
Chris@42 8525 %
Chris@42 8526 % BEWARE: when the floats start float, we have to issue warning whenever an
Chris@42 8527 % insert appears inside a float which could possibly float. --kasal, 26may04
Chris@42 8528 %
Chris@42 8529 \startsavinginserts
Chris@42 8530 %
Chris@42 8531 % We can't be used inside a paragraph.
Chris@42 8532 \par
Chris@42 8533 %
Chris@42 8534 \vtop\bgroup
Chris@42 8535 \def\floattype{#1}%
Chris@42 8536 \def\floatlabel{#2}%
Chris@42 8537 \def\floatloc{#3}% we do nothing with this yet.
Chris@42 8538 %
Chris@42 8539 \ifx\floattype\empty
Chris@42 8540 \let\safefloattype=\empty
Chris@42 8541 \else
Chris@42 8542 {%
Chris@42 8543 % the floattype might have accents or other special characters,
Chris@42 8544 % but we need to use it in a control sequence name.
Chris@42 8545 \indexnofonts
Chris@42 8546 \turnoffactive
Chris@42 8547 \xdef\safefloattype{\floattype}%
Chris@42 8548 }%
Chris@42 8549 \fi
Chris@42 8550 %
Chris@42 8551 % If label is given but no type, we handle that as the empty type.
Chris@42 8552 \ifx\floatlabel\empty \else
Chris@42 8553 % We want each FLOATTYPE to be numbered separately (Figure 1,
Chris@42 8554 % Table 1, Figure 2, ...). (And if no label, no number.)
Chris@42 8555 %
Chris@42 8556 \expandafter\getfloatno\csname\safefloattype floatno\endcsname
Chris@42 8557 \global\advance\floatno by 1
Chris@42 8558 %
Chris@42 8559 {%
Chris@42 8560 % This magic value for \lastsection is output by \setref as the
Chris@42 8561 % XREFLABEL-title value. \xrefX uses it to distinguish float
Chris@42 8562 % labels (which have a completely different output format) from
Chris@42 8563 % node and anchor labels. And \xrdef uses it to construct the
Chris@42 8564 % lists of floats.
Chris@42 8565 %
Chris@42 8566 \edef\lastsection{\floatmagic=\safefloattype}%
Chris@42 8567 \setref{\floatlabel}{Yfloat}%
Chris@42 8568 }%
Chris@42 8569 \fi
Chris@42 8570 %
Chris@42 8571 % start with \parskip glue, I guess.
Chris@42 8572 \vskip\parskip
Chris@42 8573 %
Chris@42 8574 % Don't suppress indentation if a float happens to start a section.
Chris@42 8575 \restorefirstparagraphindent
Chris@42 8576 }
Chris@42 8577
Chris@42 8578 % we have these possibilities:
Chris@42 8579 % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
Chris@42 8580 % @float Foo,lbl & no caption: Foo 1.1
Chris@42 8581 % @float Foo & @caption{Cap}: Foo: Cap
Chris@42 8582 % @float Foo & no caption: Foo
Chris@42 8583 % @float ,lbl & Caption{Cap}: 1.1: Cap
Chris@42 8584 % @float ,lbl & no caption: 1.1
Chris@42 8585 % @float & @caption{Cap}: Cap
Chris@42 8586 % @float & no caption:
Chris@42 8587 %
Chris@42 8588 \def\Efloat{%
Chris@42 8589 \let\floatident = \empty
Chris@42 8590 %
Chris@42 8591 % In all cases, if we have a float type, it comes first.
Chris@42 8592 \ifx\floattype\empty \else \def\floatident{\floattype}\fi
Chris@42 8593 %
Chris@42 8594 % If we have an xref label, the number comes next.
Chris@42 8595 \ifx\floatlabel\empty \else
Chris@42 8596 \ifx\floattype\empty \else % if also had float type, need tie first.
Chris@42 8597 \appendtomacro\floatident{\tie}%
Chris@42 8598 \fi
Chris@42 8599 % the number.
Chris@42 8600 \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
Chris@42 8601 \fi
Chris@42 8602 %
Chris@42 8603 % Start the printed caption with what we've constructed in
Chris@42 8604 % \floatident, but keep it separate; we need \floatident again.
Chris@42 8605 \let\captionline = \floatident
Chris@42 8606 %
Chris@42 8607 \ifx\thiscaption\empty \else
Chris@42 8608 \ifx\floatident\empty \else
Chris@42 8609 \appendtomacro\captionline{: }% had ident, so need a colon between
Chris@42 8610 \fi
Chris@42 8611 %
Chris@42 8612 % caption text.
Chris@42 8613 \appendtomacro\captionline{\scanexp\thiscaption}%
Chris@42 8614 \fi
Chris@42 8615 %
Chris@42 8616 % If we have anything to print, print it, with space before.
Chris@42 8617 % Eventually this needs to become an \insert.
Chris@42 8618 \ifx\captionline\empty \else
Chris@42 8619 \vskip.5\parskip
Chris@42 8620 \captionline
Chris@42 8621 %
Chris@42 8622 % Space below caption.
Chris@42 8623 \vskip\parskip
Chris@42 8624 \fi
Chris@42 8625 %
Chris@42 8626 % If have an xref label, write the list of floats info. Do this
Chris@42 8627 % after the caption, to avoid chance of it being a breakpoint.
Chris@42 8628 \ifx\floatlabel\empty \else
Chris@42 8629 % Write the text that goes in the lof to the aux file as
Chris@42 8630 % \floatlabel-lof. Besides \floatident, we include the short
Chris@42 8631 % caption if specified, else the full caption if specified, else nothing.
Chris@42 8632 {%
Chris@42 8633 \atdummies
Chris@42 8634 %
Chris@42 8635 % since we read the caption text in the macro world, where ^^M
Chris@42 8636 % is turned into a normal character, we have to scan it back, so
Chris@42 8637 % we don't write the literal three characters "^^M" into the aux file.
Chris@42 8638 \scanexp{%
Chris@42 8639 \xdef\noexpand\gtemp{%
Chris@42 8640 \ifx\thisshortcaption\empty
Chris@42 8641 \thiscaption
Chris@42 8642 \else
Chris@42 8643 \thisshortcaption
Chris@42 8644 \fi
Chris@42 8645 }%
Chris@42 8646 }%
Chris@42 8647 \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
Chris@42 8648 \ifx\gtemp\empty \else : \gtemp \fi}}%
Chris@42 8649 }%
Chris@42 8650 \fi
Chris@42 8651 \egroup % end of \vtop
Chris@42 8652 %
Chris@42 8653 % place the captured inserts
Chris@42 8654 %
Chris@42 8655 % BEWARE: when the floats start floating, we have to issue warning
Chris@42 8656 % whenever an insert appears inside a float which could possibly
Chris@42 8657 % float. --kasal, 26may04
Chris@42 8658 %
Chris@42 8659 \checkinserts
Chris@42 8660 }
Chris@42 8661
Chris@42 8662 % Append the tokens #2 to the definition of macro #1, not expanding either.
Chris@42 8663 %
Chris@42 8664 \def\appendtomacro#1#2{%
Chris@42 8665 \expandafter\def\expandafter#1\expandafter{#1#2}%
Chris@42 8666 }
Chris@42 8667
Chris@42 8668 % @caption, @shortcaption
Chris@42 8669 %
Chris@42 8670 \def\caption{\docaption\thiscaption}
Chris@42 8671 \def\shortcaption{\docaption\thisshortcaption}
Chris@42 8672 \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
Chris@42 8673 \def\defcaption#1#2{\egroup \def#1{#2}}
Chris@42 8674
Chris@42 8675 % The parameter is the control sequence identifying the counter we are
Chris@42 8676 % going to use. Create it if it doesn't exist and assign it to \floatno.
Chris@42 8677 \def\getfloatno#1{%
Chris@42 8678 \ifx#1\relax
Chris@42 8679 % Haven't seen this figure type before.
Chris@42 8680 \csname newcount\endcsname #1%
Chris@42 8681 %
Chris@42 8682 % Remember to reset this floatno at the next chap.
Chris@42 8683 \expandafter\gdef\expandafter\resetallfloatnos
Chris@42 8684 \expandafter{\resetallfloatnos #1=0 }%
Chris@42 8685 \fi
Chris@42 8686 \let\floatno#1%
Chris@42 8687 }
Chris@42 8688
Chris@42 8689 % \setref calls this to get the XREFLABEL-snt value. We want an @xref
Chris@42 8690 % to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
Chris@42 8691 % first read the @float command.
Chris@42 8692 %
Chris@42 8693 \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
Chris@42 8694
Chris@42 8695 % Magic string used for the XREFLABEL-title value, so \xrefX can
Chris@42 8696 % distinguish floats from other xref types.
Chris@42 8697 \def\floatmagic{!!float!!}
Chris@42 8698
Chris@42 8699 % #1 is the control sequence we are passed; we expand into a conditional
Chris@42 8700 % which is true if #1 represents a float ref. That is, the magic
Chris@42 8701 % \lastsection value which we \setref above.
Chris@42 8702 %
Chris@42 8703 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
Chris@42 8704 %
Chris@42 8705 % #1 is (maybe) the \floatmagic string. If so, #2 will be the
Chris@42 8706 % (safe) float type for this float. We set \iffloattype to #2.
Chris@42 8707 %
Chris@42 8708 \def\doiffloat#1=#2=#3\finish{%
Chris@42 8709 \def\temp{#1}%
Chris@42 8710 \def\iffloattype{#2}%
Chris@42 8711 \ifx\temp\floatmagic
Chris@42 8712 }
Chris@42 8713
Chris@42 8714 % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
Chris@42 8715 %
Chris@42 8716 \parseargdef\listoffloats{%
Chris@42 8717 \def\floattype{#1}% floattype
Chris@42 8718 {%
Chris@42 8719 % the floattype might have accents or other special characters,
Chris@42 8720 % but we need to use it in a control sequence name.
Chris@42 8721 \indexnofonts
Chris@42 8722 \turnoffactive
Chris@42 8723 \xdef\safefloattype{\floattype}%
Chris@42 8724 }%
Chris@42 8725 %
Chris@42 8726 % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
Chris@42 8727 \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
Chris@42 8728 \ifhavexrefs
Chris@42 8729 % if the user said @listoffloats foo but never @float foo.
Chris@42 8730 \message{\linenumber No `\safefloattype' floats to list.}%
Chris@42 8731 \fi
Chris@42 8732 \else
Chris@42 8733 \begingroup
Chris@42 8734 \leftskip=\tocindent % indent these entries like a toc
Chris@42 8735 \let\do=\listoffloatsdo
Chris@42 8736 \csname floatlist\safefloattype\endcsname
Chris@42 8737 \endgroup
Chris@42 8738 \fi
Chris@42 8739 }
Chris@42 8740
Chris@42 8741 % This is called on each entry in a list of floats. We're passed the
Chris@42 8742 % xref label, in the form LABEL-title, which is how we save it in the
Chris@42 8743 % aux file. We strip off the -title and look up \XRLABEL-lof, which
Chris@42 8744 % has the text we're supposed to typeset here.
Chris@42 8745 %
Chris@42 8746 % Figures without xref labels will not be included in the list (since
Chris@42 8747 % they won't appear in the aux file).
Chris@42 8748 %
Chris@42 8749 \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
Chris@42 8750 \def\listoffloatsdoentry#1-title\finish{{%
Chris@42 8751 % Can't fully expand XR#1-lof because it can contain anything. Just
Chris@42 8752 % pass the control sequence. On the other hand, XR#1-pg is just the
Chris@42 8753 % page number, and we want to fully expand that so we can get a link
Chris@42 8754 % in pdf output.
Chris@42 8755 \toksA = \expandafter{\csname XR#1-lof\endcsname}%
Chris@42 8756 %
Chris@42 8757 % use the same \entry macro we use to generate the TOC and index.
Chris@42 8758 \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
Chris@42 8759 \writeentry
Chris@42 8760 }}
Chris@42 8761
Chris@42 8762
Chris@42 8763 \message{localization,}
Chris@42 8764
Chris@42 8765 % For single-language documents, @documentlanguage is usually given very
Chris@42 8766 % early, just after @documentencoding. Single argument is the language
Chris@42 8767 % (de) or locale (de_DE) abbreviation.
Chris@42 8768 %
Chris@42 8769 {
Chris@42 8770 \catcode`\_ = \active
Chris@42 8771 \globaldefs=1
Chris@42 8772 \parseargdef\documentlanguage{\begingroup
Chris@42 8773 \let_=\normalunderscore % normal _ character for filenames
Chris@42 8774 \tex % read txi-??.tex file in plain TeX.
Chris@42 8775 % Read the file by the name they passed if it exists.
Chris@42 8776 \openin 1 txi-#1.tex
Chris@42 8777 \ifeof 1
Chris@42 8778 \documentlanguagetrywithoutunderscore{#1_\finish}%
Chris@42 8779 \else
Chris@42 8780 \globaldefs = 1 % everything in the txi-LL files needs to persist
Chris@42 8781 \input txi-#1.tex
Chris@42 8782 \fi
Chris@42 8783 \closein 1
Chris@42 8784 \endgroup % end raw TeX
Chris@42 8785 \endgroup}
Chris@42 8786 %
Chris@42 8787 % If they passed de_DE, and txi-de_DE.tex doesn't exist,
Chris@42 8788 % try txi-de.tex.
Chris@42 8789 %
Chris@42 8790 \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
Chris@42 8791 \openin 1 txi-#1.tex
Chris@42 8792 \ifeof 1
Chris@42 8793 \errhelp = \nolanghelp
Chris@42 8794 \errmessage{Cannot read language file txi-#1.tex}%
Chris@42 8795 \else
Chris@42 8796 \globaldefs = 1 % everything in the txi-LL files needs to persist
Chris@42 8797 \input txi-#1.tex
Chris@42 8798 \fi
Chris@42 8799 \closein 1
Chris@42 8800 }
Chris@42 8801 }% end of special _ catcode
Chris@42 8802 %
Chris@42 8803 \newhelp\nolanghelp{The given language definition file cannot be found or
Chris@42 8804 is empty. Maybe you need to install it? Putting it in the current
Chris@42 8805 directory should work if nowhere else does.}
Chris@42 8806
Chris@42 8807 % This macro is called from txi-??.tex files; the first argument is the
Chris@42 8808 % \language name to set (without the "\lang@" prefix), the second and
Chris@42 8809 % third args are \{left,right}hyphenmin.
Chris@42 8810 %
Chris@42 8811 % The language names to pass are determined when the format is built.
Chris@42 8812 % See the etex.log file created at that time, e.g.,
Chris@42 8813 % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
Chris@42 8814 %
Chris@42 8815 % With TeX Live 2008, etex now includes hyphenation patterns for all
Chris@42 8816 % available languages. This means we can support hyphenation in
Chris@42 8817 % Texinfo, at least to some extent. (This still doesn't solve the
Chris@42 8818 % accented characters problem.)
Chris@42 8819 %
Chris@42 8820 \catcode`@=11
Chris@42 8821 \def\txisetlanguage#1#2#3{%
Chris@42 8822 % do not set the language if the name is undefined in the current TeX.
Chris@42 8823 \expandafter\ifx\csname lang@#1\endcsname \relax
Chris@42 8824 \message{no patterns for #1}%
Chris@42 8825 \else
Chris@42 8826 \global\language = \csname lang@#1\endcsname
Chris@42 8827 \fi
Chris@42 8828 % but there is no harm in adjusting the hyphenmin values regardless.
Chris@42 8829 \global\lefthyphenmin = #2\relax
Chris@42 8830 \global\righthyphenmin = #3\relax
Chris@42 8831 }
Chris@42 8832
Chris@42 8833 % Helpers for encodings.
Chris@42 8834 % Set the catcode of characters 128 through 255 to the specified number.
Chris@42 8835 %
Chris@42 8836 \def\setnonasciicharscatcode#1{%
Chris@42 8837 \count255=128
Chris@42 8838 \loop\ifnum\count255<256
Chris@42 8839 \global\catcode\count255=#1\relax
Chris@42 8840 \advance\count255 by 1
Chris@42 8841 \repeat
Chris@42 8842 }
Chris@42 8843
Chris@42 8844 \def\setnonasciicharscatcodenonglobal#1{%
Chris@42 8845 \count255=128
Chris@42 8846 \loop\ifnum\count255<256
Chris@42 8847 \catcode\count255=#1\relax
Chris@42 8848 \advance\count255 by 1
Chris@42 8849 \repeat
Chris@42 8850 }
Chris@42 8851
Chris@42 8852 % @documentencoding sets the definition of non-ASCII characters
Chris@42 8853 % according to the specified encoding.
Chris@42 8854 %
Chris@42 8855 \parseargdef\documentencoding{%
Chris@42 8856 % Encoding being declared for the document.
Chris@42 8857 \def\declaredencoding{\csname #1.enc\endcsname}%
Chris@42 8858 %
Chris@42 8859 % Supported encodings: names converted to tokens in order to be able
Chris@42 8860 % to compare them with \ifx.
Chris@42 8861 \def\ascii{\csname US-ASCII.enc\endcsname}%
Chris@42 8862 \def\latnine{\csname ISO-8859-15.enc\endcsname}%
Chris@42 8863 \def\latone{\csname ISO-8859-1.enc\endcsname}%
Chris@42 8864 \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
Chris@42 8865 \def\utfeight{\csname UTF-8.enc\endcsname}%
Chris@42 8866 %
Chris@42 8867 \ifx \declaredencoding \ascii
Chris@42 8868 \asciichardefs
Chris@42 8869 %
Chris@42 8870 \else \ifx \declaredencoding \lattwo
Chris@42 8871 \setnonasciicharscatcode\active
Chris@42 8872 \lattwochardefs
Chris@42 8873 %
Chris@42 8874 \else \ifx \declaredencoding \latone
Chris@42 8875 \setnonasciicharscatcode\active
Chris@42 8876 \latonechardefs
Chris@42 8877 %
Chris@42 8878 \else \ifx \declaredencoding \latnine
Chris@42 8879 \setnonasciicharscatcode\active
Chris@42 8880 \latninechardefs
Chris@42 8881 %
Chris@42 8882 \else \ifx \declaredencoding \utfeight
Chris@42 8883 \setnonasciicharscatcode\active
Chris@42 8884 \utfeightchardefs
Chris@42 8885 %
Chris@42 8886 \else
Chris@42 8887 \message{Unknown document encoding #1, ignoring.}%
Chris@42 8888 %
Chris@42 8889 \fi % utfeight
Chris@42 8890 \fi % latnine
Chris@42 8891 \fi % latone
Chris@42 8892 \fi % lattwo
Chris@42 8893 \fi % ascii
Chris@42 8894 }
Chris@42 8895
Chris@42 8896 % A message to be logged when using a character that isn't available
Chris@42 8897 % the default font encoding (OT1).
Chris@42 8898 %
Chris@42 8899 \def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}}
Chris@42 8900
Chris@42 8901 % Take account of \c (plain) vs. \, (Texinfo) difference.
Chris@42 8902 \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
Chris@42 8903
Chris@42 8904 % First, make active non-ASCII characters in order for them to be
Chris@42 8905 % correctly categorized when TeX reads the replacement text of
Chris@42 8906 % macros containing the character definitions.
Chris@42 8907 \setnonasciicharscatcode\active
Chris@42 8908 %
Chris@42 8909 % Latin1 (ISO-8859-1) character definitions.
Chris@42 8910 \def\latonechardefs{%
Chris@42 8911 \gdef^^a0{\tie}
Chris@42 8912 \gdef^^a1{\exclamdown}
Chris@42 8913 \gdef^^a2{\missingcharmsg{CENT SIGN}}
Chris@42 8914 \gdef^^a3{{\pounds}}
Chris@42 8915 \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
Chris@42 8916 \gdef^^a5{\missingcharmsg{YEN SIGN}}
Chris@42 8917 \gdef^^a6{\missingcharmsg{BROKEN BAR}}
Chris@42 8918 \gdef^^a7{\S}
Chris@42 8919 \gdef^^a8{\"{}}
Chris@42 8920 \gdef^^a9{\copyright}
Chris@42 8921 \gdef^^aa{\ordf}
Chris@42 8922 \gdef^^ab{\guillemetleft}
Chris@42 8923 \gdef^^ac{$\lnot$}
Chris@42 8924 \gdef^^ad{\-}
Chris@42 8925 \gdef^^ae{\registeredsymbol}
Chris@42 8926 \gdef^^af{\={}}
Chris@42 8927 %
Chris@42 8928 \gdef^^b0{\textdegree}
Chris@42 8929 \gdef^^b1{$\pm$}
Chris@42 8930 \gdef^^b2{$^2$}
Chris@42 8931 \gdef^^b3{$^3$}
Chris@42 8932 \gdef^^b4{\'{}}
Chris@42 8933 \gdef^^b5{$\mu$}
Chris@42 8934 \gdef^^b6{\P}
Chris@42 8935 %
Chris@42 8936 \gdef^^b7{$^.$}
Chris@42 8937 \gdef^^b8{\cedilla\ }
Chris@42 8938 \gdef^^b9{$^1$}
Chris@42 8939 \gdef^^ba{\ordm}
Chris@42 8940 %
Chris@42 8941 \gdef^^bb{\guillemetright}
Chris@42 8942 \gdef^^bc{$1\over4$}
Chris@42 8943 \gdef^^bd{$1\over2$}
Chris@42 8944 \gdef^^be{$3\over4$}
Chris@42 8945 \gdef^^bf{\questiondown}
Chris@42 8946 %
Chris@42 8947 \gdef^^c0{\`A}
Chris@42 8948 \gdef^^c1{\'A}
Chris@42 8949 \gdef^^c2{\^A}
Chris@42 8950 \gdef^^c3{\~A}
Chris@42 8951 \gdef^^c4{\"A}
Chris@42 8952 \gdef^^c5{\ringaccent A}
Chris@42 8953 \gdef^^c6{\AE}
Chris@42 8954 \gdef^^c7{\cedilla C}
Chris@42 8955 \gdef^^c8{\`E}
Chris@42 8956 \gdef^^c9{\'E}
Chris@42 8957 \gdef^^ca{\^E}
Chris@42 8958 \gdef^^cb{\"E}
Chris@42 8959 \gdef^^cc{\`I}
Chris@42 8960 \gdef^^cd{\'I}
Chris@42 8961 \gdef^^ce{\^I}
Chris@42 8962 \gdef^^cf{\"I}
Chris@42 8963 %
Chris@42 8964 \gdef^^d0{\DH}
Chris@42 8965 \gdef^^d1{\~N}
Chris@42 8966 \gdef^^d2{\`O}
Chris@42 8967 \gdef^^d3{\'O}
Chris@42 8968 \gdef^^d4{\^O}
Chris@42 8969 \gdef^^d5{\~O}
Chris@42 8970 \gdef^^d6{\"O}
Chris@42 8971 \gdef^^d7{$\times$}
Chris@42 8972 \gdef^^d8{\O}
Chris@42 8973 \gdef^^d9{\`U}
Chris@42 8974 \gdef^^da{\'U}
Chris@42 8975 \gdef^^db{\^U}
Chris@42 8976 \gdef^^dc{\"U}
Chris@42 8977 \gdef^^dd{\'Y}
Chris@42 8978 \gdef^^de{\TH}
Chris@42 8979 \gdef^^df{\ss}
Chris@42 8980 %
Chris@42 8981 \gdef^^e0{\`a}
Chris@42 8982 \gdef^^e1{\'a}
Chris@42 8983 \gdef^^e2{\^a}
Chris@42 8984 \gdef^^e3{\~a}
Chris@42 8985 \gdef^^e4{\"a}
Chris@42 8986 \gdef^^e5{\ringaccent a}
Chris@42 8987 \gdef^^e6{\ae}
Chris@42 8988 \gdef^^e7{\cedilla c}
Chris@42 8989 \gdef^^e8{\`e}
Chris@42 8990 \gdef^^e9{\'e}
Chris@42 8991 \gdef^^ea{\^e}
Chris@42 8992 \gdef^^eb{\"e}
Chris@42 8993 \gdef^^ec{\`{\dotless i}}
Chris@42 8994 \gdef^^ed{\'{\dotless i}}
Chris@42 8995 \gdef^^ee{\^{\dotless i}}
Chris@42 8996 \gdef^^ef{\"{\dotless i}}
Chris@42 8997 %
Chris@42 8998 \gdef^^f0{\dh}
Chris@42 8999 \gdef^^f1{\~n}
Chris@42 9000 \gdef^^f2{\`o}
Chris@42 9001 \gdef^^f3{\'o}
Chris@42 9002 \gdef^^f4{\^o}
Chris@42 9003 \gdef^^f5{\~o}
Chris@42 9004 \gdef^^f6{\"o}
Chris@42 9005 \gdef^^f7{$\div$}
Chris@42 9006 \gdef^^f8{\o}
Chris@42 9007 \gdef^^f9{\`u}
Chris@42 9008 \gdef^^fa{\'u}
Chris@42 9009 \gdef^^fb{\^u}
Chris@42 9010 \gdef^^fc{\"u}
Chris@42 9011 \gdef^^fd{\'y}
Chris@42 9012 \gdef^^fe{\th}
Chris@42 9013 \gdef^^ff{\"y}
Chris@42 9014 }
Chris@42 9015
Chris@42 9016 % Latin9 (ISO-8859-15) encoding character definitions.
Chris@42 9017 \def\latninechardefs{%
Chris@42 9018 % Encoding is almost identical to Latin1.
Chris@42 9019 \latonechardefs
Chris@42 9020 %
Chris@42 9021 \gdef^^a4{\euro}
Chris@42 9022 \gdef^^a6{\v S}
Chris@42 9023 \gdef^^a8{\v s}
Chris@42 9024 \gdef^^b4{\v Z}
Chris@42 9025 \gdef^^b8{\v z}
Chris@42 9026 \gdef^^bc{\OE}
Chris@42 9027 \gdef^^bd{\oe}
Chris@42 9028 \gdef^^be{\"Y}
Chris@42 9029 }
Chris@42 9030
Chris@42 9031 % Latin2 (ISO-8859-2) character definitions.
Chris@42 9032 \def\lattwochardefs{%
Chris@42 9033 \gdef^^a0{\tie}
Chris@42 9034 \gdef^^a1{\ogonek{A}}
Chris@42 9035 \gdef^^a2{\u{}}
Chris@42 9036 \gdef^^a3{\L}
Chris@42 9037 \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
Chris@42 9038 \gdef^^a5{\v L}
Chris@42 9039 \gdef^^a6{\'S}
Chris@42 9040 \gdef^^a7{\S}
Chris@42 9041 \gdef^^a8{\"{}}
Chris@42 9042 \gdef^^a9{\v S}
Chris@42 9043 \gdef^^aa{\cedilla S}
Chris@42 9044 \gdef^^ab{\v T}
Chris@42 9045 \gdef^^ac{\'Z}
Chris@42 9046 \gdef^^ad{\-}
Chris@42 9047 \gdef^^ae{\v Z}
Chris@42 9048 \gdef^^af{\dotaccent Z}
Chris@42 9049 %
Chris@42 9050 \gdef^^b0{\textdegree}
Chris@42 9051 \gdef^^b1{\ogonek{a}}
Chris@42 9052 \gdef^^b2{\ogonek{ }}
Chris@42 9053 \gdef^^b3{\l}
Chris@42 9054 \gdef^^b4{\'{}}
Chris@42 9055 \gdef^^b5{\v l}
Chris@42 9056 \gdef^^b6{\'s}
Chris@42 9057 \gdef^^b7{\v{}}
Chris@42 9058 \gdef^^b8{\cedilla\ }
Chris@42 9059 \gdef^^b9{\v s}
Chris@42 9060 \gdef^^ba{\cedilla s}
Chris@42 9061 \gdef^^bb{\v t}
Chris@42 9062 \gdef^^bc{\'z}
Chris@42 9063 \gdef^^bd{\H{}}
Chris@42 9064 \gdef^^be{\v z}
Chris@42 9065 \gdef^^bf{\dotaccent z}
Chris@42 9066 %
Chris@42 9067 \gdef^^c0{\'R}
Chris@42 9068 \gdef^^c1{\'A}
Chris@42 9069 \gdef^^c2{\^A}
Chris@42 9070 \gdef^^c3{\u A}
Chris@42 9071 \gdef^^c4{\"A}
Chris@42 9072 \gdef^^c5{\'L}
Chris@42 9073 \gdef^^c6{\'C}
Chris@42 9074 \gdef^^c7{\cedilla C}
Chris@42 9075 \gdef^^c8{\v C}
Chris@42 9076 \gdef^^c9{\'E}
Chris@42 9077 \gdef^^ca{\ogonek{E}}
Chris@42 9078 \gdef^^cb{\"E}
Chris@42 9079 \gdef^^cc{\v E}
Chris@42 9080 \gdef^^cd{\'I}
Chris@42 9081 \gdef^^ce{\^I}
Chris@42 9082 \gdef^^cf{\v D}
Chris@42 9083 %
Chris@42 9084 \gdef^^d0{\DH}
Chris@42 9085 \gdef^^d1{\'N}
Chris@42 9086 \gdef^^d2{\v N}
Chris@42 9087 \gdef^^d3{\'O}
Chris@42 9088 \gdef^^d4{\^O}
Chris@42 9089 \gdef^^d5{\H O}
Chris@42 9090 \gdef^^d6{\"O}
Chris@42 9091 \gdef^^d7{$\times$}
Chris@42 9092 \gdef^^d8{\v R}
Chris@42 9093 \gdef^^d9{\ringaccent U}
Chris@42 9094 \gdef^^da{\'U}
Chris@42 9095 \gdef^^db{\H U}
Chris@42 9096 \gdef^^dc{\"U}
Chris@42 9097 \gdef^^dd{\'Y}
Chris@42 9098 \gdef^^de{\cedilla T}
Chris@42 9099 \gdef^^df{\ss}
Chris@42 9100 %
Chris@42 9101 \gdef^^e0{\'r}
Chris@42 9102 \gdef^^e1{\'a}
Chris@42 9103 \gdef^^e2{\^a}
Chris@42 9104 \gdef^^e3{\u a}
Chris@42 9105 \gdef^^e4{\"a}
Chris@42 9106 \gdef^^e5{\'l}
Chris@42 9107 \gdef^^e6{\'c}
Chris@42 9108 \gdef^^e7{\cedilla c}
Chris@42 9109 \gdef^^e8{\v c}
Chris@42 9110 \gdef^^e9{\'e}
Chris@42 9111 \gdef^^ea{\ogonek{e}}
Chris@42 9112 \gdef^^eb{\"e}
Chris@42 9113 \gdef^^ec{\v e}
Chris@42 9114 \gdef^^ed{\'{\dotless{i}}}
Chris@42 9115 \gdef^^ee{\^{\dotless{i}}}
Chris@42 9116 \gdef^^ef{\v d}
Chris@42 9117 %
Chris@42 9118 \gdef^^f0{\dh}
Chris@42 9119 \gdef^^f1{\'n}
Chris@42 9120 \gdef^^f2{\v n}
Chris@42 9121 \gdef^^f3{\'o}
Chris@42 9122 \gdef^^f4{\^o}
Chris@42 9123 \gdef^^f5{\H o}
Chris@42 9124 \gdef^^f6{\"o}
Chris@42 9125 \gdef^^f7{$\div$}
Chris@42 9126 \gdef^^f8{\v r}
Chris@42 9127 \gdef^^f9{\ringaccent u}
Chris@42 9128 \gdef^^fa{\'u}
Chris@42 9129 \gdef^^fb{\H u}
Chris@42 9130 \gdef^^fc{\"u}
Chris@42 9131 \gdef^^fd{\'y}
Chris@42 9132 \gdef^^fe{\cedilla t}
Chris@42 9133 \gdef^^ff{\dotaccent{}}
Chris@42 9134 }
Chris@42 9135
Chris@42 9136 % UTF-8 character definitions.
Chris@42 9137 %
Chris@42 9138 % This code to support UTF-8 is based on LaTeX's utf8.def, with some
Chris@42 9139 % changes for Texinfo conventions. It is included here under the GPL by
Chris@42 9140 % permission from Frank Mittelbach and the LaTeX team.
Chris@42 9141 %
Chris@42 9142 \newcount\countUTFx
Chris@42 9143 \newcount\countUTFy
Chris@42 9144 \newcount\countUTFz
Chris@42 9145
Chris@42 9146 \gdef\UTFviiiTwoOctets#1#2{\expandafter
Chris@42 9147 \UTFviiiDefined\csname u8:#1\string #2\endcsname}
Chris@42 9148 %
Chris@42 9149 \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
Chris@42 9150 \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
Chris@42 9151 %
Chris@42 9152 \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
Chris@42 9153 \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
Chris@42 9154
Chris@42 9155 \gdef\UTFviiiDefined#1{%
Chris@42 9156 \ifx #1\relax
Chris@42 9157 \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
Chris@42 9158 \else
Chris@42 9159 \expandafter #1%
Chris@42 9160 \fi
Chris@42 9161 }
Chris@42 9162
Chris@42 9163 \begingroup
Chris@42 9164 \catcode`\~13
Chris@42 9165 \catcode`\"12
Chris@42 9166
Chris@42 9167 \def\UTFviiiLoop{%
Chris@42 9168 \global\catcode\countUTFx\active
Chris@42 9169 \uccode`\~\countUTFx
Chris@42 9170 \uppercase\expandafter{\UTFviiiTmp}%
Chris@42 9171 \advance\countUTFx by 1
Chris@42 9172 \ifnum\countUTFx < \countUTFy
Chris@42 9173 \expandafter\UTFviiiLoop
Chris@42 9174 \fi}
Chris@42 9175
Chris@42 9176 \countUTFx = "C2
Chris@42 9177 \countUTFy = "E0
Chris@42 9178 \def\UTFviiiTmp{%
Chris@42 9179 \xdef~{\noexpand\UTFviiiTwoOctets\string~}}
Chris@42 9180 \UTFviiiLoop
Chris@42 9181
Chris@42 9182 \countUTFx = "E0
Chris@42 9183 \countUTFy = "F0
Chris@42 9184 \def\UTFviiiTmp{%
Chris@42 9185 \xdef~{\noexpand\UTFviiiThreeOctets\string~}}
Chris@42 9186 \UTFviiiLoop
Chris@42 9187
Chris@42 9188 \countUTFx = "F0
Chris@42 9189 \countUTFy = "F4
Chris@42 9190 \def\UTFviiiTmp{%
Chris@42 9191 \xdef~{\noexpand\UTFviiiFourOctets\string~}}
Chris@42 9192 \UTFviiiLoop
Chris@42 9193 \endgroup
Chris@42 9194
Chris@42 9195 \begingroup
Chris@42 9196 \catcode`\"=12
Chris@42 9197 \catcode`\<=12
Chris@42 9198 \catcode`\.=12
Chris@42 9199 \catcode`\,=12
Chris@42 9200 \catcode`\;=12
Chris@42 9201 \catcode`\!=12
Chris@42 9202 \catcode`\~=13
Chris@42 9203
Chris@42 9204 \gdef\DeclareUnicodeCharacter#1#2{%
Chris@42 9205 \countUTFz = "#1\relax
Chris@42 9206 %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}%
Chris@42 9207 \begingroup
Chris@42 9208 \parseXMLCharref
Chris@42 9209 \def\UTFviiiTwoOctets##1##2{%
Chris@42 9210 \csname u8:##1\string ##2\endcsname}%
Chris@42 9211 \def\UTFviiiThreeOctets##1##2##3{%
Chris@42 9212 \csname u8:##1\string ##2\string ##3\endcsname}%
Chris@42 9213 \def\UTFviiiFourOctets##1##2##3##4{%
Chris@42 9214 \csname u8:##1\string ##2\string ##3\string ##4\endcsname}%
Chris@42 9215 \expandafter\expandafter\expandafter\expandafter
Chris@42 9216 \expandafter\expandafter\expandafter
Chris@42 9217 \gdef\UTFviiiTmp{#2}%
Chris@42 9218 \endgroup}
Chris@42 9219
Chris@42 9220 \gdef\parseXMLCharref{%
Chris@42 9221 \ifnum\countUTFz < "A0\relax
Chris@42 9222 \errhelp = \EMsimple
Chris@42 9223 \errmessage{Cannot define Unicode char value < 00A0}%
Chris@42 9224 \else\ifnum\countUTFz < "800\relax
Chris@42 9225 \parseUTFviiiA,%
Chris@42 9226 \parseUTFviiiB C\UTFviiiTwoOctets.,%
Chris@42 9227 \else\ifnum\countUTFz < "10000\relax
Chris@42 9228 \parseUTFviiiA;%
Chris@42 9229 \parseUTFviiiA,%
Chris@42 9230 \parseUTFviiiB E\UTFviiiThreeOctets.{,;}%
Chris@42 9231 \else
Chris@42 9232 \parseUTFviiiA;%
Chris@42 9233 \parseUTFviiiA,%
Chris@42 9234 \parseUTFviiiA!%
Chris@42 9235 \parseUTFviiiB F\UTFviiiFourOctets.{!,;}%
Chris@42 9236 \fi\fi\fi
Chris@42 9237 }
Chris@42 9238
Chris@42 9239 \gdef\parseUTFviiiA#1{%
Chris@42 9240 \countUTFx = \countUTFz
Chris@42 9241 \divide\countUTFz by 64
Chris@42 9242 \countUTFy = \countUTFz
Chris@42 9243 \multiply\countUTFz by 64
Chris@42 9244 \advance\countUTFx by -\countUTFz
Chris@42 9245 \advance\countUTFx by 128
Chris@42 9246 \uccode `#1\countUTFx
Chris@42 9247 \countUTFz = \countUTFy}
Chris@42 9248
Chris@42 9249 \gdef\parseUTFviiiB#1#2#3#4{%
Chris@42 9250 \advance\countUTFz by "#10\relax
Chris@42 9251 \uccode `#3\countUTFz
Chris@42 9252 \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
Chris@42 9253 \endgroup
Chris@42 9254
Chris@42 9255 \def\utfeightchardefs{%
Chris@42 9256 \DeclareUnicodeCharacter{00A0}{\tie}
Chris@42 9257 \DeclareUnicodeCharacter{00A1}{\exclamdown}
Chris@42 9258 \DeclareUnicodeCharacter{00A3}{\pounds}
Chris@42 9259 \DeclareUnicodeCharacter{00A8}{\"{ }}
Chris@42 9260 \DeclareUnicodeCharacter{00A9}{\copyright}
Chris@42 9261 \DeclareUnicodeCharacter{00AA}{\ordf}
Chris@42 9262 \DeclareUnicodeCharacter{00AB}{\guillemetleft}
Chris@42 9263 \DeclareUnicodeCharacter{00AD}{\-}
Chris@42 9264 \DeclareUnicodeCharacter{00AE}{\registeredsymbol}
Chris@42 9265 \DeclareUnicodeCharacter{00AF}{\={ }}
Chris@42 9266
Chris@42 9267 \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}
Chris@42 9268 \DeclareUnicodeCharacter{00B4}{\'{ }}
Chris@42 9269 \DeclareUnicodeCharacter{00B8}{\cedilla{ }}
Chris@42 9270 \DeclareUnicodeCharacter{00BA}{\ordm}
Chris@42 9271 \DeclareUnicodeCharacter{00BB}{\guillemetright}
Chris@42 9272 \DeclareUnicodeCharacter{00BF}{\questiondown}
Chris@42 9273
Chris@42 9274 \DeclareUnicodeCharacter{00C0}{\`A}
Chris@42 9275 \DeclareUnicodeCharacter{00C1}{\'A}
Chris@42 9276 \DeclareUnicodeCharacter{00C2}{\^A}
Chris@42 9277 \DeclareUnicodeCharacter{00C3}{\~A}
Chris@42 9278 \DeclareUnicodeCharacter{00C4}{\"A}
Chris@42 9279 \DeclareUnicodeCharacter{00C5}{\AA}
Chris@42 9280 \DeclareUnicodeCharacter{00C6}{\AE}
Chris@42 9281 \DeclareUnicodeCharacter{00C7}{\cedilla{C}}
Chris@42 9282 \DeclareUnicodeCharacter{00C8}{\`E}
Chris@42 9283 \DeclareUnicodeCharacter{00C9}{\'E}
Chris@42 9284 \DeclareUnicodeCharacter{00CA}{\^E}
Chris@42 9285 \DeclareUnicodeCharacter{00CB}{\"E}
Chris@42 9286 \DeclareUnicodeCharacter{00CC}{\`I}
Chris@42 9287 \DeclareUnicodeCharacter{00CD}{\'I}
Chris@42 9288 \DeclareUnicodeCharacter{00CE}{\^I}
Chris@42 9289 \DeclareUnicodeCharacter{00CF}{\"I}
Chris@42 9290
Chris@42 9291 \DeclareUnicodeCharacter{00D0}{\DH}
Chris@42 9292 \DeclareUnicodeCharacter{00D1}{\~N}
Chris@42 9293 \DeclareUnicodeCharacter{00D2}{\`O}
Chris@42 9294 \DeclareUnicodeCharacter{00D3}{\'O}
Chris@42 9295 \DeclareUnicodeCharacter{00D4}{\^O}
Chris@42 9296 \DeclareUnicodeCharacter{00D5}{\~O}
Chris@42 9297 \DeclareUnicodeCharacter{00D6}{\"O}
Chris@42 9298 \DeclareUnicodeCharacter{00D8}{\O}
Chris@42 9299 \DeclareUnicodeCharacter{00D9}{\`U}
Chris@42 9300 \DeclareUnicodeCharacter{00DA}{\'U}
Chris@42 9301 \DeclareUnicodeCharacter{00DB}{\^U}
Chris@42 9302 \DeclareUnicodeCharacter{00DC}{\"U}
Chris@42 9303 \DeclareUnicodeCharacter{00DD}{\'Y}
Chris@42 9304 \DeclareUnicodeCharacter{00DE}{\TH}
Chris@42 9305 \DeclareUnicodeCharacter{00DF}{\ss}
Chris@42 9306
Chris@42 9307 \DeclareUnicodeCharacter{00E0}{\`a}
Chris@42 9308 \DeclareUnicodeCharacter{00E1}{\'a}
Chris@42 9309 \DeclareUnicodeCharacter{00E2}{\^a}
Chris@42 9310 \DeclareUnicodeCharacter{00E3}{\~a}
Chris@42 9311 \DeclareUnicodeCharacter{00E4}{\"a}
Chris@42 9312 \DeclareUnicodeCharacter{00E5}{\aa}
Chris@42 9313 \DeclareUnicodeCharacter{00E6}{\ae}
Chris@42 9314 \DeclareUnicodeCharacter{00E7}{\cedilla{c}}
Chris@42 9315 \DeclareUnicodeCharacter{00E8}{\`e}
Chris@42 9316 \DeclareUnicodeCharacter{00E9}{\'e}
Chris@42 9317 \DeclareUnicodeCharacter{00EA}{\^e}
Chris@42 9318 \DeclareUnicodeCharacter{00EB}{\"e}
Chris@42 9319 \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}
Chris@42 9320 \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}
Chris@42 9321 \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}
Chris@42 9322 \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}
Chris@42 9323
Chris@42 9324 \DeclareUnicodeCharacter{00F0}{\dh}
Chris@42 9325 \DeclareUnicodeCharacter{00F1}{\~n}
Chris@42 9326 \DeclareUnicodeCharacter{00F2}{\`o}
Chris@42 9327 \DeclareUnicodeCharacter{00F3}{\'o}
Chris@42 9328 \DeclareUnicodeCharacter{00F4}{\^o}
Chris@42 9329 \DeclareUnicodeCharacter{00F5}{\~o}
Chris@42 9330 \DeclareUnicodeCharacter{00F6}{\"o}
Chris@42 9331 \DeclareUnicodeCharacter{00F8}{\o}
Chris@42 9332 \DeclareUnicodeCharacter{00F9}{\`u}
Chris@42 9333 \DeclareUnicodeCharacter{00FA}{\'u}
Chris@42 9334 \DeclareUnicodeCharacter{00FB}{\^u}
Chris@42 9335 \DeclareUnicodeCharacter{00FC}{\"u}
Chris@42 9336 \DeclareUnicodeCharacter{00FD}{\'y}
Chris@42 9337 \DeclareUnicodeCharacter{00FE}{\th}
Chris@42 9338 \DeclareUnicodeCharacter{00FF}{\"y}
Chris@42 9339
Chris@42 9340 \DeclareUnicodeCharacter{0100}{\=A}
Chris@42 9341 \DeclareUnicodeCharacter{0101}{\=a}
Chris@42 9342 \DeclareUnicodeCharacter{0102}{\u{A}}
Chris@42 9343 \DeclareUnicodeCharacter{0103}{\u{a}}
Chris@42 9344 \DeclareUnicodeCharacter{0104}{\ogonek{A}}
Chris@42 9345 \DeclareUnicodeCharacter{0105}{\ogonek{a}}
Chris@42 9346 \DeclareUnicodeCharacter{0106}{\'C}
Chris@42 9347 \DeclareUnicodeCharacter{0107}{\'c}
Chris@42 9348 \DeclareUnicodeCharacter{0108}{\^C}
Chris@42 9349 \DeclareUnicodeCharacter{0109}{\^c}
Chris@42 9350 \DeclareUnicodeCharacter{0118}{\ogonek{E}}
Chris@42 9351 \DeclareUnicodeCharacter{0119}{\ogonek{e}}
Chris@42 9352 \DeclareUnicodeCharacter{010A}{\dotaccent{C}}
Chris@42 9353 \DeclareUnicodeCharacter{010B}{\dotaccent{c}}
Chris@42 9354 \DeclareUnicodeCharacter{010C}{\v{C}}
Chris@42 9355 \DeclareUnicodeCharacter{010D}{\v{c}}
Chris@42 9356 \DeclareUnicodeCharacter{010E}{\v{D}}
Chris@42 9357
Chris@42 9358 \DeclareUnicodeCharacter{0112}{\=E}
Chris@42 9359 \DeclareUnicodeCharacter{0113}{\=e}
Chris@42 9360 \DeclareUnicodeCharacter{0114}{\u{E}}
Chris@42 9361 \DeclareUnicodeCharacter{0115}{\u{e}}
Chris@42 9362 \DeclareUnicodeCharacter{0116}{\dotaccent{E}}
Chris@42 9363 \DeclareUnicodeCharacter{0117}{\dotaccent{e}}
Chris@42 9364 \DeclareUnicodeCharacter{011A}{\v{E}}
Chris@42 9365 \DeclareUnicodeCharacter{011B}{\v{e}}
Chris@42 9366 \DeclareUnicodeCharacter{011C}{\^G}
Chris@42 9367 \DeclareUnicodeCharacter{011D}{\^g}
Chris@42 9368 \DeclareUnicodeCharacter{011E}{\u{G}}
Chris@42 9369 \DeclareUnicodeCharacter{011F}{\u{g}}
Chris@42 9370
Chris@42 9371 \DeclareUnicodeCharacter{0120}{\dotaccent{G}}
Chris@42 9372 \DeclareUnicodeCharacter{0121}{\dotaccent{g}}
Chris@42 9373 \DeclareUnicodeCharacter{0124}{\^H}
Chris@42 9374 \DeclareUnicodeCharacter{0125}{\^h}
Chris@42 9375 \DeclareUnicodeCharacter{0128}{\~I}
Chris@42 9376 \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}
Chris@42 9377 \DeclareUnicodeCharacter{012A}{\=I}
Chris@42 9378 \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}
Chris@42 9379 \DeclareUnicodeCharacter{012C}{\u{I}}
Chris@42 9380 \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}
Chris@42 9381
Chris@42 9382 \DeclareUnicodeCharacter{0130}{\dotaccent{I}}
Chris@42 9383 \DeclareUnicodeCharacter{0131}{\dotless{i}}
Chris@42 9384 \DeclareUnicodeCharacter{0132}{IJ}
Chris@42 9385 \DeclareUnicodeCharacter{0133}{ij}
Chris@42 9386 \DeclareUnicodeCharacter{0134}{\^J}
Chris@42 9387 \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}
Chris@42 9388 \DeclareUnicodeCharacter{0139}{\'L}
Chris@42 9389 \DeclareUnicodeCharacter{013A}{\'l}
Chris@42 9390
Chris@42 9391 \DeclareUnicodeCharacter{0141}{\L}
Chris@42 9392 \DeclareUnicodeCharacter{0142}{\l}
Chris@42 9393 \DeclareUnicodeCharacter{0143}{\'N}
Chris@42 9394 \DeclareUnicodeCharacter{0144}{\'n}
Chris@42 9395 \DeclareUnicodeCharacter{0147}{\v{N}}
Chris@42 9396 \DeclareUnicodeCharacter{0148}{\v{n}}
Chris@42 9397 \DeclareUnicodeCharacter{014C}{\=O}
Chris@42 9398 \DeclareUnicodeCharacter{014D}{\=o}
Chris@42 9399 \DeclareUnicodeCharacter{014E}{\u{O}}
Chris@42 9400 \DeclareUnicodeCharacter{014F}{\u{o}}
Chris@42 9401
Chris@42 9402 \DeclareUnicodeCharacter{0150}{\H{O}}
Chris@42 9403 \DeclareUnicodeCharacter{0151}{\H{o}}
Chris@42 9404 \DeclareUnicodeCharacter{0152}{\OE}
Chris@42 9405 \DeclareUnicodeCharacter{0153}{\oe}
Chris@42 9406 \DeclareUnicodeCharacter{0154}{\'R}
Chris@42 9407 \DeclareUnicodeCharacter{0155}{\'r}
Chris@42 9408 \DeclareUnicodeCharacter{0158}{\v{R}}
Chris@42 9409 \DeclareUnicodeCharacter{0159}{\v{r}}
Chris@42 9410 \DeclareUnicodeCharacter{015A}{\'S}
Chris@42 9411 \DeclareUnicodeCharacter{015B}{\'s}
Chris@42 9412 \DeclareUnicodeCharacter{015C}{\^S}
Chris@42 9413 \DeclareUnicodeCharacter{015D}{\^s}
Chris@42 9414 \DeclareUnicodeCharacter{015E}{\cedilla{S}}
Chris@42 9415 \DeclareUnicodeCharacter{015F}{\cedilla{s}}
Chris@42 9416
Chris@42 9417 \DeclareUnicodeCharacter{0160}{\v{S}}
Chris@42 9418 \DeclareUnicodeCharacter{0161}{\v{s}}
Chris@42 9419 \DeclareUnicodeCharacter{0162}{\cedilla{t}}
Chris@42 9420 \DeclareUnicodeCharacter{0163}{\cedilla{T}}
Chris@42 9421 \DeclareUnicodeCharacter{0164}{\v{T}}
Chris@42 9422
Chris@42 9423 \DeclareUnicodeCharacter{0168}{\~U}
Chris@42 9424 \DeclareUnicodeCharacter{0169}{\~u}
Chris@42 9425 \DeclareUnicodeCharacter{016A}{\=U}
Chris@42 9426 \DeclareUnicodeCharacter{016B}{\=u}
Chris@42 9427 \DeclareUnicodeCharacter{016C}{\u{U}}
Chris@42 9428 \DeclareUnicodeCharacter{016D}{\u{u}}
Chris@42 9429 \DeclareUnicodeCharacter{016E}{\ringaccent{U}}
Chris@42 9430 \DeclareUnicodeCharacter{016F}{\ringaccent{u}}
Chris@42 9431
Chris@42 9432 \DeclareUnicodeCharacter{0170}{\H{U}}
Chris@42 9433 \DeclareUnicodeCharacter{0171}{\H{u}}
Chris@42 9434 \DeclareUnicodeCharacter{0174}{\^W}
Chris@42 9435 \DeclareUnicodeCharacter{0175}{\^w}
Chris@42 9436 \DeclareUnicodeCharacter{0176}{\^Y}
Chris@42 9437 \DeclareUnicodeCharacter{0177}{\^y}
Chris@42 9438 \DeclareUnicodeCharacter{0178}{\"Y}
Chris@42 9439 \DeclareUnicodeCharacter{0179}{\'Z}
Chris@42 9440 \DeclareUnicodeCharacter{017A}{\'z}
Chris@42 9441 \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}
Chris@42 9442 \DeclareUnicodeCharacter{017C}{\dotaccent{z}}
Chris@42 9443 \DeclareUnicodeCharacter{017D}{\v{Z}}
Chris@42 9444 \DeclareUnicodeCharacter{017E}{\v{z}}
Chris@42 9445
Chris@42 9446 \DeclareUnicodeCharacter{01C4}{D\v{Z}}
Chris@42 9447 \DeclareUnicodeCharacter{01C5}{D\v{z}}
Chris@42 9448 \DeclareUnicodeCharacter{01C6}{d\v{z}}
Chris@42 9449 \DeclareUnicodeCharacter{01C7}{LJ}
Chris@42 9450 \DeclareUnicodeCharacter{01C8}{Lj}
Chris@42 9451 \DeclareUnicodeCharacter{01C9}{lj}
Chris@42 9452 \DeclareUnicodeCharacter{01CA}{NJ}
Chris@42 9453 \DeclareUnicodeCharacter{01CB}{Nj}
Chris@42 9454 \DeclareUnicodeCharacter{01CC}{nj}
Chris@42 9455 \DeclareUnicodeCharacter{01CD}{\v{A}}
Chris@42 9456 \DeclareUnicodeCharacter{01CE}{\v{a}}
Chris@42 9457 \DeclareUnicodeCharacter{01CF}{\v{I}}
Chris@42 9458
Chris@42 9459 \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}
Chris@42 9460 \DeclareUnicodeCharacter{01D1}{\v{O}}
Chris@42 9461 \DeclareUnicodeCharacter{01D2}{\v{o}}
Chris@42 9462 \DeclareUnicodeCharacter{01D3}{\v{U}}
Chris@42 9463 \DeclareUnicodeCharacter{01D4}{\v{u}}
Chris@42 9464
Chris@42 9465 \DeclareUnicodeCharacter{01E2}{\={\AE}}
Chris@42 9466 \DeclareUnicodeCharacter{01E3}{\={\ae}}
Chris@42 9467 \DeclareUnicodeCharacter{01E6}{\v{G}}
Chris@42 9468 \DeclareUnicodeCharacter{01E7}{\v{g}}
Chris@42 9469 \DeclareUnicodeCharacter{01E8}{\v{K}}
Chris@42 9470 \DeclareUnicodeCharacter{01E9}{\v{k}}
Chris@42 9471
Chris@42 9472 \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}
Chris@42 9473 \DeclareUnicodeCharacter{01F1}{DZ}
Chris@42 9474 \DeclareUnicodeCharacter{01F2}{Dz}
Chris@42 9475 \DeclareUnicodeCharacter{01F3}{dz}
Chris@42 9476 \DeclareUnicodeCharacter{01F4}{\'G}
Chris@42 9477 \DeclareUnicodeCharacter{01F5}{\'g}
Chris@42 9478 \DeclareUnicodeCharacter{01F8}{\`N}
Chris@42 9479 \DeclareUnicodeCharacter{01F9}{\`n}
Chris@42 9480 \DeclareUnicodeCharacter{01FC}{\'{\AE}}
Chris@42 9481 \DeclareUnicodeCharacter{01FD}{\'{\ae}}
Chris@42 9482 \DeclareUnicodeCharacter{01FE}{\'{\O}}
Chris@42 9483 \DeclareUnicodeCharacter{01FF}{\'{\o}}
Chris@42 9484
Chris@42 9485 \DeclareUnicodeCharacter{021E}{\v{H}}
Chris@42 9486 \DeclareUnicodeCharacter{021F}{\v{h}}
Chris@42 9487
Chris@42 9488 \DeclareUnicodeCharacter{0226}{\dotaccent{A}}
Chris@42 9489 \DeclareUnicodeCharacter{0227}{\dotaccent{a}}
Chris@42 9490 \DeclareUnicodeCharacter{0228}{\cedilla{E}}
Chris@42 9491 \DeclareUnicodeCharacter{0229}{\cedilla{e}}
Chris@42 9492 \DeclareUnicodeCharacter{022E}{\dotaccent{O}}
Chris@42 9493 \DeclareUnicodeCharacter{022F}{\dotaccent{o}}
Chris@42 9494
Chris@42 9495 \DeclareUnicodeCharacter{0232}{\=Y}
Chris@42 9496 \DeclareUnicodeCharacter{0233}{\=y}
Chris@42 9497 \DeclareUnicodeCharacter{0237}{\dotless{j}}
Chris@42 9498
Chris@42 9499 \DeclareUnicodeCharacter{02DB}{\ogonek{ }}
Chris@42 9500
Chris@42 9501 \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}
Chris@42 9502 \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}
Chris@42 9503 \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}
Chris@42 9504 \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}
Chris@42 9505 \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}
Chris@42 9506 \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}
Chris@42 9507 \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}
Chris@42 9508 \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}
Chris@42 9509 \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}
Chris@42 9510 \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}
Chris@42 9511 \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}
Chris@42 9512 \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}
Chris@42 9513
Chris@42 9514 \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}
Chris@42 9515 \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}
Chris@42 9516
Chris@42 9517 \DeclareUnicodeCharacter{1E20}{\=G}
Chris@42 9518 \DeclareUnicodeCharacter{1E21}{\=g}
Chris@42 9519 \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}
Chris@42 9520 \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}
Chris@42 9521 \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}
Chris@42 9522 \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}
Chris@42 9523 \DeclareUnicodeCharacter{1E26}{\"H}
Chris@42 9524 \DeclareUnicodeCharacter{1E27}{\"h}
Chris@42 9525
Chris@42 9526 \DeclareUnicodeCharacter{1E30}{\'K}
Chris@42 9527 \DeclareUnicodeCharacter{1E31}{\'k}
Chris@42 9528 \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}
Chris@42 9529 \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}
Chris@42 9530 \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}
Chris@42 9531 \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}
Chris@42 9532 \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}
Chris@42 9533 \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}
Chris@42 9534 \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}
Chris@42 9535 \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}
Chris@42 9536 \DeclareUnicodeCharacter{1E3E}{\'M}
Chris@42 9537 \DeclareUnicodeCharacter{1E3F}{\'m}
Chris@42 9538
Chris@42 9539 \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}
Chris@42 9540 \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}
Chris@42 9541 \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}
Chris@42 9542 \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}
Chris@42 9543 \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}
Chris@42 9544 \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}
Chris@42 9545 \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}
Chris@42 9546 \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}
Chris@42 9547 \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}
Chris@42 9548 \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}
Chris@42 9549
Chris@42 9550 \DeclareUnicodeCharacter{1E54}{\'P}
Chris@42 9551 \DeclareUnicodeCharacter{1E55}{\'p}
Chris@42 9552 \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}
Chris@42 9553 \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}
Chris@42 9554 \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}
Chris@42 9555 \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}
Chris@42 9556 \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}
Chris@42 9557 \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}
Chris@42 9558 \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}
Chris@42 9559 \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}
Chris@42 9560
Chris@42 9561 \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}
Chris@42 9562 \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}
Chris@42 9563 \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}
Chris@42 9564 \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}
Chris@42 9565 \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}
Chris@42 9566 \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}
Chris@42 9567 \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}
Chris@42 9568 \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}
Chris@42 9569 \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}
Chris@42 9570 \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}
Chris@42 9571
Chris@42 9572 \DeclareUnicodeCharacter{1E7C}{\~V}
Chris@42 9573 \DeclareUnicodeCharacter{1E7D}{\~v}
Chris@42 9574 \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}
Chris@42 9575 \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}
Chris@42 9576
Chris@42 9577 \DeclareUnicodeCharacter{1E80}{\`W}
Chris@42 9578 \DeclareUnicodeCharacter{1E81}{\`w}
Chris@42 9579 \DeclareUnicodeCharacter{1E82}{\'W}
Chris@42 9580 \DeclareUnicodeCharacter{1E83}{\'w}
Chris@42 9581 \DeclareUnicodeCharacter{1E84}{\"W}
Chris@42 9582 \DeclareUnicodeCharacter{1E85}{\"w}
Chris@42 9583 \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}
Chris@42 9584 \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}
Chris@42 9585 \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}
Chris@42 9586 \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}
Chris@42 9587 \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}
Chris@42 9588 \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}
Chris@42 9589 \DeclareUnicodeCharacter{1E8C}{\"X}
Chris@42 9590 \DeclareUnicodeCharacter{1E8D}{\"x}
Chris@42 9591 \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}
Chris@42 9592 \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}
Chris@42 9593
Chris@42 9594 \DeclareUnicodeCharacter{1E90}{\^Z}
Chris@42 9595 \DeclareUnicodeCharacter{1E91}{\^z}
Chris@42 9596 \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}
Chris@42 9597 \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}
Chris@42 9598 \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}
Chris@42 9599 \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}
Chris@42 9600 \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}
Chris@42 9601 \DeclareUnicodeCharacter{1E97}{\"t}
Chris@42 9602 \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}
Chris@42 9603 \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}
Chris@42 9604
Chris@42 9605 \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}
Chris@42 9606 \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}
Chris@42 9607
Chris@42 9608 \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}
Chris@42 9609 \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}
Chris@42 9610 \DeclareUnicodeCharacter{1EBC}{\~E}
Chris@42 9611 \DeclareUnicodeCharacter{1EBD}{\~e}
Chris@42 9612
Chris@42 9613 \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}
Chris@42 9614 \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}
Chris@42 9615 \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}
Chris@42 9616 \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}
Chris@42 9617
Chris@42 9618 \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}
Chris@42 9619 \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}
Chris@42 9620
Chris@42 9621 \DeclareUnicodeCharacter{1EF2}{\`Y}
Chris@42 9622 \DeclareUnicodeCharacter{1EF3}{\`y}
Chris@42 9623 \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}
Chris@42 9624
Chris@42 9625 \DeclareUnicodeCharacter{1EF8}{\~Y}
Chris@42 9626 \DeclareUnicodeCharacter{1EF9}{\~y}
Chris@42 9627
Chris@42 9628 \DeclareUnicodeCharacter{2013}{--}
Chris@42 9629 \DeclareUnicodeCharacter{2014}{---}
Chris@42 9630 \DeclareUnicodeCharacter{2018}{\quoteleft}
Chris@42 9631 \DeclareUnicodeCharacter{2019}{\quoteright}
Chris@42 9632 \DeclareUnicodeCharacter{201A}{\quotesinglbase}
Chris@42 9633 \DeclareUnicodeCharacter{201C}{\quotedblleft}
Chris@42 9634 \DeclareUnicodeCharacter{201D}{\quotedblright}
Chris@42 9635 \DeclareUnicodeCharacter{201E}{\quotedblbase}
Chris@42 9636 \DeclareUnicodeCharacter{2022}{\bullet}
Chris@42 9637 \DeclareUnicodeCharacter{2026}{\dots}
Chris@42 9638 \DeclareUnicodeCharacter{2039}{\guilsinglleft}
Chris@42 9639 \DeclareUnicodeCharacter{203A}{\guilsinglright}
Chris@42 9640 \DeclareUnicodeCharacter{20AC}{\euro}
Chris@42 9641
Chris@42 9642 \DeclareUnicodeCharacter{2192}{\expansion}
Chris@42 9643 \DeclareUnicodeCharacter{21D2}{\result}
Chris@42 9644
Chris@42 9645 \DeclareUnicodeCharacter{2212}{\minus}
Chris@42 9646 \DeclareUnicodeCharacter{2217}{\point}
Chris@42 9647 \DeclareUnicodeCharacter{2261}{\equiv}
Chris@42 9648 }% end of \utfeightchardefs
Chris@42 9649
Chris@42 9650
Chris@42 9651 % US-ASCII character definitions.
Chris@42 9652 \def\asciichardefs{% nothing need be done
Chris@42 9653 \relax
Chris@42 9654 }
Chris@42 9655
Chris@42 9656 % Make non-ASCII characters printable again for compatibility with
Chris@42 9657 % existing Texinfo documents that may use them, even without declaring a
Chris@42 9658 % document encoding.
Chris@42 9659 %
Chris@42 9660 \setnonasciicharscatcode \other
Chris@42 9661
Chris@42 9662
Chris@42 9663 \message{formatting,}
Chris@42 9664
Chris@42 9665 \newdimen\defaultparindent \defaultparindent = 15pt
Chris@42 9666
Chris@42 9667 \chapheadingskip = 15pt plus 4pt minus 2pt
Chris@42 9668 \secheadingskip = 12pt plus 3pt minus 2pt
Chris@42 9669 \subsecheadingskip = 9pt plus 2pt minus 2pt
Chris@42 9670
Chris@42 9671 % Prevent underfull vbox error messages.
Chris@42 9672 \vbadness = 10000
Chris@42 9673
Chris@42 9674 % Don't be very finicky about underfull hboxes, either.
Chris@42 9675 \hbadness = 6666
Chris@42 9676
Chris@42 9677 % Following George Bush, get rid of widows and orphans.
Chris@42 9678 \widowpenalty=10000
Chris@42 9679 \clubpenalty=10000
Chris@42 9680
Chris@42 9681 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
Chris@42 9682 % using an old version of TeX, don't do anything. We want the amount of
Chris@42 9683 % stretch added to depend on the line length, hence the dependence on
Chris@42 9684 % \hsize. We call this whenever the paper size is set.
Chris@42 9685 %
Chris@42 9686 \def\setemergencystretch{%
Chris@42 9687 \ifx\emergencystretch\thisisundefined
Chris@42 9688 % Allow us to assign to \emergencystretch anyway.
Chris@42 9689 \def\emergencystretch{\dimen0}%
Chris@42 9690 \else
Chris@42 9691 \emergencystretch = .15\hsize
Chris@42 9692 \fi
Chris@42 9693 }
Chris@42 9694
Chris@42 9695 % Parameters in order: 1) textheight; 2) textwidth;
Chris@42 9696 % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
Chris@42 9697 % 7) physical page height; 8) physical page width.
Chris@42 9698 %
Chris@42 9699 % We also call \setleading{\textleading}, so the caller should define
Chris@42 9700 % \textleading. The caller should also set \parskip.
Chris@42 9701 %
Chris@42 9702 \def\internalpagesizes#1#2#3#4#5#6#7#8{%
Chris@42 9703 \voffset = #3\relax
Chris@42 9704 \topskip = #6\relax
Chris@42 9705 \splittopskip = \topskip
Chris@42 9706 %
Chris@42 9707 \vsize = #1\relax
Chris@42 9708 \advance\vsize by \topskip
Chris@42 9709 \outervsize = \vsize
Chris@42 9710 \advance\outervsize by 2\topandbottommargin
Chris@42 9711 \pageheight = \vsize
Chris@42 9712 %
Chris@42 9713 \hsize = #2\relax
Chris@42 9714 \outerhsize = \hsize
Chris@42 9715 \advance\outerhsize by 0.5in
Chris@42 9716 \pagewidth = \hsize
Chris@42 9717 %
Chris@42 9718 \normaloffset = #4\relax
Chris@42 9719 \bindingoffset = #5\relax
Chris@42 9720 %
Chris@42 9721 \ifpdf
Chris@42 9722 \pdfpageheight #7\relax
Chris@42 9723 \pdfpagewidth #8\relax
Chris@42 9724 % if we don't reset these, they will remain at "1 true in" of
Chris@42 9725 % whatever layout pdftex was dumped with.
Chris@42 9726 \pdfhorigin = 1 true in
Chris@42 9727 \pdfvorigin = 1 true in
Chris@42 9728 \fi
Chris@42 9729 %
Chris@42 9730 \setleading{\textleading}
Chris@42 9731 %
Chris@42 9732 \parindent = \defaultparindent
Chris@42 9733 \setemergencystretch
Chris@42 9734 }
Chris@42 9735
Chris@42 9736 % @letterpaper (the default).
Chris@42 9737 \def\letterpaper{{\globaldefs = 1
Chris@42 9738 \parskip = 3pt plus 2pt minus 1pt
Chris@42 9739 \textleading = 13.2pt
Chris@42 9740 %
Chris@42 9741 % If page is nothing but text, make it come out even.
Chris@42 9742 \internalpagesizes{607.2pt}{6in}% that's 46 lines
Chris@42 9743 {\voffset}{.25in}%
Chris@42 9744 {\bindingoffset}{36pt}%
Chris@42 9745 {11in}{8.5in}%
Chris@42 9746 }}
Chris@42 9747
Chris@42 9748 % Use @smallbook to reset parameters for 7x9.25 trim size.
Chris@42 9749 \def\smallbook{{\globaldefs = 1
Chris@42 9750 \parskip = 2pt plus 1pt
Chris@42 9751 \textleading = 12pt
Chris@42 9752 %
Chris@42 9753 \internalpagesizes{7.5in}{5in}%
Chris@42 9754 {-.2in}{0in}%
Chris@42 9755 {\bindingoffset}{16pt}%
Chris@42 9756 {9.25in}{7in}%
Chris@42 9757 %
Chris@42 9758 \lispnarrowing = 0.3in
Chris@42 9759 \tolerance = 700
Chris@42 9760 \hfuzz = 1pt
Chris@42 9761 \contentsrightmargin = 0pt
Chris@42 9762 \defbodyindent = .5cm
Chris@42 9763 }}
Chris@42 9764
Chris@42 9765 % Use @smallerbook to reset parameters for 6x9 trim size.
Chris@42 9766 % (Just testing, parameters still in flux.)
Chris@42 9767 \def\smallerbook{{\globaldefs = 1
Chris@42 9768 \parskip = 1.5pt plus 1pt
Chris@42 9769 \textleading = 12pt
Chris@42 9770 %
Chris@42 9771 \internalpagesizes{7.4in}{4.8in}%
Chris@42 9772 {-.2in}{-.4in}%
Chris@42 9773 {0pt}{14pt}%
Chris@42 9774 {9in}{6in}%
Chris@42 9775 %
Chris@42 9776 \lispnarrowing = 0.25in
Chris@42 9777 \tolerance = 700
Chris@42 9778 \hfuzz = 1pt
Chris@42 9779 \contentsrightmargin = 0pt
Chris@42 9780 \defbodyindent = .4cm
Chris@42 9781 }}
Chris@42 9782
Chris@42 9783 % Use @afourpaper to print on European A4 paper.
Chris@42 9784 \def\afourpaper{{\globaldefs = 1
Chris@42 9785 \parskip = 3pt plus 2pt minus 1pt
Chris@42 9786 \textleading = 13.2pt
Chris@42 9787 %
Chris@42 9788 % Double-side printing via postscript on Laserjet 4050
Chris@42 9789 % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
Chris@42 9790 % To change the settings for a different printer or situation, adjust
Chris@42 9791 % \normaloffset until the front-side and back-side texts align. Then
Chris@42 9792 % do the same for \bindingoffset. You can set these for testing in
Chris@42 9793 % your texinfo source file like this:
Chris@42 9794 % @tex
Chris@42 9795 % \global\normaloffset = -6mm
Chris@42 9796 % \global\bindingoffset = 10mm
Chris@42 9797 % @end tex
Chris@42 9798 \internalpagesizes{673.2pt}{160mm}% that's 51 lines
Chris@42 9799 {\voffset}{\hoffset}%
Chris@42 9800 {\bindingoffset}{44pt}%
Chris@42 9801 {297mm}{210mm}%
Chris@42 9802 %
Chris@42 9803 \tolerance = 700
Chris@42 9804 \hfuzz = 1pt
Chris@42 9805 \contentsrightmargin = 0pt
Chris@42 9806 \defbodyindent = 5mm
Chris@42 9807 }}
Chris@42 9808
Chris@42 9809 % Use @afivepaper to print on European A5 paper.
Chris@42 9810 % From romildo@urano.iceb.ufop.br, 2 July 2000.
Chris@42 9811 % He also recommends making @example and @lisp be small.
Chris@42 9812 \def\afivepaper{{\globaldefs = 1
Chris@42 9813 \parskip = 2pt plus 1pt minus 0.1pt
Chris@42 9814 \textleading = 12.5pt
Chris@42 9815 %
Chris@42 9816 \internalpagesizes{160mm}{120mm}%
Chris@42 9817 {\voffset}{\hoffset}%
Chris@42 9818 {\bindingoffset}{8pt}%
Chris@42 9819 {210mm}{148mm}%
Chris@42 9820 %
Chris@42 9821 \lispnarrowing = 0.2in
Chris@42 9822 \tolerance = 800
Chris@42 9823 \hfuzz = 1.2pt
Chris@42 9824 \contentsrightmargin = 0pt
Chris@42 9825 \defbodyindent = 2mm
Chris@42 9826 \tableindent = 12mm
Chris@42 9827 }}
Chris@42 9828
Chris@42 9829 % A specific text layout, 24x15cm overall, intended for A4 paper.
Chris@42 9830 \def\afourlatex{{\globaldefs = 1
Chris@42 9831 \afourpaper
Chris@42 9832 \internalpagesizes{237mm}{150mm}%
Chris@42 9833 {\voffset}{4.6mm}%
Chris@42 9834 {\bindingoffset}{7mm}%
Chris@42 9835 {297mm}{210mm}%
Chris@42 9836 %
Chris@42 9837 % Must explicitly reset to 0 because we call \afourpaper.
Chris@42 9838 \globaldefs = 0
Chris@42 9839 }}
Chris@42 9840
Chris@42 9841 % Use @afourwide to print on A4 paper in landscape format.
Chris@42 9842 \def\afourwide{{\globaldefs = 1
Chris@42 9843 \afourpaper
Chris@42 9844 \internalpagesizes{241mm}{165mm}%
Chris@42 9845 {\voffset}{-2.95mm}%
Chris@42 9846 {\bindingoffset}{7mm}%
Chris@42 9847 {297mm}{210mm}%
Chris@42 9848 \globaldefs = 0
Chris@42 9849 }}
Chris@42 9850
Chris@42 9851 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
Chris@42 9852 % Perhaps we should allow setting the margins, \topskip, \parskip,
Chris@42 9853 % and/or leading, also. Or perhaps we should compute them somehow.
Chris@42 9854 %
Chris@42 9855 \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
Chris@42 9856 \def\pagesizesyyy#1,#2,#3\finish{{%
Chris@42 9857 \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
Chris@42 9858 \globaldefs = 1
Chris@42 9859 %
Chris@42 9860 \parskip = 3pt plus 2pt minus 1pt
Chris@42 9861 \setleading{\textleading}%
Chris@42 9862 %
Chris@42 9863 \dimen0 = #1\relax
Chris@42 9864 \advance\dimen0 by \voffset
Chris@42 9865 %
Chris@42 9866 \dimen2 = \hsize
Chris@42 9867 \advance\dimen2 by \normaloffset
Chris@42 9868 %
Chris@42 9869 \internalpagesizes{#1}{\hsize}%
Chris@42 9870 {\voffset}{\normaloffset}%
Chris@42 9871 {\bindingoffset}{44pt}%
Chris@42 9872 {\dimen0}{\dimen2}%
Chris@42 9873 }}
Chris@42 9874
Chris@42 9875 % Set default to letter.
Chris@42 9876 %
Chris@42 9877 \letterpaper
Chris@42 9878
Chris@42 9879
Chris@42 9880 \message{and turning on texinfo input format.}
Chris@42 9881
Chris@42 9882 \def^^L{\par} % remove \outer, so ^L can appear in an @comment
Chris@42 9883
Chris@42 9884 % DEL is a comment character, in case @c does not suffice.
Chris@42 9885 \catcode`\^^? = 14
Chris@42 9886
Chris@42 9887 % Define macros to output various characters with catcode for normal text.
Chris@42 9888 \catcode`\"=\other \def\normaldoublequote{"}
Chris@42 9889 \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
Chris@42 9890 \catcode`\+=\other \def\normalplus{+}
Chris@42 9891 \catcode`\<=\other \def\normalless{<}
Chris@42 9892 \catcode`\>=\other \def\normalgreater{>}
Chris@42 9893 \catcode`\^=\other \def\normalcaret{^}
Chris@42 9894 \catcode`\_=\other \def\normalunderscore{_}
Chris@42 9895 \catcode`\|=\other \def\normalverticalbar{|}
Chris@42 9896 \catcode`\~=\other \def\normaltilde{~}
Chris@42 9897
Chris@42 9898 % This macro is used to make a character print one way in \tt
Chris@42 9899 % (where it can probably be output as-is), and another way in other fonts,
Chris@42 9900 % where something hairier probably needs to be done.
Chris@42 9901 %
Chris@42 9902 % #1 is what to print if we are indeed using \tt; #2 is what to print
Chris@42 9903 % otherwise. Since all the Computer Modern typewriter fonts have zero
Chris@42 9904 % interword stretch (and shrink), and it is reasonable to expect all
Chris@42 9905 % typewriter fonts to have this, we can check that font parameter.
Chris@42 9906 %
Chris@42 9907 \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
Chris@42 9908
Chris@42 9909 % Same as above, but check for italic font. Actually this also catches
Chris@42 9910 % non-italic slanted fonts since it is impossible to distinguish them from
Chris@42 9911 % italic fonts. But since this is only used by $ and it uses \sl anyway
Chris@42 9912 % this is not a problem.
Chris@42 9913 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
Chris@42 9914
Chris@42 9915 % Turn off all special characters except @
Chris@42 9916 % (and those which the user can use as if they were ordinary).
Chris@42 9917 % Most of these we simply print from the \tt font, but for some, we can
Chris@42 9918 % use math or other variants that look better in normal text.
Chris@42 9919
Chris@42 9920 \catcode`\"=\active
Chris@42 9921 \def\activedoublequote{{\tt\char34}}
Chris@42 9922 \let"=\activedoublequote
Chris@42 9923 \catcode`\~=\active
Chris@42 9924 \def~{{\tt\char126}}
Chris@42 9925 \chardef\hat=`\^
Chris@42 9926 \catcode`\^=\active
Chris@42 9927 \def^{{\tt \hat}}
Chris@42 9928
Chris@42 9929 \catcode`\_=\active
Chris@42 9930 \def_{\ifusingtt\normalunderscore\_}
Chris@42 9931 \let\realunder=_
Chris@42 9932 % Subroutine for the previous macro.
Chris@42 9933 \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
Chris@42 9934
Chris@42 9935 \catcode`\|=\active
Chris@42 9936 \def|{{\tt\char124}}
Chris@42 9937 \chardef \less=`\<
Chris@42 9938 \catcode`\<=\active
Chris@42 9939 \def<{{\tt \less}}
Chris@42 9940 \chardef \gtr=`\>
Chris@42 9941 \catcode`\>=\active
Chris@42 9942 \def>{{\tt \gtr}}
Chris@42 9943 \catcode`\+=\active
Chris@42 9944 \def+{{\tt \char 43}}
Chris@42 9945 \catcode`\$=\active
Chris@42 9946 \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
Chris@42 9947
Chris@42 9948 % If a .fmt file is being used, characters that might appear in a file
Chris@42 9949 % name cannot be active until we have parsed the command line.
Chris@42 9950 % So turn them off again, and have \everyjob (or @setfilename) turn them on.
Chris@42 9951 % \otherifyactive is called near the end of this file.
Chris@42 9952 \def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
Chris@42 9953
Chris@42 9954 % Used sometimes to turn off (effectively) the active characters even after
Chris@42 9955 % parsing them.
Chris@42 9956 \def\turnoffactive{%
Chris@42 9957 \normalturnoffactive
Chris@42 9958 \otherbackslash
Chris@42 9959 }
Chris@42 9960
Chris@42 9961 \catcode`\@=0
Chris@42 9962
Chris@42 9963 % \backslashcurfont outputs one backslash character in current font,
Chris@42 9964 % as in \char`\\.
Chris@42 9965 \global\chardef\backslashcurfont=`\\
Chris@42 9966 \global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work
Chris@42 9967
Chris@42 9968 % \realbackslash is an actual character `\' with catcode other, and
Chris@42 9969 % \doublebackslash is two of them (for the pdf outlines).
Chris@42 9970 {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
Chris@42 9971
Chris@42 9972 % In texinfo, backslash is an active character; it prints the backslash
Chris@42 9973 % in fixed width font.
Chris@42 9974 \catcode`\\=\active % @ for escape char from now on.
Chris@42 9975
Chris@42 9976 % The story here is that in math mode, the \char of \backslashcurfont
Chris@42 9977 % ends up printing the roman \ from the math symbol font (because \char
Chris@42 9978 % in math mode uses the \mathcode, and plain.tex sets
Chris@42 9979 % \mathcode`\\="026E). It seems better for @backslashchar{} to always
Chris@42 9980 % print a typewriter backslash, hence we use an explicit \mathchar,
Chris@42 9981 % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
Chris@42 9982 % ignored family value; char position "5C). We can't use " for the
Chris@42 9983 % usual hex value because it has already been made active.
Chris@42 9984 @def@normalbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
Chris@42 9985 @let@backslashchar = @normalbackslash % @backslashchar{} is for user documents.
Chris@42 9986
Chris@42 9987 % On startup, @fixbackslash assigns:
Chris@42 9988 % @let \ = @normalbackslash
Chris@42 9989 % \rawbackslash defines an active \ to do \backslashcurfont.
Chris@42 9990 % \otherbackslash defines an active \ to be a literal `\' character with
Chris@42 9991 % catcode other. We switch back and forth between these.
Chris@42 9992 @gdef@rawbackslash{@let\=@backslashcurfont}
Chris@42 9993 @gdef@otherbackslash{@let\=@realbackslash}
Chris@42 9994
Chris@42 9995 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
Chris@42 9996 % the literal character `\'. Also revert - to its normal character, in
Chris@42 9997 % case the active - from code has slipped in.
Chris@42 9998 %
Chris@42 9999 {@catcode`- = @active
Chris@42 10000 @gdef@normalturnoffactive{%
Chris@42 10001 @let-=@normaldash
Chris@42 10002 @let"=@normaldoublequote
Chris@42 10003 @let$=@normaldollar %$ font-lock fix
Chris@42 10004 @let+=@normalplus
Chris@42 10005 @let<=@normalless
Chris@42 10006 @let>=@normalgreater
Chris@42 10007 @let\=@normalbackslash
Chris@42 10008 @let^=@normalcaret
Chris@42 10009 @let_=@normalunderscore
Chris@42 10010 @let|=@normalverticalbar
Chris@42 10011 @let~=@normaltilde
Chris@42 10012 @markupsetuplqdefault
Chris@42 10013 @markupsetuprqdefault
Chris@42 10014 @unsepspaces
Chris@42 10015 }
Chris@42 10016 }
Chris@42 10017
Chris@42 10018 % Make _ and + \other characters, temporarily.
Chris@42 10019 % This is canceled by @fixbackslash.
Chris@42 10020 @otherifyactive
Chris@42 10021
Chris@42 10022 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
Chris@42 10023 % That is what \eatinput is for; after that, the `\' should revert to printing
Chris@42 10024 % a backslash.
Chris@42 10025 %
Chris@42 10026 @gdef@eatinput input texinfo{@fixbackslash}
Chris@42 10027 @global@let\ = @eatinput
Chris@42 10028
Chris@42 10029 % On the other hand, perhaps the file did not have a `\input texinfo'. Then
Chris@42 10030 % the first `\' in the file would cause an error. This macro tries to fix
Chris@42 10031 % that, assuming it is called before the first `\' could plausibly occur.
Chris@42 10032 % Also turn back on active characters that might appear in the input
Chris@42 10033 % file name, in case not using a pre-dumped format.
Chris@42 10034 %
Chris@42 10035 @gdef@fixbackslash{%
Chris@42 10036 @ifx\@eatinput @let\ = @normalbackslash @fi
Chris@42 10037 @catcode`+=@active
Chris@42 10038 @catcode`@_=@active
Chris@42 10039 }
Chris@42 10040
Chris@42 10041 % Say @foo, not \foo, in error messages.
Chris@42 10042 @escapechar = `@@
Chris@42 10043
Chris@42 10044 % These (along with & and #) are made active for url-breaking, so need
Chris@42 10045 % active definitions as the normal characters.
Chris@42 10046 @def@normaldot{.}
Chris@42 10047 @def@normalquest{?}
Chris@42 10048 @def@normalslash{/}
Chris@42 10049
Chris@42 10050 % These look ok in all fonts, so just make them not special.
Chris@42 10051 % @hashchar{} gets its own user-level command, because of #line.
Chris@42 10052 @catcode`@& = @other @def@normalamp{&}
Chris@42 10053 @catcode`@# = @other @def@normalhash{#}
Chris@42 10054 @catcode`@% = @other @def@normalpercent{%}
Chris@42 10055
Chris@42 10056 @let @hashchar = @normalhash
Chris@42 10057
Chris@42 10058 @c Finally, make ` and ' active, so that txicodequoteundirected and
Chris@42 10059 @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we
Chris@42 10060 @c don't make ` and ' active, @code will not get them as active chars.
Chris@42 10061 @c Do this last of all since we use ` in the previous @catcode assignments.
Chris@42 10062 @catcode`@'=@active
Chris@42 10063 @catcode`@`=@active
Chris@42 10064 @markupsetuplqdefault
Chris@42 10065 @markupsetuprqdefault
Chris@42 10066
Chris@42 10067 @c Local variables:
Chris@42 10068 @c eval: (add-hook 'write-file-hooks 'time-stamp)
Chris@42 10069 @c page-delimiter: "^\\\\message"
Chris@42 10070 @c time-stamp-start: "def\\\\texinfoversion{"
Chris@42 10071 @c time-stamp-format: "%:y-%02m-%02d.%02H"
Chris@42 10072 @c time-stamp-end: "}"
Chris@42 10073 @c End:
Chris@42 10074
Chris@42 10075 @c vim:sw=2:
Chris@42 10076
Chris@42 10077 @ignore
Chris@42 10078 arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
Chris@42 10079 @end ignore