]> code.delx.au - gnu-emacs/blob - doc/misc/texinfo.tex
Update texinfo.tex
[gnu-emacs] / doc / misc / texinfo.tex
1 % texinfo.tex -- TeX macros to handle Texinfo files.
2 %
3 % Load plain if necessary, i.e., if running under initex.
4 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5 %
6 \def\texinfoversion{2016-06-07.21}
7 %
8 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
9 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
10 % 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
11 % Free Software Foundation, Inc.
12 %
13 % This texinfo.tex file is free software: you can redistribute it and/or
14 % modify it under the terms of the GNU General Public License as
15 % published by the Free Software Foundation, either version 3 of the
16 % License, or (at your option) any later version.
17 %
18 % This texinfo.tex file is distributed in the hope that it will be
19 % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
20 % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 % General Public License for more details.
22 %
23 % You should have received a copy of the GNU General Public License
24 % along with this program. If not, see <http://www.gnu.org/licenses/>.
25 %
26 % As a special exception, when this file is read by TeX when processing
27 % a Texinfo source document, you may use the result without
28 % restriction. This Exception is an additional permission under section 7
29 % of the GNU General Public License, version 3 ("GPLv3").
30 %
31 % Please try the latest version of texinfo.tex before submitting bug
32 % reports; you can get the latest version from:
33 % http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
34 % http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
35 % http://www.gnu.org/software/texinfo/ (the Texinfo home page)
36 % The texinfo.tex in any given distribution could well be out
37 % of date, so if that's what you're using, please check.
38 %
39 % Send bug reports to bug-texinfo@gnu.org. Please include including a
40 % complete document in each bug report with which we can reproduce the
41 % problem. Patches are, of course, greatly appreciated.
42 %
43 % To process a Texinfo manual with TeX, it's most reliable to use the
44 % texi2dvi shell script that comes with the distribution. For a simple
45 % manual foo.texi, however, you can get away with this:
46 % tex foo.texi
47 % texindex foo.??
48 % tex foo.texi
49 % tex foo.texi
50 % dvips foo.dvi -o # or whatever; this makes foo.ps.
51 % The extra TeX runs get the cross-reference information correct.
52 % Sometimes one run after texindex suffices, and sometimes you need more
53 % than two; texi2dvi does it as many times as necessary.
54 %
55 % It is possible to adapt texinfo.tex for other languages, to some
56 % extent. You can get the existing language-specific files from the
57 % full Texinfo distribution.
58 %
59 % The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
60
61
62 \message{Loading texinfo [version \texinfoversion]:}
63
64 % If in a .fmt file, print the version number
65 % and turn on active characters that we couldn't do earlier because
66 % they might have appeared in the input file name.
67 \everyjob{\message{[Texinfo version \texinfoversion]}%
68 \catcode`+=\active \catcode`\_=\active}
69
70 % LaTeX's \typeout. This ensures that the messages it is used for
71 % are identical in format to the corresponding ones from latex/pdflatex.
72 \def\typeout{\immediate\write17}%
73
74 \chardef\other=12
75
76 % We never want plain's \outer definition of \+ in Texinfo.
77 % For @tex, we can use \tabalign.
78 \let\+ = \relax
79
80 % Save some plain tex macros whose names we will redefine.
81 \let\ptexb=\b
82 \let\ptexbullet=\bullet
83 \let\ptexc=\c
84 \let\ptexcomma=\,
85 \let\ptexdot=\.
86 \let\ptexdots=\dots
87 \let\ptexend=\end
88 \let\ptexequiv=\equiv
89 \let\ptexexclam=\!
90 \let\ptexfootnote=\footnote
91 \let\ptexgtr=>
92 \let\ptexhat=^
93 \let\ptexi=\i
94 \let\ptexindent=\indent
95 \let\ptexinsert=\insert
96 \let\ptexlbrace=\{
97 \let\ptexless=<
98 \let\ptexnewwrite\newwrite
99 \let\ptexnoindent=\noindent
100 \let\ptexplus=+
101 \let\ptexraggedright=\raggedright
102 \let\ptexrbrace=\}
103 \let\ptexslash=\/
104 \let\ptexsp=\sp
105 \let\ptexstar=\*
106 \let\ptexsup=\sup
107 \let\ptext=\t
108 \let\ptextop=\top
109 {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
110
111 % If this character appears in an error message or help string, it
112 % starts a new line in the output.
113 \newlinechar = `^^J
114
115 % Use TeX 3.0's \inputlineno to get the line number, for better error
116 % messages, but if we're using an old version of TeX, don't do anything.
117 %
118 \ifx\inputlineno\thisisundefined
119 \let\linenumber = \empty % Pre-3.0.
120 \else
121 \def\linenumber{l.\the\inputlineno:\space}
122 \fi
123
124 % Set up fixed words for English if not already set.
125 \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
126 \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
127 \ifx\putworderror\undefined \gdef\putworderror{error}\fi
128 \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
129 \ifx\putwordin\undefined \gdef\putwordin{in}\fi
130 \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
131 \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
132 \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
133 \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
134 \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
135 \ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi
136 \ifx\putwordof\undefined \gdef\putwordof{of}\fi
137 \ifx\putwordon\undefined \gdef\putwordon{on}\fi
138 \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi
139 \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi
140 \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi
141 \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi
142 \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi
143 \ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi
144 \ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi
145 %
146 \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
147 \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
148 \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
149 \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
150 \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
151 \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
152 \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
153 \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
154 \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
155 \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
156 \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
157 \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
158 %
159 \ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi
160 \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi
161 \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi
162 \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi
163 \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi
164
165 % Give the space character the catcode for a space.
166 \def\spaceisspace{\catcode`\ =10\relax}
167
168 \chardef\dashChar = `\-
169 \chardef\slashChar = `\/
170 \chardef\underChar = `\_
171
172 % Ignore a token.
173 %
174 \def\gobble#1{}
175
176 % The following is used inside several \edef's.
177 \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
178
179 % Hyphenation fixes.
180 \hyphenation{
181 Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
182 ap-pen-dix bit-map bit-maps
183 data-base data-bases eshell fall-ing half-way long-est man-u-script
184 man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
185 par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
186 spell-ing spell-ings
187 stand-alone strong-est time-stamp time-stamps which-ever white-space
188 wide-spread wrap-around
189 }
190
191 % Sometimes it is convenient to have everything in the transcript file
192 % and nothing on the terminal. We don't just call \tracingall here,
193 % since that produces some useless output on the terminal. We also make
194 % some effort to order the tracing commands to reduce output in the log
195 % file; cf. trace.sty in LaTeX.
196 %
197 \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
198 \def\loggingall{%
199 \tracingstats2
200 \tracingpages1
201 \tracinglostchars2 % 2 gives us more in etex
202 \tracingparagraphs1
203 \tracingoutput1
204 \tracingmacros2
205 \tracingrestores1
206 \showboxbreadth\maxdimen \showboxdepth\maxdimen
207 \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
208 \tracingscantokens1
209 \tracingifs1
210 \tracinggroups1
211 \tracingnesting2
212 \tracingassigns1
213 \fi
214 \tracingcommands3 % 3 gives us more in etex
215 \errorcontextlines16
216 }%
217
218 % @errormsg{MSG}. Do the index-like expansions on MSG, but if things
219 % aren't perfect, it's not the end of the world, being an error message,
220 % after all.
221 %
222 \def\errormsg{\begingroup \indexnofonts \doerrormsg}
223 \def\doerrormsg#1{\errmessage{#1}}
224
225 % add check for \lastpenalty to plain's definitions. If the last thing
226 % we did was a \nobreak, we don't want to insert more space.
227 %
228 \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
229 \removelastskip\penalty-50\smallskip\fi\fi}
230 \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
231 \removelastskip\penalty-100\medskip\fi\fi}
232 \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
233 \removelastskip\penalty-200\bigskip\fi\fi}
234
235 %\f Output routine
236 %
237
238 % For a final copy, take out the rectangles
239 % that mark overfull boxes (in case you have decided
240 % that the text looks ok even though it passes the margin).
241 %
242 \def\finalout{\overfullrule=0pt }
243
244 % Do @cropmarks to get crop marks.
245 %
246 \newif\ifcropmarks
247 \let\cropmarks = \cropmarkstrue
248 %
249 % Dimensions to add cropmarks at corners.
250 % Added by P. A. MacKay, 12 Nov. 1986
251 %
252 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
253 \newdimen\cornerlong \cornerlong=1pc
254 \newdimen\cornerthick \cornerthick=.3pt
255 \newdimen\topandbottommargin \topandbottommargin=.75in
256
257 % Output a mark which sets \thischapter, \thissection and \thiscolor.
258 % We dump everything together because we only have one kind of mark.
259 % This works because we only use \botmark / \topmark, not \firstmark.
260 %
261 % A mark contains a subexpression of the \ifcase ... \fi construct.
262 % \get*marks macros below extract the needed part using \ifcase.
263 %
264 % Another complication is to let the user choose whether \thischapter
265 % (\thissection) refers to the chapter (section) in effect at the top
266 % of a page, or that at the bottom of a page.
267
268 % \domark is called twice inside \chapmacro, to add one
269 % mark before the section break, and one after.
270 % In the second call \prevchapterdefs is the same as \lastchapterdefs,
271 % and \prevsectiondefs is the same as \lastsectiondefs.
272 % Then if the page is not broken at the mark, some of the previous
273 % section appears on the page, and we can get the name of this section
274 % from \firstmark for @everyheadingmarks top.
275 % @everyheadingmarks bottom uses \botmark.
276 %
277 % See page 260 of The TeXbook.
278 \def\domark{%
279 \toks0=\expandafter{\lastchapterdefs}%
280 \toks2=\expandafter{\lastsectiondefs}%
281 \toks4=\expandafter{\prevchapterdefs}%
282 \toks6=\expandafter{\prevsectiondefs}%
283 \toks8=\expandafter{\lastcolordefs}%
284 \mark{%
285 \the\toks0 \the\toks2 % 0: marks for @everyheadingmarks top
286 \noexpand\or \the\toks4 \the\toks6 % 1: for @everyheadingmarks bottom
287 \noexpand\else \the\toks8 % 2: color marks
288 }%
289 }
290
291 % \gettopheadingmarks, \getbottomheadingmarks,
292 % \getcolormarks - extract needed part of mark.
293 %
294 % \topmark doesn't work for the very first chapter (after the title
295 % page or the contents), so we use \firstmark there -- this gets us
296 % the mark with the chapter defs, unless the user sneaks in, e.g.,
297 % @setcolor (or @url, or @link, etc.) between @contents and the very
298 % first @chapter.
299 \def\gettopheadingmarks{%
300 \ifcase0\topmark\fi
301 \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
302 }
303 \def\getbottomheadingmarks{\ifcase1\botmark\fi}
304 \def\getcolormarks{\ifcase2\topmark\fi}
305
306 % Avoid "undefined control sequence" errors.
307 \def\lastchapterdefs{}
308 \def\lastsectiondefs{}
309 \def\lastsection{}
310 \def\prevchapterdefs{}
311 \def\prevsectiondefs{}
312 \def\lastcolordefs{}
313
314 % Margin to add to right of even pages, to left of odd pages.
315 \newdimen\bindingoffset
316 \newdimen\normaloffset
317 \newdimen\txipagewidth \newdimen\txipageheight
318
319 % Main output routine.
320 %
321 \chardef\PAGE = 255
322 \output = {\onepageout{\pagecontents\PAGE}}
323
324 \newbox\headlinebox
325 \newbox\footlinebox
326
327 % \onepageout takes a vbox as an argument.
328 % \shipout a vbox for a single page, adding an optional header, footer,
329 % cropmarks, and footnote. This also causes index entries for this page
330 % to be written to the auxiliary files.
331 %
332 \def\onepageout#1{%
333 \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
334 %
335 \ifodd\pageno \advance\hoffset by \bindingoffset
336 \else \advance\hoffset by -\bindingoffset\fi
337 %
338 % Common context changes for both heading and footing.
339 % Do this outside of the \shipout so @code etc. will be expanded in
340 % the headline as they should be, not taken literally (outputting ''code).
341 \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars}
342 %
343 % Retrieve the information for the headings from the marks in the page,
344 % and call Plain TeX's \makeheadline and \makefootline, which use the
345 % values in \headline and \footline.
346 %
347 % This is used to check if we are on the first page of a chapter.
348 \ifcase1\topmark\fi
349 \let\prevchaptername\thischaptername
350 \ifcase0\firstmark\fi
351 \let\curchaptername\thischaptername
352 %
353 \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
354 \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
355 %
356 \ifx\curchaptername\prevchaptername
357 \let\thischapterheading\thischapter
358 \else
359 % \thischapterheading is the same as \thischapter except it is blank
360 % for the first page of a chapter. This is to prevent the chapter name
361 % being shown twice.
362 \def\thischapterheading{}%
363 \fi
364 %
365 \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}%
366 \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}%
367 %
368 {%
369 % Set context for writing to auxiliary files like index files.
370 % Have to do this stuff outside the \shipout because we want it to
371 % take effect in \write's, yet the group defined by the \vbox ends
372 % before the \shipout runs.
373 %
374 \indexdummies % don't expand commands in the output.
375 \normalturnoffactive % \ in index entries must not stay \, e.g., if
376 % the page break happens to be in the middle of an example.
377 % We don't want .vr (or whatever) entries like this:
378 % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}}
379 % "\acronym" won't work when it's read back in;
380 % it needs to be
381 % {\code {{\backslashcurfont }acronym}
382 \shipout\vbox{%
383 % Do this early so pdf references go to the beginning of the page.
384 \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
385 %
386 \ifcropmarks \vbox to \outervsize\bgroup
387 \hsize = \outerhsize
388 \vskip-\topandbottommargin
389 \vtop to0pt{%
390 \line{\ewtop\hfil\ewtop}%
391 \nointerlineskip
392 \line{%
393 \vbox{\moveleft\cornerthick\nstop}%
394 \hfill
395 \vbox{\moveright\cornerthick\nstop}%
396 }%
397 \vss}%
398 \vskip\topandbottommargin
399 \line\bgroup
400 \hfil % center the page within the outer (page) hsize.
401 \ifodd\pageno\hskip\bindingoffset\fi
402 \vbox\bgroup
403 \fi
404 %
405 \unvbox\headlinebox
406 \pagebody{#1}%
407 \ifdim\ht\footlinebox > 0pt
408 % Only leave this space if the footline is nonempty.
409 % (We lessened \vsize for it in \oddfootingyyy.)
410 % The \baselineskip=24pt in plain's \makefootline has no effect.
411 \vskip 24pt
412 \unvbox\footlinebox
413 \fi
414 %
415 \ifcropmarks
416 \egroup % end of \vbox\bgroup
417 \hfil\egroup % end of (centering) \line\bgroup
418 \vskip\topandbottommargin plus1fill minus1fill
419 \boxmaxdepth = \cornerthick
420 \vbox to0pt{\vss
421 \line{%
422 \vbox{\moveleft\cornerthick\nsbot}%
423 \hfill
424 \vbox{\moveright\cornerthick\nsbot}%
425 }%
426 \nointerlineskip
427 \line{\ewbot\hfil\ewbot}%
428 }%
429 \egroup % \vbox from first cropmarks clause
430 \fi
431 }% end of \shipout\vbox
432 }% end of group with \indexdummies
433 \advancepageno
434 \ifnum\outputpenalty>-20000 \else\dosupereject\fi
435 }
436
437 \newinsert\margin \dimen\margin=\maxdimen
438
439 % Main part of page, including any footnotes
440 \def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
441 {\catcode`\@ =11
442 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
443 % marginal hacks, juha@viisa.uucp (Juha Takala)
444 \ifvoid\margin\else % marginal info is present
445 \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
446 \dimen@=\dp#1\relax \unvbox#1\relax
447 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
448 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
449 }
450
451 % Here are the rules for the cropmarks. Note that they are
452 % offset so that the space between them is truly \outerhsize or \outervsize
453 % (P. A. MacKay, 12 November, 1986)
454 %
455 \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
456 \def\nstop{\vbox
457 {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
458 \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
459 \def\nsbot{\vbox
460 {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
461
462
463 % Argument parsing
464
465 % Parse an argument, then pass it to #1. The argument is the rest of
466 % the input line (except we remove a trailing comment). #1 should be a
467 % macro which expects an ordinary undelimited TeX argument.
468 % For example, \def\foo{\parsearg\fooxxx}.
469 %
470 \def\parsearg{\parseargusing{}}
471 \def\parseargusing#1#2{%
472 \def\argtorun{#2}%
473 \begingroup
474 \obeylines
475 \spaceisspace
476 #1%
477 \parseargline\empty% Insert the \empty token, see \finishparsearg below.
478 }
479
480 {\obeylines %
481 \gdef\parseargline#1^^M{%
482 \endgroup % End of the group started in \parsearg.
483 \argremovecomment #1\comment\ArgTerm%
484 }%
485 }
486
487 % First remove any @comment, then any @c comment. Also remove a @texinfoc
488 % comment (see \scanmacro for details). Pass the result on to \argcheckspaces.
489 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
490 \def\argremovec#1\c#2\ArgTerm{\argremovetexinfoc #1\texinfoc\ArgTerm}
491 \def\argremovetexinfoc#1\texinfoc#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
492
493 % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
494 %
495 % \argremovec might leave us with trailing space, e.g.,
496 % @end itemize @c foo
497 % This space token undergoes the same procedure and is eventually removed
498 % by \finishparsearg.
499 %
500 \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
501 \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
502 \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
503 \def\temp{#3}%
504 \ifx\temp\empty
505 % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
506 \let\temp\finishparsearg
507 \else
508 \let\temp\argcheckspaces
509 \fi
510 % Put the space token in:
511 \temp#1 #3\ArgTerm
512 }
513
514 % If a _delimited_ argument is enclosed in braces, they get stripped; so
515 % to get _exactly_ the rest of the line, we had to prevent such situation.
516 % We prepended an \empty token at the very beginning and we expand it now,
517 % just before passing the control to \argtorun.
518 % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
519 % either the null string, or it ends with \^^M---thus there is no danger
520 % that a pair of braces would be stripped.
521 %
522 % But first, we have to remove the trailing space token.
523 %
524 \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
525
526
527 % \parseargdef - define a command taking an argument on the line
528 %
529 % \parseargdef\foo{...}
530 % is roughly equivalent to
531 % \def\foo{\parsearg\Xfoo}
532 % \def\Xfoo#1{...}
533 \def\parseargdef#1{%
534 \expandafter \doparseargdef \csname\string#1\endcsname #1%
535 }
536 \def\doparseargdef#1#2{%
537 \def#2{\parsearg#1}%
538 \def#1##1%
539 }
540
541 % Several utility definitions with active space:
542 {
543 \obeyspaces
544 \gdef\obeyedspace{ }
545
546 % Make each space character in the input produce a normal interword
547 % space in the output. Don't allow a line break at this space, as this
548 % is used only in environments like @example, where each line of input
549 % should produce a line of output anyway.
550 %
551 \gdef\sepspaces{\obeyspaces\let =\tie}
552
553 % If an index command is used in an @example environment, any spaces
554 % therein should become regular spaces in the raw index file, not the
555 % expansion of \tie (\leavevmode \penalty \@M \ ).
556 \gdef\unsepspaces{\let =\space}
557 }
558
559
560 \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
561
562 % Define the framework for environments in texinfo.tex. It's used like this:
563 %
564 % \envdef\foo{...}
565 % \def\Efoo{...}
566 %
567 % It's the responsibility of \envdef to insert \begingroup before the
568 % actual body; @end closes the group after calling \Efoo. \envdef also
569 % defines \thisenv, so the current environment is known; @end checks
570 % whether the environment name matches. The \checkenv macro can also be
571 % used to check whether the current environment is the one expected.
572 %
573 % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
574 % are not treated as environments; they don't open a group. (The
575 % implementation of @end takes care not to call \endgroup in this
576 % special case.)
577
578
579 % At run-time, environments start with this:
580 \def\startenvironment#1{\begingroup\def\thisenv{#1}}
581 % initialize
582 \let\thisenv\empty
583
584 % ... but they get defined via ``\envdef\foo{...}'':
585 \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
586 \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
587
588 % Check whether we're in the right environment:
589 \def\checkenv#1{%
590 \def\temp{#1}%
591 \ifx\thisenv\temp
592 \else
593 \badenverr
594 \fi
595 }
596
597 % Environment mismatch, #1 expected:
598 \def\badenverr{%
599 \errhelp = \EMsimple
600 \errmessage{This command can appear only \inenvironment\temp,
601 not \inenvironment\thisenv}%
602 }
603 \def\inenvironment#1{%
604 \ifx#1\empty
605 outside of any environment%
606 \else
607 in environment \expandafter\string#1%
608 \fi
609 }
610
611 % @end foo executes the definition of \Efoo.
612 % But first, it executes a specialized version of \checkenv
613 %
614 \parseargdef\end{%
615 \if 1\csname iscond.#1\endcsname
616 \else
617 % The general wording of \badenverr may not be ideal.
618 \expandafter\checkenv\csname#1\endcsname
619 \csname E#1\endcsname
620 \endgroup
621 \fi
622 }
623
624 \newhelp\EMsimple{Press RETURN to continue.}
625
626
627 % Be sure we're in horizontal mode when doing a tie, since we make space
628 % equivalent to this in @example-like environments. Otherwise, a space
629 % at the beginning of a line will start with \penalty -- and
630 % since \penalty is valid in vertical mode, we'd end up putting the
631 % penalty on the vertical list instead of in the new paragraph.
632 {\catcode`@ = 11
633 % Avoid using \@M directly, because that causes trouble
634 % if the definition is written into an index file.
635 \global\let\tiepenalty = \@M
636 \gdef\tie{\leavevmode\penalty\tiepenalty\ }
637 }
638
639 % @: forces normal size whitespace following.
640 \def\:{\spacefactor=1000 }
641
642 % @* forces a line break.
643 \def\*{\unskip\hfil\break\hbox{}\ignorespaces}
644
645 % @/ allows a line break.
646 \let\/=\allowbreak
647
648 % @. is an end-of-sentence period.
649 \def\.{.\spacefactor=\endofsentencespacefactor\space}
650
651 % @! is an end-of-sentence bang.
652 \def\!{!\spacefactor=\endofsentencespacefactor\space}
653
654 % @? is an end-of-sentence query.
655 \def\?{?\spacefactor=\endofsentencespacefactor\space}
656
657 % @frenchspacing on|off says whether to put extra space after punctuation.
658 %
659 \def\onword{on}
660 \def\offword{off}
661 %
662 \parseargdef\frenchspacing{%
663 \def\temp{#1}%
664 \ifx\temp\onword \plainfrenchspacing
665 \else\ifx\temp\offword \plainnonfrenchspacing
666 \else
667 \errhelp = \EMsimple
668 \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
669 \fi\fi
670 }
671
672 % @w prevents a word break. Without the \leavevmode, @w at the
673 % beginning of a paragraph, when TeX is still in vertical mode, would
674 % produce a whole line of output instead of starting the paragraph.
675 \def\w#1{\leavevmode\hbox{#1}}
676
677 % @group ... @end group forces ... to be all on one page, by enclosing
678 % it in a TeX vbox. We use \vtop instead of \vbox to construct the box
679 % to keep its height that of a normal line. According to the rules for
680 % \topskip (p.114 of the TeXbook), the glue inserted is
681 % max (\topskip - \ht (first item), 0). If that height is large,
682 % therefore, no glue is inserted, and the space between the headline and
683 % the text is small, which looks bad.
684 %
685 % Another complication is that the group might be very large. This can
686 % cause the glue on the previous page to be unduly stretched, because it
687 % does not have much material. In this case, it's better to add an
688 % explicit \vfill so that the extra space is at the bottom. The
689 % threshold for doing this is if the group is more than \vfilllimit
690 % percent of a page (\vfilllimit can be changed inside of @tex).
691 %
692 \newbox\groupbox
693 \def\vfilllimit{0.7}
694 %
695 \envdef\group{%
696 \ifnum\catcode`\^^M=\active \else
697 \errhelp = \groupinvalidhelp
698 \errmessage{@group invalid in context where filling is enabled}%
699 \fi
700 \startsavinginserts
701 %
702 \setbox\groupbox = \vtop\bgroup
703 % Do @comment since we are called inside an environment such as
704 % @example, where each end-of-line in the input causes an
705 % end-of-line in the output. We don't want the end-of-line after
706 % the `@group' to put extra space in the output. Since @group
707 % should appear on a line by itself (according to the Texinfo
708 % manual), we don't worry about eating any user text.
709 \comment
710 }
711 %
712 % The \vtop produces a box with normal height and large depth; thus, TeX puts
713 % \baselineskip glue before it, and (when the next line of text is done)
714 % \lineskip glue after it. Thus, space below is not quite equal to space
715 % above. But it's pretty close.
716 \def\Egroup{%
717 % To get correct interline space between the last line of the group
718 % and the first line afterwards, we have to propagate \prevdepth.
719 \endgraf % Not \par, as it may have been set to \lisppar.
720 \global\dimen1 = \prevdepth
721 \egroup % End the \vtop.
722 \addgroupbox
723 \prevdepth = \dimen1
724 \checkinserts
725 }
726
727 \def\addgroupbox{
728 % \dimen0 is the vertical size of the group's box.
729 \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox
730 % \dimen2 is how much space is left on the page (more or less).
731 \dimen2 = \txipageheight \advance\dimen2 by -\pagetotal
732 % if the group doesn't fit on the current page, and it's a big big
733 % group, force a page break.
734 \ifdim \dimen0 > \dimen2
735 \ifdim \pagetotal < \vfilllimit\txipageheight
736 \page
737 \fi
738 \fi
739 \box\groupbox
740 }
741
742 %
743 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
744 % message, so this ends up printing `@group can only ...'.
745 %
746 \newhelp\groupinvalidhelp{%
747 group can only be used in environments such as @example,^^J%
748 where each line of input produces a line of output.}
749
750 % @need space-in-mils
751 % forces a page break if there is not space-in-mils remaining.
752
753 \newdimen\mil \mil=0.001in
754
755 \parseargdef\need{%
756 % Ensure vertical mode, so we don't make a big box in the middle of a
757 % paragraph.
758 \par
759 %
760 % If the @need value is less than one line space, it's useless.
761 \dimen0 = #1\mil
762 \dimen2 = \ht\strutbox
763 \advance\dimen2 by \dp\strutbox
764 \ifdim\dimen0 > \dimen2
765 %
766 % Do a \strut just to make the height of this box be normal, so the
767 % normal leading is inserted relative to the preceding line.
768 % And a page break here is fine.
769 \vtop to #1\mil{\strut\vfil}%
770 %
771 % TeX does not even consider page breaks if a penalty added to the
772 % main vertical list is 10000 or more. But in order to see if the
773 % empty box we just added fits on the page, we must make it consider
774 % page breaks. On the other hand, we don't want to actually break the
775 % page after the empty box. So we use a penalty of 9999.
776 %
777 % There is an extremely small chance that TeX will actually break the
778 % page at this \penalty, if there are no other feasible breakpoints in
779 % sight. (If the user is using lots of big @group commands, which
780 % almost-but-not-quite fill up a page, TeX will have a hard time doing
781 % good page breaking, for example.) However, I could not construct an
782 % example where a page broke at this \penalty; if it happens in a real
783 % document, then we can reconsider our strategy.
784 \penalty9999
785 %
786 % Back up by the size of the box, whether we did a page break or not.
787 \kern -#1\mil
788 %
789 % Do not allow a page break right after this kern.
790 \nobreak
791 \fi
792 }
793
794 % @br forces paragraph break (and is undocumented).
795
796 \let\br = \par
797
798 % @page forces the start of a new page.
799 %
800 \def\page{\par\vfill\supereject}
801
802 % @exdent text....
803 % outputs text on separate line in roman font, starting at standard page margin
804
805 % This records the amount of indent in the innermost environment.
806 % That's how much \exdent should take out.
807 \newskip\exdentamount
808
809 % This defn is used inside fill environments such as @defun.
810 \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
811
812 % This defn is used inside nofill environments such as @example.
813 \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
814 \leftline{\hskip\leftskip{\rm#1}}}}
815
816 % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
817 % paragraph. For more general purposes, use the \margin insertion
818 % class. WHICH is `l' or `r'. Not documented, written for gawk manual.
819 %
820 \newskip\inmarginspacing \inmarginspacing=1cm
821 \def\strutdepth{\dp\strutbox}
822 %
823 \def\doinmargin#1#2{\strut\vadjust{%
824 \nobreak
825 \kern-\strutdepth
826 \vtop to \strutdepth{%
827 \baselineskip=\strutdepth
828 \vss
829 % if you have multiple lines of stuff to put here, you'll need to
830 % make the vbox yourself of the appropriate size.
831 \ifx#1l%
832 \llap{\ignorespaces #2\hskip\inmarginspacing}%
833 \else
834 \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
835 \fi
836 \null
837 }%
838 }}
839 \def\inleftmargin{\doinmargin l}
840 \def\inrightmargin{\doinmargin r}
841 %
842 % @inmargin{TEXT [, RIGHT-TEXT]}
843 % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
844 % else use TEXT for both).
845 %
846 \def\inmargin#1{\parseinmargin #1,,\finish}
847 \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
848 \setbox0 = \hbox{\ignorespaces #2}%
849 \ifdim\wd0 > 0pt
850 \def\lefttext{#1}% have both texts
851 \def\righttext{#2}%
852 \else
853 \def\lefttext{#1}% have only one text
854 \def\righttext{#1}%
855 \fi
856 %
857 \ifodd\pageno
858 \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
859 \else
860 \def\temp{\inleftmargin\lefttext}%
861 \fi
862 \temp
863 }
864
865 % @| inserts a changebar to the left of the current line. It should
866 % surround any changed text. This approach does *not* work if the
867 % change spans more than two lines of output. To handle that, we would
868 % have adopt a much more difficult approach (putting marks into the main
869 % vertical list for the beginning and end of each change). This command
870 % is not documented, not supported, and doesn't work.
871 %
872 \def\|{%
873 % \vadjust can only be used in horizontal mode.
874 \leavevmode
875 %
876 % Append this vertical mode material after the current line in the output.
877 \vadjust{%
878 % We want to insert a rule with the height and depth of the current
879 % leading; that is exactly what \strutbox is supposed to record.
880 \vskip-\baselineskip
881 %
882 % \vadjust-items are inserted at the left edge of the type. So
883 % the \llap here moves out into the left-hand margin.
884 \llap{%
885 %
886 % For a thicker or thinner bar, change the `1pt'.
887 \vrule height\baselineskip width1pt
888 %
889 % This is the space between the bar and the text.
890 \hskip 12pt
891 }%
892 }%
893 }
894
895 % @include FILE -- \input text of FILE.
896 %
897 \def\include{\parseargusing\filenamecatcodes\includezzz}
898 \def\includezzz#1{%
899 \pushthisfilestack
900 \def\thisfile{#1}%
901 {%
902 \makevalueexpandable % we want to expand any @value in FILE.
903 \turnoffactive % and allow special characters in the expansion
904 \indexnofonts % Allow `@@' and other weird things in file names.
905 \wlog{texinfo.tex: doing @include of #1^^J}%
906 \edef\temp{\noexpand\input #1 }%
907 %
908 % This trickery is to read FILE outside of a group, in case it makes
909 % definitions, etc.
910 \expandafter
911 }\temp
912 \popthisfilestack
913 }
914 \def\filenamecatcodes{%
915 \catcode`\\=\other
916 \catcode`~=\other
917 \catcode`^=\other
918 \catcode`_=\other
919 \catcode`|=\other
920 \catcode`<=\other
921 \catcode`>=\other
922 \catcode`+=\other
923 \catcode`-=\other
924 \catcode`\`=\other
925 \catcode`\'=\other
926 }
927
928 \def\pushthisfilestack{%
929 \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
930 }
931 \def\pushthisfilestackX{%
932 \expandafter\pushthisfilestackY\thisfile\StackTerm
933 }
934 \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
935 \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
936 }
937
938 \def\popthisfilestack{\errthisfilestackempty}
939 \def\errthisfilestackempty{\errmessage{Internal error:
940 the stack of filenames is empty.}}
941 %
942 \def\thisfile{}
943
944 % @center line
945 % outputs that line, centered.
946 %
947 \parseargdef\center{%
948 \ifhmode
949 \let\centersub\centerH
950 \else
951 \let\centersub\centerV
952 \fi
953 \centersub{\hfil \ignorespaces#1\unskip \hfil}%
954 \let\centersub\relax % don't let the definition persist, just in case
955 }
956 \def\centerH#1{{%
957 \hfil\break
958 \advance\hsize by -\leftskip
959 \advance\hsize by -\rightskip
960 \line{#1}%
961 \break
962 }}
963 %
964 \newcount\centerpenalty
965 \def\centerV#1{%
966 % The idea here is the same as in \startdefun, \cartouche, etc.: if
967 % @center is the first thing after a section heading, we need to wipe
968 % out the negative parskip inserted by \sectionheading, but still
969 % prevent a page break here.
970 \centerpenalty = \lastpenalty
971 \ifnum\centerpenalty>10000 \vskip\parskip \fi
972 \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
973 \line{\kern\leftskip #1\kern\rightskip}%
974 }
975
976 % @sp n outputs n lines of vertical space
977 %
978 \parseargdef\sp{\vskip #1\baselineskip}
979
980 % @comment ...line which is ignored...
981 % @c is the same as @comment
982 % @ignore ... @end ignore is another way to write a comment
983 %
984 \def\comment{\begingroup \catcode`\^^M=\active%
985 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other\commentxxx}%
986
987 {\catcode`\^^M=\active%
988 \gdef\commentxxx#1^^M{\endgroup%
989 \futurelet\nexttoken\commentxxxx}%
990 \gdef\commentxxxx{\ifx\nexttoken\aftermacro\expandafter\comment\fi}%
991 }
992
993 \def\c{\begingroup \catcode`\^^M=\active%
994 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
995 \cxxx}
996 {\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
997 % See comment in \scanmacro about why the definitions of @c and @comment differ
998
999 % @paragraphindent NCHARS
1000 % We'll use ems for NCHARS, close enough.
1001 % NCHARS can also be the word `asis' or `none'.
1002 % We cannot feasibly implement @paragraphindent asis, though.
1003 %
1004 \def\asisword{asis} % no translation, these are keywords
1005 \def\noneword{none}
1006 %
1007 \parseargdef\paragraphindent{%
1008 \def\temp{#1}%
1009 \ifx\temp\asisword
1010 \else
1011 \ifx\temp\noneword
1012 \defaultparindent = 0pt
1013 \else
1014 \defaultparindent = #1em
1015 \fi
1016 \fi
1017 \parindent = \defaultparindent
1018 }
1019
1020 % @exampleindent NCHARS
1021 % We'll use ems for NCHARS like @paragraphindent.
1022 % It seems @exampleindent asis isn't necessary, but
1023 % I preserve it to make it similar to @paragraphindent.
1024 \parseargdef\exampleindent{%
1025 \def\temp{#1}%
1026 \ifx\temp\asisword
1027 \else
1028 \ifx\temp\noneword
1029 \lispnarrowing = 0pt
1030 \else
1031 \lispnarrowing = #1em
1032 \fi
1033 \fi
1034 }
1035
1036 % @firstparagraphindent WORD
1037 % If WORD is `none', then suppress indentation of the first paragraph
1038 % after a section heading. If WORD is `insert', then do indent at such
1039 % paragraphs.
1040 %
1041 % The paragraph indentation is suppressed or not by calling
1042 % \suppressfirstparagraphindent, which the sectioning commands do.
1043 % We switch the definition of this back and forth according to WORD.
1044 % By default, we suppress indentation.
1045 %
1046 \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
1047 \def\insertword{insert}
1048 %
1049 \parseargdef\firstparagraphindent{%
1050 \def\temp{#1}%
1051 \ifx\temp\noneword
1052 \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
1053 \else\ifx\temp\insertword
1054 \let\suppressfirstparagraphindent = \relax
1055 \else
1056 \errhelp = \EMsimple
1057 \errmessage{Unknown @firstparagraphindent option `\temp'}%
1058 \fi\fi
1059 }
1060
1061 % Here is how we actually suppress indentation. Redefine \everypar to
1062 % \kern backwards by \parindent, and then reset itself to empty.
1063 %
1064 % We also make \indent itself not actually do anything until the next
1065 % paragraph.
1066 %
1067 \gdef\dosuppressfirstparagraphindent{%
1068 \gdef\indent {\restorefirstparagraphindent \indent}%
1069 \gdef\noindent{\restorefirstparagraphindent \noindent}%
1070 \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
1071 }
1072 %
1073 \gdef\restorefirstparagraphindent{%
1074 \global\let\indent = \ptexindent
1075 \global\let\noindent = \ptexnoindent
1076 \global\everypar = {}%
1077 }
1078
1079
1080 % @refill is a no-op.
1081 \let\refill=\relax
1082
1083 % @setfilename INFO-FILENAME - ignored
1084 \let\setfilename=\comment
1085
1086 % @bye.
1087 \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
1088
1089
1090 \message{pdf,}
1091 % adobe `portable' document format
1092 \newcount\tempnum
1093 \newcount\lnkcount
1094 \newtoks\filename
1095 \newcount\filenamelength
1096 \newcount\pgn
1097 \newtoks\toksA
1098 \newtoks\toksB
1099 \newtoks\toksC
1100 \newtoks\toksD
1101 \newbox\boxA
1102 \newbox\boxB
1103 \newcount\countA
1104 \newif\ifpdf
1105 \newif\ifpdfmakepagedest
1106
1107 %
1108 % For LuaTeX
1109 %
1110
1111 \ifx\luatexversion\thisisundefined
1112 \else
1113 % Escape PDF strings UTF-8 to UTF-16
1114 \begingroup
1115 \catcode`\%=12
1116 \directlua{
1117 function UTF16oct(str)
1118 tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
1119 for c in string.utfvalues(str) do
1120 if c < 0x10000 then
1121 tex.sprint(
1122 string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1123 string.char(0x5c) .. string.char(0x25) .. '03o',
1124 (c / 256), (c % 256)))
1125 else
1126 c = c - 0x10000
1127 local c_hi = c / 1024 + 0xd800
1128 local c_lo = c % 1024 + 0xdc00
1129 tex.sprint(
1130 string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1131 string.char(0x5c) .. string.char(0x25) .. '03o' ..
1132 string.char(0x5c) .. string.char(0x25) .. '03o' ..
1133 string.char(0x5c) .. string.char(0x25) .. '03o',
1134 (c_hi / 256), (c_hi % 256),
1135 (c_lo / 256), (c_lo % 256)))
1136 end
1137 end
1138 end
1139 }
1140 \endgroup
1141 \def\pdfescapestring#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
1142 \ifnum\luatexversion>84
1143 % For LuaTeX >= 0.85
1144 \def\pdfdest{\pdfextension dest}
1145 \let\pdfoutput\outputmode
1146 \def\pdfliteral{\pdfextension literal}
1147 \def\pdfcatalog{\pdfextension catalog}
1148 \def\pdftexversion{\numexpr\pdffeedback version\relax}
1149 \let\pdfximage\saveimageresource
1150 \let\pdfrefximage\useimageresource
1151 \let\pdflastximage\lastsavedimageresourceindex
1152 \def\pdfendlink{\pdfextension endlink\relax}
1153 \def\pdfoutline{\pdfextension outline}
1154 \def\pdfstartlink{\pdfextension startlink}
1155 \def\pdffontattr{\pdfextension fontattr}
1156 \def\pdfobj{\pdfextension obj}
1157 \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
1158 \let\pdfpagewidth\pagewidth
1159 \let\pdfpageheight\pageheight
1160 \edef\pdfhorigin{\pdfvariable horigin}
1161 \edef\pdfvorigin{\pdfvariable vorigin}
1162 \fi
1163 \fi
1164
1165 % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1166 % can be set). So we test for \relax and 0 as well as being undefined.
1167 \ifx\pdfoutput\thisisundefined
1168 \else
1169 \ifx\pdfoutput\relax
1170 \else
1171 \ifcase\pdfoutput
1172 \else
1173 \pdftrue
1174 \fi
1175 \fi
1176 \fi
1177
1178 % PDF uses PostScript string constants for the names of xref targets,
1179 % for display in the outlines, and in other places. Thus, we have to
1180 % double any backslashes. Otherwise, a name like "\node" will be
1181 % interpreted as a newline (\n), followed by o, d, e. Not good.
1182 %
1183 % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
1184 % related messages. The final outcome is that it is up to the TeX user
1185 % to double the backslashes and otherwise make the string valid, so
1186 % that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to
1187 % do this reliably, so we use it.
1188
1189 % #1 is a control sequence in which to do the replacements,
1190 % which we \xdef.
1191 \def\txiescapepdf#1{%
1192 \ifx\pdfescapestring\thisisundefined
1193 % No primitive available; should we give a warning or log?
1194 % Many times it won't matter.
1195 \xdef#1{#1}%
1196 \else
1197 % The expandable \pdfescapestring primitive escapes parentheses,
1198 % backslashes, and other special chars.
1199 \xdef#1{\pdfescapestring{#1}}%
1200 \fi
1201 }
1202
1203 \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1204 with PDF output, and none of those formats could be found. (.eps cannot
1205 be supported due to the design of the PDF format; use regular TeX (DVI
1206 output) for that.)}
1207
1208 \ifpdf
1209 %
1210 % Color manipulation macros using ideas from pdfcolor.tex,
1211 % except using rgb instead of cmyk; the latter is said to render as a
1212 % very dark gray on-screen and a very dark halftone in print, instead
1213 % of actual black. The dark red here is dark enough to print on paper as
1214 % nearly black, but still distinguishable for online viewing. We use
1215 % black by default, though.
1216 \def\rgbDarkRed{0.50 0.09 0.12}
1217 \def\rgbBlack{0 0 0}
1218 %
1219 % rg sets the color for filling (usual text, etc.);
1220 % RG sets the color for stroking (thin rules, e.g., normal _'s).
1221 \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}}
1222 %
1223 % Set color, and create a mark which defines \thiscolor accordingly,
1224 % so that \makeheadline knows which color to restore.
1225 \def\setcolor#1{%
1226 \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
1227 \domark
1228 \pdfsetcolor{#1}%
1229 }
1230 %
1231 \def\maincolor{\rgbBlack}
1232 \pdfsetcolor{\maincolor}
1233 \edef\thiscolor{\maincolor}
1234 \def\lastcolordefs{}
1235 %
1236 \def\makefootline{%
1237 \baselineskip24pt
1238 \line{\pdfsetcolor{\maincolor}\the\footline}%
1239 }
1240 %
1241 \def\makeheadline{%
1242 \vbox to 0pt{%
1243 \vskip-22.5pt
1244 \line{%
1245 \vbox to8.5pt{}%
1246 % Extract \thiscolor definition from the marks.
1247 \getcolormarks
1248 % Typeset the headline with \maincolor, then restore the color.
1249 \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1250 }%
1251 \vss
1252 }%
1253 \nointerlineskip
1254 }
1255 %
1256 %
1257 \pdfcatalog{/PageMode /UseOutlines}
1258 %
1259 % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1260 \def\dopdfimage#1#2#3{%
1261 \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1262 \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1263 %
1264 % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1265 % others). Let's try in that order, PDF first since if
1266 % someone has a scalable image, presumably better to use that than a
1267 % bitmap.
1268 \let\pdfimgext=\empty
1269 \begingroup
1270 \openin 1 #1.pdf \ifeof 1
1271 \openin 1 #1.PDF \ifeof 1
1272 \openin 1 #1.png \ifeof 1
1273 \openin 1 #1.jpg \ifeof 1
1274 \openin 1 #1.jpeg \ifeof 1
1275 \openin 1 #1.JPG \ifeof 1
1276 \errhelp = \nopdfimagehelp
1277 \errmessage{Could not find image file #1 for pdf}%
1278 \else \gdef\pdfimgext{JPG}%
1279 \fi
1280 \else \gdef\pdfimgext{jpeg}%
1281 \fi
1282 \else \gdef\pdfimgext{jpg}%
1283 \fi
1284 \else \gdef\pdfimgext{png}%
1285 \fi
1286 \else \gdef\pdfimgext{PDF}%
1287 \fi
1288 \else \gdef\pdfimgext{pdf}%
1289 \fi
1290 \closein 1
1291 \endgroup
1292 %
1293 % without \immediate, ancient pdftex seg faults when the same image is
1294 % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.)
1295 \ifnum\pdftexversion < 14
1296 \immediate\pdfimage
1297 \else
1298 \immediate\pdfximage
1299 \fi
1300 \ifdim \wd0 >0pt width \pdfimagewidth \fi
1301 \ifdim \wd2 >0pt height \pdfimageheight \fi
1302 \ifnum\pdftexversion<13
1303 #1.\pdfimgext
1304 \else
1305 {#1.\pdfimgext}%
1306 \fi
1307 \ifnum\pdftexversion < 14 \else
1308 \pdfrefximage \pdflastximage
1309 \fi}
1310 %
1311 \def\pdfmkdest#1{{%
1312 % We have to set dummies so commands such as @code, and characters
1313 % such as \, aren't expanded when present in a section title.
1314 \indexnofonts
1315 \makevalueexpandable
1316 \turnoffactive
1317 % Use ASCII approximations in destination names.
1318 \passthroughcharsfalse
1319 \def\pdfdestname{#1}%
1320 \txiescapepdf\pdfdestname
1321 \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1322 }}
1323 %
1324 % used to mark target names; must be expandable.
1325 \def\pdfmkpgn#1{#1}
1326 %
1327 % by default, use black for everything.
1328 \def\urlcolor{\rgbBlack}
1329 \def\linkcolor{\rgbBlack}
1330 \def\endlink{\setcolor{\maincolor}\pdfendlink}
1331 %
1332 % Adding outlines to PDF; macros for calculating structure of outlines
1333 % come from Petr Olsak
1334 \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1335 \else \csname#1\endcsname \fi}
1336 \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1337 \advance\tempnum by 1
1338 \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1339 %
1340 % #1 is the section text, which is what will be displayed in the
1341 % outline by the pdf viewer. #2 is the pdf expression for the number
1342 % of subentries (or empty, for subsubsections). #3 is the node text,
1343 % which might be empty if this toc entry had no corresponding node.
1344 % #4 is the page number
1345 %
1346 \def\dopdfoutline#1#2#3#4{%
1347 % Generate a link to the node text if that exists; else, use the
1348 % page number. We could generate a destination for the section
1349 % text in the case where a section has no node, but it doesn't
1350 % seem worth the trouble, since most documents are normally structured.
1351 {
1352 \ifx\luatexversion\thisisundefined \else
1353 \turnoffactive % LuaTeX can use Unicode strings for PDF
1354 \fi
1355 \edef\pdfoutlinedest{#3}%
1356 \ifx\pdfoutlinedest\empty
1357 \def\pdfoutlinedest{#4}%
1358 \else
1359 \txiescapepdf\pdfoutlinedest
1360 \fi
1361 %
1362 % Also escape PDF chars in the display string.
1363 \bgroup
1364 \ifx \declaredencoding \latone
1365 % The PDF format can use an extended form of Latin-1 in bookmark
1366 % strings. See Appendix D of the PDF Reference, Sixth Edition, for
1367 % the "PDFDocEncoding".
1368 \passthroughcharstrue
1369 \fi
1370 \ifx \declaredencoding \utfeight
1371 % TODO: the PDF format can use UTF-16 in bookmark strings, but the
1372 % code for this isn't done yet.
1373 \fi
1374 \globaldefs=1
1375 \edef\pdfoutlinetext{#1}%
1376 \txiescapepdf\pdfoutlinetext
1377 \egroup
1378 %
1379 \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
1380 }
1381 }
1382 %
1383 \def\pdfmakeoutlines{%
1384 \begingroup
1385 % Read toc silently, to get counts of subentries for \pdfoutline.
1386 \def\partentry##1##2##3##4{}% ignore parts in the outlines
1387 \def\numchapentry##1##2##3##4{%
1388 \def\thischapnum{##2}%
1389 \def\thissecnum{0}%
1390 \def\thissubsecnum{0}%
1391 }%
1392 \def\numsecentry##1##2##3##4{%
1393 \advancenumber{chap\thischapnum}%
1394 \def\thissecnum{##2}%
1395 \def\thissubsecnum{0}%
1396 }%
1397 \def\numsubsecentry##1##2##3##4{%
1398 \advancenumber{sec\thissecnum}%
1399 \def\thissubsecnum{##2}%
1400 }%
1401 \def\numsubsubsecentry##1##2##3##4{%
1402 \advancenumber{subsec\thissubsecnum}%
1403 }%
1404 \def\thischapnum{0}%
1405 \def\thissecnum{0}%
1406 \def\thissubsecnum{0}%
1407 %
1408 % use \def rather than \let here because we redefine \chapentry et
1409 % al. a second time, below.
1410 \def\appentry{\numchapentry}%
1411 \def\appsecentry{\numsecentry}%
1412 \def\appsubsecentry{\numsubsecentry}%
1413 \def\appsubsubsecentry{\numsubsubsecentry}%
1414 \def\unnchapentry{\numchapentry}%
1415 \def\unnsecentry{\numsecentry}%
1416 \def\unnsubsecentry{\numsubsecentry}%
1417 \def\unnsubsubsecentry{\numsubsubsecentry}%
1418 \readdatafile{toc}%
1419 %
1420 % Read toc second time, this time actually producing the outlines.
1421 % The `-' means take the \expnumber as the absolute number of
1422 % subentries, which we calculated on our first read of the .toc above.
1423 %
1424 % We use the node names as the destinations.
1425 \def\numchapentry##1##2##3##4{%
1426 \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1427 \def\numsecentry##1##2##3##4{%
1428 \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1429 \def\numsubsecentry##1##2##3##4{%
1430 \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1431 \def\numsubsubsecentry##1##2##3##4{% count is always zero
1432 \dopdfoutline{##1}{}{##3}{##4}}%
1433 %
1434 % PDF outlines are displayed using system fonts, instead of
1435 % document fonts. Therefore we cannot use special characters,
1436 % since the encoding is unknown. For example, the eogonek from
1437 % Latin 2 (0xea) gets translated to a | character. Info from
1438 % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1439 %
1440 % TODO this right, we have to translate 8-bit characters to
1441 % their "best" equivalent, based on the @documentencoding. Too
1442 % much work for too little return. Just use the ASCII equivalents
1443 % we use for the index sort strings.
1444 %
1445 \indexnofonts
1446 \setupdatafile
1447 % We can have normal brace characters in the PDF outlines, unlike
1448 % Texinfo index files. So set that up.
1449 \def\{{\lbracecharliteral}%
1450 \def\}{\rbracecharliteral}%
1451 \catcode`\\=\active \otherbackslash
1452 \input \tocreadfilename
1453 \endgroup
1454 }
1455 {\catcode`[=1 \catcode`]=2
1456 \catcode`{=\other \catcode`}=\other
1457 \gdef\lbracecharliteral[{]%
1458 \gdef\rbracecharliteral[}]%
1459 ]
1460 %
1461 \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1462 \ifx\PP\D\let\nextsp\relax
1463 \else\let\nextsp\skipspaces
1464 \addtokens{\filename}{\PP}%
1465 \advance\filenamelength by 1
1466 \fi
1467 \nextsp}
1468 \def\getfilename#1{%
1469 \filenamelength=0
1470 % If we don't expand the argument now, \skipspaces will get
1471 % snagged on things like "@value{foo}".
1472 \edef\temp{#1}%
1473 \expandafter\skipspaces\temp|\relax
1474 }
1475 \ifnum\pdftexversion < 14
1476 \let \startlink \pdfannotlink
1477 \else
1478 \let \startlink \pdfstartlink
1479 \fi
1480 % make a live url in pdf output.
1481 \def\pdfurl#1{%
1482 \begingroup
1483 % it seems we really need yet another set of dummies; have not
1484 % tried to figure out what each command should do in the context
1485 % of @url. for now, just make @/ a no-op, that's the only one
1486 % people have actually reported a problem with.
1487 %
1488 \normalturnoffactive
1489 \def\@{@}%
1490 \let\/=\empty
1491 \makevalueexpandable
1492 % do we want to go so far as to use \indexnofonts instead of just
1493 % special-casing \var here?
1494 \def\var##1{##1}%
1495 %
1496 \leavevmode\setcolor{\urlcolor}%
1497 \startlink attr{/Border [0 0 0]}%
1498 user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1499 \endgroup}
1500 \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1501 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1502 \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1503 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1504 \def\maketoks{%
1505 \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1506 \ifx\first0\adn0
1507 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1508 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1509 \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1510 \else
1511 \ifnum0=\countA\else\makelink\fi
1512 \ifx\first.\let\next=\done\else
1513 \let\next=\maketoks
1514 \addtokens{\toksB}{\the\toksD}
1515 \ifx\first,\addtokens{\toksB}{\space}\fi
1516 \fi
1517 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1518 \next}
1519 \def\makelink{\addtokens{\toksB}%
1520 {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1521 \def\pdflink#1{%
1522 \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1523 \setcolor{\linkcolor}#1\endlink}
1524 \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1525 \else
1526 % non-pdf mode
1527 \let\pdfmkdest = \gobble
1528 \let\pdfurl = \gobble
1529 \let\endlink = \relax
1530 \let\setcolor = \gobble
1531 \let\pdfsetcolor = \gobble
1532 \let\pdfmakeoutlines = \relax
1533 \fi % \ifx\pdfoutput
1534
1535 %
1536 % For XeTeX
1537 %
1538 \newif\iftxiuseunicodedestname
1539 \ifx\XeTeXrevision\thisisundefined
1540 \else
1541 %
1542 % XeTeX version check
1543 %
1544 \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99995}>-1
1545 % XeTeX 0.99995+ contains xdvipdfmx 20160307+.
1546 % It can handle Unicode destination name for PDF.
1547 \txiuseunicodedestnametrue
1548 \else
1549 % XeTeX < 0.99995 can not handle Unicode destination name for PDF
1550 % because xdvipdfmx 20150315 has UTF-16 convert issue.
1551 % It fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1552 \txiuseunicodedestnamefalse
1553 \fi
1554 %
1555 % PDF outline support
1556 %
1557 % Emulate the primitive of pdfTeX
1558 \def\pdfdest name#1 xyz{%
1559 \special{pdf:dest (name#1) [@thispage /XYZ @xpos @ypos]}%
1560 }
1561 \def\pdfmkdest#1{{%
1562 % We have to set dummies so commands such as @code, and characters
1563 % such as \, aren't expanded when present in a section title.
1564 \indexnofonts
1565 \iftxiuseunicodedestname
1566 \def\pdfdestname{#1}% Pass through Unicode characters.
1567 \else
1568 \edef\pdfdestname{#1}% Replace Unicode characters to ASCII.
1569 \fi
1570 \turnoffactive
1571 \makevalueexpandable
1572 \txiescapepdf\pdfdestname
1573 \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1574 }}
1575 %
1576 \def\dopdfoutline#1#2#3#4{%
1577 \iftxiuseunicodedestname
1578 \def\pdfoutlinedest{#3}% Pass through Unicode characters.
1579 \else
1580 \edef\pdfoutlinedest{#3}% Replace Unicode characters to ASCII.
1581 \fi
1582 \ifx\pdfoutlinedest\empty
1583 \def\pdfoutlinedest{#4}%
1584 \fi
1585 {
1586 \turnoffactive
1587 \txiescapepdf\pdfoutlinedest
1588 \edef\pdfoutlinetext{#1}%
1589 \txiescapepdf\pdfoutlinetext
1590 %
1591 \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
1592 << /S /GoTo /D (name\pdfoutlinedest) >> >> }%
1593 }
1594 }
1595 %
1596 \def\pdfmakeoutlines{%
1597 \begingroup
1598 %
1599 % In the case of XeTeX, counts of subentries is not necesary.
1600 % Therefore, read toc only once.
1601 %
1602 % We use the node names as the destinations.
1603 \def\partentry##1##2##3##4{}% ignore parts in the outlines
1604 \def\numchapentry##1##2##3##4{%
1605 \dopdfoutline{##1}{1}{##3}{##4}}%
1606 \def\numsecentry##1##2##3##4{%
1607 \dopdfoutline{##1}{2}{##3}{##4}}%
1608 \def\numsubsecentry##1##2##3##4{%
1609 \dopdfoutline{##1}{3}{##3}{##4}}%
1610 \def\numsubsubsecentry##1##2##3##4{%
1611 \dopdfoutline{##1}{4}{##3}{##4}}%
1612 %
1613 \let\appentry\numchapentry%
1614 \let\appsecentry\numsecentry%
1615 \let\appsubsecentry\numsubsecentry%
1616 \let\appsubsubsecentry\numsubsubsecentry%
1617 \let\unnchapentry\numchapentry%
1618 \let\unnsecentry\numsecentry%
1619 \let\unnsubsecentry\numsubsecentry%
1620 \let\unnsubsubsecentry\numsubsubsecentry%
1621 %
1622 % In the case of XeTeX, xdvipdfmx converts strings to UTF-16.
1623 % Therefore, the encoding and the language may not be considered.
1624 %
1625 \indexnofonts
1626 \setupdatafile
1627 % We can have normal brace characters in the PDF outlines, unlike
1628 % Texinfo index files. So set that up.
1629 \def\{{\lbracecharliteral}%
1630 \def\}{\rbracecharliteral}%
1631 \catcode`\\=\active \otherbackslash
1632 \input \tocreadfilename
1633 \endgroup
1634 }
1635 {\catcode`[=1 \catcode`]=2
1636 \catcode`{=\other \catcode`}=\other
1637 \gdef\lbracecharliteral[{]%
1638 \gdef\rbracecharliteral[}]%
1639 ]
1640
1641 \special{pdf:docview << /PageMode /UseOutlines >> }
1642 % ``\special{pdf:tounicode ...}'' is not necessary
1643 % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
1644 % However, due to UTF-16 convert issue of xdvipdfmx 20150315,
1645 % ``\special{pdf:dest ...}'' can not handle non-ASCII strings.
1646 % It fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1647 %
1648 \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1649 \ifx\PP\D\let\nextsp\relax
1650 \else\let\nextsp\skipspaces
1651 \addtokens{\filename}{\PP}%
1652 \advance\filenamelength by 1
1653 \fi
1654 \nextsp}
1655 \def\getfilename#1{%
1656 \filenamelength=0
1657 % If we don't expand the argument now, \skipspaces will get
1658 % snagged on things like "@value{foo}".
1659 \edef\temp{#1}%
1660 \expandafter\skipspaces\temp|\relax
1661 }
1662 % make a live url in pdf output.
1663 \def\pdfurl#1{%
1664 \begingroup
1665 % it seems we really need yet another set of dummies; have not
1666 % tried to figure out what each command should do in the context
1667 % of @url. for now, just make @/ a no-op, that's the only one
1668 % people have actually reported a problem with.
1669 %
1670 \normalturnoffactive
1671 \def\@{@}%
1672 \let\/=\empty
1673 \makevalueexpandable
1674 % do we want to go so far as to use \indexnofonts instead of just
1675 % special-casing \var here?
1676 \def\var##1{##1}%
1677 %
1678 \leavevmode\setcolor{\urlcolor}%
1679 \special{pdf:bann << /Border [0 0 0]
1680 /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
1681 \endgroup}
1682 \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
1683 \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1684 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1685 \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1686 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1687 \def\maketoks{%
1688 \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1689 \ifx\first0\adn0
1690 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1691 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1692 \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1693 \else
1694 \ifnum0=\countA\else\makelink\fi
1695 \ifx\first.\let\next=\done\else
1696 \let\next=\maketoks
1697 \addtokens{\toksB}{\the\toksD}
1698 \ifx\first,\addtokens{\toksB}{\space}\fi
1699 \fi
1700 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1701 \next}
1702 \def\makelink{\addtokens{\toksB}%
1703 {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1704 \def\pdflink#1{%
1705 \special{pdf:bann << /Border [0 0 0]
1706 /Type /Annot /Subtype /Link /A << /S /GoTo /D (name#1) >> >>}%
1707 \setcolor{\linkcolor}#1\endlink}
1708 \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1709 %
1710 %
1711 % @image support
1712 %
1713 % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1714 \def\doxeteximage#1#2#3{%
1715 \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1716 \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1717 %
1718 % XeTeX (and the PDF format) support .pdf, .png, .jpg (among
1719 % others). Let's try in that order, PDF first since if
1720 % someone has a scalable image, presumably better to use that than a
1721 % bitmap.
1722 \let\xeteximgext=\empty
1723 \begingroup
1724 \openin 1 #1.pdf \ifeof 1
1725 \openin 1 #1.PDF \ifeof 1
1726 \openin 1 #1.png \ifeof 1
1727 \openin 1 #1.jpg \ifeof 1
1728 \openin 1 #1.jpeg \ifeof 1
1729 \openin 1 #1.JPG \ifeof 1
1730 \errmessage{Could not find image file #1 for XeTeX}%
1731 \else \gdef\xeteximgext{JPG}%
1732 \fi
1733 \else \gdef\xeteximgext{jpeg}%
1734 \fi
1735 \else \gdef\xeteximgext{jpg}%
1736 \fi
1737 \else \gdef\xeteximgext{png}%
1738 \fi
1739 \else \gdef\xeteximgext{PDF}%
1740 \fi
1741 \else \gdef\xeteximgext{pdf}%
1742 \fi
1743 \closein 1
1744 \endgroup
1745 %
1746 \def\xetexpdfext{pdf}%
1747 \ifx\xeteximgext\xetexpdfext
1748 \XeTeXpdffile "#1".\xeteximgext ""
1749 \else
1750 \def\xetexpdfext{PDF}%
1751 \ifx\xeteximgext\xetexpdfext
1752 \XeTeXpdffile "#1".\xeteximgext ""
1753 \else
1754 \XeTeXpicfile "#1".\xeteximgext ""
1755 \fi
1756 \fi
1757 \ifdim \wd0 >0pt width \xeteximagewidth \fi
1758 \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1759 }
1760 \fi
1761
1762 \message{fonts,}
1763
1764 % Change the current font style to #1, remembering it in \curfontstyle.
1765 % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
1766 % italics, not bold italics.
1767 %
1768 \def\setfontstyle#1{%
1769 \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
1770 \csname ten#1\endcsname % change the current font
1771 }
1772
1773 % Select #1 fonts with the current style.
1774 %
1775 \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
1776
1777 \def\rm{\fam=0 \setfontstyle{rm}}
1778 \def\it{\fam=\itfam \setfontstyle{it}}
1779 \def\sl{\fam=\slfam \setfontstyle{sl}}
1780 \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
1781 \def\tt{\fam=\ttfam \setfontstyle{tt}}
1782
1783 % Unfortunately, we have to override this for titles and the like, since
1784 % in those cases "rm" is bold. Sigh.
1785 \def\rmisbold{\rm\def\curfontstyle{bf}}
1786
1787 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
1788 % So we set up a \sf.
1789 \newfam\sffam
1790 \def\sf{\fam=\sffam \setfontstyle{sf}}
1791 \let\li = \sf % Sometimes we call it \li, not \sf.
1792
1793 % We don't need math for this font style.
1794 \def\ttsl{\setfontstyle{ttsl}}
1795
1796
1797 % Set the baselineskip to #1, and the lineskip and strut size
1798 % correspondingly. There is no deep meaning behind these magic numbers
1799 % used as factors; they just match (closely enough) what Knuth defined.
1800 %
1801 \def\lineskipfactor{.08333}
1802 \def\strutheightpercent{.70833}
1803 \def\strutdepthpercent {.29167}
1804 %
1805 % can get a sort of poor man's double spacing by redefining this.
1806 \def\baselinefactor{1}
1807 %
1808 \newdimen\textleading
1809 \def\setleading#1{%
1810 \dimen0 = #1\relax
1811 \normalbaselineskip = \baselinefactor\dimen0
1812 \normallineskip = \lineskipfactor\normalbaselineskip
1813 \normalbaselines
1814 \setbox\strutbox =\hbox{%
1815 \vrule width0pt height\strutheightpercent\baselineskip
1816 depth \strutdepthpercent \baselineskip
1817 }%
1818 }
1819
1820 % PDF CMaps. See also LaTeX's t1.cmap.
1821 %
1822 % do nothing with this by default.
1823 \expandafter\let\csname cmapOT1\endcsname\gobble
1824 \expandafter\let\csname cmapOT1IT\endcsname\gobble
1825 \expandafter\let\csname cmapOT1TT\endcsname\gobble
1826
1827 % if we are producing pdf, and we have \pdffontattr, then define cmaps.
1828 % (\pdffontattr was introduced many years ago, but people still run
1829 % older pdftex's; it's easy to conditionalize, so we do.)
1830 \ifpdf \ifx\pdffontattr\thisisundefined \else
1831 \begingroup
1832 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1833 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1834 %%DocumentNeededResources: ProcSet (CIDInit)
1835 %%IncludeResource: ProcSet (CIDInit)
1836 %%BeginResource: CMap (TeX-OT1-0)
1837 %%Title: (TeX-OT1-0 TeX OT1 0)
1838 %%Version: 1.000
1839 %%EndComments
1840 /CIDInit /ProcSet findresource begin
1841 12 dict begin
1842 begincmap
1843 /CIDSystemInfo
1844 << /Registry (TeX)
1845 /Ordering (OT1)
1846 /Supplement 0
1847 >> def
1848 /CMapName /TeX-OT1-0 def
1849 /CMapType 2 def
1850 1 begincodespacerange
1851 <00> <7F>
1852 endcodespacerange
1853 8 beginbfrange
1854 <00> <01> <0393>
1855 <09> <0A> <03A8>
1856 <23> <26> <0023>
1857 <28> <3B> <0028>
1858 <3F> <5B> <003F>
1859 <5D> <5E> <005D>
1860 <61> <7A> <0061>
1861 <7B> <7C> <2013>
1862 endbfrange
1863 40 beginbfchar
1864 <02> <0398>
1865 <03> <039B>
1866 <04> <039E>
1867 <05> <03A0>
1868 <06> <03A3>
1869 <07> <03D2>
1870 <08> <03A6>
1871 <0B> <00660066>
1872 <0C> <00660069>
1873 <0D> <0066006C>
1874 <0E> <006600660069>
1875 <0F> <00660066006C>
1876 <10> <0131>
1877 <11> <0237>
1878 <12> <0060>
1879 <13> <00B4>
1880 <14> <02C7>
1881 <15> <02D8>
1882 <16> <00AF>
1883 <17> <02DA>
1884 <18> <00B8>
1885 <19> <00DF>
1886 <1A> <00E6>
1887 <1B> <0153>
1888 <1C> <00F8>
1889 <1D> <00C6>
1890 <1E> <0152>
1891 <1F> <00D8>
1892 <21> <0021>
1893 <22> <201D>
1894 <27> <2019>
1895 <3C> <00A1>
1896 <3D> <003D>
1897 <3E> <00BF>
1898 <5C> <201C>
1899 <5F> <02D9>
1900 <60> <2018>
1901 <7D> <02DD>
1902 <7E> <007E>
1903 <7F> <00A8>
1904 endbfchar
1905 endcmap
1906 CMapName currentdict /CMap defineresource pop
1907 end
1908 end
1909 %%EndResource
1910 %%EOF
1911 }\endgroup
1912 \expandafter\edef\csname cmapOT1\endcsname#1{%
1913 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1914 }%
1915 %
1916 % \cmapOT1IT
1917 \begingroup
1918 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1919 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1920 %%DocumentNeededResources: ProcSet (CIDInit)
1921 %%IncludeResource: ProcSet (CIDInit)
1922 %%BeginResource: CMap (TeX-OT1IT-0)
1923 %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
1924 %%Version: 1.000
1925 %%EndComments
1926 /CIDInit /ProcSet findresource begin
1927 12 dict begin
1928 begincmap
1929 /CIDSystemInfo
1930 << /Registry (TeX)
1931 /Ordering (OT1IT)
1932 /Supplement 0
1933 >> def
1934 /CMapName /TeX-OT1IT-0 def
1935 /CMapType 2 def
1936 1 begincodespacerange
1937 <00> <7F>
1938 endcodespacerange
1939 8 beginbfrange
1940 <00> <01> <0393>
1941 <09> <0A> <03A8>
1942 <25> <26> <0025>
1943 <28> <3B> <0028>
1944 <3F> <5B> <003F>
1945 <5D> <5E> <005D>
1946 <61> <7A> <0061>
1947 <7B> <7C> <2013>
1948 endbfrange
1949 42 beginbfchar
1950 <02> <0398>
1951 <03> <039B>
1952 <04> <039E>
1953 <05> <03A0>
1954 <06> <03A3>
1955 <07> <03D2>
1956 <08> <03A6>
1957 <0B> <00660066>
1958 <0C> <00660069>
1959 <0D> <0066006C>
1960 <0E> <006600660069>
1961 <0F> <00660066006C>
1962 <10> <0131>
1963 <11> <0237>
1964 <12> <0060>
1965 <13> <00B4>
1966 <14> <02C7>
1967 <15> <02D8>
1968 <16> <00AF>
1969 <17> <02DA>
1970 <18> <00B8>
1971 <19> <00DF>
1972 <1A> <00E6>
1973 <1B> <0153>
1974 <1C> <00F8>
1975 <1D> <00C6>
1976 <1E> <0152>
1977 <1F> <00D8>
1978 <21> <0021>
1979 <22> <201D>
1980 <23> <0023>
1981 <24> <00A3>
1982 <27> <2019>
1983 <3C> <00A1>
1984 <3D> <003D>
1985 <3E> <00BF>
1986 <5C> <201C>
1987 <5F> <02D9>
1988 <60> <2018>
1989 <7D> <02DD>
1990 <7E> <007E>
1991 <7F> <00A8>
1992 endbfchar
1993 endcmap
1994 CMapName currentdict /CMap defineresource pop
1995 end
1996 end
1997 %%EndResource
1998 %%EOF
1999 }\endgroup
2000 \expandafter\edef\csname cmapOT1IT\endcsname#1{%
2001 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2002 }%
2003 %
2004 % \cmapOT1TT
2005 \begingroup
2006 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2007 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2008 %%DocumentNeededResources: ProcSet (CIDInit)
2009 %%IncludeResource: ProcSet (CIDInit)
2010 %%BeginResource: CMap (TeX-OT1TT-0)
2011 %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
2012 %%Version: 1.000
2013 %%EndComments
2014 /CIDInit /ProcSet findresource begin
2015 12 dict begin
2016 begincmap
2017 /CIDSystemInfo
2018 << /Registry (TeX)
2019 /Ordering (OT1TT)
2020 /Supplement 0
2021 >> def
2022 /CMapName /TeX-OT1TT-0 def
2023 /CMapType 2 def
2024 1 begincodespacerange
2025 <00> <7F>
2026 endcodespacerange
2027 5 beginbfrange
2028 <00> <01> <0393>
2029 <09> <0A> <03A8>
2030 <21> <26> <0021>
2031 <28> <5F> <0028>
2032 <61> <7E> <0061>
2033 endbfrange
2034 32 beginbfchar
2035 <02> <0398>
2036 <03> <039B>
2037 <04> <039E>
2038 <05> <03A0>
2039 <06> <03A3>
2040 <07> <03D2>
2041 <08> <03A6>
2042 <0B> <2191>
2043 <0C> <2193>
2044 <0D> <0027>
2045 <0E> <00A1>
2046 <0F> <00BF>
2047 <10> <0131>
2048 <11> <0237>
2049 <12> <0060>
2050 <13> <00B4>
2051 <14> <02C7>
2052 <15> <02D8>
2053 <16> <00AF>
2054 <17> <02DA>
2055 <18> <00B8>
2056 <19> <00DF>
2057 <1A> <00E6>
2058 <1B> <0153>
2059 <1C> <00F8>
2060 <1D> <00C6>
2061 <1E> <0152>
2062 <1F> <00D8>
2063 <20> <2423>
2064 <27> <2019>
2065 <60> <2018>
2066 <7F> <00A8>
2067 endbfchar
2068 endcmap
2069 CMapName currentdict /CMap defineresource pop
2070 end
2071 end
2072 %%EndResource
2073 %%EOF
2074 }\endgroup
2075 \expandafter\edef\csname cmapOT1TT\endcsname#1{%
2076 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2077 }%
2078 \fi\fi
2079
2080
2081 % Set the font macro #1 to the font named \fontprefix#2.
2082 % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
2083 % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
2084 % Example:
2085 % #1 = \textrm
2086 % #2 = \rmshape
2087 % #3 = 10
2088 % #4 = \mainmagstep
2089 % #5 = OT1
2090 %
2091 \def\setfont#1#2#3#4#5{%
2092 \font#1=\fontprefix#2#3 scaled #4
2093 \csname cmap#5\endcsname#1%
2094 }
2095 % This is what gets called when #5 of \setfont is empty.
2096 \let\cmap\gobble
2097 %
2098 % (end of cmaps)
2099
2100 % Use cm as the default font prefix.
2101 % To specify the font prefix, you must define \fontprefix
2102 % before you read in texinfo.tex.
2103 \ifx\fontprefix\thisisundefined
2104 \def\fontprefix{cm}
2105 \fi
2106 % Support font families that don't use the same naming scheme as CM.
2107 \def\rmshape{r}
2108 \def\rmbshape{bx} % where the normal face is bold
2109 \def\bfshape{b}
2110 \def\bxshape{bx}
2111 \def\ttshape{tt}
2112 \def\ttbshape{tt}
2113 \def\ttslshape{sltt}
2114 \def\itshape{ti}
2115 \def\itbshape{bxti}
2116 \def\slshape{sl}
2117 \def\slbshape{bxsl}
2118 \def\sfshape{ss}
2119 \def\sfbshape{ss}
2120 \def\scshape{csc}
2121 \def\scbshape{csc}
2122
2123 % Definitions for a main text size of 11pt. (The default in Texinfo.)
2124 %
2125 \def\definetextfontsizexi{%
2126 % Text fonts (11.2pt, magstep1).
2127 \def\textnominalsize{11pt}
2128 \edef\mainmagstep{\magstephalf}
2129 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2130 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2131 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2132 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2133 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2134 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2135 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2136 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2137 \font\texti=cmmi10 scaled \mainmagstep
2138 \font\textsy=cmsy10 scaled \mainmagstep
2139 \def\textecsize{1095}
2140
2141 % A few fonts for @defun names and args.
2142 \setfont\defbf\bfshape{10}{\magstep1}{OT1}
2143 \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
2144 \setfont\defsl\slshape{10}{\magstep1}{OT1TT}
2145 \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
2146 \def\df{\let\tentt=\deftt \let\tenbf = \defbf
2147 \let\tenttsl=\defttsl \let\tensl=\defsl \bf}
2148
2149 % Fonts for indices, footnotes, small examples (9pt).
2150 \def\smallnominalsize{9pt}
2151 \setfont\smallrm\rmshape{9}{1000}{OT1}
2152 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2153 \setfont\smallbf\bfshape{10}{900}{OT1}
2154 \setfont\smallit\itshape{9}{1000}{OT1IT}
2155 \setfont\smallsl\slshape{9}{1000}{OT1}
2156 \setfont\smallsf\sfshape{9}{1000}{OT1}
2157 \setfont\smallsc\scshape{10}{900}{OT1}
2158 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2159 \font\smalli=cmmi9
2160 \font\smallsy=cmsy9
2161 \def\smallecsize{0900}
2162
2163 % Fonts for small examples (8pt).
2164 \def\smallernominalsize{8pt}
2165 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2166 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2167 \setfont\smallerbf\bfshape{10}{800}{OT1}
2168 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2169 \setfont\smallersl\slshape{8}{1000}{OT1}
2170 \setfont\smallersf\sfshape{8}{1000}{OT1}
2171 \setfont\smallersc\scshape{10}{800}{OT1}
2172 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2173 \font\smalleri=cmmi8
2174 \font\smallersy=cmsy8
2175 \def\smallerecsize{0800}
2176
2177 % Fonts for title page (20.4pt):
2178 \def\titlenominalsize{20pt}
2179 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2180 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2181 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2182 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2183 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2184 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2185 \let\titlebf=\titlerm
2186 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2187 \font\titlei=cmmi12 scaled \magstep3
2188 \font\titlesy=cmsy10 scaled \magstep4
2189 \def\titleecsize{2074}
2190
2191 % Chapter (and unnumbered) fonts (17.28pt).
2192 \def\chapnominalsize{17pt}
2193 \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2194 \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2195 \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2196 \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2197 \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2198 \setfont\chapsf\sfbshape{17}{1000}{OT1}
2199 \let\chapbf=\chaprm
2200 \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
2201 \font\chapi=cmmi12 scaled \magstep2
2202 \font\chapsy=cmsy10 scaled \magstep3
2203 \def\chapecsize{1728}
2204
2205 % Section fonts (14.4pt).
2206 \def\secnominalsize{14pt}
2207 \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
2208 \setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
2209 \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2210 \setfont\secsl\slbshape{10}{\magstep2}{OT1}
2211 \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2212 \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2213 \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
2214 \let\secbf\secrm
2215 \setfont\secsc\scbshape{10}{\magstep2}{OT1}
2216 \font\seci=cmmi12 scaled \magstep1
2217 \font\secsy=cmsy10 scaled \magstep2
2218 \def\sececsize{1440}
2219
2220 % Subsection fonts (13.15pt).
2221 \def\ssecnominalsize{13pt}
2222 \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2223 \setfont\ssecit\itbshape{10}{1315}{OT1IT}
2224 \setfont\ssecsl\slbshape{10}{1315}{OT1}
2225 \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2226 \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2227 \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
2228 \let\ssecbf\ssecrm
2229 \setfont\ssecsc\scbshape{10}{1315}{OT1}
2230 \font\sseci=cmmi12 scaled \magstephalf
2231 \font\ssecsy=cmsy10 scaled 1315
2232 \def\ssececsize{1200}
2233
2234 % Reduced fonts for @acro in text (10pt).
2235 \def\reducednominalsize{10pt}
2236 \setfont\reducedrm\rmshape{10}{1000}{OT1}
2237 \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2238 \setfont\reducedbf\bfshape{10}{1000}{OT1}
2239 \setfont\reducedit\itshape{10}{1000}{OT1IT}
2240 \setfont\reducedsl\slshape{10}{1000}{OT1}
2241 \setfont\reducedsf\sfshape{10}{1000}{OT1}
2242 \setfont\reducedsc\scshape{10}{1000}{OT1}
2243 \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
2244 \font\reducedi=cmmi10
2245 \font\reducedsy=cmsy10
2246 \def\reducedecsize{1000}
2247
2248 \textleading = 13.2pt % line spacing for 11pt CM
2249 \textfonts % reset the current fonts
2250 \rm
2251 } % end of 11pt text font size definitions, \definetextfontsizexi
2252
2253
2254 % Definitions to make the main text be 10pt Computer Modern, with
2255 % section, chapter, etc., sizes following suit. This is for the GNU
2256 % Press printing of the Emacs 22 manual. Maybe other manuals in the
2257 % future. Used with @smallbook, which sets the leading to 12pt.
2258 %
2259 \def\definetextfontsizex{%
2260 % Text fonts (10pt).
2261 \def\textnominalsize{10pt}
2262 \edef\mainmagstep{1000}
2263 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2264 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2265 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2266 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2267 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2268 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2269 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2270 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2271 \font\texti=cmmi10 scaled \mainmagstep
2272 \font\textsy=cmsy10 scaled \mainmagstep
2273 \def\textecsize{1000}
2274
2275 % A few fonts for @defun names and args.
2276 \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2277 \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
2278 \setfont\defsl\slshape{10}{\magstephalf}{OT1TT}
2279 \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
2280 \def\df{\let\tentt=\deftt \let\tenbf = \defbf
2281 \let\tensl=\defsl \let\tenttsl=\defttsl \bf}
2282
2283 % Fonts for indices, footnotes, small examples (9pt).
2284 \def\smallnominalsize{9pt}
2285 \setfont\smallrm\rmshape{9}{1000}{OT1}
2286 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2287 \setfont\smallbf\bfshape{10}{900}{OT1}
2288 \setfont\smallit\itshape{9}{1000}{OT1IT}
2289 \setfont\smallsl\slshape{9}{1000}{OT1}
2290 \setfont\smallsf\sfshape{9}{1000}{OT1}
2291 \setfont\smallsc\scshape{10}{900}{OT1}
2292 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2293 \font\smalli=cmmi9
2294 \font\smallsy=cmsy9
2295 \def\smallecsize{0900}
2296
2297 % Fonts for small examples (8pt).
2298 \def\smallernominalsize{8pt}
2299 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2300 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2301 \setfont\smallerbf\bfshape{10}{800}{OT1}
2302 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2303 \setfont\smallersl\slshape{8}{1000}{OT1}
2304 \setfont\smallersf\sfshape{8}{1000}{OT1}
2305 \setfont\smallersc\scshape{10}{800}{OT1}
2306 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2307 \font\smalleri=cmmi8
2308 \font\smallersy=cmsy8
2309 \def\smallerecsize{0800}
2310
2311 % Fonts for title page (20.4pt):
2312 \def\titlenominalsize{20pt}
2313 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2314 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2315 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2316 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2317 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2318 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2319 \let\titlebf=\titlerm
2320 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2321 \font\titlei=cmmi12 scaled \magstep3
2322 \font\titlesy=cmsy10 scaled \magstep4
2323 \def\titleecsize{2074}
2324
2325 % Chapter fonts (14.4pt).
2326 \def\chapnominalsize{14pt}
2327 \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2328 \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2329 \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2330 \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2331 \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2332 \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2333 \let\chapbf\chaprm
2334 \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2335 \font\chapi=cmmi12 scaled \magstep1
2336 \font\chapsy=cmsy10 scaled \magstep2
2337 \def\chapecsize{1440}
2338
2339 % Section fonts (12pt).
2340 \def\secnominalsize{12pt}
2341 \setfont\secrm\rmbshape{12}{1000}{OT1}
2342 \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2343 \setfont\secsl\slbshape{10}{\magstep1}{OT1}
2344 \setfont\sectt\ttbshape{12}{1000}{OT1TT}
2345 \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2346 \setfont\secsf\sfbshape{12}{1000}{OT1}
2347 \let\secbf\secrm
2348 \setfont\secsc\scbshape{10}{\magstep1}{OT1}
2349 \font\seci=cmmi12
2350 \font\secsy=cmsy10 scaled \magstep1
2351 \def\sececsize{1200}
2352
2353 % Subsection fonts (10pt).
2354 \def\ssecnominalsize{10pt}
2355 \setfont\ssecrm\rmbshape{10}{1000}{OT1}
2356 \setfont\ssecit\itbshape{10}{1000}{OT1IT}
2357 \setfont\ssecsl\slbshape{10}{1000}{OT1}
2358 \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2359 \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2360 \setfont\ssecsf\sfbshape{10}{1000}{OT1}
2361 \let\ssecbf\ssecrm
2362 \setfont\ssecsc\scbshape{10}{1000}{OT1}
2363 \font\sseci=cmmi10
2364 \font\ssecsy=cmsy10
2365 \def\ssececsize{1000}
2366
2367 % Reduced fonts for @acro in text (9pt).
2368 \def\reducednominalsize{9pt}
2369 \setfont\reducedrm\rmshape{9}{1000}{OT1}
2370 \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2371 \setfont\reducedbf\bfshape{10}{900}{OT1}
2372 \setfont\reducedit\itshape{9}{1000}{OT1IT}
2373 \setfont\reducedsl\slshape{9}{1000}{OT1}
2374 \setfont\reducedsf\sfshape{9}{1000}{OT1}
2375 \setfont\reducedsc\scshape{10}{900}{OT1}
2376 \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2377 \font\reducedi=cmmi9
2378 \font\reducedsy=cmsy9
2379 \def\reducedecsize{0900}
2380
2381 \divide\parskip by 2 % reduce space between paragraphs
2382 \textleading = 12pt % line spacing for 10pt CM
2383 \textfonts % reset the current fonts
2384 \rm
2385 } % end of 10pt text font size definitions, \definetextfontsizex
2386
2387
2388 % We provide the user-level command
2389 % @fonttextsize 10
2390 % (or 11) to redefine the text font size. pt is assumed.
2391 %
2392 \def\xiword{11}
2393 \def\xword{10}
2394 \def\xwordpt{10pt}
2395 %
2396 \parseargdef\fonttextsize{%
2397 \def\textsizearg{#1}%
2398 %\wlog{doing @fonttextsize \textsizearg}%
2399 %
2400 % Set \globaldefs so that documents can use this inside @tex, since
2401 % makeinfo 4.8 does not support it, but we need it nonetheless.
2402 %
2403 \begingroup \globaldefs=1
2404 \ifx\textsizearg\xword \definetextfontsizex
2405 \else \ifx\textsizearg\xiword \definetextfontsizexi
2406 \else
2407 \errhelp=\EMsimple
2408 \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2409 \fi\fi
2410 \endgroup
2411 }
2412
2413 % In order for the font changes to affect most math symbols and letters,
2414 % we have to define the \textfont of the standard families. We don't
2415 % bother to reset \scriptfont and \scriptscriptfont; awaiting user need.
2416 %
2417 \def\resetmathfonts{%
2418 \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
2419 \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
2420 \textfont\ttfam=\tentt \textfont\sffam=\tensf
2421 }
2422
2423 % The font-changing commands redefine the meanings of \tenSTYLE, instead
2424 % of just \STYLE. We do this because \STYLE needs to also set the
2425 % current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire
2426 % \tenSTYLE to set the current font.
2427 %
2428 % Each font-changing command also sets the names \lsize (one size lower)
2429 % and \lllsize (three sizes lower). These relative commands are used
2430 % in, e.g., the LaTeX logo and acronyms.
2431 %
2432 % This all needs generalizing, badly.
2433 %
2434 \def\textfonts{%
2435 \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
2436 \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
2437 \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
2438 \let\tenttsl=\textttsl
2439 \def\curfontsize{text}%
2440 \def\lsize{reduced}\def\lllsize{smaller}%
2441 \resetmathfonts \setleading{\textleading}}
2442 \def\titlefonts{%
2443 \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
2444 \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
2445 \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
2446 \let\tenttsl=\titlettsl
2447 \def\curfontsize{title}%
2448 \def\lsize{chap}\def\lllsize{subsec}%
2449 \resetmathfonts \setleading{27pt}}
2450 \def\titlefont#1{{\titlefonts\rmisbold #1}}
2451 \def\chapfonts{%
2452 \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
2453 \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
2454 \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
2455 \let\tenttsl=\chapttsl
2456 \def\curfontsize{chap}%
2457 \def\lsize{sec}\def\lllsize{text}%
2458 \resetmathfonts \setleading{19pt}}
2459 \def\secfonts{%
2460 \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
2461 \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
2462 \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
2463 \let\tenttsl=\secttsl
2464 \def\curfontsize{sec}%
2465 \def\lsize{subsec}\def\lllsize{reduced}%
2466 \resetmathfonts \setleading{17pt}}
2467 \def\subsecfonts{%
2468 \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
2469 \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
2470 \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
2471 \let\tenttsl=\ssecttsl
2472 \def\curfontsize{ssec}%
2473 \def\lsize{text}\def\lllsize{small}%
2474 \resetmathfonts \setleading{15pt}}
2475 \let\subsubsecfonts = \subsecfonts
2476 \def\reducedfonts{%
2477 \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl
2478 \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc
2479 \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy
2480 \let\tenttsl=\reducedttsl
2481 \def\curfontsize{reduced}%
2482 \def\lsize{small}\def\lllsize{smaller}%
2483 \resetmathfonts \setleading{10.5pt}}
2484 \def\smallfonts{%
2485 \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
2486 \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
2487 \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
2488 \let\tenttsl=\smallttsl
2489 \def\curfontsize{small}%
2490 \def\lsize{smaller}\def\lllsize{smaller}%
2491 \resetmathfonts \setleading{10.5pt}}
2492 \def\smallerfonts{%
2493 \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
2494 \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
2495 \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
2496 \let\tenttsl=\smallerttsl
2497 \def\curfontsize{smaller}%
2498 \def\lsize{smaller}\def\lllsize{smaller}%
2499 \resetmathfonts \setleading{9.5pt}}
2500
2501 % Fonts for short table of contents.
2502 \setfont\shortcontrm\rmshape{12}{1000}{OT1}
2503 \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12
2504 \setfont\shortcontsl\slshape{12}{1000}{OT1}
2505 \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2506
2507 % Define these just so they can be easily changed for other fonts.
2508 \def\angleleft{$\langle$}
2509 \def\angleright{$\rangle$}
2510
2511 % Set the fonts to use with the @small... environments.
2512 \let\smallexamplefonts = \smallfonts
2513
2514 % About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample
2515 % can fit this many characters:
2516 % 8.5x11=86 smallbook=72 a4=90 a5=69
2517 % If we use \scriptfonts (8pt), then we can fit this many characters:
2518 % 8.5x11=90+ smallbook=80 a4=90+ a5=77
2519 % For me, subjectively, the few extra characters that fit aren't worth
2520 % the additional smallness of 8pt. So I'm making the default 9pt.
2521 %
2522 % By the way, for comparison, here's what fits with @example (10pt):
2523 % 8.5x11=71 smallbook=60 a4=75 a5=58
2524 % --karl, 24jan03.
2525
2526 % Set up the default fonts, so we can use them for creating boxes.
2527 %
2528 \definetextfontsizexi
2529
2530
2531 \message{markup,}
2532
2533 % Check if we are currently using a typewriter font. Since all the
2534 % Computer Modern typewriter fonts have zero interword stretch (and
2535 % shrink), and it is reasonable to expect all typewriter fonts to have
2536 % this property, we can check that font parameter.
2537 %
2538 \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
2539
2540 % Markup style infrastructure. \defmarkupstylesetup\INITMACRO will
2541 % define and register \INITMACRO to be called on markup style changes.
2542 % \INITMACRO can check \currentmarkupstyle for the innermost
2543 % style and the set of \ifmarkupSTYLE switches for all styles
2544 % currently in effect.
2545 \newif\ifmarkupvar
2546 \newif\ifmarkupsamp
2547 \newif\ifmarkupkey
2548 %\newif\ifmarkupfile % @file == @samp.
2549 %\newif\ifmarkupoption % @option == @samp.
2550 \newif\ifmarkupcode
2551 \newif\ifmarkupkbd
2552 %\newif\ifmarkupenv % @env == @code.
2553 %\newif\ifmarkupcommand % @command == @code.
2554 \newif\ifmarkuptex % @tex (and part of @math, for now).
2555 \newif\ifmarkupexample
2556 \newif\ifmarkupverb
2557 \newif\ifmarkupverbatim
2558
2559 \let\currentmarkupstyle\empty
2560
2561 \def\setupmarkupstyle#1{%
2562 \csname markup#1true\endcsname
2563 \def\currentmarkupstyle{#1}%
2564 \markupstylesetup
2565 }
2566
2567 \let\markupstylesetup\empty
2568
2569 \def\defmarkupstylesetup#1{%
2570 \expandafter\def\expandafter\markupstylesetup
2571 \expandafter{\markupstylesetup #1}%
2572 \def#1%
2573 }
2574
2575 % Markup style setup for left and right quotes.
2576 \defmarkupstylesetup\markupsetuplq{%
2577 \expandafter\let\expandafter \temp
2578 \csname markupsetuplq\currentmarkupstyle\endcsname
2579 \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
2580 }
2581
2582 \defmarkupstylesetup\markupsetuprq{%
2583 \expandafter\let\expandafter \temp
2584 \csname markupsetuprq\currentmarkupstyle\endcsname
2585 \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
2586 }
2587
2588 {
2589 \catcode`\'=\active
2590 \catcode`\`=\active
2591
2592 \gdef\markupsetuplqdefault{\let`\lq}
2593 \gdef\markupsetuprqdefault{\let'\rq}
2594
2595 \gdef\markupsetcodequoteleft{\let`\codequoteleft}
2596 \gdef\markupsetcodequoteright{\let'\codequoteright}
2597 }
2598
2599 \let\markupsetuplqcode \markupsetcodequoteleft
2600 \let\markupsetuprqcode \markupsetcodequoteright
2601 %
2602 \let\markupsetuplqexample \markupsetcodequoteleft
2603 \let\markupsetuprqexample \markupsetcodequoteright
2604 %
2605 \let\markupsetuplqkbd \markupsetcodequoteleft
2606 \let\markupsetuprqkbd \markupsetcodequoteright
2607 %
2608 \let\markupsetuplqsamp \markupsetcodequoteleft
2609 \let\markupsetuprqsamp \markupsetcodequoteright
2610 %
2611 \let\markupsetuplqverb \markupsetcodequoteleft
2612 \let\markupsetuprqverb \markupsetcodequoteright
2613 %
2614 \let\markupsetuplqverbatim \markupsetcodequoteleft
2615 \let\markupsetuprqverbatim \markupsetcodequoteright
2616
2617 % Allow an option to not use regular directed right quote/apostrophe
2618 % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2619 % The undirected quote is ugly, so don't make it the default, but it
2620 % works for pasting with more pdf viewers (at least evince), the
2621 % lilypond developers report. xpdf does work with the regular 0x27.
2622 %
2623 \def\codequoteright{%
2624 \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
2625 \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
2626 '%
2627 \else \char'15 \fi
2628 \else \char'15 \fi
2629 }
2630 %
2631 % and a similar option for the left quote char vs. a grave accent.
2632 % Modern fonts display ASCII 0x60 as a grave accent, so some people like
2633 % the code environments to do likewise.
2634 %
2635 \def\codequoteleft{%
2636 \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
2637 \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
2638 % [Knuth] pp. 380,381,391
2639 % \relax disables Spanish ligatures ?` and !` of \tt font.
2640 \relax`%
2641 \else \char'22 \fi
2642 \else \char'22 \fi
2643 }
2644
2645 % Commands to set the quote options.
2646 %
2647 \parseargdef\codequoteundirected{%
2648 \def\temp{#1}%
2649 \ifx\temp\onword
2650 \expandafter\let\csname SETtxicodequoteundirected\endcsname
2651 = t%
2652 \else\ifx\temp\offword
2653 \expandafter\let\csname SETtxicodequoteundirected\endcsname
2654 = \relax
2655 \else
2656 \errhelp = \EMsimple
2657 \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2658 \fi\fi
2659 }
2660 %
2661 \parseargdef\codequotebacktick{%
2662 \def\temp{#1}%
2663 \ifx\temp\onword
2664 \expandafter\let\csname SETtxicodequotebacktick\endcsname
2665 = t%
2666 \else\ifx\temp\offword
2667 \expandafter\let\csname SETtxicodequotebacktick\endcsname
2668 = \relax
2669 \else
2670 \errhelp = \EMsimple
2671 \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2672 \fi\fi
2673 }
2674
2675 % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2676 \def\noligaturesquoteleft{\relax\lq}
2677
2678 % Count depth in font-changes, for error checks
2679 \newcount\fontdepth \fontdepth=0
2680
2681 % Font commands.
2682
2683 % #1 is the font command (\sl or \it), #2 is the text to slant.
2684 % If we are in a monospaced environment, however, 1) always use \ttsl,
2685 % and 2) do not add an italic correction.
2686 \def\dosmartslant#1#2{%
2687 \ifusingtt
2688 {{\ttsl #2}\let\next=\relax}%
2689 {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
2690 \next
2691 }
2692 \def\smartslanted{\dosmartslant\sl}
2693 \def\smartitalic{\dosmartslant\it}
2694
2695 % Output an italic correction unless \next (presumed to be the following
2696 % character) is such as not to need one.
2697 \def\smartitaliccorrection{%
2698 \ifx\next,%
2699 \else\ifx\next-%
2700 \else\ifx\next.%
2701 \else\ifx\next\.%
2702 \else\ifx\next\comma%
2703 \else\ptexslash
2704 \fi\fi\fi\fi\fi
2705 \aftersmartic
2706 }
2707
2708 % Unconditional use \ttsl, and no ic. @var is set to this for defuns.
2709 \def\ttslanted#1{{\ttsl #1}}
2710
2711 % @cite is like \smartslanted except unconditionally use \sl. We never want
2712 % ttsl for book titles, do we?
2713 \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
2714
2715 \def\aftersmartic{}
2716 \def\var#1{%
2717 \let\saveaftersmartic = \aftersmartic
2718 \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
2719 \smartslanted{#1}%
2720 }
2721
2722 \let\i=\smartitalic
2723 \let\slanted=\smartslanted
2724 \let\dfn=\smartslanted
2725 \let\emph=\smartitalic
2726
2727 % Explicit font changes: @r, @sc, undocumented @ii.
2728 \def\r#1{{\rm #1}} % roman font
2729 \def\sc#1{{\smallcaps#1}} % smallcaps font
2730 \def\ii#1{{\it #1}} % italic font
2731
2732 % @b, explicit bold. Also @strong.
2733 \def\b#1{{\bf #1}}
2734 \let\strong=\b
2735
2736 % @sansserif, explicit sans.
2737 \def\sansserif#1{{\sf #1}}
2738
2739 % We can't just use \exhyphenpenalty, because that only has effect at
2740 % the end of a paragraph. Restore normal hyphenation at the end of the
2741 % group within which \nohyphenation is presumably called.
2742 %
2743 \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
2744 \def\restorehyphenation{\hyphenchar\font = `- }
2745
2746 % Set sfcode to normal for the chars that usually have another value.
2747 % Can't use plain's \frenchspacing because it uses the `\x notation, and
2748 % sometimes \x has an active definition that messes things up.
2749 %
2750 \catcode`@=11
2751 \def\plainfrenchspacing{%
2752 \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
2753 \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
2754 \def\endofsentencespacefactor{1000}% for @. and friends
2755 }
2756 \def\plainnonfrenchspacing{%
2757 \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2758 \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2759 \def\endofsentencespacefactor{3000}% for @. and friends
2760 }
2761 \catcode`@=\other
2762 \def\endofsentencespacefactor{3000}% default
2763
2764 % @t, explicit typewriter.
2765 \def\t#1{%
2766 {\tt \rawbackslash \plainfrenchspacing #1}%
2767 \null
2768 }
2769
2770 % @samp.
2771 \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
2772
2773 % @indicateurl is \samp, that is, with quotes.
2774 \let\indicateurl=\samp
2775
2776 % @code (and similar) prints in typewriter, but with spaces the same
2777 % size as normal in the surrounding text, without hyphenation, etc.
2778 % This is a subroutine for that.
2779 \def\tclose#1{%
2780 {%
2781 % Change normal interword space to be same as for the current font.
2782 \spaceskip = \fontdimen2\font
2783 %
2784 % Switch to typewriter.
2785 \tt
2786 %
2787 % But `\ ' produces the large typewriter interword space.
2788 \def\ {{\spaceskip = 0pt{} }}%
2789 %
2790 % Turn off hyphenation.
2791 \nohyphenation
2792 %
2793 \rawbackslash
2794 \plainfrenchspacing
2795 #1%
2796 }%
2797 \null % reset spacefactor to 1000
2798 }
2799
2800 % We *must* turn on hyphenation at `-' and `_' in @code.
2801 % (But see \codedashfinish below.)
2802 % Otherwise, it is too hard to avoid overfull hboxes
2803 % in the Emacs manual, the Library manual, etc.
2804 %
2805 % Unfortunately, TeX uses one parameter (\hyphenchar) to control
2806 % both hyphenation at - and hyphenation within words.
2807 % We must therefore turn them both off (\tclose does that)
2808 % and arrange explicitly to hyphenate at a dash. -- rms.
2809 {
2810 \catcode`\-=\active \catcode`\_=\active
2811 \catcode`\'=\active \catcode`\`=\active
2812 \global\let'=\rq \global\let`=\lq % default definitions
2813 %
2814 \global\def\code{\begingroup
2815 \setupmarkupstyle{code}%
2816 % The following should really be moved into \setupmarkupstyle handlers.
2817 \catcode\dashChar=\active \catcode\underChar=\active
2818 \ifallowcodebreaks
2819 \let-\codedash
2820 \let_\codeunder
2821 \else
2822 \let-\normaldash
2823 \let_\realunder
2824 \fi
2825 % Given -foo (with a single dash), we do not want to allow a break
2826 % after the hyphen.
2827 \global\let\codedashprev=\codedash
2828 %
2829 \codex
2830 }
2831 %
2832 \gdef\codedash{\futurelet\next\codedashfinish}
2833 \gdef\codedashfinish{%
2834 \normaldash % always output the dash character itself.
2835 %
2836 % Now, output a discretionary to allow a line break, unless
2837 % (a) the next character is a -, or
2838 % (b) the preceding character is a -.
2839 % E.g., given --posix, we do not want to allow a break after either -.
2840 % Given --foo-bar, we do want to allow a break between the - and the b.
2841 \ifx\next\codedash \else
2842 \ifx\codedashprev\codedash
2843 \else \discretionary{}{}{}\fi
2844 \fi
2845 % we need the space after the = for the case when \next itself is a
2846 % space token; it would get swallowed otherwise. As in @code{- a}.
2847 \global\let\codedashprev= \next
2848 }
2849 }
2850 \def\normaldash{-}
2851 %
2852 \def\codex #1{\tclose{#1}\endgroup}
2853
2854 \def\codeunder{%
2855 % this is all so @math{@code{var_name}+1} can work. In math mode, _
2856 % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2857 % will therefore expand the active definition of _, which is us
2858 % (inside @code that is), therefore an endless loop.
2859 \ifusingtt{\ifmmode
2860 \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2861 \else\normalunderscore \fi
2862 \discretionary{}{}{}}%
2863 {\_}%
2864 }
2865
2866 % An additional complication: the above will allow breaks after, e.g.,
2867 % each of the four underscores in __typeof__. This is bad.
2868 % @allowcodebreaks provides a document-level way to turn breaking at -
2869 % and _ on and off.
2870 %
2871 \newif\ifallowcodebreaks \allowcodebreakstrue
2872
2873 \def\keywordtrue{true}
2874 \def\keywordfalse{false}
2875
2876 \parseargdef\allowcodebreaks{%
2877 \def\txiarg{#1}%
2878 \ifx\txiarg\keywordtrue
2879 \allowcodebreakstrue
2880 \else\ifx\txiarg\keywordfalse
2881 \allowcodebreaksfalse
2882 \else
2883 \errhelp = \EMsimple
2884 \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
2885 \fi\fi
2886 }
2887
2888 % For @command, @env, @file, @option quotes seem unnecessary,
2889 % so use \code rather than \samp.
2890 \let\command=\code
2891 \let\env=\code
2892 \let\file=\code
2893 \let\option=\code
2894
2895 % @uref (abbreviation for `urlref') aka @url takes an optional
2896 % (comma-separated) second argument specifying the text to display and
2897 % an optional third arg as text to display instead of (rather than in
2898 % addition to) the url itself. First (mandatory) arg is the url.
2899
2900 % TeX-only option to allow changing PDF output to show only the second
2901 % arg (if given), and not the url (which is then just the link target).
2902 \newif\ifurefurlonlylink
2903
2904 % The main macro is \urefbreak, which allows breaking at expected
2905 % places within the url. (There used to be another version, which
2906 % didn't support automatic breaking.)
2907 \def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
2908 \let\uref=\urefbreak
2909 %
2910 \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
2911 \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
2912 \unsepspaces
2913 \pdfurl{#1}%
2914 \setbox0 = \hbox{\ignorespaces #3}%
2915 \ifdim\wd0 > 0pt
2916 \unhbox0 % third arg given, show only that
2917 \else
2918 \setbox0 = \hbox{\ignorespaces #2}% look for second arg
2919 \ifdim\wd0 > 0pt
2920 \ifpdf
2921 % For pdfTeX and LuaTeX
2922 \ifurefurlonlylink
2923 % PDF plus option to not display url, show just arg
2924 \unhbox0
2925 \else
2926 % PDF, normally display both arg and url for consistency,
2927 % visibility, if the pdf is eventually used to print, etc.
2928 \unhbox0\ (\urefcode{#1})%
2929 \fi
2930 \else
2931 \ifx\XeTeXrevision\thisisundefined
2932 \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
2933 \else
2934 % For XeTeX
2935 \ifurefurlonlylink
2936 % PDF plus option to not display url, show just arg
2937 \unhbox0
2938 \else
2939 % PDF, normally display both arg and url for consistency,
2940 % visibility, if the pdf is eventually used to print, etc.
2941 \unhbox0\ (\urefcode{#1})%
2942 \fi
2943 \fi
2944 \fi
2945 \else
2946 \urefcode{#1}% only url given, so show it
2947 \fi
2948 \fi
2949 \endlink
2950 \endgroup}
2951
2952 % Allow line breaks around only a few characters (only).
2953 \def\urefcatcodes{%
2954 \catcode`\&=\active \catcode`\.=\active
2955 \catcode`\#=\active \catcode`\?=\active
2956 \catcode`\/=\active
2957 }
2958 {
2959 \urefcatcodes
2960 %
2961 \global\def\urefcode{\begingroup
2962 \setupmarkupstyle{code}%
2963 \urefcatcodes
2964 \let&\urefcodeamp
2965 \let.\urefcodedot
2966 \let#\urefcodehash
2967 \let?\urefcodequest
2968 \let/\urefcodeslash
2969 \codex
2970 }
2971 %
2972 % By default, they are just regular characters.
2973 \global\def&{\normalamp}
2974 \global\def.{\normaldot}
2975 \global\def#{\normalhash}
2976 \global\def?{\normalquest}
2977 \global\def/{\normalslash}
2978 }
2979
2980 % we put a little stretch before and after the breakable chars, to help
2981 % line breaking of long url's. The unequal skips make look better in
2982 % cmtt at least, especially for dots.
2983 \def\urefprestretchamount{.13em}
2984 \def\urefpoststretchamount{.1em}
2985 \def\urefprestretch{\urefprebreak \hskip0pt plus\urefprestretchamount\relax}
2986 \def\urefpoststretch{\urefpostbreak \hskip0pt plus\urefprestretchamount\relax}
2987 %
2988 \def\urefcodeamp{\urefprestretch \&\urefpoststretch}
2989 \def\urefcodedot{\urefprestretch .\urefpoststretch}
2990 \def\urefcodehash{\urefprestretch \#\urefpoststretch}
2991 \def\urefcodequest{\urefprestretch ?\urefpoststretch}
2992 \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
2993 {
2994 \catcode`\/=\active
2995 \global\def\urefcodeslashfinish{%
2996 \urefprestretch \slashChar
2997 % Allow line break only after the final / in a sequence of
2998 % slashes, to avoid line break between the slashes in http://.
2999 \ifx\next/\else \urefpoststretch \fi
3000 }
3001 }
3002
3003 % One more complication: by default we'll break after the special
3004 % characters, but some people like to break before the special chars, so
3005 % allow that. Also allow no breaking at all, for manual control.
3006 %
3007 \parseargdef\urefbreakstyle{%
3008 \def\txiarg{#1}%
3009 \ifx\txiarg\wordnone
3010 \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
3011 \else\ifx\txiarg\wordbefore
3012 \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
3013 \else\ifx\txiarg\wordafter
3014 \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
3015 \else
3016 \errhelp = \EMsimple
3017 \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
3018 \fi\fi\fi
3019 }
3020 \def\wordafter{after}
3021 \def\wordbefore{before}
3022 \def\wordnone{none}
3023
3024 \urefbreakstyle after
3025
3026 % @url synonym for @uref, since that's how everyone uses it.
3027 %
3028 \let\url=\uref
3029
3030 % rms does not like angle brackets --karl, 17may97.
3031 % So now @email is just like @uref, unless we are pdf.
3032 %
3033 %\def\email#1{\angleleft{\tt #1}\angleright}
3034 \ifpdf
3035 \def\email#1{\doemail#1,,\finish}
3036 \def\doemail#1,#2,#3\finish{\begingroup
3037 \unsepspaces
3038 \pdfurl{mailto:#1}%
3039 \setbox0 = \hbox{\ignorespaces #2}%
3040 \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3041 \endlink
3042 \endgroup}
3043 \else
3044 \ifx\XeTeXrevision\thisisundefined
3045 \let\email=\uref
3046 \else
3047 \def\email#1{\doemail#1,,\finish}
3048 \def\doemail#1,#2,#3\finish{\begingroup
3049 \unsepspaces
3050 \pdfurl{mailto:#1}%
3051 \setbox0 = \hbox{\ignorespaces #2}%
3052 \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3053 \endlink
3054 \endgroup}
3055 \fi
3056 \fi
3057
3058 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
3059 % `example' (@kbd uses ttsl only inside of @example and friends),
3060 % or `code' (@kbd uses normal tty font always).
3061 \parseargdef\kbdinputstyle{%
3062 \def\txiarg{#1}%
3063 \ifx\txiarg\worddistinct
3064 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
3065 \else\ifx\txiarg\wordexample
3066 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
3067 \else\ifx\txiarg\wordcode
3068 \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
3069 \else
3070 \errhelp = \EMsimple
3071 \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
3072 \fi\fi\fi
3073 }
3074 \def\worddistinct{distinct}
3075 \def\wordexample{example}
3076 \def\wordcode{code}
3077
3078 % Default is `distinct'.
3079 \kbdinputstyle distinct
3080
3081 % @kbd is like @code, except that if the argument is just one @key command,
3082 % then @kbd has no effect.
3083 \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
3084
3085 \def\xkey{\key}
3086 \def\kbdsub#1#2#3\par{%
3087 \def\one{#1}\def\three{#3}\def\threex{??}%
3088 \ifx\one\xkey\ifx\threex\three \key{#2}%
3089 \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3090 \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3091 }
3092
3093 % definition of @key that produces a lozenge. Doesn't adjust to text size.
3094 %\setfont\keyrm\rmshape{8}{1000}{OT1}
3095 %\font\keysy=cmsy9
3096 %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
3097 % \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
3098 % \vbox{\hrule\kern-0.4pt
3099 % \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
3100 % \kern-0.4pt\hrule}%
3101 % \kern-.06em\raise0.4pt\hbox{\angleright}}}}
3102
3103 % definition of @key with no lozenge. If the current font is already
3104 % monospace, don't change it; that way, we respect @kbdinputstyle. But
3105 % if it isn't monospace, then use \tt.
3106 %
3107 \def\key#1{{\setupmarkupstyle{key}%
3108 \nohyphenation
3109 \ifmonospace\else\tt\fi
3110 #1}\null}
3111
3112 % @clicksequence{File @click{} Open ...}
3113 \def\clicksequence#1{\begingroup #1\endgroup}
3114
3115 % @clickstyle @arrow (by default)
3116 \parseargdef\clickstyle{\def\click{#1}}
3117 \def\click{\arrow}
3118
3119 % Typeset a dimension, e.g., `in' or `pt'. The only reason for the
3120 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
3121 %
3122 \def\dmn#1{\thinspace #1}
3123
3124 % @acronym for "FBI", "NATO", and the like.
3125 % We print this one point size smaller, since it's intended for
3126 % all-uppercase.
3127 %
3128 \def\acronym#1{\doacronym #1,,\finish}
3129 \def\doacronym#1,#2,#3\finish{%
3130 {\selectfonts\lsize #1}%
3131 \def\temp{#2}%
3132 \ifx\temp\empty \else
3133 \space ({\unsepspaces \ignorespaces \temp \unskip})%
3134 \fi
3135 \null % reset \spacefactor=1000
3136 }
3137
3138 % @abbr for "Comput. J." and the like.
3139 % No font change, but don't do end-of-sentence spacing.
3140 %
3141 \def\abbr#1{\doabbr #1,,\finish}
3142 \def\doabbr#1,#2,#3\finish{%
3143 {\plainfrenchspacing #1}%
3144 \def\temp{#2}%
3145 \ifx\temp\empty \else
3146 \space ({\unsepspaces \ignorespaces \temp \unskip})%
3147 \fi
3148 \null % reset \spacefactor=1000
3149 }
3150
3151 % @asis just yields its argument. Used with @table, for example.
3152 %
3153 \def\asis#1{#1}
3154
3155 % @math outputs its argument in math mode.
3156 %
3157 % One complication: _ usually means subscripts, but it could also mean
3158 % an actual _ character, as in @math{@var{some_variable} + 1}. So make
3159 % _ active, and distinguish by seeing if the current family is \slfam,
3160 % which is what @var uses.
3161 {
3162 \catcode`\_ = \active
3163 \gdef\mathunderscore{%
3164 \catcode`\_=\active
3165 \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
3166 }
3167 }
3168 % Another complication: we want \\ (and @\) to output a math (or tt) \.
3169 % FYI, plain.tex uses \\ as a temporary control sequence (for no
3170 % particular reason), but this is not advertised and we don't care.
3171 %
3172 % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
3173 \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
3174 %
3175 \def\math{%
3176 \ifmmode\else % only go into math if not in math mode already
3177 \tex
3178 \mathunderscore
3179 \let\\ = \mathbackslash
3180 \mathactive
3181 % make the texinfo accent commands work in math mode
3182 \let\"=\ddot
3183 \let\'=\acute
3184 \let\==\bar
3185 \let\^=\hat
3186 \let\`=\grave
3187 \let\u=\breve
3188 \let\v=\check
3189 \let\~=\tilde
3190 \let\dotaccent=\dot
3191 % have to provide another name for sup operator
3192 \let\mathopsup=\sup
3193 $\expandafter\finishmath\fi
3194 }
3195 \def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
3196
3197 % Some active characters (such as <) are spaced differently in math.
3198 % We have to reset their definitions in case the @math was an argument
3199 % to a command which sets the catcodes (such as @item or @section).
3200 %
3201 {
3202 \catcode`^ = \active
3203 \catcode`< = \active
3204 \catcode`> = \active
3205 \catcode`+ = \active
3206 \catcode`' = \active
3207 \gdef\mathactive{%
3208 \let^ = \ptexhat
3209 \let< = \ptexless
3210 \let> = \ptexgtr
3211 \let+ = \ptexplus
3212 \let' = \ptexquoteright
3213 }
3214 }
3215
3216 % for @sub and @sup, if in math mode, just do a normal sub/superscript.
3217 % If in text, use math to place as sub/superscript, but switch
3218 % into text mode, with smaller fonts. This is a different font than the
3219 % one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3220 % fix it (significant additions to font machinery) until someone notices.
3221 %
3222 \def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
3223 \def\finishsub#1{$\sb{\hbox{\selectfonts\lllsize #1}}$}%
3224 %
3225 \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
3226 \def\finishsup#1{$\ptexsp{\hbox{\selectfonts\lllsize #1}}$}%
3227
3228 % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3229 % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3230 % except specified as a normal braced arg, so no newlines to worry about.
3231 %
3232 \def\outfmtnametex{tex}
3233 %
3234 \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3235 \long\def\doinlinefmt#1,#2,\finish{%
3236 \def\inlinefmtname{#1}%
3237 \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3238 }
3239 %
3240 % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3241 % FMTNAME is tex, else ELSE-TEXT.
3242 \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3243 \long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3244 \def\inlinefmtname{#1}%
3245 \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3246 }
3247 %
3248 % For raw, must switch into @tex before parsing the argument, to avoid
3249 % setting catcodes prematurely. Doing it this way means that, for
3250 % example, @inlineraw{html, foo{bar} gets a parse error instead of being
3251 % ignored. But this isn't important because if people want a literal
3252 % *right* brace they would have to use a command anyway, so they may as
3253 % well use a command to get a left brace too. We could re-use the
3254 % delimiter character idea from \verb, but it seems like overkill.
3255 %
3256 \long\def\inlineraw{\tex \doinlineraw}
3257 \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3258 \def\doinlinerawtwo#1,#2,\finish{%
3259 \def\inlinerawname{#1}%
3260 \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3261 \endgroup % close group opened by \tex.
3262 }
3263
3264 % @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3265 %
3266 \long\def\inlineifset#1{\doinlineifset #1,\finish}
3267 \long\def\doinlineifset#1,#2,\finish{%
3268 \def\inlinevarname{#1}%
3269 \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3270 \else\ignorespaces#2\fi
3271 }
3272
3273 % @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3274 %
3275 \long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3276 \long\def\doinlineifclear#1,#2,\finish{%
3277 \def\inlinevarname{#1}%
3278 \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3279 }
3280
3281
3282 \message{glyphs,}
3283 % and logos.
3284
3285 % @@ prints an @, as does @atchar{}.
3286 \def\@{\char64 }
3287 \let\atchar=\@
3288
3289 % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
3290 % Unless we're in typewriter, use \ecfont because the CM text fonts do
3291 % not have braces, and we don't want to switch into math.
3292 \def\mylbrace{{\ifmonospace\char123\else\ensuremath\lbrace\fi}}
3293 \def\myrbrace{{\ifmonospace\char125\else\ensuremath\rbrace\fi}}
3294 \let\{=\mylbrace \let\lbracechar=\{
3295 \let\}=\myrbrace \let\rbracechar=\}
3296 \begingroup
3297 % Definitions to produce \{ and \} commands for indices,
3298 % and @{ and @} for the aux/toc files.
3299 \catcode`\{ = \other \catcode`\} = \other
3300 \catcode`\[ = 1 \catcode`\] = 2
3301 \catcode`\! = 0 \catcode`\\ = \other
3302 !gdef!lbracecmd[\{]%
3303 !gdef!rbracecmd[\}]%
3304 !gdef!lbraceatcmd[@{]%
3305 !gdef!rbraceatcmd[@}]%
3306 !endgroup
3307
3308 % @comma{} to avoid , parsing problems.
3309 \let\comma = ,
3310
3311 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3312 % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3313 \let\, = \ptexc
3314 \let\dotaccent = \ptexdot
3315 \def\ringaccent#1{{\accent23 #1}}
3316 \let\tieaccent = \ptext
3317 \let\ubaraccent = \ptexb
3318 \let\udotaccent = \d
3319
3320 % Other special characters: @questiondown @exclamdown @ordf @ordm
3321 % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3322 \def\questiondown{?`}
3323 \def\exclamdown{!`}
3324 \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
3325 \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
3326
3327 % Dotless i and dotless j, used for accents.
3328 \def\imacro{i}
3329 \def\jmacro{j}
3330 \def\dotless#1{%
3331 \def\temp{#1}%
3332 \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3333 \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3334 \else \errmessage{@dotless can be used only with i or j}%
3335 \fi\fi
3336 }
3337
3338 % The \TeX{} logo, as in plain, but resetting the spacing so that a
3339 % period following counts as ending a sentence. (Idea found in latex.)
3340 %
3341 \edef\TeX{\TeX \spacefactor=1000 }
3342
3343 % @LaTeX{} logo. Not quite the same results as the definition in
3344 % latex.ltx, since we use a different font for the raised A; it's most
3345 % convenient for us to use an explicitly smaller font, rather than using
3346 % the \scriptstyle font (since we don't reset \scriptstyle and
3347 % \scriptscriptstyle).
3348 %
3349 \def\LaTeX{%
3350 L\kern-.36em
3351 {\setbox0=\hbox{T}%
3352 \vbox to \ht0{\hbox{%
3353 \ifx\textnominalsize\xwordpt
3354 % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX.
3355 % Revert to plain's \scriptsize, which is 7pt.
3356 \count255=\the\fam $\fam\count255 \scriptstyle A$%
3357 \else
3358 % For 11pt, we can use our lllsize.
3359 \selectfonts\lllsize A%
3360 \fi
3361 }%
3362 \vss
3363 }}%
3364 \kern-.15em
3365 \TeX
3366 }
3367
3368 % Some math mode symbols. Define \ensuremath to switch into math mode
3369 % unless we are already there. Expansion tricks may not be needed here,
3370 % but safer, and can't hurt.
3371 \def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3372 \def\ensuredmath#1{$\relax#1$}
3373 %
3374 \def\bullet{\ensuremath\ptexbullet}
3375 \def\geq{\ensuremath\ge}
3376 \def\leq{\ensuremath\le}
3377 \def\minus{\ensuremath-}
3378
3379 % @dots{} outputs an ellipsis using the current font.
3380 % We do .5em per period so that it has the same spacing in the cm
3381 % typewriter fonts as three actual period characters; on the other hand,
3382 % in other typewriter fonts three periods are wider than 1.5em. So do
3383 % whichever is larger.
3384 %
3385 \def\dots{%
3386 \leavevmode
3387 \setbox0=\hbox{...}% get width of three periods
3388 \ifdim\wd0 > 1.5em
3389 \dimen0 = \wd0
3390 \else
3391 \dimen0 = 1.5em
3392 \fi
3393 \hbox to \dimen0{%
3394 \hskip 0pt plus.25fil
3395 .\hskip 0pt plus1fil
3396 .\hskip 0pt plus1fil
3397 .\hskip 0pt plus.5fil
3398 }%
3399 }
3400
3401 % @enddots{} is an end-of-sentence ellipsis.
3402 %
3403 \def\enddots{%
3404 \dots
3405 \spacefactor=\endofsentencespacefactor
3406 }
3407
3408 % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3409 %
3410 % Since these characters are used in examples, they should be an even number of
3411 % \tt widths. Each \tt character is 1en, so two makes it 1em.
3412 %
3413 \def\point{$\star$}
3414 \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3415 \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3416 \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3417 \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3418 \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3419
3420 % The @error{} command.
3421 % Adapted from the TeXbook's \boxit.
3422 %
3423 \newbox\errorbox
3424 %
3425 {\tentt \global\dimen0 = 3em}% Width of the box.
3426 \dimen2 = .55pt % Thickness of rules
3427 % The text. (`r' is open on the right, `e' somewhat less so on the left.)
3428 \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3429 %
3430 \setbox\errorbox=\hbox to \dimen0{\hfil
3431 \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3432 \advance\hsize by -2\dimen2 % Rules.
3433 \vbox{%
3434 \hrule height\dimen2
3435 \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
3436 \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3437 \kern3pt\vrule width\dimen2}% Space to right.
3438 \hrule height\dimen2}
3439 \hfil}
3440 %
3441 \def\error{\leavevmode\lower.7ex\copy\errorbox}
3442
3443 % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3444 %
3445 \def\pounds{{\it\$}}
3446
3447 % @euro{} comes from a separate font, depending on the current style.
3448 % We use the free feym* fonts from the eurosym package by Henrik
3449 % Theiling, which support regular, slanted, bold and bold slanted (and
3450 % "outlined" (blackboard board, sort of) versions, which we don't need).
3451 % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3452 %
3453 % Although only regular is the truly official Euro symbol, we ignore
3454 % that. The Euro is designed to be slightly taller than the regular
3455 % font height.
3456 %
3457 % feymr - regular
3458 % feymo - slanted
3459 % feybr - bold
3460 % feybo - bold slanted
3461 %
3462 % There is no good (free) typewriter version, to my knowledge.
3463 % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3464 % Hmm.
3465 %
3466 % Also doesn't work in math. Do we need to do math with euro symbols?
3467 % Hope not.
3468 %
3469 %
3470 \def\euro{{\eurofont e}}
3471 \def\eurofont{%
3472 % We set the font at each command, rather than predefining it in
3473 % \textfonts and the other font-switching commands, so that
3474 % installations which never need the symbol don't have to have the
3475 % font installed.
3476 %
3477 % There is only one designed size (nominal 10pt), so we always scale
3478 % that to the current nominal size.
3479 %
3480 % By the way, simply using "at 1em" works for cmr10 and the like, but
3481 % does not work for cmbx10 and other extended/shrunken fonts.
3482 %
3483 \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3484 %
3485 \ifx\curfontstyle\bfstylename
3486 % bold:
3487 \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3488 \else
3489 % regular:
3490 \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3491 \fi
3492 \thiseurofont
3493 }
3494
3495 % Glyphs from the EC fonts. We don't use \let for the aliases, because
3496 % sometimes we redefine the original macro, and the alias should reflect
3497 % the redefinition.
3498 %
3499 % Use LaTeX names for the Icelandic letters.
3500 \def\DH{{\ecfont \char"D0}} % Eth
3501 \def\dh{{\ecfont \char"F0}} % eth
3502 \def\TH{{\ecfont \char"DE}} % Thorn
3503 \def\th{{\ecfont \char"FE}} % thorn
3504 %
3505 \def\guillemetleft{{\ecfont \char"13}}
3506 \def\guillemotleft{\guillemetleft}
3507 \def\guillemetright{{\ecfont \char"14}}
3508 \def\guillemotright{\guillemetright}
3509 \def\guilsinglleft{{\ecfont \char"0E}}
3510 \def\guilsinglright{{\ecfont \char"0F}}
3511 \def\quotedblbase{{\ecfont \char"12}}
3512 \def\quotesinglbase{{\ecfont \char"0D}}
3513 %
3514 % This positioning is not perfect (see the ogonek LaTeX package), but
3515 % we have the precomposed glyphs for the most common cases. We put the
3516 % tests to use those glyphs in the single \ogonek macro so we have fewer
3517 % dummy definitions to worry about for index entries, etc.
3518 %
3519 % ogonek is also used with other letters in Lithuanian (IOU), but using
3520 % the precomposed glyphs for those is not so easy since they aren't in
3521 % the same EC font.
3522 \def\ogonek#1{{%
3523 \def\temp{#1}%
3524 \ifx\temp\macrocharA\Aogonek
3525 \else\ifx\temp\macrochara\aogonek
3526 \else\ifx\temp\macrocharE\Eogonek
3527 \else\ifx\temp\macrochare\eogonek
3528 \else
3529 \ecfont \setbox0=\hbox{#1}%
3530 \ifdim\ht0=1ex\accent"0C #1%
3531 \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3532 \fi
3533 \fi\fi\fi\fi
3534 }%
3535 }
3536 \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3537 \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3538 \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3539 \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3540 %
3541 % Use the European Computer Modern fonts (cm-super in outline format)
3542 % for non-CM glyphs. That is ec* for regular text and tc* for the text
3543 % companion symbols (LaTeX TS1 encoding). Both are part of the ec
3544 % package and follow the same conventions.
3545 %
3546 \def\ecfont{\etcfont{e}}
3547 \def\tcfont{\etcfont{t}}
3548 %
3549 \def\etcfont#1{%
3550 % We can't distinguish serif/sans and italic/slanted, but this
3551 % is used for crude hacks anyway (like adding French and German
3552 % quotes to documents typeset with CM, where we lose kerning), so
3553 % hopefully nobody will notice/care.
3554 \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3555 \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
3556 \ifmonospace
3557 % typewriter:
3558 \font\thisecfont = #1ctt\ecsize \space at \nominalsize
3559 \else
3560 \ifx\curfontstyle\bfstylename
3561 % bold:
3562 \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
3563 \else
3564 % regular:
3565 \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
3566 \fi
3567 \fi
3568 \thisecfont
3569 }
3570
3571 % @registeredsymbol - R in a circle. The font for the R should really
3572 % be smaller yet, but lllsize is the best we can do for now.
3573 % Adapted from the plain.tex definition of \copyright.
3574 %
3575 \def\registeredsymbol{%
3576 $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
3577 \hfil\crcr\Orb}}%
3578 }$%
3579 }
3580
3581 % @textdegree - the normal degrees sign.
3582 %
3583 \def\textdegree{$^\circ$}
3584
3585 % Laurent Siebenmann reports \Orb undefined with:
3586 % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
3587 % so we'll define it if necessary.
3588 %
3589 \ifx\Orb\thisisundefined
3590 \def\Orb{\mathhexbox20D}
3591 \fi
3592
3593 % Quotes.
3594 \chardef\quotedblleft="5C
3595 \chardef\quotedblright=`\"
3596 \chardef\quoteleft=`\`
3597 \chardef\quoteright=`\'
3598
3599
3600 \message{page headings,}
3601
3602 \newskip\titlepagetopglue \titlepagetopglue = 1.5in
3603 \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3604
3605 % First the title page. Must do @settitle before @titlepage.
3606 \newif\ifseenauthor
3607 \newif\iffinishedtitlepage
3608
3609 % @setcontentsaftertitlepage used to do an implicit @contents or
3610 % @shortcontents after @end titlepage, but it is now obsolete.
3611 \def\setcontentsaftertitlepage{%
3612 \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
3613 command; move your @contents command if you want the contents
3614 after the title page.}}%
3615 \def\setshortcontentsaftertitlepage{%
3616 \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
3617 command; move your @shortcontents and @contents commands if you
3618 want the contents after the title page.}}%
3619
3620 \parseargdef\shorttitlepage{%
3621 \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3622 \endgroup\page\hbox{}\page}
3623
3624 \envdef\titlepage{%
3625 % Open one extra group, as we want to close it in the middle of \Etitlepage.
3626 \begingroup
3627 \parindent=0pt \textfonts
3628 % Leave some space at the very top of the page.
3629 \vglue\titlepagetopglue
3630 % No rule at page bottom unless we print one at the top with @title.
3631 \finishedtitlepagetrue
3632 %
3633 % Most title ``pages'' are actually two pages long, with space
3634 % at the top of the second. We don't want the ragged left on the second.
3635 \let\oldpage = \page
3636 \def\page{%
3637 \iffinishedtitlepage\else
3638 \finishtitlepage
3639 \fi
3640 \let\page = \oldpage
3641 \page
3642 \null
3643 }%
3644 }
3645
3646 \def\Etitlepage{%
3647 \iffinishedtitlepage\else
3648 \finishtitlepage
3649 \fi
3650 % It is important to do the page break before ending the group,
3651 % because the headline and footline are only empty inside the group.
3652 % If we use the new definition of \page, we always get a blank page
3653 % after the title page, which we certainly don't want.
3654 \oldpage
3655 \endgroup
3656 %
3657 % Need this before the \...aftertitlepage checks so that if they are
3658 % in effect the toc pages will come out with page numbers.
3659 \HEADINGSon
3660 }
3661
3662 \def\finishtitlepage{%
3663 \vskip4pt \hrule height 2pt width \hsize
3664 \vskip\titlepagebottomglue
3665 \finishedtitlepagetrue
3666 }
3667
3668 % Settings used for typesetting titles: no hyphenation, no indentation,
3669 % don't worry much about spacing, ragged right. This should be used
3670 % inside a \vbox, and fonts need to be set appropriately first. Because
3671 % it is always used for titles, nothing else, we call \rmisbold. \par
3672 % should be specified before the end of the \vbox, since a vbox is a group.
3673 %
3674 \def\raggedtitlesettings{%
3675 \rmisbold
3676 \hyphenpenalty=10000
3677 \parindent=0pt
3678 \tolerance=5000
3679 \ptexraggedright
3680 }
3681
3682 % Macros to be used within @titlepage:
3683
3684 \let\subtitlerm=\tenrm
3685 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3686
3687 \parseargdef\title{%
3688 \checkenv\titlepage
3689 \vbox{\titlefonts \raggedtitlesettings #1\par}%
3690 % print a rule at the page bottom also.
3691 \finishedtitlepagefalse
3692 \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3693 }
3694
3695 \parseargdef\subtitle{%
3696 \checkenv\titlepage
3697 {\subtitlefont \rightline{#1}}%
3698 }
3699
3700 % @author should come last, but may come many times.
3701 % It can also be used inside @quotation.
3702 %
3703 \parseargdef\author{%
3704 \def\temp{\quotation}%
3705 \ifx\thisenv\temp
3706 \def\quotationauthor{#1}% printed in \Equotation.
3707 \else
3708 \checkenv\titlepage
3709 \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3710 {\secfonts\rmisbold \leftline{#1}}%
3711 \fi
3712 }
3713
3714
3715 % Set up page headings and footings.
3716
3717 \let\thispage=\folio
3718
3719 \newtoks\evenheadline % headline on even pages
3720 \newtoks\oddheadline % headline on odd pages
3721 \newtoks\evenfootline % footline on even pages
3722 \newtoks\oddfootline % footline on odd pages
3723
3724 % Now make \makeheadline and \makefootline in Plain TeX use those variables
3725 \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
3726 \else \the\evenheadline \fi}}
3727 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
3728 \else \the\evenfootline \fi}\HEADINGShook}
3729 \let\HEADINGShook=\relax
3730
3731 % Commands to set those variables.
3732 % For example, this is what @headings on does
3733 % @evenheading @thistitle|@thispage|@thischapter
3734 % @oddheading @thischapter|@thispage|@thistitle
3735 % @evenfooting @thisfile||
3736 % @oddfooting ||@thisfile
3737
3738
3739 \def\evenheading{\parsearg\evenheadingxxx}
3740 \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3741 \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
3742 \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3743
3744 \def\oddheading{\parsearg\oddheadingxxx}
3745 \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3746 \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
3747 \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3748
3749 \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3750
3751 \def\evenfooting{\parsearg\evenfootingxxx}
3752 \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3753 \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3754 \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3755
3756 \def\oddfooting{\parsearg\oddfootingxxx}
3757 \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3758 \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3759 \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3760 %
3761 % Leave some space for the footline. Hopefully ok to assume
3762 % @evenfooting will not be used by itself.
3763 \global\advance\txipageheight by -12pt
3764 \global\advance\vsize by -12pt
3765 }
3766
3767 \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3768
3769 % @evenheadingmarks top \thischapter <- chapter at the top of a page
3770 % @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page
3771 %
3772 % The same set of arguments for:
3773 %
3774 % @oddheadingmarks
3775 % @evenfootingmarks
3776 % @oddfootingmarks
3777 % @everyheadingmarks
3778 % @everyfootingmarks
3779
3780 % These define \getoddheadingmarks, \getevenheadingmarks,
3781 % \getoddfootingmarks, and \getevenfootingmarks, each to one of
3782 % \gettopheadingmarks, \getbottomheadingmarks.
3783 %
3784 \def\evenheadingmarks{\headingmarks{even}{heading}}
3785 \def\oddheadingmarks{\headingmarks{odd}{heading}}
3786 \def\evenfootingmarks{\headingmarks{even}{footing}}
3787 \def\oddfootingmarks{\headingmarks{odd}{footing}}
3788 \parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
3789 \headingmarks{odd}{heading}{#1} }
3790 \parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
3791 \headingmarks{odd}{footing}{#1} }
3792 % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3793 \def\headingmarks#1#2#3 {%
3794 \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3795 \global\expandafter\let\csname get#1#2marks\endcsname \temp
3796 }
3797
3798 \everyheadingmarks bottom
3799 \everyfootingmarks bottom
3800
3801 % @headings double turns headings on for double-sided printing.
3802 % @headings single turns headings on for single-sided printing.
3803 % @headings off turns them off.
3804 % @headings on same as @headings double, retained for compatibility.
3805 % @headings after turns on double-sided headings after this page.
3806 % @headings doubleafter turns on double-sided headings after this page.
3807 % @headings singleafter turns on single-sided headings after this page.
3808 % By default, they are off at the start of a document,
3809 % and turned `on' after @end titlepage.
3810
3811 \parseargdef\headings{\csname HEADINGS#1\endcsname}
3812
3813 \def\headingsoff{% non-global headings elimination
3814 \evenheadline={\hfil}\evenfootline={\hfil}%
3815 \oddheadline={\hfil}\oddfootline={\hfil}%
3816 }
3817
3818 \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3819 \HEADINGSoff % it's the default
3820
3821 % When we turn headings on, set the page number to 1.
3822 % For double-sided printing, put current file name in lower left corner,
3823 % chapter name on inside top of right hand pages, document
3824 % title on inside top of left hand pages, and page numbers on outside top
3825 % edge of all pages.
3826 \def\HEADINGSdouble{%
3827 \global\pageno=1
3828 \global\evenfootline={\hfil}
3829 \global\oddfootline={\hfil}
3830 \global\evenheadline={\line{\folio\hfil\thistitle}}
3831 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3832 \global\let\contentsalignmacro = \chapoddpage
3833 }
3834 \let\contentsalignmacro = \chappager
3835
3836 % For single-sided printing, chapter title goes across top left of page,
3837 % page number on top right.
3838 \def\HEADINGSsingle{%
3839 \global\pageno=1
3840 \global\evenfootline={\hfil}
3841 \global\oddfootline={\hfil}
3842 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
3843 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3844 \global\let\contentsalignmacro = \chappager
3845 }
3846 \def\HEADINGSon{\HEADINGSdouble}
3847
3848 \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
3849 \let\HEADINGSdoubleafter=\HEADINGSafter
3850 \def\HEADINGSdoublex{%
3851 \global\evenfootline={\hfil}
3852 \global\oddfootline={\hfil}
3853 \global\evenheadline={\line{\folio\hfil\thistitle}}
3854 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3855 \global\let\contentsalignmacro = \chapoddpage
3856 }
3857
3858 \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
3859 \def\HEADINGSsinglex{%
3860 \global\evenfootline={\hfil}
3861 \global\oddfootline={\hfil}
3862 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
3863 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3864 \global\let\contentsalignmacro = \chappager
3865 }
3866
3867 % Subroutines used in generating headings
3868 % This produces Day Month Year style of output.
3869 % Only define if not already defined, in case a txi-??.tex file has set
3870 % up a different format (e.g., txi-cs.tex does this).
3871 \ifx\today\thisisundefined
3872 \def\today{%
3873 \number\day\space
3874 \ifcase\month
3875 \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
3876 \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
3877 \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
3878 \fi
3879 \space\number\year}
3880 \fi
3881
3882 % @settitle line... specifies the title of the document, for headings.
3883 % It generates no output of its own.
3884 \def\thistitle{\putwordNoTitle}
3885 \def\settitle{\parsearg{\gdef\thistitle}}
3886
3887
3888 \message{tables,}
3889 % Tables -- @table, @ftable, @vtable, @item(x).
3890
3891 % default indentation of table text
3892 \newdimen\tableindent \tableindent=.8in
3893 % default indentation of @itemize and @enumerate text
3894 \newdimen\itemindent \itemindent=.3in
3895 % margin between end of table item and start of table text.
3896 \newdimen\itemmargin \itemmargin=.1in
3897
3898 % used internally for \itemindent minus \itemmargin
3899 \newdimen\itemmax
3900
3901 % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
3902 % these defs.
3903 % They also define \itemindex
3904 % to index the item name in whatever manner is desired (perhaps none).
3905
3906 \newif\ifitemxneedsnegativevskip
3907
3908 \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
3909
3910 \def\internalBitem{\smallbreak \parsearg\itemzzz}
3911 \def\internalBitemx{\itemxpar \parsearg\itemzzz}
3912
3913 \def\itemzzz #1{\begingroup %
3914 \advance\hsize by -\rightskip
3915 \advance\hsize by -\tableindent
3916 \setbox0=\hbox{\itemindicate{#1}}%
3917 \itemindex{#1}%
3918 \nobreak % This prevents a break before @itemx.
3919 %
3920 % If the item text does not fit in the space we have, put it on a line
3921 % by itself, and do not allow a page break either before or after that
3922 % line. We do not start a paragraph here because then if the next
3923 % command is, e.g., @kindex, the whatsit would get put into the
3924 % horizontal list on a line by itself, resulting in extra blank space.
3925 \ifdim \wd0>\itemmax
3926 %
3927 % Make this a paragraph so we get the \parskip glue and wrapping,
3928 % but leave it ragged-right.
3929 \begingroup
3930 \advance\leftskip by-\tableindent
3931 \advance\hsize by\tableindent
3932 \advance\rightskip by0pt plus1fil\relax
3933 \leavevmode\unhbox0\par
3934 \endgroup
3935 %
3936 % We're going to be starting a paragraph, but we don't want the
3937 % \parskip glue -- logically it's part of the @item we just started.
3938 \nobreak \vskip-\parskip
3939 %
3940 % Stop a page break at the \parskip glue coming up. However, if
3941 % what follows is an environment such as @example, there will be no
3942 % \parskip glue; then the negative vskip we just inserted would
3943 % cause the example and the item to crash together. So we use this
3944 % bizarre value of 10001 as a signal to \aboveenvbreak to insert
3945 % \parskip glue after all. Section titles are handled this way also.
3946 %
3947 \penalty 10001
3948 \endgroup
3949 \itemxneedsnegativevskipfalse
3950 \else
3951 % The item text fits into the space. Start a paragraph, so that the
3952 % following text (if any) will end up on the same line.
3953 \noindent
3954 % Do this with kerns and \unhbox so that if there is a footnote in
3955 % the item text, it can migrate to the main vertical list and
3956 % eventually be printed.
3957 \nobreak\kern-\tableindent
3958 \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
3959 \unhbox0
3960 \nobreak\kern\dimen0
3961 \endgroup
3962 \itemxneedsnegativevskiptrue
3963 \fi
3964 }
3965
3966 \def\item{\errmessage{@item while not in a list environment}}
3967 \def\itemx{\errmessage{@itemx while not in a list environment}}
3968
3969 % @table, @ftable, @vtable.
3970 \envdef\table{%
3971 \let\itemindex\gobble
3972 \tablecheck{table}%
3973 }
3974 \envdef\ftable{%
3975 \def\itemindex ##1{\doind {fn}{\code{##1}}}%
3976 \tablecheck{ftable}%
3977 }
3978 \envdef\vtable{%
3979 \def\itemindex ##1{\doind {vr}{\code{##1}}}%
3980 \tablecheck{vtable}%
3981 }
3982 \def\tablecheck#1{%
3983 \ifnum \the\catcode`\^^M=\active
3984 \endgroup
3985 \errmessage{This command won't work in this context; perhaps the problem is
3986 that we are \inenvironment\thisenv}%
3987 \def\next{\doignore{#1}}%
3988 \else
3989 \let\next\tablex
3990 \fi
3991 \next
3992 }
3993 \def\tablex#1{%
3994 \def\itemindicate{#1}%
3995 \parsearg\tabley
3996 }
3997 \def\tabley#1{%
3998 {%
3999 \makevalueexpandable
4000 \edef\temp{\noexpand\tablez #1\space\space\space}%
4001 \expandafter
4002 }\temp \endtablez
4003 }
4004 \def\tablez #1 #2 #3 #4\endtablez{%
4005 \aboveenvbreak
4006 \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
4007 \ifnum 0#2>0 \tableindent=#2\mil \fi
4008 \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
4009 \itemmax=\tableindent
4010 \advance \itemmax by -\itemmargin
4011 \advance \leftskip by \tableindent
4012 \exdentamount=\tableindent
4013 \parindent = 0pt
4014 \parskip = \smallskipamount
4015 \ifdim \parskip=0pt \parskip=2pt \fi
4016 \let\item = \internalBitem
4017 \let\itemx = \internalBitemx
4018 }
4019 \def\Etable{\endgraf\afterenvbreak}
4020 \let\Eftable\Etable
4021 \let\Evtable\Etable
4022 \let\Eitemize\Etable
4023 \let\Eenumerate\Etable
4024
4025 % This is the counter used by @enumerate, which is really @itemize
4026
4027 \newcount \itemno
4028
4029 \envdef\itemize{\parsearg\doitemize}
4030
4031 \def\doitemize#1{%
4032 \aboveenvbreak
4033 \itemmax=\itemindent
4034 \advance\itemmax by -\itemmargin
4035 \advance\leftskip by \itemindent
4036 \exdentamount=\itemindent
4037 \parindent=0pt
4038 \parskip=\smallskipamount
4039 \ifdim\parskip=0pt \parskip=2pt \fi
4040 %
4041 % Try typesetting the item mark so that if the document erroneously says
4042 % something like @itemize @samp (intending @table), there's an error
4043 % right away at the @itemize. It's not the best error message in the
4044 % world, but it's better than leaving it to the @item. This means if
4045 % the user wants an empty mark, they have to say @w{} not just @w.
4046 \def\itemcontents{#1}%
4047 \setbox0 = \hbox{\itemcontents}%
4048 %
4049 % @itemize with no arg is equivalent to @itemize @bullet.
4050 \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
4051 %
4052 \let\item=\itemizeitem
4053 }
4054
4055 % Definition of @item while inside @itemize and @enumerate.
4056 %
4057 \def\itemizeitem{%
4058 \advance\itemno by 1 % for enumerations
4059 {\let\par=\endgraf \smallbreak}% reasonable place to break
4060 {%
4061 % If the document has an @itemize directly after a section title, a
4062 % \nobreak will be last on the list, and \sectionheading will have
4063 % done a \vskip-\parskip. In that case, we don't want to zero
4064 % parskip, or the item text will crash with the heading. On the
4065 % other hand, when there is normal text preceding the item (as there
4066 % usually is), we do want to zero parskip, or there would be too much
4067 % space. In that case, we won't have a \nobreak before. At least
4068 % that's the theory.
4069 \ifnum\lastpenalty<10000 \parskip=0in \fi
4070 \noindent
4071 \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
4072 %
4073 \ifinner\else
4074 \vadjust{\penalty 1200}% not good to break after first line of item.
4075 \fi
4076 % We can be in inner vertical mode in a footnote, although an
4077 % @itemize looks awful there.
4078 }%
4079 \flushcr
4080 }
4081
4082 % \splitoff TOKENS\endmark defines \first to be the first token in
4083 % TOKENS, and \rest to be the remainder.
4084 %
4085 \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
4086
4087 % Allow an optional argument of an uppercase letter, lowercase letter,
4088 % or number, to specify the first label in the enumerated list. No
4089 % argument is the same as `1'.
4090 %
4091 \envparseargdef\enumerate{\enumeratey #1 \endenumeratey}
4092 \def\enumeratey #1 #2\endenumeratey{%
4093 % If we were given no argument, pretend we were given `1'.
4094 \def\thearg{#1}%
4095 \ifx\thearg\empty \def\thearg{1}\fi
4096 %
4097 % Detect if the argument is a single token. If so, it might be a
4098 % letter. Otherwise, the only valid thing it can be is a number.
4099 % (We will always have one token, because of the test we just made.
4100 % This is a good thing, since \splitoff doesn't work given nothing at
4101 % all -- the first parameter is undelimited.)
4102 \expandafter\splitoff\thearg\endmark
4103 \ifx\rest\empty
4104 % Only one token in the argument. It could still be anything.
4105 % A ``lowercase letter'' is one whose \lccode is nonzero.
4106 % An ``uppercase letter'' is one whose \lccode is both nonzero, and
4107 % not equal to itself.
4108 % Otherwise, we assume it's a number.
4109 %
4110 % We need the \relax at the end of the \ifnum lines to stop TeX from
4111 % continuing to look for a <number>.
4112 %
4113 \ifnum\lccode\expandafter`\thearg=0\relax
4114 \numericenumerate % a number (we hope)
4115 \else
4116 % It's a letter.
4117 \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
4118 \lowercaseenumerate % lowercase letter
4119 \else
4120 \uppercaseenumerate % uppercase letter
4121 \fi
4122 \fi
4123 \else
4124 % Multiple tokens in the argument. We hope it's a number.
4125 \numericenumerate
4126 \fi
4127 }
4128
4129 % An @enumerate whose labels are integers. The starting integer is
4130 % given in \thearg.
4131 %
4132 \def\numericenumerate{%
4133 \itemno = \thearg
4134 \startenumeration{\the\itemno}%
4135 }
4136
4137 % The starting (lowercase) letter is in \thearg.
4138 \def\lowercaseenumerate{%
4139 \itemno = \expandafter`\thearg
4140 \startenumeration{%
4141 % Be sure we're not beyond the end of the alphabet.
4142 \ifnum\itemno=0
4143 \errmessage{No more lowercase letters in @enumerate; get a bigger
4144 alphabet}%
4145 \fi
4146 \char\lccode\itemno
4147 }%
4148 }
4149
4150 % The starting (uppercase) letter is in \thearg.
4151 \def\uppercaseenumerate{%
4152 \itemno = \expandafter`\thearg
4153 \startenumeration{%
4154 % Be sure we're not beyond the end of the alphabet.
4155 \ifnum\itemno=0
4156 \errmessage{No more uppercase letters in @enumerate; get a bigger
4157 alphabet}
4158 \fi
4159 \char\uccode\itemno
4160 }%
4161 }
4162
4163 % Call \doitemize, adding a period to the first argument and supplying the
4164 % common last two arguments. Also subtract one from the initial value in
4165 % \itemno, since @item increments \itemno.
4166 %
4167 \def\startenumeration#1{%
4168 \advance\itemno by -1
4169 \doitemize{#1.}\flushcr
4170 }
4171
4172 % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
4173 % to @enumerate.
4174 %
4175 \def\alphaenumerate{\enumerate{a}}
4176 \def\capsenumerate{\enumerate{A}}
4177 \def\Ealphaenumerate{\Eenumerate}
4178 \def\Ecapsenumerate{\Eenumerate}
4179
4180
4181 % @multitable macros
4182 % Amy Hendrickson, 8/18/94, 3/6/96
4183 %
4184 % @multitable ... @end multitable will make as many columns as desired.
4185 % Contents of each column will wrap at width given in preamble. Width
4186 % can be specified either with sample text given in a template line,
4187 % or in percent of \hsize, the current width of text on page.
4188
4189 % Table can continue over pages but will only break between lines.
4190
4191 % To make preamble:
4192 %
4193 % Either define widths of columns in terms of percent of \hsize:
4194 % @multitable @columnfractions .25 .3 .45
4195 % @item ...
4196 %
4197 % Numbers following @columnfractions are the percent of the total
4198 % current hsize to be used for each column. You may use as many
4199 % columns as desired.
4200
4201
4202 % Or use a template:
4203 % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4204 % @item ...
4205 % using the widest term desired in each column.
4206
4207 % Each new table line starts with @item, each subsequent new column
4208 % starts with @tab. Empty columns may be produced by supplying @tab's
4209 % with nothing between them for as many times as empty columns are needed,
4210 % ie, @tab@tab@tab will produce two empty columns.
4211
4212 % @item, @tab do not need to be on their own lines, but it will not hurt
4213 % if they are.
4214
4215 % Sample multitable:
4216
4217 % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4218 % @item first col stuff @tab second col stuff @tab third col
4219 % @item
4220 % first col stuff
4221 % @tab
4222 % second col stuff
4223 % @tab
4224 % third col
4225 % @item first col stuff @tab second col stuff
4226 % @tab Many paragraphs of text may be used in any column.
4227 %
4228 % They will wrap at the width determined by the template.
4229 % @item@tab@tab This will be in third column.
4230 % @end multitable
4231
4232 % Default dimensions may be reset by user.
4233 % @multitableparskip is vertical space between paragraphs in table.
4234 % @multitableparindent is paragraph indent in table.
4235 % @multitablecolmargin is horizontal space to be left between columns.
4236 % @multitablelinespace is space to leave between table items, baseline
4237 % to baseline.
4238 % 0pt means it depends on current normal line spacing.
4239 %
4240 \newskip\multitableparskip
4241 \newskip\multitableparindent
4242 \newdimen\multitablecolspace
4243 \newskip\multitablelinespace
4244 \multitableparskip=0pt
4245 \multitableparindent=6pt
4246 \multitablecolspace=12pt
4247 \multitablelinespace=0pt
4248
4249 % Macros used to set up halign preamble:
4250 %
4251 \let\endsetuptable\relax
4252 \def\xendsetuptable{\endsetuptable}
4253 \let\columnfractions\relax
4254 \def\xcolumnfractions{\columnfractions}
4255 \newif\ifsetpercent
4256
4257 % #1 is the @columnfraction, usually a decimal number like .5, but might
4258 % be just 1. We just use it, whatever it is.
4259 %
4260 \def\pickupwholefraction#1 {%
4261 \global\advance\colcount by 1
4262 \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
4263 \setuptable
4264 }
4265
4266 \newcount\colcount
4267 \def\setuptable#1{%
4268 \def\firstarg{#1}%
4269 \ifx\firstarg\xendsetuptable
4270 \let\go = \relax
4271 \else
4272 \ifx\firstarg\xcolumnfractions
4273 \global\setpercenttrue
4274 \else
4275 \ifsetpercent
4276 \let\go\pickupwholefraction
4277 \else
4278 \global\advance\colcount by 1
4279 \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
4280 % separator; typically that is always in the input, anyway.
4281 \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
4282 \fi
4283 \fi
4284 \ifx\go\pickupwholefraction
4285 % Put the argument back for the \pickupwholefraction call, so
4286 % we'll always have a period there to be parsed.
4287 \def\go{\pickupwholefraction#1}%
4288 \else
4289 \let\go = \setuptable
4290 \fi%
4291 \fi
4292 \go
4293 }
4294
4295 % multitable-only commands.
4296 %
4297 % @headitem starts a heading row, which we typeset in bold. Assignments
4298 % have to be global since we are inside the implicit group of an
4299 % alignment entry. \everycr below resets \everytab so we don't have to
4300 % undo it ourselves.
4301 \def\headitemfont{\b}% for people to use in the template row; not changeable
4302 \def\headitem{%
4303 \checkenv\multitable
4304 \crcr
4305 \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
4306 \global\everytab={\bf}% can't use \headitemfont since the parsing differs
4307 \the\everytab % for the first item
4308 }%
4309 %
4310 % default for tables with no headings.
4311 \let\headitemcrhook=\relax
4312 %
4313 % A \tab used to include \hskip1sp. But then the space in a template
4314 % line is not enough. That is bad. So let's go back to just `&' until
4315 % we again encounter the problem the 1sp was intended to solve.
4316 % --karl, nathan@acm.org, 20apr99.
4317 \def\tab{\checkenv\multitable &\the\everytab}%
4318
4319 % @multitable ... @end multitable definitions:
4320 %
4321 \newtoks\everytab % insert after every tab.
4322 %
4323 \envdef\multitable{%
4324 \vskip\parskip
4325 \startsavinginserts
4326 %
4327 % @item within a multitable starts a normal row.
4328 % We use \def instead of \let so that if one of the multitable entries
4329 % contains an @itemize, we don't choke on the \item (seen as \crcr aka
4330 % \endtemplate) expanding \doitemize.
4331 \def\item{\crcr}%
4332 %
4333 \tolerance=9500
4334 \hbadness=9500
4335 \setmultitablespacing
4336 \parskip=\multitableparskip
4337 \parindent=\multitableparindent
4338 \overfullrule=0pt
4339 \global\colcount=0
4340 %
4341 \everycr = {%
4342 \noalign{%
4343 \global\everytab={}% Reset from possible headitem.
4344 \global\colcount=0 % Reset the column counter.
4345 %
4346 % Check for saved footnotes, etc.:
4347 \checkinserts
4348 %
4349 % Perhaps a \nobreak, then reset:
4350 \headitemcrhook
4351 \global\let\headitemcrhook=\relax
4352 }%
4353 }%
4354 %
4355 \parsearg\domultitable
4356 }
4357 \def\domultitable#1{%
4358 % To parse everything between @multitable and @item:
4359 \setuptable#1 \endsetuptable
4360 %
4361 % This preamble sets up a generic column definition, which will
4362 % be used as many times as user calls for columns.
4363 % \vtop will set a single line and will also let text wrap and
4364 % continue for many paragraphs if desired.
4365 \halign\bgroup &%
4366 \global\advance\colcount by 1
4367 \multistrut
4368 \vtop{%
4369 % Use the current \colcount to find the correct column width:
4370 \hsize=\expandafter\csname col\the\colcount\endcsname
4371 %
4372 % In order to keep entries from bumping into each other
4373 % we will add a \leftskip of \multitablecolspace to all columns after
4374 % the first one.
4375 %
4376 % If a template has been used, we will add \multitablecolspace
4377 % to the width of each template entry.
4378 %
4379 % If the user has set preamble in terms of percent of \hsize we will
4380 % use that dimension as the width of the column, and the \leftskip
4381 % will keep entries from bumping into each other. Table will start at
4382 % left margin and final column will justify at right margin.
4383 %
4384 % Make sure we don't inherit \rightskip from the outer environment.
4385 \rightskip=0pt
4386 \ifnum\colcount=1
4387 % The first column will be indented with the surrounding text.
4388 \advance\hsize by\leftskip
4389 \else
4390 \ifsetpercent \else
4391 % If user has not set preamble in terms of percent of \hsize
4392 % we will advance \hsize by \multitablecolspace.
4393 \advance\hsize by \multitablecolspace
4394 \fi
4395 % In either case we will make \leftskip=\multitablecolspace:
4396 \leftskip=\multitablecolspace
4397 \fi
4398 % Ignoring space at the beginning and end avoids an occasional spurious
4399 % blank line, when TeX decides to break the line at the space before the
4400 % box from the multistrut, so the strut ends up on a line by itself.
4401 % For example:
4402 % @multitable @columnfractions .11 .89
4403 % @item @code{#}
4404 % @tab Legal holiday which is valid in major parts of the whole country.
4405 % Is automatically provided with highlighting sequences respectively
4406 % marking characters.
4407 \noindent\ignorespaces##\unskip\multistrut
4408 }\cr
4409 }
4410 \def\Emultitable{%
4411 \crcr
4412 \egroup % end the \halign
4413 \global\setpercentfalse
4414 }
4415
4416 \def\setmultitablespacing{%
4417 \def\multistrut{\strut}% just use the standard line spacing
4418 %
4419 % Compute \multitablelinespace (if not defined by user) for use in
4420 % \multitableparskip calculation. We used define \multistrut based on
4421 % this, but (ironically) that caused the spacing to be off.
4422 % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
4423 \ifdim\multitablelinespace=0pt
4424 \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
4425 \global\advance\multitablelinespace by-\ht0
4426 \fi
4427 % Test to see if parskip is larger than space between lines of
4428 % table. If not, do nothing.
4429 % If so, set to same dimension as multitablelinespace.
4430 \ifdim\multitableparskip>\multitablelinespace
4431 \global\multitableparskip=\multitablelinespace
4432 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4433 % than skip between lines in the table.
4434 \fi%
4435 \ifdim\multitableparskip=0pt
4436 \global\multitableparskip=\multitablelinespace
4437 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4438 % than skip between lines in the table.
4439 \fi}
4440
4441
4442 \message{conditionals,}
4443
4444 % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
4445 % @ifnotxml always succeed. They currently do nothing; we don't
4446 % attempt to check whether the conditionals are properly nested. But we
4447 % have to remember that they are conditionals, so that @end doesn't
4448 % attempt to close an environment group.
4449 %
4450 \def\makecond#1{%
4451 \expandafter\let\csname #1\endcsname = \relax
4452 \expandafter\let\csname iscond.#1\endcsname = 1
4453 }
4454 \makecond{iftex}
4455 \makecond{ifnotdocbook}
4456 \makecond{ifnothtml}
4457 \makecond{ifnotinfo}
4458 \makecond{ifnotplaintext}
4459 \makecond{ifnotxml}
4460
4461 % Ignore @ignore, @ifhtml, @ifinfo, and the like.
4462 %
4463 \def\direntry{\doignore{direntry}}
4464 \def\documentdescription{\doignore{documentdescription}}
4465 \def\docbook{\doignore{docbook}}
4466 \def\html{\doignore{html}}
4467 \def\ifdocbook{\doignore{ifdocbook}}
4468 \def\ifhtml{\doignore{ifhtml}}
4469 \def\ifinfo{\doignore{ifinfo}}
4470 \def\ifnottex{\doignore{ifnottex}}
4471 \def\ifplaintext{\doignore{ifplaintext}}
4472 \def\ifxml{\doignore{ifxml}}
4473 \def\ignore{\doignore{ignore}}
4474 \def\menu{\doignore{menu}}
4475 \def\xml{\doignore{xml}}
4476
4477 % Ignore text until a line `@end #1', keeping track of nested conditionals.
4478 %
4479 % A count to remember the depth of nesting.
4480 \newcount\doignorecount
4481
4482 \def\doignore#1{\begingroup
4483 % Scan in ``verbatim'' mode:
4484 \obeylines
4485 \catcode`\@ = \other
4486 \catcode`\{ = \other
4487 \catcode`\} = \other
4488 %
4489 % Make sure that spaces turn into tokens that match what \doignoretext wants.
4490 \spaceisspace
4491 %
4492 % Count number of #1's that we've seen.
4493 \doignorecount = 0
4494 %
4495 % Swallow text until we reach the matching `@end #1'.
4496 \dodoignore{#1}%
4497 }
4498
4499 { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4500 \obeylines %
4501 %
4502 \gdef\dodoignore#1{%
4503 % #1 contains the command name as a string, e.g., `ifinfo'.
4504 %
4505 % Define a command to find the next `@end #1'.
4506 \long\def\doignoretext##1^^M@end #1{%
4507 \doignoretextyyy##1^^M@#1\_STOP_}%
4508 %
4509 % And this command to find another #1 command, at the beginning of a
4510 % line. (Otherwise, we would consider a line `@c @ifset', for
4511 % example, to count as an @ifset for nesting.)
4512 \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
4513 %
4514 % And now expand that command.
4515 \doignoretext ^^M%
4516 }%
4517 }
4518
4519 \def\doignoreyyy#1{%
4520 \def\temp{#1}%
4521 \ifx\temp\empty % Nothing found.
4522 \let\next\doignoretextzzz
4523 \else % Found a nested condition, ...
4524 \advance\doignorecount by 1
4525 \let\next\doignoretextyyy % ..., look for another.
4526 % If we're here, #1 ends with ^^M\ifinfo (for example).
4527 \fi
4528 \next #1% the token \_STOP_ is present just after this macro.
4529 }
4530
4531 % We have to swallow the remaining "\_STOP_".
4532 %
4533 \def\doignoretextzzz#1{%
4534 \ifnum\doignorecount = 0 % We have just found the outermost @end.
4535 \let\next\enddoignore
4536 \else % Still inside a nested condition.
4537 \advance\doignorecount by -1
4538 \let\next\doignoretext % Look for the next @end.
4539 \fi
4540 \next
4541 }
4542
4543 % Finish off ignored text.
4544 { \obeylines%
4545 % Ignore anything after the last `@end #1'; this matters in verbatim
4546 % environments, where otherwise the newline after an ignored conditional
4547 % would result in a blank line in the output.
4548 \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4549 }
4550
4551
4552 % @set VAR sets the variable VAR to an empty value.
4553 % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4554 %
4555 % Since we want to separate VAR from REST-OF-LINE (which might be
4556 % empty), we can't just use \parsearg; we have to insert a space of our
4557 % own to delimit the rest of the line, and then take it out again if we
4558 % didn't need it.
4559 % We rely on the fact that \parsearg sets \catcode`\ =10.
4560 %
4561 \parseargdef\set{\setyyy#1 \endsetyyy}
4562 \def\setyyy#1 #2\endsetyyy{%
4563 {%
4564 \makevalueexpandable
4565 \def\temp{#2}%
4566 \edef\next{\gdef\makecsname{SET#1}}%
4567 \ifx\temp\empty
4568 \next{}%
4569 \else
4570 \setzzz#2\endsetzzz
4571 \fi
4572 }%
4573 }
4574 % Remove the trailing space \setxxx inserted.
4575 \def\setzzz#1 \endsetzzz{\next{#1}}
4576
4577 % @clear VAR clears (i.e., unsets) the variable VAR.
4578 %
4579 \parseargdef\clear{%
4580 {%
4581 \makevalueexpandable
4582 \global\expandafter\let\csname SET#1\endcsname=\relax
4583 }%
4584 }
4585
4586 % @value{foo} gets the text saved in variable foo.
4587 \def\value{\begingroup\makevalueexpandable\valuexxx}
4588 \def\valuexxx#1{\expandablevalue{#1}\endgroup}
4589 {
4590 \catcode`\-=\active \catcode`\_=\active
4591 %
4592 \gdef\makevalueexpandable{%
4593 \let\value = \expandablevalue
4594 % We don't want these characters active, ...
4595 \catcode`\-=\other \catcode`\_=\other
4596 % ..., but we might end up with active ones in the argument if
4597 % we're called from @code, as @code{@value{foo-bar_}}, though.
4598 % So \let them to their normal equivalents.
4599 \let-\normaldash \let_\normalunderscore
4600 }
4601 }
4602
4603 % We have this subroutine so that we can handle at least some @value's
4604 % properly in indexes (we call \makevalueexpandable in \indexdummies).
4605 % The command has to be fully expandable (if the variable is set), since
4606 % the result winds up in the index file. This means that if the
4607 % variable's value contains other Texinfo commands, it's almost certain
4608 % it will fail (although perhaps we could fix that with sufficient work
4609 % to do a one-level expansion on the result, instead of complete).
4610 %
4611 % Unfortunately, this has the consequence that when _ is in the *value*
4612 % of an @set, it does not print properly in the roman fonts (get the cmr
4613 % dot accent at position 126 instead). No fix comes to mind, and it's
4614 % been this way since 2003 or earlier, so just ignore it.
4615 %
4616 \def\expandablevalue#1{%
4617 \expandafter\ifx\csname SET#1\endcsname\relax
4618 {[No value for ``#1'']}%
4619 \message{Variable `#1', used in @value, is not set.}%
4620 \else
4621 \csname SET#1\endcsname
4622 \fi
4623 }
4624
4625 % Like \expandablevalue, but completely expandable (the \message in the
4626 % definition above operates at the execution level of TeX). Used when
4627 % writing to auxiliary files, due to the expansion that \write does.
4628 % If flag is undefined, pass through an unexpanded @value command: maybe it
4629 % will be set by the time it is read back in.
4630 %
4631 % NB flag names containing - or _ may not work here.
4632 \def\dummyvalue#1{%
4633 \expandafter\ifx\csname SET#1\endcsname\relax
4634 \noexpand\value{#1}%
4635 \else
4636 \csname SET#1\endcsname
4637 \fi
4638 }
4639
4640 % Used for @value's in index entries to form the sort key: expand the @value
4641 % if possible, otherwise sort late.
4642 \def\indexnofontsvalue#1{%
4643 \expandafter\ifx\csname SET#1\endcsname\relax
4644 ZZZZZZZ
4645 \else
4646 \csname SET#1\endcsname
4647 \fi
4648 }
4649
4650 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4651 % with @set.
4652 %
4653 % To get the special treatment we need for `@end ifset,' we call
4654 % \makecond and then redefine.
4655 %
4656 \makecond{ifset}
4657 \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4658 \def\doifset#1#2{%
4659 {%
4660 \makevalueexpandable
4661 \let\next=\empty
4662 \expandafter\ifx\csname SET#2\endcsname\relax
4663 #1% If not set, redefine \next.
4664 \fi
4665 \expandafter
4666 }\next
4667 }
4668 \def\ifsetfail{\doignore{ifset}}
4669
4670 % @ifclear VAR ... @end executes the `...' iff VAR has never been
4671 % defined with @set, or has been undefined with @clear.
4672 %
4673 % The `\else' inside the `\doifset' parameter is a trick to reuse the
4674 % above code: if the variable is not set, do nothing, if it is set,
4675 % then redefine \next to \ifclearfail.
4676 %
4677 \makecond{ifclear}
4678 \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4679 \def\ifclearfail{\doignore{ifclear}}
4680
4681 % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
4682 % without the @) is in fact defined. We can only feasibly check at the
4683 % TeX level, so something like `mathcode' is going to considered
4684 % defined even though it is not a Texinfo command.
4685 %
4686 \makecond{ifcommanddefined}
4687 \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
4688 %
4689 \def\doifcmddefined#1#2{{%
4690 \makevalueexpandable
4691 \let\next=\empty
4692 \expandafter\ifx\csname #2\endcsname\relax
4693 #1% If not defined, \let\next as above.
4694 \fi
4695 \expandafter
4696 }\next
4697 }
4698 \def\ifcmddefinedfail{\doignore{ifcommanddefined}}
4699
4700 % @ifcommandnotdefined CMD ... handled similar to @ifclear above.
4701 \makecond{ifcommandnotdefined}
4702 \def\ifcommandnotdefined{%
4703 \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
4704 \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
4705
4706 % Set the `txicommandconditionals' variable, so documents have a way to
4707 % test if the @ifcommand...defined conditionals are available.
4708 \set txicommandconditionals
4709
4710 % @dircategory CATEGORY -- specify a category of the dir file
4711 % which this file should belong to. Ignore this in TeX.
4712 \let\dircategory=\comment
4713
4714 % @defininfoenclose.
4715 \let\definfoenclose=\comment
4716
4717
4718 \message{indexing,}
4719 % Index generation facilities
4720
4721 % Define \newwrite to be identical to plain tex's \newwrite
4722 % except not \outer, so it can be used within macros and \if's.
4723 \edef\newwrite{\makecsname{ptexnewwrite}}
4724
4725 % \newindex {foo} defines an index named IX.
4726 % It automatically defines \IXindex such that
4727 % \IXindex ...rest of line... puts an entry in the index IX.
4728 % It also defines \IXindfile to be the number of the output channel for
4729 % the file that accumulates this index. The file's extension is IX.
4730 % The name of an index should be no more than 2 characters long
4731 % for the sake of vms.
4732 %
4733 \def\newindex#1{%
4734 \expandafter\chardef\csname#1indfile\endcsname=0
4735 \expandafter\xdef\csname#1index\endcsname{% % Define @#1index
4736 \noexpand\doindex{#1}}
4737 }
4738
4739 % @defindex foo == \newindex{foo}
4740 %
4741 \def\defindex{\parsearg\newindex}
4742
4743 % Define @defcodeindex, like @defindex except put all entries in @code.
4744 %
4745 \def\defcodeindex{\parsearg\newcodeindex}
4746 %
4747 \def\newcodeindex#1{%
4748 \expandafter\chardef\csname#1indfile\endcsname=0
4749 \expandafter\xdef\csname#1index\endcsname{%
4750 \noexpand\docodeindex{#1}}%
4751 }
4752
4753 % The default indices:
4754 \newindex{cp}% concepts,
4755 \newcodeindex{fn}% functions,
4756 \newcodeindex{vr}% variables,
4757 \newcodeindex{tp}% types,
4758 \newcodeindex{ky}% keys
4759 \newcodeindex{pg}% and programs.
4760
4761
4762 % @synindex foo bar makes index foo feed into index bar.
4763 % Do this instead of @defindex foo if you don't want it as a separate index.
4764 %
4765 % @syncodeindex foo bar similar, but put all entries made for index foo
4766 % inside @code.
4767 %
4768 \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4769 \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4770
4771 % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4772 % #3 the target index (bar).
4773 \def\dosynindex#1#2#3{%
4774 % Only do \closeout if we haven't already done it, else we'll end up
4775 % closing the target index.
4776 \expandafter \ifx\csname donesynindex#2\endcsname \relax
4777 % The \closeout helps reduce unnecessary open files; the limit on the
4778 % Acorn RISC OS is a mere 16 files.
4779 \expandafter\closeout\csname#2indfile\endcsname
4780 \expandafter\let\csname donesynindex#2\endcsname = 1
4781 \fi
4782 % redefine \fooindfile:
4783 \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4784 \expandafter\let\csname#2indfile\endcsname=\temp
4785 % redefine \fooindex:
4786 \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
4787 }
4788
4789 % Define \doindex, the driver for all index macros.
4790 % Argument #1 is generated by the calling \fooindex macro,
4791 % and it is the two-letter name of the index.
4792
4793 \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
4794 \def\doindexxxx #1{\doind{\indexname}{#1}}
4795
4796 % like the previous two, but they put @code around the argument.
4797 \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
4798 \def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
4799
4800 \f
4801 % Used when writing an index entry out to an index file to prevent
4802 % expansion of Texinfo commands that can appear in an index entry.
4803 %
4804 \def\indexdummies{%
4805 \escapechar = `\\ % use backslash in output files.
4806 \def\@{@}% change to @@ when we switch to @ as escape char in index files.
4807 \def\ {\realbackslash\space }%
4808 %
4809 % Need these unexpandable (because we define \tt as a dummy)
4810 % definitions when @{ or @} appear in index entry text. Also, more
4811 % complicated, when \tex is in effect and \{ is a \delimiter again.
4812 % We can't use \lbracecmd and \rbracecmd because texindex assumes
4813 % braces and backslashes are used only as delimiters. Perhaps we
4814 % should use @lbracechar and @rbracechar?
4815 \def\{{{\tt\char123}}%
4816 \def\}{{\tt\char125}}%
4817 %
4818 % Do the redefinitions.
4819 \definedummies
4820 }
4821
4822 % Used for the aux and toc files, where @ is the escape character.
4823 %
4824 % For the aux and toc files, @ is the escape character. So we want to
4825 % redefine everything using @ as the escape character (instead of
4826 % \realbackslash, still used for index files). When everything uses @,
4827 % this will be simpler.
4828 %
4829 \def\atdummies{%
4830 \def\@{@@}%
4831 \def\ {@ }%
4832 \let\{ = \lbraceatcmd
4833 \let\} = \rbraceatcmd
4834 %
4835 % Do the redefinitions.
4836 \definedummies
4837 \otherbackslash
4838 }
4839
4840 % \definedummyword defines \#1 as \string\#1\space, thus effectively
4841 % preventing its expansion. This is used only for control words,
4842 % not control letters, because the \space would be incorrect for
4843 % control characters, but is needed to separate the control word
4844 % from whatever follows.
4845 %
4846 % These can be used both for control words that take an argument and
4847 % those that do not. If it is followed by {arg} in the input, then
4848 % that will dutifully get written to the index (or wherever).
4849 %
4850 % For control letters, we have \definedummyletter, which omits the
4851 % space.
4852 %
4853 \def\definedummyword #1{\def#1{\string#1\space}}%
4854 \def\definedummyletter#1{\def#1{\string#1}}%
4855 \let\definedummyaccent\definedummyletter
4856
4857 % Called from \indexdummies and \atdummies, to effectively prevent
4858 % the expansion of commands.
4859 %
4860 \def\definedummies{%
4861 %
4862 \let\commondummyword\definedummyword
4863 \let\commondummyletter\definedummyletter
4864 \let\commondummyaccent\definedummyaccent
4865 \commondummiesnofonts
4866 %
4867 \definedummyletter\_%
4868 \definedummyletter\-%
4869 %
4870 % Non-English letters.
4871 \definedummyword\AA
4872 \definedummyword\AE
4873 \definedummyword\DH
4874 \definedummyword\L
4875 \definedummyword\O
4876 \definedummyword\OE
4877 \definedummyword\TH
4878 \definedummyword\aa
4879 \definedummyword\ae
4880 \definedummyword\dh
4881 \definedummyword\exclamdown
4882 \definedummyword\l
4883 \definedummyword\o
4884 \definedummyword\oe
4885 \definedummyword\ordf
4886 \definedummyword\ordm
4887 \definedummyword\questiondown
4888 \definedummyword\ss
4889 \definedummyword\th
4890 %
4891 % Although these internal commands shouldn't show up, sometimes they do.
4892 \definedummyword\bf
4893 \definedummyword\gtr
4894 \definedummyword\hat
4895 \definedummyword\less
4896 \definedummyword\sf
4897 \definedummyword\sl
4898 \definedummyword\tclose
4899 \definedummyword\tt
4900 %
4901 \definedummyword\LaTeX
4902 \definedummyword\TeX
4903 %
4904 % Assorted special characters.
4905 \definedummyword\arrow
4906 \definedummyword\bullet
4907 \definedummyword\comma
4908 \definedummyword\copyright
4909 \definedummyword\registeredsymbol
4910 \definedummyword\dots
4911 \definedummyword\enddots
4912 \definedummyword\entrybreak
4913 \definedummyword\equiv
4914 \definedummyword\error
4915 \definedummyword\euro
4916 \definedummyword\expansion
4917 \definedummyword\geq
4918 \definedummyword\guillemetleft
4919 \definedummyword\guillemetright
4920 \definedummyword\guilsinglleft
4921 \definedummyword\guilsinglright
4922 \definedummyword\lbracechar
4923 \definedummyword\leq
4924 \definedummyword\mathopsup
4925 \definedummyword\minus
4926 \definedummyword\ogonek
4927 \definedummyword\pounds
4928 \definedummyword\point
4929 \definedummyword\print
4930 \definedummyword\quotedblbase
4931 \definedummyword\quotedblleft
4932 \definedummyword\quotedblright
4933 \definedummyword\quoteleft
4934 \definedummyword\quoteright
4935 \definedummyword\quotesinglbase
4936 \definedummyword\rbracechar
4937 \definedummyword\result
4938 \definedummyword\sub
4939 \definedummyword\sup
4940 \definedummyword\textdegree
4941 %
4942 % We want to disable all macros so that they are not expanded by \write.
4943 \macrolist
4944 \let\value\dummyvalue
4945 %
4946 \normalturnoffactive
4947 }
4948
4949 % \commondummiesnofonts: common to \definedummies and \indexnofonts.
4950 % Define \commondummyletter, \commondummyaccent and \commondummyword before
4951 % using. Used for accents, font commands, and various control letters.
4952 %
4953 \def\commondummiesnofonts{%
4954 % Control letters and accents.
4955 \commondummyletter\!%
4956 \commondummyaccent\"%
4957 \commondummyaccent\'%
4958 \commondummyletter\*%
4959 \commondummyaccent\,%
4960 \commondummyletter\.%
4961 \commondummyletter\/%
4962 \commondummyletter\:%
4963 \commondummyaccent\=%
4964 \commondummyletter\?%
4965 \commondummyaccent\^%
4966 \commondummyaccent\`%
4967 \commondummyaccent\~%
4968 \commondummyword\u
4969 \commondummyword\v
4970 \commondummyword\H
4971 \commondummyword\dotaccent
4972 \commondummyword\ogonek
4973 \commondummyword\ringaccent
4974 \commondummyword\tieaccent
4975 \commondummyword\ubaraccent
4976 \commondummyword\udotaccent
4977 \commondummyword\dotless
4978 %
4979 % Texinfo font commands.
4980 \commondummyword\b
4981 \commondummyword\i
4982 \commondummyword\r
4983 \commondummyword\sansserif
4984 \commondummyword\sc
4985 \commondummyword\slanted
4986 \commondummyword\t
4987 %
4988 % Commands that take arguments.
4989 \commondummyword\abbr
4990 \commondummyword\acronym
4991 \commondummyword\anchor
4992 \commondummyword\cite
4993 \commondummyword\code
4994 \commondummyword\command
4995 \commondummyword\dfn
4996 \commondummyword\dmn
4997 \commondummyword\email
4998 \commondummyword\emph
4999 \commondummyword\env
5000 \commondummyword\file
5001 \commondummyword\image
5002 \commondummyword\indicateurl
5003 \commondummyword\inforef
5004 \commondummyword\kbd
5005 \commondummyword\key
5006 \commondummyword\math
5007 \commondummyword\option
5008 \commondummyword\pxref
5009 \commondummyword\ref
5010 \commondummyword\samp
5011 \commondummyword\strong
5012 \commondummyword\tie
5013 \commondummyword\U
5014 \commondummyword\uref
5015 \commondummyword\url
5016 \commondummyword\var
5017 \commondummyword\verb
5018 \commondummyword\w
5019 \commondummyword\xref
5020 }
5021
5022 % For testing: output @{ and @} in index sort strings as \{ and \}.
5023 \newif\ifusebracesinindexes
5024
5025 \let\indexlbrace\relax
5026 \let\indexrbrace\relax
5027
5028 {\catcode`\@=0
5029 \catcode`\\=13
5030 @gdef@backslashdisappear{@def\{}}
5031 }
5032
5033 {
5034 \catcode`\<=13
5035 \catcode`\-=13
5036 \catcode`\`=13
5037 \gdef\indexnonalnumdisappear{%
5038 \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
5039 % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
5040 % (Introduced for FSFS 2nd ed.)
5041 \let`=\empty
5042 \fi
5043 %
5044 \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
5045 \backslashdisappear
5046 \fi
5047 %
5048 \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
5049 \def-{}%
5050 \fi
5051 \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
5052 \def<{}%
5053 \fi
5054 \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
5055 \def\@{}%
5056 \fi
5057 }
5058
5059 \gdef\indexnonalnumreappear{%
5060 \useindexbackslash
5061 \let-\normaldash
5062 \let<\normalless
5063 \def\@{@}%
5064 }
5065 }
5066
5067
5068 % \indexnofonts is used when outputting the strings to sort the index
5069 % by, and when constructing control sequence names. It eliminates all
5070 % control sequences and just writes whatever the best ASCII sort string
5071 % would be for a given command (usually its argument).
5072 %
5073 \def\indexnofonts{%
5074 % Accent commands should become @asis.
5075 \def\commondummyaccent##1{\let##1\asis}%
5076 % We can just ignore other control letters.
5077 \def\commondummyletter##1{\let##1\empty}%
5078 % All control words become @asis by default; overrides below.
5079 \let\commondummyword\commondummyaccent
5080 \commondummiesnofonts
5081 %
5082 % Don't no-op \tt, since it isn't a user-level command
5083 % and is used in the definitions of the active chars like <, >, |, etc.
5084 % Likewise with the other plain tex font commands.
5085 %\let\tt=\asis
5086 %
5087 \def\ { }%
5088 \def\@{@}%
5089 \def\_{\normalunderscore}%
5090 \def\-{}% @- shouldn't affect sorting
5091 %
5092 \uccode`\1=`\{ \uppercase{\def\{{1}}%
5093 \uccode`\1=`\} \uppercase{\def\}{1}}%
5094 \let\lbracechar\{%
5095 \let\rbracechar\}%
5096 %
5097 % Non-English letters.
5098 \def\AA{AA}%
5099 \def\AE{AE}%
5100 \def\DH{DZZ}%
5101 \def\L{L}%
5102 \def\OE{OE}%
5103 \def\O{O}%
5104 \def\TH{TH}%
5105 \def\aa{aa}%
5106 \def\ae{ae}%
5107 \def\dh{dzz}%
5108 \def\exclamdown{!}%
5109 \def\l{l}%
5110 \def\oe{oe}%
5111 \def\ordf{a}%
5112 \def\ordm{o}%
5113 \def\o{o}%
5114 \def\questiondown{?}%
5115 \def\ss{ss}%
5116 \def\th{th}%
5117 %
5118 \def\LaTeX{LaTeX}%
5119 \def\TeX{TeX}%
5120 %
5121 % Assorted special characters.
5122 % (The following {} will end up in the sort string, but that's ok.)
5123 \def\arrow{->}%
5124 \def\bullet{bullet}%
5125 \def\comma{,}%
5126 \def\copyright{copyright}%
5127 \def\dots{...}%
5128 \def\enddots{...}%
5129 \def\equiv{==}%
5130 \def\error{error}%
5131 \def\euro{euro}%
5132 \def\expansion{==>}%
5133 \def\geq{>=}%
5134 \def\guillemetleft{<<}%
5135 \def\guillemetright{>>}%
5136 \def\guilsinglleft{<}%
5137 \def\guilsinglright{>}%
5138 \def\leq{<=}%
5139 \def\minus{-}%
5140 \def\point{.}%
5141 \def\pounds{pounds}%
5142 \def\print{-|}%
5143 \def\quotedblbase{"}%
5144 \def\quotedblleft{"}%
5145 \def\quotedblright{"}%
5146 \def\quoteleft{`}%
5147 \def\quoteright{'}%
5148 \def\quotesinglbase{,}%
5149 \def\registeredsymbol{R}%
5150 \def\result{=>}%
5151 \def\textdegree{o}%
5152 %
5153 % We need to get rid of all macros, leaving only the arguments (if present).
5154 % Of course this is not nearly correct, but it is the best we can do for now.
5155 % makeinfo does not expand macros in the argument to @deffn, which ends up
5156 % writing an index entry, and texindex isn't prepared for an index sort entry
5157 % that starts with \.
5158 %
5159 % Since macro invocations are followed by braces, we can just redefine them
5160 % to take a single TeX argument. The case of a macro invocation that
5161 % goes to end-of-line is not handled.
5162 %
5163 \macrolist
5164 \let\value\indexnofontsvalue
5165 }
5166
5167 \f
5168
5169
5170 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
5171
5172 % Most index entries go through here, but \dosubind is the general case.
5173 % #1 is the index name, #2 is the entry text.
5174 \def\doind#1#2{\dosubind{#1}{#2}{}}
5175
5176 % There is also \dosubind {index}{topic}{subtopic}
5177 % which makes an entry in a two-level index such as the operation index.
5178 % TODO: Two-level index? Operation index?
5179
5180 % Workhorse for all indexes.
5181 % #1 is name of index, #2 is stuff to put there, #3 is subentry --
5182 % empty if called from \doind, as we usually are (the main exception
5183 % is with most defuns, which call us directly).
5184 %
5185 \def\dosubind#1#2#3{%
5186 \iflinks
5187 {%
5188 \requireopenindexfile{#1}%
5189 % Store the main index entry text (including the third arg).
5190 \toks0 = {#2}%
5191 % If third arg is present, precede it with a space.
5192 \def\thirdarg{#3}%
5193 \ifx\thirdarg\empty \else
5194 \toks0 = \expandafter{\the\toks0 \space #3}%
5195 \fi
5196 %
5197 \edef\writeto{\csname#1indfile\endcsname}%
5198 %
5199 \safewhatsit\dosubindwrite
5200 }%
5201 \fi
5202 }
5203
5204 % Check if an index file has been opened, and if not, open it.
5205 \def\requireopenindexfile#1{%
5206 \ifnum\csname #1indfile\endcsname=0
5207 \expandafter\newwrite \csname#1indfile\endcsname
5208 \edef\suffix{#1}%
5209 % A .fls suffix would conflict with the file extension for the output
5210 % of -recorder, so use .f1s instead.
5211 \ifx\suffix\indexisfl\def\suffix{f1}\fi
5212 % Open the file
5213 \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
5214 % Using \immediate above here prevents an object entering into the current
5215 % box, which could confound checks such as those in \safewhatsit for
5216 % preceding skips.
5217 \typeout{Writing index file \jobname.\suffix}%
5218 \fi}
5219 \def\indexisfl{fl}
5220
5221 % Output \ as {\indexbackslash}, because \ is an escape character in
5222 % the index files.
5223 \let\indexbackslash=\relax
5224 {\catcode`\@=0 \catcode`\\=\active
5225 @gdef@useindexbackslash{@def\{{@indexbackslash}}}
5226 }
5227
5228 % Definition for writing index entry text.
5229 \def\sortas#1{\ignorespaces}%
5230
5231 % Definition for writing index entry sort key. Should occur at the at
5232 % the beginning of the index entry, like
5233 % @cindex @sortas{september} \september
5234 % The \ignorespaces takes care of following space, but there's no way
5235 % to remove space before it.
5236 {
5237 \catcode`\-=13
5238 \gdef\indexwritesortas{%
5239 \begingroup
5240 \indexnonalnumreappear
5241 \indexwritesortasxxx}
5242 \gdef\indexwritesortasxxx#1{%
5243 \xdef\indexsortkey{#1}\endgroup}
5244 }
5245
5246
5247 % Write the entry in \toks0 to the index file.
5248 %
5249 \def\dosubindwrite{%
5250 % Put the index entry in the margin if desired.
5251 \ifx\SETmarginindex\relax\else
5252 \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
5253 \fi
5254 %
5255 % Remember, we are within a group.
5256 \indexdummies % Must do this here, since \bf, etc expand at this stage
5257 \useindexbackslash % \indexbackslash isn't defined now so it will be output
5258 % as is; and it will print as backslash.
5259 % The braces around \indexbrace are recognized by texindex.
5260 %
5261 % Get the string to sort by, by processing the index entry with all
5262 % font commands turned off.
5263 {\indexnofonts
5264 \def\lbracechar{{\indexlbrace}}%
5265 \def\rbracechar{{\indexrbrace}}%
5266 \let\{=\lbracechar
5267 \let\}=\rbracechar
5268 \indexnonalnumdisappear
5269 \xdef\indexsortkey{}%
5270 \let\sortas=\indexwritesortas
5271 \edef\temp{\the\toks0}%
5272 \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas
5273 \ifx\indexsortkey\empty
5274 \xdef\indexsortkey{\temp}%
5275 \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
5276 \fi
5277 }%
5278 %
5279 % Set up the complete index entry, with both the sort key and
5280 % the original text, including any font commands. We write
5281 % three arguments to \entry to the .?? file (four in the
5282 % subentry case), texindex reduces to two when writing the .??s
5283 % sorted result.
5284 \edef\temp{%
5285 \write\writeto{%
5286 \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}%
5287 }%
5288 \temp
5289 }
5290 \newbox\dummybox % used above
5291
5292 % Take care of unwanted page breaks/skips around a whatsit:
5293 %
5294 % If a skip is the last thing on the list now, preserve it
5295 % by backing up by \lastskip, doing the \write, then inserting
5296 % the skip again. Otherwise, the whatsit generated by the
5297 % \write or \pdfdest will make \lastskip zero. The result is that
5298 % sequences like this:
5299 % @end defun
5300 % @tindex whatever
5301 % @defun ...
5302 % will have extra space inserted, because the \medbreak in the
5303 % start of the @defun won't see the skip inserted by the @end of
5304 % the previous defun.
5305 %
5306 % But don't do any of this if we're not in vertical mode. We
5307 % don't want to do a \vskip and prematurely end a paragraph.
5308 %
5309 % Avoid page breaks due to these extra skips, too.
5310 %
5311 % But wait, there is a catch there:
5312 % We'll have to check whether \lastskip is zero skip. \ifdim is not
5313 % sufficient for this purpose, as it ignores stretch and shrink parts
5314 % of the skip. The only way seems to be to check the textual
5315 % representation of the skip.
5316 %
5317 % The following is almost like \def\zeroskipmacro{0.0pt} except that
5318 % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
5319 %
5320 \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
5321 %
5322 \newskip\whatsitskip
5323 \newcount\whatsitpenalty
5324 %
5325 % ..., ready, GO:
5326 %
5327 \def\safewhatsit#1{\ifhmode
5328 #1%
5329 \else
5330 % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
5331 \whatsitskip = \lastskip
5332 \edef\lastskipmacro{\the\lastskip}%
5333 \whatsitpenalty = \lastpenalty
5334 %
5335 % If \lastskip is nonzero, that means the last item was a
5336 % skip. And since a skip is discardable, that means this
5337 % -\whatsitskip glue we're inserting is preceded by a
5338 % non-discardable item, therefore it is not a potential
5339 % breakpoint, therefore no \nobreak needed.
5340 \ifx\lastskipmacro\zeroskipmacro
5341 \else
5342 \vskip-\whatsitskip
5343 \fi
5344 %
5345 #1%
5346 %
5347 \ifx\lastskipmacro\zeroskipmacro
5348 % If \lastskip was zero, perhaps the last item was a penalty, and
5349 % perhaps it was >=10000, e.g., a \nobreak. In that case, we want
5350 % to re-insert the same penalty (values >10000 are used for various
5351 % signals); since we just inserted a non-discardable item, any
5352 % following glue (such as a \parskip) would be a breakpoint. For example:
5353 % @deffn deffn-whatever
5354 % @vindex index-whatever
5355 % Description.
5356 % would allow a break between the index-whatever whatsit
5357 % and the "Description." paragraph.
5358 \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
5359 \else
5360 % On the other hand, if we had a nonzero \lastskip,
5361 % this make-up glue would be preceded by a non-discardable item
5362 % (the whatsit from the \write), so we must insert a \nobreak.
5363 \nobreak\vskip\whatsitskip
5364 \fi
5365 \fi}
5366
5367 % The index entry written in the file actually looks like
5368 % \entry {sortstring}{page}{topic}
5369 % or
5370 % \entry {sortstring}{page}{topic}{subtopic}
5371 % The texindex program reads in these files and writes files
5372 % containing these kinds of lines:
5373 % \initial {c}
5374 % before the first topic whose initial is c
5375 % \entry {topic}{pagelist}
5376 % for a topic that is used without subtopics
5377 % \primary {topic}
5378 % for the beginning of a topic that is used with subtopics
5379 % \secondary {subtopic}{pagelist}
5380 % for each subtopic.
5381
5382 % Define the user-accessible indexing commands
5383 % @findex, @vindex, @kindex, @cindex.
5384
5385 \def\findex {\fnindex}
5386 \def\kindex {\kyindex}
5387 \def\cindex {\cpindex}
5388 \def\vindex {\vrindex}
5389 \def\tindex {\tpindex}
5390 \def\pindex {\pgindex}
5391
5392 \def\cindexsub {\begingroup\obeylines\cindexsub}
5393 {\obeylines %
5394 \gdef\cindexsub "#1" #2^^M{\endgroup %
5395 \dosubind{cp}{#2}{#1}}}
5396
5397 % Define the macros used in formatting output of the sorted index material.
5398
5399 % @printindex causes a particular index (the ??s file) to get printed.
5400 % It does not print any chapter heading (usually an @unnumbered).
5401 %
5402 \parseargdef\printindex{\begingroup
5403 \dobreak \chapheadingskip{10000}%
5404 %
5405 \smallfonts \rm
5406 \tolerance = 9500
5407 \plainfrenchspacing
5408 \everypar = {}% don't want the \kern\-parindent from indentation suppression.
5409 %
5410 % See if the index file exists and is nonempty.
5411 % Change catcode of @ here so that if the index file contains
5412 % \initial {@}
5413 % as its first line, TeX doesn't complain about mismatched braces
5414 % (because it thinks @} is a control sequence).
5415 \catcode`\@ = 11
5416 % See comment in \requireopenindexfile.
5417 \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
5418 \openin 1 \jobname.\indexname s
5419 \ifeof 1
5420 % \enddoublecolumns gets confused if there is no text in the index,
5421 % and it loses the chapter title and the aux file entries for the
5422 % index. The easiest way to prevent this problem is to make sure
5423 % there is some text.
5424 \putwordIndexNonexistent
5425 \typeout{No file \jobname.\indexname s.}%
5426 \else
5427 \catcode`\\ = 0
5428 %
5429 % If the index file exists but is empty, then \openin leaves \ifeof
5430 % false. We have to make TeX try to read something from the file, so
5431 % it can discover if there is anything in it.
5432 \read 1 to \thisline
5433 \ifeof 1
5434 \putwordIndexIsEmpty
5435 \else
5436 % Index files are almost Texinfo source, but we use \ as the escape
5437 % character. It would be better to use @, but that's too big a change
5438 % to make right now.
5439 \def\indexbackslash{\ttbackslash}%
5440 \let\indexlbrace\{ % Likewise, set these sequences for braces
5441 \let\indexrbrace\} % used in the sort key.
5442 \begindoublecolumns
5443 \let\entryorphanpenalty=\indexorphanpenalty
5444 %
5445 % Read input from the index file line by line.
5446 \loopdo
5447 \ifeof1
5448 \let\firsttoken\relax
5449 \else
5450 \read 1 to \nextline
5451 \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}%
5452 \act
5453 \fi
5454 \thisline
5455 %
5456 \ifeof1\else
5457 \let\thisline\nextline
5458 \repeat
5459 %%
5460 \enddoublecolumns
5461 \fi
5462 \fi
5463 \closein 1
5464 \endgroup}
5465
5466 \def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken}
5467 \long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1}
5468
5469 \def\loopdo#1\repeat{\def\body{#1}\loopdoxxx}
5470 \def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next}
5471
5472 % These macros are used by the sorted index file itself.
5473 % Change them to control the appearance of the index.
5474
5475 {\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
5476 \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
5477 \catcode`\$=3
5478 \gdef\initialglyphs{%
5479 % Some changes for non-alphabetic characters. Using the glyphs from the
5480 % math fonts looks more consistent than the typewriter font used elsewhere
5481 % for these characters.
5482 \def\indexbackslash{\math{\backslash}}%
5483 \let\\=\indexbackslash
5484 %
5485 % Can't get bold backslash so don't use bold forward slash
5486 \catcode`\/=13
5487 \def/{{\secrmnotbold \normalslash}}%
5488 \def-{{\normaldash\normaldash}}% en dash `--'
5489 \def^{{\chapbf \normalcaret}}%
5490 \def~{{\chapbf \normaltilde}}%
5491 \def\_{%
5492 \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
5493 \def|{$\vert$}%
5494 \def<{$\less$}%
5495 \def>{$\gtr$}%
5496 \def+{$\normalplus$}%
5497 }}
5498
5499 \def\initial{%
5500 \bgroup
5501 \initialglyphs
5502 \initialx
5503 }
5504
5505 \def\initialx#1{%
5506 % Remove any glue we may have, we'll be inserting our own.
5507 \removelastskip
5508 %
5509 % We like breaks before the index initials, so insert a bonus.
5510 % The glue before the bonus allows a little bit of space at the
5511 % bottom of a column to reduce an increase in inter-line spacing.
5512 \nobreak
5513 \vskip 0pt plus 5\baselineskip
5514 \penalty -300
5515 \vskip 0pt plus -5\baselineskip
5516 %
5517 % Typeset the initial. Making this add up to a whole number of
5518 % baselineskips increases the chance of the dots lining up from column
5519 % to column. It still won't often be perfect, because of the stretch
5520 % we need before each entry, but it's better.
5521 %
5522 % No shrink because it confuses \balancecolumns.
5523 \vskip 1.67\baselineskip plus 1\baselineskip
5524 \leftline{\secfonts \kern-0.05em \secbf #1}%
5525 % \secfonts is inside the argument of \leftline so that the change of
5526 % \baselineskip will not affect any glue inserted before the vbox that
5527 % \leftline creates.
5528 % Do our best not to break after the initial.
5529 \nobreak
5530 \vskip .33\baselineskip plus .1\baselineskip
5531 \egroup % \initialglyphs
5532 }
5533
5534 \newdimen\entryrightmargin
5535 \entryrightmargin=0pt
5536
5537 % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
5538 % then page number (#2) flushed to the right margin. It is used for index
5539 % and table of contents entries. The paragraph is indented by \leftskip.
5540 %
5541 \def\entry{%
5542 \begingroup
5543 %
5544 % Start a new paragraph if necessary, so our assignments below can't
5545 % affect previous text.
5546 \par
5547 %
5548 % No extra space above this paragraph.
5549 \parskip = 0in
5550 %
5551 % When reading the text of entry, convert explicit line breaks
5552 % from @* into spaces. The user might give these in long section
5553 % titles, for instance.
5554 \def\*{\unskip\space\ignorespaces}%
5555 \def\entrybreak{\hfil\break}% An undocumented command
5556 %
5557 % A bit of stretch before each entry for the benefit of balancing
5558 % columns.
5559 \vskip 0pt plus0.5pt
5560 %
5561 % Swallow the left brace of the text (first parameter):
5562 \afterassignment\doentry
5563 \let\temp =
5564 }
5565 \def\entrybreak{\unskip\space\ignorespaces}%
5566 \def\doentry{%
5567 % Save the text of the entry
5568 \global\setbox\boxA=\hbox\bgroup
5569 \bgroup % Instead of the swallowed brace.
5570 \noindent
5571 \aftergroup\finishentry
5572 % And now comes the text of the entry.
5573 % Not absorbing as a macro argument reduces the chance of problems
5574 % with catcodes occurring.
5575 }
5576 {\catcode`\@=11
5577 \gdef\finishentry#1{%
5578 \egroup % end box A
5579 \dimen@ = \wd\boxA % Length of text of entry
5580 \global\setbox\boxA=\hbox\bgroup\unhbox\boxA
5581 % #1 is the page number.
5582 %
5583 % Get the width of the page numbers, and only use
5584 % leaders if they are present.
5585 \global\setbox\boxB = \hbox{#1}%
5586 \ifdim\wd\boxB = 0pt
5587 \null\nobreak\hfill\ %
5588 \else
5589 %
5590 \null\nobreak\indexdotfill % Have leaders before the page number.
5591 %
5592 \ifpdf
5593 \pdfgettoks#1.%
5594 \bgroup\let\domark\relax
5595 \hskip\skip\thinshrinkable\the\toksA
5596 \egroup
5597 % The redefinion of \domark stops marks being added in \pdflink to
5598 % preserve coloured links across page boundaries. Otherwise the marks
5599 % would get in the way of \lastbox in \insertindexentrybox.
5600 \else
5601 \ifx\XeTeXrevision\thisisundefined
5602 \hskip\skip\thinshrinkable #1%
5603 \else
5604 \pdfgettoks#1.%
5605 \bgroup\let\domark\relax
5606 \hskip\skip\thinshrinkable\the\toksA
5607 \egroup
5608 \fi
5609 \fi
5610 \fi
5611 \egroup % end \boxA
5612 \ifdim\wd\boxB = 0pt
5613 \global\setbox\entryindexbox=\vbox{\unhbox\boxA}%
5614 \else
5615 \global\setbox\entryindexbox=\vbox\bgroup
5616 \prevdepth=\entrylinedepth
5617 \noindent
5618 % We want the text of the entries to be aligned to the left, and the
5619 % page numbers to be aligned to the right.
5620 %
5621 \advance\leftskip by 0pt plus 1fil
5622 \advance\leftskip by 0pt plus -1fill
5623 \rightskip = 0pt plus -1fil
5624 \advance\rightskip by 0pt plus 1fill
5625 % Cause last line, which could consist of page numbers on their own
5626 % if the list of page numbers is long, to be aligned to the right.
5627 \parfillskip=0pt plus -1fill
5628 %
5629 \hangindent=1em
5630 %
5631 \advance\rightskip by \entryrightmargin
5632 % Determine how far we can stretch into the margin.
5633 % This allows, e.g., "Appendix H GNU Free Documentation License" to
5634 % fit on one line in @letterpaper format.
5635 \ifdim\entryrightmargin>2.1em
5636 \dimen@i=2.1em
5637 \else
5638 \dimen@i=0em
5639 \fi
5640 \advance \parfillskip by 0pt minus 1\dimen@i
5641 %
5642 \dimen@ii = \hsize
5643 \advance\dimen@ii by -1\leftskip
5644 \advance\dimen@ii by -1\entryrightmargin
5645 \advance\dimen@ii by 1\dimen@i
5646 \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
5647 \ifdim\dimen@ > 0.8\dimen@ii % due to long index text
5648 \dimen@ = 0.7\dimen@ % Try to split the text roughly evenly
5649 \dimen@ii = \hsize
5650 \advance \dimen@ii by -1em
5651 \ifnum\dimen@>\dimen@ii
5652 % If the entry is too long, use the whole line
5653 \dimen@ = \dimen@ii
5654 \fi
5655 \advance\leftskip by 0pt plus 1fill % ragged right
5656 \advance \dimen@ by 1\rightskip
5657 \parshape = 2 0pt \dimen@ 1em \dimen@ii
5658 % Ideally we'd add a finite glue at the end of the first line only, but
5659 % TeX doesn't seem to provide a way to do such a thing.
5660 \fi\fi
5661 \unhbox\boxA
5662 %
5663 % Do not prefer a separate line ending with a hyphen to fewer lines.
5664 \finalhyphendemerits = 0
5665 %
5666 % Word spacing - no stretch
5667 \spaceskip=\fontdimen2\font minus \fontdimen4\font
5668 %
5669 \linepenalty=1000 % Discourage line breaks.
5670 \hyphenpenalty=5000 % Discourage hyphenation.
5671 %
5672 \par % format the paragraph
5673 \egroup % The \vbox
5674 \fi
5675 \endgroup
5676 % delay text of entry until after penalty
5677 \bgroup\aftergroup\insertindexentrybox
5678 \entryorphanpenalty
5679 }}
5680
5681 \newskip\thinshrinkable
5682 \skip\thinshrinkable=.15em minus .15em
5683
5684 \newbox\entryindexbox
5685 \def\insertindexentrybox{%
5686 \copy\entryindexbox
5687 % The following gets the depth of the last box. This is for even
5688 % line spacing when entries span several lines.
5689 \setbox\dummybox\vbox{%
5690 \unvbox\entryindexbox
5691 \nointerlineskip
5692 \lastbox
5693 \global\entrylinedepth=\prevdepth
5694 }%
5695 % Note that we couldn't simply \unvbox\entryindexbox followed by
5696 % \nointerlineskip\lastbox to remove the last box and then reinstate it,
5697 % because this resets how far the box has been \moveleft'ed to 0. \unvbox
5698 % doesn't affect \prevdepth either.
5699 }
5700 \newdimen\entrylinedepth
5701
5702 % Default is no penalty
5703 \let\entryorphanpenalty\egroup
5704
5705 % Used from \printindex. \firsttoken should be the first token
5706 % after the \entry. If it's not another \entry, we are at the last
5707 % line of a group of index entries, so insert a penalty to discourage
5708 % orphaned index entries.
5709 \long\def\indexorphanpenalty{%
5710 \def\isentry{\entry}%
5711 \ifx\firsttoken\isentry
5712 \else
5713 \unskip\penalty 9000
5714 % The \unskip here stops breaking before the glue. It relies on the
5715 % \vskip above being there, otherwise there is an error
5716 % "You can't use `\unskip' in vertical mode". There has to be glue
5717 % in the current vertical list that hasn't been added to the
5718 % "current page". See Chapter 24 of the TeXbook. This contradicts
5719 % Section 8.3.7 in "TeX by Topic," though.
5720 \fi
5721 \egroup % now comes the box added with \aftergroup
5722 }
5723
5724 % Like plain.tex's \dotfill, except uses up at least 1 em.
5725 % The filll stretch here overpowers both the fil and fill stretch to push
5726 % the page number to the right.
5727 \def\indexdotfill{\cleaders
5728 \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
5729
5730
5731 \def\primary #1{\line{#1\hfil}}
5732
5733 \newskip\secondaryindent \secondaryindent=0.5cm
5734 \def\secondary#1#2{{%
5735 \parfillskip=0in
5736 \parskip=0in
5737 \hangindent=1in
5738 \hangafter=1
5739 \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
5740 \ifpdf
5741 \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5742 \else
5743 \ifx\XeTeXrevision\thisisundefined
5744 #2
5745 \else
5746 \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5747 \fi
5748 \fi
5749 \par
5750 }}
5751
5752 % Define two-column mode, which we use to typeset indexes.
5753 % Adapted from the TeXbook, page 416, which is to say,
5754 % the manmac.tex format used to print the TeXbook itself.
5755 \catcode`\@=11 % private names
5756
5757 \newbox\partialpage
5758 \newdimen\doublecolumnhsize
5759 \newdimen\doublecolumntopgap
5760 \doublecolumntopgap = 0pt
5761
5762 % Use inside an output routine to save \topmark and \firstmark
5763 \def\savemarks{%
5764 \global\savedtopmark=\expandafter{\topmark }%
5765 \global\savedfirstmark=\expandafter{\firstmark }%
5766 }
5767 \newtoks\savedtopmark
5768 \newtoks\savedfirstmark
5769
5770 % Set \topmark and \firstmark for next time \output runs.
5771 % Can't be run from withinside \output (because any material
5772 % added while an output routine is active, including
5773 % penalties, is saved for after it finishes). The page so far
5774 % should be empty, otherwise what's on it will be thrown away.
5775 \def\restoremarks{%
5776 \mark{\the\savedtopmark}%
5777 \bgroup\output = {%
5778 \setbox\dummybox=\box\PAGE
5779 }abc\eject\egroup
5780 % "abc" because output routine doesn't fire for a completely empty page.
5781 \mark{\the\savedfirstmark}%
5782 }
5783
5784 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
5785 % If not much space left on page, start a new page.
5786 \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
5787 %
5788 % Grab any single-column material above us.
5789 \output = {%
5790 %
5791 % Here is a possibility not foreseen in manmac: if we accumulate a
5792 % whole lot of material, we might end up calling this \output
5793 % routine twice in a row (see the doublecol-lose test, which is
5794 % essentially a couple of indexes with @setchapternewpage off). In
5795 % that case we just ship out what is in \partialpage with the normal
5796 % output routine. Generally, \partialpage will be empty when this
5797 % runs and this will be a no-op. See the indexspread.tex test case.
5798 \ifvoid\partialpage \else
5799 \onepageout{\pagecontents\partialpage}%
5800 \fi
5801 %
5802 \global\setbox\partialpage = \vbox{%
5803 % Unvbox the main output page.
5804 \unvbox\PAGE
5805 \kern-\topskip \kern\baselineskip
5806 }%
5807 \savemarks
5808 }%
5809 \eject % run that output routine to set \partialpage
5810 \restoremarks
5811 %
5812 % We recover the two marks that the last output routine saved in order
5813 % to propagate the information in marks added around a chapter heading,
5814 % which could be otherwise be lost by the time the final page is output.
5815 %
5816 %
5817 % Use the double-column output routine for subsequent pages.
5818 \output = {\doublecolumnout}%
5819 %
5820 % Change the page size parameters. We could do this once outside this
5821 % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5822 % format, but then we repeat the same computation. Repeating a couple
5823 % of assignments once per index is clearly meaningless for the
5824 % execution time, so we may as well do it in one place.
5825 %
5826 % First we halve the line length, less a little for the gutter between
5827 % the columns. We compute the gutter based on the line length, so it
5828 % changes automatically with the paper format. The magic constant
5829 % below is chosen so that the gutter has the same value (well, +-<1pt)
5830 % as it did when we hard-coded it.
5831 %
5832 % We put the result in a separate register, \doublecolumhsize, so we
5833 % can restore it in \pagesofar, after \hsize itself has (potentially)
5834 % been clobbered.
5835 %
5836 \doublecolumnhsize = \hsize
5837 \advance\doublecolumnhsize by -.04154\hsize
5838 \divide\doublecolumnhsize by 2
5839 \hsize = \doublecolumnhsize
5840 %
5841 % Double the \vsize as well. (We don't need a separate register here,
5842 % since nobody clobbers \vsize.)
5843 \global\doublecolumntopgap = \topskip
5844 \global\advance\doublecolumntopgap by -1\baselineskip
5845 \advance\vsize by -1\doublecolumntopgap
5846 \vsize = 2\vsize
5847 \topskip=0pt
5848 \global\entrylinedepth=0pt\relax
5849 }
5850
5851 % The double-column output routine for all double-column pages except
5852 % the last, which is done by \balancecolumns.
5853 %
5854 \def\doublecolumnout{%
5855 %
5856 \splittopskip=\topskip \splitmaxdepth=\maxdepth
5857 % Get the available space for the double columns -- the normal
5858 % (undoubled) page height minus any material left over from the
5859 % previous page.
5860 \dimen@ = \vsize
5861 \divide\dimen@ by 2
5862 \advance\dimen@ by -\ht\partialpage
5863 %
5864 % box0 will be the left-hand column, box2 the right.
5865 \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
5866 \onepageout\pagesofar
5867 \unvbox255
5868 \penalty\outputpenalty
5869 }
5870 %
5871 % Re-output the contents of the output page -- any previous material,
5872 % followed by the two boxes we just split, in box0 and box2.
5873 \def\pagesofar{%
5874 \unvbox\partialpage
5875 %
5876 \hsize = \doublecolumnhsize
5877 \wd0=\hsize \wd2=\hsize
5878 \vbox{%
5879 \vskip\doublecolumntopgap
5880 \hbox to\txipagewidth{\box0\hfil\box2}}%
5881 }
5882
5883
5884 % Finished with with double columns.
5885 \def\enddoublecolumns{%
5886 % The following penalty ensures that the page builder is exercised
5887 % _before_ we change the output routine. This is necessary in the
5888 % following situation:
5889 %
5890 % The last section of the index consists only of a single entry.
5891 % Before this section, \pagetotal is less than \pagegoal, so no
5892 % break occurs before the last section starts. However, the last
5893 % section, consisting of \initial and the single \entry, does not
5894 % fit on the page and has to be broken off. Without the following
5895 % penalty the page builder will not be exercised until \eject
5896 % below, and by that time we'll already have changed the output
5897 % routine to the \balancecolumns version, so the next-to-last
5898 % double-column page will be processed with \balancecolumns, which
5899 % is wrong: The two columns will go to the main vertical list, with
5900 % the broken-off section in the recent contributions. As soon as
5901 % the output routine finishes, TeX starts reconsidering the page
5902 % break. The two columns and the broken-off section both fit on the
5903 % page, because the two columns now take up only half of the page
5904 % goal. When TeX sees \eject from below which follows the final
5905 % section, it invokes the new output routine that we've set after
5906 % \balancecolumns below; \onepageout will try to fit the two columns
5907 % and the final section into the vbox of \txipageheight (see
5908 % \pagebody), causing an overfull box.
5909 %
5910 % Note that glue won't work here, because glue does not exercise the
5911 % page builder, unlike penalties (see The TeXbook, pp. 280-281).
5912 \penalty0
5913 %
5914 \output = {%
5915 % Split the last of the double-column material.
5916 \savemarks
5917 \balancecolumns
5918 %
5919 % Having called \balancecolumns once, we do not
5920 % want to call it again. Therefore, reset \output to its normal
5921 % definition right away.
5922 \global\output = {\onepageout{\pagecontents\PAGE}}%
5923 }%
5924 \eject
5925 \endgroup % started in \begindoublecolumns
5926 \restoremarks
5927 % Leave the double-column material on the current page, no automatic
5928 % page break.
5929 \box\balancedcolumns
5930 %
5931 % \pagegoal was set to the doubled \vsize above, since we restarted
5932 % the current page. We're now back to normal single-column
5933 % typesetting, so reset \pagegoal to the normal \vsize (after the
5934 % \endgroup where \vsize got restored).
5935 \pagegoal = \vsize
5936 }
5937 \newbox\balancedcolumns
5938 \setbox\balancedcolumns=\vbox{shouldnt see this}%
5939 %
5940 % Only called for the last of the double column material. \doublecolumnout
5941 % does the others.
5942 \def\balancecolumns{%
5943 \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
5944 \dimen@ = \ht0
5945 \advance\dimen@ by \topskip
5946 \advance\dimen@ by-\baselineskip
5947 \ifdim\dimen@<14\baselineskip
5948 % Don't split a short final column in two.
5949 \setbox2=\vbox{}%
5950 \else
5951 \divide\dimen@ by 2 % target to split to
5952 \dimen@ii = \dimen@
5953 \splittopskip = \topskip
5954 % Loop until the second column is no higher than the first
5955 {%
5956 \vbadness = 10000
5957 \loop
5958 \global\setbox3 = \copy0
5959 \global\setbox1 = \vsplit3 to \dimen@
5960 % Remove glue from bottom of first column to
5961 % make sure it is higher than the second.
5962 \global\setbox1 = \vbox{\unvbox1\unpenalty\unskip}%
5963 \ifdim\ht3>\ht1
5964 \global\advance\dimen@ by 1pt
5965 \repeat
5966 }%
5967 \multiply\dimen@ii by 4
5968 \divide\dimen@ii by 5
5969 \ifdim\ht3<\dimen@ii
5970 % Column heights are too different, so don't make their bottoms
5971 % flush with each other. The glue at the end of the second column
5972 % allows a second column to stretch, reducing the difference in
5973 % height between the two.
5974 \setbox0=\vbox to\dimen@{\unvbox1\vfill}%
5975 \setbox2=\vbox to\dimen@{\unvbox3\vskip 0pt plus 0.3\ht0}%
5976 \else
5977 \setbox0=\vbox to\dimen@{\unvbox1}%
5978 \setbox2=\vbox to\dimen@{\unvbox3}%
5979 \fi
5980 \fi
5981 %
5982 \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5983 }
5984 \catcode`\@ = \other
5985
5986
5987 \message{sectioning,}
5988 % Chapters, sections, etc.
5989
5990 % Let's start with @part.
5991 \outer\parseargdef\part{\partzzz{#1}}
5992 \def\partzzz#1{%
5993 \chapoddpage
5994 \null
5995 \vskip.3\vsize % move it down on the page a bit
5996 \begingroup
5997 \noindent \titlefonts\rmisbold #1\par % the text
5998 \let\lastnode=\empty % no node to associate with
5999 \writetocentry{part}{#1}{}% but put it in the toc
6000 \headingsoff % no headline or footline on the part page
6001 % This outputs a mark at the end of the page that clears \thischapter
6002 % and \thissection, as is done in \startcontents.
6003 \let\pchapsepmacro\relax
6004 \chapmacro{}{Yomitfromtoc}{}%
6005 \chapoddpage
6006 \endgroup
6007 }
6008
6009 % \unnumberedno is an oxymoron. But we count the unnumbered
6010 % sections so that we can refer to them unambiguously in the pdf
6011 % outlines by their "section number". We avoid collisions with chapter
6012 % numbers by starting them at 10000. (If a document ever has 10000
6013 % chapters, we're in trouble anyway, I'm sure.)
6014 \newcount\unnumberedno \unnumberedno = 10000
6015 \newcount\chapno
6016 \newcount\secno \secno=0
6017 \newcount\subsecno \subsecno=0
6018 \newcount\subsubsecno \subsubsecno=0
6019
6020 % This counter is funny since it counts through charcodes of letters A, B, ...
6021 \newcount\appendixno \appendixno = `\@
6022 %
6023 % \def\appendixletter{\char\the\appendixno}
6024 % We do the following ugly conditional instead of the above simple
6025 % construct for the sake of pdftex, which needs the actual
6026 % letter in the expansion, not just typeset.
6027 %
6028 \def\appendixletter{%
6029 \ifnum\appendixno=`A A%
6030 \else\ifnum\appendixno=`B B%
6031 \else\ifnum\appendixno=`C C%
6032 \else\ifnum\appendixno=`D D%
6033 \else\ifnum\appendixno=`E E%
6034 \else\ifnum\appendixno=`F F%
6035 \else\ifnum\appendixno=`G G%
6036 \else\ifnum\appendixno=`H H%
6037 \else\ifnum\appendixno=`I I%
6038 \else\ifnum\appendixno=`J J%
6039 \else\ifnum\appendixno=`K K%
6040 \else\ifnum\appendixno=`L L%
6041 \else\ifnum\appendixno=`M M%
6042 \else\ifnum\appendixno=`N N%
6043 \else\ifnum\appendixno=`O O%
6044 \else\ifnum\appendixno=`P P%
6045 \else\ifnum\appendixno=`Q Q%
6046 \else\ifnum\appendixno=`R R%
6047 \else\ifnum\appendixno=`S S%
6048 \else\ifnum\appendixno=`T T%
6049 \else\ifnum\appendixno=`U U%
6050 \else\ifnum\appendixno=`V V%
6051 \else\ifnum\appendixno=`W W%
6052 \else\ifnum\appendixno=`X X%
6053 \else\ifnum\appendixno=`Y Y%
6054 \else\ifnum\appendixno=`Z Z%
6055 % The \the is necessary, despite appearances, because \appendixletter is
6056 % expanded while writing the .toc file. \char\appendixno is not
6057 % expandable, thus it is written literally, thus all appendixes come out
6058 % with the same letter (or @) in the toc without it.
6059 \else\char\the\appendixno
6060 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
6061 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
6062
6063 % Each @chapter defines these (using marks) as the number+name, number
6064 % and name of the chapter. Page headings and footings can use
6065 % these. @section does likewise.
6066 \def\thischapter{}
6067 \def\thischapternum{}
6068 \def\thischaptername{}
6069 \def\thissection{}
6070 \def\thissectionnum{}
6071 \def\thissectionname{}
6072
6073 \newcount\absseclevel % used to calculate proper heading level
6074 \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
6075
6076 % @raisesections: treat @section as chapter, @subsection as section, etc.
6077 \def\raisesections{\global\advance\secbase by -1}
6078 \let\up=\raisesections % original BFox name
6079
6080 % @lowersections: treat @chapter as section, @section as subsection, etc.
6081 \def\lowersections{\global\advance\secbase by 1}
6082 \let\down=\lowersections % original BFox name
6083
6084 % we only have subsub.
6085 \chardef\maxseclevel = 3
6086 %
6087 % A numbered section within an unnumbered changes to unnumbered too.
6088 % To achieve this, remember the "biggest" unnum. sec. we are currently in:
6089 \chardef\unnlevel = \maxseclevel
6090 %
6091 % Trace whether the current chapter is an appendix or not:
6092 % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
6093 \def\chapheadtype{N}
6094
6095 % Choose a heading macro
6096 % #1 is heading type
6097 % #2 is heading level
6098 % #3 is text for heading
6099 \def\genhead#1#2#3{%
6100 % Compute the abs. sec. level:
6101 \absseclevel=#2
6102 \advance\absseclevel by \secbase
6103 % Make sure \absseclevel doesn't fall outside the range:
6104 \ifnum \absseclevel < 0
6105 \absseclevel = 0
6106 \else
6107 \ifnum \absseclevel > 3
6108 \absseclevel = 3
6109 \fi
6110 \fi
6111 % The heading type:
6112 \def\headtype{#1}%
6113 \if \headtype U%
6114 \ifnum \absseclevel < \unnlevel
6115 \chardef\unnlevel = \absseclevel
6116 \fi
6117 \else
6118 % Check for appendix sections:
6119 \ifnum \absseclevel = 0
6120 \edef\chapheadtype{\headtype}%
6121 \else
6122 \if \headtype A\if \chapheadtype N%
6123 \errmessage{@appendix... within a non-appendix chapter}%
6124 \fi\fi
6125 \fi
6126 % Check for numbered within unnumbered:
6127 \ifnum \absseclevel > \unnlevel
6128 \def\headtype{U}%
6129 \else
6130 \chardef\unnlevel = 3
6131 \fi
6132 \fi
6133 % Now print the heading:
6134 \if \headtype U%
6135 \ifcase\absseclevel
6136 \unnumberedzzz{#3}%
6137 \or \unnumberedseczzz{#3}%
6138 \or \unnumberedsubseczzz{#3}%
6139 \or \unnumberedsubsubseczzz{#3}%
6140 \fi
6141 \else
6142 \if \headtype A%
6143 \ifcase\absseclevel
6144 \appendixzzz{#3}%
6145 \or \appendixsectionzzz{#3}%
6146 \or \appendixsubseczzz{#3}%
6147 \or \appendixsubsubseczzz{#3}%
6148 \fi
6149 \else
6150 \ifcase\absseclevel
6151 \chapterzzz{#3}%
6152 \or \seczzz{#3}%
6153 \or \numberedsubseczzz{#3}%
6154 \or \numberedsubsubseczzz{#3}%
6155 \fi
6156 \fi
6157 \fi
6158 \suppressfirstparagraphindent
6159 }
6160
6161 % an interface:
6162 \def\numhead{\genhead N}
6163 \def\apphead{\genhead A}
6164 \def\unnmhead{\genhead U}
6165
6166 % @chapter, @appendix, @unnumbered. Increment top-level counter, reset
6167 % all lower-level sectioning counters to zero.
6168 %
6169 % Also set \chaplevelprefix, which we prepend to @float sequence numbers
6170 % (e.g., figures), q.v. By default (before any chapter), that is empty.
6171 \let\chaplevelprefix = \empty
6172 %
6173 \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
6174 \def\chapterzzz#1{%
6175 % section resetting is \global in case the chapter is in a group, such
6176 % as an @include file.
6177 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6178 \global\advance\chapno by 1
6179 %
6180 % Used for \float.
6181 \gdef\chaplevelprefix{\the\chapno.}%
6182 \resetallfloatnos
6183 %
6184 % \putwordChapter can contain complex things in translations.
6185 \toks0=\expandafter{\putwordChapter}%
6186 \message{\the\toks0 \space \the\chapno}%
6187 %
6188 % Write the actual heading.
6189 \chapmacro{#1}{Ynumbered}{\the\chapno}%
6190 %
6191 % So @section and the like are numbered underneath this chapter.
6192 \global\let\section = \numberedsec
6193 \global\let\subsection = \numberedsubsec
6194 \global\let\subsubsection = \numberedsubsubsec
6195 }
6196
6197 \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
6198 %
6199 \def\appendixzzz#1{%
6200 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6201 \global\advance\appendixno by 1
6202 \gdef\chaplevelprefix{\appendixletter.}%
6203 \resetallfloatnos
6204 %
6205 % \putwordAppendix can contain complex things in translations.
6206 \toks0=\expandafter{\putwordAppendix}%
6207 \message{\the\toks0 \space \appendixletter}%
6208 %
6209 \chapmacro{#1}{Yappendix}{\appendixletter}%
6210 %
6211 \global\let\section = \appendixsec
6212 \global\let\subsection = \appendixsubsec
6213 \global\let\subsubsection = \appendixsubsubsec
6214 }
6215
6216 % normally unnmhead0 calls unnumberedzzz:
6217 \outer\parseargdef\unnumbered{\unnmhead0{#1}}
6218 \def\unnumberedzzz#1{%
6219 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6220 \global\advance\unnumberedno by 1
6221 %
6222 % Since an unnumbered has no number, no prefix for figures.
6223 \global\let\chaplevelprefix = \empty
6224 \resetallfloatnos
6225 %
6226 % This used to be simply \message{#1}, but TeX fully expands the
6227 % argument to \message. Therefore, if #1 contained @-commands, TeX
6228 % expanded them. For example, in `@unnumbered The @cite{Book}', TeX
6229 % expanded @cite (which turns out to cause errors because \cite is meant
6230 % to be executed, not expanded).
6231 %
6232 % Anyway, we don't want the fully-expanded definition of @cite to appear
6233 % as a result of the \message, we just want `@cite' itself. We use
6234 % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6235 % simply yielding the contents of <toks register>. (We also do this for
6236 % the toc entries.)
6237 \toks0 = {#1}%
6238 \message{(\the\toks0)}%
6239 %
6240 \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
6241 %
6242 \global\let\section = \unnumberedsec
6243 \global\let\subsection = \unnumberedsubsec
6244 \global\let\subsubsection = \unnumberedsubsubsec
6245 }
6246
6247 % @centerchap is like @unnumbered, but the heading is centered.
6248 \outer\parseargdef\centerchap{%
6249 \let\centerparametersmaybe = \centerparameters
6250 \unnmhead0{#1}%
6251 \let\centerparametersmaybe = \relax
6252 }
6253
6254 % @top is like @unnumbered.
6255 \let\top\unnumbered
6256
6257 % Sections.
6258 %
6259 \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6260 \def\seczzz#1{%
6261 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
6262 \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
6263 }
6264
6265 % normally calls appendixsectionzzz:
6266 \outer\parseargdef\appendixsection{\apphead1{#1}}
6267 \def\appendixsectionzzz#1{%
6268 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
6269 \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
6270 }
6271 \let\appendixsec\appendixsection
6272
6273 % normally calls unnumberedseczzz:
6274 \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
6275 \def\unnumberedseczzz#1{%
6276 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
6277 \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
6278 }
6279
6280 % Subsections.
6281 %
6282 % normally calls numberedsubseczzz:
6283 \outer\parseargdef\numberedsubsec{\numhead2{#1}}
6284 \def\numberedsubseczzz#1{%
6285 \global\subsubsecno=0 \global\advance\subsecno by 1
6286 \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
6287 }
6288
6289 % normally calls appendixsubseczzz:
6290 \outer\parseargdef\appendixsubsec{\apphead2{#1}}
6291 \def\appendixsubseczzz#1{%
6292 \global\subsubsecno=0 \global\advance\subsecno by 1
6293 \sectionheading{#1}{subsec}{Yappendix}%
6294 {\appendixletter.\the\secno.\the\subsecno}%
6295 }
6296
6297 % normally calls unnumberedsubseczzz:
6298 \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
6299 \def\unnumberedsubseczzz#1{%
6300 \global\subsubsecno=0 \global\advance\subsecno by 1
6301 \sectionheading{#1}{subsec}{Ynothing}%
6302 {\the\unnumberedno.\the\secno.\the\subsecno}%
6303 }
6304
6305 % Subsubsections.
6306 %
6307 % normally numberedsubsubseczzz:
6308 \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
6309 \def\numberedsubsubseczzz#1{%
6310 \global\advance\subsubsecno by 1
6311 \sectionheading{#1}{subsubsec}{Ynumbered}%
6312 {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
6313 }
6314
6315 % normally appendixsubsubseczzz:
6316 \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
6317 \def\appendixsubsubseczzz#1{%
6318 \global\advance\subsubsecno by 1
6319 \sectionheading{#1}{subsubsec}{Yappendix}%
6320 {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
6321 }
6322
6323 % normally unnumberedsubsubseczzz:
6324 \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
6325 \def\unnumberedsubsubseczzz#1{%
6326 \global\advance\subsubsecno by 1
6327 \sectionheading{#1}{subsubsec}{Ynothing}%
6328 {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
6329 }
6330
6331 % These macros control what the section commands do, according
6332 % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6333 % Define them by default for a numbered chapter.
6334 \let\section = \numberedsec
6335 \let\subsection = \numberedsubsec
6336 \let\subsubsection = \numberedsubsubsec
6337
6338 % Define @majorheading, @heading and @subheading
6339
6340 \def\majorheading{%
6341 {\advance\chapheadingskip by 10pt \chapbreak }%
6342 \parsearg\chapheadingzzz
6343 }
6344
6345 \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6346 \def\chapheadingzzz#1{%
6347 \vbox{\chapfonts \raggedtitlesettings #1\par}%
6348 \nobreak\bigskip \nobreak
6349 \suppressfirstparagraphindent
6350 }
6351
6352 % @heading, @subheading, @subsubheading.
6353 \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6354 \suppressfirstparagraphindent}
6355 \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6356 \suppressfirstparagraphindent}
6357 \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6358 \suppressfirstparagraphindent}
6359
6360 % These macros generate a chapter, section, etc. heading only
6361 % (including whitespace, linebreaking, etc. around it),
6362 % given all the information in convenient, parsed form.
6363
6364 % Args are the skip and penalty (usually negative)
6365 \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6366
6367 % Parameter controlling skip before chapter headings (if needed)
6368 \newskip\chapheadingskip
6369
6370 % Define plain chapter starts, and page on/off switching for it.
6371 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
6372
6373 % Start a new page
6374 \def\chappager{\par\vfill\supereject}
6375
6376 % \chapoddpage - start on an odd page for a new chapter
6377 % Because \domark is called before \chapoddpage, the filler page will
6378 % get the headings for the next chapter, which is wrong. But we don't
6379 % care -- we just disable all headings on the filler page.
6380 \def\chapoddpage{%
6381 \chappager
6382 \ifodd\pageno \else
6383 \begingroup
6384 \headingsoff
6385 \null
6386 \chappager
6387 \endgroup
6388 \fi
6389 }
6390
6391 \parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
6392
6393 \def\CHAPPAGoff{%
6394 \global\let\contentsalignmacro = \chappager
6395 \global\let\pchapsepmacro=\chapbreak
6396 \global\let\pagealignmacro=\chappager}
6397
6398 \def\CHAPPAGon{%
6399 \global\let\contentsalignmacro = \chappager
6400 \global\let\pchapsepmacro=\chappager
6401 \global\let\pagealignmacro=\chappager
6402 \global\def\HEADINGSon{\HEADINGSsingle}}
6403
6404 \def\CHAPPAGodd{%
6405 \global\let\contentsalignmacro = \chapoddpage
6406 \global\let\pchapsepmacro=\chapoddpage
6407 \global\let\pagealignmacro=\chapoddpage
6408 \global\def\HEADINGSon{\HEADINGSdouble}}
6409
6410 \CHAPPAGon
6411
6412 % \chapmacro - Chapter opening.
6413 %
6414 % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6415 % Yappendix, Yomitfromtoc), #3 the chapter number.
6416 % Not used for @heading series.
6417 %
6418 % To test against our argument.
6419 \def\Ynothingkeyword{Ynothing}
6420 \def\Yappendixkeyword{Yappendix}
6421 \def\Yomitfromtockeyword{Yomitfromtoc}
6422 %
6423 \def\chapmacro#1#2#3{%
6424 \expandafter\ifx\thisenv\titlepage\else
6425 \checkenv{}% chapters, etc., should not start inside an environment.
6426 \fi
6427 % FIXME: \chapmacro is currently called from inside \titlepage when
6428 % \setcontentsaftertitlepage to print the "Table of Contents" heading, but
6429 % this should probably be done by \sectionheading with an option to print
6430 % in chapter size.
6431 %
6432 % Insert the first mark before the heading break (see notes for \domark).
6433 \let\prevchapterdefs=\lastchapterdefs
6434 \let\prevsectiondefs=\lastsectiondefs
6435 \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6436 \gdef\thissection{}}%
6437 %
6438 \def\temptype{#2}%
6439 \ifx\temptype\Ynothingkeyword
6440 \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6441 \gdef\thischapter{\thischaptername}}%
6442 \else\ifx\temptype\Yomitfromtockeyword
6443 \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6444 \gdef\thischapter{}}%
6445 \else\ifx\temptype\Yappendixkeyword
6446 \toks0={#1}%
6447 \xdef\lastchapterdefs{%
6448 \gdef\noexpand\thischaptername{\the\toks0}%
6449 \gdef\noexpand\thischapternum{\appendixletter}%
6450 % \noexpand\putwordAppendix avoids expanding indigestible
6451 % commands in some of the translations.
6452 \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
6453 \noexpand\thischapternum:
6454 \noexpand\thischaptername}%
6455 }%
6456 \else
6457 \toks0={#1}%
6458 \xdef\lastchapterdefs{%
6459 \gdef\noexpand\thischaptername{\the\toks0}%
6460 \gdef\noexpand\thischapternum{\the\chapno}%
6461 % \noexpand\putwordChapter avoids expanding indigestible
6462 % commands in some of the translations.
6463 \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
6464 \noexpand\thischapternum:
6465 \noexpand\thischaptername}%
6466 }%
6467 \fi\fi\fi
6468 %
6469 % Output the mark. Pass it through \safewhatsit, to take care of
6470 % the preceding space.
6471 \safewhatsit\domark
6472 %
6473 % Insert the chapter heading break.
6474 \pchapsepmacro
6475 %
6476 % Now the second mark, after the heading break. No break points
6477 % between here and the heading.
6478 \let\prevchapterdefs=\lastchapterdefs
6479 \let\prevsectiondefs=\lastsectiondefs
6480 \domark
6481 %
6482 {%
6483 \chapfonts \rmisbold
6484 \let\footnote=\errfootnoteheading % give better error message
6485 %
6486 % Have to define \lastsection before calling \donoderef, because the
6487 % xref code eventually uses it. On the other hand, it has to be called
6488 % after \pchapsepmacro, or the headline will change too soon.
6489 \gdef\lastsection{#1}%
6490 %
6491 % Only insert the separating space if we have a chapter/appendix
6492 % number, and don't print the unnumbered ``number''.
6493 \ifx\temptype\Ynothingkeyword
6494 \setbox0 = \hbox{}%
6495 \def\toctype{unnchap}%
6496 \else\ifx\temptype\Yomitfromtockeyword
6497 \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6498 \def\toctype{omit}%
6499 \else\ifx\temptype\Yappendixkeyword
6500 \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6501 \def\toctype{app}%
6502 \else
6503 \setbox0 = \hbox{#3\enspace}%
6504 \def\toctype{numchap}%
6505 \fi\fi\fi
6506 %
6507 % Write the toc entry for this chapter. Must come before the
6508 % \donoderef, because we include the current node name in the toc
6509 % entry, and \donoderef resets it to empty.
6510 \writetocentry{\toctype}{#1}{#3}%
6511 %
6512 % For pdftex, we have to write out the node definition (aka, make
6513 % the pdfdest) after any page break, but before the actual text has
6514 % been typeset. If the destination for the pdf outline is after the
6515 % text, then jumping from the outline may wind up with the text not
6516 % being visible, for instance under high magnification.
6517 \donoderef{#2}%
6518 %
6519 % Typeset the actual heading.
6520 \nobreak % Avoid page breaks at the interline glue.
6521 \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
6522 \unhbox0 #1\par}%
6523 }%
6524 \nobreak\bigskip % no page break after a chapter title
6525 \nobreak
6526 }
6527
6528 % @centerchap -- centered and unnumbered.
6529 \let\centerparametersmaybe = \relax
6530 \def\centerparameters{%
6531 \advance\rightskip by 3\rightskip
6532 \leftskip = \rightskip
6533 \parfillskip = 0pt
6534 }
6535
6536
6537 % Section titles. These macros combine the section number parts and
6538 % call the generic \sectionheading to do the printing.
6539 %
6540 \newskip\secheadingskip
6541 \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
6542
6543 % Subsection titles.
6544 \newskip\subsecheadingskip
6545 \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
6546
6547 % Subsubsection titles.
6548 \def\subsubsecheadingskip{\subsecheadingskip}
6549 \def\subsubsecheadingbreak{\subsecheadingbreak}
6550
6551
6552 % Print any size, any type, section title.
6553 %
6554 % #1 is the text of the title,
6555 % #2 is the section level (sec/subsec/subsubsec),
6556 % #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6557 % #4 is the section number.
6558 %
6559 \def\seckeyword{sec}
6560 %
6561 \def\sectionheading#1#2#3#4{%
6562 {%
6563 \def\sectionlevel{#2}%
6564 \def\temptype{#3}%
6565 %
6566 % It is ok for the @heading series commands to appear inside an
6567 % environment (it's been historically allowed, though the logic is
6568 % dubious), but not the others.
6569 \ifx\temptype\Yomitfromtockeyword\else
6570 \checkenv{}% non-@*heading should not be in an environment.
6571 \fi
6572 \let\footnote=\errfootnoteheading
6573 %
6574 % Switch to the right set of fonts.
6575 \csname #2fonts\endcsname \rmisbold
6576 %
6577 % Insert first mark before the heading break (see notes for \domark).
6578 \let\prevsectiondefs=\lastsectiondefs
6579 \ifx\temptype\Ynothingkeyword
6580 \ifx\sectionlevel\seckeyword
6581 \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6582 \gdef\thissection{\thissectionname}}%
6583 \fi
6584 \else\ifx\temptype\Yomitfromtockeyword
6585 % Don't redefine \thissection.
6586 \else\ifx\temptype\Yappendixkeyword
6587 \ifx\sectionlevel\seckeyword
6588 \toks0={#1}%
6589 \xdef\lastsectiondefs{%
6590 \gdef\noexpand\thissectionname{\the\toks0}%
6591 \gdef\noexpand\thissectionnum{#4}%
6592 % \noexpand\putwordSection avoids expanding indigestible
6593 % commands in some of the translations.
6594 \gdef\noexpand\thissection{\noexpand\putwordSection{}
6595 \noexpand\thissectionnum:
6596 \noexpand\thissectionname}%
6597 }%
6598 \fi
6599 \else
6600 \ifx\sectionlevel\seckeyword
6601 \toks0={#1}%
6602 \xdef\lastsectiondefs{%
6603 \gdef\noexpand\thissectionname{\the\toks0}%
6604 \gdef\noexpand\thissectionnum{#4}%
6605 % \noexpand\putwordSection avoids expanding indigestible
6606 % commands in some of the translations.
6607 \gdef\noexpand\thissection{\noexpand\putwordSection{}
6608 \noexpand\thissectionnum:
6609 \noexpand\thissectionname}%
6610 }%
6611 \fi
6612 \fi\fi\fi
6613 %
6614 % Go into vertical mode. Usually we'll already be there, but we
6615 % don't want the following whatsit to end up in a preceding paragraph
6616 % if the document didn't happen to have a blank line.
6617 \par
6618 %
6619 % Output the mark. Pass it through \safewhatsit, to take care of
6620 % the preceding space.
6621 \safewhatsit\domark
6622 %
6623 % Insert space above the heading.
6624 \csname #2headingbreak\endcsname
6625 %
6626 % Now the second mark, after the heading break. No break points
6627 % between here and the heading.
6628 \global\let\prevsectiondefs=\lastsectiondefs
6629 \domark
6630 %
6631 % Only insert the space after the number if we have a section number.
6632 \ifx\temptype\Ynothingkeyword
6633 \setbox0 = \hbox{}%
6634 \def\toctype{unn}%
6635 \gdef\lastsection{#1}%
6636 \else\ifx\temptype\Yomitfromtockeyword
6637 % for @headings -- no section number, don't include in toc,
6638 % and don't redefine \lastsection.
6639 \setbox0 = \hbox{}%
6640 \def\toctype{omit}%
6641 \let\sectionlevel=\empty
6642 \else\ifx\temptype\Yappendixkeyword
6643 \setbox0 = \hbox{#4\enspace}%
6644 \def\toctype{app}%
6645 \gdef\lastsection{#1}%
6646 \else
6647 \setbox0 = \hbox{#4\enspace}%
6648 \def\toctype{num}%
6649 \gdef\lastsection{#1}%
6650 \fi\fi\fi
6651 %
6652 % Write the toc entry (before \donoderef). See comments in \chapmacro.
6653 \writetocentry{\toctype\sectionlevel}{#1}{#4}%
6654 %
6655 % Write the node reference (= pdf destination for pdftex).
6656 % Again, see comments in \chapmacro.
6657 \donoderef{#3}%
6658 %
6659 % Interline glue will be inserted when the vbox is completed.
6660 % That glue will be a valid breakpoint for the page, since it'll be
6661 % preceded by a whatsit (usually from the \donoderef, or from the
6662 % \writetocentry if there was no node). We don't want to allow that
6663 % break, since then the whatsits could end up on page n while the
6664 % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000.
6665 \nobreak
6666 %
6667 % Output the actual section heading.
6668 \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
6669 \hangindent=\wd0 % zero if no section number
6670 \unhbox0 #1}%
6671 }%
6672 % Add extra space after the heading -- half of whatever came above it.
6673 % Don't allow stretch, though.
6674 \kern .5 \csname #2headingskip\endcsname
6675 %
6676 % Do not let the kern be a potential breakpoint, as it would be if it
6677 % was followed by glue.
6678 \nobreak
6679 %
6680 % We'll almost certainly start a paragraph next, so don't let that
6681 % glue accumulate. (Not a breakpoint because it's preceded by a
6682 % discardable item.) However, when a paragraph is not started next
6683 % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6684 % or the negative glue will cause weirdly wrong output, typically
6685 % obscuring the section heading with something else.
6686 \vskip-\parskip
6687 %
6688 % This is so the last item on the main vertical list is a known
6689 % \penalty > 10000, so \startdefun, etc., can recognize the situation
6690 % and do the needful.
6691 \penalty 10001
6692 }
6693
6694
6695 \message{toc,}
6696 % Table of contents.
6697 \newwrite\tocfile
6698
6699 % Write an entry to the toc file, opening it if necessary.
6700 % Called from @chapter, etc.
6701 %
6702 % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6703 % We append the current node name (if any) and page number as additional
6704 % arguments for the \{chap,sec,...}entry macros which will eventually
6705 % read this. The node name is used in the pdf outlines as the
6706 % destination to jump to.
6707 %
6708 % We open the .toc file for writing here instead of at @setfilename (or
6709 % any other fixed time) so that @contents can be anywhere in the document.
6710 % But if #1 is `omit', then we don't do anything. This is used for the
6711 % table of contents chapter openings themselves.
6712 %
6713 \newif\iftocfileopened
6714 \def\omitkeyword{omit}%
6715 %
6716 \def\writetocentry#1#2#3{%
6717 \edef\writetoctype{#1}%
6718 \ifx\writetoctype\omitkeyword \else
6719 \iftocfileopened\else
6720 \immediate\openout\tocfile = \jobname.toc
6721 \global\tocfileopenedtrue
6722 \fi
6723 %
6724 \iflinks
6725 {\atdummies
6726 \edef\temp{%
6727 \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6728 \temp
6729 }%
6730 \fi
6731 \fi
6732 %
6733 % Tell \shipout to create a pdf destination on each page, if we're
6734 % writing pdf. These are used in the table of contents. We can't
6735 % just write one on every page because the title pages are numbered
6736 % 1 and 2 (the page numbers aren't printed), and so are the first
6737 % two pages of the document. Thus, we'd have two destinations named
6738 % `1', and two named `2'.
6739 \ifpdf
6740 \global\pdfmakepagedesttrue
6741 \else
6742 \ifx\XeTeXrevision\thisisundefined
6743 \else
6744 \global\pdfmakepagedesttrue
6745 \fi
6746 \fi
6747 }
6748
6749
6750 % These characters do not print properly in the Computer Modern roman
6751 % fonts, so we must take special care. This is more or less redundant
6752 % with the Texinfo input format setup at the end of this file.
6753 %
6754 \def\activecatcodes{%
6755 \catcode`\"=\active
6756 \catcode`\$=\active
6757 \catcode`\<=\active
6758 \catcode`\>=\active
6759 \catcode`\\=\active
6760 \catcode`\^=\active
6761 \catcode`\_=\active
6762 \catcode`\|=\active
6763 \catcode`\~=\active
6764 }
6765
6766
6767 % Read the toc file, which is essentially Texinfo input.
6768 \def\readtocfile{%
6769 \setupdatafile
6770 \activecatcodes
6771 \input \tocreadfilename
6772 }
6773
6774 \newskip\contentsrightmargin \contentsrightmargin=1in
6775 \newcount\savepageno
6776 \newcount\lastnegativepageno \lastnegativepageno = -1
6777
6778 % Prepare to read what we've written to \tocfile.
6779 %
6780 \def\startcontents#1{%
6781 % If @setchapternewpage on, and @headings double, the contents should
6782 % start on an odd page, unlike chapters. Thus, we maintain
6783 % \contentsalignmacro in parallel with \pagealignmacro.
6784 % From: Torbjorn Granlund <tege@matematik.su.se>
6785 \contentsalignmacro
6786 \immediate\closeout\tocfile
6787 %
6788 % Don't need to put `Contents' or `Short Contents' in the headline.
6789 % It is abundantly clear what they are.
6790 \chapmacro{#1}{Yomitfromtoc}{}%
6791 %
6792 \savepageno = \pageno
6793 \begingroup % Set up to handle contents files properly.
6794 \raggedbottom % Worry more about breakpoints than the bottom.
6795 \entryrightmargin=\contentsrightmargin % Don't use the full line length.
6796 %
6797 % Roman numerals for page numbers.
6798 \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
6799 }
6800
6801 % redefined for the two-volume lispref. We always output on
6802 % \jobname.toc even if this is redefined.
6803 %
6804 \def\tocreadfilename{\jobname.toc}
6805
6806 % Normal (long) toc.
6807 %
6808 \def\contents{%
6809 \startcontents{\putwordTOC}%
6810 \openin 1 \tocreadfilename\space
6811 \ifeof 1 \else
6812 \readtocfile
6813 \fi
6814 \vfill \eject
6815 \contentsalignmacro % in case @setchapternewpage odd is in effect
6816 \ifeof 1 \else
6817 \pdfmakeoutlines
6818 \fi
6819 \closein 1
6820 \endgroup
6821 \lastnegativepageno = \pageno
6822 \global\pageno = \savepageno
6823 }
6824
6825 % And just the chapters.
6826 \def\summarycontents{%
6827 \startcontents{\putwordShortTOC}%
6828 %
6829 \let\partentry = \shortpartentry
6830 \let\numchapentry = \shortchapentry
6831 \let\appentry = \shortchapentry
6832 \let\unnchapentry = \shortunnchapentry
6833 % We want a true roman here for the page numbers.
6834 \secfonts
6835 \let\rm=\shortcontrm \let\bf=\shortcontbf
6836 \let\sl=\shortcontsl \let\tt=\shortconttt
6837 \rm
6838 \hyphenpenalty = 10000
6839 \advance\baselineskip by 1pt % Open it up a little.
6840 \def\numsecentry##1##2##3##4{}
6841 \let\appsecentry = \numsecentry
6842 \let\unnsecentry = \numsecentry
6843 \let\numsubsecentry = \numsecentry
6844 \let\appsubsecentry = \numsecentry
6845 \let\unnsubsecentry = \numsecentry
6846 \let\numsubsubsecentry = \numsecentry
6847 \let\appsubsubsecentry = \numsecentry
6848 \let\unnsubsubsecentry = \numsecentry
6849 \openin 1 \tocreadfilename\space
6850 \ifeof 1 \else
6851 \readtocfile
6852 \fi
6853 \closein 1
6854 \vfill \eject
6855 \contentsalignmacro % in case @setchapternewpage odd is in effect
6856 \endgroup
6857 \lastnegativepageno = \pageno
6858 \global\pageno = \savepageno
6859 }
6860 \let\shortcontents = \summarycontents
6861
6862 % Typeset the label for a chapter or appendix for the short contents.
6863 % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6864 %
6865 \def\shortchaplabel#1{%
6866 % This space should be enough, since a single number is .5em, and the
6867 % widest letter (M) is 1em, at least in the Computer Modern fonts.
6868 % But use \hss just in case.
6869 % (This space doesn't include the extra space that gets added after
6870 % the label; that gets put in by \shortchapentry above.)
6871 %
6872 % We'd like to right-justify chapter numbers, but that looks strange
6873 % with appendix letters. And right-justifying numbers and
6874 % left-justifying letters looks strange when there is less than 10
6875 % chapters. Have to read the whole toc once to know how many chapters
6876 % there are before deciding ...
6877 \hbox to 1em{#1\hss}%
6878 }
6879
6880 % These macros generate individual entries in the table of contents.
6881 % The first argument is the chapter or section name.
6882 % The last argument is the page number.
6883 % The arguments in between are the chapter number, section number, ...
6884
6885 % Parts, in the main contents. Replace the part number, which doesn't
6886 % exist, with an empty box. Let's hope all the numbers have the same width.
6887 % Also ignore the page number, which is conventionally not printed.
6888 \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6889 \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}}
6890 %
6891 % Parts, in the short toc.
6892 \def\shortpartentry#1#2#3#4{%
6893 \penalty-300
6894 \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
6895 \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
6896 }
6897
6898 % Chapters, in the main contents.
6899 \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
6900
6901 % Chapters, in the short toc.
6902 % See comments in \dochapentry re vbox and related settings.
6903 \def\shortchapentry#1#2#3#4{%
6904 \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
6905 }
6906
6907 % Appendices, in the main contents.
6908 % Need the word Appendix, and a fixed-size box.
6909 %
6910 \def\appendixbox#1{%
6911 % We use M since it's probably the widest letter.
6912 \setbox0 = \hbox{\putwordAppendix{} M}%
6913 \hbox to \wd0{\putwordAppendix{} #1\hss}}
6914 %
6915 \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
6916
6917 % Unnumbered chapters.
6918 \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
6919 \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
6920
6921 % Sections.
6922 \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
6923 \let\appsecentry=\numsecentry
6924 \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
6925
6926 % Subsections.
6927 \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
6928 \let\appsubsecentry=\numsubsecentry
6929 \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
6930
6931 % And subsubsections.
6932 \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
6933 \let\appsubsubsecentry=\numsubsubsecentry
6934 \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
6935
6936 % This parameter controls the indentation of the various levels.
6937 % Same as \defaultparindent.
6938 \newdimen\tocindent \tocindent = 15pt
6939
6940 % Now for the actual typesetting. In all these, #1 is the text and #2 is the
6941 % page number.
6942 %
6943 % If the toc has to be broken over pages, we want it to be at chapters
6944 % if at all possible; hence the \penalty.
6945 \def\dochapentry#1#2{%
6946 \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
6947 \begingroup
6948 % Move the page numbers slightly to the right
6949 \advance\entryrightmargin by -0.05em
6950 \chapentryfonts
6951 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6952 \endgroup
6953 \nobreak\vskip .25\baselineskip plus.1\baselineskip
6954 }
6955
6956 \def\dosecentry#1#2{\begingroup
6957 \secentryfonts \leftskip=\tocindent
6958 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6959 \endgroup}
6960
6961 \def\dosubsecentry#1#2{\begingroup
6962 \subsecentryfonts \leftskip=2\tocindent
6963 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6964 \endgroup}
6965
6966 \def\dosubsubsecentry#1#2{\begingroup
6967 \subsubsecentryfonts \leftskip=3\tocindent
6968 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6969 \endgroup}
6970
6971 % We use the same \entry macro as for the index entries.
6972 \let\tocentry = \entry
6973
6974 % Space between chapter (or whatever) number and the title.
6975 \def\labelspace{\hskip1em \relax}
6976
6977 \def\dopageno#1{{\rm #1}}
6978 \def\doshortpageno#1{{\rm #1}}
6979
6980 \def\chapentryfonts{\secfonts \rm}
6981 \def\secentryfonts{\textfonts}
6982 \def\subsecentryfonts{\textfonts}
6983 \def\subsubsecentryfonts{\textfonts}
6984
6985
6986 \message{environments,}
6987 % @foo ... @end foo.
6988
6989 % @tex ... @end tex escapes into raw TeX temporarily.
6990 % One exception: @ is still an escape character, so that @end tex works.
6991 % But \@ or @@ will get a plain @ character.
6992
6993 \envdef\tex{%
6994 \setupmarkupstyle{tex}%
6995 \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
6996 \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
6997 \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
6998 \catcode `\%=14
6999 \catcode `\+=\other
7000 \catcode `\"=\other
7001 \catcode `\|=\other
7002 \catcode `\<=\other
7003 \catcode `\>=\other
7004 \catcode `\`=\other
7005 \catcode `\'=\other
7006 %
7007 % ' is active in math mode (mathcode"8000). So reset it, and all our
7008 % other math active characters (just in case), to plain's definitions.
7009 \mathactive
7010 %
7011 % Inverse of the list at the beginning of the file.
7012 \let\b=\ptexb
7013 \let\bullet=\ptexbullet
7014 \let\c=\ptexc
7015 \let\,=\ptexcomma
7016 \let\.=\ptexdot
7017 \let\dots=\ptexdots
7018 \let\equiv=\ptexequiv
7019 \let\!=\ptexexclam
7020 \let\i=\ptexi
7021 \let\indent=\ptexindent
7022 \let\noindent=\ptexnoindent
7023 \let\{=\ptexlbrace
7024 \let\+=\tabalign
7025 \let\}=\ptexrbrace
7026 \let\/=\ptexslash
7027 \let\sp=\ptexsp
7028 \let\*=\ptexstar
7029 %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
7030 \let\t=\ptext
7031 \expandafter \let\csname top\endcsname=\ptextop % we've made it outer
7032 \let\frenchspacing=\plainfrenchspacing
7033 %
7034 \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
7035 \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
7036 \def\@{@}%
7037 }
7038 % There is no need to define \Etex.
7039
7040 % Define @lisp ... @end lisp.
7041 % @lisp environment forms a group so it can rebind things,
7042 % including the definition of @end lisp (which normally is erroneous).
7043
7044 % Amount to narrow the margins by for @lisp.
7045 \newskip\lispnarrowing \lispnarrowing=0.4in
7046
7047 % This is the definition that ^^M gets inside @lisp, @example, and other
7048 % such environments. \null is better than a space, since it doesn't
7049 % have any width.
7050 \def\lisppar{\null\endgraf}
7051
7052 % This space is always present above and below environments.
7053 \newskip\envskipamount \envskipamount = 0pt
7054
7055 % Make spacing and below environment symmetrical. We use \parskip here
7056 % to help in doing that, since in @example-like environments \parskip
7057 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
7058 % start of the next paragraph will insert \parskip.
7059 %
7060 \def\aboveenvbreak{{%
7061 % =10000 instead of <10000 because of a special case in \itemzzz and
7062 % \sectionheading, q.v.
7063 \ifnum \lastpenalty=10000 \else
7064 \advance\envskipamount by \parskip
7065 \endgraf
7066 \ifdim\lastskip<\envskipamount
7067 \removelastskip
7068 \ifnum\lastpenalty<10000
7069 % Penalize breaking before the environment, because preceding text
7070 % often leads into it.
7071 \penalty100
7072 \fi
7073 \vskip\envskipamount
7074 \fi
7075 \fi
7076 }}
7077
7078 \def\afterenvbreak{{%
7079 % =10000 instead of <10000 because of a special case in \itemzzz and
7080 % \sectionheading, q.v.
7081 \ifnum \lastpenalty=10000 \else
7082 \advance\envskipamount by \parskip
7083 \endgraf
7084 \ifdim\lastskip<\envskipamount
7085 \removelastskip
7086 % it's not a good place to break if the last penalty was \nobreak
7087 % or better ...
7088 \ifnum\lastpenalty<10000 \penalty-50 \fi
7089 \vskip\envskipamount
7090 \fi
7091 \fi
7092 }}
7093
7094 % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will
7095 % also clear it, so that its embedded environments do the narrowing again.
7096 \let\nonarrowing=\relax
7097
7098 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
7099 % environment contents.
7100 \font\circle=lcircle10
7101 \newdimen\circthick
7102 \newdimen\cartouter\newdimen\cartinner
7103 \newskip\normbskip\newskip\normpskip\newskip\normlskip
7104 \circthick=\fontdimen8\circle
7105 %
7106 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
7107 \def\ctr{{\hskip 6pt\circle\char'010}}
7108 \def\cbl{{\circle\char'012\hskip -6pt}}
7109 \def\cbr{{\hskip 6pt\circle\char'011}}
7110 \def\carttop{\hbox to \cartouter{\hskip\lskip
7111 \ctl\leaders\hrule height\circthick\hfil\ctr
7112 \hskip\rskip}}
7113 \def\cartbot{\hbox to \cartouter{\hskip\lskip
7114 \cbl\leaders\hrule height\circthick\hfil\cbr
7115 \hskip\rskip}}
7116 %
7117 \newskip\lskip\newskip\rskip
7118
7119 \envdef\cartouche{%
7120 \ifhmode\par\fi % can't be in the midst of a paragraph.
7121 \startsavinginserts
7122 \lskip=\leftskip \rskip=\rightskip
7123 \leftskip=0pt\rightskip=0pt % we want these *outside*.
7124 \cartinner=\hsize \advance\cartinner by-\lskip
7125 \advance\cartinner by-\rskip
7126 \cartouter=\hsize
7127 \advance\cartouter by 18.4pt % allow for 3pt kerns on either
7128 % side, and for 6pt waste from
7129 % each corner char, and rule thickness
7130 \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
7131 %
7132 % If this cartouche directly follows a sectioning command, we need the
7133 % \parskip glue (backspaced over by default) or the cartouche can
7134 % collide with the section heading.
7135 \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
7136 %
7137 \setbox\groupbox=\vbox\bgroup
7138 \baselineskip=0pt\parskip=0pt\lineskip=0pt
7139 \carttop
7140 \hbox\bgroup
7141 \hskip\lskip
7142 \vrule\kern3pt
7143 \vbox\bgroup
7144 \kern3pt
7145 \hsize=\cartinner
7146 \baselineskip=\normbskip
7147 \lineskip=\normlskip
7148 \parskip=\normpskip
7149 \vskip -\parskip
7150 \comment % For explanation, see the end of def\group.
7151 }
7152 \def\Ecartouche{%
7153 \ifhmode\par\fi
7154 \kern3pt
7155 \egroup
7156 \kern3pt\vrule
7157 \hskip\rskip
7158 \egroup
7159 \cartbot
7160 \egroup
7161 \addgroupbox
7162 \checkinserts
7163 }
7164
7165
7166 % This macro is called at the beginning of all the @example variants,
7167 % inside a group.
7168 \newdimen\nonfillparindent
7169 \def\nonfillstart{%
7170 \aboveenvbreak
7171 \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
7172 \sepspaces % Make spaces be word-separators rather than space tokens.
7173 \let\par = \lisppar % don't ignore blank lines
7174 \obeylines % each line of input is a line of output
7175 \parskip = 0pt
7176 % Turn off paragraph indentation but redefine \indent to emulate
7177 % the normal \indent.
7178 \nonfillparindent=\parindent
7179 \parindent = 0pt
7180 \let\indent\nonfillindent
7181 %
7182 \emergencystretch = 0pt % don't try to avoid overfull boxes
7183 \ifx\nonarrowing\relax
7184 \advance \leftskip by \lispnarrowing
7185 \exdentamount=\lispnarrowing
7186 \else
7187 \let\nonarrowing = \relax
7188 \fi
7189 \let\exdent=\nofillexdent
7190 }
7191
7192 \begingroup
7193 \obeyspaces
7194 % We want to swallow spaces (but not other tokens) after the fake
7195 % @indent in our nonfill-environments, where spaces are normally
7196 % active and set to @tie, resulting in them not being ignored after
7197 % @indent.
7198 \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
7199 \gdef\nonfillindentcheck{%
7200 \ifx\temp %
7201 \expandafter\nonfillindentgobble%
7202 \else%
7203 \leavevmode\nonfillindentbox%
7204 \fi%
7205 }%
7206 \endgroup
7207 \def\nonfillindentgobble#1{\nonfillindent}
7208 \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7209
7210 % If you want all examples etc. small: @set dispenvsize small.
7211 % If you want even small examples the full size: @set dispenvsize nosmall.
7212 % This affects the following displayed environments:
7213 % @example, @display, @format, @lisp
7214 %
7215 \def\smallword{small}
7216 \def\nosmallword{nosmall}
7217 \let\SETdispenvsize\relax
7218 \def\setnormaldispenv{%
7219 \ifx\SETdispenvsize\smallword
7220 % end paragraph for sake of leading, in case document has no blank
7221 % line. This is redundant with what happens in \aboveenvbreak, but
7222 % we need to do it before changing the fonts, and it's inconvenient
7223 % to change the fonts afterward.
7224 \ifnum \lastpenalty=10000 \else \endgraf \fi
7225 \smallexamplefonts \rm
7226 \fi
7227 }
7228 \def\setsmalldispenv{%
7229 \ifx\SETdispenvsize\nosmallword
7230 \else
7231 \ifnum \lastpenalty=10000 \else \endgraf \fi
7232 \smallexamplefonts \rm
7233 \fi
7234 }
7235
7236 % We often define two environments, @foo and @smallfoo.
7237 % Let's do it in one command. #1 is the env name, #2 the definition.
7238 \def\makedispenvdef#1#2{%
7239 \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7240 \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
7241 \expandafter\let\csname E#1\endcsname \afterenvbreak
7242 \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
7243 }
7244
7245 % Define two environment synonyms (#1 and #2) for an environment.
7246 \def\maketwodispenvdef#1#2#3{%
7247 \makedispenvdef{#1}{#3}%
7248 \makedispenvdef{#2}{#3}%
7249 }
7250 %
7251 % @lisp: indented, narrowed, typewriter font;
7252 % @example: same as @lisp.
7253 %
7254 % @smallexample and @smalllisp: use smaller fonts.
7255 % Originally contributed by Pavel@xerox.
7256 %
7257 \maketwodispenvdef{lisp}{example}{%
7258 \nonfillstart
7259 \tt\setupmarkupstyle{example}%
7260 \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
7261 \gobble % eat return
7262 }
7263 % @display/@smalldisplay: same as @lisp except keep current font.
7264 %
7265 \makedispenvdef{display}{%
7266 \nonfillstart
7267 \gobble
7268 }
7269
7270 % @format/@smallformat: same as @display except don't narrow margins.
7271 %
7272 \makedispenvdef{format}{%
7273 \let\nonarrowing = t%
7274 \nonfillstart
7275 \gobble
7276 }
7277
7278 % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7279 \envdef\flushleft{%
7280 \let\nonarrowing = t%
7281 \nonfillstart
7282 \gobble
7283 }
7284 \let\Eflushleft = \afterenvbreak
7285
7286 % @flushright.
7287 %
7288 \envdef\flushright{%
7289 \let\nonarrowing = t%
7290 \nonfillstart
7291 \advance\leftskip by 0pt plus 1fill\relax
7292 \gobble
7293 }
7294 \let\Eflushright = \afterenvbreak
7295
7296
7297 % @raggedright does more-or-less normal line breaking but no right
7298 % justification. From plain.tex. Don't stretch around special
7299 % characters in urls in this environment, since the stretch at the right
7300 % should be enough.
7301 \envdef\raggedright{%
7302 \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7303 \def\urefprestretchamount{0pt}%
7304 \def\urefpoststretchamount{0pt}%
7305 }
7306 \let\Eraggedright\par
7307
7308 \envdef\raggedleft{%
7309 \parindent=0pt \leftskip0pt plus2em
7310 \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7311 \hbadness=10000 % Last line will usually be underfull, so turn off
7312 % badness reporting.
7313 }
7314 \let\Eraggedleft\par
7315
7316 \envdef\raggedcenter{%
7317 \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
7318 \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7319 \hbadness=10000 % Last line will usually be underfull, so turn off
7320 % badness reporting.
7321 }
7322 \let\Eraggedcenter\par
7323
7324
7325 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
7326 % and narrows the margins. We keep \parskip nonzero in general, since
7327 % we're doing normal filling. So, when using \aboveenvbreak and
7328 % \afterenvbreak, temporarily make \parskip 0.
7329 %
7330 \makedispenvdef{quotation}{\quotationstart}
7331 %
7332 \def\quotationstart{%
7333 \indentedblockstart % same as \indentedblock, but increase right margin too.
7334 \ifx\nonarrowing\relax
7335 \advance\rightskip by \lispnarrowing
7336 \fi
7337 \parsearg\quotationlabel
7338 }
7339
7340 % We have retained a nonzero parskip for the environment, since we're
7341 % doing normal filling.
7342 %
7343 \def\Equotation{%
7344 \par
7345 \ifx\quotationauthor\thisisundefined\else
7346 % indent a bit.
7347 \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7348 \fi
7349 {\parskip=0pt \afterenvbreak}%
7350 }
7351 \def\Esmallquotation{\Equotation}
7352
7353 % If we're given an argument, typeset it in bold with a colon after.
7354 \def\quotationlabel#1{%
7355 \def\temp{#1}%
7356 \ifx\temp\empty \else
7357 {\bf #1: }%
7358 \fi
7359 }
7360
7361 % @indentedblock is like @quotation, but indents only on the left and
7362 % has no optional argument.
7363 %
7364 \makedispenvdef{indentedblock}{\indentedblockstart}
7365 %
7366 \def\indentedblockstart{%
7367 {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7368 \parindent=0pt
7369 %
7370 % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7371 \ifx\nonarrowing\relax
7372 \advance\leftskip by \lispnarrowing
7373 \exdentamount = \lispnarrowing
7374 \else
7375 \let\nonarrowing = \relax
7376 \fi
7377 }
7378
7379 % Keep a nonzero parskip for the environment, since we're doing normal filling.
7380 %
7381 \def\Eindentedblock{%
7382 \par
7383 {\parskip=0pt \afterenvbreak}%
7384 }
7385 \def\Esmallindentedblock{\Eindentedblock}
7386
7387
7388 % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7389 % If we want to allow any <char> as delimiter,
7390 % we need the curly braces so that makeinfo sees the @verb command, eg:
7391 % `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org
7392 %
7393 % [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
7394 %
7395 % [Knuth] p.344; only we need to do the other characters Texinfo sets
7396 % active too. Otherwise, they get lost as the first character on a
7397 % verbatim line.
7398 \def\dospecials{%
7399 \do\ \do\\\do\{\do\}\do\$\do\&%
7400 \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7401 \do\<\do\>\do\|\do\@\do+\do\"%
7402 % Don't do the quotes -- if we do, @set txicodequoteundirected and
7403 % @set txicodequotebacktick will not have effect on @verb and
7404 % @verbatim, and ?` and !` ligatures won't get disabled.
7405 %\do\`\do\'%
7406 }
7407 %
7408 % [Knuth] p. 380
7409 \def\uncatcodespecials{%
7410 \def\do##1{\catcode`##1=\other}\dospecials}
7411 %
7412 % Setup for the @verb command.
7413 %
7414 % Eight spaces for a tab
7415 \begingroup
7416 \catcode`\^^I=\active
7417 \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7418 \endgroup
7419 %
7420 \def\setupverb{%
7421 \tt % easiest (and conventionally used) font for verbatim
7422 \def\par{\leavevmode\endgraf}%
7423 \setupmarkupstyle{verb}%
7424 \tabeightspaces
7425 % Respect line breaks,
7426 % print special symbols as themselves, and
7427 % make each space count
7428 % must do in this order:
7429 \obeylines \uncatcodespecials \sepspaces
7430 }
7431
7432 % Setup for the @verbatim environment
7433 %
7434 % Real tab expansion.
7435 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7436 %
7437 % We typeset each line of the verbatim in an \hbox, so we can handle
7438 % tabs. The \global is in case the verbatim line starts with an accent,
7439 % or some other command that starts with a begin-group. Otherwise, the
7440 % entire \verbbox would disappear at the corresponding end-group, before
7441 % it is typeset. Meanwhile, we can't have nested verbatim commands
7442 % (can we?), so the \global won't be overwriting itself.
7443 \newbox\verbbox
7444 \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
7445 %
7446 \begingroup
7447 \catcode`\^^I=\active
7448 \gdef\tabexpand{%
7449 \catcode`\^^I=\active
7450 \def^^I{\leavevmode\egroup
7451 \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7452 \divide\dimen\verbbox by\tabw
7453 \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7454 \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw
7455 \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
7456 }%
7457 }
7458 \endgroup
7459
7460 % start the verbatim environment.
7461 \def\setupverbatim{%
7462 \let\nonarrowing = t%
7463 \nonfillstart
7464 \tt % easiest (and conventionally used) font for verbatim
7465 % The \leavevmode here is for blank lines. Otherwise, we would
7466 % never \starttabox and the \egroup would end verbatim mode.
7467 \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
7468 \tabexpand
7469 \setupmarkupstyle{verbatim}%
7470 % Respect line breaks,
7471 % print special symbols as themselves, and
7472 % make each space count.
7473 % Must do in this order:
7474 \obeylines \uncatcodespecials \sepspaces
7475 \everypar{\starttabbox}%
7476 }
7477
7478 % Do the @verb magic: verbatim text is quoted by unique
7479 % delimiter characters. Before first delimiter expect a
7480 % right brace, after last delimiter expect closing brace:
7481 %
7482 % \def\doverb'{'<char>#1<char>'}'{#1}
7483 %
7484 % [Knuth] p. 382; only eat outer {}
7485 \begingroup
7486 \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
7487 \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7488 \endgroup
7489 %
7490 \def\verb{\begingroup\setupverb\doverb}
7491 %
7492 %
7493 % Do the @verbatim magic: define the macro \doverbatim so that
7494 % the (first) argument ends when '@end verbatim' is reached, ie:
7495 %
7496 % \def\doverbatim#1@end verbatim{#1}
7497 %
7498 % For Texinfo it's a lot easier than for LaTeX,
7499 % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
7500 % we need not redefine '\', '{' and '}'.
7501 %
7502 % Inspired by LaTeX's verbatim command set [latex.ltx]
7503 %
7504 \begingroup
7505 \catcode`\ =\active
7506 \obeylines %
7507 % ignore everything up to the first ^^M, that's the newline at the end
7508 % of the @verbatim input line itself. Otherwise we get an extra blank
7509 % line in the output.
7510 \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
7511 % We really want {...\end verbatim} in the body of the macro, but
7512 % without the active space; thus we have to use \xdef and \gobble.
7513 \endgroup
7514 %
7515 \envdef\verbatim{%
7516 \setupverbatim\doverbatim
7517 }
7518 \let\Everbatim = \afterenvbreak
7519
7520
7521 % @verbatiminclude FILE - insert text of file in verbatim environment.
7522 %
7523 \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
7524 %
7525 \def\doverbatiminclude#1{%
7526 {%
7527 \makevalueexpandable
7528 \setupverbatim
7529 \indexnofonts % Allow `@@' and other weird things in file names.
7530 \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
7531 \input #1
7532 \afterenvbreak
7533 }%
7534 }
7535
7536 % @copying ... @end copying.
7537 % Save the text away for @insertcopying later.
7538 %
7539 % We save the uninterpreted tokens, rather than creating a box.
7540 % Saving the text in a box would be much easier, but then all the
7541 % typesetting commands (@smallbook, font changes, etc.) have to be done
7542 % beforehand -- and a) we want @copying to be done first in the source
7543 % file; b) letting users define the frontmatter in as flexible order as
7544 % possible is desirable.
7545 %
7546 \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
7547 \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
7548 %
7549 \def\insertcopying{%
7550 \begingroup
7551 \parindent = 0pt % paragraph indentation looks wrong on title page
7552 \scanexp\copyingtext
7553 \endgroup
7554 }
7555
7556
7557 \message{defuns,}
7558 % @defun etc.
7559
7560 \newskip\defbodyindent \defbodyindent=.4in
7561 \newskip\defargsindent \defargsindent=50pt
7562 \newskip\deflastargmargin \deflastargmargin=18pt
7563 \newcount\defunpenalty
7564
7565 % Start the processing of @deffn:
7566 \def\startdefun{%
7567 \ifnum\lastpenalty<10000
7568 \medbreak
7569 \defunpenalty=10003 % Will keep this @deffn together with the
7570 % following @def command, see below.
7571 \else
7572 % If there are two @def commands in a row, we'll have a \nobreak,
7573 % which is there to keep the function description together with its
7574 % header. But if there's nothing but headers, we need to allow a
7575 % break somewhere. Check specifically for penalty 10002, inserted
7576 % by \printdefunline, instead of 10000, since the sectioning
7577 % commands also insert a nobreak penalty, and we don't want to allow
7578 % a break between a section heading and a defun.
7579 %
7580 % As a further refinement, we avoid "club" headers by signalling
7581 % with penalty of 10003 after the very first @deffn in the
7582 % sequence (see above), and penalty of 10002 after any following
7583 % @def command.
7584 \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
7585 %
7586 % Similarly, after a section heading, do not allow a break.
7587 % But do insert the glue.
7588 \medskip % preceded by discardable penalty, so not a breakpoint
7589 \fi
7590 %
7591 \parindent=0in
7592 \advance\leftskip by \defbodyindent
7593 \exdentamount=\defbodyindent
7594 }
7595
7596 \def\dodefunx#1{%
7597 % First, check whether we are in the right environment:
7598 \checkenv#1%
7599 %
7600 % As above, allow line break if we have multiple x headers in a row.
7601 % It's not a great place, though.
7602 \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
7603 %
7604 % And now, it's time to reuse the body of the original defun:
7605 \expandafter\gobbledefun#1%
7606 }
7607 \def\gobbledefun#1\startdefun{}
7608
7609 % \printdefunline \deffnheader{text}
7610 %
7611 \def\printdefunline#1#2{%
7612 \begingroup
7613 % call \deffnheader:
7614 #1#2 \endheader
7615 % common ending:
7616 \interlinepenalty = 10000
7617 \advance\rightskip by 0pt plus 1fil\relax
7618 \endgraf
7619 \nobreak\vskip -\parskip
7620 \penalty\defunpenalty % signal to \startdefun and \dodefunx
7621 % Some of the @defun-type tags do not enable magic parentheses,
7622 % rendering the following check redundant. But we don't optimize.
7623 \checkparencounts
7624 \endgroup
7625 }
7626
7627 \def\Edefun{\endgraf\medbreak}
7628
7629 % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
7630 % the only thing remaining is to define \deffnheader.
7631 %
7632 \def\makedefun#1{%
7633 \expandafter\let\csname E#1\endcsname = \Edefun
7634 \edef\temp{\noexpand\domakedefun
7635 \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7636 \temp
7637 }
7638
7639 % \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
7640 %
7641 % Define \deffn and \deffnx, without parameters.
7642 % \deffnheader has to be defined explicitly.
7643 %
7644 \def\domakedefun#1#2#3{%
7645 \envdef#1{%
7646 \startdefun
7647 \doingtypefnfalse % distinguish typed functions from all else
7648 \parseargusing\activeparens{\printdefunline#3}%
7649 }%
7650 \def#2{\dodefunx#1}%
7651 \def#3%
7652 }
7653
7654 \newif\ifdoingtypefn % doing typed function?
7655 \newif\ifrettypeownline % typeset return type on its own line?
7656
7657 % @deftypefnnewline on|off says whether the return type of typed functions
7658 % are printed on their own line. This affects @deftypefn, @deftypefun,
7659 % @deftypeop, and @deftypemethod.
7660 %
7661 \parseargdef\deftypefnnewline{%
7662 \def\temp{#1}%
7663 \ifx\temp\onword
7664 \expandafter\let\csname SETtxideftypefnnl\endcsname
7665 = \empty
7666 \else\ifx\temp\offword
7667 \expandafter\let\csname SETtxideftypefnnl\endcsname
7668 = \relax
7669 \else
7670 \errhelp = \EMsimple
7671 \errmessage{Unknown @txideftypefnnl value `\temp',
7672 must be on|off}%
7673 \fi\fi
7674 }
7675
7676 % Untyped functions:
7677
7678 % @deffn category name args
7679 \makedefun{deffn}{\deffngeneral{}}
7680
7681 % @deffn category class name args
7682 \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
7683
7684 % \defopon {category on}class name args
7685 \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7686
7687 % \deffngeneral {subind}category name args
7688 %
7689 \def\deffngeneral#1#2 #3 #4\endheader{%
7690 % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
7691 \dosubind{fn}{\code{#3}}{#1}%
7692 \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
7693 }
7694
7695 % Typed functions:
7696
7697 % @deftypefn category type name args
7698 \makedefun{deftypefn}{\deftypefngeneral{}}
7699
7700 % @deftypeop category class type name args
7701 \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
7702
7703 % \deftypeopon {category on}class type name args
7704 \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7705
7706 % \deftypefngeneral {subind}category type name args
7707 %
7708 \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
7709 \dosubind{fn}{\code{#4}}{#1}%
7710 \doingtypefntrue
7711 \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7712 }
7713
7714 % Typed variables:
7715
7716 % @deftypevr category type var args
7717 \makedefun{deftypevr}{\deftypecvgeneral{}}
7718
7719 % @deftypecv category class type var args
7720 \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
7721
7722 % \deftypecvof {category of}class type var args
7723 \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
7724
7725 % \deftypecvgeneral {subind}category type var args
7726 %
7727 \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
7728 \dosubind{vr}{\code{#4}}{#1}%
7729 \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7730 }
7731
7732 % Untyped variables:
7733
7734 % @defvr category var args
7735 \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
7736
7737 % @defcv category class var args
7738 \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
7739
7740 % \defcvof {category of}class var args
7741 \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
7742
7743 % Types:
7744
7745 % @deftp category name args
7746 \makedefun{deftp}#1 #2 #3\endheader{%
7747 \doind{tp}{\code{#2}}%
7748 \defname{#1}{}{#2}\defunargs{#3\unskip}%
7749 }
7750
7751 % Remaining @defun-like shortcuts:
7752 \makedefun{defun}{\deffnheader{\putwordDeffunc} }
7753 \makedefun{defmac}{\deffnheader{\putwordDefmac} }
7754 \makedefun{defspec}{\deffnheader{\putwordDefspec} }
7755 \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7756 \makedefun{defvar}{\defvrheader{\putwordDefvar} }
7757 \makedefun{defopt}{\defvrheader{\putwordDefopt} }
7758 \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
7759 \makedefun{defmethod}{\defopon\putwordMethodon}
7760 \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
7761 \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
7762 \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
7763
7764 % \defname, which formats the name of the @def (not the args).
7765 % #1 is the category, such as "Function".
7766 % #2 is the return type, if any.
7767 % #3 is the function name.
7768 %
7769 % We are followed by (but not passed) the arguments, if any.
7770 %
7771 \def\defname#1#2#3{%
7772 \par
7773 % Get the values of \leftskip and \rightskip as they were outside the @def...
7774 \advance\leftskip by -\defbodyindent
7775 %
7776 % Determine if we are typesetting the return type of a typed function
7777 % on a line by itself.
7778 \rettypeownlinefalse
7779 \ifdoingtypefn % doing a typed function specifically?
7780 % then check user option for putting return type on its own line:
7781 \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
7782 \rettypeownlinetrue
7783 \fi
7784 \fi
7785 %
7786 % How we'll format the category name. Putting it in brackets helps
7787 % distinguish it from the body text that may end up on the next line
7788 % just below it.
7789 \def\temp{#1}%
7790 \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7791 %
7792 % Figure out line sizes for the paragraph shape. We'll always have at
7793 % least two.
7794 \tempnum = 2
7795 %
7796 % The first line needs space for \box0; but if \rightskip is nonzero,
7797 % we need only space for the part of \box0 which exceeds it:
7798 \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
7799 %
7800 % If doing a return type on its own line, we'll have another line.
7801 \ifrettypeownline
7802 \advance\tempnum by 1
7803 \def\maybeshapeline{0in \hsize}%
7804 \else
7805 \def\maybeshapeline{}%
7806 \fi
7807 %
7808 % The continuations:
7809 \dimen2=\hsize \advance\dimen2 by -\defargsindent
7810 %
7811 % The final paragraph shape:
7812 \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2
7813 %
7814 % Put the category name at the right margin.
7815 \noindent
7816 \hbox to 0pt{%
7817 \hfil\box0 \kern-\hsize
7818 % \hsize has to be shortened this way:
7819 \kern\leftskip
7820 % Intentionally do not respect \rightskip, since we need the space.
7821 }%
7822 %
7823 % Allow all lines to be underfull without complaint:
7824 \tolerance=10000 \hbadness=10000
7825 \exdentamount=\defbodyindent
7826 {%
7827 % defun fonts. We use typewriter by default (used to be bold) because:
7828 % . we're printing identifiers, they should be in tt in principle.
7829 % . in languages with many accents, such as Czech or French, it's
7830 % common to leave accents off identifiers. The result looks ok in
7831 % tt, but exceedingly strange in rm.
7832 % . we don't want -- and --- to be treated as ligatures.
7833 % . this still does not fix the ?` and !` ligatures, but so far no
7834 % one has made identifiers using them :).
7835 \df \tt
7836 \def\temp{#2}% text of the return type
7837 \ifx\temp\empty\else
7838 \tclose{\temp}% typeset the return type
7839 \ifrettypeownline
7840 % put return type on its own line; prohibit line break following:
7841 \hfil\vadjust{\nobreak}\break
7842 \else
7843 \space % type on same line, so just followed by a space
7844 \fi
7845 \fi % no return type
7846 #3% output function name
7847 }%
7848 {\rm\enskip}% hskip 0.5 em of \tenrm
7849 %
7850 \boldbrax
7851 % arguments will be output next, if any.
7852 }
7853
7854 % Print arguments in slanted roman (not ttsl), inconsistently with using
7855 % tt for the name. This is because literal text is sometimes needed in
7856 % the argument list (groff manual), and ttsl and tt are not very
7857 % distinguishable. Prevent hyphenation at `-' chars.
7858 %
7859 \def\defunargs#1{%
7860 % use sl by default (not ttsl),
7861 % tt for the names.
7862 \df \sl \hyphenchar\font=0
7863 %
7864 % On the other hand, if an argument has two dashes (for instance), we
7865 % want a way to get ttsl. We used to recommend @var for that, so
7866 % leave the code in, but it's strange for @var to lead to typewriter.
7867 % Nowadays we recommend @code, since the difference between a ttsl hyphen
7868 % and a tt hyphen is pretty tiny. @code also disables ?` !`.
7869 \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
7870 #1%
7871 \sl\hyphenchar\font=45
7872 }
7873
7874 % We want ()&[] to print specially on the defun line.
7875 %
7876 \def\activeparens{%
7877 \catcode`\(=\active \catcode`\)=\active
7878 \catcode`\[=\active \catcode`\]=\active
7879 \catcode`\&=\active
7880 }
7881
7882 % Make control sequences which act like normal parenthesis chars.
7883 \let\lparen = ( \let\rparen = )
7884
7885 % Be sure that we always have a definition for `(', etc. For example,
7886 % if the fn name has parens in it, \boldbrax will not be in effect yet,
7887 % so TeX would otherwise complain about undefined control sequence.
7888 {
7889 \activeparens
7890 \global\let(=\lparen \global\let)=\rparen
7891 \global\let[=\lbrack \global\let]=\rbrack
7892 \global\let& = \&
7893
7894 \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
7895 \gdef\magicamp{\let&=\amprm}
7896 }
7897
7898 \newcount\parencount
7899
7900 % If we encounter &foo, then turn on ()-hacking afterwards
7901 \newif\ifampseen
7902 \def\amprm#1 {\ampseentrue{\bf\&#1 }}
7903
7904 \def\parenfont{%
7905 \ifampseen
7906 % At the first level, print parens in roman,
7907 % otherwise use the default font.
7908 \ifnum \parencount=1 \rm \fi
7909 \else
7910 % The \sf parens (in \boldbrax) actually are a little bolder than
7911 % the contained text. This is especially needed for [ and ] .
7912 \sf
7913 \fi
7914 }
7915 \def\infirstlevel#1{%
7916 \ifampseen
7917 \ifnum\parencount=1
7918 #1%
7919 \fi
7920 \fi
7921 }
7922 \def\bfafterword#1 {#1 \bf}
7923
7924 \def\opnr{%
7925 \global\advance\parencount by 1
7926 {\parenfont(}%
7927 \infirstlevel \bfafterword
7928 }
7929 \def\clnr{%
7930 {\parenfont)}%
7931 \infirstlevel \sl
7932 \global\advance\parencount by -1
7933 }
7934
7935 \newcount\brackcount
7936 \def\lbrb{%
7937 \global\advance\brackcount by 1
7938 {\bf[}%
7939 }
7940 \def\rbrb{%
7941 {\bf]}%
7942 \global\advance\brackcount by -1
7943 }
7944
7945 \def\checkparencounts{%
7946 \ifnum\parencount=0 \else \badparencount \fi
7947 \ifnum\brackcount=0 \else \badbrackcount \fi
7948 }
7949 % these should not use \errmessage; the glibc manual, at least, actually
7950 % has such constructs (when documenting function pointers).
7951 \def\badparencount{%
7952 \message{Warning: unbalanced parentheses in @def...}%
7953 \global\parencount=0
7954 }
7955 \def\badbrackcount{%
7956 \message{Warning: unbalanced square brackets in @def...}%
7957 \global\brackcount=0
7958 }
7959
7960
7961 \message{macros,}
7962 % @macro.
7963
7964 % To do this right we need a feature of e-TeX, \scantokens,
7965 % which we arrange to emulate with a temporary file in ordinary TeX.
7966 \ifx\eTeXversion\thisisundefined
7967 \newwrite\macscribble
7968 \def\scantokens#1{%
7969 \toks0={#1}%
7970 \immediate\openout\macscribble=\jobname.tmp
7971 \immediate\write\macscribble{\the\toks0}%
7972 \immediate\closeout\macscribble
7973 \input \jobname.tmp
7974 }
7975 \fi
7976
7977 \let\aftermacroxxx\relax
7978 \def\aftermacro{\aftermacroxxx}
7979
7980 % alias because \c means cedilla in @tex or @math
7981 \let\texinfoc=\c
7982
7983 \newcount\savedcatcodeone
7984 \newcount\savedcatcodetwo
7985
7986 % Used at the time of macro expansion.
7987 % Argument is macro body with arguments substituted
7988 \def\scanmacro#1{%
7989 \newlinechar`\^^M
7990 \def\xeatspaces{\eatspaces}%
7991 %
7992 % Temporarily undo catcode changes of \printindex. Set catcode of @ to
7993 % 0 so that @-commands in macro expansions aren't printed literally when
7994 % formatting an index file, where \ is used as the escape character.
7995 \savedcatcodeone=\catcode`\@
7996 \savedcatcodetwo=\catcode`\\
7997 \catcode`\@=0
7998 \catcode`\\=\active
7999 %
8000 % Process the macro body under the current catcode regime.
8001 \scantokens{#1@texinfoc}\aftermacro%
8002 %
8003 \catcode`\@=\savedcatcodeone
8004 \catcode`\\=\savedcatcodetwo
8005 %
8006 % The \texinfoc is to remove the \newlinechar added by \scantokens, and
8007 % can be noticed by \parsearg.
8008 % The \aftermacro allows a \comment at the end of the macro definition
8009 % to duplicate itself past the final \newlinechar added by \scantokens:
8010 % this is used in the definition of \group to comment out a newline. We
8011 % don't do the same for \c to support Texinfo files with macros that ended
8012 % with a @c, which should no longer be necessary.
8013 % We avoid surrounding the call to \scantokens with \bgroup and \egroup
8014 % to allow macros to open or close groups themselves.
8015 }
8016
8017 % Used for copying and captions
8018 \def\scanexp#1{%
8019 \expandafter\scanmacro\expandafter{#1}%
8020 }
8021
8022 \newcount\paramno % Count of parameters
8023 \newtoks\macname % Macro name
8024 \newif\ifrecursive % Is it recursive?
8025
8026 % List of all defined macros in the form
8027 % \definedummyword\macro1\definedummyword\macro2...
8028 % Currently is also contains all @aliases; the list can be split
8029 % if there is a need.
8030 \def\macrolist{}
8031
8032 % Add the macro to \macrolist
8033 \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
8034 \def\addtomacrolistxxx#1{%
8035 \toks0 = \expandafter{\macrolist\definedummyword#1}%
8036 \xdef\macrolist{\the\toks0}%
8037 }
8038
8039 % Utility routines.
8040 % This does \let #1 = #2, with \csnames; that is,
8041 % \let \csname#1\endcsname = \csname#2\endcsname
8042 % (except of course we have to play expansion games).
8043 %
8044 \def\cslet#1#2{%
8045 \expandafter\let
8046 \csname#1\expandafter\endcsname
8047 \csname#2\endcsname
8048 }
8049
8050 % Trim leading and trailing spaces off a string.
8051 % Concepts from aro-bend problem 15 (see CTAN).
8052 {\catcode`\@=11
8053 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
8054 \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
8055 \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
8056 \def\unbrace#1{#1}
8057 \unbrace{\gdef\trim@@@ #1 } #2@{#1}
8058 }
8059
8060 % Trim a single trailing ^^M off a string.
8061 {\catcode`\^^M=\other \catcode`\Q=3%
8062 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
8063 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
8064 \gdef\eatcrb#1Q#2Q{#1}%
8065 }
8066
8067 % Macro bodies are absorbed as an argument in a context where
8068 % all characters are catcode 10, 11 or 12, except \ which is active
8069 % (as in normal texinfo). It is necessary to change the definition of \
8070 % to recognize macro arguments; this is the job of \mbodybackslash.
8071 %
8072 % Non-ASCII encodings make 8-bit characters active, so un-activate
8073 % them to avoid their expansion. Must do this non-globally, to
8074 % confine the change to the current group.
8075 %
8076 % It's necessary to have hard CRs when the macro is executed. This is
8077 % done by making ^^M (\endlinechar) catcode 12 when reading the macro
8078 % body, and then making it the \newlinechar in \scanmacro.
8079 %
8080 \def\scanctxt{% used as subroutine
8081 \catcode`\"=\other
8082 \catcode`\+=\other
8083 \catcode`\<=\other
8084 \catcode`\>=\other
8085 \catcode`\^=\other
8086 \catcode`\_=\other
8087 \catcode`\|=\other
8088 \catcode`\~=\other
8089 \passthroughcharstrue
8090 }
8091
8092 \def\scanargctxt{% used for copying and captions, not macros.
8093 \scanctxt
8094 \catcode`\@=\other
8095 \catcode`\\=\other
8096 \catcode`\^^M=\other
8097 }
8098
8099 \def\macrobodyctxt{% used for @macro definitions
8100 \scanctxt
8101 \catcode`\ =\other
8102 \catcode`\@=\other
8103 \catcode`\{=\other
8104 \catcode`\}=\other
8105 \catcode`\^^M=\other
8106 \usembodybackslash
8107 }
8108
8109 % Used when scanning braced macro arguments. Note, however, that catcode
8110 % changes here are ineffectual if the macro invocation was nested inside
8111 % an argument to another Texinfo command.
8112 \def\macroargctxt{%
8113 \scanctxt
8114 \catcode`\ =\active
8115 \catcode`\^^M=\other
8116 \catcode`\\=\active
8117 }
8118
8119 \def\macrolineargctxt{% used for whole-line arguments without braces
8120 \scanctxt
8121 \catcode`\{=\other
8122 \catcode`\}=\other
8123 }
8124
8125 % \mbodybackslash is the definition of \ in @macro bodies.
8126 % It maps \foo\ => \csname macarg.foo\endcsname => #N
8127 % where N is the macro parameter number.
8128 % We define \csname macarg.\endcsname to be \realbackslash, so
8129 % \\ in macro replacement text gets you a backslash.
8130 %
8131 {\catcode`@=0 @catcode`@\=@active
8132 @gdef@usembodybackslash{@let\=@mbodybackslash}
8133 @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
8134 }
8135 \expandafter\def\csname macarg.\endcsname{\realbackslash}
8136
8137 \def\margbackslash#1{\char`\#1 }
8138
8139 \def\macro{\recursivefalse\parsearg\macroxxx}
8140 \def\rmacro{\recursivetrue\parsearg\macroxxx}
8141
8142 \def\macroxxx#1{%
8143 \getargs{#1}% now \macname is the macname and \argl the arglist
8144 \ifx\argl\empty % no arguments
8145 \paramno=0\relax
8146 \else
8147 \expandafter\parsemargdef \argl;%
8148 \if\paramno>256\relax
8149 \ifx\eTeXversion\thisisundefined
8150 \errhelp = \EMsimple
8151 \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
8152 \fi
8153 \fi
8154 \fi
8155 \if1\csname ismacro.\the\macname\endcsname
8156 \message{Warning: redefining \the\macname}%
8157 \else
8158 \expandafter\ifx\csname \the\macname\endcsname \relax
8159 \else \errmessage{Macro name \the\macname\space already defined}\fi
8160 \global\cslet{macsave.\the\macname}{\the\macname}%
8161 \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
8162 \addtomacrolist{\the\macname}%
8163 \fi
8164 \begingroup \macrobodyctxt
8165 \ifrecursive \expandafter\parsermacbody
8166 \else \expandafter\parsemacbody
8167 \fi}
8168
8169 \parseargdef\unmacro{%
8170 \if1\csname ismacro.#1\endcsname
8171 \global\cslet{#1}{macsave.#1}%
8172 \global\expandafter\let \csname ismacro.#1\endcsname=0%
8173 % Remove the macro name from \macrolist:
8174 \begingroup
8175 \expandafter\let\csname#1\endcsname \relax
8176 \let\definedummyword\unmacrodo
8177 \xdef\macrolist{\macrolist}%
8178 \endgroup
8179 \else
8180 \errmessage{Macro #1 not defined}%
8181 \fi
8182 }
8183
8184 % Called by \do from \dounmacro on each macro. The idea is to omit any
8185 % macro definitions that have been changed to \relax.
8186 %
8187 \def\unmacrodo#1{%
8188 \ifx #1\relax
8189 % remove this
8190 \else
8191 \noexpand\definedummyword \noexpand#1%
8192 \fi
8193 }
8194
8195 % \getargs -- Parse the arguments to a @macro line. Set \macname to
8196 % the name of the macro, and \argl to the braced argument list.
8197 \def\getargs#1{\getargsxxx#1{}}
8198 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
8199 \def\getmacname#1 #2\relax{\macname={#1}}
8200 \def\getmacargs#1{\def\argl{#1}}
8201 % This made use of the feature that if the last token of a
8202 % <parameter list> is #, then the preceding argument is delimited by
8203 % an opening brace, and that opening brace is not consumed.
8204
8205 % Parse the optional {params} list to @macro or @rmacro.
8206 % Set \paramno to the number of arguments,
8207 % and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
8208 % three-param macro.) Define \macarg.BLAH for each BLAH in the params
8209 % list to some hook where the argument is to be expanded. If there are
8210 % less than 10 arguments that hook is to be replaced by ##N where N
8211 % is the position in that list, that is to say the macro arguments are to be
8212 % defined `a la TeX in the macro body.
8213 %
8214 % That gets used by \mbodybackslash (above).
8215 %
8216 % If there are 10 or more arguments, a different technique is used: see
8217 % \parsemmanyargdef.
8218 %
8219 \def\parsemargdef#1;{%
8220 \paramno=0\def\paramlist{}%
8221 \let\hash\relax
8222 % \hash is redefined to `#' later to get it into definitions
8223 \let\xeatspaces\relax
8224 \parsemargdefxxx#1,;,%
8225 \ifnum\paramno<10\relax\else
8226 \paramno0\relax
8227 \parsemmanyargdef@@#1,;,% 10 or more arguments
8228 \fi
8229 }
8230 \def\parsemargdefxxx#1,{%
8231 \if#1;\let\next=\relax
8232 \else \let\next=\parsemargdefxxx
8233 \advance\paramno by 1
8234 \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
8235 {\xeatspaces{\hash\the\paramno}}%
8236 \edef\paramlist{\paramlist\hash\the\paramno,}%
8237 \fi\next}
8238
8239 % \parsemacbody, \parsermacbody
8240 %
8241 % Read recursive and nonrecursive macro bodies. (They're different since
8242 % rec and nonrec macros end differently.)
8243 %
8244 % We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro
8245 % body to be transformed.
8246 % Set \macrobody to the body of the macro, and call \defmacro.
8247 %
8248 {\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{%
8249 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8250 {\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
8251 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8252
8253 % Make @ a letter, so that we can make private-to-Texinfo macro names.
8254 \edef\texiatcatcode{\the\catcode`\@}
8255 \catcode `@=11\relax
8256
8257 %%%%%%%%%%%%%% Code for > 10 arguments only %%%%%%%%%%%%%%%%%%
8258
8259 % If there are 10 or more arguments, a different technique is used, where the
8260 % hook remains in the body, and when macro is to be expanded the body is
8261 % processed again to replace the arguments.
8262 %
8263 % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
8264 % argument N value and then \edef the body (nothing else will expand because of
8265 % the catcode regime under which the body was input).
8266 %
8267 % If you compile with TeX (not eTeX), and you have macros with 10 or more
8268 % arguments, no macro can have more than 256 arguments (else error).
8269 %
8270 % In case that there are 10 or more arguments we parse again the arguments
8271 % list to set new definitions for the \macarg.BLAH macros corresponding to
8272 % each BLAH argument. It was anyhow needed to parse already once this list
8273 % in order to count the arguments, and as macros with at most 9 arguments
8274 % are by far more frequent than macro with 10 or more arguments, defining
8275 % twice the \macarg.BLAH macros does not cost too much processing power.
8276 \def\parsemmanyargdef@@#1,{%
8277 \if#1;\let\next=\relax
8278 \else
8279 \let\next=\parsemmanyargdef@@
8280 \edef\tempb{\eatspaces{#1}}%
8281 \expandafter\def\expandafter\tempa
8282 \expandafter{\csname macarg.\tempb\endcsname}%
8283 % Note that we need some extra \noexpand\noexpand, this is because we
8284 % don't want \the to be expanded in the \parsermacbody as it uses an
8285 % \xdef .
8286 \expandafter\edef\tempa
8287 {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
8288 \advance\paramno by 1\relax
8289 \fi\next}
8290
8291
8292 \let\endargs@\relax
8293 \let\nil@\relax
8294 \def\nilm@{\nil@}%
8295 \long\def\nillm@{\nil@}%
8296
8297 % This macro is expanded during the Texinfo macro expansion, not during its
8298 % definition. It gets all the arguments' values and assigns them to macros
8299 % macarg.ARGNAME
8300 %
8301 % #1 is the macro name
8302 % #2 is the list of argument names
8303 % #3 is the list of argument values
8304 \def\getargvals@#1#2#3{%
8305 \def\macargdeflist@{}%
8306 \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
8307 \def\paramlist{#2,\nil@}%
8308 \def\macroname{#1}%
8309 \begingroup
8310 \macroargctxt
8311 \def\argvaluelist{#3,\nil@}%
8312 \def\@tempa{#3}%
8313 \ifx\@tempa\empty
8314 \setemptyargvalues@
8315 \else
8316 \getargvals@@
8317 \fi
8318 }
8319 \def\getargvals@@{%
8320 \ifx\paramlist\nilm@
8321 % Some sanity check needed here that \argvaluelist is also empty.
8322 \ifx\argvaluelist\nillm@
8323 \else
8324 \errhelp = \EMsimple
8325 \errmessage{Too many arguments in macro `\macroname'!}%
8326 \fi
8327 \let\next\macargexpandinbody@
8328 \else
8329 \ifx\argvaluelist\nillm@
8330 % No more arguments values passed to macro. Set remaining named-arg
8331 % macros to empty.
8332 \let\next\setemptyargvalues@
8333 \else
8334 % pop current arg name into \@tempb
8335 \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
8336 \expandafter\@tempa\expandafter{\paramlist}%
8337 % pop current argument value into \@tempc
8338 \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
8339 \expandafter\@tempa\expandafter{\argvaluelist}%
8340 % Here \@tempb is the current arg name and \@tempc is the current arg value.
8341 % First place the new argument macro definition into \@tempd
8342 \expandafter\macname\expandafter{\@tempc}%
8343 \expandafter\let\csname macarg.\@tempb\endcsname\relax
8344 \expandafter\def\expandafter\@tempe\expandafter{%
8345 \csname macarg.\@tempb\endcsname}%
8346 \edef\@tempd{\long\def\@tempe{\the\macname}}%
8347 \push@\@tempd\macargdeflist@
8348 \let\next\getargvals@@
8349 \fi
8350 \fi
8351 \next
8352 }
8353
8354 \def\push@#1#2{%
8355 \expandafter\expandafter\expandafter\def
8356 \expandafter\expandafter\expandafter#2%
8357 \expandafter\expandafter\expandafter{%
8358 \expandafter#1#2}%
8359 }
8360
8361 % Replace arguments by their values in the macro body, and place the result
8362 % in macro \@tempa.
8363 %
8364 \def\macvalstoargs@{%
8365 % To do this we use the property that token registers that are \the'ed
8366 % within an \edef expand only once. So we are going to place all argument
8367 % values into respective token registers.
8368 %
8369 % First we save the token context, and initialize argument numbering.
8370 \begingroup
8371 \paramno0\relax
8372 % Then, for each argument number #N, we place the corresponding argument
8373 % value into a new token list register \toks#N
8374 \expandafter\putargsintokens@\saveparamlist@,;,%
8375 % Then, we expand the body so that argument are replaced by their
8376 % values. The trick for values not to be expanded themselves is that they
8377 % are within tokens and that tokens expand only once in an \edef .
8378 \edef\@tempc{\csname mac.\macroname .body\endcsname}%
8379 % Now we restore the token stack pointer to free the token list registers
8380 % which we have used, but we make sure that expanded body is saved after
8381 % group.
8382 \expandafter
8383 \endgroup
8384 \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
8385 }
8386
8387 % Define the named-macro outside of this group and then close this group.
8388 %
8389 \def\macargexpandinbody@{%
8390 \expandafter
8391 \endgroup
8392 \macargdeflist@
8393 % First the replace in body the macro arguments by their values, the result
8394 % is in \@tempa .
8395 \macvalstoargs@
8396 % Then we point at the \norecurse or \gobble (for recursive) macro value
8397 % with \@tempb .
8398 \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
8399 % Depending on whether it is recursive or not, we need some tailing
8400 % \egroup .
8401 \ifx\@tempb\gobble
8402 \let\@tempc\relax
8403 \else
8404 \let\@tempc\egroup
8405 \fi
8406 % And now we do the real job:
8407 \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
8408 \@tempd
8409 }
8410
8411 \def\putargsintokens@#1,{%
8412 \if#1;\let\next\relax
8413 \else
8414 \let\next\putargsintokens@
8415 % First we allocate the new token list register, and give it a temporary
8416 % alias \@tempb .
8417 \toksdef\@tempb\the\paramno
8418 % Then we place the argument value into that token list register.
8419 \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
8420 \expandafter\@tempb\expandafter{\@tempa}%
8421 \advance\paramno by 1\relax
8422 \fi
8423 \next
8424 }
8425
8426 % Trailing missing arguments are set to empty.
8427 %
8428 \def\setemptyargvalues@{%
8429 \ifx\paramlist\nilm@
8430 \let\next\macargexpandinbody@
8431 \else
8432 \expandafter\setemptyargvaluesparser@\paramlist\endargs@
8433 \let\next\setemptyargvalues@
8434 \fi
8435 \next
8436 }
8437
8438 \def\setemptyargvaluesparser@#1,#2\endargs@{%
8439 \expandafter\def\expandafter\@tempa\expandafter{%
8440 \expandafter\def\csname macarg.#1\endcsname{}}%
8441 \push@\@tempa\macargdeflist@
8442 \def\paramlist{#2}%
8443 }
8444
8445 % #1 is the element target macro
8446 % #2 is the list macro
8447 % #3,#4\endargs@ is the list value
8448 \def\pop@#1#2#3,#4\endargs@{%
8449 \def#1{#3}%
8450 \def#2{#4}%
8451 }
8452 \long\def\longpop@#1#2#3,#4\endargs@{%
8453 \long\def#1{#3}%
8454 \long\def#2{#4}%
8455 }
8456
8457
8458 %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
8459
8460
8461 % This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
8462 % \macrobody has the body of the macro in it, with placeholders for
8463 % its parameters, looking like "\xeatspaces{\hash 1}".
8464 % \paramno is the number of parameters
8465 % \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
8466 % There are eight cases: recursive and nonrecursive macros of zero, one,
8467 % up to nine, and many arguments.
8468 % \xdef is used so that macro definitions will survive the file
8469 % they're defined in: @include reads the file inside a group.
8470 %
8471 \def\defmacro{%
8472 \let\hash=##% convert placeholders to macro parameter chars
8473 \ifnum\paramno=1
8474 \def\xeatspaces##1{##1}%
8475 % This removes the pair of braces around the argument. We don't
8476 % use \eatspaces, because this can cause ends of lines to be lost
8477 % when the argument to \eatspaces is read, leading to line-based
8478 % commands like "@itemize" not being read correctly.
8479 \else
8480 \let\xeatspaces\relax % suppress expansion
8481 \fi
8482 \ifrecursive %%%%%%%%%%%%%% Recursive %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8483 \ifcase\paramno
8484 % 0
8485 \expandafter\xdef\csname\the\macname\endcsname{%
8486 \noexpand\scanmacro{\macrobody}}%
8487 \or % 1
8488 \expandafter\xdef\csname\the\macname\endcsname{%
8489 \bgroup
8490 \noexpand\braceorline
8491 \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8492 \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8493 \egroup
8494 \noexpand\scanmacro{\macrobody}%
8495 }%
8496 \else
8497 \ifnum\paramno<10\relax % at most 9
8498 % See non-recursive section below for comments
8499 \expandafter\xdef\csname\the\macname\endcsname{%
8500 \bgroup
8501 \noexpand\expandafter
8502 \noexpand\macroargctxt
8503 \noexpand\expandafter
8504 \expandafter\noexpand\csname\the\macname @@\endcsname}%
8505 \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8506 \noexpand\passargtomacro
8507 \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8508 \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8509 \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8510 \expandafter\expandafter
8511 \expandafter\xdef
8512 \expandafter\expandafter
8513 \csname\the\macname @@@@\endcsname\paramlist{%
8514 \egroup\noexpand\scanmacro{\macrobody}}%
8515 \else % 10 or more
8516 \expandafter\xdef\csname\the\macname\endcsname{%
8517 \noexpand\getargvals@{\the\macname}{\argl}%
8518 }%
8519 \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8520 \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
8521 \fi
8522 \fi
8523 \else %%%%%%%%%%%%%%%%%%%%%% Non-recursive %%%%%%%%%%%%%%%%%%%%%%%%%%
8524 \ifcase\paramno
8525 % 0
8526 \expandafter\xdef\csname\the\macname\endcsname{%
8527 \noexpand\scanmacro{\macrobody}}%
8528 \or % 1
8529 \expandafter\xdef\csname\the\macname\endcsname{%
8530 \bgroup
8531 \noexpand\braceorline
8532 \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8533 \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8534 \egroup
8535 \noexpand\scanmacro{\macrobody}%
8536 }%
8537 \else % at most 9
8538 \ifnum\paramno<10\relax
8539 % @MACNAME sets the context for reading the macro argument
8540 % @MACNAME@@ gets the argument, processes backslashes and appends a
8541 % comma.
8542 % @MACNAME@@@ removes braces surrounding the argument list.
8543 % @MACNAME@@@@ scans the macro body with arguments substituted.
8544 \expandafter\xdef\csname\the\macname\endcsname{%
8545 \bgroup
8546 \noexpand\expandafter % This \expandafter skip any spaces after the
8547 \noexpand\macroargctxt % macro before we change the catcode of space.
8548 \noexpand\expandafter
8549 \expandafter\noexpand\csname\the\macname @@\endcsname}%
8550 \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8551 \noexpand\passargtomacro
8552 \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8553 \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8554 \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8555 \expandafter\expandafter
8556 \expandafter\xdef
8557 \expandafter\expandafter
8558 \csname\the\macname @@@@\endcsname\paramlist{%
8559 \egroup\noexpand\scanmacro{\macrobody}}%
8560 \else % 10 or more:
8561 \expandafter\xdef\csname\the\macname\endcsname{%
8562 \noexpand\getargvals@{\the\macname}{\argl}%
8563 }%
8564 \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8565 \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse
8566 \fi
8567 \fi
8568 \fi}
8569
8570 \catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
8571
8572 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
8573
8574
8575 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8576 %
8577 {\catcode`\@=0 \catcode`\\=13 % We need to manipulate \ so use @ as escape
8578 @catcode`@_=11 % private names
8579 @catcode`@!=11 % used as argument separator
8580
8581 % \passargtomacro#1#2 -
8582 % Call #1 with a list of tokens #2, with any doubled backslashes in #2
8583 % compressed to one.
8584 %
8585 % This implementation works by expansion, and not execution (so we cannot use
8586 % \def or similar). This reduces the risk of this failing in contexts where
8587 % complete expansion is done with no execution (for example, in writing out to
8588 % an auxiliary file for an index entry).
8589 %
8590 % State is kept in the input stream: the argument passed to
8591 % @look_ahead, @gobble_and_check_finish and @add_segment is
8592 %
8593 % THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN (... rest of input)
8594 %
8595 % where:
8596 % THE_MACRO - name of the macro we want to call
8597 % ARG_RESULT - argument list we build to pass to that macro
8598 % PENDING_BS - either a backslash or nothing
8599 % NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
8600
8601 @gdef@passargtomacro#1#2{%
8602 @add_segment #1!{}@relax#2\@_finish\%
8603 }
8604 @gdef@_finish{@_finishx} @global@let@_finishx@relax
8605
8606 % #1 - THE_MACRO ARG_RESULT
8607 % #2 - PENDING_BS
8608 % #3 - NEXT_TOKEN
8609 % #4 used to look ahead
8610 %
8611 % If the next token is not a backslash, process the rest of the argument;
8612 % otherwise, remove the next token.
8613 @gdef@look_ahead#1!#2#3#4{%
8614 @ifx#4\%
8615 @expandafter@gobble_and_check_finish
8616 @else
8617 @expandafter@add_segment
8618 @fi#1!{#2}#4#4%
8619 }
8620
8621 % #1 - THE_MACRO ARG_RESULT
8622 % #2 - PENDING_BS
8623 % #3 - NEXT_TOKEN
8624 % #4 should be a backslash, which is gobbled.
8625 % #5 looks ahead
8626 %
8627 % Double backslash found. Add a single backslash, and look ahead.
8628 @gdef@gobble_and_check_finish#1!#2#3#4#5{%
8629 @add_segment#1\!{}#5#5%
8630 }
8631
8632 @gdef@is_fi{@fi}
8633
8634 % #1 - THE_MACRO ARG_RESULT
8635 % #2 - PENDING_BS
8636 % #3 - NEXT_TOKEN
8637 % #4 is input stream until next backslash
8638 %
8639 % Input stream is either at the start of the argument, or just after a
8640 % backslash sequence, either a lone backslash, or a doubled backslash.
8641 % NEXT_TOKEN contains the first token in the input stream: if it is \finish,
8642 % finish; otherwise, append to ARG_RESULT the segment of the argument up until
8643 % the next backslash. PENDING_BACKSLASH contains a backslash to represent
8644 % a backslash just before the start of the input stream that has not been
8645 % added to ARG_RESULT.
8646 @gdef@add_segment#1!#2#3#4\{%
8647 @ifx#3@_finish
8648 @call_the_macro#1!%
8649 @else
8650 % append the pending backslash to the result, followed by the next segment
8651 @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
8652 % this @fi is discarded by @look_ahead.
8653 % we can't get rid of it with \expandafter because we don't know how
8654 % long #4 is.
8655 }
8656
8657 % #1 - THE_MACRO
8658 % #2 - ARG_RESULT
8659 % #3 discards the res of the conditional in @add_segment, and @is_fi ends the
8660 % conditional.
8661 @gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
8662
8663 }
8664 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8665
8666 % \braceorline MAC is used for a one-argument macro MAC. It checks
8667 % whether the next non-whitespace character is a {. It sets the context
8668 % for reading the argument (slightly different in the two cases). Then,
8669 % to read the argument, in the whole-line case, it then calls the regular
8670 % \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
8671 %
8672 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
8673 \def\braceorlinexxx{%
8674 \ifx\nchar\bgroup
8675 \macroargctxt
8676 \expandafter\passargtomacro
8677 \else
8678 \macrolineargctxt\expandafter\parsearg
8679 \fi \macnamexxx}
8680
8681
8682 % @alias.
8683 % We need some trickery to remove the optional spaces around the equal
8684 % sign. Make them active and then expand them all to nothing.
8685 %
8686 \def\alias{\parseargusing\obeyspaces\aliasxxx}
8687 \def\aliasxxx #1{\aliasyyy#1\relax}
8688 \def\aliasyyy #1=#2\relax{%
8689 {%
8690 \expandafter\let\obeyedspace=\empty
8691 \addtomacrolist{#1}%
8692 \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
8693 }%
8694 \next
8695 }
8696
8697
8698 \message{cross references,}
8699
8700 \newwrite\auxfile
8701 \newif\ifhavexrefs % True if xref values are known.
8702 \newif\ifwarnedxrefs % True if we warned once that they aren't known.
8703
8704 % @inforef is relatively simple.
8705 \def\inforef #1{\inforefzzz #1,,,,**}
8706 \def\inforefzzz #1,#2,#3,#4**{%
8707 \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
8708 node \samp{\ignorespaces#1{}}}
8709
8710 % @node's only job in TeX is to define \lastnode, which is used in
8711 % cross-references. The @node line might or might not have commas, and
8712 % might or might not have spaces before the first comma, like:
8713 % @node foo , bar , ...
8714 % We don't want such trailing spaces in the node name.
8715 %
8716 \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
8717 %
8718 % also remove a trailing comma, in case of something like this:
8719 % @node Help-Cross, , , Cross-refs
8720 \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
8721 \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
8722
8723 \let\nwnode=\node
8724 \let\lastnode=\empty
8725
8726 % Write a cross-reference definition for the current node. #1 is the
8727 % type (Ynumbered, Yappendix, Ynothing).
8728 %
8729 \def\donoderef#1{%
8730 \ifx\lastnode\empty\else
8731 \setref{\lastnode}{#1}%
8732 \global\let\lastnode=\empty
8733 \fi
8734 }
8735
8736 % @anchor{NAME} -- define xref target at arbitrary point.
8737 %
8738 \newcount\savesfregister
8739 %
8740 \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
8741 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
8742 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
8743
8744 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
8745 % anchor), which consists of three parts:
8746 % 1) NAME-title - the current sectioning name taken from \lastsection,
8747 % or the anchor name.
8748 % 2) NAME-snt - section number and type, passed as the SNT arg, or
8749 % empty for anchors.
8750 % 3) NAME-pg - the page number.
8751 %
8752 % This is called from \donoderef, \anchor, and \dofloat. In the case of
8753 % floats, there is an additional part, which is not written here:
8754 % 4) NAME-lof - the text as it should appear in a @listoffloats.
8755 %
8756 \def\setref#1#2{%
8757 \pdfmkdest{#1}%
8758 \iflinks
8759 {%
8760 \requireauxfile
8761 \atdummies % preserve commands, but don't expand them
8762 % match definition in \xrdef, \refx, \xrefX.
8763 \def\value##1{##1}%
8764 \edef\writexrdef##1##2{%
8765 \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
8766 ##1}{##2}}% these are parameters of \writexrdef
8767 }%
8768 \toks0 = \expandafter{\lastsection}%
8769 \immediate \writexrdef{title}{\the\toks0 }%
8770 \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
8771 \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
8772 }%
8773 \fi
8774 }
8775
8776 % @xrefautosectiontitle on|off says whether @section(ing) names are used
8777 % automatically in xrefs, if the third arg is not explicitly specified.
8778 % This was provided as a "secret" @set xref-automatic-section-title
8779 % variable, now it's official.
8780 %
8781 \parseargdef\xrefautomaticsectiontitle{%
8782 \def\temp{#1}%
8783 \ifx\temp\onword
8784 \expandafter\let\csname SETxref-automatic-section-title\endcsname
8785 = \empty
8786 \else\ifx\temp\offword
8787 \expandafter\let\csname SETxref-automatic-section-title\endcsname
8788 = \relax
8789 \else
8790 \errhelp = \EMsimple
8791 \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
8792 must be on|off}%
8793 \fi\fi
8794 }
8795
8796 % \f
8797 % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
8798 % the node name, #2 the name of the Info cross-reference, #3 the printed
8799 % node name, #4 the name of the Info file, #5 the name of the printed
8800 % manual. All but the node name can be omitted.
8801 %
8802 \def\pxref{\putwordsee{} \xrefXX}
8803 \def\xref{\putwordSee{} \xrefXX}
8804 \def\ref{\xrefXX}
8805
8806 \def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
8807 \def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
8808 %
8809 \newbox\toprefbox
8810 \newbox\printedrefnamebox
8811 \newbox\infofilenamebox
8812 \newbox\printedmanualbox
8813 %
8814 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
8815 \unsepspaces
8816 %
8817 % Get args without leading/trailing spaces.
8818 \def\printedrefname{\ignorespaces #3}%
8819 \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
8820 %
8821 \def\infofilename{\ignorespaces #4}%
8822 \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
8823 %
8824 \def\printedmanual{\ignorespaces #5}%
8825 \setbox\printedmanualbox = \hbox{\printedmanual\unskip}%
8826 %
8827 % If the printed reference name (arg #3) was not explicitly given in
8828 % the @xref, figure out what we want to use.
8829 \ifdim \wd\printedrefnamebox = 0pt
8830 % No printed node name was explicitly given.
8831 \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
8832 % Not auto section-title: use node name inside the square brackets.
8833 \def\printedrefname{\ignorespaces #1}%
8834 \else
8835 % Auto section-title: use chapter/section title inside
8836 % the square brackets if we have it.
8837 \ifdim \wd\printedmanualbox > 0pt
8838 % It is in another manual, so we don't have it; use node name.
8839 \def\printedrefname{\ignorespaces #1}%
8840 \else
8841 \ifhavexrefs
8842 % We (should) know the real title if we have the xref values.
8843 \def\printedrefname{\refx{#1-title}{}}%
8844 \else
8845 % Otherwise just copy the Info node name.
8846 \def\printedrefname{\ignorespaces #1}%
8847 \fi%
8848 \fi
8849 \fi
8850 \fi
8851 %
8852 % Make link in pdf output.
8853 \ifpdf
8854 % For pdfTeX and LuaTeX
8855 {\indexnofonts
8856 \turnoffactive
8857 \makevalueexpandable
8858 % This expands tokens, so do it after making catcode changes, so _
8859 % etc. don't get their TeX definitions. This ignores all spaces in
8860 % #4, including (wrongly) those in the middle of the filename.
8861 \getfilename{#4}%
8862 %
8863 % This (wrongly) does not take account of leading or trailing
8864 % spaces in #1, which should be ignored.
8865 \edef\pdfxrefdest{#1}%
8866 \ifx\pdfxrefdest\empty
8867 \def\pdfxrefdest{Top}% no empty targets
8868 \else
8869 \txiescapepdf\pdfxrefdest % escape PDF special chars
8870 \fi
8871 %
8872 \leavevmode
8873 \startlink attr{/Border [0 0 0]}%
8874 \ifnum\filenamelength>0
8875 goto file{\the\filename.pdf} name{\pdfxrefdest}%
8876 \else
8877 goto name{\pdfmkpgn{\pdfxrefdest}}%
8878 \fi
8879 }%
8880 \setcolor{\linkcolor}%
8881 \else
8882 \ifx\XeTeXrevision\thisisundefined
8883 \else
8884 % For XeTeX
8885 {\indexnofonts
8886 \turnoffactive
8887 \makevalueexpandable
8888 % This expands tokens, so do it after making catcode changes, so _
8889 % etc. don't get their TeX definitions. This ignores all spaces in
8890 % #4, including (wrongly) those in the middle of the filename.
8891 \getfilename{#4}%
8892 %
8893 % This (wrongly) does not take account of leading or trailing
8894 % spaces in #1, which should be ignored.
8895 \iftxiuseunicodedestname
8896 \def\pdfxrefdest{#1}% Pass through Unicode characters.
8897 \else
8898 \edef\pdfxrefdest{#1}% Replace Unicode characters to ASCII.
8899 \fi
8900 \ifx\pdfxrefdest\empty
8901 \def\pdfxrefdest{Top}% no empty targets
8902 \else
8903 \txiescapepdf\pdfxrefdest % escape PDF special chars
8904 \fi
8905 %
8906 \leavevmode
8907 \ifnum\filenamelength>0
8908 % By the default settings,
8909 % XeTeX (xdvipdfmx) replaces link destination names with integers.
8910 % In this case, the replaced destination names of
8911 % remote PDF cannot be known. In order to avoid replacement,
8912 % you can use commandline option `-C 0x0010' for xdvipdfmx.
8913 \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8914 << /S /GoToR /F (\the\filename.pdf) /D (name\pdfxrefdest) >> >>}%
8915 \else
8916 \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8917 << /S /GoTo /D (name\pdfxrefdest) >> >>}%
8918 \fi
8919 }%
8920 \setcolor{\linkcolor}%
8921 \fi
8922 \fi
8923 {%
8924 % Have to otherify everything special to allow the \csname to
8925 % include an _ in the xref name, etc.
8926 \indexnofonts
8927 \turnoffactive
8928 \def\value##1{##1}%
8929 \expandafter\global\expandafter\let\expandafter\Xthisreftitle
8930 \csname XR#1-title\endcsname
8931 }%
8932 %
8933 % Float references are printed completely differently: "Figure 1.2"
8934 % instead of "[somenode], p.3". \iffloat distinguishes them by
8935 % \Xthisreftitle being set to a magic string.
8936 \iffloat\Xthisreftitle
8937 % If the user specified the print name (third arg) to the ref,
8938 % print it instead of our usual "Figure 1.2".
8939 \ifdim\wd\printedrefnamebox = 0pt
8940 \refx{#1-snt}{}%
8941 \else
8942 \printedrefname
8943 \fi
8944 %
8945 % If the user also gave the printed manual name (fifth arg), append
8946 % "in MANUALNAME".
8947 \ifdim \wd\printedmanualbox > 0pt
8948 \space \putwordin{} \cite{\printedmanual}%
8949 \fi
8950 \else
8951 % node/anchor (non-float) references.
8952 %
8953 % If we use \unhbox to print the node names, TeX does not insert
8954 % empty discretionaries after hyphens, which means that it will not
8955 % find a line break at a hyphen in a node names. Since some manuals
8956 % are best written with fairly long node names, containing hyphens,
8957 % this is a loss. Therefore, we give the text of the node name
8958 % again, so it is as if TeX is seeing it for the first time.
8959 %
8960 \ifdim \wd\printedmanualbox > 0pt
8961 % Cross-manual reference with a printed manual name.
8962 %
8963 \crossmanualxref{\cite{\printedmanual\unskip}}%
8964 %
8965 \else\ifdim \wd\infofilenamebox > 0pt
8966 % Cross-manual reference with only an info filename (arg 4), no
8967 % printed manual name (arg 5). This is essentially the same as
8968 % the case above; we output the filename, since we have nothing else.
8969 %
8970 \crossmanualxref{\code{\infofilename\unskip}}%
8971 %
8972 \else
8973 % Reference within this manual.
8974 %
8975 % _ (for example) has to be the character _ for the purposes of the
8976 % control sequence corresponding to the node, but it has to expand
8977 % into the usual \leavevmode...\vrule stuff for purposes of
8978 % printing. So we \turnoffactive for the \refx-snt, back on for the
8979 % printing, back off for the \refx-pg.
8980 {\turnoffactive
8981 % Only output a following space if the -snt ref is nonempty; for
8982 % @unnumbered and @anchor, it won't be.
8983 \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
8984 \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
8985 }%
8986 % output the `[mynode]' via the macro below so it can be overridden.
8987 \xrefprintnodename\printedrefname
8988 %
8989 % But we always want a comma and a space:
8990 ,\space
8991 %
8992 % output the `page 3'.
8993 \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
8994 % Add a , if xref followed by a space
8995 \if\space\noexpand\tokenafterxref ,%
8996 \else\ifx\ \tokenafterxref ,% @TAB
8997 \else\ifx\*\tokenafterxref ,% @*
8998 \else\ifx\ \tokenafterxref ,% @SPACE
8999 \else\ifx\
9000 \tokenafterxref ,% @NL
9001 \else\ifx\tie\tokenafterxref ,% @tie
9002 \fi\fi\fi\fi\fi\fi
9003 \fi\fi
9004 \fi
9005 \endlink
9006 \endgroup}
9007
9008 % Output a cross-manual xref to #1. Used just above (twice).
9009 %
9010 % Only include the text "Section ``foo'' in" if the foo is neither
9011 % missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply
9012 % "see The Foo Manual", the idea being to refer to the whole manual.
9013 %
9014 % But, this being TeX, we can't easily compare our node name against the
9015 % string "Top" while ignoring the possible spaces before and after in
9016 % the input. By adding the arbitrary 7sp below, we make it much less
9017 % likely that a real node name would have the same width as "Top" (e.g.,
9018 % in a monospaced font). Hopefully it will never happen in practice.
9019 %
9020 % For the same basic reason, we retypeset the "Top" at every
9021 % reference, since the current font is indeterminate.
9022 %
9023 \def\crossmanualxref#1{%
9024 \setbox\toprefbox = \hbox{Top\kern7sp}%
9025 \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
9026 \ifdim \wd2 > 7sp % nonempty?
9027 \ifdim \wd2 = \wd\toprefbox \else % same as Top?
9028 \putwordSection{} ``\printedrefname'' \putwordin{}\space
9029 \fi
9030 \fi
9031 #1%
9032 }
9033
9034 % This macro is called from \xrefX for the `[nodename]' part of xref
9035 % output. It's a separate macro only so it can be changed more easily,
9036 % since square brackets don't work well in some documents. Particularly
9037 % one that Bob is working on :).
9038 %
9039 \def\xrefprintnodename#1{[#1]}
9040
9041 % Things referred to by \setref.
9042 %
9043 \def\Ynothing{}
9044 \def\Yomitfromtoc{}
9045 \def\Ynumbered{%
9046 \ifnum\secno=0
9047 \putwordChapter@tie \the\chapno
9048 \else \ifnum\subsecno=0
9049 \putwordSection@tie \the\chapno.\the\secno
9050 \else \ifnum\subsubsecno=0
9051 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
9052 \else
9053 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
9054 \fi\fi\fi
9055 }
9056 \def\Yappendix{%
9057 \ifnum\secno=0
9058 \putwordAppendix@tie @char\the\appendixno{}%
9059 \else \ifnum\subsecno=0
9060 \putwordSection@tie @char\the\appendixno.\the\secno
9061 \else \ifnum\subsubsecno=0
9062 \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
9063 \else
9064 \putwordSection@tie
9065 @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
9066 \fi\fi\fi
9067 }
9068
9069 % \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME. SUFFIX
9070 % is output afterwards if non-empty.
9071 \def\refx#1#2{%
9072 \requireauxfile
9073 {%
9074 \indexnofonts
9075 \otherbackslash
9076 \def\value##1{##1}%
9077 \expandafter\global\expandafter\let\expandafter\thisrefX
9078 \csname XR#1\endcsname
9079 }%
9080 \ifx\thisrefX\relax
9081 % If not defined, say something at least.
9082 \angleleft un\-de\-fined\angleright
9083 \iflinks
9084 \ifhavexrefs
9085 {\toks0 = {#1}% avoid expansion of possibly-complex value
9086 \message{\linenumber Undefined cross reference `\the\toks0'.}}%
9087 \else
9088 \ifwarnedxrefs\else
9089 \global\warnedxrefstrue
9090 \message{Cross reference values unknown; you must run TeX again.}%
9091 \fi
9092 \fi
9093 \fi
9094 \else
9095 % It's defined, so just use it.
9096 \thisrefX
9097 \fi
9098 #2% Output the suffix in any case.
9099 }
9100
9101 % This is the macro invoked by entries in the aux file. Define a control
9102 % sequence for a cross-reference target (we prepend XR to the control sequence
9103 % name to avoid collisions). The value is the page number. If this is a float
9104 % type, we have more work to do.
9105 %
9106 \def\xrdef#1#2{%
9107 {% Expand the node or anchor name to remove control sequences.
9108 % \turnoffactive stops 8-bit characters being changed to commands
9109 % like @'e. \refx does the same to retrieve the value in the definition.
9110 \indexnofonts
9111 \turnoffactive
9112 \def\value##1{##1}%
9113 \xdef\safexrefname{#1}%
9114 }%
9115 %
9116 \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref
9117 %
9118 % Was that xref control sequence that we just defined for a float?
9119 \expandafter\iffloat\csname XR\safexrefname\endcsname
9120 % it was a float, and we have the (safe) float type in \iffloattype.
9121 \expandafter\let\expandafter\floatlist
9122 \csname floatlist\iffloattype\endcsname
9123 %
9124 % Is this the first time we've seen this float type?
9125 \expandafter\ifx\floatlist\relax
9126 \toks0 = {\do}% yes, so just \do
9127 \else
9128 % had it before, so preserve previous elements in list.
9129 \toks0 = \expandafter{\floatlist\do}%
9130 \fi
9131 %
9132 % Remember this xref in the control sequence \floatlistFLOATTYPE,
9133 % for later use in \listoffloats.
9134 \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
9135 {\safexrefname}}%
9136 \fi
9137 }
9138
9139 % If working on a large document in chapters, it is convenient to
9140 % be able to disable indexing, cross-referencing, and contents, for test runs.
9141 % This is done with @novalidate at the beginning of the file.
9142 %
9143 \newif\iflinks \linkstrue % by default we want the aux files.
9144 \let\novalidate = \linksfalse
9145
9146 % Used when writing to the aux file, or when using data from it.
9147 \def\requireauxfile{%
9148 \iflinks
9149 \tryauxfile
9150 % Open the new aux file. TeX will close it automatically at exit.
9151 \immediate\openout\auxfile=\jobname.aux
9152 \fi
9153 \global\let\requireauxfile=\relax % Only do this once.
9154 }
9155
9156 % Read the last existing aux file, if any. No error if none exists.
9157 %
9158 \def\tryauxfile{%
9159 \openin 1 \jobname.aux
9160 \ifeof 1 \else
9161 \readdatafile{aux}%
9162 \global\havexrefstrue
9163 \fi
9164 \closein 1
9165 }
9166
9167 \def\setupdatafile{%
9168 \catcode`\^^@=\other
9169 \catcode`\^^A=\other
9170 \catcode`\^^B=\other
9171 \catcode`\^^C=\other
9172 \catcode`\^^D=\other
9173 \catcode`\^^E=\other
9174 \catcode`\^^F=\other
9175 \catcode`\^^G=\other
9176 \catcode`\^^H=\other
9177 \catcode`\^^K=\other
9178 \catcode`\^^L=\other
9179 \catcode`\^^N=\other
9180 \catcode`\^^P=\other
9181 \catcode`\^^Q=\other
9182 \catcode`\^^R=\other
9183 \catcode`\^^S=\other
9184 \catcode`\^^T=\other
9185 \catcode`\^^U=\other
9186 \catcode`\^^V=\other
9187 \catcode`\^^W=\other
9188 \catcode`\^^X=\other
9189 \catcode`\^^Z=\other
9190 \catcode`\^^[=\other
9191 \catcode`\^^\=\other
9192 \catcode`\^^]=\other
9193 \catcode`\^^^=\other
9194 \catcode`\^^_=\other
9195 % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
9196 % in xref tags, i.e., node names. But since ^^e4 notation isn't
9197 % supported in the main text, it doesn't seem desirable. Furthermore,
9198 % that is not enough: for node names that actually contain a ^
9199 % character, we would end up writing a line like this: 'xrdef {'hat
9200 % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
9201 % argument, and \hat is not an expandable control sequence. It could
9202 % all be worked out, but why? Either we support ^^ or we don't.
9203 %
9204 % The other change necessary for this was to define \auxhat:
9205 % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
9206 % and then to call \auxhat in \setq.
9207 %
9208 \catcode`\^=\other
9209 %
9210 % Special characters. Should be turned off anyway, but...
9211 \catcode`\~=\other
9212 \catcode`\[=\other
9213 \catcode`\]=\other
9214 \catcode`\"=\other
9215 \catcode`\_=\other
9216 \catcode`\|=\other
9217 \catcode`\<=\other
9218 \catcode`\>=\other
9219 \catcode`\$=\other
9220 \catcode`\#=\other
9221 \catcode`\&=\other
9222 \catcode`\%=\other
9223 \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
9224 %
9225 % This is to support \ in node names and titles, since the \
9226 % characters end up in a \csname. It's easier than
9227 % leaving it active and making its active definition an actual \
9228 % character. What I don't understand is why it works in the *value*
9229 % of the xrdef. Seems like it should be a catcode12 \, and that
9230 % should not typeset properly. But it works, so I'm moving on for
9231 % now. --karl, 15jan04.
9232 \catcode`\\=\other
9233 %
9234 % @ is our escape character in .aux files, and we need braces.
9235 \catcode`\{=1
9236 \catcode`\}=2
9237 \catcode`\@=0
9238 }
9239
9240 \def\readdatafile#1{%
9241 \begingroup
9242 \setupdatafile
9243 \input\jobname.#1
9244 \endgroup}
9245
9246
9247 \message{insertions,}
9248 % including footnotes.
9249
9250 \newcount \footnoteno
9251
9252 % The trailing space in the following definition for supereject is
9253 % vital for proper filling; pages come out unaligned when you do a
9254 % pagealignmacro call if that space before the closing brace is
9255 % removed. (Generally, numeric constants should always be followed by a
9256 % space to prevent strange expansion errors.)
9257 \def\supereject{\par\penalty -20000\footnoteno =0 }
9258
9259 % @footnotestyle is meaningful for Info output only.
9260 \let\footnotestyle=\comment
9261
9262 {\catcode `\@=11
9263 %
9264 % Auto-number footnotes. Otherwise like plain.
9265 \gdef\footnote{%
9266 \global\advance\footnoteno by \@ne
9267 \edef\thisfootno{$^{\the\footnoteno}$}%
9268 %
9269 % In case the footnote comes at the end of a sentence, preserve the
9270 % extra spacing after we do the footnote number.
9271 \let\@sf\empty
9272 \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9273 %
9274 % Remove inadvertent blank space before typesetting the footnote number.
9275 \unskip
9276 \thisfootno\@sf
9277 \dofootnote
9278 }%
9279
9280 % Don't bother with the trickery in plain.tex to not require the
9281 % footnote text as a parameter. Our footnotes don't need to be so general.
9282 %
9283 % Oh yes, they do; otherwise, @ifset (and anything else that uses
9284 % \parseargline) fails inside footnotes because the tokens are fixed when
9285 % the footnote is read. --karl, 16nov96.
9286 %
9287 \gdef\dofootnote{%
9288 \insert\footins\bgroup
9289 %
9290 % Nested footnotes are not supported in TeX, that would take a lot
9291 % more work. (\startsavinginserts does not suffice.)
9292 \let\footnote=\errfootnotenest
9293 %
9294 % We want to typeset this text as a normal paragraph, even if the
9295 % footnote reference occurs in (for example) a display environment.
9296 % So reset some parameters.
9297 \hsize=\txipagewidth
9298 \interlinepenalty\interfootnotelinepenalty
9299 \splittopskip\ht\strutbox % top baseline for broken footnotes
9300 \splitmaxdepth\dp\strutbox
9301 \floatingpenalty\@MM
9302 \leftskip\z@skip
9303 \rightskip\z@skip
9304 \spaceskip\z@skip
9305 \xspaceskip\z@skip
9306 \parindent\defaultparindent
9307 %
9308 \smallfonts \rm
9309 %
9310 % Because we use hanging indentation in footnotes, a @noindent appears
9311 % to exdent this text, so make it be a no-op. makeinfo does not use
9312 % hanging indentation so @noindent can still be needed within footnote
9313 % text after an @example or the like (not that this is good style).
9314 \let\noindent = \relax
9315 %
9316 % Hang the footnote text off the number. Use \everypar in case the
9317 % footnote extends for more than one paragraph.
9318 \everypar = {\hang}%
9319 \textindent{\thisfootno}%
9320 %
9321 % Don't crash into the line above the footnote text. Since this
9322 % expands into a box, it must come within the paragraph, lest it
9323 % provide a place where TeX can split the footnote.
9324 \footstrut
9325 %
9326 % Invoke rest of plain TeX footnote routine.
9327 \futurelet\next\fo@t
9328 }
9329 }%end \catcode `\@=11
9330
9331 \def\errfootnotenest{%
9332 \errhelp=\EMsimple
9333 \errmessage{Nested footnotes not supported in texinfo.tex,
9334 even though they work in makeinfo; sorry}
9335 }
9336
9337 \def\errfootnoteheading{%
9338 \errhelp=\EMsimple
9339 \errmessage{Footnotes in chapters, sections, etc., are not supported}
9340 }
9341
9342 % In case a @footnote appears in a vbox, save the footnote text and create
9343 % the real \insert just after the vbox finished. Otherwise, the insertion
9344 % would be lost.
9345 % Similarly, if a @footnote appears inside an alignment, save the footnote
9346 % text to a box and make the \insert when a row of the table is finished.
9347 % And the same can be done for other insert classes. --kasal, 16nov03.
9348 %
9349 % Replace the \insert primitive by a cheating macro.
9350 % Deeper inside, just make sure that the saved insertions are not spilled
9351 % out prematurely.
9352 %
9353 \def\startsavinginserts{%
9354 \ifx \insert\ptexinsert
9355 \let\insert\saveinsert
9356 \else
9357 \let\checkinserts\relax
9358 \fi
9359 }
9360
9361 % This \insert replacement works for both \insert\footins{foo} and
9362 % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9363 %
9364 \def\saveinsert#1{%
9365 \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9366 \afterassignment\next
9367 % swallow the left brace
9368 \let\temp =
9369 }
9370 \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9371 \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9372
9373 \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9374
9375 \def\placesaveins#1{%
9376 \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9377 {\box#1}%
9378 }
9379
9380 % eat @SAVE -- beware, all of them have catcode \other:
9381 {
9382 \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-)
9383 \gdef\gobblesave @SAVE{}
9384 }
9385
9386 % initialization:
9387 \def\newsaveins #1{%
9388 \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9389 \next
9390 }
9391 \def\newsaveinsX #1{%
9392 \csname newbox\endcsname #1%
9393 \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9394 \checksaveins #1}%
9395 }
9396
9397 % initialize:
9398 \let\checkinserts\empty
9399 \newsaveins\footins
9400 \newsaveins\margin
9401
9402
9403 % @image. We use the macros from epsf.tex to support this.
9404 % If epsf.tex is not installed and @image is used, we complain.
9405 %
9406 % Check for and read epsf.tex up front. If we read it only at @image
9407 % time, we might be inside a group, and then its definitions would get
9408 % undone and the next image would fail.
9409 \openin 1 = epsf.tex
9410 \ifeof 1 \else
9411 % Do not bother showing banner with epsf.tex v2.7k (available in
9412 % doc/epsf.tex and on ctan).
9413 \def\epsfannounce{\toks0 = }%
9414 \input epsf.tex
9415 \fi
9416 \closein 1
9417 %
9418 % We will only complain once about lack of epsf.tex.
9419 \newif\ifwarnednoepsf
9420 \newhelp\noepsfhelp{epsf.tex must be installed for images to
9421 work. It is also included in the Texinfo distribution, or you can get
9422 it from ftp://tug.org/tex/epsf.tex.}
9423 %
9424 \def\image#1{%
9425 \ifx\epsfbox\thisisundefined
9426 \ifwarnednoepsf \else
9427 \errhelp = \noepsfhelp
9428 \errmessage{epsf.tex not found, images will be ignored}%
9429 \global\warnednoepsftrue
9430 \fi
9431 \else
9432 \imagexxx #1,,,,,\finish
9433 \fi
9434 }
9435 %
9436 % Arguments to @image:
9437 % #1 is (mandatory) image filename; we tack on .eps extension.
9438 % #2 is (optional) width, #3 is (optional) height.
9439 % #4 is (ignored optional) html alt text.
9440 % #5 is (ignored optional) extension.
9441 % #6 is just the usual extra ignored arg for parsing stuff.
9442 \newif\ifimagevmode
9443 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
9444 \catcode`\^^M = 5 % in case we're inside an example
9445 \normalturnoffactive % allow _ et al. in names
9446 \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
9447 % If the image is by itself, center it.
9448 \ifvmode
9449 \imagevmodetrue
9450 \else \ifx\centersub\centerV
9451 % for @center @image, we need a vbox so we can have our vertical space
9452 \imagevmodetrue
9453 \vbox\bgroup % vbox has better behavior than vtop herev
9454 \fi\fi
9455 %
9456 \ifimagevmode
9457 \nobreak\medskip
9458 % Usually we'll have text after the image which will insert
9459 % \parskip glue, so insert it here too to equalize the space
9460 % above and below.
9461 \nobreak\vskip\parskip
9462 \nobreak
9463 \fi
9464 %
9465 % Leave vertical mode so that indentation from an enclosing
9466 % environment such as @quotation is respected.
9467 % However, if we're at the top level, we don't want the
9468 % normal paragraph indentation.
9469 % On the other hand, if we are in the case of @center @image, we don't
9470 % want to start a paragraph, which will create a hsize-width box and
9471 % eradicate the centering.
9472 \ifx\centersub\centerV\else \noindent \fi
9473 %
9474 % Output the image.
9475 \ifpdf
9476 % For pdfTeX and LuaTeX <= 0.80
9477 \dopdfimage{#1}{#2}{#3}%
9478 \else
9479 \ifx\XeTeXrevision\thisisundefined
9480 % For epsf.tex
9481 % \epsfbox itself resets \epsf?size at each figure.
9482 \setbox0 = \hbox{\ignorespaces #2}%
9483 \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9484 \setbox0 = \hbox{\ignorespaces #3}%
9485 \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9486 \epsfbox{#1.eps}%
9487 \else
9488 % For XeTeX
9489 \doxeteximage{#1}{#2}{#3}%
9490 \fi
9491 \fi
9492 %
9493 \ifimagevmode
9494 \medskip % space after a standalone image
9495 \fi
9496 \ifx\centersub\centerV \egroup \fi
9497 \endgroup}
9498
9499
9500 % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9501 % etc. We don't actually implement floating yet, we always include the
9502 % float "here". But it seemed the best name for the future.
9503 %
9504 \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9505
9506 % There may be a space before second and/or third parameter; delete it.
9507 \def\eatcommaspace#1, {#1,}
9508
9509 % #1 is the optional FLOATTYPE, the text label for this float, typically
9510 % "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
9511 % this float will not be numbered and cannot be referred to.
9512 %
9513 % #2 is the optional xref label. Also must be present for the float to
9514 % be referable.
9515 %
9516 % #3 is the optional positioning argument; for now, it is ignored. It
9517 % will somehow specify the positions allowed to float to (here, top, bottom).
9518 %
9519 % We keep a separate counter for each FLOATTYPE, which we reset at each
9520 % chapter-level command.
9521 \let\resetallfloatnos=\empty
9522 %
9523 \def\dofloat#1,#2,#3,#4\finish{%
9524 \let\thiscaption=\empty
9525 \let\thisshortcaption=\empty
9526 %
9527 % don't lose footnotes inside @float.
9528 %
9529 % BEWARE: when the floats start float, we have to issue warning whenever an
9530 % insert appears inside a float which could possibly float. --kasal, 26may04
9531 %
9532 \startsavinginserts
9533 %
9534 % We can't be used inside a paragraph.
9535 \par
9536 %
9537 \vtop\bgroup
9538 \def\floattype{#1}%
9539 \def\floatlabel{#2}%
9540 \def\floatloc{#3}% we do nothing with this yet.
9541 %
9542 \ifx\floattype\empty
9543 \let\safefloattype=\empty
9544 \else
9545 {%
9546 % the floattype might have accents or other special characters,
9547 % but we need to use it in a control sequence name.
9548 \indexnofonts
9549 \turnoffactive
9550 \xdef\safefloattype{\floattype}%
9551 }%
9552 \fi
9553 %
9554 % If label is given but no type, we handle that as the empty type.
9555 \ifx\floatlabel\empty \else
9556 % We want each FLOATTYPE to be numbered separately (Figure 1,
9557 % Table 1, Figure 2, ...). (And if no label, no number.)
9558 %
9559 \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9560 \global\advance\floatno by 1
9561 %
9562 {%
9563 % This magic value for \lastsection is output by \setref as the
9564 % XREFLABEL-title value. \xrefX uses it to distinguish float
9565 % labels (which have a completely different output format) from
9566 % node and anchor labels. And \xrdef uses it to construct the
9567 % lists of floats.
9568 %
9569 \edef\lastsection{\floatmagic=\safefloattype}%
9570 \setref{\floatlabel}{Yfloat}%
9571 }%
9572 \fi
9573 %
9574 % start with \parskip glue, I guess.
9575 \vskip\parskip
9576 %
9577 % Don't suppress indentation if a float happens to start a section.
9578 \restorefirstparagraphindent
9579 }
9580
9581 % we have these possibilities:
9582 % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9583 % @float Foo,lbl & no caption: Foo 1.1
9584 % @float Foo & @caption{Cap}: Foo: Cap
9585 % @float Foo & no caption: Foo
9586 % @float ,lbl & Caption{Cap}: 1.1: Cap
9587 % @float ,lbl & no caption: 1.1
9588 % @float & @caption{Cap}: Cap
9589 % @float & no caption:
9590 %
9591 \def\Efloat{%
9592 \let\floatident = \empty
9593 %
9594 % In all cases, if we have a float type, it comes first.
9595 \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9596 %
9597 % If we have an xref label, the number comes next.
9598 \ifx\floatlabel\empty \else
9599 \ifx\floattype\empty \else % if also had float type, need tie first.
9600 \appendtomacro\floatident{\tie}%
9601 \fi
9602 % the number.
9603 \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9604 \fi
9605 %
9606 % Start the printed caption with what we've constructed in
9607 % \floatident, but keep it separate; we need \floatident again.
9608 \let\captionline = \floatident
9609 %
9610 \ifx\thiscaption\empty \else
9611 \ifx\floatident\empty \else
9612 \appendtomacro\captionline{: }% had ident, so need a colon between
9613 \fi
9614 %
9615 % caption text.
9616 \appendtomacro\captionline{\scanexp\thiscaption}%
9617 \fi
9618 %
9619 % If we have anything to print, print it, with space before.
9620 % Eventually this needs to become an \insert.
9621 \ifx\captionline\empty \else
9622 \vskip.5\parskip
9623 \captionline
9624 %
9625 % Space below caption.
9626 \vskip\parskip
9627 \fi
9628 %
9629 % If have an xref label, write the list of floats info. Do this
9630 % after the caption, to avoid chance of it being a breakpoint.
9631 \ifx\floatlabel\empty \else
9632 % Write the text that goes in the lof to the aux file as
9633 % \floatlabel-lof. Besides \floatident, we include the short
9634 % caption if specified, else the full caption if specified, else nothing.
9635 {%
9636 \requireauxfile
9637 \atdummies
9638 %
9639 \ifx\thisshortcaption\empty
9640 \def\gtemp{\thiscaption}%
9641 \else
9642 \def\gtemp{\thisshortcaption}%
9643 \fi
9644 \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
9645 \ifx\gtemp\empty \else : \gtemp \fi}}%
9646 }%
9647 \fi
9648 \egroup % end of \vtop
9649 %
9650 \checkinserts
9651 }
9652
9653 % Append the tokens #2 to the definition of macro #1, not expanding either.
9654 %
9655 \def\appendtomacro#1#2{%
9656 \expandafter\def\expandafter#1\expandafter{#1#2}%
9657 }
9658
9659 % @caption, @shortcaption
9660 %
9661 \def\caption{\docaption\thiscaption}
9662 \def\shortcaption{\docaption\thisshortcaption}
9663 \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
9664 \def\defcaption#1#2{\egroup \def#1{#2}}
9665
9666 % The parameter is the control sequence identifying the counter we are
9667 % going to use. Create it if it doesn't exist and assign it to \floatno.
9668 \def\getfloatno#1{%
9669 \ifx#1\relax
9670 % Haven't seen this figure type before.
9671 \csname newcount\endcsname #1%
9672 %
9673 % Remember to reset this floatno at the next chap.
9674 \expandafter\gdef\expandafter\resetallfloatnos
9675 \expandafter{\resetallfloatnos #1=0 }%
9676 \fi
9677 \let\floatno#1%
9678 }
9679
9680 % \setref calls this to get the XREFLABEL-snt value. We want an @xref
9681 % to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
9682 % first read the @float command.
9683 %
9684 \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9685
9686 % Magic string used for the XREFLABEL-title value, so \xrefX can
9687 % distinguish floats from other xref types.
9688 \def\floatmagic{!!float!!}
9689
9690 % #1 is the control sequence we are passed; we expand into a conditional
9691 % which is true if #1 represents a float ref. That is, the magic
9692 % \lastsection value which we \setref above.
9693 %
9694 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
9695 %
9696 % #1 is (maybe) the \floatmagic string. If so, #2 will be the
9697 % (safe) float type for this float. We set \iffloattype to #2.
9698 %
9699 \def\doiffloat#1=#2=#3\finish{%
9700 \def\temp{#1}%
9701 \def\iffloattype{#2}%
9702 \ifx\temp\floatmagic
9703 }
9704
9705 % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9706 %
9707 \parseargdef\listoffloats{%
9708 \def\floattype{#1}% floattype
9709 {%
9710 % the floattype might have accents or other special characters,
9711 % but we need to use it in a control sequence name.
9712 \indexnofonts
9713 \turnoffactive
9714 \xdef\safefloattype{\floattype}%
9715 }%
9716 %
9717 % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9718 \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9719 \ifhavexrefs
9720 % if the user said @listoffloats foo but never @float foo.
9721 \message{\linenumber No `\safefloattype' floats to list.}%
9722 \fi
9723 \else
9724 \begingroup
9725 \leftskip=\tocindent % indent these entries like a toc
9726 \let\do=\listoffloatsdo
9727 \csname floatlist\safefloattype\endcsname
9728 \endgroup
9729 \fi
9730 }
9731
9732 % This is called on each entry in a list of floats. We're passed the
9733 % xref label, in the form LABEL-title, which is how we save it in the
9734 % aux file. We strip off the -title and look up \XRLABEL-lof, which
9735 % has the text we're supposed to typeset here.
9736 %
9737 % Figures without xref labels will not be included in the list (since
9738 % they won't appear in the aux file).
9739 %
9740 \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9741 \def\listoffloatsdoentry#1-title\finish{{%
9742 % Can't fully expand XR#1-lof because it can contain anything. Just
9743 % pass the control sequence. On the other hand, XR#1-pg is just the
9744 % page number, and we want to fully expand that so we can get a link
9745 % in pdf output.
9746 \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9747 %
9748 % use the same \entry macro we use to generate the TOC and index.
9749 \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9750 \writeentry
9751 }}
9752
9753
9754 \message{localization,}
9755
9756 % For single-language documents, @documentlanguage is usually given very
9757 % early, just after @documentencoding. Single argument is the language
9758 % (de) or locale (de_DE) abbreviation.
9759 %
9760 {
9761 \catcode`\_ = \active
9762 \globaldefs=1
9763 \parseargdef\documentlanguage{%
9764 \tex % read txi-??.tex file in plain TeX.
9765 % Read the file by the name they passed if it exists.
9766 \let_ = \normalunderscore % normal _ character for filename test
9767 \openin 1 txi-#1.tex
9768 \ifeof 1
9769 \documentlanguagetrywithoutunderscore #1_\finish
9770 \else
9771 \globaldefs = 1 % everything in the txi-LL files needs to persist
9772 \input txi-#1.tex
9773 \fi
9774 \closein 1
9775 \endgroup % end raw TeX
9776 }
9777 %
9778 % If they passed de_DE, and txi-de_DE.tex doesn't exist,
9779 % try txi-de.tex.
9780 %
9781 \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
9782 \openin 1 txi-#1.tex
9783 \ifeof 1
9784 \errhelp = \nolanghelp
9785 \errmessage{Cannot read language file txi-#1.tex}%
9786 \else
9787 \globaldefs = 1 % everything in the txi-LL files needs to persist
9788 \input txi-#1.tex
9789 \fi
9790 \closein 1
9791 }
9792 }% end of special _ catcode
9793 %
9794 \newhelp\nolanghelp{The given language definition file cannot be found or
9795 is empty. Maybe you need to install it? Putting it in the current
9796 directory should work if nowhere else does.}
9797
9798 % This macro is called from txi-??.tex files; the first argument is the
9799 % \language name to set (without the "\lang@" prefix), the second and
9800 % third args are \{left,right}hyphenmin.
9801 %
9802 % The language names to pass are determined when the format is built.
9803 % See the etex.log file created at that time, e.g.,
9804 % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9805 %
9806 % With TeX Live 2008, etex now includes hyphenation patterns for all
9807 % available languages. This means we can support hyphenation in
9808 % Texinfo, at least to some extent. (This still doesn't solve the
9809 % accented characters problem.)
9810 %
9811 \catcode`@=11
9812 \def\txisetlanguage#1#2#3{%
9813 % do not set the language if the name is undefined in the current TeX.
9814 \expandafter\ifx\csname lang@#1\endcsname \relax
9815 \message{no patterns for #1}%
9816 \else
9817 \global\language = \csname lang@#1\endcsname
9818 \fi
9819 % but there is no harm in adjusting the hyphenmin values regardless.
9820 \global\lefthyphenmin = #2\relax
9821 \global\righthyphenmin = #3\relax
9822 }
9823
9824 % XeTeX and LuaTeX can handle native Unicode.
9825 % Their default I/O is UTF-8 sequence instead of byte-wise.
9826 % Other TeX engine (pdfTeX etc.) I/O is byte-wise.
9827 %
9828 \newif\iftxinativeunicodecapable
9829 \newif\iftxiusebytewiseio
9830
9831 \ifx\XeTeXrevision\thisisundefined
9832 \ifx\luatexversion\thisisundefined
9833 \txinativeunicodecapablefalse
9834 \txiusebytewiseiotrue
9835 \else
9836 \txinativeunicodecapabletrue
9837 \txiusebytewiseiofalse
9838 \fi
9839 \else
9840 \txinativeunicodecapabletrue
9841 \txiusebytewiseiofalse
9842 \fi
9843
9844 % Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9845 % for non-UTF-8 (byte-wise) encodings.
9846 %
9847 \def\setbytewiseio{%
9848 \ifx\XeTeXrevision\thisisundefined
9849 \else
9850 \XeTeXdefaultencoding "bytes" % For subsequent files to be read
9851 \XeTeXinputencoding "bytes" % For document root file
9852 % Unfortunately, there seems to be no corresponding XeTeX command for
9853 % output encoding. This is a problem for auxiliary index and TOC files.
9854 % The only solution would be perhaps to write out @U{...} sequences in
9855 % place of non-ASCII characters.
9856 \fi
9857
9858 \ifx\luatexversion\thisisundefined
9859 \else
9860 \directlua{
9861 local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9862 local function convert_char (char)
9863 return utf8_char(byte(char))
9864 end
9865
9866 local function convert_line (line)
9867 return gsub(line, ".", convert_char)
9868 end
9869
9870 callback.register("process_input_buffer", convert_line)
9871
9872 local function convert_line_out (line)
9873 local line_out = ""
9874 for c in string.utfvalues(line) do
9875 line_out = line_out .. string.char(c)
9876 end
9877 return line_out
9878 end
9879
9880 callback.register("process_output_buffer", convert_line_out)
9881 }
9882 \fi
9883
9884 \txiusebytewiseiotrue
9885 }
9886
9887
9888 % Helpers for encodings.
9889 % Set the catcode of characters 128 through 255 to the specified number.
9890 %
9891 \def\setnonasciicharscatcode#1{%
9892 \count255=128
9893 \loop\ifnum\count255<256
9894 \global\catcode\count255=#1\relax
9895 \advance\count255 by 1
9896 \repeat
9897 }
9898
9899 \def\setnonasciicharscatcodenonglobal#1{%
9900 \count255=128
9901 \loop\ifnum\count255<256
9902 \catcode\count255=#1\relax
9903 \advance\count255 by 1
9904 \repeat
9905 }
9906
9907 % @documentencoding sets the definition of non-ASCII characters
9908 % according to the specified encoding.
9909 %
9910 \def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9911 \def\documentencodingzzz#1{%
9912 %
9913 % Encoding being declared for the document.
9914 \def\declaredencoding{\csname #1.enc\endcsname}%
9915 %
9916 % Supported encodings: names converted to tokens in order to be able
9917 % to compare them with \ifx.
9918 \def\ascii{\csname US-ASCII.enc\endcsname}%
9919 \def\latnine{\csname ISO-8859-15.enc\endcsname}%
9920 \def\latone{\csname ISO-8859-1.enc\endcsname}%
9921 \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
9922 \def\utfeight{\csname UTF-8.enc\endcsname}%
9923 %
9924 \ifx \declaredencoding \ascii
9925 \asciichardefs
9926 %
9927 \else \ifx \declaredencoding \lattwo
9928 \iftxinativeunicodecapable
9929 \setbytewiseio
9930 \fi
9931 \setnonasciicharscatcode\active
9932 \lattwochardefs
9933 %
9934 \else \ifx \declaredencoding \latone
9935 \iftxinativeunicodecapable
9936 \setbytewiseio
9937 \fi
9938 \setnonasciicharscatcode\active
9939 \latonechardefs
9940 %
9941 \else \ifx \declaredencoding \latnine
9942 \iftxinativeunicodecapable
9943 \setbytewiseio
9944 \fi
9945 \setnonasciicharscatcode\active
9946 \latninechardefs
9947 %
9948 \else \ifx \declaredencoding \utfeight
9949 \iftxinativeunicodecapable
9950 % For native Unicode (XeTeX and LuaTeX)
9951 \nativeunicodechardefs
9952 \else
9953 % For UTF-8 byte sequence (TeX, eTeX and pdfTeX)
9954 \setnonasciicharscatcode\active
9955 % since we already invoked \utfeightchardefs at the top level
9956 % (below), do not re-invoke it, then our check for duplicated
9957 % definitions triggers. Making non-ascii chars active is enough.
9958 \fi
9959 %
9960 \else
9961 \message{Ignoring unknown document encoding: #1.}%
9962 %
9963 \fi % utfeight
9964 \fi % latnine
9965 \fi % latone
9966 \fi % lattwo
9967 \fi % ascii
9968 }
9969
9970 % emacs-page
9971 % A message to be logged when using a character that isn't available
9972 % the default font encoding (OT1).
9973 %
9974 \def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
9975
9976 % Take account of \c (plain) vs. \, (Texinfo) difference.
9977 \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
9978
9979 % First, make active non-ASCII characters in order for them to be
9980 % correctly categorized when TeX reads the replacement text of
9981 % macros containing the character definitions.
9982 \setnonasciicharscatcode\active
9983 %
9984
9985 \def\gdefchar#1#2{%
9986 \gdef#1{%
9987 \ifpassthroughchars
9988 \string#1%
9989 \else
9990 #2%
9991 \fi
9992 }}
9993
9994 % Latin1 (ISO-8859-1) character definitions.
9995 \def\latonechardefs{%
9996 \gdefchar^^a0{\tie}
9997 \gdefchar^^a1{\exclamdown}
9998 \gdefchar^^a2{{\tcfont \char162}} % cent
9999 \gdefchar^^a3{\pounds}
10000 \gdefchar^^a4{{\tcfont \char164}} % currency
10001 \gdefchar^^a5{{\tcfont \char165}} % yen
10002 \gdefchar^^a6{{\tcfont \char166}} % broken bar
10003 \gdefchar^^a7{\S}
10004 \gdefchar^^a8{\"{}}
10005 \gdefchar^^a9{\copyright}
10006 \gdefchar^^aa{\ordf}
10007 \gdefchar^^ab{\guillemetleft}
10008 \gdefchar^^ac{\ensuremath\lnot}
10009 \gdefchar^^ad{\-}
10010 \gdefchar^^ae{\registeredsymbol}
10011 \gdefchar^^af{\={}}
10012 %
10013 \gdefchar^^b0{\textdegree}
10014 \gdefchar^^b1{$\pm$}
10015 \gdefchar^^b2{$^2$}
10016 \gdefchar^^b3{$^3$}
10017 \gdefchar^^b4{\'{}}
10018 \gdefchar^^b5{$\mu$}
10019 \gdefchar^^b6{\P}
10020 \gdefchar^^b7{\ensuremath\cdot}
10021 \gdefchar^^b8{\cedilla\ }
10022 \gdefchar^^b9{$^1$}
10023 \gdefchar^^ba{\ordm}
10024 \gdefchar^^bb{\guillemetright}
10025 \gdefchar^^bc{$1\over4$}
10026 \gdefchar^^bd{$1\over2$}
10027 \gdefchar^^be{$3\over4$}
10028 \gdefchar^^bf{\questiondown}
10029 %
10030 \gdefchar^^c0{\`A}
10031 \gdefchar^^c1{\'A}
10032 \gdefchar^^c2{\^A}
10033 \gdefchar^^c3{\~A}
10034 \gdefchar^^c4{\"A}
10035 \gdefchar^^c5{\ringaccent A}
10036 \gdefchar^^c6{\AE}
10037 \gdefchar^^c7{\cedilla C}
10038 \gdefchar^^c8{\`E}
10039 \gdefchar^^c9{\'E}
10040 \gdefchar^^ca{\^E}
10041 \gdefchar^^cb{\"E}
10042 \gdefchar^^cc{\`I}
10043 \gdefchar^^cd{\'I}
10044 \gdefchar^^ce{\^I}
10045 \gdefchar^^cf{\"I}
10046 %
10047 \gdefchar^^d0{\DH}
10048 \gdefchar^^d1{\~N}
10049 \gdefchar^^d2{\`O}
10050 \gdefchar^^d3{\'O}
10051 \gdefchar^^d4{\^O}
10052 \gdefchar^^d5{\~O}
10053 \gdefchar^^d6{\"O}
10054 \gdefchar^^d7{$\times$}
10055 \gdefchar^^d8{\O}
10056 \gdefchar^^d9{\`U}
10057 \gdefchar^^da{\'U}
10058 \gdefchar^^db{\^U}
10059 \gdefchar^^dc{\"U}
10060 \gdefchar^^dd{\'Y}
10061 \gdefchar^^de{\TH}
10062 \gdefchar^^df{\ss}
10063 %
10064 \gdefchar^^e0{\`a}
10065 \gdefchar^^e1{\'a}
10066 \gdefchar^^e2{\^a}
10067 \gdefchar^^e3{\~a}
10068 \gdefchar^^e4{\"a}
10069 \gdefchar^^e5{\ringaccent a}
10070 \gdefchar^^e6{\ae}
10071 \gdefchar^^e7{\cedilla c}
10072 \gdefchar^^e8{\`e}
10073 \gdefchar^^e9{\'e}
10074 \gdefchar^^ea{\^e}
10075 \gdefchar^^eb{\"e}
10076 \gdefchar^^ec{\`{\dotless i}}
10077 \gdefchar^^ed{\'{\dotless i}}
10078 \gdefchar^^ee{\^{\dotless i}}
10079 \gdefchar^^ef{\"{\dotless i}}
10080 %
10081 \gdefchar^^f0{\dh}
10082 \gdefchar^^f1{\~n}
10083 \gdefchar^^f2{\`o}
10084 \gdefchar^^f3{\'o}
10085 \gdefchar^^f4{\^o}
10086 \gdefchar^^f5{\~o}
10087 \gdefchar^^f6{\"o}
10088 \gdefchar^^f7{$\div$}
10089 \gdefchar^^f8{\o}
10090 \gdefchar^^f9{\`u}
10091 \gdefchar^^fa{\'u}
10092 \gdefchar^^fb{\^u}
10093 \gdefchar^^fc{\"u}
10094 \gdefchar^^fd{\'y}
10095 \gdefchar^^fe{\th}
10096 \gdefchar^^ff{\"y}
10097 }
10098
10099 % Latin9 (ISO-8859-15) encoding character definitions.
10100 \def\latninechardefs{%
10101 % Encoding is almost identical to Latin1.
10102 \latonechardefs
10103 %
10104 \gdefchar^^a4{\euro}
10105 \gdefchar^^a6{\v S}
10106 \gdefchar^^a8{\v s}
10107 \gdefchar^^b4{\v Z}
10108 \gdefchar^^b8{\v z}
10109 \gdefchar^^bc{\OE}
10110 \gdefchar^^bd{\oe}
10111 \gdefchar^^be{\"Y}
10112 }
10113
10114 % Latin2 (ISO-8859-2) character definitions.
10115 \def\lattwochardefs{%
10116 \gdefchar^^a0{\tie}
10117 \gdefchar^^a1{\ogonek{A}}
10118 \gdefchar^^a2{\u{}}
10119 \gdefchar^^a3{\L}
10120 \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
10121 \gdefchar^^a5{\v L}
10122 \gdefchar^^a6{\'S}
10123 \gdefchar^^a7{\S}
10124 \gdefchar^^a8{\"{}}
10125 \gdefchar^^a9{\v S}
10126 \gdefchar^^aa{\cedilla S}
10127 \gdefchar^^ab{\v T}
10128 \gdefchar^^ac{\'Z}
10129 \gdefchar^^ad{\-}
10130 \gdefchar^^ae{\v Z}
10131 \gdefchar^^af{\dotaccent Z}
10132 %
10133 \gdefchar^^b0{\textdegree}
10134 \gdefchar^^b1{\ogonek{a}}
10135 \gdefchar^^b2{\ogonek{ }}
10136 \gdefchar^^b3{\l}
10137 \gdefchar^^b4{\'{}}
10138 \gdefchar^^b5{\v l}
10139 \gdefchar^^b6{\'s}
10140 \gdefchar^^b7{\v{}}
10141 \gdefchar^^b8{\cedilla\ }
10142 \gdefchar^^b9{\v s}
10143 \gdefchar^^ba{\cedilla s}
10144 \gdefchar^^bb{\v t}
10145 \gdefchar^^bc{\'z}
10146 \gdefchar^^bd{\H{}}
10147 \gdefchar^^be{\v z}
10148 \gdefchar^^bf{\dotaccent z}
10149 %
10150 \gdefchar^^c0{\'R}
10151 \gdefchar^^c1{\'A}
10152 \gdefchar^^c2{\^A}
10153 \gdefchar^^c3{\u A}
10154 \gdefchar^^c4{\"A}
10155 \gdefchar^^c5{\'L}
10156 \gdefchar^^c6{\'C}
10157 \gdefchar^^c7{\cedilla C}
10158 \gdefchar^^c8{\v C}
10159 \gdefchar^^c9{\'E}
10160 \gdefchar^^ca{\ogonek{E}}
10161 \gdefchar^^cb{\"E}
10162 \gdefchar^^cc{\v E}
10163 \gdefchar^^cd{\'I}
10164 \gdefchar^^ce{\^I}
10165 \gdefchar^^cf{\v D}
10166 %
10167 \gdefchar^^d0{\DH}
10168 \gdefchar^^d1{\'N}
10169 \gdefchar^^d2{\v N}
10170 \gdefchar^^d3{\'O}
10171 \gdefchar^^d4{\^O}
10172 \gdefchar^^d5{\H O}
10173 \gdefchar^^d6{\"O}
10174 \gdefchar^^d7{$\times$}
10175 \gdefchar^^d8{\v R}
10176 \gdefchar^^d9{\ringaccent U}
10177 \gdefchar^^da{\'U}
10178 \gdefchar^^db{\H U}
10179 \gdefchar^^dc{\"U}
10180 \gdefchar^^dd{\'Y}
10181 \gdefchar^^de{\cedilla T}
10182 \gdefchar^^df{\ss}
10183 %
10184 \gdefchar^^e0{\'r}
10185 \gdefchar^^e1{\'a}
10186 \gdefchar^^e2{\^a}
10187 \gdefchar^^e3{\u a}
10188 \gdefchar^^e4{\"a}
10189 \gdefchar^^e5{\'l}
10190 \gdefchar^^e6{\'c}
10191 \gdefchar^^e7{\cedilla c}
10192 \gdefchar^^e8{\v c}
10193 \gdefchar^^e9{\'e}
10194 \gdefchar^^ea{\ogonek{e}}
10195 \gdefchar^^eb{\"e}
10196 \gdefchar^^ec{\v e}
10197 \gdefchar^^ed{\'{\dotless{i}}}
10198 \gdefchar^^ee{\^{\dotless{i}}}
10199 \gdefchar^^ef{\v d}
10200 %
10201 \gdefchar^^f0{\dh}
10202 \gdefchar^^f1{\'n}
10203 \gdefchar^^f2{\v n}
10204 \gdefchar^^f3{\'o}
10205 \gdefchar^^f4{\^o}
10206 \gdefchar^^f5{\H o}
10207 \gdefchar^^f6{\"o}
10208 \gdefchar^^f7{$\div$}
10209 \gdefchar^^f8{\v r}
10210 \gdefchar^^f9{\ringaccent u}
10211 \gdefchar^^fa{\'u}
10212 \gdefchar^^fb{\H u}
10213 \gdefchar^^fc{\"u}
10214 \gdefchar^^fd{\'y}
10215 \gdefchar^^fe{\cedilla t}
10216 \gdefchar^^ff{\dotaccent{}}
10217 }
10218
10219 % UTF-8 character definitions.
10220 %
10221 % This code to support UTF-8 is based on LaTeX's utf8.def, with some
10222 % changes for Texinfo conventions. It is included here under the GPL by
10223 % permission from Frank Mittelbach and the LaTeX team.
10224 %
10225 \newcount\countUTFx
10226 \newcount\countUTFy
10227 \newcount\countUTFz
10228
10229 \gdef\UTFviiiTwoOctets#1#2{\expandafter
10230 \UTFviiiDefined\csname u8:#1\string #2\endcsname}
10231 %
10232 \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
10233 \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
10234 %
10235 \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
10236 \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
10237
10238 \gdef\UTFviiiDefined#1{%
10239 \ifx #1\relax
10240 \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10241 \else
10242 \expandafter #1%
10243 \fi
10244 }
10245
10246 % Give non-ASCII bytes the active definitions for processing UTF-8 sequences
10247 \begingroup
10248 \catcode`\~13
10249 \catcode`\$12
10250 \catcode`\"12
10251
10252 % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
10253 % substituting ~ and $ with a character token of that value.
10254 \def\UTFviiiLoop{%
10255 \global\catcode\countUTFx\active
10256 \uccode`\~\countUTFx
10257 \uccode`\$\countUTFx
10258 \uppercase\expandafter{\UTFviiiTmp}%
10259 \advance\countUTFx by 1
10260 \ifnum\countUTFx < \countUTFy
10261 \expandafter\UTFviiiLoop
10262 \fi}
10263
10264 % For bytes other than the first in a UTF-8 sequence. Not expected to
10265 % be expanded except when writing to auxiliary files.
10266 \countUTFx = "80
10267 \countUTFy = "C2
10268 \def\UTFviiiTmp{%
10269 \gdef~{%
10270 \ifpassthroughchars $\fi}}%
10271 \UTFviiiLoop
10272
10273 \countUTFx = "C2
10274 \countUTFy = "E0
10275 \def\UTFviiiTmp{%
10276 \gdef~{%
10277 \ifpassthroughchars $%
10278 \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
10279 \UTFviiiLoop
10280
10281 \countUTFx = "E0
10282 \countUTFy = "F0
10283 \def\UTFviiiTmp{%
10284 \gdef~{%
10285 \ifpassthroughchars $%
10286 \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
10287 \UTFviiiLoop
10288
10289 \countUTFx = "F0
10290 \countUTFy = "F4
10291 \def\UTFviiiTmp{%
10292 \gdef~{%
10293 \ifpassthroughchars $%
10294 \else\expandafter\UTFviiiFourOctets\expandafter$\fi
10295 }}%
10296 \UTFviiiLoop
10297 \endgroup
10298
10299 \def\globallet{\global\let} % save some \expandafter's below
10300
10301 % @U{xxxx} to produce U+xxxx, if we support it.
10302 \def\U#1{%
10303 \expandafter\ifx\csname uni:#1\endcsname \relax
10304 \iftxinativeunicodecapable
10305 % Any Unicode characters can be used by native Unicode.
10306 % However, if the font does not have the glyph, the letter will miss.
10307 \begingroup
10308 \uccode`\.="#1\relax
10309 \uppercase{.}
10310 \endgroup
10311 \else
10312 \errhelp = \EMsimple
10313 \errmessage{Unicode character U+#1 not supported, sorry}%
10314 \fi
10315 \else
10316 \csname uni:#1\endcsname
10317 \fi
10318 }
10319
10320 % These macros are used here to construct the name of a control
10321 % sequence to be defined.
10322 \def\UTFviiiTwoOctetsName#1#2{%
10323 \csname u8:#1\string #2\endcsname}%
10324 \def\UTFviiiThreeOctetsName#1#2#3{%
10325 \csname u8:#1\string #2\string #3\endcsname}%
10326 \def\UTFviiiFourOctetsName#1#2#3#4{%
10327 \csname u8:#1\string #2\string #3\string #4\endcsname}%
10328
10329 % For UTF-8 byte sequence (TeX, e-TeX and pdfTeX)
10330 % Definition macro to replace the Unicode character
10331 % Definition macro that is used by @U command
10332 %
10333 \begingroup
10334 \catcode`\"=12
10335 \catcode`\<=12
10336 \catcode`\.=12
10337 \catcode`\,=12
10338 \catcode`\;=12
10339 \catcode`\!=12
10340 \catcode`\~=13
10341 \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
10342 \countUTFz = "#1\relax
10343 \begingroup
10344 \parseXMLCharref
10345
10346 % Give \u8:... its definition. The sequence of seven \expandafter's
10347 % expands after the \gdef three times, e.g.
10348 %
10349 % 1. \UTFviiTwoOctetsName B1 B2
10350 % 2. \csname u8:B1 \string B2 \endcsname
10351 % 3. \u8: B1 B2 (a single control sequence token)
10352 %
10353 \expandafter\expandafter
10354 \expandafter\expandafter
10355 \expandafter\expandafter
10356 \expandafter\gdef \UTFviiiTmp{#2}%
10357 %
10358 \expandafter\ifx\csname uni:#1\endcsname \relax \else
10359 \message{Internal error, already defined: #1}%
10360 \fi
10361 %
10362 % define an additional control sequence for this code point.
10363 \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
10364 \endgroup}
10365 %
10366 % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp
10367 % to the corresponding UTF-8 sequence.
10368 \gdef\parseXMLCharref{%
10369 \ifnum\countUTFz < "A0\relax
10370 \errhelp = \EMsimple
10371 \errmessage{Cannot define Unicode char value < 00A0}%
10372 \else\ifnum\countUTFz < "800\relax
10373 \parseUTFviiiA,%
10374 \parseUTFviiiB C\UTFviiiTwoOctetsName.,%
10375 \else\ifnum\countUTFz < "10000\relax
10376 \parseUTFviiiA;%
10377 \parseUTFviiiA,%
10378 \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}%
10379 \else
10380 \parseUTFviiiA;%
10381 \parseUTFviiiA,%
10382 \parseUTFviiiA!%
10383 \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}%
10384 \fi\fi\fi
10385 }
10386
10387 % Extract a byte from the end of the UTF-8 representation of \countUTFx.
10388 % It must be a non-initial byte in the sequence.
10389 % Change \uccode of #1 for it to be used in \parseUTFviiiB as one
10390 % of the bytes.
10391 \gdef\parseUTFviiiA#1{%
10392 \countUTFx = \countUTFz
10393 \divide\countUTFz by 64
10394 \countUTFy = \countUTFz % Save to be the future value of \countUTFz.
10395 \multiply\countUTFz by 64
10396
10397 % \countUTFz is now \countUTFx with the last 5 bits cleared. Subtract
10398 % in order to get the last five bits.
10399 \advance\countUTFx by -\countUTFz
10400
10401 % Convert this to the byte in the UTF-8 sequence.
10402 \advance\countUTFx by 128
10403 \uccode `#1\countUTFx
10404 \countUTFz = \countUTFy}
10405
10406 % Used to put a UTF-8 byte sequence into \UTFviiiTmp
10407 % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8
10408 % sequence.
10409 % #2 is one of the \UTFviii*OctetsName macros.
10410 % #3 is always a full stop (.)
10411 % #4 is a template for the other bytes in the sequence. The values for these
10412 % bytes is substituted in here with \uppercase using the \uccode's.
10413 \gdef\parseUTFviiiB#1#2#3#4{%
10414 \advance\countUTFz by "#10\relax
10415 \uccode `#3\countUTFz
10416 \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10417 \endgroup
10418
10419 % For native Unicode (XeTeX and LuaTeX)
10420 % Definition macro that is set catcode other non global
10421 %
10422 \def\DeclareUnicodeCharacterNativeOther#1#2{%
10423 \catcode"#1=\other
10424 }
10425
10426 % https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10427 % U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10428 % U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10429 % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10430 % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10431 %
10432 % Many of our renditions are less than wonderful, and all the missing
10433 % characters are available somewhere. Loading the necessary fonts
10434 % awaits user request. We can't truly support Unicode without
10435 % reimplementing everything that's been done in LaTeX for many years,
10436 % plus probably using luatex or xetex, and who knows what else.
10437 % We won't be doing that here in this simple file. But we can try to at
10438 % least make most of the characters not bomb out.
10439 %
10440 \def\unicodechardefs{%
10441 \DeclareUnicodeCharacter{00A0}{\tie}%
10442 \DeclareUnicodeCharacter{00A1}{\exclamdown}%
10443 \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
10444 \DeclareUnicodeCharacter{00A3}{\pounds}%
10445 \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10446 \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10447 \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
10448 \DeclareUnicodeCharacter{00A7}{\S}%
10449 \DeclareUnicodeCharacter{00A8}{\"{ }}%
10450 \DeclareUnicodeCharacter{00A9}{\copyright}%
10451 \DeclareUnicodeCharacter{00AA}{\ordf}%
10452 \DeclareUnicodeCharacter{00AB}{\guillemetleft}%
10453 \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10454 \DeclareUnicodeCharacter{00AD}{\-}%
10455 \DeclareUnicodeCharacter{00AE}{\registeredsymbol}%
10456 \DeclareUnicodeCharacter{00AF}{\={ }}%
10457 %
10458 \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
10459 \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10460 \DeclareUnicodeCharacter{00B2}{$^2$}%
10461 \DeclareUnicodeCharacter{00B3}{$^3$}%
10462 \DeclareUnicodeCharacter{00B4}{\'{ }}%
10463 \DeclareUnicodeCharacter{00B5}{$\mu$}%
10464 \DeclareUnicodeCharacter{00B6}{\P}%
10465 \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10466 \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10467 \DeclareUnicodeCharacter{00B9}{$^1$}%
10468 \DeclareUnicodeCharacter{00BA}{\ordm}%
10469 \DeclareUnicodeCharacter{00BB}{\guillemetright}%
10470 \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10471 \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10472 \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10473 \DeclareUnicodeCharacter{00BF}{\questiondown}%
10474 %
10475 \DeclareUnicodeCharacter{00C0}{\`A}%
10476 \DeclareUnicodeCharacter{00C1}{\'A}%
10477 \DeclareUnicodeCharacter{00C2}{\^A}%
10478 \DeclareUnicodeCharacter{00C3}{\~A}%
10479 \DeclareUnicodeCharacter{00C4}{\"A}%
10480 \DeclareUnicodeCharacter{00C5}{\AA}%
10481 \DeclareUnicodeCharacter{00C6}{\AE}%
10482 \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10483 \DeclareUnicodeCharacter{00C8}{\`E}%
10484 \DeclareUnicodeCharacter{00C9}{\'E}%
10485 \DeclareUnicodeCharacter{00CA}{\^E}%
10486 \DeclareUnicodeCharacter{00CB}{\"E}%
10487 \DeclareUnicodeCharacter{00CC}{\`I}%
10488 \DeclareUnicodeCharacter{00CD}{\'I}%
10489 \DeclareUnicodeCharacter{00CE}{\^I}%
10490 \DeclareUnicodeCharacter{00CF}{\"I}%
10491 %
10492 \DeclareUnicodeCharacter{00D0}{\DH}%
10493 \DeclareUnicodeCharacter{00D1}{\~N}%
10494 \DeclareUnicodeCharacter{00D2}{\`O}%
10495 \DeclareUnicodeCharacter{00D3}{\'O}%
10496 \DeclareUnicodeCharacter{00D4}{\^O}%
10497 \DeclareUnicodeCharacter{00D5}{\~O}%
10498 \DeclareUnicodeCharacter{00D6}{\"O}%
10499 \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10500 \DeclareUnicodeCharacter{00D8}{\O}%
10501 \DeclareUnicodeCharacter{00D9}{\`U}%
10502 \DeclareUnicodeCharacter{00DA}{\'U}%
10503 \DeclareUnicodeCharacter{00DB}{\^U}%
10504 \DeclareUnicodeCharacter{00DC}{\"U}%
10505 \DeclareUnicodeCharacter{00DD}{\'Y}%
10506 \DeclareUnicodeCharacter{00DE}{\TH}%
10507 \DeclareUnicodeCharacter{00DF}{\ss}%
10508 %
10509 \DeclareUnicodeCharacter{00E0}{\`a}%
10510 \DeclareUnicodeCharacter{00E1}{\'a}%
10511 \DeclareUnicodeCharacter{00E2}{\^a}%
10512 \DeclareUnicodeCharacter{00E3}{\~a}%
10513 \DeclareUnicodeCharacter{00E4}{\"a}%
10514 \DeclareUnicodeCharacter{00E5}{\aa}%
10515 \DeclareUnicodeCharacter{00E6}{\ae}%
10516 \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10517 \DeclareUnicodeCharacter{00E8}{\`e}%
10518 \DeclareUnicodeCharacter{00E9}{\'e}%
10519 \DeclareUnicodeCharacter{00EA}{\^e}%
10520 \DeclareUnicodeCharacter{00EB}{\"e}%
10521 \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10522 \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10523 \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10524 \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10525 %
10526 \DeclareUnicodeCharacter{00F0}{\dh}%
10527 \DeclareUnicodeCharacter{00F1}{\~n}%
10528 \DeclareUnicodeCharacter{00F2}{\`o}%
10529 \DeclareUnicodeCharacter{00F3}{\'o}%
10530 \DeclareUnicodeCharacter{00F4}{\^o}%
10531 \DeclareUnicodeCharacter{00F5}{\~o}%
10532 \DeclareUnicodeCharacter{00F6}{\"o}%
10533 \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10534 \DeclareUnicodeCharacter{00F8}{\o}%
10535 \DeclareUnicodeCharacter{00F9}{\`u}%
10536 \DeclareUnicodeCharacter{00FA}{\'u}%
10537 \DeclareUnicodeCharacter{00FB}{\^u}%
10538 \DeclareUnicodeCharacter{00FC}{\"u}%
10539 \DeclareUnicodeCharacter{00FD}{\'y}%
10540 \DeclareUnicodeCharacter{00FE}{\th}%
10541 \DeclareUnicodeCharacter{00FF}{\"y}%
10542 %
10543 \DeclareUnicodeCharacter{0100}{\=A}%
10544 \DeclareUnicodeCharacter{0101}{\=a}%
10545 \DeclareUnicodeCharacter{0102}{\u{A}}%
10546 \DeclareUnicodeCharacter{0103}{\u{a}}%
10547 \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10548 \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10549 \DeclareUnicodeCharacter{0106}{\'C}%
10550 \DeclareUnicodeCharacter{0107}{\'c}%
10551 \DeclareUnicodeCharacter{0108}{\^C}%
10552 \DeclareUnicodeCharacter{0109}{\^c}%
10553 \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10554 \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10555 \DeclareUnicodeCharacter{010C}{\v{C}}%
10556 \DeclareUnicodeCharacter{010D}{\v{c}}%
10557 \DeclareUnicodeCharacter{010E}{\v{D}}%
10558 \DeclareUnicodeCharacter{010F}{d'}%
10559 %
10560 \DeclareUnicodeCharacter{0110}{\DH}%
10561 \DeclareUnicodeCharacter{0111}{\dh}%
10562 \DeclareUnicodeCharacter{0112}{\=E}%
10563 \DeclareUnicodeCharacter{0113}{\=e}%
10564 \DeclareUnicodeCharacter{0114}{\u{E}}%
10565 \DeclareUnicodeCharacter{0115}{\u{e}}%
10566 \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10567 \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10568 \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10569 \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10570 \DeclareUnicodeCharacter{011A}{\v{E}}%
10571 \DeclareUnicodeCharacter{011B}{\v{e}}%
10572 \DeclareUnicodeCharacter{011C}{\^G}%
10573 \DeclareUnicodeCharacter{011D}{\^g}%
10574 \DeclareUnicodeCharacter{011E}{\u{G}}%
10575 \DeclareUnicodeCharacter{011F}{\u{g}}%
10576 %
10577 \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10578 \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10579 \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10580 \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10581 \DeclareUnicodeCharacter{0124}{\^H}%
10582 \DeclareUnicodeCharacter{0125}{\^h}%
10583 \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10584 \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10585 \DeclareUnicodeCharacter{0128}{\~I}%
10586 \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10587 \DeclareUnicodeCharacter{012A}{\=I}%
10588 \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10589 \DeclareUnicodeCharacter{012C}{\u{I}}%
10590 \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10591 \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10592 \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10593 %
10594 \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10595 \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10596 \DeclareUnicodeCharacter{0132}{IJ}%
10597 \DeclareUnicodeCharacter{0133}{ij}%
10598 \DeclareUnicodeCharacter{0134}{\^J}%
10599 \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10600 \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10601 \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10602 \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10603 \DeclareUnicodeCharacter{0139}{\'L}%
10604 \DeclareUnicodeCharacter{013A}{\'l}%
10605 \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10606 \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
10607 \DeclareUnicodeCharacter{013D}{L'}% should kern
10608 \DeclareUnicodeCharacter{013E}{l'}% should kern
10609 \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10610 %
10611 \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10612 \DeclareUnicodeCharacter{0141}{\L}%
10613 \DeclareUnicodeCharacter{0142}{\l}%
10614 \DeclareUnicodeCharacter{0143}{\'N}%
10615 \DeclareUnicodeCharacter{0144}{\'n}%
10616 \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10617 \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10618 \DeclareUnicodeCharacter{0147}{\v{N}}%
10619 \DeclareUnicodeCharacter{0148}{\v{n}}%
10620 \DeclareUnicodeCharacter{0149}{'n}%
10621 \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10622 \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10623 \DeclareUnicodeCharacter{014C}{\=O}%
10624 \DeclareUnicodeCharacter{014D}{\=o}%
10625 \DeclareUnicodeCharacter{014E}{\u{O}}%
10626 \DeclareUnicodeCharacter{014F}{\u{o}}%
10627 %
10628 \DeclareUnicodeCharacter{0150}{\H{O}}%
10629 \DeclareUnicodeCharacter{0151}{\H{o}}%
10630 \DeclareUnicodeCharacter{0152}{\OE}%
10631 \DeclareUnicodeCharacter{0153}{\oe}%
10632 \DeclareUnicodeCharacter{0154}{\'R}%
10633 \DeclareUnicodeCharacter{0155}{\'r}%
10634 \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10635 \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10636 \DeclareUnicodeCharacter{0158}{\v{R}}%
10637 \DeclareUnicodeCharacter{0159}{\v{r}}%
10638 \DeclareUnicodeCharacter{015A}{\'S}%
10639 \DeclareUnicodeCharacter{015B}{\'s}%
10640 \DeclareUnicodeCharacter{015C}{\^S}%
10641 \DeclareUnicodeCharacter{015D}{\^s}%
10642 \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10643 \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10644 %
10645 \DeclareUnicodeCharacter{0160}{\v{S}}%
10646 \DeclareUnicodeCharacter{0161}{\v{s}}%
10647 \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10648 \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10649 \DeclareUnicodeCharacter{0164}{\v{T}}%
10650 \DeclareUnicodeCharacter{0165}{\v{t}}%
10651 \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10652 \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10653 \DeclareUnicodeCharacter{0168}{\~U}%
10654 \DeclareUnicodeCharacter{0169}{\~u}%
10655 \DeclareUnicodeCharacter{016A}{\=U}%
10656 \DeclareUnicodeCharacter{016B}{\=u}%
10657 \DeclareUnicodeCharacter{016C}{\u{U}}%
10658 \DeclareUnicodeCharacter{016D}{\u{u}}%
10659 \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10660 \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10661 %
10662 \DeclareUnicodeCharacter{0170}{\H{U}}%
10663 \DeclareUnicodeCharacter{0171}{\H{u}}%
10664 \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10665 \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10666 \DeclareUnicodeCharacter{0174}{\^W}%
10667 \DeclareUnicodeCharacter{0175}{\^w}%
10668 \DeclareUnicodeCharacter{0176}{\^Y}%
10669 \DeclareUnicodeCharacter{0177}{\^y}%
10670 \DeclareUnicodeCharacter{0178}{\"Y}%
10671 \DeclareUnicodeCharacter{0179}{\'Z}%
10672 \DeclareUnicodeCharacter{017A}{\'z}%
10673 \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10674 \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10675 \DeclareUnicodeCharacter{017D}{\v{Z}}%
10676 \DeclareUnicodeCharacter{017E}{\v{z}}%
10677 \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10678 %
10679 \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10680 \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10681 \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10682 \DeclareUnicodeCharacter{01C7}{LJ}%
10683 \DeclareUnicodeCharacter{01C8}{Lj}%
10684 \DeclareUnicodeCharacter{01C9}{lj}%
10685 \DeclareUnicodeCharacter{01CA}{NJ}%
10686 \DeclareUnicodeCharacter{01CB}{Nj}%
10687 \DeclareUnicodeCharacter{01CC}{nj}%
10688 \DeclareUnicodeCharacter{01CD}{\v{A}}%
10689 \DeclareUnicodeCharacter{01CE}{\v{a}}%
10690 \DeclareUnicodeCharacter{01CF}{\v{I}}%
10691 %
10692 \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10693 \DeclareUnicodeCharacter{01D1}{\v{O}}%
10694 \DeclareUnicodeCharacter{01D2}{\v{o}}%
10695 \DeclareUnicodeCharacter{01D3}{\v{U}}%
10696 \DeclareUnicodeCharacter{01D4}{\v{u}}%
10697 %
10698 \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10699 \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10700 \DeclareUnicodeCharacter{01E6}{\v{G}}%
10701 \DeclareUnicodeCharacter{01E7}{\v{g}}%
10702 \DeclareUnicodeCharacter{01E8}{\v{K}}%
10703 \DeclareUnicodeCharacter{01E9}{\v{k}}%
10704 %
10705 \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10706 \DeclareUnicodeCharacter{01F1}{DZ}%
10707 \DeclareUnicodeCharacter{01F2}{Dz}%
10708 \DeclareUnicodeCharacter{01F3}{dz}%
10709 \DeclareUnicodeCharacter{01F4}{\'G}%
10710 \DeclareUnicodeCharacter{01F5}{\'g}%
10711 \DeclareUnicodeCharacter{01F8}{\`N}%
10712 \DeclareUnicodeCharacter{01F9}{\`n}%
10713 \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10714 \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10715 \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10716 \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10717 %
10718 \DeclareUnicodeCharacter{021E}{\v{H}}%
10719 \DeclareUnicodeCharacter{021F}{\v{h}}%
10720 %
10721 \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10722 \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10723 \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10724 \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10725 \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10726 \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10727 %
10728 \DeclareUnicodeCharacter{0232}{\=Y}%
10729 \DeclareUnicodeCharacter{0233}{\=y}%
10730 \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10731 %
10732 \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10733 %
10734 % Greek letters upper case
10735 \DeclareUnicodeCharacter{0391}{{\it A}}%
10736 \DeclareUnicodeCharacter{0392}{{\it B}}%
10737 \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10738 \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10739 \DeclareUnicodeCharacter{0395}{{\it E}}%
10740 \DeclareUnicodeCharacter{0396}{{\it Z}}%
10741 \DeclareUnicodeCharacter{0397}{{\it H}}%
10742 \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10743 \DeclareUnicodeCharacter{0399}{{\it I}}%
10744 \DeclareUnicodeCharacter{039A}{{\it K}}%
10745 \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10746 \DeclareUnicodeCharacter{039C}{{\it M}}%
10747 \DeclareUnicodeCharacter{039D}{{\it N}}%
10748 \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10749 \DeclareUnicodeCharacter{039F}{{\it O}}%
10750 \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10751 \DeclareUnicodeCharacter{03A1}{{\it P}}%
10752 %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
10753 \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10754 \DeclareUnicodeCharacter{03A4}{{\it T}}%
10755 \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10756 \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10757 \DeclareUnicodeCharacter{03A7}{{\it X}}%
10758 \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10759 \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10760 %
10761 % Vowels with accents
10762 \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10763 \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10764 \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10765 \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10766 \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10767 \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10768 %
10769 % Standalone accent
10770 \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10771 %
10772 % Greek letters lower case
10773 \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10774 \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10775 \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10776 \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10777 \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10778 \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10779 \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10780 \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10781 \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10782 \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10783 \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10784 \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10785 \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10786 \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10787 \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10788 \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10789 \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10790 \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10791 \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10792 \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10793 \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10794 \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10795 \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10796 \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10797 \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10798 %
10799 % More Greek vowels with accents
10800 \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10801 \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10802 \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10803 \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10804 \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10805 %
10806 % Variant Greek letters
10807 \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10808 \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10809 \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10810 %
10811 \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10812 \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10813 \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10814 \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10815 \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10816 \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10817 \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10818 \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10819 \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10820 \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10821 \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10822 \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10823 %
10824 \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10825 \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10826 %
10827 \DeclareUnicodeCharacter{1E20}{\=G}%
10828 \DeclareUnicodeCharacter{1E21}{\=g}%
10829 \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10830 \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10831 \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10832 \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10833 \DeclareUnicodeCharacter{1E26}{\"H}%
10834 \DeclareUnicodeCharacter{1E27}{\"h}%
10835 %
10836 \DeclareUnicodeCharacter{1E30}{\'K}%
10837 \DeclareUnicodeCharacter{1E31}{\'k}%
10838 \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10839 \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10840 \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10841 \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10842 \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10843 \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10844 \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10845 \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10846 \DeclareUnicodeCharacter{1E3E}{\'M}%
10847 \DeclareUnicodeCharacter{1E3F}{\'m}%
10848 %
10849 \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10850 \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10851 \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10852 \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10853 \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10854 \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10855 \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10856 \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10857 \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10858 \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10859 %
10860 \DeclareUnicodeCharacter{1E54}{\'P}%
10861 \DeclareUnicodeCharacter{1E55}{\'p}%
10862 \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10863 \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10864 \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10865 \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10866 \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10867 \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10868 \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10869 \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10870 %
10871 \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10872 \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10873 \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10874 \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10875 \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10876 \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10877 \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10878 \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10879 \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10880 \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10881 %
10882 \DeclareUnicodeCharacter{1E7C}{\~V}%
10883 \DeclareUnicodeCharacter{1E7D}{\~v}%
10884 \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10885 \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10886 %
10887 \DeclareUnicodeCharacter{1E80}{\`W}%
10888 \DeclareUnicodeCharacter{1E81}{\`w}%
10889 \DeclareUnicodeCharacter{1E82}{\'W}%
10890 \DeclareUnicodeCharacter{1E83}{\'w}%
10891 \DeclareUnicodeCharacter{1E84}{\"W}%
10892 \DeclareUnicodeCharacter{1E85}{\"w}%
10893 \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10894 \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10895 \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10896 \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10897 \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10898 \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10899 \DeclareUnicodeCharacter{1E8C}{\"X}%
10900 \DeclareUnicodeCharacter{1E8D}{\"x}%
10901 \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10902 \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10903 %
10904 \DeclareUnicodeCharacter{1E90}{\^Z}%
10905 \DeclareUnicodeCharacter{1E91}{\^z}%
10906 \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
10907 \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
10908 \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
10909 \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
10910 \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
10911 \DeclareUnicodeCharacter{1E97}{\"t}%
10912 \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
10913 \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
10914 %
10915 \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
10916 \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
10917 %
10918 \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
10919 \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
10920 \DeclareUnicodeCharacter{1EBC}{\~E}%
10921 \DeclareUnicodeCharacter{1EBD}{\~e}%
10922 %
10923 \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
10924 \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
10925 \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
10926 \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
10927 %
10928 \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
10929 \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
10930 %
10931 \DeclareUnicodeCharacter{1EF2}{\`Y}%
10932 \DeclareUnicodeCharacter{1EF3}{\`y}%
10933 \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
10934 %
10935 \DeclareUnicodeCharacter{1EF8}{\~Y}%
10936 \DeclareUnicodeCharacter{1EF9}{\~y}%
10937 %
10938 % Punctuation
10939 \DeclareUnicodeCharacter{2013}{--}%
10940 \DeclareUnicodeCharacter{2014}{---}%
10941 \DeclareUnicodeCharacter{2018}{\quoteleft}%
10942 \DeclareUnicodeCharacter{2019}{\quoteright}%
10943 \DeclareUnicodeCharacter{201A}{\quotesinglbase}%
10944 \DeclareUnicodeCharacter{201C}{\quotedblleft}%
10945 \DeclareUnicodeCharacter{201D}{\quotedblright}%
10946 \DeclareUnicodeCharacter{201E}{\quotedblbase}%
10947 \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}%
10948 \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}%
10949 \DeclareUnicodeCharacter{2022}{\bullet}%
10950 \DeclareUnicodeCharacter{202F}{\thinspace}%
10951 \DeclareUnicodeCharacter{2026}{\dots}%
10952 \DeclareUnicodeCharacter{2039}{\guilsinglleft}%
10953 \DeclareUnicodeCharacter{203A}{\guilsinglright}%
10954 %
10955 \DeclareUnicodeCharacter{20AC}{\euro}%
10956 %
10957 \DeclareUnicodeCharacter{2192}{\expansion}%
10958 \DeclareUnicodeCharacter{21D2}{\result}%
10959 %
10960 % Mathematical symbols
10961 \DeclareUnicodeCharacter{2200}{\ensuremath\forall}%
10962 \DeclareUnicodeCharacter{2203}{\ensuremath\exists}%
10963 \DeclareUnicodeCharacter{2208}{\ensuremath\in}%
10964 \DeclareUnicodeCharacter{2212}{\minus}%
10965 \DeclareUnicodeCharacter{2217}{\ast}%
10966 \DeclareUnicodeCharacter{221E}{\ensuremath\infty}%
10967 \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}%
10968 \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}%
10969 \DeclareUnicodeCharacter{2229}{\ensuremath\cap}%
10970 \DeclareUnicodeCharacter{2261}{\equiv}%
10971 \DeclareUnicodeCharacter{2264}{\ensuremath\leq}%
10972 \DeclareUnicodeCharacter{2265}{\ensuremath\geq}%
10973 \DeclareUnicodeCharacter{2282}{\ensuremath\subset}%
10974 \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}%
10975 %
10976 \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}%
10977 \DeclareUnicodeCharacter{2032}{\ensuremath\prime}%
10978 \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}%
10979 \DeclareUnicodeCharacter{2111}{\ensuremath\Im}%
10980 \DeclareUnicodeCharacter{2113}{\ensuremath\ell}%
10981 \DeclareUnicodeCharacter{2118}{\ensuremath\wp}%
10982 \DeclareUnicodeCharacter{211C}{\ensuremath\Re}%
10983 \DeclareUnicodeCharacter{2127}{\ensuremath\mho}%
10984 \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}%
10985 \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}%
10986 \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}%
10987 \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}%
10988 \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}%
10989 \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}%
10990 \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}%
10991 \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}%
10992 \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}%
10993 \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}%
10994 \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}%
10995 \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}%
10996 \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}%
10997 \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}%
10998 \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}%
10999 \DeclareUnicodeCharacter{21BE}{\ensuremath\upharpoonright}%
11000 \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}%
11001 \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}%
11002 \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}%
11003 \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}%
11004 \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}%
11005 \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}%
11006 \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}%
11007 \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}%
11008 \DeclareUnicodeCharacter{21DD}{\ensuremath\leadsto}%
11009 \DeclareUnicodeCharacter{2201}{\ensuremath\complement}%
11010 \DeclareUnicodeCharacter{2202}{\ensuremath\partial}%
11011 \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}%
11012 \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}%
11013 \DeclareUnicodeCharacter{2209}{\ensuremath\notin}%
11014 \DeclareUnicodeCharacter{220B}{\ensuremath\owns}%
11015 \DeclareUnicodeCharacter{220F}{\ensuremath\prod}%
11016 \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}%
11017 \DeclareUnicodeCharacter{2211}{\ensuremath\sum}%
11018 \DeclareUnicodeCharacter{2213}{\ensuremath\mp}%
11019 \DeclareUnicodeCharacter{2218}{\ensuremath\circ}%
11020 \DeclareUnicodeCharacter{221A}{\ensuremath\surd}%
11021 \DeclareUnicodeCharacter{221D}{\ensuremath\propto}%
11022 \DeclareUnicodeCharacter{2220}{\ensuremath\angle}%
11023 \DeclareUnicodeCharacter{2223}{\ensuremath\mid}%
11024 \DeclareUnicodeCharacter{2228}{\ensuremath\vee}%
11025 \DeclareUnicodeCharacter{222A}{\ensuremath\cup}%
11026 \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}%
11027 \DeclareUnicodeCharacter{222E}{\ensuremath\oint}%
11028 \DeclareUnicodeCharacter{223C}{\ensuremath\sim}%
11029 \DeclareUnicodeCharacter{2240}{\ensuremath\wr}%
11030 \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}%
11031 \DeclareUnicodeCharacter{2245}{\ensuremath\cong}%
11032 \DeclareUnicodeCharacter{2248}{\ensuremath\approx}%
11033 \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}%
11034 \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}%
11035 \DeclareUnicodeCharacter{2260}{\ensuremath\neq}%
11036 \DeclareUnicodeCharacter{226A}{\ensuremath\ll}%
11037 \DeclareUnicodeCharacter{226B}{\ensuremath\gg}%
11038 \DeclareUnicodeCharacter{227A}{\ensuremath\prec}%
11039 \DeclareUnicodeCharacter{227B}{\ensuremath\succ}%
11040 \DeclareUnicodeCharacter{2283}{\ensuremath\supset}%
11041 \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}%
11042 \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}%
11043 \DeclareUnicodeCharacter{228F}{\ensuremath\sqsubset}%
11044 \DeclareUnicodeCharacter{2290}{\ensuremath\sqsupset}%
11045 \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}%
11046 \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}%
11047 \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}%
11048 \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}%
11049 \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}%
11050 \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}%
11051 \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}%
11052 \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}%
11053 \DeclareUnicodeCharacter{2299}{\ensuremath\odot}%
11054 \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}%
11055 \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}%
11056 \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}%
11057 \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}%
11058 \DeclareUnicodeCharacter{22A8}{\ensuremath\models}%
11059 \DeclareUnicodeCharacter{22B4}{\ensuremath\unlhd}%
11060 \DeclareUnicodeCharacter{22B5}{\ensuremath\unrhd}%
11061 \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}%
11062 \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}%
11063 \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}%
11064 \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}%
11065 \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}%
11066 \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}%
11067 \DeclareUnicodeCharacter{22C6}{\ensuremath\star}%
11068 \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}%
11069 \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}%
11070 \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}%
11071 \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}%
11072 \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}%
11073 \DeclareUnicodeCharacter{2322}{\ensuremath\frown}%
11074 \DeclareUnicodeCharacter{2323}{\ensuremath\smile}%
11075 %
11076 \DeclareUnicodeCharacter{25A1}{\ensuremath\Box}%
11077 \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
11078 \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
11079 \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
11080 \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
11081 \DeclareUnicodeCharacter{25C7}{\ensuremath\Diamond}%
11082 \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}%
11083 \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}%
11084 \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}%
11085 \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}%
11086 \DeclareUnicodeCharacter{266D}{\ensuremath\flat}%
11087 \DeclareUnicodeCharacter{266E}{\ensuremath\natural}%
11088 \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}%
11089 \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}%
11090 \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}%
11091 \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}%
11092 \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}%
11093 \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}%
11094 \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}%
11095 \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}%
11096 \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}%
11097 \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}%
11098 \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}%
11099 \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}%
11100 \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}%
11101 \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}%
11102 \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}%
11103 \DeclareUnicodeCharacter{2A1D}{\ensuremath\Join}%
11104 \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}%
11105 \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}%
11106 \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}%
11107 %
11108 \global\mathchardef\checkmark="1370% actually the square root sign
11109 \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}%
11110 }% end of \unicodechardefs
11111
11112 % UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
11113 % It makes the setting that replace UTF-8 byte sequence.
11114 \def\utfeightchardefs{%
11115 \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
11116 \unicodechardefs
11117 }
11118
11119 % Whether the active definitions of non-ASCII characters expand to
11120 % non-active tokens with the same character code. This is used to
11121 % write characters literally, instead of using active definitions for
11122 % printing the correct glyphs.
11123 \newif\ifpassthroughchars
11124 \passthroughcharsfalse
11125
11126 % For native Unicode (XeTeX and LuaTeX)
11127 % Definition macro to replace / pass-through the Unicode character
11128 %
11129 \def\DeclareUnicodeCharacterNative#1#2{%
11130 \catcode"#1=\active
11131 \def\dodeclareunicodecharacternative##1##2##3{%
11132 \begingroup
11133 \uccode`\~="##2\relax
11134 \uppercase{\gdef~}{%
11135 \ifpassthroughchars
11136 ##1%
11137 \else
11138 ##3%
11139 \fi
11140 }
11141 \endgroup
11142 }
11143 \begingroup
11144 \uccode`\.="#1\relax
11145 \uppercase{\def\UTFNativeTmp{.}}%
11146 \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
11147 \endgroup
11148 }
11149
11150 % Native Unicode (XeTeX and LuaTeX) character replacing definitions
11151 % It makes the setting that replace the Unicode characters.
11152 \def\nativeunicodechardefs{%
11153 \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
11154 \unicodechardefs
11155 }
11156
11157 % For native Unicode (XeTeX and LuaTeX). Make the character token expand
11158 % to the sequences given in \unicodechardefs for printing.
11159 \def\DeclareUnicodeCharacterNativeAtU#1#2{%
11160 \def\UTFAtUTmp{#2}
11161 \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
11162 }
11163
11164 % Native Unicode (XeTeX and LuaTeX) @U command definitions
11165 \def\nativeunicodechardefsatu{%
11166 \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
11167 \unicodechardefs
11168 }
11169
11170 % US-ASCII character definitions.
11171 \def\asciichardefs{% nothing need be done
11172 \relax
11173 }
11174
11175 % define all the unicode characters we know about, for the sake of @U.
11176 \iftxinativeunicodecapable
11177 \nativeunicodechardefsatu
11178 \else
11179 \utfeightchardefs
11180 \fi
11181
11182
11183 % Make non-ASCII characters printable again for compatibility with
11184 % existing Texinfo documents that may use them, even without declaring a
11185 % document encoding.
11186 %
11187 \setnonasciicharscatcode \other
11188
11189
11190 \message{formatting,}
11191
11192 \newdimen\defaultparindent \defaultparindent = 15pt
11193
11194 \chapheadingskip = 15pt plus 4pt minus 2pt
11195 \secheadingskip = 12pt plus 3pt minus 2pt
11196 \subsecheadingskip = 9pt plus 2pt minus 2pt
11197
11198 % Prevent underfull vbox error messages.
11199 \vbadness = 10000
11200
11201 % Don't be very finicky about underfull hboxes, either.
11202 \hbadness = 6666
11203
11204 % Following George Bush, get rid of widows and orphans.
11205 \widowpenalty=10000
11206 \clubpenalty=10000
11207
11208 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
11209 % using an old version of TeX, don't do anything. We want the amount of
11210 % stretch added to depend on the line length, hence the dependence on
11211 % \hsize. We call this whenever the paper size is set.
11212 %
11213 \def\setemergencystretch{%
11214 \ifx\emergencystretch\thisisundefined
11215 % Allow us to assign to \emergencystretch anyway.
11216 \def\emergencystretch{\dimen0}%
11217 \else
11218 \emergencystretch = .15\hsize
11219 \fi
11220 }
11221
11222 % Parameters in order: 1) textheight; 2) textwidth;
11223 % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11224 % 7) physical page height; 8) physical page width.
11225 %
11226 % We also call \setleading{\textleading}, so the caller should define
11227 % \textleading. The caller should also set \parskip.
11228 %
11229 \def\internalpagesizes#1#2#3#4#5#6#7#8{%
11230 \voffset = #3\relax
11231 \topskip = #6\relax
11232 \splittopskip = \topskip
11233 %
11234 \vsize = #1\relax
11235 \advance\vsize by \topskip
11236 \outervsize = \vsize
11237 \advance\outervsize by 2\topandbottommargin
11238 \txipageheight = \vsize
11239 %
11240 \hsize = #2\relax
11241 \outerhsize = \hsize
11242 \advance\outerhsize by 0.5in
11243 \txipagewidth = \hsize
11244 %
11245 \normaloffset = #4\relax
11246 \bindingoffset = #5\relax
11247 %
11248 \ifpdf
11249 \pdfpageheight #7\relax
11250 \pdfpagewidth #8\relax
11251 % if we don't reset these, they will remain at "1 true in" of
11252 % whatever layout pdftex was dumped with.
11253 \pdfhorigin = 1 true in
11254 \pdfvorigin = 1 true in
11255 \else
11256 \ifx\XeTeXrevision\thisisundefined
11257 \else
11258 \pdfpageheight #7\relax
11259 \pdfpagewidth #8\relax
11260 % XeTeX does not have \pdfhorigin and \pdfvorigin.
11261 \fi
11262 \fi
11263 %
11264 \setleading{\textleading}
11265 %
11266 \parindent = \defaultparindent
11267 \setemergencystretch
11268 }
11269
11270 % @letterpaper (the default).
11271 \def\letterpaper{{\globaldefs = 1
11272 \parskip = 3pt plus 2pt minus 1pt
11273 \textleading = 13.2pt
11274 %
11275 % If page is nothing but text, make it come out even.
11276 \internalpagesizes{607.2pt}{6in}% that's 46 lines
11277 {\voffset}{.25in}%
11278 {\bindingoffset}{36pt}%
11279 {11in}{8.5in}%
11280 }}
11281
11282 % Use @smallbook to reset parameters for 7x9.25 trim size.
11283 \def\smallbook{{\globaldefs = 1
11284 \parskip = 2pt plus 1pt
11285 \textleading = 12pt
11286 %
11287 \internalpagesizes{7.5in}{5in}%
11288 {-.2in}{0in}%
11289 {\bindingoffset}{16pt}%
11290 {9.25in}{7in}%
11291 %
11292 \lispnarrowing = 0.3in
11293 \tolerance = 700
11294 \hfuzz = 1pt
11295 \contentsrightmargin = 0pt
11296 \defbodyindent = .5cm
11297 }}
11298
11299 % Use @smallerbook to reset parameters for 6x9 trim size.
11300 % (Just testing, parameters still in flux.)
11301 \def\smallerbook{{\globaldefs = 1
11302 \parskip = 1.5pt plus 1pt
11303 \textleading = 12pt
11304 %
11305 \internalpagesizes{7.4in}{4.8in}%
11306 {-.2in}{-.4in}%
11307 {0pt}{14pt}%
11308 {9in}{6in}%
11309 %
11310 \lispnarrowing = 0.25in
11311 \tolerance = 700
11312 \hfuzz = 1pt
11313 \contentsrightmargin = 0pt
11314 \defbodyindent = .4cm
11315 }}
11316
11317 % Use @afourpaper to print on European A4 paper.
11318 \def\afourpaper{{\globaldefs = 1
11319 \parskip = 3pt plus 2pt minus 1pt
11320 \textleading = 13.2pt
11321 %
11322 % Double-side printing via postscript on Laserjet 4050
11323 % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11324 % To change the settings for a different printer or situation, adjust
11325 % \normaloffset until the front-side and back-side texts align. Then
11326 % do the same for \bindingoffset. You can set these for testing in
11327 % your texinfo source file like this:
11328 % @tex
11329 % \global\normaloffset = -6mm
11330 % \global\bindingoffset = 10mm
11331 % @end tex
11332 \internalpagesizes{673.2pt}{160mm}% that's 51 lines
11333 {\voffset}{\hoffset}%
11334 {\bindingoffset}{44pt}%
11335 {297mm}{210mm}%
11336 %
11337 \tolerance = 700
11338 \hfuzz = 1pt
11339 \contentsrightmargin = 0pt
11340 \defbodyindent = 5mm
11341 }}
11342
11343 % Use @afivepaper to print on European A5 paper.
11344 % From romildo@urano.iceb.ufop.br, 2 July 2000.
11345 % He also recommends making @example and @lisp be small.
11346 \def\afivepaper{{\globaldefs = 1
11347 \parskip = 2pt plus 1pt minus 0.1pt
11348 \textleading = 12.5pt
11349 %
11350 \internalpagesizes{160mm}{120mm}%
11351 {\voffset}{\hoffset}%
11352 {\bindingoffset}{8pt}%
11353 {210mm}{148mm}%
11354 %
11355 \lispnarrowing = 0.2in
11356 \tolerance = 800
11357 \hfuzz = 1.2pt
11358 \contentsrightmargin = 0pt
11359 \defbodyindent = 2mm
11360 \tableindent = 12mm
11361 }}
11362
11363 % A specific text layout, 24x15cm overall, intended for A4 paper.
11364 \def\afourlatex{{\globaldefs = 1
11365 \afourpaper
11366 \internalpagesizes{237mm}{150mm}%
11367 {\voffset}{4.6mm}%
11368 {\bindingoffset}{7mm}%
11369 {297mm}{210mm}%
11370 %
11371 % Must explicitly reset to 0 because we call \afourpaper.
11372 \globaldefs = 0
11373 }}
11374
11375 % Use @afourwide to print on A4 paper in landscape format.
11376 \def\afourwide{{\globaldefs = 1
11377 \afourpaper
11378 \internalpagesizes{241mm}{165mm}%
11379 {\voffset}{-2.95mm}%
11380 {\bindingoffset}{7mm}%
11381 {297mm}{210mm}%
11382 \globaldefs = 0
11383 }}
11384
11385 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11386 % Perhaps we should allow setting the margins, \topskip, \parskip,
11387 % and/or leading, also. Or perhaps we should compute them somehow.
11388 %
11389 \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
11390 \def\pagesizesyyy#1,#2,#3\finish{{%
11391 \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11392 \globaldefs = 1
11393 %
11394 \parskip = 3pt plus 2pt minus 1pt
11395 \setleading{\textleading}%
11396 %
11397 \dimen0 = #1\relax
11398 \advance\dimen0 by \voffset
11399 %
11400 \dimen2 = \hsize
11401 \advance\dimen2 by \normaloffset
11402 %
11403 \internalpagesizes{#1}{\hsize}%
11404 {\voffset}{\normaloffset}%
11405 {\bindingoffset}{44pt}%
11406 {\dimen0}{\dimen2}%
11407 }}
11408
11409 % Set default to letter.
11410 %
11411 \letterpaper
11412
11413
11414 \message{and turning on texinfo input format.}
11415
11416 \def^^L{\par} % remove \outer, so ^L can appear in an @comment
11417
11418 % DEL is a comment character, in case @c does not suffice.
11419 \catcode`\^^? = 14
11420
11421 % Define macros to output various characters with catcode for normal text.
11422 \catcode`\"=\other \def\normaldoublequote{"}
11423 \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11424 \catcode`\+=\other \def\normalplus{+}
11425 \catcode`\<=\other \def\normalless{<}
11426 \catcode`\>=\other \def\normalgreater{>}
11427 \catcode`\^=\other \def\normalcaret{^}
11428 \catcode`\_=\other \def\normalunderscore{_}
11429 \catcode`\|=\other \def\normalverticalbar{|}
11430 \catcode`\~=\other \def\normaltilde{~}
11431
11432 % This macro is used to make a character print one way in \tt
11433 % (where it can probably be output as-is), and another way in other fonts,
11434 % where something hairier probably needs to be done.
11435 %
11436 % #1 is what to print if we are indeed using \tt; #2 is what to print
11437 % otherwise. Since all the Computer Modern typewriter fonts have zero
11438 % interword stretch (and shrink), and it is reasonable to expect all
11439 % typewriter fonts to have this, we can check that font parameter.
11440 %
11441 \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
11442
11443 % Same as above, but check for italic font. Actually this also catches
11444 % non-italic slanted fonts since it is impossible to distinguish them from
11445 % italic fonts. But since this is only used by $ and it uses \sl anyway
11446 % this is not a problem.
11447 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
11448
11449 % Set catcodes for Texinfo file
11450
11451 % Active characters for printing the wanted glyph.
11452 % Most of these we simply print from the \tt font, but for some, we can
11453 % use math or other variants that look better in normal text.
11454 %
11455 \catcode`\"=\active
11456 \def\activedoublequote{{\tt\char34}}
11457 \let"=\activedoublequote
11458 \catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
11459 \chardef\hatchar=`\^
11460 \catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
11461
11462 \catcode`\_=\active
11463 \def_{\ifusingtt\normalunderscore\_}
11464 \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
11465 \let\realunder=_
11466
11467 \catcode`\|=\active \def|{{\tt\char124}}
11468
11469 \chardef \less=`\<
11470 \catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
11471 \chardef \gtr=`\>
11472 \catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11473 \catcode`\+=\active \def+{{\tt \char 43}}
11474 \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
11475 \catcode`\-=\active \let-=\normaldash
11476
11477
11478 % used for headline/footline in the output routine, in case the page
11479 % breaks in the middle of an @tex block.
11480 \def\texinfochars{%
11481 \let< = \activeless
11482 \let> = \activegtr
11483 \let~ = \activetilde
11484 \let^ = \activehat
11485 \markupsetuplqdefault \markupsetuprqdefault
11486 \let\b = \strong
11487 \let\i = \smartitalic
11488 % in principle, all other definitions in \tex have to be undone too.
11489 }
11490
11491 % Used sometimes to turn off (effectively) the active characters even after
11492 % parsing them.
11493 \def\turnoffactive{%
11494 \normalturnoffactive
11495 \otherbackslash
11496 }
11497
11498 \catcode`\@=0
11499
11500 % \backslashcurfont outputs one backslash character in current font,
11501 % as in \char`\\.
11502 \global\chardef\backslashcurfont=`\\
11503 \global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work
11504
11505 % \realbackslash is an actual character `\' with catcode other, and
11506 % \doublebackslash is two of them (for the pdf outlines).
11507 {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
11508
11509 % In Texinfo, backslash is an active character; it prints the backslash
11510 % in fixed width font.
11511 \catcode`\\=\active % @ for escape char from now on.
11512
11513 % Print a typewriter backslash. For math mode, we can't simply use
11514 % \backslashcurfont: the story here is that in math mode, the \char
11515 % of \backslashcurfont ends up printing the roman \ from the math symbol
11516 % font (because \char in math mode uses the \mathcode, and plain.tex
11517 % sets \mathcode`\\="026E). Hence we use an explicit \mathchar,
11518 % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11519 % ignored family value; char position "5C). We can't use " for the
11520 % usual hex value because it has already been made active.
11521
11522 @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
11523 @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
11524
11525 % \rawbackslash defines an active \ to do \backslashcurfont.
11526 % \otherbackslash defines an active \ to be a literal `\' character with
11527 % catcode other. We switch back and forth between these.
11528 @gdef@rawbackslash{@let\=@backslashcurfont}
11529 @gdef@otherbackslash{@let\=@realbackslash}
11530
11531 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
11532 % the literal character `\'.
11533 %
11534 {@catcode`- = @active
11535 @gdef@normalturnoffactive{%
11536 @passthroughcharstrue
11537 @let-=@normaldash
11538 @let"=@normaldoublequote
11539 @let$=@normaldollar %$ font-lock fix
11540 @let+=@normalplus
11541 @let<=@normalless
11542 @let>=@normalgreater
11543 @let^=@normalcaret
11544 @let_=@normalunderscore
11545 @let|=@normalverticalbar
11546 @let~=@normaltilde
11547 @let\=@ttbackslash
11548 @markupsetuplqdefault
11549 @markupsetuprqdefault
11550 @unsepspaces
11551 }
11552 }
11553
11554 % If a .fmt file is being used, characters that might appear in a file
11555 % name cannot be active until we have parsed the command line.
11556 % So turn them off again, and have @fixbackslash turn them back on.
11557 @catcode`+=@other @catcode`@_=@other
11558
11559 % \enablebackslashhack - allow file to begin `\input texinfo'
11560 %
11561 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
11562 % That is what \eatinput is for; after that, the `\' should revert to printing
11563 % a backslash.
11564 % If the file did not have a `\input texinfo', then it is turned off after
11565 % the first line; otherwise the first `\' in the file would cause an error.
11566 % This is used on the very last line of this file, texinfo.tex.
11567 % We also use @c to call @fixbackslash, in case ends of lines are hidden.
11568 {
11569 @catcode`@^=7
11570 @catcode`@^^M=13@gdef@enablebackslashhack{%
11571 @global@let\ = @eatinput%
11572 @catcode`@^^M=13%
11573 @def@c{@fixbackslash@c}%
11574 % Definition for the newline at the end of this file.
11575 @def ^^M{@let^^M@secondlinenl}%
11576 % Definition for a newline in the main Texinfo file.
11577 @gdef @secondlinenl{@fixbackslash}%
11578 }}
11579
11580 {@catcode`@^=7 @catcode`@^^M=13%
11581 @gdef@eatinput input texinfo#1^^M{@fixbackslash}}
11582
11583 % Emergency active definition of newline, in case an active newline token
11584 % appears by mistake.
11585 {@catcode`@^=7 @catcode13=13%
11586 @gdef@enableemergencynewline{%
11587 @gdef^^M{%
11588 @par%
11589 %<warning: active newline>@par%
11590 }}}
11591
11592
11593 @gdef@fixbackslash{%
11594 @ifx\@eatinput @let\ = @ttbackslash @fi
11595 @catcode13=5 % regular end of line
11596 @enableemergencynewline
11597 @let@c=@texinfoc
11598 % Also turn back on active characters that might appear in the input
11599 % file name, in case not using a pre-dumped format.
11600 @catcode`+=@active
11601 @catcode`@_=@active
11602 %
11603 % If texinfo.cnf is present on the system, read it.
11604 % Useful for site-wide @afourpaper, etc. This macro, @fixbackslash, gets
11605 % called at the beginning of every Texinfo file. Not opening texinfo.cnf
11606 % directly in this file, texinfo.tex, makes it possible to make a format
11607 % file for Texinfo.
11608 %
11609 @openin 1 texinfo.cnf
11610 @ifeof 1 @else @input texinfo.cnf @fi
11611 @closein 1
11612 }
11613
11614
11615 % Say @foo, not \foo, in error messages.
11616 @escapechar = `@@
11617
11618 % These (along with & and #) are made active for url-breaking, so need
11619 % active definitions as the normal characters.
11620 @def@normaldot{.}
11621 @def@normalquest{?}
11622 @def@normalslash{/}
11623
11624 % These look ok in all fonts, so just make them not special.
11625 % @hashchar{} gets its own user-level command, because of #line.
11626 @catcode`@& = @other @def@normalamp{&}
11627 @catcode`@# = @other @def@normalhash{#}
11628 @catcode`@% = @other @def@normalpercent{%}
11629
11630 @let @hashchar = @normalhash
11631
11632 @c Finally, make ` and ' active, so that txicodequoteundirected and
11633 @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we
11634 @c don't make ` and ' active, @code will not get them as active chars.
11635 @c Do this last of all since we use ` in the previous @catcode assignments.
11636 @catcode`@'=@active
11637 @catcode`@`=@active
11638 @markupsetuplqdefault
11639 @markupsetuprqdefault
11640
11641 @c Local variables:
11642 @c eval: (add-hook 'write-file-hooks 'time-stamp)
11643 @c page-delimiter: "^\\\\message\\|emacs-page"
11644 @c time-stamp-start: "def\\\\texinfoversion{"
11645 @c time-stamp-format: "%:y-%02m-%02d.%02H"
11646 @c time-stamp-end: "}"
11647 @c End:
11648
11649 @c vim:sw=2:
11650
11651 @ignore
11652 arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
11653 @end ignore
11654 @enablebackslashhack