]> code.delx.au - gnu-emacs/blob - doc/misc/texinfo.tex
Bring the Gnus Cloud package into working order.
[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-18.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 \ifdim2\ht1>\vsize
5968 % The left column has come out longer than the page itself. (Note
5969 % that we have doubled \vsize for the double columns, so
5970 % the actual height of the page is 0.5\vsize). Just split the last
5971 % of the double column material roughly in half.
5972 \setbox2=\box0
5973 \setbox0 = \vsplit2 to \dimen@ii
5974 \setbox0=\vbox to\dimen@ii{\unvbox0}%
5975 \setbox2=\vbox to\dimen@ii{\unvbox2}%
5976 \else
5977 \multiply\dimen@ii by 5
5978 \divide\dimen@ii by 4
5979 \global\setbox3 = \copy0
5980 \global\setbox1 = \vsplit3 to \dimen@ii
5981 \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5982 \ifdim\ht3<\dimen@ii
5983 % Column heights are too different, so don't make their bottoms
5984 % flush with each other. The glue at the end of the second column
5985 % allows a second column to stretch, reducing the difference in
5986 % height between the two.
5987 \setbox0=\vbox to\dimen@{\unvbox1\vfill}%
5988 \setbox2=\vbox to\dimen@{\unvbox3\vskip 0pt plus 0.3\ht0}%
5989 \else
5990 \setbox0=\vbox to\dimen@{\unvbox1}%
5991 \setbox2=\vbox to\dimen@{\unvbox3}%
5992 \fi
5993 \fi
5994 \fi
5995 %
5996 \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5997 }
5998 \catcode`\@ = \other
5999
6000
6001 \message{sectioning,}
6002 % Chapters, sections, etc.
6003
6004 % Let's start with @part.
6005 \outer\parseargdef\part{\partzzz{#1}}
6006 \def\partzzz#1{%
6007 \chapoddpage
6008 \null
6009 \vskip.3\vsize % move it down on the page a bit
6010 \begingroup
6011 \noindent \titlefonts\rmisbold #1\par % the text
6012 \let\lastnode=\empty % no node to associate with
6013 \writetocentry{part}{#1}{}% but put it in the toc
6014 \headingsoff % no headline or footline on the part page
6015 % This outputs a mark at the end of the page that clears \thischapter
6016 % and \thissection, as is done in \startcontents.
6017 \let\pchapsepmacro\relax
6018 \chapmacro{}{Yomitfromtoc}{}%
6019 \chapoddpage
6020 \endgroup
6021 }
6022
6023 % \unnumberedno is an oxymoron. But we count the unnumbered
6024 % sections so that we can refer to them unambiguously in the pdf
6025 % outlines by their "section number". We avoid collisions with chapter
6026 % numbers by starting them at 10000. (If a document ever has 10000
6027 % chapters, we're in trouble anyway, I'm sure.)
6028 \newcount\unnumberedno \unnumberedno = 10000
6029 \newcount\chapno
6030 \newcount\secno \secno=0
6031 \newcount\subsecno \subsecno=0
6032 \newcount\subsubsecno \subsubsecno=0
6033
6034 % This counter is funny since it counts through charcodes of letters A, B, ...
6035 \newcount\appendixno \appendixno = `\@
6036 %
6037 % \def\appendixletter{\char\the\appendixno}
6038 % We do the following ugly conditional instead of the above simple
6039 % construct for the sake of pdftex, which needs the actual
6040 % letter in the expansion, not just typeset.
6041 %
6042 \def\appendixletter{%
6043 \ifnum\appendixno=`A A%
6044 \else\ifnum\appendixno=`B B%
6045 \else\ifnum\appendixno=`C C%
6046 \else\ifnum\appendixno=`D D%
6047 \else\ifnum\appendixno=`E E%
6048 \else\ifnum\appendixno=`F F%
6049 \else\ifnum\appendixno=`G G%
6050 \else\ifnum\appendixno=`H H%
6051 \else\ifnum\appendixno=`I I%
6052 \else\ifnum\appendixno=`J J%
6053 \else\ifnum\appendixno=`K K%
6054 \else\ifnum\appendixno=`L L%
6055 \else\ifnum\appendixno=`M M%
6056 \else\ifnum\appendixno=`N N%
6057 \else\ifnum\appendixno=`O O%
6058 \else\ifnum\appendixno=`P P%
6059 \else\ifnum\appendixno=`Q Q%
6060 \else\ifnum\appendixno=`R R%
6061 \else\ifnum\appendixno=`S S%
6062 \else\ifnum\appendixno=`T T%
6063 \else\ifnum\appendixno=`U U%
6064 \else\ifnum\appendixno=`V V%
6065 \else\ifnum\appendixno=`W W%
6066 \else\ifnum\appendixno=`X X%
6067 \else\ifnum\appendixno=`Y Y%
6068 \else\ifnum\appendixno=`Z Z%
6069 % The \the is necessary, despite appearances, because \appendixletter is
6070 % expanded while writing the .toc file. \char\appendixno is not
6071 % expandable, thus it is written literally, thus all appendixes come out
6072 % with the same letter (or @) in the toc without it.
6073 \else\char\the\appendixno
6074 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
6075 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
6076
6077 % Each @chapter defines these (using marks) as the number+name, number
6078 % and name of the chapter. Page headings and footings can use
6079 % these. @section does likewise.
6080 \def\thischapter{}
6081 \def\thischapternum{}
6082 \def\thischaptername{}
6083 \def\thissection{}
6084 \def\thissectionnum{}
6085 \def\thissectionname{}
6086
6087 \newcount\absseclevel % used to calculate proper heading level
6088 \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
6089
6090 % @raisesections: treat @section as chapter, @subsection as section, etc.
6091 \def\raisesections{\global\advance\secbase by -1}
6092 \let\up=\raisesections % original BFox name
6093
6094 % @lowersections: treat @chapter as section, @section as subsection, etc.
6095 \def\lowersections{\global\advance\secbase by 1}
6096 \let\down=\lowersections % original BFox name
6097
6098 % we only have subsub.
6099 \chardef\maxseclevel = 3
6100 %
6101 % A numbered section within an unnumbered changes to unnumbered too.
6102 % To achieve this, remember the "biggest" unnum. sec. we are currently in:
6103 \chardef\unnlevel = \maxseclevel
6104 %
6105 % Trace whether the current chapter is an appendix or not:
6106 % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
6107 \def\chapheadtype{N}
6108
6109 % Choose a heading macro
6110 % #1 is heading type
6111 % #2 is heading level
6112 % #3 is text for heading
6113 \def\genhead#1#2#3{%
6114 % Compute the abs. sec. level:
6115 \absseclevel=#2
6116 \advance\absseclevel by \secbase
6117 % Make sure \absseclevel doesn't fall outside the range:
6118 \ifnum \absseclevel < 0
6119 \absseclevel = 0
6120 \else
6121 \ifnum \absseclevel > 3
6122 \absseclevel = 3
6123 \fi
6124 \fi
6125 % The heading type:
6126 \def\headtype{#1}%
6127 \if \headtype U%
6128 \ifnum \absseclevel < \unnlevel
6129 \chardef\unnlevel = \absseclevel
6130 \fi
6131 \else
6132 % Check for appendix sections:
6133 \ifnum \absseclevel = 0
6134 \edef\chapheadtype{\headtype}%
6135 \else
6136 \if \headtype A\if \chapheadtype N%
6137 \errmessage{@appendix... within a non-appendix chapter}%
6138 \fi\fi
6139 \fi
6140 % Check for numbered within unnumbered:
6141 \ifnum \absseclevel > \unnlevel
6142 \def\headtype{U}%
6143 \else
6144 \chardef\unnlevel = 3
6145 \fi
6146 \fi
6147 % Now print the heading:
6148 \if \headtype U%
6149 \ifcase\absseclevel
6150 \unnumberedzzz{#3}%
6151 \or \unnumberedseczzz{#3}%
6152 \or \unnumberedsubseczzz{#3}%
6153 \or \unnumberedsubsubseczzz{#3}%
6154 \fi
6155 \else
6156 \if \headtype A%
6157 \ifcase\absseclevel
6158 \appendixzzz{#3}%
6159 \or \appendixsectionzzz{#3}%
6160 \or \appendixsubseczzz{#3}%
6161 \or \appendixsubsubseczzz{#3}%
6162 \fi
6163 \else
6164 \ifcase\absseclevel
6165 \chapterzzz{#3}%
6166 \or \seczzz{#3}%
6167 \or \numberedsubseczzz{#3}%
6168 \or \numberedsubsubseczzz{#3}%
6169 \fi
6170 \fi
6171 \fi
6172 \suppressfirstparagraphindent
6173 }
6174
6175 % an interface:
6176 \def\numhead{\genhead N}
6177 \def\apphead{\genhead A}
6178 \def\unnmhead{\genhead U}
6179
6180 % @chapter, @appendix, @unnumbered. Increment top-level counter, reset
6181 % all lower-level sectioning counters to zero.
6182 %
6183 % Also set \chaplevelprefix, which we prepend to @float sequence numbers
6184 % (e.g., figures), q.v. By default (before any chapter), that is empty.
6185 \let\chaplevelprefix = \empty
6186 %
6187 \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
6188 \def\chapterzzz#1{%
6189 % section resetting is \global in case the chapter is in a group, such
6190 % as an @include file.
6191 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6192 \global\advance\chapno by 1
6193 %
6194 % Used for \float.
6195 \gdef\chaplevelprefix{\the\chapno.}%
6196 \resetallfloatnos
6197 %
6198 % \putwordChapter can contain complex things in translations.
6199 \toks0=\expandafter{\putwordChapter}%
6200 \message{\the\toks0 \space \the\chapno}%
6201 %
6202 % Write the actual heading.
6203 \chapmacro{#1}{Ynumbered}{\the\chapno}%
6204 %
6205 % So @section and the like are numbered underneath this chapter.
6206 \global\let\section = \numberedsec
6207 \global\let\subsection = \numberedsubsec
6208 \global\let\subsubsection = \numberedsubsubsec
6209 }
6210
6211 \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
6212 %
6213 \def\appendixzzz#1{%
6214 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6215 \global\advance\appendixno by 1
6216 \gdef\chaplevelprefix{\appendixletter.}%
6217 \resetallfloatnos
6218 %
6219 % \putwordAppendix can contain complex things in translations.
6220 \toks0=\expandafter{\putwordAppendix}%
6221 \message{\the\toks0 \space \appendixletter}%
6222 %
6223 \chapmacro{#1}{Yappendix}{\appendixletter}%
6224 %
6225 \global\let\section = \appendixsec
6226 \global\let\subsection = \appendixsubsec
6227 \global\let\subsubsection = \appendixsubsubsec
6228 }
6229
6230 % normally unnmhead0 calls unnumberedzzz:
6231 \outer\parseargdef\unnumbered{\unnmhead0{#1}}
6232 \def\unnumberedzzz#1{%
6233 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6234 \global\advance\unnumberedno by 1
6235 %
6236 % Since an unnumbered has no number, no prefix for figures.
6237 \global\let\chaplevelprefix = \empty
6238 \resetallfloatnos
6239 %
6240 % This used to be simply \message{#1}, but TeX fully expands the
6241 % argument to \message. Therefore, if #1 contained @-commands, TeX
6242 % expanded them. For example, in `@unnumbered The @cite{Book}', TeX
6243 % expanded @cite (which turns out to cause errors because \cite is meant
6244 % to be executed, not expanded).
6245 %
6246 % Anyway, we don't want the fully-expanded definition of @cite to appear
6247 % as a result of the \message, we just want `@cite' itself. We use
6248 % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6249 % simply yielding the contents of <toks register>. (We also do this for
6250 % the toc entries.)
6251 \toks0 = {#1}%
6252 \message{(\the\toks0)}%
6253 %
6254 \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
6255 %
6256 \global\let\section = \unnumberedsec
6257 \global\let\subsection = \unnumberedsubsec
6258 \global\let\subsubsection = \unnumberedsubsubsec
6259 }
6260
6261 % @centerchap is like @unnumbered, but the heading is centered.
6262 \outer\parseargdef\centerchap{%
6263 \let\centerparametersmaybe = \centerparameters
6264 \unnmhead0{#1}%
6265 \let\centerparametersmaybe = \relax
6266 }
6267
6268 % @top is like @unnumbered.
6269 \let\top\unnumbered
6270
6271 % Sections.
6272 %
6273 \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6274 \def\seczzz#1{%
6275 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
6276 \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
6277 }
6278
6279 % normally calls appendixsectionzzz:
6280 \outer\parseargdef\appendixsection{\apphead1{#1}}
6281 \def\appendixsectionzzz#1{%
6282 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
6283 \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
6284 }
6285 \let\appendixsec\appendixsection
6286
6287 % normally calls unnumberedseczzz:
6288 \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
6289 \def\unnumberedseczzz#1{%
6290 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
6291 \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
6292 }
6293
6294 % Subsections.
6295 %
6296 % normally calls numberedsubseczzz:
6297 \outer\parseargdef\numberedsubsec{\numhead2{#1}}
6298 \def\numberedsubseczzz#1{%
6299 \global\subsubsecno=0 \global\advance\subsecno by 1
6300 \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
6301 }
6302
6303 % normally calls appendixsubseczzz:
6304 \outer\parseargdef\appendixsubsec{\apphead2{#1}}
6305 \def\appendixsubseczzz#1{%
6306 \global\subsubsecno=0 \global\advance\subsecno by 1
6307 \sectionheading{#1}{subsec}{Yappendix}%
6308 {\appendixletter.\the\secno.\the\subsecno}%
6309 }
6310
6311 % normally calls unnumberedsubseczzz:
6312 \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
6313 \def\unnumberedsubseczzz#1{%
6314 \global\subsubsecno=0 \global\advance\subsecno by 1
6315 \sectionheading{#1}{subsec}{Ynothing}%
6316 {\the\unnumberedno.\the\secno.\the\subsecno}%
6317 }
6318
6319 % Subsubsections.
6320 %
6321 % normally numberedsubsubseczzz:
6322 \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
6323 \def\numberedsubsubseczzz#1{%
6324 \global\advance\subsubsecno by 1
6325 \sectionheading{#1}{subsubsec}{Ynumbered}%
6326 {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
6327 }
6328
6329 % normally appendixsubsubseczzz:
6330 \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
6331 \def\appendixsubsubseczzz#1{%
6332 \global\advance\subsubsecno by 1
6333 \sectionheading{#1}{subsubsec}{Yappendix}%
6334 {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
6335 }
6336
6337 % normally unnumberedsubsubseczzz:
6338 \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
6339 \def\unnumberedsubsubseczzz#1{%
6340 \global\advance\subsubsecno by 1
6341 \sectionheading{#1}{subsubsec}{Ynothing}%
6342 {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
6343 }
6344
6345 % These macros control what the section commands do, according
6346 % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6347 % Define them by default for a numbered chapter.
6348 \let\section = \numberedsec
6349 \let\subsection = \numberedsubsec
6350 \let\subsubsection = \numberedsubsubsec
6351
6352 % Define @majorheading, @heading and @subheading
6353
6354 \def\majorheading{%
6355 {\advance\chapheadingskip by 10pt \chapbreak }%
6356 \parsearg\chapheadingzzz
6357 }
6358
6359 \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6360 \def\chapheadingzzz#1{%
6361 \vbox{\chapfonts \raggedtitlesettings #1\par}%
6362 \nobreak\bigskip \nobreak
6363 \suppressfirstparagraphindent
6364 }
6365
6366 % @heading, @subheading, @subsubheading.
6367 \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6368 \suppressfirstparagraphindent}
6369 \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6370 \suppressfirstparagraphindent}
6371 \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6372 \suppressfirstparagraphindent}
6373
6374 % These macros generate a chapter, section, etc. heading only
6375 % (including whitespace, linebreaking, etc. around it),
6376 % given all the information in convenient, parsed form.
6377
6378 % Args are the skip and penalty (usually negative)
6379 \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6380
6381 % Parameter controlling skip before chapter headings (if needed)
6382 \newskip\chapheadingskip
6383
6384 % Define plain chapter starts, and page on/off switching for it.
6385 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
6386
6387 % Start a new page
6388 \def\chappager{\par\vfill\supereject}
6389
6390 % \chapoddpage - start on an odd page for a new chapter
6391 % Because \domark is called before \chapoddpage, the filler page will
6392 % get the headings for the next chapter, which is wrong. But we don't
6393 % care -- we just disable all headings on the filler page.
6394 \def\chapoddpage{%
6395 \chappager
6396 \ifodd\pageno \else
6397 \begingroup
6398 \headingsoff
6399 \null
6400 \chappager
6401 \endgroup
6402 \fi
6403 }
6404
6405 \parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
6406
6407 \def\CHAPPAGoff{%
6408 \global\let\contentsalignmacro = \chappager
6409 \global\let\pchapsepmacro=\chapbreak
6410 \global\let\pagealignmacro=\chappager}
6411
6412 \def\CHAPPAGon{%
6413 \global\let\contentsalignmacro = \chappager
6414 \global\let\pchapsepmacro=\chappager
6415 \global\let\pagealignmacro=\chappager
6416 \global\def\HEADINGSon{\HEADINGSsingle}}
6417
6418 \def\CHAPPAGodd{%
6419 \global\let\contentsalignmacro = \chapoddpage
6420 \global\let\pchapsepmacro=\chapoddpage
6421 \global\let\pagealignmacro=\chapoddpage
6422 \global\def\HEADINGSon{\HEADINGSdouble}}
6423
6424 \CHAPPAGon
6425
6426 % \chapmacro - Chapter opening.
6427 %
6428 % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6429 % Yappendix, Yomitfromtoc), #3 the chapter number.
6430 % Not used for @heading series.
6431 %
6432 % To test against our argument.
6433 \def\Ynothingkeyword{Ynothing}
6434 \def\Yappendixkeyword{Yappendix}
6435 \def\Yomitfromtockeyword{Yomitfromtoc}
6436 %
6437 \def\chapmacro#1#2#3{%
6438 \expandafter\ifx\thisenv\titlepage\else
6439 \checkenv{}% chapters, etc., should not start inside an environment.
6440 \fi
6441 % FIXME: \chapmacro is currently called from inside \titlepage when
6442 % \setcontentsaftertitlepage to print the "Table of Contents" heading, but
6443 % this should probably be done by \sectionheading with an option to print
6444 % in chapter size.
6445 %
6446 % Insert the first mark before the heading break (see notes for \domark).
6447 \let\prevchapterdefs=\lastchapterdefs
6448 \let\prevsectiondefs=\lastsectiondefs
6449 \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6450 \gdef\thissection{}}%
6451 %
6452 \def\temptype{#2}%
6453 \ifx\temptype\Ynothingkeyword
6454 \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6455 \gdef\thischapter{\thischaptername}}%
6456 \else\ifx\temptype\Yomitfromtockeyword
6457 \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6458 \gdef\thischapter{}}%
6459 \else\ifx\temptype\Yappendixkeyword
6460 \toks0={#1}%
6461 \xdef\lastchapterdefs{%
6462 \gdef\noexpand\thischaptername{\the\toks0}%
6463 \gdef\noexpand\thischapternum{\appendixletter}%
6464 % \noexpand\putwordAppendix avoids expanding indigestible
6465 % commands in some of the translations.
6466 \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
6467 \noexpand\thischapternum:
6468 \noexpand\thischaptername}%
6469 }%
6470 \else
6471 \toks0={#1}%
6472 \xdef\lastchapterdefs{%
6473 \gdef\noexpand\thischaptername{\the\toks0}%
6474 \gdef\noexpand\thischapternum{\the\chapno}%
6475 % \noexpand\putwordChapter avoids expanding indigestible
6476 % commands in some of the translations.
6477 \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
6478 \noexpand\thischapternum:
6479 \noexpand\thischaptername}%
6480 }%
6481 \fi\fi\fi
6482 %
6483 % Output the mark. Pass it through \safewhatsit, to take care of
6484 % the preceding space.
6485 \safewhatsit\domark
6486 %
6487 % Insert the chapter heading break.
6488 \pchapsepmacro
6489 %
6490 % Now the second mark, after the heading break. No break points
6491 % between here and the heading.
6492 \let\prevchapterdefs=\lastchapterdefs
6493 \let\prevsectiondefs=\lastsectiondefs
6494 \domark
6495 %
6496 {%
6497 \chapfonts \rmisbold
6498 \let\footnote=\errfootnoteheading % give better error message
6499 %
6500 % Have to define \lastsection before calling \donoderef, because the
6501 % xref code eventually uses it. On the other hand, it has to be called
6502 % after \pchapsepmacro, or the headline will change too soon.
6503 \gdef\lastsection{#1}%
6504 %
6505 % Only insert the separating space if we have a chapter/appendix
6506 % number, and don't print the unnumbered ``number''.
6507 \ifx\temptype\Ynothingkeyword
6508 \setbox0 = \hbox{}%
6509 \def\toctype{unnchap}%
6510 \else\ifx\temptype\Yomitfromtockeyword
6511 \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6512 \def\toctype{omit}%
6513 \else\ifx\temptype\Yappendixkeyword
6514 \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6515 \def\toctype{app}%
6516 \else
6517 \setbox0 = \hbox{#3\enspace}%
6518 \def\toctype{numchap}%
6519 \fi\fi\fi
6520 %
6521 % Write the toc entry for this chapter. Must come before the
6522 % \donoderef, because we include the current node name in the toc
6523 % entry, and \donoderef resets it to empty.
6524 \writetocentry{\toctype}{#1}{#3}%
6525 %
6526 % For pdftex, we have to write out the node definition (aka, make
6527 % the pdfdest) after any page break, but before the actual text has
6528 % been typeset. If the destination for the pdf outline is after the
6529 % text, then jumping from the outline may wind up with the text not
6530 % being visible, for instance under high magnification.
6531 \donoderef{#2}%
6532 %
6533 % Typeset the actual heading.
6534 \nobreak % Avoid page breaks at the interline glue.
6535 \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
6536 \unhbox0 #1\par}%
6537 }%
6538 \nobreak\bigskip % no page break after a chapter title
6539 \nobreak
6540 }
6541
6542 % @centerchap -- centered and unnumbered.
6543 \let\centerparametersmaybe = \relax
6544 \def\centerparameters{%
6545 \advance\rightskip by 3\rightskip
6546 \leftskip = \rightskip
6547 \parfillskip = 0pt
6548 }
6549
6550
6551 % Section titles. These macros combine the section number parts and
6552 % call the generic \sectionheading to do the printing.
6553 %
6554 \newskip\secheadingskip
6555 \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
6556
6557 % Subsection titles.
6558 \newskip\subsecheadingskip
6559 \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
6560
6561 % Subsubsection titles.
6562 \def\subsubsecheadingskip{\subsecheadingskip}
6563 \def\subsubsecheadingbreak{\subsecheadingbreak}
6564
6565
6566 % Print any size, any type, section title.
6567 %
6568 % #1 is the text of the title,
6569 % #2 is the section level (sec/subsec/subsubsec),
6570 % #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6571 % #4 is the section number.
6572 %
6573 \def\seckeyword{sec}
6574 %
6575 \def\sectionheading#1#2#3#4{%
6576 {%
6577 \def\sectionlevel{#2}%
6578 \def\temptype{#3}%
6579 %
6580 % It is ok for the @heading series commands to appear inside an
6581 % environment (it's been historically allowed, though the logic is
6582 % dubious), but not the others.
6583 \ifx\temptype\Yomitfromtockeyword\else
6584 \checkenv{}% non-@*heading should not be in an environment.
6585 \fi
6586 \let\footnote=\errfootnoteheading
6587 %
6588 % Switch to the right set of fonts.
6589 \csname #2fonts\endcsname \rmisbold
6590 %
6591 % Insert first mark before the heading break (see notes for \domark).
6592 \let\prevsectiondefs=\lastsectiondefs
6593 \ifx\temptype\Ynothingkeyword
6594 \ifx\sectionlevel\seckeyword
6595 \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6596 \gdef\thissection{\thissectionname}}%
6597 \fi
6598 \else\ifx\temptype\Yomitfromtockeyword
6599 % Don't redefine \thissection.
6600 \else\ifx\temptype\Yappendixkeyword
6601 \ifx\sectionlevel\seckeyword
6602 \toks0={#1}%
6603 \xdef\lastsectiondefs{%
6604 \gdef\noexpand\thissectionname{\the\toks0}%
6605 \gdef\noexpand\thissectionnum{#4}%
6606 % \noexpand\putwordSection avoids expanding indigestible
6607 % commands in some of the translations.
6608 \gdef\noexpand\thissection{\noexpand\putwordSection{}
6609 \noexpand\thissectionnum:
6610 \noexpand\thissectionname}%
6611 }%
6612 \fi
6613 \else
6614 \ifx\sectionlevel\seckeyword
6615 \toks0={#1}%
6616 \xdef\lastsectiondefs{%
6617 \gdef\noexpand\thissectionname{\the\toks0}%
6618 \gdef\noexpand\thissectionnum{#4}%
6619 % \noexpand\putwordSection avoids expanding indigestible
6620 % commands in some of the translations.
6621 \gdef\noexpand\thissection{\noexpand\putwordSection{}
6622 \noexpand\thissectionnum:
6623 \noexpand\thissectionname}%
6624 }%
6625 \fi
6626 \fi\fi\fi
6627 %
6628 % Go into vertical mode. Usually we'll already be there, but we
6629 % don't want the following whatsit to end up in a preceding paragraph
6630 % if the document didn't happen to have a blank line.
6631 \par
6632 %
6633 % Output the mark. Pass it through \safewhatsit, to take care of
6634 % the preceding space.
6635 \safewhatsit\domark
6636 %
6637 % Insert space above the heading.
6638 \csname #2headingbreak\endcsname
6639 %
6640 % Now the second mark, after the heading break. No break points
6641 % between here and the heading.
6642 \global\let\prevsectiondefs=\lastsectiondefs
6643 \domark
6644 %
6645 % Only insert the space after the number if we have a section number.
6646 \ifx\temptype\Ynothingkeyword
6647 \setbox0 = \hbox{}%
6648 \def\toctype{unn}%
6649 \gdef\lastsection{#1}%
6650 \else\ifx\temptype\Yomitfromtockeyword
6651 % for @headings -- no section number, don't include in toc,
6652 % and don't redefine \lastsection.
6653 \setbox0 = \hbox{}%
6654 \def\toctype{omit}%
6655 \let\sectionlevel=\empty
6656 \else\ifx\temptype\Yappendixkeyword
6657 \setbox0 = \hbox{#4\enspace}%
6658 \def\toctype{app}%
6659 \gdef\lastsection{#1}%
6660 \else
6661 \setbox0 = \hbox{#4\enspace}%
6662 \def\toctype{num}%
6663 \gdef\lastsection{#1}%
6664 \fi\fi\fi
6665 %
6666 % Write the toc entry (before \donoderef). See comments in \chapmacro.
6667 \writetocentry{\toctype\sectionlevel}{#1}{#4}%
6668 %
6669 % Write the node reference (= pdf destination for pdftex).
6670 % Again, see comments in \chapmacro.
6671 \donoderef{#3}%
6672 %
6673 % Interline glue will be inserted when the vbox is completed.
6674 % That glue will be a valid breakpoint for the page, since it'll be
6675 % preceded by a whatsit (usually from the \donoderef, or from the
6676 % \writetocentry if there was no node). We don't want to allow that
6677 % break, since then the whatsits could end up on page n while the
6678 % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000.
6679 \nobreak
6680 %
6681 % Output the actual section heading.
6682 \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
6683 \hangindent=\wd0 % zero if no section number
6684 \unhbox0 #1}%
6685 }%
6686 % Add extra space after the heading -- half of whatever came above it.
6687 % Don't allow stretch, though.
6688 \kern .5 \csname #2headingskip\endcsname
6689 %
6690 % Do not let the kern be a potential breakpoint, as it would be if it
6691 % was followed by glue.
6692 \nobreak
6693 %
6694 % We'll almost certainly start a paragraph next, so don't let that
6695 % glue accumulate. (Not a breakpoint because it's preceded by a
6696 % discardable item.) However, when a paragraph is not started next
6697 % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6698 % or the negative glue will cause weirdly wrong output, typically
6699 % obscuring the section heading with something else.
6700 \vskip-\parskip
6701 %
6702 % This is so the last item on the main vertical list is a known
6703 % \penalty > 10000, so \startdefun, etc., can recognize the situation
6704 % and do the needful.
6705 \penalty 10001
6706 }
6707
6708
6709 \message{toc,}
6710 % Table of contents.
6711 \newwrite\tocfile
6712
6713 % Write an entry to the toc file, opening it if necessary.
6714 % Called from @chapter, etc.
6715 %
6716 % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6717 % We append the current node name (if any) and page number as additional
6718 % arguments for the \{chap,sec,...}entry macros which will eventually
6719 % read this. The node name is used in the pdf outlines as the
6720 % destination to jump to.
6721 %
6722 % We open the .toc file for writing here instead of at @setfilename (or
6723 % any other fixed time) so that @contents can be anywhere in the document.
6724 % But if #1 is `omit', then we don't do anything. This is used for the
6725 % table of contents chapter openings themselves.
6726 %
6727 \newif\iftocfileopened
6728 \def\omitkeyword{omit}%
6729 %
6730 \def\writetocentry#1#2#3{%
6731 \edef\writetoctype{#1}%
6732 \ifx\writetoctype\omitkeyword \else
6733 \iftocfileopened\else
6734 \immediate\openout\tocfile = \jobname.toc
6735 \global\tocfileopenedtrue
6736 \fi
6737 %
6738 \iflinks
6739 {\atdummies
6740 \edef\temp{%
6741 \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6742 \temp
6743 }%
6744 \fi
6745 \fi
6746 %
6747 % Tell \shipout to create a pdf destination on each page, if we're
6748 % writing pdf. These are used in the table of contents. We can't
6749 % just write one on every page because the title pages are numbered
6750 % 1 and 2 (the page numbers aren't printed), and so are the first
6751 % two pages of the document. Thus, we'd have two destinations named
6752 % `1', and two named `2'.
6753 \ifpdf
6754 \global\pdfmakepagedesttrue
6755 \else
6756 \ifx\XeTeXrevision\thisisundefined
6757 \else
6758 \global\pdfmakepagedesttrue
6759 \fi
6760 \fi
6761 }
6762
6763
6764 % These characters do not print properly in the Computer Modern roman
6765 % fonts, so we must take special care. This is more or less redundant
6766 % with the Texinfo input format setup at the end of this file.
6767 %
6768 \def\activecatcodes{%
6769 \catcode`\"=\active
6770 \catcode`\$=\active
6771 \catcode`\<=\active
6772 \catcode`\>=\active
6773 \catcode`\\=\active
6774 \catcode`\^=\active
6775 \catcode`\_=\active
6776 \catcode`\|=\active
6777 \catcode`\~=\active
6778 }
6779
6780
6781 % Read the toc file, which is essentially Texinfo input.
6782 \def\readtocfile{%
6783 \setupdatafile
6784 \activecatcodes
6785 \input \tocreadfilename
6786 }
6787
6788 \newskip\contentsrightmargin \contentsrightmargin=1in
6789 \newcount\savepageno
6790 \newcount\lastnegativepageno \lastnegativepageno = -1
6791
6792 % Prepare to read what we've written to \tocfile.
6793 %
6794 \def\startcontents#1{%
6795 % If @setchapternewpage on, and @headings double, the contents should
6796 % start on an odd page, unlike chapters. Thus, we maintain
6797 % \contentsalignmacro in parallel with \pagealignmacro.
6798 % From: Torbjorn Granlund <tege@matematik.su.se>
6799 \contentsalignmacro
6800 \immediate\closeout\tocfile
6801 %
6802 % Don't need to put `Contents' or `Short Contents' in the headline.
6803 % It is abundantly clear what they are.
6804 \chapmacro{#1}{Yomitfromtoc}{}%
6805 %
6806 \savepageno = \pageno
6807 \begingroup % Set up to handle contents files properly.
6808 \raggedbottom % Worry more about breakpoints than the bottom.
6809 \entryrightmargin=\contentsrightmargin % Don't use the full line length.
6810 %
6811 % Roman numerals for page numbers.
6812 \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
6813 }
6814
6815 % redefined for the two-volume lispref. We always output on
6816 % \jobname.toc even if this is redefined.
6817 %
6818 \def\tocreadfilename{\jobname.toc}
6819
6820 % Normal (long) toc.
6821 %
6822 \def\contents{%
6823 \startcontents{\putwordTOC}%
6824 \openin 1 \tocreadfilename\space
6825 \ifeof 1 \else
6826 \readtocfile
6827 \fi
6828 \vfill \eject
6829 \contentsalignmacro % in case @setchapternewpage odd is in effect
6830 \ifeof 1 \else
6831 \pdfmakeoutlines
6832 \fi
6833 \closein 1
6834 \endgroup
6835 \lastnegativepageno = \pageno
6836 \global\pageno = \savepageno
6837 }
6838
6839 % And just the chapters.
6840 \def\summarycontents{%
6841 \startcontents{\putwordShortTOC}%
6842 %
6843 \let\partentry = \shortpartentry
6844 \let\numchapentry = \shortchapentry
6845 \let\appentry = \shortchapentry
6846 \let\unnchapentry = \shortunnchapentry
6847 % We want a true roman here for the page numbers.
6848 \secfonts
6849 \let\rm=\shortcontrm \let\bf=\shortcontbf
6850 \let\sl=\shortcontsl \let\tt=\shortconttt
6851 \rm
6852 \hyphenpenalty = 10000
6853 \advance\baselineskip by 1pt % Open it up a little.
6854 \def\numsecentry##1##2##3##4{}
6855 \let\appsecentry = \numsecentry
6856 \let\unnsecentry = \numsecentry
6857 \let\numsubsecentry = \numsecentry
6858 \let\appsubsecentry = \numsecentry
6859 \let\unnsubsecentry = \numsecentry
6860 \let\numsubsubsecentry = \numsecentry
6861 \let\appsubsubsecentry = \numsecentry
6862 \let\unnsubsubsecentry = \numsecentry
6863 \openin 1 \tocreadfilename\space
6864 \ifeof 1 \else
6865 \readtocfile
6866 \fi
6867 \closein 1
6868 \vfill \eject
6869 \contentsalignmacro % in case @setchapternewpage odd is in effect
6870 \endgroup
6871 \lastnegativepageno = \pageno
6872 \global\pageno = \savepageno
6873 }
6874 \let\shortcontents = \summarycontents
6875
6876 % Typeset the label for a chapter or appendix for the short contents.
6877 % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6878 %
6879 \def\shortchaplabel#1{%
6880 % This space should be enough, since a single number is .5em, and the
6881 % widest letter (M) is 1em, at least in the Computer Modern fonts.
6882 % But use \hss just in case.
6883 % (This space doesn't include the extra space that gets added after
6884 % the label; that gets put in by \shortchapentry above.)
6885 %
6886 % We'd like to right-justify chapter numbers, but that looks strange
6887 % with appendix letters. And right-justifying numbers and
6888 % left-justifying letters looks strange when there is less than 10
6889 % chapters. Have to read the whole toc once to know how many chapters
6890 % there are before deciding ...
6891 \hbox to 1em{#1\hss}%
6892 }
6893
6894 % These macros generate individual entries in the table of contents.
6895 % The first argument is the chapter or section name.
6896 % The last argument is the page number.
6897 % The arguments in between are the chapter number, section number, ...
6898
6899 % Parts, in the main contents. Replace the part number, which doesn't
6900 % exist, with an empty box. Let's hope all the numbers have the same width.
6901 % Also ignore the page number, which is conventionally not printed.
6902 \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6903 \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}}
6904 %
6905 % Parts, in the short toc.
6906 \def\shortpartentry#1#2#3#4{%
6907 \penalty-300
6908 \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
6909 \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
6910 }
6911
6912 % Chapters, in the main contents.
6913 \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
6914
6915 % Chapters, in the short toc.
6916 % See comments in \dochapentry re vbox and related settings.
6917 \def\shortchapentry#1#2#3#4{%
6918 \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
6919 }
6920
6921 % Appendices, in the main contents.
6922 % Need the word Appendix, and a fixed-size box.
6923 %
6924 \def\appendixbox#1{%
6925 % We use M since it's probably the widest letter.
6926 \setbox0 = \hbox{\putwordAppendix{} M}%
6927 \hbox to \wd0{\putwordAppendix{} #1\hss}}
6928 %
6929 \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
6930
6931 % Unnumbered chapters.
6932 \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
6933 \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
6934
6935 % Sections.
6936 \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
6937 \let\appsecentry=\numsecentry
6938 \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
6939
6940 % Subsections.
6941 \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
6942 \let\appsubsecentry=\numsubsecentry
6943 \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
6944
6945 % And subsubsections.
6946 \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
6947 \let\appsubsubsecentry=\numsubsubsecentry
6948 \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
6949
6950 % This parameter controls the indentation of the various levels.
6951 % Same as \defaultparindent.
6952 \newdimen\tocindent \tocindent = 15pt
6953
6954 % Now for the actual typesetting. In all these, #1 is the text and #2 is the
6955 % page number.
6956 %
6957 % If the toc has to be broken over pages, we want it to be at chapters
6958 % if at all possible; hence the \penalty.
6959 \def\dochapentry#1#2{%
6960 \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
6961 \begingroup
6962 % Move the page numbers slightly to the right
6963 \advance\entryrightmargin by -0.05em
6964 \chapentryfonts
6965 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6966 \endgroup
6967 \nobreak\vskip .25\baselineskip plus.1\baselineskip
6968 }
6969
6970 \def\dosecentry#1#2{\begingroup
6971 \secentryfonts \leftskip=\tocindent
6972 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6973 \endgroup}
6974
6975 \def\dosubsecentry#1#2{\begingroup
6976 \subsecentryfonts \leftskip=2\tocindent
6977 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6978 \endgroup}
6979
6980 \def\dosubsubsecentry#1#2{\begingroup
6981 \subsubsecentryfonts \leftskip=3\tocindent
6982 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6983 \endgroup}
6984
6985 % We use the same \entry macro as for the index entries.
6986 \let\tocentry = \entry
6987
6988 % Space between chapter (or whatever) number and the title.
6989 \def\labelspace{\hskip1em \relax}
6990
6991 \def\dopageno#1{{\rm #1}}
6992 \def\doshortpageno#1{{\rm #1}}
6993
6994 \def\chapentryfonts{\secfonts \rm}
6995 \def\secentryfonts{\textfonts}
6996 \def\subsecentryfonts{\textfonts}
6997 \def\subsubsecentryfonts{\textfonts}
6998
6999
7000 \message{environments,}
7001 % @foo ... @end foo.
7002
7003 % @tex ... @end tex escapes into raw TeX temporarily.
7004 % One exception: @ is still an escape character, so that @end tex works.
7005 % But \@ or @@ will get a plain @ character.
7006
7007 \envdef\tex{%
7008 \setupmarkupstyle{tex}%
7009 \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
7010 \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
7011 \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
7012 \catcode `\%=14
7013 \catcode `\+=\other
7014 \catcode `\"=\other
7015 \catcode `\|=\other
7016 \catcode `\<=\other
7017 \catcode `\>=\other
7018 \catcode `\`=\other
7019 \catcode `\'=\other
7020 %
7021 % ' is active in math mode (mathcode"8000). So reset it, and all our
7022 % other math active characters (just in case), to plain's definitions.
7023 \mathactive
7024 %
7025 % Inverse of the list at the beginning of the file.
7026 \let\b=\ptexb
7027 \let\bullet=\ptexbullet
7028 \let\c=\ptexc
7029 \let\,=\ptexcomma
7030 \let\.=\ptexdot
7031 \let\dots=\ptexdots
7032 \let\equiv=\ptexequiv
7033 \let\!=\ptexexclam
7034 \let\i=\ptexi
7035 \let\indent=\ptexindent
7036 \let\noindent=\ptexnoindent
7037 \let\{=\ptexlbrace
7038 \let\+=\tabalign
7039 \let\}=\ptexrbrace
7040 \let\/=\ptexslash
7041 \let\sp=\ptexsp
7042 \let\*=\ptexstar
7043 %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
7044 \let\t=\ptext
7045 \expandafter \let\csname top\endcsname=\ptextop % we've made it outer
7046 \let\frenchspacing=\plainfrenchspacing
7047 %
7048 \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
7049 \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
7050 \def\@{@}%
7051 }
7052 % There is no need to define \Etex.
7053
7054 % Define @lisp ... @end lisp.
7055 % @lisp environment forms a group so it can rebind things,
7056 % including the definition of @end lisp (which normally is erroneous).
7057
7058 % Amount to narrow the margins by for @lisp.
7059 \newskip\lispnarrowing \lispnarrowing=0.4in
7060
7061 % This is the definition that ^^M gets inside @lisp, @example, and other
7062 % such environments. \null is better than a space, since it doesn't
7063 % have any width.
7064 \def\lisppar{\null\endgraf}
7065
7066 % This space is always present above and below environments.
7067 \newskip\envskipamount \envskipamount = 0pt
7068
7069 % Make spacing and below environment symmetrical. We use \parskip here
7070 % to help in doing that, since in @example-like environments \parskip
7071 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
7072 % start of the next paragraph will insert \parskip.
7073 %
7074 \def\aboveenvbreak{{%
7075 % =10000 instead of <10000 because of a special case in \itemzzz and
7076 % \sectionheading, q.v.
7077 \ifnum \lastpenalty=10000 \else
7078 \advance\envskipamount by \parskip
7079 \endgraf
7080 \ifdim\lastskip<\envskipamount
7081 \removelastskip
7082 \ifnum\lastpenalty<10000
7083 % Penalize breaking before the environment, because preceding text
7084 % often leads into it.
7085 \penalty100
7086 \fi
7087 \vskip\envskipamount
7088 \fi
7089 \fi
7090 }}
7091
7092 \def\afterenvbreak{{%
7093 % =10000 instead of <10000 because of a special case in \itemzzz and
7094 % \sectionheading, q.v.
7095 \ifnum \lastpenalty=10000 \else
7096 \advance\envskipamount by \parskip
7097 \endgraf
7098 \ifdim\lastskip<\envskipamount
7099 \removelastskip
7100 % it's not a good place to break if the last penalty was \nobreak
7101 % or better ...
7102 \ifnum\lastpenalty<10000 \penalty-50 \fi
7103 \vskip\envskipamount
7104 \fi
7105 \fi
7106 }}
7107
7108 % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will
7109 % also clear it, so that its embedded environments do the narrowing again.
7110 \let\nonarrowing=\relax
7111
7112 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
7113 % environment contents.
7114 \font\circle=lcircle10
7115 \newdimen\circthick
7116 \newdimen\cartouter\newdimen\cartinner
7117 \newskip\normbskip\newskip\normpskip\newskip\normlskip
7118 \circthick=\fontdimen8\circle
7119 %
7120 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
7121 \def\ctr{{\hskip 6pt\circle\char'010}}
7122 \def\cbl{{\circle\char'012\hskip -6pt}}
7123 \def\cbr{{\hskip 6pt\circle\char'011}}
7124 \def\carttop{\hbox to \cartouter{\hskip\lskip
7125 \ctl\leaders\hrule height\circthick\hfil\ctr
7126 \hskip\rskip}}
7127 \def\cartbot{\hbox to \cartouter{\hskip\lskip
7128 \cbl\leaders\hrule height\circthick\hfil\cbr
7129 \hskip\rskip}}
7130 %
7131 \newskip\lskip\newskip\rskip
7132
7133 \envdef\cartouche{%
7134 \ifhmode\par\fi % can't be in the midst of a paragraph.
7135 \startsavinginserts
7136 \lskip=\leftskip \rskip=\rightskip
7137 \leftskip=0pt\rightskip=0pt % we want these *outside*.
7138 \cartinner=\hsize \advance\cartinner by-\lskip
7139 \advance\cartinner by-\rskip
7140 \cartouter=\hsize
7141 \advance\cartouter by 18.4pt % allow for 3pt kerns on either
7142 % side, and for 6pt waste from
7143 % each corner char, and rule thickness
7144 \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
7145 %
7146 % If this cartouche directly follows a sectioning command, we need the
7147 % \parskip glue (backspaced over by default) or the cartouche can
7148 % collide with the section heading.
7149 \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
7150 %
7151 \setbox\groupbox=\vbox\bgroup
7152 \baselineskip=0pt\parskip=0pt\lineskip=0pt
7153 \carttop
7154 \hbox\bgroup
7155 \hskip\lskip
7156 \vrule\kern3pt
7157 \vbox\bgroup
7158 \kern3pt
7159 \hsize=\cartinner
7160 \baselineskip=\normbskip
7161 \lineskip=\normlskip
7162 \parskip=\normpskip
7163 \vskip -\parskip
7164 \comment % For explanation, see the end of def\group.
7165 }
7166 \def\Ecartouche{%
7167 \ifhmode\par\fi
7168 \kern3pt
7169 \egroup
7170 \kern3pt\vrule
7171 \hskip\rskip
7172 \egroup
7173 \cartbot
7174 \egroup
7175 \addgroupbox
7176 \checkinserts
7177 }
7178
7179
7180 % This macro is called at the beginning of all the @example variants,
7181 % inside a group.
7182 \newdimen\nonfillparindent
7183 \def\nonfillstart{%
7184 \aboveenvbreak
7185 \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
7186 \sepspaces % Make spaces be word-separators rather than space tokens.
7187 \let\par = \lisppar % don't ignore blank lines
7188 \obeylines % each line of input is a line of output
7189 \parskip = 0pt
7190 % Turn off paragraph indentation but redefine \indent to emulate
7191 % the normal \indent.
7192 \nonfillparindent=\parindent
7193 \parindent = 0pt
7194 \let\indent\nonfillindent
7195 %
7196 \emergencystretch = 0pt % don't try to avoid overfull boxes
7197 \ifx\nonarrowing\relax
7198 \advance \leftskip by \lispnarrowing
7199 \exdentamount=\lispnarrowing
7200 \else
7201 \let\nonarrowing = \relax
7202 \fi
7203 \let\exdent=\nofillexdent
7204 }
7205
7206 \begingroup
7207 \obeyspaces
7208 % We want to swallow spaces (but not other tokens) after the fake
7209 % @indent in our nonfill-environments, where spaces are normally
7210 % active and set to @tie, resulting in them not being ignored after
7211 % @indent.
7212 \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
7213 \gdef\nonfillindentcheck{%
7214 \ifx\temp %
7215 \expandafter\nonfillindentgobble%
7216 \else%
7217 \leavevmode\nonfillindentbox%
7218 \fi%
7219 }%
7220 \endgroup
7221 \def\nonfillindentgobble#1{\nonfillindent}
7222 \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7223
7224 % If you want all examples etc. small: @set dispenvsize small.
7225 % If you want even small examples the full size: @set dispenvsize nosmall.
7226 % This affects the following displayed environments:
7227 % @example, @display, @format, @lisp
7228 %
7229 \def\smallword{small}
7230 \def\nosmallword{nosmall}
7231 \let\SETdispenvsize\relax
7232 \def\setnormaldispenv{%
7233 \ifx\SETdispenvsize\smallword
7234 % end paragraph for sake of leading, in case document has no blank
7235 % line. This is redundant with what happens in \aboveenvbreak, but
7236 % we need to do it before changing the fonts, and it's inconvenient
7237 % to change the fonts afterward.
7238 \ifnum \lastpenalty=10000 \else \endgraf \fi
7239 \smallexamplefonts \rm
7240 \fi
7241 }
7242 \def\setsmalldispenv{%
7243 \ifx\SETdispenvsize\nosmallword
7244 \else
7245 \ifnum \lastpenalty=10000 \else \endgraf \fi
7246 \smallexamplefonts \rm
7247 \fi
7248 }
7249
7250 % We often define two environments, @foo and @smallfoo.
7251 % Let's do it in one command. #1 is the env name, #2 the definition.
7252 \def\makedispenvdef#1#2{%
7253 \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7254 \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
7255 \expandafter\let\csname E#1\endcsname \afterenvbreak
7256 \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
7257 }
7258
7259 % Define two environment synonyms (#1 and #2) for an environment.
7260 \def\maketwodispenvdef#1#2#3{%
7261 \makedispenvdef{#1}{#3}%
7262 \makedispenvdef{#2}{#3}%
7263 }
7264 %
7265 % @lisp: indented, narrowed, typewriter font;
7266 % @example: same as @lisp.
7267 %
7268 % @smallexample and @smalllisp: use smaller fonts.
7269 % Originally contributed by Pavel@xerox.
7270 %
7271 \maketwodispenvdef{lisp}{example}{%
7272 \nonfillstart
7273 \tt\setupmarkupstyle{example}%
7274 \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
7275 \gobble % eat return
7276 }
7277 % @display/@smalldisplay: same as @lisp except keep current font.
7278 %
7279 \makedispenvdef{display}{%
7280 \nonfillstart
7281 \gobble
7282 }
7283
7284 % @format/@smallformat: same as @display except don't narrow margins.
7285 %
7286 \makedispenvdef{format}{%
7287 \let\nonarrowing = t%
7288 \nonfillstart
7289 \gobble
7290 }
7291
7292 % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7293 \envdef\flushleft{%
7294 \let\nonarrowing = t%
7295 \nonfillstart
7296 \gobble
7297 }
7298 \let\Eflushleft = \afterenvbreak
7299
7300 % @flushright.
7301 %
7302 \envdef\flushright{%
7303 \let\nonarrowing = t%
7304 \nonfillstart
7305 \advance\leftskip by 0pt plus 1fill\relax
7306 \gobble
7307 }
7308 \let\Eflushright = \afterenvbreak
7309
7310
7311 % @raggedright does more-or-less normal line breaking but no right
7312 % justification. From plain.tex. Don't stretch around special
7313 % characters in urls in this environment, since the stretch at the right
7314 % should be enough.
7315 \envdef\raggedright{%
7316 \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7317 \def\urefprestretchamount{0pt}%
7318 \def\urefpoststretchamount{0pt}%
7319 }
7320 \let\Eraggedright\par
7321
7322 \envdef\raggedleft{%
7323 \parindent=0pt \leftskip0pt plus2em
7324 \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7325 \hbadness=10000 % Last line will usually be underfull, so turn off
7326 % badness reporting.
7327 }
7328 \let\Eraggedleft\par
7329
7330 \envdef\raggedcenter{%
7331 \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
7332 \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7333 \hbadness=10000 % Last line will usually be underfull, so turn off
7334 % badness reporting.
7335 }
7336 \let\Eraggedcenter\par
7337
7338
7339 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
7340 % and narrows the margins. We keep \parskip nonzero in general, since
7341 % we're doing normal filling. So, when using \aboveenvbreak and
7342 % \afterenvbreak, temporarily make \parskip 0.
7343 %
7344 \makedispenvdef{quotation}{\quotationstart}
7345 %
7346 \def\quotationstart{%
7347 \indentedblockstart % same as \indentedblock, but increase right margin too.
7348 \ifx\nonarrowing\relax
7349 \advance\rightskip by \lispnarrowing
7350 \fi
7351 \parsearg\quotationlabel
7352 }
7353
7354 % We have retained a nonzero parskip for the environment, since we're
7355 % doing normal filling.
7356 %
7357 \def\Equotation{%
7358 \par
7359 \ifx\quotationauthor\thisisundefined\else
7360 % indent a bit.
7361 \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7362 \fi
7363 {\parskip=0pt \afterenvbreak}%
7364 }
7365 \def\Esmallquotation{\Equotation}
7366
7367 % If we're given an argument, typeset it in bold with a colon after.
7368 \def\quotationlabel#1{%
7369 \def\temp{#1}%
7370 \ifx\temp\empty \else
7371 {\bf #1: }%
7372 \fi
7373 }
7374
7375 % @indentedblock is like @quotation, but indents only on the left and
7376 % has no optional argument.
7377 %
7378 \makedispenvdef{indentedblock}{\indentedblockstart}
7379 %
7380 \def\indentedblockstart{%
7381 {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7382 \parindent=0pt
7383 %
7384 % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7385 \ifx\nonarrowing\relax
7386 \advance\leftskip by \lispnarrowing
7387 \exdentamount = \lispnarrowing
7388 \else
7389 \let\nonarrowing = \relax
7390 \fi
7391 }
7392
7393 % Keep a nonzero parskip for the environment, since we're doing normal filling.
7394 %
7395 \def\Eindentedblock{%
7396 \par
7397 {\parskip=0pt \afterenvbreak}%
7398 }
7399 \def\Esmallindentedblock{\Eindentedblock}
7400
7401
7402 % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7403 % If we want to allow any <char> as delimiter,
7404 % we need the curly braces so that makeinfo sees the @verb command, eg:
7405 % `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org
7406 %
7407 % [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
7408 %
7409 % [Knuth] p.344; only we need to do the other characters Texinfo sets
7410 % active too. Otherwise, they get lost as the first character on a
7411 % verbatim line.
7412 \def\dospecials{%
7413 \do\ \do\\\do\{\do\}\do\$\do\&%
7414 \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7415 \do\<\do\>\do\|\do\@\do+\do\"%
7416 % Don't do the quotes -- if we do, @set txicodequoteundirected and
7417 % @set txicodequotebacktick will not have effect on @verb and
7418 % @verbatim, and ?` and !` ligatures won't get disabled.
7419 %\do\`\do\'%
7420 }
7421 %
7422 % [Knuth] p. 380
7423 \def\uncatcodespecials{%
7424 \def\do##1{\catcode`##1=\other}\dospecials}
7425 %
7426 % Setup for the @verb command.
7427 %
7428 % Eight spaces for a tab
7429 \begingroup
7430 \catcode`\^^I=\active
7431 \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7432 \endgroup
7433 %
7434 \def\setupverb{%
7435 \tt % easiest (and conventionally used) font for verbatim
7436 \def\par{\leavevmode\endgraf}%
7437 \setupmarkupstyle{verb}%
7438 \tabeightspaces
7439 % Respect line breaks,
7440 % print special symbols as themselves, and
7441 % make each space count
7442 % must do in this order:
7443 \obeylines \uncatcodespecials \sepspaces
7444 }
7445
7446 % Setup for the @verbatim environment
7447 %
7448 % Real tab expansion.
7449 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7450 %
7451 % We typeset each line of the verbatim in an \hbox, so we can handle
7452 % tabs. The \global is in case the verbatim line starts with an accent,
7453 % or some other command that starts with a begin-group. Otherwise, the
7454 % entire \verbbox would disappear at the corresponding end-group, before
7455 % it is typeset. Meanwhile, we can't have nested verbatim commands
7456 % (can we?), so the \global won't be overwriting itself.
7457 \newbox\verbbox
7458 \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
7459 %
7460 \begingroup
7461 \catcode`\^^I=\active
7462 \gdef\tabexpand{%
7463 \catcode`\^^I=\active
7464 \def^^I{\leavevmode\egroup
7465 \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7466 \divide\dimen\verbbox by\tabw
7467 \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7468 \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw
7469 \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
7470 }%
7471 }
7472 \endgroup
7473
7474 % start the verbatim environment.
7475 \def\setupverbatim{%
7476 \let\nonarrowing = t%
7477 \nonfillstart
7478 \tt % easiest (and conventionally used) font for verbatim
7479 % The \leavevmode here is for blank lines. Otherwise, we would
7480 % never \starttabox and the \egroup would end verbatim mode.
7481 \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
7482 \tabexpand
7483 \setupmarkupstyle{verbatim}%
7484 % Respect line breaks,
7485 % print special symbols as themselves, and
7486 % make each space count.
7487 % Must do in this order:
7488 \obeylines \uncatcodespecials \sepspaces
7489 \everypar{\starttabbox}%
7490 }
7491
7492 % Do the @verb magic: verbatim text is quoted by unique
7493 % delimiter characters. Before first delimiter expect a
7494 % right brace, after last delimiter expect closing brace:
7495 %
7496 % \def\doverb'{'<char>#1<char>'}'{#1}
7497 %
7498 % [Knuth] p. 382; only eat outer {}
7499 \begingroup
7500 \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
7501 \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7502 \endgroup
7503 %
7504 \def\verb{\begingroup\setupverb\doverb}
7505 %
7506 %
7507 % Do the @verbatim magic: define the macro \doverbatim so that
7508 % the (first) argument ends when '@end verbatim' is reached, ie:
7509 %
7510 % \def\doverbatim#1@end verbatim{#1}
7511 %
7512 % For Texinfo it's a lot easier than for LaTeX,
7513 % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
7514 % we need not redefine '\', '{' and '}'.
7515 %
7516 % Inspired by LaTeX's verbatim command set [latex.ltx]
7517 %
7518 \begingroup
7519 \catcode`\ =\active
7520 \obeylines %
7521 % ignore everything up to the first ^^M, that's the newline at the end
7522 % of the @verbatim input line itself. Otherwise we get an extra blank
7523 % line in the output.
7524 \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
7525 % We really want {...\end verbatim} in the body of the macro, but
7526 % without the active space; thus we have to use \xdef and \gobble.
7527 \endgroup
7528 %
7529 \envdef\verbatim{%
7530 \setupverbatim\doverbatim
7531 }
7532 \let\Everbatim = \afterenvbreak
7533
7534
7535 % @verbatiminclude FILE - insert text of file in verbatim environment.
7536 %
7537 \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
7538 %
7539 \def\doverbatiminclude#1{%
7540 {%
7541 \makevalueexpandable
7542 \setupverbatim
7543 \indexnofonts % Allow `@@' and other weird things in file names.
7544 \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
7545 \input #1
7546 \afterenvbreak
7547 }%
7548 }
7549
7550 % @copying ... @end copying.
7551 % Save the text away for @insertcopying later.
7552 %
7553 % We save the uninterpreted tokens, rather than creating a box.
7554 % Saving the text in a box would be much easier, but then all the
7555 % typesetting commands (@smallbook, font changes, etc.) have to be done
7556 % beforehand -- and a) we want @copying to be done first in the source
7557 % file; b) letting users define the frontmatter in as flexible order as
7558 % possible is desirable.
7559 %
7560 \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
7561 \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
7562 %
7563 \def\insertcopying{%
7564 \begingroup
7565 \parindent = 0pt % paragraph indentation looks wrong on title page
7566 \scanexp\copyingtext
7567 \endgroup
7568 }
7569
7570
7571 \message{defuns,}
7572 % @defun etc.
7573
7574 \newskip\defbodyindent \defbodyindent=.4in
7575 \newskip\defargsindent \defargsindent=50pt
7576 \newskip\deflastargmargin \deflastargmargin=18pt
7577 \newcount\defunpenalty
7578
7579 % Start the processing of @deffn:
7580 \def\startdefun{%
7581 \ifnum\lastpenalty<10000
7582 \medbreak
7583 \defunpenalty=10003 % Will keep this @deffn together with the
7584 % following @def command, see below.
7585 \else
7586 % If there are two @def commands in a row, we'll have a \nobreak,
7587 % which is there to keep the function description together with its
7588 % header. But if there's nothing but headers, we need to allow a
7589 % break somewhere. Check specifically for penalty 10002, inserted
7590 % by \printdefunline, instead of 10000, since the sectioning
7591 % commands also insert a nobreak penalty, and we don't want to allow
7592 % a break between a section heading and a defun.
7593 %
7594 % As a further refinement, we avoid "club" headers by signalling
7595 % with penalty of 10003 after the very first @deffn in the
7596 % sequence (see above), and penalty of 10002 after any following
7597 % @def command.
7598 \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
7599 %
7600 % Similarly, after a section heading, do not allow a break.
7601 % But do insert the glue.
7602 \medskip % preceded by discardable penalty, so not a breakpoint
7603 \fi
7604 %
7605 \parindent=0in
7606 \advance\leftskip by \defbodyindent
7607 \exdentamount=\defbodyindent
7608 }
7609
7610 \def\dodefunx#1{%
7611 % First, check whether we are in the right environment:
7612 \checkenv#1%
7613 %
7614 % As above, allow line break if we have multiple x headers in a row.
7615 % It's not a great place, though.
7616 \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
7617 %
7618 % And now, it's time to reuse the body of the original defun:
7619 \expandafter\gobbledefun#1%
7620 }
7621 \def\gobbledefun#1\startdefun{}
7622
7623 % \printdefunline \deffnheader{text}
7624 %
7625 \def\printdefunline#1#2{%
7626 \begingroup
7627 % call \deffnheader:
7628 #1#2 \endheader
7629 % common ending:
7630 \interlinepenalty = 10000
7631 \advance\rightskip by 0pt plus 1fil\relax
7632 \endgraf
7633 \nobreak\vskip -\parskip
7634 \penalty\defunpenalty % signal to \startdefun and \dodefunx
7635 % Some of the @defun-type tags do not enable magic parentheses,
7636 % rendering the following check redundant. But we don't optimize.
7637 \checkparencounts
7638 \endgroup
7639 }
7640
7641 \def\Edefun{\endgraf\medbreak}
7642
7643 % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
7644 % the only thing remaining is to define \deffnheader.
7645 %
7646 \def\makedefun#1{%
7647 \expandafter\let\csname E#1\endcsname = \Edefun
7648 \edef\temp{\noexpand\domakedefun
7649 \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7650 \temp
7651 }
7652
7653 % \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
7654 %
7655 % Define \deffn and \deffnx, without parameters.
7656 % \deffnheader has to be defined explicitly.
7657 %
7658 \def\domakedefun#1#2#3{%
7659 \envdef#1{%
7660 \startdefun
7661 \doingtypefnfalse % distinguish typed functions from all else
7662 \parseargusing\activeparens{\printdefunline#3}%
7663 }%
7664 \def#2{\dodefunx#1}%
7665 \def#3%
7666 }
7667
7668 \newif\ifdoingtypefn % doing typed function?
7669 \newif\ifrettypeownline % typeset return type on its own line?
7670
7671 % @deftypefnnewline on|off says whether the return type of typed functions
7672 % are printed on their own line. This affects @deftypefn, @deftypefun,
7673 % @deftypeop, and @deftypemethod.
7674 %
7675 \parseargdef\deftypefnnewline{%
7676 \def\temp{#1}%
7677 \ifx\temp\onword
7678 \expandafter\let\csname SETtxideftypefnnl\endcsname
7679 = \empty
7680 \else\ifx\temp\offword
7681 \expandafter\let\csname SETtxideftypefnnl\endcsname
7682 = \relax
7683 \else
7684 \errhelp = \EMsimple
7685 \errmessage{Unknown @txideftypefnnl value `\temp',
7686 must be on|off}%
7687 \fi\fi
7688 }
7689
7690 % Untyped functions:
7691
7692 % @deffn category name args
7693 \makedefun{deffn}{\deffngeneral{}}
7694
7695 % @deffn category class name args
7696 \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
7697
7698 % \defopon {category on}class name args
7699 \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7700
7701 % \deffngeneral {subind}category name args
7702 %
7703 \def\deffngeneral#1#2 #3 #4\endheader{%
7704 % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
7705 \dosubind{fn}{\code{#3}}{#1}%
7706 \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
7707 }
7708
7709 % Typed functions:
7710
7711 % @deftypefn category type name args
7712 \makedefun{deftypefn}{\deftypefngeneral{}}
7713
7714 % @deftypeop category class type name args
7715 \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
7716
7717 % \deftypeopon {category on}class type name args
7718 \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7719
7720 % \deftypefngeneral {subind}category type name args
7721 %
7722 \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
7723 \dosubind{fn}{\code{#4}}{#1}%
7724 \doingtypefntrue
7725 \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7726 }
7727
7728 % Typed variables:
7729
7730 % @deftypevr category type var args
7731 \makedefun{deftypevr}{\deftypecvgeneral{}}
7732
7733 % @deftypecv category class type var args
7734 \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
7735
7736 % \deftypecvof {category of}class type var args
7737 \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
7738
7739 % \deftypecvgeneral {subind}category type var args
7740 %
7741 \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
7742 \dosubind{vr}{\code{#4}}{#1}%
7743 \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7744 }
7745
7746 % Untyped variables:
7747
7748 % @defvr category var args
7749 \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
7750
7751 % @defcv category class var args
7752 \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
7753
7754 % \defcvof {category of}class var args
7755 \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
7756
7757 % Types:
7758
7759 % @deftp category name args
7760 \makedefun{deftp}#1 #2 #3\endheader{%
7761 \doind{tp}{\code{#2}}%
7762 \defname{#1}{}{#2}\defunargs{#3\unskip}%
7763 }
7764
7765 % Remaining @defun-like shortcuts:
7766 \makedefun{defun}{\deffnheader{\putwordDeffunc} }
7767 \makedefun{defmac}{\deffnheader{\putwordDefmac} }
7768 \makedefun{defspec}{\deffnheader{\putwordDefspec} }
7769 \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7770 \makedefun{defvar}{\defvrheader{\putwordDefvar} }
7771 \makedefun{defopt}{\defvrheader{\putwordDefopt} }
7772 \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
7773 \makedefun{defmethod}{\defopon\putwordMethodon}
7774 \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
7775 \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
7776 \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
7777
7778 % \defname, which formats the name of the @def (not the args).
7779 % #1 is the category, such as "Function".
7780 % #2 is the return type, if any.
7781 % #3 is the function name.
7782 %
7783 % We are followed by (but not passed) the arguments, if any.
7784 %
7785 \def\defname#1#2#3{%
7786 \par
7787 % Get the values of \leftskip and \rightskip as they were outside the @def...
7788 \advance\leftskip by -\defbodyindent
7789 %
7790 % Determine if we are typesetting the return type of a typed function
7791 % on a line by itself.
7792 \rettypeownlinefalse
7793 \ifdoingtypefn % doing a typed function specifically?
7794 % then check user option for putting return type on its own line:
7795 \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
7796 \rettypeownlinetrue
7797 \fi
7798 \fi
7799 %
7800 % How we'll format the category name. Putting it in brackets helps
7801 % distinguish it from the body text that may end up on the next line
7802 % just below it.
7803 \def\temp{#1}%
7804 \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7805 %
7806 % Figure out line sizes for the paragraph shape. We'll always have at
7807 % least two.
7808 \tempnum = 2
7809 %
7810 % The first line needs space for \box0; but if \rightskip is nonzero,
7811 % we need only space for the part of \box0 which exceeds it:
7812 \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
7813 %
7814 % If doing a return type on its own line, we'll have another line.
7815 \ifrettypeownline
7816 \advance\tempnum by 1
7817 \def\maybeshapeline{0in \hsize}%
7818 \else
7819 \def\maybeshapeline{}%
7820 \fi
7821 %
7822 % The continuations:
7823 \dimen2=\hsize \advance\dimen2 by -\defargsindent
7824 %
7825 % The final paragraph shape:
7826 \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2
7827 %
7828 % Put the category name at the right margin.
7829 \noindent
7830 \hbox to 0pt{%
7831 \hfil\box0 \kern-\hsize
7832 % \hsize has to be shortened this way:
7833 \kern\leftskip
7834 % Intentionally do not respect \rightskip, since we need the space.
7835 }%
7836 %
7837 % Allow all lines to be underfull without complaint:
7838 \tolerance=10000 \hbadness=10000
7839 \exdentamount=\defbodyindent
7840 {%
7841 % defun fonts. We use typewriter by default (used to be bold) because:
7842 % . we're printing identifiers, they should be in tt in principle.
7843 % . in languages with many accents, such as Czech or French, it's
7844 % common to leave accents off identifiers. The result looks ok in
7845 % tt, but exceedingly strange in rm.
7846 % . we don't want -- and --- to be treated as ligatures.
7847 % . this still does not fix the ?` and !` ligatures, but so far no
7848 % one has made identifiers using them :).
7849 \df \tt
7850 \def\temp{#2}% text of the return type
7851 \ifx\temp\empty\else
7852 \tclose{\temp}% typeset the return type
7853 \ifrettypeownline
7854 % put return type on its own line; prohibit line break following:
7855 \hfil\vadjust{\nobreak}\break
7856 \else
7857 \space % type on same line, so just followed by a space
7858 \fi
7859 \fi % no return type
7860 #3% output function name
7861 }%
7862 {\rm\enskip}% hskip 0.5 em of \tenrm
7863 %
7864 \boldbrax
7865 % arguments will be output next, if any.
7866 }
7867
7868 % Print arguments in slanted roman (not ttsl), inconsistently with using
7869 % tt for the name. This is because literal text is sometimes needed in
7870 % the argument list (groff manual), and ttsl and tt are not very
7871 % distinguishable. Prevent hyphenation at `-' chars.
7872 %
7873 \def\defunargs#1{%
7874 % use sl by default (not ttsl),
7875 % tt for the names.
7876 \df \sl \hyphenchar\font=0
7877 %
7878 % On the other hand, if an argument has two dashes (for instance), we
7879 % want a way to get ttsl. We used to recommend @var for that, so
7880 % leave the code in, but it's strange for @var to lead to typewriter.
7881 % Nowadays we recommend @code, since the difference between a ttsl hyphen
7882 % and a tt hyphen is pretty tiny. @code also disables ?` !`.
7883 \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
7884 #1%
7885 \sl\hyphenchar\font=45
7886 }
7887
7888 % We want ()&[] to print specially on the defun line.
7889 %
7890 \def\activeparens{%
7891 \catcode`\(=\active \catcode`\)=\active
7892 \catcode`\[=\active \catcode`\]=\active
7893 \catcode`\&=\active
7894 }
7895
7896 % Make control sequences which act like normal parenthesis chars.
7897 \let\lparen = ( \let\rparen = )
7898
7899 % Be sure that we always have a definition for `(', etc. For example,
7900 % if the fn name has parens in it, \boldbrax will not be in effect yet,
7901 % so TeX would otherwise complain about undefined control sequence.
7902 {
7903 \activeparens
7904 \global\let(=\lparen \global\let)=\rparen
7905 \global\let[=\lbrack \global\let]=\rbrack
7906 \global\let& = \&
7907
7908 \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
7909 \gdef\magicamp{\let&=\amprm}
7910 }
7911
7912 \newcount\parencount
7913
7914 % If we encounter &foo, then turn on ()-hacking afterwards
7915 \newif\ifampseen
7916 \def\amprm#1 {\ampseentrue{\bf\&#1 }}
7917
7918 \def\parenfont{%
7919 \ifampseen
7920 % At the first level, print parens in roman,
7921 % otherwise use the default font.
7922 \ifnum \parencount=1 \rm \fi
7923 \else
7924 % The \sf parens (in \boldbrax) actually are a little bolder than
7925 % the contained text. This is especially needed for [ and ] .
7926 \sf
7927 \fi
7928 }
7929 \def\infirstlevel#1{%
7930 \ifampseen
7931 \ifnum\parencount=1
7932 #1%
7933 \fi
7934 \fi
7935 }
7936 \def\bfafterword#1 {#1 \bf}
7937
7938 \def\opnr{%
7939 \global\advance\parencount by 1
7940 {\parenfont(}%
7941 \infirstlevel \bfafterword
7942 }
7943 \def\clnr{%
7944 {\parenfont)}%
7945 \infirstlevel \sl
7946 \global\advance\parencount by -1
7947 }
7948
7949 \newcount\brackcount
7950 \def\lbrb{%
7951 \global\advance\brackcount by 1
7952 {\bf[}%
7953 }
7954 \def\rbrb{%
7955 {\bf]}%
7956 \global\advance\brackcount by -1
7957 }
7958
7959 \def\checkparencounts{%
7960 \ifnum\parencount=0 \else \badparencount \fi
7961 \ifnum\brackcount=0 \else \badbrackcount \fi
7962 }
7963 % these should not use \errmessage; the glibc manual, at least, actually
7964 % has such constructs (when documenting function pointers).
7965 \def\badparencount{%
7966 \message{Warning: unbalanced parentheses in @def...}%
7967 \global\parencount=0
7968 }
7969 \def\badbrackcount{%
7970 \message{Warning: unbalanced square brackets in @def...}%
7971 \global\brackcount=0
7972 }
7973
7974
7975 \message{macros,}
7976 % @macro.
7977
7978 % To do this right we need a feature of e-TeX, \scantokens,
7979 % which we arrange to emulate with a temporary file in ordinary TeX.
7980 \ifx\eTeXversion\thisisundefined
7981 \newwrite\macscribble
7982 \def\scantokens#1{%
7983 \toks0={#1}%
7984 \immediate\openout\macscribble=\jobname.tmp
7985 \immediate\write\macscribble{\the\toks0}%
7986 \immediate\closeout\macscribble
7987 \input \jobname.tmp
7988 }
7989 \fi
7990
7991 \let\aftermacroxxx\relax
7992 \def\aftermacro{\aftermacroxxx}
7993
7994 % alias because \c means cedilla in @tex or @math
7995 \let\texinfoc=\c
7996
7997 \newcount\savedcatcodeone
7998 \newcount\savedcatcodetwo
7999
8000 % Used at the time of macro expansion.
8001 % Argument is macro body with arguments substituted
8002 \def\scanmacro#1{%
8003 \newlinechar`\^^M
8004 \def\xeatspaces{\eatspaces}%
8005 %
8006 % Temporarily undo catcode changes of \printindex. Set catcode of @ to
8007 % 0 so that @-commands in macro expansions aren't printed literally when
8008 % formatting an index file, where \ is used as the escape character.
8009 \savedcatcodeone=\catcode`\@
8010 \savedcatcodetwo=\catcode`\\
8011 \catcode`\@=0
8012 \catcode`\\=\active
8013 %
8014 % Process the macro body under the current catcode regime.
8015 \scantokens{#1@texinfoc}\aftermacro%
8016 %
8017 \catcode`\@=\savedcatcodeone
8018 \catcode`\\=\savedcatcodetwo
8019 %
8020 % The \texinfoc is to remove the \newlinechar added by \scantokens, and
8021 % can be noticed by \parsearg.
8022 % The \aftermacro allows a \comment at the end of the macro definition
8023 % to duplicate itself past the final \newlinechar added by \scantokens:
8024 % this is used in the definition of \group to comment out a newline. We
8025 % don't do the same for \c to support Texinfo files with macros that ended
8026 % with a @c, which should no longer be necessary.
8027 % We avoid surrounding the call to \scantokens with \bgroup and \egroup
8028 % to allow macros to open or close groups themselves.
8029 }
8030
8031 % Used for copying and captions
8032 \def\scanexp#1{%
8033 \expandafter\scanmacro\expandafter{#1}%
8034 }
8035
8036 \newcount\paramno % Count of parameters
8037 \newtoks\macname % Macro name
8038 \newif\ifrecursive % Is it recursive?
8039
8040 % List of all defined macros in the form
8041 % \definedummyword\macro1\definedummyword\macro2...
8042 % Currently is also contains all @aliases; the list can be split
8043 % if there is a need.
8044 \def\macrolist{}
8045
8046 % Add the macro to \macrolist
8047 \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
8048 \def\addtomacrolistxxx#1{%
8049 \toks0 = \expandafter{\macrolist\definedummyword#1}%
8050 \xdef\macrolist{\the\toks0}%
8051 }
8052
8053 % Utility routines.
8054 % This does \let #1 = #2, with \csnames; that is,
8055 % \let \csname#1\endcsname = \csname#2\endcsname
8056 % (except of course we have to play expansion games).
8057 %
8058 \def\cslet#1#2{%
8059 \expandafter\let
8060 \csname#1\expandafter\endcsname
8061 \csname#2\endcsname
8062 }
8063
8064 % Trim leading and trailing spaces off a string.
8065 % Concepts from aro-bend problem 15 (see CTAN).
8066 {\catcode`\@=11
8067 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
8068 \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
8069 \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
8070 \def\unbrace#1{#1}
8071 \unbrace{\gdef\trim@@@ #1 } #2@{#1}
8072 }
8073
8074 % Trim a single trailing ^^M off a string.
8075 {\catcode`\^^M=\other \catcode`\Q=3%
8076 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
8077 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
8078 \gdef\eatcrb#1Q#2Q{#1}%
8079 }
8080
8081 % Macro bodies are absorbed as an argument in a context where
8082 % all characters are catcode 10, 11 or 12, except \ which is active
8083 % (as in normal texinfo). It is necessary to change the definition of \
8084 % to recognize macro arguments; this is the job of \mbodybackslash.
8085 %
8086 % Non-ASCII encodings make 8-bit characters active, so un-activate
8087 % them to avoid their expansion. Must do this non-globally, to
8088 % confine the change to the current group.
8089 %
8090 % It's necessary to have hard CRs when the macro is executed. This is
8091 % done by making ^^M (\endlinechar) catcode 12 when reading the macro
8092 % body, and then making it the \newlinechar in \scanmacro.
8093 %
8094 \def\scanctxt{% used as subroutine
8095 \catcode`\"=\other
8096 \catcode`\+=\other
8097 \catcode`\<=\other
8098 \catcode`\>=\other
8099 \catcode`\^=\other
8100 \catcode`\_=\other
8101 \catcode`\|=\other
8102 \catcode`\~=\other
8103 \passthroughcharstrue
8104 }
8105
8106 \def\scanargctxt{% used for copying and captions, not macros.
8107 \scanctxt
8108 \catcode`\@=\other
8109 \catcode`\\=\other
8110 \catcode`\^^M=\other
8111 }
8112
8113 \def\macrobodyctxt{% used for @macro definitions
8114 \scanctxt
8115 \catcode`\ =\other
8116 \catcode`\@=\other
8117 \catcode`\{=\other
8118 \catcode`\}=\other
8119 \catcode`\^^M=\other
8120 \usembodybackslash
8121 }
8122
8123 % Used when scanning braced macro arguments. Note, however, that catcode
8124 % changes here are ineffectual if the macro invocation was nested inside
8125 % an argument to another Texinfo command.
8126 \def\macroargctxt{%
8127 \scanctxt
8128 \catcode`\ =\active
8129 \catcode`\^^M=\other
8130 \catcode`\\=\active
8131 }
8132
8133 \def\macrolineargctxt{% used for whole-line arguments without braces
8134 \scanctxt
8135 \catcode`\{=\other
8136 \catcode`\}=\other
8137 }
8138
8139 % \mbodybackslash is the definition of \ in @macro bodies.
8140 % It maps \foo\ => \csname macarg.foo\endcsname => #N
8141 % where N is the macro parameter number.
8142 % We define \csname macarg.\endcsname to be \realbackslash, so
8143 % \\ in macro replacement text gets you a backslash.
8144 %
8145 {\catcode`@=0 @catcode`@\=@active
8146 @gdef@usembodybackslash{@let\=@mbodybackslash}
8147 @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
8148 }
8149 \expandafter\def\csname macarg.\endcsname{\realbackslash}
8150
8151 \def\margbackslash#1{\char`\#1 }
8152
8153 \def\macro{\recursivefalse\parsearg\macroxxx}
8154 \def\rmacro{\recursivetrue\parsearg\macroxxx}
8155
8156 \def\macroxxx#1{%
8157 \getargs{#1}% now \macname is the macname and \argl the arglist
8158 \ifx\argl\empty % no arguments
8159 \paramno=0\relax
8160 \else
8161 \expandafter\parsemargdef \argl;%
8162 \if\paramno>256\relax
8163 \ifx\eTeXversion\thisisundefined
8164 \errhelp = \EMsimple
8165 \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
8166 \fi
8167 \fi
8168 \fi
8169 \if1\csname ismacro.\the\macname\endcsname
8170 \message{Warning: redefining \the\macname}%
8171 \else
8172 \expandafter\ifx\csname \the\macname\endcsname \relax
8173 \else \errmessage{Macro name \the\macname\space already defined}\fi
8174 \global\cslet{macsave.\the\macname}{\the\macname}%
8175 \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
8176 \addtomacrolist{\the\macname}%
8177 \fi
8178 \begingroup \macrobodyctxt
8179 \ifrecursive \expandafter\parsermacbody
8180 \else \expandafter\parsemacbody
8181 \fi}
8182
8183 \parseargdef\unmacro{%
8184 \if1\csname ismacro.#1\endcsname
8185 \global\cslet{#1}{macsave.#1}%
8186 \global\expandafter\let \csname ismacro.#1\endcsname=0%
8187 % Remove the macro name from \macrolist:
8188 \begingroup
8189 \expandafter\let\csname#1\endcsname \relax
8190 \let\definedummyword\unmacrodo
8191 \xdef\macrolist{\macrolist}%
8192 \endgroup
8193 \else
8194 \errmessage{Macro #1 not defined}%
8195 \fi
8196 }
8197
8198 % Called by \do from \dounmacro on each macro. The idea is to omit any
8199 % macro definitions that have been changed to \relax.
8200 %
8201 \def\unmacrodo#1{%
8202 \ifx #1\relax
8203 % remove this
8204 \else
8205 \noexpand\definedummyword \noexpand#1%
8206 \fi
8207 }
8208
8209 % \getargs -- Parse the arguments to a @macro line. Set \macname to
8210 % the name of the macro, and \argl to the braced argument list.
8211 \def\getargs#1{\getargsxxx#1{}}
8212 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
8213 \def\getmacname#1 #2\relax{\macname={#1}}
8214 \def\getmacargs#1{\def\argl{#1}}
8215 % This made use of the feature that if the last token of a
8216 % <parameter list> is #, then the preceding argument is delimited by
8217 % an opening brace, and that opening brace is not consumed.
8218
8219 % Parse the optional {params} list to @macro or @rmacro.
8220 % Set \paramno to the number of arguments,
8221 % and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
8222 % three-param macro.) Define \macarg.BLAH for each BLAH in the params
8223 % list to some hook where the argument is to be expanded. If there are
8224 % less than 10 arguments that hook is to be replaced by ##N where N
8225 % is the position in that list, that is to say the macro arguments are to be
8226 % defined `a la TeX in the macro body.
8227 %
8228 % That gets used by \mbodybackslash (above).
8229 %
8230 % If there are 10 or more arguments, a different technique is used: see
8231 % \parsemmanyargdef.
8232 %
8233 \def\parsemargdef#1;{%
8234 \paramno=0\def\paramlist{}%
8235 \let\hash\relax
8236 % \hash is redefined to `#' later to get it into definitions
8237 \let\xeatspaces\relax
8238 \parsemargdefxxx#1,;,%
8239 \ifnum\paramno<10\relax\else
8240 \paramno0\relax
8241 \parsemmanyargdef@@#1,;,% 10 or more arguments
8242 \fi
8243 }
8244 \def\parsemargdefxxx#1,{%
8245 \if#1;\let\next=\relax
8246 \else \let\next=\parsemargdefxxx
8247 \advance\paramno by 1
8248 \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
8249 {\xeatspaces{\hash\the\paramno}}%
8250 \edef\paramlist{\paramlist\hash\the\paramno,}%
8251 \fi\next}
8252
8253 % \parsemacbody, \parsermacbody
8254 %
8255 % Read recursive and nonrecursive macro bodies. (They're different since
8256 % rec and nonrec macros end differently.)
8257 %
8258 % We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro
8259 % body to be transformed.
8260 % Set \macrobody to the body of the macro, and call \defmacro.
8261 %
8262 {\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{%
8263 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8264 {\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
8265 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8266
8267 % Make @ a letter, so that we can make private-to-Texinfo macro names.
8268 \edef\texiatcatcode{\the\catcode`\@}
8269 \catcode `@=11\relax
8270
8271 %%%%%%%%%%%%%% Code for > 10 arguments only %%%%%%%%%%%%%%%%%%
8272
8273 % If there are 10 or more arguments, a different technique is used, where the
8274 % hook remains in the body, and when macro is to be expanded the body is
8275 % processed again to replace the arguments.
8276 %
8277 % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
8278 % argument N value and then \edef the body (nothing else will expand because of
8279 % the catcode regime under which the body was input).
8280 %
8281 % If you compile with TeX (not eTeX), and you have macros with 10 or more
8282 % arguments, no macro can have more than 256 arguments (else error).
8283 %
8284 % In case that there are 10 or more arguments we parse again the arguments
8285 % list to set new definitions for the \macarg.BLAH macros corresponding to
8286 % each BLAH argument. It was anyhow needed to parse already once this list
8287 % in order to count the arguments, and as macros with at most 9 arguments
8288 % are by far more frequent than macro with 10 or more arguments, defining
8289 % twice the \macarg.BLAH macros does not cost too much processing power.
8290 \def\parsemmanyargdef@@#1,{%
8291 \if#1;\let\next=\relax
8292 \else
8293 \let\next=\parsemmanyargdef@@
8294 \edef\tempb{\eatspaces{#1}}%
8295 \expandafter\def\expandafter\tempa
8296 \expandafter{\csname macarg.\tempb\endcsname}%
8297 % Note that we need some extra \noexpand\noexpand, this is because we
8298 % don't want \the to be expanded in the \parsermacbody as it uses an
8299 % \xdef .
8300 \expandafter\edef\tempa
8301 {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
8302 \advance\paramno by 1\relax
8303 \fi\next}
8304
8305
8306 \let\endargs@\relax
8307 \let\nil@\relax
8308 \def\nilm@{\nil@}%
8309 \long\def\nillm@{\nil@}%
8310
8311 % This macro is expanded during the Texinfo macro expansion, not during its
8312 % definition. It gets all the arguments' values and assigns them to macros
8313 % macarg.ARGNAME
8314 %
8315 % #1 is the macro name
8316 % #2 is the list of argument names
8317 % #3 is the list of argument values
8318 \def\getargvals@#1#2#3{%
8319 \def\macargdeflist@{}%
8320 \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
8321 \def\paramlist{#2,\nil@}%
8322 \def\macroname{#1}%
8323 \begingroup
8324 \macroargctxt
8325 \def\argvaluelist{#3,\nil@}%
8326 \def\@tempa{#3}%
8327 \ifx\@tempa\empty
8328 \setemptyargvalues@
8329 \else
8330 \getargvals@@
8331 \fi
8332 }
8333 \def\getargvals@@{%
8334 \ifx\paramlist\nilm@
8335 % Some sanity check needed here that \argvaluelist is also empty.
8336 \ifx\argvaluelist\nillm@
8337 \else
8338 \errhelp = \EMsimple
8339 \errmessage{Too many arguments in macro `\macroname'!}%
8340 \fi
8341 \let\next\macargexpandinbody@
8342 \else
8343 \ifx\argvaluelist\nillm@
8344 % No more arguments values passed to macro. Set remaining named-arg
8345 % macros to empty.
8346 \let\next\setemptyargvalues@
8347 \else
8348 % pop current arg name into \@tempb
8349 \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
8350 \expandafter\@tempa\expandafter{\paramlist}%
8351 % pop current argument value into \@tempc
8352 \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
8353 \expandafter\@tempa\expandafter{\argvaluelist}%
8354 % Here \@tempb is the current arg name and \@tempc is the current arg value.
8355 % First place the new argument macro definition into \@tempd
8356 \expandafter\macname\expandafter{\@tempc}%
8357 \expandafter\let\csname macarg.\@tempb\endcsname\relax
8358 \expandafter\def\expandafter\@tempe\expandafter{%
8359 \csname macarg.\@tempb\endcsname}%
8360 \edef\@tempd{\long\def\@tempe{\the\macname}}%
8361 \push@\@tempd\macargdeflist@
8362 \let\next\getargvals@@
8363 \fi
8364 \fi
8365 \next
8366 }
8367
8368 \def\push@#1#2{%
8369 \expandafter\expandafter\expandafter\def
8370 \expandafter\expandafter\expandafter#2%
8371 \expandafter\expandafter\expandafter{%
8372 \expandafter#1#2}%
8373 }
8374
8375 % Replace arguments by their values in the macro body, and place the result
8376 % in macro \@tempa.
8377 %
8378 \def\macvalstoargs@{%
8379 % To do this we use the property that token registers that are \the'ed
8380 % within an \edef expand only once. So we are going to place all argument
8381 % values into respective token registers.
8382 %
8383 % First we save the token context, and initialize argument numbering.
8384 \begingroup
8385 \paramno0\relax
8386 % Then, for each argument number #N, we place the corresponding argument
8387 % value into a new token list register \toks#N
8388 \expandafter\putargsintokens@\saveparamlist@,;,%
8389 % Then, we expand the body so that argument are replaced by their
8390 % values. The trick for values not to be expanded themselves is that they
8391 % are within tokens and that tokens expand only once in an \edef .
8392 \edef\@tempc{\csname mac.\macroname .body\endcsname}%
8393 % Now we restore the token stack pointer to free the token list registers
8394 % which we have used, but we make sure that expanded body is saved after
8395 % group.
8396 \expandafter
8397 \endgroup
8398 \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
8399 }
8400
8401 % Define the named-macro outside of this group and then close this group.
8402 %
8403 \def\macargexpandinbody@{%
8404 \expandafter
8405 \endgroup
8406 \macargdeflist@
8407 % First the replace in body the macro arguments by their values, the result
8408 % is in \@tempa .
8409 \macvalstoargs@
8410 % Then we point at the \norecurse or \gobble (for recursive) macro value
8411 % with \@tempb .
8412 \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
8413 % Depending on whether it is recursive or not, we need some tailing
8414 % \egroup .
8415 \ifx\@tempb\gobble
8416 \let\@tempc\relax
8417 \else
8418 \let\@tempc\egroup
8419 \fi
8420 % And now we do the real job:
8421 \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
8422 \@tempd
8423 }
8424
8425 \def\putargsintokens@#1,{%
8426 \if#1;\let\next\relax
8427 \else
8428 \let\next\putargsintokens@
8429 % First we allocate the new token list register, and give it a temporary
8430 % alias \@tempb .
8431 \toksdef\@tempb\the\paramno
8432 % Then we place the argument value into that token list register.
8433 \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
8434 \expandafter\@tempb\expandafter{\@tempa}%
8435 \advance\paramno by 1\relax
8436 \fi
8437 \next
8438 }
8439
8440 % Trailing missing arguments are set to empty.
8441 %
8442 \def\setemptyargvalues@{%
8443 \ifx\paramlist\nilm@
8444 \let\next\macargexpandinbody@
8445 \else
8446 \expandafter\setemptyargvaluesparser@\paramlist\endargs@
8447 \let\next\setemptyargvalues@
8448 \fi
8449 \next
8450 }
8451
8452 \def\setemptyargvaluesparser@#1,#2\endargs@{%
8453 \expandafter\def\expandafter\@tempa\expandafter{%
8454 \expandafter\def\csname macarg.#1\endcsname{}}%
8455 \push@\@tempa\macargdeflist@
8456 \def\paramlist{#2}%
8457 }
8458
8459 % #1 is the element target macro
8460 % #2 is the list macro
8461 % #3,#4\endargs@ is the list value
8462 \def\pop@#1#2#3,#4\endargs@{%
8463 \def#1{#3}%
8464 \def#2{#4}%
8465 }
8466 \long\def\longpop@#1#2#3,#4\endargs@{%
8467 \long\def#1{#3}%
8468 \long\def#2{#4}%
8469 }
8470
8471
8472 %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
8473
8474
8475 % This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
8476 % \macrobody has the body of the macro in it, with placeholders for
8477 % its parameters, looking like "\xeatspaces{\hash 1}".
8478 % \paramno is the number of parameters
8479 % \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
8480 % There are eight cases: recursive and nonrecursive macros of zero, one,
8481 % up to nine, and many arguments.
8482 % \xdef is used so that macro definitions will survive the file
8483 % they're defined in: @include reads the file inside a group.
8484 %
8485 \def\defmacro{%
8486 \let\hash=##% convert placeholders to macro parameter chars
8487 \ifnum\paramno=1
8488 \def\xeatspaces##1{##1}%
8489 % This removes the pair of braces around the argument. We don't
8490 % use \eatspaces, because this can cause ends of lines to be lost
8491 % when the argument to \eatspaces is read, leading to line-based
8492 % commands like "@itemize" not being read correctly.
8493 \else
8494 \let\xeatspaces\relax % suppress expansion
8495 \fi
8496 \ifrecursive %%%%%%%%%%%%%% Recursive %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8497 \ifcase\paramno
8498 % 0
8499 \expandafter\xdef\csname\the\macname\endcsname{%
8500 \noexpand\scanmacro{\macrobody}}%
8501 \or % 1
8502 \expandafter\xdef\csname\the\macname\endcsname{%
8503 \bgroup
8504 \noexpand\braceorline
8505 \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8506 \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8507 \egroup
8508 \noexpand\scanmacro{\macrobody}%
8509 }%
8510 \else
8511 \ifnum\paramno<10\relax % at most 9
8512 % See non-recursive section below for comments
8513 \expandafter\xdef\csname\the\macname\endcsname{%
8514 \bgroup
8515 \noexpand\expandafter
8516 \noexpand\macroargctxt
8517 \noexpand\expandafter
8518 \expandafter\noexpand\csname\the\macname @@\endcsname}%
8519 \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8520 \noexpand\passargtomacro
8521 \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8522 \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8523 \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8524 \expandafter\expandafter
8525 \expandafter\xdef
8526 \expandafter\expandafter
8527 \csname\the\macname @@@@\endcsname\paramlist{%
8528 \egroup\noexpand\scanmacro{\macrobody}}%
8529 \else % 10 or more
8530 \expandafter\xdef\csname\the\macname\endcsname{%
8531 \noexpand\getargvals@{\the\macname}{\argl}%
8532 }%
8533 \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8534 \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
8535 \fi
8536 \fi
8537 \else %%%%%%%%%%%%%%%%%%%%%% Non-recursive %%%%%%%%%%%%%%%%%%%%%%%%%%
8538 \ifcase\paramno
8539 % 0
8540 \expandafter\xdef\csname\the\macname\endcsname{%
8541 \noexpand\scanmacro{\macrobody}}%
8542 \or % 1
8543 \expandafter\xdef\csname\the\macname\endcsname{%
8544 \bgroup
8545 \noexpand\braceorline
8546 \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8547 \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8548 \egroup
8549 \noexpand\scanmacro{\macrobody}%
8550 }%
8551 \else % at most 9
8552 \ifnum\paramno<10\relax
8553 % @MACNAME sets the context for reading the macro argument
8554 % @MACNAME@@ gets the argument, processes backslashes and appends a
8555 % comma.
8556 % @MACNAME@@@ removes braces surrounding the argument list.
8557 % @MACNAME@@@@ scans the macro body with arguments substituted.
8558 \expandafter\xdef\csname\the\macname\endcsname{%
8559 \bgroup
8560 \noexpand\expandafter % This \expandafter skip any spaces after the
8561 \noexpand\macroargctxt % macro before we change the catcode of space.
8562 \noexpand\expandafter
8563 \expandafter\noexpand\csname\the\macname @@\endcsname}%
8564 \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8565 \noexpand\passargtomacro
8566 \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8567 \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8568 \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8569 \expandafter\expandafter
8570 \expandafter\xdef
8571 \expandafter\expandafter
8572 \csname\the\macname @@@@\endcsname\paramlist{%
8573 \egroup\noexpand\scanmacro{\macrobody}}%
8574 \else % 10 or more:
8575 \expandafter\xdef\csname\the\macname\endcsname{%
8576 \noexpand\getargvals@{\the\macname}{\argl}%
8577 }%
8578 \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8579 \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse
8580 \fi
8581 \fi
8582 \fi}
8583
8584 \catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
8585
8586 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
8587
8588
8589 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8590 %
8591 {\catcode`\@=0 \catcode`\\=13 % We need to manipulate \ so use @ as escape
8592 @catcode`@_=11 % private names
8593 @catcode`@!=11 % used as argument separator
8594
8595 % \passargtomacro#1#2 -
8596 % Call #1 with a list of tokens #2, with any doubled backslashes in #2
8597 % compressed to one.
8598 %
8599 % This implementation works by expansion, and not execution (so we cannot use
8600 % \def or similar). This reduces the risk of this failing in contexts where
8601 % complete expansion is done with no execution (for example, in writing out to
8602 % an auxiliary file for an index entry).
8603 %
8604 % State is kept in the input stream: the argument passed to
8605 % @look_ahead, @gobble_and_check_finish and @add_segment is
8606 %
8607 % THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN (... rest of input)
8608 %
8609 % where:
8610 % THE_MACRO - name of the macro we want to call
8611 % ARG_RESULT - argument list we build to pass to that macro
8612 % PENDING_BS - either a backslash or nothing
8613 % NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
8614
8615 @gdef@passargtomacro#1#2{%
8616 @add_segment #1!{}@relax#2\@_finish\%
8617 }
8618 @gdef@_finish{@_finishx} @global@let@_finishx@relax
8619
8620 % #1 - THE_MACRO ARG_RESULT
8621 % #2 - PENDING_BS
8622 % #3 - NEXT_TOKEN
8623 % #4 used to look ahead
8624 %
8625 % If the next token is not a backslash, process the rest of the argument;
8626 % otherwise, remove the next token.
8627 @gdef@look_ahead#1!#2#3#4{%
8628 @ifx#4\%
8629 @expandafter@gobble_and_check_finish
8630 @else
8631 @expandafter@add_segment
8632 @fi#1!{#2}#4#4%
8633 }
8634
8635 % #1 - THE_MACRO ARG_RESULT
8636 % #2 - PENDING_BS
8637 % #3 - NEXT_TOKEN
8638 % #4 should be a backslash, which is gobbled.
8639 % #5 looks ahead
8640 %
8641 % Double backslash found. Add a single backslash, and look ahead.
8642 @gdef@gobble_and_check_finish#1!#2#3#4#5{%
8643 @add_segment#1\!{}#5#5%
8644 }
8645
8646 @gdef@is_fi{@fi}
8647
8648 % #1 - THE_MACRO ARG_RESULT
8649 % #2 - PENDING_BS
8650 % #3 - NEXT_TOKEN
8651 % #4 is input stream until next backslash
8652 %
8653 % Input stream is either at the start of the argument, or just after a
8654 % backslash sequence, either a lone backslash, or a doubled backslash.
8655 % NEXT_TOKEN contains the first token in the input stream: if it is \finish,
8656 % finish; otherwise, append to ARG_RESULT the segment of the argument up until
8657 % the next backslash. PENDING_BACKSLASH contains a backslash to represent
8658 % a backslash just before the start of the input stream that has not been
8659 % added to ARG_RESULT.
8660 @gdef@add_segment#1!#2#3#4\{%
8661 @ifx#3@_finish
8662 @call_the_macro#1!%
8663 @else
8664 % append the pending backslash to the result, followed by the next segment
8665 @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
8666 % this @fi is discarded by @look_ahead.
8667 % we can't get rid of it with \expandafter because we don't know how
8668 % long #4 is.
8669 }
8670
8671 % #1 - THE_MACRO
8672 % #2 - ARG_RESULT
8673 % #3 discards the res of the conditional in @add_segment, and @is_fi ends the
8674 % conditional.
8675 @gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
8676
8677 }
8678 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8679
8680 % \braceorline MAC is used for a one-argument macro MAC. It checks
8681 % whether the next non-whitespace character is a {. It sets the context
8682 % for reading the argument (slightly different in the two cases). Then,
8683 % to read the argument, in the whole-line case, it then calls the regular
8684 % \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
8685 %
8686 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
8687 \def\braceorlinexxx{%
8688 \ifx\nchar\bgroup
8689 \macroargctxt
8690 \expandafter\passargtomacro
8691 \else
8692 \macrolineargctxt\expandafter\parsearg
8693 \fi \macnamexxx}
8694
8695
8696 % @alias.
8697 % We need some trickery to remove the optional spaces around the equal
8698 % sign. Make them active and then expand them all to nothing.
8699 %
8700 \def\alias{\parseargusing\obeyspaces\aliasxxx}
8701 \def\aliasxxx #1{\aliasyyy#1\relax}
8702 \def\aliasyyy #1=#2\relax{%
8703 {%
8704 \expandafter\let\obeyedspace=\empty
8705 \addtomacrolist{#1}%
8706 \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
8707 }%
8708 \next
8709 }
8710
8711
8712 \message{cross references,}
8713
8714 \newwrite\auxfile
8715 \newif\ifhavexrefs % True if xref values are known.
8716 \newif\ifwarnedxrefs % True if we warned once that they aren't known.
8717
8718 % @inforef is relatively simple.
8719 \def\inforef #1{\inforefzzz #1,,,,**}
8720 \def\inforefzzz #1,#2,#3,#4**{%
8721 \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
8722 node \samp{\ignorespaces#1{}}}
8723
8724 % @node's only job in TeX is to define \lastnode, which is used in
8725 % cross-references. The @node line might or might not have commas, and
8726 % might or might not have spaces before the first comma, like:
8727 % @node foo , bar , ...
8728 % We don't want such trailing spaces in the node name.
8729 %
8730 \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
8731 %
8732 % also remove a trailing comma, in case of something like this:
8733 % @node Help-Cross, , , Cross-refs
8734 \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
8735 \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
8736
8737 \let\nwnode=\node
8738 \let\lastnode=\empty
8739
8740 % Write a cross-reference definition for the current node. #1 is the
8741 % type (Ynumbered, Yappendix, Ynothing).
8742 %
8743 \def\donoderef#1{%
8744 \ifx\lastnode\empty\else
8745 \setref{\lastnode}{#1}%
8746 \global\let\lastnode=\empty
8747 \fi
8748 }
8749
8750 % @anchor{NAME} -- define xref target at arbitrary point.
8751 %
8752 \newcount\savesfregister
8753 %
8754 \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
8755 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
8756 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
8757
8758 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
8759 % anchor), which consists of three parts:
8760 % 1) NAME-title - the current sectioning name taken from \lastsection,
8761 % or the anchor name.
8762 % 2) NAME-snt - section number and type, passed as the SNT arg, or
8763 % empty for anchors.
8764 % 3) NAME-pg - the page number.
8765 %
8766 % This is called from \donoderef, \anchor, and \dofloat. In the case of
8767 % floats, there is an additional part, which is not written here:
8768 % 4) NAME-lof - the text as it should appear in a @listoffloats.
8769 %
8770 \def\setref#1#2{%
8771 \pdfmkdest{#1}%
8772 \iflinks
8773 {%
8774 \requireauxfile
8775 \atdummies % preserve commands, but don't expand them
8776 % match definition in \xrdef, \refx, \xrefX.
8777 \def\value##1{##1}%
8778 \edef\writexrdef##1##2{%
8779 \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
8780 ##1}{##2}}% these are parameters of \writexrdef
8781 }%
8782 \toks0 = \expandafter{\lastsection}%
8783 \immediate \writexrdef{title}{\the\toks0 }%
8784 \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
8785 \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
8786 }%
8787 \fi
8788 }
8789
8790 % @xrefautosectiontitle on|off says whether @section(ing) names are used
8791 % automatically in xrefs, if the third arg is not explicitly specified.
8792 % This was provided as a "secret" @set xref-automatic-section-title
8793 % variable, now it's official.
8794 %
8795 \parseargdef\xrefautomaticsectiontitle{%
8796 \def\temp{#1}%
8797 \ifx\temp\onword
8798 \expandafter\let\csname SETxref-automatic-section-title\endcsname
8799 = \empty
8800 \else\ifx\temp\offword
8801 \expandafter\let\csname SETxref-automatic-section-title\endcsname
8802 = \relax
8803 \else
8804 \errhelp = \EMsimple
8805 \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
8806 must be on|off}%
8807 \fi\fi
8808 }
8809
8810 % \f
8811 % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
8812 % the node name, #2 the name of the Info cross-reference, #3 the printed
8813 % node name, #4 the name of the Info file, #5 the name of the printed
8814 % manual. All but the node name can be omitted.
8815 %
8816 \def\pxref{\putwordsee{} \xrefXX}
8817 \def\xref{\putwordSee{} \xrefXX}
8818 \def\ref{\xrefXX}
8819
8820 \def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
8821 \def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
8822 %
8823 \newbox\toprefbox
8824 \newbox\printedrefnamebox
8825 \newbox\infofilenamebox
8826 \newbox\printedmanualbox
8827 %
8828 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
8829 \unsepspaces
8830 %
8831 % Get args without leading/trailing spaces.
8832 \def\printedrefname{\ignorespaces #3}%
8833 \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
8834 %
8835 \def\infofilename{\ignorespaces #4}%
8836 \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
8837 %
8838 \def\printedmanual{\ignorespaces #5}%
8839 \setbox\printedmanualbox = \hbox{\printedmanual\unskip}%
8840 %
8841 % If the printed reference name (arg #3) was not explicitly given in
8842 % the @xref, figure out what we want to use.
8843 \ifdim \wd\printedrefnamebox = 0pt
8844 % No printed node name was explicitly given.
8845 \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
8846 % Not auto section-title: use node name inside the square brackets.
8847 \def\printedrefname{\ignorespaces #1}%
8848 \else
8849 % Auto section-title: use chapter/section title inside
8850 % the square brackets if we have it.
8851 \ifdim \wd\printedmanualbox > 0pt
8852 % It is in another manual, so we don't have it; use node name.
8853 \def\printedrefname{\ignorespaces #1}%
8854 \else
8855 \ifhavexrefs
8856 % We (should) know the real title if we have the xref values.
8857 \def\printedrefname{\refx{#1-title}{}}%
8858 \else
8859 % Otherwise just copy the Info node name.
8860 \def\printedrefname{\ignorespaces #1}%
8861 \fi%
8862 \fi
8863 \fi
8864 \fi
8865 %
8866 % Make link in pdf output.
8867 \ifpdf
8868 % For pdfTeX and LuaTeX
8869 {\indexnofonts
8870 \turnoffactive
8871 \makevalueexpandable
8872 % This expands tokens, so do it after making catcode changes, so _
8873 % etc. don't get their TeX definitions. This ignores all spaces in
8874 % #4, including (wrongly) those in the middle of the filename.
8875 \getfilename{#4}%
8876 %
8877 % This (wrongly) does not take account of leading or trailing
8878 % spaces in #1, which should be ignored.
8879 \edef\pdfxrefdest{#1}%
8880 \ifx\pdfxrefdest\empty
8881 \def\pdfxrefdest{Top}% no empty targets
8882 \else
8883 \txiescapepdf\pdfxrefdest % escape PDF special chars
8884 \fi
8885 %
8886 \leavevmode
8887 \startlink attr{/Border [0 0 0]}%
8888 \ifnum\filenamelength>0
8889 goto file{\the\filename.pdf} name{\pdfxrefdest}%
8890 \else
8891 goto name{\pdfmkpgn{\pdfxrefdest}}%
8892 \fi
8893 }%
8894 \setcolor{\linkcolor}%
8895 \else
8896 \ifx\XeTeXrevision\thisisundefined
8897 \else
8898 % For XeTeX
8899 {\indexnofonts
8900 \turnoffactive
8901 \makevalueexpandable
8902 % This expands tokens, so do it after making catcode changes, so _
8903 % etc. don't get their TeX definitions. This ignores all spaces in
8904 % #4, including (wrongly) those in the middle of the filename.
8905 \getfilename{#4}%
8906 %
8907 % This (wrongly) does not take account of leading or trailing
8908 % spaces in #1, which should be ignored.
8909 \iftxiuseunicodedestname
8910 \def\pdfxrefdest{#1}% Pass through Unicode characters.
8911 \else
8912 \edef\pdfxrefdest{#1}% Replace Unicode characters to ASCII.
8913 \fi
8914 \ifx\pdfxrefdest\empty
8915 \def\pdfxrefdest{Top}% no empty targets
8916 \else
8917 \txiescapepdf\pdfxrefdest % escape PDF special chars
8918 \fi
8919 %
8920 \leavevmode
8921 \ifnum\filenamelength>0
8922 % By the default settings,
8923 % XeTeX (xdvipdfmx) replaces link destination names with integers.
8924 % In this case, the replaced destination names of
8925 % remote PDF cannot be known. In order to avoid replacement,
8926 % you can use commandline option `-C 0x0010' for xdvipdfmx.
8927 \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8928 << /S /GoToR /F (\the\filename.pdf) /D (name\pdfxrefdest) >> >>}%
8929 \else
8930 \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8931 << /S /GoTo /D (name\pdfxrefdest) >> >>}%
8932 \fi
8933 }%
8934 \setcolor{\linkcolor}%
8935 \fi
8936 \fi
8937 {%
8938 % Have to otherify everything special to allow the \csname to
8939 % include an _ in the xref name, etc.
8940 \indexnofonts
8941 \turnoffactive
8942 \def\value##1{##1}%
8943 \expandafter\global\expandafter\let\expandafter\Xthisreftitle
8944 \csname XR#1-title\endcsname
8945 }%
8946 %
8947 % Float references are printed completely differently: "Figure 1.2"
8948 % instead of "[somenode], p.3". \iffloat distinguishes them by
8949 % \Xthisreftitle being set to a magic string.
8950 \iffloat\Xthisreftitle
8951 % If the user specified the print name (third arg) to the ref,
8952 % print it instead of our usual "Figure 1.2".
8953 \ifdim\wd\printedrefnamebox = 0pt
8954 \refx{#1-snt}{}%
8955 \else
8956 \printedrefname
8957 \fi
8958 %
8959 % If the user also gave the printed manual name (fifth arg), append
8960 % "in MANUALNAME".
8961 \ifdim \wd\printedmanualbox > 0pt
8962 \space \putwordin{} \cite{\printedmanual}%
8963 \fi
8964 \else
8965 % node/anchor (non-float) references.
8966 %
8967 % If we use \unhbox to print the node names, TeX does not insert
8968 % empty discretionaries after hyphens, which means that it will not
8969 % find a line break at a hyphen in a node names. Since some manuals
8970 % are best written with fairly long node names, containing hyphens,
8971 % this is a loss. Therefore, we give the text of the node name
8972 % again, so it is as if TeX is seeing it for the first time.
8973 %
8974 \ifdim \wd\printedmanualbox > 0pt
8975 % Cross-manual reference with a printed manual name.
8976 %
8977 \crossmanualxref{\cite{\printedmanual\unskip}}%
8978 %
8979 \else\ifdim \wd\infofilenamebox > 0pt
8980 % Cross-manual reference with only an info filename (arg 4), no
8981 % printed manual name (arg 5). This is essentially the same as
8982 % the case above; we output the filename, since we have nothing else.
8983 %
8984 \crossmanualxref{\code{\infofilename\unskip}}%
8985 %
8986 \else
8987 % Reference within this manual.
8988 %
8989 % _ (for example) has to be the character _ for the purposes of the
8990 % control sequence corresponding to the node, but it has to expand
8991 % into the usual \leavevmode...\vrule stuff for purposes of
8992 % printing. So we \turnoffactive for the \refx-snt, back on for the
8993 % printing, back off for the \refx-pg.
8994 {\turnoffactive
8995 % Only output a following space if the -snt ref is nonempty; for
8996 % @unnumbered and @anchor, it won't be.
8997 \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
8998 \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
8999 }%
9000 % output the `[mynode]' via the macro below so it can be overridden.
9001 \xrefprintnodename\printedrefname
9002 %
9003 % But we always want a comma and a space:
9004 ,\space
9005 %
9006 % output the `page 3'.
9007 \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
9008 % Add a , if xref followed by a space
9009 \if\space\noexpand\tokenafterxref ,%
9010 \else\ifx\ \tokenafterxref ,% @TAB
9011 \else\ifx\*\tokenafterxref ,% @*
9012 \else\ifx\ \tokenafterxref ,% @SPACE
9013 \else\ifx\
9014 \tokenafterxref ,% @NL
9015 \else\ifx\tie\tokenafterxref ,% @tie
9016 \fi\fi\fi\fi\fi\fi
9017 \fi\fi
9018 \fi
9019 \endlink
9020 \endgroup}
9021
9022 % Output a cross-manual xref to #1. Used just above (twice).
9023 %
9024 % Only include the text "Section ``foo'' in" if the foo is neither
9025 % missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply
9026 % "see The Foo Manual", the idea being to refer to the whole manual.
9027 %
9028 % But, this being TeX, we can't easily compare our node name against the
9029 % string "Top" while ignoring the possible spaces before and after in
9030 % the input. By adding the arbitrary 7sp below, we make it much less
9031 % likely that a real node name would have the same width as "Top" (e.g.,
9032 % in a monospaced font). Hopefully it will never happen in practice.
9033 %
9034 % For the same basic reason, we retypeset the "Top" at every
9035 % reference, since the current font is indeterminate.
9036 %
9037 \def\crossmanualxref#1{%
9038 \setbox\toprefbox = \hbox{Top\kern7sp}%
9039 \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
9040 \ifdim \wd2 > 7sp % nonempty?
9041 \ifdim \wd2 = \wd\toprefbox \else % same as Top?
9042 \putwordSection{} ``\printedrefname'' \putwordin{}\space
9043 \fi
9044 \fi
9045 #1%
9046 }
9047
9048 % This macro is called from \xrefX for the `[nodename]' part of xref
9049 % output. It's a separate macro only so it can be changed more easily,
9050 % since square brackets don't work well in some documents. Particularly
9051 % one that Bob is working on :).
9052 %
9053 \def\xrefprintnodename#1{[#1]}
9054
9055 % Things referred to by \setref.
9056 %
9057 \def\Ynothing{}
9058 \def\Yomitfromtoc{}
9059 \def\Ynumbered{%
9060 \ifnum\secno=0
9061 \putwordChapter@tie \the\chapno
9062 \else \ifnum\subsecno=0
9063 \putwordSection@tie \the\chapno.\the\secno
9064 \else \ifnum\subsubsecno=0
9065 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
9066 \else
9067 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
9068 \fi\fi\fi
9069 }
9070 \def\Yappendix{%
9071 \ifnum\secno=0
9072 \putwordAppendix@tie @char\the\appendixno{}%
9073 \else \ifnum\subsecno=0
9074 \putwordSection@tie @char\the\appendixno.\the\secno
9075 \else \ifnum\subsubsecno=0
9076 \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
9077 \else
9078 \putwordSection@tie
9079 @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
9080 \fi\fi\fi
9081 }
9082
9083 % \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME. SUFFIX
9084 % is output afterwards if non-empty.
9085 \def\refx#1#2{%
9086 \requireauxfile
9087 {%
9088 \indexnofonts
9089 \otherbackslash
9090 \def\value##1{##1}%
9091 \expandafter\global\expandafter\let\expandafter\thisrefX
9092 \csname XR#1\endcsname
9093 }%
9094 \ifx\thisrefX\relax
9095 % If not defined, say something at least.
9096 \angleleft un\-de\-fined\angleright
9097 \iflinks
9098 \ifhavexrefs
9099 {\toks0 = {#1}% avoid expansion of possibly-complex value
9100 \message{\linenumber Undefined cross reference `\the\toks0'.}}%
9101 \else
9102 \ifwarnedxrefs\else
9103 \global\warnedxrefstrue
9104 \message{Cross reference values unknown; you must run TeX again.}%
9105 \fi
9106 \fi
9107 \fi
9108 \else
9109 % It's defined, so just use it.
9110 \thisrefX
9111 \fi
9112 #2% Output the suffix in any case.
9113 }
9114
9115 % This is the macro invoked by entries in the aux file. Define a control
9116 % sequence for a cross-reference target (we prepend XR to the control sequence
9117 % name to avoid collisions). The value is the page number. If this is a float
9118 % type, we have more work to do.
9119 %
9120 \def\xrdef#1#2{%
9121 {% Expand the node or anchor name to remove control sequences.
9122 % \turnoffactive stops 8-bit characters being changed to commands
9123 % like @'e. \refx does the same to retrieve the value in the definition.
9124 \indexnofonts
9125 \turnoffactive
9126 \def\value##1{##1}%
9127 \xdef\safexrefname{#1}%
9128 }%
9129 %
9130 \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref
9131 %
9132 % Was that xref control sequence that we just defined for a float?
9133 \expandafter\iffloat\csname XR\safexrefname\endcsname
9134 % it was a float, and we have the (safe) float type in \iffloattype.
9135 \expandafter\let\expandafter\floatlist
9136 \csname floatlist\iffloattype\endcsname
9137 %
9138 % Is this the first time we've seen this float type?
9139 \expandafter\ifx\floatlist\relax
9140 \toks0 = {\do}% yes, so just \do
9141 \else
9142 % had it before, so preserve previous elements in list.
9143 \toks0 = \expandafter{\floatlist\do}%
9144 \fi
9145 %
9146 % Remember this xref in the control sequence \floatlistFLOATTYPE,
9147 % for later use in \listoffloats.
9148 \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
9149 {\safexrefname}}%
9150 \fi
9151 }
9152
9153 % If working on a large document in chapters, it is convenient to
9154 % be able to disable indexing, cross-referencing, and contents, for test runs.
9155 % This is done with @novalidate at the beginning of the file.
9156 %
9157 \newif\iflinks \linkstrue % by default we want the aux files.
9158 \let\novalidate = \linksfalse
9159
9160 % Used when writing to the aux file, or when using data from it.
9161 \def\requireauxfile{%
9162 \iflinks
9163 \tryauxfile
9164 % Open the new aux file. TeX will close it automatically at exit.
9165 \immediate\openout\auxfile=\jobname.aux
9166 \fi
9167 \global\let\requireauxfile=\relax % Only do this once.
9168 }
9169
9170 % Read the last existing aux file, if any. No error if none exists.
9171 %
9172 \def\tryauxfile{%
9173 \openin 1 \jobname.aux
9174 \ifeof 1 \else
9175 \readdatafile{aux}%
9176 \global\havexrefstrue
9177 \fi
9178 \closein 1
9179 }
9180
9181 \def\setupdatafile{%
9182 \catcode`\^^@=\other
9183 \catcode`\^^A=\other
9184 \catcode`\^^B=\other
9185 \catcode`\^^C=\other
9186 \catcode`\^^D=\other
9187 \catcode`\^^E=\other
9188 \catcode`\^^F=\other
9189 \catcode`\^^G=\other
9190 \catcode`\^^H=\other
9191 \catcode`\^^K=\other
9192 \catcode`\^^L=\other
9193 \catcode`\^^N=\other
9194 \catcode`\^^P=\other
9195 \catcode`\^^Q=\other
9196 \catcode`\^^R=\other
9197 \catcode`\^^S=\other
9198 \catcode`\^^T=\other
9199 \catcode`\^^U=\other
9200 \catcode`\^^V=\other
9201 \catcode`\^^W=\other
9202 \catcode`\^^X=\other
9203 \catcode`\^^Z=\other
9204 \catcode`\^^[=\other
9205 \catcode`\^^\=\other
9206 \catcode`\^^]=\other
9207 \catcode`\^^^=\other
9208 \catcode`\^^_=\other
9209 % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
9210 % in xref tags, i.e., node names. But since ^^e4 notation isn't
9211 % supported in the main text, it doesn't seem desirable. Furthermore,
9212 % that is not enough: for node names that actually contain a ^
9213 % character, we would end up writing a line like this: 'xrdef {'hat
9214 % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
9215 % argument, and \hat is not an expandable control sequence. It could
9216 % all be worked out, but why? Either we support ^^ or we don't.
9217 %
9218 % The other change necessary for this was to define \auxhat:
9219 % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
9220 % and then to call \auxhat in \setq.
9221 %
9222 \catcode`\^=\other
9223 %
9224 % Special characters. Should be turned off anyway, but...
9225 \catcode`\~=\other
9226 \catcode`\[=\other
9227 \catcode`\]=\other
9228 \catcode`\"=\other
9229 \catcode`\_=\other
9230 \catcode`\|=\other
9231 \catcode`\<=\other
9232 \catcode`\>=\other
9233 \catcode`\$=\other
9234 \catcode`\#=\other
9235 \catcode`\&=\other
9236 \catcode`\%=\other
9237 \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
9238 %
9239 % This is to support \ in node names and titles, since the \
9240 % characters end up in a \csname. It's easier than
9241 % leaving it active and making its active definition an actual \
9242 % character. What I don't understand is why it works in the *value*
9243 % of the xrdef. Seems like it should be a catcode12 \, and that
9244 % should not typeset properly. But it works, so I'm moving on for
9245 % now. --karl, 15jan04.
9246 \catcode`\\=\other
9247 %
9248 % @ is our escape character in .aux files, and we need braces.
9249 \catcode`\{=1
9250 \catcode`\}=2
9251 \catcode`\@=0
9252 }
9253
9254 \def\readdatafile#1{%
9255 \begingroup
9256 \setupdatafile
9257 \input\jobname.#1
9258 \endgroup}
9259
9260
9261 \message{insertions,}
9262 % including footnotes.
9263
9264 \newcount \footnoteno
9265
9266 % The trailing space in the following definition for supereject is
9267 % vital for proper filling; pages come out unaligned when you do a
9268 % pagealignmacro call if that space before the closing brace is
9269 % removed. (Generally, numeric constants should always be followed by a
9270 % space to prevent strange expansion errors.)
9271 \def\supereject{\par\penalty -20000\footnoteno =0 }
9272
9273 % @footnotestyle is meaningful for Info output only.
9274 \let\footnotestyle=\comment
9275
9276 {\catcode `\@=11
9277 %
9278 % Auto-number footnotes. Otherwise like plain.
9279 \gdef\footnote{%
9280 \global\advance\footnoteno by \@ne
9281 \edef\thisfootno{$^{\the\footnoteno}$}%
9282 %
9283 % In case the footnote comes at the end of a sentence, preserve the
9284 % extra spacing after we do the footnote number.
9285 \let\@sf\empty
9286 \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9287 %
9288 % Remove inadvertent blank space before typesetting the footnote number.
9289 \unskip
9290 \thisfootno\@sf
9291 \dofootnote
9292 }%
9293
9294 % Don't bother with the trickery in plain.tex to not require the
9295 % footnote text as a parameter. Our footnotes don't need to be so general.
9296 %
9297 % Oh yes, they do; otherwise, @ifset (and anything else that uses
9298 % \parseargline) fails inside footnotes because the tokens are fixed when
9299 % the footnote is read. --karl, 16nov96.
9300 %
9301 \gdef\dofootnote{%
9302 \insert\footins\bgroup
9303 %
9304 % Nested footnotes are not supported in TeX, that would take a lot
9305 % more work. (\startsavinginserts does not suffice.)
9306 \let\footnote=\errfootnotenest
9307 %
9308 % We want to typeset this text as a normal paragraph, even if the
9309 % footnote reference occurs in (for example) a display environment.
9310 % So reset some parameters.
9311 \hsize=\txipagewidth
9312 \interlinepenalty\interfootnotelinepenalty
9313 \splittopskip\ht\strutbox % top baseline for broken footnotes
9314 \splitmaxdepth\dp\strutbox
9315 \floatingpenalty\@MM
9316 \leftskip\z@skip
9317 \rightskip\z@skip
9318 \spaceskip\z@skip
9319 \xspaceskip\z@skip
9320 \parindent\defaultparindent
9321 %
9322 \smallfonts \rm
9323 %
9324 % Because we use hanging indentation in footnotes, a @noindent appears
9325 % to exdent this text, so make it be a no-op. makeinfo does not use
9326 % hanging indentation so @noindent can still be needed within footnote
9327 % text after an @example or the like (not that this is good style).
9328 \let\noindent = \relax
9329 %
9330 % Hang the footnote text off the number. Use \everypar in case the
9331 % footnote extends for more than one paragraph.
9332 \everypar = {\hang}%
9333 \textindent{\thisfootno}%
9334 %
9335 % Don't crash into the line above the footnote text. Since this
9336 % expands into a box, it must come within the paragraph, lest it
9337 % provide a place where TeX can split the footnote.
9338 \footstrut
9339 %
9340 % Invoke rest of plain TeX footnote routine.
9341 \futurelet\next\fo@t
9342 }
9343 }%end \catcode `\@=11
9344
9345 \def\errfootnotenest{%
9346 \errhelp=\EMsimple
9347 \errmessage{Nested footnotes not supported in texinfo.tex,
9348 even though they work in makeinfo; sorry}
9349 }
9350
9351 \def\errfootnoteheading{%
9352 \errhelp=\EMsimple
9353 \errmessage{Footnotes in chapters, sections, etc., are not supported}
9354 }
9355
9356 % In case a @footnote appears in a vbox, save the footnote text and create
9357 % the real \insert just after the vbox finished. Otherwise, the insertion
9358 % would be lost.
9359 % Similarly, if a @footnote appears inside an alignment, save the footnote
9360 % text to a box and make the \insert when a row of the table is finished.
9361 % And the same can be done for other insert classes. --kasal, 16nov03.
9362 %
9363 % Replace the \insert primitive by a cheating macro.
9364 % Deeper inside, just make sure that the saved insertions are not spilled
9365 % out prematurely.
9366 %
9367 \def\startsavinginserts{%
9368 \ifx \insert\ptexinsert
9369 \let\insert\saveinsert
9370 \else
9371 \let\checkinserts\relax
9372 \fi
9373 }
9374
9375 % This \insert replacement works for both \insert\footins{foo} and
9376 % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9377 %
9378 \def\saveinsert#1{%
9379 \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9380 \afterassignment\next
9381 % swallow the left brace
9382 \let\temp =
9383 }
9384 \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9385 \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9386
9387 \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9388
9389 \def\placesaveins#1{%
9390 \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9391 {\box#1}%
9392 }
9393
9394 % eat @SAVE -- beware, all of them have catcode \other:
9395 {
9396 \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-)
9397 \gdef\gobblesave @SAVE{}
9398 }
9399
9400 % initialization:
9401 \def\newsaveins #1{%
9402 \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9403 \next
9404 }
9405 \def\newsaveinsX #1{%
9406 \csname newbox\endcsname #1%
9407 \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9408 \checksaveins #1}%
9409 }
9410
9411 % initialize:
9412 \let\checkinserts\empty
9413 \newsaveins\footins
9414 \newsaveins\margin
9415
9416
9417 % @image. We use the macros from epsf.tex to support this.
9418 % If epsf.tex is not installed and @image is used, we complain.
9419 %
9420 % Check for and read epsf.tex up front. If we read it only at @image
9421 % time, we might be inside a group, and then its definitions would get
9422 % undone and the next image would fail.
9423 \openin 1 = epsf.tex
9424 \ifeof 1 \else
9425 % Do not bother showing banner with epsf.tex v2.7k (available in
9426 % doc/epsf.tex and on ctan).
9427 \def\epsfannounce{\toks0 = }%
9428 \input epsf.tex
9429 \fi
9430 \closein 1
9431 %
9432 % We will only complain once about lack of epsf.tex.
9433 \newif\ifwarnednoepsf
9434 \newhelp\noepsfhelp{epsf.tex must be installed for images to
9435 work. It is also included in the Texinfo distribution, or you can get
9436 it from ftp://tug.org/tex/epsf.tex.}
9437 %
9438 \def\image#1{%
9439 \ifx\epsfbox\thisisundefined
9440 \ifwarnednoepsf \else
9441 \errhelp = \noepsfhelp
9442 \errmessage{epsf.tex not found, images will be ignored}%
9443 \global\warnednoepsftrue
9444 \fi
9445 \else
9446 \imagexxx #1,,,,,\finish
9447 \fi
9448 }
9449 %
9450 % Arguments to @image:
9451 % #1 is (mandatory) image filename; we tack on .eps extension.
9452 % #2 is (optional) width, #3 is (optional) height.
9453 % #4 is (ignored optional) html alt text.
9454 % #5 is (ignored optional) extension.
9455 % #6 is just the usual extra ignored arg for parsing stuff.
9456 \newif\ifimagevmode
9457 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
9458 \catcode`\^^M = 5 % in case we're inside an example
9459 \normalturnoffactive % allow _ et al. in names
9460 \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
9461 % If the image is by itself, center it.
9462 \ifvmode
9463 \imagevmodetrue
9464 \else \ifx\centersub\centerV
9465 % for @center @image, we need a vbox so we can have our vertical space
9466 \imagevmodetrue
9467 \vbox\bgroup % vbox has better behavior than vtop herev
9468 \fi\fi
9469 %
9470 \ifimagevmode
9471 \nobreak\medskip
9472 % Usually we'll have text after the image which will insert
9473 % \parskip glue, so insert it here too to equalize the space
9474 % above and below.
9475 \nobreak\vskip\parskip
9476 \nobreak
9477 \fi
9478 %
9479 % Leave vertical mode so that indentation from an enclosing
9480 % environment such as @quotation is respected.
9481 % However, if we're at the top level, we don't want the
9482 % normal paragraph indentation.
9483 % On the other hand, if we are in the case of @center @image, we don't
9484 % want to start a paragraph, which will create a hsize-width box and
9485 % eradicate the centering.
9486 \ifx\centersub\centerV\else \noindent \fi
9487 %
9488 % Output the image.
9489 \ifpdf
9490 % For pdfTeX and LuaTeX <= 0.80
9491 \dopdfimage{#1}{#2}{#3}%
9492 \else
9493 \ifx\XeTeXrevision\thisisundefined
9494 % For epsf.tex
9495 % \epsfbox itself resets \epsf?size at each figure.
9496 \setbox0 = \hbox{\ignorespaces #2}%
9497 \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9498 \setbox0 = \hbox{\ignorespaces #3}%
9499 \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9500 \epsfbox{#1.eps}%
9501 \else
9502 % For XeTeX
9503 \doxeteximage{#1}{#2}{#3}%
9504 \fi
9505 \fi
9506 %
9507 \ifimagevmode
9508 \medskip % space after a standalone image
9509 \fi
9510 \ifx\centersub\centerV \egroup \fi
9511 \endgroup}
9512
9513
9514 % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9515 % etc. We don't actually implement floating yet, we always include the
9516 % float "here". But it seemed the best name for the future.
9517 %
9518 \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9519
9520 % There may be a space before second and/or third parameter; delete it.
9521 \def\eatcommaspace#1, {#1,}
9522
9523 % #1 is the optional FLOATTYPE, the text label for this float, typically
9524 % "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
9525 % this float will not be numbered and cannot be referred to.
9526 %
9527 % #2 is the optional xref label. Also must be present for the float to
9528 % be referable.
9529 %
9530 % #3 is the optional positioning argument; for now, it is ignored. It
9531 % will somehow specify the positions allowed to float to (here, top, bottom).
9532 %
9533 % We keep a separate counter for each FLOATTYPE, which we reset at each
9534 % chapter-level command.
9535 \let\resetallfloatnos=\empty
9536 %
9537 \def\dofloat#1,#2,#3,#4\finish{%
9538 \let\thiscaption=\empty
9539 \let\thisshortcaption=\empty
9540 %
9541 % don't lose footnotes inside @float.
9542 %
9543 % BEWARE: when the floats start float, we have to issue warning whenever an
9544 % insert appears inside a float which could possibly float. --kasal, 26may04
9545 %
9546 \startsavinginserts
9547 %
9548 % We can't be used inside a paragraph.
9549 \par
9550 %
9551 \vtop\bgroup
9552 \def\floattype{#1}%
9553 \def\floatlabel{#2}%
9554 \def\floatloc{#3}% we do nothing with this yet.
9555 %
9556 \ifx\floattype\empty
9557 \let\safefloattype=\empty
9558 \else
9559 {%
9560 % the floattype might have accents or other special characters,
9561 % but we need to use it in a control sequence name.
9562 \indexnofonts
9563 \turnoffactive
9564 \xdef\safefloattype{\floattype}%
9565 }%
9566 \fi
9567 %
9568 % If label is given but no type, we handle that as the empty type.
9569 \ifx\floatlabel\empty \else
9570 % We want each FLOATTYPE to be numbered separately (Figure 1,
9571 % Table 1, Figure 2, ...). (And if no label, no number.)
9572 %
9573 \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9574 \global\advance\floatno by 1
9575 %
9576 {%
9577 % This magic value for \lastsection is output by \setref as the
9578 % XREFLABEL-title value. \xrefX uses it to distinguish float
9579 % labels (which have a completely different output format) from
9580 % node and anchor labels. And \xrdef uses it to construct the
9581 % lists of floats.
9582 %
9583 \edef\lastsection{\floatmagic=\safefloattype}%
9584 \setref{\floatlabel}{Yfloat}%
9585 }%
9586 \fi
9587 %
9588 % start with \parskip glue, I guess.
9589 \vskip\parskip
9590 %
9591 % Don't suppress indentation if a float happens to start a section.
9592 \restorefirstparagraphindent
9593 }
9594
9595 % we have these possibilities:
9596 % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9597 % @float Foo,lbl & no caption: Foo 1.1
9598 % @float Foo & @caption{Cap}: Foo: Cap
9599 % @float Foo & no caption: Foo
9600 % @float ,lbl & Caption{Cap}: 1.1: Cap
9601 % @float ,lbl & no caption: 1.1
9602 % @float & @caption{Cap}: Cap
9603 % @float & no caption:
9604 %
9605 \def\Efloat{%
9606 \let\floatident = \empty
9607 %
9608 % In all cases, if we have a float type, it comes first.
9609 \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9610 %
9611 % If we have an xref label, the number comes next.
9612 \ifx\floatlabel\empty \else
9613 \ifx\floattype\empty \else % if also had float type, need tie first.
9614 \appendtomacro\floatident{\tie}%
9615 \fi
9616 % the number.
9617 \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9618 \fi
9619 %
9620 % Start the printed caption with what we've constructed in
9621 % \floatident, but keep it separate; we need \floatident again.
9622 \let\captionline = \floatident
9623 %
9624 \ifx\thiscaption\empty \else
9625 \ifx\floatident\empty \else
9626 \appendtomacro\captionline{: }% had ident, so need a colon between
9627 \fi
9628 %
9629 % caption text.
9630 \appendtomacro\captionline{\scanexp\thiscaption}%
9631 \fi
9632 %
9633 % If we have anything to print, print it, with space before.
9634 % Eventually this needs to become an \insert.
9635 \ifx\captionline\empty \else
9636 \vskip.5\parskip
9637 \captionline
9638 %
9639 % Space below caption.
9640 \vskip\parskip
9641 \fi
9642 %
9643 % If have an xref label, write the list of floats info. Do this
9644 % after the caption, to avoid chance of it being a breakpoint.
9645 \ifx\floatlabel\empty \else
9646 % Write the text that goes in the lof to the aux file as
9647 % \floatlabel-lof. Besides \floatident, we include the short
9648 % caption if specified, else the full caption if specified, else nothing.
9649 {%
9650 \requireauxfile
9651 \atdummies
9652 %
9653 \ifx\thisshortcaption\empty
9654 \def\gtemp{\thiscaption}%
9655 \else
9656 \def\gtemp{\thisshortcaption}%
9657 \fi
9658 \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
9659 \ifx\gtemp\empty \else : \gtemp \fi}}%
9660 }%
9661 \fi
9662 \egroup % end of \vtop
9663 %
9664 \checkinserts
9665 }
9666
9667 % Append the tokens #2 to the definition of macro #1, not expanding either.
9668 %
9669 \def\appendtomacro#1#2{%
9670 \expandafter\def\expandafter#1\expandafter{#1#2}%
9671 }
9672
9673 % @caption, @shortcaption
9674 %
9675 \def\caption{\docaption\thiscaption}
9676 \def\shortcaption{\docaption\thisshortcaption}
9677 \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
9678 \def\defcaption#1#2{\egroup \def#1{#2}}
9679
9680 % The parameter is the control sequence identifying the counter we are
9681 % going to use. Create it if it doesn't exist and assign it to \floatno.
9682 \def\getfloatno#1{%
9683 \ifx#1\relax
9684 % Haven't seen this figure type before.
9685 \csname newcount\endcsname #1%
9686 %
9687 % Remember to reset this floatno at the next chap.
9688 \expandafter\gdef\expandafter\resetallfloatnos
9689 \expandafter{\resetallfloatnos #1=0 }%
9690 \fi
9691 \let\floatno#1%
9692 }
9693
9694 % \setref calls this to get the XREFLABEL-snt value. We want an @xref
9695 % to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
9696 % first read the @float command.
9697 %
9698 \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9699
9700 % Magic string used for the XREFLABEL-title value, so \xrefX can
9701 % distinguish floats from other xref types.
9702 \def\floatmagic{!!float!!}
9703
9704 % #1 is the control sequence we are passed; we expand into a conditional
9705 % which is true if #1 represents a float ref. That is, the magic
9706 % \lastsection value which we \setref above.
9707 %
9708 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
9709 %
9710 % #1 is (maybe) the \floatmagic string. If so, #2 will be the
9711 % (safe) float type for this float. We set \iffloattype to #2.
9712 %
9713 \def\doiffloat#1=#2=#3\finish{%
9714 \def\temp{#1}%
9715 \def\iffloattype{#2}%
9716 \ifx\temp\floatmagic
9717 }
9718
9719 % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9720 %
9721 \parseargdef\listoffloats{%
9722 \def\floattype{#1}% floattype
9723 {%
9724 % the floattype might have accents or other special characters,
9725 % but we need to use it in a control sequence name.
9726 \indexnofonts
9727 \turnoffactive
9728 \xdef\safefloattype{\floattype}%
9729 }%
9730 %
9731 % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9732 \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9733 \ifhavexrefs
9734 % if the user said @listoffloats foo but never @float foo.
9735 \message{\linenumber No `\safefloattype' floats to list.}%
9736 \fi
9737 \else
9738 \begingroup
9739 \leftskip=\tocindent % indent these entries like a toc
9740 \let\do=\listoffloatsdo
9741 \csname floatlist\safefloattype\endcsname
9742 \endgroup
9743 \fi
9744 }
9745
9746 % This is called on each entry in a list of floats. We're passed the
9747 % xref label, in the form LABEL-title, which is how we save it in the
9748 % aux file. We strip off the -title and look up \XRLABEL-lof, which
9749 % has the text we're supposed to typeset here.
9750 %
9751 % Figures without xref labels will not be included in the list (since
9752 % they won't appear in the aux file).
9753 %
9754 \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9755 \def\listoffloatsdoentry#1-title\finish{{%
9756 % Can't fully expand XR#1-lof because it can contain anything. Just
9757 % pass the control sequence. On the other hand, XR#1-pg is just the
9758 % page number, and we want to fully expand that so we can get a link
9759 % in pdf output.
9760 \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9761 %
9762 % use the same \entry macro we use to generate the TOC and index.
9763 \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9764 \writeentry
9765 }}
9766
9767
9768 \message{localization,}
9769
9770 % For single-language documents, @documentlanguage is usually given very
9771 % early, just after @documentencoding. Single argument is the language
9772 % (de) or locale (de_DE) abbreviation.
9773 %
9774 {
9775 \catcode`\_ = \active
9776 \globaldefs=1
9777 \parseargdef\documentlanguage{%
9778 \tex % read txi-??.tex file in plain TeX.
9779 % Read the file by the name they passed if it exists.
9780 \let_ = \normalunderscore % normal _ character for filename test
9781 \openin 1 txi-#1.tex
9782 \ifeof 1
9783 \documentlanguagetrywithoutunderscore #1_\finish
9784 \else
9785 \globaldefs = 1 % everything in the txi-LL files needs to persist
9786 \input txi-#1.tex
9787 \fi
9788 \closein 1
9789 \endgroup % end raw TeX
9790 }
9791 %
9792 % If they passed de_DE, and txi-de_DE.tex doesn't exist,
9793 % try txi-de.tex.
9794 %
9795 \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
9796 \openin 1 txi-#1.tex
9797 \ifeof 1
9798 \errhelp = \nolanghelp
9799 \errmessage{Cannot read language file txi-#1.tex}%
9800 \else
9801 \globaldefs = 1 % everything in the txi-LL files needs to persist
9802 \input txi-#1.tex
9803 \fi
9804 \closein 1
9805 }
9806 }% end of special _ catcode
9807 %
9808 \newhelp\nolanghelp{The given language definition file cannot be found or
9809 is empty. Maybe you need to install it? Putting it in the current
9810 directory should work if nowhere else does.}
9811
9812 % This macro is called from txi-??.tex files; the first argument is the
9813 % \language name to set (without the "\lang@" prefix), the second and
9814 % third args are \{left,right}hyphenmin.
9815 %
9816 % The language names to pass are determined when the format is built.
9817 % See the etex.log file created at that time, e.g.,
9818 % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9819 %
9820 % With TeX Live 2008, etex now includes hyphenation patterns for all
9821 % available languages. This means we can support hyphenation in
9822 % Texinfo, at least to some extent. (This still doesn't solve the
9823 % accented characters problem.)
9824 %
9825 \catcode`@=11
9826 \def\txisetlanguage#1#2#3{%
9827 % do not set the language if the name is undefined in the current TeX.
9828 \expandafter\ifx\csname lang@#1\endcsname \relax
9829 \message{no patterns for #1}%
9830 \else
9831 \global\language = \csname lang@#1\endcsname
9832 \fi
9833 % but there is no harm in adjusting the hyphenmin values regardless.
9834 \global\lefthyphenmin = #2\relax
9835 \global\righthyphenmin = #3\relax
9836 }
9837
9838 % XeTeX and LuaTeX can handle native Unicode.
9839 % Their default I/O is UTF-8 sequence instead of byte-wise.
9840 % Other TeX engine (pdfTeX etc.) I/O is byte-wise.
9841 %
9842 \newif\iftxinativeunicodecapable
9843 \newif\iftxiusebytewiseio
9844
9845 \ifx\XeTeXrevision\thisisundefined
9846 \ifx\luatexversion\thisisundefined
9847 \txinativeunicodecapablefalse
9848 \txiusebytewiseiotrue
9849 \else
9850 \txinativeunicodecapabletrue
9851 \txiusebytewiseiofalse
9852 \fi
9853 \else
9854 \txinativeunicodecapabletrue
9855 \txiusebytewiseiofalse
9856 \fi
9857
9858 % Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9859 % for non-UTF-8 (byte-wise) encodings.
9860 %
9861 \def\setbytewiseio{%
9862 \ifx\XeTeXrevision\thisisundefined
9863 \else
9864 \XeTeXdefaultencoding "bytes" % For subsequent files to be read
9865 \XeTeXinputencoding "bytes" % For document root file
9866 % Unfortunately, there seems to be no corresponding XeTeX command for
9867 % output encoding. This is a problem for auxiliary index and TOC files.
9868 % The only solution would be perhaps to write out @U{...} sequences in
9869 % place of non-ASCII characters.
9870 \fi
9871
9872 \ifx\luatexversion\thisisundefined
9873 \else
9874 \directlua{
9875 local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9876 local function convert_char (char)
9877 return utf8_char(byte(char))
9878 end
9879
9880 local function convert_line (line)
9881 return gsub(line, ".", convert_char)
9882 end
9883
9884 callback.register("process_input_buffer", convert_line)
9885
9886 local function convert_line_out (line)
9887 local line_out = ""
9888 for c in string.utfvalues(line) do
9889 line_out = line_out .. string.char(c)
9890 end
9891 return line_out
9892 end
9893
9894 callback.register("process_output_buffer", convert_line_out)
9895 }
9896 \fi
9897
9898 \txiusebytewiseiotrue
9899 }
9900
9901
9902 % Helpers for encodings.
9903 % Set the catcode of characters 128 through 255 to the specified number.
9904 %
9905 \def\setnonasciicharscatcode#1{%
9906 \count255=128
9907 \loop\ifnum\count255<256
9908 \global\catcode\count255=#1\relax
9909 \advance\count255 by 1
9910 \repeat
9911 }
9912
9913 \def\setnonasciicharscatcodenonglobal#1{%
9914 \count255=128
9915 \loop\ifnum\count255<256
9916 \catcode\count255=#1\relax
9917 \advance\count255 by 1
9918 \repeat
9919 }
9920
9921 % @documentencoding sets the definition of non-ASCII characters
9922 % according to the specified encoding.
9923 %
9924 \def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9925 \def\documentencodingzzz#1{%
9926 %
9927 % Encoding being declared for the document.
9928 \def\declaredencoding{\csname #1.enc\endcsname}%
9929 %
9930 % Supported encodings: names converted to tokens in order to be able
9931 % to compare them with \ifx.
9932 \def\ascii{\csname US-ASCII.enc\endcsname}%
9933 \def\latnine{\csname ISO-8859-15.enc\endcsname}%
9934 \def\latone{\csname ISO-8859-1.enc\endcsname}%
9935 \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
9936 \def\utfeight{\csname UTF-8.enc\endcsname}%
9937 %
9938 \ifx \declaredencoding \ascii
9939 \asciichardefs
9940 %
9941 \else \ifx \declaredencoding \lattwo
9942 \iftxinativeunicodecapable
9943 \setbytewiseio
9944 \fi
9945 \setnonasciicharscatcode\active
9946 \lattwochardefs
9947 %
9948 \else \ifx \declaredencoding \latone
9949 \iftxinativeunicodecapable
9950 \setbytewiseio
9951 \fi
9952 \setnonasciicharscatcode\active
9953 \latonechardefs
9954 %
9955 \else \ifx \declaredencoding \latnine
9956 \iftxinativeunicodecapable
9957 \setbytewiseio
9958 \fi
9959 \setnonasciicharscatcode\active
9960 \latninechardefs
9961 %
9962 \else \ifx \declaredencoding \utfeight
9963 \iftxinativeunicodecapable
9964 % For native Unicode (XeTeX and LuaTeX)
9965 \nativeunicodechardefs
9966 \else
9967 % For UTF-8 byte sequence (TeX, eTeX and pdfTeX)
9968 \setnonasciicharscatcode\active
9969 % since we already invoked \utfeightchardefs at the top level
9970 % (below), do not re-invoke it, then our check for duplicated
9971 % definitions triggers. Making non-ascii chars active is enough.
9972 \fi
9973 %
9974 \else
9975 \message{Ignoring unknown document encoding: #1.}%
9976 %
9977 \fi % utfeight
9978 \fi % latnine
9979 \fi % latone
9980 \fi % lattwo
9981 \fi % ascii
9982 }
9983
9984 % emacs-page
9985 % A message to be logged when using a character that isn't available
9986 % the default font encoding (OT1).
9987 %
9988 \def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
9989
9990 % Take account of \c (plain) vs. \, (Texinfo) difference.
9991 \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
9992
9993 % First, make active non-ASCII characters in order for them to be
9994 % correctly categorized when TeX reads the replacement text of
9995 % macros containing the character definitions.
9996 \setnonasciicharscatcode\active
9997 %
9998
9999 \def\gdefchar#1#2{%
10000 \gdef#1{%
10001 \ifpassthroughchars
10002 \string#1%
10003 \else
10004 #2%
10005 \fi
10006 }}
10007
10008 % Latin1 (ISO-8859-1) character definitions.
10009 \def\latonechardefs{%
10010 \gdefchar^^a0{\tie}
10011 \gdefchar^^a1{\exclamdown}
10012 \gdefchar^^a2{{\tcfont \char162}} % cent
10013 \gdefchar^^a3{\pounds}
10014 \gdefchar^^a4{{\tcfont \char164}} % currency
10015 \gdefchar^^a5{{\tcfont \char165}} % yen
10016 \gdefchar^^a6{{\tcfont \char166}} % broken bar
10017 \gdefchar^^a7{\S}
10018 \gdefchar^^a8{\"{}}
10019 \gdefchar^^a9{\copyright}
10020 \gdefchar^^aa{\ordf}
10021 \gdefchar^^ab{\guillemetleft}
10022 \gdefchar^^ac{\ensuremath\lnot}
10023 \gdefchar^^ad{\-}
10024 \gdefchar^^ae{\registeredsymbol}
10025 \gdefchar^^af{\={}}
10026 %
10027 \gdefchar^^b0{\textdegree}
10028 \gdefchar^^b1{$\pm$}
10029 \gdefchar^^b2{$^2$}
10030 \gdefchar^^b3{$^3$}
10031 \gdefchar^^b4{\'{}}
10032 \gdefchar^^b5{$\mu$}
10033 \gdefchar^^b6{\P}
10034 \gdefchar^^b7{\ensuremath\cdot}
10035 \gdefchar^^b8{\cedilla\ }
10036 \gdefchar^^b9{$^1$}
10037 \gdefchar^^ba{\ordm}
10038 \gdefchar^^bb{\guillemetright}
10039 \gdefchar^^bc{$1\over4$}
10040 \gdefchar^^bd{$1\over2$}
10041 \gdefchar^^be{$3\over4$}
10042 \gdefchar^^bf{\questiondown}
10043 %
10044 \gdefchar^^c0{\`A}
10045 \gdefchar^^c1{\'A}
10046 \gdefchar^^c2{\^A}
10047 \gdefchar^^c3{\~A}
10048 \gdefchar^^c4{\"A}
10049 \gdefchar^^c5{\ringaccent A}
10050 \gdefchar^^c6{\AE}
10051 \gdefchar^^c7{\cedilla C}
10052 \gdefchar^^c8{\`E}
10053 \gdefchar^^c9{\'E}
10054 \gdefchar^^ca{\^E}
10055 \gdefchar^^cb{\"E}
10056 \gdefchar^^cc{\`I}
10057 \gdefchar^^cd{\'I}
10058 \gdefchar^^ce{\^I}
10059 \gdefchar^^cf{\"I}
10060 %
10061 \gdefchar^^d0{\DH}
10062 \gdefchar^^d1{\~N}
10063 \gdefchar^^d2{\`O}
10064 \gdefchar^^d3{\'O}
10065 \gdefchar^^d4{\^O}
10066 \gdefchar^^d5{\~O}
10067 \gdefchar^^d6{\"O}
10068 \gdefchar^^d7{$\times$}
10069 \gdefchar^^d8{\O}
10070 \gdefchar^^d9{\`U}
10071 \gdefchar^^da{\'U}
10072 \gdefchar^^db{\^U}
10073 \gdefchar^^dc{\"U}
10074 \gdefchar^^dd{\'Y}
10075 \gdefchar^^de{\TH}
10076 \gdefchar^^df{\ss}
10077 %
10078 \gdefchar^^e0{\`a}
10079 \gdefchar^^e1{\'a}
10080 \gdefchar^^e2{\^a}
10081 \gdefchar^^e3{\~a}
10082 \gdefchar^^e4{\"a}
10083 \gdefchar^^e5{\ringaccent a}
10084 \gdefchar^^e6{\ae}
10085 \gdefchar^^e7{\cedilla c}
10086 \gdefchar^^e8{\`e}
10087 \gdefchar^^e9{\'e}
10088 \gdefchar^^ea{\^e}
10089 \gdefchar^^eb{\"e}
10090 \gdefchar^^ec{\`{\dotless i}}
10091 \gdefchar^^ed{\'{\dotless i}}
10092 \gdefchar^^ee{\^{\dotless i}}
10093 \gdefchar^^ef{\"{\dotless i}}
10094 %
10095 \gdefchar^^f0{\dh}
10096 \gdefchar^^f1{\~n}
10097 \gdefchar^^f2{\`o}
10098 \gdefchar^^f3{\'o}
10099 \gdefchar^^f4{\^o}
10100 \gdefchar^^f5{\~o}
10101 \gdefchar^^f6{\"o}
10102 \gdefchar^^f7{$\div$}
10103 \gdefchar^^f8{\o}
10104 \gdefchar^^f9{\`u}
10105 \gdefchar^^fa{\'u}
10106 \gdefchar^^fb{\^u}
10107 \gdefchar^^fc{\"u}
10108 \gdefchar^^fd{\'y}
10109 \gdefchar^^fe{\th}
10110 \gdefchar^^ff{\"y}
10111 }
10112
10113 % Latin9 (ISO-8859-15) encoding character definitions.
10114 \def\latninechardefs{%
10115 % Encoding is almost identical to Latin1.
10116 \latonechardefs
10117 %
10118 \gdefchar^^a4{\euro}
10119 \gdefchar^^a6{\v S}
10120 \gdefchar^^a8{\v s}
10121 \gdefchar^^b4{\v Z}
10122 \gdefchar^^b8{\v z}
10123 \gdefchar^^bc{\OE}
10124 \gdefchar^^bd{\oe}
10125 \gdefchar^^be{\"Y}
10126 }
10127
10128 % Latin2 (ISO-8859-2) character definitions.
10129 \def\lattwochardefs{%
10130 \gdefchar^^a0{\tie}
10131 \gdefchar^^a1{\ogonek{A}}
10132 \gdefchar^^a2{\u{}}
10133 \gdefchar^^a3{\L}
10134 \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
10135 \gdefchar^^a5{\v L}
10136 \gdefchar^^a6{\'S}
10137 \gdefchar^^a7{\S}
10138 \gdefchar^^a8{\"{}}
10139 \gdefchar^^a9{\v S}
10140 \gdefchar^^aa{\cedilla S}
10141 \gdefchar^^ab{\v T}
10142 \gdefchar^^ac{\'Z}
10143 \gdefchar^^ad{\-}
10144 \gdefchar^^ae{\v Z}
10145 \gdefchar^^af{\dotaccent Z}
10146 %
10147 \gdefchar^^b0{\textdegree}
10148 \gdefchar^^b1{\ogonek{a}}
10149 \gdefchar^^b2{\ogonek{ }}
10150 \gdefchar^^b3{\l}
10151 \gdefchar^^b4{\'{}}
10152 \gdefchar^^b5{\v l}
10153 \gdefchar^^b6{\'s}
10154 \gdefchar^^b7{\v{}}
10155 \gdefchar^^b8{\cedilla\ }
10156 \gdefchar^^b9{\v s}
10157 \gdefchar^^ba{\cedilla s}
10158 \gdefchar^^bb{\v t}
10159 \gdefchar^^bc{\'z}
10160 \gdefchar^^bd{\H{}}
10161 \gdefchar^^be{\v z}
10162 \gdefchar^^bf{\dotaccent z}
10163 %
10164 \gdefchar^^c0{\'R}
10165 \gdefchar^^c1{\'A}
10166 \gdefchar^^c2{\^A}
10167 \gdefchar^^c3{\u A}
10168 \gdefchar^^c4{\"A}
10169 \gdefchar^^c5{\'L}
10170 \gdefchar^^c6{\'C}
10171 \gdefchar^^c7{\cedilla C}
10172 \gdefchar^^c8{\v C}
10173 \gdefchar^^c9{\'E}
10174 \gdefchar^^ca{\ogonek{E}}
10175 \gdefchar^^cb{\"E}
10176 \gdefchar^^cc{\v E}
10177 \gdefchar^^cd{\'I}
10178 \gdefchar^^ce{\^I}
10179 \gdefchar^^cf{\v D}
10180 %
10181 \gdefchar^^d0{\DH}
10182 \gdefchar^^d1{\'N}
10183 \gdefchar^^d2{\v N}
10184 \gdefchar^^d3{\'O}
10185 \gdefchar^^d4{\^O}
10186 \gdefchar^^d5{\H O}
10187 \gdefchar^^d6{\"O}
10188 \gdefchar^^d7{$\times$}
10189 \gdefchar^^d8{\v R}
10190 \gdefchar^^d9{\ringaccent U}
10191 \gdefchar^^da{\'U}
10192 \gdefchar^^db{\H U}
10193 \gdefchar^^dc{\"U}
10194 \gdefchar^^dd{\'Y}
10195 \gdefchar^^de{\cedilla T}
10196 \gdefchar^^df{\ss}
10197 %
10198 \gdefchar^^e0{\'r}
10199 \gdefchar^^e1{\'a}
10200 \gdefchar^^e2{\^a}
10201 \gdefchar^^e3{\u a}
10202 \gdefchar^^e4{\"a}
10203 \gdefchar^^e5{\'l}
10204 \gdefchar^^e6{\'c}
10205 \gdefchar^^e7{\cedilla c}
10206 \gdefchar^^e8{\v c}
10207 \gdefchar^^e9{\'e}
10208 \gdefchar^^ea{\ogonek{e}}
10209 \gdefchar^^eb{\"e}
10210 \gdefchar^^ec{\v e}
10211 \gdefchar^^ed{\'{\dotless{i}}}
10212 \gdefchar^^ee{\^{\dotless{i}}}
10213 \gdefchar^^ef{\v d}
10214 %
10215 \gdefchar^^f0{\dh}
10216 \gdefchar^^f1{\'n}
10217 \gdefchar^^f2{\v n}
10218 \gdefchar^^f3{\'o}
10219 \gdefchar^^f4{\^o}
10220 \gdefchar^^f5{\H o}
10221 \gdefchar^^f6{\"o}
10222 \gdefchar^^f7{$\div$}
10223 \gdefchar^^f8{\v r}
10224 \gdefchar^^f9{\ringaccent u}
10225 \gdefchar^^fa{\'u}
10226 \gdefchar^^fb{\H u}
10227 \gdefchar^^fc{\"u}
10228 \gdefchar^^fd{\'y}
10229 \gdefchar^^fe{\cedilla t}
10230 \gdefchar^^ff{\dotaccent{}}
10231 }
10232
10233 % UTF-8 character definitions.
10234 %
10235 % This code to support UTF-8 is based on LaTeX's utf8.def, with some
10236 % changes for Texinfo conventions. It is included here under the GPL by
10237 % permission from Frank Mittelbach and the LaTeX team.
10238 %
10239 \newcount\countUTFx
10240 \newcount\countUTFy
10241 \newcount\countUTFz
10242
10243 \gdef\UTFviiiTwoOctets#1#2{\expandafter
10244 \UTFviiiDefined\csname u8:#1\string #2\endcsname}
10245 %
10246 \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
10247 \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
10248 %
10249 \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
10250 \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
10251
10252 \gdef\UTFviiiDefined#1{%
10253 \ifx #1\relax
10254 \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10255 \else
10256 \expandafter #1%
10257 \fi
10258 }
10259
10260 % Give non-ASCII bytes the active definitions for processing UTF-8 sequences
10261 \begingroup
10262 \catcode`\~13
10263 \catcode`\$12
10264 \catcode`\"12
10265
10266 % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
10267 % substituting ~ and $ with a character token of that value.
10268 \def\UTFviiiLoop{%
10269 \global\catcode\countUTFx\active
10270 \uccode`\~\countUTFx
10271 \uccode`\$\countUTFx
10272 \uppercase\expandafter{\UTFviiiTmp}%
10273 \advance\countUTFx by 1
10274 \ifnum\countUTFx < \countUTFy
10275 \expandafter\UTFviiiLoop
10276 \fi}
10277
10278 % For bytes other than the first in a UTF-8 sequence. Not expected to
10279 % be expanded except when writing to auxiliary files.
10280 \countUTFx = "80
10281 \countUTFy = "C2
10282 \def\UTFviiiTmp{%
10283 \gdef~{%
10284 \ifpassthroughchars $\fi}}%
10285 \UTFviiiLoop
10286
10287 \countUTFx = "C2
10288 \countUTFy = "E0
10289 \def\UTFviiiTmp{%
10290 \gdef~{%
10291 \ifpassthroughchars $%
10292 \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
10293 \UTFviiiLoop
10294
10295 \countUTFx = "E0
10296 \countUTFy = "F0
10297 \def\UTFviiiTmp{%
10298 \gdef~{%
10299 \ifpassthroughchars $%
10300 \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
10301 \UTFviiiLoop
10302
10303 \countUTFx = "F0
10304 \countUTFy = "F4
10305 \def\UTFviiiTmp{%
10306 \gdef~{%
10307 \ifpassthroughchars $%
10308 \else\expandafter\UTFviiiFourOctets\expandafter$\fi
10309 }}%
10310 \UTFviiiLoop
10311 \endgroup
10312
10313 \def\globallet{\global\let} % save some \expandafter's below
10314
10315 % @U{xxxx} to produce U+xxxx, if we support it.
10316 \def\U#1{%
10317 \expandafter\ifx\csname uni:#1\endcsname \relax
10318 \iftxinativeunicodecapable
10319 % Any Unicode characters can be used by native Unicode.
10320 % However, if the font does not have the glyph, the letter will miss.
10321 \begingroup
10322 \uccode`\.="#1\relax
10323 \uppercase{.}
10324 \endgroup
10325 \else
10326 \errhelp = \EMsimple
10327 \errmessage{Unicode character U+#1 not supported, sorry}%
10328 \fi
10329 \else
10330 \csname uni:#1\endcsname
10331 \fi
10332 }
10333
10334 % These macros are used here to construct the name of a control
10335 % sequence to be defined.
10336 \def\UTFviiiTwoOctetsName#1#2{%
10337 \csname u8:#1\string #2\endcsname}%
10338 \def\UTFviiiThreeOctetsName#1#2#3{%
10339 \csname u8:#1\string #2\string #3\endcsname}%
10340 \def\UTFviiiFourOctetsName#1#2#3#4{%
10341 \csname u8:#1\string #2\string #3\string #4\endcsname}%
10342
10343 % For UTF-8 byte sequence (TeX, e-TeX and pdfTeX)
10344 % Definition macro to replace the Unicode character
10345 % Definition macro that is used by @U command
10346 %
10347 \begingroup
10348 \catcode`\"=12
10349 \catcode`\<=12
10350 \catcode`\.=12
10351 \catcode`\,=12
10352 \catcode`\;=12
10353 \catcode`\!=12
10354 \catcode`\~=13
10355 \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
10356 \countUTFz = "#1\relax
10357 \begingroup
10358 \parseXMLCharref
10359
10360 % Give \u8:... its definition. The sequence of seven \expandafter's
10361 % expands after the \gdef three times, e.g.
10362 %
10363 % 1. \UTFviiTwoOctetsName B1 B2
10364 % 2. \csname u8:B1 \string B2 \endcsname
10365 % 3. \u8: B1 B2 (a single control sequence token)
10366 %
10367 \expandafter\expandafter
10368 \expandafter\expandafter
10369 \expandafter\expandafter
10370 \expandafter\gdef \UTFviiiTmp{#2}%
10371 %
10372 \expandafter\ifx\csname uni:#1\endcsname \relax \else
10373 \message{Internal error, already defined: #1}%
10374 \fi
10375 %
10376 % define an additional control sequence for this code point.
10377 \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
10378 \endgroup}
10379 %
10380 % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp
10381 % to the corresponding UTF-8 sequence.
10382 \gdef\parseXMLCharref{%
10383 \ifnum\countUTFz < "A0\relax
10384 \errhelp = \EMsimple
10385 \errmessage{Cannot define Unicode char value < 00A0}%
10386 \else\ifnum\countUTFz < "800\relax
10387 \parseUTFviiiA,%
10388 \parseUTFviiiB C\UTFviiiTwoOctetsName.,%
10389 \else\ifnum\countUTFz < "10000\relax
10390 \parseUTFviiiA;%
10391 \parseUTFviiiA,%
10392 \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}%
10393 \else
10394 \parseUTFviiiA;%
10395 \parseUTFviiiA,%
10396 \parseUTFviiiA!%
10397 \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}%
10398 \fi\fi\fi
10399 }
10400
10401 % Extract a byte from the end of the UTF-8 representation of \countUTFx.
10402 % It must be a non-initial byte in the sequence.
10403 % Change \uccode of #1 for it to be used in \parseUTFviiiB as one
10404 % of the bytes.
10405 \gdef\parseUTFviiiA#1{%
10406 \countUTFx = \countUTFz
10407 \divide\countUTFz by 64
10408 \countUTFy = \countUTFz % Save to be the future value of \countUTFz.
10409 \multiply\countUTFz by 64
10410
10411 % \countUTFz is now \countUTFx with the last 5 bits cleared. Subtract
10412 % in order to get the last five bits.
10413 \advance\countUTFx by -\countUTFz
10414
10415 % Convert this to the byte in the UTF-8 sequence.
10416 \advance\countUTFx by 128
10417 \uccode `#1\countUTFx
10418 \countUTFz = \countUTFy}
10419
10420 % Used to put a UTF-8 byte sequence into \UTFviiiTmp
10421 % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8
10422 % sequence.
10423 % #2 is one of the \UTFviii*OctetsName macros.
10424 % #3 is always a full stop (.)
10425 % #4 is a template for the other bytes in the sequence. The values for these
10426 % bytes is substituted in here with \uppercase using the \uccode's.
10427 \gdef\parseUTFviiiB#1#2#3#4{%
10428 \advance\countUTFz by "#10\relax
10429 \uccode `#3\countUTFz
10430 \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10431 \endgroup
10432
10433 % For native Unicode (XeTeX and LuaTeX)
10434 % Definition macro that is set catcode other non global
10435 %
10436 \def\DeclareUnicodeCharacterNativeOther#1#2{%
10437 \catcode"#1=\other
10438 }
10439
10440 % https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10441 % U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10442 % U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10443 % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10444 % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10445 %
10446 % Many of our renditions are less than wonderful, and all the missing
10447 % characters are available somewhere. Loading the necessary fonts
10448 % awaits user request. We can't truly support Unicode without
10449 % reimplementing everything that's been done in LaTeX for many years,
10450 % plus probably using luatex or xetex, and who knows what else.
10451 % We won't be doing that here in this simple file. But we can try to at
10452 % least make most of the characters not bomb out.
10453 %
10454 \def\unicodechardefs{%
10455 \DeclareUnicodeCharacter{00A0}{\tie}%
10456 \DeclareUnicodeCharacter{00A1}{\exclamdown}%
10457 \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
10458 \DeclareUnicodeCharacter{00A3}{\pounds}%
10459 \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10460 \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10461 \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
10462 \DeclareUnicodeCharacter{00A7}{\S}%
10463 \DeclareUnicodeCharacter{00A8}{\"{ }}%
10464 \DeclareUnicodeCharacter{00A9}{\copyright}%
10465 \DeclareUnicodeCharacter{00AA}{\ordf}%
10466 \DeclareUnicodeCharacter{00AB}{\guillemetleft}%
10467 \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10468 \DeclareUnicodeCharacter{00AD}{\-}%
10469 \DeclareUnicodeCharacter{00AE}{\registeredsymbol}%
10470 \DeclareUnicodeCharacter{00AF}{\={ }}%
10471 %
10472 \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
10473 \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10474 \DeclareUnicodeCharacter{00B2}{$^2$}%
10475 \DeclareUnicodeCharacter{00B3}{$^3$}%
10476 \DeclareUnicodeCharacter{00B4}{\'{ }}%
10477 \DeclareUnicodeCharacter{00B5}{$\mu$}%
10478 \DeclareUnicodeCharacter{00B6}{\P}%
10479 \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10480 \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10481 \DeclareUnicodeCharacter{00B9}{$^1$}%
10482 \DeclareUnicodeCharacter{00BA}{\ordm}%
10483 \DeclareUnicodeCharacter{00BB}{\guillemetright}%
10484 \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10485 \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10486 \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10487 \DeclareUnicodeCharacter{00BF}{\questiondown}%
10488 %
10489 \DeclareUnicodeCharacter{00C0}{\`A}%
10490 \DeclareUnicodeCharacter{00C1}{\'A}%
10491 \DeclareUnicodeCharacter{00C2}{\^A}%
10492 \DeclareUnicodeCharacter{00C3}{\~A}%
10493 \DeclareUnicodeCharacter{00C4}{\"A}%
10494 \DeclareUnicodeCharacter{00C5}{\AA}%
10495 \DeclareUnicodeCharacter{00C6}{\AE}%
10496 \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10497 \DeclareUnicodeCharacter{00C8}{\`E}%
10498 \DeclareUnicodeCharacter{00C9}{\'E}%
10499 \DeclareUnicodeCharacter{00CA}{\^E}%
10500 \DeclareUnicodeCharacter{00CB}{\"E}%
10501 \DeclareUnicodeCharacter{00CC}{\`I}%
10502 \DeclareUnicodeCharacter{00CD}{\'I}%
10503 \DeclareUnicodeCharacter{00CE}{\^I}%
10504 \DeclareUnicodeCharacter{00CF}{\"I}%
10505 %
10506 \DeclareUnicodeCharacter{00D0}{\DH}%
10507 \DeclareUnicodeCharacter{00D1}{\~N}%
10508 \DeclareUnicodeCharacter{00D2}{\`O}%
10509 \DeclareUnicodeCharacter{00D3}{\'O}%
10510 \DeclareUnicodeCharacter{00D4}{\^O}%
10511 \DeclareUnicodeCharacter{00D5}{\~O}%
10512 \DeclareUnicodeCharacter{00D6}{\"O}%
10513 \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10514 \DeclareUnicodeCharacter{00D8}{\O}%
10515 \DeclareUnicodeCharacter{00D9}{\`U}%
10516 \DeclareUnicodeCharacter{00DA}{\'U}%
10517 \DeclareUnicodeCharacter{00DB}{\^U}%
10518 \DeclareUnicodeCharacter{00DC}{\"U}%
10519 \DeclareUnicodeCharacter{00DD}{\'Y}%
10520 \DeclareUnicodeCharacter{00DE}{\TH}%
10521 \DeclareUnicodeCharacter{00DF}{\ss}%
10522 %
10523 \DeclareUnicodeCharacter{00E0}{\`a}%
10524 \DeclareUnicodeCharacter{00E1}{\'a}%
10525 \DeclareUnicodeCharacter{00E2}{\^a}%
10526 \DeclareUnicodeCharacter{00E3}{\~a}%
10527 \DeclareUnicodeCharacter{00E4}{\"a}%
10528 \DeclareUnicodeCharacter{00E5}{\aa}%
10529 \DeclareUnicodeCharacter{00E6}{\ae}%
10530 \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10531 \DeclareUnicodeCharacter{00E8}{\`e}%
10532 \DeclareUnicodeCharacter{00E9}{\'e}%
10533 \DeclareUnicodeCharacter{00EA}{\^e}%
10534 \DeclareUnicodeCharacter{00EB}{\"e}%
10535 \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10536 \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10537 \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10538 \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10539 %
10540 \DeclareUnicodeCharacter{00F0}{\dh}%
10541 \DeclareUnicodeCharacter{00F1}{\~n}%
10542 \DeclareUnicodeCharacter{00F2}{\`o}%
10543 \DeclareUnicodeCharacter{00F3}{\'o}%
10544 \DeclareUnicodeCharacter{00F4}{\^o}%
10545 \DeclareUnicodeCharacter{00F5}{\~o}%
10546 \DeclareUnicodeCharacter{00F6}{\"o}%
10547 \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10548 \DeclareUnicodeCharacter{00F8}{\o}%
10549 \DeclareUnicodeCharacter{00F9}{\`u}%
10550 \DeclareUnicodeCharacter{00FA}{\'u}%
10551 \DeclareUnicodeCharacter{00FB}{\^u}%
10552 \DeclareUnicodeCharacter{00FC}{\"u}%
10553 \DeclareUnicodeCharacter{00FD}{\'y}%
10554 \DeclareUnicodeCharacter{00FE}{\th}%
10555 \DeclareUnicodeCharacter{00FF}{\"y}%
10556 %
10557 \DeclareUnicodeCharacter{0100}{\=A}%
10558 \DeclareUnicodeCharacter{0101}{\=a}%
10559 \DeclareUnicodeCharacter{0102}{\u{A}}%
10560 \DeclareUnicodeCharacter{0103}{\u{a}}%
10561 \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10562 \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10563 \DeclareUnicodeCharacter{0106}{\'C}%
10564 \DeclareUnicodeCharacter{0107}{\'c}%
10565 \DeclareUnicodeCharacter{0108}{\^C}%
10566 \DeclareUnicodeCharacter{0109}{\^c}%
10567 \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10568 \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10569 \DeclareUnicodeCharacter{010C}{\v{C}}%
10570 \DeclareUnicodeCharacter{010D}{\v{c}}%
10571 \DeclareUnicodeCharacter{010E}{\v{D}}%
10572 \DeclareUnicodeCharacter{010F}{d'}%
10573 %
10574 \DeclareUnicodeCharacter{0110}{\DH}%
10575 \DeclareUnicodeCharacter{0111}{\dh}%
10576 \DeclareUnicodeCharacter{0112}{\=E}%
10577 \DeclareUnicodeCharacter{0113}{\=e}%
10578 \DeclareUnicodeCharacter{0114}{\u{E}}%
10579 \DeclareUnicodeCharacter{0115}{\u{e}}%
10580 \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10581 \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10582 \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10583 \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10584 \DeclareUnicodeCharacter{011A}{\v{E}}%
10585 \DeclareUnicodeCharacter{011B}{\v{e}}%
10586 \DeclareUnicodeCharacter{011C}{\^G}%
10587 \DeclareUnicodeCharacter{011D}{\^g}%
10588 \DeclareUnicodeCharacter{011E}{\u{G}}%
10589 \DeclareUnicodeCharacter{011F}{\u{g}}%
10590 %
10591 \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10592 \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10593 \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10594 \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10595 \DeclareUnicodeCharacter{0124}{\^H}%
10596 \DeclareUnicodeCharacter{0125}{\^h}%
10597 \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10598 \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10599 \DeclareUnicodeCharacter{0128}{\~I}%
10600 \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10601 \DeclareUnicodeCharacter{012A}{\=I}%
10602 \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10603 \DeclareUnicodeCharacter{012C}{\u{I}}%
10604 \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10605 \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10606 \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10607 %
10608 \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10609 \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10610 \DeclareUnicodeCharacter{0132}{IJ}%
10611 \DeclareUnicodeCharacter{0133}{ij}%
10612 \DeclareUnicodeCharacter{0134}{\^J}%
10613 \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10614 \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10615 \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10616 \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10617 \DeclareUnicodeCharacter{0139}{\'L}%
10618 \DeclareUnicodeCharacter{013A}{\'l}%
10619 \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10620 \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
10621 \DeclareUnicodeCharacter{013D}{L'}% should kern
10622 \DeclareUnicodeCharacter{013E}{l'}% should kern
10623 \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10624 %
10625 \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10626 \DeclareUnicodeCharacter{0141}{\L}%
10627 \DeclareUnicodeCharacter{0142}{\l}%
10628 \DeclareUnicodeCharacter{0143}{\'N}%
10629 \DeclareUnicodeCharacter{0144}{\'n}%
10630 \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10631 \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10632 \DeclareUnicodeCharacter{0147}{\v{N}}%
10633 \DeclareUnicodeCharacter{0148}{\v{n}}%
10634 \DeclareUnicodeCharacter{0149}{'n}%
10635 \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10636 \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10637 \DeclareUnicodeCharacter{014C}{\=O}%
10638 \DeclareUnicodeCharacter{014D}{\=o}%
10639 \DeclareUnicodeCharacter{014E}{\u{O}}%
10640 \DeclareUnicodeCharacter{014F}{\u{o}}%
10641 %
10642 \DeclareUnicodeCharacter{0150}{\H{O}}%
10643 \DeclareUnicodeCharacter{0151}{\H{o}}%
10644 \DeclareUnicodeCharacter{0152}{\OE}%
10645 \DeclareUnicodeCharacter{0153}{\oe}%
10646 \DeclareUnicodeCharacter{0154}{\'R}%
10647 \DeclareUnicodeCharacter{0155}{\'r}%
10648 \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10649 \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10650 \DeclareUnicodeCharacter{0158}{\v{R}}%
10651 \DeclareUnicodeCharacter{0159}{\v{r}}%
10652 \DeclareUnicodeCharacter{015A}{\'S}%
10653 \DeclareUnicodeCharacter{015B}{\'s}%
10654 \DeclareUnicodeCharacter{015C}{\^S}%
10655 \DeclareUnicodeCharacter{015D}{\^s}%
10656 \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10657 \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10658 %
10659 \DeclareUnicodeCharacter{0160}{\v{S}}%
10660 \DeclareUnicodeCharacter{0161}{\v{s}}%
10661 \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10662 \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10663 \DeclareUnicodeCharacter{0164}{\v{T}}%
10664 \DeclareUnicodeCharacter{0165}{\v{t}}%
10665 \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10666 \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10667 \DeclareUnicodeCharacter{0168}{\~U}%
10668 \DeclareUnicodeCharacter{0169}{\~u}%
10669 \DeclareUnicodeCharacter{016A}{\=U}%
10670 \DeclareUnicodeCharacter{016B}{\=u}%
10671 \DeclareUnicodeCharacter{016C}{\u{U}}%
10672 \DeclareUnicodeCharacter{016D}{\u{u}}%
10673 \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10674 \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10675 %
10676 \DeclareUnicodeCharacter{0170}{\H{U}}%
10677 \DeclareUnicodeCharacter{0171}{\H{u}}%
10678 \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10679 \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10680 \DeclareUnicodeCharacter{0174}{\^W}%
10681 \DeclareUnicodeCharacter{0175}{\^w}%
10682 \DeclareUnicodeCharacter{0176}{\^Y}%
10683 \DeclareUnicodeCharacter{0177}{\^y}%
10684 \DeclareUnicodeCharacter{0178}{\"Y}%
10685 \DeclareUnicodeCharacter{0179}{\'Z}%
10686 \DeclareUnicodeCharacter{017A}{\'z}%
10687 \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10688 \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10689 \DeclareUnicodeCharacter{017D}{\v{Z}}%
10690 \DeclareUnicodeCharacter{017E}{\v{z}}%
10691 \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10692 %
10693 \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10694 \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10695 \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10696 \DeclareUnicodeCharacter{01C7}{LJ}%
10697 \DeclareUnicodeCharacter{01C8}{Lj}%
10698 \DeclareUnicodeCharacter{01C9}{lj}%
10699 \DeclareUnicodeCharacter{01CA}{NJ}%
10700 \DeclareUnicodeCharacter{01CB}{Nj}%
10701 \DeclareUnicodeCharacter{01CC}{nj}%
10702 \DeclareUnicodeCharacter{01CD}{\v{A}}%
10703 \DeclareUnicodeCharacter{01CE}{\v{a}}%
10704 \DeclareUnicodeCharacter{01CF}{\v{I}}%
10705 %
10706 \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10707 \DeclareUnicodeCharacter{01D1}{\v{O}}%
10708 \DeclareUnicodeCharacter{01D2}{\v{o}}%
10709 \DeclareUnicodeCharacter{01D3}{\v{U}}%
10710 \DeclareUnicodeCharacter{01D4}{\v{u}}%
10711 %
10712 \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10713 \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10714 \DeclareUnicodeCharacter{01E6}{\v{G}}%
10715 \DeclareUnicodeCharacter{01E7}{\v{g}}%
10716 \DeclareUnicodeCharacter{01E8}{\v{K}}%
10717 \DeclareUnicodeCharacter{01E9}{\v{k}}%
10718 %
10719 \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10720 \DeclareUnicodeCharacter{01F1}{DZ}%
10721 \DeclareUnicodeCharacter{01F2}{Dz}%
10722 \DeclareUnicodeCharacter{01F3}{dz}%
10723 \DeclareUnicodeCharacter{01F4}{\'G}%
10724 \DeclareUnicodeCharacter{01F5}{\'g}%
10725 \DeclareUnicodeCharacter{01F8}{\`N}%
10726 \DeclareUnicodeCharacter{01F9}{\`n}%
10727 \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10728 \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10729 \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10730 \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10731 %
10732 \DeclareUnicodeCharacter{021E}{\v{H}}%
10733 \DeclareUnicodeCharacter{021F}{\v{h}}%
10734 %
10735 \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10736 \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10737 \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10738 \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10739 \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10740 \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10741 %
10742 \DeclareUnicodeCharacter{0232}{\=Y}%
10743 \DeclareUnicodeCharacter{0233}{\=y}%
10744 \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10745 %
10746 \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10747 %
10748 % Greek letters upper case
10749 \DeclareUnicodeCharacter{0391}{{\it A}}%
10750 \DeclareUnicodeCharacter{0392}{{\it B}}%
10751 \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10752 \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10753 \DeclareUnicodeCharacter{0395}{{\it E}}%
10754 \DeclareUnicodeCharacter{0396}{{\it Z}}%
10755 \DeclareUnicodeCharacter{0397}{{\it H}}%
10756 \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10757 \DeclareUnicodeCharacter{0399}{{\it I}}%
10758 \DeclareUnicodeCharacter{039A}{{\it K}}%
10759 \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10760 \DeclareUnicodeCharacter{039C}{{\it M}}%
10761 \DeclareUnicodeCharacter{039D}{{\it N}}%
10762 \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10763 \DeclareUnicodeCharacter{039F}{{\it O}}%
10764 \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10765 \DeclareUnicodeCharacter{03A1}{{\it P}}%
10766 %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
10767 \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10768 \DeclareUnicodeCharacter{03A4}{{\it T}}%
10769 \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10770 \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10771 \DeclareUnicodeCharacter{03A7}{{\it X}}%
10772 \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10773 \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10774 %
10775 % Vowels with accents
10776 \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10777 \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10778 \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10779 \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10780 \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10781 \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10782 %
10783 % Standalone accent
10784 \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10785 %
10786 % Greek letters lower case
10787 \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10788 \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10789 \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10790 \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10791 \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10792 \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10793 \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10794 \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10795 \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10796 \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10797 \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10798 \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10799 \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10800 \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10801 \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10802 \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10803 \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10804 \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10805 \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10806 \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10807 \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10808 \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10809 \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10810 \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10811 \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10812 %
10813 % More Greek vowels with accents
10814 \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10815 \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10816 \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10817 \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10818 \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10819 %
10820 % Variant Greek letters
10821 \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10822 \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10823 \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10824 %
10825 \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10826 \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10827 \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10828 \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10829 \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10830 \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10831 \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10832 \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10833 \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10834 \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10835 \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10836 \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10837 %
10838 \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10839 \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10840 %
10841 \DeclareUnicodeCharacter{1E20}{\=G}%
10842 \DeclareUnicodeCharacter{1E21}{\=g}%
10843 \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10844 \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10845 \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10846 \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10847 \DeclareUnicodeCharacter{1E26}{\"H}%
10848 \DeclareUnicodeCharacter{1E27}{\"h}%
10849 %
10850 \DeclareUnicodeCharacter{1E30}{\'K}%
10851 \DeclareUnicodeCharacter{1E31}{\'k}%
10852 \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10853 \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10854 \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10855 \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10856 \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10857 \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10858 \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10859 \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10860 \DeclareUnicodeCharacter{1E3E}{\'M}%
10861 \DeclareUnicodeCharacter{1E3F}{\'m}%
10862 %
10863 \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10864 \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10865 \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10866 \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10867 \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10868 \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10869 \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10870 \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10871 \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10872 \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10873 %
10874 \DeclareUnicodeCharacter{1E54}{\'P}%
10875 \DeclareUnicodeCharacter{1E55}{\'p}%
10876 \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10877 \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10878 \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10879 \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10880 \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10881 \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10882 \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10883 \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10884 %
10885 \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10886 \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10887 \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10888 \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10889 \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10890 \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10891 \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10892 \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10893 \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10894 \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10895 %
10896 \DeclareUnicodeCharacter{1E7C}{\~V}%
10897 \DeclareUnicodeCharacter{1E7D}{\~v}%
10898 \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10899 \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10900 %
10901 \DeclareUnicodeCharacter{1E80}{\`W}%
10902 \DeclareUnicodeCharacter{1E81}{\`w}%
10903 \DeclareUnicodeCharacter{1E82}{\'W}%
10904 \DeclareUnicodeCharacter{1E83}{\'w}%
10905 \DeclareUnicodeCharacter{1E84}{\"W}%
10906 \DeclareUnicodeCharacter{1E85}{\"w}%
10907 \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10908 \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10909 \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10910 \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10911 \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10912 \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10913 \DeclareUnicodeCharacter{1E8C}{\"X}%
10914 \DeclareUnicodeCharacter{1E8D}{\"x}%
10915 \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10916 \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10917 %
10918 \DeclareUnicodeCharacter{1E90}{\^Z}%
10919 \DeclareUnicodeCharacter{1E91}{\^z}%
10920 \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
10921 \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
10922 \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
10923 \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
10924 \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
10925 \DeclareUnicodeCharacter{1E97}{\"t}%
10926 \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
10927 \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
10928 %
10929 \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
10930 \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
10931 %
10932 \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
10933 \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
10934 \DeclareUnicodeCharacter{1EBC}{\~E}%
10935 \DeclareUnicodeCharacter{1EBD}{\~e}%
10936 %
10937 \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
10938 \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
10939 \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
10940 \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
10941 %
10942 \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
10943 \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
10944 %
10945 \DeclareUnicodeCharacter{1EF2}{\`Y}%
10946 \DeclareUnicodeCharacter{1EF3}{\`y}%
10947 \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
10948 %
10949 \DeclareUnicodeCharacter{1EF8}{\~Y}%
10950 \DeclareUnicodeCharacter{1EF9}{\~y}%
10951 %
10952 % Punctuation
10953 \DeclareUnicodeCharacter{2013}{--}%
10954 \DeclareUnicodeCharacter{2014}{---}%
10955 \DeclareUnicodeCharacter{2018}{\quoteleft}%
10956 \DeclareUnicodeCharacter{2019}{\quoteright}%
10957 \DeclareUnicodeCharacter{201A}{\quotesinglbase}%
10958 \DeclareUnicodeCharacter{201C}{\quotedblleft}%
10959 \DeclareUnicodeCharacter{201D}{\quotedblright}%
10960 \DeclareUnicodeCharacter{201E}{\quotedblbase}%
10961 \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}%
10962 \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}%
10963 \DeclareUnicodeCharacter{2022}{\bullet}%
10964 \DeclareUnicodeCharacter{202F}{\thinspace}%
10965 \DeclareUnicodeCharacter{2026}{\dots}%
10966 \DeclareUnicodeCharacter{2039}{\guilsinglleft}%
10967 \DeclareUnicodeCharacter{203A}{\guilsinglright}%
10968 %
10969 \DeclareUnicodeCharacter{20AC}{\euro}%
10970 %
10971 \DeclareUnicodeCharacter{2192}{\expansion}%
10972 \DeclareUnicodeCharacter{21D2}{\result}%
10973 %
10974 % Mathematical symbols
10975 \DeclareUnicodeCharacter{2200}{\ensuremath\forall}%
10976 \DeclareUnicodeCharacter{2203}{\ensuremath\exists}%
10977 \DeclareUnicodeCharacter{2208}{\ensuremath\in}%
10978 \DeclareUnicodeCharacter{2212}{\minus}%
10979 \DeclareUnicodeCharacter{2217}{\ast}%
10980 \DeclareUnicodeCharacter{221E}{\ensuremath\infty}%
10981 \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}%
10982 \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}%
10983 \DeclareUnicodeCharacter{2229}{\ensuremath\cap}%
10984 \DeclareUnicodeCharacter{2261}{\equiv}%
10985 \DeclareUnicodeCharacter{2264}{\ensuremath\leq}%
10986 \DeclareUnicodeCharacter{2265}{\ensuremath\geq}%
10987 \DeclareUnicodeCharacter{2282}{\ensuremath\subset}%
10988 \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}%
10989 %
10990 \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}%
10991 \DeclareUnicodeCharacter{2032}{\ensuremath\prime}%
10992 \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}%
10993 \DeclareUnicodeCharacter{2111}{\ensuremath\Im}%
10994 \DeclareUnicodeCharacter{2113}{\ensuremath\ell}%
10995 \DeclareUnicodeCharacter{2118}{\ensuremath\wp}%
10996 \DeclareUnicodeCharacter{211C}{\ensuremath\Re}%
10997 \DeclareUnicodeCharacter{2127}{\ensuremath\mho}%
10998 \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}%
10999 \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}%
11000 \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}%
11001 \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}%
11002 \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}%
11003 \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}%
11004 \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}%
11005 \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}%
11006 \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}%
11007 \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}%
11008 \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}%
11009 \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}%
11010 \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}%
11011 \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}%
11012 \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}%
11013 \DeclareUnicodeCharacter{21BE}{\ensuremath\upharpoonright}%
11014 \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}%
11015 \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}%
11016 \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}%
11017 \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}%
11018 \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}%
11019 \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}%
11020 \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}%
11021 \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}%
11022 \DeclareUnicodeCharacter{21DD}{\ensuremath\leadsto}%
11023 \DeclareUnicodeCharacter{2201}{\ensuremath\complement}%
11024 \DeclareUnicodeCharacter{2202}{\ensuremath\partial}%
11025 \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}%
11026 \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}%
11027 \DeclareUnicodeCharacter{2209}{\ensuremath\notin}%
11028 \DeclareUnicodeCharacter{220B}{\ensuremath\owns}%
11029 \DeclareUnicodeCharacter{220F}{\ensuremath\prod}%
11030 \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}%
11031 \DeclareUnicodeCharacter{2211}{\ensuremath\sum}%
11032 \DeclareUnicodeCharacter{2213}{\ensuremath\mp}%
11033 \DeclareUnicodeCharacter{2218}{\ensuremath\circ}%
11034 \DeclareUnicodeCharacter{221A}{\ensuremath\surd}%
11035 \DeclareUnicodeCharacter{221D}{\ensuremath\propto}%
11036 \DeclareUnicodeCharacter{2220}{\ensuremath\angle}%
11037 \DeclareUnicodeCharacter{2223}{\ensuremath\mid}%
11038 \DeclareUnicodeCharacter{2228}{\ensuremath\vee}%
11039 \DeclareUnicodeCharacter{222A}{\ensuremath\cup}%
11040 \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}%
11041 \DeclareUnicodeCharacter{222E}{\ensuremath\oint}%
11042 \DeclareUnicodeCharacter{223C}{\ensuremath\sim}%
11043 \DeclareUnicodeCharacter{2240}{\ensuremath\wr}%
11044 \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}%
11045 \DeclareUnicodeCharacter{2245}{\ensuremath\cong}%
11046 \DeclareUnicodeCharacter{2248}{\ensuremath\approx}%
11047 \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}%
11048 \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}%
11049 \DeclareUnicodeCharacter{2260}{\ensuremath\neq}%
11050 \DeclareUnicodeCharacter{226A}{\ensuremath\ll}%
11051 \DeclareUnicodeCharacter{226B}{\ensuremath\gg}%
11052 \DeclareUnicodeCharacter{227A}{\ensuremath\prec}%
11053 \DeclareUnicodeCharacter{227B}{\ensuremath\succ}%
11054 \DeclareUnicodeCharacter{2283}{\ensuremath\supset}%
11055 \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}%
11056 \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}%
11057 \DeclareUnicodeCharacter{228F}{\ensuremath\sqsubset}%
11058 \DeclareUnicodeCharacter{2290}{\ensuremath\sqsupset}%
11059 \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}%
11060 \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}%
11061 \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}%
11062 \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}%
11063 \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}%
11064 \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}%
11065 \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}%
11066 \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}%
11067 \DeclareUnicodeCharacter{2299}{\ensuremath\odot}%
11068 \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}%
11069 \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}%
11070 \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}%
11071 \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}%
11072 \DeclareUnicodeCharacter{22A8}{\ensuremath\models}%
11073 \DeclareUnicodeCharacter{22B4}{\ensuremath\unlhd}%
11074 \DeclareUnicodeCharacter{22B5}{\ensuremath\unrhd}%
11075 \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}%
11076 \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}%
11077 \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}%
11078 \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}%
11079 \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}%
11080 \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}%
11081 \DeclareUnicodeCharacter{22C6}{\ensuremath\star}%
11082 \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}%
11083 \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}%
11084 \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}%
11085 \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}%
11086 \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}%
11087 \DeclareUnicodeCharacter{2322}{\ensuremath\frown}%
11088 \DeclareUnicodeCharacter{2323}{\ensuremath\smile}%
11089 %
11090 \DeclareUnicodeCharacter{25A1}{\ensuremath\Box}%
11091 \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
11092 \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
11093 \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
11094 \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
11095 \DeclareUnicodeCharacter{25C7}{\ensuremath\Diamond}%
11096 \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}%
11097 \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}%
11098 \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}%
11099 \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}%
11100 \DeclareUnicodeCharacter{266D}{\ensuremath\flat}%
11101 \DeclareUnicodeCharacter{266E}{\ensuremath\natural}%
11102 \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}%
11103 \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}%
11104 \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}%
11105 \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}%
11106 \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}%
11107 \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}%
11108 \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}%
11109 \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}%
11110 \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}%
11111 \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}%
11112 \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}%
11113 \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}%
11114 \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}%
11115 \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}%
11116 \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}%
11117 \DeclareUnicodeCharacter{2A1D}{\ensuremath\Join}%
11118 \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}%
11119 \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}%
11120 \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}%
11121 %
11122 \global\mathchardef\checkmark="1370% actually the square root sign
11123 \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}%
11124 }% end of \unicodechardefs
11125
11126 % UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
11127 % It makes the setting that replace UTF-8 byte sequence.
11128 \def\utfeightchardefs{%
11129 \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
11130 \unicodechardefs
11131 }
11132
11133 % Whether the active definitions of non-ASCII characters expand to
11134 % non-active tokens with the same character code. This is used to
11135 % write characters literally, instead of using active definitions for
11136 % printing the correct glyphs.
11137 \newif\ifpassthroughchars
11138 \passthroughcharsfalse
11139
11140 % For native Unicode (XeTeX and LuaTeX)
11141 % Definition macro to replace / pass-through the Unicode character
11142 %
11143 \def\DeclareUnicodeCharacterNative#1#2{%
11144 \catcode"#1=\active
11145 \def\dodeclareunicodecharacternative##1##2##3{%
11146 \begingroup
11147 \uccode`\~="##2\relax
11148 \uppercase{\gdef~}{%
11149 \ifpassthroughchars
11150 ##1%
11151 \else
11152 ##3%
11153 \fi
11154 }
11155 \endgroup
11156 }
11157 \begingroup
11158 \uccode`\.="#1\relax
11159 \uppercase{\def\UTFNativeTmp{.}}%
11160 \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
11161 \endgroup
11162 }
11163
11164 % Native Unicode (XeTeX and LuaTeX) character replacing definitions
11165 % It makes the setting that replace the Unicode characters.
11166 \def\nativeunicodechardefs{%
11167 \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
11168 \unicodechardefs
11169 }
11170
11171 % For native Unicode (XeTeX and LuaTeX). Make the character token expand
11172 % to the sequences given in \unicodechardefs for printing.
11173 \def\DeclareUnicodeCharacterNativeAtU#1#2{%
11174 \def\UTFAtUTmp{#2}
11175 \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
11176 }
11177
11178 % Native Unicode (XeTeX and LuaTeX) @U command definitions
11179 \def\nativeunicodechardefsatu{%
11180 \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
11181 \unicodechardefs
11182 }
11183
11184 % US-ASCII character definitions.
11185 \def\asciichardefs{% nothing need be done
11186 \relax
11187 }
11188
11189 % define all the unicode characters we know about, for the sake of @U.
11190 \iftxinativeunicodecapable
11191 \nativeunicodechardefsatu
11192 \else
11193 \utfeightchardefs
11194 \fi
11195
11196
11197 % Make non-ASCII characters printable again for compatibility with
11198 % existing Texinfo documents that may use them, even without declaring a
11199 % document encoding.
11200 %
11201 \setnonasciicharscatcode \other
11202
11203
11204 \message{formatting,}
11205
11206 \newdimen\defaultparindent \defaultparindent = 15pt
11207
11208 \chapheadingskip = 15pt plus 4pt minus 2pt
11209 \secheadingskip = 12pt plus 3pt minus 2pt
11210 \subsecheadingskip = 9pt plus 2pt minus 2pt
11211
11212 % Prevent underfull vbox error messages.
11213 \vbadness = 10000
11214
11215 % Don't be very finicky about underfull hboxes, either.
11216 \hbadness = 6666
11217
11218 % Following George Bush, get rid of widows and orphans.
11219 \widowpenalty=10000
11220 \clubpenalty=10000
11221
11222 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
11223 % using an old version of TeX, don't do anything. We want the amount of
11224 % stretch added to depend on the line length, hence the dependence on
11225 % \hsize. We call this whenever the paper size is set.
11226 %
11227 \def\setemergencystretch{%
11228 \ifx\emergencystretch\thisisundefined
11229 % Allow us to assign to \emergencystretch anyway.
11230 \def\emergencystretch{\dimen0}%
11231 \else
11232 \emergencystretch = .15\hsize
11233 \fi
11234 }
11235
11236 % Parameters in order: 1) textheight; 2) textwidth;
11237 % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11238 % 7) physical page height; 8) physical page width.
11239 %
11240 % We also call \setleading{\textleading}, so the caller should define
11241 % \textleading. The caller should also set \parskip.
11242 %
11243 \def\internalpagesizes#1#2#3#4#5#6#7#8{%
11244 \voffset = #3\relax
11245 \topskip = #6\relax
11246 \splittopskip = \topskip
11247 %
11248 \vsize = #1\relax
11249 \advance\vsize by \topskip
11250 \outervsize = \vsize
11251 \advance\outervsize by 2\topandbottommargin
11252 \txipageheight = \vsize
11253 %
11254 \hsize = #2\relax
11255 \outerhsize = \hsize
11256 \advance\outerhsize by 0.5in
11257 \txipagewidth = \hsize
11258 %
11259 \normaloffset = #4\relax
11260 \bindingoffset = #5\relax
11261 %
11262 \ifpdf
11263 \pdfpageheight #7\relax
11264 \pdfpagewidth #8\relax
11265 % if we don't reset these, they will remain at "1 true in" of
11266 % whatever layout pdftex was dumped with.
11267 \pdfhorigin = 1 true in
11268 \pdfvorigin = 1 true in
11269 \else
11270 \ifx\XeTeXrevision\thisisundefined
11271 \else
11272 \pdfpageheight #7\relax
11273 \pdfpagewidth #8\relax
11274 % XeTeX does not have \pdfhorigin and \pdfvorigin.
11275 \fi
11276 \fi
11277 %
11278 \setleading{\textleading}
11279 %
11280 \parindent = \defaultparindent
11281 \setemergencystretch
11282 }
11283
11284 % @letterpaper (the default).
11285 \def\letterpaper{{\globaldefs = 1
11286 \parskip = 3pt plus 2pt minus 1pt
11287 \textleading = 13.2pt
11288 %
11289 % If page is nothing but text, make it come out even.
11290 \internalpagesizes{607.2pt}{6in}% that's 46 lines
11291 {\voffset}{.25in}%
11292 {\bindingoffset}{36pt}%
11293 {11in}{8.5in}%
11294 }}
11295
11296 % Use @smallbook to reset parameters for 7x9.25 trim size.
11297 \def\smallbook{{\globaldefs = 1
11298 \parskip = 2pt plus 1pt
11299 \textleading = 12pt
11300 %
11301 \internalpagesizes{7.5in}{5in}%
11302 {-.2in}{0in}%
11303 {\bindingoffset}{16pt}%
11304 {9.25in}{7in}%
11305 %
11306 \lispnarrowing = 0.3in
11307 \tolerance = 700
11308 \hfuzz = 1pt
11309 \contentsrightmargin = 0pt
11310 \defbodyindent = .5cm
11311 }}
11312
11313 % Use @smallerbook to reset parameters for 6x9 trim size.
11314 % (Just testing, parameters still in flux.)
11315 \def\smallerbook{{\globaldefs = 1
11316 \parskip = 1.5pt plus 1pt
11317 \textleading = 12pt
11318 %
11319 \internalpagesizes{7.4in}{4.8in}%
11320 {-.2in}{-.4in}%
11321 {0pt}{14pt}%
11322 {9in}{6in}%
11323 %
11324 \lispnarrowing = 0.25in
11325 \tolerance = 700
11326 \hfuzz = 1pt
11327 \contentsrightmargin = 0pt
11328 \defbodyindent = .4cm
11329 }}
11330
11331 % Use @afourpaper to print on European A4 paper.
11332 \def\afourpaper{{\globaldefs = 1
11333 \parskip = 3pt plus 2pt minus 1pt
11334 \textleading = 13.2pt
11335 %
11336 % Double-side printing via postscript on Laserjet 4050
11337 % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11338 % To change the settings for a different printer or situation, adjust
11339 % \normaloffset until the front-side and back-side texts align. Then
11340 % do the same for \bindingoffset. You can set these for testing in
11341 % your texinfo source file like this:
11342 % @tex
11343 % \global\normaloffset = -6mm
11344 % \global\bindingoffset = 10mm
11345 % @end tex
11346 \internalpagesizes{673.2pt}{160mm}% that's 51 lines
11347 {\voffset}{\hoffset}%
11348 {\bindingoffset}{44pt}%
11349 {297mm}{210mm}%
11350 %
11351 \tolerance = 700
11352 \hfuzz = 1pt
11353 \contentsrightmargin = 0pt
11354 \defbodyindent = 5mm
11355 }}
11356
11357 % Use @afivepaper to print on European A5 paper.
11358 % From romildo@urano.iceb.ufop.br, 2 July 2000.
11359 % He also recommends making @example and @lisp be small.
11360 \def\afivepaper{{\globaldefs = 1
11361 \parskip = 2pt plus 1pt minus 0.1pt
11362 \textleading = 12.5pt
11363 %
11364 \internalpagesizes{160mm}{120mm}%
11365 {\voffset}{\hoffset}%
11366 {\bindingoffset}{8pt}%
11367 {210mm}{148mm}%
11368 %
11369 \lispnarrowing = 0.2in
11370 \tolerance = 800
11371 \hfuzz = 1.2pt
11372 \contentsrightmargin = 0pt
11373 \defbodyindent = 2mm
11374 \tableindent = 12mm
11375 }}
11376
11377 % A specific text layout, 24x15cm overall, intended for A4 paper.
11378 \def\afourlatex{{\globaldefs = 1
11379 \afourpaper
11380 \internalpagesizes{237mm}{150mm}%
11381 {\voffset}{4.6mm}%
11382 {\bindingoffset}{7mm}%
11383 {297mm}{210mm}%
11384 %
11385 % Must explicitly reset to 0 because we call \afourpaper.
11386 \globaldefs = 0
11387 }}
11388
11389 % Use @afourwide to print on A4 paper in landscape format.
11390 \def\afourwide{{\globaldefs = 1
11391 \afourpaper
11392 \internalpagesizes{241mm}{165mm}%
11393 {\voffset}{-2.95mm}%
11394 {\bindingoffset}{7mm}%
11395 {297mm}{210mm}%
11396 \globaldefs = 0
11397 }}
11398
11399 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11400 % Perhaps we should allow setting the margins, \topskip, \parskip,
11401 % and/or leading, also. Or perhaps we should compute them somehow.
11402 %
11403 \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
11404 \def\pagesizesyyy#1,#2,#3\finish{{%
11405 \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11406 \globaldefs = 1
11407 %
11408 \parskip = 3pt plus 2pt minus 1pt
11409 \setleading{\textleading}%
11410 %
11411 \dimen0 = #1\relax
11412 \advance\dimen0 by \voffset
11413 %
11414 \dimen2 = \hsize
11415 \advance\dimen2 by \normaloffset
11416 %
11417 \internalpagesizes{#1}{\hsize}%
11418 {\voffset}{\normaloffset}%
11419 {\bindingoffset}{44pt}%
11420 {\dimen0}{\dimen2}%
11421 }}
11422
11423 % Set default to letter.
11424 %
11425 \letterpaper
11426
11427
11428 \message{and turning on texinfo input format.}
11429
11430 \def^^L{\par} % remove \outer, so ^L can appear in an @comment
11431
11432 % DEL is a comment character, in case @c does not suffice.
11433 \catcode`\^^? = 14
11434
11435 % Define macros to output various characters with catcode for normal text.
11436 \catcode`\"=\other \def\normaldoublequote{"}
11437 \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11438 \catcode`\+=\other \def\normalplus{+}
11439 \catcode`\<=\other \def\normalless{<}
11440 \catcode`\>=\other \def\normalgreater{>}
11441 \catcode`\^=\other \def\normalcaret{^}
11442 \catcode`\_=\other \def\normalunderscore{_}
11443 \catcode`\|=\other \def\normalverticalbar{|}
11444 \catcode`\~=\other \def\normaltilde{~}
11445
11446 % This macro is used to make a character print one way in \tt
11447 % (where it can probably be output as-is), and another way in other fonts,
11448 % where something hairier probably needs to be done.
11449 %
11450 % #1 is what to print if we are indeed using \tt; #2 is what to print
11451 % otherwise. Since all the Computer Modern typewriter fonts have zero
11452 % interword stretch (and shrink), and it is reasonable to expect all
11453 % typewriter fonts to have this, we can check that font parameter.
11454 %
11455 \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
11456
11457 % Same as above, but check for italic font. Actually this also catches
11458 % non-italic slanted fonts since it is impossible to distinguish them from
11459 % italic fonts. But since this is only used by $ and it uses \sl anyway
11460 % this is not a problem.
11461 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
11462
11463 % Set catcodes for Texinfo file
11464
11465 % Active characters for printing the wanted glyph.
11466 % Most of these we simply print from the \tt font, but for some, we can
11467 % use math or other variants that look better in normal text.
11468 %
11469 \catcode`\"=\active
11470 \def\activedoublequote{{\tt\char34}}
11471 \let"=\activedoublequote
11472 \catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
11473 \chardef\hatchar=`\^
11474 \catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
11475
11476 \catcode`\_=\active
11477 \def_{\ifusingtt\normalunderscore\_}
11478 \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
11479 \let\realunder=_
11480
11481 \catcode`\|=\active \def|{{\tt\char124}}
11482
11483 \chardef \less=`\<
11484 \catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
11485 \chardef \gtr=`\>
11486 \catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11487 \catcode`\+=\active \def+{{\tt \char 43}}
11488 \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
11489 \catcode`\-=\active \let-=\normaldash
11490
11491
11492 % used for headline/footline in the output routine, in case the page
11493 % breaks in the middle of an @tex block.
11494 \def\texinfochars{%
11495 \let< = \activeless
11496 \let> = \activegtr
11497 \let~ = \activetilde
11498 \let^ = \activehat
11499 \markupsetuplqdefault \markupsetuprqdefault
11500 \let\b = \strong
11501 \let\i = \smartitalic
11502 % in principle, all other definitions in \tex have to be undone too.
11503 }
11504
11505 % Used sometimes to turn off (effectively) the active characters even after
11506 % parsing them.
11507 \def\turnoffactive{%
11508 \normalturnoffactive
11509 \otherbackslash
11510 }
11511
11512 \catcode`\@=0
11513
11514 % \backslashcurfont outputs one backslash character in current font,
11515 % as in \char`\\.
11516 \global\chardef\backslashcurfont=`\\
11517 \global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work
11518
11519 % \realbackslash is an actual character `\' with catcode other, and
11520 % \doublebackslash is two of them (for the pdf outlines).
11521 {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
11522
11523 % In Texinfo, backslash is an active character; it prints the backslash
11524 % in fixed width font.
11525 \catcode`\\=\active % @ for escape char from now on.
11526
11527 % Print a typewriter backslash. For math mode, we can't simply use
11528 % \backslashcurfont: the story here is that in math mode, the \char
11529 % of \backslashcurfont ends up printing the roman \ from the math symbol
11530 % font (because \char in math mode uses the \mathcode, and plain.tex
11531 % sets \mathcode`\\="026E). Hence we use an explicit \mathchar,
11532 % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11533 % ignored family value; char position "5C). We can't use " for the
11534 % usual hex value because it has already been made active.
11535
11536 @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
11537 @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
11538
11539 % \rawbackslash defines an active \ to do \backslashcurfont.
11540 % \otherbackslash defines an active \ to be a literal `\' character with
11541 % catcode other. We switch back and forth between these.
11542 @gdef@rawbackslash{@let\=@backslashcurfont}
11543 @gdef@otherbackslash{@let\=@realbackslash}
11544
11545 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
11546 % the literal character `\'.
11547 %
11548 {@catcode`- = @active
11549 @gdef@normalturnoffactive{%
11550 @passthroughcharstrue
11551 @let-=@normaldash
11552 @let"=@normaldoublequote
11553 @let$=@normaldollar %$ font-lock fix
11554 @let+=@normalplus
11555 @let<=@normalless
11556 @let>=@normalgreater
11557 @let^=@normalcaret
11558 @let_=@normalunderscore
11559 @let|=@normalverticalbar
11560 @let~=@normaltilde
11561 @let\=@ttbackslash
11562 @markupsetuplqdefault
11563 @markupsetuprqdefault
11564 @unsepspaces
11565 }
11566 }
11567
11568 % If a .fmt file is being used, characters that might appear in a file
11569 % name cannot be active until we have parsed the command line.
11570 % So turn them off again, and have @fixbackslash turn them back on.
11571 @catcode`+=@other @catcode`@_=@other
11572
11573 % \enablebackslashhack - allow file to begin `\input texinfo'
11574 %
11575 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
11576 % That is what \eatinput is for; after that, the `\' should revert to printing
11577 % a backslash.
11578 % If the file did not have a `\input texinfo', then it is turned off after
11579 % the first line; otherwise the first `\' in the file would cause an error.
11580 % This is used on the very last line of this file, texinfo.tex.
11581 % We also use @c to call @fixbackslash, in case ends of lines are hidden.
11582 {
11583 @catcode`@^=7
11584 @catcode`@^^M=13@gdef@enablebackslashhack{%
11585 @global@let\ = @eatinput%
11586 @catcode`@^^M=13%
11587 @def@c{@fixbackslash@c}%
11588 % Definition for the newline at the end of this file.
11589 @def ^^M{@let^^M@secondlinenl}%
11590 % Definition for a newline in the main Texinfo file.
11591 @gdef @secondlinenl{@fixbackslash}%
11592 }}
11593
11594 {@catcode`@^=7 @catcode`@^^M=13%
11595 @gdef@eatinput input texinfo#1^^M{@fixbackslash}}
11596
11597 % Emergency active definition of newline, in case an active newline token
11598 % appears by mistake.
11599 {@catcode`@^=7 @catcode13=13%
11600 @gdef@enableemergencynewline{%
11601 @gdef^^M{%
11602 @par%
11603 %<warning: active newline>@par%
11604 }}}
11605
11606
11607 @gdef@fixbackslash{%
11608 @ifx\@eatinput @let\ = @ttbackslash @fi
11609 @catcode13=5 % regular end of line
11610 @enableemergencynewline
11611 @let@c=@texinfoc
11612 % Also turn back on active characters that might appear in the input
11613 % file name, in case not using a pre-dumped format.
11614 @catcode`+=@active
11615 @catcode`@_=@active
11616 %
11617 % If texinfo.cnf is present on the system, read it.
11618 % Useful for site-wide @afourpaper, etc. This macro, @fixbackslash, gets
11619 % called at the beginning of every Texinfo file. Not opening texinfo.cnf
11620 % directly in this file, texinfo.tex, makes it possible to make a format
11621 % file for Texinfo.
11622 %
11623 @openin 1 texinfo.cnf
11624 @ifeof 1 @else @input texinfo.cnf @fi
11625 @closein 1
11626 }
11627
11628
11629 % Say @foo, not \foo, in error messages.
11630 @escapechar = `@@
11631
11632 % These (along with & and #) are made active for url-breaking, so need
11633 % active definitions as the normal characters.
11634 @def@normaldot{.}
11635 @def@normalquest{?}
11636 @def@normalslash{/}
11637
11638 % These look ok in all fonts, so just make them not special.
11639 % @hashchar{} gets its own user-level command, because of #line.
11640 @catcode`@& = @other @def@normalamp{&}
11641 @catcode`@# = @other @def@normalhash{#}
11642 @catcode`@% = @other @def@normalpercent{%}
11643
11644 @let @hashchar = @normalhash
11645
11646 @c Finally, make ` and ' active, so that txicodequoteundirected and
11647 @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we
11648 @c don't make ` and ' active, @code will not get them as active chars.
11649 @c Do this last of all since we use ` in the previous @catcode assignments.
11650 @catcode`@'=@active
11651 @catcode`@`=@active
11652 @markupsetuplqdefault
11653 @markupsetuprqdefault
11654
11655 @c Local variables:
11656 @c eval: (add-hook 'write-file-hooks 'time-stamp)
11657 @c page-delimiter: "^\\\\message\\|emacs-page"
11658 @c time-stamp-start: "def\\\\texinfoversion{"
11659 @c time-stamp-format: "%:y-%02m-%02d.%02H"
11660 @c time-stamp-end: "}"
11661 @c End:
11662
11663 @c vim:sw=2:
11664
11665 @ignore
11666 arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
11667 @end ignore
11668 @enablebackslashhack