annotate src/fftw-3.3.8/doc/texinfo.tex @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents bd3cc4d1df30
children
rev   line source
cannam@167 1 % texinfo.tex -- TeX macros to handle Texinfo files.
cannam@167 2 %
cannam@167 3 % Load plain if necessary, i.e., if running under initex.
cannam@167 4 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
cannam@167 5 %
cannam@167 6 \def\texinfoversion{2013-02-01.11}
cannam@167 7 %
cannam@167 8 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
cannam@167 9 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
cannam@167 10 % 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
cannam@167 11 %
cannam@167 12 % This texinfo.tex file is free software: you can redistribute it and/or
cannam@167 13 % modify it under the terms of the GNU General Public License as
cannam@167 14 % published by the Free Software Foundation, either version 3 of the
cannam@167 15 % License, or (at your option) any later version.
cannam@167 16 %
cannam@167 17 % This texinfo.tex file is distributed in the hope that it will be
cannam@167 18 % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
cannam@167 19 % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cannam@167 20 % General Public License for more details.
cannam@167 21 %
cannam@167 22 % You should have received a copy of the GNU General Public License
cannam@167 23 % along with this program. If not, see <http://www.gnu.org/licenses/>.
cannam@167 24 %
cannam@167 25 % As a special exception, when this file is read by TeX when processing
cannam@167 26 % a Texinfo source document, you may use the result without
cannam@167 27 % restriction. This Exception is an additional permission under section 7
cannam@167 28 % of the GNU General Public License, version 3 ("GPLv3").
cannam@167 29 %
cannam@167 30 % Please try the latest version of texinfo.tex before submitting bug
cannam@167 31 % reports; you can get the latest version from:
cannam@167 32 % http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
cannam@167 33 % http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
cannam@167 34 % http://www.gnu.org/software/texinfo/ (the Texinfo home page)
cannam@167 35 % The texinfo.tex in any given distribution could well be out
cannam@167 36 % of date, so if that's what you're using, please check.
cannam@167 37 %
cannam@167 38 % Send bug reports to bug-texinfo@gnu.org. Please include including a
cannam@167 39 % complete document in each bug report with which we can reproduce the
cannam@167 40 % problem. Patches are, of course, greatly appreciated.
cannam@167 41 %
cannam@167 42 % To process a Texinfo manual with TeX, it's most reliable to use the
cannam@167 43 % texi2dvi shell script that comes with the distribution. For a simple
cannam@167 44 % manual foo.texi, however, you can get away with this:
cannam@167 45 % tex foo.texi
cannam@167 46 % texindex foo.??
cannam@167 47 % tex foo.texi
cannam@167 48 % tex foo.texi
cannam@167 49 % dvips foo.dvi -o # or whatever; this makes foo.ps.
cannam@167 50 % The extra TeX runs get the cross-reference information correct.
cannam@167 51 % Sometimes one run after texindex suffices, and sometimes you need more
cannam@167 52 % than two; texi2dvi does it as many times as necessary.
cannam@167 53 %
cannam@167 54 % It is possible to adapt texinfo.tex for other languages, to some
cannam@167 55 % extent. You can get the existing language-specific files from the
cannam@167 56 % full Texinfo distribution.
cannam@167 57 %
cannam@167 58 % The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
cannam@167 59
cannam@167 60
cannam@167 61 \message{Loading texinfo [version \texinfoversion]:}
cannam@167 62
cannam@167 63 % If in a .fmt file, print the version number
cannam@167 64 % and turn on active characters that we couldn't do earlier because
cannam@167 65 % they might have appeared in the input file name.
cannam@167 66 \everyjob{\message{[Texinfo version \texinfoversion]}%
cannam@167 67 \catcode`+=\active \catcode`\_=\active}
cannam@167 68
cannam@167 69 \chardef\other=12
cannam@167 70
cannam@167 71 % We never want plain's \outer definition of \+ in Texinfo.
cannam@167 72 % For @tex, we can use \tabalign.
cannam@167 73 \let\+ = \relax
cannam@167 74
cannam@167 75 % Save some plain tex macros whose names we will redefine.
cannam@167 76 \let\ptexb=\b
cannam@167 77 \let\ptexbullet=\bullet
cannam@167 78 \let\ptexc=\c
cannam@167 79 \let\ptexcomma=\,
cannam@167 80 \let\ptexdot=\.
cannam@167 81 \let\ptexdots=\dots
cannam@167 82 \let\ptexend=\end
cannam@167 83 \let\ptexequiv=\equiv
cannam@167 84 \let\ptexexclam=\!
cannam@167 85 \let\ptexfootnote=\footnote
cannam@167 86 \let\ptexgtr=>
cannam@167 87 \let\ptexhat=^
cannam@167 88 \let\ptexi=\i
cannam@167 89 \let\ptexindent=\indent
cannam@167 90 \let\ptexinsert=\insert
cannam@167 91 \let\ptexlbrace=\{
cannam@167 92 \let\ptexless=<
cannam@167 93 \let\ptexnewwrite\newwrite
cannam@167 94 \let\ptexnoindent=\noindent
cannam@167 95 \let\ptexplus=+
cannam@167 96 \let\ptexraggedright=\raggedright
cannam@167 97 \let\ptexrbrace=\}
cannam@167 98 \let\ptexslash=\/
cannam@167 99 \let\ptexstar=\*
cannam@167 100 \let\ptext=\t
cannam@167 101 \let\ptextop=\top
cannam@167 102 {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
cannam@167 103
cannam@167 104 % If this character appears in an error message or help string, it
cannam@167 105 % starts a new line in the output.
cannam@167 106 \newlinechar = `^^J
cannam@167 107
cannam@167 108 % Use TeX 3.0's \inputlineno to get the line number, for better error
cannam@167 109 % messages, but if we're using an old version of TeX, don't do anything.
cannam@167 110 %
cannam@167 111 \ifx\inputlineno\thisisundefined
cannam@167 112 \let\linenumber = \empty % Pre-3.0.
cannam@167 113 \else
cannam@167 114 \def\linenumber{l.\the\inputlineno:\space}
cannam@167 115 \fi
cannam@167 116
cannam@167 117 % Set up fixed words for English if not already set.
cannam@167 118 \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
cannam@167 119 \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
cannam@167 120 \ifx\putworderror\undefined \gdef\putworderror{error}\fi
cannam@167 121 \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
cannam@167 122 \ifx\putwordin\undefined \gdef\putwordin{in}\fi
cannam@167 123 \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
cannam@167 124 \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
cannam@167 125 \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
cannam@167 126 \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
cannam@167 127 \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
cannam@167 128 \ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi
cannam@167 129 \ifx\putwordof\undefined \gdef\putwordof{of}\fi
cannam@167 130 \ifx\putwordon\undefined \gdef\putwordon{on}\fi
cannam@167 131 \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi
cannam@167 132 \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi
cannam@167 133 \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi
cannam@167 134 \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi
cannam@167 135 \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi
cannam@167 136 \ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi
cannam@167 137 \ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi
cannam@167 138 %
cannam@167 139 \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
cannam@167 140 \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
cannam@167 141 \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
cannam@167 142 \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
cannam@167 143 \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
cannam@167 144 \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
cannam@167 145 \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
cannam@167 146 \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
cannam@167 147 \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
cannam@167 148 \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
cannam@167 149 \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
cannam@167 150 \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
cannam@167 151 %
cannam@167 152 \ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi
cannam@167 153 \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi
cannam@167 154 \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi
cannam@167 155 \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi
cannam@167 156 \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi
cannam@167 157
cannam@167 158 % Since the category of space is not known, we have to be careful.
cannam@167 159 \chardef\spacecat = 10
cannam@167 160 \def\spaceisspace{\catcode`\ =\spacecat}
cannam@167 161
cannam@167 162 % sometimes characters are active, so we need control sequences.
cannam@167 163 \chardef\ampChar = `\&
cannam@167 164 \chardef\colonChar = `\:
cannam@167 165 \chardef\commaChar = `\,
cannam@167 166 \chardef\dashChar = `\-
cannam@167 167 \chardef\dotChar = `\.
cannam@167 168 \chardef\exclamChar= `\!
cannam@167 169 \chardef\hashChar = `\#
cannam@167 170 \chardef\lquoteChar= `\`
cannam@167 171 \chardef\questChar = `\?
cannam@167 172 \chardef\rquoteChar= `\'
cannam@167 173 \chardef\semiChar = `\;
cannam@167 174 \chardef\slashChar = `\/
cannam@167 175 \chardef\underChar = `\_
cannam@167 176
cannam@167 177 % Ignore a token.
cannam@167 178 %
cannam@167 179 \def\gobble#1{}
cannam@167 180
cannam@167 181 % The following is used inside several \edef's.
cannam@167 182 \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
cannam@167 183
cannam@167 184 % Hyphenation fixes.
cannam@167 185 \hyphenation{
cannam@167 186 Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
cannam@167 187 ap-pen-dix bit-map bit-maps
cannam@167 188 data-base data-bases eshell fall-ing half-way long-est man-u-script
cannam@167 189 man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
cannam@167 190 par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
cannam@167 191 spell-ing spell-ings
cannam@167 192 stand-alone strong-est time-stamp time-stamps which-ever white-space
cannam@167 193 wide-spread wrap-around
cannam@167 194 }
cannam@167 195
cannam@167 196 % Margin to add to right of even pages, to left of odd pages.
cannam@167 197 \newdimen\bindingoffset
cannam@167 198 \newdimen\normaloffset
cannam@167 199 \newdimen\pagewidth \newdimen\pageheight
cannam@167 200
cannam@167 201 % For a final copy, take out the rectangles
cannam@167 202 % that mark overfull boxes (in case you have decided
cannam@167 203 % that the text looks ok even though it passes the margin).
cannam@167 204 %
cannam@167 205 \def\finalout{\overfullrule=0pt }
cannam@167 206
cannam@167 207 % Sometimes it is convenient to have everything in the transcript file
cannam@167 208 % and nothing on the terminal. We don't just call \tracingall here,
cannam@167 209 % since that produces some useless output on the terminal. We also make
cannam@167 210 % some effort to order the tracing commands to reduce output in the log
cannam@167 211 % file; cf. trace.sty in LaTeX.
cannam@167 212 %
cannam@167 213 \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
cannam@167 214 \def\loggingall{%
cannam@167 215 \tracingstats2
cannam@167 216 \tracingpages1
cannam@167 217 \tracinglostchars2 % 2 gives us more in etex
cannam@167 218 \tracingparagraphs1
cannam@167 219 \tracingoutput1
cannam@167 220 \tracingmacros2
cannam@167 221 \tracingrestores1
cannam@167 222 \showboxbreadth\maxdimen \showboxdepth\maxdimen
cannam@167 223 \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
cannam@167 224 \tracingscantokens1
cannam@167 225 \tracingifs1
cannam@167 226 \tracinggroups1
cannam@167 227 \tracingnesting2
cannam@167 228 \tracingassigns1
cannam@167 229 \fi
cannam@167 230 \tracingcommands3 % 3 gives us more in etex
cannam@167 231 \errorcontextlines16
cannam@167 232 }%
cannam@167 233
cannam@167 234 % @errormsg{MSG}. Do the index-like expansions on MSG, but if things
cannam@167 235 % aren't perfect, it's not the end of the world, being an error message,
cannam@167 236 % after all.
cannam@167 237 %
cannam@167 238 \def\errormsg{\begingroup \indexnofonts \doerrormsg}
cannam@167 239 \def\doerrormsg#1{\errmessage{#1}}
cannam@167 240
cannam@167 241 % add check for \lastpenalty to plain's definitions. If the last thing
cannam@167 242 % we did was a \nobreak, we don't want to insert more space.
cannam@167 243 %
cannam@167 244 \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
cannam@167 245 \removelastskip\penalty-50\smallskip\fi\fi}
cannam@167 246 \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
cannam@167 247 \removelastskip\penalty-100\medskip\fi\fi}
cannam@167 248 \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
cannam@167 249 \removelastskip\penalty-200\bigskip\fi\fi}
cannam@167 250
cannam@167 251 % Do @cropmarks to get crop marks.
cannam@167 252 %
cannam@167 253 \newif\ifcropmarks
cannam@167 254 \let\cropmarks = \cropmarkstrue
cannam@167 255 %
cannam@167 256 % Dimensions to add cropmarks at corners.
cannam@167 257 % Added by P. A. MacKay, 12 Nov. 1986
cannam@167 258 %
cannam@167 259 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
cannam@167 260 \newdimen\cornerlong \cornerlong=1pc
cannam@167 261 \newdimen\cornerthick \cornerthick=.3pt
cannam@167 262 \newdimen\topandbottommargin \topandbottommargin=.75in
cannam@167 263
cannam@167 264 % Output a mark which sets \thischapter, \thissection and \thiscolor.
cannam@167 265 % We dump everything together because we only have one kind of mark.
cannam@167 266 % This works because we only use \botmark / \topmark, not \firstmark.
cannam@167 267 %
cannam@167 268 % A mark contains a subexpression of the \ifcase ... \fi construct.
cannam@167 269 % \get*marks macros below extract the needed part using \ifcase.
cannam@167 270 %
cannam@167 271 % Another complication is to let the user choose whether \thischapter
cannam@167 272 % (\thissection) refers to the chapter (section) in effect at the top
cannam@167 273 % of a page, or that at the bottom of a page. The solution is
cannam@167 274 % described on page 260 of The TeXbook. It involves outputting two
cannam@167 275 % marks for the sectioning macros, one before the section break, and
cannam@167 276 % one after. I won't pretend I can describe this better than DEK...
cannam@167 277 \def\domark{%
cannam@167 278 \toks0=\expandafter{\lastchapterdefs}%
cannam@167 279 \toks2=\expandafter{\lastsectiondefs}%
cannam@167 280 \toks4=\expandafter{\prevchapterdefs}%
cannam@167 281 \toks6=\expandafter{\prevsectiondefs}%
cannam@167 282 \toks8=\expandafter{\lastcolordefs}%
cannam@167 283 \mark{%
cannam@167 284 \the\toks0 \the\toks2
cannam@167 285 \noexpand\or \the\toks4 \the\toks6
cannam@167 286 \noexpand\else \the\toks8
cannam@167 287 }%
cannam@167 288 }
cannam@167 289 % \topmark doesn't work for the very first chapter (after the title
cannam@167 290 % page or the contents), so we use \firstmark there -- this gets us
cannam@167 291 % the mark with the chapter defs, unless the user sneaks in, e.g.,
cannam@167 292 % @setcolor (or @url, or @link, etc.) between @contents and the very
cannam@167 293 % first @chapter.
cannam@167 294 \def\gettopheadingmarks{%
cannam@167 295 \ifcase0\topmark\fi
cannam@167 296 \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
cannam@167 297 }
cannam@167 298 \def\getbottomheadingmarks{\ifcase1\botmark\fi}
cannam@167 299 \def\getcolormarks{\ifcase2\topmark\fi}
cannam@167 300
cannam@167 301 % Avoid "undefined control sequence" errors.
cannam@167 302 \def\lastchapterdefs{}
cannam@167 303 \def\lastsectiondefs{}
cannam@167 304 \def\prevchapterdefs{}
cannam@167 305 \def\prevsectiondefs{}
cannam@167 306 \def\lastcolordefs{}
cannam@167 307
cannam@167 308 % Main output routine.
cannam@167 309 \chardef\PAGE = 255
cannam@167 310 \output = {\onepageout{\pagecontents\PAGE}}
cannam@167 311
cannam@167 312 \newbox\headlinebox
cannam@167 313 \newbox\footlinebox
cannam@167 314
cannam@167 315 % \onepageout takes a vbox as an argument. Note that \pagecontents
cannam@167 316 % does insertions, but you have to call it yourself.
cannam@167 317 \def\onepageout#1{%
cannam@167 318 \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
cannam@167 319 %
cannam@167 320 \ifodd\pageno \advance\hoffset by \bindingoffset
cannam@167 321 \else \advance\hoffset by -\bindingoffset\fi
cannam@167 322 %
cannam@167 323 % Do this outside of the \shipout so @code etc. will be expanded in
cannam@167 324 % the headline as they should be, not taken literally (outputting ''code).
cannam@167 325 \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
cannam@167 326 \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
cannam@167 327 \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
cannam@167 328 \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
cannam@167 329 %
cannam@167 330 {%
cannam@167 331 % Have to do this stuff outside the \shipout because we want it to
cannam@167 332 % take effect in \write's, yet the group defined by the \vbox ends
cannam@167 333 % before the \shipout runs.
cannam@167 334 %
cannam@167 335 \indexdummies % don't expand commands in the output.
cannam@167 336 \normalturnoffactive % \ in index entries must not stay \, e.g., if
cannam@167 337 % the page break happens to be in the middle of an example.
cannam@167 338 % We don't want .vr (or whatever) entries like this:
cannam@167 339 % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
cannam@167 340 % "\acronym" won't work when it's read back in;
cannam@167 341 % it needs to be
cannam@167 342 % {\code {{\tt \backslashcurfont }acronym}
cannam@167 343 \shipout\vbox{%
cannam@167 344 % Do this early so pdf references go to the beginning of the page.
cannam@167 345 \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
cannam@167 346 %
cannam@167 347 \ifcropmarks \vbox to \outervsize\bgroup
cannam@167 348 \hsize = \outerhsize
cannam@167 349 \vskip-\topandbottommargin
cannam@167 350 \vtop to0pt{%
cannam@167 351 \line{\ewtop\hfil\ewtop}%
cannam@167 352 \nointerlineskip
cannam@167 353 \line{%
cannam@167 354 \vbox{\moveleft\cornerthick\nstop}%
cannam@167 355 \hfill
cannam@167 356 \vbox{\moveright\cornerthick\nstop}%
cannam@167 357 }%
cannam@167 358 \vss}%
cannam@167 359 \vskip\topandbottommargin
cannam@167 360 \line\bgroup
cannam@167 361 \hfil % center the page within the outer (page) hsize.
cannam@167 362 \ifodd\pageno\hskip\bindingoffset\fi
cannam@167 363 \vbox\bgroup
cannam@167 364 \fi
cannam@167 365 %
cannam@167 366 \unvbox\headlinebox
cannam@167 367 \pagebody{#1}%
cannam@167 368 \ifdim\ht\footlinebox > 0pt
cannam@167 369 % Only leave this space if the footline is nonempty.
cannam@167 370 % (We lessened \vsize for it in \oddfootingyyy.)
cannam@167 371 % The \baselineskip=24pt in plain's \makefootline has no effect.
cannam@167 372 \vskip 24pt
cannam@167 373 \unvbox\footlinebox
cannam@167 374 \fi
cannam@167 375 %
cannam@167 376 \ifcropmarks
cannam@167 377 \egroup % end of \vbox\bgroup
cannam@167 378 \hfil\egroup % end of (centering) \line\bgroup
cannam@167 379 \vskip\topandbottommargin plus1fill minus1fill
cannam@167 380 \boxmaxdepth = \cornerthick
cannam@167 381 \vbox to0pt{\vss
cannam@167 382 \line{%
cannam@167 383 \vbox{\moveleft\cornerthick\nsbot}%
cannam@167 384 \hfill
cannam@167 385 \vbox{\moveright\cornerthick\nsbot}%
cannam@167 386 }%
cannam@167 387 \nointerlineskip
cannam@167 388 \line{\ewbot\hfil\ewbot}%
cannam@167 389 }%
cannam@167 390 \egroup % \vbox from first cropmarks clause
cannam@167 391 \fi
cannam@167 392 }% end of \shipout\vbox
cannam@167 393 }% end of group with \indexdummies
cannam@167 394 \advancepageno
cannam@167 395 \ifnum\outputpenalty>-20000 \else\dosupereject\fi
cannam@167 396 }
cannam@167 397
cannam@167 398 \newinsert\margin \dimen\margin=\maxdimen
cannam@167 399
cannam@167 400 \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
cannam@167 401 {\catcode`\@ =11
cannam@167 402 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
cannam@167 403 % marginal hacks, juha@viisa.uucp (Juha Takala)
cannam@167 404 \ifvoid\margin\else % marginal info is present
cannam@167 405 \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
cannam@167 406 \dimen@=\dp#1\relax \unvbox#1\relax
cannam@167 407 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
cannam@167 408 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
cannam@167 409 }
cannam@167 410
cannam@167 411 % Here are the rules for the cropmarks. Note that they are
cannam@167 412 % offset so that the space between them is truly \outerhsize or \outervsize
cannam@167 413 % (P. A. MacKay, 12 November, 1986)
cannam@167 414 %
cannam@167 415 \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
cannam@167 416 \def\nstop{\vbox
cannam@167 417 {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
cannam@167 418 \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
cannam@167 419 \def\nsbot{\vbox
cannam@167 420 {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
cannam@167 421
cannam@167 422 % Parse an argument, then pass it to #1. The argument is the rest of
cannam@167 423 % the input line (except we remove a trailing comment). #1 should be a
cannam@167 424 % macro which expects an ordinary undelimited TeX argument.
cannam@167 425 %
cannam@167 426 \def\parsearg{\parseargusing{}}
cannam@167 427 \def\parseargusing#1#2{%
cannam@167 428 \def\argtorun{#2}%
cannam@167 429 \begingroup
cannam@167 430 \obeylines
cannam@167 431 \spaceisspace
cannam@167 432 #1%
cannam@167 433 \parseargline\empty% Insert the \empty token, see \finishparsearg below.
cannam@167 434 }
cannam@167 435
cannam@167 436 {\obeylines %
cannam@167 437 \gdef\parseargline#1^^M{%
cannam@167 438 \endgroup % End of the group started in \parsearg.
cannam@167 439 \argremovecomment #1\comment\ArgTerm%
cannam@167 440 }%
cannam@167 441 }
cannam@167 442
cannam@167 443 % First remove any @comment, then any @c comment.
cannam@167 444 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
cannam@167 445 \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
cannam@167 446
cannam@167 447 % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
cannam@167 448 %
cannam@167 449 % \argremovec might leave us with trailing space, e.g.,
cannam@167 450 % @end itemize @c foo
cannam@167 451 % This space token undergoes the same procedure and is eventually removed
cannam@167 452 % by \finishparsearg.
cannam@167 453 %
cannam@167 454 \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
cannam@167 455 \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
cannam@167 456 \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
cannam@167 457 \def\temp{#3}%
cannam@167 458 \ifx\temp\empty
cannam@167 459 % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
cannam@167 460 \let\temp\finishparsearg
cannam@167 461 \else
cannam@167 462 \let\temp\argcheckspaces
cannam@167 463 \fi
cannam@167 464 % Put the space token in:
cannam@167 465 \temp#1 #3\ArgTerm
cannam@167 466 }
cannam@167 467
cannam@167 468 % If a _delimited_ argument is enclosed in braces, they get stripped; so
cannam@167 469 % to get _exactly_ the rest of the line, we had to prevent such situation.
cannam@167 470 % We prepended an \empty token at the very beginning and we expand it now,
cannam@167 471 % just before passing the control to \argtorun.
cannam@167 472 % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
cannam@167 473 % either the null string, or it ends with \^^M---thus there is no danger
cannam@167 474 % that a pair of braces would be stripped.
cannam@167 475 %
cannam@167 476 % But first, we have to remove the trailing space token.
cannam@167 477 %
cannam@167 478 \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
cannam@167 479
cannam@167 480 % \parseargdef\foo{...}
cannam@167 481 % is roughly equivalent to
cannam@167 482 % \def\foo{\parsearg\Xfoo}
cannam@167 483 % \def\Xfoo#1{...}
cannam@167 484 %
cannam@167 485 % Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
cannam@167 486 % favourite TeX trick. --kasal, 16nov03
cannam@167 487
cannam@167 488 \def\parseargdef#1{%
cannam@167 489 \expandafter \doparseargdef \csname\string#1\endcsname #1%
cannam@167 490 }
cannam@167 491 \def\doparseargdef#1#2{%
cannam@167 492 \def#2{\parsearg#1}%
cannam@167 493 \def#1##1%
cannam@167 494 }
cannam@167 495
cannam@167 496 % Several utility definitions with active space:
cannam@167 497 {
cannam@167 498 \obeyspaces
cannam@167 499 \gdef\obeyedspace{ }
cannam@167 500
cannam@167 501 % Make each space character in the input produce a normal interword
cannam@167 502 % space in the output. Don't allow a line break at this space, as this
cannam@167 503 % is used only in environments like @example, where each line of input
cannam@167 504 % should produce a line of output anyway.
cannam@167 505 %
cannam@167 506 \gdef\sepspaces{\obeyspaces\let =\tie}
cannam@167 507
cannam@167 508 % If an index command is used in an @example environment, any spaces
cannam@167 509 % therein should become regular spaces in the raw index file, not the
cannam@167 510 % expansion of \tie (\leavevmode \penalty \@M \ ).
cannam@167 511 \gdef\unsepspaces{\let =\space}
cannam@167 512 }
cannam@167 513
cannam@167 514
cannam@167 515 \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
cannam@167 516
cannam@167 517 % Define the framework for environments in texinfo.tex. It's used like this:
cannam@167 518 %
cannam@167 519 % \envdef\foo{...}
cannam@167 520 % \def\Efoo{...}
cannam@167 521 %
cannam@167 522 % It's the responsibility of \envdef to insert \begingroup before the
cannam@167 523 % actual body; @end closes the group after calling \Efoo. \envdef also
cannam@167 524 % defines \thisenv, so the current environment is known; @end checks
cannam@167 525 % whether the environment name matches. The \checkenv macro can also be
cannam@167 526 % used to check whether the current environment is the one expected.
cannam@167 527 %
cannam@167 528 % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
cannam@167 529 % are not treated as environments; they don't open a group. (The
cannam@167 530 % implementation of @end takes care not to call \endgroup in this
cannam@167 531 % special case.)
cannam@167 532
cannam@167 533
cannam@167 534 % At run-time, environments start with this:
cannam@167 535 \def\startenvironment#1{\begingroup\def\thisenv{#1}}
cannam@167 536 % initialize
cannam@167 537 \let\thisenv\empty
cannam@167 538
cannam@167 539 % ... but they get defined via ``\envdef\foo{...}'':
cannam@167 540 \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
cannam@167 541 \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
cannam@167 542
cannam@167 543 % Check whether we're in the right environment:
cannam@167 544 \def\checkenv#1{%
cannam@167 545 \def\temp{#1}%
cannam@167 546 \ifx\thisenv\temp
cannam@167 547 \else
cannam@167 548 \badenverr
cannam@167 549 \fi
cannam@167 550 }
cannam@167 551
cannam@167 552 % Environment mismatch, #1 expected:
cannam@167 553 \def\badenverr{%
cannam@167 554 \errhelp = \EMsimple
cannam@167 555 \errmessage{This command can appear only \inenvironment\temp,
cannam@167 556 not \inenvironment\thisenv}%
cannam@167 557 }
cannam@167 558 \def\inenvironment#1{%
cannam@167 559 \ifx#1\empty
cannam@167 560 outside of any environment%
cannam@167 561 \else
cannam@167 562 in environment \expandafter\string#1%
cannam@167 563 \fi
cannam@167 564 }
cannam@167 565
cannam@167 566 % @end foo executes the definition of \Efoo.
cannam@167 567 % But first, it executes a specialized version of \checkenv
cannam@167 568 %
cannam@167 569 \parseargdef\end{%
cannam@167 570 \if 1\csname iscond.#1\endcsname
cannam@167 571 \else
cannam@167 572 % The general wording of \badenverr may not be ideal.
cannam@167 573 \expandafter\checkenv\csname#1\endcsname
cannam@167 574 \csname E#1\endcsname
cannam@167 575 \endgroup
cannam@167 576 \fi
cannam@167 577 }
cannam@167 578
cannam@167 579 \newhelp\EMsimple{Press RETURN to continue.}
cannam@167 580
cannam@167 581
cannam@167 582 % Be sure we're in horizontal mode when doing a tie, since we make space
cannam@167 583 % equivalent to this in @example-like environments. Otherwise, a space
cannam@167 584 % at the beginning of a line will start with \penalty -- and
cannam@167 585 % since \penalty is valid in vertical mode, we'd end up putting the
cannam@167 586 % penalty on the vertical list instead of in the new paragraph.
cannam@167 587 {\catcode`@ = 11
cannam@167 588 % Avoid using \@M directly, because that causes trouble
cannam@167 589 % if the definition is written into an index file.
cannam@167 590 \global\let\tiepenalty = \@M
cannam@167 591 \gdef\tie{\leavevmode\penalty\tiepenalty\ }
cannam@167 592 }
cannam@167 593
cannam@167 594 % @: forces normal size whitespace following.
cannam@167 595 \def\:{\spacefactor=1000 }
cannam@167 596
cannam@167 597 % @* forces a line break.
cannam@167 598 \def\*{\unskip\hfil\break\hbox{}\ignorespaces}
cannam@167 599
cannam@167 600 % @/ allows a line break.
cannam@167 601 \let\/=\allowbreak
cannam@167 602
cannam@167 603 % @. is an end-of-sentence period.
cannam@167 604 \def\.{.\spacefactor=\endofsentencespacefactor\space}
cannam@167 605
cannam@167 606 % @! is an end-of-sentence bang.
cannam@167 607 \def\!{!\spacefactor=\endofsentencespacefactor\space}
cannam@167 608
cannam@167 609 % @? is an end-of-sentence query.
cannam@167 610 \def\?{?\spacefactor=\endofsentencespacefactor\space}
cannam@167 611
cannam@167 612 % @frenchspacing on|off says whether to put extra space after punctuation.
cannam@167 613 %
cannam@167 614 \def\onword{on}
cannam@167 615 \def\offword{off}
cannam@167 616 %
cannam@167 617 \parseargdef\frenchspacing{%
cannam@167 618 \def\temp{#1}%
cannam@167 619 \ifx\temp\onword \plainfrenchspacing
cannam@167 620 \else\ifx\temp\offword \plainnonfrenchspacing
cannam@167 621 \else
cannam@167 622 \errhelp = \EMsimple
cannam@167 623 \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
cannam@167 624 \fi\fi
cannam@167 625 }
cannam@167 626
cannam@167 627 % @w prevents a word break. Without the \leavevmode, @w at the
cannam@167 628 % beginning of a paragraph, when TeX is still in vertical mode, would
cannam@167 629 % produce a whole line of output instead of starting the paragraph.
cannam@167 630 \def\w#1{\leavevmode\hbox{#1}}
cannam@167 631
cannam@167 632 % @group ... @end group forces ... to be all on one page, by enclosing
cannam@167 633 % it in a TeX vbox. We use \vtop instead of \vbox to construct the box
cannam@167 634 % to keep its height that of a normal line. According to the rules for
cannam@167 635 % \topskip (p.114 of the TeXbook), the glue inserted is
cannam@167 636 % max (\topskip - \ht (first item), 0). If that height is large,
cannam@167 637 % therefore, no glue is inserted, and the space between the headline and
cannam@167 638 % the text is small, which looks bad.
cannam@167 639 %
cannam@167 640 % Another complication is that the group might be very large. This can
cannam@167 641 % cause the glue on the previous page to be unduly stretched, because it
cannam@167 642 % does not have much material. In this case, it's better to add an
cannam@167 643 % explicit \vfill so that the extra space is at the bottom. The
cannam@167 644 % threshold for doing this is if the group is more than \vfilllimit
cannam@167 645 % percent of a page (\vfilllimit can be changed inside of @tex).
cannam@167 646 %
cannam@167 647 \newbox\groupbox
cannam@167 648 \def\vfilllimit{0.7}
cannam@167 649 %
cannam@167 650 \envdef\group{%
cannam@167 651 \ifnum\catcode`\^^M=\active \else
cannam@167 652 \errhelp = \groupinvalidhelp
cannam@167 653 \errmessage{@group invalid in context where filling is enabled}%
cannam@167 654 \fi
cannam@167 655 \startsavinginserts
cannam@167 656 %
cannam@167 657 \setbox\groupbox = \vtop\bgroup
cannam@167 658 % Do @comment since we are called inside an environment such as
cannam@167 659 % @example, where each end-of-line in the input causes an
cannam@167 660 % end-of-line in the output. We don't want the end-of-line after
cannam@167 661 % the `@group' to put extra space in the output. Since @group
cannam@167 662 % should appear on a line by itself (according to the Texinfo
cannam@167 663 % manual), we don't worry about eating any user text.
cannam@167 664 \comment
cannam@167 665 }
cannam@167 666 %
cannam@167 667 % The \vtop produces a box with normal height and large depth; thus, TeX puts
cannam@167 668 % \baselineskip glue before it, and (when the next line of text is done)
cannam@167 669 % \lineskip glue after it. Thus, space below is not quite equal to space
cannam@167 670 % above. But it's pretty close.
cannam@167 671 \def\Egroup{%
cannam@167 672 % To get correct interline space between the last line of the group
cannam@167 673 % and the first line afterwards, we have to propagate \prevdepth.
cannam@167 674 \endgraf % Not \par, as it may have been set to \lisppar.
cannam@167 675 \global\dimen1 = \prevdepth
cannam@167 676 \egroup % End the \vtop.
cannam@167 677 % \dimen0 is the vertical size of the group's box.
cannam@167 678 \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox
cannam@167 679 % \dimen2 is how much space is left on the page (more or less).
cannam@167 680 \dimen2 = \pageheight \advance\dimen2 by -\pagetotal
cannam@167 681 % if the group doesn't fit on the current page, and it's a big big
cannam@167 682 % group, force a page break.
cannam@167 683 \ifdim \dimen0 > \dimen2
cannam@167 684 \ifdim \pagetotal < \vfilllimit\pageheight
cannam@167 685 \page
cannam@167 686 \fi
cannam@167 687 \fi
cannam@167 688 \box\groupbox
cannam@167 689 \prevdepth = \dimen1
cannam@167 690 \checkinserts
cannam@167 691 }
cannam@167 692 %
cannam@167 693 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
cannam@167 694 % message, so this ends up printing `@group can only ...'.
cannam@167 695 %
cannam@167 696 \newhelp\groupinvalidhelp{%
cannam@167 697 group can only be used in environments such as @example,^^J%
cannam@167 698 where each line of input produces a line of output.}
cannam@167 699
cannam@167 700 % @need space-in-mils
cannam@167 701 % forces a page break if there is not space-in-mils remaining.
cannam@167 702
cannam@167 703 \newdimen\mil \mil=0.001in
cannam@167 704
cannam@167 705 \parseargdef\need{%
cannam@167 706 % Ensure vertical mode, so we don't make a big box in the middle of a
cannam@167 707 % paragraph.
cannam@167 708 \par
cannam@167 709 %
cannam@167 710 % If the @need value is less than one line space, it's useless.
cannam@167 711 \dimen0 = #1\mil
cannam@167 712 \dimen2 = \ht\strutbox
cannam@167 713 \advance\dimen2 by \dp\strutbox
cannam@167 714 \ifdim\dimen0 > \dimen2
cannam@167 715 %
cannam@167 716 % Do a \strut just to make the height of this box be normal, so the
cannam@167 717 % normal leading is inserted relative to the preceding line.
cannam@167 718 % And a page break here is fine.
cannam@167 719 \vtop to #1\mil{\strut\vfil}%
cannam@167 720 %
cannam@167 721 % TeX does not even consider page breaks if a penalty added to the
cannam@167 722 % main vertical list is 10000 or more. But in order to see if the
cannam@167 723 % empty box we just added fits on the page, we must make it consider
cannam@167 724 % page breaks. On the other hand, we don't want to actually break the
cannam@167 725 % page after the empty box. So we use a penalty of 9999.
cannam@167 726 %
cannam@167 727 % There is an extremely small chance that TeX will actually break the
cannam@167 728 % page at this \penalty, if there are no other feasible breakpoints in
cannam@167 729 % sight. (If the user is using lots of big @group commands, which
cannam@167 730 % almost-but-not-quite fill up a page, TeX will have a hard time doing
cannam@167 731 % good page breaking, for example.) However, I could not construct an
cannam@167 732 % example where a page broke at this \penalty; if it happens in a real
cannam@167 733 % document, then we can reconsider our strategy.
cannam@167 734 \penalty9999
cannam@167 735 %
cannam@167 736 % Back up by the size of the box, whether we did a page break or not.
cannam@167 737 \kern -#1\mil
cannam@167 738 %
cannam@167 739 % Do not allow a page break right after this kern.
cannam@167 740 \nobreak
cannam@167 741 \fi
cannam@167 742 }
cannam@167 743
cannam@167 744 % @br forces paragraph break (and is undocumented).
cannam@167 745
cannam@167 746 \let\br = \par
cannam@167 747
cannam@167 748 % @page forces the start of a new page.
cannam@167 749 %
cannam@167 750 \def\page{\par\vfill\supereject}
cannam@167 751
cannam@167 752 % @exdent text....
cannam@167 753 % outputs text on separate line in roman font, starting at standard page margin
cannam@167 754
cannam@167 755 % This records the amount of indent in the innermost environment.
cannam@167 756 % That's how much \exdent should take out.
cannam@167 757 \newskip\exdentamount
cannam@167 758
cannam@167 759 % This defn is used inside fill environments such as @defun.
cannam@167 760 \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
cannam@167 761
cannam@167 762 % This defn is used inside nofill environments such as @example.
cannam@167 763 \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
cannam@167 764 \leftline{\hskip\leftskip{\rm#1}}}}
cannam@167 765
cannam@167 766 % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
cannam@167 767 % paragraph. For more general purposes, use the \margin insertion
cannam@167 768 % class. WHICH is `l' or `r'. Not documented, written for gawk manual.
cannam@167 769 %
cannam@167 770 \newskip\inmarginspacing \inmarginspacing=1cm
cannam@167 771 \def\strutdepth{\dp\strutbox}
cannam@167 772 %
cannam@167 773 \def\doinmargin#1#2{\strut\vadjust{%
cannam@167 774 \nobreak
cannam@167 775 \kern-\strutdepth
cannam@167 776 \vtop to \strutdepth{%
cannam@167 777 \baselineskip=\strutdepth
cannam@167 778 \vss
cannam@167 779 % if you have multiple lines of stuff to put here, you'll need to
cannam@167 780 % make the vbox yourself of the appropriate size.
cannam@167 781 \ifx#1l%
cannam@167 782 \llap{\ignorespaces #2\hskip\inmarginspacing}%
cannam@167 783 \else
cannam@167 784 \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
cannam@167 785 \fi
cannam@167 786 \null
cannam@167 787 }%
cannam@167 788 }}
cannam@167 789 \def\inleftmargin{\doinmargin l}
cannam@167 790 \def\inrightmargin{\doinmargin r}
cannam@167 791 %
cannam@167 792 % @inmargin{TEXT [, RIGHT-TEXT]}
cannam@167 793 % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
cannam@167 794 % else use TEXT for both).
cannam@167 795 %
cannam@167 796 \def\inmargin#1{\parseinmargin #1,,\finish}
cannam@167 797 \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
cannam@167 798 \setbox0 = \hbox{\ignorespaces #2}%
cannam@167 799 \ifdim\wd0 > 0pt
cannam@167 800 \def\lefttext{#1}% have both texts
cannam@167 801 \def\righttext{#2}%
cannam@167 802 \else
cannam@167 803 \def\lefttext{#1}% have only one text
cannam@167 804 \def\righttext{#1}%
cannam@167 805 \fi
cannam@167 806 %
cannam@167 807 \ifodd\pageno
cannam@167 808 \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
cannam@167 809 \else
cannam@167 810 \def\temp{\inleftmargin\lefttext}%
cannam@167 811 \fi
cannam@167 812 \temp
cannam@167 813 }
cannam@167 814
cannam@167 815 % @| inserts a changebar to the left of the current line. It should
cannam@167 816 % surround any changed text. This approach does *not* work if the
cannam@167 817 % change spans more than two lines of output. To handle that, we would
cannam@167 818 % have adopt a much more difficult approach (putting marks into the main
cannam@167 819 % vertical list for the beginning and end of each change). This command
cannam@167 820 % is not documented, not supported, and doesn't work.
cannam@167 821 %
cannam@167 822 \def\|{%
cannam@167 823 % \vadjust can only be used in horizontal mode.
cannam@167 824 \leavevmode
cannam@167 825 %
cannam@167 826 % Append this vertical mode material after the current line in the output.
cannam@167 827 \vadjust{%
cannam@167 828 % We want to insert a rule with the height and depth of the current
cannam@167 829 % leading; that is exactly what \strutbox is supposed to record.
cannam@167 830 \vskip-\baselineskip
cannam@167 831 %
cannam@167 832 % \vadjust-items are inserted at the left edge of the type. So
cannam@167 833 % the \llap here moves out into the left-hand margin.
cannam@167 834 \llap{%
cannam@167 835 %
cannam@167 836 % For a thicker or thinner bar, change the `1pt'.
cannam@167 837 \vrule height\baselineskip width1pt
cannam@167 838 %
cannam@167 839 % This is the space between the bar and the text.
cannam@167 840 \hskip 12pt
cannam@167 841 }%
cannam@167 842 }%
cannam@167 843 }
cannam@167 844
cannam@167 845 % @include FILE -- \input text of FILE.
cannam@167 846 %
cannam@167 847 \def\include{\parseargusing\filenamecatcodes\includezzz}
cannam@167 848 \def\includezzz#1{%
cannam@167 849 \pushthisfilestack
cannam@167 850 \def\thisfile{#1}%
cannam@167 851 {%
cannam@167 852 \makevalueexpandable % we want to expand any @value in FILE.
cannam@167 853 \turnoffactive % and allow special characters in the expansion
cannam@167 854 \indexnofonts % Allow `@@' and other weird things in file names.
cannam@167 855 \wlog{texinfo.tex: doing @include of #1^^J}%
cannam@167 856 \edef\temp{\noexpand\input #1 }%
cannam@167 857 %
cannam@167 858 % This trickery is to read FILE outside of a group, in case it makes
cannam@167 859 % definitions, etc.
cannam@167 860 \expandafter
cannam@167 861 }\temp
cannam@167 862 \popthisfilestack
cannam@167 863 }
cannam@167 864 \def\filenamecatcodes{%
cannam@167 865 \catcode`\\=\other
cannam@167 866 \catcode`~=\other
cannam@167 867 \catcode`^=\other
cannam@167 868 \catcode`_=\other
cannam@167 869 \catcode`|=\other
cannam@167 870 \catcode`<=\other
cannam@167 871 \catcode`>=\other
cannam@167 872 \catcode`+=\other
cannam@167 873 \catcode`-=\other
cannam@167 874 \catcode`\`=\other
cannam@167 875 \catcode`\'=\other
cannam@167 876 }
cannam@167 877
cannam@167 878 \def\pushthisfilestack{%
cannam@167 879 \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
cannam@167 880 }
cannam@167 881 \def\pushthisfilestackX{%
cannam@167 882 \expandafter\pushthisfilestackY\thisfile\StackTerm
cannam@167 883 }
cannam@167 884 \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
cannam@167 885 \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
cannam@167 886 }
cannam@167 887
cannam@167 888 \def\popthisfilestack{\errthisfilestackempty}
cannam@167 889 \def\errthisfilestackempty{\errmessage{Internal error:
cannam@167 890 the stack of filenames is empty.}}
cannam@167 891 %
cannam@167 892 \def\thisfile{}
cannam@167 893
cannam@167 894 % @center line
cannam@167 895 % outputs that line, centered.
cannam@167 896 %
cannam@167 897 \parseargdef\center{%
cannam@167 898 \ifhmode
cannam@167 899 \let\centersub\centerH
cannam@167 900 \else
cannam@167 901 \let\centersub\centerV
cannam@167 902 \fi
cannam@167 903 \centersub{\hfil \ignorespaces#1\unskip \hfil}%
cannam@167 904 \let\centersub\relax % don't let the definition persist, just in case
cannam@167 905 }
cannam@167 906 \def\centerH#1{{%
cannam@167 907 \hfil\break
cannam@167 908 \advance\hsize by -\leftskip
cannam@167 909 \advance\hsize by -\rightskip
cannam@167 910 \line{#1}%
cannam@167 911 \break
cannam@167 912 }}
cannam@167 913 %
cannam@167 914 \newcount\centerpenalty
cannam@167 915 \def\centerV#1{%
cannam@167 916 % The idea here is the same as in \startdefun, \cartouche, etc.: if
cannam@167 917 % @center is the first thing after a section heading, we need to wipe
cannam@167 918 % out the negative parskip inserted by \sectionheading, but still
cannam@167 919 % prevent a page break here.
cannam@167 920 \centerpenalty = \lastpenalty
cannam@167 921 \ifnum\centerpenalty>10000 \vskip\parskip \fi
cannam@167 922 \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
cannam@167 923 \line{\kern\leftskip #1\kern\rightskip}%
cannam@167 924 }
cannam@167 925
cannam@167 926 % @sp n outputs n lines of vertical space
cannam@167 927 %
cannam@167 928 \parseargdef\sp{\vskip #1\baselineskip}
cannam@167 929
cannam@167 930 % @comment ...line which is ignored...
cannam@167 931 % @c is the same as @comment
cannam@167 932 % @ignore ... @end ignore is another way to write a comment
cannam@167 933 %
cannam@167 934 \def\comment{\begingroup \catcode`\^^M=\other%
cannam@167 935 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
cannam@167 936 \commentxxx}
cannam@167 937 {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
cannam@167 938 %
cannam@167 939 \let\c=\comment
cannam@167 940
cannam@167 941 % @paragraphindent NCHARS
cannam@167 942 % We'll use ems for NCHARS, close enough.
cannam@167 943 % NCHARS can also be the word `asis' or `none'.
cannam@167 944 % We cannot feasibly implement @paragraphindent asis, though.
cannam@167 945 %
cannam@167 946 \def\asisword{asis} % no translation, these are keywords
cannam@167 947 \def\noneword{none}
cannam@167 948 %
cannam@167 949 \parseargdef\paragraphindent{%
cannam@167 950 \def\temp{#1}%
cannam@167 951 \ifx\temp\asisword
cannam@167 952 \else
cannam@167 953 \ifx\temp\noneword
cannam@167 954 \defaultparindent = 0pt
cannam@167 955 \else
cannam@167 956 \defaultparindent = #1em
cannam@167 957 \fi
cannam@167 958 \fi
cannam@167 959 \parindent = \defaultparindent
cannam@167 960 }
cannam@167 961
cannam@167 962 % @exampleindent NCHARS
cannam@167 963 % We'll use ems for NCHARS like @paragraphindent.
cannam@167 964 % It seems @exampleindent asis isn't necessary, but
cannam@167 965 % I preserve it to make it similar to @paragraphindent.
cannam@167 966 \parseargdef\exampleindent{%
cannam@167 967 \def\temp{#1}%
cannam@167 968 \ifx\temp\asisword
cannam@167 969 \else
cannam@167 970 \ifx\temp\noneword
cannam@167 971 \lispnarrowing = 0pt
cannam@167 972 \else
cannam@167 973 \lispnarrowing = #1em
cannam@167 974 \fi
cannam@167 975 \fi
cannam@167 976 }
cannam@167 977
cannam@167 978 % @firstparagraphindent WORD
cannam@167 979 % If WORD is `none', then suppress indentation of the first paragraph
cannam@167 980 % after a section heading. If WORD is `insert', then do indent at such
cannam@167 981 % paragraphs.
cannam@167 982 %
cannam@167 983 % The paragraph indentation is suppressed or not by calling
cannam@167 984 % \suppressfirstparagraphindent, which the sectioning commands do.
cannam@167 985 % We switch the definition of this back and forth according to WORD.
cannam@167 986 % By default, we suppress indentation.
cannam@167 987 %
cannam@167 988 \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
cannam@167 989 \def\insertword{insert}
cannam@167 990 %
cannam@167 991 \parseargdef\firstparagraphindent{%
cannam@167 992 \def\temp{#1}%
cannam@167 993 \ifx\temp\noneword
cannam@167 994 \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
cannam@167 995 \else\ifx\temp\insertword
cannam@167 996 \let\suppressfirstparagraphindent = \relax
cannam@167 997 \else
cannam@167 998 \errhelp = \EMsimple
cannam@167 999 \errmessage{Unknown @firstparagraphindent option `\temp'}%
cannam@167 1000 \fi\fi
cannam@167 1001 }
cannam@167 1002
cannam@167 1003 % Here is how we actually suppress indentation. Redefine \everypar to
cannam@167 1004 % \kern backwards by \parindent, and then reset itself to empty.
cannam@167 1005 %
cannam@167 1006 % We also make \indent itself not actually do anything until the next
cannam@167 1007 % paragraph.
cannam@167 1008 %
cannam@167 1009 \gdef\dosuppressfirstparagraphindent{%
cannam@167 1010 \gdef\indent{%
cannam@167 1011 \restorefirstparagraphindent
cannam@167 1012 \indent
cannam@167 1013 }%
cannam@167 1014 \gdef\noindent{%
cannam@167 1015 \restorefirstparagraphindent
cannam@167 1016 \noindent
cannam@167 1017 }%
cannam@167 1018 \global\everypar = {%
cannam@167 1019 \kern -\parindent
cannam@167 1020 \restorefirstparagraphindent
cannam@167 1021 }%
cannam@167 1022 }
cannam@167 1023
cannam@167 1024 \gdef\restorefirstparagraphindent{%
cannam@167 1025 \global \let \indent = \ptexindent
cannam@167 1026 \global \let \noindent = \ptexnoindent
cannam@167 1027 \global \everypar = {}%
cannam@167 1028 }
cannam@167 1029
cannam@167 1030
cannam@167 1031 % @refill is a no-op.
cannam@167 1032 \let\refill=\relax
cannam@167 1033
cannam@167 1034 % If working on a large document in chapters, it is convenient to
cannam@167 1035 % be able to disable indexing, cross-referencing, and contents, for test runs.
cannam@167 1036 % This is done with @novalidate (before @setfilename).
cannam@167 1037 %
cannam@167 1038 \newif\iflinks \linkstrue % by default we want the aux files.
cannam@167 1039 \let\novalidate = \linksfalse
cannam@167 1040
cannam@167 1041 % @setfilename is done at the beginning of every texinfo file.
cannam@167 1042 % So open here the files we need to have open while reading the input.
cannam@167 1043 % This makes it possible to make a .fmt file for texinfo.
cannam@167 1044 \def\setfilename{%
cannam@167 1045 \fixbackslash % Turn off hack to swallow `\input texinfo'.
cannam@167 1046 \iflinks
cannam@167 1047 \tryauxfile
cannam@167 1048 % Open the new aux file. TeX will close it automatically at exit.
cannam@167 1049 \immediate\openout\auxfile=\jobname.aux
cannam@167 1050 \fi % \openindices needs to do some work in any case.
cannam@167 1051 \openindices
cannam@167 1052 \let\setfilename=\comment % Ignore extra @setfilename cmds.
cannam@167 1053 %
cannam@167 1054 % If texinfo.cnf is present on the system, read it.
cannam@167 1055 % Useful for site-wide @afourpaper, etc.
cannam@167 1056 \openin 1 texinfo.cnf
cannam@167 1057 \ifeof 1 \else \input texinfo.cnf \fi
cannam@167 1058 \closein 1
cannam@167 1059 %
cannam@167 1060 \comment % Ignore the actual filename.
cannam@167 1061 }
cannam@167 1062
cannam@167 1063 % Called from \setfilename.
cannam@167 1064 %
cannam@167 1065 \def\openindices{%
cannam@167 1066 \newindex{cp}%
cannam@167 1067 \newcodeindex{fn}%
cannam@167 1068 \newcodeindex{vr}%
cannam@167 1069 \newcodeindex{tp}%
cannam@167 1070 \newcodeindex{ky}%
cannam@167 1071 \newcodeindex{pg}%
cannam@167 1072 }
cannam@167 1073
cannam@167 1074 % @bye.
cannam@167 1075 \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
cannam@167 1076
cannam@167 1077
cannam@167 1078 \message{pdf,}
cannam@167 1079 % adobe `portable' document format
cannam@167 1080 \newcount\tempnum
cannam@167 1081 \newcount\lnkcount
cannam@167 1082 \newtoks\filename
cannam@167 1083 \newcount\filenamelength
cannam@167 1084 \newcount\pgn
cannam@167 1085 \newtoks\toksA
cannam@167 1086 \newtoks\toksB
cannam@167 1087 \newtoks\toksC
cannam@167 1088 \newtoks\toksD
cannam@167 1089 \newbox\boxA
cannam@167 1090 \newcount\countA
cannam@167 1091 \newif\ifpdf
cannam@167 1092 \newif\ifpdfmakepagedest
cannam@167 1093
cannam@167 1094 % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
cannam@167 1095 % can be set). So we test for \relax and 0 as well as being undefined.
cannam@167 1096 \ifx\pdfoutput\thisisundefined
cannam@167 1097 \else
cannam@167 1098 \ifx\pdfoutput\relax
cannam@167 1099 \else
cannam@167 1100 \ifcase\pdfoutput
cannam@167 1101 \else
cannam@167 1102 \pdftrue
cannam@167 1103 \fi
cannam@167 1104 \fi
cannam@167 1105 \fi
cannam@167 1106
cannam@167 1107 % PDF uses PostScript string constants for the names of xref targets,
cannam@167 1108 % for display in the outlines, and in other places. Thus, we have to
cannam@167 1109 % double any backslashes. Otherwise, a name like "\node" will be
cannam@167 1110 % interpreted as a newline (\n), followed by o, d, e. Not good.
cannam@167 1111 %
cannam@167 1112 % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
cannam@167 1113 % related messages. The final outcome is that it is up to the TeX user
cannam@167 1114 % to double the backslashes and otherwise make the string valid, so
cannam@167 1115 % that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to
cannam@167 1116 % do this reliably, so we use it.
cannam@167 1117
cannam@167 1118 % #1 is a control sequence in which to do the replacements,
cannam@167 1119 % which we \xdef.
cannam@167 1120 \def\txiescapepdf#1{%
cannam@167 1121 \ifx\pdfescapestring\thisisundefined
cannam@167 1122 % No primitive available; should we give a warning or log?
cannam@167 1123 % Many times it won't matter.
cannam@167 1124 \else
cannam@167 1125 % The expandable \pdfescapestring primitive escapes parentheses,
cannam@167 1126 % backslashes, and other special chars.
cannam@167 1127 \xdef#1{\pdfescapestring{#1}}%
cannam@167 1128 \fi
cannam@167 1129 }
cannam@167 1130
cannam@167 1131 \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
cannam@167 1132 with PDF output, and none of those formats could be found. (.eps cannot
cannam@167 1133 be supported due to the design of the PDF format; use regular TeX (DVI
cannam@167 1134 output) for that.)}
cannam@167 1135
cannam@167 1136 \ifpdf
cannam@167 1137 %
cannam@167 1138 % Color manipulation macros based on pdfcolor.tex,
cannam@167 1139 % except using rgb instead of cmyk; the latter is said to render as a
cannam@167 1140 % very dark gray on-screen and a very dark halftone in print, instead
cannam@167 1141 % of actual black.
cannam@167 1142 \def\rgbDarkRed{0.50 0.09 0.12}
cannam@167 1143 \def\rgbBlack{0 0 0}
cannam@167 1144 %
cannam@167 1145 % k sets the color for filling (usual text, etc.);
cannam@167 1146 % K sets the color for stroking (thin rules, e.g., normal _'s).
cannam@167 1147 \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}}
cannam@167 1148 %
cannam@167 1149 % Set color, and create a mark which defines \thiscolor accordingly,
cannam@167 1150 % so that \makeheadline knows which color to restore.
cannam@167 1151 \def\setcolor#1{%
cannam@167 1152 \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
cannam@167 1153 \domark
cannam@167 1154 \pdfsetcolor{#1}%
cannam@167 1155 }
cannam@167 1156 %
cannam@167 1157 \def\maincolor{\rgbBlack}
cannam@167 1158 \pdfsetcolor{\maincolor}
cannam@167 1159 \edef\thiscolor{\maincolor}
cannam@167 1160 \def\lastcolordefs{}
cannam@167 1161 %
cannam@167 1162 \def\makefootline{%
cannam@167 1163 \baselineskip24pt
cannam@167 1164 \line{\pdfsetcolor{\maincolor}\the\footline}%
cannam@167 1165 }
cannam@167 1166 %
cannam@167 1167 \def\makeheadline{%
cannam@167 1168 \vbox to 0pt{%
cannam@167 1169 \vskip-22.5pt
cannam@167 1170 \line{%
cannam@167 1171 \vbox to8.5pt{}%
cannam@167 1172 % Extract \thiscolor definition from the marks.
cannam@167 1173 \getcolormarks
cannam@167 1174 % Typeset the headline with \maincolor, then restore the color.
cannam@167 1175 \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
cannam@167 1176 }%
cannam@167 1177 \vss
cannam@167 1178 }%
cannam@167 1179 \nointerlineskip
cannam@167 1180 }
cannam@167 1181 %
cannam@167 1182 %
cannam@167 1183 \pdfcatalog{/PageMode /UseOutlines}
cannam@167 1184 %
cannam@167 1185 % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
cannam@167 1186 \def\dopdfimage#1#2#3{%
cannam@167 1187 \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
cannam@167 1188 \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
cannam@167 1189 %
cannam@167 1190 % pdftex (and the PDF format) support .pdf, .png, .jpg (among
cannam@167 1191 % others). Let's try in that order, PDF first since if
cannam@167 1192 % someone has a scalable image, presumably better to use that than a
cannam@167 1193 % bitmap.
cannam@167 1194 \let\pdfimgext=\empty
cannam@167 1195 \begingroup
cannam@167 1196 \openin 1 #1.pdf \ifeof 1
cannam@167 1197 \openin 1 #1.PDF \ifeof 1
cannam@167 1198 \openin 1 #1.png \ifeof 1
cannam@167 1199 \openin 1 #1.jpg \ifeof 1
cannam@167 1200 \openin 1 #1.jpeg \ifeof 1
cannam@167 1201 \openin 1 #1.JPG \ifeof 1
cannam@167 1202 \errhelp = \nopdfimagehelp
cannam@167 1203 \errmessage{Could not find image file #1 for pdf}%
cannam@167 1204 \else \gdef\pdfimgext{JPG}%
cannam@167 1205 \fi
cannam@167 1206 \else \gdef\pdfimgext{jpeg}%
cannam@167 1207 \fi
cannam@167 1208 \else \gdef\pdfimgext{jpg}%
cannam@167 1209 \fi
cannam@167 1210 \else \gdef\pdfimgext{png}%
cannam@167 1211 \fi
cannam@167 1212 \else \gdef\pdfimgext{PDF}%
cannam@167 1213 \fi
cannam@167 1214 \else \gdef\pdfimgext{pdf}%
cannam@167 1215 \fi
cannam@167 1216 \closein 1
cannam@167 1217 \endgroup
cannam@167 1218 %
cannam@167 1219 % without \immediate, ancient pdftex seg faults when the same image is
cannam@167 1220 % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.)
cannam@167 1221 \ifnum\pdftexversion < 14
cannam@167 1222 \immediate\pdfimage
cannam@167 1223 \else
cannam@167 1224 \immediate\pdfximage
cannam@167 1225 \fi
cannam@167 1226 \ifdim \wd0 >0pt width \pdfimagewidth \fi
cannam@167 1227 \ifdim \wd2 >0pt height \pdfimageheight \fi
cannam@167 1228 \ifnum\pdftexversion<13
cannam@167 1229 #1.\pdfimgext
cannam@167 1230 \else
cannam@167 1231 {#1.\pdfimgext}%
cannam@167 1232 \fi
cannam@167 1233 \ifnum\pdftexversion < 14 \else
cannam@167 1234 \pdfrefximage \pdflastximage
cannam@167 1235 \fi}
cannam@167 1236 %
cannam@167 1237 \def\pdfmkdest#1{{%
cannam@167 1238 % We have to set dummies so commands such as @code, and characters
cannam@167 1239 % such as \, aren't expanded when present in a section title.
cannam@167 1240 \indexnofonts
cannam@167 1241 \turnoffactive
cannam@167 1242 \makevalueexpandable
cannam@167 1243 \def\pdfdestname{#1}%
cannam@167 1244 \txiescapepdf\pdfdestname
cannam@167 1245 \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
cannam@167 1246 }}
cannam@167 1247 %
cannam@167 1248 % used to mark target names; must be expandable.
cannam@167 1249 \def\pdfmkpgn#1{#1}
cannam@167 1250 %
cannam@167 1251 % by default, use a color that is dark enough to print on paper as
cannam@167 1252 % nearly black, but still distinguishable for online viewing.
cannam@167 1253 \def\urlcolor{\rgbDarkRed}
cannam@167 1254 \def\linkcolor{\rgbDarkRed}
cannam@167 1255 \def\endlink{\setcolor{\maincolor}\pdfendlink}
cannam@167 1256 %
cannam@167 1257 % Adding outlines to PDF; macros for calculating structure of outlines
cannam@167 1258 % come from Petr Olsak
cannam@167 1259 \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
cannam@167 1260 \else \csname#1\endcsname \fi}
cannam@167 1261 \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
cannam@167 1262 \advance\tempnum by 1
cannam@167 1263 \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
cannam@167 1264 %
cannam@167 1265 % #1 is the section text, which is what will be displayed in the
cannam@167 1266 % outline by the pdf viewer. #2 is the pdf expression for the number
cannam@167 1267 % of subentries (or empty, for subsubsections). #3 is the node text,
cannam@167 1268 % which might be empty if this toc entry had no corresponding node.
cannam@167 1269 % #4 is the page number
cannam@167 1270 %
cannam@167 1271 \def\dopdfoutline#1#2#3#4{%
cannam@167 1272 % Generate a link to the node text if that exists; else, use the
cannam@167 1273 % page number. We could generate a destination for the section
cannam@167 1274 % text in the case where a section has no node, but it doesn't
cannam@167 1275 % seem worth the trouble, since most documents are normally structured.
cannam@167 1276 \edef\pdfoutlinedest{#3}%
cannam@167 1277 \ifx\pdfoutlinedest\empty
cannam@167 1278 \def\pdfoutlinedest{#4}%
cannam@167 1279 \else
cannam@167 1280 \txiescapepdf\pdfoutlinedest
cannam@167 1281 \fi
cannam@167 1282 %
cannam@167 1283 % Also escape PDF chars in the display string.
cannam@167 1284 \edef\pdfoutlinetext{#1}%
cannam@167 1285 \txiescapepdf\pdfoutlinetext
cannam@167 1286 %
cannam@167 1287 \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
cannam@167 1288 }
cannam@167 1289 %
cannam@167 1290 \def\pdfmakeoutlines{%
cannam@167 1291 \begingroup
cannam@167 1292 % Read toc silently, to get counts of subentries for \pdfoutline.
cannam@167 1293 \def\partentry##1##2##3##4{}% ignore parts in the outlines
cannam@167 1294 \def\numchapentry##1##2##3##4{%
cannam@167 1295 \def\thischapnum{##2}%
cannam@167 1296 \def\thissecnum{0}%
cannam@167 1297 \def\thissubsecnum{0}%
cannam@167 1298 }%
cannam@167 1299 \def\numsecentry##1##2##3##4{%
cannam@167 1300 \advancenumber{chap\thischapnum}%
cannam@167 1301 \def\thissecnum{##2}%
cannam@167 1302 \def\thissubsecnum{0}%
cannam@167 1303 }%
cannam@167 1304 \def\numsubsecentry##1##2##3##4{%
cannam@167 1305 \advancenumber{sec\thissecnum}%
cannam@167 1306 \def\thissubsecnum{##2}%
cannam@167 1307 }%
cannam@167 1308 \def\numsubsubsecentry##1##2##3##4{%
cannam@167 1309 \advancenumber{subsec\thissubsecnum}%
cannam@167 1310 }%
cannam@167 1311 \def\thischapnum{0}%
cannam@167 1312 \def\thissecnum{0}%
cannam@167 1313 \def\thissubsecnum{0}%
cannam@167 1314 %
cannam@167 1315 % use \def rather than \let here because we redefine \chapentry et
cannam@167 1316 % al. a second time, below.
cannam@167 1317 \def\appentry{\numchapentry}%
cannam@167 1318 \def\appsecentry{\numsecentry}%
cannam@167 1319 \def\appsubsecentry{\numsubsecentry}%
cannam@167 1320 \def\appsubsubsecentry{\numsubsubsecentry}%
cannam@167 1321 \def\unnchapentry{\numchapentry}%
cannam@167 1322 \def\unnsecentry{\numsecentry}%
cannam@167 1323 \def\unnsubsecentry{\numsubsecentry}%
cannam@167 1324 \def\unnsubsubsecentry{\numsubsubsecentry}%
cannam@167 1325 \readdatafile{toc}%
cannam@167 1326 %
cannam@167 1327 % Read toc second time, this time actually producing the outlines.
cannam@167 1328 % The `-' means take the \expnumber as the absolute number of
cannam@167 1329 % subentries, which we calculated on our first read of the .toc above.
cannam@167 1330 %
cannam@167 1331 % We use the node names as the destinations.
cannam@167 1332 \def\numchapentry##1##2##3##4{%
cannam@167 1333 \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
cannam@167 1334 \def\numsecentry##1##2##3##4{%
cannam@167 1335 \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
cannam@167 1336 \def\numsubsecentry##1##2##3##4{%
cannam@167 1337 \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
cannam@167 1338 \def\numsubsubsecentry##1##2##3##4{% count is always zero
cannam@167 1339 \dopdfoutline{##1}{}{##3}{##4}}%
cannam@167 1340 %
cannam@167 1341 % PDF outlines are displayed using system fonts, instead of
cannam@167 1342 % document fonts. Therefore we cannot use special characters,
cannam@167 1343 % since the encoding is unknown. For example, the eogonek from
cannam@167 1344 % Latin 2 (0xea) gets translated to a | character. Info from
cannam@167 1345 % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
cannam@167 1346 %
cannam@167 1347 % TODO this right, we have to translate 8-bit characters to
cannam@167 1348 % their "best" equivalent, based on the @documentencoding. Too
cannam@167 1349 % much work for too little return. Just use the ASCII equivalents
cannam@167 1350 % we use for the index sort strings.
cannam@167 1351 %
cannam@167 1352 \indexnofonts
cannam@167 1353 \setupdatafile
cannam@167 1354 % We can have normal brace characters in the PDF outlines, unlike
cannam@167 1355 % Texinfo index files. So set that up.
cannam@167 1356 \def\{{\lbracecharliteral}%
cannam@167 1357 \def\}{\rbracecharliteral}%
cannam@167 1358 \catcode`\\=\active \otherbackslash
cannam@167 1359 \input \tocreadfilename
cannam@167 1360 \endgroup
cannam@167 1361 }
cannam@167 1362 {\catcode`[=1 \catcode`]=2
cannam@167 1363 \catcode`{=\other \catcode`}=\other
cannam@167 1364 \gdef\lbracecharliteral[{]%
cannam@167 1365 \gdef\rbracecharliteral[}]%
cannam@167 1366 ]
cannam@167 1367 %
cannam@167 1368 \def\skipspaces#1{\def\PP{#1}\def\D{|}%
cannam@167 1369 \ifx\PP\D\let\nextsp\relax
cannam@167 1370 \else\let\nextsp\skipspaces
cannam@167 1371 \addtokens{\filename}{\PP}%
cannam@167 1372 \advance\filenamelength by 1
cannam@167 1373 \fi
cannam@167 1374 \nextsp}
cannam@167 1375 \def\getfilename#1{%
cannam@167 1376 \filenamelength=0
cannam@167 1377 % If we don't expand the argument now, \skipspaces will get
cannam@167 1378 % snagged on things like "@value{foo}".
cannam@167 1379 \edef\temp{#1}%
cannam@167 1380 \expandafter\skipspaces\temp|\relax
cannam@167 1381 }
cannam@167 1382 \ifnum\pdftexversion < 14
cannam@167 1383 \let \startlink \pdfannotlink
cannam@167 1384 \else
cannam@167 1385 \let \startlink \pdfstartlink
cannam@167 1386 \fi
cannam@167 1387 % make a live url in pdf output.
cannam@167 1388 \def\pdfurl#1{%
cannam@167 1389 \begingroup
cannam@167 1390 % it seems we really need yet another set of dummies; have not
cannam@167 1391 % tried to figure out what each command should do in the context
cannam@167 1392 % of @url. for now, just make @/ a no-op, that's the only one
cannam@167 1393 % people have actually reported a problem with.
cannam@167 1394 %
cannam@167 1395 \normalturnoffactive
cannam@167 1396 \def\@{@}%
cannam@167 1397 \let\/=\empty
cannam@167 1398 \makevalueexpandable
cannam@167 1399 % do we want to go so far as to use \indexnofonts instead of just
cannam@167 1400 % special-casing \var here?
cannam@167 1401 \def\var##1{##1}%
cannam@167 1402 %
cannam@167 1403 \leavevmode\setcolor{\urlcolor}%
cannam@167 1404 \startlink attr{/Border [0 0 0]}%
cannam@167 1405 user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
cannam@167 1406 \endgroup}
cannam@167 1407 \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
cannam@167 1408 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
cannam@167 1409 \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
cannam@167 1410 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
cannam@167 1411 \def\maketoks{%
cannam@167 1412 \expandafter\poptoks\the\toksA|ENDTOKS|\relax
cannam@167 1413 \ifx\first0\adn0
cannam@167 1414 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
cannam@167 1415 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
cannam@167 1416 \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
cannam@167 1417 \else
cannam@167 1418 \ifnum0=\countA\else\makelink\fi
cannam@167 1419 \ifx\first.\let\next=\done\else
cannam@167 1420 \let\next=\maketoks
cannam@167 1421 \addtokens{\toksB}{\the\toksD}
cannam@167 1422 \ifx\first,\addtokens{\toksB}{\space}\fi
cannam@167 1423 \fi
cannam@167 1424 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
cannam@167 1425 \next}
cannam@167 1426 \def\makelink{\addtokens{\toksB}%
cannam@167 1427 {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
cannam@167 1428 \def\pdflink#1{%
cannam@167 1429 \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
cannam@167 1430 \setcolor{\linkcolor}#1\endlink}
cannam@167 1431 \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
cannam@167 1432 \else
cannam@167 1433 % non-pdf mode
cannam@167 1434 \let\pdfmkdest = \gobble
cannam@167 1435 \let\pdfurl = \gobble
cannam@167 1436 \let\endlink = \relax
cannam@167 1437 \let\setcolor = \gobble
cannam@167 1438 \let\pdfsetcolor = \gobble
cannam@167 1439 \let\pdfmakeoutlines = \relax
cannam@167 1440 \fi % \ifx\pdfoutput
cannam@167 1441
cannam@167 1442
cannam@167 1443 \message{fonts,}
cannam@167 1444
cannam@167 1445 % Change the current font style to #1, remembering it in \curfontstyle.
cannam@167 1446 % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
cannam@167 1447 % italics, not bold italics.
cannam@167 1448 %
cannam@167 1449 \def\setfontstyle#1{%
cannam@167 1450 \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
cannam@167 1451 \csname ten#1\endcsname % change the current font
cannam@167 1452 }
cannam@167 1453
cannam@167 1454 % Select #1 fonts with the current style.
cannam@167 1455 %
cannam@167 1456 \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
cannam@167 1457
cannam@167 1458 \def\rm{\fam=0 \setfontstyle{rm}}
cannam@167 1459 \def\it{\fam=\itfam \setfontstyle{it}}
cannam@167 1460 \def\sl{\fam=\slfam \setfontstyle{sl}}
cannam@167 1461 \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
cannam@167 1462 \def\tt{\fam=\ttfam \setfontstyle{tt}}
cannam@167 1463
cannam@167 1464 % Unfortunately, we have to override this for titles and the like, since
cannam@167 1465 % in those cases "rm" is bold. Sigh.
cannam@167 1466 \def\rmisbold{\rm\def\curfontstyle{bf}}
cannam@167 1467
cannam@167 1468 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
cannam@167 1469 % So we set up a \sf.
cannam@167 1470 \newfam\sffam
cannam@167 1471 \def\sf{\fam=\sffam \setfontstyle{sf}}
cannam@167 1472 \let\li = \sf % Sometimes we call it \li, not \sf.
cannam@167 1473
cannam@167 1474 % We don't need math for this font style.
cannam@167 1475 \def\ttsl{\setfontstyle{ttsl}}
cannam@167 1476
cannam@167 1477
cannam@167 1478 % Set the baselineskip to #1, and the lineskip and strut size
cannam@167 1479 % correspondingly. There is no deep meaning behind these magic numbers
cannam@167 1480 % used as factors; they just match (closely enough) what Knuth defined.
cannam@167 1481 %
cannam@167 1482 \def\lineskipfactor{.08333}
cannam@167 1483 \def\strutheightpercent{.70833}
cannam@167 1484 \def\strutdepthpercent {.29167}
cannam@167 1485 %
cannam@167 1486 % can get a sort of poor man's double spacing by redefining this.
cannam@167 1487 \def\baselinefactor{1}
cannam@167 1488 %
cannam@167 1489 \newdimen\textleading
cannam@167 1490 \def\setleading#1{%
cannam@167 1491 \dimen0 = #1\relax
cannam@167 1492 \normalbaselineskip = \baselinefactor\dimen0
cannam@167 1493 \normallineskip = \lineskipfactor\normalbaselineskip
cannam@167 1494 \normalbaselines
cannam@167 1495 \setbox\strutbox =\hbox{%
cannam@167 1496 \vrule width0pt height\strutheightpercent\baselineskip
cannam@167 1497 depth \strutdepthpercent \baselineskip
cannam@167 1498 }%
cannam@167 1499 }
cannam@167 1500
cannam@167 1501 % PDF CMaps. See also LaTeX's t1.cmap.
cannam@167 1502 %
cannam@167 1503 % do nothing with this by default.
cannam@167 1504 \expandafter\let\csname cmapOT1\endcsname\gobble
cannam@167 1505 \expandafter\let\csname cmapOT1IT\endcsname\gobble
cannam@167 1506 \expandafter\let\csname cmapOT1TT\endcsname\gobble
cannam@167 1507
cannam@167 1508 % if we are producing pdf, and we have \pdffontattr, then define cmaps.
cannam@167 1509 % (\pdffontattr was introduced many years ago, but people still run
cannam@167 1510 % older pdftex's; it's easy to conditionalize, so we do.)
cannam@167 1511 \ifpdf \ifx\pdffontattr\thisisundefined \else
cannam@167 1512 \begingroup
cannam@167 1513 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
cannam@167 1514 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
cannam@167 1515 %%DocumentNeededResources: ProcSet (CIDInit)
cannam@167 1516 %%IncludeResource: ProcSet (CIDInit)
cannam@167 1517 %%BeginResource: CMap (TeX-OT1-0)
cannam@167 1518 %%Title: (TeX-OT1-0 TeX OT1 0)
cannam@167 1519 %%Version: 1.000
cannam@167 1520 %%EndComments
cannam@167 1521 /CIDInit /ProcSet findresource begin
cannam@167 1522 12 dict begin
cannam@167 1523 begincmap
cannam@167 1524 /CIDSystemInfo
cannam@167 1525 << /Registry (TeX)
cannam@167 1526 /Ordering (OT1)
cannam@167 1527 /Supplement 0
cannam@167 1528 >> def
cannam@167 1529 /CMapName /TeX-OT1-0 def
cannam@167 1530 /CMapType 2 def
cannam@167 1531 1 begincodespacerange
cannam@167 1532 <00> <7F>
cannam@167 1533 endcodespacerange
cannam@167 1534 8 beginbfrange
cannam@167 1535 <00> <01> <0393>
cannam@167 1536 <09> <0A> <03A8>
cannam@167 1537 <23> <26> <0023>
cannam@167 1538 <28> <3B> <0028>
cannam@167 1539 <3F> <5B> <003F>
cannam@167 1540 <5D> <5E> <005D>
cannam@167 1541 <61> <7A> <0061>
cannam@167 1542 <7B> <7C> <2013>
cannam@167 1543 endbfrange
cannam@167 1544 40 beginbfchar
cannam@167 1545 <02> <0398>
cannam@167 1546 <03> <039B>
cannam@167 1547 <04> <039E>
cannam@167 1548 <05> <03A0>
cannam@167 1549 <06> <03A3>
cannam@167 1550 <07> <03D2>
cannam@167 1551 <08> <03A6>
cannam@167 1552 <0B> <00660066>
cannam@167 1553 <0C> <00660069>
cannam@167 1554 <0D> <0066006C>
cannam@167 1555 <0E> <006600660069>
cannam@167 1556 <0F> <00660066006C>
cannam@167 1557 <10> <0131>
cannam@167 1558 <11> <0237>
cannam@167 1559 <12> <0060>
cannam@167 1560 <13> <00B4>
cannam@167 1561 <14> <02C7>
cannam@167 1562 <15> <02D8>
cannam@167 1563 <16> <00AF>
cannam@167 1564 <17> <02DA>
cannam@167 1565 <18> <00B8>
cannam@167 1566 <19> <00DF>
cannam@167 1567 <1A> <00E6>
cannam@167 1568 <1B> <0153>
cannam@167 1569 <1C> <00F8>
cannam@167 1570 <1D> <00C6>
cannam@167 1571 <1E> <0152>
cannam@167 1572 <1F> <00D8>
cannam@167 1573 <21> <0021>
cannam@167 1574 <22> <201D>
cannam@167 1575 <27> <2019>
cannam@167 1576 <3C> <00A1>
cannam@167 1577 <3D> <003D>
cannam@167 1578 <3E> <00BF>
cannam@167 1579 <5C> <201C>
cannam@167 1580 <5F> <02D9>
cannam@167 1581 <60> <2018>
cannam@167 1582 <7D> <02DD>
cannam@167 1583 <7E> <007E>
cannam@167 1584 <7F> <00A8>
cannam@167 1585 endbfchar
cannam@167 1586 endcmap
cannam@167 1587 CMapName currentdict /CMap defineresource pop
cannam@167 1588 end
cannam@167 1589 end
cannam@167 1590 %%EndResource
cannam@167 1591 %%EOF
cannam@167 1592 }\endgroup
cannam@167 1593 \expandafter\edef\csname cmapOT1\endcsname#1{%
cannam@167 1594 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
cannam@167 1595 }%
cannam@167 1596 %
cannam@167 1597 % \cmapOT1IT
cannam@167 1598 \begingroup
cannam@167 1599 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
cannam@167 1600 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
cannam@167 1601 %%DocumentNeededResources: ProcSet (CIDInit)
cannam@167 1602 %%IncludeResource: ProcSet (CIDInit)
cannam@167 1603 %%BeginResource: CMap (TeX-OT1IT-0)
cannam@167 1604 %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
cannam@167 1605 %%Version: 1.000
cannam@167 1606 %%EndComments
cannam@167 1607 /CIDInit /ProcSet findresource begin
cannam@167 1608 12 dict begin
cannam@167 1609 begincmap
cannam@167 1610 /CIDSystemInfo
cannam@167 1611 << /Registry (TeX)
cannam@167 1612 /Ordering (OT1IT)
cannam@167 1613 /Supplement 0
cannam@167 1614 >> def
cannam@167 1615 /CMapName /TeX-OT1IT-0 def
cannam@167 1616 /CMapType 2 def
cannam@167 1617 1 begincodespacerange
cannam@167 1618 <00> <7F>
cannam@167 1619 endcodespacerange
cannam@167 1620 8 beginbfrange
cannam@167 1621 <00> <01> <0393>
cannam@167 1622 <09> <0A> <03A8>
cannam@167 1623 <25> <26> <0025>
cannam@167 1624 <28> <3B> <0028>
cannam@167 1625 <3F> <5B> <003F>
cannam@167 1626 <5D> <5E> <005D>
cannam@167 1627 <61> <7A> <0061>
cannam@167 1628 <7B> <7C> <2013>
cannam@167 1629 endbfrange
cannam@167 1630 42 beginbfchar
cannam@167 1631 <02> <0398>
cannam@167 1632 <03> <039B>
cannam@167 1633 <04> <039E>
cannam@167 1634 <05> <03A0>
cannam@167 1635 <06> <03A3>
cannam@167 1636 <07> <03D2>
cannam@167 1637 <08> <03A6>
cannam@167 1638 <0B> <00660066>
cannam@167 1639 <0C> <00660069>
cannam@167 1640 <0D> <0066006C>
cannam@167 1641 <0E> <006600660069>
cannam@167 1642 <0F> <00660066006C>
cannam@167 1643 <10> <0131>
cannam@167 1644 <11> <0237>
cannam@167 1645 <12> <0060>
cannam@167 1646 <13> <00B4>
cannam@167 1647 <14> <02C7>
cannam@167 1648 <15> <02D8>
cannam@167 1649 <16> <00AF>
cannam@167 1650 <17> <02DA>
cannam@167 1651 <18> <00B8>
cannam@167 1652 <19> <00DF>
cannam@167 1653 <1A> <00E6>
cannam@167 1654 <1B> <0153>
cannam@167 1655 <1C> <00F8>
cannam@167 1656 <1D> <00C6>
cannam@167 1657 <1E> <0152>
cannam@167 1658 <1F> <00D8>
cannam@167 1659 <21> <0021>
cannam@167 1660 <22> <201D>
cannam@167 1661 <23> <0023>
cannam@167 1662 <24> <00A3>
cannam@167 1663 <27> <2019>
cannam@167 1664 <3C> <00A1>
cannam@167 1665 <3D> <003D>
cannam@167 1666 <3E> <00BF>
cannam@167 1667 <5C> <201C>
cannam@167 1668 <5F> <02D9>
cannam@167 1669 <60> <2018>
cannam@167 1670 <7D> <02DD>
cannam@167 1671 <7E> <007E>
cannam@167 1672 <7F> <00A8>
cannam@167 1673 endbfchar
cannam@167 1674 endcmap
cannam@167 1675 CMapName currentdict /CMap defineresource pop
cannam@167 1676 end
cannam@167 1677 end
cannam@167 1678 %%EndResource
cannam@167 1679 %%EOF
cannam@167 1680 }\endgroup
cannam@167 1681 \expandafter\edef\csname cmapOT1IT\endcsname#1{%
cannam@167 1682 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
cannam@167 1683 }%
cannam@167 1684 %
cannam@167 1685 % \cmapOT1TT
cannam@167 1686 \begingroup
cannam@167 1687 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
cannam@167 1688 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
cannam@167 1689 %%DocumentNeededResources: ProcSet (CIDInit)
cannam@167 1690 %%IncludeResource: ProcSet (CIDInit)
cannam@167 1691 %%BeginResource: CMap (TeX-OT1TT-0)
cannam@167 1692 %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
cannam@167 1693 %%Version: 1.000
cannam@167 1694 %%EndComments
cannam@167 1695 /CIDInit /ProcSet findresource begin
cannam@167 1696 12 dict begin
cannam@167 1697 begincmap
cannam@167 1698 /CIDSystemInfo
cannam@167 1699 << /Registry (TeX)
cannam@167 1700 /Ordering (OT1TT)
cannam@167 1701 /Supplement 0
cannam@167 1702 >> def
cannam@167 1703 /CMapName /TeX-OT1TT-0 def
cannam@167 1704 /CMapType 2 def
cannam@167 1705 1 begincodespacerange
cannam@167 1706 <00> <7F>
cannam@167 1707 endcodespacerange
cannam@167 1708 5 beginbfrange
cannam@167 1709 <00> <01> <0393>
cannam@167 1710 <09> <0A> <03A8>
cannam@167 1711 <21> <26> <0021>
cannam@167 1712 <28> <5F> <0028>
cannam@167 1713 <61> <7E> <0061>
cannam@167 1714 endbfrange
cannam@167 1715 32 beginbfchar
cannam@167 1716 <02> <0398>
cannam@167 1717 <03> <039B>
cannam@167 1718 <04> <039E>
cannam@167 1719 <05> <03A0>
cannam@167 1720 <06> <03A3>
cannam@167 1721 <07> <03D2>
cannam@167 1722 <08> <03A6>
cannam@167 1723 <0B> <2191>
cannam@167 1724 <0C> <2193>
cannam@167 1725 <0D> <0027>
cannam@167 1726 <0E> <00A1>
cannam@167 1727 <0F> <00BF>
cannam@167 1728 <10> <0131>
cannam@167 1729 <11> <0237>
cannam@167 1730 <12> <0060>
cannam@167 1731 <13> <00B4>
cannam@167 1732 <14> <02C7>
cannam@167 1733 <15> <02D8>
cannam@167 1734 <16> <00AF>
cannam@167 1735 <17> <02DA>
cannam@167 1736 <18> <00B8>
cannam@167 1737 <19> <00DF>
cannam@167 1738 <1A> <00E6>
cannam@167 1739 <1B> <0153>
cannam@167 1740 <1C> <00F8>
cannam@167 1741 <1D> <00C6>
cannam@167 1742 <1E> <0152>
cannam@167 1743 <1F> <00D8>
cannam@167 1744 <20> <2423>
cannam@167 1745 <27> <2019>
cannam@167 1746 <60> <2018>
cannam@167 1747 <7F> <00A8>
cannam@167 1748 endbfchar
cannam@167 1749 endcmap
cannam@167 1750 CMapName currentdict /CMap defineresource pop
cannam@167 1751 end
cannam@167 1752 end
cannam@167 1753 %%EndResource
cannam@167 1754 %%EOF
cannam@167 1755 }\endgroup
cannam@167 1756 \expandafter\edef\csname cmapOT1TT\endcsname#1{%
cannam@167 1757 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
cannam@167 1758 }%
cannam@167 1759 \fi\fi
cannam@167 1760
cannam@167 1761
cannam@167 1762 % Set the font macro #1 to the font named \fontprefix#2.
cannam@167 1763 % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
cannam@167 1764 % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
cannam@167 1765 % Example:
cannam@167 1766 % #1 = \textrm
cannam@167 1767 % #2 = \rmshape
cannam@167 1768 % #3 = 10
cannam@167 1769 % #4 = \mainmagstep
cannam@167 1770 % #5 = OT1
cannam@167 1771 %
cannam@167 1772 \def\setfont#1#2#3#4#5{%
cannam@167 1773 \font#1=\fontprefix#2#3 scaled #4
cannam@167 1774 \csname cmap#5\endcsname#1%
cannam@167 1775 }
cannam@167 1776 % This is what gets called when #5 of \setfont is empty.
cannam@167 1777 \let\cmap\gobble
cannam@167 1778 %
cannam@167 1779 % (end of cmaps)
cannam@167 1780
cannam@167 1781 % Use cm as the default font prefix.
cannam@167 1782 % To specify the font prefix, you must define \fontprefix
cannam@167 1783 % before you read in texinfo.tex.
cannam@167 1784 \ifx\fontprefix\thisisundefined
cannam@167 1785 \def\fontprefix{cm}
cannam@167 1786 \fi
cannam@167 1787 % Support font families that don't use the same naming scheme as CM.
cannam@167 1788 \def\rmshape{r}
cannam@167 1789 \def\rmbshape{bx} % where the normal face is bold
cannam@167 1790 \def\bfshape{b}
cannam@167 1791 \def\bxshape{bx}
cannam@167 1792 \def\ttshape{tt}
cannam@167 1793 \def\ttbshape{tt}
cannam@167 1794 \def\ttslshape{sltt}
cannam@167 1795 \def\itshape{ti}
cannam@167 1796 \def\itbshape{bxti}
cannam@167 1797 \def\slshape{sl}
cannam@167 1798 \def\slbshape{bxsl}
cannam@167 1799 \def\sfshape{ss}
cannam@167 1800 \def\sfbshape{ss}
cannam@167 1801 \def\scshape{csc}
cannam@167 1802 \def\scbshape{csc}
cannam@167 1803
cannam@167 1804 % Definitions for a main text size of 11pt. (The default in Texinfo.)
cannam@167 1805 %
cannam@167 1806 \def\definetextfontsizexi{%
cannam@167 1807 % Text fonts (11.2pt, magstep1).
cannam@167 1808 \def\textnominalsize{11pt}
cannam@167 1809 \edef\mainmagstep{\magstephalf}
cannam@167 1810 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
cannam@167 1811 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
cannam@167 1812 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
cannam@167 1813 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
cannam@167 1814 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
cannam@167 1815 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
cannam@167 1816 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
cannam@167 1817 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
cannam@167 1818 \font\texti=cmmi10 scaled \mainmagstep
cannam@167 1819 \font\textsy=cmsy10 scaled \mainmagstep
cannam@167 1820 \def\textecsize{1095}
cannam@167 1821
cannam@167 1822 % A few fonts for @defun names and args.
cannam@167 1823 \setfont\defbf\bfshape{10}{\magstep1}{OT1}
cannam@167 1824 \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
cannam@167 1825 \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
cannam@167 1826 \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
cannam@167 1827
cannam@167 1828 % Fonts for indices, footnotes, small examples (9pt).
cannam@167 1829 \def\smallnominalsize{9pt}
cannam@167 1830 \setfont\smallrm\rmshape{9}{1000}{OT1}
cannam@167 1831 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
cannam@167 1832 \setfont\smallbf\bfshape{10}{900}{OT1}
cannam@167 1833 \setfont\smallit\itshape{9}{1000}{OT1IT}
cannam@167 1834 \setfont\smallsl\slshape{9}{1000}{OT1}
cannam@167 1835 \setfont\smallsf\sfshape{9}{1000}{OT1}
cannam@167 1836 \setfont\smallsc\scshape{10}{900}{OT1}
cannam@167 1837 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
cannam@167 1838 \font\smalli=cmmi9
cannam@167 1839 \font\smallsy=cmsy9
cannam@167 1840 \def\smallecsize{0900}
cannam@167 1841
cannam@167 1842 % Fonts for small examples (8pt).
cannam@167 1843 \def\smallernominalsize{8pt}
cannam@167 1844 \setfont\smallerrm\rmshape{8}{1000}{OT1}
cannam@167 1845 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
cannam@167 1846 \setfont\smallerbf\bfshape{10}{800}{OT1}
cannam@167 1847 \setfont\smallerit\itshape{8}{1000}{OT1IT}
cannam@167 1848 \setfont\smallersl\slshape{8}{1000}{OT1}
cannam@167 1849 \setfont\smallersf\sfshape{8}{1000}{OT1}
cannam@167 1850 \setfont\smallersc\scshape{10}{800}{OT1}
cannam@167 1851 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
cannam@167 1852 \font\smalleri=cmmi8
cannam@167 1853 \font\smallersy=cmsy8
cannam@167 1854 \def\smallerecsize{0800}
cannam@167 1855
cannam@167 1856 % Fonts for title page (20.4pt):
cannam@167 1857 \def\titlenominalsize{20pt}
cannam@167 1858 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
cannam@167 1859 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
cannam@167 1860 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
cannam@167 1861 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
cannam@167 1862 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
cannam@167 1863 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
cannam@167 1864 \let\titlebf=\titlerm
cannam@167 1865 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
cannam@167 1866 \font\titlei=cmmi12 scaled \magstep3
cannam@167 1867 \font\titlesy=cmsy10 scaled \magstep4
cannam@167 1868 \def\titleecsize{2074}
cannam@167 1869
cannam@167 1870 % Chapter (and unnumbered) fonts (17.28pt).
cannam@167 1871 \def\chapnominalsize{17pt}
cannam@167 1872 \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
cannam@167 1873 \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
cannam@167 1874 \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
cannam@167 1875 \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
cannam@167 1876 \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
cannam@167 1877 \setfont\chapsf\sfbshape{17}{1000}{OT1}
cannam@167 1878 \let\chapbf=\chaprm
cannam@167 1879 \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
cannam@167 1880 \font\chapi=cmmi12 scaled \magstep2
cannam@167 1881 \font\chapsy=cmsy10 scaled \magstep3
cannam@167 1882 \def\chapecsize{1728}
cannam@167 1883
cannam@167 1884 % Section fonts (14.4pt).
cannam@167 1885 \def\secnominalsize{14pt}
cannam@167 1886 \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
cannam@167 1887 \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
cannam@167 1888 \setfont\secsl\slbshape{10}{\magstep2}{OT1}
cannam@167 1889 \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
cannam@167 1890 \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
cannam@167 1891 \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
cannam@167 1892 \let\secbf\secrm
cannam@167 1893 \setfont\secsc\scbshape{10}{\magstep2}{OT1}
cannam@167 1894 \font\seci=cmmi12 scaled \magstep1
cannam@167 1895 \font\secsy=cmsy10 scaled \magstep2
cannam@167 1896 \def\sececsize{1440}
cannam@167 1897
cannam@167 1898 % Subsection fonts (13.15pt).
cannam@167 1899 \def\ssecnominalsize{13pt}
cannam@167 1900 \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
cannam@167 1901 \setfont\ssecit\itbshape{10}{1315}{OT1IT}
cannam@167 1902 \setfont\ssecsl\slbshape{10}{1315}{OT1}
cannam@167 1903 \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
cannam@167 1904 \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
cannam@167 1905 \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
cannam@167 1906 \let\ssecbf\ssecrm
cannam@167 1907 \setfont\ssecsc\scbshape{10}{1315}{OT1}
cannam@167 1908 \font\sseci=cmmi12 scaled \magstephalf
cannam@167 1909 \font\ssecsy=cmsy10 scaled 1315
cannam@167 1910 \def\ssececsize{1200}
cannam@167 1911
cannam@167 1912 % Reduced fonts for @acro in text (10pt).
cannam@167 1913 \def\reducednominalsize{10pt}
cannam@167 1914 \setfont\reducedrm\rmshape{10}{1000}{OT1}
cannam@167 1915 \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
cannam@167 1916 \setfont\reducedbf\bfshape{10}{1000}{OT1}
cannam@167 1917 \setfont\reducedit\itshape{10}{1000}{OT1IT}
cannam@167 1918 \setfont\reducedsl\slshape{10}{1000}{OT1}
cannam@167 1919 \setfont\reducedsf\sfshape{10}{1000}{OT1}
cannam@167 1920 \setfont\reducedsc\scshape{10}{1000}{OT1}
cannam@167 1921 \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
cannam@167 1922 \font\reducedi=cmmi10
cannam@167 1923 \font\reducedsy=cmsy10
cannam@167 1924 \def\reducedecsize{1000}
cannam@167 1925
cannam@167 1926 \textleading = 13.2pt % line spacing for 11pt CM
cannam@167 1927 \textfonts % reset the current fonts
cannam@167 1928 \rm
cannam@167 1929 } % end of 11pt text font size definitions, \definetextfontsizexi
cannam@167 1930
cannam@167 1931
cannam@167 1932 % Definitions to make the main text be 10pt Computer Modern, with
cannam@167 1933 % section, chapter, etc., sizes following suit. This is for the GNU
cannam@167 1934 % Press printing of the Emacs 22 manual. Maybe other manuals in the
cannam@167 1935 % future. Used with @smallbook, which sets the leading to 12pt.
cannam@167 1936 %
cannam@167 1937 \def\definetextfontsizex{%
cannam@167 1938 % Text fonts (10pt).
cannam@167 1939 \def\textnominalsize{10pt}
cannam@167 1940 \edef\mainmagstep{1000}
cannam@167 1941 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
cannam@167 1942 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
cannam@167 1943 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
cannam@167 1944 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
cannam@167 1945 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
cannam@167 1946 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
cannam@167 1947 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
cannam@167 1948 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
cannam@167 1949 \font\texti=cmmi10 scaled \mainmagstep
cannam@167 1950 \font\textsy=cmsy10 scaled \mainmagstep
cannam@167 1951 \def\textecsize{1000}
cannam@167 1952
cannam@167 1953 % A few fonts for @defun names and args.
cannam@167 1954 \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
cannam@167 1955 \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
cannam@167 1956 \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
cannam@167 1957 \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
cannam@167 1958
cannam@167 1959 % Fonts for indices, footnotes, small examples (9pt).
cannam@167 1960 \def\smallnominalsize{9pt}
cannam@167 1961 \setfont\smallrm\rmshape{9}{1000}{OT1}
cannam@167 1962 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
cannam@167 1963 \setfont\smallbf\bfshape{10}{900}{OT1}
cannam@167 1964 \setfont\smallit\itshape{9}{1000}{OT1IT}
cannam@167 1965 \setfont\smallsl\slshape{9}{1000}{OT1}
cannam@167 1966 \setfont\smallsf\sfshape{9}{1000}{OT1}
cannam@167 1967 \setfont\smallsc\scshape{10}{900}{OT1}
cannam@167 1968 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
cannam@167 1969 \font\smalli=cmmi9
cannam@167 1970 \font\smallsy=cmsy9
cannam@167 1971 \def\smallecsize{0900}
cannam@167 1972
cannam@167 1973 % Fonts for small examples (8pt).
cannam@167 1974 \def\smallernominalsize{8pt}
cannam@167 1975 \setfont\smallerrm\rmshape{8}{1000}{OT1}
cannam@167 1976 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
cannam@167 1977 \setfont\smallerbf\bfshape{10}{800}{OT1}
cannam@167 1978 \setfont\smallerit\itshape{8}{1000}{OT1IT}
cannam@167 1979 \setfont\smallersl\slshape{8}{1000}{OT1}
cannam@167 1980 \setfont\smallersf\sfshape{8}{1000}{OT1}
cannam@167 1981 \setfont\smallersc\scshape{10}{800}{OT1}
cannam@167 1982 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
cannam@167 1983 \font\smalleri=cmmi8
cannam@167 1984 \font\smallersy=cmsy8
cannam@167 1985 \def\smallerecsize{0800}
cannam@167 1986
cannam@167 1987 % Fonts for title page (20.4pt):
cannam@167 1988 \def\titlenominalsize{20pt}
cannam@167 1989 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
cannam@167 1990 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
cannam@167 1991 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
cannam@167 1992 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
cannam@167 1993 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
cannam@167 1994 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
cannam@167 1995 \let\titlebf=\titlerm
cannam@167 1996 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
cannam@167 1997 \font\titlei=cmmi12 scaled \magstep3
cannam@167 1998 \font\titlesy=cmsy10 scaled \magstep4
cannam@167 1999 \def\titleecsize{2074}
cannam@167 2000
cannam@167 2001 % Chapter fonts (14.4pt).
cannam@167 2002 \def\chapnominalsize{14pt}
cannam@167 2003 \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
cannam@167 2004 \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
cannam@167 2005 \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
cannam@167 2006 \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
cannam@167 2007 \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
cannam@167 2008 \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
cannam@167 2009 \let\chapbf\chaprm
cannam@167 2010 \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
cannam@167 2011 \font\chapi=cmmi12 scaled \magstep1
cannam@167 2012 \font\chapsy=cmsy10 scaled \magstep2
cannam@167 2013 \def\chapecsize{1440}
cannam@167 2014
cannam@167 2015 % Section fonts (12pt).
cannam@167 2016 \def\secnominalsize{12pt}
cannam@167 2017 \setfont\secrm\rmbshape{12}{1000}{OT1}
cannam@167 2018 \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
cannam@167 2019 \setfont\secsl\slbshape{10}{\magstep1}{OT1}
cannam@167 2020 \setfont\sectt\ttbshape{12}{1000}{OT1TT}
cannam@167 2021 \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
cannam@167 2022 \setfont\secsf\sfbshape{12}{1000}{OT1}
cannam@167 2023 \let\secbf\secrm
cannam@167 2024 \setfont\secsc\scbshape{10}{\magstep1}{OT1}
cannam@167 2025 \font\seci=cmmi12
cannam@167 2026 \font\secsy=cmsy10 scaled \magstep1
cannam@167 2027 \def\sececsize{1200}
cannam@167 2028
cannam@167 2029 % Subsection fonts (10pt).
cannam@167 2030 \def\ssecnominalsize{10pt}
cannam@167 2031 \setfont\ssecrm\rmbshape{10}{1000}{OT1}
cannam@167 2032 \setfont\ssecit\itbshape{10}{1000}{OT1IT}
cannam@167 2033 \setfont\ssecsl\slbshape{10}{1000}{OT1}
cannam@167 2034 \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
cannam@167 2035 \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
cannam@167 2036 \setfont\ssecsf\sfbshape{10}{1000}{OT1}
cannam@167 2037 \let\ssecbf\ssecrm
cannam@167 2038 \setfont\ssecsc\scbshape{10}{1000}{OT1}
cannam@167 2039 \font\sseci=cmmi10
cannam@167 2040 \font\ssecsy=cmsy10
cannam@167 2041 \def\ssececsize{1000}
cannam@167 2042
cannam@167 2043 % Reduced fonts for @acro in text (9pt).
cannam@167 2044 \def\reducednominalsize{9pt}
cannam@167 2045 \setfont\reducedrm\rmshape{9}{1000}{OT1}
cannam@167 2046 \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
cannam@167 2047 \setfont\reducedbf\bfshape{10}{900}{OT1}
cannam@167 2048 \setfont\reducedit\itshape{9}{1000}{OT1IT}
cannam@167 2049 \setfont\reducedsl\slshape{9}{1000}{OT1}
cannam@167 2050 \setfont\reducedsf\sfshape{9}{1000}{OT1}
cannam@167 2051 \setfont\reducedsc\scshape{10}{900}{OT1}
cannam@167 2052 \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
cannam@167 2053 \font\reducedi=cmmi9
cannam@167 2054 \font\reducedsy=cmsy9
cannam@167 2055 \def\reducedecsize{0900}
cannam@167 2056
cannam@167 2057 \divide\parskip by 2 % reduce space between paragraphs
cannam@167 2058 \textleading = 12pt % line spacing for 10pt CM
cannam@167 2059 \textfonts % reset the current fonts
cannam@167 2060 \rm
cannam@167 2061 } % end of 10pt text font size definitions, \definetextfontsizex
cannam@167 2062
cannam@167 2063
cannam@167 2064 % We provide the user-level command
cannam@167 2065 % @fonttextsize 10
cannam@167 2066 % (or 11) to redefine the text font size. pt is assumed.
cannam@167 2067 %
cannam@167 2068 \def\xiword{11}
cannam@167 2069 \def\xword{10}
cannam@167 2070 \def\xwordpt{10pt}
cannam@167 2071 %
cannam@167 2072 \parseargdef\fonttextsize{%
cannam@167 2073 \def\textsizearg{#1}%
cannam@167 2074 %\wlog{doing @fonttextsize \textsizearg}%
cannam@167 2075 %
cannam@167 2076 % Set \globaldefs so that documents can use this inside @tex, since
cannam@167 2077 % makeinfo 4.8 does not support it, but we need it nonetheless.
cannam@167 2078 %
cannam@167 2079 \begingroup \globaldefs=1
cannam@167 2080 \ifx\textsizearg\xword \definetextfontsizex
cannam@167 2081 \else \ifx\textsizearg\xiword \definetextfontsizexi
cannam@167 2082 \else
cannam@167 2083 \errhelp=\EMsimple
cannam@167 2084 \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
cannam@167 2085 \fi\fi
cannam@167 2086 \endgroup
cannam@167 2087 }
cannam@167 2088
cannam@167 2089
cannam@167 2090 % In order for the font changes to affect most math symbols and letters,
cannam@167 2091 % we have to define the \textfont of the standard families. Since
cannam@167 2092 % texinfo doesn't allow for producing subscripts and superscripts except
cannam@167 2093 % in the main text, we don't bother to reset \scriptfont and
cannam@167 2094 % \scriptscriptfont (which would also require loading a lot more fonts).
cannam@167 2095 %
cannam@167 2096 \def\resetmathfonts{%
cannam@167 2097 \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
cannam@167 2098 \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
cannam@167 2099 \textfont\ttfam=\tentt \textfont\sffam=\tensf
cannam@167 2100 }
cannam@167 2101
cannam@167 2102 % The font-changing commands redefine the meanings of \tenSTYLE, instead
cannam@167 2103 % of just \STYLE. We do this because \STYLE needs to also set the
cannam@167 2104 % current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire
cannam@167 2105 % \tenSTYLE to set the current font.
cannam@167 2106 %
cannam@167 2107 % Each font-changing command also sets the names \lsize (one size lower)
cannam@167 2108 % and \lllsize (three sizes lower). These relative commands are used in
cannam@167 2109 % the LaTeX logo and acronyms.
cannam@167 2110 %
cannam@167 2111 % This all needs generalizing, badly.
cannam@167 2112 %
cannam@167 2113 \def\textfonts{%
cannam@167 2114 \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
cannam@167 2115 \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
cannam@167 2116 \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
cannam@167 2117 \let\tenttsl=\textttsl
cannam@167 2118 \def\curfontsize{text}%
cannam@167 2119 \def\lsize{reduced}\def\lllsize{smaller}%
cannam@167 2120 \resetmathfonts \setleading{\textleading}}
cannam@167 2121 \def\titlefonts{%
cannam@167 2122 \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
cannam@167 2123 \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
cannam@167 2124 \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
cannam@167 2125 \let\tenttsl=\titlettsl
cannam@167 2126 \def\curfontsize{title}%
cannam@167 2127 \def\lsize{chap}\def\lllsize{subsec}%
cannam@167 2128 \resetmathfonts \setleading{27pt}}
cannam@167 2129 \def\titlefont#1{{\titlefonts\rmisbold #1}}
cannam@167 2130 \def\chapfonts{%
cannam@167 2131 \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
cannam@167 2132 \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
cannam@167 2133 \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
cannam@167 2134 \let\tenttsl=\chapttsl
cannam@167 2135 \def\curfontsize{chap}%
cannam@167 2136 \def\lsize{sec}\def\lllsize{text}%
cannam@167 2137 \resetmathfonts \setleading{19pt}}
cannam@167 2138 \def\secfonts{%
cannam@167 2139 \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
cannam@167 2140 \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
cannam@167 2141 \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
cannam@167 2142 \let\tenttsl=\secttsl
cannam@167 2143 \def\curfontsize{sec}%
cannam@167 2144 \def\lsize{subsec}\def\lllsize{reduced}%
cannam@167 2145 \resetmathfonts \setleading{16pt}}
cannam@167 2146 \def\subsecfonts{%
cannam@167 2147 \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
cannam@167 2148 \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
cannam@167 2149 \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
cannam@167 2150 \let\tenttsl=\ssecttsl
cannam@167 2151 \def\curfontsize{ssec}%
cannam@167 2152 \def\lsize{text}\def\lllsize{small}%
cannam@167 2153 \resetmathfonts \setleading{15pt}}
cannam@167 2154 \let\subsubsecfonts = \subsecfonts
cannam@167 2155 \def\reducedfonts{%
cannam@167 2156 \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl
cannam@167 2157 \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc
cannam@167 2158 \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy
cannam@167 2159 \let\tenttsl=\reducedttsl
cannam@167 2160 \def\curfontsize{reduced}%
cannam@167 2161 \def\lsize{small}\def\lllsize{smaller}%
cannam@167 2162 \resetmathfonts \setleading{10.5pt}}
cannam@167 2163 \def\smallfonts{%
cannam@167 2164 \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
cannam@167 2165 \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
cannam@167 2166 \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
cannam@167 2167 \let\tenttsl=\smallttsl
cannam@167 2168 \def\curfontsize{small}%
cannam@167 2169 \def\lsize{smaller}\def\lllsize{smaller}%
cannam@167 2170 \resetmathfonts \setleading{10.5pt}}
cannam@167 2171 \def\smallerfonts{%
cannam@167 2172 \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
cannam@167 2173 \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
cannam@167 2174 \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
cannam@167 2175 \let\tenttsl=\smallerttsl
cannam@167 2176 \def\curfontsize{smaller}%
cannam@167 2177 \def\lsize{smaller}\def\lllsize{smaller}%
cannam@167 2178 \resetmathfonts \setleading{9.5pt}}
cannam@167 2179
cannam@167 2180 % Fonts for short table of contents.
cannam@167 2181 \setfont\shortcontrm\rmshape{12}{1000}{OT1}
cannam@167 2182 \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12
cannam@167 2183 \setfont\shortcontsl\slshape{12}{1000}{OT1}
cannam@167 2184 \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
cannam@167 2185
cannam@167 2186 % Define these just so they can be easily changed for other fonts.
cannam@167 2187 \def\angleleft{$\langle$}
cannam@167 2188 \def\angleright{$\rangle$}
cannam@167 2189
cannam@167 2190 % Set the fonts to use with the @small... environments.
cannam@167 2191 \let\smallexamplefonts = \smallfonts
cannam@167 2192
cannam@167 2193 % About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample
cannam@167 2194 % can fit this many characters:
cannam@167 2195 % 8.5x11=86 smallbook=72 a4=90 a5=69
cannam@167 2196 % If we use \scriptfonts (8pt), then we can fit this many characters:
cannam@167 2197 % 8.5x11=90+ smallbook=80 a4=90+ a5=77
cannam@167 2198 % For me, subjectively, the few extra characters that fit aren't worth
cannam@167 2199 % the additional smallness of 8pt. So I'm making the default 9pt.
cannam@167 2200 %
cannam@167 2201 % By the way, for comparison, here's what fits with @example (10pt):
cannam@167 2202 % 8.5x11=71 smallbook=60 a4=75 a5=58
cannam@167 2203 % --karl, 24jan03.
cannam@167 2204
cannam@167 2205 % Set up the default fonts, so we can use them for creating boxes.
cannam@167 2206 %
cannam@167 2207 \definetextfontsizexi
cannam@167 2208
cannam@167 2209
cannam@167 2210 \message{markup,}
cannam@167 2211
cannam@167 2212 % Check if we are currently using a typewriter font. Since all the
cannam@167 2213 % Computer Modern typewriter fonts have zero interword stretch (and
cannam@167 2214 % shrink), and it is reasonable to expect all typewriter fonts to have
cannam@167 2215 % this property, we can check that font parameter.
cannam@167 2216 %
cannam@167 2217 \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
cannam@167 2218
cannam@167 2219 % Markup style infrastructure. \defmarkupstylesetup\INITMACRO will
cannam@167 2220 % define and register \INITMACRO to be called on markup style changes.
cannam@167 2221 % \INITMACRO can check \currentmarkupstyle for the innermost
cannam@167 2222 % style and the set of \ifmarkupSTYLE switches for all styles
cannam@167 2223 % currently in effect.
cannam@167 2224 \newif\ifmarkupvar
cannam@167 2225 \newif\ifmarkupsamp
cannam@167 2226 \newif\ifmarkupkey
cannam@167 2227 %\newif\ifmarkupfile % @file == @samp.
cannam@167 2228 %\newif\ifmarkupoption % @option == @samp.
cannam@167 2229 \newif\ifmarkupcode
cannam@167 2230 \newif\ifmarkupkbd
cannam@167 2231 %\newif\ifmarkupenv % @env == @code.
cannam@167 2232 %\newif\ifmarkupcommand % @command == @code.
cannam@167 2233 \newif\ifmarkuptex % @tex (and part of @math, for now).
cannam@167 2234 \newif\ifmarkupexample
cannam@167 2235 \newif\ifmarkupverb
cannam@167 2236 \newif\ifmarkupverbatim
cannam@167 2237
cannam@167 2238 \let\currentmarkupstyle\empty
cannam@167 2239
cannam@167 2240 \def\setupmarkupstyle#1{%
cannam@167 2241 \csname markup#1true\endcsname
cannam@167 2242 \def\currentmarkupstyle{#1}%
cannam@167 2243 \markupstylesetup
cannam@167 2244 }
cannam@167 2245
cannam@167 2246 \let\markupstylesetup\empty
cannam@167 2247
cannam@167 2248 \def\defmarkupstylesetup#1{%
cannam@167 2249 \expandafter\def\expandafter\markupstylesetup
cannam@167 2250 \expandafter{\markupstylesetup #1}%
cannam@167 2251 \def#1%
cannam@167 2252 }
cannam@167 2253
cannam@167 2254 % Markup style setup for left and right quotes.
cannam@167 2255 \defmarkupstylesetup\markupsetuplq{%
cannam@167 2256 \expandafter\let\expandafter \temp
cannam@167 2257 \csname markupsetuplq\currentmarkupstyle\endcsname
cannam@167 2258 \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
cannam@167 2259 }
cannam@167 2260
cannam@167 2261 \defmarkupstylesetup\markupsetuprq{%
cannam@167 2262 \expandafter\let\expandafter \temp
cannam@167 2263 \csname markupsetuprq\currentmarkupstyle\endcsname
cannam@167 2264 \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
cannam@167 2265 }
cannam@167 2266
cannam@167 2267 {
cannam@167 2268 \catcode`\'=\active
cannam@167 2269 \catcode`\`=\active
cannam@167 2270
cannam@167 2271 \gdef\markupsetuplqdefault{\let`\lq}
cannam@167 2272 \gdef\markupsetuprqdefault{\let'\rq}
cannam@167 2273
cannam@167 2274 \gdef\markupsetcodequoteleft{\let`\codequoteleft}
cannam@167 2275 \gdef\markupsetcodequoteright{\let'\codequoteright}
cannam@167 2276 }
cannam@167 2277
cannam@167 2278 \let\markupsetuplqcode \markupsetcodequoteleft
cannam@167 2279 \let\markupsetuprqcode \markupsetcodequoteright
cannam@167 2280 %
cannam@167 2281 \let\markupsetuplqexample \markupsetcodequoteleft
cannam@167 2282 \let\markupsetuprqexample \markupsetcodequoteright
cannam@167 2283 %
cannam@167 2284 \let\markupsetuplqkbd \markupsetcodequoteleft
cannam@167 2285 \let\markupsetuprqkbd \markupsetcodequoteright
cannam@167 2286 %
cannam@167 2287 \let\markupsetuplqsamp \markupsetcodequoteleft
cannam@167 2288 \let\markupsetuprqsamp \markupsetcodequoteright
cannam@167 2289 %
cannam@167 2290 \let\markupsetuplqverb \markupsetcodequoteleft
cannam@167 2291 \let\markupsetuprqverb \markupsetcodequoteright
cannam@167 2292 %
cannam@167 2293 \let\markupsetuplqverbatim \markupsetcodequoteleft
cannam@167 2294 \let\markupsetuprqverbatim \markupsetcodequoteright
cannam@167 2295
cannam@167 2296 % Allow an option to not use regular directed right quote/apostrophe
cannam@167 2297 % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
cannam@167 2298 % The undirected quote is ugly, so don't make it the default, but it
cannam@167 2299 % works for pasting with more pdf viewers (at least evince), the
cannam@167 2300 % lilypond developers report. xpdf does work with the regular 0x27.
cannam@167 2301 %
cannam@167 2302 \def\codequoteright{%
cannam@167 2303 \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
cannam@167 2304 \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
cannam@167 2305 '%
cannam@167 2306 \else \char'15 \fi
cannam@167 2307 \else \char'15 \fi
cannam@167 2308 }
cannam@167 2309 %
cannam@167 2310 % and a similar option for the left quote char vs. a grave accent.
cannam@167 2311 % Modern fonts display ASCII 0x60 as a grave accent, so some people like
cannam@167 2312 % the code environments to do likewise.
cannam@167 2313 %
cannam@167 2314 \def\codequoteleft{%
cannam@167 2315 \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
cannam@167 2316 \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
cannam@167 2317 % [Knuth] pp. 380,381,391
cannam@167 2318 % \relax disables Spanish ligatures ?` and !` of \tt font.
cannam@167 2319 \relax`%
cannam@167 2320 \else \char'22 \fi
cannam@167 2321 \else \char'22 \fi
cannam@167 2322 }
cannam@167 2323
cannam@167 2324 % Commands to set the quote options.
cannam@167 2325 %
cannam@167 2326 \parseargdef\codequoteundirected{%
cannam@167 2327 \def\temp{#1}%
cannam@167 2328 \ifx\temp\onword
cannam@167 2329 \expandafter\let\csname SETtxicodequoteundirected\endcsname
cannam@167 2330 = t%
cannam@167 2331 \else\ifx\temp\offword
cannam@167 2332 \expandafter\let\csname SETtxicodequoteundirected\endcsname
cannam@167 2333 = \relax
cannam@167 2334 \else
cannam@167 2335 \errhelp = \EMsimple
cannam@167 2336 \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
cannam@167 2337 \fi\fi
cannam@167 2338 }
cannam@167 2339 %
cannam@167 2340 \parseargdef\codequotebacktick{%
cannam@167 2341 \def\temp{#1}%
cannam@167 2342 \ifx\temp\onword
cannam@167 2343 \expandafter\let\csname SETtxicodequotebacktick\endcsname
cannam@167 2344 = t%
cannam@167 2345 \else\ifx\temp\offword
cannam@167 2346 \expandafter\let\csname SETtxicodequotebacktick\endcsname
cannam@167 2347 = \relax
cannam@167 2348 \else
cannam@167 2349 \errhelp = \EMsimple
cannam@167 2350 \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
cannam@167 2351 \fi\fi
cannam@167 2352 }
cannam@167 2353
cannam@167 2354 % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
cannam@167 2355 \def\noligaturesquoteleft{\relax\lq}
cannam@167 2356
cannam@167 2357 % Count depth in font-changes, for error checks
cannam@167 2358 \newcount\fontdepth \fontdepth=0
cannam@167 2359
cannam@167 2360 % Font commands.
cannam@167 2361
cannam@167 2362 % #1 is the font command (\sl or \it), #2 is the text to slant.
cannam@167 2363 % If we are in a monospaced environment, however, 1) always use \ttsl,
cannam@167 2364 % and 2) do not add an italic correction.
cannam@167 2365 \def\dosmartslant#1#2{%
cannam@167 2366 \ifusingtt
cannam@167 2367 {{\ttsl #2}\let\next=\relax}%
cannam@167 2368 {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
cannam@167 2369 \next
cannam@167 2370 }
cannam@167 2371 \def\smartslanted{\dosmartslant\sl}
cannam@167 2372 \def\smartitalic{\dosmartslant\it}
cannam@167 2373
cannam@167 2374 % Output an italic correction unless \next (presumed to be the following
cannam@167 2375 % character) is such as not to need one.
cannam@167 2376 \def\smartitaliccorrection{%
cannam@167 2377 \ifx\next,%
cannam@167 2378 \else\ifx\next-%
cannam@167 2379 \else\ifx\next.%
cannam@167 2380 \else\ptexslash
cannam@167 2381 \fi\fi\fi
cannam@167 2382 \aftersmartic
cannam@167 2383 }
cannam@167 2384
cannam@167 2385 % Unconditional use \ttsl, and no ic. @var is set to this for defuns.
cannam@167 2386 \def\ttslanted#1{{\ttsl #1}}
cannam@167 2387
cannam@167 2388 % @cite is like \smartslanted except unconditionally use \sl. We never want
cannam@167 2389 % ttsl for book titles, do we?
cannam@167 2390 \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
cannam@167 2391
cannam@167 2392 \def\aftersmartic{}
cannam@167 2393 \def\var#1{%
cannam@167 2394 \let\saveaftersmartic = \aftersmartic
cannam@167 2395 \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
cannam@167 2396 \smartslanted{#1}%
cannam@167 2397 }
cannam@167 2398
cannam@167 2399 \let\i=\smartitalic
cannam@167 2400 \let\slanted=\smartslanted
cannam@167 2401 \let\dfn=\smartslanted
cannam@167 2402 \let\emph=\smartitalic
cannam@167 2403
cannam@167 2404 % Explicit font changes: @r, @sc, undocumented @ii.
cannam@167 2405 \def\r#1{{\rm #1}} % roman font
cannam@167 2406 \def\sc#1{{\smallcaps#1}} % smallcaps font
cannam@167 2407 \def\ii#1{{\it #1}} % italic font
cannam@167 2408
cannam@167 2409 % @b, explicit bold. Also @strong.
cannam@167 2410 \def\b#1{{\bf #1}}
cannam@167 2411 \let\strong=\b
cannam@167 2412
cannam@167 2413 % @sansserif, explicit sans.
cannam@167 2414 \def\sansserif#1{{\sf #1}}
cannam@167 2415
cannam@167 2416 % We can't just use \exhyphenpenalty, because that only has effect at
cannam@167 2417 % the end of a paragraph. Restore normal hyphenation at the end of the
cannam@167 2418 % group within which \nohyphenation is presumably called.
cannam@167 2419 %
cannam@167 2420 \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
cannam@167 2421 \def\restorehyphenation{\hyphenchar\font = `- }
cannam@167 2422
cannam@167 2423 % Set sfcode to normal for the chars that usually have another value.
cannam@167 2424 % Can't use plain's \frenchspacing because it uses the `\x notation, and
cannam@167 2425 % sometimes \x has an active definition that messes things up.
cannam@167 2426 %
cannam@167 2427 \catcode`@=11
cannam@167 2428 \def\plainfrenchspacing{%
cannam@167 2429 \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m
cannam@167 2430 \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m
cannam@167 2431 \def\endofsentencespacefactor{1000}% for @. and friends
cannam@167 2432 }
cannam@167 2433 \def\plainnonfrenchspacing{%
cannam@167 2434 \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
cannam@167 2435 \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
cannam@167 2436 \def\endofsentencespacefactor{3000}% for @. and friends
cannam@167 2437 }
cannam@167 2438 \catcode`@=\other
cannam@167 2439 \def\endofsentencespacefactor{3000}% default
cannam@167 2440
cannam@167 2441 % @t, explicit typewriter.
cannam@167 2442 \def\t#1{%
cannam@167 2443 {\tt \rawbackslash \plainfrenchspacing #1}%
cannam@167 2444 \null
cannam@167 2445 }
cannam@167 2446
cannam@167 2447 % @samp.
cannam@167 2448 \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
cannam@167 2449
cannam@167 2450 % @indicateurl is \samp, that is, with quotes.
cannam@167 2451 \let\indicateurl=\samp
cannam@167 2452
cannam@167 2453 % @code (and similar) prints in typewriter, but with spaces the same
cannam@167 2454 % size as normal in the surrounding text, without hyphenation, etc.
cannam@167 2455 % This is a subroutine for that.
cannam@167 2456 \def\tclose#1{%
cannam@167 2457 {%
cannam@167 2458 % Change normal interword space to be same as for the current font.
cannam@167 2459 \spaceskip = \fontdimen2\font
cannam@167 2460 %
cannam@167 2461 % Switch to typewriter.
cannam@167 2462 \tt
cannam@167 2463 %
cannam@167 2464 % But `\ ' produces the large typewriter interword space.
cannam@167 2465 \def\ {{\spaceskip = 0pt{} }}%
cannam@167 2466 %
cannam@167 2467 % Turn off hyphenation.
cannam@167 2468 \nohyphenation
cannam@167 2469 %
cannam@167 2470 \rawbackslash
cannam@167 2471 \plainfrenchspacing
cannam@167 2472 #1%
cannam@167 2473 }%
cannam@167 2474 \null % reset spacefactor to 1000
cannam@167 2475 }
cannam@167 2476
cannam@167 2477 % We *must* turn on hyphenation at `-' and `_' in @code.
cannam@167 2478 % Otherwise, it is too hard to avoid overfull hboxes
cannam@167 2479 % in the Emacs manual, the Library manual, etc.
cannam@167 2480 %
cannam@167 2481 % Unfortunately, TeX uses one parameter (\hyphenchar) to control
cannam@167 2482 % both hyphenation at - and hyphenation within words.
cannam@167 2483 % We must therefore turn them both off (\tclose does that)
cannam@167 2484 % and arrange explicitly to hyphenate at a dash.
cannam@167 2485 % -- rms.
cannam@167 2486 {
cannam@167 2487 \catcode`\-=\active \catcode`\_=\active
cannam@167 2488 \catcode`\'=\active \catcode`\`=\active
cannam@167 2489 \global\let'=\rq \global\let`=\lq % default definitions
cannam@167 2490 %
cannam@167 2491 \global\def\code{\begingroup
cannam@167 2492 \setupmarkupstyle{code}%
cannam@167 2493 % The following should really be moved into \setupmarkupstyle handlers.
cannam@167 2494 \catcode\dashChar=\active \catcode\underChar=\active
cannam@167 2495 \ifallowcodebreaks
cannam@167 2496 \let-\codedash
cannam@167 2497 \let_\codeunder
cannam@167 2498 \else
cannam@167 2499 \let-\normaldash
cannam@167 2500 \let_\realunder
cannam@167 2501 \fi
cannam@167 2502 \codex
cannam@167 2503 }
cannam@167 2504 }
cannam@167 2505
cannam@167 2506 \def\codex #1{\tclose{#1}\endgroup}
cannam@167 2507
cannam@167 2508 \def\normaldash{-}
cannam@167 2509 \def\codedash{-\discretionary{}{}{}}
cannam@167 2510 \def\codeunder{%
cannam@167 2511 % this is all so @math{@code{var_name}+1} can work. In math mode, _
cannam@167 2512 % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
cannam@167 2513 % will therefore expand the active definition of _, which is us
cannam@167 2514 % (inside @code that is), therefore an endless loop.
cannam@167 2515 \ifusingtt{\ifmmode
cannam@167 2516 \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
cannam@167 2517 \else\normalunderscore \fi
cannam@167 2518 \discretionary{}{}{}}%
cannam@167 2519 {\_}%
cannam@167 2520 }
cannam@167 2521
cannam@167 2522 % An additional complication: the above will allow breaks after, e.g.,
cannam@167 2523 % each of the four underscores in __typeof__. This is bad.
cannam@167 2524 % @allowcodebreaks provides a document-level way to turn breaking at -
cannam@167 2525 % and _ on and off.
cannam@167 2526 %
cannam@167 2527 \newif\ifallowcodebreaks \allowcodebreakstrue
cannam@167 2528
cannam@167 2529 \def\keywordtrue{true}
cannam@167 2530 \def\keywordfalse{false}
cannam@167 2531
cannam@167 2532 \parseargdef\allowcodebreaks{%
cannam@167 2533 \def\txiarg{#1}%
cannam@167 2534 \ifx\txiarg\keywordtrue
cannam@167 2535 \allowcodebreakstrue
cannam@167 2536 \else\ifx\txiarg\keywordfalse
cannam@167 2537 \allowcodebreaksfalse
cannam@167 2538 \else
cannam@167 2539 \errhelp = \EMsimple
cannam@167 2540 \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
cannam@167 2541 \fi\fi
cannam@167 2542 }
cannam@167 2543
cannam@167 2544 % For @command, @env, @file, @option quotes seem unnecessary,
cannam@167 2545 % so use \code rather than \samp.
cannam@167 2546 \let\command=\code
cannam@167 2547 \let\env=\code
cannam@167 2548 \let\file=\code
cannam@167 2549 \let\option=\code
cannam@167 2550
cannam@167 2551 % @uref (abbreviation for `urlref') takes an optional (comma-separated)
cannam@167 2552 % second argument specifying the text to display and an optional third
cannam@167 2553 % arg as text to display instead of (rather than in addition to) the url
cannam@167 2554 % itself. First (mandatory) arg is the url.
cannam@167 2555 % (This \urefnobreak definition isn't used now, leaving it for a while
cannam@167 2556 % for comparison.)
cannam@167 2557 \def\urefnobreak#1{\dourefnobreak #1,,,\finish}
cannam@167 2558 \def\dourefnobreak#1,#2,#3,#4\finish{\begingroup
cannam@167 2559 \unsepspaces
cannam@167 2560 \pdfurl{#1}%
cannam@167 2561 \setbox0 = \hbox{\ignorespaces #3}%
cannam@167 2562 \ifdim\wd0 > 0pt
cannam@167 2563 \unhbox0 % third arg given, show only that
cannam@167 2564 \else
cannam@167 2565 \setbox0 = \hbox{\ignorespaces #2}%
cannam@167 2566 \ifdim\wd0 > 0pt
cannam@167 2567 \ifpdf
cannam@167 2568 \unhbox0 % PDF: 2nd arg given, show only it
cannam@167 2569 \else
cannam@167 2570 \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
cannam@167 2571 \fi
cannam@167 2572 \else
cannam@167 2573 \code{#1}% only url given, so show it
cannam@167 2574 \fi
cannam@167 2575 \fi
cannam@167 2576 \endlink
cannam@167 2577 \endgroup}
cannam@167 2578
cannam@167 2579 % This \urefbreak definition is the active one.
cannam@167 2580 \def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
cannam@167 2581 \let\uref=\urefbreak
cannam@167 2582 \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
cannam@167 2583 \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
cannam@167 2584 \unsepspaces
cannam@167 2585 \pdfurl{#1}%
cannam@167 2586 \setbox0 = \hbox{\ignorespaces #3}%
cannam@167 2587 \ifdim\wd0 > 0pt
cannam@167 2588 \unhbox0 % third arg given, show only that
cannam@167 2589 \else
cannam@167 2590 \setbox0 = \hbox{\ignorespaces #2}%
cannam@167 2591 \ifdim\wd0 > 0pt
cannam@167 2592 \ifpdf
cannam@167 2593 \unhbox0 % PDF: 2nd arg given, show only it
cannam@167 2594 \else
cannam@167 2595 \unhbox0\ (\urefcode{#1})% DVI: 2nd arg given, show both it and url
cannam@167 2596 \fi
cannam@167 2597 \else
cannam@167 2598 \urefcode{#1}% only url given, so show it
cannam@167 2599 \fi
cannam@167 2600 \fi
cannam@167 2601 \endlink
cannam@167 2602 \endgroup}
cannam@167 2603
cannam@167 2604 % Allow line breaks around only a few characters (only).
cannam@167 2605 \def\urefcatcodes{%
cannam@167 2606 \catcode\ampChar=\active \catcode\dotChar=\active
cannam@167 2607 \catcode\hashChar=\active \catcode\questChar=\active
cannam@167 2608 \catcode\slashChar=\active
cannam@167 2609 }
cannam@167 2610 {
cannam@167 2611 \urefcatcodes
cannam@167 2612 %
cannam@167 2613 \global\def\urefcode{\begingroup
cannam@167 2614 \setupmarkupstyle{code}%
cannam@167 2615 \urefcatcodes
cannam@167 2616 \let&\urefcodeamp
cannam@167 2617 \let.\urefcodedot
cannam@167 2618 \let#\urefcodehash
cannam@167 2619 \let?\urefcodequest
cannam@167 2620 \let/\urefcodeslash
cannam@167 2621 \codex
cannam@167 2622 }
cannam@167 2623 %
cannam@167 2624 % By default, they are just regular characters.
cannam@167 2625 \global\def&{\normalamp}
cannam@167 2626 \global\def.{\normaldot}
cannam@167 2627 \global\def#{\normalhash}
cannam@167 2628 \global\def?{\normalquest}
cannam@167 2629 \global\def/{\normalslash}
cannam@167 2630 }
cannam@167 2631
cannam@167 2632 % we put a little stretch before and after the breakable chars, to help
cannam@167 2633 % line breaking of long url's. The unequal skips make look better in
cannam@167 2634 % cmtt at least, especially for dots.
cannam@167 2635 \def\urefprestretch{\urefprebreak \hskip0pt plus.13em }
cannam@167 2636 \def\urefpoststretch{\urefpostbreak \hskip0pt plus.1em }
cannam@167 2637 %
cannam@167 2638 \def\urefcodeamp{\urefprestretch \&\urefpoststretch}
cannam@167 2639 \def\urefcodedot{\urefprestretch .\urefpoststretch}
cannam@167 2640 \def\urefcodehash{\urefprestretch \#\urefpoststretch}
cannam@167 2641 \def\urefcodequest{\urefprestretch ?\urefpoststretch}
cannam@167 2642 \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
cannam@167 2643 {
cannam@167 2644 \catcode`\/=\active
cannam@167 2645 \global\def\urefcodeslashfinish{%
cannam@167 2646 \urefprestretch \slashChar
cannam@167 2647 % Allow line break only after the final / in a sequence of
cannam@167 2648 % slashes, to avoid line break between the slashes in http://.
cannam@167 2649 \ifx\next/\else \urefpoststretch \fi
cannam@167 2650 }
cannam@167 2651 }
cannam@167 2652
cannam@167 2653 % One more complication: by default we'll break after the special
cannam@167 2654 % characters, but some people like to break before the special chars, so
cannam@167 2655 % allow that. Also allow no breaking at all, for manual control.
cannam@167 2656 %
cannam@167 2657 \parseargdef\urefbreakstyle{%
cannam@167 2658 \def\txiarg{#1}%
cannam@167 2659 \ifx\txiarg\wordnone
cannam@167 2660 \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
cannam@167 2661 \else\ifx\txiarg\wordbefore
cannam@167 2662 \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
cannam@167 2663 \else\ifx\txiarg\wordafter
cannam@167 2664 \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
cannam@167 2665 \else
cannam@167 2666 \errhelp = \EMsimple
cannam@167 2667 \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
cannam@167 2668 \fi\fi\fi
cannam@167 2669 }
cannam@167 2670 \def\wordafter{after}
cannam@167 2671 \def\wordbefore{before}
cannam@167 2672 \def\wordnone{none}
cannam@167 2673
cannam@167 2674 \urefbreakstyle after
cannam@167 2675
cannam@167 2676 % @url synonym for @uref, since that's how everyone uses it.
cannam@167 2677 %
cannam@167 2678 \let\url=\uref
cannam@167 2679
cannam@167 2680 % rms does not like angle brackets --karl, 17may97.
cannam@167 2681 % So now @email is just like @uref, unless we are pdf.
cannam@167 2682 %
cannam@167 2683 %\def\email#1{\angleleft{\tt #1}\angleright}
cannam@167 2684 \ifpdf
cannam@167 2685 \def\email#1{\doemail#1,,\finish}
cannam@167 2686 \def\doemail#1,#2,#3\finish{\begingroup
cannam@167 2687 \unsepspaces
cannam@167 2688 \pdfurl{mailto:#1}%
cannam@167 2689 \setbox0 = \hbox{\ignorespaces #2}%
cannam@167 2690 \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
cannam@167 2691 \endlink
cannam@167 2692 \endgroup}
cannam@167 2693 \else
cannam@167 2694 \let\email=\uref
cannam@167 2695 \fi
cannam@167 2696
cannam@167 2697 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
cannam@167 2698 % `example' (@kbd uses ttsl only inside of @example and friends),
cannam@167 2699 % or `code' (@kbd uses normal tty font always).
cannam@167 2700 \parseargdef\kbdinputstyle{%
cannam@167 2701 \def\txiarg{#1}%
cannam@167 2702 \ifx\txiarg\worddistinct
cannam@167 2703 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
cannam@167 2704 \else\ifx\txiarg\wordexample
cannam@167 2705 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
cannam@167 2706 \else\ifx\txiarg\wordcode
cannam@167 2707 \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
cannam@167 2708 \else
cannam@167 2709 \errhelp = \EMsimple
cannam@167 2710 \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
cannam@167 2711 \fi\fi\fi
cannam@167 2712 }
cannam@167 2713 \def\worddistinct{distinct}
cannam@167 2714 \def\wordexample{example}
cannam@167 2715 \def\wordcode{code}
cannam@167 2716
cannam@167 2717 % Default is `distinct'.
cannam@167 2718 \kbdinputstyle distinct
cannam@167 2719
cannam@167 2720 % @kbd is like @code, except that if the argument is just one @key command,
cannam@167 2721 % then @kbd has no effect.
cannam@167 2722 \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
cannam@167 2723
cannam@167 2724 \def\xkey{\key}
cannam@167 2725 \def\kbdsub#1#2#3\par{%
cannam@167 2726 \def\one{#1}\def\three{#3}\def\threex{??}%
cannam@167 2727 \ifx\one\xkey\ifx\threex\three \key{#2}%
cannam@167 2728 \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
cannam@167 2729 \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
cannam@167 2730 }
cannam@167 2731
cannam@167 2732 % definition of @key that produces a lozenge. Doesn't adjust to text size.
cannam@167 2733 %\setfont\keyrm\rmshape{8}{1000}{OT1}
cannam@167 2734 %\font\keysy=cmsy9
cannam@167 2735 %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
cannam@167 2736 % \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
cannam@167 2737 % \vbox{\hrule\kern-0.4pt
cannam@167 2738 % \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
cannam@167 2739 % \kern-0.4pt\hrule}%
cannam@167 2740 % \kern-.06em\raise0.4pt\hbox{\angleright}}}}
cannam@167 2741
cannam@167 2742 % definition of @key with no lozenge. If the current font is already
cannam@167 2743 % monospace, don't change it; that way, we respect @kbdinputstyle. But
cannam@167 2744 % if it isn't monospace, then use \tt.
cannam@167 2745 %
cannam@167 2746 \def\key#1{{\setupmarkupstyle{key}%
cannam@167 2747 \nohyphenation
cannam@167 2748 \ifmonospace\else\tt\fi
cannam@167 2749 #1}\null}
cannam@167 2750
cannam@167 2751 % @clicksequence{File @click{} Open ...}
cannam@167 2752 \def\clicksequence#1{\begingroup #1\endgroup}
cannam@167 2753
cannam@167 2754 % @clickstyle @arrow (by default)
cannam@167 2755 \parseargdef\clickstyle{\def\click{#1}}
cannam@167 2756 \def\click{\arrow}
cannam@167 2757
cannam@167 2758 % Typeset a dimension, e.g., `in' or `pt'. The only reason for the
cannam@167 2759 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
cannam@167 2760 %
cannam@167 2761 \def\dmn#1{\thinspace #1}
cannam@167 2762
cannam@167 2763 % @l was never documented to mean ``switch to the Lisp font'',
cannam@167 2764 % and it is not used as such in any manual I can find. We need it for
cannam@167 2765 % Polish suppressed-l. --karl, 22sep96.
cannam@167 2766 %\def\l#1{{\li #1}\null}
cannam@167 2767
cannam@167 2768 % @acronym for "FBI", "NATO", and the like.
cannam@167 2769 % We print this one point size smaller, since it's intended for
cannam@167 2770 % all-uppercase.
cannam@167 2771 %
cannam@167 2772 \def\acronym#1{\doacronym #1,,\finish}
cannam@167 2773 \def\doacronym#1,#2,#3\finish{%
cannam@167 2774 {\selectfonts\lsize #1}%
cannam@167 2775 \def\temp{#2}%
cannam@167 2776 \ifx\temp\empty \else
cannam@167 2777 \space ({\unsepspaces \ignorespaces \temp \unskip})%
cannam@167 2778 \fi
cannam@167 2779 \null % reset \spacefactor=1000
cannam@167 2780 }
cannam@167 2781
cannam@167 2782 % @abbr for "Comput. J." and the like.
cannam@167 2783 % No font change, but don't do end-of-sentence spacing.
cannam@167 2784 %
cannam@167 2785 \def\abbr#1{\doabbr #1,,\finish}
cannam@167 2786 \def\doabbr#1,#2,#3\finish{%
cannam@167 2787 {\plainfrenchspacing #1}%
cannam@167 2788 \def\temp{#2}%
cannam@167 2789 \ifx\temp\empty \else
cannam@167 2790 \space ({\unsepspaces \ignorespaces \temp \unskip})%
cannam@167 2791 \fi
cannam@167 2792 \null % reset \spacefactor=1000
cannam@167 2793 }
cannam@167 2794
cannam@167 2795 % @asis just yields its argument. Used with @table, for example.
cannam@167 2796 %
cannam@167 2797 \def\asis#1{#1}
cannam@167 2798
cannam@167 2799 % @math outputs its argument in math mode.
cannam@167 2800 %
cannam@167 2801 % One complication: _ usually means subscripts, but it could also mean
cannam@167 2802 % an actual _ character, as in @math{@var{some_variable} + 1}. So make
cannam@167 2803 % _ active, and distinguish by seeing if the current family is \slfam,
cannam@167 2804 % which is what @var uses.
cannam@167 2805 {
cannam@167 2806 \catcode`\_ = \active
cannam@167 2807 \gdef\mathunderscore{%
cannam@167 2808 \catcode`\_=\active
cannam@167 2809 \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
cannam@167 2810 }
cannam@167 2811 }
cannam@167 2812 % Another complication: we want \\ (and @\) to output a math (or tt) \.
cannam@167 2813 % FYI, plain.tex uses \\ as a temporary control sequence (for no
cannam@167 2814 % particular reason), but this is not advertised and we don't care.
cannam@167 2815 %
cannam@167 2816 % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
cannam@167 2817 \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
cannam@167 2818 %
cannam@167 2819 \def\math{%
cannam@167 2820 \tex
cannam@167 2821 \mathunderscore
cannam@167 2822 \let\\ = \mathbackslash
cannam@167 2823 \mathactive
cannam@167 2824 % make the texinfo accent commands work in math mode
cannam@167 2825 \let\"=\ddot
cannam@167 2826 \let\'=\acute
cannam@167 2827 \let\==\bar
cannam@167 2828 \let\^=\hat
cannam@167 2829 \let\`=\grave
cannam@167 2830 \let\u=\breve
cannam@167 2831 \let\v=\check
cannam@167 2832 \let\~=\tilde
cannam@167 2833 \let\dotaccent=\dot
cannam@167 2834 $\finishmath
cannam@167 2835 }
cannam@167 2836 \def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
cannam@167 2837
cannam@167 2838 % Some active characters (such as <) are spaced differently in math.
cannam@167 2839 % We have to reset their definitions in case the @math was an argument
cannam@167 2840 % to a command which sets the catcodes (such as @item or @section).
cannam@167 2841 %
cannam@167 2842 {
cannam@167 2843 \catcode`^ = \active
cannam@167 2844 \catcode`< = \active
cannam@167 2845 \catcode`> = \active
cannam@167 2846 \catcode`+ = \active
cannam@167 2847 \catcode`' = \active
cannam@167 2848 \gdef\mathactive{%
cannam@167 2849 \let^ = \ptexhat
cannam@167 2850 \let< = \ptexless
cannam@167 2851 \let> = \ptexgtr
cannam@167 2852 \let+ = \ptexplus
cannam@167 2853 \let' = \ptexquoteright
cannam@167 2854 }
cannam@167 2855 }
cannam@167 2856
cannam@167 2857 % ctrl is no longer a Texinfo command, but leave this definition for fun.
cannam@167 2858 \def\ctrl #1{{\tt \rawbackslash \hat}#1}
cannam@167 2859
cannam@167 2860 % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
cannam@167 2861 % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
cannam@167 2862 % except specified as a normal braced arg, so no newlines to worry about.
cannam@167 2863 %
cannam@167 2864 \def\outfmtnametex{tex}
cannam@167 2865 %
cannam@167 2866 \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
cannam@167 2867 \long\def\doinlinefmt#1,#2,\finish{%
cannam@167 2868 \def\inlinefmtname{#1}%
cannam@167 2869 \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
cannam@167 2870 }
cannam@167 2871 % For raw, must switch into @tex before parsing the argument, to avoid
cannam@167 2872 % setting catcodes prematurely. Doing it this way means that, for
cannam@167 2873 % example, @inlineraw{html, foo{bar} gets a parse error instead of being
cannam@167 2874 % ignored. But this isn't important because if people want a literal
cannam@167 2875 % *right* brace they would have to use a command anyway, so they may as
cannam@167 2876 % well use a command to get a left brace too. We could re-use the
cannam@167 2877 % delimiter character idea from \verb, but it seems like overkill.
cannam@167 2878 %
cannam@167 2879 \long\def\inlineraw{\tex \doinlineraw}
cannam@167 2880 \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
cannam@167 2881 \def\doinlinerawtwo#1,#2,\finish{%
cannam@167 2882 \def\inlinerawname{#1}%
cannam@167 2883 \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
cannam@167 2884 \endgroup % close group opened by \tex.
cannam@167 2885 }
cannam@167 2886
cannam@167 2887
cannam@167 2888 \message{glyphs,}
cannam@167 2889 % and logos.
cannam@167 2890
cannam@167 2891 % @@ prints an @, as does @atchar{}.
cannam@167 2892 \def\@{\char64 }
cannam@167 2893 \let\atchar=\@
cannam@167 2894
cannam@167 2895 % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
cannam@167 2896 % Unless we're in typewriter, use \ecfont because the CM text fonts do
cannam@167 2897 % not have braces, and we don't want to switch into math.
cannam@167 2898 \def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}}
cannam@167 2899 \def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}}
cannam@167 2900 \let\{=\mylbrace \let\lbracechar=\{
cannam@167 2901 \let\}=\myrbrace \let\rbracechar=\}
cannam@167 2902 \begingroup
cannam@167 2903 % Definitions to produce \{ and \} commands for indices,
cannam@167 2904 % and @{ and @} for the aux/toc files.
cannam@167 2905 \catcode`\{ = \other \catcode`\} = \other
cannam@167 2906 \catcode`\[ = 1 \catcode`\] = 2
cannam@167 2907 \catcode`\! = 0 \catcode`\\ = \other
cannam@167 2908 !gdef!lbracecmd[\{]%
cannam@167 2909 !gdef!rbracecmd[\}]%
cannam@167 2910 !gdef!lbraceatcmd[@{]%
cannam@167 2911 !gdef!rbraceatcmd[@}]%
cannam@167 2912 !endgroup
cannam@167 2913
cannam@167 2914 % @comma{} to avoid , parsing problems.
cannam@167 2915 \let\comma = ,
cannam@167 2916
cannam@167 2917 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
cannam@167 2918 % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
cannam@167 2919 \let\, = \ptexc
cannam@167 2920 \let\dotaccent = \ptexdot
cannam@167 2921 \def\ringaccent#1{{\accent23 #1}}
cannam@167 2922 \let\tieaccent = \ptext
cannam@167 2923 \let\ubaraccent = \ptexb
cannam@167 2924 \let\udotaccent = \d
cannam@167 2925
cannam@167 2926 % Other special characters: @questiondown @exclamdown @ordf @ordm
cannam@167 2927 % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
cannam@167 2928 \def\questiondown{?`}
cannam@167 2929 \def\exclamdown{!`}
cannam@167 2930 \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
cannam@167 2931 \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
cannam@167 2932
cannam@167 2933 % Dotless i and dotless j, used for accents.
cannam@167 2934 \def\imacro{i}
cannam@167 2935 \def\jmacro{j}
cannam@167 2936 \def\dotless#1{%
cannam@167 2937 \def\temp{#1}%
cannam@167 2938 \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
cannam@167 2939 \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
cannam@167 2940 \else \errmessage{@dotless can be used only with i or j}%
cannam@167 2941 \fi\fi
cannam@167 2942 }
cannam@167 2943
cannam@167 2944 % The \TeX{} logo, as in plain, but resetting the spacing so that a
cannam@167 2945 % period following counts as ending a sentence. (Idea found in latex.)
cannam@167 2946 %
cannam@167 2947 \edef\TeX{\TeX \spacefactor=1000 }
cannam@167 2948
cannam@167 2949 % @LaTeX{} logo. Not quite the same results as the definition in
cannam@167 2950 % latex.ltx, since we use a different font for the raised A; it's most
cannam@167 2951 % convenient for us to use an explicitly smaller font, rather than using
cannam@167 2952 % the \scriptstyle font (since we don't reset \scriptstyle and
cannam@167 2953 % \scriptscriptstyle).
cannam@167 2954 %
cannam@167 2955 \def\LaTeX{%
cannam@167 2956 L\kern-.36em
cannam@167 2957 {\setbox0=\hbox{T}%
cannam@167 2958 \vbox to \ht0{\hbox{%
cannam@167 2959 \ifx\textnominalsize\xwordpt
cannam@167 2960 % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX.
cannam@167 2961 % Revert to plain's \scriptsize, which is 7pt.
cannam@167 2962 \count255=\the\fam $\fam\count255 \scriptstyle A$%
cannam@167 2963 \else
cannam@167 2964 % For 11pt, we can use our lllsize.
cannam@167 2965 \selectfonts\lllsize A%
cannam@167 2966 \fi
cannam@167 2967 }%
cannam@167 2968 \vss
cannam@167 2969 }}%
cannam@167 2970 \kern-.15em
cannam@167 2971 \TeX
cannam@167 2972 }
cannam@167 2973
cannam@167 2974 % Some math mode symbols.
cannam@167 2975 \def\bullet{$\ptexbullet$}
cannam@167 2976 \def\geq{\ifmmode \ge\else $\ge$\fi}
cannam@167 2977 \def\leq{\ifmmode \le\else $\le$\fi}
cannam@167 2978 \def\minus{\ifmmode -\else $-$\fi}
cannam@167 2979
cannam@167 2980 % @dots{} outputs an ellipsis using the current font.
cannam@167 2981 % We do .5em per period so that it has the same spacing in the cm
cannam@167 2982 % typewriter fonts as three actual period characters; on the other hand,
cannam@167 2983 % in other typewriter fonts three periods are wider than 1.5em. So do
cannam@167 2984 % whichever is larger.
cannam@167 2985 %
cannam@167 2986 \def\dots{%
cannam@167 2987 \leavevmode
cannam@167 2988 \setbox0=\hbox{...}% get width of three periods
cannam@167 2989 \ifdim\wd0 > 1.5em
cannam@167 2990 \dimen0 = \wd0
cannam@167 2991 \else
cannam@167 2992 \dimen0 = 1.5em
cannam@167 2993 \fi
cannam@167 2994 \hbox to \dimen0{%
cannam@167 2995 \hskip 0pt plus.25fil
cannam@167 2996 .\hskip 0pt plus1fil
cannam@167 2997 .\hskip 0pt plus1fil
cannam@167 2998 .\hskip 0pt plus.5fil
cannam@167 2999 }%
cannam@167 3000 }
cannam@167 3001
cannam@167 3002 % @enddots{} is an end-of-sentence ellipsis.
cannam@167 3003 %
cannam@167 3004 \def\enddots{%
cannam@167 3005 \dots
cannam@167 3006 \spacefactor=\endofsentencespacefactor
cannam@167 3007 }
cannam@167 3008
cannam@167 3009 % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
cannam@167 3010 %
cannam@167 3011 % Since these characters are used in examples, they should be an even number of
cannam@167 3012 % \tt widths. Each \tt character is 1en, so two makes it 1em.
cannam@167 3013 %
cannam@167 3014 \def\point{$\star$}
cannam@167 3015 \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
cannam@167 3016 \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
cannam@167 3017 \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
cannam@167 3018 \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
cannam@167 3019 \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
cannam@167 3020
cannam@167 3021 % The @error{} command.
cannam@167 3022 % Adapted from the TeXbook's \boxit.
cannam@167 3023 %
cannam@167 3024 \newbox\errorbox
cannam@167 3025 %
cannam@167 3026 {\tentt \global\dimen0 = 3em}% Width of the box.
cannam@167 3027 \dimen2 = .55pt % Thickness of rules
cannam@167 3028 % The text. (`r' is open on the right, `e' somewhat less so on the left.)
cannam@167 3029 \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
cannam@167 3030 %
cannam@167 3031 \setbox\errorbox=\hbox to \dimen0{\hfil
cannam@167 3032 \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
cannam@167 3033 \advance\hsize by -2\dimen2 % Rules.
cannam@167 3034 \vbox{%
cannam@167 3035 \hrule height\dimen2
cannam@167 3036 \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
cannam@167 3037 \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
cannam@167 3038 \kern3pt\vrule width\dimen2}% Space to right.
cannam@167 3039 \hrule height\dimen2}
cannam@167 3040 \hfil}
cannam@167 3041 %
cannam@167 3042 \def\error{\leavevmode\lower.7ex\copy\errorbox}
cannam@167 3043
cannam@167 3044 % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
cannam@167 3045 %
cannam@167 3046 \def\pounds{{\it\$}}
cannam@167 3047
cannam@167 3048 % @euro{} comes from a separate font, depending on the current style.
cannam@167 3049 % We use the free feym* fonts from the eurosym package by Henrik
cannam@167 3050 % Theiling, which support regular, slanted, bold and bold slanted (and
cannam@167 3051 % "outlined" (blackboard board, sort of) versions, which we don't need).
cannam@167 3052 % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
cannam@167 3053 %
cannam@167 3054 % Although only regular is the truly official Euro symbol, we ignore
cannam@167 3055 % that. The Euro is designed to be slightly taller than the regular
cannam@167 3056 % font height.
cannam@167 3057 %
cannam@167 3058 % feymr - regular
cannam@167 3059 % feymo - slanted
cannam@167 3060 % feybr - bold
cannam@167 3061 % feybo - bold slanted
cannam@167 3062 %
cannam@167 3063 % There is no good (free) typewriter version, to my knowledge.
cannam@167 3064 % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
cannam@167 3065 % Hmm.
cannam@167 3066 %
cannam@167 3067 % Also doesn't work in math. Do we need to do math with euro symbols?
cannam@167 3068 % Hope not.
cannam@167 3069 %
cannam@167 3070 %
cannam@167 3071 \def\euro{{\eurofont e}}
cannam@167 3072 \def\eurofont{%
cannam@167 3073 % We set the font at each command, rather than predefining it in
cannam@167 3074 % \textfonts and the other font-switching commands, so that
cannam@167 3075 % installations which never need the symbol don't have to have the
cannam@167 3076 % font installed.
cannam@167 3077 %
cannam@167 3078 % There is only one designed size (nominal 10pt), so we always scale
cannam@167 3079 % that to the current nominal size.
cannam@167 3080 %
cannam@167 3081 % By the way, simply using "at 1em" works for cmr10 and the like, but
cannam@167 3082 % does not work for cmbx10 and other extended/shrunken fonts.
cannam@167 3083 %
cannam@167 3084 \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
cannam@167 3085 %
cannam@167 3086 \ifx\curfontstyle\bfstylename
cannam@167 3087 % bold:
cannam@167 3088 \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
cannam@167 3089 \else
cannam@167 3090 % regular:
cannam@167 3091 \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
cannam@167 3092 \fi
cannam@167 3093 \thiseurofont
cannam@167 3094 }
cannam@167 3095
cannam@167 3096 % Glyphs from the EC fonts. We don't use \let for the aliases, because
cannam@167 3097 % sometimes we redefine the original macro, and the alias should reflect
cannam@167 3098 % the redefinition.
cannam@167 3099 %
cannam@167 3100 % Use LaTeX names for the Icelandic letters.
cannam@167 3101 \def\DH{{\ecfont \char"D0}} % Eth
cannam@167 3102 \def\dh{{\ecfont \char"F0}} % eth
cannam@167 3103 \def\TH{{\ecfont \char"DE}} % Thorn
cannam@167 3104 \def\th{{\ecfont \char"FE}} % thorn
cannam@167 3105 %
cannam@167 3106 \def\guillemetleft{{\ecfont \char"13}}
cannam@167 3107 \def\guillemotleft{\guillemetleft}
cannam@167 3108 \def\guillemetright{{\ecfont \char"14}}
cannam@167 3109 \def\guillemotright{\guillemetright}
cannam@167 3110 \def\guilsinglleft{{\ecfont \char"0E}}
cannam@167 3111 \def\guilsinglright{{\ecfont \char"0F}}
cannam@167 3112 \def\quotedblbase{{\ecfont \char"12}}
cannam@167 3113 \def\quotesinglbase{{\ecfont \char"0D}}
cannam@167 3114 %
cannam@167 3115 % This positioning is not perfect (see the ogonek LaTeX package), but
cannam@167 3116 % we have the precomposed glyphs for the most common cases. We put the
cannam@167 3117 % tests to use those glyphs in the single \ogonek macro so we have fewer
cannam@167 3118 % dummy definitions to worry about for index entries, etc.
cannam@167 3119 %
cannam@167 3120 % ogonek is also used with other letters in Lithuanian (IOU), but using
cannam@167 3121 % the precomposed glyphs for those is not so easy since they aren't in
cannam@167 3122 % the same EC font.
cannam@167 3123 \def\ogonek#1{{%
cannam@167 3124 \def\temp{#1}%
cannam@167 3125 \ifx\temp\macrocharA\Aogonek
cannam@167 3126 \else\ifx\temp\macrochara\aogonek
cannam@167 3127 \else\ifx\temp\macrocharE\Eogonek
cannam@167 3128 \else\ifx\temp\macrochare\eogonek
cannam@167 3129 \else
cannam@167 3130 \ecfont \setbox0=\hbox{#1}%
cannam@167 3131 \ifdim\ht0=1ex\accent"0C #1%
cannam@167 3132 \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
cannam@167 3133 \fi
cannam@167 3134 \fi\fi\fi\fi
cannam@167 3135 }%
cannam@167 3136 }
cannam@167 3137 \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
cannam@167 3138 \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
cannam@167 3139 \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
cannam@167 3140 \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
cannam@167 3141 %
cannam@167 3142 % Use the ec* fonts (cm-super in outline format) for non-CM glyphs.
cannam@167 3143 \def\ecfont{%
cannam@167 3144 % We can't distinguish serif/sans and italic/slanted, but this
cannam@167 3145 % is used for crude hacks anyway (like adding French and German
cannam@167 3146 % quotes to documents typeset with CM, where we lose kerning), so
cannam@167 3147 % hopefully nobody will notice/care.
cannam@167 3148 \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
cannam@167 3149 \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
cannam@167 3150 \ifmonospace
cannam@167 3151 % typewriter:
cannam@167 3152 \font\thisecfont = ectt\ecsize \space at \nominalsize
cannam@167 3153 \else
cannam@167 3154 \ifx\curfontstyle\bfstylename
cannam@167 3155 % bold:
cannam@167 3156 \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize
cannam@167 3157 \else
cannam@167 3158 % regular:
cannam@167 3159 \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize
cannam@167 3160 \fi
cannam@167 3161 \fi
cannam@167 3162 \thisecfont
cannam@167 3163 }
cannam@167 3164
cannam@167 3165 % @registeredsymbol - R in a circle. The font for the R should really
cannam@167 3166 % be smaller yet, but lllsize is the best we can do for now.
cannam@167 3167 % Adapted from the plain.tex definition of \copyright.
cannam@167 3168 %
cannam@167 3169 \def\registeredsymbol{%
cannam@167 3170 $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
cannam@167 3171 \hfil\crcr\Orb}}%
cannam@167 3172 }$%
cannam@167 3173 }
cannam@167 3174
cannam@167 3175 % @textdegree - the normal degrees sign.
cannam@167 3176 %
cannam@167 3177 \def\textdegree{$^\circ$}
cannam@167 3178
cannam@167 3179 % Laurent Siebenmann reports \Orb undefined with:
cannam@167 3180 % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
cannam@167 3181 % so we'll define it if necessary.
cannam@167 3182 %
cannam@167 3183 \ifx\Orb\thisisundefined
cannam@167 3184 \def\Orb{\mathhexbox20D}
cannam@167 3185 \fi
cannam@167 3186
cannam@167 3187 % Quotes.
cannam@167 3188 \chardef\quotedblleft="5C
cannam@167 3189 \chardef\quotedblright=`\"
cannam@167 3190 \chardef\quoteleft=`\`
cannam@167 3191 \chardef\quoteright=`\'
cannam@167 3192
cannam@167 3193
cannam@167 3194 \message{page headings,}
cannam@167 3195
cannam@167 3196 \newskip\titlepagetopglue \titlepagetopglue = 1.5in
cannam@167 3197 \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
cannam@167 3198
cannam@167 3199 % First the title page. Must do @settitle before @titlepage.
cannam@167 3200 \newif\ifseenauthor
cannam@167 3201 \newif\iffinishedtitlepage
cannam@167 3202
cannam@167 3203 % Do an implicit @contents or @shortcontents after @end titlepage if the
cannam@167 3204 % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
cannam@167 3205 %
cannam@167 3206 \newif\ifsetcontentsaftertitlepage
cannam@167 3207 \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
cannam@167 3208 \newif\ifsetshortcontentsaftertitlepage
cannam@167 3209 \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
cannam@167 3210
cannam@167 3211 \parseargdef\shorttitlepage{%
cannam@167 3212 \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
cannam@167 3213 \endgroup\page\hbox{}\page}
cannam@167 3214
cannam@167 3215 \envdef\titlepage{%
cannam@167 3216 % Open one extra group, as we want to close it in the middle of \Etitlepage.
cannam@167 3217 \begingroup
cannam@167 3218 \parindent=0pt \textfonts
cannam@167 3219 % Leave some space at the very top of the page.
cannam@167 3220 \vglue\titlepagetopglue
cannam@167 3221 % No rule at page bottom unless we print one at the top with @title.
cannam@167 3222 \finishedtitlepagetrue
cannam@167 3223 %
cannam@167 3224 % Most title ``pages'' are actually two pages long, with space
cannam@167 3225 % at the top of the second. We don't want the ragged left on the second.
cannam@167 3226 \let\oldpage = \page
cannam@167 3227 \def\page{%
cannam@167 3228 \iffinishedtitlepage\else
cannam@167 3229 \finishtitlepage
cannam@167 3230 \fi
cannam@167 3231 \let\page = \oldpage
cannam@167 3232 \page
cannam@167 3233 \null
cannam@167 3234 }%
cannam@167 3235 }
cannam@167 3236
cannam@167 3237 \def\Etitlepage{%
cannam@167 3238 \iffinishedtitlepage\else
cannam@167 3239 \finishtitlepage
cannam@167 3240 \fi
cannam@167 3241 % It is important to do the page break before ending the group,
cannam@167 3242 % because the headline and footline are only empty inside the group.
cannam@167 3243 % If we use the new definition of \page, we always get a blank page
cannam@167 3244 % after the title page, which we certainly don't want.
cannam@167 3245 \oldpage
cannam@167 3246 \endgroup
cannam@167 3247 %
cannam@167 3248 % Need this before the \...aftertitlepage checks so that if they are
cannam@167 3249 % in effect the toc pages will come out with page numbers.
cannam@167 3250 \HEADINGSon
cannam@167 3251 %
cannam@167 3252 % If they want short, they certainly want long too.
cannam@167 3253 \ifsetshortcontentsaftertitlepage
cannam@167 3254 \shortcontents
cannam@167 3255 \contents
cannam@167 3256 \global\let\shortcontents = \relax
cannam@167 3257 \global\let\contents = \relax
cannam@167 3258 \fi
cannam@167 3259 %
cannam@167 3260 \ifsetcontentsaftertitlepage
cannam@167 3261 \contents
cannam@167 3262 \global\let\contents = \relax
cannam@167 3263 \global\let\shortcontents = \relax
cannam@167 3264 \fi
cannam@167 3265 }
cannam@167 3266
cannam@167 3267 \def\finishtitlepage{%
cannam@167 3268 \vskip4pt \hrule height 2pt width \hsize
cannam@167 3269 \vskip\titlepagebottomglue
cannam@167 3270 \finishedtitlepagetrue
cannam@167 3271 }
cannam@167 3272
cannam@167 3273 % Settings used for typesetting titles: no hyphenation, no indentation,
cannam@167 3274 % don't worry much about spacing, ragged right. This should be used
cannam@167 3275 % inside a \vbox, and fonts need to be set appropriately first. Because
cannam@167 3276 % it is always used for titles, nothing else, we call \rmisbold. \par
cannam@167 3277 % should be specified before the end of the \vbox, since a vbox is a group.
cannam@167 3278 %
cannam@167 3279 \def\raggedtitlesettings{%
cannam@167 3280 \rmisbold
cannam@167 3281 \hyphenpenalty=10000
cannam@167 3282 \parindent=0pt
cannam@167 3283 \tolerance=5000
cannam@167 3284 \ptexraggedright
cannam@167 3285 }
cannam@167 3286
cannam@167 3287 % Macros to be used within @titlepage:
cannam@167 3288
cannam@167 3289 \let\subtitlerm=\tenrm
cannam@167 3290 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
cannam@167 3291
cannam@167 3292 \parseargdef\title{%
cannam@167 3293 \checkenv\titlepage
cannam@167 3294 \vbox{\titlefonts \raggedtitlesettings #1\par}%
cannam@167 3295 % print a rule at the page bottom also.
cannam@167 3296 \finishedtitlepagefalse
cannam@167 3297 \vskip4pt \hrule height 4pt width \hsize \vskip4pt
cannam@167 3298 }
cannam@167 3299
cannam@167 3300 \parseargdef\subtitle{%
cannam@167 3301 \checkenv\titlepage
cannam@167 3302 {\subtitlefont \rightline{#1}}%
cannam@167 3303 }
cannam@167 3304
cannam@167 3305 % @author should come last, but may come many times.
cannam@167 3306 % It can also be used inside @quotation.
cannam@167 3307 %
cannam@167 3308 \parseargdef\author{%
cannam@167 3309 \def\temp{\quotation}%
cannam@167 3310 \ifx\thisenv\temp
cannam@167 3311 \def\quotationauthor{#1}% printed in \Equotation.
cannam@167 3312 \else
cannam@167 3313 \checkenv\titlepage
cannam@167 3314 \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
cannam@167 3315 {\secfonts\rmisbold \leftline{#1}}%
cannam@167 3316 \fi
cannam@167 3317 }
cannam@167 3318
cannam@167 3319
cannam@167 3320 % Set up page headings and footings.
cannam@167 3321
cannam@167 3322 \let\thispage=\folio
cannam@167 3323
cannam@167 3324 \newtoks\evenheadline % headline on even pages
cannam@167 3325 \newtoks\oddheadline % headline on odd pages
cannam@167 3326 \newtoks\evenfootline % footline on even pages
cannam@167 3327 \newtoks\oddfootline % footline on odd pages
cannam@167 3328
cannam@167 3329 % Now make TeX use those variables
cannam@167 3330 \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
cannam@167 3331 \else \the\evenheadline \fi}}
cannam@167 3332 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
cannam@167 3333 \else \the\evenfootline \fi}\HEADINGShook}
cannam@167 3334 \let\HEADINGShook=\relax
cannam@167 3335
cannam@167 3336 % Commands to set those variables.
cannam@167 3337 % For example, this is what @headings on does
cannam@167 3338 % @evenheading @thistitle|@thispage|@thischapter
cannam@167 3339 % @oddheading @thischapter|@thispage|@thistitle
cannam@167 3340 % @evenfooting @thisfile||
cannam@167 3341 % @oddfooting ||@thisfile
cannam@167 3342
cannam@167 3343
cannam@167 3344 \def\evenheading{\parsearg\evenheadingxxx}
cannam@167 3345 \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
cannam@167 3346 \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
cannam@167 3347 \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
cannam@167 3348
cannam@167 3349 \def\oddheading{\parsearg\oddheadingxxx}
cannam@167 3350 \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
cannam@167 3351 \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
cannam@167 3352 \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
cannam@167 3353
cannam@167 3354 \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
cannam@167 3355
cannam@167 3356 \def\evenfooting{\parsearg\evenfootingxxx}
cannam@167 3357 \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
cannam@167 3358 \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
cannam@167 3359 \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
cannam@167 3360
cannam@167 3361 \def\oddfooting{\parsearg\oddfootingxxx}
cannam@167 3362 \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
cannam@167 3363 \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
cannam@167 3364 \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
cannam@167 3365 %
cannam@167 3366 % Leave some space for the footline. Hopefully ok to assume
cannam@167 3367 % @evenfooting will not be used by itself.
cannam@167 3368 \global\advance\pageheight by -12pt
cannam@167 3369 \global\advance\vsize by -12pt
cannam@167 3370 }
cannam@167 3371
cannam@167 3372 \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
cannam@167 3373
cannam@167 3374 % @evenheadingmarks top \thischapter <- chapter at the top of a page
cannam@167 3375 % @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page
cannam@167 3376 %
cannam@167 3377 % The same set of arguments for:
cannam@167 3378 %
cannam@167 3379 % @oddheadingmarks
cannam@167 3380 % @evenfootingmarks
cannam@167 3381 % @oddfootingmarks
cannam@167 3382 % @everyheadingmarks
cannam@167 3383 % @everyfootingmarks
cannam@167 3384
cannam@167 3385 \def\evenheadingmarks{\headingmarks{even}{heading}}
cannam@167 3386 \def\oddheadingmarks{\headingmarks{odd}{heading}}
cannam@167 3387 \def\evenfootingmarks{\headingmarks{even}{footing}}
cannam@167 3388 \def\oddfootingmarks{\headingmarks{odd}{footing}}
cannam@167 3389 \def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1}
cannam@167 3390 \headingmarks{odd}{heading}{#1} }
cannam@167 3391 \def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1}
cannam@167 3392 \headingmarks{odd}{footing}{#1} }
cannam@167 3393 % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
cannam@167 3394 \def\headingmarks#1#2#3 {%
cannam@167 3395 \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
cannam@167 3396 \global\expandafter\let\csname get#1#2marks\endcsname \temp
cannam@167 3397 }
cannam@167 3398
cannam@167 3399 \everyheadingmarks bottom
cannam@167 3400 \everyfootingmarks bottom
cannam@167 3401
cannam@167 3402 % @headings double turns headings on for double-sided printing.
cannam@167 3403 % @headings single turns headings on for single-sided printing.
cannam@167 3404 % @headings off turns them off.
cannam@167 3405 % @headings on same as @headings double, retained for compatibility.
cannam@167 3406 % @headings after turns on double-sided headings after this page.
cannam@167 3407 % @headings doubleafter turns on double-sided headings after this page.
cannam@167 3408 % @headings singleafter turns on single-sided headings after this page.
cannam@167 3409 % By default, they are off at the start of a document,
cannam@167 3410 % and turned `on' after @end titlepage.
cannam@167 3411
cannam@167 3412 \def\headings #1 {\csname HEADINGS#1\endcsname}
cannam@167 3413
cannam@167 3414 \def\headingsoff{% non-global headings elimination
cannam@167 3415 \evenheadline={\hfil}\evenfootline={\hfil}%
cannam@167 3416 \oddheadline={\hfil}\oddfootline={\hfil}%
cannam@167 3417 }
cannam@167 3418
cannam@167 3419 \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
cannam@167 3420 \HEADINGSoff % it's the default
cannam@167 3421
cannam@167 3422 % When we turn headings on, set the page number to 1.
cannam@167 3423 % For double-sided printing, put current file name in lower left corner,
cannam@167 3424 % chapter name on inside top of right hand pages, document
cannam@167 3425 % title on inside top of left hand pages, and page numbers on outside top
cannam@167 3426 % edge of all pages.
cannam@167 3427 \def\HEADINGSdouble{%
cannam@167 3428 \global\pageno=1
cannam@167 3429 \global\evenfootline={\hfil}
cannam@167 3430 \global\oddfootline={\hfil}
cannam@167 3431 \global\evenheadline={\line{\folio\hfil\thistitle}}
cannam@167 3432 \global\oddheadline={\line{\thischapter\hfil\folio}}
cannam@167 3433 \global\let\contentsalignmacro = \chapoddpage
cannam@167 3434 }
cannam@167 3435 \let\contentsalignmacro = \chappager
cannam@167 3436
cannam@167 3437 % For single-sided printing, chapter title goes across top left of page,
cannam@167 3438 % page number on top right.
cannam@167 3439 \def\HEADINGSsingle{%
cannam@167 3440 \global\pageno=1
cannam@167 3441 \global\evenfootline={\hfil}
cannam@167 3442 \global\oddfootline={\hfil}
cannam@167 3443 \global\evenheadline={\line{\thischapter\hfil\folio}}
cannam@167 3444 \global\oddheadline={\line{\thischapter\hfil\folio}}
cannam@167 3445 \global\let\contentsalignmacro = \chappager
cannam@167 3446 }
cannam@167 3447 \def\HEADINGSon{\HEADINGSdouble}
cannam@167 3448
cannam@167 3449 \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
cannam@167 3450 \let\HEADINGSdoubleafter=\HEADINGSafter
cannam@167 3451 \def\HEADINGSdoublex{%
cannam@167 3452 \global\evenfootline={\hfil}
cannam@167 3453 \global\oddfootline={\hfil}
cannam@167 3454 \global\evenheadline={\line{\folio\hfil\thistitle}}
cannam@167 3455 \global\oddheadline={\line{\thischapter\hfil\folio}}
cannam@167 3456 \global\let\contentsalignmacro = \chapoddpage
cannam@167 3457 }
cannam@167 3458
cannam@167 3459 \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
cannam@167 3460 \def\HEADINGSsinglex{%
cannam@167 3461 \global\evenfootline={\hfil}
cannam@167 3462 \global\oddfootline={\hfil}
cannam@167 3463 \global\evenheadline={\line{\thischapter\hfil\folio}}
cannam@167 3464 \global\oddheadline={\line{\thischapter\hfil\folio}}
cannam@167 3465 \global\let\contentsalignmacro = \chappager
cannam@167 3466 }
cannam@167 3467
cannam@167 3468 % Subroutines used in generating headings
cannam@167 3469 % This produces Day Month Year style of output.
cannam@167 3470 % Only define if not already defined, in case a txi-??.tex file has set
cannam@167 3471 % up a different format (e.g., txi-cs.tex does this).
cannam@167 3472 \ifx\today\thisisundefined
cannam@167 3473 \def\today{%
cannam@167 3474 \number\day\space
cannam@167 3475 \ifcase\month
cannam@167 3476 \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
cannam@167 3477 \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
cannam@167 3478 \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
cannam@167 3479 \fi
cannam@167 3480 \space\number\year}
cannam@167 3481 \fi
cannam@167 3482
cannam@167 3483 % @settitle line... specifies the title of the document, for headings.
cannam@167 3484 % It generates no output of its own.
cannam@167 3485 \def\thistitle{\putwordNoTitle}
cannam@167 3486 \def\settitle{\parsearg{\gdef\thistitle}}
cannam@167 3487
cannam@167 3488
cannam@167 3489 \message{tables,}
cannam@167 3490 % Tables -- @table, @ftable, @vtable, @item(x).
cannam@167 3491
cannam@167 3492 % default indentation of table text
cannam@167 3493 \newdimen\tableindent \tableindent=.8in
cannam@167 3494 % default indentation of @itemize and @enumerate text
cannam@167 3495 \newdimen\itemindent \itemindent=.3in
cannam@167 3496 % margin between end of table item and start of table text.
cannam@167 3497 \newdimen\itemmargin \itemmargin=.1in
cannam@167 3498
cannam@167 3499 % used internally for \itemindent minus \itemmargin
cannam@167 3500 \newdimen\itemmax
cannam@167 3501
cannam@167 3502 % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
cannam@167 3503 % these defs.
cannam@167 3504 % They also define \itemindex
cannam@167 3505 % to index the item name in whatever manner is desired (perhaps none).
cannam@167 3506
cannam@167 3507 \newif\ifitemxneedsnegativevskip
cannam@167 3508
cannam@167 3509 \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
cannam@167 3510
cannam@167 3511 \def\internalBitem{\smallbreak \parsearg\itemzzz}
cannam@167 3512 \def\internalBitemx{\itemxpar \parsearg\itemzzz}
cannam@167 3513
cannam@167 3514 \def\itemzzz #1{\begingroup %
cannam@167 3515 \advance\hsize by -\rightskip
cannam@167 3516 \advance\hsize by -\tableindent
cannam@167 3517 \setbox0=\hbox{\itemindicate{#1}}%
cannam@167 3518 \itemindex{#1}%
cannam@167 3519 \nobreak % This prevents a break before @itemx.
cannam@167 3520 %
cannam@167 3521 % If the item text does not fit in the space we have, put it on a line
cannam@167 3522 % by itself, and do not allow a page break either before or after that
cannam@167 3523 % line. We do not start a paragraph here because then if the next
cannam@167 3524 % command is, e.g., @kindex, the whatsit would get put into the
cannam@167 3525 % horizontal list on a line by itself, resulting in extra blank space.
cannam@167 3526 \ifdim \wd0>\itemmax
cannam@167 3527 %
cannam@167 3528 % Make this a paragraph so we get the \parskip glue and wrapping,
cannam@167 3529 % but leave it ragged-right.
cannam@167 3530 \begingroup
cannam@167 3531 \advance\leftskip by-\tableindent
cannam@167 3532 \advance\hsize by\tableindent
cannam@167 3533 \advance\rightskip by0pt plus1fil\relax
cannam@167 3534 \leavevmode\unhbox0\par
cannam@167 3535 \endgroup
cannam@167 3536 %
cannam@167 3537 % We're going to be starting a paragraph, but we don't want the
cannam@167 3538 % \parskip glue -- logically it's part of the @item we just started.
cannam@167 3539 \nobreak \vskip-\parskip
cannam@167 3540 %
cannam@167 3541 % Stop a page break at the \parskip glue coming up. However, if
cannam@167 3542 % what follows is an environment such as @example, there will be no
cannam@167 3543 % \parskip glue; then the negative vskip we just inserted would
cannam@167 3544 % cause the example and the item to crash together. So we use this
cannam@167 3545 % bizarre value of 10001 as a signal to \aboveenvbreak to insert
cannam@167 3546 % \parskip glue after all. Section titles are handled this way also.
cannam@167 3547 %
cannam@167 3548 \penalty 10001
cannam@167 3549 \endgroup
cannam@167 3550 \itemxneedsnegativevskipfalse
cannam@167 3551 \else
cannam@167 3552 % The item text fits into the space. Start a paragraph, so that the
cannam@167 3553 % following text (if any) will end up on the same line.
cannam@167 3554 \noindent
cannam@167 3555 % Do this with kerns and \unhbox so that if there is a footnote in
cannam@167 3556 % the item text, it can migrate to the main vertical list and
cannam@167 3557 % eventually be printed.
cannam@167 3558 \nobreak\kern-\tableindent
cannam@167 3559 \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
cannam@167 3560 \unhbox0
cannam@167 3561 \nobreak\kern\dimen0
cannam@167 3562 \endgroup
cannam@167 3563 \itemxneedsnegativevskiptrue
cannam@167 3564 \fi
cannam@167 3565 }
cannam@167 3566
cannam@167 3567 \def\item{\errmessage{@item while not in a list environment}}
cannam@167 3568 \def\itemx{\errmessage{@itemx while not in a list environment}}
cannam@167 3569
cannam@167 3570 % @table, @ftable, @vtable.
cannam@167 3571 \envdef\table{%
cannam@167 3572 \let\itemindex\gobble
cannam@167 3573 \tablecheck{table}%
cannam@167 3574 }
cannam@167 3575 \envdef\ftable{%
cannam@167 3576 \def\itemindex ##1{\doind {fn}{\code{##1}}}%
cannam@167 3577 \tablecheck{ftable}%
cannam@167 3578 }
cannam@167 3579 \envdef\vtable{%
cannam@167 3580 \def\itemindex ##1{\doind {vr}{\code{##1}}}%
cannam@167 3581 \tablecheck{vtable}%
cannam@167 3582 }
cannam@167 3583 \def\tablecheck#1{%
cannam@167 3584 \ifnum \the\catcode`\^^M=\active
cannam@167 3585 \endgroup
cannam@167 3586 \errmessage{This command won't work in this context; perhaps the problem is
cannam@167 3587 that we are \inenvironment\thisenv}%
cannam@167 3588 \def\next{\doignore{#1}}%
cannam@167 3589 \else
cannam@167 3590 \let\next\tablex
cannam@167 3591 \fi
cannam@167 3592 \next
cannam@167 3593 }
cannam@167 3594 \def\tablex#1{%
cannam@167 3595 \def\itemindicate{#1}%
cannam@167 3596 \parsearg\tabley
cannam@167 3597 }
cannam@167 3598 \def\tabley#1{%
cannam@167 3599 {%
cannam@167 3600 \makevalueexpandable
cannam@167 3601 \edef\temp{\noexpand\tablez #1\space\space\space}%
cannam@167 3602 \expandafter
cannam@167 3603 }\temp \endtablez
cannam@167 3604 }
cannam@167 3605 \def\tablez #1 #2 #3 #4\endtablez{%
cannam@167 3606 \aboveenvbreak
cannam@167 3607 \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
cannam@167 3608 \ifnum 0#2>0 \tableindent=#2\mil \fi
cannam@167 3609 \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
cannam@167 3610 \itemmax=\tableindent
cannam@167 3611 \advance \itemmax by -\itemmargin
cannam@167 3612 \advance \leftskip by \tableindent
cannam@167 3613 \exdentamount=\tableindent
cannam@167 3614 \parindent = 0pt
cannam@167 3615 \parskip = \smallskipamount
cannam@167 3616 \ifdim \parskip=0pt \parskip=2pt \fi
cannam@167 3617 \let\item = \internalBitem
cannam@167 3618 \let\itemx = \internalBitemx
cannam@167 3619 }
cannam@167 3620 \def\Etable{\endgraf\afterenvbreak}
cannam@167 3621 \let\Eftable\Etable
cannam@167 3622 \let\Evtable\Etable
cannam@167 3623 \let\Eitemize\Etable
cannam@167 3624 \let\Eenumerate\Etable
cannam@167 3625
cannam@167 3626 % This is the counter used by @enumerate, which is really @itemize
cannam@167 3627
cannam@167 3628 \newcount \itemno
cannam@167 3629
cannam@167 3630 \envdef\itemize{\parsearg\doitemize}
cannam@167 3631
cannam@167 3632 \def\doitemize#1{%
cannam@167 3633 \aboveenvbreak
cannam@167 3634 \itemmax=\itemindent
cannam@167 3635 \advance\itemmax by -\itemmargin
cannam@167 3636 \advance\leftskip by \itemindent
cannam@167 3637 \exdentamount=\itemindent
cannam@167 3638 \parindent=0pt
cannam@167 3639 \parskip=\smallskipamount
cannam@167 3640 \ifdim\parskip=0pt \parskip=2pt \fi
cannam@167 3641 %
cannam@167 3642 % Try typesetting the item mark that if the document erroneously says
cannam@167 3643 % something like @itemize @samp (intending @table), there's an error
cannam@167 3644 % right away at the @itemize. It's not the best error message in the
cannam@167 3645 % world, but it's better than leaving it to the @item. This means if
cannam@167 3646 % the user wants an empty mark, they have to say @w{} not just @w.
cannam@167 3647 \def\itemcontents{#1}%
cannam@167 3648 \setbox0 = \hbox{\itemcontents}%
cannam@167 3649 %
cannam@167 3650 % @itemize with no arg is equivalent to @itemize @bullet.
cannam@167 3651 \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
cannam@167 3652 %
cannam@167 3653 \let\item=\itemizeitem
cannam@167 3654 }
cannam@167 3655
cannam@167 3656 % Definition of @item while inside @itemize and @enumerate.
cannam@167 3657 %
cannam@167 3658 \def\itemizeitem{%
cannam@167 3659 \advance\itemno by 1 % for enumerations
cannam@167 3660 {\let\par=\endgraf \smallbreak}% reasonable place to break
cannam@167 3661 {%
cannam@167 3662 % If the document has an @itemize directly after a section title, a
cannam@167 3663 % \nobreak will be last on the list, and \sectionheading will have
cannam@167 3664 % done a \vskip-\parskip. In that case, we don't want to zero
cannam@167 3665 % parskip, or the item text will crash with the heading. On the
cannam@167 3666 % other hand, when there is normal text preceding the item (as there
cannam@167 3667 % usually is), we do want to zero parskip, or there would be too much
cannam@167 3668 % space. In that case, we won't have a \nobreak before. At least
cannam@167 3669 % that's the theory.
cannam@167 3670 \ifnum\lastpenalty<10000 \parskip=0in \fi
cannam@167 3671 \noindent
cannam@167 3672 \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
cannam@167 3673 %
cannam@167 3674 \vadjust{\penalty 1200}}% not good to break after first line of item.
cannam@167 3675 \flushcr
cannam@167 3676 }
cannam@167 3677
cannam@167 3678 % \splitoff TOKENS\endmark defines \first to be the first token in
cannam@167 3679 % TOKENS, and \rest to be the remainder.
cannam@167 3680 %
cannam@167 3681 \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
cannam@167 3682
cannam@167 3683 % Allow an optional argument of an uppercase letter, lowercase letter,
cannam@167 3684 % or number, to specify the first label in the enumerated list. No
cannam@167 3685 % argument is the same as `1'.
cannam@167 3686 %
cannam@167 3687 \envparseargdef\enumerate{\enumeratey #1 \endenumeratey}
cannam@167 3688 \def\enumeratey #1 #2\endenumeratey{%
cannam@167 3689 % If we were given no argument, pretend we were given `1'.
cannam@167 3690 \def\thearg{#1}%
cannam@167 3691 \ifx\thearg\empty \def\thearg{1}\fi
cannam@167 3692 %
cannam@167 3693 % Detect if the argument is a single token. If so, it might be a
cannam@167 3694 % letter. Otherwise, the only valid thing it can be is a number.
cannam@167 3695 % (We will always have one token, because of the test we just made.
cannam@167 3696 % This is a good thing, since \splitoff doesn't work given nothing at
cannam@167 3697 % all -- the first parameter is undelimited.)
cannam@167 3698 \expandafter\splitoff\thearg\endmark
cannam@167 3699 \ifx\rest\empty
cannam@167 3700 % Only one token in the argument. It could still be anything.
cannam@167 3701 % A ``lowercase letter'' is one whose \lccode is nonzero.
cannam@167 3702 % An ``uppercase letter'' is one whose \lccode is both nonzero, and
cannam@167 3703 % not equal to itself.
cannam@167 3704 % Otherwise, we assume it's a number.
cannam@167 3705 %
cannam@167 3706 % We need the \relax at the end of the \ifnum lines to stop TeX from
cannam@167 3707 % continuing to look for a <number>.
cannam@167 3708 %
cannam@167 3709 \ifnum\lccode\expandafter`\thearg=0\relax
cannam@167 3710 \numericenumerate % a number (we hope)
cannam@167 3711 \else
cannam@167 3712 % It's a letter.
cannam@167 3713 \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
cannam@167 3714 \lowercaseenumerate % lowercase letter
cannam@167 3715 \else
cannam@167 3716 \uppercaseenumerate % uppercase letter
cannam@167 3717 \fi
cannam@167 3718 \fi
cannam@167 3719 \else
cannam@167 3720 % Multiple tokens in the argument. We hope it's a number.
cannam@167 3721 \numericenumerate
cannam@167 3722 \fi
cannam@167 3723 }
cannam@167 3724
cannam@167 3725 % An @enumerate whose labels are integers. The starting integer is
cannam@167 3726 % given in \thearg.
cannam@167 3727 %
cannam@167 3728 \def\numericenumerate{%
cannam@167 3729 \itemno = \thearg
cannam@167 3730 \startenumeration{\the\itemno}%
cannam@167 3731 }
cannam@167 3732
cannam@167 3733 % The starting (lowercase) letter is in \thearg.
cannam@167 3734 \def\lowercaseenumerate{%
cannam@167 3735 \itemno = \expandafter`\thearg
cannam@167 3736 \startenumeration{%
cannam@167 3737 % Be sure we're not beyond the end of the alphabet.
cannam@167 3738 \ifnum\itemno=0
cannam@167 3739 \errmessage{No more lowercase letters in @enumerate; get a bigger
cannam@167 3740 alphabet}%
cannam@167 3741 \fi
cannam@167 3742 \char\lccode\itemno
cannam@167 3743 }%
cannam@167 3744 }
cannam@167 3745
cannam@167 3746 % The starting (uppercase) letter is in \thearg.
cannam@167 3747 \def\uppercaseenumerate{%
cannam@167 3748 \itemno = \expandafter`\thearg
cannam@167 3749 \startenumeration{%
cannam@167 3750 % Be sure we're not beyond the end of the alphabet.
cannam@167 3751 \ifnum\itemno=0
cannam@167 3752 \errmessage{No more uppercase letters in @enumerate; get a bigger
cannam@167 3753 alphabet}
cannam@167 3754 \fi
cannam@167 3755 \char\uccode\itemno
cannam@167 3756 }%
cannam@167 3757 }
cannam@167 3758
cannam@167 3759 % Call \doitemize, adding a period to the first argument and supplying the
cannam@167 3760 % common last two arguments. Also subtract one from the initial value in
cannam@167 3761 % \itemno, since @item increments \itemno.
cannam@167 3762 %
cannam@167 3763 \def\startenumeration#1{%
cannam@167 3764 \advance\itemno by -1
cannam@167 3765 \doitemize{#1.}\flushcr
cannam@167 3766 }
cannam@167 3767
cannam@167 3768 % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
cannam@167 3769 % to @enumerate.
cannam@167 3770 %
cannam@167 3771 \def\alphaenumerate{\enumerate{a}}
cannam@167 3772 \def\capsenumerate{\enumerate{A}}
cannam@167 3773 \def\Ealphaenumerate{\Eenumerate}
cannam@167 3774 \def\Ecapsenumerate{\Eenumerate}
cannam@167 3775
cannam@167 3776
cannam@167 3777 % @multitable macros
cannam@167 3778 % Amy Hendrickson, 8/18/94, 3/6/96
cannam@167 3779 %
cannam@167 3780 % @multitable ... @end multitable will make as many columns as desired.
cannam@167 3781 % Contents of each column will wrap at width given in preamble. Width
cannam@167 3782 % can be specified either with sample text given in a template line,
cannam@167 3783 % or in percent of \hsize, the current width of text on page.
cannam@167 3784
cannam@167 3785 % Table can continue over pages but will only break between lines.
cannam@167 3786
cannam@167 3787 % To make preamble:
cannam@167 3788 %
cannam@167 3789 % Either define widths of columns in terms of percent of \hsize:
cannam@167 3790 % @multitable @columnfractions .25 .3 .45
cannam@167 3791 % @item ...
cannam@167 3792 %
cannam@167 3793 % Numbers following @columnfractions are the percent of the total
cannam@167 3794 % current hsize to be used for each column. You may use as many
cannam@167 3795 % columns as desired.
cannam@167 3796
cannam@167 3797
cannam@167 3798 % Or use a template:
cannam@167 3799 % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
cannam@167 3800 % @item ...
cannam@167 3801 % using the widest term desired in each column.
cannam@167 3802
cannam@167 3803 % Each new table line starts with @item, each subsequent new column
cannam@167 3804 % starts with @tab. Empty columns may be produced by supplying @tab's
cannam@167 3805 % with nothing between them for as many times as empty columns are needed,
cannam@167 3806 % ie, @tab@tab@tab will produce two empty columns.
cannam@167 3807
cannam@167 3808 % @item, @tab do not need to be on their own lines, but it will not hurt
cannam@167 3809 % if they are.
cannam@167 3810
cannam@167 3811 % Sample multitable:
cannam@167 3812
cannam@167 3813 % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
cannam@167 3814 % @item first col stuff @tab second col stuff @tab third col
cannam@167 3815 % @item
cannam@167 3816 % first col stuff
cannam@167 3817 % @tab
cannam@167 3818 % second col stuff
cannam@167 3819 % @tab
cannam@167 3820 % third col
cannam@167 3821 % @item first col stuff @tab second col stuff
cannam@167 3822 % @tab Many paragraphs of text may be used in any column.
cannam@167 3823 %
cannam@167 3824 % They will wrap at the width determined by the template.
cannam@167 3825 % @item@tab@tab This will be in third column.
cannam@167 3826 % @end multitable
cannam@167 3827
cannam@167 3828 % Default dimensions may be reset by user.
cannam@167 3829 % @multitableparskip is vertical space between paragraphs in table.
cannam@167 3830 % @multitableparindent is paragraph indent in table.
cannam@167 3831 % @multitablecolmargin is horizontal space to be left between columns.
cannam@167 3832 % @multitablelinespace is space to leave between table items, baseline
cannam@167 3833 % to baseline.
cannam@167 3834 % 0pt means it depends on current normal line spacing.
cannam@167 3835 %
cannam@167 3836 \newskip\multitableparskip
cannam@167 3837 \newskip\multitableparindent
cannam@167 3838 \newdimen\multitablecolspace
cannam@167 3839 \newskip\multitablelinespace
cannam@167 3840 \multitableparskip=0pt
cannam@167 3841 \multitableparindent=6pt
cannam@167 3842 \multitablecolspace=12pt
cannam@167 3843 \multitablelinespace=0pt
cannam@167 3844
cannam@167 3845 % Macros used to set up halign preamble:
cannam@167 3846 %
cannam@167 3847 \let\endsetuptable\relax
cannam@167 3848 \def\xendsetuptable{\endsetuptable}
cannam@167 3849 \let\columnfractions\relax
cannam@167 3850 \def\xcolumnfractions{\columnfractions}
cannam@167 3851 \newif\ifsetpercent
cannam@167 3852
cannam@167 3853 % #1 is the @columnfraction, usually a decimal number like .5, but might
cannam@167 3854 % be just 1. We just use it, whatever it is.
cannam@167 3855 %
cannam@167 3856 \def\pickupwholefraction#1 {%
cannam@167 3857 \global\advance\colcount by 1
cannam@167 3858 \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
cannam@167 3859 \setuptable
cannam@167 3860 }
cannam@167 3861
cannam@167 3862 \newcount\colcount
cannam@167 3863 \def\setuptable#1{%
cannam@167 3864 \def\firstarg{#1}%
cannam@167 3865 \ifx\firstarg\xendsetuptable
cannam@167 3866 \let\go = \relax
cannam@167 3867 \else
cannam@167 3868 \ifx\firstarg\xcolumnfractions
cannam@167 3869 \global\setpercenttrue
cannam@167 3870 \else
cannam@167 3871 \ifsetpercent
cannam@167 3872 \let\go\pickupwholefraction
cannam@167 3873 \else
cannam@167 3874 \global\advance\colcount by 1
cannam@167 3875 \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
cannam@167 3876 % separator; typically that is always in the input, anyway.
cannam@167 3877 \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
cannam@167 3878 \fi
cannam@167 3879 \fi
cannam@167 3880 \ifx\go\pickupwholefraction
cannam@167 3881 % Put the argument back for the \pickupwholefraction call, so
cannam@167 3882 % we'll always have a period there to be parsed.
cannam@167 3883 \def\go{\pickupwholefraction#1}%
cannam@167 3884 \else
cannam@167 3885 \let\go = \setuptable
cannam@167 3886 \fi%
cannam@167 3887 \fi
cannam@167 3888 \go
cannam@167 3889 }
cannam@167 3890
cannam@167 3891 % multitable-only commands.
cannam@167 3892 %
cannam@167 3893 % @headitem starts a heading row, which we typeset in bold.
cannam@167 3894 % Assignments have to be global since we are inside the implicit group
cannam@167 3895 % of an alignment entry. \everycr resets \everytab so we don't have to
cannam@167 3896 % undo it ourselves.
cannam@167 3897 \def\headitemfont{\b}% for people to use in the template row; not changeable
cannam@167 3898 \def\headitem{%
cannam@167 3899 \checkenv\multitable
cannam@167 3900 \crcr
cannam@167 3901 \global\everytab={\bf}% can't use \headitemfont since the parsing differs
cannam@167 3902 \the\everytab % for the first item
cannam@167 3903 }%
cannam@167 3904 %
cannam@167 3905 % A \tab used to include \hskip1sp. But then the space in a template
cannam@167 3906 % line is not enough. That is bad. So let's go back to just `&' until
cannam@167 3907 % we again encounter the problem the 1sp was intended to solve.
cannam@167 3908 % --karl, nathan@acm.org, 20apr99.
cannam@167 3909 \def\tab{\checkenv\multitable &\the\everytab}%
cannam@167 3910
cannam@167 3911 % @multitable ... @end multitable definitions:
cannam@167 3912 %
cannam@167 3913 \newtoks\everytab % insert after every tab.
cannam@167 3914 %
cannam@167 3915 \envdef\multitable{%
cannam@167 3916 \vskip\parskip
cannam@167 3917 \startsavinginserts
cannam@167 3918 %
cannam@167 3919 % @item within a multitable starts a normal row.
cannam@167 3920 % We use \def instead of \let so that if one of the multitable entries
cannam@167 3921 % contains an @itemize, we don't choke on the \item (seen as \crcr aka
cannam@167 3922 % \endtemplate) expanding \doitemize.
cannam@167 3923 \def\item{\crcr}%
cannam@167 3924 %
cannam@167 3925 \tolerance=9500
cannam@167 3926 \hbadness=9500
cannam@167 3927 \setmultitablespacing
cannam@167 3928 \parskip=\multitableparskip
cannam@167 3929 \parindent=\multitableparindent
cannam@167 3930 \overfullrule=0pt
cannam@167 3931 \global\colcount=0
cannam@167 3932 %
cannam@167 3933 \everycr = {%
cannam@167 3934 \noalign{%
cannam@167 3935 \global\everytab={}%
cannam@167 3936 \global\colcount=0 % Reset the column counter.
cannam@167 3937 % Check for saved footnotes, etc.
cannam@167 3938 \checkinserts
cannam@167 3939 % Keeps underfull box messages off when table breaks over pages.
cannam@167 3940 %\filbreak
cannam@167 3941 % Maybe so, but it also creates really weird page breaks when the
cannam@167 3942 % table breaks over pages. Wouldn't \vfil be better? Wait until the
cannam@167 3943 % problem manifests itself, so it can be fixed for real --karl.
cannam@167 3944 }%
cannam@167 3945 }%
cannam@167 3946 %
cannam@167 3947 \parsearg\domultitable
cannam@167 3948 }
cannam@167 3949 \def\domultitable#1{%
cannam@167 3950 % To parse everything between @multitable and @item:
cannam@167 3951 \setuptable#1 \endsetuptable
cannam@167 3952 %
cannam@167 3953 % This preamble sets up a generic column definition, which will
cannam@167 3954 % be used as many times as user calls for columns.
cannam@167 3955 % \vtop will set a single line and will also let text wrap and
cannam@167 3956 % continue for many paragraphs if desired.
cannam@167 3957 \halign\bgroup &%
cannam@167 3958 \global\advance\colcount by 1
cannam@167 3959 \multistrut
cannam@167 3960 \vtop{%
cannam@167 3961 % Use the current \colcount to find the correct column width:
cannam@167 3962 \hsize=\expandafter\csname col\the\colcount\endcsname
cannam@167 3963 %
cannam@167 3964 % In order to keep entries from bumping into each other
cannam@167 3965 % we will add a \leftskip of \multitablecolspace to all columns after
cannam@167 3966 % the first one.
cannam@167 3967 %
cannam@167 3968 % If a template has been used, we will add \multitablecolspace
cannam@167 3969 % to the width of each template entry.
cannam@167 3970 %
cannam@167 3971 % If the user has set preamble in terms of percent of \hsize we will
cannam@167 3972 % use that dimension as the width of the column, and the \leftskip
cannam@167 3973 % will keep entries from bumping into each other. Table will start at
cannam@167 3974 % left margin and final column will justify at right margin.
cannam@167 3975 %
cannam@167 3976 % Make sure we don't inherit \rightskip from the outer environment.
cannam@167 3977 \rightskip=0pt
cannam@167 3978 \ifnum\colcount=1
cannam@167 3979 % The first column will be indented with the surrounding text.
cannam@167 3980 \advance\hsize by\leftskip
cannam@167 3981 \else
cannam@167 3982 \ifsetpercent \else
cannam@167 3983 % If user has not set preamble in terms of percent of \hsize
cannam@167 3984 % we will advance \hsize by \multitablecolspace.
cannam@167 3985 \advance\hsize by \multitablecolspace
cannam@167 3986 \fi
cannam@167 3987 % In either case we will make \leftskip=\multitablecolspace:
cannam@167 3988 \leftskip=\multitablecolspace
cannam@167 3989 \fi
cannam@167 3990 % Ignoring space at the beginning and end avoids an occasional spurious
cannam@167 3991 % blank line, when TeX decides to break the line at the space before the
cannam@167 3992 % box from the multistrut, so the strut ends up on a line by itself.
cannam@167 3993 % For example:
cannam@167 3994 % @multitable @columnfractions .11 .89
cannam@167 3995 % @item @code{#}
cannam@167 3996 % @tab Legal holiday which is valid in major parts of the whole country.
cannam@167 3997 % Is automatically provided with highlighting sequences respectively
cannam@167 3998 % marking characters.
cannam@167 3999 \noindent\ignorespaces##\unskip\multistrut
cannam@167 4000 }\cr
cannam@167 4001 }
cannam@167 4002 \def\Emultitable{%
cannam@167 4003 \crcr
cannam@167 4004 \egroup % end the \halign
cannam@167 4005 \global\setpercentfalse
cannam@167 4006 }
cannam@167 4007
cannam@167 4008 \def\setmultitablespacing{%
cannam@167 4009 \def\multistrut{\strut}% just use the standard line spacing
cannam@167 4010 %
cannam@167 4011 % Compute \multitablelinespace (if not defined by user) for use in
cannam@167 4012 % \multitableparskip calculation. We used define \multistrut based on
cannam@167 4013 % this, but (ironically) that caused the spacing to be off.
cannam@167 4014 % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
cannam@167 4015 \ifdim\multitablelinespace=0pt
cannam@167 4016 \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
cannam@167 4017 \global\advance\multitablelinespace by-\ht0
cannam@167 4018 \fi
cannam@167 4019 % Test to see if parskip is larger than space between lines of
cannam@167 4020 % table. If not, do nothing.
cannam@167 4021 % If so, set to same dimension as multitablelinespace.
cannam@167 4022 \ifdim\multitableparskip>\multitablelinespace
cannam@167 4023 \global\multitableparskip=\multitablelinespace
cannam@167 4024 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
cannam@167 4025 % than skip between lines in the table.
cannam@167 4026 \fi%
cannam@167 4027 \ifdim\multitableparskip=0pt
cannam@167 4028 \global\multitableparskip=\multitablelinespace
cannam@167 4029 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
cannam@167 4030 % than skip between lines in the table.
cannam@167 4031 \fi}
cannam@167 4032
cannam@167 4033
cannam@167 4034 \message{conditionals,}
cannam@167 4035
cannam@167 4036 % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
cannam@167 4037 % @ifnotxml always succeed. They currently do nothing; we don't
cannam@167 4038 % attempt to check whether the conditionals are properly nested. But we
cannam@167 4039 % have to remember that they are conditionals, so that @end doesn't
cannam@167 4040 % attempt to close an environment group.
cannam@167 4041 %
cannam@167 4042 \def\makecond#1{%
cannam@167 4043 \expandafter\let\csname #1\endcsname = \relax
cannam@167 4044 \expandafter\let\csname iscond.#1\endcsname = 1
cannam@167 4045 }
cannam@167 4046 \makecond{iftex}
cannam@167 4047 \makecond{ifnotdocbook}
cannam@167 4048 \makecond{ifnothtml}
cannam@167 4049 \makecond{ifnotinfo}
cannam@167 4050 \makecond{ifnotplaintext}
cannam@167 4051 \makecond{ifnotxml}
cannam@167 4052
cannam@167 4053 % Ignore @ignore, @ifhtml, @ifinfo, and the like.
cannam@167 4054 %
cannam@167 4055 \def\direntry{\doignore{direntry}}
cannam@167 4056 \def\documentdescription{\doignore{documentdescription}}
cannam@167 4057 \def\docbook{\doignore{docbook}}
cannam@167 4058 \def\html{\doignore{html}}
cannam@167 4059 \def\ifdocbook{\doignore{ifdocbook}}
cannam@167 4060 \def\ifhtml{\doignore{ifhtml}}
cannam@167 4061 \def\ifinfo{\doignore{ifinfo}}
cannam@167 4062 \def\ifnottex{\doignore{ifnottex}}
cannam@167 4063 \def\ifplaintext{\doignore{ifplaintext}}
cannam@167 4064 \def\ifxml{\doignore{ifxml}}
cannam@167 4065 \def\ignore{\doignore{ignore}}
cannam@167 4066 \def\menu{\doignore{menu}}
cannam@167 4067 \def\xml{\doignore{xml}}
cannam@167 4068
cannam@167 4069 % Ignore text until a line `@end #1', keeping track of nested conditionals.
cannam@167 4070 %
cannam@167 4071 % A count to remember the depth of nesting.
cannam@167 4072 \newcount\doignorecount
cannam@167 4073
cannam@167 4074 \def\doignore#1{\begingroup
cannam@167 4075 % Scan in ``verbatim'' mode:
cannam@167 4076 \obeylines
cannam@167 4077 \catcode`\@ = \other
cannam@167 4078 \catcode`\{ = \other
cannam@167 4079 \catcode`\} = \other
cannam@167 4080 %
cannam@167 4081 % Make sure that spaces turn into tokens that match what \doignoretext wants.
cannam@167 4082 \spaceisspace
cannam@167 4083 %
cannam@167 4084 % Count number of #1's that we've seen.
cannam@167 4085 \doignorecount = 0
cannam@167 4086 %
cannam@167 4087 % Swallow text until we reach the matching `@end #1'.
cannam@167 4088 \dodoignore{#1}%
cannam@167 4089 }
cannam@167 4090
cannam@167 4091 { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
cannam@167 4092 \obeylines %
cannam@167 4093 %
cannam@167 4094 \gdef\dodoignore#1{%
cannam@167 4095 % #1 contains the command name as a string, e.g., `ifinfo'.
cannam@167 4096 %
cannam@167 4097 % Define a command to find the next `@end #1'.
cannam@167 4098 \long\def\doignoretext##1^^M@end #1{%
cannam@167 4099 \doignoretextyyy##1^^M@#1\_STOP_}%
cannam@167 4100 %
cannam@167 4101 % And this command to find another #1 command, at the beginning of a
cannam@167 4102 % line. (Otherwise, we would consider a line `@c @ifset', for
cannam@167 4103 % example, to count as an @ifset for nesting.)
cannam@167 4104 \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
cannam@167 4105 %
cannam@167 4106 % And now expand that command.
cannam@167 4107 \doignoretext ^^M%
cannam@167 4108 }%
cannam@167 4109 }
cannam@167 4110
cannam@167 4111 \def\doignoreyyy#1{%
cannam@167 4112 \def\temp{#1}%
cannam@167 4113 \ifx\temp\empty % Nothing found.
cannam@167 4114 \let\next\doignoretextzzz
cannam@167 4115 \else % Found a nested condition, ...
cannam@167 4116 \advance\doignorecount by 1
cannam@167 4117 \let\next\doignoretextyyy % ..., look for another.
cannam@167 4118 % If we're here, #1 ends with ^^M\ifinfo (for example).
cannam@167 4119 \fi
cannam@167 4120 \next #1% the token \_STOP_ is present just after this macro.
cannam@167 4121 }
cannam@167 4122
cannam@167 4123 % We have to swallow the remaining "\_STOP_".
cannam@167 4124 %
cannam@167 4125 \def\doignoretextzzz#1{%
cannam@167 4126 \ifnum\doignorecount = 0 % We have just found the outermost @end.
cannam@167 4127 \let\next\enddoignore
cannam@167 4128 \else % Still inside a nested condition.
cannam@167 4129 \advance\doignorecount by -1
cannam@167 4130 \let\next\doignoretext % Look for the next @end.
cannam@167 4131 \fi
cannam@167 4132 \next
cannam@167 4133 }
cannam@167 4134
cannam@167 4135 % Finish off ignored text.
cannam@167 4136 { \obeylines%
cannam@167 4137 % Ignore anything after the last `@end #1'; this matters in verbatim
cannam@167 4138 % environments, where otherwise the newline after an ignored conditional
cannam@167 4139 % would result in a blank line in the output.
cannam@167 4140 \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
cannam@167 4141 }
cannam@167 4142
cannam@167 4143
cannam@167 4144 % @set VAR sets the variable VAR to an empty value.
cannam@167 4145 % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
cannam@167 4146 %
cannam@167 4147 % Since we want to separate VAR from REST-OF-LINE (which might be
cannam@167 4148 % empty), we can't just use \parsearg; we have to insert a space of our
cannam@167 4149 % own to delimit the rest of the line, and then take it out again if we
cannam@167 4150 % didn't need it.
cannam@167 4151 % We rely on the fact that \parsearg sets \catcode`\ =10.
cannam@167 4152 %
cannam@167 4153 \parseargdef\set{\setyyy#1 \endsetyyy}
cannam@167 4154 \def\setyyy#1 #2\endsetyyy{%
cannam@167 4155 {%
cannam@167 4156 \makevalueexpandable
cannam@167 4157 \def\temp{#2}%
cannam@167 4158 \edef\next{\gdef\makecsname{SET#1}}%
cannam@167 4159 \ifx\temp\empty
cannam@167 4160 \next{}%
cannam@167 4161 \else
cannam@167 4162 \setzzz#2\endsetzzz
cannam@167 4163 \fi
cannam@167 4164 }%
cannam@167 4165 }
cannam@167 4166 % Remove the trailing space \setxxx inserted.
cannam@167 4167 \def\setzzz#1 \endsetzzz{\next{#1}}
cannam@167 4168
cannam@167 4169 % @clear VAR clears (i.e., unsets) the variable VAR.
cannam@167 4170 %
cannam@167 4171 \parseargdef\clear{%
cannam@167 4172 {%
cannam@167 4173 \makevalueexpandable
cannam@167 4174 \global\expandafter\let\csname SET#1\endcsname=\relax
cannam@167 4175 }%
cannam@167 4176 }
cannam@167 4177
cannam@167 4178 % @value{foo} gets the text saved in variable foo.
cannam@167 4179 \def\value{\begingroup\makevalueexpandable\valuexxx}
cannam@167 4180 \def\valuexxx#1{\expandablevalue{#1}\endgroup}
cannam@167 4181 {
cannam@167 4182 \catcode`\- = \active \catcode`\_ = \active
cannam@167 4183 %
cannam@167 4184 \gdef\makevalueexpandable{%
cannam@167 4185 \let\value = \expandablevalue
cannam@167 4186 % We don't want these characters active, ...
cannam@167 4187 \catcode`\-=\other \catcode`\_=\other
cannam@167 4188 % ..., but we might end up with active ones in the argument if
cannam@167 4189 % we're called from @code, as @code{@value{foo-bar_}}, though.
cannam@167 4190 % So \let them to their normal equivalents.
cannam@167 4191 \let-\normaldash \let_\normalunderscore
cannam@167 4192 }
cannam@167 4193 }
cannam@167 4194
cannam@167 4195 % We have this subroutine so that we can handle at least some @value's
cannam@167 4196 % properly in indexes (we call \makevalueexpandable in \indexdummies).
cannam@167 4197 % The command has to be fully expandable (if the variable is set), since
cannam@167 4198 % the result winds up in the index file. This means that if the
cannam@167 4199 % variable's value contains other Texinfo commands, it's almost certain
cannam@167 4200 % it will fail (although perhaps we could fix that with sufficient work
cannam@167 4201 % to do a one-level expansion on the result, instead of complete).
cannam@167 4202 %
cannam@167 4203 \def\expandablevalue#1{%
cannam@167 4204 \expandafter\ifx\csname SET#1\endcsname\relax
cannam@167 4205 {[No value for ``#1'']}%
cannam@167 4206 \message{Variable `#1', used in @value, is not set.}%
cannam@167 4207 \else
cannam@167 4208 \csname SET#1\endcsname
cannam@167 4209 \fi
cannam@167 4210 }
cannam@167 4211
cannam@167 4212 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
cannam@167 4213 % with @set.
cannam@167 4214 %
cannam@167 4215 % To get special treatment of `@end ifset,' call \makeond and the redefine.
cannam@167 4216 %
cannam@167 4217 \makecond{ifset}
cannam@167 4218 \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
cannam@167 4219 \def\doifset#1#2{%
cannam@167 4220 {%
cannam@167 4221 \makevalueexpandable
cannam@167 4222 \let\next=\empty
cannam@167 4223 \expandafter\ifx\csname SET#2\endcsname\relax
cannam@167 4224 #1% If not set, redefine \next.
cannam@167 4225 \fi
cannam@167 4226 \expandafter
cannam@167 4227 }\next
cannam@167 4228 }
cannam@167 4229 \def\ifsetfail{\doignore{ifset}}
cannam@167 4230
cannam@167 4231 % @ifclear VAR ... @end executes the `...' iff VAR has never been
cannam@167 4232 % defined with @set, or has been undefined with @clear.
cannam@167 4233 %
cannam@167 4234 % The `\else' inside the `\doifset' parameter is a trick to reuse the
cannam@167 4235 % above code: if the variable is not set, do nothing, if it is set,
cannam@167 4236 % then redefine \next to \ifclearfail.
cannam@167 4237 %
cannam@167 4238 \makecond{ifclear}
cannam@167 4239 \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
cannam@167 4240 \def\ifclearfail{\doignore{ifclear}}
cannam@167 4241
cannam@167 4242 % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
cannam@167 4243 % without the @) is in fact defined. We can only feasibly check at the
cannam@167 4244 % TeX level, so something like `mathcode' is going to considered
cannam@167 4245 % defined even though it is not a Texinfo command.
cannam@167 4246 %
cannam@167 4247 \makecond{ifcommanddefined}
cannam@167 4248 \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
cannam@167 4249 %
cannam@167 4250 \def\doifcmddefined#1#2{{%
cannam@167 4251 \makevalueexpandable
cannam@167 4252 \let\next=\empty
cannam@167 4253 \expandafter\ifx\csname #2\endcsname\relax
cannam@167 4254 #1% If not defined, \let\next as above.
cannam@167 4255 \fi
cannam@167 4256 \expandafter
cannam@167 4257 }\next
cannam@167 4258 }
cannam@167 4259 \def\ifcmddefinedfail{\doignore{ifcommanddefined}}
cannam@167 4260
cannam@167 4261 % @ifcommandnotdefined CMD ... handled similar to @ifclear above.
cannam@167 4262 \makecond{ifcommandnotdefined}
cannam@167 4263 \def\ifcommandnotdefined{%
cannam@167 4264 \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
cannam@167 4265 \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
cannam@167 4266
cannam@167 4267 % Set the `txicommandconditionals' variable, so documents have a way to
cannam@167 4268 % test if the @ifcommand...defined conditionals are available.
cannam@167 4269 \set txicommandconditionals
cannam@167 4270
cannam@167 4271 % @dircategory CATEGORY -- specify a category of the dir file
cannam@167 4272 % which this file should belong to. Ignore this in TeX.
cannam@167 4273 \let\dircategory=\comment
cannam@167 4274
cannam@167 4275 % @defininfoenclose.
cannam@167 4276 \let\definfoenclose=\comment
cannam@167 4277
cannam@167 4278
cannam@167 4279 \message{indexing,}
cannam@167 4280 % Index generation facilities
cannam@167 4281
cannam@167 4282 % Define \newwrite to be identical to plain tex's \newwrite
cannam@167 4283 % except not \outer, so it can be used within macros and \if's.
cannam@167 4284 \edef\newwrite{\makecsname{ptexnewwrite}}
cannam@167 4285
cannam@167 4286 % \newindex {foo} defines an index named foo.
cannam@167 4287 % It automatically defines \fooindex such that
cannam@167 4288 % \fooindex ...rest of line... puts an entry in the index foo.
cannam@167 4289 % It also defines \fooindfile to be the number of the output channel for
cannam@167 4290 % the file that accumulates this index. The file's extension is foo.
cannam@167 4291 % The name of an index should be no more than 2 characters long
cannam@167 4292 % for the sake of vms.
cannam@167 4293 %
cannam@167 4294 \def\newindex#1{%
cannam@167 4295 \iflinks
cannam@167 4296 \expandafter\newwrite \csname#1indfile\endcsname
cannam@167 4297 \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
cannam@167 4298 \fi
cannam@167 4299 \expandafter\xdef\csname#1index\endcsname{% % Define @#1index
cannam@167 4300 \noexpand\doindex{#1}}
cannam@167 4301 }
cannam@167 4302
cannam@167 4303 % @defindex foo == \newindex{foo}
cannam@167 4304 %
cannam@167 4305 \def\defindex{\parsearg\newindex}
cannam@167 4306
cannam@167 4307 % Define @defcodeindex, like @defindex except put all entries in @code.
cannam@167 4308 %
cannam@167 4309 \def\defcodeindex{\parsearg\newcodeindex}
cannam@167 4310 %
cannam@167 4311 \def\newcodeindex#1{%
cannam@167 4312 \iflinks
cannam@167 4313 \expandafter\newwrite \csname#1indfile\endcsname
cannam@167 4314 \openout \csname#1indfile\endcsname \jobname.#1
cannam@167 4315 \fi
cannam@167 4316 \expandafter\xdef\csname#1index\endcsname{%
cannam@167 4317 \noexpand\docodeindex{#1}}%
cannam@167 4318 }
cannam@167 4319
cannam@167 4320
cannam@167 4321 % @synindex foo bar makes index foo feed into index bar.
cannam@167 4322 % Do this instead of @defindex foo if you don't want it as a separate index.
cannam@167 4323 %
cannam@167 4324 % @syncodeindex foo bar similar, but put all entries made for index foo
cannam@167 4325 % inside @code.
cannam@167 4326 %
cannam@167 4327 \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
cannam@167 4328 \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
cannam@167 4329
cannam@167 4330 % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
cannam@167 4331 % #3 the target index (bar).
cannam@167 4332 \def\dosynindex#1#2#3{%
cannam@167 4333 % Only do \closeout if we haven't already done it, else we'll end up
cannam@167 4334 % closing the target index.
cannam@167 4335 \expandafter \ifx\csname donesynindex#2\endcsname \relax
cannam@167 4336 % The \closeout helps reduce unnecessary open files; the limit on the
cannam@167 4337 % Acorn RISC OS is a mere 16 files.
cannam@167 4338 \expandafter\closeout\csname#2indfile\endcsname
cannam@167 4339 \expandafter\let\csname donesynindex#2\endcsname = 1
cannam@167 4340 \fi
cannam@167 4341 % redefine \fooindfile:
cannam@167 4342 \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
cannam@167 4343 \expandafter\let\csname#2indfile\endcsname=\temp
cannam@167 4344 % redefine \fooindex:
cannam@167 4345 \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
cannam@167 4346 }
cannam@167 4347
cannam@167 4348 % Define \doindex, the driver for all \fooindex macros.
cannam@167 4349 % Argument #1 is generated by the calling \fooindex macro,
cannam@167 4350 % and it is "foo", the name of the index.
cannam@167 4351
cannam@167 4352 % \doindex just uses \parsearg; it calls \doind for the actual work.
cannam@167 4353 % This is because \doind is more useful to call from other macros.
cannam@167 4354
cannam@167 4355 % There is also \dosubind {index}{topic}{subtopic}
cannam@167 4356 % which makes an entry in a two-level index such as the operation index.
cannam@167 4357
cannam@167 4358 \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
cannam@167 4359 \def\singleindexer #1{\doind{\indexname}{#1}}
cannam@167 4360
cannam@167 4361 % like the previous two, but they put @code around the argument.
cannam@167 4362 \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
cannam@167 4363 \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
cannam@167 4364
cannam@167 4365 % Take care of Texinfo commands that can appear in an index entry.
cannam@167 4366 % Since there are some commands we want to expand, and others we don't,
cannam@167 4367 % we have to laboriously prevent expansion for those that we don't.
cannam@167 4368 %
cannam@167 4369 \def\indexdummies{%
cannam@167 4370 \escapechar = `\\ % use backslash in output files.
cannam@167 4371 \def\@{@}% change to @@ when we switch to @ as escape char in index files.
cannam@167 4372 \def\ {\realbackslash\space }%
cannam@167 4373 %
cannam@167 4374 % Need these unexpandable (because we define \tt as a dummy)
cannam@167 4375 % definitions when @{ or @} appear in index entry text. Also, more
cannam@167 4376 % complicated, when \tex is in effect and \{ is a \delimiter again.
cannam@167 4377 % We can't use \lbracecmd and \rbracecmd because texindex assumes
cannam@167 4378 % braces and backslashes are used only as delimiters. Perhaps we
cannam@167 4379 % should define @lbrace and @rbrace commands a la @comma.
cannam@167 4380 \def\{{{\tt\char123}}%
cannam@167 4381 \def\}{{\tt\char125}}%
cannam@167 4382 %
cannam@167 4383 % I don't entirely understand this, but when an index entry is
cannam@167 4384 % generated from a macro call, the \endinput which \scanmacro inserts
cannam@167 4385 % causes processing to be prematurely terminated. This is,
cannam@167 4386 % apparently, because \indexsorttmp is fully expanded, and \endinput
cannam@167 4387 % is an expandable command. The redefinition below makes \endinput
cannam@167 4388 % disappear altogether for that purpose -- although logging shows that
cannam@167 4389 % processing continues to some further point. On the other hand, it
cannam@167 4390 % seems \endinput does not hurt in the printed index arg, since that
cannam@167 4391 % is still getting written without apparent harm.
cannam@167 4392 %
cannam@167 4393 % Sample source (mac-idx3.tex, reported by Graham Percival to
cannam@167 4394 % help-texinfo, 22may06):
cannam@167 4395 % @macro funindex {WORD}
cannam@167 4396 % @findex xyz
cannam@167 4397 % @end macro
cannam@167 4398 % ...
cannam@167 4399 % @funindex commtest
cannam@167 4400 %
cannam@167 4401 % The above is not enough to reproduce the bug, but it gives the flavor.
cannam@167 4402 %
cannam@167 4403 % Sample whatsit resulting:
cannam@167 4404 % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}}
cannam@167 4405 %
cannam@167 4406 % So:
cannam@167 4407 \let\endinput = \empty
cannam@167 4408 %
cannam@167 4409 % Do the redefinitions.
cannam@167 4410 \commondummies
cannam@167 4411 }
cannam@167 4412
cannam@167 4413 % For the aux and toc files, @ is the escape character. So we want to
cannam@167 4414 % redefine everything using @ as the escape character (instead of
cannam@167 4415 % \realbackslash, still used for index files). When everything uses @,
cannam@167 4416 % this will be simpler.
cannam@167 4417 %
cannam@167 4418 \def\atdummies{%
cannam@167 4419 \def\@{@@}%
cannam@167 4420 \def\ {@ }%
cannam@167 4421 \let\{ = \lbraceatcmd
cannam@167 4422 \let\} = \rbraceatcmd
cannam@167 4423 %
cannam@167 4424 % Do the redefinitions.
cannam@167 4425 \commondummies
cannam@167 4426 \otherbackslash
cannam@167 4427 }
cannam@167 4428
cannam@167 4429 % Called from \indexdummies and \atdummies.
cannam@167 4430 %
cannam@167 4431 \def\commondummies{%
cannam@167 4432 %
cannam@167 4433 % \definedummyword defines \#1 as \string\#1\space, thus effectively
cannam@167 4434 % preventing its expansion. This is used only for control words,
cannam@167 4435 % not control letters, because the \space would be incorrect for
cannam@167 4436 % control characters, but is needed to separate the control word
cannam@167 4437 % from whatever follows.
cannam@167 4438 %
cannam@167 4439 % For control letters, we have \definedummyletter, which omits the
cannam@167 4440 % space.
cannam@167 4441 %
cannam@167 4442 % These can be used both for control words that take an argument and
cannam@167 4443 % those that do not. If it is followed by {arg} in the input, then
cannam@167 4444 % that will dutifully get written to the index (or wherever).
cannam@167 4445 %
cannam@167 4446 \def\definedummyword ##1{\def##1{\string##1\space}}%
cannam@167 4447 \def\definedummyletter##1{\def##1{\string##1}}%
cannam@167 4448 \let\definedummyaccent\definedummyletter
cannam@167 4449 %
cannam@167 4450 \commondummiesnofonts
cannam@167 4451 %
cannam@167 4452 \definedummyletter\_%
cannam@167 4453 \definedummyletter\-%
cannam@167 4454 %
cannam@167 4455 % Non-English letters.
cannam@167 4456 \definedummyword\AA
cannam@167 4457 \definedummyword\AE
cannam@167 4458 \definedummyword\DH
cannam@167 4459 \definedummyword\L
cannam@167 4460 \definedummyword\O
cannam@167 4461 \definedummyword\OE
cannam@167 4462 \definedummyword\TH
cannam@167 4463 \definedummyword\aa
cannam@167 4464 \definedummyword\ae
cannam@167 4465 \definedummyword\dh
cannam@167 4466 \definedummyword\exclamdown
cannam@167 4467 \definedummyword\l
cannam@167 4468 \definedummyword\o
cannam@167 4469 \definedummyword\oe
cannam@167 4470 \definedummyword\ordf
cannam@167 4471 \definedummyword\ordm
cannam@167 4472 \definedummyword\questiondown
cannam@167 4473 \definedummyword\ss
cannam@167 4474 \definedummyword\th
cannam@167 4475 %
cannam@167 4476 % Although these internal commands shouldn't show up, sometimes they do.
cannam@167 4477 \definedummyword\bf
cannam@167 4478 \definedummyword\gtr
cannam@167 4479 \definedummyword\hat
cannam@167 4480 \definedummyword\less
cannam@167 4481 \definedummyword\sf
cannam@167 4482 \definedummyword\sl
cannam@167 4483 \definedummyword\tclose
cannam@167 4484 \definedummyword\tt
cannam@167 4485 %
cannam@167 4486 \definedummyword\LaTeX
cannam@167 4487 \definedummyword\TeX
cannam@167 4488 %
cannam@167 4489 % Assorted special characters.
cannam@167 4490 \definedummyword\arrow
cannam@167 4491 \definedummyword\bullet
cannam@167 4492 \definedummyword\comma
cannam@167 4493 \definedummyword\copyright
cannam@167 4494 \definedummyword\registeredsymbol
cannam@167 4495 \definedummyword\dots
cannam@167 4496 \definedummyword\enddots
cannam@167 4497 \definedummyword\entrybreak
cannam@167 4498 \definedummyword\equiv
cannam@167 4499 \definedummyword\error
cannam@167 4500 \definedummyword\euro
cannam@167 4501 \definedummyword\expansion
cannam@167 4502 \definedummyword\geq
cannam@167 4503 \definedummyword\guillemetleft
cannam@167 4504 \definedummyword\guillemetright
cannam@167 4505 \definedummyword\guilsinglleft
cannam@167 4506 \definedummyword\guilsinglright
cannam@167 4507 \definedummyword\lbracechar
cannam@167 4508 \definedummyword\leq
cannam@167 4509 \definedummyword\minus
cannam@167 4510 \definedummyword\ogonek
cannam@167 4511 \definedummyword\pounds
cannam@167 4512 \definedummyword\point
cannam@167 4513 \definedummyword\print
cannam@167 4514 \definedummyword\quotedblbase
cannam@167 4515 \definedummyword\quotedblleft
cannam@167 4516 \definedummyword\quotedblright
cannam@167 4517 \definedummyword\quoteleft
cannam@167 4518 \definedummyword\quoteright
cannam@167 4519 \definedummyword\quotesinglbase
cannam@167 4520 \definedummyword\rbracechar
cannam@167 4521 \definedummyword\result
cannam@167 4522 \definedummyword\textdegree
cannam@167 4523 %
cannam@167 4524 % We want to disable all macros so that they are not expanded by \write.
cannam@167 4525 \macrolist
cannam@167 4526 %
cannam@167 4527 \normalturnoffactive
cannam@167 4528 %
cannam@167 4529 % Handle some cases of @value -- where it does not contain any
cannam@167 4530 % (non-fully-expandable) commands.
cannam@167 4531 \makevalueexpandable
cannam@167 4532 }
cannam@167 4533
cannam@167 4534 % \commondummiesnofonts: common to \commondummies and \indexnofonts.
cannam@167 4535 %
cannam@167 4536 \def\commondummiesnofonts{%
cannam@167 4537 % Control letters and accents.
cannam@167 4538 \definedummyletter\!%
cannam@167 4539 \definedummyaccent\"%
cannam@167 4540 \definedummyaccent\'%
cannam@167 4541 \definedummyletter\*%
cannam@167 4542 \definedummyaccent\,%
cannam@167 4543 \definedummyletter\.%
cannam@167 4544 \definedummyletter\/%
cannam@167 4545 \definedummyletter\:%
cannam@167 4546 \definedummyaccent\=%
cannam@167 4547 \definedummyletter\?%
cannam@167 4548 \definedummyaccent\^%
cannam@167 4549 \definedummyaccent\`%
cannam@167 4550 \definedummyaccent\~%
cannam@167 4551 \definedummyword\u
cannam@167 4552 \definedummyword\v
cannam@167 4553 \definedummyword\H
cannam@167 4554 \definedummyword\dotaccent
cannam@167 4555 \definedummyword\ogonek
cannam@167 4556 \definedummyword\ringaccent
cannam@167 4557 \definedummyword\tieaccent
cannam@167 4558 \definedummyword\ubaraccent
cannam@167 4559 \definedummyword\udotaccent
cannam@167 4560 \definedummyword\dotless
cannam@167 4561 %
cannam@167 4562 % Texinfo font commands.
cannam@167 4563 \definedummyword\b
cannam@167 4564 \definedummyword\i
cannam@167 4565 \definedummyword\r
cannam@167 4566 \definedummyword\sansserif
cannam@167 4567 \definedummyword\sc
cannam@167 4568 \definedummyword\slanted
cannam@167 4569 \definedummyword\t
cannam@167 4570 %
cannam@167 4571 % Commands that take arguments.
cannam@167 4572 \definedummyword\abbr
cannam@167 4573 \definedummyword\acronym
cannam@167 4574 \definedummyword\anchor
cannam@167 4575 \definedummyword\cite
cannam@167 4576 \definedummyword\code
cannam@167 4577 \definedummyword\command
cannam@167 4578 \definedummyword\dfn
cannam@167 4579 \definedummyword\dmn
cannam@167 4580 \definedummyword\email
cannam@167 4581 \definedummyword\emph
cannam@167 4582 \definedummyword\env
cannam@167 4583 \definedummyword\file
cannam@167 4584 \definedummyword\image
cannam@167 4585 \definedummyword\indicateurl
cannam@167 4586 \definedummyword\inforef
cannam@167 4587 \definedummyword\kbd
cannam@167 4588 \definedummyword\key
cannam@167 4589 \definedummyword\math
cannam@167 4590 \definedummyword\option
cannam@167 4591 \definedummyword\pxref
cannam@167 4592 \definedummyword\ref
cannam@167 4593 \definedummyword\samp
cannam@167 4594 \definedummyword\strong
cannam@167 4595 \definedummyword\tie
cannam@167 4596 \definedummyword\uref
cannam@167 4597 \definedummyword\url
cannam@167 4598 \definedummyword\var
cannam@167 4599 \definedummyword\verb
cannam@167 4600 \definedummyword\w
cannam@167 4601 \definedummyword\xref
cannam@167 4602 }
cannam@167 4603
cannam@167 4604 % \indexnofonts is used when outputting the strings to sort the index
cannam@167 4605 % by, and when constructing control sequence names. It eliminates all
cannam@167 4606 % control sequences and just writes whatever the best ASCII sort string
cannam@167 4607 % would be for a given command (usually its argument).
cannam@167 4608 %
cannam@167 4609 \def\indexnofonts{%
cannam@167 4610 % Accent commands should become @asis.
cannam@167 4611 \def\definedummyaccent##1{\let##1\asis}%
cannam@167 4612 % We can just ignore other control letters.
cannam@167 4613 \def\definedummyletter##1{\let##1\empty}%
cannam@167 4614 % All control words become @asis by default; overrides below.
cannam@167 4615 \let\definedummyword\definedummyaccent
cannam@167 4616 %
cannam@167 4617 \commondummiesnofonts
cannam@167 4618 %
cannam@167 4619 % Don't no-op \tt, since it isn't a user-level command
cannam@167 4620 % and is used in the definitions of the active chars like <, >, |, etc.
cannam@167 4621 % Likewise with the other plain tex font commands.
cannam@167 4622 %\let\tt=\asis
cannam@167 4623 %
cannam@167 4624 \def\ { }%
cannam@167 4625 \def\@{@}%
cannam@167 4626 \def\_{\normalunderscore}%
cannam@167 4627 \def\-{}% @- shouldn't affect sorting
cannam@167 4628 %
cannam@167 4629 % Unfortunately, texindex is not prepared to handle braces in the
cannam@167 4630 % content at all. So for index sorting, we map @{ and @} to strings
cannam@167 4631 % starting with |, since that ASCII character is between ASCII { and }.
cannam@167 4632 \def\{{|a}%
cannam@167 4633 \def\lbracechar{|a}%
cannam@167 4634 %
cannam@167 4635 \def\}{|b}%
cannam@167 4636 \def\rbracechar{|b}%
cannam@167 4637 %
cannam@167 4638 % Non-English letters.
cannam@167 4639 \def\AA{AA}%
cannam@167 4640 \def\AE{AE}%
cannam@167 4641 \def\DH{DZZ}%
cannam@167 4642 \def\L{L}%
cannam@167 4643 \def\OE{OE}%
cannam@167 4644 \def\O{O}%
cannam@167 4645 \def\TH{ZZZ}%
cannam@167 4646 \def\aa{aa}%
cannam@167 4647 \def\ae{ae}%
cannam@167 4648 \def\dh{dzz}%
cannam@167 4649 \def\exclamdown{!}%
cannam@167 4650 \def\l{l}%
cannam@167 4651 \def\oe{oe}%
cannam@167 4652 \def\ordf{a}%
cannam@167 4653 \def\ordm{o}%
cannam@167 4654 \def\o{o}%
cannam@167 4655 \def\questiondown{?}%
cannam@167 4656 \def\ss{ss}%
cannam@167 4657 \def\th{zzz}%
cannam@167 4658 %
cannam@167 4659 \def\LaTeX{LaTeX}%
cannam@167 4660 \def\TeX{TeX}%
cannam@167 4661 %
cannam@167 4662 % Assorted special characters.
cannam@167 4663 % (The following {} will end up in the sort string, but that's ok.)
cannam@167 4664 \def\arrow{->}%
cannam@167 4665 \def\bullet{bullet}%
cannam@167 4666 \def\comma{,}%
cannam@167 4667 \def\copyright{copyright}%
cannam@167 4668 \def\dots{...}%
cannam@167 4669 \def\enddots{...}%
cannam@167 4670 \def\equiv{==}%
cannam@167 4671 \def\error{error}%
cannam@167 4672 \def\euro{euro}%
cannam@167 4673 \def\expansion{==>}%
cannam@167 4674 \def\geq{>=}%
cannam@167 4675 \def\guillemetleft{<<}%
cannam@167 4676 \def\guillemetright{>>}%
cannam@167 4677 \def\guilsinglleft{<}%
cannam@167 4678 \def\guilsinglright{>}%
cannam@167 4679 \def\leq{<=}%
cannam@167 4680 \def\minus{-}%
cannam@167 4681 \def\point{.}%
cannam@167 4682 \def\pounds{pounds}%
cannam@167 4683 \def\print{-|}%
cannam@167 4684 \def\quotedblbase{"}%
cannam@167 4685 \def\quotedblleft{"}%
cannam@167 4686 \def\quotedblright{"}%
cannam@167 4687 \def\quoteleft{`}%
cannam@167 4688 \def\quoteright{'}%
cannam@167 4689 \def\quotesinglbase{,}%
cannam@167 4690 \def\registeredsymbol{R}%
cannam@167 4691 \def\result{=>}%
cannam@167 4692 \def\textdegree{o}%
cannam@167 4693 %
cannam@167 4694 \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax
cannam@167 4695 \else \indexlquoteignore \fi
cannam@167 4696 %
cannam@167 4697 % We need to get rid of all macros, leaving only the arguments (if present).
cannam@167 4698 % Of course this is not nearly correct, but it is the best we can do for now.
cannam@167 4699 % makeinfo does not expand macros in the argument to @deffn, which ends up
cannam@167 4700 % writing an index entry, and texindex isn't prepared for an index sort entry
cannam@167 4701 % that starts with \.
cannam@167 4702 %
cannam@167 4703 % Since macro invocations are followed by braces, we can just redefine them
cannam@167 4704 % to take a single TeX argument. The case of a macro invocation that
cannam@167 4705 % goes to end-of-line is not handled.
cannam@167 4706 %
cannam@167 4707 \macrolist
cannam@167 4708 }
cannam@167 4709
cannam@167 4710 % Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us
cannam@167 4711 % ignore left quotes in the sort term.
cannam@167 4712 {\catcode`\`=\active
cannam@167 4713 \gdef\indexlquoteignore{\let`=\empty}}
cannam@167 4714
cannam@167 4715 \let\indexbackslash=0 %overridden during \printindex.
cannam@167 4716 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
cannam@167 4717
cannam@167 4718 % Most index entries go through here, but \dosubind is the general case.
cannam@167 4719 % #1 is the index name, #2 is the entry text.
cannam@167 4720 \def\doind#1#2{\dosubind{#1}{#2}{}}
cannam@167 4721
cannam@167 4722 % Workhorse for all \fooindexes.
cannam@167 4723 % #1 is name of index, #2 is stuff to put there, #3 is subentry --
cannam@167 4724 % empty if called from \doind, as we usually are (the main exception
cannam@167 4725 % is with most defuns, which call us directly).
cannam@167 4726 %
cannam@167 4727 \def\dosubind#1#2#3{%
cannam@167 4728 \iflinks
cannam@167 4729 {%
cannam@167 4730 % Store the main index entry text (including the third arg).
cannam@167 4731 \toks0 = {#2}%
cannam@167 4732 % If third arg is present, precede it with a space.
cannam@167 4733 \def\thirdarg{#3}%
cannam@167 4734 \ifx\thirdarg\empty \else
cannam@167 4735 \toks0 = \expandafter{\the\toks0 \space #3}%
cannam@167 4736 \fi
cannam@167 4737 %
cannam@167 4738 \edef\writeto{\csname#1indfile\endcsname}%
cannam@167 4739 %
cannam@167 4740 \safewhatsit\dosubindwrite
cannam@167 4741 }%
cannam@167 4742 \fi
cannam@167 4743 }
cannam@167 4744
cannam@167 4745 % Write the entry in \toks0 to the index file:
cannam@167 4746 %
cannam@167 4747 \def\dosubindwrite{%
cannam@167 4748 % Put the index entry in the margin if desired.
cannam@167 4749 \ifx\SETmarginindex\relax\else
cannam@167 4750 \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
cannam@167 4751 \fi
cannam@167 4752 %
cannam@167 4753 % Remember, we are within a group.
cannam@167 4754 \indexdummies % Must do this here, since \bf, etc expand at this stage
cannam@167 4755 \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
cannam@167 4756 % so it will be output as is; and it will print as backslash.
cannam@167 4757 %
cannam@167 4758 % Process the index entry with all font commands turned off, to
cannam@167 4759 % get the string to sort by.
cannam@167 4760 {\indexnofonts
cannam@167 4761 \edef\temp{\the\toks0}% need full expansion
cannam@167 4762 \xdef\indexsorttmp{\temp}%
cannam@167 4763 }%
cannam@167 4764 %
cannam@167 4765 % Set up the complete index entry, with both the sort key and
cannam@167 4766 % the original text, including any font commands. We write
cannam@167 4767 % three arguments to \entry to the .?? file (four in the
cannam@167 4768 % subentry case), texindex reduces to two when writing the .??s
cannam@167 4769 % sorted result.
cannam@167 4770 \edef\temp{%
cannam@167 4771 \write\writeto{%
cannam@167 4772 \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
cannam@167 4773 }%
cannam@167 4774 \temp
cannam@167 4775 }
cannam@167 4776
cannam@167 4777 % Take care of unwanted page breaks/skips around a whatsit:
cannam@167 4778 %
cannam@167 4779 % If a skip is the last thing on the list now, preserve it
cannam@167 4780 % by backing up by \lastskip, doing the \write, then inserting
cannam@167 4781 % the skip again. Otherwise, the whatsit generated by the
cannam@167 4782 % \write or \pdfdest will make \lastskip zero. The result is that
cannam@167 4783 % sequences like this:
cannam@167 4784 % @end defun
cannam@167 4785 % @tindex whatever
cannam@167 4786 % @defun ...
cannam@167 4787 % will have extra space inserted, because the \medbreak in the
cannam@167 4788 % start of the @defun won't see the skip inserted by the @end of
cannam@167 4789 % the previous defun.
cannam@167 4790 %
cannam@167 4791 % But don't do any of this if we're not in vertical mode. We
cannam@167 4792 % don't want to do a \vskip and prematurely end a paragraph.
cannam@167 4793 %
cannam@167 4794 % Avoid page breaks due to these extra skips, too.
cannam@167 4795 %
cannam@167 4796 % But wait, there is a catch there:
cannam@167 4797 % We'll have to check whether \lastskip is zero skip. \ifdim is not
cannam@167 4798 % sufficient for this purpose, as it ignores stretch and shrink parts
cannam@167 4799 % of the skip. The only way seems to be to check the textual
cannam@167 4800 % representation of the skip.
cannam@167 4801 %
cannam@167 4802 % The following is almost like \def\zeroskipmacro{0.0pt} except that
cannam@167 4803 % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
cannam@167 4804 %
cannam@167 4805 \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
cannam@167 4806 %
cannam@167 4807 \newskip\whatsitskip
cannam@167 4808 \newcount\whatsitpenalty
cannam@167 4809 %
cannam@167 4810 % ..., ready, GO:
cannam@167 4811 %
cannam@167 4812 \def\safewhatsit#1{\ifhmode
cannam@167 4813 #1%
cannam@167 4814 \else
cannam@167 4815 % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
cannam@167 4816 \whatsitskip = \lastskip
cannam@167 4817 \edef\lastskipmacro{\the\lastskip}%
cannam@167 4818 \whatsitpenalty = \lastpenalty
cannam@167 4819 %
cannam@167 4820 % If \lastskip is nonzero, that means the last item was a
cannam@167 4821 % skip. And since a skip is discardable, that means this
cannam@167 4822 % -\whatsitskip glue we're inserting is preceded by a
cannam@167 4823 % non-discardable item, therefore it is not a potential
cannam@167 4824 % breakpoint, therefore no \nobreak needed.
cannam@167 4825 \ifx\lastskipmacro\zeroskipmacro
cannam@167 4826 \else
cannam@167 4827 \vskip-\whatsitskip
cannam@167 4828 \fi
cannam@167 4829 %
cannam@167 4830 #1%
cannam@167 4831 %
cannam@167 4832 \ifx\lastskipmacro\zeroskipmacro
cannam@167 4833 % If \lastskip was zero, perhaps the last item was a penalty, and
cannam@167 4834 % perhaps it was >=10000, e.g., a \nobreak. In that case, we want
cannam@167 4835 % to re-insert the same penalty (values >10000 are used for various
cannam@167 4836 % signals); since we just inserted a non-discardable item, any
cannam@167 4837 % following glue (such as a \parskip) would be a breakpoint. For example:
cannam@167 4838 % @deffn deffn-whatever
cannam@167 4839 % @vindex index-whatever
cannam@167 4840 % Description.
cannam@167 4841 % would allow a break between the index-whatever whatsit
cannam@167 4842 % and the "Description." paragraph.
cannam@167 4843 \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
cannam@167 4844 \else
cannam@167 4845 % On the other hand, if we had a nonzero \lastskip,
cannam@167 4846 % this make-up glue would be preceded by a non-discardable item
cannam@167 4847 % (the whatsit from the \write), so we must insert a \nobreak.
cannam@167 4848 \nobreak\vskip\whatsitskip
cannam@167 4849 \fi
cannam@167 4850 \fi}
cannam@167 4851
cannam@167 4852 % The index entry written in the file actually looks like
cannam@167 4853 % \entry {sortstring}{page}{topic}
cannam@167 4854 % or
cannam@167 4855 % \entry {sortstring}{page}{topic}{subtopic}
cannam@167 4856 % The texindex program reads in these files and writes files
cannam@167 4857 % containing these kinds of lines:
cannam@167 4858 % \initial {c}
cannam@167 4859 % before the first topic whose initial is c
cannam@167 4860 % \entry {topic}{pagelist}
cannam@167 4861 % for a topic that is used without subtopics
cannam@167 4862 % \primary {topic}
cannam@167 4863 % for the beginning of a topic that is used with subtopics
cannam@167 4864 % \secondary {subtopic}{pagelist}
cannam@167 4865 % for each subtopic.
cannam@167 4866
cannam@167 4867 % Define the user-accessible indexing commands
cannam@167 4868 % @findex, @vindex, @kindex, @cindex.
cannam@167 4869
cannam@167 4870 \def\findex {\fnindex}
cannam@167 4871 \def\kindex {\kyindex}
cannam@167 4872 \def\cindex {\cpindex}
cannam@167 4873 \def\vindex {\vrindex}
cannam@167 4874 \def\tindex {\tpindex}
cannam@167 4875 \def\pindex {\pgindex}
cannam@167 4876
cannam@167 4877 \def\cindexsub {\begingroup\obeylines\cindexsub}
cannam@167 4878 {\obeylines %
cannam@167 4879 \gdef\cindexsub "#1" #2^^M{\endgroup %
cannam@167 4880 \dosubind{cp}{#2}{#1}}}
cannam@167 4881
cannam@167 4882 % Define the macros used in formatting output of the sorted index material.
cannam@167 4883
cannam@167 4884 % @printindex causes a particular index (the ??s file) to get printed.
cannam@167 4885 % It does not print any chapter heading (usually an @unnumbered).
cannam@167 4886 %
cannam@167 4887 \parseargdef\printindex{\begingroup
cannam@167 4888 \dobreak \chapheadingskip{10000}%
cannam@167 4889 %
cannam@167 4890 \smallfonts \rm
cannam@167 4891 \tolerance = 9500
cannam@167 4892 \plainfrenchspacing
cannam@167 4893 \everypar = {}% don't want the \kern\-parindent from indentation suppression.
cannam@167 4894 %
cannam@167 4895 % See if the index file exists and is nonempty.
cannam@167 4896 % Change catcode of @ here so that if the index file contains
cannam@167 4897 % \initial {@}
cannam@167 4898 % as its first line, TeX doesn't complain about mismatched braces
cannam@167 4899 % (because it thinks @} is a control sequence).
cannam@167 4900 \catcode`\@ = 11
cannam@167 4901 \openin 1 \jobname.#1s
cannam@167 4902 \ifeof 1
cannam@167 4903 % \enddoublecolumns gets confused if there is no text in the index,
cannam@167 4904 % and it loses the chapter title and the aux file entries for the
cannam@167 4905 % index. The easiest way to prevent this problem is to make sure
cannam@167 4906 % there is some text.
cannam@167 4907 \putwordIndexNonexistent
cannam@167 4908 \else
cannam@167 4909 %
cannam@167 4910 % If the index file exists but is empty, then \openin leaves \ifeof
cannam@167 4911 % false. We have to make TeX try to read something from the file, so
cannam@167 4912 % it can discover if there is anything in it.
cannam@167 4913 \read 1 to \temp
cannam@167 4914 \ifeof 1
cannam@167 4915 \putwordIndexIsEmpty
cannam@167 4916 \else
cannam@167 4917 % Index files are almost Texinfo source, but we use \ as the escape
cannam@167 4918 % character. It would be better to use @, but that's too big a change
cannam@167 4919 % to make right now.
cannam@167 4920 \def\indexbackslash{\backslashcurfont}%
cannam@167 4921 \catcode`\\ = 0
cannam@167 4922 \escapechar = `\\
cannam@167 4923 \begindoublecolumns
cannam@167 4924 \input \jobname.#1s
cannam@167 4925 \enddoublecolumns
cannam@167 4926 \fi
cannam@167 4927 \fi
cannam@167 4928 \closein 1
cannam@167 4929 \endgroup}
cannam@167 4930
cannam@167 4931 % These macros are used by the sorted index file itself.
cannam@167 4932 % Change them to control the appearance of the index.
cannam@167 4933
cannam@167 4934 \def\initial#1{{%
cannam@167 4935 % Some minor font changes for the special characters.
cannam@167 4936 \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
cannam@167 4937 %
cannam@167 4938 % Remove any glue we may have, we'll be inserting our own.
cannam@167 4939 \removelastskip
cannam@167 4940 %
cannam@167 4941 % We like breaks before the index initials, so insert a bonus.
cannam@167 4942 \nobreak
cannam@167 4943 \vskip 0pt plus 3\baselineskip
cannam@167 4944 \penalty 0
cannam@167 4945 \vskip 0pt plus -3\baselineskip
cannam@167 4946 %
cannam@167 4947 % Typeset the initial. Making this add up to a whole number of
cannam@167 4948 % baselineskips increases the chance of the dots lining up from column
cannam@167 4949 % to column. It still won't often be perfect, because of the stretch
cannam@167 4950 % we need before each entry, but it's better.
cannam@167 4951 %
cannam@167 4952 % No shrink because it confuses \balancecolumns.
cannam@167 4953 \vskip 1.67\baselineskip plus .5\baselineskip
cannam@167 4954 \leftline{\secbf #1}%
cannam@167 4955 % Do our best not to break after the initial.
cannam@167 4956 \nobreak
cannam@167 4957 \vskip .33\baselineskip plus .1\baselineskip
cannam@167 4958 }}
cannam@167 4959
cannam@167 4960 % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
cannam@167 4961 % then page number (#2) flushed to the right margin. It is used for index
cannam@167 4962 % and table of contents entries. The paragraph is indented by \leftskip.
cannam@167 4963 %
cannam@167 4964 % A straightforward implementation would start like this:
cannam@167 4965 % \def\entry#1#2{...
cannam@167 4966 % But this freezes the catcodes in the argument, and can cause problems to
cannam@167 4967 % @code, which sets - active. This problem was fixed by a kludge---
cannam@167 4968 % ``-'' was active throughout whole index, but this isn't really right.
cannam@167 4969 % The right solution is to prevent \entry from swallowing the whole text.
cannam@167 4970 % --kasal, 21nov03
cannam@167 4971 \def\entry{%
cannam@167 4972 \begingroup
cannam@167 4973 %
cannam@167 4974 % Start a new paragraph if necessary, so our assignments below can't
cannam@167 4975 % affect previous text.
cannam@167 4976 \par
cannam@167 4977 %
cannam@167 4978 % Do not fill out the last line with white space.
cannam@167 4979 \parfillskip = 0in
cannam@167 4980 %
cannam@167 4981 % No extra space above this paragraph.
cannam@167 4982 \parskip = 0in
cannam@167 4983 %
cannam@167 4984 % Do not prefer a separate line ending with a hyphen to fewer lines.
cannam@167 4985 \finalhyphendemerits = 0
cannam@167 4986 %
cannam@167 4987 % \hangindent is only relevant when the entry text and page number
cannam@167 4988 % don't both fit on one line. In that case, bob suggests starting the
cannam@167 4989 % dots pretty far over on the line. Unfortunately, a large
cannam@167 4990 % indentation looks wrong when the entry text itself is broken across
cannam@167 4991 % lines. So we use a small indentation and put up with long leaders.
cannam@167 4992 %
cannam@167 4993 % \hangafter is reset to 1 (which is the value we want) at the start
cannam@167 4994 % of each paragraph, so we need not do anything with that.
cannam@167 4995 \hangindent = 2em
cannam@167 4996 %
cannam@167 4997 % When the entry text needs to be broken, just fill out the first line
cannam@167 4998 % with blank space.
cannam@167 4999 \rightskip = 0pt plus1fil
cannam@167 5000 %
cannam@167 5001 % A bit of stretch before each entry for the benefit of balancing
cannam@167 5002 % columns.
cannam@167 5003 \vskip 0pt plus1pt
cannam@167 5004 %
cannam@167 5005 % When reading the text of entry, convert explicit line breaks
cannam@167 5006 % from @* into spaces. The user might give these in long section
cannam@167 5007 % titles, for instance.
cannam@167 5008 \def\*{\unskip\space\ignorespaces}%
cannam@167 5009 \def\entrybreak{\hfil\break}%
cannam@167 5010 %
cannam@167 5011 % Swallow the left brace of the text (first parameter):
cannam@167 5012 \afterassignment\doentry
cannam@167 5013 \let\temp =
cannam@167 5014 }
cannam@167 5015 \def\entrybreak{\unskip\space\ignorespaces}%
cannam@167 5016 \def\doentry{%
cannam@167 5017 \bgroup % Instead of the swallowed brace.
cannam@167 5018 \noindent
cannam@167 5019 \aftergroup\finishentry
cannam@167 5020 % And now comes the text of the entry.
cannam@167 5021 }
cannam@167 5022 \def\finishentry#1{%
cannam@167 5023 % #1 is the page number.
cannam@167 5024 %
cannam@167 5025 % The following is kludged to not output a line of dots in the index if
cannam@167 5026 % there are no page numbers. The next person who breaks this will be
cannam@167 5027 % cursed by a Unix daemon.
cannam@167 5028 \setbox\boxA = \hbox{#1}%
cannam@167 5029 \ifdim\wd\boxA = 0pt
cannam@167 5030 \ %
cannam@167 5031 \else
cannam@167 5032 %
cannam@167 5033 % If we must, put the page number on a line of its own, and fill out
cannam@167 5034 % this line with blank space. (The \hfil is overwhelmed with the
cannam@167 5035 % fill leaders glue in \indexdotfill if the page number does fit.)
cannam@167 5036 \hfil\penalty50
cannam@167 5037 \null\nobreak\indexdotfill % Have leaders before the page number.
cannam@167 5038 %
cannam@167 5039 % The `\ ' here is removed by the implicit \unskip that TeX does as
cannam@167 5040 % part of (the primitive) \par. Without it, a spurious underfull
cannam@167 5041 % \hbox ensues.
cannam@167 5042 \ifpdf
cannam@167 5043 \pdfgettoks#1.%
cannam@167 5044 \ \the\toksA
cannam@167 5045 \else
cannam@167 5046 \ #1%
cannam@167 5047 \fi
cannam@167 5048 \fi
cannam@167 5049 \par
cannam@167 5050 \endgroup
cannam@167 5051 }
cannam@167 5052
cannam@167 5053 % Like plain.tex's \dotfill, except uses up at least 1 em.
cannam@167 5054 \def\indexdotfill{\cleaders
cannam@167 5055 \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill}
cannam@167 5056
cannam@167 5057 \def\primary #1{\line{#1\hfil}}
cannam@167 5058
cannam@167 5059 \newskip\secondaryindent \secondaryindent=0.5cm
cannam@167 5060 \def\secondary#1#2{{%
cannam@167 5061 \parfillskip=0in
cannam@167 5062 \parskip=0in
cannam@167 5063 \hangindent=1in
cannam@167 5064 \hangafter=1
cannam@167 5065 \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
cannam@167 5066 \ifpdf
cannam@167 5067 \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
cannam@167 5068 \else
cannam@167 5069 #2
cannam@167 5070 \fi
cannam@167 5071 \par
cannam@167 5072 }}
cannam@167 5073
cannam@167 5074 % Define two-column mode, which we use to typeset indexes.
cannam@167 5075 % Adapted from the TeXbook, page 416, which is to say,
cannam@167 5076 % the manmac.tex format used to print the TeXbook itself.
cannam@167 5077 \catcode`\@=11
cannam@167 5078
cannam@167 5079 \newbox\partialpage
cannam@167 5080 \newdimen\doublecolumnhsize
cannam@167 5081
cannam@167 5082 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
cannam@167 5083 % Grab any single-column material above us.
cannam@167 5084 \output = {%
cannam@167 5085 %
cannam@167 5086 % Here is a possibility not foreseen in manmac: if we accumulate a
cannam@167 5087 % whole lot of material, we might end up calling this \output
cannam@167 5088 % routine twice in a row (see the doublecol-lose test, which is
cannam@167 5089 % essentially a couple of indexes with @setchapternewpage off). In
cannam@167 5090 % that case we just ship out what is in \partialpage with the normal
cannam@167 5091 % output routine. Generally, \partialpage will be empty when this
cannam@167 5092 % runs and this will be a no-op. See the indexspread.tex test case.
cannam@167 5093 \ifvoid\partialpage \else
cannam@167 5094 \onepageout{\pagecontents\partialpage}%
cannam@167 5095 \fi
cannam@167 5096 %
cannam@167 5097 \global\setbox\partialpage = \vbox{%
cannam@167 5098 % Unvbox the main output page.
cannam@167 5099 \unvbox\PAGE
cannam@167 5100 \kern-\topskip \kern\baselineskip
cannam@167 5101 }%
cannam@167 5102 }%
cannam@167 5103 \eject % run that output routine to set \partialpage
cannam@167 5104 %
cannam@167 5105 % Use the double-column output routine for subsequent pages.
cannam@167 5106 \output = {\doublecolumnout}%
cannam@167 5107 %
cannam@167 5108 % Change the page size parameters. We could do this once outside this
cannam@167 5109 % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
cannam@167 5110 % format, but then we repeat the same computation. Repeating a couple
cannam@167 5111 % of assignments once per index is clearly meaningless for the
cannam@167 5112 % execution time, so we may as well do it in one place.
cannam@167 5113 %
cannam@167 5114 % First we halve the line length, less a little for the gutter between
cannam@167 5115 % the columns. We compute the gutter based on the line length, so it
cannam@167 5116 % changes automatically with the paper format. The magic constant
cannam@167 5117 % below is chosen so that the gutter has the same value (well, +-<1pt)
cannam@167 5118 % as it did when we hard-coded it.
cannam@167 5119 %
cannam@167 5120 % We put the result in a separate register, \doublecolumhsize, so we
cannam@167 5121 % can restore it in \pagesofar, after \hsize itself has (potentially)
cannam@167 5122 % been clobbered.
cannam@167 5123 %
cannam@167 5124 \doublecolumnhsize = \hsize
cannam@167 5125 \advance\doublecolumnhsize by -.04154\hsize
cannam@167 5126 \divide\doublecolumnhsize by 2
cannam@167 5127 \hsize = \doublecolumnhsize
cannam@167 5128 %
cannam@167 5129 % Double the \vsize as well. (We don't need a separate register here,
cannam@167 5130 % since nobody clobbers \vsize.)
cannam@167 5131 \vsize = 2\vsize
cannam@167 5132 }
cannam@167 5133
cannam@167 5134 % The double-column output routine for all double-column pages except
cannam@167 5135 % the last.
cannam@167 5136 %
cannam@167 5137 \def\doublecolumnout{%
cannam@167 5138 \splittopskip=\topskip \splitmaxdepth=\maxdepth
cannam@167 5139 % Get the available space for the double columns -- the normal
cannam@167 5140 % (undoubled) page height minus any material left over from the
cannam@167 5141 % previous page.
cannam@167 5142 \dimen@ = \vsize
cannam@167 5143 \divide\dimen@ by 2
cannam@167 5144 \advance\dimen@ by -\ht\partialpage
cannam@167 5145 %
cannam@167 5146 % box0 will be the left-hand column, box2 the right.
cannam@167 5147 \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
cannam@167 5148 \onepageout\pagesofar
cannam@167 5149 \unvbox255
cannam@167 5150 \penalty\outputpenalty
cannam@167 5151 }
cannam@167 5152 %
cannam@167 5153 % Re-output the contents of the output page -- any previous material,
cannam@167 5154 % followed by the two boxes we just split, in box0 and box2.
cannam@167 5155 \def\pagesofar{%
cannam@167 5156 \unvbox\partialpage
cannam@167 5157 %
cannam@167 5158 \hsize = \doublecolumnhsize
cannam@167 5159 \wd0=\hsize \wd2=\hsize
cannam@167 5160 \hbox to\pagewidth{\box0\hfil\box2}%
cannam@167 5161 }
cannam@167 5162 %
cannam@167 5163 % All done with double columns.
cannam@167 5164 \def\enddoublecolumns{%
cannam@167 5165 % The following penalty ensures that the page builder is exercised
cannam@167 5166 % _before_ we change the output routine. This is necessary in the
cannam@167 5167 % following situation:
cannam@167 5168 %
cannam@167 5169 % The last section of the index consists only of a single entry.
cannam@167 5170 % Before this section, \pagetotal is less than \pagegoal, so no
cannam@167 5171 % break occurs before the last section starts. However, the last
cannam@167 5172 % section, consisting of \initial and the single \entry, does not
cannam@167 5173 % fit on the page and has to be broken off. Without the following
cannam@167 5174 % penalty the page builder will not be exercised until \eject
cannam@167 5175 % below, and by that time we'll already have changed the output
cannam@167 5176 % routine to the \balancecolumns version, so the next-to-last
cannam@167 5177 % double-column page will be processed with \balancecolumns, which
cannam@167 5178 % is wrong: The two columns will go to the main vertical list, with
cannam@167 5179 % the broken-off section in the recent contributions. As soon as
cannam@167 5180 % the output routine finishes, TeX starts reconsidering the page
cannam@167 5181 % break. The two columns and the broken-off section both fit on the
cannam@167 5182 % page, because the two columns now take up only half of the page
cannam@167 5183 % goal. When TeX sees \eject from below which follows the final
cannam@167 5184 % section, it invokes the new output routine that we've set after
cannam@167 5185 % \balancecolumns below; \onepageout will try to fit the two columns
cannam@167 5186 % and the final section into the vbox of \pageheight (see
cannam@167 5187 % \pagebody), causing an overfull box.
cannam@167 5188 %
cannam@167 5189 % Note that glue won't work here, because glue does not exercise the
cannam@167 5190 % page builder, unlike penalties (see The TeXbook, pp. 280-281).
cannam@167 5191 \penalty0
cannam@167 5192 %
cannam@167 5193 \output = {%
cannam@167 5194 % Split the last of the double-column material. Leave it on the
cannam@167 5195 % current page, no automatic page break.
cannam@167 5196 \balancecolumns
cannam@167 5197 %
cannam@167 5198 % If we end up splitting too much material for the current page,
cannam@167 5199 % though, there will be another page break right after this \output
cannam@167 5200 % invocation ends. Having called \balancecolumns once, we do not
cannam@167 5201 % want to call it again. Therefore, reset \output to its normal
cannam@167 5202 % definition right away. (We hope \balancecolumns will never be
cannam@167 5203 % called on to balance too much material, but if it is, this makes
cannam@167 5204 % the output somewhat more palatable.)
cannam@167 5205 \global\output = {\onepageout{\pagecontents\PAGE}}%
cannam@167 5206 }%
cannam@167 5207 \eject
cannam@167 5208 \endgroup % started in \begindoublecolumns
cannam@167 5209 %
cannam@167 5210 % \pagegoal was set to the doubled \vsize above, since we restarted
cannam@167 5211 % the current page. We're now back to normal single-column
cannam@167 5212 % typesetting, so reset \pagegoal to the normal \vsize (after the
cannam@167 5213 % \endgroup where \vsize got restored).
cannam@167 5214 \pagegoal = \vsize
cannam@167 5215 }
cannam@167 5216 %
cannam@167 5217 % Called at the end of the double column material.
cannam@167 5218 \def\balancecolumns{%
cannam@167 5219 \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
cannam@167 5220 \dimen@ = \ht0
cannam@167 5221 \advance\dimen@ by \topskip
cannam@167 5222 \advance\dimen@ by-\baselineskip
cannam@167 5223 \divide\dimen@ by 2 % target to split to
cannam@167 5224 %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}%
cannam@167 5225 \splittopskip = \topskip
cannam@167 5226 % Loop until we get a decent breakpoint.
cannam@167 5227 {%
cannam@167 5228 \vbadness = 10000
cannam@167 5229 \loop
cannam@167 5230 \global\setbox3 = \copy0
cannam@167 5231 \global\setbox1 = \vsplit3 to \dimen@
cannam@167 5232 \ifdim\ht3>\dimen@
cannam@167 5233 \global\advance\dimen@ by 1pt
cannam@167 5234 \repeat
cannam@167 5235 }%
cannam@167 5236 %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
cannam@167 5237 \setbox0=\vbox to\dimen@{\unvbox1}%
cannam@167 5238 \setbox2=\vbox to\dimen@{\unvbox3}%
cannam@167 5239 %
cannam@167 5240 \pagesofar
cannam@167 5241 }
cannam@167 5242 \catcode`\@ = \other
cannam@167 5243
cannam@167 5244
cannam@167 5245 \message{sectioning,}
cannam@167 5246 % Chapters, sections, etc.
cannam@167 5247
cannam@167 5248 % Let's start with @part.
cannam@167 5249 \outer\parseargdef\part{\partzzz{#1}}
cannam@167 5250 \def\partzzz#1{%
cannam@167 5251 \chapoddpage
cannam@167 5252 \null
cannam@167 5253 \vskip.3\vsize % move it down on the page a bit
cannam@167 5254 \begingroup
cannam@167 5255 \noindent \titlefonts\rmisbold #1\par % the text
cannam@167 5256 \let\lastnode=\empty % no node to associate with
cannam@167 5257 \writetocentry{part}{#1}{}% but put it in the toc
cannam@167 5258 \headingsoff % no headline or footline on the part page
cannam@167 5259 \chapoddpage
cannam@167 5260 \endgroup
cannam@167 5261 }
cannam@167 5262
cannam@167 5263 % \unnumberedno is an oxymoron. But we count the unnumbered
cannam@167 5264 % sections so that we can refer to them unambiguously in the pdf
cannam@167 5265 % outlines by their "section number". We avoid collisions with chapter
cannam@167 5266 % numbers by starting them at 10000. (If a document ever has 10000
cannam@167 5267 % chapters, we're in trouble anyway, I'm sure.)
cannam@167 5268 \newcount\unnumberedno \unnumberedno = 10000
cannam@167 5269 \newcount\chapno
cannam@167 5270 \newcount\secno \secno=0
cannam@167 5271 \newcount\subsecno \subsecno=0
cannam@167 5272 \newcount\subsubsecno \subsubsecno=0
cannam@167 5273
cannam@167 5274 % This counter is funny since it counts through charcodes of letters A, B, ...
cannam@167 5275 \newcount\appendixno \appendixno = `\@
cannam@167 5276 %
cannam@167 5277 % \def\appendixletter{\char\the\appendixno}
cannam@167 5278 % We do the following ugly conditional instead of the above simple
cannam@167 5279 % construct for the sake of pdftex, which needs the actual
cannam@167 5280 % letter in the expansion, not just typeset.
cannam@167 5281 %
cannam@167 5282 \def\appendixletter{%
cannam@167 5283 \ifnum\appendixno=`A A%
cannam@167 5284 \else\ifnum\appendixno=`B B%
cannam@167 5285 \else\ifnum\appendixno=`C C%
cannam@167 5286 \else\ifnum\appendixno=`D D%
cannam@167 5287 \else\ifnum\appendixno=`E E%
cannam@167 5288 \else\ifnum\appendixno=`F F%
cannam@167 5289 \else\ifnum\appendixno=`G G%
cannam@167 5290 \else\ifnum\appendixno=`H H%
cannam@167 5291 \else\ifnum\appendixno=`I I%
cannam@167 5292 \else\ifnum\appendixno=`J J%
cannam@167 5293 \else\ifnum\appendixno=`K K%
cannam@167 5294 \else\ifnum\appendixno=`L L%
cannam@167 5295 \else\ifnum\appendixno=`M M%
cannam@167 5296 \else\ifnum\appendixno=`N N%
cannam@167 5297 \else\ifnum\appendixno=`O O%
cannam@167 5298 \else\ifnum\appendixno=`P P%
cannam@167 5299 \else\ifnum\appendixno=`Q Q%
cannam@167 5300 \else\ifnum\appendixno=`R R%
cannam@167 5301 \else\ifnum\appendixno=`S S%
cannam@167 5302 \else\ifnum\appendixno=`T T%
cannam@167 5303 \else\ifnum\appendixno=`U U%
cannam@167 5304 \else\ifnum\appendixno=`V V%
cannam@167 5305 \else\ifnum\appendixno=`W W%
cannam@167 5306 \else\ifnum\appendixno=`X X%
cannam@167 5307 \else\ifnum\appendixno=`Y Y%
cannam@167 5308 \else\ifnum\appendixno=`Z Z%
cannam@167 5309 % The \the is necessary, despite appearances, because \appendixletter is
cannam@167 5310 % expanded while writing the .toc file. \char\appendixno is not
cannam@167 5311 % expandable, thus it is written literally, thus all appendixes come out
cannam@167 5312 % with the same letter (or @) in the toc without it.
cannam@167 5313 \else\char\the\appendixno
cannam@167 5314 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
cannam@167 5315 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
cannam@167 5316
cannam@167 5317 % Each @chapter defines these (using marks) as the number+name, number
cannam@167 5318 % and name of the chapter. Page headings and footings can use
cannam@167 5319 % these. @section does likewise.
cannam@167 5320 \def\thischapter{}
cannam@167 5321 \def\thischapternum{}
cannam@167 5322 \def\thischaptername{}
cannam@167 5323 \def\thissection{}
cannam@167 5324 \def\thissectionnum{}
cannam@167 5325 \def\thissectionname{}
cannam@167 5326
cannam@167 5327 \newcount\absseclevel % used to calculate proper heading level
cannam@167 5328 \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
cannam@167 5329
cannam@167 5330 % @raisesections: treat @section as chapter, @subsection as section, etc.
cannam@167 5331 \def\raisesections{\global\advance\secbase by -1}
cannam@167 5332 \let\up=\raisesections % original BFox name
cannam@167 5333
cannam@167 5334 % @lowersections: treat @chapter as section, @section as subsection, etc.
cannam@167 5335 \def\lowersections{\global\advance\secbase by 1}
cannam@167 5336 \let\down=\lowersections % original BFox name
cannam@167 5337
cannam@167 5338 % we only have subsub.
cannam@167 5339 \chardef\maxseclevel = 3
cannam@167 5340 %
cannam@167 5341 % A numbered section within an unnumbered changes to unnumbered too.
cannam@167 5342 % To achieve this, remember the "biggest" unnum. sec. we are currently in:
cannam@167 5343 \chardef\unnlevel = \maxseclevel
cannam@167 5344 %
cannam@167 5345 % Trace whether the current chapter is an appendix or not:
cannam@167 5346 % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
cannam@167 5347 \def\chapheadtype{N}
cannam@167 5348
cannam@167 5349 % Choose a heading macro
cannam@167 5350 % #1 is heading type
cannam@167 5351 % #2 is heading level
cannam@167 5352 % #3 is text for heading
cannam@167 5353 \def\genhead#1#2#3{%
cannam@167 5354 % Compute the abs. sec. level:
cannam@167 5355 \absseclevel=#2
cannam@167 5356 \advance\absseclevel by \secbase
cannam@167 5357 % Make sure \absseclevel doesn't fall outside the range:
cannam@167 5358 \ifnum \absseclevel < 0
cannam@167 5359 \absseclevel = 0
cannam@167 5360 \else
cannam@167 5361 \ifnum \absseclevel > 3
cannam@167 5362 \absseclevel = 3
cannam@167 5363 \fi
cannam@167 5364 \fi
cannam@167 5365 % The heading type:
cannam@167 5366 \def\headtype{#1}%
cannam@167 5367 \if \headtype U%
cannam@167 5368 \ifnum \absseclevel < \unnlevel
cannam@167 5369 \chardef\unnlevel = \absseclevel
cannam@167 5370 \fi
cannam@167 5371 \else
cannam@167 5372 % Check for appendix sections:
cannam@167 5373 \ifnum \absseclevel = 0
cannam@167 5374 \edef\chapheadtype{\headtype}%
cannam@167 5375 \else
cannam@167 5376 \if \headtype A\if \chapheadtype N%
cannam@167 5377 \errmessage{@appendix... within a non-appendix chapter}%
cannam@167 5378 \fi\fi
cannam@167 5379 \fi
cannam@167 5380 % Check for numbered within unnumbered:
cannam@167 5381 \ifnum \absseclevel > \unnlevel
cannam@167 5382 \def\headtype{U}%
cannam@167 5383 \else
cannam@167 5384 \chardef\unnlevel = 3
cannam@167 5385 \fi
cannam@167 5386 \fi
cannam@167 5387 % Now print the heading:
cannam@167 5388 \if \headtype U%
cannam@167 5389 \ifcase\absseclevel
cannam@167 5390 \unnumberedzzz{#3}%
cannam@167 5391 \or \unnumberedseczzz{#3}%
cannam@167 5392 \or \unnumberedsubseczzz{#3}%
cannam@167 5393 \or \unnumberedsubsubseczzz{#3}%
cannam@167 5394 \fi
cannam@167 5395 \else
cannam@167 5396 \if \headtype A%
cannam@167 5397 \ifcase\absseclevel
cannam@167 5398 \appendixzzz{#3}%
cannam@167 5399 \or \appendixsectionzzz{#3}%
cannam@167 5400 \or \appendixsubseczzz{#3}%
cannam@167 5401 \or \appendixsubsubseczzz{#3}%
cannam@167 5402 \fi
cannam@167 5403 \else
cannam@167 5404 \ifcase\absseclevel
cannam@167 5405 \chapterzzz{#3}%
cannam@167 5406 \or \seczzz{#3}%
cannam@167 5407 \or \numberedsubseczzz{#3}%
cannam@167 5408 \or \numberedsubsubseczzz{#3}%
cannam@167 5409 \fi
cannam@167 5410 \fi
cannam@167 5411 \fi
cannam@167 5412 \suppressfirstparagraphindent
cannam@167 5413 }
cannam@167 5414
cannam@167 5415 % an interface:
cannam@167 5416 \def\numhead{\genhead N}
cannam@167 5417 \def\apphead{\genhead A}
cannam@167 5418 \def\unnmhead{\genhead U}
cannam@167 5419
cannam@167 5420 % @chapter, @appendix, @unnumbered. Increment top-level counter, reset
cannam@167 5421 % all lower-level sectioning counters to zero.
cannam@167 5422 %
cannam@167 5423 % Also set \chaplevelprefix, which we prepend to @float sequence numbers
cannam@167 5424 % (e.g., figures), q.v. By default (before any chapter), that is empty.
cannam@167 5425 \let\chaplevelprefix = \empty
cannam@167 5426 %
cannam@167 5427 \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
cannam@167 5428 \def\chapterzzz#1{%
cannam@167 5429 % section resetting is \global in case the chapter is in a group, such
cannam@167 5430 % as an @include file.
cannam@167 5431 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
cannam@167 5432 \global\advance\chapno by 1
cannam@167 5433 %
cannam@167 5434 % Used for \float.
cannam@167 5435 \gdef\chaplevelprefix{\the\chapno.}%
cannam@167 5436 \resetallfloatnos
cannam@167 5437 %
cannam@167 5438 % \putwordChapter can contain complex things in translations.
cannam@167 5439 \toks0=\expandafter{\putwordChapter}%
cannam@167 5440 \message{\the\toks0 \space \the\chapno}%
cannam@167 5441 %
cannam@167 5442 % Write the actual heading.
cannam@167 5443 \chapmacro{#1}{Ynumbered}{\the\chapno}%
cannam@167 5444 %
cannam@167 5445 % So @section and the like are numbered underneath this chapter.
cannam@167 5446 \global\let\section = \numberedsec
cannam@167 5447 \global\let\subsection = \numberedsubsec
cannam@167 5448 \global\let\subsubsection = \numberedsubsubsec
cannam@167 5449 }
cannam@167 5450
cannam@167 5451 \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
cannam@167 5452 %
cannam@167 5453 \def\appendixzzz#1{%
cannam@167 5454 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
cannam@167 5455 \global\advance\appendixno by 1
cannam@167 5456 \gdef\chaplevelprefix{\appendixletter.}%
cannam@167 5457 \resetallfloatnos
cannam@167 5458 %
cannam@167 5459 % \putwordAppendix can contain complex things in translations.
cannam@167 5460 \toks0=\expandafter{\putwordAppendix}%
cannam@167 5461 \message{\the\toks0 \space \appendixletter}%
cannam@167 5462 %
cannam@167 5463 \chapmacro{#1}{Yappendix}{\appendixletter}%
cannam@167 5464 %
cannam@167 5465 \global\let\section = \appendixsec
cannam@167 5466 \global\let\subsection = \appendixsubsec
cannam@167 5467 \global\let\subsubsection = \appendixsubsubsec
cannam@167 5468 }
cannam@167 5469
cannam@167 5470 % normally unnmhead0 calls unnumberedzzz:
cannam@167 5471 \outer\parseargdef\unnumbered{\unnmhead0{#1}}
cannam@167 5472 \def\unnumberedzzz#1{%
cannam@167 5473 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
cannam@167 5474 \global\advance\unnumberedno by 1
cannam@167 5475 %
cannam@167 5476 % Since an unnumbered has no number, no prefix for figures.
cannam@167 5477 \global\let\chaplevelprefix = \empty
cannam@167 5478 \resetallfloatnos
cannam@167 5479 %
cannam@167 5480 % This used to be simply \message{#1}, but TeX fully expands the
cannam@167 5481 % argument to \message. Therefore, if #1 contained @-commands, TeX
cannam@167 5482 % expanded them. For example, in `@unnumbered The @cite{Book}', TeX
cannam@167 5483 % expanded @cite (which turns out to cause errors because \cite is meant
cannam@167 5484 % to be executed, not expanded).
cannam@167 5485 %
cannam@167 5486 % Anyway, we don't want the fully-expanded definition of @cite to appear
cannam@167 5487 % as a result of the \message, we just want `@cite' itself. We use
cannam@167 5488 % \the<toks register> to achieve this: TeX expands \the<toks> only once,
cannam@167 5489 % simply yielding the contents of <toks register>. (We also do this for
cannam@167 5490 % the toc entries.)
cannam@167 5491 \toks0 = {#1}%
cannam@167 5492 \message{(\the\toks0)}%
cannam@167 5493 %
cannam@167 5494 \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
cannam@167 5495 %
cannam@167 5496 \global\let\section = \unnumberedsec
cannam@167 5497 \global\let\subsection = \unnumberedsubsec
cannam@167 5498 \global\let\subsubsection = \unnumberedsubsubsec
cannam@167 5499 }
cannam@167 5500
cannam@167 5501 % @centerchap is like @unnumbered, but the heading is centered.
cannam@167 5502 \outer\parseargdef\centerchap{%
cannam@167 5503 % Well, we could do the following in a group, but that would break
cannam@167 5504 % an assumption that \chapmacro is called at the outermost level.
cannam@167 5505 % Thus we are safer this way: --kasal, 24feb04
cannam@167 5506 \let\centerparametersmaybe = \centerparameters
cannam@167 5507 \unnmhead0{#1}%
cannam@167 5508 \let\centerparametersmaybe = \relax
cannam@167 5509 }
cannam@167 5510
cannam@167 5511 % @top is like @unnumbered.
cannam@167 5512 \let\top\unnumbered
cannam@167 5513
cannam@167 5514 % Sections.
cannam@167 5515 %
cannam@167 5516 \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
cannam@167 5517 \def\seczzz#1{%
cannam@167 5518 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
cannam@167 5519 \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
cannam@167 5520 }
cannam@167 5521
cannam@167 5522 % normally calls appendixsectionzzz:
cannam@167 5523 \outer\parseargdef\appendixsection{\apphead1{#1}}
cannam@167 5524 \def\appendixsectionzzz#1{%
cannam@167 5525 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
cannam@167 5526 \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
cannam@167 5527 }
cannam@167 5528 \let\appendixsec\appendixsection
cannam@167 5529
cannam@167 5530 % normally calls unnumberedseczzz:
cannam@167 5531 \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
cannam@167 5532 \def\unnumberedseczzz#1{%
cannam@167 5533 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
cannam@167 5534 \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
cannam@167 5535 }
cannam@167 5536
cannam@167 5537 % Subsections.
cannam@167 5538 %
cannam@167 5539 % normally calls numberedsubseczzz:
cannam@167 5540 \outer\parseargdef\numberedsubsec{\numhead2{#1}}
cannam@167 5541 \def\numberedsubseczzz#1{%
cannam@167 5542 \global\subsubsecno=0 \global\advance\subsecno by 1
cannam@167 5543 \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
cannam@167 5544 }
cannam@167 5545
cannam@167 5546 % normally calls appendixsubseczzz:
cannam@167 5547 \outer\parseargdef\appendixsubsec{\apphead2{#1}}
cannam@167 5548 \def\appendixsubseczzz#1{%
cannam@167 5549 \global\subsubsecno=0 \global\advance\subsecno by 1
cannam@167 5550 \sectionheading{#1}{subsec}{Yappendix}%
cannam@167 5551 {\appendixletter.\the\secno.\the\subsecno}%
cannam@167 5552 }
cannam@167 5553
cannam@167 5554 % normally calls unnumberedsubseczzz:
cannam@167 5555 \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
cannam@167 5556 \def\unnumberedsubseczzz#1{%
cannam@167 5557 \global\subsubsecno=0 \global\advance\subsecno by 1
cannam@167 5558 \sectionheading{#1}{subsec}{Ynothing}%
cannam@167 5559 {\the\unnumberedno.\the\secno.\the\subsecno}%
cannam@167 5560 }
cannam@167 5561
cannam@167 5562 % Subsubsections.
cannam@167 5563 %
cannam@167 5564 % normally numberedsubsubseczzz:
cannam@167 5565 \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
cannam@167 5566 \def\numberedsubsubseczzz#1{%
cannam@167 5567 \global\advance\subsubsecno by 1
cannam@167 5568 \sectionheading{#1}{subsubsec}{Ynumbered}%
cannam@167 5569 {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
cannam@167 5570 }
cannam@167 5571
cannam@167 5572 % normally appendixsubsubseczzz:
cannam@167 5573 \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
cannam@167 5574 \def\appendixsubsubseczzz#1{%
cannam@167 5575 \global\advance\subsubsecno by 1
cannam@167 5576 \sectionheading{#1}{subsubsec}{Yappendix}%
cannam@167 5577 {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
cannam@167 5578 }
cannam@167 5579
cannam@167 5580 % normally unnumberedsubsubseczzz:
cannam@167 5581 \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
cannam@167 5582 \def\unnumberedsubsubseczzz#1{%
cannam@167 5583 \global\advance\subsubsecno by 1
cannam@167 5584 \sectionheading{#1}{subsubsec}{Ynothing}%
cannam@167 5585 {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
cannam@167 5586 }
cannam@167 5587
cannam@167 5588 % These macros control what the section commands do, according
cannam@167 5589 % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
cannam@167 5590 % Define them by default for a numbered chapter.
cannam@167 5591 \let\section = \numberedsec
cannam@167 5592 \let\subsection = \numberedsubsec
cannam@167 5593 \let\subsubsection = \numberedsubsubsec
cannam@167 5594
cannam@167 5595 % Define @majorheading, @heading and @subheading
cannam@167 5596
cannam@167 5597 \def\majorheading{%
cannam@167 5598 {\advance\chapheadingskip by 10pt \chapbreak }%
cannam@167 5599 \parsearg\chapheadingzzz
cannam@167 5600 }
cannam@167 5601
cannam@167 5602 \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
cannam@167 5603 \def\chapheadingzzz#1{%
cannam@167 5604 \vbox{\chapfonts \raggedtitlesettings #1\par}%
cannam@167 5605 \nobreak\bigskip \nobreak
cannam@167 5606 \suppressfirstparagraphindent
cannam@167 5607 }
cannam@167 5608
cannam@167 5609 % @heading, @subheading, @subsubheading.
cannam@167 5610 \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
cannam@167 5611 \suppressfirstparagraphindent}
cannam@167 5612 \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
cannam@167 5613 \suppressfirstparagraphindent}
cannam@167 5614 \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
cannam@167 5615 \suppressfirstparagraphindent}
cannam@167 5616
cannam@167 5617 % These macros generate a chapter, section, etc. heading only
cannam@167 5618 % (including whitespace, linebreaking, etc. around it),
cannam@167 5619 % given all the information in convenient, parsed form.
cannam@167 5620
cannam@167 5621 % Args are the skip and penalty (usually negative)
cannam@167 5622 \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
cannam@167 5623
cannam@167 5624 % Parameter controlling skip before chapter headings (if needed)
cannam@167 5625 \newskip\chapheadingskip
cannam@167 5626
cannam@167 5627 % Define plain chapter starts, and page on/off switching for it.
cannam@167 5628 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
cannam@167 5629 \def\chappager{\par\vfill\supereject}
cannam@167 5630 % Because \domark is called before \chapoddpage, the filler page will
cannam@167 5631 % get the headings for the next chapter, which is wrong. But we don't
cannam@167 5632 % care -- we just disable all headings on the filler page.
cannam@167 5633 \def\chapoddpage{%
cannam@167 5634 \chappager
cannam@167 5635 \ifodd\pageno \else
cannam@167 5636 \begingroup
cannam@167 5637 \headingsoff
cannam@167 5638 \null
cannam@167 5639 \chappager
cannam@167 5640 \endgroup
cannam@167 5641 \fi
cannam@167 5642 }
cannam@167 5643
cannam@167 5644 \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
cannam@167 5645
cannam@167 5646 \def\CHAPPAGoff{%
cannam@167 5647 \global\let\contentsalignmacro = \chappager
cannam@167 5648 \global\let\pchapsepmacro=\chapbreak
cannam@167 5649 \global\let\pagealignmacro=\chappager}
cannam@167 5650
cannam@167 5651 \def\CHAPPAGon{%
cannam@167 5652 \global\let\contentsalignmacro = \chappager
cannam@167 5653 \global\let\pchapsepmacro=\chappager
cannam@167 5654 \global\let\pagealignmacro=\chappager
cannam@167 5655 \global\def\HEADINGSon{\HEADINGSsingle}}
cannam@167 5656
cannam@167 5657 \def\CHAPPAGodd{%
cannam@167 5658 \global\let\contentsalignmacro = \chapoddpage
cannam@167 5659 \global\let\pchapsepmacro=\chapoddpage
cannam@167 5660 \global\let\pagealignmacro=\chapoddpage
cannam@167 5661 \global\def\HEADINGSon{\HEADINGSdouble}}
cannam@167 5662
cannam@167 5663 \CHAPPAGon
cannam@167 5664
cannam@167 5665 % Chapter opening.
cannam@167 5666 %
cannam@167 5667 % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
cannam@167 5668 % Yappendix, Yomitfromtoc), #3 the chapter number.
cannam@167 5669 %
cannam@167 5670 % To test against our argument.
cannam@167 5671 \def\Ynothingkeyword{Ynothing}
cannam@167 5672 \def\Yomitfromtockeyword{Yomitfromtoc}
cannam@167 5673 \def\Yappendixkeyword{Yappendix}
cannam@167 5674 %
cannam@167 5675 \def\chapmacro#1#2#3{%
cannam@167 5676 % Insert the first mark before the heading break (see notes for \domark).
cannam@167 5677 \let\prevchapterdefs=\lastchapterdefs
cannam@167 5678 \let\prevsectiondefs=\lastsectiondefs
cannam@167 5679 \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
cannam@167 5680 \gdef\thissection{}}%
cannam@167 5681 %
cannam@167 5682 \def\temptype{#2}%
cannam@167 5683 \ifx\temptype\Ynothingkeyword
cannam@167 5684 \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
cannam@167 5685 \gdef\thischapter{\thischaptername}}%
cannam@167 5686 \else\ifx\temptype\Yomitfromtockeyword
cannam@167 5687 \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
cannam@167 5688 \gdef\thischapter{}}%
cannam@167 5689 \else\ifx\temptype\Yappendixkeyword
cannam@167 5690 \toks0={#1}%
cannam@167 5691 \xdef\lastchapterdefs{%
cannam@167 5692 \gdef\noexpand\thischaptername{\the\toks0}%
cannam@167 5693 \gdef\noexpand\thischapternum{\appendixletter}%
cannam@167 5694 % \noexpand\putwordAppendix avoids expanding indigestible
cannam@167 5695 % commands in some of the translations.
cannam@167 5696 \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
cannam@167 5697 \noexpand\thischapternum:
cannam@167 5698 \noexpand\thischaptername}%
cannam@167 5699 }%
cannam@167 5700 \else
cannam@167 5701 \toks0={#1}%
cannam@167 5702 \xdef\lastchapterdefs{%
cannam@167 5703 \gdef\noexpand\thischaptername{\the\toks0}%
cannam@167 5704 \gdef\noexpand\thischapternum{\the\chapno}%
cannam@167 5705 % \noexpand\putwordChapter avoids expanding indigestible
cannam@167 5706 % commands in some of the translations.
cannam@167 5707 \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
cannam@167 5708 \noexpand\thischapternum:
cannam@167 5709 \noexpand\thischaptername}%
cannam@167 5710 }%
cannam@167 5711 \fi\fi\fi
cannam@167 5712 %
cannam@167 5713 % Output the mark. Pass it through \safewhatsit, to take care of
cannam@167 5714 % the preceding space.
cannam@167 5715 \safewhatsit\domark
cannam@167 5716 %
cannam@167 5717 % Insert the chapter heading break.
cannam@167 5718 \pchapsepmacro
cannam@167 5719 %
cannam@167 5720 % Now the second mark, after the heading break. No break points
cannam@167 5721 % between here and the heading.
cannam@167 5722 \let\prevchapterdefs=\lastchapterdefs
cannam@167 5723 \let\prevsectiondefs=\lastsectiondefs
cannam@167 5724 \domark
cannam@167 5725 %
cannam@167 5726 {%
cannam@167 5727 \chapfonts \rmisbold
cannam@167 5728 %
cannam@167 5729 % Have to define \lastsection before calling \donoderef, because the
cannam@167 5730 % xref code eventually uses it. On the other hand, it has to be called
cannam@167 5731 % after \pchapsepmacro, or the headline will change too soon.
cannam@167 5732 \gdef\lastsection{#1}%
cannam@167 5733 %
cannam@167 5734 % Only insert the separating space if we have a chapter/appendix
cannam@167 5735 % number, and don't print the unnumbered ``number''.
cannam@167 5736 \ifx\temptype\Ynothingkeyword
cannam@167 5737 \setbox0 = \hbox{}%
cannam@167 5738 \def\toctype{unnchap}%
cannam@167 5739 \else\ifx\temptype\Yomitfromtockeyword
cannam@167 5740 \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
cannam@167 5741 \def\toctype{omit}%
cannam@167 5742 \else\ifx\temptype\Yappendixkeyword
cannam@167 5743 \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
cannam@167 5744 \def\toctype{app}%
cannam@167 5745 \else
cannam@167 5746 \setbox0 = \hbox{#3\enspace}%
cannam@167 5747 \def\toctype{numchap}%
cannam@167 5748 \fi\fi\fi
cannam@167 5749 %
cannam@167 5750 % Write the toc entry for this chapter. Must come before the
cannam@167 5751 % \donoderef, because we include the current node name in the toc
cannam@167 5752 % entry, and \donoderef resets it to empty.
cannam@167 5753 \writetocentry{\toctype}{#1}{#3}%
cannam@167 5754 %
cannam@167 5755 % For pdftex, we have to write out the node definition (aka, make
cannam@167 5756 % the pdfdest) after any page break, but before the actual text has
cannam@167 5757 % been typeset. If the destination for the pdf outline is after the
cannam@167 5758 % text, then jumping from the outline may wind up with the text not
cannam@167 5759 % being visible, for instance under high magnification.
cannam@167 5760 \donoderef{#2}%
cannam@167 5761 %
cannam@167 5762 % Typeset the actual heading.
cannam@167 5763 \nobreak % Avoid page breaks at the interline glue.
cannam@167 5764 \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
cannam@167 5765 \unhbox0 #1\par}%
cannam@167 5766 }%
cannam@167 5767 \nobreak\bigskip % no page break after a chapter title
cannam@167 5768 \nobreak
cannam@167 5769 }
cannam@167 5770
cannam@167 5771 % @centerchap -- centered and unnumbered.
cannam@167 5772 \let\centerparametersmaybe = \relax
cannam@167 5773 \def\centerparameters{%
cannam@167 5774 \advance\rightskip by 3\rightskip
cannam@167 5775 \leftskip = \rightskip
cannam@167 5776 \parfillskip = 0pt
cannam@167 5777 }
cannam@167 5778
cannam@167 5779
cannam@167 5780 % I don't think this chapter style is supported any more, so I'm not
cannam@167 5781 % updating it with the new noderef stuff. We'll see. --karl, 11aug03.
cannam@167 5782 %
cannam@167 5783 \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
cannam@167 5784 %
cannam@167 5785 \def\unnchfopen #1{%
cannam@167 5786 \chapoddpage
cannam@167 5787 \vbox{\chapfonts \raggedtitlesettings #1\par}%
cannam@167 5788 \nobreak\bigskip\nobreak
cannam@167 5789 }
cannam@167 5790 \def\chfopen #1#2{\chapoddpage {\chapfonts
cannam@167 5791 \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
cannam@167 5792 \par\penalty 5000 %
cannam@167 5793 }
cannam@167 5794 \def\centerchfopen #1{%
cannam@167 5795 \chapoddpage
cannam@167 5796 \vbox{\chapfonts \raggedtitlesettings \hfill #1\hfill}%
cannam@167 5797 \nobreak\bigskip \nobreak
cannam@167 5798 }
cannam@167 5799 \def\CHAPFopen{%
cannam@167 5800 \global\let\chapmacro=\chfopen
cannam@167 5801 \global\let\centerchapmacro=\centerchfopen}
cannam@167 5802
cannam@167 5803
cannam@167 5804 % Section titles. These macros combine the section number parts and
cannam@167 5805 % call the generic \sectionheading to do the printing.
cannam@167 5806 %
cannam@167 5807 \newskip\secheadingskip
cannam@167 5808 \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
cannam@167 5809
cannam@167 5810 % Subsection titles.
cannam@167 5811 \newskip\subsecheadingskip
cannam@167 5812 \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
cannam@167 5813
cannam@167 5814 % Subsubsection titles.
cannam@167 5815 \def\subsubsecheadingskip{\subsecheadingskip}
cannam@167 5816 \def\subsubsecheadingbreak{\subsecheadingbreak}
cannam@167 5817
cannam@167 5818
cannam@167 5819 % Print any size, any type, section title.
cannam@167 5820 %
cannam@167 5821 % #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is
cannam@167 5822 % the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
cannam@167 5823 % section number.
cannam@167 5824 %
cannam@167 5825 \def\seckeyword{sec}
cannam@167 5826 %
cannam@167 5827 \def\sectionheading#1#2#3#4{%
cannam@167 5828 {%
cannam@167 5829 \checkenv{}% should not be in an environment.
cannam@167 5830 %
cannam@167 5831 % Switch to the right set of fonts.
cannam@167 5832 \csname #2fonts\endcsname \rmisbold
cannam@167 5833 %
cannam@167 5834 \def\sectionlevel{#2}%
cannam@167 5835 \def\temptype{#3}%
cannam@167 5836 %
cannam@167 5837 % Insert first mark before the heading break (see notes for \domark).
cannam@167 5838 \let\prevsectiondefs=\lastsectiondefs
cannam@167 5839 \ifx\temptype\Ynothingkeyword
cannam@167 5840 \ifx\sectionlevel\seckeyword
cannam@167 5841 \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
cannam@167 5842 \gdef\thissection{\thissectionname}}%
cannam@167 5843 \fi
cannam@167 5844 \else\ifx\temptype\Yomitfromtockeyword
cannam@167 5845 % Don't redefine \thissection.
cannam@167 5846 \else\ifx\temptype\Yappendixkeyword
cannam@167 5847 \ifx\sectionlevel\seckeyword
cannam@167 5848 \toks0={#1}%
cannam@167 5849 \xdef\lastsectiondefs{%
cannam@167 5850 \gdef\noexpand\thissectionname{\the\toks0}%
cannam@167 5851 \gdef\noexpand\thissectionnum{#4}%
cannam@167 5852 % \noexpand\putwordSection avoids expanding indigestible
cannam@167 5853 % commands in some of the translations.
cannam@167 5854 \gdef\noexpand\thissection{\noexpand\putwordSection{}
cannam@167 5855 \noexpand\thissectionnum:
cannam@167 5856 \noexpand\thissectionname}%
cannam@167 5857 }%
cannam@167 5858 \fi
cannam@167 5859 \else
cannam@167 5860 \ifx\sectionlevel\seckeyword
cannam@167 5861 \toks0={#1}%
cannam@167 5862 \xdef\lastsectiondefs{%
cannam@167 5863 \gdef\noexpand\thissectionname{\the\toks0}%
cannam@167 5864 \gdef\noexpand\thissectionnum{#4}%
cannam@167 5865 % \noexpand\putwordSection avoids expanding indigestible
cannam@167 5866 % commands in some of the translations.
cannam@167 5867 \gdef\noexpand\thissection{\noexpand\putwordSection{}
cannam@167 5868 \noexpand\thissectionnum:
cannam@167 5869 \noexpand\thissectionname}%
cannam@167 5870 }%
cannam@167 5871 \fi
cannam@167 5872 \fi\fi\fi
cannam@167 5873 %
cannam@167 5874 % Go into vertical mode. Usually we'll already be there, but we
cannam@167 5875 % don't want the following whatsit to end up in a preceding paragraph
cannam@167 5876 % if the document didn't happen to have a blank line.
cannam@167 5877 \par
cannam@167 5878 %
cannam@167 5879 % Output the mark. Pass it through \safewhatsit, to take care of
cannam@167 5880 % the preceding space.
cannam@167 5881 \safewhatsit\domark
cannam@167 5882 %
cannam@167 5883 % Insert space above the heading.
cannam@167 5884 \csname #2headingbreak\endcsname
cannam@167 5885 %
cannam@167 5886 % Now the second mark, after the heading break. No break points
cannam@167 5887 % between here and the heading.
cannam@167 5888 \let\prevsectiondefs=\lastsectiondefs
cannam@167 5889 \domark
cannam@167 5890 %
cannam@167 5891 % Only insert the space after the number if we have a section number.
cannam@167 5892 \ifx\temptype\Ynothingkeyword
cannam@167 5893 \setbox0 = \hbox{}%
cannam@167 5894 \def\toctype{unn}%
cannam@167 5895 \gdef\lastsection{#1}%
cannam@167 5896 \else\ifx\temptype\Yomitfromtockeyword
cannam@167 5897 % for @headings -- no section number, don't include in toc,
cannam@167 5898 % and don't redefine \lastsection.
cannam@167 5899 \setbox0 = \hbox{}%
cannam@167 5900 \def\toctype{omit}%
cannam@167 5901 \let\sectionlevel=\empty
cannam@167 5902 \else\ifx\temptype\Yappendixkeyword
cannam@167 5903 \setbox0 = \hbox{#4\enspace}%
cannam@167 5904 \def\toctype{app}%
cannam@167 5905 \gdef\lastsection{#1}%
cannam@167 5906 \else
cannam@167 5907 \setbox0 = \hbox{#4\enspace}%
cannam@167 5908 \def\toctype{num}%
cannam@167 5909 \gdef\lastsection{#1}%
cannam@167 5910 \fi\fi\fi
cannam@167 5911 %
cannam@167 5912 % Write the toc entry (before \donoderef). See comments in \chapmacro.
cannam@167 5913 \writetocentry{\toctype\sectionlevel}{#1}{#4}%
cannam@167 5914 %
cannam@167 5915 % Write the node reference (= pdf destination for pdftex).
cannam@167 5916 % Again, see comments in \chapmacro.
cannam@167 5917 \donoderef{#3}%
cannam@167 5918 %
cannam@167 5919 % Interline glue will be inserted when the vbox is completed.
cannam@167 5920 % That glue will be a valid breakpoint for the page, since it'll be
cannam@167 5921 % preceded by a whatsit (usually from the \donoderef, or from the
cannam@167 5922 % \writetocentry if there was no node). We don't want to allow that
cannam@167 5923 % break, since then the whatsits could end up on page n while the
cannam@167 5924 % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000.
cannam@167 5925 \nobreak
cannam@167 5926 %
cannam@167 5927 % Output the actual section heading.
cannam@167 5928 \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
cannam@167 5929 \hangindent=\wd0 % zero if no section number
cannam@167 5930 \unhbox0 #1}%
cannam@167 5931 }%
cannam@167 5932 % Add extra space after the heading -- half of whatever came above it.
cannam@167 5933 % Don't allow stretch, though.
cannam@167 5934 \kern .5 \csname #2headingskip\endcsname
cannam@167 5935 %
cannam@167 5936 % Do not let the kern be a potential breakpoint, as it would be if it
cannam@167 5937 % was followed by glue.
cannam@167 5938 \nobreak
cannam@167 5939 %
cannam@167 5940 % We'll almost certainly start a paragraph next, so don't let that
cannam@167 5941 % glue accumulate. (Not a breakpoint because it's preceded by a
cannam@167 5942 % discardable item.) However, when a paragraph is not started next
cannam@167 5943 % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
cannam@167 5944 % or the negative glue will cause weirdly wrong output, typically
cannam@167 5945 % obscuring the section heading with something else.
cannam@167 5946 \vskip-\parskip
cannam@167 5947 %
cannam@167 5948 % This is so the last item on the main vertical list is a known
cannam@167 5949 % \penalty > 10000, so \startdefun, etc., can recognize the situation
cannam@167 5950 % and do the needful.
cannam@167 5951 \penalty 10001
cannam@167 5952 }
cannam@167 5953
cannam@167 5954
cannam@167 5955 \message{toc,}
cannam@167 5956 % Table of contents.
cannam@167 5957 \newwrite\tocfile
cannam@167 5958
cannam@167 5959 % Write an entry to the toc file, opening it if necessary.
cannam@167 5960 % Called from @chapter, etc.
cannam@167 5961 %
cannam@167 5962 % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
cannam@167 5963 % We append the current node name (if any) and page number as additional
cannam@167 5964 % arguments for the \{chap,sec,...}entry macros which will eventually
cannam@167 5965 % read this. The node name is used in the pdf outlines as the
cannam@167 5966 % destination to jump to.
cannam@167 5967 %
cannam@167 5968 % We open the .toc file for writing here instead of at @setfilename (or
cannam@167 5969 % any other fixed time) so that @contents can be anywhere in the document.
cannam@167 5970 % But if #1 is `omit', then we don't do anything. This is used for the
cannam@167 5971 % table of contents chapter openings themselves.
cannam@167 5972 %
cannam@167 5973 \newif\iftocfileopened
cannam@167 5974 \def\omitkeyword{omit}%
cannam@167 5975 %
cannam@167 5976 \def\writetocentry#1#2#3{%
cannam@167 5977 \edef\writetoctype{#1}%
cannam@167 5978 \ifx\writetoctype\omitkeyword \else
cannam@167 5979 \iftocfileopened\else
cannam@167 5980 \immediate\openout\tocfile = \jobname.toc
cannam@167 5981 \global\tocfileopenedtrue
cannam@167 5982 \fi
cannam@167 5983 %
cannam@167 5984 \iflinks
cannam@167 5985 {\atdummies
cannam@167 5986 \edef\temp{%
cannam@167 5987 \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
cannam@167 5988 \temp
cannam@167 5989 }%
cannam@167 5990 \fi
cannam@167 5991 \fi
cannam@167 5992 %
cannam@167 5993 % Tell \shipout to create a pdf destination on each page, if we're
cannam@167 5994 % writing pdf. These are used in the table of contents. We can't
cannam@167 5995 % just write one on every page because the title pages are numbered
cannam@167 5996 % 1 and 2 (the page numbers aren't printed), and so are the first
cannam@167 5997 % two pages of the document. Thus, we'd have two destinations named
cannam@167 5998 % `1', and two named `2'.
cannam@167 5999 \ifpdf \global\pdfmakepagedesttrue \fi
cannam@167 6000 }
cannam@167 6001
cannam@167 6002
cannam@167 6003 % These characters do not print properly in the Computer Modern roman
cannam@167 6004 % fonts, so we must take special care. This is more or less redundant
cannam@167 6005 % with the Texinfo input format setup at the end of this file.
cannam@167 6006 %
cannam@167 6007 \def\activecatcodes{%
cannam@167 6008 \catcode`\"=\active
cannam@167 6009 \catcode`\$=\active
cannam@167 6010 \catcode`\<=\active
cannam@167 6011 \catcode`\>=\active
cannam@167 6012 \catcode`\\=\active
cannam@167 6013 \catcode`\^=\active
cannam@167 6014 \catcode`\_=\active
cannam@167 6015 \catcode`\|=\active
cannam@167 6016 \catcode`\~=\active
cannam@167 6017 }
cannam@167 6018
cannam@167 6019
cannam@167 6020 % Read the toc file, which is essentially Texinfo input.
cannam@167 6021 \def\readtocfile{%
cannam@167 6022 \setupdatafile
cannam@167 6023 \activecatcodes
cannam@167 6024 \input \tocreadfilename
cannam@167 6025 }
cannam@167 6026
cannam@167 6027 \newskip\contentsrightmargin \contentsrightmargin=1in
cannam@167 6028 \newcount\savepageno
cannam@167 6029 \newcount\lastnegativepageno \lastnegativepageno = -1
cannam@167 6030
cannam@167 6031 % Prepare to read what we've written to \tocfile.
cannam@167 6032 %
cannam@167 6033 \def\startcontents#1{%
cannam@167 6034 % If @setchapternewpage on, and @headings double, the contents should
cannam@167 6035 % start on an odd page, unlike chapters. Thus, we maintain
cannam@167 6036 % \contentsalignmacro in parallel with \pagealignmacro.
cannam@167 6037 % From: Torbjorn Granlund <tege@matematik.su.se>
cannam@167 6038 \contentsalignmacro
cannam@167 6039 \immediate\closeout\tocfile
cannam@167 6040 %
cannam@167 6041 % Don't need to put `Contents' or `Short Contents' in the headline.
cannam@167 6042 % It is abundantly clear what they are.
cannam@167 6043 \chapmacro{#1}{Yomitfromtoc}{}%
cannam@167 6044 %
cannam@167 6045 \savepageno = \pageno
cannam@167 6046 \begingroup % Set up to handle contents files properly.
cannam@167 6047 \raggedbottom % Worry more about breakpoints than the bottom.
cannam@167 6048 \advance\hsize by -\contentsrightmargin % Don't use the full line length.
cannam@167 6049 %
cannam@167 6050 % Roman numerals for page numbers.
cannam@167 6051 \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
cannam@167 6052 }
cannam@167 6053
cannam@167 6054 % redefined for the two-volume lispref. We always output on
cannam@167 6055 % \jobname.toc even if this is redefined.
cannam@167 6056 %
cannam@167 6057 \def\tocreadfilename{\jobname.toc}
cannam@167 6058
cannam@167 6059 % Normal (long) toc.
cannam@167 6060 %
cannam@167 6061 \def\contents{%
cannam@167 6062 \startcontents{\putwordTOC}%
cannam@167 6063 \openin 1 \tocreadfilename\space
cannam@167 6064 \ifeof 1 \else
cannam@167 6065 \readtocfile
cannam@167 6066 \fi
cannam@167 6067 \vfill \eject
cannam@167 6068 \contentsalignmacro % in case @setchapternewpage odd is in effect
cannam@167 6069 \ifeof 1 \else
cannam@167 6070 \pdfmakeoutlines
cannam@167 6071 \fi
cannam@167 6072 \closein 1
cannam@167 6073 \endgroup
cannam@167 6074 \lastnegativepageno = \pageno
cannam@167 6075 \global\pageno = \savepageno
cannam@167 6076 }
cannam@167 6077
cannam@167 6078 % And just the chapters.
cannam@167 6079 \def\summarycontents{%
cannam@167 6080 \startcontents{\putwordShortTOC}%
cannam@167 6081 %
cannam@167 6082 \let\partentry = \shortpartentry
cannam@167 6083 \let\numchapentry = \shortchapentry
cannam@167 6084 \let\appentry = \shortchapentry
cannam@167 6085 \let\unnchapentry = \shortunnchapentry
cannam@167 6086 % We want a true roman here for the page numbers.
cannam@167 6087 \secfonts
cannam@167 6088 \let\rm=\shortcontrm \let\bf=\shortcontbf
cannam@167 6089 \let\sl=\shortcontsl \let\tt=\shortconttt
cannam@167 6090 \rm
cannam@167 6091 \hyphenpenalty = 10000
cannam@167 6092 \advance\baselineskip by 1pt % Open it up a little.
cannam@167 6093 \def\numsecentry##1##2##3##4{}
cannam@167 6094 \let\appsecentry = \numsecentry
cannam@167 6095 \let\unnsecentry = \numsecentry
cannam@167 6096 \let\numsubsecentry = \numsecentry
cannam@167 6097 \let\appsubsecentry = \numsecentry
cannam@167 6098 \let\unnsubsecentry = \numsecentry
cannam@167 6099 \let\numsubsubsecentry = \numsecentry
cannam@167 6100 \let\appsubsubsecentry = \numsecentry
cannam@167 6101 \let\unnsubsubsecentry = \numsecentry
cannam@167 6102 \openin 1 \tocreadfilename\space
cannam@167 6103 \ifeof 1 \else
cannam@167 6104 \readtocfile
cannam@167 6105 \fi
cannam@167 6106 \closein 1
cannam@167 6107 \vfill \eject
cannam@167 6108 \contentsalignmacro % in case @setchapternewpage odd is in effect
cannam@167 6109 \endgroup
cannam@167 6110 \lastnegativepageno = \pageno
cannam@167 6111 \global\pageno = \savepageno
cannam@167 6112 }
cannam@167 6113 \let\shortcontents = \summarycontents
cannam@167 6114
cannam@167 6115 % Typeset the label for a chapter or appendix for the short contents.
cannam@167 6116 % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
cannam@167 6117 %
cannam@167 6118 \def\shortchaplabel#1{%
cannam@167 6119 % This space should be enough, since a single number is .5em, and the
cannam@167 6120 % widest letter (M) is 1em, at least in the Computer Modern fonts.
cannam@167 6121 % But use \hss just in case.
cannam@167 6122 % (This space doesn't include the extra space that gets added after
cannam@167 6123 % the label; that gets put in by \shortchapentry above.)
cannam@167 6124 %
cannam@167 6125 % We'd like to right-justify chapter numbers, but that looks strange
cannam@167 6126 % with appendix letters. And right-justifying numbers and
cannam@167 6127 % left-justifying letters looks strange when there is less than 10
cannam@167 6128 % chapters. Have to read the whole toc once to know how many chapters
cannam@167 6129 % there are before deciding ...
cannam@167 6130 \hbox to 1em{#1\hss}%
cannam@167 6131 }
cannam@167 6132
cannam@167 6133 % These macros generate individual entries in the table of contents.
cannam@167 6134 % The first argument is the chapter or section name.
cannam@167 6135 % The last argument is the page number.
cannam@167 6136 % The arguments in between are the chapter number, section number, ...
cannam@167 6137
cannam@167 6138 % Parts, in the main contents. Replace the part number, which doesn't
cannam@167 6139 % exist, with an empty box. Let's hope all the numbers have the same width.
cannam@167 6140 % Also ignore the page number, which is conventionally not printed.
cannam@167 6141 \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
cannam@167 6142 \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}}
cannam@167 6143 %
cannam@167 6144 % Parts, in the short toc.
cannam@167 6145 \def\shortpartentry#1#2#3#4{%
cannam@167 6146 \penalty-300
cannam@167 6147 \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
cannam@167 6148 \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
cannam@167 6149 }
cannam@167 6150
cannam@167 6151 % Chapters, in the main contents.
cannam@167 6152 \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
cannam@167 6153 %
cannam@167 6154 % Chapters, in the short toc.
cannam@167 6155 % See comments in \dochapentry re vbox and related settings.
cannam@167 6156 \def\shortchapentry#1#2#3#4{%
cannam@167 6157 \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
cannam@167 6158 }
cannam@167 6159
cannam@167 6160 % Appendices, in the main contents.
cannam@167 6161 % Need the word Appendix, and a fixed-size box.
cannam@167 6162 %
cannam@167 6163 \def\appendixbox#1{%
cannam@167 6164 % We use M since it's probably the widest letter.
cannam@167 6165 \setbox0 = \hbox{\putwordAppendix{} M}%
cannam@167 6166 \hbox to \wd0{\putwordAppendix{} #1\hss}}
cannam@167 6167 %
cannam@167 6168 \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}}
cannam@167 6169
cannam@167 6170 % Unnumbered chapters.
cannam@167 6171 \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
cannam@167 6172 \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
cannam@167 6173
cannam@167 6174 % Sections.
cannam@167 6175 \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
cannam@167 6176 \let\appsecentry=\numsecentry
cannam@167 6177 \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
cannam@167 6178
cannam@167 6179 % Subsections.
cannam@167 6180 \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
cannam@167 6181 \let\appsubsecentry=\numsubsecentry
cannam@167 6182 \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
cannam@167 6183
cannam@167 6184 % And subsubsections.
cannam@167 6185 \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
cannam@167 6186 \let\appsubsubsecentry=\numsubsubsecentry
cannam@167 6187 \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
cannam@167 6188
cannam@167 6189 % This parameter controls the indentation of the various levels.
cannam@167 6190 % Same as \defaultparindent.
cannam@167 6191 \newdimen\tocindent \tocindent = 15pt
cannam@167 6192
cannam@167 6193 % Now for the actual typesetting. In all these, #1 is the text and #2 is the
cannam@167 6194 % page number.
cannam@167 6195 %
cannam@167 6196 % If the toc has to be broken over pages, we want it to be at chapters
cannam@167 6197 % if at all possible; hence the \penalty.
cannam@167 6198 \def\dochapentry#1#2{%
cannam@167 6199 \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
cannam@167 6200 \begingroup
cannam@167 6201 \chapentryfonts
cannam@167 6202 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
cannam@167 6203 \endgroup
cannam@167 6204 \nobreak\vskip .25\baselineskip plus.1\baselineskip
cannam@167 6205 }
cannam@167 6206
cannam@167 6207 \def\dosecentry#1#2{\begingroup
cannam@167 6208 \secentryfonts \leftskip=\tocindent
cannam@167 6209 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
cannam@167 6210 \endgroup}
cannam@167 6211
cannam@167 6212 \def\dosubsecentry#1#2{\begingroup
cannam@167 6213 \subsecentryfonts \leftskip=2\tocindent
cannam@167 6214 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
cannam@167 6215 \endgroup}
cannam@167 6216
cannam@167 6217 \def\dosubsubsecentry#1#2{\begingroup
cannam@167 6218 \subsubsecentryfonts \leftskip=3\tocindent
cannam@167 6219 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
cannam@167 6220 \endgroup}
cannam@167 6221
cannam@167 6222 % We use the same \entry macro as for the index entries.
cannam@167 6223 \let\tocentry = \entry
cannam@167 6224
cannam@167 6225 % Space between chapter (or whatever) number and the title.
cannam@167 6226 \def\labelspace{\hskip1em \relax}
cannam@167 6227
cannam@167 6228 \def\dopageno#1{{\rm #1}}
cannam@167 6229 \def\doshortpageno#1{{\rm #1}}
cannam@167 6230
cannam@167 6231 \def\chapentryfonts{\secfonts \rm}
cannam@167 6232 \def\secentryfonts{\textfonts}
cannam@167 6233 \def\subsecentryfonts{\textfonts}
cannam@167 6234 \def\subsubsecentryfonts{\textfonts}
cannam@167 6235
cannam@167 6236
cannam@167 6237 \message{environments,}
cannam@167 6238 % @foo ... @end foo.
cannam@167 6239
cannam@167 6240 % @tex ... @end tex escapes into raw TeX temporarily.
cannam@167 6241 % One exception: @ is still an escape character, so that @end tex works.
cannam@167 6242 % But \@ or @@ will get a plain @ character.
cannam@167 6243
cannam@167 6244 \envdef\tex{%
cannam@167 6245 \setupmarkupstyle{tex}%
cannam@167 6246 \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
cannam@167 6247 \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
cannam@167 6248 \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
cannam@167 6249 \catcode `\%=14
cannam@167 6250 \catcode `\+=\other
cannam@167 6251 \catcode `\"=\other
cannam@167 6252 \catcode `\|=\other
cannam@167 6253 \catcode `\<=\other
cannam@167 6254 \catcode `\>=\other
cannam@167 6255 \catcode`\`=\other
cannam@167 6256 \catcode`\'=\other
cannam@167 6257 \escapechar=`\\
cannam@167 6258 %
cannam@167 6259 % ' is active in math mode (mathcode"8000). So reset it, and all our
cannam@167 6260 % other math active characters (just in case), to plain's definitions.
cannam@167 6261 \mathactive
cannam@167 6262 %
cannam@167 6263 \let\b=\ptexb
cannam@167 6264 \let\bullet=\ptexbullet
cannam@167 6265 \let\c=\ptexc
cannam@167 6266 \let\,=\ptexcomma
cannam@167 6267 \let\.=\ptexdot
cannam@167 6268 \let\dots=\ptexdots
cannam@167 6269 \let\equiv=\ptexequiv
cannam@167 6270 \let\!=\ptexexclam
cannam@167 6271 \let\i=\ptexi
cannam@167 6272 \let\indent=\ptexindent
cannam@167 6273 \let\noindent=\ptexnoindent
cannam@167 6274 \let\{=\ptexlbrace
cannam@167 6275 \let\+=\tabalign
cannam@167 6276 \let\}=\ptexrbrace
cannam@167 6277 \let\/=\ptexslash
cannam@167 6278 \let\*=\ptexstar
cannam@167 6279 \let\t=\ptext
cannam@167 6280 \expandafter \let\csname top\endcsname=\ptextop % outer
cannam@167 6281 \let\frenchspacing=\plainfrenchspacing
cannam@167 6282 %
cannam@167 6283 \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
cannam@167 6284 \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
cannam@167 6285 \def\@{@}%
cannam@167 6286 }
cannam@167 6287 % There is no need to define \Etex.
cannam@167 6288
cannam@167 6289 % Define @lisp ... @end lisp.
cannam@167 6290 % @lisp environment forms a group so it can rebind things,
cannam@167 6291 % including the definition of @end lisp (which normally is erroneous).
cannam@167 6292
cannam@167 6293 % Amount to narrow the margins by for @lisp.
cannam@167 6294 \newskip\lispnarrowing \lispnarrowing=0.4in
cannam@167 6295
cannam@167 6296 % This is the definition that ^^M gets inside @lisp, @example, and other
cannam@167 6297 % such environments. \null is better than a space, since it doesn't
cannam@167 6298 % have any width.
cannam@167 6299 \def\lisppar{\null\endgraf}
cannam@167 6300
cannam@167 6301 % This space is always present above and below environments.
cannam@167 6302 \newskip\envskipamount \envskipamount = 0pt
cannam@167 6303
cannam@167 6304 % Make spacing and below environment symmetrical. We use \parskip here
cannam@167 6305 % to help in doing that, since in @example-like environments \parskip
cannam@167 6306 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
cannam@167 6307 % start of the next paragraph will insert \parskip.
cannam@167 6308 %
cannam@167 6309 \def\aboveenvbreak{{%
cannam@167 6310 % =10000 instead of <10000 because of a special case in \itemzzz and
cannam@167 6311 % \sectionheading, q.v.
cannam@167 6312 \ifnum \lastpenalty=10000 \else
cannam@167 6313 \advance\envskipamount by \parskip
cannam@167 6314 \endgraf
cannam@167 6315 \ifdim\lastskip<\envskipamount
cannam@167 6316 \removelastskip
cannam@167 6317 % it's not a good place to break if the last penalty was \nobreak
cannam@167 6318 % or better ...
cannam@167 6319 \ifnum\lastpenalty<10000 \penalty-50 \fi
cannam@167 6320 \vskip\envskipamount
cannam@167 6321 \fi
cannam@167 6322 \fi
cannam@167 6323 }}
cannam@167 6324
cannam@167 6325 \let\afterenvbreak = \aboveenvbreak
cannam@167 6326
cannam@167 6327 % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will
cannam@167 6328 % also clear it, so that its embedded environments do the narrowing again.
cannam@167 6329 \let\nonarrowing=\relax
cannam@167 6330
cannam@167 6331 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
cannam@167 6332 % environment contents.
cannam@167 6333 \font\circle=lcircle10
cannam@167 6334 \newdimen\circthick
cannam@167 6335 \newdimen\cartouter\newdimen\cartinner
cannam@167 6336 \newskip\normbskip\newskip\normpskip\newskip\normlskip
cannam@167 6337 \circthick=\fontdimen8\circle
cannam@167 6338 %
cannam@167 6339 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
cannam@167 6340 \def\ctr{{\hskip 6pt\circle\char'010}}
cannam@167 6341 \def\cbl{{\circle\char'012\hskip -6pt}}
cannam@167 6342 \def\cbr{{\hskip 6pt\circle\char'011}}
cannam@167 6343 \def\carttop{\hbox to \cartouter{\hskip\lskip
cannam@167 6344 \ctl\leaders\hrule height\circthick\hfil\ctr
cannam@167 6345 \hskip\rskip}}
cannam@167 6346 \def\cartbot{\hbox to \cartouter{\hskip\lskip
cannam@167 6347 \cbl\leaders\hrule height\circthick\hfil\cbr
cannam@167 6348 \hskip\rskip}}
cannam@167 6349 %
cannam@167 6350 \newskip\lskip\newskip\rskip
cannam@167 6351
cannam@167 6352 \envdef\cartouche{%
cannam@167 6353 \ifhmode\par\fi % can't be in the midst of a paragraph.
cannam@167 6354 \startsavinginserts
cannam@167 6355 \lskip=\leftskip \rskip=\rightskip
cannam@167 6356 \leftskip=0pt\rightskip=0pt % we want these *outside*.
cannam@167 6357 \cartinner=\hsize \advance\cartinner by-\lskip
cannam@167 6358 \advance\cartinner by-\rskip
cannam@167 6359 \cartouter=\hsize
cannam@167 6360 \advance\cartouter by 18.4pt % allow for 3pt kerns on either
cannam@167 6361 % side, and for 6pt waste from
cannam@167 6362 % each corner char, and rule thickness
cannam@167 6363 \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
cannam@167 6364 % Flag to tell @lisp, etc., not to narrow margin.
cannam@167 6365 \let\nonarrowing = t%
cannam@167 6366 %
cannam@167 6367 % If this cartouche directly follows a sectioning command, we need the
cannam@167 6368 % \parskip glue (backspaced over by default) or the cartouche can
cannam@167 6369 % collide with the section heading.
cannam@167 6370 \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
cannam@167 6371 %
cannam@167 6372 \vbox\bgroup
cannam@167 6373 \baselineskip=0pt\parskip=0pt\lineskip=0pt
cannam@167 6374 \carttop
cannam@167 6375 \hbox\bgroup
cannam@167 6376 \hskip\lskip
cannam@167 6377 \vrule\kern3pt
cannam@167 6378 \vbox\bgroup
cannam@167 6379 \kern3pt
cannam@167 6380 \hsize=\cartinner
cannam@167 6381 \baselineskip=\normbskip
cannam@167 6382 \lineskip=\normlskip
cannam@167 6383 \parskip=\normpskip
cannam@167 6384 \vskip -\parskip
cannam@167 6385 \comment % For explanation, see the end of def\group.
cannam@167 6386 }
cannam@167 6387 \def\Ecartouche{%
cannam@167 6388 \ifhmode\par\fi
cannam@167 6389 \kern3pt
cannam@167 6390 \egroup
cannam@167 6391 \kern3pt\vrule
cannam@167 6392 \hskip\rskip
cannam@167 6393 \egroup
cannam@167 6394 \cartbot
cannam@167 6395 \egroup
cannam@167 6396 \checkinserts
cannam@167 6397 }
cannam@167 6398
cannam@167 6399
cannam@167 6400 % This macro is called at the beginning of all the @example variants,
cannam@167 6401 % inside a group.
cannam@167 6402 \newdimen\nonfillparindent
cannam@167 6403 \def\nonfillstart{%
cannam@167 6404 \aboveenvbreak
cannam@167 6405 \hfuzz = 12pt % Don't be fussy
cannam@167 6406 \sepspaces % Make spaces be word-separators rather than space tokens.
cannam@167 6407 \let\par = \lisppar % don't ignore blank lines
cannam@167 6408 \obeylines % each line of input is a line of output
cannam@167 6409 \parskip = 0pt
cannam@167 6410 % Turn off paragraph indentation but redefine \indent to emulate
cannam@167 6411 % the normal \indent.
cannam@167 6412 \nonfillparindent=\parindent
cannam@167 6413 \parindent = 0pt
cannam@167 6414 \let\indent\nonfillindent
cannam@167 6415 %
cannam@167 6416 \emergencystretch = 0pt % don't try to avoid overfull boxes
cannam@167 6417 \ifx\nonarrowing\relax
cannam@167 6418 \advance \leftskip by \lispnarrowing
cannam@167 6419 \exdentamount=\lispnarrowing
cannam@167 6420 \else
cannam@167 6421 \let\nonarrowing = \relax
cannam@167 6422 \fi
cannam@167 6423 \let\exdent=\nofillexdent
cannam@167 6424 }
cannam@167 6425
cannam@167 6426 \begingroup
cannam@167 6427 \obeyspaces
cannam@167 6428 % We want to swallow spaces (but not other tokens) after the fake
cannam@167 6429 % @indent in our nonfill-environments, where spaces are normally
cannam@167 6430 % active and set to @tie, resulting in them not being ignored after
cannam@167 6431 % @indent.
cannam@167 6432 \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
cannam@167 6433 \gdef\nonfillindentcheck{%
cannam@167 6434 \ifx\temp %
cannam@167 6435 \expandafter\nonfillindentgobble%
cannam@167 6436 \else%
cannam@167 6437 \leavevmode\nonfillindentbox%
cannam@167 6438 \fi%
cannam@167 6439 }%
cannam@167 6440 \endgroup
cannam@167 6441 \def\nonfillindentgobble#1{\nonfillindent}
cannam@167 6442 \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
cannam@167 6443
cannam@167 6444 % If you want all examples etc. small: @set dispenvsize small.
cannam@167 6445 % If you want even small examples the full size: @set dispenvsize nosmall.
cannam@167 6446 % This affects the following displayed environments:
cannam@167 6447 % @example, @display, @format, @lisp
cannam@167 6448 %
cannam@167 6449 \def\smallword{small}
cannam@167 6450 \def\nosmallword{nosmall}
cannam@167 6451 \let\SETdispenvsize\relax
cannam@167 6452 \def\setnormaldispenv{%
cannam@167 6453 \ifx\SETdispenvsize\smallword
cannam@167 6454 % end paragraph for sake of leading, in case document has no blank
cannam@167 6455 % line. This is redundant with what happens in \aboveenvbreak, but
cannam@167 6456 % we need to do it before changing the fonts, and it's inconvenient
cannam@167 6457 % to change the fonts afterward.
cannam@167 6458 \ifnum \lastpenalty=10000 \else \endgraf \fi
cannam@167 6459 \smallexamplefonts \rm
cannam@167 6460 \fi
cannam@167 6461 }
cannam@167 6462 \def\setsmalldispenv{%
cannam@167 6463 \ifx\SETdispenvsize\nosmallword
cannam@167 6464 \else
cannam@167 6465 \ifnum \lastpenalty=10000 \else \endgraf \fi
cannam@167 6466 \smallexamplefonts \rm
cannam@167 6467 \fi
cannam@167 6468 }
cannam@167 6469
cannam@167 6470 % We often define two environments, @foo and @smallfoo.
cannam@167 6471 % Let's do it in one command. #1 is the env name, #2 the definition.
cannam@167 6472 \def\makedispenvdef#1#2{%
cannam@167 6473 \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
cannam@167 6474 \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
cannam@167 6475 \expandafter\let\csname E#1\endcsname \afterenvbreak
cannam@167 6476 \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
cannam@167 6477 }
cannam@167 6478
cannam@167 6479 % Define two environment synonyms (#1 and #2) for an environment.
cannam@167 6480 \def\maketwodispenvdef#1#2#3{%
cannam@167 6481 \makedispenvdef{#1}{#3}%
cannam@167 6482 \makedispenvdef{#2}{#3}%
cannam@167 6483 }
cannam@167 6484 %
cannam@167 6485 % @lisp: indented, narrowed, typewriter font;
cannam@167 6486 % @example: same as @lisp.
cannam@167 6487 %
cannam@167 6488 % @smallexample and @smalllisp: use smaller fonts.
cannam@167 6489 % Originally contributed by Pavel@xerox.
cannam@167 6490 %
cannam@167 6491 \maketwodispenvdef{lisp}{example}{%
cannam@167 6492 \nonfillstart
cannam@167 6493 \tt\setupmarkupstyle{example}%
cannam@167 6494 \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
cannam@167 6495 \gobble % eat return
cannam@167 6496 }
cannam@167 6497 % @display/@smalldisplay: same as @lisp except keep current font.
cannam@167 6498 %
cannam@167 6499 \makedispenvdef{display}{%
cannam@167 6500 \nonfillstart
cannam@167 6501 \gobble
cannam@167 6502 }
cannam@167 6503
cannam@167 6504 % @format/@smallformat: same as @display except don't narrow margins.
cannam@167 6505 %
cannam@167 6506 \makedispenvdef{format}{%
cannam@167 6507 \let\nonarrowing = t%
cannam@167 6508 \nonfillstart
cannam@167 6509 \gobble
cannam@167 6510 }
cannam@167 6511
cannam@167 6512 % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
cannam@167 6513 \envdef\flushleft{%
cannam@167 6514 \let\nonarrowing = t%
cannam@167 6515 \nonfillstart
cannam@167 6516 \gobble
cannam@167 6517 }
cannam@167 6518 \let\Eflushleft = \afterenvbreak
cannam@167 6519
cannam@167 6520 % @flushright.
cannam@167 6521 %
cannam@167 6522 \envdef\flushright{%
cannam@167 6523 \let\nonarrowing = t%
cannam@167 6524 \nonfillstart
cannam@167 6525 \advance\leftskip by 0pt plus 1fill\relax
cannam@167 6526 \gobble
cannam@167 6527 }
cannam@167 6528 \let\Eflushright = \afterenvbreak
cannam@167 6529
cannam@167 6530
cannam@167 6531 % @raggedright does more-or-less normal line breaking but no right
cannam@167 6532 % justification. From plain.tex.
cannam@167 6533 \envdef\raggedright{%
cannam@167 6534 \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax
cannam@167 6535 }
cannam@167 6536 \let\Eraggedright\par
cannam@167 6537
cannam@167 6538 \envdef\raggedleft{%
cannam@167 6539 \parindent=0pt \leftskip0pt plus2em
cannam@167 6540 \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
cannam@167 6541 \hbadness=10000 % Last line will usually be underfull, so turn off
cannam@167 6542 % badness reporting.
cannam@167 6543 }
cannam@167 6544 \let\Eraggedleft\par
cannam@167 6545
cannam@167 6546 \envdef\raggedcenter{%
cannam@167 6547 \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
cannam@167 6548 \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
cannam@167 6549 \hbadness=10000 % Last line will usually be underfull, so turn off
cannam@167 6550 % badness reporting.
cannam@167 6551 }
cannam@167 6552 \let\Eraggedcenter\par
cannam@167 6553
cannam@167 6554
cannam@167 6555 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
cannam@167 6556 % and narrows the margins. We keep \parskip nonzero in general, since
cannam@167 6557 % we're doing normal filling. So, when using \aboveenvbreak and
cannam@167 6558 % \afterenvbreak, temporarily make \parskip 0.
cannam@167 6559 %
cannam@167 6560 \makedispenvdef{quotation}{\quotationstart}
cannam@167 6561 %
cannam@167 6562 \def\quotationstart{%
cannam@167 6563 \indentedblockstart % same as \indentedblock, but increase right margin too.
cannam@167 6564 \ifx\nonarrowing\relax
cannam@167 6565 \advance\rightskip by \lispnarrowing
cannam@167 6566 \fi
cannam@167 6567 \parsearg\quotationlabel
cannam@167 6568 }
cannam@167 6569
cannam@167 6570 % We have retained a nonzero parskip for the environment, since we're
cannam@167 6571 % doing normal filling.
cannam@167 6572 %
cannam@167 6573 \def\Equotation{%
cannam@167 6574 \par
cannam@167 6575 \ifx\quotationauthor\thisisundefined\else
cannam@167 6576 % indent a bit.
cannam@167 6577 \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
cannam@167 6578 \fi
cannam@167 6579 {\parskip=0pt \afterenvbreak}%
cannam@167 6580 }
cannam@167 6581 \def\Esmallquotation{\Equotation}
cannam@167 6582
cannam@167 6583 % If we're given an argument, typeset it in bold with a colon after.
cannam@167 6584 \def\quotationlabel#1{%
cannam@167 6585 \def\temp{#1}%
cannam@167 6586 \ifx\temp\empty \else
cannam@167 6587 {\bf #1: }%
cannam@167 6588 \fi
cannam@167 6589 }
cannam@167 6590
cannam@167 6591 % @indentedblock is like @quotation, but indents only on the left and
cannam@167 6592 % has no optional argument.
cannam@167 6593 %
cannam@167 6594 \makedispenvdef{indentedblock}{\indentedblockstart}
cannam@167 6595 %
cannam@167 6596 \def\indentedblockstart{%
cannam@167 6597 {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
cannam@167 6598 \parindent=0pt
cannam@167 6599 %
cannam@167 6600 % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
cannam@167 6601 \ifx\nonarrowing\relax
cannam@167 6602 \advance\leftskip by \lispnarrowing
cannam@167 6603 \exdentamount = \lispnarrowing
cannam@167 6604 \else
cannam@167 6605 \let\nonarrowing = \relax
cannam@167 6606 \fi
cannam@167 6607 }
cannam@167 6608
cannam@167 6609 % Keep a nonzero parskip for the environment, since we're doing normal filling.
cannam@167 6610 %
cannam@167 6611 \def\Eindentedblock{%
cannam@167 6612 \par
cannam@167 6613 {\parskip=0pt \afterenvbreak}%
cannam@167 6614 }
cannam@167 6615 \def\Esmallindentedblock{\Eindentedblock}
cannam@167 6616
cannam@167 6617
cannam@167 6618 % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
cannam@167 6619 % If we want to allow any <char> as delimiter,
cannam@167 6620 % we need the curly braces so that makeinfo sees the @verb command, eg:
cannam@167 6621 % `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org
cannam@167 6622 %
cannam@167 6623 % [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
cannam@167 6624 %
cannam@167 6625 % [Knuth] p.344; only we need to do the other characters Texinfo sets
cannam@167 6626 % active too. Otherwise, they get lost as the first character on a
cannam@167 6627 % verbatim line.
cannam@167 6628 \def\dospecials{%
cannam@167 6629 \do\ \do\\\do\{\do\}\do\$\do\&%
cannam@167 6630 \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
cannam@167 6631 \do\<\do\>\do\|\do\@\do+\do\"%
cannam@167 6632 % Don't do the quotes -- if we do, @set txicodequoteundirected and
cannam@167 6633 % @set txicodequotebacktick will not have effect on @verb and
cannam@167 6634 % @verbatim, and ?` and !` ligatures won't get disabled.
cannam@167 6635 %\do\`\do\'%
cannam@167 6636 }
cannam@167 6637 %
cannam@167 6638 % [Knuth] p. 380
cannam@167 6639 \def\uncatcodespecials{%
cannam@167 6640 \def\do##1{\catcode`##1=\other}\dospecials}
cannam@167 6641 %
cannam@167 6642 % Setup for the @verb command.
cannam@167 6643 %
cannam@167 6644 % Eight spaces for a tab
cannam@167 6645 \begingroup
cannam@167 6646 \catcode`\^^I=\active
cannam@167 6647 \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
cannam@167 6648 \endgroup
cannam@167 6649 %
cannam@167 6650 \def\setupverb{%
cannam@167 6651 \tt % easiest (and conventionally used) font for verbatim
cannam@167 6652 \def\par{\leavevmode\endgraf}%
cannam@167 6653 \setupmarkupstyle{verb}%
cannam@167 6654 \tabeightspaces
cannam@167 6655 % Respect line breaks,
cannam@167 6656 % print special symbols as themselves, and
cannam@167 6657 % make each space count
cannam@167 6658 % must do in this order:
cannam@167 6659 \obeylines \uncatcodespecials \sepspaces
cannam@167 6660 }
cannam@167 6661
cannam@167 6662 % Setup for the @verbatim environment
cannam@167 6663 %
cannam@167 6664 % Real tab expansion.
cannam@167 6665 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
cannam@167 6666 %
cannam@167 6667 % We typeset each line of the verbatim in an \hbox, so we can handle
cannam@167 6668 % tabs. The \global is in case the verbatim line starts with an accent,
cannam@167 6669 % or some other command that starts with a begin-group. Otherwise, the
cannam@167 6670 % entire \verbbox would disappear at the corresponding end-group, before
cannam@167 6671 % it is typeset. Meanwhile, we can't have nested verbatim commands
cannam@167 6672 % (can we?), so the \global won't be overwriting itself.
cannam@167 6673 \newbox\verbbox
cannam@167 6674 \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
cannam@167 6675 %
cannam@167 6676 \begingroup
cannam@167 6677 \catcode`\^^I=\active
cannam@167 6678 \gdef\tabexpand{%
cannam@167 6679 \catcode`\^^I=\active
cannam@167 6680 \def^^I{\leavevmode\egroup
cannam@167 6681 \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
cannam@167 6682 \divide\dimen\verbbox by\tabw
cannam@167 6683 \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
cannam@167 6684 \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw
cannam@167 6685 \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
cannam@167 6686 }%
cannam@167 6687 }
cannam@167 6688 \endgroup
cannam@167 6689
cannam@167 6690 % start the verbatim environment.
cannam@167 6691 \def\setupverbatim{%
cannam@167 6692 \let\nonarrowing = t%
cannam@167 6693 \nonfillstart
cannam@167 6694 \tt % easiest (and conventionally used) font for verbatim
cannam@167 6695 % The \leavevmode here is for blank lines. Otherwise, we would
cannam@167 6696 % never \starttabox and the \egroup would end verbatim mode.
cannam@167 6697 \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
cannam@167 6698 \tabexpand
cannam@167 6699 \setupmarkupstyle{verbatim}%
cannam@167 6700 % Respect line breaks,
cannam@167 6701 % print special symbols as themselves, and
cannam@167 6702 % make each space count.
cannam@167 6703 % Must do in this order:
cannam@167 6704 \obeylines \uncatcodespecials \sepspaces
cannam@167 6705 \everypar{\starttabbox}%
cannam@167 6706 }
cannam@167 6707
cannam@167 6708 % Do the @verb magic: verbatim text is quoted by unique
cannam@167 6709 % delimiter characters. Before first delimiter expect a
cannam@167 6710 % right brace, after last delimiter expect closing brace:
cannam@167 6711 %
cannam@167 6712 % \def\doverb'{'<char>#1<char>'}'{#1}
cannam@167 6713 %
cannam@167 6714 % [Knuth] p. 382; only eat outer {}
cannam@167 6715 \begingroup
cannam@167 6716 \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
cannam@167 6717 \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
cannam@167 6718 \endgroup
cannam@167 6719 %
cannam@167 6720 \def\verb{\begingroup\setupverb\doverb}
cannam@167 6721 %
cannam@167 6722 %
cannam@167 6723 % Do the @verbatim magic: define the macro \doverbatim so that
cannam@167 6724 % the (first) argument ends when '@end verbatim' is reached, ie:
cannam@167 6725 %
cannam@167 6726 % \def\doverbatim#1@end verbatim{#1}
cannam@167 6727 %
cannam@167 6728 % For Texinfo it's a lot easier than for LaTeX,
cannam@167 6729 % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
cannam@167 6730 % we need not redefine '\', '{' and '}'.
cannam@167 6731 %
cannam@167 6732 % Inspired by LaTeX's verbatim command set [latex.ltx]
cannam@167 6733 %
cannam@167 6734 \begingroup
cannam@167 6735 \catcode`\ =\active
cannam@167 6736 \obeylines %
cannam@167 6737 % ignore everything up to the first ^^M, that's the newline at the end
cannam@167 6738 % of the @verbatim input line itself. Otherwise we get an extra blank
cannam@167 6739 % line in the output.
cannam@167 6740 \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
cannam@167 6741 % We really want {...\end verbatim} in the body of the macro, but
cannam@167 6742 % without the active space; thus we have to use \xdef and \gobble.
cannam@167 6743 \endgroup
cannam@167 6744 %
cannam@167 6745 \envdef\verbatim{%
cannam@167 6746 \setupverbatim\doverbatim
cannam@167 6747 }
cannam@167 6748 \let\Everbatim = \afterenvbreak
cannam@167 6749
cannam@167 6750
cannam@167 6751 % @verbatiminclude FILE - insert text of file in verbatim environment.
cannam@167 6752 %
cannam@167 6753 \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
cannam@167 6754 %
cannam@167 6755 \def\doverbatiminclude#1{%
cannam@167 6756 {%
cannam@167 6757 \makevalueexpandable
cannam@167 6758 \setupverbatim
cannam@167 6759 \indexnofonts % Allow `@@' and other weird things in file names.
cannam@167 6760 \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
cannam@167 6761 \input #1
cannam@167 6762 \afterenvbreak
cannam@167 6763 }%
cannam@167 6764 }
cannam@167 6765
cannam@167 6766 % @copying ... @end copying.
cannam@167 6767 % Save the text away for @insertcopying later.
cannam@167 6768 %
cannam@167 6769 % We save the uninterpreted tokens, rather than creating a box.
cannam@167 6770 % Saving the text in a box would be much easier, but then all the
cannam@167 6771 % typesetting commands (@smallbook, font changes, etc.) have to be done
cannam@167 6772 % beforehand -- and a) we want @copying to be done first in the source
cannam@167 6773 % file; b) letting users define the frontmatter in as flexible order as
cannam@167 6774 % possible is very desirable.
cannam@167 6775 %
cannam@167 6776 \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
cannam@167 6777 \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
cannam@167 6778 %
cannam@167 6779 \def\insertcopying{%
cannam@167 6780 \begingroup
cannam@167 6781 \parindent = 0pt % paragraph indentation looks wrong on title page
cannam@167 6782 \scanexp\copyingtext
cannam@167 6783 \endgroup
cannam@167 6784 }
cannam@167 6785
cannam@167 6786
cannam@167 6787 \message{defuns,}
cannam@167 6788 % @defun etc.
cannam@167 6789
cannam@167 6790 \newskip\defbodyindent \defbodyindent=.4in
cannam@167 6791 \newskip\defargsindent \defargsindent=50pt
cannam@167 6792 \newskip\deflastargmargin \deflastargmargin=18pt
cannam@167 6793 \newcount\defunpenalty
cannam@167 6794
cannam@167 6795 % Start the processing of @deffn:
cannam@167 6796 \def\startdefun{%
cannam@167 6797 \ifnum\lastpenalty<10000
cannam@167 6798 \medbreak
cannam@167 6799 \defunpenalty=10003 % Will keep this @deffn together with the
cannam@167 6800 % following @def command, see below.
cannam@167 6801 \else
cannam@167 6802 % If there are two @def commands in a row, we'll have a \nobreak,
cannam@167 6803 % which is there to keep the function description together with its
cannam@167 6804 % header. But if there's nothing but headers, we need to allow a
cannam@167 6805 % break somewhere. Check specifically for penalty 10002, inserted
cannam@167 6806 % by \printdefunline, instead of 10000, since the sectioning
cannam@167 6807 % commands also insert a nobreak penalty, and we don't want to allow
cannam@167 6808 % a break between a section heading and a defun.
cannam@167 6809 %
cannam@167 6810 % As a further refinement, we avoid "club" headers by signalling
cannam@167 6811 % with penalty of 10003 after the very first @deffn in the
cannam@167 6812 % sequence (see above), and penalty of 10002 after any following
cannam@167 6813 % @def command.
cannam@167 6814 \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
cannam@167 6815 %
cannam@167 6816 % Similarly, after a section heading, do not allow a break.
cannam@167 6817 % But do insert the glue.
cannam@167 6818 \medskip % preceded by discardable penalty, so not a breakpoint
cannam@167 6819 \fi
cannam@167 6820 %
cannam@167 6821 \parindent=0in
cannam@167 6822 \advance\leftskip by \defbodyindent
cannam@167 6823 \exdentamount=\defbodyindent
cannam@167 6824 }
cannam@167 6825
cannam@167 6826 \def\dodefunx#1{%
cannam@167 6827 % First, check whether we are in the right environment:
cannam@167 6828 \checkenv#1%
cannam@167 6829 %
cannam@167 6830 % As above, allow line break if we have multiple x headers in a row.
cannam@167 6831 % It's not a great place, though.
cannam@167 6832 \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
cannam@167 6833 %
cannam@167 6834 % And now, it's time to reuse the body of the original defun:
cannam@167 6835 \expandafter\gobbledefun#1%
cannam@167 6836 }
cannam@167 6837 \def\gobbledefun#1\startdefun{}
cannam@167 6838
cannam@167 6839 % \printdefunline \deffnheader{text}
cannam@167 6840 %
cannam@167 6841 \def\printdefunline#1#2{%
cannam@167 6842 \begingroup
cannam@167 6843 % call \deffnheader:
cannam@167 6844 #1#2 \endheader
cannam@167 6845 % common ending:
cannam@167 6846 \interlinepenalty = 10000
cannam@167 6847 \advance\rightskip by 0pt plus 1fil\relax
cannam@167 6848 \endgraf
cannam@167 6849 \nobreak\vskip -\parskip
cannam@167 6850 \penalty\defunpenalty % signal to \startdefun and \dodefunx
cannam@167 6851 % Some of the @defun-type tags do not enable magic parentheses,
cannam@167 6852 % rendering the following check redundant. But we don't optimize.
cannam@167 6853 \checkparencounts
cannam@167 6854 \endgroup
cannam@167 6855 }
cannam@167 6856
cannam@167 6857 \def\Edefun{\endgraf\medbreak}
cannam@167 6858
cannam@167 6859 % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
cannam@167 6860 % the only thing remaining is to define \deffnheader.
cannam@167 6861 %
cannam@167 6862 \def\makedefun#1{%
cannam@167 6863 \expandafter\let\csname E#1\endcsname = \Edefun
cannam@167 6864 \edef\temp{\noexpand\domakedefun
cannam@167 6865 \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
cannam@167 6866 \temp
cannam@167 6867 }
cannam@167 6868
cannam@167 6869 % \domakedefun \deffn \deffnx \deffnheader
cannam@167 6870 %
cannam@167 6871 % Define \deffn and \deffnx, without parameters.
cannam@167 6872 % \deffnheader has to be defined explicitly.
cannam@167 6873 %
cannam@167 6874 \def\domakedefun#1#2#3{%
cannam@167 6875 \envdef#1{%
cannam@167 6876 \startdefun
cannam@167 6877 \doingtypefnfalse % distinguish typed functions from all else
cannam@167 6878 \parseargusing\activeparens{\printdefunline#3}%
cannam@167 6879 }%
cannam@167 6880 \def#2{\dodefunx#1}%
cannam@167 6881 \def#3%
cannam@167 6882 }
cannam@167 6883
cannam@167 6884 \newif\ifdoingtypefn % doing typed function?
cannam@167 6885 \newif\ifrettypeownline % typeset return type on its own line?
cannam@167 6886
cannam@167 6887 % @deftypefnnewline on|off says whether the return type of typed functions
cannam@167 6888 % are printed on their own line. This affects @deftypefn, @deftypefun,
cannam@167 6889 % @deftypeop, and @deftypemethod.
cannam@167 6890 %
cannam@167 6891 \parseargdef\deftypefnnewline{%
cannam@167 6892 \def\temp{#1}%
cannam@167 6893 \ifx\temp\onword
cannam@167 6894 \expandafter\let\csname SETtxideftypefnnl\endcsname
cannam@167 6895 = \empty
cannam@167 6896 \else\ifx\temp\offword
cannam@167 6897 \expandafter\let\csname SETtxideftypefnnl\endcsname
cannam@167 6898 = \relax
cannam@167 6899 \else
cannam@167 6900 \errhelp = \EMsimple
cannam@167 6901 \errmessage{Unknown @txideftypefnnl value `\temp',
cannam@167 6902 must be on|off}%
cannam@167 6903 \fi\fi
cannam@167 6904 }
cannam@167 6905
cannam@167 6906 % Untyped functions:
cannam@167 6907
cannam@167 6908 % @deffn category name args
cannam@167 6909 \makedefun{deffn}{\deffngeneral{}}
cannam@167 6910
cannam@167 6911 % @deffn category class name args
cannam@167 6912 \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
cannam@167 6913
cannam@167 6914 % \defopon {category on}class name args
cannam@167 6915 \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
cannam@167 6916
cannam@167 6917 % \deffngeneral {subind}category name args
cannam@167 6918 %
cannam@167 6919 \def\deffngeneral#1#2 #3 #4\endheader{%
cannam@167 6920 % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
cannam@167 6921 \dosubind{fn}{\code{#3}}{#1}%
cannam@167 6922 \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
cannam@167 6923 }
cannam@167 6924
cannam@167 6925 % Typed functions:
cannam@167 6926
cannam@167 6927 % @deftypefn category type name args
cannam@167 6928 \makedefun{deftypefn}{\deftypefngeneral{}}
cannam@167 6929
cannam@167 6930 % @deftypeop category class type name args
cannam@167 6931 \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
cannam@167 6932
cannam@167 6933 % \deftypeopon {category on}class type name args
cannam@167 6934 \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
cannam@167 6935
cannam@167 6936 % \deftypefngeneral {subind}category type name args
cannam@167 6937 %
cannam@167 6938 \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
cannam@167 6939 \dosubind{fn}{\code{#4}}{#1}%
cannam@167 6940 \doingtypefntrue
cannam@167 6941 \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
cannam@167 6942 }
cannam@167 6943
cannam@167 6944 % Typed variables:
cannam@167 6945
cannam@167 6946 % @deftypevr category type var args
cannam@167 6947 \makedefun{deftypevr}{\deftypecvgeneral{}}
cannam@167 6948
cannam@167 6949 % @deftypecv category class type var args
cannam@167 6950 \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
cannam@167 6951
cannam@167 6952 % \deftypecvof {category of}class type var args
cannam@167 6953 \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
cannam@167 6954
cannam@167 6955 % \deftypecvgeneral {subind}category type var args
cannam@167 6956 %
cannam@167 6957 \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
cannam@167 6958 \dosubind{vr}{\code{#4}}{#1}%
cannam@167 6959 \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
cannam@167 6960 }
cannam@167 6961
cannam@167 6962 % Untyped variables:
cannam@167 6963
cannam@167 6964 % @defvr category var args
cannam@167 6965 \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
cannam@167 6966
cannam@167 6967 % @defcv category class var args
cannam@167 6968 \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
cannam@167 6969
cannam@167 6970 % \defcvof {category of}class var args
cannam@167 6971 \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
cannam@167 6972
cannam@167 6973 % Types:
cannam@167 6974
cannam@167 6975 % @deftp category name args
cannam@167 6976 \makedefun{deftp}#1 #2 #3\endheader{%
cannam@167 6977 \doind{tp}{\code{#2}}%
cannam@167 6978 \defname{#1}{}{#2}\defunargs{#3\unskip}%
cannam@167 6979 }
cannam@167 6980
cannam@167 6981 % Remaining @defun-like shortcuts:
cannam@167 6982 \makedefun{defun}{\deffnheader{\putwordDeffunc} }
cannam@167 6983 \makedefun{defmac}{\deffnheader{\putwordDefmac} }
cannam@167 6984 \makedefun{defspec}{\deffnheader{\putwordDefspec} }
cannam@167 6985 \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
cannam@167 6986 \makedefun{defvar}{\defvrheader{\putwordDefvar} }
cannam@167 6987 \makedefun{defopt}{\defvrheader{\putwordDefopt} }
cannam@167 6988 \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
cannam@167 6989 \makedefun{defmethod}{\defopon\putwordMethodon}
cannam@167 6990 \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
cannam@167 6991 \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
cannam@167 6992 \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
cannam@167 6993
cannam@167 6994 % \defname, which formats the name of the @def (not the args).
cannam@167 6995 % #1 is the category, such as "Function".
cannam@167 6996 % #2 is the return type, if any.
cannam@167 6997 % #3 is the function name.
cannam@167 6998 %
cannam@167 6999 % We are followed by (but not passed) the arguments, if any.
cannam@167 7000 %
cannam@167 7001 \def\defname#1#2#3{%
cannam@167 7002 \par
cannam@167 7003 % Get the values of \leftskip and \rightskip as they were outside the @def...
cannam@167 7004 \advance\leftskip by -\defbodyindent
cannam@167 7005 %
cannam@167 7006 % Determine if we are typesetting the return type of a typed function
cannam@167 7007 % on a line by itself.
cannam@167 7008 \rettypeownlinefalse
cannam@167 7009 \ifdoingtypefn % doing a typed function specifically?
cannam@167 7010 % then check user option for putting return type on its own line:
cannam@167 7011 \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
cannam@167 7012 \rettypeownlinetrue
cannam@167 7013 \fi
cannam@167 7014 \fi
cannam@167 7015 %
cannam@167 7016 % How we'll format the category name. Putting it in brackets helps
cannam@167 7017 % distinguish it from the body text that may end up on the next line
cannam@167 7018 % just below it.
cannam@167 7019 \def\temp{#1}%
cannam@167 7020 \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
cannam@167 7021 %
cannam@167 7022 % Figure out line sizes for the paragraph shape. We'll always have at
cannam@167 7023 % least two.
cannam@167 7024 \tempnum = 2
cannam@167 7025 %
cannam@167 7026 % The first line needs space for \box0; but if \rightskip is nonzero,
cannam@167 7027 % we need only space for the part of \box0 which exceeds it:
cannam@167 7028 \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
cannam@167 7029 %
cannam@167 7030 % If doing a return type on its own line, we'll have another line.
cannam@167 7031 \ifrettypeownline
cannam@167 7032 \advance\tempnum by 1
cannam@167 7033 \def\maybeshapeline{0in \hsize}%
cannam@167 7034 \else
cannam@167 7035 \def\maybeshapeline{}%
cannam@167 7036 \fi
cannam@167 7037 %
cannam@167 7038 % The continuations:
cannam@167 7039 \dimen2=\hsize \advance\dimen2 by -\defargsindent
cannam@167 7040 %
cannam@167 7041 % The final paragraph shape:
cannam@167 7042 \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2
cannam@167 7043 %
cannam@167 7044 % Put the category name at the right margin.
cannam@167 7045 \noindent
cannam@167 7046 \hbox to 0pt{%
cannam@167 7047 \hfil\box0 \kern-\hsize
cannam@167 7048 % \hsize has to be shortened this way:
cannam@167 7049 \kern\leftskip
cannam@167 7050 % Intentionally do not respect \rightskip, since we need the space.
cannam@167 7051 }%
cannam@167 7052 %
cannam@167 7053 % Allow all lines to be underfull without complaint:
cannam@167 7054 \tolerance=10000 \hbadness=10000
cannam@167 7055 \exdentamount=\defbodyindent
cannam@167 7056 {%
cannam@167 7057 % defun fonts. We use typewriter by default (used to be bold) because:
cannam@167 7058 % . we're printing identifiers, they should be in tt in principle.
cannam@167 7059 % . in languages with many accents, such as Czech or French, it's
cannam@167 7060 % common to leave accents off identifiers. The result looks ok in
cannam@167 7061 % tt, but exceedingly strange in rm.
cannam@167 7062 % . we don't want -- and --- to be treated as ligatures.
cannam@167 7063 % . this still does not fix the ?` and !` ligatures, but so far no
cannam@167 7064 % one has made identifiers using them :).
cannam@167 7065 \df \tt
cannam@167 7066 \def\temp{#2}% text of the return type
cannam@167 7067 \ifx\temp\empty\else
cannam@167 7068 \tclose{\temp}% typeset the return type
cannam@167 7069 \ifrettypeownline
cannam@167 7070 % put return type on its own line; prohibit line break following:
cannam@167 7071 \hfil\vadjust{\nobreak}\break
cannam@167 7072 \else
cannam@167 7073 \space % type on same line, so just followed by a space
cannam@167 7074 \fi
cannam@167 7075 \fi % no return type
cannam@167 7076 #3% output function name
cannam@167 7077 }%
cannam@167 7078 {\rm\enskip}% hskip 0.5 em of \tenrm
cannam@167 7079 %
cannam@167 7080 \boldbrax
cannam@167 7081 % arguments will be output next, if any.
cannam@167 7082 }
cannam@167 7083
cannam@167 7084 % Print arguments in slanted roman (not ttsl), inconsistently with using
cannam@167 7085 % tt for the name. This is because literal text is sometimes needed in
cannam@167 7086 % the argument list (groff manual), and ttsl and tt are not very
cannam@167 7087 % distinguishable. Prevent hyphenation at `-' chars.
cannam@167 7088 %
cannam@167 7089 \def\defunargs#1{%
cannam@167 7090 % use sl by default (not ttsl),
cannam@167 7091 % tt for the names.
cannam@167 7092 \df \sl \hyphenchar\font=0
cannam@167 7093 %
cannam@167 7094 % On the other hand, if an argument has two dashes (for instance), we
cannam@167 7095 % want a way to get ttsl. We used to recommend @var for that, so
cannam@167 7096 % leave the code in, but it's strange for @var to lead to typewriter.
cannam@167 7097 % Nowadays we recommend @code, since the difference between a ttsl hyphen
cannam@167 7098 % and a tt hyphen is pretty tiny. @code also disables ?` !`.
cannam@167 7099 \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
cannam@167 7100 #1%
cannam@167 7101 \sl\hyphenchar\font=45
cannam@167 7102 }
cannam@167 7103
cannam@167 7104 % We want ()&[] to print specially on the defun line.
cannam@167 7105 %
cannam@167 7106 \def\activeparens{%
cannam@167 7107 \catcode`\(=\active \catcode`\)=\active
cannam@167 7108 \catcode`\[=\active \catcode`\]=\active
cannam@167 7109 \catcode`\&=\active
cannam@167 7110 }
cannam@167 7111
cannam@167 7112 % Make control sequences which act like normal parenthesis chars.
cannam@167 7113 \let\lparen = ( \let\rparen = )
cannam@167 7114
cannam@167 7115 % Be sure that we always have a definition for `(', etc. For example,
cannam@167 7116 % if the fn name has parens in it, \boldbrax will not be in effect yet,
cannam@167 7117 % so TeX would otherwise complain about undefined control sequence.
cannam@167 7118 {
cannam@167 7119 \activeparens
cannam@167 7120 \global\let(=\lparen \global\let)=\rparen
cannam@167 7121 \global\let[=\lbrack \global\let]=\rbrack
cannam@167 7122 \global\let& = \&
cannam@167 7123
cannam@167 7124 \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
cannam@167 7125 \gdef\magicamp{\let&=\amprm}
cannam@167 7126 }
cannam@167 7127
cannam@167 7128 \newcount\parencount
cannam@167 7129
cannam@167 7130 % If we encounter &foo, then turn on ()-hacking afterwards
cannam@167 7131 \newif\ifampseen
cannam@167 7132 \def\amprm#1 {\ampseentrue{\bf\&#1 }}
cannam@167 7133
cannam@167 7134 \def\parenfont{%
cannam@167 7135 \ifampseen
cannam@167 7136 % At the first level, print parens in roman,
cannam@167 7137 % otherwise use the default font.
cannam@167 7138 \ifnum \parencount=1 \rm \fi
cannam@167 7139 \else
cannam@167 7140 % The \sf parens (in \boldbrax) actually are a little bolder than
cannam@167 7141 % the contained text. This is especially needed for [ and ] .
cannam@167 7142 \sf
cannam@167 7143 \fi
cannam@167 7144 }
cannam@167 7145 \def\infirstlevel#1{%
cannam@167 7146 \ifampseen
cannam@167 7147 \ifnum\parencount=1
cannam@167 7148 #1%
cannam@167 7149 \fi
cannam@167 7150 \fi
cannam@167 7151 }
cannam@167 7152 \def\bfafterword#1 {#1 \bf}
cannam@167 7153
cannam@167 7154 \def\opnr{%
cannam@167 7155 \global\advance\parencount by 1
cannam@167 7156 {\parenfont(}%
cannam@167 7157 \infirstlevel \bfafterword
cannam@167 7158 }
cannam@167 7159 \def\clnr{%
cannam@167 7160 {\parenfont)}%
cannam@167 7161 \infirstlevel \sl
cannam@167 7162 \global\advance\parencount by -1
cannam@167 7163 }
cannam@167 7164
cannam@167 7165 \newcount\brackcount
cannam@167 7166 \def\lbrb{%
cannam@167 7167 \global\advance\brackcount by 1
cannam@167 7168 {\bf[}%
cannam@167 7169 }
cannam@167 7170 \def\rbrb{%
cannam@167 7171 {\bf]}%
cannam@167 7172 \global\advance\brackcount by -1
cannam@167 7173 }
cannam@167 7174
cannam@167 7175 \def\checkparencounts{%
cannam@167 7176 \ifnum\parencount=0 \else \badparencount \fi
cannam@167 7177 \ifnum\brackcount=0 \else \badbrackcount \fi
cannam@167 7178 }
cannam@167 7179 % these should not use \errmessage; the glibc manual, at least, actually
cannam@167 7180 % has such constructs (when documenting function pointers).
cannam@167 7181 \def\badparencount{%
cannam@167 7182 \message{Warning: unbalanced parentheses in @def...}%
cannam@167 7183 \global\parencount=0
cannam@167 7184 }
cannam@167 7185 \def\badbrackcount{%
cannam@167 7186 \message{Warning: unbalanced square brackets in @def...}%
cannam@167 7187 \global\brackcount=0
cannam@167 7188 }
cannam@167 7189
cannam@167 7190
cannam@167 7191 \message{macros,}
cannam@167 7192 % @macro.
cannam@167 7193
cannam@167 7194 % To do this right we need a feature of e-TeX, \scantokens,
cannam@167 7195 % which we arrange to emulate with a temporary file in ordinary TeX.
cannam@167 7196 \ifx\eTeXversion\thisisundefined
cannam@167 7197 \newwrite\macscribble
cannam@167 7198 \def\scantokens#1{%
cannam@167 7199 \toks0={#1}%
cannam@167 7200 \immediate\openout\macscribble=\jobname.tmp
cannam@167 7201 \immediate\write\macscribble{\the\toks0}%
cannam@167 7202 \immediate\closeout\macscribble
cannam@167 7203 \input \jobname.tmp
cannam@167 7204 }
cannam@167 7205 \fi
cannam@167 7206
cannam@167 7207 \def\scanmacro#1{\begingroup
cannam@167 7208 \newlinechar`\^^M
cannam@167 7209 \let\xeatspaces\eatspaces
cannam@167 7210 %
cannam@167 7211 % Undo catcode changes of \startcontents and \doprintindex
cannam@167 7212 % When called from @insertcopying or (short)caption, we need active
cannam@167 7213 % backslash to get it printed correctly. Previously, we had
cannam@167 7214 % \catcode`\\=\other instead. We'll see whether a problem appears
cannam@167 7215 % with macro expansion. --kasal, 19aug04
cannam@167 7216 \catcode`\@=0 \catcode`\\=\active \escapechar=`\@
cannam@167 7217 %
cannam@167 7218 % ... and for \example:
cannam@167 7219 \spaceisspace
cannam@167 7220 %
cannam@167 7221 % The \empty here causes a following catcode 5 newline to be eaten as
cannam@167 7222 % part of reading whitespace after a control sequence. It does not
cannam@167 7223 % eat a catcode 13 newline. There's no good way to handle the two
cannam@167 7224 % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX
cannam@167 7225 % would then have different behavior). See the Macro Details node in
cannam@167 7226 % the manual for the workaround we recommend for macros and
cannam@167 7227 % line-oriented commands.
cannam@167 7228 %
cannam@167 7229 \scantokens{#1\empty}%
cannam@167 7230 \endgroup}
cannam@167 7231
cannam@167 7232 \def\scanexp#1{%
cannam@167 7233 \edef\temp{\noexpand\scanmacro{#1}}%
cannam@167 7234 \temp
cannam@167 7235 }
cannam@167 7236
cannam@167 7237 \newcount\paramno % Count of parameters
cannam@167 7238 \newtoks\macname % Macro name
cannam@167 7239 \newif\ifrecursive % Is it recursive?
cannam@167 7240
cannam@167 7241 % List of all defined macros in the form
cannam@167 7242 % \definedummyword\macro1\definedummyword\macro2...
cannam@167 7243 % Currently is also contains all @aliases; the list can be split
cannam@167 7244 % if there is a need.
cannam@167 7245 \def\macrolist{}
cannam@167 7246
cannam@167 7247 % Add the macro to \macrolist
cannam@167 7248 \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
cannam@167 7249 \def\addtomacrolistxxx#1{%
cannam@167 7250 \toks0 = \expandafter{\macrolist\definedummyword#1}%
cannam@167 7251 \xdef\macrolist{\the\toks0}%
cannam@167 7252 }
cannam@167 7253
cannam@167 7254 % Utility routines.
cannam@167 7255 % This does \let #1 = #2, with \csnames; that is,
cannam@167 7256 % \let \csname#1\endcsname = \csname#2\endcsname
cannam@167 7257 % (except of course we have to play expansion games).
cannam@167 7258 %
cannam@167 7259 \def\cslet#1#2{%
cannam@167 7260 \expandafter\let
cannam@167 7261 \csname#1\expandafter\endcsname
cannam@167 7262 \csname#2\endcsname
cannam@167 7263 }
cannam@167 7264
cannam@167 7265 % Trim leading and trailing spaces off a string.
cannam@167 7266 % Concepts from aro-bend problem 15 (see CTAN).
cannam@167 7267 {\catcode`\@=11
cannam@167 7268 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
cannam@167 7269 \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
cannam@167 7270 \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
cannam@167 7271 \def\unbrace#1{#1}
cannam@167 7272 \unbrace{\gdef\trim@@@ #1 } #2@{#1}
cannam@167 7273 }
cannam@167 7274
cannam@167 7275 % Trim a single trailing ^^M off a string.
cannam@167 7276 {\catcode`\^^M=\other \catcode`\Q=3%
cannam@167 7277 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
cannam@167 7278 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
cannam@167 7279 \gdef\eatcrb#1Q#2Q{#1}%
cannam@167 7280 }
cannam@167 7281
cannam@167 7282 % Macro bodies are absorbed as an argument in a context where
cannam@167 7283 % all characters are catcode 10, 11 or 12, except \ which is active
cannam@167 7284 % (as in normal texinfo). It is necessary to change the definition of \
cannam@167 7285 % to recognize macro arguments; this is the job of \mbodybackslash.
cannam@167 7286 %
cannam@167 7287 % Non-ASCII encodings make 8-bit characters active, so un-activate
cannam@167 7288 % them to avoid their expansion. Must do this non-globally, to
cannam@167 7289 % confine the change to the current group.
cannam@167 7290 %
cannam@167 7291 % It's necessary to have hard CRs when the macro is executed. This is
cannam@167 7292 % done by making ^^M (\endlinechar) catcode 12 when reading the macro
cannam@167 7293 % body, and then making it the \newlinechar in \scanmacro.
cannam@167 7294 %
cannam@167 7295 \def\scanctxt{% used as subroutine
cannam@167 7296 \catcode`\"=\other
cannam@167 7297 \catcode`\+=\other
cannam@167 7298 \catcode`\<=\other
cannam@167 7299 \catcode`\>=\other
cannam@167 7300 \catcode`\@=\other
cannam@167 7301 \catcode`\^=\other
cannam@167 7302 \catcode`\_=\other
cannam@167 7303 \catcode`\|=\other
cannam@167 7304 \catcode`\~=\other
cannam@167 7305 \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi
cannam@167 7306 }
cannam@167 7307
cannam@167 7308 \def\scanargctxt{% used for copying and captions, not macros.
cannam@167 7309 \scanctxt
cannam@167 7310 \catcode`\\=\other
cannam@167 7311 \catcode`\^^M=\other
cannam@167 7312 }
cannam@167 7313
cannam@167 7314 \def\macrobodyctxt{% used for @macro definitions
cannam@167 7315 \scanctxt
cannam@167 7316 \catcode`\{=\other
cannam@167 7317 \catcode`\}=\other
cannam@167 7318 \catcode`\^^M=\other
cannam@167 7319 \usembodybackslash
cannam@167 7320 }
cannam@167 7321
cannam@167 7322 \def\macroargctxt{% used when scanning invocations
cannam@167 7323 \scanctxt
cannam@167 7324 \catcode`\\=0
cannam@167 7325 }
cannam@167 7326 % why catcode 0 for \ in the above? To recognize \\ \{ \} as "escapes"
cannam@167 7327 % for the single characters \ { }. Thus, we end up with the "commands"
cannam@167 7328 % that would be written @\ @{ @} in a Texinfo document.
cannam@167 7329 %
cannam@167 7330 % We already have @{ and @}. For @\, we define it here, and only for
cannam@167 7331 % this purpose, to produce a typewriter backslash (so, the @\ that we
cannam@167 7332 % define for @math can't be used with @macro calls):
cannam@167 7333 %
cannam@167 7334 \def\\{\normalbackslash}%
cannam@167 7335 %
cannam@167 7336 % We would like to do this for \, too, since that is what makeinfo does.
cannam@167 7337 % But it is not possible, because Texinfo already has a command @, for a
cannam@167 7338 % cedilla accent. Documents must use @comma{} instead.
cannam@167 7339 %
cannam@167 7340 % \anythingelse will almost certainly be an error of some kind.
cannam@167 7341
cannam@167 7342
cannam@167 7343 % \mbodybackslash is the definition of \ in @macro bodies.
cannam@167 7344 % It maps \foo\ => \csname macarg.foo\endcsname => #N
cannam@167 7345 % where N is the macro parameter number.
cannam@167 7346 % We define \csname macarg.\endcsname to be \realbackslash, so
cannam@167 7347 % \\ in macro replacement text gets you a backslash.
cannam@167 7348 %
cannam@167 7349 {\catcode`@=0 @catcode`@\=@active
cannam@167 7350 @gdef@usembodybackslash{@let\=@mbodybackslash}
cannam@167 7351 @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
cannam@167 7352 }
cannam@167 7353 \expandafter\def\csname macarg.\endcsname{\realbackslash}
cannam@167 7354
cannam@167 7355 \def\margbackslash#1{\char`\#1 }
cannam@167 7356
cannam@167 7357 \def\macro{\recursivefalse\parsearg\macroxxx}
cannam@167 7358 \def\rmacro{\recursivetrue\parsearg\macroxxx}
cannam@167 7359
cannam@167 7360 \def\macroxxx#1{%
cannam@167 7361 \getargs{#1}% now \macname is the macname and \argl the arglist
cannam@167 7362 \ifx\argl\empty % no arguments
cannam@167 7363 \paramno=0\relax
cannam@167 7364 \else
cannam@167 7365 \expandafter\parsemargdef \argl;%
cannam@167 7366 \if\paramno>256\relax
cannam@167 7367 \ifx\eTeXversion\thisisundefined
cannam@167 7368 \errhelp = \EMsimple
cannam@167 7369 \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
cannam@167 7370 \fi
cannam@167 7371 \fi
cannam@167 7372 \fi
cannam@167 7373 \if1\csname ismacro.\the\macname\endcsname
cannam@167 7374 \message{Warning: redefining \the\macname}%
cannam@167 7375 \else
cannam@167 7376 \expandafter\ifx\csname \the\macname\endcsname \relax
cannam@167 7377 \else \errmessage{Macro name \the\macname\space already defined}\fi
cannam@167 7378 \global\cslet{macsave.\the\macname}{\the\macname}%
cannam@167 7379 \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
cannam@167 7380 \addtomacrolist{\the\macname}%
cannam@167 7381 \fi
cannam@167 7382 \begingroup \macrobodyctxt
cannam@167 7383 \ifrecursive \expandafter\parsermacbody
cannam@167 7384 \else \expandafter\parsemacbody
cannam@167 7385 \fi}
cannam@167 7386
cannam@167 7387 \parseargdef\unmacro{%
cannam@167 7388 \if1\csname ismacro.#1\endcsname
cannam@167 7389 \global\cslet{#1}{macsave.#1}%
cannam@167 7390 \global\expandafter\let \csname ismacro.#1\endcsname=0%
cannam@167 7391 % Remove the macro name from \macrolist:
cannam@167 7392 \begingroup
cannam@167 7393 \expandafter\let\csname#1\endcsname \relax
cannam@167 7394 \let\definedummyword\unmacrodo
cannam@167 7395 \xdef\macrolist{\macrolist}%
cannam@167 7396 \endgroup
cannam@167 7397 \else
cannam@167 7398 \errmessage{Macro #1 not defined}%
cannam@167 7399 \fi
cannam@167 7400 }
cannam@167 7401
cannam@167 7402 % Called by \do from \dounmacro on each macro. The idea is to omit any
cannam@167 7403 % macro definitions that have been changed to \relax.
cannam@167 7404 %
cannam@167 7405 \def\unmacrodo#1{%
cannam@167 7406 \ifx #1\relax
cannam@167 7407 % remove this
cannam@167 7408 \else
cannam@167 7409 \noexpand\definedummyword \noexpand#1%
cannam@167 7410 \fi
cannam@167 7411 }
cannam@167 7412
cannam@167 7413 % This makes use of the obscure feature that if the last token of a
cannam@167 7414 % <parameter list> is #, then the preceding argument is delimited by
cannam@167 7415 % an opening brace, and that opening brace is not consumed.
cannam@167 7416 \def\getargs#1{\getargsxxx#1{}}
cannam@167 7417 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
cannam@167 7418 \def\getmacname#1 #2\relax{\macname={#1}}
cannam@167 7419 \def\getmacargs#1{\def\argl{#1}}
cannam@167 7420
cannam@167 7421 % For macro processing make @ a letter so that we can make Texinfo private macro names.
cannam@167 7422 \edef\texiatcatcode{\the\catcode`\@}
cannam@167 7423 \catcode `@=11\relax
cannam@167 7424
cannam@167 7425 % Parse the optional {params} list. Set up \paramno and \paramlist
cannam@167 7426 % so \defmacro knows what to do. Define \macarg.BLAH for each BLAH
cannam@167 7427 % in the params list to some hook where the argument si to be expanded. If
cannam@167 7428 % there are less than 10 arguments that hook is to be replaced by ##N where N
cannam@167 7429 % is the position in that list, that is to say the macro arguments are to be
cannam@167 7430 % defined `a la TeX in the macro body.
cannam@167 7431 %
cannam@167 7432 % That gets used by \mbodybackslash (above).
cannam@167 7433 %
cannam@167 7434 % We need to get `macro parameter char #' into several definitions.
cannam@167 7435 % The technique used is stolen from LaTeX: let \hash be something
cannam@167 7436 % unexpandable, insert that wherever you need a #, and then redefine
cannam@167 7437 % it to # just before using the token list produced.
cannam@167 7438 %
cannam@167 7439 % The same technique is used to protect \eatspaces till just before
cannam@167 7440 % the macro is used.
cannam@167 7441 %
cannam@167 7442 % If there are 10 or more arguments, a different technique is used, where the
cannam@167 7443 % hook remains in the body, and when macro is to be expanded the body is
cannam@167 7444 % processed again to replace the arguments.
cannam@167 7445 %
cannam@167 7446 % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
cannam@167 7447 % argument N value and then \edef the body (nothing else will expand because of
cannam@167 7448 % the catcode regime underwhich the body was input).
cannam@167 7449 %
cannam@167 7450 % If you compile with TeX (not eTeX), and you have macros with 10 or more
cannam@167 7451 % arguments, you need that no macro has more than 256 arguments, otherwise an
cannam@167 7452 % error is produced.
cannam@167 7453 \def\parsemargdef#1;{%
cannam@167 7454 \paramno=0\def\paramlist{}%
cannam@167 7455 \let\hash\relax
cannam@167 7456 \let\xeatspaces\relax
cannam@167 7457 \parsemargdefxxx#1,;,%
cannam@167 7458 % In case that there are 10 or more arguments we parse again the arguments
cannam@167 7459 % list to set new definitions for the \macarg.BLAH macros corresponding to
cannam@167 7460 % each BLAH argument. It was anyhow needed to parse already once this list
cannam@167 7461 % in order to count the arguments, and as macros with at most 9 arguments
cannam@167 7462 % are by far more frequent than macro with 10 or more arguments, defining
cannam@167 7463 % twice the \macarg.BLAH macros does not cost too much processing power.
cannam@167 7464 \ifnum\paramno<10\relax\else
cannam@167 7465 \paramno0\relax
cannam@167 7466 \parsemmanyargdef@@#1,;,% 10 or more arguments
cannam@167 7467 \fi
cannam@167 7468 }
cannam@167 7469 \def\parsemargdefxxx#1,{%
cannam@167 7470 \if#1;\let\next=\relax
cannam@167 7471 \else \let\next=\parsemargdefxxx
cannam@167 7472 \advance\paramno by 1
cannam@167 7473 \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
cannam@167 7474 {\xeatspaces{\hash\the\paramno}}%
cannam@167 7475 \edef\paramlist{\paramlist\hash\the\paramno,}%
cannam@167 7476 \fi\next}
cannam@167 7477
cannam@167 7478 \def\parsemmanyargdef@@#1,{%
cannam@167 7479 \if#1;\let\next=\relax
cannam@167 7480 \else
cannam@167 7481 \let\next=\parsemmanyargdef@@
cannam@167 7482 \edef\tempb{\eatspaces{#1}}%
cannam@167 7483 \expandafter\def\expandafter\tempa
cannam@167 7484 \expandafter{\csname macarg.\tempb\endcsname}%
cannam@167 7485 % Note that we need some extra \noexpand\noexpand, this is because we
cannam@167 7486 % don't want \the to be expanded in the \parsermacbody as it uses an
cannam@167 7487 % \xdef .
cannam@167 7488 \expandafter\edef\tempa
cannam@167 7489 {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
cannam@167 7490 \advance\paramno by 1\relax
cannam@167 7491 \fi\next}
cannam@167 7492
cannam@167 7493 % These two commands read recursive and nonrecursive macro bodies.
cannam@167 7494 % (They're different since rec and nonrec macros end differently.)
cannam@167 7495 %
cannam@167 7496
cannam@167 7497 \catcode `\@\texiatcatcode
cannam@167 7498 \long\def\parsemacbody#1@end macro%
cannam@167 7499 {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
cannam@167 7500 \long\def\parsermacbody#1@end rmacro%
cannam@167 7501 {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
cannam@167 7502 \catcode `\@=11\relax
cannam@167 7503
cannam@167 7504 \let\endargs@\relax
cannam@167 7505 \let\nil@\relax
cannam@167 7506 \def\nilm@{\nil@}%
cannam@167 7507 \long\def\nillm@{\nil@}%
cannam@167 7508
cannam@167 7509 % This macro is expanded during the Texinfo macro expansion, not during its
cannam@167 7510 % definition. It gets all the arguments values and assigns them to macros
cannam@167 7511 % macarg.ARGNAME
cannam@167 7512 %
cannam@167 7513 % #1 is the macro name
cannam@167 7514 % #2 is the list of argument names
cannam@167 7515 % #3 is the list of argument values
cannam@167 7516 \def\getargvals@#1#2#3{%
cannam@167 7517 \def\macargdeflist@{}%
cannam@167 7518 \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
cannam@167 7519 \def\paramlist{#2,\nil@}%
cannam@167 7520 \def\macroname{#1}%
cannam@167 7521 \begingroup
cannam@167 7522 \macroargctxt
cannam@167 7523 \def\argvaluelist{#3,\nil@}%
cannam@167 7524 \def\@tempa{#3}%
cannam@167 7525 \ifx\@tempa\empty
cannam@167 7526 \setemptyargvalues@
cannam@167 7527 \else
cannam@167 7528 \getargvals@@
cannam@167 7529 \fi
cannam@167 7530 }
cannam@167 7531
cannam@167 7532 %
cannam@167 7533 \def\getargvals@@{%
cannam@167 7534 \ifx\paramlist\nilm@
cannam@167 7535 % Some sanity check needed here that \argvaluelist is also empty.
cannam@167 7536 \ifx\argvaluelist\nillm@
cannam@167 7537 \else
cannam@167 7538 \errhelp = \EMsimple
cannam@167 7539 \errmessage{Too many arguments in macro `\macroname'!}%
cannam@167 7540 \fi
cannam@167 7541 \let\next\macargexpandinbody@
cannam@167 7542 \else
cannam@167 7543 \ifx\argvaluelist\nillm@
cannam@167 7544 % No more arguments values passed to macro. Set remaining named-arg
cannam@167 7545 % macros to empty.
cannam@167 7546 \let\next\setemptyargvalues@
cannam@167 7547 \else
cannam@167 7548 % pop current arg name into \@tempb
cannam@167 7549 \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
cannam@167 7550 \expandafter\@tempa\expandafter{\paramlist}%
cannam@167 7551 % pop current argument value into \@tempc
cannam@167 7552 \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
cannam@167 7553 \expandafter\@tempa\expandafter{\argvaluelist}%
cannam@167 7554 % Here \@tempb is the current arg name and \@tempc is the current arg value.
cannam@167 7555 % First place the new argument macro definition into \@tempd
cannam@167 7556 \expandafter\macname\expandafter{\@tempc}%
cannam@167 7557 \expandafter\let\csname macarg.\@tempb\endcsname\relax
cannam@167 7558 \expandafter\def\expandafter\@tempe\expandafter{%
cannam@167 7559 \csname macarg.\@tempb\endcsname}%
cannam@167 7560 \edef\@tempd{\long\def\@tempe{\the\macname}}%
cannam@167 7561 \push@\@tempd\macargdeflist@
cannam@167 7562 \let\next\getargvals@@
cannam@167 7563 \fi
cannam@167 7564 \fi
cannam@167 7565 \next
cannam@167 7566 }
cannam@167 7567
cannam@167 7568 \def\push@#1#2{%
cannam@167 7569 \expandafter\expandafter\expandafter\def
cannam@167 7570 \expandafter\expandafter\expandafter#2%
cannam@167 7571 \expandafter\expandafter\expandafter{%
cannam@167 7572 \expandafter#1#2}%
cannam@167 7573 }
cannam@167 7574
cannam@167 7575 % Replace arguments by their values in the macro body, and place the result
cannam@167 7576 % in macro \@tempa
cannam@167 7577 \def\macvalstoargs@{%
cannam@167 7578 % To do this we use the property that token registers that are \the'ed
cannam@167 7579 % within an \edef expand only once. So we are going to place all argument
cannam@167 7580 % values into respective token registers.
cannam@167 7581 %
cannam@167 7582 % First we save the token context, and initialize argument numbering.
cannam@167 7583 \begingroup
cannam@167 7584 \paramno0\relax
cannam@167 7585 % Then, for each argument number #N, we place the corresponding argument
cannam@167 7586 % value into a new token list register \toks#N
cannam@167 7587 \expandafter\putargsintokens@\saveparamlist@,;,%
cannam@167 7588 % Then, we expand the body so that argument are replaced by their
cannam@167 7589 % values. The trick for values not to be expanded themselves is that they
cannam@167 7590 % are within tokens and that tokens expand only once in an \edef .
cannam@167 7591 \edef\@tempc{\csname mac.\macroname .body\endcsname}%
cannam@167 7592 % Now we restore the token stack pointer to free the token list registers
cannam@167 7593 % which we have used, but we make sure that expanded body is saved after
cannam@167 7594 % group.
cannam@167 7595 \expandafter
cannam@167 7596 \endgroup
cannam@167 7597 \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
cannam@167 7598 }
cannam@167 7599
cannam@167 7600 \def\macargexpandinbody@{%
cannam@167 7601 %% Define the named-macro outside of this group and then close this group.
cannam@167 7602 \expandafter
cannam@167 7603 \endgroup
cannam@167 7604 \macargdeflist@
cannam@167 7605 % First the replace in body the macro arguments by their values, the result
cannam@167 7606 % is in \@tempa .
cannam@167 7607 \macvalstoargs@
cannam@167 7608 % Then we point at the \norecurse or \gobble (for recursive) macro value
cannam@167 7609 % with \@tempb .
cannam@167 7610 \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
cannam@167 7611 % Depending on whether it is recursive or not, we need some tailing
cannam@167 7612 % \egroup .
cannam@167 7613 \ifx\@tempb\gobble
cannam@167 7614 \let\@tempc\relax
cannam@167 7615 \else
cannam@167 7616 \let\@tempc\egroup
cannam@167 7617 \fi
cannam@167 7618 % And now we do the real job:
cannam@167 7619 \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
cannam@167 7620 \@tempd
cannam@167 7621 }
cannam@167 7622
cannam@167 7623 \def\putargsintokens@#1,{%
cannam@167 7624 \if#1;\let\next\relax
cannam@167 7625 \else
cannam@167 7626 \let\next\putargsintokens@
cannam@167 7627 % First we allocate the new token list register, and give it a temporary
cannam@167 7628 % alias \@tempb .
cannam@167 7629 \toksdef\@tempb\the\paramno
cannam@167 7630 % Then we place the argument value into that token list register.
cannam@167 7631 \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
cannam@167 7632 \expandafter\@tempb\expandafter{\@tempa}%
cannam@167 7633 \advance\paramno by 1\relax
cannam@167 7634 \fi
cannam@167 7635 \next
cannam@167 7636 }
cannam@167 7637
cannam@167 7638 % Save the token stack pointer into macro #1
cannam@167 7639 \def\texisavetoksstackpoint#1{\edef#1{\the\@cclvi}}
cannam@167 7640 % Restore the token stack pointer from number in macro #1
cannam@167 7641 \def\texirestoretoksstackpoint#1{\expandafter\mathchardef\expandafter\@cclvi#1\relax}
cannam@167 7642 % newtoks that can be used non \outer .
cannam@167 7643 \def\texinonouternewtoks{\alloc@ 5\toks \toksdef \@cclvi}
cannam@167 7644
cannam@167 7645 % Tailing missing arguments are set to empty
cannam@167 7646 \def\setemptyargvalues@{%
cannam@167 7647 \ifx\paramlist\nilm@
cannam@167 7648 \let\next\macargexpandinbody@
cannam@167 7649 \else
cannam@167 7650 \expandafter\setemptyargvaluesparser@\paramlist\endargs@
cannam@167 7651 \let\next\setemptyargvalues@
cannam@167 7652 \fi
cannam@167 7653 \next
cannam@167 7654 }
cannam@167 7655
cannam@167 7656 \def\setemptyargvaluesparser@#1,#2\endargs@{%
cannam@167 7657 \expandafter\def\expandafter\@tempa\expandafter{%
cannam@167 7658 \expandafter\def\csname macarg.#1\endcsname{}}%
cannam@167 7659 \push@\@tempa\macargdeflist@
cannam@167 7660 \def\paramlist{#2}%
cannam@167 7661 }
cannam@167 7662
cannam@167 7663 % #1 is the element target macro
cannam@167 7664 % #2 is the list macro
cannam@167 7665 % #3,#4\endargs@ is the list value
cannam@167 7666 \def\pop@#1#2#3,#4\endargs@{%
cannam@167 7667 \def#1{#3}%
cannam@167 7668 \def#2{#4}%
cannam@167 7669 }
cannam@167 7670 \long\def\longpop@#1#2#3,#4\endargs@{%
cannam@167 7671 \long\def#1{#3}%
cannam@167 7672 \long\def#2{#4}%
cannam@167 7673 }
cannam@167 7674
cannam@167 7675 % This defines a Texinfo @macro. There are eight cases: recursive and
cannam@167 7676 % nonrecursive macros of zero, one, up to nine, and many arguments.
cannam@167 7677 % Much magic with \expandafter here.
cannam@167 7678 % \xdef is used so that macro definitions will survive the file
cannam@167 7679 % they're defined in; @include reads the file inside a group.
cannam@167 7680 %
cannam@167 7681 \def\defmacro{%
cannam@167 7682 \let\hash=##% convert placeholders to macro parameter chars
cannam@167 7683 \ifrecursive
cannam@167 7684 \ifcase\paramno
cannam@167 7685 % 0
cannam@167 7686 \expandafter\xdef\csname\the\macname\endcsname{%
cannam@167 7687 \noexpand\scanmacro{\temp}}%
cannam@167 7688 \or % 1
cannam@167 7689 \expandafter\xdef\csname\the\macname\endcsname{%
cannam@167 7690 \bgroup\noexpand\macroargctxt
cannam@167 7691 \noexpand\braceorline
cannam@167 7692 \expandafter\noexpand\csname\the\macname xxx\endcsname}%
cannam@167 7693 \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
cannam@167 7694 \egroup\noexpand\scanmacro{\temp}}%
cannam@167 7695 \else
cannam@167 7696 \ifnum\paramno<10\relax % at most 9
cannam@167 7697 \expandafter\xdef\csname\the\macname\endcsname{%
cannam@167 7698 \bgroup\noexpand\macroargctxt
cannam@167 7699 \noexpand\csname\the\macname xx\endcsname}%
cannam@167 7700 \expandafter\xdef\csname\the\macname xx\endcsname##1{%
cannam@167 7701 \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
cannam@167 7702 \expandafter\expandafter
cannam@167 7703 \expandafter\xdef
cannam@167 7704 \expandafter\expandafter
cannam@167 7705 \csname\the\macname xxx\endcsname
cannam@167 7706 \paramlist{\egroup\noexpand\scanmacro{\temp}}%
cannam@167 7707 \else % 10 or more
cannam@167 7708 \expandafter\xdef\csname\the\macname\endcsname{%
cannam@167 7709 \noexpand\getargvals@{\the\macname}{\argl}%
cannam@167 7710 }%
cannam@167 7711 \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp
cannam@167 7712 \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
cannam@167 7713 \fi
cannam@167 7714 \fi
cannam@167 7715 \else
cannam@167 7716 \ifcase\paramno
cannam@167 7717 % 0
cannam@167 7718 \expandafter\xdef\csname\the\macname\endcsname{%
cannam@167 7719 \noexpand\norecurse{\the\macname}%
cannam@167 7720 \noexpand\scanmacro{\temp}\egroup}%
cannam@167 7721 \or % 1
cannam@167 7722 \expandafter\xdef\csname\the\macname\endcsname{%
cannam@167 7723 \bgroup\noexpand\macroargctxt
cannam@167 7724 \noexpand\braceorline
cannam@167 7725 \expandafter\noexpand\csname\the\macname xxx\endcsname}%
cannam@167 7726 \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
cannam@167 7727 \egroup
cannam@167 7728 \noexpand\norecurse{\the\macname}%
cannam@167 7729 \noexpand\scanmacro{\temp}\egroup}%
cannam@167 7730 \else % at most 9
cannam@167 7731 \ifnum\paramno<10\relax
cannam@167 7732 \expandafter\xdef\csname\the\macname\endcsname{%
cannam@167 7733 \bgroup\noexpand\macroargctxt
cannam@167 7734 \expandafter\noexpand\csname\the\macname xx\endcsname}%
cannam@167 7735 \expandafter\xdef\csname\the\macname xx\endcsname##1{%
cannam@167 7736 \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
cannam@167 7737 \expandafter\expandafter
cannam@167 7738 \expandafter\xdef
cannam@167 7739 \expandafter\expandafter
cannam@167 7740 \csname\the\macname xxx\endcsname
cannam@167 7741 \paramlist{%
cannam@167 7742 \egroup
cannam@167 7743 \noexpand\norecurse{\the\macname}%
cannam@167 7744 \noexpand\scanmacro{\temp}\egroup}%
cannam@167 7745 \else % 10 or more:
cannam@167 7746 \expandafter\xdef\csname\the\macname\endcsname{%
cannam@167 7747 \noexpand\getargvals@{\the\macname}{\argl}%
cannam@167 7748 }%
cannam@167 7749 \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp
cannam@167 7750 \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse
cannam@167 7751 \fi
cannam@167 7752 \fi
cannam@167 7753 \fi}
cannam@167 7754
cannam@167 7755 \catcode `\@\texiatcatcode\relax
cannam@167 7756
cannam@167 7757 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
cannam@167 7758
cannam@167 7759 % \braceorline decides whether the next nonwhitespace character is a
cannam@167 7760 % {. If so it reads up to the closing }, if not, it reads the whole
cannam@167 7761 % line. Whatever was read is then fed to the next control sequence
cannam@167 7762 % as an argument (by \parsebrace or \parsearg).
cannam@167 7763 %
cannam@167 7764 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
cannam@167 7765 \def\braceorlinexxx{%
cannam@167 7766 \ifx\nchar\bgroup\else
cannam@167 7767 \expandafter\parsearg
cannam@167 7768 \fi \macnamexxx}
cannam@167 7769
cannam@167 7770
cannam@167 7771 % @alias.
cannam@167 7772 % We need some trickery to remove the optional spaces around the equal
cannam@167 7773 % sign. Make them active and then expand them all to nothing.
cannam@167 7774 %
cannam@167 7775 \def\alias{\parseargusing\obeyspaces\aliasxxx}
cannam@167 7776 \def\aliasxxx #1{\aliasyyy#1\relax}
cannam@167 7777 \def\aliasyyy #1=#2\relax{%
cannam@167 7778 {%
cannam@167 7779 \expandafter\let\obeyedspace=\empty
cannam@167 7780 \addtomacrolist{#1}%
cannam@167 7781 \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
cannam@167 7782 }%
cannam@167 7783 \next
cannam@167 7784 }
cannam@167 7785
cannam@167 7786
cannam@167 7787 \message{cross references,}
cannam@167 7788
cannam@167 7789 \newwrite\auxfile
cannam@167 7790 \newif\ifhavexrefs % True if xref values are known.
cannam@167 7791 \newif\ifwarnedxrefs % True if we warned once that they aren't known.
cannam@167 7792
cannam@167 7793 % @inforef is relatively simple.
cannam@167 7794 \def\inforef #1{\inforefzzz #1,,,,**}
cannam@167 7795 \def\inforefzzz #1,#2,#3,#4**{%
cannam@167 7796 \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
cannam@167 7797 node \samp{\ignorespaces#1{}}}
cannam@167 7798
cannam@167 7799 % @node's only job in TeX is to define \lastnode, which is used in
cannam@167 7800 % cross-references. The @node line might or might not have commas, and
cannam@167 7801 % might or might not have spaces before the first comma, like:
cannam@167 7802 % @node foo , bar , ...
cannam@167 7803 % We don't want such trailing spaces in the node name.
cannam@167 7804 %
cannam@167 7805 \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
cannam@167 7806 %
cannam@167 7807 % also remove a trailing comma, in case of something like this:
cannam@167 7808 % @node Help-Cross, , , Cross-refs
cannam@167 7809 \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
cannam@167 7810 \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
cannam@167 7811
cannam@167 7812 \let\nwnode=\node
cannam@167 7813 \let\lastnode=\empty
cannam@167 7814
cannam@167 7815 % Write a cross-reference definition for the current node. #1 is the
cannam@167 7816 % type (Ynumbered, Yappendix, Ynothing).
cannam@167 7817 %
cannam@167 7818 \def\donoderef#1{%
cannam@167 7819 \ifx\lastnode\empty\else
cannam@167 7820 \setref{\lastnode}{#1}%
cannam@167 7821 \global\let\lastnode=\empty
cannam@167 7822 \fi
cannam@167 7823 }
cannam@167 7824
cannam@167 7825 % @anchor{NAME} -- define xref target at arbitrary point.
cannam@167 7826 %
cannam@167 7827 \newcount\savesfregister
cannam@167 7828 %
cannam@167 7829 \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
cannam@167 7830 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
cannam@167 7831 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
cannam@167 7832
cannam@167 7833 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
cannam@167 7834 % anchor), which consists of three parts:
cannam@167 7835 % 1) NAME-title - the current sectioning name taken from \lastsection,
cannam@167 7836 % or the anchor name.
cannam@167 7837 % 2) NAME-snt - section number and type, passed as the SNT arg, or
cannam@167 7838 % empty for anchors.
cannam@167 7839 % 3) NAME-pg - the page number.
cannam@167 7840 %
cannam@167 7841 % This is called from \donoderef, \anchor, and \dofloat. In the case of
cannam@167 7842 % floats, there is an additional part, which is not written here:
cannam@167 7843 % 4) NAME-lof - the text as it should appear in a @listoffloats.
cannam@167 7844 %
cannam@167 7845 \def\setref#1#2{%
cannam@167 7846 \pdfmkdest{#1}%
cannam@167 7847 \iflinks
cannam@167 7848 {%
cannam@167 7849 \atdummies % preserve commands, but don't expand them
cannam@167 7850 \edef\writexrdef##1##2{%
cannam@167 7851 \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
cannam@167 7852 ##1}{##2}}% these are parameters of \writexrdef
cannam@167 7853 }%
cannam@167 7854 \toks0 = \expandafter{\lastsection}%
cannam@167 7855 \immediate \writexrdef{title}{\the\toks0 }%
cannam@167 7856 \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
cannam@167 7857 \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
cannam@167 7858 }%
cannam@167 7859 \fi
cannam@167 7860 }
cannam@167 7861
cannam@167 7862 % @xrefautosectiontitle on|off says whether @section(ing) names are used
cannam@167 7863 % automatically in xrefs, if the third arg is not explicitly specified.
cannam@167 7864 % This was provided as a "secret" @set xref-automatic-section-title
cannam@167 7865 % variable, now it's official.
cannam@167 7866 %
cannam@167 7867 \parseargdef\xrefautomaticsectiontitle{%
cannam@167 7868 \def\temp{#1}%
cannam@167 7869 \ifx\temp\onword
cannam@167 7870 \expandafter\let\csname SETxref-automatic-section-title\endcsname
cannam@167 7871 = \empty
cannam@167 7872 \else\ifx\temp\offword
cannam@167 7873 \expandafter\let\csname SETxref-automatic-section-title\endcsname
cannam@167 7874 = \relax
cannam@167 7875 \else
cannam@167 7876 \errhelp = \EMsimple
cannam@167 7877 \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
cannam@167 7878 must be on|off}%
cannam@167 7879 \fi\fi
cannam@167 7880 }
cannam@167 7881
cannam@167 7882 %
cannam@167 7883 % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
cannam@167 7884 % the node name, #2 the name of the Info cross-reference, #3 the printed
cannam@167 7885 % node name, #4 the name of the Info file, #5 the name of the printed
cannam@167 7886 % manual. All but the node name can be omitted.
cannam@167 7887 %
cannam@167 7888 \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
cannam@167 7889 \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
cannam@167 7890 \def\ref#1{\xrefX[#1,,,,,,,]}
cannam@167 7891 %
cannam@167 7892 \newbox\toprefbox
cannam@167 7893 \newbox\printedrefnamebox
cannam@167 7894 \newbox\infofilenamebox
cannam@167 7895 \newbox\printedmanualbox
cannam@167 7896 %
cannam@167 7897 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
cannam@167 7898 \unsepspaces
cannam@167 7899 %
cannam@167 7900 % Get args without leading/trailing spaces.
cannam@167 7901 \def\printedrefname{\ignorespaces #3}%
cannam@167 7902 \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
cannam@167 7903 %
cannam@167 7904 \def\infofilename{\ignorespaces #4}%
cannam@167 7905 \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
cannam@167 7906 %
cannam@167 7907 \def\printedmanual{\ignorespaces #5}%
cannam@167 7908 \setbox\printedmanualbox = \hbox{\printedmanual\unskip}%
cannam@167 7909 %
cannam@167 7910 % If the printed reference name (arg #3) was not explicitly given in
cannam@167 7911 % the @xref, figure out what we want to use.
cannam@167 7912 \ifdim \wd\printedrefnamebox = 0pt
cannam@167 7913 % No printed node name was explicitly given.
cannam@167 7914 \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
cannam@167 7915 % Not auto section-title: use node name inside the square brackets.
cannam@167 7916 \def\printedrefname{\ignorespaces #1}%
cannam@167 7917 \else
cannam@167 7918 % Auto section-title: use chapter/section title inside
cannam@167 7919 % the square brackets if we have it.
cannam@167 7920 \ifdim \wd\printedmanualbox > 0pt
cannam@167 7921 % It is in another manual, so we don't have it; use node name.
cannam@167 7922 \def\printedrefname{\ignorespaces #1}%
cannam@167 7923 \else
cannam@167 7924 \ifhavexrefs
cannam@167 7925 % We (should) know the real title if we have the xref values.
cannam@167 7926 \def\printedrefname{\refx{#1-title}{}}%
cannam@167 7927 \else
cannam@167 7928 % Otherwise just copy the Info node name.
cannam@167 7929 \def\printedrefname{\ignorespaces #1}%
cannam@167 7930 \fi%
cannam@167 7931 \fi
cannam@167 7932 \fi
cannam@167 7933 \fi
cannam@167 7934 %
cannam@167 7935 % Make link in pdf output.
cannam@167 7936 \ifpdf
cannam@167 7937 {\indexnofonts
cannam@167 7938 \turnoffactive
cannam@167 7939 \makevalueexpandable
cannam@167 7940 % This expands tokens, so do it after making catcode changes, so _
cannam@167 7941 % etc. don't get their TeX definitions. This ignores all spaces in
cannam@167 7942 % #4, including (wrongly) those in the middle of the filename.
cannam@167 7943 \getfilename{#4}%
cannam@167 7944 %
cannam@167 7945 % This (wrongly) does not take account of leading or trailing
cannam@167 7946 % spaces in #1, which should be ignored.
cannam@167 7947 \edef\pdfxrefdest{#1}%
cannam@167 7948 \ifx\pdfxrefdest\empty
cannam@167 7949 \def\pdfxrefdest{Top}% no empty targets
cannam@167 7950 \else
cannam@167 7951 \txiescapepdf\pdfxrefdest % escape PDF special chars
cannam@167 7952 \fi
cannam@167 7953 %
cannam@167 7954 \leavevmode
cannam@167 7955 \startlink attr{/Border [0 0 0]}%
cannam@167 7956 \ifnum\filenamelength>0
cannam@167 7957 goto file{\the\filename.pdf} name{\pdfxrefdest}%
cannam@167 7958 \else
cannam@167 7959 goto name{\pdfmkpgn{\pdfxrefdest}}%
cannam@167 7960 \fi
cannam@167 7961 }%
cannam@167 7962 \setcolor{\linkcolor}%
cannam@167 7963 \fi
cannam@167 7964 %
cannam@167 7965 % Float references are printed completely differently: "Figure 1.2"
cannam@167 7966 % instead of "[somenode], p.3". We distinguish them by the
cannam@167 7967 % LABEL-title being set to a magic string.
cannam@167 7968 {%
cannam@167 7969 % Have to otherify everything special to allow the \csname to
cannam@167 7970 % include an _ in the xref name, etc.
cannam@167 7971 \indexnofonts
cannam@167 7972 \turnoffactive
cannam@167 7973 \expandafter\global\expandafter\let\expandafter\Xthisreftitle
cannam@167 7974 \csname XR#1-title\endcsname
cannam@167 7975 }%
cannam@167 7976 \iffloat\Xthisreftitle
cannam@167 7977 % If the user specified the print name (third arg) to the ref,
cannam@167 7978 % print it instead of our usual "Figure 1.2".
cannam@167 7979 \ifdim\wd\printedrefnamebox = 0pt
cannam@167 7980 \refx{#1-snt}{}%
cannam@167 7981 \else
cannam@167 7982 \printedrefname
cannam@167 7983 \fi
cannam@167 7984 %
cannam@167 7985 % If the user also gave the printed manual name (fifth arg), append
cannam@167 7986 % "in MANUALNAME".
cannam@167 7987 \ifdim \wd\printedmanualbox > 0pt
cannam@167 7988 \space \putwordin{} \cite{\printedmanual}%
cannam@167 7989 \fi
cannam@167 7990 \else
cannam@167 7991 % node/anchor (non-float) references.
cannam@167 7992 %
cannam@167 7993 % If we use \unhbox to print the node names, TeX does not insert
cannam@167 7994 % empty discretionaries after hyphens, which means that it will not
cannam@167 7995 % find a line break at a hyphen in a node names. Since some manuals
cannam@167 7996 % are best written with fairly long node names, containing hyphens,
cannam@167 7997 % this is a loss. Therefore, we give the text of the node name
cannam@167 7998 % again, so it is as if TeX is seeing it for the first time.
cannam@167 7999 %
cannam@167 8000 \ifdim \wd\printedmanualbox > 0pt
cannam@167 8001 % Cross-manual reference with a printed manual name.
cannam@167 8002 %
cannam@167 8003 \crossmanualxref{\cite{\printedmanual\unskip}}%
cannam@167 8004 %
cannam@167 8005 \else\ifdim \wd\infofilenamebox > 0pt
cannam@167 8006 % Cross-manual reference with only an info filename (arg 4), no
cannam@167 8007 % printed manual name (arg 5). This is essentially the same as
cannam@167 8008 % the case above; we output the filename, since we have nothing else.
cannam@167 8009 %
cannam@167 8010 \crossmanualxref{\code{\infofilename\unskip}}%
cannam@167 8011 %
cannam@167 8012 \else
cannam@167 8013 % Reference within this manual.
cannam@167 8014 %
cannam@167 8015 % _ (for example) has to be the character _ for the purposes of the
cannam@167 8016 % control sequence corresponding to the node, but it has to expand
cannam@167 8017 % into the usual \leavevmode...\vrule stuff for purposes of
cannam@167 8018 % printing. So we \turnoffactive for the \refx-snt, back on for the
cannam@167 8019 % printing, back off for the \refx-pg.
cannam@167 8020 {\turnoffactive
cannam@167 8021 % Only output a following space if the -snt ref is nonempty; for
cannam@167 8022 % @unnumbered and @anchor, it won't be.
cannam@167 8023 \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
cannam@167 8024 \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
cannam@167 8025 }%
cannam@167 8026 % output the `[mynode]' via the macro below so it can be overridden.
cannam@167 8027 \xrefprintnodename\printedrefname
cannam@167 8028 %
cannam@167 8029 % But we always want a comma and a space:
cannam@167 8030 ,\space
cannam@167 8031 %
cannam@167 8032 % output the `page 3'.
cannam@167 8033 \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
cannam@167 8034 \fi\fi
cannam@167 8035 \fi
cannam@167 8036 \endlink
cannam@167 8037 \endgroup}
cannam@167 8038
cannam@167 8039 % Output a cross-manual xref to #1. Used just above (twice).
cannam@167 8040 %
cannam@167 8041 % Only include the text "Section ``foo'' in" if the foo is neither
cannam@167 8042 % missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply
cannam@167 8043 % "see The Foo Manual", the idea being to refer to the whole manual.
cannam@167 8044 %
cannam@167 8045 % But, this being TeX, we can't easily compare our node name against the
cannam@167 8046 % string "Top" while ignoring the possible spaces before and after in
cannam@167 8047 % the input. By adding the arbitrary 7sp below, we make it much less
cannam@167 8048 % likely that a real node name would have the same width as "Top" (e.g.,
cannam@167 8049 % in a monospaced font). Hopefully it will never happen in practice.
cannam@167 8050 %
cannam@167 8051 % For the same basic reason, we retypeset the "Top" at every
cannam@167 8052 % reference, since the current font is indeterminate.
cannam@167 8053 %
cannam@167 8054 \def\crossmanualxref#1{%
cannam@167 8055 \setbox\toprefbox = \hbox{Top\kern7sp}%
cannam@167 8056 \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
cannam@167 8057 \ifdim \wd2 > 7sp % nonempty?
cannam@167 8058 \ifdim \wd2 = \wd\toprefbox \else % same as Top?
cannam@167 8059 \putwordSection{} ``\printedrefname'' \putwordin{}\space
cannam@167 8060 \fi
cannam@167 8061 \fi
cannam@167 8062 #1%
cannam@167 8063 }
cannam@167 8064
cannam@167 8065 % This macro is called from \xrefX for the `[nodename]' part of xref
cannam@167 8066 % output. It's a separate macro only so it can be changed more easily,
cannam@167 8067 % since square brackets don't work well in some documents. Particularly
cannam@167 8068 % one that Bob is working on :).
cannam@167 8069 %
cannam@167 8070 \def\xrefprintnodename#1{[#1]}
cannam@167 8071
cannam@167 8072 % Things referred to by \setref.
cannam@167 8073 %
cannam@167 8074 \def\Ynothing{}
cannam@167 8075 \def\Yomitfromtoc{}
cannam@167 8076 \def\Ynumbered{%
cannam@167 8077 \ifnum\secno=0
cannam@167 8078 \putwordChapter@tie \the\chapno
cannam@167 8079 \else \ifnum\subsecno=0
cannam@167 8080 \putwordSection@tie \the\chapno.\the\secno
cannam@167 8081 \else \ifnum\subsubsecno=0
cannam@167 8082 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
cannam@167 8083 \else
cannam@167 8084 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
cannam@167 8085 \fi\fi\fi
cannam@167 8086 }
cannam@167 8087 \def\Yappendix{%
cannam@167 8088 \ifnum\secno=0
cannam@167 8089 \putwordAppendix@tie @char\the\appendixno{}%
cannam@167 8090 \else \ifnum\subsecno=0
cannam@167 8091 \putwordSection@tie @char\the\appendixno.\the\secno
cannam@167 8092 \else \ifnum\subsubsecno=0
cannam@167 8093 \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
cannam@167 8094 \else
cannam@167 8095 \putwordSection@tie
cannam@167 8096 @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
cannam@167 8097 \fi\fi\fi
cannam@167 8098 }
cannam@167 8099
cannam@167 8100 % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
cannam@167 8101 % If its value is nonempty, SUFFIX is output afterward.
cannam@167 8102 %
cannam@167 8103 \def\refx#1#2{%
cannam@167 8104 {%
cannam@167 8105 \indexnofonts
cannam@167 8106 \otherbackslash
cannam@167 8107 \expandafter\global\expandafter\let\expandafter\thisrefX
cannam@167 8108 \csname XR#1\endcsname
cannam@167 8109 }%
cannam@167 8110 \ifx\thisrefX\relax
cannam@167 8111 % If not defined, say something at least.
cannam@167 8112 \angleleft un\-de\-fined\angleright
cannam@167 8113 \iflinks
cannam@167 8114 \ifhavexrefs
cannam@167 8115 {\toks0 = {#1}% avoid expansion of possibly-complex value
cannam@167 8116 \message{\linenumber Undefined cross reference `\the\toks0'.}}%
cannam@167 8117 \else
cannam@167 8118 \ifwarnedxrefs\else
cannam@167 8119 \global\warnedxrefstrue
cannam@167 8120 \message{Cross reference values unknown; you must run TeX again.}%
cannam@167 8121 \fi
cannam@167 8122 \fi
cannam@167 8123 \fi
cannam@167 8124 \else
cannam@167 8125 % It's defined, so just use it.
cannam@167 8126 \thisrefX
cannam@167 8127 \fi
cannam@167 8128 #2% Output the suffix in any case.
cannam@167 8129 }
cannam@167 8130
cannam@167 8131 % This is the macro invoked by entries in the aux file. Usually it's
cannam@167 8132 % just a \def (we prepend XR to the control sequence name to avoid
cannam@167 8133 % collisions). But if this is a float type, we have more work to do.
cannam@167 8134 %
cannam@167 8135 \def\xrdef#1#2{%
cannam@167 8136 {% The node name might contain 8-bit characters, which in our current
cannam@167 8137 % implementation are changed to commands like @'e. Don't let these
cannam@167 8138 % mess up the control sequence name.
cannam@167 8139 \indexnofonts
cannam@167 8140 \turnoffactive
cannam@167 8141 \xdef\safexrefname{#1}%
cannam@167 8142 }%
cannam@167 8143 %
cannam@167 8144 \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref
cannam@167 8145 %
cannam@167 8146 % Was that xref control sequence that we just defined for a float?
cannam@167 8147 \expandafter\iffloat\csname XR\safexrefname\endcsname
cannam@167 8148 % it was a float, and we have the (safe) float type in \iffloattype.
cannam@167 8149 \expandafter\let\expandafter\floatlist
cannam@167 8150 \csname floatlist\iffloattype\endcsname
cannam@167 8151 %
cannam@167 8152 % Is this the first time we've seen this float type?
cannam@167 8153 \expandafter\ifx\floatlist\relax
cannam@167 8154 \toks0 = {\do}% yes, so just \do
cannam@167 8155 \else
cannam@167 8156 % had it before, so preserve previous elements in list.
cannam@167 8157 \toks0 = \expandafter{\floatlist\do}%
cannam@167 8158 \fi
cannam@167 8159 %
cannam@167 8160 % Remember this xref in the control sequence \floatlistFLOATTYPE,
cannam@167 8161 % for later use in \listoffloats.
cannam@167 8162 \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
cannam@167 8163 {\safexrefname}}%
cannam@167 8164 \fi
cannam@167 8165 }
cannam@167 8166
cannam@167 8167 % Read the last existing aux file, if any. No error if none exists.
cannam@167 8168 %
cannam@167 8169 \def\tryauxfile{%
cannam@167 8170 \openin 1 \jobname.aux
cannam@167 8171 \ifeof 1 \else
cannam@167 8172 \readdatafile{aux}%
cannam@167 8173 \global\havexrefstrue
cannam@167 8174 \fi
cannam@167 8175 \closein 1
cannam@167 8176 }
cannam@167 8177
cannam@167 8178 \def\setupdatafile{%
cannam@167 8179 \catcode`\^^@=\other
cannam@167 8180 \catcode`\^^A=\other
cannam@167 8181 \catcode`\^^B=\other
cannam@167 8182 \catcode`\^^C=\other
cannam@167 8183 \catcode`\^^D=\other
cannam@167 8184 \catcode`\^^E=\other
cannam@167 8185 \catcode`\^^F=\other
cannam@167 8186 \catcode`\^^G=\other
cannam@167 8187 \catcode`\^^H=\other
cannam@167 8188 \catcode`\^^K=\other
cannam@167 8189 \catcode`\^^L=\other
cannam@167 8190 \catcode`\^^N=\other
cannam@167 8191 \catcode`\^^P=\other
cannam@167 8192 \catcode`\^^Q=\other
cannam@167 8193 \catcode`\^^R=\other
cannam@167 8194 \catcode`\^^S=\other
cannam@167 8195 \catcode`\^^T=\other
cannam@167 8196 \catcode`\^^U=\other
cannam@167 8197 \catcode`\^^V=\other
cannam@167 8198 \catcode`\^^W=\other
cannam@167 8199 \catcode`\^^X=\other
cannam@167 8200 \catcode`\^^Z=\other
cannam@167 8201 \catcode`\^^[=\other
cannam@167 8202 \catcode`\^^\=\other
cannam@167 8203 \catcode`\^^]=\other
cannam@167 8204 \catcode`\^^^=\other
cannam@167 8205 \catcode`\^^_=\other
cannam@167 8206 % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
cannam@167 8207 % in xref tags, i.e., node names. But since ^^e4 notation isn't
cannam@167 8208 % supported in the main text, it doesn't seem desirable. Furthermore,
cannam@167 8209 % that is not enough: for node names that actually contain a ^
cannam@167 8210 % character, we would end up writing a line like this: 'xrdef {'hat
cannam@167 8211 % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
cannam@167 8212 % argument, and \hat is not an expandable control sequence. It could
cannam@167 8213 % all be worked out, but why? Either we support ^^ or we don't.
cannam@167 8214 %
cannam@167 8215 % The other change necessary for this was to define \auxhat:
cannam@167 8216 % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
cannam@167 8217 % and then to call \auxhat in \setq.
cannam@167 8218 %
cannam@167 8219 \catcode`\^=\other
cannam@167 8220 %
cannam@167 8221 % Special characters. Should be turned off anyway, but...
cannam@167 8222 \catcode`\~=\other
cannam@167 8223 \catcode`\[=\other
cannam@167 8224 \catcode`\]=\other
cannam@167 8225 \catcode`\"=\other
cannam@167 8226 \catcode`\_=\other
cannam@167 8227 \catcode`\|=\other
cannam@167 8228 \catcode`\<=\other
cannam@167 8229 \catcode`\>=\other
cannam@167 8230 \catcode`\$=\other
cannam@167 8231 \catcode`\#=\other
cannam@167 8232 \catcode`\&=\other
cannam@167 8233 \catcode`\%=\other
cannam@167 8234 \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
cannam@167 8235 %
cannam@167 8236 % This is to support \ in node names and titles, since the \
cannam@167 8237 % characters end up in a \csname. It's easier than
cannam@167 8238 % leaving it active and making its active definition an actual \
cannam@167 8239 % character. What I don't understand is why it works in the *value*
cannam@167 8240 % of the xrdef. Seems like it should be a catcode12 \, and that
cannam@167 8241 % should not typeset properly. But it works, so I'm moving on for
cannam@167 8242 % now. --karl, 15jan04.
cannam@167 8243 \catcode`\\=\other
cannam@167 8244 %
cannam@167 8245 % Make the characters 128-255 be printing characters.
cannam@167 8246 {%
cannam@167 8247 \count1=128
cannam@167 8248 \def\loop{%
cannam@167 8249 \catcode\count1=\other
cannam@167 8250 \advance\count1 by 1
cannam@167 8251 \ifnum \count1<256 \loop \fi
cannam@167 8252 }%
cannam@167 8253 }%
cannam@167 8254 %
cannam@167 8255 % @ is our escape character in .aux files, and we need braces.
cannam@167 8256 \catcode`\{=1
cannam@167 8257 \catcode`\}=2
cannam@167 8258 \catcode`\@=0
cannam@167 8259 }
cannam@167 8260
cannam@167 8261 \def\readdatafile#1{%
cannam@167 8262 \begingroup
cannam@167 8263 \setupdatafile
cannam@167 8264 \input\jobname.#1
cannam@167 8265 \endgroup}
cannam@167 8266
cannam@167 8267
cannam@167 8268 \message{insertions,}
cannam@167 8269 % including footnotes.
cannam@167 8270
cannam@167 8271 \newcount \footnoteno
cannam@167 8272
cannam@167 8273 % The trailing space in the following definition for supereject is
cannam@167 8274 % vital for proper filling; pages come out unaligned when you do a
cannam@167 8275 % pagealignmacro call if that space before the closing brace is
cannam@167 8276 % removed. (Generally, numeric constants should always be followed by a
cannam@167 8277 % space to prevent strange expansion errors.)
cannam@167 8278 \def\supereject{\par\penalty -20000\footnoteno =0 }
cannam@167 8279
cannam@167 8280 % @footnotestyle is meaningful for Info output only.
cannam@167 8281 \let\footnotestyle=\comment
cannam@167 8282
cannam@167 8283 {\catcode `\@=11
cannam@167 8284 %
cannam@167 8285 % Auto-number footnotes. Otherwise like plain.
cannam@167 8286 \gdef\footnote{%
cannam@167 8287 \let\indent=\ptexindent
cannam@167 8288 \let\noindent=\ptexnoindent
cannam@167 8289 \global\advance\footnoteno by \@ne
cannam@167 8290 \edef\thisfootno{$^{\the\footnoteno}$}%
cannam@167 8291 %
cannam@167 8292 % In case the footnote comes at the end of a sentence, preserve the
cannam@167 8293 % extra spacing after we do the footnote number.
cannam@167 8294 \let\@sf\empty
cannam@167 8295 \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
cannam@167 8296 %
cannam@167 8297 % Remove inadvertent blank space before typesetting the footnote number.
cannam@167 8298 \unskip
cannam@167 8299 \thisfootno\@sf
cannam@167 8300 \dofootnote
cannam@167 8301 }%
cannam@167 8302
cannam@167 8303 % Don't bother with the trickery in plain.tex to not require the
cannam@167 8304 % footnote text as a parameter. Our footnotes don't need to be so general.
cannam@167 8305 %
cannam@167 8306 % Oh yes, they do; otherwise, @ifset (and anything else that uses
cannam@167 8307 % \parseargline) fails inside footnotes because the tokens are fixed when
cannam@167 8308 % the footnote is read. --karl, 16nov96.
cannam@167 8309 %
cannam@167 8310 \gdef\dofootnote{%
cannam@167 8311 \insert\footins\bgroup
cannam@167 8312 % We want to typeset this text as a normal paragraph, even if the
cannam@167 8313 % footnote reference occurs in (for example) a display environment.
cannam@167 8314 % So reset some parameters.
cannam@167 8315 \hsize=\pagewidth
cannam@167 8316 \interlinepenalty\interfootnotelinepenalty
cannam@167 8317 \splittopskip\ht\strutbox % top baseline for broken footnotes
cannam@167 8318 \splitmaxdepth\dp\strutbox
cannam@167 8319 \floatingpenalty\@MM
cannam@167 8320 \leftskip\z@skip
cannam@167 8321 \rightskip\z@skip
cannam@167 8322 \spaceskip\z@skip
cannam@167 8323 \xspaceskip\z@skip
cannam@167 8324 \parindent\defaultparindent
cannam@167 8325 %
cannam@167 8326 \smallfonts \rm
cannam@167 8327 %
cannam@167 8328 % Because we use hanging indentation in footnotes, a @noindent appears
cannam@167 8329 % to exdent this text, so make it be a no-op. makeinfo does not use
cannam@167 8330 % hanging indentation so @noindent can still be needed within footnote
cannam@167 8331 % text after an @example or the like (not that this is good style).
cannam@167 8332 \let\noindent = \relax
cannam@167 8333 %
cannam@167 8334 % Hang the footnote text off the number. Use \everypar in case the
cannam@167 8335 % footnote extends for more than one paragraph.
cannam@167 8336 \everypar = {\hang}%
cannam@167 8337 \textindent{\thisfootno}%
cannam@167 8338 %
cannam@167 8339 % Don't crash into the line above the footnote text. Since this
cannam@167 8340 % expands into a box, it must come within the paragraph, lest it
cannam@167 8341 % provide a place where TeX can split the footnote.
cannam@167 8342 \footstrut
cannam@167 8343 %
cannam@167 8344 % Invoke rest of plain TeX footnote routine.
cannam@167 8345 \futurelet\next\fo@t
cannam@167 8346 }
cannam@167 8347 }%end \catcode `\@=11
cannam@167 8348
cannam@167 8349 % In case a @footnote appears in a vbox, save the footnote text and create
cannam@167 8350 % the real \insert just after the vbox finished. Otherwise, the insertion
cannam@167 8351 % would be lost.
cannam@167 8352 % Similarly, if a @footnote appears inside an alignment, save the footnote
cannam@167 8353 % text to a box and make the \insert when a row of the table is finished.
cannam@167 8354 % And the same can be done for other insert classes. --kasal, 16nov03.
cannam@167 8355
cannam@167 8356 % Replace the \insert primitive by a cheating macro.
cannam@167 8357 % Deeper inside, just make sure that the saved insertions are not spilled
cannam@167 8358 % out prematurely.
cannam@167 8359 %
cannam@167 8360 \def\startsavinginserts{%
cannam@167 8361 \ifx \insert\ptexinsert
cannam@167 8362 \let\insert\saveinsert
cannam@167 8363 \else
cannam@167 8364 \let\checkinserts\relax
cannam@167 8365 \fi
cannam@167 8366 }
cannam@167 8367
cannam@167 8368 % This \insert replacement works for both \insert\footins{foo} and
cannam@167 8369 % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
cannam@167 8370 %
cannam@167 8371 \def\saveinsert#1{%
cannam@167 8372 \edef\next{\noexpand\savetobox \makeSAVEname#1}%
cannam@167 8373 \afterassignment\next
cannam@167 8374 % swallow the left brace
cannam@167 8375 \let\temp =
cannam@167 8376 }
cannam@167 8377 \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
cannam@167 8378 \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
cannam@167 8379
cannam@167 8380 \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
cannam@167 8381
cannam@167 8382 \def\placesaveins#1{%
cannam@167 8383 \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
cannam@167 8384 {\box#1}%
cannam@167 8385 }
cannam@167 8386
cannam@167 8387 % eat @SAVE -- beware, all of them have catcode \other:
cannam@167 8388 {
cannam@167 8389 \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-)
cannam@167 8390 \gdef\gobblesave @SAVE{}
cannam@167 8391 }
cannam@167 8392
cannam@167 8393 % initialization:
cannam@167 8394 \def\newsaveins #1{%
cannam@167 8395 \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
cannam@167 8396 \next
cannam@167 8397 }
cannam@167 8398 \def\newsaveinsX #1{%
cannam@167 8399 \csname newbox\endcsname #1%
cannam@167 8400 \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
cannam@167 8401 \checksaveins #1}%
cannam@167 8402 }
cannam@167 8403
cannam@167 8404 % initialize:
cannam@167 8405 \let\checkinserts\empty
cannam@167 8406 \newsaveins\footins
cannam@167 8407 \newsaveins\margin
cannam@167 8408
cannam@167 8409
cannam@167 8410 % @image. We use the macros from epsf.tex to support this.
cannam@167 8411 % If epsf.tex is not installed and @image is used, we complain.
cannam@167 8412 %
cannam@167 8413 % Check for and read epsf.tex up front. If we read it only at @image
cannam@167 8414 % time, we might be inside a group, and then its definitions would get
cannam@167 8415 % undone and the next image would fail.
cannam@167 8416 \openin 1 = epsf.tex
cannam@167 8417 \ifeof 1 \else
cannam@167 8418 % Do not bother showing banner with epsf.tex v2.7k (available in
cannam@167 8419 % doc/epsf.tex and on ctan).
cannam@167 8420 \def\epsfannounce{\toks0 = }%
cannam@167 8421 \input epsf.tex
cannam@167 8422 \fi
cannam@167 8423 \closein 1
cannam@167 8424 %
cannam@167 8425 % We will only complain once about lack of epsf.tex.
cannam@167 8426 \newif\ifwarnednoepsf
cannam@167 8427 \newhelp\noepsfhelp{epsf.tex must be installed for images to
cannam@167 8428 work. It is also included in the Texinfo distribution, or you can get
cannam@167 8429 it from ftp://tug.org/tex/epsf.tex.}
cannam@167 8430 %
cannam@167 8431 \def\image#1{%
cannam@167 8432 \ifx\epsfbox\thisisundefined
cannam@167 8433 \ifwarnednoepsf \else
cannam@167 8434 \errhelp = \noepsfhelp
cannam@167 8435 \errmessage{epsf.tex not found, images will be ignored}%
cannam@167 8436 \global\warnednoepsftrue
cannam@167 8437 \fi
cannam@167 8438 \else
cannam@167 8439 \imagexxx #1,,,,,\finish
cannam@167 8440 \fi
cannam@167 8441 }
cannam@167 8442 %
cannam@167 8443 % Arguments to @image:
cannam@167 8444 % #1 is (mandatory) image filename; we tack on .eps extension.
cannam@167 8445 % #2 is (optional) width, #3 is (optional) height.
cannam@167 8446 % #4 is (ignored optional) html alt text.
cannam@167 8447 % #5 is (ignored optional) extension.
cannam@167 8448 % #6 is just the usual extra ignored arg for parsing stuff.
cannam@167 8449 \newif\ifimagevmode
cannam@167 8450 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
cannam@167 8451 \catcode`\^^M = 5 % in case we're inside an example
cannam@167 8452 \normalturnoffactive % allow _ et al. in names
cannam@167 8453 % If the image is by itself, center it.
cannam@167 8454 \ifvmode
cannam@167 8455 \imagevmodetrue
cannam@167 8456 \else \ifx\centersub\centerV
cannam@167 8457 % for @center @image, we need a vbox so we can have our vertical space
cannam@167 8458 \imagevmodetrue
cannam@167 8459 \vbox\bgroup % vbox has better behavior than vtop herev
cannam@167 8460 \fi\fi
cannam@167 8461 %
cannam@167 8462 \ifimagevmode
cannam@167 8463 \nobreak\medskip
cannam@167 8464 % Usually we'll have text after the image which will insert
cannam@167 8465 % \parskip glue, so insert it here too to equalize the space
cannam@167 8466 % above and below.
cannam@167 8467 \nobreak\vskip\parskip
cannam@167 8468 \nobreak
cannam@167 8469 \fi
cannam@167 8470 %
cannam@167 8471 % Leave vertical mode so that indentation from an enclosing
cannam@167 8472 % environment such as @quotation is respected.
cannam@167 8473 % However, if we're at the top level, we don't want the
cannam@167 8474 % normal paragraph indentation.
cannam@167 8475 % On the other hand, if we are in the case of @center @image, we don't
cannam@167 8476 % want to start a paragraph, which will create a hsize-width box and
cannam@167 8477 % eradicate the centering.
cannam@167 8478 \ifx\centersub\centerV\else \noindent \fi
cannam@167 8479 %
cannam@167 8480 % Output the image.
cannam@167 8481 \ifpdf
cannam@167 8482 \dopdfimage{#1}{#2}{#3}%
cannam@167 8483 \else
cannam@167 8484 % \epsfbox itself resets \epsf?size at each figure.
cannam@167 8485 \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
cannam@167 8486 \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
cannam@167 8487 \epsfbox{#1.eps}%
cannam@167 8488 \fi
cannam@167 8489 %
cannam@167 8490 \ifimagevmode
cannam@167 8491 \medskip % space after a standalone image
cannam@167 8492 \fi
cannam@167 8493 \ifx\centersub\centerV \egroup \fi
cannam@167 8494 \endgroup}
cannam@167 8495
cannam@167 8496
cannam@167 8497 % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
cannam@167 8498 % etc. We don't actually implement floating yet, we always include the
cannam@167 8499 % float "here". But it seemed the best name for the future.
cannam@167 8500 %
cannam@167 8501 \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
cannam@167 8502
cannam@167 8503 % There may be a space before second and/or third parameter; delete it.
cannam@167 8504 \def\eatcommaspace#1, {#1,}
cannam@167 8505
cannam@167 8506 % #1 is the optional FLOATTYPE, the text label for this float, typically
cannam@167 8507 % "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
cannam@167 8508 % this float will not be numbered and cannot be referred to.
cannam@167 8509 %
cannam@167 8510 % #2 is the optional xref label. Also must be present for the float to
cannam@167 8511 % be referable.
cannam@167 8512 %
cannam@167 8513 % #3 is the optional positioning argument; for now, it is ignored. It
cannam@167 8514 % will somehow specify the positions allowed to float to (here, top, bottom).
cannam@167 8515 %
cannam@167 8516 % We keep a separate counter for each FLOATTYPE, which we reset at each
cannam@167 8517 % chapter-level command.
cannam@167 8518 \let\resetallfloatnos=\empty
cannam@167 8519 %
cannam@167 8520 \def\dofloat#1,#2,#3,#4\finish{%
cannam@167 8521 \let\thiscaption=\empty
cannam@167 8522 \let\thisshortcaption=\empty
cannam@167 8523 %
cannam@167 8524 % don't lose footnotes inside @float.
cannam@167 8525 %
cannam@167 8526 % BEWARE: when the floats start float, we have to issue warning whenever an
cannam@167 8527 % insert appears inside a float which could possibly float. --kasal, 26may04
cannam@167 8528 %
cannam@167 8529 \startsavinginserts
cannam@167 8530 %
cannam@167 8531 % We can't be used inside a paragraph.
cannam@167 8532 \par
cannam@167 8533 %
cannam@167 8534 \vtop\bgroup
cannam@167 8535 \def\floattype{#1}%
cannam@167 8536 \def\floatlabel{#2}%
cannam@167 8537 \def\floatloc{#3}% we do nothing with this yet.
cannam@167 8538 %
cannam@167 8539 \ifx\floattype\empty
cannam@167 8540 \let\safefloattype=\empty
cannam@167 8541 \else
cannam@167 8542 {%
cannam@167 8543 % the floattype might have accents or other special characters,
cannam@167 8544 % but we need to use it in a control sequence name.
cannam@167 8545 \indexnofonts
cannam@167 8546 \turnoffactive
cannam@167 8547 \xdef\safefloattype{\floattype}%
cannam@167 8548 }%
cannam@167 8549 \fi
cannam@167 8550 %
cannam@167 8551 % If label is given but no type, we handle that as the empty type.
cannam@167 8552 \ifx\floatlabel\empty \else
cannam@167 8553 % We want each FLOATTYPE to be numbered separately (Figure 1,
cannam@167 8554 % Table 1, Figure 2, ...). (And if no label, no number.)
cannam@167 8555 %
cannam@167 8556 \expandafter\getfloatno\csname\safefloattype floatno\endcsname
cannam@167 8557 \global\advance\floatno by 1
cannam@167 8558 %
cannam@167 8559 {%
cannam@167 8560 % This magic value for \lastsection is output by \setref as the
cannam@167 8561 % XREFLABEL-title value. \xrefX uses it to distinguish float
cannam@167 8562 % labels (which have a completely different output format) from
cannam@167 8563 % node and anchor labels. And \xrdef uses it to construct the
cannam@167 8564 % lists of floats.
cannam@167 8565 %
cannam@167 8566 \edef\lastsection{\floatmagic=\safefloattype}%
cannam@167 8567 \setref{\floatlabel}{Yfloat}%
cannam@167 8568 }%
cannam@167 8569 \fi
cannam@167 8570 %
cannam@167 8571 % start with \parskip glue, I guess.
cannam@167 8572 \vskip\parskip
cannam@167 8573 %
cannam@167 8574 % Don't suppress indentation if a float happens to start a section.
cannam@167 8575 \restorefirstparagraphindent
cannam@167 8576 }
cannam@167 8577
cannam@167 8578 % we have these possibilities:
cannam@167 8579 % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
cannam@167 8580 % @float Foo,lbl & no caption: Foo 1.1
cannam@167 8581 % @float Foo & @caption{Cap}: Foo: Cap
cannam@167 8582 % @float Foo & no caption: Foo
cannam@167 8583 % @float ,lbl & Caption{Cap}: 1.1: Cap
cannam@167 8584 % @float ,lbl & no caption: 1.1
cannam@167 8585 % @float & @caption{Cap}: Cap
cannam@167 8586 % @float & no caption:
cannam@167 8587 %
cannam@167 8588 \def\Efloat{%
cannam@167 8589 \let\floatident = \empty
cannam@167 8590 %
cannam@167 8591 % In all cases, if we have a float type, it comes first.
cannam@167 8592 \ifx\floattype\empty \else \def\floatident{\floattype}\fi
cannam@167 8593 %
cannam@167 8594 % If we have an xref label, the number comes next.
cannam@167 8595 \ifx\floatlabel\empty \else
cannam@167 8596 \ifx\floattype\empty \else % if also had float type, need tie first.
cannam@167 8597 \appendtomacro\floatident{\tie}%
cannam@167 8598 \fi
cannam@167 8599 % the number.
cannam@167 8600 \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
cannam@167 8601 \fi
cannam@167 8602 %
cannam@167 8603 % Start the printed caption with what we've constructed in
cannam@167 8604 % \floatident, but keep it separate; we need \floatident again.
cannam@167 8605 \let\captionline = \floatident
cannam@167 8606 %
cannam@167 8607 \ifx\thiscaption\empty \else
cannam@167 8608 \ifx\floatident\empty \else
cannam@167 8609 \appendtomacro\captionline{: }% had ident, so need a colon between
cannam@167 8610 \fi
cannam@167 8611 %
cannam@167 8612 % caption text.
cannam@167 8613 \appendtomacro\captionline{\scanexp\thiscaption}%
cannam@167 8614 \fi
cannam@167 8615 %
cannam@167 8616 % If we have anything to print, print it, with space before.
cannam@167 8617 % Eventually this needs to become an \insert.
cannam@167 8618 \ifx\captionline\empty \else
cannam@167 8619 \vskip.5\parskip
cannam@167 8620 \captionline
cannam@167 8621 %
cannam@167 8622 % Space below caption.
cannam@167 8623 \vskip\parskip
cannam@167 8624 \fi
cannam@167 8625 %
cannam@167 8626 % If have an xref label, write the list of floats info. Do this
cannam@167 8627 % after the caption, to avoid chance of it being a breakpoint.
cannam@167 8628 \ifx\floatlabel\empty \else
cannam@167 8629 % Write the text that goes in the lof to the aux file as
cannam@167 8630 % \floatlabel-lof. Besides \floatident, we include the short
cannam@167 8631 % caption if specified, else the full caption if specified, else nothing.
cannam@167 8632 {%
cannam@167 8633 \atdummies
cannam@167 8634 %
cannam@167 8635 % since we read the caption text in the macro world, where ^^M
cannam@167 8636 % is turned into a normal character, we have to scan it back, so
cannam@167 8637 % we don't write the literal three characters "^^M" into the aux file.
cannam@167 8638 \scanexp{%
cannam@167 8639 \xdef\noexpand\gtemp{%
cannam@167 8640 \ifx\thisshortcaption\empty
cannam@167 8641 \thiscaption
cannam@167 8642 \else
cannam@167 8643 \thisshortcaption
cannam@167 8644 \fi
cannam@167 8645 }%
cannam@167 8646 }%
cannam@167 8647 \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
cannam@167 8648 \ifx\gtemp\empty \else : \gtemp \fi}}%
cannam@167 8649 }%
cannam@167 8650 \fi
cannam@167 8651 \egroup % end of \vtop
cannam@167 8652 %
cannam@167 8653 % place the captured inserts
cannam@167 8654 %
cannam@167 8655 % BEWARE: when the floats start floating, we have to issue warning
cannam@167 8656 % whenever an insert appears inside a float which could possibly
cannam@167 8657 % float. --kasal, 26may04
cannam@167 8658 %
cannam@167 8659 \checkinserts
cannam@167 8660 }
cannam@167 8661
cannam@167 8662 % Append the tokens #2 to the definition of macro #1, not expanding either.
cannam@167 8663 %
cannam@167 8664 \def\appendtomacro#1#2{%
cannam@167 8665 \expandafter\def\expandafter#1\expandafter{#1#2}%
cannam@167 8666 }
cannam@167 8667
cannam@167 8668 % @caption, @shortcaption
cannam@167 8669 %
cannam@167 8670 \def\caption{\docaption\thiscaption}
cannam@167 8671 \def\shortcaption{\docaption\thisshortcaption}
cannam@167 8672 \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
cannam@167 8673 \def\defcaption#1#2{\egroup \def#1{#2}}
cannam@167 8674
cannam@167 8675 % The parameter is the control sequence identifying the counter we are
cannam@167 8676 % going to use. Create it if it doesn't exist and assign it to \floatno.
cannam@167 8677 \def\getfloatno#1{%
cannam@167 8678 \ifx#1\relax
cannam@167 8679 % Haven't seen this figure type before.
cannam@167 8680 \csname newcount\endcsname #1%
cannam@167 8681 %
cannam@167 8682 % Remember to reset this floatno at the next chap.
cannam@167 8683 \expandafter\gdef\expandafter\resetallfloatnos
cannam@167 8684 \expandafter{\resetallfloatnos #1=0 }%
cannam@167 8685 \fi
cannam@167 8686 \let\floatno#1%
cannam@167 8687 }
cannam@167 8688
cannam@167 8689 % \setref calls this to get the XREFLABEL-snt value. We want an @xref
cannam@167 8690 % to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
cannam@167 8691 % first read the @float command.
cannam@167 8692 %
cannam@167 8693 \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
cannam@167 8694
cannam@167 8695 % Magic string used for the XREFLABEL-title value, so \xrefX can
cannam@167 8696 % distinguish floats from other xref types.
cannam@167 8697 \def\floatmagic{!!float!!}
cannam@167 8698
cannam@167 8699 % #1 is the control sequence we are passed; we expand into a conditional
cannam@167 8700 % which is true if #1 represents a float ref. That is, the magic
cannam@167 8701 % \lastsection value which we \setref above.
cannam@167 8702 %
cannam@167 8703 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
cannam@167 8704 %
cannam@167 8705 % #1 is (maybe) the \floatmagic string. If so, #2 will be the
cannam@167 8706 % (safe) float type for this float. We set \iffloattype to #2.
cannam@167 8707 %
cannam@167 8708 \def\doiffloat#1=#2=#3\finish{%
cannam@167 8709 \def\temp{#1}%
cannam@167 8710 \def\iffloattype{#2}%
cannam@167 8711 \ifx\temp\floatmagic
cannam@167 8712 }
cannam@167 8713
cannam@167 8714 % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
cannam@167 8715 %
cannam@167 8716 \parseargdef\listoffloats{%
cannam@167 8717 \def\floattype{#1}% floattype
cannam@167 8718 {%
cannam@167 8719 % the floattype might have accents or other special characters,
cannam@167 8720 % but we need to use it in a control sequence name.
cannam@167 8721 \indexnofonts
cannam@167 8722 \turnoffactive
cannam@167 8723 \xdef\safefloattype{\floattype}%
cannam@167 8724 }%
cannam@167 8725 %
cannam@167 8726 % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
cannam@167 8727 \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
cannam@167 8728 \ifhavexrefs
cannam@167 8729 % if the user said @listoffloats foo but never @float foo.
cannam@167 8730 \message{\linenumber No `\safefloattype' floats to list.}%
cannam@167 8731 \fi
cannam@167 8732 \else
cannam@167 8733 \begingroup
cannam@167 8734 \leftskip=\tocindent % indent these entries like a toc
cannam@167 8735 \let\do=\listoffloatsdo
cannam@167 8736 \csname floatlist\safefloattype\endcsname
cannam@167 8737 \endgroup
cannam@167 8738 \fi
cannam@167 8739 }
cannam@167 8740
cannam@167 8741 % This is called on each entry in a list of floats. We're passed the
cannam@167 8742 % xref label, in the form LABEL-title, which is how we save it in the
cannam@167 8743 % aux file. We strip off the -title and look up \XRLABEL-lof, which
cannam@167 8744 % has the text we're supposed to typeset here.
cannam@167 8745 %
cannam@167 8746 % Figures without xref labels will not be included in the list (since
cannam@167 8747 % they won't appear in the aux file).
cannam@167 8748 %
cannam@167 8749 \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
cannam@167 8750 \def\listoffloatsdoentry#1-title\finish{{%
cannam@167 8751 % Can't fully expand XR#1-lof because it can contain anything. Just
cannam@167 8752 % pass the control sequence. On the other hand, XR#1-pg is just the
cannam@167 8753 % page number, and we want to fully expand that so we can get a link
cannam@167 8754 % in pdf output.
cannam@167 8755 \toksA = \expandafter{\csname XR#1-lof\endcsname}%
cannam@167 8756 %
cannam@167 8757 % use the same \entry macro we use to generate the TOC and index.
cannam@167 8758 \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
cannam@167 8759 \writeentry
cannam@167 8760 }}
cannam@167 8761
cannam@167 8762
cannam@167 8763 \message{localization,}
cannam@167 8764
cannam@167 8765 % For single-language documents, @documentlanguage is usually given very
cannam@167 8766 % early, just after @documentencoding. Single argument is the language
cannam@167 8767 % (de) or locale (de_DE) abbreviation.
cannam@167 8768 %
cannam@167 8769 {
cannam@167 8770 \catcode`\_ = \active
cannam@167 8771 \globaldefs=1
cannam@167 8772 \parseargdef\documentlanguage{\begingroup
cannam@167 8773 \let_=\normalunderscore % normal _ character for filenames
cannam@167 8774 \tex % read txi-??.tex file in plain TeX.
cannam@167 8775 % Read the file by the name they passed if it exists.
cannam@167 8776 \openin 1 txi-#1.tex
cannam@167 8777 \ifeof 1
cannam@167 8778 \documentlanguagetrywithoutunderscore{#1_\finish}%
cannam@167 8779 \else
cannam@167 8780 \globaldefs = 1 % everything in the txi-LL files needs to persist
cannam@167 8781 \input txi-#1.tex
cannam@167 8782 \fi
cannam@167 8783 \closein 1
cannam@167 8784 \endgroup % end raw TeX
cannam@167 8785 \endgroup}
cannam@167 8786 %
cannam@167 8787 % If they passed de_DE, and txi-de_DE.tex doesn't exist,
cannam@167 8788 % try txi-de.tex.
cannam@167 8789 %
cannam@167 8790 \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
cannam@167 8791 \openin 1 txi-#1.tex
cannam@167 8792 \ifeof 1
cannam@167 8793 \errhelp = \nolanghelp
cannam@167 8794 \errmessage{Cannot read language file txi-#1.tex}%
cannam@167 8795 \else
cannam@167 8796 \globaldefs = 1 % everything in the txi-LL files needs to persist
cannam@167 8797 \input txi-#1.tex
cannam@167 8798 \fi
cannam@167 8799 \closein 1
cannam@167 8800 }
cannam@167 8801 }% end of special _ catcode
cannam@167 8802 %
cannam@167 8803 \newhelp\nolanghelp{The given language definition file cannot be found or
cannam@167 8804 is empty. Maybe you need to install it? Putting it in the current
cannam@167 8805 directory should work if nowhere else does.}
cannam@167 8806
cannam@167 8807 % This macro is called from txi-??.tex files; the first argument is the
cannam@167 8808 % \language name to set (without the "\lang@" prefix), the second and
cannam@167 8809 % third args are \{left,right}hyphenmin.
cannam@167 8810 %
cannam@167 8811 % The language names to pass are determined when the format is built.
cannam@167 8812 % See the etex.log file created at that time, e.g.,
cannam@167 8813 % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
cannam@167 8814 %
cannam@167 8815 % With TeX Live 2008, etex now includes hyphenation patterns for all
cannam@167 8816 % available languages. This means we can support hyphenation in
cannam@167 8817 % Texinfo, at least to some extent. (This still doesn't solve the
cannam@167 8818 % accented characters problem.)
cannam@167 8819 %
cannam@167 8820 \catcode`@=11
cannam@167 8821 \def\txisetlanguage#1#2#3{%
cannam@167 8822 % do not set the language if the name is undefined in the current TeX.
cannam@167 8823 \expandafter\ifx\csname lang@#1\endcsname \relax
cannam@167 8824 \message{no patterns for #1}%
cannam@167 8825 \else
cannam@167 8826 \global\language = \csname lang@#1\endcsname
cannam@167 8827 \fi
cannam@167 8828 % but there is no harm in adjusting the hyphenmin values regardless.
cannam@167 8829 \global\lefthyphenmin = #2\relax
cannam@167 8830 \global\righthyphenmin = #3\relax
cannam@167 8831 }
cannam@167 8832
cannam@167 8833 % Helpers for encodings.
cannam@167 8834 % Set the catcode of characters 128 through 255 to the specified number.
cannam@167 8835 %
cannam@167 8836 \def\setnonasciicharscatcode#1{%
cannam@167 8837 \count255=128
cannam@167 8838 \loop\ifnum\count255<256
cannam@167 8839 \global\catcode\count255=#1\relax
cannam@167 8840 \advance\count255 by 1
cannam@167 8841 \repeat
cannam@167 8842 }
cannam@167 8843
cannam@167 8844 \def\setnonasciicharscatcodenonglobal#1{%
cannam@167 8845 \count255=128
cannam@167 8846 \loop\ifnum\count255<256
cannam@167 8847 \catcode\count255=#1\relax
cannam@167 8848 \advance\count255 by 1
cannam@167 8849 \repeat
cannam@167 8850 }
cannam@167 8851
cannam@167 8852 % @documentencoding sets the definition of non-ASCII characters
cannam@167 8853 % according to the specified encoding.
cannam@167 8854 %
cannam@167 8855 \parseargdef\documentencoding{%
cannam@167 8856 % Encoding being declared for the document.
cannam@167 8857 \def\declaredencoding{\csname #1.enc\endcsname}%
cannam@167 8858 %
cannam@167 8859 % Supported encodings: names converted to tokens in order to be able
cannam@167 8860 % to compare them with \ifx.
cannam@167 8861 \def\ascii{\csname US-ASCII.enc\endcsname}%
cannam@167 8862 \def\latnine{\csname ISO-8859-15.enc\endcsname}%
cannam@167 8863 \def\latone{\csname ISO-8859-1.enc\endcsname}%
cannam@167 8864 \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
cannam@167 8865 \def\utfeight{\csname UTF-8.enc\endcsname}%
cannam@167 8866 %
cannam@167 8867 \ifx \declaredencoding \ascii
cannam@167 8868 \asciichardefs
cannam@167 8869 %
cannam@167 8870 \else \ifx \declaredencoding \lattwo
cannam@167 8871 \setnonasciicharscatcode\active
cannam@167 8872 \lattwochardefs
cannam@167 8873 %
cannam@167 8874 \else \ifx \declaredencoding \latone
cannam@167 8875 \setnonasciicharscatcode\active
cannam@167 8876 \latonechardefs
cannam@167 8877 %
cannam@167 8878 \else \ifx \declaredencoding \latnine
cannam@167 8879 \setnonasciicharscatcode\active
cannam@167 8880 \latninechardefs
cannam@167 8881 %
cannam@167 8882 \else \ifx \declaredencoding \utfeight
cannam@167 8883 \setnonasciicharscatcode\active
cannam@167 8884 \utfeightchardefs
cannam@167 8885 %
cannam@167 8886 \else
cannam@167 8887 \message{Unknown document encoding #1, ignoring.}%
cannam@167 8888 %
cannam@167 8889 \fi % utfeight
cannam@167 8890 \fi % latnine
cannam@167 8891 \fi % latone
cannam@167 8892 \fi % lattwo
cannam@167 8893 \fi % ascii
cannam@167 8894 }
cannam@167 8895
cannam@167 8896 % A message to be logged when using a character that isn't available
cannam@167 8897 % the default font encoding (OT1).
cannam@167 8898 %
cannam@167 8899 \def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}}
cannam@167 8900
cannam@167 8901 % Take account of \c (plain) vs. \, (Texinfo) difference.
cannam@167 8902 \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
cannam@167 8903
cannam@167 8904 % First, make active non-ASCII characters in order for them to be
cannam@167 8905 % correctly categorized when TeX reads the replacement text of
cannam@167 8906 % macros containing the character definitions.
cannam@167 8907 \setnonasciicharscatcode\active
cannam@167 8908 %
cannam@167 8909 % Latin1 (ISO-8859-1) character definitions.
cannam@167 8910 \def\latonechardefs{%
cannam@167 8911 \gdef^^a0{\tie}
cannam@167 8912 \gdef^^a1{\exclamdown}
cannam@167 8913 \gdef^^a2{\missingcharmsg{CENT SIGN}}
cannam@167 8914 \gdef^^a3{{\pounds}}
cannam@167 8915 \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
cannam@167 8916 \gdef^^a5{\missingcharmsg{YEN SIGN}}
cannam@167 8917 \gdef^^a6{\missingcharmsg{BROKEN BAR}}
cannam@167 8918 \gdef^^a7{\S}
cannam@167 8919 \gdef^^a8{\"{}}
cannam@167 8920 \gdef^^a9{\copyright}
cannam@167 8921 \gdef^^aa{\ordf}
cannam@167 8922 \gdef^^ab{\guillemetleft}
cannam@167 8923 \gdef^^ac{$\lnot$}
cannam@167 8924 \gdef^^ad{\-}
cannam@167 8925 \gdef^^ae{\registeredsymbol}
cannam@167 8926 \gdef^^af{\={}}
cannam@167 8927 %
cannam@167 8928 \gdef^^b0{\textdegree}
cannam@167 8929 \gdef^^b1{$\pm$}
cannam@167 8930 \gdef^^b2{$^2$}
cannam@167 8931 \gdef^^b3{$^3$}
cannam@167 8932 \gdef^^b4{\'{}}
cannam@167 8933 \gdef^^b5{$\mu$}
cannam@167 8934 \gdef^^b6{\P}
cannam@167 8935 %
cannam@167 8936 \gdef^^b7{$^.$}
cannam@167 8937 \gdef^^b8{\cedilla\ }
cannam@167 8938 \gdef^^b9{$^1$}
cannam@167 8939 \gdef^^ba{\ordm}
cannam@167 8940 %
cannam@167 8941 \gdef^^bb{\guillemetright}
cannam@167 8942 \gdef^^bc{$1\over4$}
cannam@167 8943 \gdef^^bd{$1\over2$}
cannam@167 8944 \gdef^^be{$3\over4$}
cannam@167 8945 \gdef^^bf{\questiondown}
cannam@167 8946 %
cannam@167 8947 \gdef^^c0{\`A}
cannam@167 8948 \gdef^^c1{\'A}
cannam@167 8949 \gdef^^c2{\^A}
cannam@167 8950 \gdef^^c3{\~A}
cannam@167 8951 \gdef^^c4{\"A}
cannam@167 8952 \gdef^^c5{\ringaccent A}
cannam@167 8953 \gdef^^c6{\AE}
cannam@167 8954 \gdef^^c7{\cedilla C}
cannam@167 8955 \gdef^^c8{\`E}
cannam@167 8956 \gdef^^c9{\'E}
cannam@167 8957 \gdef^^ca{\^E}
cannam@167 8958 \gdef^^cb{\"E}
cannam@167 8959 \gdef^^cc{\`I}
cannam@167 8960 \gdef^^cd{\'I}
cannam@167 8961 \gdef^^ce{\^I}
cannam@167 8962 \gdef^^cf{\"I}
cannam@167 8963 %
cannam@167 8964 \gdef^^d0{\DH}
cannam@167 8965 \gdef^^d1{\~N}
cannam@167 8966 \gdef^^d2{\`O}
cannam@167 8967 \gdef^^d3{\'O}
cannam@167 8968 \gdef^^d4{\^O}
cannam@167 8969 \gdef^^d5{\~O}
cannam@167 8970 \gdef^^d6{\"O}
cannam@167 8971 \gdef^^d7{$\times$}
cannam@167 8972 \gdef^^d8{\O}
cannam@167 8973 \gdef^^d9{\`U}
cannam@167 8974 \gdef^^da{\'U}
cannam@167 8975 \gdef^^db{\^U}
cannam@167 8976 \gdef^^dc{\"U}
cannam@167 8977 \gdef^^dd{\'Y}
cannam@167 8978 \gdef^^de{\TH}
cannam@167 8979 \gdef^^df{\ss}
cannam@167 8980 %
cannam@167 8981 \gdef^^e0{\`a}
cannam@167 8982 \gdef^^e1{\'a}
cannam@167 8983 \gdef^^e2{\^a}
cannam@167 8984 \gdef^^e3{\~a}
cannam@167 8985 \gdef^^e4{\"a}
cannam@167 8986 \gdef^^e5{\ringaccent a}
cannam@167 8987 \gdef^^e6{\ae}
cannam@167 8988 \gdef^^e7{\cedilla c}
cannam@167 8989 \gdef^^e8{\`e}
cannam@167 8990 \gdef^^e9{\'e}
cannam@167 8991 \gdef^^ea{\^e}
cannam@167 8992 \gdef^^eb{\"e}
cannam@167 8993 \gdef^^ec{\`{\dotless i}}
cannam@167 8994 \gdef^^ed{\'{\dotless i}}
cannam@167 8995 \gdef^^ee{\^{\dotless i}}
cannam@167 8996 \gdef^^ef{\"{\dotless i}}
cannam@167 8997 %
cannam@167 8998 \gdef^^f0{\dh}
cannam@167 8999 \gdef^^f1{\~n}
cannam@167 9000 \gdef^^f2{\`o}
cannam@167 9001 \gdef^^f3{\'o}
cannam@167 9002 \gdef^^f4{\^o}
cannam@167 9003 \gdef^^f5{\~o}
cannam@167 9004 \gdef^^f6{\"o}
cannam@167 9005 \gdef^^f7{$\div$}
cannam@167 9006 \gdef^^f8{\o}
cannam@167 9007 \gdef^^f9{\`u}
cannam@167 9008 \gdef^^fa{\'u}
cannam@167 9009 \gdef^^fb{\^u}
cannam@167 9010 \gdef^^fc{\"u}
cannam@167 9011 \gdef^^fd{\'y}
cannam@167 9012 \gdef^^fe{\th}
cannam@167 9013 \gdef^^ff{\"y}
cannam@167 9014 }
cannam@167 9015
cannam@167 9016 % Latin9 (ISO-8859-15) encoding character definitions.
cannam@167 9017 \def\latninechardefs{%
cannam@167 9018 % Encoding is almost identical to Latin1.
cannam@167 9019 \latonechardefs
cannam@167 9020 %
cannam@167 9021 \gdef^^a4{\euro}
cannam@167 9022 \gdef^^a6{\v S}
cannam@167 9023 \gdef^^a8{\v s}
cannam@167 9024 \gdef^^b4{\v Z}
cannam@167 9025 \gdef^^b8{\v z}
cannam@167 9026 \gdef^^bc{\OE}
cannam@167 9027 \gdef^^bd{\oe}
cannam@167 9028 \gdef^^be{\"Y}
cannam@167 9029 }
cannam@167 9030
cannam@167 9031 % Latin2 (ISO-8859-2) character definitions.
cannam@167 9032 \def\lattwochardefs{%
cannam@167 9033 \gdef^^a0{\tie}
cannam@167 9034 \gdef^^a1{\ogonek{A}}
cannam@167 9035 \gdef^^a2{\u{}}
cannam@167 9036 \gdef^^a3{\L}
cannam@167 9037 \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
cannam@167 9038 \gdef^^a5{\v L}
cannam@167 9039 \gdef^^a6{\'S}
cannam@167 9040 \gdef^^a7{\S}
cannam@167 9041 \gdef^^a8{\"{}}
cannam@167 9042 \gdef^^a9{\v S}
cannam@167 9043 \gdef^^aa{\cedilla S}
cannam@167 9044 \gdef^^ab{\v T}
cannam@167 9045 \gdef^^ac{\'Z}
cannam@167 9046 \gdef^^ad{\-}
cannam@167 9047 \gdef^^ae{\v Z}
cannam@167 9048 \gdef^^af{\dotaccent Z}
cannam@167 9049 %
cannam@167 9050 \gdef^^b0{\textdegree}
cannam@167 9051 \gdef^^b1{\ogonek{a}}
cannam@167 9052 \gdef^^b2{\ogonek{ }}
cannam@167 9053 \gdef^^b3{\l}
cannam@167 9054 \gdef^^b4{\'{}}
cannam@167 9055 \gdef^^b5{\v l}
cannam@167 9056 \gdef^^b6{\'s}
cannam@167 9057 \gdef^^b7{\v{}}
cannam@167 9058 \gdef^^b8{\cedilla\ }
cannam@167 9059 \gdef^^b9{\v s}
cannam@167 9060 \gdef^^ba{\cedilla s}
cannam@167 9061 \gdef^^bb{\v t}
cannam@167 9062 \gdef^^bc{\'z}
cannam@167 9063 \gdef^^bd{\H{}}
cannam@167 9064 \gdef^^be{\v z}
cannam@167 9065 \gdef^^bf{\dotaccent z}
cannam@167 9066 %
cannam@167 9067 \gdef^^c0{\'R}
cannam@167 9068 \gdef^^c1{\'A}
cannam@167 9069 \gdef^^c2{\^A}
cannam@167 9070 \gdef^^c3{\u A}
cannam@167 9071 \gdef^^c4{\"A}
cannam@167 9072 \gdef^^c5{\'L}
cannam@167 9073 \gdef^^c6{\'C}
cannam@167 9074 \gdef^^c7{\cedilla C}
cannam@167 9075 \gdef^^c8{\v C}
cannam@167 9076 \gdef^^c9{\'E}
cannam@167 9077 \gdef^^ca{\ogonek{E}}
cannam@167 9078 \gdef^^cb{\"E}
cannam@167 9079 \gdef^^cc{\v E}
cannam@167 9080 \gdef^^cd{\'I}
cannam@167 9081 \gdef^^ce{\^I}
cannam@167 9082 \gdef^^cf{\v D}
cannam@167 9083 %
cannam@167 9084 \gdef^^d0{\DH}
cannam@167 9085 \gdef^^d1{\'N}
cannam@167 9086 \gdef^^d2{\v N}
cannam@167 9087 \gdef^^d3{\'O}
cannam@167 9088 \gdef^^d4{\^O}
cannam@167 9089 \gdef^^d5{\H O}
cannam@167 9090 \gdef^^d6{\"O}
cannam@167 9091 \gdef^^d7{$\times$}
cannam@167 9092 \gdef^^d8{\v R}
cannam@167 9093 \gdef^^d9{\ringaccent U}
cannam@167 9094 \gdef^^da{\'U}
cannam@167 9095 \gdef^^db{\H U}
cannam@167 9096 \gdef^^dc{\"U}
cannam@167 9097 \gdef^^dd{\'Y}
cannam@167 9098 \gdef^^de{\cedilla T}
cannam@167 9099 \gdef^^df{\ss}
cannam@167 9100 %
cannam@167 9101 \gdef^^e0{\'r}
cannam@167 9102 \gdef^^e1{\'a}
cannam@167 9103 \gdef^^e2{\^a}
cannam@167 9104 \gdef^^e3{\u a}
cannam@167 9105 \gdef^^e4{\"a}
cannam@167 9106 \gdef^^e5{\'l}
cannam@167 9107 \gdef^^e6{\'c}
cannam@167 9108 \gdef^^e7{\cedilla c}
cannam@167 9109 \gdef^^e8{\v c}
cannam@167 9110 \gdef^^e9{\'e}
cannam@167 9111 \gdef^^ea{\ogonek{e}}
cannam@167 9112 \gdef^^eb{\"e}
cannam@167 9113 \gdef^^ec{\v e}
cannam@167 9114 \gdef^^ed{\'{\dotless{i}}}
cannam@167 9115 \gdef^^ee{\^{\dotless{i}}}
cannam@167 9116 \gdef^^ef{\v d}
cannam@167 9117 %
cannam@167 9118 \gdef^^f0{\dh}
cannam@167 9119 \gdef^^f1{\'n}
cannam@167 9120 \gdef^^f2{\v n}
cannam@167 9121 \gdef^^f3{\'o}
cannam@167 9122 \gdef^^f4{\^o}
cannam@167 9123 \gdef^^f5{\H o}
cannam@167 9124 \gdef^^f6{\"o}
cannam@167 9125 \gdef^^f7{$\div$}
cannam@167 9126 \gdef^^f8{\v r}
cannam@167 9127 \gdef^^f9{\ringaccent u}
cannam@167 9128 \gdef^^fa{\'u}
cannam@167 9129 \gdef^^fb{\H u}
cannam@167 9130 \gdef^^fc{\"u}
cannam@167 9131 \gdef^^fd{\'y}
cannam@167 9132 \gdef^^fe{\cedilla t}
cannam@167 9133 \gdef^^ff{\dotaccent{}}
cannam@167 9134 }
cannam@167 9135
cannam@167 9136 % UTF-8 character definitions.
cannam@167 9137 %
cannam@167 9138 % This code to support UTF-8 is based on LaTeX's utf8.def, with some
cannam@167 9139 % changes for Texinfo conventions. It is included here under the GPL by
cannam@167 9140 % permission from Frank Mittelbach and the LaTeX team.
cannam@167 9141 %
cannam@167 9142 \newcount\countUTFx
cannam@167 9143 \newcount\countUTFy
cannam@167 9144 \newcount\countUTFz
cannam@167 9145
cannam@167 9146 \gdef\UTFviiiTwoOctets#1#2{\expandafter
cannam@167 9147 \UTFviiiDefined\csname u8:#1\string #2\endcsname}
cannam@167 9148 %
cannam@167 9149 \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
cannam@167 9150 \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
cannam@167 9151 %
cannam@167 9152 \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
cannam@167 9153 \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
cannam@167 9154
cannam@167 9155 \gdef\UTFviiiDefined#1{%
cannam@167 9156 \ifx #1\relax
cannam@167 9157 \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
cannam@167 9158 \else
cannam@167 9159 \expandafter #1%
cannam@167 9160 \fi
cannam@167 9161 }
cannam@167 9162
cannam@167 9163 \begingroup
cannam@167 9164 \catcode`\~13
cannam@167 9165 \catcode`\"12
cannam@167 9166
cannam@167 9167 \def\UTFviiiLoop{%
cannam@167 9168 \global\catcode\countUTFx\active
cannam@167 9169 \uccode`\~\countUTFx
cannam@167 9170 \uppercase\expandafter{\UTFviiiTmp}%
cannam@167 9171 \advance\countUTFx by 1
cannam@167 9172 \ifnum\countUTFx < \countUTFy
cannam@167 9173 \expandafter\UTFviiiLoop
cannam@167 9174 \fi}
cannam@167 9175
cannam@167 9176 \countUTFx = "C2
cannam@167 9177 \countUTFy = "E0
cannam@167 9178 \def\UTFviiiTmp{%
cannam@167 9179 \xdef~{\noexpand\UTFviiiTwoOctets\string~}}
cannam@167 9180 \UTFviiiLoop
cannam@167 9181
cannam@167 9182 \countUTFx = "E0
cannam@167 9183 \countUTFy = "F0
cannam@167 9184 \def\UTFviiiTmp{%
cannam@167 9185 \xdef~{\noexpand\UTFviiiThreeOctets\string~}}
cannam@167 9186 \UTFviiiLoop
cannam@167 9187
cannam@167 9188 \countUTFx = "F0
cannam@167 9189 \countUTFy = "F4
cannam@167 9190 \def\UTFviiiTmp{%
cannam@167 9191 \xdef~{\noexpand\UTFviiiFourOctets\string~}}
cannam@167 9192 \UTFviiiLoop
cannam@167 9193 \endgroup
cannam@167 9194
cannam@167 9195 \begingroup
cannam@167 9196 \catcode`\"=12
cannam@167 9197 \catcode`\<=12
cannam@167 9198 \catcode`\.=12
cannam@167 9199 \catcode`\,=12
cannam@167 9200 \catcode`\;=12
cannam@167 9201 \catcode`\!=12
cannam@167 9202 \catcode`\~=13
cannam@167 9203
cannam@167 9204 \gdef\DeclareUnicodeCharacter#1#2{%
cannam@167 9205 \countUTFz = "#1\relax
cannam@167 9206 %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}%
cannam@167 9207 \begingroup
cannam@167 9208 \parseXMLCharref
cannam@167 9209 \def\UTFviiiTwoOctets##1##2{%
cannam@167 9210 \csname u8:##1\string ##2\endcsname}%
cannam@167 9211 \def\UTFviiiThreeOctets##1##2##3{%
cannam@167 9212 \csname u8:##1\string ##2\string ##3\endcsname}%
cannam@167 9213 \def\UTFviiiFourOctets##1##2##3##4{%
cannam@167 9214 \csname u8:##1\string ##2\string ##3\string ##4\endcsname}%
cannam@167 9215 \expandafter\expandafter\expandafter\expandafter
cannam@167 9216 \expandafter\expandafter\expandafter
cannam@167 9217 \gdef\UTFviiiTmp{#2}%
cannam@167 9218 \endgroup}
cannam@167 9219
cannam@167 9220 \gdef\parseXMLCharref{%
cannam@167 9221 \ifnum\countUTFz < "A0\relax
cannam@167 9222 \errhelp = \EMsimple
cannam@167 9223 \errmessage{Cannot define Unicode char value < 00A0}%
cannam@167 9224 \else\ifnum\countUTFz < "800\relax
cannam@167 9225 \parseUTFviiiA,%
cannam@167 9226 \parseUTFviiiB C\UTFviiiTwoOctets.,%
cannam@167 9227 \else\ifnum\countUTFz < "10000\relax
cannam@167 9228 \parseUTFviiiA;%
cannam@167 9229 \parseUTFviiiA,%
cannam@167 9230 \parseUTFviiiB E\UTFviiiThreeOctets.{,;}%
cannam@167 9231 \else
cannam@167 9232 \parseUTFviiiA;%
cannam@167 9233 \parseUTFviiiA,%
cannam@167 9234 \parseUTFviiiA!%
cannam@167 9235 \parseUTFviiiB F\UTFviiiFourOctets.{!,;}%
cannam@167 9236 \fi\fi\fi
cannam@167 9237 }
cannam@167 9238
cannam@167 9239 \gdef\parseUTFviiiA#1{%
cannam@167 9240 \countUTFx = \countUTFz
cannam@167 9241 \divide\countUTFz by 64
cannam@167 9242 \countUTFy = \countUTFz
cannam@167 9243 \multiply\countUTFz by 64
cannam@167 9244 \advance\countUTFx by -\countUTFz
cannam@167 9245 \advance\countUTFx by 128
cannam@167 9246 \uccode `#1\countUTFx
cannam@167 9247 \countUTFz = \countUTFy}
cannam@167 9248
cannam@167 9249 \gdef\parseUTFviiiB#1#2#3#4{%
cannam@167 9250 \advance\countUTFz by "#10\relax
cannam@167 9251 \uccode `#3\countUTFz
cannam@167 9252 \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
cannam@167 9253 \endgroup
cannam@167 9254
cannam@167 9255 \def\utfeightchardefs{%
cannam@167 9256 \DeclareUnicodeCharacter{00A0}{\tie}
cannam@167 9257 \DeclareUnicodeCharacter{00A1}{\exclamdown}
cannam@167 9258 \DeclareUnicodeCharacter{00A3}{\pounds}
cannam@167 9259 \DeclareUnicodeCharacter{00A8}{\"{ }}
cannam@167 9260 \DeclareUnicodeCharacter{00A9}{\copyright}
cannam@167 9261 \DeclareUnicodeCharacter{00AA}{\ordf}
cannam@167 9262 \DeclareUnicodeCharacter{00AB}{\guillemetleft}
cannam@167 9263 \DeclareUnicodeCharacter{00AD}{\-}
cannam@167 9264 \DeclareUnicodeCharacter{00AE}{\registeredsymbol}
cannam@167 9265 \DeclareUnicodeCharacter{00AF}{\={ }}
cannam@167 9266
cannam@167 9267 \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}
cannam@167 9268 \DeclareUnicodeCharacter{00B4}{\'{ }}
cannam@167 9269 \DeclareUnicodeCharacter{00B8}{\cedilla{ }}
cannam@167 9270 \DeclareUnicodeCharacter{00BA}{\ordm}
cannam@167 9271 \DeclareUnicodeCharacter{00BB}{\guillemetright}
cannam@167 9272 \DeclareUnicodeCharacter{00BF}{\questiondown}
cannam@167 9273
cannam@167 9274 \DeclareUnicodeCharacter{00C0}{\`A}
cannam@167 9275 \DeclareUnicodeCharacter{00C1}{\'A}
cannam@167 9276 \DeclareUnicodeCharacter{00C2}{\^A}
cannam@167 9277 \DeclareUnicodeCharacter{00C3}{\~A}
cannam@167 9278 \DeclareUnicodeCharacter{00C4}{\"A}
cannam@167 9279 \DeclareUnicodeCharacter{00C5}{\AA}
cannam@167 9280 \DeclareUnicodeCharacter{00C6}{\AE}
cannam@167 9281 \DeclareUnicodeCharacter{00C7}{\cedilla{C}}
cannam@167 9282 \DeclareUnicodeCharacter{00C8}{\`E}
cannam@167 9283 \DeclareUnicodeCharacter{00C9}{\'E}
cannam@167 9284 \DeclareUnicodeCharacter{00CA}{\^E}
cannam@167 9285 \DeclareUnicodeCharacter{00CB}{\"E}
cannam@167 9286 \DeclareUnicodeCharacter{00CC}{\`I}
cannam@167 9287 \DeclareUnicodeCharacter{00CD}{\'I}
cannam@167 9288 \DeclareUnicodeCharacter{00CE}{\^I}
cannam@167 9289 \DeclareUnicodeCharacter{00CF}{\"I}
cannam@167 9290
cannam@167 9291 \DeclareUnicodeCharacter{00D0}{\DH}
cannam@167 9292 \DeclareUnicodeCharacter{00D1}{\~N}
cannam@167 9293 \DeclareUnicodeCharacter{00D2}{\`O}
cannam@167 9294 \DeclareUnicodeCharacter{00D3}{\'O}
cannam@167 9295 \DeclareUnicodeCharacter{00D4}{\^O}
cannam@167 9296 \DeclareUnicodeCharacter{00D5}{\~O}
cannam@167 9297 \DeclareUnicodeCharacter{00D6}{\"O}
cannam@167 9298 \DeclareUnicodeCharacter{00D8}{\O}
cannam@167 9299 \DeclareUnicodeCharacter{00D9}{\`U}
cannam@167 9300 \DeclareUnicodeCharacter{00DA}{\'U}
cannam@167 9301 \DeclareUnicodeCharacter{00DB}{\^U}
cannam@167 9302 \DeclareUnicodeCharacter{00DC}{\"U}
cannam@167 9303 \DeclareUnicodeCharacter{00DD}{\'Y}
cannam@167 9304 \DeclareUnicodeCharacter{00DE}{\TH}
cannam@167 9305 \DeclareUnicodeCharacter{00DF}{\ss}
cannam@167 9306
cannam@167 9307 \DeclareUnicodeCharacter{00E0}{\`a}
cannam@167 9308 \DeclareUnicodeCharacter{00E1}{\'a}
cannam@167 9309 \DeclareUnicodeCharacter{00E2}{\^a}
cannam@167 9310 \DeclareUnicodeCharacter{00E3}{\~a}
cannam@167 9311 \DeclareUnicodeCharacter{00E4}{\"a}
cannam@167 9312 \DeclareUnicodeCharacter{00E5}{\aa}
cannam@167 9313 \DeclareUnicodeCharacter{00E6}{\ae}
cannam@167 9314 \DeclareUnicodeCharacter{00E7}{\cedilla{c}}
cannam@167 9315 \DeclareUnicodeCharacter{00E8}{\`e}
cannam@167 9316 \DeclareUnicodeCharacter{00E9}{\'e}
cannam@167 9317 \DeclareUnicodeCharacter{00EA}{\^e}
cannam@167 9318 \DeclareUnicodeCharacter{00EB}{\"e}
cannam@167 9319 \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}
cannam@167 9320 \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}
cannam@167 9321 \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}
cannam@167 9322 \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}
cannam@167 9323
cannam@167 9324 \DeclareUnicodeCharacter{00F0}{\dh}
cannam@167 9325 \DeclareUnicodeCharacter{00F1}{\~n}
cannam@167 9326 \DeclareUnicodeCharacter{00F2}{\`o}
cannam@167 9327 \DeclareUnicodeCharacter{00F3}{\'o}
cannam@167 9328 \DeclareUnicodeCharacter{00F4}{\^o}
cannam@167 9329 \DeclareUnicodeCharacter{00F5}{\~o}
cannam@167 9330 \DeclareUnicodeCharacter{00F6}{\"o}
cannam@167 9331 \DeclareUnicodeCharacter{00F8}{\o}
cannam@167 9332 \DeclareUnicodeCharacter{00F9}{\`u}
cannam@167 9333 \DeclareUnicodeCharacter{00FA}{\'u}
cannam@167 9334 \DeclareUnicodeCharacter{00FB}{\^u}
cannam@167 9335 \DeclareUnicodeCharacter{00FC}{\"u}
cannam@167 9336 \DeclareUnicodeCharacter{00FD}{\'y}
cannam@167 9337 \DeclareUnicodeCharacter{00FE}{\th}
cannam@167 9338 \DeclareUnicodeCharacter{00FF}{\"y}
cannam@167 9339
cannam@167 9340 \DeclareUnicodeCharacter{0100}{\=A}
cannam@167 9341 \DeclareUnicodeCharacter{0101}{\=a}
cannam@167 9342 \DeclareUnicodeCharacter{0102}{\u{A}}
cannam@167 9343 \DeclareUnicodeCharacter{0103}{\u{a}}
cannam@167 9344 \DeclareUnicodeCharacter{0104}{\ogonek{A}}
cannam@167 9345 \DeclareUnicodeCharacter{0105}{\ogonek{a}}
cannam@167 9346 \DeclareUnicodeCharacter{0106}{\'C}
cannam@167 9347 \DeclareUnicodeCharacter{0107}{\'c}
cannam@167 9348 \DeclareUnicodeCharacter{0108}{\^C}
cannam@167 9349 \DeclareUnicodeCharacter{0109}{\^c}
cannam@167 9350 \DeclareUnicodeCharacter{0118}{\ogonek{E}}
cannam@167 9351 \DeclareUnicodeCharacter{0119}{\ogonek{e}}
cannam@167 9352 \DeclareUnicodeCharacter{010A}{\dotaccent{C}}
cannam@167 9353 \DeclareUnicodeCharacter{010B}{\dotaccent{c}}
cannam@167 9354 \DeclareUnicodeCharacter{010C}{\v{C}}
cannam@167 9355 \DeclareUnicodeCharacter{010D}{\v{c}}
cannam@167 9356 \DeclareUnicodeCharacter{010E}{\v{D}}
cannam@167 9357
cannam@167 9358 \DeclareUnicodeCharacter{0112}{\=E}
cannam@167 9359 \DeclareUnicodeCharacter{0113}{\=e}
cannam@167 9360 \DeclareUnicodeCharacter{0114}{\u{E}}
cannam@167 9361 \DeclareUnicodeCharacter{0115}{\u{e}}
cannam@167 9362 \DeclareUnicodeCharacter{0116}{\dotaccent{E}}
cannam@167 9363 \DeclareUnicodeCharacter{0117}{\dotaccent{e}}
cannam@167 9364 \DeclareUnicodeCharacter{011A}{\v{E}}
cannam@167 9365 \DeclareUnicodeCharacter{011B}{\v{e}}
cannam@167 9366 \DeclareUnicodeCharacter{011C}{\^G}
cannam@167 9367 \DeclareUnicodeCharacter{011D}{\^g}
cannam@167 9368 \DeclareUnicodeCharacter{011E}{\u{G}}
cannam@167 9369 \DeclareUnicodeCharacter{011F}{\u{g}}
cannam@167 9370
cannam@167 9371 \DeclareUnicodeCharacter{0120}{\dotaccent{G}}
cannam@167 9372 \DeclareUnicodeCharacter{0121}{\dotaccent{g}}
cannam@167 9373 \DeclareUnicodeCharacter{0124}{\^H}
cannam@167 9374 \DeclareUnicodeCharacter{0125}{\^h}
cannam@167 9375 \DeclareUnicodeCharacter{0128}{\~I}
cannam@167 9376 \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}
cannam@167 9377 \DeclareUnicodeCharacter{012A}{\=I}
cannam@167 9378 \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}
cannam@167 9379 \DeclareUnicodeCharacter{012C}{\u{I}}
cannam@167 9380 \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}
cannam@167 9381
cannam@167 9382 \DeclareUnicodeCharacter{0130}{\dotaccent{I}}
cannam@167 9383 \DeclareUnicodeCharacter{0131}{\dotless{i}}
cannam@167 9384 \DeclareUnicodeCharacter{0132}{IJ}
cannam@167 9385 \DeclareUnicodeCharacter{0133}{ij}
cannam@167 9386 \DeclareUnicodeCharacter{0134}{\^J}
cannam@167 9387 \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}
cannam@167 9388 \DeclareUnicodeCharacter{0139}{\'L}
cannam@167 9389 \DeclareUnicodeCharacter{013A}{\'l}
cannam@167 9390
cannam@167 9391 \DeclareUnicodeCharacter{0141}{\L}
cannam@167 9392 \DeclareUnicodeCharacter{0142}{\l}
cannam@167 9393 \DeclareUnicodeCharacter{0143}{\'N}
cannam@167 9394 \DeclareUnicodeCharacter{0144}{\'n}
cannam@167 9395 \DeclareUnicodeCharacter{0147}{\v{N}}
cannam@167 9396 \DeclareUnicodeCharacter{0148}{\v{n}}
cannam@167 9397 \DeclareUnicodeCharacter{014C}{\=O}
cannam@167 9398 \DeclareUnicodeCharacter{014D}{\=o}
cannam@167 9399 \DeclareUnicodeCharacter{014E}{\u{O}}
cannam@167 9400 \DeclareUnicodeCharacter{014F}{\u{o}}
cannam@167 9401
cannam@167 9402 \DeclareUnicodeCharacter{0150}{\H{O}}
cannam@167 9403 \DeclareUnicodeCharacter{0151}{\H{o}}
cannam@167 9404 \DeclareUnicodeCharacter{0152}{\OE}
cannam@167 9405 \DeclareUnicodeCharacter{0153}{\oe}
cannam@167 9406 \DeclareUnicodeCharacter{0154}{\'R}
cannam@167 9407 \DeclareUnicodeCharacter{0155}{\'r}
cannam@167 9408 \DeclareUnicodeCharacter{0158}{\v{R}}
cannam@167 9409 \DeclareUnicodeCharacter{0159}{\v{r}}
cannam@167 9410 \DeclareUnicodeCharacter{015A}{\'S}
cannam@167 9411 \DeclareUnicodeCharacter{015B}{\'s}
cannam@167 9412 \DeclareUnicodeCharacter{015C}{\^S}
cannam@167 9413 \DeclareUnicodeCharacter{015D}{\^s}
cannam@167 9414 \DeclareUnicodeCharacter{015E}{\cedilla{S}}
cannam@167 9415 \DeclareUnicodeCharacter{015F}{\cedilla{s}}
cannam@167 9416
cannam@167 9417 \DeclareUnicodeCharacter{0160}{\v{S}}
cannam@167 9418 \DeclareUnicodeCharacter{0161}{\v{s}}
cannam@167 9419 \DeclareUnicodeCharacter{0162}{\cedilla{t}}
cannam@167 9420 \DeclareUnicodeCharacter{0163}{\cedilla{T}}
cannam@167 9421 \DeclareUnicodeCharacter{0164}{\v{T}}
cannam@167 9422
cannam@167 9423 \DeclareUnicodeCharacter{0168}{\~U}
cannam@167 9424 \DeclareUnicodeCharacter{0169}{\~u}
cannam@167 9425 \DeclareUnicodeCharacter{016A}{\=U}
cannam@167 9426 \DeclareUnicodeCharacter{016B}{\=u}
cannam@167 9427 \DeclareUnicodeCharacter{016C}{\u{U}}
cannam@167 9428 \DeclareUnicodeCharacter{016D}{\u{u}}
cannam@167 9429 \DeclareUnicodeCharacter{016E}{\ringaccent{U}}
cannam@167 9430 \DeclareUnicodeCharacter{016F}{\ringaccent{u}}
cannam@167 9431
cannam@167 9432 \DeclareUnicodeCharacter{0170}{\H{U}}
cannam@167 9433 \DeclareUnicodeCharacter{0171}{\H{u}}
cannam@167 9434 \DeclareUnicodeCharacter{0174}{\^W}
cannam@167 9435 \DeclareUnicodeCharacter{0175}{\^w}
cannam@167 9436 \DeclareUnicodeCharacter{0176}{\^Y}
cannam@167 9437 \DeclareUnicodeCharacter{0177}{\^y}
cannam@167 9438 \DeclareUnicodeCharacter{0178}{\"Y}
cannam@167 9439 \DeclareUnicodeCharacter{0179}{\'Z}
cannam@167 9440 \DeclareUnicodeCharacter{017A}{\'z}
cannam@167 9441 \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}
cannam@167 9442 \DeclareUnicodeCharacter{017C}{\dotaccent{z}}
cannam@167 9443 \DeclareUnicodeCharacter{017D}{\v{Z}}
cannam@167 9444 \DeclareUnicodeCharacter{017E}{\v{z}}
cannam@167 9445
cannam@167 9446 \DeclareUnicodeCharacter{01C4}{D\v{Z}}
cannam@167 9447 \DeclareUnicodeCharacter{01C5}{D\v{z}}
cannam@167 9448 \DeclareUnicodeCharacter{01C6}{d\v{z}}
cannam@167 9449 \DeclareUnicodeCharacter{01C7}{LJ}
cannam@167 9450 \DeclareUnicodeCharacter{01C8}{Lj}
cannam@167 9451 \DeclareUnicodeCharacter{01C9}{lj}
cannam@167 9452 \DeclareUnicodeCharacter{01CA}{NJ}
cannam@167 9453 \DeclareUnicodeCharacter{01CB}{Nj}
cannam@167 9454 \DeclareUnicodeCharacter{01CC}{nj}
cannam@167 9455 \DeclareUnicodeCharacter{01CD}{\v{A}}
cannam@167 9456 \DeclareUnicodeCharacter{01CE}{\v{a}}
cannam@167 9457 \DeclareUnicodeCharacter{01CF}{\v{I}}
cannam@167 9458
cannam@167 9459 \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}
cannam@167 9460 \DeclareUnicodeCharacter{01D1}{\v{O}}
cannam@167 9461 \DeclareUnicodeCharacter{01D2}{\v{o}}
cannam@167 9462 \DeclareUnicodeCharacter{01D3}{\v{U}}
cannam@167 9463 \DeclareUnicodeCharacter{01D4}{\v{u}}
cannam@167 9464
cannam@167 9465 \DeclareUnicodeCharacter{01E2}{\={\AE}}
cannam@167 9466 \DeclareUnicodeCharacter{01E3}{\={\ae}}
cannam@167 9467 \DeclareUnicodeCharacter{01E6}{\v{G}}
cannam@167 9468 \DeclareUnicodeCharacter{01E7}{\v{g}}
cannam@167 9469 \DeclareUnicodeCharacter{01E8}{\v{K}}
cannam@167 9470 \DeclareUnicodeCharacter{01E9}{\v{k}}
cannam@167 9471
cannam@167 9472 \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}
cannam@167 9473 \DeclareUnicodeCharacter{01F1}{DZ}
cannam@167 9474 \DeclareUnicodeCharacter{01F2}{Dz}
cannam@167 9475 \DeclareUnicodeCharacter{01F3}{dz}
cannam@167 9476 \DeclareUnicodeCharacter{01F4}{\'G}
cannam@167 9477 \DeclareUnicodeCharacter{01F5}{\'g}
cannam@167 9478 \DeclareUnicodeCharacter{01F8}{\`N}
cannam@167 9479 \DeclareUnicodeCharacter{01F9}{\`n}
cannam@167 9480 \DeclareUnicodeCharacter{01FC}{\'{\AE}}
cannam@167 9481 \DeclareUnicodeCharacter{01FD}{\'{\ae}}
cannam@167 9482 \DeclareUnicodeCharacter{01FE}{\'{\O}}
cannam@167 9483 \DeclareUnicodeCharacter{01FF}{\'{\o}}
cannam@167 9484
cannam@167 9485 \DeclareUnicodeCharacter{021E}{\v{H}}
cannam@167 9486 \DeclareUnicodeCharacter{021F}{\v{h}}
cannam@167 9487
cannam@167 9488 \DeclareUnicodeCharacter{0226}{\dotaccent{A}}
cannam@167 9489 \DeclareUnicodeCharacter{0227}{\dotaccent{a}}
cannam@167 9490 \DeclareUnicodeCharacter{0228}{\cedilla{E}}
cannam@167 9491 \DeclareUnicodeCharacter{0229}{\cedilla{e}}
cannam@167 9492 \DeclareUnicodeCharacter{022E}{\dotaccent{O}}
cannam@167 9493 \DeclareUnicodeCharacter{022F}{\dotaccent{o}}
cannam@167 9494
cannam@167 9495 \DeclareUnicodeCharacter{0232}{\=Y}
cannam@167 9496 \DeclareUnicodeCharacter{0233}{\=y}
cannam@167 9497 \DeclareUnicodeCharacter{0237}{\dotless{j}}
cannam@167 9498
cannam@167 9499 \DeclareUnicodeCharacter{02DB}{\ogonek{ }}
cannam@167 9500
cannam@167 9501 \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}
cannam@167 9502 \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}
cannam@167 9503 \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}
cannam@167 9504 \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}
cannam@167 9505 \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}
cannam@167 9506 \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}
cannam@167 9507 \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}
cannam@167 9508 \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}
cannam@167 9509 \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}
cannam@167 9510 \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}
cannam@167 9511 \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}
cannam@167 9512 \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}
cannam@167 9513
cannam@167 9514 \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}
cannam@167 9515 \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}
cannam@167 9516
cannam@167 9517 \DeclareUnicodeCharacter{1E20}{\=G}
cannam@167 9518 \DeclareUnicodeCharacter{1E21}{\=g}
cannam@167 9519 \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}
cannam@167 9520 \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}
cannam@167 9521 \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}
cannam@167 9522 \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}
cannam@167 9523 \DeclareUnicodeCharacter{1E26}{\"H}
cannam@167 9524 \DeclareUnicodeCharacter{1E27}{\"h}
cannam@167 9525
cannam@167 9526 \DeclareUnicodeCharacter{1E30}{\'K}
cannam@167 9527 \DeclareUnicodeCharacter{1E31}{\'k}
cannam@167 9528 \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}
cannam@167 9529 \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}
cannam@167 9530 \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}
cannam@167 9531 \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}
cannam@167 9532 \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}
cannam@167 9533 \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}
cannam@167 9534 \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}
cannam@167 9535 \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}
cannam@167 9536 \DeclareUnicodeCharacter{1E3E}{\'M}
cannam@167 9537 \DeclareUnicodeCharacter{1E3F}{\'m}
cannam@167 9538
cannam@167 9539 \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}
cannam@167 9540 \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}
cannam@167 9541 \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}
cannam@167 9542 \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}
cannam@167 9543 \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}
cannam@167 9544 \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}
cannam@167 9545 \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}
cannam@167 9546 \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}
cannam@167 9547 \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}
cannam@167 9548 \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}
cannam@167 9549
cannam@167 9550 \DeclareUnicodeCharacter{1E54}{\'P}
cannam@167 9551 \DeclareUnicodeCharacter{1E55}{\'p}
cannam@167 9552 \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}
cannam@167 9553 \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}
cannam@167 9554 \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}
cannam@167 9555 \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}
cannam@167 9556 \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}
cannam@167 9557 \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}
cannam@167 9558 \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}
cannam@167 9559 \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}
cannam@167 9560
cannam@167 9561 \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}
cannam@167 9562 \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}
cannam@167 9563 \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}
cannam@167 9564 \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}
cannam@167 9565 \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}
cannam@167 9566 \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}
cannam@167 9567 \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}
cannam@167 9568 \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}
cannam@167 9569 \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}
cannam@167 9570 \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}
cannam@167 9571
cannam@167 9572 \DeclareUnicodeCharacter{1E7C}{\~V}
cannam@167 9573 \DeclareUnicodeCharacter{1E7D}{\~v}
cannam@167 9574 \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}
cannam@167 9575 \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}
cannam@167 9576
cannam@167 9577 \DeclareUnicodeCharacter{1E80}{\`W}
cannam@167 9578 \DeclareUnicodeCharacter{1E81}{\`w}
cannam@167 9579 \DeclareUnicodeCharacter{1E82}{\'W}
cannam@167 9580 \DeclareUnicodeCharacter{1E83}{\'w}
cannam@167 9581 \DeclareUnicodeCharacter{1E84}{\"W}
cannam@167 9582 \DeclareUnicodeCharacter{1E85}{\"w}
cannam@167 9583 \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}
cannam@167 9584 \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}
cannam@167 9585 \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}
cannam@167 9586 \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}
cannam@167 9587 \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}
cannam@167 9588 \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}
cannam@167 9589 \DeclareUnicodeCharacter{1E8C}{\"X}
cannam@167 9590 \DeclareUnicodeCharacter{1E8D}{\"x}
cannam@167 9591 \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}
cannam@167 9592 \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}
cannam@167 9593
cannam@167 9594 \DeclareUnicodeCharacter{1E90}{\^Z}
cannam@167 9595 \DeclareUnicodeCharacter{1E91}{\^z}
cannam@167 9596 \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}
cannam@167 9597 \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}
cannam@167 9598 \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}
cannam@167 9599 \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}
cannam@167 9600 \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}
cannam@167 9601 \DeclareUnicodeCharacter{1E97}{\"t}
cannam@167 9602 \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}
cannam@167 9603 \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}
cannam@167 9604
cannam@167 9605 \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}
cannam@167 9606 \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}
cannam@167 9607
cannam@167 9608 \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}
cannam@167 9609 \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}
cannam@167 9610 \DeclareUnicodeCharacter{1EBC}{\~E}
cannam@167 9611 \DeclareUnicodeCharacter{1EBD}{\~e}
cannam@167 9612
cannam@167 9613 \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}
cannam@167 9614 \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}
cannam@167 9615 \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}
cannam@167 9616 \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}
cannam@167 9617
cannam@167 9618 \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}
cannam@167 9619 \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}
cannam@167 9620
cannam@167 9621 \DeclareUnicodeCharacter{1EF2}{\`Y}
cannam@167 9622 \DeclareUnicodeCharacter{1EF3}{\`y}
cannam@167 9623 \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}
cannam@167 9624
cannam@167 9625 \DeclareUnicodeCharacter{1EF8}{\~Y}
cannam@167 9626 \DeclareUnicodeCharacter{1EF9}{\~y}
cannam@167 9627
cannam@167 9628 \DeclareUnicodeCharacter{2013}{--}
cannam@167 9629 \DeclareUnicodeCharacter{2014}{---}
cannam@167 9630 \DeclareUnicodeCharacter{2018}{\quoteleft}
cannam@167 9631 \DeclareUnicodeCharacter{2019}{\quoteright}
cannam@167 9632 \DeclareUnicodeCharacter{201A}{\quotesinglbase}
cannam@167 9633 \DeclareUnicodeCharacter{201C}{\quotedblleft}
cannam@167 9634 \DeclareUnicodeCharacter{201D}{\quotedblright}
cannam@167 9635 \DeclareUnicodeCharacter{201E}{\quotedblbase}
cannam@167 9636 \DeclareUnicodeCharacter{2022}{\bullet}
cannam@167 9637 \DeclareUnicodeCharacter{2026}{\dots}
cannam@167 9638 \DeclareUnicodeCharacter{2039}{\guilsinglleft}
cannam@167 9639 \DeclareUnicodeCharacter{203A}{\guilsinglright}
cannam@167 9640 \DeclareUnicodeCharacter{20AC}{\euro}
cannam@167 9641
cannam@167 9642 \DeclareUnicodeCharacter{2192}{\expansion}
cannam@167 9643 \DeclareUnicodeCharacter{21D2}{\result}
cannam@167 9644
cannam@167 9645 \DeclareUnicodeCharacter{2212}{\minus}
cannam@167 9646 \DeclareUnicodeCharacter{2217}{\point}
cannam@167 9647 \DeclareUnicodeCharacter{2261}{\equiv}
cannam@167 9648 }% end of \utfeightchardefs
cannam@167 9649
cannam@167 9650
cannam@167 9651 % US-ASCII character definitions.
cannam@167 9652 \def\asciichardefs{% nothing need be done
cannam@167 9653 \relax
cannam@167 9654 }
cannam@167 9655
cannam@167 9656 % Make non-ASCII characters printable again for compatibility with
cannam@167 9657 % existing Texinfo documents that may use them, even without declaring a
cannam@167 9658 % document encoding.
cannam@167 9659 %
cannam@167 9660 \setnonasciicharscatcode \other
cannam@167 9661
cannam@167 9662
cannam@167 9663 \message{formatting,}
cannam@167 9664
cannam@167 9665 \newdimen\defaultparindent \defaultparindent = 15pt
cannam@167 9666
cannam@167 9667 \chapheadingskip = 15pt plus 4pt minus 2pt
cannam@167 9668 \secheadingskip = 12pt plus 3pt minus 2pt
cannam@167 9669 \subsecheadingskip = 9pt plus 2pt minus 2pt
cannam@167 9670
cannam@167 9671 % Prevent underfull vbox error messages.
cannam@167 9672 \vbadness = 10000
cannam@167 9673
cannam@167 9674 % Don't be very finicky about underfull hboxes, either.
cannam@167 9675 \hbadness = 6666
cannam@167 9676
cannam@167 9677 % Following George Bush, get rid of widows and orphans.
cannam@167 9678 \widowpenalty=10000
cannam@167 9679 \clubpenalty=10000
cannam@167 9680
cannam@167 9681 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
cannam@167 9682 % using an old version of TeX, don't do anything. We want the amount of
cannam@167 9683 % stretch added to depend on the line length, hence the dependence on
cannam@167 9684 % \hsize. We call this whenever the paper size is set.
cannam@167 9685 %
cannam@167 9686 \def\setemergencystretch{%
cannam@167 9687 \ifx\emergencystretch\thisisundefined
cannam@167 9688 % Allow us to assign to \emergencystretch anyway.
cannam@167 9689 \def\emergencystretch{\dimen0}%
cannam@167 9690 \else
cannam@167 9691 \emergencystretch = .15\hsize
cannam@167 9692 \fi
cannam@167 9693 }
cannam@167 9694
cannam@167 9695 % Parameters in order: 1) textheight; 2) textwidth;
cannam@167 9696 % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
cannam@167 9697 % 7) physical page height; 8) physical page width.
cannam@167 9698 %
cannam@167 9699 % We also call \setleading{\textleading}, so the caller should define
cannam@167 9700 % \textleading. The caller should also set \parskip.
cannam@167 9701 %
cannam@167 9702 \def\internalpagesizes#1#2#3#4#5#6#7#8{%
cannam@167 9703 \voffset = #3\relax
cannam@167 9704 \topskip = #6\relax
cannam@167 9705 \splittopskip = \topskip
cannam@167 9706 %
cannam@167 9707 \vsize = #1\relax
cannam@167 9708 \advance\vsize by \topskip
cannam@167 9709 \outervsize = \vsize
cannam@167 9710 \advance\outervsize by 2\topandbottommargin
cannam@167 9711 \pageheight = \vsize
cannam@167 9712 %
cannam@167 9713 \hsize = #2\relax
cannam@167 9714 \outerhsize = \hsize
cannam@167 9715 \advance\outerhsize by 0.5in
cannam@167 9716 \pagewidth = \hsize
cannam@167 9717 %
cannam@167 9718 \normaloffset = #4\relax
cannam@167 9719 \bindingoffset = #5\relax
cannam@167 9720 %
cannam@167 9721 \ifpdf
cannam@167 9722 \pdfpageheight #7\relax
cannam@167 9723 \pdfpagewidth #8\relax
cannam@167 9724 % if we don't reset these, they will remain at "1 true in" of
cannam@167 9725 % whatever layout pdftex was dumped with.
cannam@167 9726 \pdfhorigin = 1 true in
cannam@167 9727 \pdfvorigin = 1 true in
cannam@167 9728 \fi
cannam@167 9729 %
cannam@167 9730 \setleading{\textleading}
cannam@167 9731 %
cannam@167 9732 \parindent = \defaultparindent
cannam@167 9733 \setemergencystretch
cannam@167 9734 }
cannam@167 9735
cannam@167 9736 % @letterpaper (the default).
cannam@167 9737 \def\letterpaper{{\globaldefs = 1
cannam@167 9738 \parskip = 3pt plus 2pt minus 1pt
cannam@167 9739 \textleading = 13.2pt
cannam@167 9740 %
cannam@167 9741 % If page is nothing but text, make it come out even.
cannam@167 9742 \internalpagesizes{607.2pt}{6in}% that's 46 lines
cannam@167 9743 {\voffset}{.25in}%
cannam@167 9744 {\bindingoffset}{36pt}%
cannam@167 9745 {11in}{8.5in}%
cannam@167 9746 }}
cannam@167 9747
cannam@167 9748 % Use @smallbook to reset parameters for 7x9.25 trim size.
cannam@167 9749 \def\smallbook{{\globaldefs = 1
cannam@167 9750 \parskip = 2pt plus 1pt
cannam@167 9751 \textleading = 12pt
cannam@167 9752 %
cannam@167 9753 \internalpagesizes{7.5in}{5in}%
cannam@167 9754 {-.2in}{0in}%
cannam@167 9755 {\bindingoffset}{16pt}%
cannam@167 9756 {9.25in}{7in}%
cannam@167 9757 %
cannam@167 9758 \lispnarrowing = 0.3in
cannam@167 9759 \tolerance = 700
cannam@167 9760 \hfuzz = 1pt
cannam@167 9761 \contentsrightmargin = 0pt
cannam@167 9762 \defbodyindent = .5cm
cannam@167 9763 }}
cannam@167 9764
cannam@167 9765 % Use @smallerbook to reset parameters for 6x9 trim size.
cannam@167 9766 % (Just testing, parameters still in flux.)
cannam@167 9767 \def\smallerbook{{\globaldefs = 1
cannam@167 9768 \parskip = 1.5pt plus 1pt
cannam@167 9769 \textleading = 12pt
cannam@167 9770 %
cannam@167 9771 \internalpagesizes{7.4in}{4.8in}%
cannam@167 9772 {-.2in}{-.4in}%
cannam@167 9773 {0pt}{14pt}%
cannam@167 9774 {9in}{6in}%
cannam@167 9775 %
cannam@167 9776 \lispnarrowing = 0.25in
cannam@167 9777 \tolerance = 700
cannam@167 9778 \hfuzz = 1pt
cannam@167 9779 \contentsrightmargin = 0pt
cannam@167 9780 \defbodyindent = .4cm
cannam@167 9781 }}
cannam@167 9782
cannam@167 9783 % Use @afourpaper to print on European A4 paper.
cannam@167 9784 \def\afourpaper{{\globaldefs = 1
cannam@167 9785 \parskip = 3pt plus 2pt minus 1pt
cannam@167 9786 \textleading = 13.2pt
cannam@167 9787 %
cannam@167 9788 % Double-side printing via postscript on Laserjet 4050
cannam@167 9789 % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
cannam@167 9790 % To change the settings for a different printer or situation, adjust
cannam@167 9791 % \normaloffset until the front-side and back-side texts align. Then
cannam@167 9792 % do the same for \bindingoffset. You can set these for testing in
cannam@167 9793 % your texinfo source file like this:
cannam@167 9794 % @tex
cannam@167 9795 % \global\normaloffset = -6mm
cannam@167 9796 % \global\bindingoffset = 10mm
cannam@167 9797 % @end tex
cannam@167 9798 \internalpagesizes{673.2pt}{160mm}% that's 51 lines
cannam@167 9799 {\voffset}{\hoffset}%
cannam@167 9800 {\bindingoffset}{44pt}%
cannam@167 9801 {297mm}{210mm}%
cannam@167 9802 %
cannam@167 9803 \tolerance = 700
cannam@167 9804 \hfuzz = 1pt
cannam@167 9805 \contentsrightmargin = 0pt
cannam@167 9806 \defbodyindent = 5mm
cannam@167 9807 }}
cannam@167 9808
cannam@167 9809 % Use @afivepaper to print on European A5 paper.
cannam@167 9810 % From romildo@urano.iceb.ufop.br, 2 July 2000.
cannam@167 9811 % He also recommends making @example and @lisp be small.
cannam@167 9812 \def\afivepaper{{\globaldefs = 1
cannam@167 9813 \parskip = 2pt plus 1pt minus 0.1pt
cannam@167 9814 \textleading = 12.5pt
cannam@167 9815 %
cannam@167 9816 \internalpagesizes{160mm}{120mm}%
cannam@167 9817 {\voffset}{\hoffset}%
cannam@167 9818 {\bindingoffset}{8pt}%
cannam@167 9819 {210mm}{148mm}%
cannam@167 9820 %
cannam@167 9821 \lispnarrowing = 0.2in
cannam@167 9822 \tolerance = 800
cannam@167 9823 \hfuzz = 1.2pt
cannam@167 9824 \contentsrightmargin = 0pt
cannam@167 9825 \defbodyindent = 2mm
cannam@167 9826 \tableindent = 12mm
cannam@167 9827 }}
cannam@167 9828
cannam@167 9829 % A specific text layout, 24x15cm overall, intended for A4 paper.
cannam@167 9830 \def\afourlatex{{\globaldefs = 1
cannam@167 9831 \afourpaper
cannam@167 9832 \internalpagesizes{237mm}{150mm}%
cannam@167 9833 {\voffset}{4.6mm}%
cannam@167 9834 {\bindingoffset}{7mm}%
cannam@167 9835 {297mm}{210mm}%
cannam@167 9836 %
cannam@167 9837 % Must explicitly reset to 0 because we call \afourpaper.
cannam@167 9838 \globaldefs = 0
cannam@167 9839 }}
cannam@167 9840
cannam@167 9841 % Use @afourwide to print on A4 paper in landscape format.
cannam@167 9842 \def\afourwide{{\globaldefs = 1
cannam@167 9843 \afourpaper
cannam@167 9844 \internalpagesizes{241mm}{165mm}%
cannam@167 9845 {\voffset}{-2.95mm}%
cannam@167 9846 {\bindingoffset}{7mm}%
cannam@167 9847 {297mm}{210mm}%
cannam@167 9848 \globaldefs = 0
cannam@167 9849 }}
cannam@167 9850
cannam@167 9851 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
cannam@167 9852 % Perhaps we should allow setting the margins, \topskip, \parskip,
cannam@167 9853 % and/or leading, also. Or perhaps we should compute them somehow.
cannam@167 9854 %
cannam@167 9855 \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
cannam@167 9856 \def\pagesizesyyy#1,#2,#3\finish{{%
cannam@167 9857 \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
cannam@167 9858 \globaldefs = 1
cannam@167 9859 %
cannam@167 9860 \parskip = 3pt plus 2pt minus 1pt
cannam@167 9861 \setleading{\textleading}%
cannam@167 9862 %
cannam@167 9863 \dimen0 = #1\relax
cannam@167 9864 \advance\dimen0 by \voffset
cannam@167 9865 %
cannam@167 9866 \dimen2 = \hsize
cannam@167 9867 \advance\dimen2 by \normaloffset
cannam@167 9868 %
cannam@167 9869 \internalpagesizes{#1}{\hsize}%
cannam@167 9870 {\voffset}{\normaloffset}%
cannam@167 9871 {\bindingoffset}{44pt}%
cannam@167 9872 {\dimen0}{\dimen2}%
cannam@167 9873 }}
cannam@167 9874
cannam@167 9875 % Set default to letter.
cannam@167 9876 %
cannam@167 9877 \letterpaper
cannam@167 9878
cannam@167 9879
cannam@167 9880 \message{and turning on texinfo input format.}
cannam@167 9881
cannam@167 9882 \def^^L{\par} % remove \outer, so ^L can appear in an @comment
cannam@167 9883
cannam@167 9884 % DEL is a comment character, in case @c does not suffice.
cannam@167 9885 \catcode`\^^? = 14
cannam@167 9886
cannam@167 9887 % Define macros to output various characters with catcode for normal text.
cannam@167 9888 \catcode`\"=\other \def\normaldoublequote{"}
cannam@167 9889 \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
cannam@167 9890 \catcode`\+=\other \def\normalplus{+}
cannam@167 9891 \catcode`\<=\other \def\normalless{<}
cannam@167 9892 \catcode`\>=\other \def\normalgreater{>}
cannam@167 9893 \catcode`\^=\other \def\normalcaret{^}
cannam@167 9894 \catcode`\_=\other \def\normalunderscore{_}
cannam@167 9895 \catcode`\|=\other \def\normalverticalbar{|}
cannam@167 9896 \catcode`\~=\other \def\normaltilde{~}
cannam@167 9897
cannam@167 9898 % This macro is used to make a character print one way in \tt
cannam@167 9899 % (where it can probably be output as-is), and another way in other fonts,
cannam@167 9900 % where something hairier probably needs to be done.
cannam@167 9901 %
cannam@167 9902 % #1 is what to print if we are indeed using \tt; #2 is what to print
cannam@167 9903 % otherwise. Since all the Computer Modern typewriter fonts have zero
cannam@167 9904 % interword stretch (and shrink), and it is reasonable to expect all
cannam@167 9905 % typewriter fonts to have this, we can check that font parameter.
cannam@167 9906 %
cannam@167 9907 \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
cannam@167 9908
cannam@167 9909 % Same as above, but check for italic font. Actually this also catches
cannam@167 9910 % non-italic slanted fonts since it is impossible to distinguish them from
cannam@167 9911 % italic fonts. But since this is only used by $ and it uses \sl anyway
cannam@167 9912 % this is not a problem.
cannam@167 9913 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
cannam@167 9914
cannam@167 9915 % Turn off all special characters except @
cannam@167 9916 % (and those which the user can use as if they were ordinary).
cannam@167 9917 % Most of these we simply print from the \tt font, but for some, we can
cannam@167 9918 % use math or other variants that look better in normal text.
cannam@167 9919
cannam@167 9920 \catcode`\"=\active
cannam@167 9921 \def\activedoublequote{{\tt\char34}}
cannam@167 9922 \let"=\activedoublequote
cannam@167 9923 \catcode`\~=\active
cannam@167 9924 \def~{{\tt\char126}}
cannam@167 9925 \chardef\hat=`\^
cannam@167 9926 \catcode`\^=\active
cannam@167 9927 \def^{{\tt \hat}}
cannam@167 9928
cannam@167 9929 \catcode`\_=\active
cannam@167 9930 \def_{\ifusingtt\normalunderscore\_}
cannam@167 9931 \let\realunder=_
cannam@167 9932 % Subroutine for the previous macro.
cannam@167 9933 \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
cannam@167 9934
cannam@167 9935 \catcode`\|=\active
cannam@167 9936 \def|{{\tt\char124}}
cannam@167 9937 \chardef \less=`\<
cannam@167 9938 \catcode`\<=\active
cannam@167 9939 \def<{{\tt \less}}
cannam@167 9940 \chardef \gtr=`\>
cannam@167 9941 \catcode`\>=\active
cannam@167 9942 \def>{{\tt \gtr}}
cannam@167 9943 \catcode`\+=\active
cannam@167 9944 \def+{{\tt \char 43}}
cannam@167 9945 \catcode`\$=\active
cannam@167 9946 \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
cannam@167 9947
cannam@167 9948 % If a .fmt file is being used, characters that might appear in a file
cannam@167 9949 % name cannot be active until we have parsed the command line.
cannam@167 9950 % So turn them off again, and have \everyjob (or @setfilename) turn them on.
cannam@167 9951 % \otherifyactive is called near the end of this file.
cannam@167 9952 \def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
cannam@167 9953
cannam@167 9954 % Used sometimes to turn off (effectively) the active characters even after
cannam@167 9955 % parsing them.
cannam@167 9956 \def\turnoffactive{%
cannam@167 9957 \normalturnoffactive
cannam@167 9958 \otherbackslash
cannam@167 9959 }
cannam@167 9960
cannam@167 9961 \catcode`\@=0
cannam@167 9962
cannam@167 9963 % \backslashcurfont outputs one backslash character in current font,
cannam@167 9964 % as in \char`\\.
cannam@167 9965 \global\chardef\backslashcurfont=`\\
cannam@167 9966 \global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work
cannam@167 9967
cannam@167 9968 % \realbackslash is an actual character `\' with catcode other, and
cannam@167 9969 % \doublebackslash is two of them (for the pdf outlines).
cannam@167 9970 {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
cannam@167 9971
cannam@167 9972 % In texinfo, backslash is an active character; it prints the backslash
cannam@167 9973 % in fixed width font.
cannam@167 9974 \catcode`\\=\active % @ for escape char from now on.
cannam@167 9975
cannam@167 9976 % The story here is that in math mode, the \char of \backslashcurfont
cannam@167 9977 % ends up printing the roman \ from the math symbol font (because \char
cannam@167 9978 % in math mode uses the \mathcode, and plain.tex sets
cannam@167 9979 % \mathcode`\\="026E). It seems better for @backslashchar{} to always
cannam@167 9980 % print a typewriter backslash, hence we use an explicit \mathchar,
cannam@167 9981 % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
cannam@167 9982 % ignored family value; char position "5C). We can't use " for the
cannam@167 9983 % usual hex value because it has already been made active.
cannam@167 9984 @def@normalbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
cannam@167 9985 @let@backslashchar = @normalbackslash % @backslashchar{} is for user documents.
cannam@167 9986
cannam@167 9987 % On startup, @fixbackslash assigns:
cannam@167 9988 % @let \ = @normalbackslash
cannam@167 9989 % \rawbackslash defines an active \ to do \backslashcurfont.
cannam@167 9990 % \otherbackslash defines an active \ to be a literal `\' character with
cannam@167 9991 % catcode other. We switch back and forth between these.
cannam@167 9992 @gdef@rawbackslash{@let\=@backslashcurfont}
cannam@167 9993 @gdef@otherbackslash{@let\=@realbackslash}
cannam@167 9994
cannam@167 9995 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
cannam@167 9996 % the literal character `\'. Also revert - to its normal character, in
cannam@167 9997 % case the active - from code has slipped in.
cannam@167 9998 %
cannam@167 9999 {@catcode`- = @active
cannam@167 10000 @gdef@normalturnoffactive{%
cannam@167 10001 @let-=@normaldash
cannam@167 10002 @let"=@normaldoublequote
cannam@167 10003 @let$=@normaldollar %$ font-lock fix
cannam@167 10004 @let+=@normalplus
cannam@167 10005 @let<=@normalless
cannam@167 10006 @let>=@normalgreater
cannam@167 10007 @let\=@normalbackslash
cannam@167 10008 @let^=@normalcaret
cannam@167 10009 @let_=@normalunderscore
cannam@167 10010 @let|=@normalverticalbar
cannam@167 10011 @let~=@normaltilde
cannam@167 10012 @markupsetuplqdefault
cannam@167 10013 @markupsetuprqdefault
cannam@167 10014 @unsepspaces
cannam@167 10015 }
cannam@167 10016 }
cannam@167 10017
cannam@167 10018 % Make _ and + \other characters, temporarily.
cannam@167 10019 % This is canceled by @fixbackslash.
cannam@167 10020 @otherifyactive
cannam@167 10021
cannam@167 10022 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
cannam@167 10023 % That is what \eatinput is for; after that, the `\' should revert to printing
cannam@167 10024 % a backslash.
cannam@167 10025 %
cannam@167 10026 @gdef@eatinput input texinfo{@fixbackslash}
cannam@167 10027 @global@let\ = @eatinput
cannam@167 10028
cannam@167 10029 % On the other hand, perhaps the file did not have a `\input texinfo'. Then
cannam@167 10030 % the first `\' in the file would cause an error. This macro tries to fix
cannam@167 10031 % that, assuming it is called before the first `\' could plausibly occur.
cannam@167 10032 % Also turn back on active characters that might appear in the input
cannam@167 10033 % file name, in case not using a pre-dumped format.
cannam@167 10034 %
cannam@167 10035 @gdef@fixbackslash{%
cannam@167 10036 @ifx\@eatinput @let\ = @normalbackslash @fi
cannam@167 10037 @catcode`+=@active
cannam@167 10038 @catcode`@_=@active
cannam@167 10039 }
cannam@167 10040
cannam@167 10041 % Say @foo, not \foo, in error messages.
cannam@167 10042 @escapechar = `@@
cannam@167 10043
cannam@167 10044 % These (along with & and #) are made active for url-breaking, so need
cannam@167 10045 % active definitions as the normal characters.
cannam@167 10046 @def@normaldot{.}
cannam@167 10047 @def@normalquest{?}
cannam@167 10048 @def@normalslash{/}
cannam@167 10049
cannam@167 10050 % These look ok in all fonts, so just make them not special.
cannam@167 10051 % @hashchar{} gets its own user-level command, because of #line.
cannam@167 10052 @catcode`@& = @other @def@normalamp{&}
cannam@167 10053 @catcode`@# = @other @def@normalhash{#}
cannam@167 10054 @catcode`@% = @other @def@normalpercent{%}
cannam@167 10055
cannam@167 10056 @let @hashchar = @normalhash
cannam@167 10057
cannam@167 10058 @c Finally, make ` and ' active, so that txicodequoteundirected and
cannam@167 10059 @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we
cannam@167 10060 @c don't make ` and ' active, @code will not get them as active chars.
cannam@167 10061 @c Do this last of all since we use ` in the previous @catcode assignments.
cannam@167 10062 @catcode`@'=@active
cannam@167 10063 @catcode`@`=@active
cannam@167 10064 @markupsetuplqdefault
cannam@167 10065 @markupsetuprqdefault
cannam@167 10066
cannam@167 10067 @c Local variables:
cannam@167 10068 @c eval: (add-hook 'write-file-hooks 'time-stamp)
cannam@167 10069 @c page-delimiter: "^\\\\message"
cannam@167 10070 @c time-stamp-start: "def\\\\texinfoversion{"
cannam@167 10071 @c time-stamp-format: "%:y-%02m-%02d.%02H"
cannam@167 10072 @c time-stamp-end: "}"
cannam@167 10073 @c End:
cannam@167 10074
cannam@167 10075 @c vim:sw=2:
cannam@167 10076
cannam@167 10077 @ignore
cannam@167 10078 arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
cannam@167 10079 @end ignore