document mingw linker fix and close associated bug
[debian/gzip] / build-aux / 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{2018-09-21.20}
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, 2017, 2018
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 <https://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 %   https://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
34 %   https://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
35 %   https://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 https://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 % Likewise for ^^M, the end of line character.
169 \def\endlineisspace{\catcode13=10\relax}
170
171 \chardef\dashChar  = `\-
172 \chardef\slashChar = `\/
173 \chardef\underChar = `\_
174
175 % Ignore a token.
176 %
177 \def\gobble#1{}
178
179 % The following is used inside several \edef's.
180 \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
181
182 % Hyphenation fixes.
183 \hyphenation{
184   Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
185   ap-pen-dix bit-map bit-maps
186   data-base data-bases eshell fall-ing half-way long-est man-u-script
187   man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
188   par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
189   spell-ing spell-ings
190   stand-alone strong-est time-stamp time-stamps which-ever white-space
191   wide-spread wrap-around
192 }
193
194 % Sometimes it is convenient to have everything in the transcript file
195 % and nothing on the terminal.  We don't just call \tracingall here,
196 % since that produces some useless output on the terminal.  We also make
197 % some effort to order the tracing commands to reduce output in the log
198 % file; cf. trace.sty in LaTeX.
199 %
200 \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
201 \def\loggingall{%
202   \tracingstats2
203   \tracingpages1
204   \tracinglostchars2  % 2 gives us more in etex
205   \tracingparagraphs1
206   \tracingoutput1
207   \tracingmacros2
208   \tracingrestores1
209   \showboxbreadth\maxdimen \showboxdepth\maxdimen
210   \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
211     \tracingscantokens1
212     \tracingifs1
213     \tracinggroups1
214     \tracingnesting2
215     \tracingassigns1
216   \fi
217   \tracingcommands3  % 3 gives us more in etex
218   \errorcontextlines16
219 }%
220
221 % @errormsg{MSG}.  Do the index-like expansions on MSG, but if things
222 % aren't perfect, it's not the end of the world, being an error message,
223 % after all.
224
225 \def\errormsg{\begingroup \indexnofonts \doerrormsg}
226 \def\doerrormsg#1{\errmessage{#1}}
227
228 % add check for \lastpenalty to plain's definitions.  If the last thing
229 % we did was a \nobreak, we don't want to insert more space.
230 %
231 \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
232   \removelastskip\penalty-50\smallskip\fi\fi}
233 \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
234   \removelastskip\penalty-100\medskip\fi\fi}
235 \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
236   \removelastskip\penalty-200\bigskip\fi\fi}
237
238 %\f Output routine
239 %
240
241 % For a final copy, take out the rectangles
242 % that mark overfull boxes (in case you have decided
243 % that the text looks ok even though it passes the margin).
244 %
245 \def\finalout{\overfullrule=0pt }
246
247 % Do @cropmarks to get crop marks.
248 %
249 \newif\ifcropmarks
250 \let\cropmarks = \cropmarkstrue
251 %
252 % Dimensions to add cropmarks at corners.
253 % Added by P. A. MacKay, 12 Nov. 1986
254 %
255 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
256 \newdimen\cornerlong  \cornerlong=1pc
257 \newdimen\cornerthick \cornerthick=.3pt
258 \newdimen\topandbottommargin \topandbottommargin=.75in
259
260 % Output a mark which sets \thischapter, \thissection and \thiscolor.
261 % We dump everything together because we only have one kind of mark.
262 % This works because we only use \botmark / \topmark, not \firstmark.
263 %
264 % A mark contains a subexpression of the \ifcase ... \fi construct.
265 % \get*marks macros below extract the needed part using \ifcase.
266 %
267 % Another complication is to let the user choose whether \thischapter
268 % (\thissection) refers to the chapter (section) in effect at the top
269 % of a page, or that at the bottom of a page.
270
271 % \domark is called twice inside \chapmacro, to add one
272 % mark before the section break, and one after.
273 %   In the second call \prevchapterdefs is the same as \lastchapterdefs,
274 % and \prevsectiondefs is the same as \lastsectiondefs.
275 %   Then if the page is not broken at the mark, some of the previous
276 % section appears on the page, and we can get the name of this section
277 % from \firstmark for @everyheadingmarks top.
278 %   @everyheadingmarks bottom uses \botmark.
279 %
280 % See page 260 of The TeXbook.
281 \def\domark{%
282   \toks0=\expandafter{\lastchapterdefs}%
283   \toks2=\expandafter{\lastsectiondefs}%
284   \toks4=\expandafter{\prevchapterdefs}%
285   \toks6=\expandafter{\prevsectiondefs}%
286   \toks8=\expandafter{\lastcolordefs}%
287   \mark{%
288                    \the\toks0 \the\toks2  % 0: marks for @everyheadingmarks top
289       \noexpand\or \the\toks4 \the\toks6  % 1: for @everyheadingmarks bottom
290     \noexpand\else \the\toks8             % 2: color marks
291   }%
292 }
293
294 % \gettopheadingmarks, \getbottomheadingmarks,
295 % \getcolormarks - extract needed part of mark.
296 %
297 % \topmark doesn't work for the very first chapter (after the title
298 % page or the contents), so we use \firstmark there -- this gets us
299 % the mark with the chapter defs, unless the user sneaks in, e.g.,
300 % @setcolor (or @url, or @link, etc.) between @contents and the very
301 % first @chapter.
302 \def\gettopheadingmarks{%
303   \ifcase0\topmark\fi
304   \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
305 }
306 \def\getbottomheadingmarks{\ifcase1\botmark\fi}
307 \def\getcolormarks{\ifcase2\topmark\fi}
308
309 % Avoid "undefined control sequence" errors.
310 \def\lastchapterdefs{}
311 \def\lastsectiondefs{}
312 \def\lastsection{}
313 \def\prevchapterdefs{}
314 \def\prevsectiondefs{}
315 \def\lastcolordefs{}
316
317 % Margin to add to right of even pages, to left of odd pages.
318 \newdimen\bindingoffset
319 \newdimen\normaloffset
320 \newdimen\txipagewidth \newdimen\txipageheight
321
322 % Main output routine.
323 %
324 \chardef\PAGE = 255
325 \output = {\onepageout{\pagecontents\PAGE}}
326
327 \newbox\headlinebox
328 \newbox\footlinebox
329
330 % \onepageout takes a vbox as an argument.
331 % \shipout a vbox for a single page, adding an optional header, footer,
332 % cropmarks, and footnote.  This also causes index entries for this page
333 % to be written to the auxiliary files.
334 %
335 \def\onepageout#1{%
336   \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
337   %
338   \ifodd\pageno  \advance\hoffset by \bindingoffset
339   \else \advance\hoffset by -\bindingoffset\fi
340   %
341   % Common context changes for both heading and footing.
342   % Do this outside of the \shipout so @code etc. will be expanded in
343   % the headline as they should be, not taken literally (outputting ''code).
344   \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars}
345   %
346   % Retrieve the information for the headings from the marks in the page,
347   % and call Plain TeX's \makeheadline and \makefootline, which use the
348   % values in \headline and \footline.
349   %
350   % This is used to check if we are on the first page of a chapter.
351   \ifcase1\topmark\fi
352   \let\prevchaptername\thischaptername
353   \ifcase0\firstmark\fi
354   \let\curchaptername\thischaptername
355   %
356   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
357   \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
358   %
359   \ifx\curchaptername\prevchaptername
360     \let\thischapterheading\thischapter
361   \else
362     % \thischapterheading is the same as \thischapter except it is blank
363     % for the first page of a chapter.  This is to prevent the chapter name 
364     % being shown twice.
365     \def\thischapterheading{}%
366   \fi
367   %
368   \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}%
369   \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}%
370   %
371   {%
372     % Set context for writing to auxiliary files like index files.
373     % Have to do this stuff outside the \shipout because we want it to
374     % take effect in \write's, yet the group defined by the \vbox ends
375     % before the \shipout runs.
376     %
377     \indexdummies         % don't expand commands in the output.
378     \normalturnoffactive  % \ in index entries must not stay \, e.g., if
379                % the page break happens to be in the middle of an example.
380                % We don't want .vr (or whatever) entries like this:
381                % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}}
382                % "\acronym" won't work when it's read back in;
383                % it needs to be
384                % {\code {{\backslashcurfont }acronym}
385     \shipout\vbox{%
386       % Do this early so pdf references go to the beginning of the page.
387       \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
388       %
389       \ifcropmarks \vbox to \outervsize\bgroup
390         \hsize = \outerhsize
391         \vskip-\topandbottommargin
392         \vtop to0pt{%
393           \line{\ewtop\hfil\ewtop}%
394           \nointerlineskip
395           \line{%
396             \vbox{\moveleft\cornerthick\nstop}%
397             \hfill
398             \vbox{\moveright\cornerthick\nstop}%
399           }%
400           \vss}%
401         \vskip\topandbottommargin
402         \line\bgroup
403           \hfil % center the page within the outer (page) hsize.
404           \ifodd\pageno\hskip\bindingoffset\fi
405           \vbox\bgroup
406       \fi
407       %
408       \unvbox\headlinebox
409       \pagebody{#1}%
410       \ifdim\ht\footlinebox > 0pt
411         % Only leave this space if the footline is nonempty.
412         % (We lessened \vsize for it in \oddfootingyyy.)
413         % The \baselineskip=24pt in plain's \makefootline has no effect.
414         \vskip 24pt
415         \unvbox\footlinebox
416       \fi
417       %
418       \ifcropmarks
419           \egroup % end of \vbox\bgroup
420         \hfil\egroup % end of (centering) \line\bgroup
421         \vskip\topandbottommargin plus1fill minus1fill
422         \boxmaxdepth = \cornerthick
423         \vbox to0pt{\vss
424           \line{%
425             \vbox{\moveleft\cornerthick\nsbot}%
426             \hfill
427             \vbox{\moveright\cornerthick\nsbot}%
428           }%
429           \nointerlineskip
430           \line{\ewbot\hfil\ewbot}%
431         }%
432       \egroup % \vbox from first cropmarks clause
433       \fi
434     }% end of \shipout\vbox
435   }% end of group with \indexdummies
436   \advancepageno
437   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
438 }
439
440 \newinsert\margin \dimen\margin=\maxdimen
441
442 % Main part of page, including any footnotes
443 \def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
444 {\catcode`\@ =11
445 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
446 % marginal hacks, juha@viisa.uucp (Juha Takala)
447 \ifvoid\margin\else % marginal info is present
448   \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
449 \dimen@=\dp#1\relax \unvbox#1\relax
450 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
451 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
452 }
453
454 % Here are the rules for the cropmarks.  Note that they are
455 % offset so that the space between them is truly \outerhsize or \outervsize
456 % (P. A. MacKay, 12 November, 1986)
457 %
458 \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
459 \def\nstop{\vbox
460   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
461 \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
462 \def\nsbot{\vbox
463   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
464
465
466 % Argument parsing
467
468 % Parse an argument, then pass it to #1.  The argument is the rest of
469 % the input line (except we remove a trailing comment).  #1 should be a
470 % macro which expects an ordinary undelimited TeX argument.
471 % For example, \def\foo{\parsearg\fooxxx}.
472 %
473 \def\parsearg{\parseargusing{}}
474 \def\parseargusing#1#2{%
475   \def\argtorun{#2}%
476   \begingroup
477     \obeylines
478     \spaceisspace
479     #1%
480     \parseargline\empty% Insert the \empty token, see \finishparsearg below.
481 }
482
483 {\obeylines %
484   \gdef\parseargline#1^^M{%
485     \endgroup % End of the group started in \parsearg.
486     \argremovecomment #1\comment\ArgTerm%
487   }%
488 }
489
490 % First remove any @comment, then any @c comment.  Also remove a @texinfoc
491 % comment (see \scanmacro for details).  Pass the result on to \argcheckspaces.
492 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
493 \def\argremovec#1\c#2\ArgTerm{\argremovetexinfoc #1\texinfoc\ArgTerm}
494 \def\argremovetexinfoc#1\texinfoc#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
495
496 % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
497 %
498 % \argremovec might leave us with trailing space, e.g.,
499 %    @end itemize  @c foo
500 % This space token undergoes the same procedure and is eventually removed
501 % by \finishparsearg.
502 %
503 \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
504 \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
505 \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
506   \def\temp{#3}%
507   \ifx\temp\empty
508     % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
509     \let\temp\finishparsearg
510   \else
511     \let\temp\argcheckspaces
512   \fi
513   % Put the space token in:
514   \temp#1 #3\ArgTerm
515 }
516
517 % If a _delimited_ argument is enclosed in braces, they get stripped; so
518 % to get _exactly_ the rest of the line, we had to prevent such situation.
519 % We prepended an \empty token at the very beginning and we expand it now,
520 % just before passing the control to \argtorun.
521 % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
522 % either the null string, or it ends with \^^M---thus there is no danger
523 % that a pair of braces would be stripped.
524 %
525 % But first, we have to remove the trailing space token.
526 %
527 \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
528
529
530 % \parseargdef - define a command taking an argument on the line
531 %
532 % \parseargdef\foo{...}
533 %       is roughly equivalent to
534 % \def\foo{\parsearg\Xfoo}
535 % \def\Xfoo#1{...}
536 \def\parseargdef#1{%
537   \expandafter \doparseargdef \csname\string#1\endcsname #1%
538 }
539 \def\doparseargdef#1#2{%
540   \def#2{\parsearg#1}%
541   \def#1##1%
542 }
543
544 % Several utility definitions with active space:
545 {
546   \obeyspaces
547   \gdef\obeyedspace{ }
548
549   % Make each space character in the input produce a normal interword
550   % space in the output.  Don't allow a line break at this space, as this
551   % is used only in environments like @example, where each line of input
552   % should produce a line of output anyway.
553   %
554   \gdef\sepspaces{\obeyspaces\let =\tie}
555
556   % If an index command is used in an @example environment, any spaces
557   % therein should become regular spaces in the raw index file, not the
558   % expansion of \tie (\leavevmode \penalty \@M \ ).
559   \gdef\unsepspaces{\let =\space}
560 }
561
562
563 \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
564
565 % Define the framework for environments in texinfo.tex.  It's used like this:
566 %
567 %   \envdef\foo{...}
568 %   \def\Efoo{...}
569 %
570 % It's the responsibility of \envdef to insert \begingroup before the
571 % actual body; @end closes the group after calling \Efoo.  \envdef also
572 % defines \thisenv, so the current environment is known; @end checks
573 % whether the environment name matches.  The \checkenv macro can also be
574 % used to check whether the current environment is the one expected.
575 %
576 % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
577 % are not treated as environments; they don't open a group.  (The
578 % implementation of @end takes care not to call \endgroup in this
579 % special case.)
580
581
582 % At run-time, environments start with this:
583 \def\startenvironment#1{\begingroup\def\thisenv{#1}}
584 % initialize
585 \let\thisenv\empty
586
587 % ... but they get defined via ``\envdef\foo{...}'':
588 \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
589 \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
590
591 % Check whether we're in the right environment:
592 \def\checkenv#1{%
593   \def\temp{#1}%
594   \ifx\thisenv\temp
595   \else
596     \badenverr
597   \fi
598 }
599
600 % Environment mismatch, #1 expected:
601 \def\badenverr{%
602   \errhelp = \EMsimple
603   \errmessage{This command can appear only \inenvironment\temp,
604     not \inenvironment\thisenv}%
605 }
606 \def\inenvironment#1{%
607   \ifx#1\empty
608     outside of any environment%
609   \else
610     in environment \expandafter\string#1%
611   \fi
612 }
613
614 % @end foo executes the definition of \Efoo.
615 % But first, it executes a specialized version of \checkenv
616 %
617 \parseargdef\end{%
618   \if 1\csname iscond.#1\endcsname
619   \else
620     % The general wording of \badenverr may not be ideal.
621     \expandafter\checkenv\csname#1\endcsname
622     \csname E#1\endcsname
623     \endgroup
624   \fi
625 }
626
627 \newhelp\EMsimple{Press RETURN to continue.}
628
629
630 % Be sure we're in horizontal mode when doing a tie, since we make space
631 % equivalent to this in @example-like environments. Otherwise, a space
632 % at the beginning of a line will start with \penalty -- and
633 % since \penalty is valid in vertical mode, we'd end up putting the
634 % penalty on the vertical list instead of in the new paragraph.
635 {\catcode`@ = 11
636  % Avoid using \@M directly, because that causes trouble
637  % if the definition is written into an index file.
638  \global\let\tiepenalty = \@M
639  \gdef\tie{\leavevmode\penalty\tiepenalty\ }
640 }
641
642 % @: forces normal size whitespace following.
643 \def\:{\spacefactor=1000 }
644
645 % @* forces a line break.
646 \def\*{\unskip\hfil\break\hbox{}\ignorespaces}
647
648 % @/ allows a line break.
649 \let\/=\allowbreak
650
651 % @. is an end-of-sentence period.
652 \def\.{.\spacefactor=\endofsentencespacefactor\space}
653
654 % @! is an end-of-sentence bang.
655 \def\!{!\spacefactor=\endofsentencespacefactor\space}
656
657 % @? is an end-of-sentence query.
658 \def\?{?\spacefactor=\endofsentencespacefactor\space}
659
660 % @frenchspacing on|off  says whether to put extra space after punctuation.
661 %
662 \def\onword{on}
663 \def\offword{off}
664 %
665 \parseargdef\frenchspacing{%
666   \def\temp{#1}%
667   \ifx\temp\onword \plainfrenchspacing
668   \else\ifx\temp\offword \plainnonfrenchspacing
669   \else
670     \errhelp = \EMsimple
671     \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
672   \fi\fi
673 }
674
675 % @w prevents a word break.  Without the \leavevmode, @w at the
676 % beginning of a paragraph, when TeX is still in vertical mode, would
677 % produce a whole line of output instead of starting the paragraph.
678 \def\w#1{\leavevmode\hbox{#1}}
679
680 % @group ... @end group forces ... to be all on one page, by enclosing
681 % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
682 % to keep its height that of a normal line.  According to the rules for
683 % \topskip (p.114 of the TeXbook), the glue inserted is
684 % max (\topskip - \ht (first item), 0).  If that height is large,
685 % therefore, no glue is inserted, and the space between the headline and
686 % the text is small, which looks bad.
687 %
688 % Another complication is that the group might be very large.  This can
689 % cause the glue on the previous page to be unduly stretched, because it
690 % does not have much material.  In this case, it's better to add an
691 % explicit \vfill so that the extra space is at the bottom.  The
692 % threshold for doing this is if the group is more than \vfilllimit
693 % percent of a page (\vfilllimit can be changed inside of @tex).
694 %
695 \newbox\groupbox
696 \def\vfilllimit{0.7}
697 %
698 \envdef\group{%
699   \ifnum\catcode`\^^M=\active \else
700     \errhelp = \groupinvalidhelp
701     \errmessage{@group invalid in context where filling is enabled}%
702   \fi
703   \startsavinginserts
704   %
705   \setbox\groupbox = \vtop\bgroup
706     % Do @comment since we are called inside an environment such as
707     % @example, where each end-of-line in the input causes an
708     % end-of-line in the output.  We don't want the end-of-line after
709     % the `@group' to put extra space in the output.  Since @group
710     % should appear on a line by itself (according to the Texinfo
711     % manual), we don't worry about eating any user text.
712     \comment
713 }
714 %
715 % The \vtop produces a box with normal height and large depth; thus, TeX puts
716 % \baselineskip glue before it, and (when the next line of text is done)
717 % \lineskip glue after it.  Thus, space below is not quite equal to space
718 % above.  But it's pretty close.
719 \def\Egroup{%
720     % To get correct interline space between the last line of the group
721     % and the first line afterwards, we have to propagate \prevdepth.
722     \endgraf % Not \par, as it may have been set to \lisppar.
723     \global\dimen1 = \prevdepth
724   \egroup           % End the \vtop.
725   \addgroupbox
726   \prevdepth = \dimen1
727   \checkinserts
728 }
729
730 \def\addgroupbox{
731   % \dimen0 is the vertical size of the group's box.
732   \dimen0 = \ht\groupbox  \advance\dimen0 by \dp\groupbox
733   % \dimen2 is how much space is left on the page (more or less).
734   \dimen2 = \txipageheight   \advance\dimen2 by -\pagetotal
735   % if the group doesn't fit on the current page, and it's a big big
736   % group, force a page break.
737   \ifdim \dimen0 > \dimen2
738     \ifdim \pagetotal < \vfilllimit\txipageheight
739       \page
740     \fi
741   \fi
742   \box\groupbox
743 }
744
745 %
746 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
747 % message, so this ends up printing `@group can only ...'.
748 %
749 \newhelp\groupinvalidhelp{%
750 group can only be used in environments such as @example,^^J%
751 where each line of input produces a line of output.}
752
753 % @need space-in-mils
754 % forces a page break if there is not space-in-mils remaining.
755
756 \newdimen\mil  \mil=0.001in
757
758 \parseargdef\need{%
759   % Ensure vertical mode, so we don't make a big box in the middle of a
760   % paragraph.
761   \par
762   %
763   % If the @need value is less than one line space, it's useless.
764   \dimen0 = #1\mil
765   \dimen2 = \ht\strutbox
766   \advance\dimen2 by \dp\strutbox
767   \ifdim\dimen0 > \dimen2
768     %
769     % Do a \strut just to make the height of this box be normal, so the
770     % normal leading is inserted relative to the preceding line.
771     % And a page break here is fine.
772     \vtop to #1\mil{\strut\vfil}%
773     %
774     % TeX does not even consider page breaks if a penalty added to the
775     % main vertical list is 10000 or more.  But in order to see if the
776     % empty box we just added fits on the page, we must make it consider
777     % page breaks.  On the other hand, we don't want to actually break the
778     % page after the empty box.  So we use a penalty of 9999.
779     %
780     % There is an extremely small chance that TeX will actually break the
781     % page at this \penalty, if there are no other feasible breakpoints in
782     % sight.  (If the user is using lots of big @group commands, which
783     % almost-but-not-quite fill up a page, TeX will have a hard time doing
784     % good page breaking, for example.)  However, I could not construct an
785     % example where a page broke at this \penalty; if it happens in a real
786     % document, then we can reconsider our strategy.
787     \penalty9999
788     %
789     % Back up by the size of the box, whether we did a page break or not.
790     \kern -#1\mil
791     %
792     % Do not allow a page break right after this kern.
793     \nobreak
794   \fi
795 }
796
797 % @br   forces paragraph break (and is undocumented).
798
799 \let\br = \par
800
801 % @page forces the start of a new page.
802 %
803 \def\page{\par\vfill\supereject}
804
805 % @exdent text....
806 % outputs text on separate line in roman font, starting at standard page margin
807
808 % This records the amount of indent in the innermost environment.
809 % That's how much \exdent should take out.
810 \newskip\exdentamount
811
812 % This defn is used inside fill environments such as @defun.
813 \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
814
815 % This defn is used inside nofill environments such as @example.
816 \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
817   \leftline{\hskip\leftskip{\rm#1}}}}
818
819 % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
820 % paragraph.  For more general purposes, use the \margin insertion
821 % class.  WHICH is `l' or `r'.  Not documented, written for gawk manual.
822 %
823 \newskip\inmarginspacing \inmarginspacing=1cm
824 \def\strutdepth{\dp\strutbox}
825 %
826 \def\doinmargin#1#2{\strut\vadjust{%
827   \nobreak
828   \kern-\strutdepth
829   \vtop to \strutdepth{%
830     \baselineskip=\strutdepth
831     \vss
832     % if you have multiple lines of stuff to put here, you'll need to
833     % make the vbox yourself of the appropriate size.
834     \ifx#1l%
835       \llap{\ignorespaces #2\hskip\inmarginspacing}%
836     \else
837       \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
838     \fi
839     \null
840   }%
841 }}
842 \def\inleftmargin{\doinmargin l}
843 \def\inrightmargin{\doinmargin r}
844 %
845 % @inmargin{TEXT [, RIGHT-TEXT]}
846 % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
847 % else use TEXT for both).
848 %
849 \def\inmargin#1{\parseinmargin #1,,\finish}
850 \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
851   \setbox0 = \hbox{\ignorespaces #2}%
852   \ifdim\wd0 > 0pt
853     \def\lefttext{#1}%  have both texts
854     \def\righttext{#2}%
855   \else
856     \def\lefttext{#1}%  have only one text
857     \def\righttext{#1}%
858   \fi
859   %
860   \ifodd\pageno
861     \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
862   \else
863     \def\temp{\inleftmargin\lefttext}%
864   \fi
865   \temp
866 }
867
868 % @include FILE -- \input text of FILE.
869 %
870 \def\include{\parseargusing\filenamecatcodes\includezzz}
871 \def\includezzz#1{%
872   \pushthisfilestack
873   \def\thisfile{#1}%
874   {%
875     \makevalueexpandable  % we want to expand any @value in FILE.
876     \turnoffactive        % and allow special characters in the expansion
877     \indexnofonts         % Allow `@@' and other weird things in file names.
878     \wlog{texinfo.tex: doing @include of #1^^J}%
879     \edef\temp{\noexpand\input #1 }%
880     %
881     % This trickery is to read FILE outside of a group, in case it makes
882     % definitions, etc.
883     \expandafter
884   }\temp
885   \popthisfilestack
886 }
887 \def\filenamecatcodes{%
888   \catcode`\\=\other
889   \catcode`~=\other
890   \catcode`^=\other
891   \catcode`_=\other
892   \catcode`|=\other
893   \catcode`<=\other
894   \catcode`>=\other
895   \catcode`+=\other
896   \catcode`-=\other
897   \catcode`\`=\other
898   \catcode`\'=\other
899 }
900
901 \def\pushthisfilestack{%
902   \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
903 }
904 \def\pushthisfilestackX{%
905   \expandafter\pushthisfilestackY\thisfile\StackTerm
906 }
907 \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
908   \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
909 }
910
911 \def\popthisfilestack{\errthisfilestackempty}
912 \def\errthisfilestackempty{\errmessage{Internal error:
913   the stack of filenames is empty.}}
914 %
915 \def\thisfile{}
916
917 % @center line
918 % outputs that line, centered.
919 %
920 \parseargdef\center{%
921   \ifhmode
922     \let\centersub\centerH
923   \else
924     \let\centersub\centerV
925   \fi
926   \centersub{\hfil \ignorespaces#1\unskip \hfil}%
927   \let\centersub\relax % don't let the definition persist, just in case
928 }
929 \def\centerH#1{{%
930   \hfil\break
931   \advance\hsize by -\leftskip
932   \advance\hsize by -\rightskip
933   \line{#1}%
934   \break
935 }}
936 %
937 \newcount\centerpenalty
938 \def\centerV#1{%
939   % The idea here is the same as in \startdefun, \cartouche, etc.: if
940   % @center is the first thing after a section heading, we need to wipe
941   % out the negative parskip inserted by \sectionheading, but still
942   % prevent a page break here.
943   \centerpenalty = \lastpenalty
944   \ifnum\centerpenalty>10000 \vskip\parskip \fi
945   \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
946   \line{\kern\leftskip #1\kern\rightskip}%
947 }
948
949 % @sp n   outputs n lines of vertical space
950 %
951 \parseargdef\sp{\vskip #1\baselineskip}
952
953 % @comment ...line which is ignored...
954 % @c is the same as @comment
955 % @ignore ... @end ignore  is another way to write a comment
956
957
958 \def\c{\begingroup \catcode`\^^M=\active%
959 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
960 \cxxx}
961 {\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
962 %
963 \let\comment\c
964
965 % @paragraphindent NCHARS
966 % We'll use ems for NCHARS, close enough.
967 % NCHARS can also be the word `asis' or `none'.
968 % We cannot feasibly implement @paragraphindent asis, though.
969 %
970 \def\asisword{asis} % no translation, these are keywords
971 \def\noneword{none}
972 %
973 \parseargdef\paragraphindent{%
974   \def\temp{#1}%
975   \ifx\temp\asisword
976   \else
977     \ifx\temp\noneword
978       \defaultparindent = 0pt
979     \else
980       \defaultparindent = #1em
981     \fi
982   \fi
983   \parindent = \defaultparindent
984 }
985
986 % @exampleindent NCHARS
987 % We'll use ems for NCHARS like @paragraphindent.
988 % It seems @exampleindent asis isn't necessary, but
989 % I preserve it to make it similar to @paragraphindent.
990 \parseargdef\exampleindent{%
991   \def\temp{#1}%
992   \ifx\temp\asisword
993   \else
994     \ifx\temp\noneword
995       \lispnarrowing = 0pt
996     \else
997       \lispnarrowing = #1em
998     \fi
999   \fi
1000 }
1001
1002 % @firstparagraphindent WORD
1003 % If WORD is `none', then suppress indentation of the first paragraph
1004 % after a section heading.  If WORD is `insert', then do indent at such
1005 % paragraphs.
1006 %
1007 % The paragraph indentation is suppressed or not by calling
1008 % \suppressfirstparagraphindent, which the sectioning commands do.
1009 % We switch the definition of this back and forth according to WORD.
1010 % By default, we suppress indentation.
1011 %
1012 \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
1013 \def\insertword{insert}
1014 %
1015 \parseargdef\firstparagraphindent{%
1016   \def\temp{#1}%
1017   \ifx\temp\noneword
1018     \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
1019   \else\ifx\temp\insertword
1020     \let\suppressfirstparagraphindent = \relax
1021   \else
1022     \errhelp = \EMsimple
1023     \errmessage{Unknown @firstparagraphindent option `\temp'}%
1024   \fi\fi
1025 }
1026
1027 % Here is how we actually suppress indentation.  Redefine \everypar to
1028 % \kern backwards by \parindent, and then reset itself to empty.
1029 %
1030 % We also make \indent itself not actually do anything until the next
1031 % paragraph.
1032 %
1033 \gdef\dosuppressfirstparagraphindent{%
1034   \gdef\indent  {\restorefirstparagraphindent \indent}%
1035   \gdef\noindent{\restorefirstparagraphindent \noindent}%
1036   \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
1037 }
1038 %
1039 \gdef\restorefirstparagraphindent{%
1040   \global\let\indent = \ptexindent
1041   \global\let\noindent = \ptexnoindent
1042   \global\everypar = {}%
1043 }
1044
1045
1046 % @refill is a no-op.
1047 \let\refill=\relax
1048
1049 % @setfilename INFO-FILENAME - ignored
1050 \let\setfilename=\comment
1051
1052 % @bye.
1053 \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
1054
1055
1056 \message{pdf,}
1057 % adobe `portable' document format
1058 \newcount\tempnum
1059 \newcount\lnkcount
1060 \newtoks\filename
1061 \newcount\filenamelength
1062 \newcount\pgn
1063 \newtoks\toksA
1064 \newtoks\toksB
1065 \newtoks\toksC
1066 \newtoks\toksD
1067 \newbox\boxA
1068 \newbox\boxB
1069 \newcount\countA
1070 \newif\ifpdf
1071 \newif\ifpdfmakepagedest
1072
1073 %
1074 % For LuaTeX
1075 %
1076
1077 \newif\iftxiuseunicodedestname
1078 \txiuseunicodedestnamefalse % For pdfTeX etc.
1079
1080 \ifx\luatexversion\thisisundefined
1081 \else
1082   % Use Unicode destination names
1083   \txiuseunicodedestnametrue
1084   % Escape PDF strings with converting UTF-16 from UTF-8
1085   \begingroup
1086     \catcode`\%=12
1087     \directlua{
1088       function UTF16oct(str)
1089         tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
1090         for c in string.utfvalues(str) do
1091           if c < 0x10000 then
1092             tex.sprint(
1093               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1094                             string.char(0x5c) .. string.char(0x25) .. '03o',
1095                             (c / 256), (c % 256)))
1096           else
1097             c = c - 0x10000
1098             local c_hi = c / 1024 + 0xd800
1099             local c_lo = c % 1024 + 0xdc00
1100             tex.sprint(
1101               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1102                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
1103                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
1104                             string.char(0x5c) .. string.char(0x25) .. '03o',
1105                             (c_hi / 256), (c_hi % 256),
1106                             (c_lo / 256), (c_lo % 256)))
1107           end
1108         end
1109       end
1110     }
1111   \endgroup
1112   \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
1113   % Escape PDF strings without converting
1114   \begingroup
1115     \directlua{
1116       function PDFescstr(str)
1117         for c in string.bytes(str) do
1118           if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
1119             tex.sprint(
1120               string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
1121                             c))
1122           else
1123             tex.sprint(string.char(c))
1124           end
1125         end
1126       end
1127     }
1128   \endgroup
1129   \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
1130   \ifnum\luatexversion>84
1131     % For LuaTeX >= 0.85
1132     \def\pdfdest{\pdfextension dest}
1133     \let\pdfoutput\outputmode
1134     \def\pdfliteral{\pdfextension literal}
1135     \def\pdfcatalog{\pdfextension catalog}
1136     \def\pdftexversion{\numexpr\pdffeedback version\relax}
1137     \let\pdfximage\saveimageresource
1138     \let\pdfrefximage\useimageresource
1139     \let\pdflastximage\lastsavedimageresourceindex
1140     \def\pdfendlink{\pdfextension endlink\relax}
1141     \def\pdfoutline{\pdfextension outline}
1142     \def\pdfstartlink{\pdfextension startlink}
1143     \def\pdffontattr{\pdfextension fontattr}
1144     \def\pdfobj{\pdfextension obj}
1145     \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
1146     \let\pdfpagewidth\pagewidth
1147     \let\pdfpageheight\pageheight
1148     \edef\pdfhorigin{\pdfvariable horigin}
1149     \edef\pdfvorigin{\pdfvariable vorigin}
1150   \fi
1151 \fi
1152
1153 % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1154 % can be set).  So we test for \relax and 0 as well as being undefined.
1155 \ifx\pdfoutput\thisisundefined
1156 \else
1157   \ifx\pdfoutput\relax
1158   \else
1159     \ifcase\pdfoutput
1160     \else
1161       \pdftrue
1162     \fi
1163   \fi
1164 \fi
1165
1166 % PDF uses PostScript string constants for the names of xref targets,
1167 % for display in the outlines, and in other places.  Thus, we have to
1168 % double any backslashes.  Otherwise, a name like "\node" will be
1169 % interpreted as a newline (\n), followed by o, d, e.  Not good.
1170
1171 % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
1172 % related messages.  The final outcome is that it is up to the TeX user
1173 % to double the backslashes and otherwise make the string valid, so
1174 % that's what we do.  pdftex 1.30.0 (ca.2005) introduced a primitive to
1175 % do this reliably, so we use it.
1176
1177 % #1 is a control sequence in which to do the replacements,
1178 % which we \xdef.
1179 \def\txiescapepdf#1{%
1180   \ifx\pdfescapestring\thisisundefined
1181     % No primitive available; should we give a warning or log?
1182     % Many times it won't matter.
1183     \xdef#1{#1}%
1184   \else
1185     % The expandable \pdfescapestring primitive escapes parentheses,
1186     % backslashes, and other special chars.
1187     \xdef#1{\pdfescapestring{#1}}%
1188   \fi
1189 }
1190 \def\txiescapepdfutfsixteen#1{%
1191   \ifx\pdfescapestrutfsixteen\thisisundefined
1192     % No UTF-16 converting macro available.
1193     \txiescapepdf{#1}%
1194   \else
1195     \xdef#1{\pdfescapestrutfsixteen{#1}}%
1196   \fi
1197 }
1198
1199 \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1200 with PDF output, and none of those formats could be found.  (.eps cannot
1201 be supported due to the design of the PDF format; use regular TeX (DVI
1202 output) for that.)}
1203
1204 \ifpdf
1205   %
1206   % Color manipulation macros using ideas from pdfcolor.tex,
1207   % except using rgb instead of cmyk; the latter is said to render as a
1208   % very dark gray on-screen and a very dark halftone in print, instead
1209   % of actual black. The dark red here is dark enough to print on paper as
1210   % nearly black, but still distinguishable for online viewing.  We use
1211   % black by default, though.
1212   \def\rgbDarkRed{0.50 0.09 0.12}
1213   \def\rgbBlack{0 0 0}
1214   %
1215   % rg sets the color for filling (usual text, etc.);
1216   % RG sets the color for stroking (thin rules, e.g., normal _'s).
1217   \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
1218   %
1219   % Set color, and create a mark which defines \thiscolor accordingly,
1220   % so that \makeheadline knows which color to restore.
1221   \def\setcolor#1{%
1222     \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
1223     \domark
1224     \pdfsetcolor{#1}%
1225   }
1226   %
1227   \def\maincolor{\rgbBlack}
1228   \pdfsetcolor{\maincolor}
1229   \edef\thiscolor{\maincolor}
1230   \def\lastcolordefs{}
1231   %
1232   \def\makefootline{%
1233     \baselineskip24pt
1234     \line{\pdfsetcolor{\maincolor}\the\footline}%
1235   }
1236   %
1237   \def\makeheadline{%
1238     \vbox to 0pt{%
1239       \vskip-22.5pt
1240       \line{%
1241         \vbox to8.5pt{}%
1242         % Extract \thiscolor definition from the marks.
1243         \getcolormarks
1244         % Typeset the headline with \maincolor, then restore the color.
1245         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1246       }%
1247       \vss
1248     }%
1249     \nointerlineskip
1250   }
1251   %
1252   %
1253   \pdfcatalog{/PageMode /UseOutlines}
1254   %
1255   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1256   \def\dopdfimage#1#2#3{%
1257     \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1258     \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1259     %
1260     % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1261     % others).  Let's try in that order, PDF first since if
1262     % someone has a scalable image, presumably better to use that than a
1263     % bitmap.
1264     \let\pdfimgext=\empty
1265     \begingroup
1266       \openin 1 #1.pdf \ifeof 1
1267         \openin 1 #1.PDF \ifeof 1
1268           \openin 1 #1.png \ifeof 1
1269             \openin 1 #1.jpg \ifeof 1
1270               \openin 1 #1.jpeg \ifeof 1
1271                 \openin 1 #1.JPG \ifeof 1
1272                   \errhelp = \nopdfimagehelp
1273                   \errmessage{Could not find image file #1 for pdf}%
1274                 \else \gdef\pdfimgext{JPG}%
1275                 \fi
1276               \else \gdef\pdfimgext{jpeg}%
1277               \fi
1278             \else \gdef\pdfimgext{jpg}%
1279             \fi
1280           \else \gdef\pdfimgext{png}%
1281           \fi
1282         \else \gdef\pdfimgext{PDF}%
1283         \fi
1284       \else \gdef\pdfimgext{pdf}%
1285       \fi
1286       \closein 1
1287     \endgroup
1288     %
1289     % without \immediate, ancient pdftex seg faults when the same image is
1290     % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
1291     \ifnum\pdftexversion < 14
1292       \immediate\pdfimage
1293     \else
1294       \immediate\pdfximage
1295     \fi
1296       \ifdim \wd0 >0pt width \pdfimagewidth \fi
1297       \ifdim \wd2 >0pt height \pdfimageheight \fi
1298       \ifnum\pdftexversion<13
1299          #1.\pdfimgext
1300        \else
1301          {#1.\pdfimgext}%
1302        \fi
1303     \ifnum\pdftexversion < 14 \else
1304       \pdfrefximage \pdflastximage
1305     \fi}
1306   %
1307   \def\setpdfdestname#1{{%
1308     % We have to set dummies so commands such as @code, and characters
1309     % such as \, aren't expanded when present in a section title.
1310     \indexnofonts
1311     \makevalueexpandable
1312     \turnoffactive
1313     \iftxiuseunicodedestname
1314       \ifx \declaredencoding \latone
1315         % Pass through Latin-1 characters.
1316         % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode.
1317       \else
1318         \ifx \declaredencoding \utfeight
1319           % Pass through Unicode characters.
1320         \else
1321           % Use ASCII approximations in destination names.
1322           \passthroughcharsfalse
1323         \fi
1324       \fi
1325     \else
1326       % Use ASCII approximations in destination names.
1327       \passthroughcharsfalse
1328     \fi
1329     \def\pdfdestname{#1}%
1330     \txiescapepdf\pdfdestname
1331   }}
1332   %
1333   \def\setpdfoutlinetext#1{{%
1334     \indexnofonts
1335     \makevalueexpandable
1336     \turnoffactive
1337     \ifx \declaredencoding \latone
1338       % The PDF format can use an extended form of Latin-1 in bookmark
1339       % strings.  See Appendix D of the PDF Reference, Sixth Edition, for
1340       % the "PDFDocEncoding".
1341       \passthroughcharstrue
1342       % Pass through Latin-1 characters.
1343       %   LuaTeX: Convert to Unicode
1344       %   pdfTeX: Use Latin-1 as PDFDocEncoding
1345       \def\pdfoutlinetext{#1}%
1346     \else
1347       \ifx \declaredencoding \utfeight
1348         \ifx\luatexversion\thisisundefined
1349           % For pdfTeX  with UTF-8.
1350           % TODO: the PDF format can use UTF-16 in bookmark strings,
1351           % but the code for this isn't done yet.
1352           % Use ASCII approximations.
1353           \passthroughcharsfalse
1354           \def\pdfoutlinetext{#1}%
1355         \else
1356           % For LuaTeX with UTF-8.
1357           % Pass through Unicode characters for title texts.
1358           \passthroughcharstrue
1359           \def\pdfoutlinetext{#1}%
1360         \fi
1361       \else
1362         % For non-Latin-1 or non-UTF-8 encodings.
1363         % Use ASCII approximations.
1364         \passthroughcharsfalse
1365         \def\pdfoutlinetext{#1}%
1366       \fi
1367     \fi
1368     % LuaTeX: Convert to UTF-16
1369     % pdfTeX: Use Latin-1 as PDFDocEncoding
1370     \txiescapepdfutfsixteen\pdfoutlinetext
1371   }}
1372   %
1373   \def\pdfmkdest#1{%
1374     \setpdfdestname{#1}%
1375     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1376   }
1377   %
1378   % used to mark target names; must be expandable.
1379   \def\pdfmkpgn#1{#1}
1380   %
1381   % by default, use black for everything.
1382   \def\urlcolor{\rgbBlack}
1383   \def\linkcolor{\rgbBlack}
1384   \def\endlink{\setcolor{\maincolor}\pdfendlink}
1385   %
1386   % Adding outlines to PDF; macros for calculating structure of outlines
1387   % come from Petr Olsak
1388   \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1389     \else \csname#1\endcsname \fi}
1390   \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1391     \advance\tempnum by 1
1392     \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1393   %
1394   % #1 is the section text, which is what will be displayed in the
1395   % outline by the pdf viewer.  #2 is the pdf expression for the number
1396   % of subentries (or empty, for subsubsections).  #3 is the node text,
1397   % which might be empty if this toc entry had no corresponding node.
1398   % #4 is the page number
1399   %
1400   \def\dopdfoutline#1#2#3#4{%
1401     % Generate a link to the node text if that exists; else, use the
1402     % page number.  We could generate a destination for the section
1403     % text in the case where a section has no node, but it doesn't
1404     % seem worth the trouble, since most documents are normally structured.
1405     \setpdfoutlinetext{#1}
1406     \setpdfdestname{#3}
1407     \ifx\pdfdestname\empty
1408       \def\pdfdestname{#4}%
1409     \fi
1410     %
1411     \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}%
1412   }
1413   %
1414   \def\pdfmakeoutlines{%
1415     \begingroup
1416       % Read toc silently, to get counts of subentries for \pdfoutline.
1417       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1418       \def\numchapentry##1##2##3##4{%
1419         \def\thischapnum{##2}%
1420         \def\thissecnum{0}%
1421         \def\thissubsecnum{0}%
1422       }%
1423       \def\numsecentry##1##2##3##4{%
1424         \advancenumber{chap\thischapnum}%
1425         \def\thissecnum{##2}%
1426         \def\thissubsecnum{0}%
1427       }%
1428       \def\numsubsecentry##1##2##3##4{%
1429         \advancenumber{sec\thissecnum}%
1430         \def\thissubsecnum{##2}%
1431       }%
1432       \def\numsubsubsecentry##1##2##3##4{%
1433         \advancenumber{subsec\thissubsecnum}%
1434       }%
1435       \def\thischapnum{0}%
1436       \def\thissecnum{0}%
1437       \def\thissubsecnum{0}%
1438       %
1439       % use \def rather than \let here because we redefine \chapentry et
1440       % al. a second time, below.
1441       \def\appentry{\numchapentry}%
1442       \def\appsecentry{\numsecentry}%
1443       \def\appsubsecentry{\numsubsecentry}%
1444       \def\appsubsubsecentry{\numsubsubsecentry}%
1445       \def\unnchapentry{\numchapentry}%
1446       \def\unnsecentry{\numsecentry}%
1447       \def\unnsubsecentry{\numsubsecentry}%
1448       \def\unnsubsubsecentry{\numsubsubsecentry}%
1449       \readdatafile{toc}%
1450       %
1451       % Read toc second time, this time actually producing the outlines.
1452       % The `-' means take the \expnumber as the absolute number of
1453       % subentries, which we calculated on our first read of the .toc above.
1454       %
1455       % We use the node names as the destinations.
1456       \def\numchapentry##1##2##3##4{%
1457         \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1458       \def\numsecentry##1##2##3##4{%
1459         \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1460       \def\numsubsecentry##1##2##3##4{%
1461         \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1462       \def\numsubsubsecentry##1##2##3##4{% count is always zero
1463         \dopdfoutline{##1}{}{##3}{##4}}%
1464       %
1465       % PDF outlines are displayed using system fonts, instead of
1466       % document fonts.  Therefore we cannot use special characters,
1467       % since the encoding is unknown.  For example, the eogonek from
1468       % Latin 2 (0xea) gets translated to a | character.  Info from
1469       % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1470       %
1471       % TODO this right, we have to translate 8-bit characters to
1472       % their "best" equivalent, based on the @documentencoding.  Too
1473       % much work for too little return.  Just use the ASCII equivalents
1474       % we use for the index sort strings.
1475       % 
1476       \indexnofonts
1477       \setupdatafile
1478       % We can have normal brace characters in the PDF outlines, unlike
1479       % Texinfo index files.  So set that up.
1480       \def\{{\lbracecharliteral}%
1481       \def\}{\rbracecharliteral}%
1482       \catcode`\\=\active \otherbackslash
1483       \input \tocreadfilename
1484     \endgroup
1485   }
1486   {\catcode`[=1 \catcode`]=2
1487    \catcode`{=\other \catcode`}=\other
1488    \gdef\lbracecharliteral[{]%
1489    \gdef\rbracecharliteral[}]%
1490   ]
1491   %
1492   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1493     \ifx\PP\D\let\nextsp\relax
1494     \else\let\nextsp\skipspaces
1495       \addtokens{\filename}{\PP}%
1496       \advance\filenamelength by 1
1497     \fi
1498     \nextsp}
1499   \def\getfilename#1{%
1500     \filenamelength=0
1501     % If we don't expand the argument now, \skipspaces will get
1502     % snagged on things like "@value{foo}".
1503     \edef\temp{#1}%
1504     \expandafter\skipspaces\temp|\relax
1505   }
1506   \ifnum\pdftexversion < 14
1507     \let \startlink \pdfannotlink
1508   \else
1509     \let \startlink \pdfstartlink
1510   \fi
1511   % make a live url in pdf output.
1512   \def\pdfurl#1{%
1513     \begingroup
1514       % it seems we really need yet another set of dummies; have not
1515       % tried to figure out what each command should do in the context
1516       % of @url.  for now, just make @/ a no-op, that's the only one
1517       % people have actually reported a problem with.
1518       %
1519       \normalturnoffactive
1520       \def\@{@}%
1521       \let\/=\empty
1522       \makevalueexpandable
1523       % do we want to go so far as to use \indexnofonts instead of just
1524       % special-casing \var here?
1525       \def\var##1{##1}%
1526       %
1527       \leavevmode\setcolor{\urlcolor}%
1528       \startlink attr{/Border [0 0 0]}%
1529         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1530     \endgroup}
1531   % \pdfgettoks - Surround page numbers in #1 with @pdflink.  #1 may
1532   % be a simple number, or a list of numbers in the case of an index
1533   % entry.
1534   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1535   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1536   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1537   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1538   \def\maketoks{%
1539     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1540     \ifx\first0\adn0
1541     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1542     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1543     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1544     \else
1545       \ifnum0=\countA\else\makelink\fi
1546       \ifx\first.\let\next=\done\else
1547         \let\next=\maketoks
1548         \addtokens{\toksB}{\the\toksD}
1549         \ifx\first,\addtokens{\toksB}{\space}\fi
1550       \fi
1551     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1552     \next}
1553   \def\makelink{\addtokens{\toksB}%
1554     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1555   \def\pdflink#1{%
1556     \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1557     \setcolor{\linkcolor}#1\endlink}
1558   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1559 \else
1560   % non-pdf mode
1561   \let\pdfmkdest = \gobble
1562   \let\pdfurl = \gobble
1563   \let\endlink = \relax
1564   \let\setcolor = \gobble
1565   \let\pdfsetcolor = \gobble
1566   \let\pdfmakeoutlines = \relax
1567 \fi  % \ifx\pdfoutput
1568
1569 %
1570 % For XeTeX
1571 %
1572 \ifx\XeTeXrevision\thisisundefined
1573 \else
1574   %
1575   % XeTeX version check
1576   %
1577   \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1
1578     % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307.
1579     % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941).
1580     % For avoiding PDF destination name replacement, we use this special
1581     % instead of xdvipdfmx's command line option `-C 0x0010'.
1582     \special{dvipdfmx:config C 0x0010}
1583     % XeTeX 0.99995+ comes with xdvipdfmx 20160307+.
1584     % It can handle Unicode destination names for PDF.
1585     \txiuseunicodedestnametrue
1586   \else
1587     % XeTeX < 0.99996 (TeX Live < 2016) cannot use the
1588     % `dvipdfmx:config' special.
1589     % So for avoiding PDF destination name replacement,
1590     % xdvipdfmx's command line option `-C 0x0010' is necessary.
1591     %
1592     % XeTeX < 0.99995 can not handle Unicode destination names for PDF
1593     % because xdvipdfmx 20150315 has a UTF-16 conversion issue.
1594     % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1595     \txiuseunicodedestnamefalse
1596   \fi
1597   %
1598   % Color support
1599   %
1600   \def\rgbDarkRed{0.50 0.09 0.12}
1601   \def\rgbBlack{0 0 0}
1602   %
1603   \def\pdfsetcolor#1{\special{pdf:scolor [#1]}}
1604   %
1605   % Set color, and create a mark which defines \thiscolor accordingly,
1606   % so that \makeheadline knows which color to restore.
1607   \def\setcolor#1{%
1608     \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
1609     \domark
1610     \pdfsetcolor{#1}%
1611   }
1612   %
1613   \def\maincolor{\rgbBlack}
1614   \pdfsetcolor{\maincolor}
1615   \edef\thiscolor{\maincolor}
1616   \def\lastcolordefs{}
1617   %
1618   \def\makefootline{%
1619     \baselineskip24pt
1620     \line{\pdfsetcolor{\maincolor}\the\footline}%
1621   }
1622   %
1623   \def\makeheadline{%
1624     \vbox to 0pt{%
1625       \vskip-22.5pt
1626       \line{%
1627         \vbox to8.5pt{}%
1628         % Extract \thiscolor definition from the marks.
1629         \getcolormarks
1630         % Typeset the headline with \maincolor, then restore the color.
1631         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1632       }%
1633       \vss
1634     }%
1635     \nointerlineskip
1636   }
1637   %
1638   % PDF outline support
1639   %
1640   % Emulate pdfTeX primitive
1641   \def\pdfdest name#1 xyz{%
1642     \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}%
1643   }
1644   %
1645   \def\setpdfdestname#1{{%
1646     % We have to set dummies so commands such as @code, and characters
1647     % such as \, aren't expanded when present in a section title.
1648     \indexnofonts
1649     \makevalueexpandable
1650     \turnoffactive
1651     \iftxiuseunicodedestname
1652       % Pass through Unicode characters.
1653     \else
1654       % Use ASCII approximations in destination names.
1655       \passthroughcharsfalse
1656     \fi
1657     \def\pdfdestname{#1}%
1658     \txiescapepdf\pdfdestname
1659   }}
1660   %
1661   \def\setpdfoutlinetext#1{{%
1662     \turnoffactive
1663     % Always use Unicode characters in title texts.
1664     \def\pdfoutlinetext{#1}%
1665     % For XeTeX, xdvipdfmx converts to UTF-16.
1666     % So we do not convert.
1667     \txiescapepdf\pdfoutlinetext
1668   }}
1669   %
1670   \def\pdfmkdest#1{%
1671     \setpdfdestname{#1}%
1672     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1673   }
1674   %
1675   % by default, use black for everything.
1676   \def\urlcolor{\rgbBlack}
1677   \def\linkcolor{\rgbBlack}
1678   \def\endlink{\setcolor{\maincolor}\pdfendlink}
1679   %
1680   \def\dopdfoutline#1#2#3#4{%
1681     \setpdfoutlinetext{#1}
1682     \setpdfdestname{#3}
1683     \ifx\pdfdestname\empty
1684       \def\pdfdestname{#4}%
1685     \fi
1686     %
1687     \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
1688       << /S /GoTo /D (\pdfdestname) >> >> }%
1689   }
1690   %
1691   \def\pdfmakeoutlines{%
1692     \begingroup
1693       %
1694       % For XeTeX, counts of subentries are not necessary.
1695       % Therefore, we read toc only once.
1696       %
1697       % We use node names as destinations.
1698       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1699       \def\numchapentry##1##2##3##4{%
1700         \dopdfoutline{##1}{1}{##3}{##4}}%
1701       \def\numsecentry##1##2##3##4{%
1702         \dopdfoutline{##1}{2}{##3}{##4}}%
1703       \def\numsubsecentry##1##2##3##4{%
1704         \dopdfoutline{##1}{3}{##3}{##4}}%
1705       \def\numsubsubsecentry##1##2##3##4{%
1706         \dopdfoutline{##1}{4}{##3}{##4}}%
1707       %
1708       \let\appentry\numchapentry%
1709       \let\appsecentry\numsecentry%
1710       \let\appsubsecentry\numsubsecentry%
1711       \let\appsubsubsecentry\numsubsubsecentry%
1712       \let\unnchapentry\numchapentry%
1713       \let\unnsecentry\numsecentry%
1714       \let\unnsubsecentry\numsubsecentry%
1715       \let\unnsubsubsecentry\numsubsubsecentry%
1716       %
1717       % For XeTeX, xdvipdfmx converts strings to UTF-16.
1718       % Therefore, the encoding and the language may not be considered.
1719       %
1720       \indexnofonts
1721       \setupdatafile
1722       % We can have normal brace characters in the PDF outlines, unlike
1723       % Texinfo index files.  So set that up.
1724       \def\{{\lbracecharliteral}%
1725       \def\}{\rbracecharliteral}%
1726       \catcode`\\=\active \otherbackslash
1727       \input \tocreadfilename
1728     \endgroup
1729   }
1730   {\catcode`[=1 \catcode`]=2
1731    \catcode`{=\other \catcode`}=\other
1732    \gdef\lbracecharliteral[{]%
1733    \gdef\rbracecharliteral[}]%
1734   ]
1735
1736   \special{pdf:docview << /PageMode /UseOutlines >> }
1737   % ``\special{pdf:tounicode ...}'' is not necessary
1738   % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
1739   % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315,
1740   % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings.
1741   % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1742 %
1743   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1744     \ifx\PP\D\let\nextsp\relax
1745     \else\let\nextsp\skipspaces
1746       \addtokens{\filename}{\PP}%
1747       \advance\filenamelength by 1
1748     \fi
1749     \nextsp}
1750   \def\getfilename#1{%
1751     \filenamelength=0
1752     % If we don't expand the argument now, \skipspaces will get
1753     % snagged on things like "@value{foo}".
1754     \edef\temp{#1}%
1755     \expandafter\skipspaces\temp|\relax
1756   }
1757   % make a live url in pdf output.
1758   \def\pdfurl#1{%
1759     \begingroup
1760       % it seems we really need yet another set of dummies; have not
1761       % tried to figure out what each command should do in the context
1762       % of @url.  for now, just make @/ a no-op, that's the only one
1763       % people have actually reported a problem with.
1764       %
1765       \normalturnoffactive
1766       \def\@{@}%
1767       \let\/=\empty
1768       \makevalueexpandable
1769       % do we want to go so far as to use \indexnofonts instead of just
1770       % special-casing \var here?
1771       \def\var##1{##1}%
1772       %
1773       \leavevmode\setcolor{\urlcolor}%
1774       \special{pdf:bann << /Border [0 0 0]
1775         /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
1776     \endgroup}
1777   \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
1778   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1779   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1780   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1781   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1782   \def\maketoks{%
1783     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1784     \ifx\first0\adn0
1785     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1786     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1787     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1788     \else
1789       \ifnum0=\countA\else\makelink\fi
1790       \ifx\first.\let\next=\done\else
1791         \let\next=\maketoks
1792         \addtokens{\toksB}{\the\toksD}
1793         \ifx\first,\addtokens{\toksB}{\space}\fi
1794       \fi
1795     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1796     \next}
1797   \def\makelink{\addtokens{\toksB}%
1798     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1799   \def\pdflink#1{%
1800     \special{pdf:bann << /Border [0 0 0]
1801       /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}%
1802     \setcolor{\linkcolor}#1\endlink}
1803   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1804 %
1805   %
1806   % @image support
1807   %
1808   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1809   \def\doxeteximage#1#2#3{%
1810     \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1811     \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1812     %
1813     % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among
1814     % others).  Let's try in that order, PDF first since if
1815     % someone has a scalable image, presumably better to use that than a
1816     % bitmap.
1817     \let\xeteximgext=\empty
1818     \begingroup
1819       \openin 1 #1.pdf \ifeof 1
1820         \openin 1 #1.PDF \ifeof 1
1821           \openin 1 #1.png \ifeof 1
1822             \openin 1 #1.jpg \ifeof 1
1823               \openin 1 #1.jpeg \ifeof 1
1824                 \openin 1 #1.JPG \ifeof 1
1825                   \errmessage{Could not find image file #1 for XeTeX}%
1826                 \else \gdef\xeteximgext{JPG}%
1827                 \fi
1828               \else \gdef\xeteximgext{jpeg}%
1829               \fi
1830             \else \gdef\xeteximgext{jpg}%
1831             \fi
1832           \else \gdef\xeteximgext{png}%
1833           \fi
1834         \else \gdef\xeteximgext{PDF}%
1835         \fi
1836       \else \gdef\xeteximgext{pdf}%
1837       \fi
1838       \closein 1
1839     \endgroup
1840     %
1841     \def\xetexpdfext{pdf}%
1842     \ifx\xeteximgext\xetexpdfext
1843       \XeTeXpdffile "#1".\xeteximgext ""
1844     \else
1845       \def\xetexpdfext{PDF}%
1846       \ifx\xeteximgext\xetexpdfext
1847         \XeTeXpdffile "#1".\xeteximgext ""
1848       \else
1849         \XeTeXpicfile "#1".\xeteximgext ""
1850       \fi
1851     \fi
1852     \ifdim \wd0 >0pt width \xeteximagewidth \fi
1853     \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1854   }
1855 \fi
1856
1857
1858 %
1859 \message{fonts,}
1860
1861 % Set the baselineskip to #1, and the lineskip and strut size
1862 % correspondingly.  There is no deep meaning behind these magic numbers
1863 % used as factors; they just match (closely enough) what Knuth defined.
1864 %
1865 \def\lineskipfactor{.08333}
1866 \def\strutheightpercent{.70833}
1867 \def\strutdepthpercent {.29167}
1868 %
1869 % can get a sort of poor man's double spacing by redefining this.
1870 \def\baselinefactor{1}
1871 %
1872 \newdimen\textleading
1873 \def\setleading#1{%
1874   \dimen0 = #1\relax
1875   \normalbaselineskip = \baselinefactor\dimen0
1876   \normallineskip = \lineskipfactor\normalbaselineskip
1877   \normalbaselines
1878   \setbox\strutbox =\hbox{%
1879     \vrule width0pt height\strutheightpercent\baselineskip
1880                     depth \strutdepthpercent \baselineskip
1881   }%
1882 }
1883
1884 % PDF CMaps.  See also LaTeX's t1.cmap.
1885 %
1886 % do nothing with this by default.
1887 \expandafter\let\csname cmapOT1\endcsname\gobble
1888 \expandafter\let\csname cmapOT1IT\endcsname\gobble
1889 \expandafter\let\csname cmapOT1TT\endcsname\gobble
1890
1891 % if we are producing pdf, and we have \pdffontattr, then define cmaps.
1892 % (\pdffontattr was introduced many years ago, but people still run
1893 % older pdftex's; it's easy to conditionalize, so we do.)
1894 \ifpdf \ifx\pdffontattr\thisisundefined \else
1895   \begingroup
1896     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1897     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1898 %%DocumentNeededResources: ProcSet (CIDInit)
1899 %%IncludeResource: ProcSet (CIDInit)
1900 %%BeginResource: CMap (TeX-OT1-0)
1901 %%Title: (TeX-OT1-0 TeX OT1 0)
1902 %%Version: 1.000
1903 %%EndComments
1904 /CIDInit /ProcSet findresource begin
1905 12 dict begin
1906 begincmap
1907 /CIDSystemInfo
1908 << /Registry (TeX)
1909 /Ordering (OT1)
1910 /Supplement 0
1911 >> def
1912 /CMapName /TeX-OT1-0 def
1913 /CMapType 2 def
1914 1 begincodespacerange
1915 <00> <7F>
1916 endcodespacerange
1917 8 beginbfrange
1918 <00> <01> <0393>
1919 <09> <0A> <03A8>
1920 <23> <26> <0023>
1921 <28> <3B> <0028>
1922 <3F> <5B> <003F>
1923 <5D> <5E> <005D>
1924 <61> <7A> <0061>
1925 <7B> <7C> <2013>
1926 endbfrange
1927 40 beginbfchar
1928 <02> <0398>
1929 <03> <039B>
1930 <04> <039E>
1931 <05> <03A0>
1932 <06> <03A3>
1933 <07> <03D2>
1934 <08> <03A6>
1935 <0B> <00660066>
1936 <0C> <00660069>
1937 <0D> <0066006C>
1938 <0E> <006600660069>
1939 <0F> <00660066006C>
1940 <10> <0131>
1941 <11> <0237>
1942 <12> <0060>
1943 <13> <00B4>
1944 <14> <02C7>
1945 <15> <02D8>
1946 <16> <00AF>
1947 <17> <02DA>
1948 <18> <00B8>
1949 <19> <00DF>
1950 <1A> <00E6>
1951 <1B> <0153>
1952 <1C> <00F8>
1953 <1D> <00C6>
1954 <1E> <0152>
1955 <1F> <00D8>
1956 <21> <0021>
1957 <22> <201D>
1958 <27> <2019>
1959 <3C> <00A1>
1960 <3D> <003D>
1961 <3E> <00BF>
1962 <5C> <201C>
1963 <5F> <02D9>
1964 <60> <2018>
1965 <7D> <02DD>
1966 <7E> <007E>
1967 <7F> <00A8>
1968 endbfchar
1969 endcmap
1970 CMapName currentdict /CMap defineresource pop
1971 end
1972 end
1973 %%EndResource
1974 %%EOF
1975     }\endgroup
1976   \expandafter\edef\csname cmapOT1\endcsname#1{%
1977     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1978   }%
1979 %
1980 % \cmapOT1IT
1981   \begingroup
1982     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1983     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1984 %%DocumentNeededResources: ProcSet (CIDInit)
1985 %%IncludeResource: ProcSet (CIDInit)
1986 %%BeginResource: CMap (TeX-OT1IT-0)
1987 %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
1988 %%Version: 1.000
1989 %%EndComments
1990 /CIDInit /ProcSet findresource begin
1991 12 dict begin
1992 begincmap
1993 /CIDSystemInfo
1994 << /Registry (TeX)
1995 /Ordering (OT1IT)
1996 /Supplement 0
1997 >> def
1998 /CMapName /TeX-OT1IT-0 def
1999 /CMapType 2 def
2000 1 begincodespacerange
2001 <00> <7F>
2002 endcodespacerange
2003 8 beginbfrange
2004 <00> <01> <0393>
2005 <09> <0A> <03A8>
2006 <25> <26> <0025>
2007 <28> <3B> <0028>
2008 <3F> <5B> <003F>
2009 <5D> <5E> <005D>
2010 <61> <7A> <0061>
2011 <7B> <7C> <2013>
2012 endbfrange
2013 42 beginbfchar
2014 <02> <0398>
2015 <03> <039B>
2016 <04> <039E>
2017 <05> <03A0>
2018 <06> <03A3>
2019 <07> <03D2>
2020 <08> <03A6>
2021 <0B> <00660066>
2022 <0C> <00660069>
2023 <0D> <0066006C>
2024 <0E> <006600660069>
2025 <0F> <00660066006C>
2026 <10> <0131>
2027 <11> <0237>
2028 <12> <0060>
2029 <13> <00B4>
2030 <14> <02C7>
2031 <15> <02D8>
2032 <16> <00AF>
2033 <17> <02DA>
2034 <18> <00B8>
2035 <19> <00DF>
2036 <1A> <00E6>
2037 <1B> <0153>
2038 <1C> <00F8>
2039 <1D> <00C6>
2040 <1E> <0152>
2041 <1F> <00D8>
2042 <21> <0021>
2043 <22> <201D>
2044 <23> <0023>
2045 <24> <00A3>
2046 <27> <2019>
2047 <3C> <00A1>
2048 <3D> <003D>
2049 <3E> <00BF>
2050 <5C> <201C>
2051 <5F> <02D9>
2052 <60> <2018>
2053 <7D> <02DD>
2054 <7E> <007E>
2055 <7F> <00A8>
2056 endbfchar
2057 endcmap
2058 CMapName currentdict /CMap defineresource pop
2059 end
2060 end
2061 %%EndResource
2062 %%EOF
2063     }\endgroup
2064   \expandafter\edef\csname cmapOT1IT\endcsname#1{%
2065     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2066   }%
2067 %
2068 % \cmapOT1TT
2069   \begingroup
2070     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2071     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2072 %%DocumentNeededResources: ProcSet (CIDInit)
2073 %%IncludeResource: ProcSet (CIDInit)
2074 %%BeginResource: CMap (TeX-OT1TT-0)
2075 %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
2076 %%Version: 1.000
2077 %%EndComments
2078 /CIDInit /ProcSet findresource begin
2079 12 dict begin
2080 begincmap
2081 /CIDSystemInfo
2082 << /Registry (TeX)
2083 /Ordering (OT1TT)
2084 /Supplement 0
2085 >> def
2086 /CMapName /TeX-OT1TT-0 def
2087 /CMapType 2 def
2088 1 begincodespacerange
2089 <00> <7F>
2090 endcodespacerange
2091 5 beginbfrange
2092 <00> <01> <0393>
2093 <09> <0A> <03A8>
2094 <21> <26> <0021>
2095 <28> <5F> <0028>
2096 <61> <7E> <0061>
2097 endbfrange
2098 32 beginbfchar
2099 <02> <0398>
2100 <03> <039B>
2101 <04> <039E>
2102 <05> <03A0>
2103 <06> <03A3>
2104 <07> <03D2>
2105 <08> <03A6>
2106 <0B> <2191>
2107 <0C> <2193>
2108 <0D> <0027>
2109 <0E> <00A1>
2110 <0F> <00BF>
2111 <10> <0131>
2112 <11> <0237>
2113 <12> <0060>
2114 <13> <00B4>
2115 <14> <02C7>
2116 <15> <02D8>
2117 <16> <00AF>
2118 <17> <02DA>
2119 <18> <00B8>
2120 <19> <00DF>
2121 <1A> <00E6>
2122 <1B> <0153>
2123 <1C> <00F8>
2124 <1D> <00C6>
2125 <1E> <0152>
2126 <1F> <00D8>
2127 <20> <2423>
2128 <27> <2019>
2129 <60> <2018>
2130 <7F> <00A8>
2131 endbfchar
2132 endcmap
2133 CMapName currentdict /CMap defineresource pop
2134 end
2135 end
2136 %%EndResource
2137 %%EOF
2138     }\endgroup
2139   \expandafter\edef\csname cmapOT1TT\endcsname#1{%
2140     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2141   }%
2142 \fi\fi
2143
2144
2145 % Set the font macro #1 to the font named \fontprefix#2.
2146 % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
2147 % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
2148 % Example:
2149 % #1 = \textrm
2150 % #2 = \rmshape
2151 % #3 = 10
2152 % #4 = \mainmagstep
2153 % #5 = OT1
2154 %
2155 \def\setfont#1#2#3#4#5{%
2156   \font#1=\fontprefix#2#3 scaled #4
2157   \csname cmap#5\endcsname#1%
2158 }
2159 % This is what gets called when #5 of \setfont is empty.
2160 \let\cmap\gobble
2161 %
2162 % (end of cmaps)
2163
2164 % Use cm as the default font prefix.
2165 % To specify the font prefix, you must define \fontprefix
2166 % before you read in texinfo.tex.
2167 \ifx\fontprefix\thisisundefined
2168 \def\fontprefix{cm}
2169 \fi
2170 % Support font families that don't use the same naming scheme as CM.
2171 \def\rmshape{r}
2172 \def\rmbshape{bx}               % where the normal face is bold
2173 \def\bfshape{b}
2174 \def\bxshape{bx}
2175 \def\ttshape{tt}
2176 \def\ttbshape{tt}
2177 \def\ttslshape{sltt}
2178 \def\itshape{ti}
2179 \def\itbshape{bxti}
2180 \def\slshape{sl}
2181 \def\slbshape{bxsl}
2182 \def\sfshape{ss}
2183 \def\sfbshape{ss}
2184 \def\scshape{csc}
2185 \def\scbshape{csc}
2186
2187 % Definitions for a main text size of 11pt.  (The default in Texinfo.)
2188 %
2189 \def\definetextfontsizexi{%
2190 % Text fonts (11.2pt, magstep1).
2191 \def\textnominalsize{11pt}
2192 \edef\mainmagstep{\magstephalf}
2193 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2194 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2195 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2196 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2197 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2198 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2199 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2200 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2201 \font\texti=cmmi10 scaled \mainmagstep
2202 \font\textsy=cmsy10 scaled \mainmagstep
2203 \def\textecsize{1095}
2204
2205 % A few fonts for @defun names and args.
2206 \setfont\defbf\bfshape{10}{\magstep1}{OT1}
2207 \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
2208 \setfont\defsl\slshape{10}{\magstep1}{OT1TT}
2209 \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
2210 \def\df{\let\ttfont=\deftt \let\bffont = \defbf
2211 \let\ttslfont=\defttsl \let\slfont=\defsl \bf}
2212
2213 % Fonts for indices, footnotes, small examples (9pt).
2214 \def\smallnominalsize{9pt}
2215 \setfont\smallrm\rmshape{9}{1000}{OT1}
2216 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2217 \setfont\smallbf\bfshape{10}{900}{OT1}
2218 \setfont\smallit\itshape{9}{1000}{OT1IT}
2219 \setfont\smallsl\slshape{9}{1000}{OT1}
2220 \setfont\smallsf\sfshape{9}{1000}{OT1}
2221 \setfont\smallsc\scshape{10}{900}{OT1}
2222 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2223 \font\smalli=cmmi9
2224 \font\smallsy=cmsy9
2225 \def\smallecsize{0900}
2226
2227 % Fonts for small examples (8pt).
2228 \def\smallernominalsize{8pt}
2229 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2230 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2231 \setfont\smallerbf\bfshape{10}{800}{OT1}
2232 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2233 \setfont\smallersl\slshape{8}{1000}{OT1}
2234 \setfont\smallersf\sfshape{8}{1000}{OT1}
2235 \setfont\smallersc\scshape{10}{800}{OT1}
2236 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2237 \font\smalleri=cmmi8
2238 \font\smallersy=cmsy8
2239 \def\smallerecsize{0800}
2240
2241 % Fonts for math mode superscripts (7pt).
2242 \def\sevennominalsize{7pt}
2243 \setfont\sevenrm\rmshape{7}{1000}{OT1}
2244 \setfont\seventt\ttshape{10}{700}{OT1TT}
2245 \setfont\sevenbf\bfshape{10}{700}{OT1}
2246 \setfont\sevenit\itshape{7}{1000}{OT1IT}
2247 \setfont\sevensl\slshape{10}{700}{OT1}
2248 \setfont\sevensf\sfshape{10}{700}{OT1}
2249 \setfont\sevensc\scshape{10}{700}{OT1}
2250 \setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2251 \font\seveni=cmmi7
2252 \font\sevensy=cmsy7
2253 \def\sevenecsize{0700}
2254
2255 % Fonts for title page (20.4pt):
2256 \def\titlenominalsize{20pt}
2257 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2258 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2259 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2260 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2261 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2262 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2263 \let\titlebf=\titlerm
2264 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2265 \font\titlei=cmmi12 scaled \magstep3
2266 \font\titlesy=cmsy10 scaled \magstep4
2267 \def\titleecsize{2074}
2268
2269 % Chapter (and unnumbered) fonts (17.28pt).
2270 \def\chapnominalsize{17pt}
2271 \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2272 \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2273 \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2274 \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2275 \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2276 \setfont\chapsf\sfbshape{17}{1000}{OT1}
2277 \let\chapbf=\chaprm
2278 \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
2279 \font\chapi=cmmi12 scaled \magstep2
2280 \font\chapsy=cmsy10 scaled \magstep3
2281 \def\chapecsize{1728}
2282
2283 % Section fonts (14.4pt).
2284 \def\secnominalsize{14pt}
2285 \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
2286 \setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
2287 \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2288 \setfont\secsl\slbshape{10}{\magstep2}{OT1}
2289 \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2290 \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2291 \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
2292 \let\secbf\secrm
2293 \setfont\secsc\scbshape{10}{\magstep2}{OT1}
2294 \font\seci=cmmi12 scaled \magstep1
2295 \font\secsy=cmsy10 scaled \magstep2
2296 \def\sececsize{1440}
2297
2298 % Subsection fonts (13.15pt).
2299 \def\ssecnominalsize{13pt}
2300 \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2301 \setfont\ssecit\itbshape{10}{1315}{OT1IT}
2302 \setfont\ssecsl\slbshape{10}{1315}{OT1}
2303 \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2304 \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2305 \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
2306 \let\ssecbf\ssecrm
2307 \setfont\ssecsc\scbshape{10}{1315}{OT1}
2308 \font\sseci=cmmi12 scaled \magstephalf
2309 \font\ssecsy=cmsy10 scaled 1315
2310 \def\ssececsize{1200}
2311
2312 % Reduced fonts for @acronym in text (10pt).
2313 \def\reducednominalsize{10pt}
2314 \setfont\reducedrm\rmshape{10}{1000}{OT1}
2315 \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2316 \setfont\reducedbf\bfshape{10}{1000}{OT1}
2317 \setfont\reducedit\itshape{10}{1000}{OT1IT}
2318 \setfont\reducedsl\slshape{10}{1000}{OT1}
2319 \setfont\reducedsf\sfshape{10}{1000}{OT1}
2320 \setfont\reducedsc\scshape{10}{1000}{OT1}
2321 \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
2322 \font\reducedi=cmmi10
2323 \font\reducedsy=cmsy10
2324 \def\reducedecsize{1000}
2325
2326 \textleading = 13.2pt % line spacing for 11pt CM
2327 \textfonts            % reset the current fonts
2328 \rm
2329 } % end of 11pt text font size definitions, \definetextfontsizexi
2330
2331
2332 % Definitions to make the main text be 10pt Computer Modern, with
2333 % section, chapter, etc., sizes following suit.  This is for the GNU
2334 % Press printing of the Emacs 22 manual.  Maybe other manuals in the
2335 % future.  Used with @smallbook, which sets the leading to 12pt.
2336 %
2337 \def\definetextfontsizex{%
2338 % Text fonts (10pt).
2339 \def\textnominalsize{10pt}
2340 \edef\mainmagstep{1000}
2341 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2342 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2343 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2344 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2345 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2346 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2347 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2348 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2349 \font\texti=cmmi10 scaled \mainmagstep
2350 \font\textsy=cmsy10 scaled \mainmagstep
2351 \def\textecsize{1000}
2352
2353 % A few fonts for @defun names and args.
2354 \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2355 \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
2356 \setfont\defsl\slshape{10}{\magstephalf}{OT1TT}
2357 \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
2358 \def\df{\let\ttfont=\deftt \let\bffont = \defbf
2359 \let\slfont=\defsl \let\ttslfont=\defttsl \bf}
2360
2361 % Fonts for indices, footnotes, small examples (9pt).
2362 \def\smallnominalsize{9pt}
2363 \setfont\smallrm\rmshape{9}{1000}{OT1}
2364 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2365 \setfont\smallbf\bfshape{10}{900}{OT1}
2366 \setfont\smallit\itshape{9}{1000}{OT1IT}
2367 \setfont\smallsl\slshape{9}{1000}{OT1}
2368 \setfont\smallsf\sfshape{9}{1000}{OT1}
2369 \setfont\smallsc\scshape{10}{900}{OT1}
2370 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2371 \font\smalli=cmmi9
2372 \font\smallsy=cmsy9
2373 \def\smallecsize{0900}
2374
2375 % Fonts for small examples (8pt).
2376 \def\smallernominalsize{8pt}
2377 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2378 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2379 \setfont\smallerbf\bfshape{10}{800}{OT1}
2380 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2381 \setfont\smallersl\slshape{8}{1000}{OT1}
2382 \setfont\smallersf\sfshape{8}{1000}{OT1}
2383 \setfont\smallersc\scshape{10}{800}{OT1}
2384 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2385 \font\smalleri=cmmi8
2386 \font\smallersy=cmsy8
2387 \def\smallerecsize{0800}
2388
2389 % Fonts for math mode superscripts (7pt).
2390 \def\sevennominalsize{7pt}
2391 \setfont\sevenrm\rmshape{7}{1000}{OT1}
2392 \setfont\seventt\ttshape{10}{700}{OT1TT}
2393 \setfont\sevenbf\bfshape{10}{700}{OT1}
2394 \setfont\sevenit\itshape{7}{1000}{OT1IT}
2395 \setfont\sevensl\slshape{10}{700}{OT1}
2396 \setfont\sevensf\sfshape{10}{700}{OT1}
2397 \setfont\sevensc\scshape{10}{700}{OT1}
2398 \setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2399 \font\seveni=cmmi7
2400 \font\sevensy=cmsy7
2401 \def\sevenecsize{0700}
2402
2403 % Fonts for title page (20.4pt):
2404 \def\titlenominalsize{20pt}
2405 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2406 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2407 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2408 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2409 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2410 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2411 \let\titlebf=\titlerm
2412 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2413 \font\titlei=cmmi12 scaled \magstep3
2414 \font\titlesy=cmsy10 scaled \magstep4
2415 \def\titleecsize{2074}
2416
2417 % Chapter fonts (14.4pt).
2418 \def\chapnominalsize{14pt}
2419 \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2420 \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2421 \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2422 \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2423 \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2424 \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2425 \let\chapbf\chaprm
2426 \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2427 \font\chapi=cmmi12 scaled \magstep1
2428 \font\chapsy=cmsy10 scaled \magstep2
2429 \def\chapecsize{1440}
2430
2431 % Section fonts (12pt).
2432 \def\secnominalsize{12pt}
2433 \setfont\secrm\rmbshape{12}{1000}{OT1}
2434 \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2435 \setfont\secsl\slbshape{10}{\magstep1}{OT1}
2436 \setfont\sectt\ttbshape{12}{1000}{OT1TT}
2437 \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2438 \setfont\secsf\sfbshape{12}{1000}{OT1}
2439 \let\secbf\secrm
2440 \setfont\secsc\scbshape{10}{\magstep1}{OT1}
2441 \font\seci=cmmi12
2442 \font\secsy=cmsy10 scaled \magstep1
2443 \def\sececsize{1200}
2444
2445 % Subsection fonts (10pt).
2446 \def\ssecnominalsize{10pt}
2447 \setfont\ssecrm\rmbshape{10}{1000}{OT1}
2448 \setfont\ssecit\itbshape{10}{1000}{OT1IT}
2449 \setfont\ssecsl\slbshape{10}{1000}{OT1}
2450 \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2451 \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2452 \setfont\ssecsf\sfbshape{10}{1000}{OT1}
2453 \let\ssecbf\ssecrm
2454 \setfont\ssecsc\scbshape{10}{1000}{OT1}
2455 \font\sseci=cmmi10
2456 \font\ssecsy=cmsy10
2457 \def\ssececsize{1000}
2458
2459 % Reduced fonts for @acronym in text (9pt).
2460 \def\reducednominalsize{9pt}
2461 \setfont\reducedrm\rmshape{9}{1000}{OT1}
2462 \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2463 \setfont\reducedbf\bfshape{10}{900}{OT1}
2464 \setfont\reducedit\itshape{9}{1000}{OT1IT}
2465 \setfont\reducedsl\slshape{9}{1000}{OT1}
2466 \setfont\reducedsf\sfshape{9}{1000}{OT1}
2467 \setfont\reducedsc\scshape{10}{900}{OT1}
2468 \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2469 \font\reducedi=cmmi9
2470 \font\reducedsy=cmsy9
2471 \def\reducedecsize{0900}
2472
2473 \divide\parskip by 2  % reduce space between paragraphs
2474 \textleading = 12pt   % line spacing for 10pt CM
2475 \textfonts            % reset the current fonts
2476 \rm
2477 } % end of 10pt text font size definitions, \definetextfontsizex
2478
2479 % Fonts for short table of contents.
2480 \setfont\shortcontrm\rmshape{12}{1000}{OT1}
2481 \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
2482 \setfont\shortcontsl\slshape{12}{1000}{OT1}
2483 \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2484
2485
2486 % We provide the user-level command
2487 %   @fonttextsize 10
2488 % (or 11) to redefine the text font size.  pt is assumed.
2489 %
2490 \def\xiword{11}
2491 \def\xword{10}
2492 \def\xwordpt{10pt}
2493 %
2494 \parseargdef\fonttextsize{%
2495   \def\textsizearg{#1}%
2496   %\wlog{doing @fonttextsize \textsizearg}%
2497   %
2498   % Set \globaldefs so that documents can use this inside @tex, since
2499   % makeinfo 4.8 does not support it, but we need it nonetheless.
2500   %
2501  \begingroup \globaldefs=1
2502   \ifx\textsizearg\xword \definetextfontsizex
2503   \else \ifx\textsizearg\xiword \definetextfontsizexi
2504   \else
2505     \errhelp=\EMsimple
2506     \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2507   \fi\fi
2508  \endgroup
2509 }
2510
2511 %
2512 % Change the current font style to #1, remembering it in \curfontstyle.
2513 % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
2514 % italics, not bold italics.
2515 %
2516 \def\setfontstyle#1{%
2517   \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
2518   \csname #1font\endcsname  % change the current font
2519 }
2520
2521 \def\rm{\fam=0 \setfontstyle{rm}}
2522 \def\it{\fam=\itfam \setfontstyle{it}}
2523 \def\sl{\fam=\slfam \setfontstyle{sl}}
2524 \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
2525 \def\tt{\fam=\ttfam \setfontstyle{tt}}
2526
2527 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
2528 % So we set up a \sf.
2529 \newfam\sffam
2530 \def\sf{\fam=\sffam \setfontstyle{sf}}
2531
2532 % We don't need math for this font style.
2533 \def\ttsl{\setfontstyle{ttsl}}
2534
2535
2536 % In order for the font changes to affect most math symbols and letters,
2537 % we have to define the \textfont of the standard families.
2538 % We don't bother to reset \scriptscriptfont; awaiting user need.
2539 %
2540 \def\resetmathfonts{%
2541   \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont
2542   \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont
2543   \textfont\ttfam=\ttfont \textfont\sffam=\sffont
2544   %
2545   % Fonts for superscript.  Note that the 7pt fonts are used regardless
2546   % of the current font size.
2547   \scriptfont0=\sevenrm \scriptfont1=\seveni \scriptfont2=\sevensy
2548   \scriptfont\itfam=\sevenit \scriptfont\slfam=\sevensl
2549   \scriptfont\bffam=\sevenbf \scriptfont\ttfam=\seventt
2550   \scriptfont\sffam=\sevensf
2551 }
2552
2553 %
2554
2555 % The font-changing commands (all called \...fonts) redefine the meanings
2556 % of \STYLEfont, instead of just \STYLE.  We do this because \STYLE needs
2557 % to also set the current \fam for math mode.  Our \STYLE (e.g., \rm)
2558 % commands hardwire \STYLEfont to set the current font.
2559 %
2560 % The fonts used for \ifont are for "math italics"  (\itfont is for italics
2561 % in regular text).  \syfont is also used in math mode only.
2562 %
2563 % Each font-changing command also sets the names \lsize (one size lower)
2564 % and \lllsize (three sizes lower).  These relative commands are used
2565 % in, e.g., the LaTeX logo and acronyms.
2566 %
2567 % This all needs generalizing, badly.
2568 %
2569
2570 \def\assignfonts#1{%
2571   \expandafter\let\expandafter\rmfont\csname #1rm\endcsname
2572   \expandafter\let\expandafter\itfont\csname #1it\endcsname
2573   \expandafter\let\expandafter\slfont\csname #1sl\endcsname
2574   \expandafter\let\expandafter\bffont\csname #1bf\endcsname
2575   \expandafter\let\expandafter\ttfont\csname #1tt\endcsname
2576   \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname
2577   \expandafter\let\expandafter\sffont  \csname #1sf\endcsname
2578   \expandafter\let\expandafter\ifont   \csname #1i\endcsname
2579   \expandafter\let\expandafter\syfont  \csname #1sy\endcsname
2580   \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname
2581 }
2582
2583 \newif\ifrmisbold
2584
2585 % Select smaller font size with the current style.  Used to change font size
2586 % in, e.g., the LaTeX logo and acronyms.  If we are using bold fonts for
2587 % normal roman text, also use bold fonts for roman text in the smaller size.
2588 \def\switchtolllsize{%
2589    \expandafter\assignfonts\expandafter{\lllsize}%
2590    \ifrmisbold
2591      \let\rmfont\bffont
2592    \fi
2593    \csname\curfontstyle\endcsname
2594 }%
2595
2596 \def\switchtolsize{%
2597    \expandafter\assignfonts\expandafter{\lsize}%
2598    \ifrmisbold
2599      \let\rmfont\bffont
2600    \fi
2601    \csname\curfontstyle\endcsname
2602 }%
2603
2604 \def\definefontsetatsize#1#2#3#4#5{%
2605 \expandafter\def\csname #1fonts\endcsname{%
2606   \def\curfontsize{#1}%
2607   \def\lsize{#2}\def\lllsize{#3}%
2608   \csname rmisbold#5\endcsname
2609   \assignfonts{#1}%
2610   \resetmathfonts
2611   \setleading{#4}%
2612 }}
2613
2614 \definefontsetatsize{text}   {reduced}{smaller}{\textleading}{false}
2615 \definefontsetatsize{title}  {chap}   {subsec} {27pt}  {true}
2616 \definefontsetatsize{chap}   {sec}    {text}   {19pt}  {true}
2617 \definefontsetatsize{sec}    {subsec} {reduced}{17pt}  {true}
2618 \definefontsetatsize{ssec}   {text}   {small}  {15pt}  {true}
2619 \definefontsetatsize{reduced}{small}  {smaller}{10.5pt}{false}
2620 \definefontsetatsize{small}  {smaller}{smaller}{10.5pt}{false}
2621 \definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false}
2622
2623 \def\titlefont#1{{\titlefonts\rm #1}}
2624 \let\subsecfonts = \ssecfonts
2625 \let\subsubsecfonts = \ssecfonts
2626
2627 % Define these just so they can be easily changed for other fonts.
2628 \def\angleleft{$\langle$}
2629 \def\angleright{$\rangle$}
2630
2631 % Set the fonts to use with the @small... environments.
2632 \let\smallexamplefonts = \smallfonts
2633
2634 % About \smallexamplefonts.  If we use \smallfonts (9pt), @smallexample
2635 % can fit this many characters:
2636 %   8.5x11=86   smallbook=72  a4=90  a5=69
2637 % If we use \scriptfonts (8pt), then we can fit this many characters:
2638 %   8.5x11=90+  smallbook=80  a4=90+  a5=77
2639 % For me, subjectively, the few extra characters that fit aren't worth
2640 % the additional smallness of 8pt.  So I'm making the default 9pt.
2641 %
2642 % By the way, for comparison, here's what fits with @example (10pt):
2643 %   8.5x11=71  smallbook=60  a4=75  a5=58
2644 % --karl, 24jan03.
2645
2646 % Set up the default fonts, so we can use them for creating boxes.
2647 %
2648 \definetextfontsizexi
2649
2650
2651 \message{markup,}
2652
2653 % Check if we are currently using a typewriter font.  Since all the
2654 % Computer Modern typewriter fonts have zero interword stretch (and
2655 % shrink), and it is reasonable to expect all typewriter fonts to have
2656 % this property, we can check that font parameter.
2657 %
2658 \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
2659
2660 % Markup style infrastructure.  \defmarkupstylesetup\INITMACRO will
2661 % define and register \INITMACRO to be called on markup style changes.
2662 % \INITMACRO can check \currentmarkupstyle for the innermost
2663 % style.
2664
2665 \let\currentmarkupstyle\empty
2666
2667 \def\setupmarkupstyle#1{%
2668   \def\currentmarkupstyle{#1}%
2669   \markupstylesetup
2670 }
2671
2672 \let\markupstylesetup\empty
2673
2674 \def\defmarkupstylesetup#1{%
2675   \expandafter\def\expandafter\markupstylesetup
2676     \expandafter{\markupstylesetup #1}%
2677   \def#1%
2678 }
2679
2680 % Markup style setup for left and right quotes.
2681 \defmarkupstylesetup\markupsetuplq{%
2682   \expandafter\let\expandafter \temp
2683     \csname markupsetuplq\currentmarkupstyle\endcsname
2684   \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
2685 }
2686
2687 \defmarkupstylesetup\markupsetuprq{%
2688   \expandafter\let\expandafter \temp
2689     \csname markupsetuprq\currentmarkupstyle\endcsname
2690   \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
2691 }
2692
2693 {
2694 \catcode`\'=\active
2695 \catcode`\`=\active
2696
2697 \gdef\markupsetuplqdefault{\let`\lq}
2698 \gdef\markupsetuprqdefault{\let'\rq}
2699
2700 \gdef\markupsetcodequoteleft{\let`\codequoteleft}
2701 \gdef\markupsetcodequoteright{\let'\codequoteright}
2702 }
2703
2704 \let\markupsetuplqcode \markupsetcodequoteleft
2705 \let\markupsetuprqcode \markupsetcodequoteright
2706 %
2707 \let\markupsetuplqexample \markupsetcodequoteleft
2708 \let\markupsetuprqexample \markupsetcodequoteright
2709 %
2710 \let\markupsetuplqkbd     \markupsetcodequoteleft
2711 \let\markupsetuprqkbd     \markupsetcodequoteright
2712 %
2713 \let\markupsetuplqsamp \markupsetcodequoteleft
2714 \let\markupsetuprqsamp \markupsetcodequoteright
2715 %
2716 \let\markupsetuplqverb \markupsetcodequoteleft
2717 \let\markupsetuprqverb \markupsetcodequoteright
2718 %
2719 \let\markupsetuplqverbatim \markupsetcodequoteleft
2720 \let\markupsetuprqverbatim \markupsetcodequoteright
2721
2722 % Allow an option to not use regular directed right quote/apostrophe
2723 % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2724 % The undirected quote is ugly, so don't make it the default, but it
2725 % works for pasting with more pdf viewers (at least evince), the
2726 % lilypond developers report.  xpdf does work with the regular 0x27.
2727 %
2728 \def\codequoteright{%
2729   \ifmonospace
2730     \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
2731       \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
2732         '%
2733       \else \char'15 \fi
2734     \else \char'15 \fi
2735    \else
2736      '%
2737    \fi
2738 }
2739 %
2740 % and a similar option for the left quote char vs. a grave accent.
2741 % Modern fonts display ASCII 0x60 as a grave accent, so some people like
2742 % the code environments to do likewise.
2743 %
2744 \def\codequoteleft{%
2745   \ifmonospace
2746     \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
2747       \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
2748         % [Knuth] pp. 380,381,391
2749         % \relax disables Spanish ligatures ?` and !` of \tt font.
2750         \relax`%
2751       \else \char'22 \fi
2752     \else \char'22 \fi
2753    \else
2754      \relax`%
2755    \fi
2756 }
2757
2758 % Commands to set the quote options.
2759
2760 \parseargdef\codequoteundirected{%
2761   \def\temp{#1}%
2762   \ifx\temp\onword
2763     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2764       = t%
2765   \else\ifx\temp\offword
2766     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2767       = \relax
2768   \else
2769     \errhelp = \EMsimple
2770     \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2771   \fi\fi
2772 }
2773 %
2774 \parseargdef\codequotebacktick{%
2775   \def\temp{#1}%
2776   \ifx\temp\onword
2777     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2778       = t%
2779   \else\ifx\temp\offword
2780     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2781       = \relax
2782   \else
2783     \errhelp = \EMsimple
2784     \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2785   \fi\fi
2786 }
2787
2788 % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2789 \def\noligaturesquoteleft{\relax\lq}
2790
2791 % Count depth in font-changes, for error checks
2792 \newcount\fontdepth \fontdepth=0
2793
2794 % Font commands.
2795
2796 % #1 is the font command (\sl or \it), #2 is the text to slant.
2797 % If we are in a monospaced environment, however, 1) always use \ttsl,
2798 % and 2) do not add an italic correction.
2799 \def\dosmartslant#1#2{%
2800   \ifusingtt 
2801     {{\ttsl #2}\let\next=\relax}%
2802     {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
2803   \next
2804 }
2805 \def\smartslanted{\dosmartslant\sl}
2806 \def\smartitalic{\dosmartslant\it}
2807
2808 % Output an italic correction unless \next (presumed to be the following
2809 % character) is such as not to need one.
2810 \def\smartitaliccorrection{%
2811   \ifx\next,%
2812   \else\ifx\next-%
2813   \else\ifx\next.%
2814   \else\ifx\next\.%
2815   \else\ifx\next\comma%
2816   \else\ptexslash
2817   \fi\fi\fi\fi\fi
2818   \aftersmartic
2819 }
2820
2821 % Unconditional use \ttsl, and no ic.  @var is set to this for defuns.
2822 \def\ttslanted#1{{\ttsl #1}}
2823
2824 % @cite is like \smartslanted except unconditionally use \sl.  We never want
2825 % ttsl for book titles, do we?
2826 \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
2827
2828 \def\aftersmartic{}
2829 \def\var#1{%
2830   \let\saveaftersmartic = \aftersmartic
2831   \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
2832   \smartslanted{#1}%
2833 }
2834
2835 \let\i=\smartitalic
2836 \let\slanted=\smartslanted
2837 \let\dfn=\smartslanted
2838 \let\emph=\smartitalic
2839
2840 % Explicit font changes: @r, @sc, undocumented @ii.
2841 \def\r#1{{\rm #1}}              % roman font
2842 \def\sc#1{{\smallcaps#1}}       % smallcaps font
2843 \def\ii#1{{\it #1}}             % italic font
2844
2845 % @b, explicit bold.  Also @strong.
2846 \def\b#1{{\bf #1}}
2847 \let\strong=\b
2848
2849 % @sansserif, explicit sans.
2850 \def\sansserif#1{{\sf #1}}
2851
2852 % We can't just use \exhyphenpenalty, because that only has effect at
2853 % the end of a paragraph.  Restore normal hyphenation at the end of the
2854 % group within which \nohyphenation is presumably called.
2855 %
2856 \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
2857 \def\restorehyphenation{\hyphenchar\font = `- }
2858
2859 % Set sfcode to normal for the chars that usually have another value.
2860 % Can't use plain's \frenchspacing because it uses the `\x notation, and
2861 % sometimes \x has an active definition that messes things up.
2862 %
2863 \catcode`@=11
2864   \def\plainfrenchspacing{%
2865     \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
2866     \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
2867     \def\endofsentencespacefactor{1000}% for @. and friends
2868   }
2869   \def\plainnonfrenchspacing{%
2870     \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2871     \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2872     \def\endofsentencespacefactor{3000}% for @. and friends
2873   }
2874 \catcode`@=\other
2875 \def\endofsentencespacefactor{3000}% default
2876
2877 % @t, explicit typewriter.
2878 \def\t#1{%
2879   {\tt \rawbackslash \plainfrenchspacing #1}%
2880   \null
2881 }
2882
2883 % @samp.
2884 \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
2885
2886 % @indicateurl is \samp, that is, with quotes.
2887 \let\indicateurl=\samp
2888
2889 % @code (and similar) prints in typewriter, but with spaces the same
2890 % size as normal in the surrounding text, without hyphenation, etc.
2891 % This is a subroutine for that.
2892 \def\tclose#1{%
2893   {%
2894     % Change normal interword space to be same as for the current font.
2895     \spaceskip = \fontdimen2\font
2896     %
2897     % Switch to typewriter.
2898     \tt
2899     %
2900     % But `\ ' produces the large typewriter interword space.
2901     \def\ {{\spaceskip = 0pt{} }}%
2902     %
2903     % Turn off hyphenation.
2904     \nohyphenation
2905     %
2906     \rawbackslash
2907     \plainfrenchspacing
2908     #1%
2909   }%
2910   \null % reset spacefactor to 1000
2911 }
2912
2913 % We *must* turn on hyphenation at `-' and `_' in @code.
2914 % (But see \codedashfinish below.)
2915 % Otherwise, it is too hard to avoid overfull hboxes
2916 % in the Emacs manual, the Library manual, etc.
2917 %
2918 % Unfortunately, TeX uses one parameter (\hyphenchar) to control
2919 % both hyphenation at - and hyphenation within words.
2920 % We must therefore turn them both off (\tclose does that)
2921 % and arrange explicitly to hyphenate at a dash. -- rms.
2922 {
2923   \catcode`\-=\active \catcode`\_=\active
2924   \catcode`\'=\active \catcode`\`=\active
2925   \global\let'=\rq \global\let`=\lq  % default definitions
2926   %
2927   \global\def\code{\begingroup
2928     \setupmarkupstyle{code}%
2929     % The following should really be moved into \setupmarkupstyle handlers.
2930     \catcode\dashChar=\active  \catcode\underChar=\active
2931     \ifallowcodebreaks
2932      \let-\codedash
2933      \let_\codeunder
2934     \else
2935      \let-\normaldash
2936      \let_\realunder
2937     \fi
2938     % Given -foo (with a single dash), we do not want to allow a break
2939     % after the hyphen.
2940     \global\let\codedashprev=\codedash
2941     %
2942     \codex
2943   }
2944   %
2945   \gdef\codedash{\futurelet\next\codedashfinish}
2946   \gdef\codedashfinish{%
2947     \normaldash % always output the dash character itself.
2948     % 
2949     % Now, output a discretionary to allow a line break, unless
2950     % (a) the next character is a -, or
2951     % (b) the preceding character is a -.
2952     % E.g., given --posix, we do not want to allow a break after either -.
2953     % Given --foo-bar, we do want to allow a break between the - and the b.
2954     \ifx\next\codedash \else
2955       \ifx\codedashprev\codedash 
2956       \else \discretionary{}{}{}\fi
2957     \fi
2958     % we need the space after the = for the case when \next itself is a
2959     % space token; it would get swallowed otherwise.  As in @code{- a}.
2960     \global\let\codedashprev= \next
2961   }
2962 }
2963 \def\normaldash{-}
2964 %
2965 \def\codex #1{\tclose{#1}\endgroup}
2966
2967 \def\codeunder{%
2968   % this is all so @math{@code{var_name}+1} can work.  In math mode, _
2969   % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2970   % will therefore expand the active definition of _, which is us
2971   % (inside @code that is), therefore an endless loop.
2972   \ifusingtt{\ifmmode
2973                \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2974              \else\normalunderscore \fi
2975              \discretionary{}{}{}}%
2976             {\_}%
2977 }
2978
2979 % An additional complication: the above will allow breaks after, e.g.,
2980 % each of the four underscores in __typeof__.  This is bad.
2981 % @allowcodebreaks provides a document-level way to turn breaking at -
2982 % and _ on and off.
2983 %
2984 \newif\ifallowcodebreaks  \allowcodebreakstrue
2985
2986 \def\keywordtrue{true}
2987 \def\keywordfalse{false}
2988
2989 \parseargdef\allowcodebreaks{%
2990   \def\txiarg{#1}%
2991   \ifx\txiarg\keywordtrue
2992     \allowcodebreakstrue
2993   \else\ifx\txiarg\keywordfalse
2994     \allowcodebreaksfalse
2995   \else
2996     \errhelp = \EMsimple
2997     \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
2998   \fi\fi
2999 }
3000
3001 % For @command, @env, @file, @option quotes seem unnecessary,
3002 % so use \code rather than \samp.
3003 \let\command=\code
3004 \let\env=\code
3005 \let\file=\code
3006 \let\option=\code
3007
3008 % @uref (abbreviation for `urlref') aka @url takes an optional
3009 % (comma-separated) second argument specifying the text to display and
3010 % an optional third arg as text to display instead of (rather than in
3011 % addition to) the url itself.  First (mandatory) arg is the url.
3012
3013 % TeX-only option to allow changing PDF output to show only the second
3014 % arg (if given), and not the url (which is then just the link target).
3015 \newif\ifurefurlonlylink
3016
3017 % The main macro is \urefbreak, which allows breaking at expected
3018 % places within the url.  (There used to be another version, which
3019 % didn't support automatic breaking.)
3020 \def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
3021 \let\uref=\urefbreak
3022 %
3023 \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
3024 \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
3025   \unsepspaces
3026   \pdfurl{#1}%
3027   \setbox0 = \hbox{\ignorespaces #3}%
3028   \ifdim\wd0 > 0pt
3029     \unhbox0 % third arg given, show only that
3030   \else
3031     \setbox0 = \hbox{\ignorespaces #2}% look for second arg
3032     \ifdim\wd0 > 0pt
3033       \ifpdf
3034         % For pdfTeX and LuaTeX
3035         \ifurefurlonlylink
3036           % PDF plus option to not display url, show just arg
3037           \unhbox0             
3038         \else
3039           % PDF, normally display both arg and url for consistency,
3040           % visibility, if the pdf is eventually used to print, etc.
3041           \unhbox0\ (\urefcode{#1})%
3042         \fi
3043       \else
3044         \ifx\XeTeXrevision\thisisundefined
3045           \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
3046         \else
3047           % For XeTeX
3048           \ifurefurlonlylink
3049             % PDF plus option to not display url, show just arg
3050             \unhbox0             
3051           \else
3052             % PDF, normally display both arg and url for consistency,
3053             % visibility, if the pdf is eventually used to print, etc.
3054             \unhbox0\ (\urefcode{#1})%
3055           \fi
3056         \fi
3057       \fi
3058     \else
3059       \urefcode{#1}% only url given, so show it
3060     \fi
3061   \fi
3062   \endlink
3063 \endgroup}
3064
3065 % Allow line breaks around only a few characters (only).
3066 \def\urefcatcodes{%
3067   \catcode`\&=\active \catcode`\.=\active
3068   \catcode`\#=\active \catcode`\?=\active
3069   \catcode`\/=\active
3070 }
3071 {
3072   \urefcatcodes
3073   %
3074   \global\def\urefcode{\begingroup
3075     \setupmarkupstyle{code}%
3076     \urefcatcodes
3077     \let&\urefcodeamp
3078     \let.\urefcodedot
3079     \let#\urefcodehash
3080     \let?\urefcodequest
3081     \let/\urefcodeslash
3082     \codex
3083   }
3084   %
3085   % By default, they are just regular characters.
3086   \global\def&{\normalamp}
3087   \global\def.{\normaldot}
3088   \global\def#{\normalhash}
3089   \global\def?{\normalquest}
3090   \global\def/{\normalslash}
3091 }
3092
3093 % we put a little stretch before and after the breakable chars, to help
3094 % line breaking of long url's.  The unequal skips make look better in
3095 % cmtt at least, especially for dots.
3096 \def\urefprestretchamount{.13em}
3097 \def\urefpoststretchamount{.1em}
3098 \def\urefprestretch{\urefprebreak \hskip0pt plus\urefprestretchamount\relax}
3099 \def\urefpoststretch{\urefpostbreak \hskip0pt plus\urefprestretchamount\relax}
3100 %
3101 \def\urefcodeamp{\urefprestretch \&\urefpoststretch}
3102 \def\urefcodedot{\urefprestretch .\urefpoststretch}
3103 \def\urefcodehash{\urefprestretch \#\urefpoststretch}
3104 \def\urefcodequest{\urefprestretch ?\urefpoststretch}
3105 \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
3106 {
3107   \catcode`\/=\active
3108   \global\def\urefcodeslashfinish{%
3109     \urefprestretch \slashChar
3110     % Allow line break only after the final / in a sequence of
3111     % slashes, to avoid line break between the slashes in http://.
3112     \ifx\next/\else \urefpoststretch \fi
3113   }
3114 }
3115
3116 % One more complication: by default we'll break after the special
3117 % characters, but some people like to break before the special chars, so
3118 % allow that.  Also allow no breaking at all, for manual control.
3119
3120 \parseargdef\urefbreakstyle{%
3121   \def\txiarg{#1}%
3122   \ifx\txiarg\wordnone
3123     \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
3124   \else\ifx\txiarg\wordbefore
3125     \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
3126   \else\ifx\txiarg\wordafter
3127     \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
3128   \else
3129     \errhelp = \EMsimple
3130     \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
3131   \fi\fi\fi
3132 }
3133 \def\wordafter{after}
3134 \def\wordbefore{before}
3135 \def\wordnone{none}
3136
3137 \urefbreakstyle after
3138
3139 % @url synonym for @uref, since that's how everyone uses it.
3140 %
3141 \let\url=\uref
3142
3143 % rms does not like angle brackets --karl, 17may97.
3144 % So now @email is just like @uref, unless we are pdf.
3145 %
3146 %\def\email#1{\angleleft{\tt #1}\angleright}
3147 \ifpdf
3148   \def\email#1{\doemail#1,,\finish}
3149   \def\doemail#1,#2,#3\finish{\begingroup
3150     \unsepspaces
3151     \pdfurl{mailto:#1}%
3152     \setbox0 = \hbox{\ignorespaces #2}%
3153     \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3154     \endlink
3155   \endgroup}
3156 \else
3157   \ifx\XeTeXrevision\thisisundefined
3158     \let\email=\uref
3159   \else
3160     \def\email#1{\doemail#1,,\finish}
3161     \def\doemail#1,#2,#3\finish{\begingroup
3162       \unsepspaces
3163       \pdfurl{mailto:#1}%
3164       \setbox0 = \hbox{\ignorespaces #2}%
3165       \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3166       \endlink
3167     \endgroup}
3168   \fi
3169 \fi
3170
3171 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
3172 %   `example' (@kbd uses ttsl only inside of @example and friends),
3173 %   or `code' (@kbd uses normal tty font always).
3174 \parseargdef\kbdinputstyle{%
3175   \def\txiarg{#1}%
3176   \ifx\txiarg\worddistinct
3177     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
3178   \else\ifx\txiarg\wordexample
3179     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
3180   \else\ifx\txiarg\wordcode
3181     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
3182   \else
3183     \errhelp = \EMsimple
3184     \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
3185   \fi\fi\fi
3186 }
3187 \def\worddistinct{distinct}
3188 \def\wordexample{example}
3189 \def\wordcode{code}
3190
3191 % Default is `distinct'.
3192 \kbdinputstyle distinct
3193
3194 % @kbd is like @code, except that if the argument is just one @key command,
3195 % then @kbd has no effect.
3196 \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
3197
3198 \def\xkey{\key}
3199 \def\kbdsub#1#2#3\par{%
3200   \def\one{#1}\def\three{#3}\def\threex{??}%
3201   \ifx\one\xkey\ifx\threex\three \key{#2}%
3202   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3203   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3204 }
3205
3206 % definition of @key that produces a lozenge.  Doesn't adjust to text size.
3207 %\setfont\keyrm\rmshape{8}{1000}{OT1}
3208 %\font\keysy=cmsy9
3209 %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
3210 %  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
3211 %    \vbox{\hrule\kern-0.4pt
3212 %     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
3213 %    \kern-0.4pt\hrule}%
3214 %  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
3215
3216 % definition of @key with no lozenge.  If the current font is already
3217 % monospace, don't change it; that way, we respect @kbdinputstyle.  But
3218 % if it isn't monospace, then use \tt.
3219 %
3220 \def\key#1{{\setupmarkupstyle{key}%
3221   \nohyphenation
3222   \ifmonospace\else\tt\fi
3223   #1}\null}
3224
3225 % @clicksequence{File @click{} Open ...}
3226 \def\clicksequence#1{\begingroup #1\endgroup}
3227
3228 % @clickstyle @arrow   (by default)
3229 \parseargdef\clickstyle{\def\click{#1}}
3230 \def\click{\arrow}
3231
3232 % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
3233 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
3234 %
3235 \def\dmn#1{\thinspace #1}
3236
3237 % @acronym for "FBI", "NATO", and the like.
3238 % We print this one point size smaller, since it's intended for
3239 % all-uppercase.
3240 %
3241 \def\acronym#1{\doacronym #1,,\finish}
3242 \def\doacronym#1,#2,#3\finish{%
3243   {\switchtolsize #1}%
3244   \def\temp{#2}%
3245   \ifx\temp\empty \else
3246     \space ({\unsepspaces \ignorespaces \temp \unskip})%
3247   \fi
3248   \null % reset \spacefactor=1000
3249 }
3250
3251 % @abbr for "Comput. J." and the like.
3252 % No font change, but don't do end-of-sentence spacing.
3253 %
3254 \def\abbr#1{\doabbr #1,,\finish}
3255 \def\doabbr#1,#2,#3\finish{%
3256   {\plainfrenchspacing #1}%
3257   \def\temp{#2}%
3258   \ifx\temp\empty \else
3259     \space ({\unsepspaces \ignorespaces \temp \unskip})%
3260   \fi
3261   \null % reset \spacefactor=1000
3262 }
3263
3264 % @asis just yields its argument.  Used with @table, for example.
3265 %
3266 \def\asis#1{#1}
3267
3268 % @math outputs its argument in math mode.
3269 %
3270 % One complication: _ usually means subscripts, but it could also mean
3271 % an actual _ character, as in @math{@var{some_variable} + 1}.  So make
3272 % _ active, and distinguish by seeing if the current family is \slfam,
3273 % which is what @var uses.
3274 {
3275   \catcode`\_ = \active
3276   \gdef\mathunderscore{%
3277     \catcode`\_=\active
3278     \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
3279   }
3280 }
3281 % Another complication: we want \\ (and @\) to output a math (or tt) \.
3282 % FYI, plain.tex uses \\ as a temporary control sequence (for no
3283 % particular reason), but this is not advertised and we don't care.
3284 %
3285 % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
3286 \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
3287 %
3288 \def\math{%
3289   \ifmmode\else % only go into math if not in math mode already
3290     \tex
3291     \mathunderscore
3292     \let\\ = \mathbackslash
3293     \mathactive
3294     % make the texinfo accent commands work in math mode
3295     \let\"=\ddot
3296     \let\'=\acute
3297     \let\==\bar
3298     \let\^=\hat
3299     \let\`=\grave
3300     \let\u=\breve
3301     \let\v=\check
3302     \let\~=\tilde
3303     \let\dotaccent=\dot
3304     % have to provide another name for sup operator
3305     \let\mathopsup=\sup
3306   $\expandafter\finishmath\fi
3307 }
3308 \def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
3309
3310 % Some active characters (such as <) are spaced differently in math.
3311 % We have to reset their definitions in case the @math was an argument
3312 % to a command which sets the catcodes (such as @item or @section).
3313 %
3314 {
3315   \catcode`^ = \active
3316   \catcode`< = \active
3317   \catcode`> = \active
3318   \catcode`+ = \active
3319   \catcode`' = \active
3320   \gdef\mathactive{%
3321     \let^ = \ptexhat
3322     \let< = \ptexless
3323     \let> = \ptexgtr
3324     \let+ = \ptexplus
3325     \let' = \ptexquoteright
3326   }
3327 }
3328
3329 % for @sub and @sup, if in math mode, just do a normal sub/superscript.
3330 % If in text, use math to place as sub/superscript, but switch
3331 % into text mode, with smaller fonts.  This is a different font than the
3332 % one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3333 % fix it (significant additions to font machinery) until someone notices.
3334 %
3335 \def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
3336 \def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}%
3337 %
3338 \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
3339 \def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}%
3340
3341 % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3342 % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3343 % except specified as a normal braced arg, so no newlines to worry about.
3344
3345 \def\outfmtnametex{tex}
3346 %
3347 \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3348 \long\def\doinlinefmt#1,#2,\finish{%
3349   \def\inlinefmtname{#1}%
3350   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3351 }
3352
3353 % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3354 % FMTNAME is tex, else ELSE-TEXT.
3355 \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3356 \long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3357   \def\inlinefmtname{#1}%
3358   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3359 }
3360 %
3361 % For raw, must switch into @tex before parsing the argument, to avoid
3362 % setting catcodes prematurely.  Doing it this way means that, for
3363 % example, @inlineraw{html, foo{bar} gets a parse error instead of being
3364 % ignored.  But this isn't important because if people want a literal
3365 % *right* brace they would have to use a command anyway, so they may as
3366 % well use a command to get a left brace too.  We could re-use the
3367 % delimiter character idea from \verb, but it seems like overkill.
3368
3369 \long\def\inlineraw{\tex \doinlineraw}
3370 \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3371 \def\doinlinerawtwo#1,#2,\finish{%
3372   \def\inlinerawname{#1}%
3373   \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3374   \endgroup % close group opened by \tex.
3375 }
3376
3377 % @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3378 %
3379 \long\def\inlineifset#1{\doinlineifset #1,\finish}
3380 \long\def\doinlineifset#1,#2,\finish{%
3381   \def\inlinevarname{#1}%
3382   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3383   \else\ignorespaces#2\fi
3384 }
3385
3386 % @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3387 %
3388 \long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3389 \long\def\doinlineifclear#1,#2,\finish{%
3390   \def\inlinevarname{#1}%
3391   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3392 }
3393
3394
3395 \message{glyphs,}
3396 % and logos.
3397
3398 % @@ prints an @, as does @atchar{}.
3399 \def\@{\char64 }
3400 \let\atchar=\@
3401
3402 % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
3403 \def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}}
3404 \def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}}
3405 \let\{=\lbracechar
3406 \let\}=\rbracechar
3407
3408 % @comma{} to avoid , parsing problems.
3409 \let\comma = ,
3410
3411 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3412 % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3413 \let\, = \ptexc
3414 \let\dotaccent = \ptexdot
3415 \def\ringaccent#1{{\accent23 #1}}
3416 \let\tieaccent = \ptext
3417 \let\ubaraccent = \ptexb
3418 \let\udotaccent = \d
3419
3420 % Other special characters: @questiondown @exclamdown @ordf @ordm
3421 % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3422 \def\questiondown{?`}
3423 \def\exclamdown{!`}
3424 \def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}}
3425 \def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}}
3426
3427 % Dotless i and dotless j, used for accents.
3428 \def\imacro{i}
3429 \def\jmacro{j}
3430 \def\dotless#1{%
3431   \def\temp{#1}%
3432   \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3433   \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3434   \else \errmessage{@dotless can be used only with i or j}%
3435   \fi\fi
3436 }
3437
3438 % The \TeX{} logo, as in plain, but resetting the spacing so that a
3439 % period following counts as ending a sentence.  (Idea found in latex.)
3440 %
3441 \edef\TeX{\TeX \spacefactor=1000 }
3442
3443 % @LaTeX{} logo.  Not quite the same results as the definition in
3444 % latex.ltx, since we use a different font for the raised A; it's most
3445 % convenient for us to use an explicitly smaller font, rather than using
3446 % the \scriptstyle font (since we don't reset \scriptstyle and
3447 % \scriptscriptstyle).
3448 %
3449 \def\LaTeX{%
3450   L\kern-.36em
3451   {\setbox0=\hbox{T}%
3452    \vbox to \ht0{\hbox{%
3453      \ifx\textnominalsize\xwordpt
3454        % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX.
3455        % Revert to plain's \scriptsize, which is 7pt.
3456        \count255=\the\fam $\fam\count255 \scriptstyle A$%
3457      \else
3458        % For 11pt, we can use our lllsize.
3459        \switchtolllsize A%
3460      \fi
3461      }%
3462      \vss
3463   }}%
3464   \kern-.15em
3465   \TeX
3466 }
3467
3468 % Some math mode symbols.  Define \ensuremath to switch into math mode
3469 % unless we are already there.  Expansion tricks may not be needed here,
3470 % but safer, and can't hurt.
3471 \def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3472 \def\ensuredmath#1{$\relax#1$}
3473 %
3474 \def\bullet{\ensuremath\ptexbullet}
3475 \def\geq{\ensuremath\ge}
3476 \def\leq{\ensuremath\le}
3477 \def\minus{\ensuremath-}
3478
3479 % @dots{} outputs an ellipsis using the current font.
3480 % We do .5em per period so that it has the same spacing in the cm
3481 % typewriter fonts as three actual period characters; on the other hand,
3482 % in other typewriter fonts three periods are wider than 1.5em.  So do
3483 % whichever is larger.
3484 %
3485 \def\dots{%
3486   \leavevmode
3487   \setbox0=\hbox{...}% get width of three periods
3488   \ifdim\wd0 > 1.5em
3489     \dimen0 = \wd0
3490   \else
3491     \dimen0 = 1.5em
3492   \fi
3493   \hbox to \dimen0{%
3494     \hskip 0pt plus.25fil
3495     .\hskip 0pt plus1fil
3496     .\hskip 0pt plus1fil
3497     .\hskip 0pt plus.5fil
3498   }%
3499 }
3500
3501 % @enddots{} is an end-of-sentence ellipsis.
3502 %
3503 \def\enddots{%
3504   \dots
3505   \spacefactor=\endofsentencespacefactor
3506 }
3507
3508 % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3509 %
3510 % Since these characters are used in examples, they should be an even number of
3511 % \tt widths. Each \tt character is 1en, so two makes it 1em.
3512 %
3513 \def\point{$\star$}
3514 \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3515 \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3516 \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3517 \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3518 \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3519
3520 % The @error{} command.
3521 % Adapted from the TeXbook's \boxit.
3522 %
3523 \newbox\errorbox
3524 %
3525 {\ttfont \global\dimen0 = 3em}% Width of the box.
3526 \dimen2 = .55pt % Thickness of rules
3527 % The text. (`r' is open on the right, `e' somewhat less so on the left.)
3528 \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3529 %
3530 \setbox\errorbox=\hbox to \dimen0{\hfil
3531    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3532    \advance\hsize by -2\dimen2 % Rules.
3533    \vbox{%
3534       \hrule height\dimen2
3535       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
3536          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3537          \kern3pt\vrule width\dimen2}% Space to right.
3538       \hrule height\dimen2}
3539     \hfil}
3540 %
3541 \def\error{\leavevmode\lower.7ex\copy\errorbox}
3542
3543 % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3544 %
3545 \def\pounds{{\it\$}}
3546
3547 % @euro{} comes from a separate font, depending on the current style.
3548 % We use the free feym* fonts from the eurosym package by Henrik
3549 % Theiling, which support regular, slanted, bold and bold slanted (and
3550 % "outlined" (blackboard board, sort of) versions, which we don't need).
3551 % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3552 %
3553 % Although only regular is the truly official Euro symbol, we ignore
3554 % that.  The Euro is designed to be slightly taller than the regular
3555 % font height.
3556 %
3557 % feymr - regular
3558 % feymo - slanted
3559 % feybr - bold
3560 % feybo - bold slanted
3561 %
3562 % There is no good (free) typewriter version, to my knowledge.
3563 % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3564 % Hmm.
3565 %
3566 % Also doesn't work in math.  Do we need to do math with euro symbols?
3567 % Hope not.
3568 %
3569 %
3570 \def\euro{{\eurofont e}}
3571 \def\eurofont{%
3572   % We set the font at each command, rather than predefining it in
3573   % \textfonts and the other font-switching commands, so that
3574   % installations which never need the symbol don't have to have the
3575   % font installed.
3576   %
3577   % There is only one designed size (nominal 10pt), so we always scale
3578   % that to the current nominal size.
3579   %
3580   % By the way, simply using "at 1em" works for cmr10 and the like, but
3581   % does not work for cmbx10 and other extended/shrunken fonts.
3582   %
3583   \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3584   %
3585   \ifx\curfontstyle\bfstylename
3586     % bold:
3587     \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3588   \else
3589     % regular:
3590     \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3591   \fi
3592   \thiseurofont
3593 }
3594
3595 % Glyphs from the EC fonts.  We don't use \let for the aliases, because
3596 % sometimes we redefine the original macro, and the alias should reflect
3597 % the redefinition.
3598 %
3599 % Use LaTeX names for the Icelandic letters.
3600 \def\DH{{\ecfont \char"D0}} % Eth
3601 \def\dh{{\ecfont \char"F0}} % eth
3602 \def\TH{{\ecfont \char"DE}} % Thorn
3603 \def\th{{\ecfont \char"FE}} % thorn
3604 %
3605 \def\guillemetleft{{\ecfont \char"13}}
3606 \def\guillemotleft{\guillemetleft}
3607 \def\guillemetright{{\ecfont \char"14}}
3608 \def\guillemotright{\guillemetright}
3609 \def\guilsinglleft{{\ecfont \char"0E}}
3610 \def\guilsinglright{{\ecfont \char"0F}}
3611 \def\quotedblbase{{\ecfont \char"12}}
3612 \def\quotesinglbase{{\ecfont \char"0D}}
3613 %
3614 % This positioning is not perfect (see the ogonek LaTeX package), but
3615 % we have the precomposed glyphs for the most common cases.  We put the
3616 % tests to use those glyphs in the single \ogonek macro so we have fewer
3617 % dummy definitions to worry about for index entries, etc.
3618 %
3619 % ogonek is also used with other letters in Lithuanian (IOU), but using
3620 % the precomposed glyphs for those is not so easy since they aren't in
3621 % the same EC font.
3622 \def\ogonek#1{{%
3623   \def\temp{#1}%
3624   \ifx\temp\macrocharA\Aogonek
3625   \else\ifx\temp\macrochara\aogonek
3626   \else\ifx\temp\macrocharE\Eogonek
3627   \else\ifx\temp\macrochare\eogonek
3628   \else
3629     \ecfont \setbox0=\hbox{#1}%
3630     \ifdim\ht0=1ex\accent"0C #1%
3631     \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3632     \fi
3633   \fi\fi\fi\fi
3634   }%
3635 }
3636 \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3637 \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3638 \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3639 \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3640 %
3641 % Use the European Computer Modern fonts (cm-super in outline format)
3642 % for non-CM glyphs.  That is ec* for regular text and tc* for the text
3643 % companion symbols (LaTeX TS1 encoding).  Both are part of the ec
3644 % package and follow the same conventions.
3645
3646 \def\ecfont{\etcfont{e}}
3647 \def\tcfont{\etcfont{t}}
3648 %
3649 \def\etcfont#1{%
3650   % We can't distinguish serif/sans and italic/slanted, but this
3651   % is used for crude hacks anyway (like adding French and German
3652   % quotes to documents typeset with CM, where we lose kerning), so
3653   % hopefully nobody will notice/care.
3654   \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3655   \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
3656   \ifmonospace
3657     % typewriter:
3658     \font\thisecfont = #1ctt\ecsize \space at \nominalsize
3659   \else
3660     \ifx\curfontstyle\bfstylename
3661       % bold:
3662       \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
3663     \else
3664       % regular:
3665       \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
3666     \fi
3667   \fi
3668   \thisecfont
3669 }
3670
3671 % @registeredsymbol - R in a circle.  The font for the R should really
3672 % be smaller yet, but lllsize is the best we can do for now.
3673 % Adapted from the plain.tex definition of \copyright.
3674 %
3675 \def\registeredsymbol{%
3676   $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}%
3677                \hfil\crcr\Orb}}%
3678     }$%
3679 }
3680
3681 % @textdegree - the normal degrees sign.
3682 %
3683 \def\textdegree{$^\circ$}
3684
3685 % Laurent Siebenmann reports \Orb undefined with:
3686 %  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
3687 % so we'll define it if necessary.
3688 %
3689 \ifx\Orb\thisisundefined
3690 \def\Orb{\mathhexbox20D}
3691 \fi
3692
3693 % Quotes.
3694 \chardef\quotedblleft="5C
3695 \chardef\quotedblright=`\"
3696 \chardef\quoteleft=`\`
3697 \chardef\quoteright=`\'
3698
3699
3700 \message{page headings,}
3701
3702 \newskip\titlepagetopglue \titlepagetopglue = 1.5in
3703 \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3704
3705 % First the title page.  Must do @settitle before @titlepage.
3706 \newif\ifseenauthor
3707 \newif\iffinishedtitlepage
3708
3709 % @setcontentsaftertitlepage used to do an implicit @contents or
3710 % @shortcontents after @end titlepage, but it is now obsolete.
3711 \def\setcontentsaftertitlepage{%
3712   \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
3713               command; move your @contents command if you want the contents
3714               after the title page.}}%
3715 \def\setshortcontentsaftertitlepage{%
3716   \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
3717               command; move your @shortcontents and @contents commands if you 
3718               want the contents after the title page.}}%
3719
3720 \parseargdef\shorttitlepage{%
3721   \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3722   \endgroup\page\hbox{}\page}
3723
3724 \envdef\titlepage{%
3725   % Open one extra group, as we want to close it in the middle of \Etitlepage.
3726   \begingroup
3727     \parindent=0pt \textfonts
3728     % Leave some space at the very top of the page.
3729     \vglue\titlepagetopglue
3730     % No rule at page bottom unless we print one at the top with @title.
3731     \finishedtitlepagetrue
3732     %
3733     % Most title ``pages'' are actually two pages long, with space
3734     % at the top of the second.  We don't want the ragged left on the second.
3735     \let\oldpage = \page
3736     \def\page{%
3737       \iffinishedtitlepage\else
3738          \finishtitlepage
3739       \fi
3740       \let\page = \oldpage
3741       \page
3742       \null
3743     }%
3744 }
3745
3746 \def\Etitlepage{%
3747     \iffinishedtitlepage\else
3748         \finishtitlepage
3749     \fi
3750     % It is important to do the page break before ending the group,
3751     % because the headline and footline are only empty inside the group.
3752     % If we use the new definition of \page, we always get a blank page
3753     % after the title page, which we certainly don't want.
3754     \oldpage
3755   \endgroup
3756   %
3757   % Need this before the \...aftertitlepage checks so that if they are
3758   % in effect the toc pages will come out with page numbers.
3759   \HEADINGSon
3760 }
3761
3762 \def\finishtitlepage{%
3763   \vskip4pt \hrule height 2pt width \hsize
3764   \vskip\titlepagebottomglue
3765   \finishedtitlepagetrue
3766 }
3767
3768 % Settings used for typesetting titles: no hyphenation, no indentation,
3769 % don't worry much about spacing, ragged right.  This should be used
3770 % inside a \vbox, and fonts need to be set appropriately first. \par should
3771 % be specified before the end of the \vbox, since a vbox is a group.
3772
3773 \def\raggedtitlesettings{%
3774   \rm
3775   \hyphenpenalty=10000
3776   \parindent=0pt
3777   \tolerance=5000
3778   \ptexraggedright
3779 }
3780
3781 % Macros to be used within @titlepage:
3782
3783 \let\subtitlerm=\rmfont
3784 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3785
3786 \parseargdef\title{%
3787   \checkenv\titlepage
3788   \vbox{\titlefonts \raggedtitlesettings #1\par}%
3789   % print a rule at the page bottom also.
3790   \finishedtitlepagefalse
3791   \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3792 }
3793
3794 \parseargdef\subtitle{%
3795   \checkenv\titlepage
3796   {\subtitlefont \rightline{#1}}%
3797 }
3798
3799 % @author should come last, but may come many times.
3800 % It can also be used inside @quotation.
3801 %
3802 \parseargdef\author{%
3803   \def\temp{\quotation}%
3804   \ifx\thisenv\temp
3805     \def\quotationauthor{#1}% printed in \Equotation.
3806   \else
3807     \checkenv\titlepage
3808     \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3809     {\secfonts\rm \leftline{#1}}%
3810   \fi
3811 }
3812
3813
3814 % Set up page headings and footings.
3815
3816 \let\thispage=\folio
3817
3818 \newtoks\evenheadline    % headline on even pages
3819 \newtoks\oddheadline     % headline on odd pages
3820 \newtoks\evenfootline    % footline on even pages
3821 \newtoks\oddfootline     % footline on odd pages
3822
3823 % Now make \makeheadline and \makefootline in Plain TeX use those variables
3824 \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
3825                             \else \the\evenheadline \fi}}
3826 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
3827                             \else \the\evenfootline \fi}\HEADINGShook}
3828 \let\HEADINGShook=\relax
3829
3830 % Commands to set those variables.
3831 % For example, this is what  @headings on  does
3832 % @evenheading @thistitle|@thispage|@thischapter
3833 % @oddheading @thischapter|@thispage|@thistitle
3834 % @evenfooting @thisfile||
3835 % @oddfooting ||@thisfile
3836
3837
3838 \def\evenheading{\parsearg\evenheadingxxx}
3839 \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3840 \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
3841 \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3842
3843 \def\oddheading{\parsearg\oddheadingxxx}
3844 \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3845 \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
3846 \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3847
3848 \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3849
3850 \def\evenfooting{\parsearg\evenfootingxxx}
3851 \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3852 \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3853 \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3854
3855 \def\oddfooting{\parsearg\oddfootingxxx}
3856 \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3857 \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3858   \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3859   %
3860   % Leave some space for the footline.  Hopefully ok to assume
3861   % @evenfooting will not be used by itself.
3862   \global\advance\txipageheight by -12pt
3863   \global\advance\vsize by -12pt
3864 }
3865
3866 \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3867
3868 % @evenheadingmarks top     \thischapter <- chapter at the top of a page
3869 % @evenheadingmarks bottom  \thischapter <- chapter at the bottom of a page
3870 %
3871 % The same set of arguments for:
3872 %
3873 % @oddheadingmarks
3874 % @evenfootingmarks
3875 % @oddfootingmarks
3876 % @everyheadingmarks
3877 % @everyfootingmarks
3878
3879 % These define \getoddheadingmarks, \getevenheadingmarks,
3880 % \getoddfootingmarks, and \getevenfootingmarks, each to one of
3881 % \gettopheadingmarks, \getbottomheadingmarks.
3882 %
3883 \def\evenheadingmarks{\headingmarks{even}{heading}}
3884 \def\oddheadingmarks{\headingmarks{odd}{heading}}
3885 \def\evenfootingmarks{\headingmarks{even}{footing}}
3886 \def\oddfootingmarks{\headingmarks{odd}{footing}}
3887 \parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
3888                           \headingmarks{odd}{heading}{#1} }
3889 \parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
3890                           \headingmarks{odd}{footing}{#1} }
3891 % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3892 \def\headingmarks#1#2#3 {%
3893   \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3894   \global\expandafter\let\csname get#1#2marks\endcsname \temp
3895 }
3896
3897 \everyheadingmarks bottom
3898 \everyfootingmarks bottom
3899
3900 % @headings double      turns headings on for double-sided printing.
3901 % @headings single      turns headings on for single-sided printing.
3902 % @headings off         turns them off.
3903 % @headings on          same as @headings double, retained for compatibility.
3904 % @headings after       turns on double-sided headings after this page.
3905 % @headings doubleafter turns on double-sided headings after this page.
3906 % @headings singleafter turns on single-sided headings after this page.
3907 % By default, they are off at the start of a document,
3908 % and turned `on' after @end titlepage.
3909
3910 \parseargdef\headings{\csname HEADINGS#1\endcsname}
3911
3912 \def\headingsoff{% non-global headings elimination
3913   \evenheadline={\hfil}\evenfootline={\hfil}%
3914    \oddheadline={\hfil}\oddfootline={\hfil}%
3915 }
3916
3917 \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3918 \HEADINGSoff  % it's the default
3919
3920 % When we turn headings on, set the page number to 1.
3921 % For double-sided printing, put current file name in lower left corner,
3922 % chapter name on inside top of right hand pages, document
3923 % title on inside top of left hand pages, and page numbers on outside top
3924 % edge of all pages.
3925 \def\HEADINGSdouble{%
3926 \global\pageno=1
3927 \global\evenfootline={\hfil}
3928 \global\oddfootline={\hfil}
3929 \global\evenheadline={\line{\folio\hfil\thistitle}}
3930 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3931 \global\let\contentsalignmacro = \chapoddpage
3932 }
3933 \let\contentsalignmacro = \chappager
3934
3935 % For single-sided printing, chapter title goes across top left of page,
3936 % page number on top right.
3937 \def\HEADINGSsingle{%
3938 \global\pageno=1
3939 \global\evenfootline={\hfil}
3940 \global\oddfootline={\hfil}
3941 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
3942 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3943 \global\let\contentsalignmacro = \chappager
3944 }
3945 \def\HEADINGSon{\HEADINGSdouble}
3946
3947 \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
3948 \let\HEADINGSdoubleafter=\HEADINGSafter
3949 \def\HEADINGSdoublex{%
3950 \global\evenfootline={\hfil}
3951 \global\oddfootline={\hfil}
3952 \global\evenheadline={\line{\folio\hfil\thistitle}}
3953 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3954 \global\let\contentsalignmacro = \chapoddpage
3955 }
3956
3957 \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
3958 \def\HEADINGSsinglex{%
3959 \global\evenfootline={\hfil}
3960 \global\oddfootline={\hfil}
3961 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
3962 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3963 \global\let\contentsalignmacro = \chappager
3964 }
3965
3966 % Subroutines used in generating headings
3967 % This produces Day Month Year style of output.
3968 % Only define if not already defined, in case a txi-??.tex file has set
3969 % up a different format (e.g., txi-cs.tex does this).
3970 \ifx\today\thisisundefined
3971 \def\today{%
3972   \number\day\space
3973   \ifcase\month
3974   \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
3975   \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
3976   \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
3977   \fi
3978   \space\number\year}
3979 \fi
3980
3981 % @settitle line...  specifies the title of the document, for headings.
3982 % It generates no output of its own.
3983 \def\thistitle{\putwordNoTitle}
3984 \def\settitle{\parsearg{\gdef\thistitle}}
3985
3986
3987 \message{tables,}
3988 % Tables -- @table, @ftable, @vtable, @item(x).
3989
3990 % default indentation of table text
3991 \newdimen\tableindent \tableindent=.8in
3992 % default indentation of @itemize and @enumerate text
3993 \newdimen\itemindent  \itemindent=.3in
3994 % margin between end of table item and start of table text.
3995 \newdimen\itemmargin  \itemmargin=.1in
3996
3997 % used internally for \itemindent minus \itemmargin
3998 \newdimen\itemmax
3999
4000 % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
4001 % these defs.
4002 % They also define \itemindex
4003 % to index the item name in whatever manner is desired (perhaps none).
4004
4005 \newif\ifitemxneedsnegativevskip
4006
4007 \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
4008
4009 \def\internalBitem{\smallbreak \parsearg\itemzzz}
4010 \def\internalBitemx{\itemxpar \parsearg\itemzzz}
4011
4012 \def\itemzzz #1{\begingroup %
4013   \advance\hsize by -\rightskip
4014   \advance\hsize by -\tableindent
4015   \setbox0=\hbox{\itemindicate{#1}}%
4016   \itemindex{#1}%
4017   \nobreak % This prevents a break before @itemx.
4018   %
4019   % If the item text does not fit in the space we have, put it on a line
4020   % by itself, and do not allow a page break either before or after that
4021   % line.  We do not start a paragraph here because then if the next
4022   % command is, e.g., @kindex, the whatsit would get put into the
4023   % horizontal list on a line by itself, resulting in extra blank space.
4024   \ifdim \wd0>\itemmax
4025     %
4026     % Make this a paragraph so we get the \parskip glue and wrapping,
4027     % but leave it ragged-right.
4028     \begingroup
4029       \advance\leftskip by-\tableindent
4030       \advance\hsize by\tableindent
4031       \advance\rightskip by0pt plus1fil\relax
4032       \leavevmode\unhbox0\par
4033     \endgroup
4034     %
4035     % We're going to be starting a paragraph, but we don't want the
4036     % \parskip glue -- logically it's part of the @item we just started.
4037     \nobreak \vskip-\parskip
4038     %
4039     % Stop a page break at the \parskip glue coming up.  However, if
4040     % what follows is an environment such as @example, there will be no
4041     % \parskip glue; then the negative vskip we just inserted would
4042     % cause the example and the item to crash together.  So we use this
4043     % bizarre value of 10001 as a signal to \aboveenvbreak to insert
4044     % \parskip glue after all.  Section titles are handled this way also.
4045     %
4046     \penalty 10001
4047     \endgroup
4048     \itemxneedsnegativevskipfalse
4049   \else
4050     % The item text fits into the space.  Start a paragraph, so that the
4051     % following text (if any) will end up on the same line.
4052     \noindent
4053     % Do this with kerns and \unhbox so that if there is a footnote in
4054     % the item text, it can migrate to the main vertical list and
4055     % eventually be printed.
4056     \nobreak\kern-\tableindent
4057     \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
4058     \unhbox0
4059     \nobreak\kern\dimen0
4060     \endgroup
4061     \itemxneedsnegativevskiptrue
4062   \fi
4063 }
4064
4065 \def\item{\errmessage{@item while not in a list environment}}
4066 \def\itemx{\errmessage{@itemx while not in a list environment}}
4067
4068 % @table, @ftable, @vtable.
4069 \envdef\table{%
4070   \let\itemindex\gobble
4071   \tablecheck{table}%
4072 }
4073 \envdef\ftable{%
4074   \def\itemindex ##1{\doind {fn}{\code{##1}}}%
4075   \tablecheck{ftable}%
4076 }
4077 \envdef\vtable{%
4078   \def\itemindex ##1{\doind {vr}{\code{##1}}}%
4079   \tablecheck{vtable}%
4080 }
4081 \def\tablecheck#1{%
4082   \ifnum \the\catcode`\^^M=\active
4083     \endgroup
4084     \errmessage{This command won't work in this context; perhaps the problem is
4085       that we are \inenvironment\thisenv}%
4086     \def\next{\doignore{#1}}%
4087   \else
4088     \let\next\tablex
4089   \fi
4090   \next
4091 }
4092 \def\tablex#1{%
4093   \def\itemindicate{#1}%
4094   \parsearg\tabley
4095 }
4096 \def\tabley#1{%
4097   {%
4098     \makevalueexpandable
4099     \edef\temp{\noexpand\tablez #1\space\space\space}%
4100     \expandafter
4101   }\temp \endtablez
4102 }
4103 \def\tablez #1 #2 #3 #4\endtablez{%
4104   \aboveenvbreak
4105   \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
4106   \ifnum 0#2>0 \tableindent=#2\mil \fi
4107   \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
4108   \itemmax=\tableindent
4109   \advance \itemmax by -\itemmargin
4110   \advance \leftskip by \tableindent
4111   \exdentamount=\tableindent
4112   \parindent = 0pt
4113   \parskip = \smallskipamount
4114   \ifdim \parskip=0pt \parskip=2pt \fi
4115   \let\item = \internalBitem
4116   \let\itemx = \internalBitemx
4117 }
4118 \def\Etable{\endgraf\afterenvbreak}
4119 \let\Eftable\Etable
4120 \let\Evtable\Etable
4121 \let\Eitemize\Etable
4122 \let\Eenumerate\Etable
4123
4124 % This is the counter used by @enumerate, which is really @itemize
4125
4126 \newcount \itemno
4127
4128 \envdef\itemize{\parsearg\doitemize}
4129
4130 \def\doitemize#1{%
4131   \aboveenvbreak
4132   \itemmax=\itemindent
4133   \advance\itemmax by -\itemmargin
4134   \advance\leftskip by \itemindent
4135   \exdentamount=\itemindent
4136   \parindent=0pt
4137   \parskip=\smallskipamount
4138   \ifdim\parskip=0pt \parskip=2pt \fi
4139   %
4140   % Try typesetting the item mark so that if the document erroneously says
4141   % something like @itemize @samp (intending @table), there's an error
4142   % right away at the @itemize.  It's not the best error message in the
4143   % world, but it's better than leaving it to the @item.  This means if
4144   % the user wants an empty mark, they have to say @w{} not just @w.
4145   \def\itemcontents{#1}%
4146   \setbox0 = \hbox{\itemcontents}%
4147   %
4148   % @itemize with no arg is equivalent to @itemize @bullet.
4149   \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
4150   %
4151   \let\item=\itemizeitem
4152 }
4153
4154 % Definition of @item while inside @itemize and @enumerate.
4155 %
4156 \def\itemizeitem{%
4157   \advance\itemno by 1  % for enumerations
4158   {\let\par=\endgraf \smallbreak}% reasonable place to break
4159   {%
4160    % If the document has an @itemize directly after a section title, a
4161    % \nobreak will be last on the list, and \sectionheading will have
4162    % done a \vskip-\parskip.  In that case, we don't want to zero
4163    % parskip, or the item text will crash with the heading.  On the
4164    % other hand, when there is normal text preceding the item (as there
4165    % usually is), we do want to zero parskip, or there would be too much
4166    % space.  In that case, we won't have a \nobreak before.  At least
4167    % that's the theory.
4168    \ifnum\lastpenalty<10000 \parskip=0in \fi
4169    \noindent
4170    \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
4171    %
4172    \ifinner\else
4173      \vadjust{\penalty 1200}% not good to break after first line of item.
4174    \fi
4175    % We can be in inner vertical mode in a footnote, although an
4176    % @itemize looks awful there.
4177   }%
4178   \flushcr
4179 }
4180
4181 % \splitoff TOKENS\endmark defines \first to be the first token in
4182 % TOKENS, and \rest to be the remainder.
4183 %
4184 \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
4185
4186 % Allow an optional argument of an uppercase letter, lowercase letter,
4187 % or number, to specify the first label in the enumerated list.  No
4188 % argument is the same as `1'.
4189 %
4190 \envparseargdef\enumerate{\enumeratey #1  \endenumeratey}
4191 \def\enumeratey #1 #2\endenumeratey{%
4192   % If we were given no argument, pretend we were given `1'.
4193   \def\thearg{#1}%
4194   \ifx\thearg\empty \def\thearg{1}\fi
4195   %
4196   % Detect if the argument is a single token.  If so, it might be a
4197   % letter.  Otherwise, the only valid thing it can be is a number.
4198   % (We will always have one token, because of the test we just made.
4199   % This is a good thing, since \splitoff doesn't work given nothing at
4200   % all -- the first parameter is undelimited.)
4201   \expandafter\splitoff\thearg\endmark
4202   \ifx\rest\empty
4203     % Only one token in the argument.  It could still be anything.
4204     % A ``lowercase letter'' is one whose \lccode is nonzero.
4205     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
4206     %   not equal to itself.
4207     % Otherwise, we assume it's a number.
4208     %
4209     % We need the \relax at the end of the \ifnum lines to stop TeX from
4210     % continuing to look for a <number>.
4211     %
4212     \ifnum\lccode\expandafter`\thearg=0\relax
4213       \numericenumerate % a number (we hope)
4214     \else
4215       % It's a letter.
4216       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
4217         \lowercaseenumerate % lowercase letter
4218       \else
4219         \uppercaseenumerate % uppercase letter
4220       \fi
4221     \fi
4222   \else
4223     % Multiple tokens in the argument.  We hope it's a number.
4224     \numericenumerate
4225   \fi
4226 }
4227
4228 % An @enumerate whose labels are integers.  The starting integer is
4229 % given in \thearg.
4230 %
4231 \def\numericenumerate{%
4232   \itemno = \thearg
4233   \startenumeration{\the\itemno}%
4234 }
4235
4236 % The starting (lowercase) letter is in \thearg.
4237 \def\lowercaseenumerate{%
4238   \itemno = \expandafter`\thearg
4239   \startenumeration{%
4240     % Be sure we're not beyond the end of the alphabet.
4241     \ifnum\itemno=0
4242       \errmessage{No more lowercase letters in @enumerate; get a bigger
4243                   alphabet}%
4244     \fi
4245     \char\lccode\itemno
4246   }%
4247 }
4248
4249 % The starting (uppercase) letter is in \thearg.
4250 \def\uppercaseenumerate{%
4251   \itemno = \expandafter`\thearg
4252   \startenumeration{%
4253     % Be sure we're not beyond the end of the alphabet.
4254     \ifnum\itemno=0
4255       \errmessage{No more uppercase letters in @enumerate; get a bigger
4256                   alphabet}
4257     \fi
4258     \char\uccode\itemno
4259   }%
4260 }
4261
4262 % Call \doitemize, adding a period to the first argument and supplying the
4263 % common last two arguments.  Also subtract one from the initial value in
4264 % \itemno, since @item increments \itemno.
4265 %
4266 \def\startenumeration#1{%
4267   \advance\itemno by -1
4268   \doitemize{#1.}\flushcr
4269 }
4270
4271 % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
4272 % to @enumerate.
4273 %
4274 \def\alphaenumerate{\enumerate{a}}
4275 \def\capsenumerate{\enumerate{A}}
4276 \def\Ealphaenumerate{\Eenumerate}
4277 \def\Ecapsenumerate{\Eenumerate}
4278
4279
4280 % @multitable macros
4281 % Amy Hendrickson, 8/18/94, 3/6/96
4282 %
4283 % @multitable ... @end multitable will make as many columns as desired.
4284 % Contents of each column will wrap at width given in preamble.  Width
4285 % can be specified either with sample text given in a template line,
4286 % or in percent of \hsize, the current width of text on page.
4287
4288 % Table can continue over pages but will only break between lines.
4289
4290 % To make preamble:
4291 %
4292 % Either define widths of columns in terms of percent of \hsize:
4293 %   @multitable @columnfractions .25 .3 .45
4294 %   @item ...
4295 %
4296 %   Numbers following @columnfractions are the percent of the total
4297 %   current hsize to be used for each column. You may use as many
4298 %   columns as desired.
4299
4300
4301 % Or use a template:
4302 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4303 %   @item ...
4304 %   using the widest term desired in each column.
4305
4306 % Each new table line starts with @item, each subsequent new column
4307 % starts with @tab. Empty columns may be produced by supplying @tab's
4308 % with nothing between them for as many times as empty columns are needed,
4309 % ie, @tab@tab@tab will produce two empty columns.
4310
4311 % @item, @tab do not need to be on their own lines, but it will not hurt
4312 % if they are.
4313
4314 % Sample multitable:
4315
4316 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4317 %   @item first col stuff @tab second col stuff @tab third col
4318 %   @item
4319 %   first col stuff
4320 %   @tab
4321 %   second col stuff
4322 %   @tab
4323 %   third col
4324 %   @item first col stuff @tab second col stuff
4325 %   @tab Many paragraphs of text may be used in any column.
4326 %
4327 %         They will wrap at the width determined by the template.
4328 %   @item@tab@tab This will be in third column.
4329 %   @end multitable
4330
4331 % Default dimensions may be reset by user.
4332 % @multitableparskip is vertical space between paragraphs in table.
4333 % @multitableparindent is paragraph indent in table.
4334 % @multitablecolmargin is horizontal space to be left between columns.
4335 % @multitablelinespace is space to leave between table items, baseline
4336 %                                                            to baseline.
4337 %   0pt means it depends on current normal line spacing.
4338 %
4339 \newskip\multitableparskip
4340 \newskip\multitableparindent
4341 \newdimen\multitablecolspace
4342 \newskip\multitablelinespace
4343 \multitableparskip=0pt
4344 \multitableparindent=6pt
4345 \multitablecolspace=12pt
4346 \multitablelinespace=0pt
4347
4348 % Macros used to set up halign preamble:
4349 %
4350 \let\endsetuptable\relax
4351 \def\xendsetuptable{\endsetuptable}
4352 \let\columnfractions\relax
4353 \def\xcolumnfractions{\columnfractions}
4354 \newif\ifsetpercent
4355
4356 % #1 is the @columnfraction, usually a decimal number like .5, but might
4357 % be just 1.  We just use it, whatever it is.
4358 %
4359 \def\pickupwholefraction#1 {%
4360   \global\advance\colcount by 1
4361   \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
4362   \setuptable
4363 }
4364
4365 \newcount\colcount
4366 \def\setuptable#1{%
4367   \def\firstarg{#1}%
4368   \ifx\firstarg\xendsetuptable
4369     \let\go = \relax
4370   \else
4371     \ifx\firstarg\xcolumnfractions
4372       \global\setpercenttrue
4373     \else
4374       \ifsetpercent
4375          \let\go\pickupwholefraction
4376       \else
4377          \global\advance\colcount by 1
4378          \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
4379                    % separator; typically that is always in the input, anyway.
4380          \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
4381       \fi
4382     \fi
4383     \ifx\go\pickupwholefraction
4384       % Put the argument back for the \pickupwholefraction call, so
4385       % we'll always have a period there to be parsed.
4386       \def\go{\pickupwholefraction#1}%
4387     \else
4388       \let\go = \setuptable
4389     \fi%
4390   \fi
4391   \go
4392 }
4393
4394 % multitable-only commands.
4395
4396 % @headitem starts a heading row, which we typeset in bold.  Assignments
4397 % have to be global since we are inside the implicit group of an
4398 % alignment entry.  \everycr below resets \everytab so we don't have to
4399 % undo it ourselves.
4400 \def\headitemfont{\b}% for people to use in the template row; not changeable
4401 \def\headitem{%
4402   \checkenv\multitable
4403   \crcr
4404   \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
4405   \global\everytab={\bf}% can't use \headitemfont since the parsing differs
4406   \the\everytab % for the first item
4407 }%
4408 %
4409 % default for tables with no headings.
4410 \let\headitemcrhook=\relax
4411 %
4412 % A \tab used to include \hskip1sp.  But then the space in a template
4413 % line is not enough.  That is bad.  So let's go back to just `&' until
4414 % we again encounter the problem the 1sp was intended to solve.
4415 %                                       --karl, nathan@acm.org, 20apr99.
4416 \def\tab{\checkenv\multitable &\the\everytab}%
4417
4418 % @multitable ... @end multitable definitions:
4419 %
4420 \newtoks\everytab  % insert after every tab.
4421 %
4422 \envdef\multitable{%
4423   \vskip\parskip
4424   \startsavinginserts
4425   %
4426   % @item within a multitable starts a normal row.
4427   % We use \def instead of \let so that if one of the multitable entries
4428   % contains an @itemize, we don't choke on the \item (seen as \crcr aka
4429   % \endtemplate) expanding \doitemize.
4430   \def\item{\crcr}%
4431   %
4432   \tolerance=9500
4433   \hbadness=9500
4434   \setmultitablespacing
4435   \parskip=\multitableparskip
4436   \parindent=\multitableparindent
4437   \overfullrule=0pt
4438   \global\colcount=0
4439   %
4440   \everycr = {%
4441     \noalign{%
4442       \global\everytab={}% Reset from possible headitem.
4443       \global\colcount=0 % Reset the column counter.
4444       %
4445       % Check for saved footnotes, etc.:
4446       \checkinserts
4447       %
4448       % Perhaps a \nobreak, then reset:
4449       \headitemcrhook
4450       \global\let\headitemcrhook=\relax
4451     }%
4452   }%
4453   %
4454   \parsearg\domultitable
4455 }
4456 \def\domultitable#1{%
4457   % To parse everything between @multitable and @item:
4458   \setuptable#1 \endsetuptable
4459   %
4460   % This preamble sets up a generic column definition, which will
4461   % be used as many times as user calls for columns.
4462   % \vtop will set a single line and will also let text wrap and
4463   % continue for many paragraphs if desired.
4464   \halign\bgroup &%
4465     \global\advance\colcount by 1
4466     \multistrut
4467     \vtop{%
4468       % Use the current \colcount to find the correct column width:
4469       \hsize=\expandafter\csname col\the\colcount\endcsname
4470       %
4471       % In order to keep entries from bumping into each other
4472       % we will add a \leftskip of \multitablecolspace to all columns after
4473       % the first one.
4474       %
4475       % If a template has been used, we will add \multitablecolspace
4476       % to the width of each template entry.
4477       %
4478       % If the user has set preamble in terms of percent of \hsize we will
4479       % use that dimension as the width of the column, and the \leftskip
4480       % will keep entries from bumping into each other.  Table will start at
4481       % left margin and final column will justify at right margin.
4482       %
4483       % Make sure we don't inherit \rightskip from the outer environment.
4484       \rightskip=0pt
4485       \ifnum\colcount=1
4486         % The first column will be indented with the surrounding text.
4487         \advance\hsize by\leftskip
4488       \else
4489         \ifsetpercent \else
4490           % If user has not set preamble in terms of percent of \hsize
4491           % we will advance \hsize by \multitablecolspace.
4492           \advance\hsize by \multitablecolspace
4493         \fi
4494        % In either case we will make \leftskip=\multitablecolspace:
4495       \leftskip=\multitablecolspace
4496       \fi
4497       % Ignoring space at the beginning and end avoids an occasional spurious
4498       % blank line, when TeX decides to break the line at the space before the
4499       % box from the multistrut, so the strut ends up on a line by itself.
4500       % For example:
4501       % @multitable @columnfractions .11 .89
4502       % @item @code{#}
4503       % @tab Legal holiday which is valid in major parts of the whole country.
4504       % Is automatically provided with highlighting sequences respectively
4505       % marking characters.
4506       \noindent\ignorespaces##\unskip\multistrut
4507     }\cr
4508 }
4509 \def\Emultitable{%
4510   \crcr
4511   \egroup % end the \halign
4512   \global\setpercentfalse
4513 }
4514
4515 \def\setmultitablespacing{%
4516   \def\multistrut{\strut}% just use the standard line spacing
4517   %
4518   % Compute \multitablelinespace (if not defined by user) for use in
4519   % \multitableparskip calculation.  We used define \multistrut based on
4520   % this, but (ironically) that caused the spacing to be off.
4521   % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
4522 \ifdim\multitablelinespace=0pt
4523 \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
4524 \global\advance\multitablelinespace by-\ht0
4525 \fi
4526 % Test to see if parskip is larger than space between lines of
4527 % table. If not, do nothing.
4528 %        If so, set to same dimension as multitablelinespace.
4529 \ifdim\multitableparskip>\multitablelinespace
4530 \global\multitableparskip=\multitablelinespace
4531 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4532                                       % than skip between lines in the table.
4533 \fi%
4534 \ifdim\multitableparskip=0pt
4535 \global\multitableparskip=\multitablelinespace
4536 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4537                                       % than skip between lines in the table.
4538 \fi}
4539
4540
4541 \message{conditionals,}
4542
4543 % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
4544 % @ifnotxml always succeed.  They currently do nothing; we don't
4545 % attempt to check whether the conditionals are properly nested.  But we
4546 % have to remember that they are conditionals, so that @end doesn't
4547 % attempt to close an environment group.
4548 %
4549 \def\makecond#1{%
4550   \expandafter\let\csname #1\endcsname = \relax
4551   \expandafter\let\csname iscond.#1\endcsname = 1
4552 }
4553 \makecond{iftex}
4554 \makecond{ifnotdocbook}
4555 \makecond{ifnothtml}
4556 \makecond{ifnotinfo}
4557 \makecond{ifnotplaintext}
4558 \makecond{ifnotxml}
4559
4560 % Ignore @ignore, @ifhtml, @ifinfo, and the like.
4561 %
4562 \def\direntry{\doignore{direntry}}
4563 \def\documentdescription{\doignore{documentdescription}}
4564 \def\docbook{\doignore{docbook}}
4565 \def\html{\doignore{html}}
4566 \def\ifdocbook{\doignore{ifdocbook}}
4567 \def\ifhtml{\doignore{ifhtml}}
4568 \def\ifinfo{\doignore{ifinfo}}
4569 \def\ifnottex{\doignore{ifnottex}}
4570 \def\ifplaintext{\doignore{ifplaintext}}
4571 \def\ifxml{\doignore{ifxml}}
4572 \def\ignore{\doignore{ignore}}
4573 \def\menu{\doignore{menu}}
4574 \def\xml{\doignore{xml}}
4575
4576 % Ignore text until a line `@end #1', keeping track of nested conditionals.
4577 %
4578 % A count to remember the depth of nesting.
4579 \newcount\doignorecount
4580
4581 \def\doignore#1{\begingroup
4582   % Scan in ``verbatim'' mode:
4583   \obeylines
4584   \catcode`\@ = \other
4585   \catcode`\{ = \other
4586   \catcode`\} = \other
4587   %
4588   % Make sure that spaces turn into tokens that match what \doignoretext wants.
4589   \spaceisspace
4590   %
4591   % Count number of #1's that we've seen.
4592   \doignorecount = 0
4593   %
4594   % Swallow text until we reach the matching `@end #1'.
4595   \dodoignore{#1}%
4596 }
4597
4598 { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4599   \obeylines %
4600   %
4601   \gdef\dodoignore#1{%
4602     % #1 contains the command name as a string, e.g., `ifinfo'.
4603     %
4604     % Define a command to find the next `@end #1'.
4605     \long\def\doignoretext##1^^M@end #1{%
4606       \doignoretextyyy##1^^M@#1\_STOP_}%
4607     %
4608     % And this command to find another #1 command, at the beginning of a
4609     % line.  (Otherwise, we would consider a line `@c @ifset', for
4610     % example, to count as an @ifset for nesting.)
4611     \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
4612     %
4613     % And now expand that command.
4614     \doignoretext ^^M%
4615   }%
4616 }
4617
4618 \def\doignoreyyy#1{%
4619   \def\temp{#1}%
4620   \ifx\temp\empty                       % Nothing found.
4621     \let\next\doignoretextzzz
4622   \else                                 % Found a nested condition, ...
4623     \advance\doignorecount by 1
4624     \let\next\doignoretextyyy           % ..., look for another.
4625     % If we're here, #1 ends with ^^M\ifinfo (for example).
4626   \fi
4627   \next #1% the token \_STOP_ is present just after this macro.
4628 }
4629
4630 % We have to swallow the remaining "\_STOP_".
4631 %
4632 \def\doignoretextzzz#1{%
4633   \ifnum\doignorecount = 0      % We have just found the outermost @end.
4634     \let\next\enddoignore
4635   \else                         % Still inside a nested condition.
4636     \advance\doignorecount by -1
4637     \let\next\doignoretext      % Look for the next @end.
4638   \fi
4639   \next
4640 }
4641
4642 % Finish off ignored text.
4643 { \obeylines%
4644   % Ignore anything after the last `@end #1'; this matters in verbatim
4645   % environments, where otherwise the newline after an ignored conditional
4646   % would result in a blank line in the output.
4647   \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4648 }
4649
4650
4651 % @set VAR sets the variable VAR to an empty value.
4652 % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4653 %
4654 % Since we want to separate VAR from REST-OF-LINE (which might be
4655 % empty), we can't just use \parsearg; we have to insert a space of our
4656 % own to delimit the rest of the line, and then take it out again if we
4657 % didn't need it.
4658 % We rely on the fact that \parsearg sets \catcode`\ =10.
4659 %
4660 \parseargdef\set{\setyyy#1 \endsetyyy}
4661 \def\setyyy#1 #2\endsetyyy{%
4662   {%
4663     \makevalueexpandable
4664     \def\temp{#2}%
4665     \edef\next{\gdef\makecsname{SET#1}}%
4666     \ifx\temp\empty
4667       \next{}%
4668     \else
4669       \setzzz#2\endsetzzz
4670     \fi
4671   }%
4672 }
4673 % Remove the trailing space \setxxx inserted.
4674 \def\setzzz#1 \endsetzzz{\next{#1}}
4675
4676 % @clear VAR clears (i.e., unsets) the variable VAR.
4677 %
4678 \parseargdef\clear{%
4679   {%
4680     \makevalueexpandable
4681     \global\expandafter\let\csname SET#1\endcsname=\relax
4682   }%
4683 }
4684
4685 % @value{foo} gets the text saved in variable foo.
4686 \def\value{\begingroup\makevalueexpandable\valuexxx}
4687 \def\valuexxx#1{\expandablevalue{#1}\endgroup}
4688 {
4689   \catcode`\-=\active \catcode`\_=\active
4690   %
4691   \gdef\makevalueexpandable{%
4692     \let\value = \expandablevalue
4693     % We don't want these characters active, ...
4694     \catcode`\-=\other \catcode`\_=\other
4695     % ..., but we might end up with active ones in the argument if
4696     % we're called from @code, as @code{@value{foo-bar_}}, though.
4697     % So \let them to their normal equivalents.
4698     \let-\normaldash \let_\normalunderscore
4699   }
4700 }
4701
4702 % We have this subroutine so that we can handle at least some @value's
4703 % properly in indexes (we call \makevalueexpandable in \indexdummies).
4704 % The command has to be fully expandable (if the variable is set), since
4705 % the result winds up in the index file.  This means that if the
4706 % variable's value contains other Texinfo commands, it's almost certain
4707 % it will fail (although perhaps we could fix that with sufficient work
4708 % to do a one-level expansion on the result, instead of complete).
4709
4710 % Unfortunately, this has the consequence that when _ is in the *value*
4711 % of an @set, it does not print properly in the roman fonts (get the cmr
4712 % dot accent at position 126 instead).  No fix comes to mind, and it's
4713 % been this way since 2003 or earlier, so just ignore it.
4714
4715 \def\expandablevalue#1{%
4716   \expandafter\ifx\csname SET#1\endcsname\relax
4717     {[No value for ``#1'']}%
4718     \message{Variable `#1', used in @value, is not set.}%
4719   \else
4720     \csname SET#1\endcsname
4721   \fi
4722 }
4723
4724 % Like \expandablevalue, but completely expandable (the \message in the
4725 % definition above operates at the execution level of TeX).  Used when
4726 % writing to auxiliary files, due to the expansion that \write does.
4727 % If flag is undefined, pass through an unexpanded @value command: maybe it 
4728 % will be set by the time it is read back in.
4729 %
4730 % NB flag names containing - or _ may not work here.
4731 \def\dummyvalue#1{%
4732   \expandafter\ifx\csname SET#1\endcsname\relax
4733     \noexpand\value{#1}%
4734   \else
4735     \csname SET#1\endcsname
4736   \fi
4737 }
4738
4739 % Used for @value's in index entries to form the sort key: expand the @value
4740 % if possible, otherwise sort late.
4741 \def\indexnofontsvalue#1{%
4742   \expandafter\ifx\csname SET#1\endcsname\relax
4743     ZZZZZZZ
4744   \else
4745     \csname SET#1\endcsname
4746   \fi
4747 }
4748
4749 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4750 % with @set.
4751
4752 % To get the special treatment we need for `@end ifset,' we call
4753 % \makecond and then redefine.
4754 %
4755 \makecond{ifset}
4756 \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4757 \def\doifset#1#2{%
4758   {%
4759     \makevalueexpandable
4760     \let\next=\empty
4761     \expandafter\ifx\csname SET#2\endcsname\relax
4762       #1% If not set, redefine \next.
4763     \fi
4764     \expandafter
4765   }\next
4766 }
4767 \def\ifsetfail{\doignore{ifset}}
4768
4769 % @ifclear VAR ... @end executes the `...' iff VAR has never been
4770 % defined with @set, or has been undefined with @clear.
4771 %
4772 % The `\else' inside the `\doifset' parameter is a trick to reuse the
4773 % above code: if the variable is not set, do nothing, if it is set,
4774 % then redefine \next to \ifclearfail.
4775 %
4776 \makecond{ifclear}
4777 \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4778 \def\ifclearfail{\doignore{ifclear}}
4779
4780 % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
4781 % without the @) is in fact defined.  We can only feasibly check at the
4782 % TeX level, so something like `mathcode' is going to considered
4783 % defined even though it is not a Texinfo command.
4784
4785 \makecond{ifcommanddefined}
4786 \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
4787 %
4788 \def\doifcmddefined#1#2{{%
4789     \makevalueexpandable
4790     \let\next=\empty
4791     \expandafter\ifx\csname #2\endcsname\relax
4792       #1% If not defined, \let\next as above.
4793     \fi
4794     \expandafter
4795   }\next
4796 }
4797 \def\ifcmddefinedfail{\doignore{ifcommanddefined}}
4798
4799 % @ifcommandnotdefined CMD ... handled similar to @ifclear above.
4800 \makecond{ifcommandnotdefined}
4801 \def\ifcommandnotdefined{%
4802   \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
4803 \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
4804
4805 % Set the `txicommandconditionals' variable, so documents have a way to
4806 % test if the @ifcommand...defined conditionals are available.
4807 \set txicommandconditionals
4808
4809 % @dircategory CATEGORY  -- specify a category of the dir file
4810 % which this file should belong to.  Ignore this in TeX.
4811 \let\dircategory=\comment
4812
4813 % @defininfoenclose.
4814 \let\definfoenclose=\comment
4815
4816
4817 \message{indexing,}
4818 % Index generation facilities
4819
4820 % Define \newwrite to be identical to plain tex's \newwrite
4821 % except not \outer, so it can be used within macros and \if's.
4822 \edef\newwrite{\makecsname{ptexnewwrite}}
4823
4824 % \newindex {foo} defines an index named IX.
4825 % It automatically defines \IXindex such that
4826 % \IXindex ...rest of line... puts an entry in the index IX.
4827 % It also defines \IXindfile to be the number of the output channel for
4828 % the file that accumulates this index.  The file's extension is IX.
4829 % The name of an index should be no more than 2 characters long
4830 % for the sake of vms.
4831 %
4832 \def\newindex#1{%
4833   \expandafter\chardef\csname#1indfile\endcsname=0
4834   \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
4835     \noexpand\doindex{#1}}
4836 }
4837
4838 % @defindex foo  ==  \newindex{foo}
4839 %
4840 \def\defindex{\parsearg\newindex}
4841
4842 % Define @defcodeindex, like @defindex except put all entries in @code.
4843 %
4844 \def\defcodeindex{\parsearg\newcodeindex}
4845 %
4846 \def\newcodeindex#1{%
4847   \expandafter\chardef\csname#1indfile\endcsname=0
4848   \expandafter\xdef\csname#1index\endcsname{%
4849     \noexpand\docodeindex{#1}}%
4850 }
4851
4852 % The default indices:
4853 \newindex{cp}%      concepts,
4854 \newcodeindex{fn}%  functions,
4855 \newcodeindex{vr}%  variables,
4856 \newcodeindex{tp}%  types,
4857 \newcodeindex{ky}%  keys
4858 \newcodeindex{pg}%  and programs.
4859
4860
4861 % @synindex foo bar    makes index foo feed into index bar.
4862 % Do this instead of @defindex foo if you don't want it as a separate index.
4863 %
4864 % @syncodeindex foo bar   similar, but put all entries made for index foo
4865 % inside @code.
4866 %
4867 \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4868 \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4869
4870 % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4871 % #3 the target index (bar).
4872 \def\dosynindex#1#2#3{%
4873   \requireopenindexfile{#3}%
4874   % redefine \fooindfile:
4875   \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4876   \expandafter\let\csname#2indfile\endcsname=\temp
4877   % redefine \fooindex:
4878   \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
4879 }
4880
4881 % Define \doindex, the driver for all index macros.
4882 % Argument #1 is generated by the calling \fooindex macro,
4883 % and it is the two-letter name of the index.
4884
4885 \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
4886 \def\doindexxxx #1{\doind{\indexname}{#1}}
4887
4888 % like the previous two, but they put @code around the argument.
4889 \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
4890 \def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
4891
4892 \f
4893 % Used when writing an index entry out to an index file to prevent
4894 % expansion of Texinfo commands that can appear in an index entry.
4895 %
4896 \def\indexdummies{%
4897   \escapechar = `\\     % use backslash in output files.
4898   \definedummyletter\@%
4899   \definedummyletter\ %
4900   %
4901   % For texindex which always views { and } as separators.
4902   \def\{{\lbracechar{}}%
4903   \def\}{\rbracechar{}}%
4904   %
4905   % Do the redefinitions.
4906   \definedummies
4907 }
4908
4909 % Used for the aux and toc files, where @ is the escape character.
4910 %
4911 \def\atdummies{%
4912   \definedummyletter\@%
4913   \definedummyletter\ %
4914   \definedummyletter\{%
4915   \definedummyletter\}%
4916   %
4917   % Do the redefinitions.
4918   \definedummies
4919   \otherbackslash
4920 }
4921
4922 % \definedummyword defines \#1 as \string\#1\space, thus effectively
4923 % preventing its expansion.  This is used only for control words,
4924 % not control letters, because the \space would be incorrect for
4925 % control characters, but is needed to separate the control word
4926 % from whatever follows.
4927 %
4928 % These can be used both for control words that take an argument and
4929 % those that do not.  If it is followed by {arg} in the input, then
4930 % that will dutifully get written to the index (or wherever).
4931 %
4932 % For control letters, we have \definedummyletter, which omits the
4933 % space.
4934 %
4935 \def\definedummyword  #1{\def#1{\string#1\space}}%
4936 \def\definedummyletter#1{\def#1{\string#1}}%
4937 \let\definedummyaccent\definedummyletter
4938
4939 % Called from \indexdummies and \atdummies, to effectively prevent
4940 % the expansion of commands.
4941 %
4942 \def\definedummies{%
4943   %
4944   \let\commondummyword\definedummyword
4945   \let\commondummyletter\definedummyletter
4946   \let\commondummyaccent\definedummyaccent
4947   \commondummiesnofonts
4948   %
4949   \definedummyletter\_%
4950   \definedummyletter\-%
4951   %
4952   % Non-English letters.
4953   \definedummyword\AA
4954   \definedummyword\AE
4955   \definedummyword\DH
4956   \definedummyword\L
4957   \definedummyword\O
4958   \definedummyword\OE
4959   \definedummyword\TH
4960   \definedummyword\aa
4961   \definedummyword\ae
4962   \definedummyword\dh
4963   \definedummyword\exclamdown
4964   \definedummyword\l
4965   \definedummyword\o
4966   \definedummyword\oe
4967   \definedummyword\ordf
4968   \definedummyword\ordm
4969   \definedummyword\questiondown
4970   \definedummyword\ss
4971   \definedummyword\th
4972   %
4973   % Although these internal commands shouldn't show up, sometimes they do.
4974   \definedummyword\bf
4975   \definedummyword\gtr
4976   \definedummyword\hat
4977   \definedummyword\less
4978   \definedummyword\sf
4979   \definedummyword\sl
4980   \definedummyword\tclose
4981   \definedummyword\tt
4982   %
4983   \definedummyword\LaTeX
4984   \definedummyword\TeX
4985   %
4986   % Assorted special characters.
4987   \definedummyword\atchar
4988   \definedummyword\arrow
4989   \definedummyword\bullet
4990   \definedummyword\comma
4991   \definedummyword\copyright
4992   \definedummyword\registeredsymbol
4993   \definedummyword\dots
4994   \definedummyword\enddots
4995   \definedummyword\entrybreak
4996   \definedummyword\equiv
4997   \definedummyword\error
4998   \definedummyword\euro
4999   \definedummyword\expansion
5000   \definedummyword\geq
5001   \definedummyword\guillemetleft
5002   \definedummyword\guillemetright
5003   \definedummyword\guilsinglleft
5004   \definedummyword\guilsinglright
5005   \definedummyword\lbracechar
5006   \definedummyword\leq
5007   \definedummyword\mathopsup
5008   \definedummyword\minus
5009   \definedummyword\ogonek
5010   \definedummyword\pounds
5011   \definedummyword\point
5012   \definedummyword\print
5013   \definedummyword\quotedblbase
5014   \definedummyword\quotedblleft
5015   \definedummyword\quotedblright
5016   \definedummyword\quoteleft
5017   \definedummyword\quoteright
5018   \definedummyword\quotesinglbase
5019   \definedummyword\rbracechar
5020   \definedummyword\result
5021   \definedummyword\sub
5022   \definedummyword\sup
5023   \definedummyword\textdegree
5024   %
5025   % We want to disable all macros so that they are not expanded by \write.
5026   \macrolist
5027   \let\value\dummyvalue
5028   %
5029   \normalturnoffactive
5030 }
5031
5032 % \commondummiesnofonts: common to \definedummies and \indexnofonts.
5033 % Define \commondummyletter, \commondummyaccent and \commondummyword before
5034 % using.  Used for accents, font commands, and various control letters.
5035 %
5036 \def\commondummiesnofonts{%
5037   % Control letters and accents.
5038   \commondummyletter\!%
5039   \commondummyaccent\"%
5040   \commondummyaccent\'%
5041   \commondummyletter\*%
5042   \commondummyaccent\,%
5043   \commondummyletter\.%
5044   \commondummyletter\/%
5045   \commondummyletter\:%
5046   \commondummyaccent\=%
5047   \commondummyletter\?%
5048   \commondummyaccent\^%
5049   \commondummyaccent\`%
5050   \commondummyaccent\~%
5051   \commondummyword\u
5052   \commondummyword\v
5053   \commondummyword\H
5054   \commondummyword\dotaccent
5055   \commondummyword\ogonek
5056   \commondummyword\ringaccent
5057   \commondummyword\tieaccent
5058   \commondummyword\ubaraccent
5059   \commondummyword\udotaccent
5060   \commondummyword\dotless
5061   %
5062   % Texinfo font commands.
5063   \commondummyword\b
5064   \commondummyword\i
5065   \commondummyword\r
5066   \commondummyword\sansserif
5067   \commondummyword\sc
5068   \commondummyword\slanted
5069   \commondummyword\t
5070   %
5071   % Commands that take arguments.
5072   \commondummyword\abbr
5073   \commondummyword\acronym
5074   \commondummyword\anchor
5075   \commondummyword\cite
5076   \commondummyword\code
5077   \commondummyword\command
5078   \commondummyword\dfn
5079   \commondummyword\dmn
5080   \commondummyword\email
5081   \commondummyword\emph
5082   \commondummyword\env
5083   \commondummyword\file
5084   \commondummyword\image
5085   \commondummyword\indicateurl
5086   \commondummyword\inforef
5087   \commondummyword\kbd
5088   \commondummyword\key
5089   \commondummyword\math
5090   \commondummyword\option
5091   \commondummyword\pxref
5092   \commondummyword\ref
5093   \commondummyword\samp
5094   \commondummyword\strong
5095   \commondummyword\tie
5096   \commondummyword\U
5097   \commondummyword\uref
5098   \commondummyword\url
5099   \commondummyword\var
5100   \commondummyword\verb
5101   \commondummyword\w
5102   \commondummyword\xref
5103 }
5104
5105 % For testing: output @{ and @} in index sort strings as \{ and \}.
5106 \newif\ifusebracesinindexes
5107
5108 \let\indexlbrace\relax
5109 \let\indexrbrace\relax
5110
5111 {\catcode`\@=0
5112 \catcode`\\=13
5113   @gdef@backslashdisappear{@def\{}}
5114 }
5115
5116 {
5117 \catcode`\<=13
5118 \catcode`\-=13
5119 \catcode`\`=13
5120   \gdef\indexnonalnumdisappear{%
5121     \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
5122       % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
5123       % (Introduced for FSFS 2nd ed.)
5124       \let`=\empty
5125     \fi
5126     %
5127     \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
5128       \backslashdisappear
5129     \fi
5130     %
5131     \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
5132       \def-{}%
5133     \fi
5134     \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
5135       \def<{}%
5136     \fi
5137     \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
5138       \def\@{}%
5139     \fi
5140   }
5141
5142   \gdef\indexnonalnumreappear{%
5143     \useindexbackslash
5144     \let-\normaldash
5145     \let<\normalless
5146     \def\@{@}%
5147   }
5148 }
5149
5150
5151 % \indexnofonts is used when outputting the strings to sort the index
5152 % by, and when constructing control sequence names.  It eliminates all
5153 % control sequences and just writes whatever the best ASCII sort string
5154 % would be for a given command (usually its argument).
5155 %
5156 \def\indexnofonts{%
5157   % Accent commands should become @asis.
5158   \def\commondummyaccent##1{\let##1\asis}%
5159   % We can just ignore other control letters.
5160   \def\commondummyletter##1{\let##1\empty}%
5161   % All control words become @asis by default; overrides below.
5162   \let\commondummyword\commondummyaccent
5163   \commondummiesnofonts
5164   %
5165   % Don't no-op \tt, since it isn't a user-level command
5166   % and is used in the definitions of the active chars like <, >, |, etc.
5167   % Likewise with the other plain tex font commands.
5168   %\let\tt=\asis
5169   %
5170   \def\ { }%
5171   \def\@{@}%
5172   \def\_{\normalunderscore}%
5173   \def\-{}% @- shouldn't affect sorting
5174   %
5175   \uccode`\1=`\{ \uppercase{\def\{{1}}%
5176   \uccode`\1=`\} \uppercase{\def\}{1}}%
5177   \let\lbracechar\{%
5178   \let\rbracechar\}%
5179   %
5180   % Non-English letters.
5181   \def\AA{AA}%
5182   \def\AE{AE}%
5183   \def\DH{DZZ}%
5184   \def\L{L}%
5185   \def\OE{OE}%
5186   \def\O{O}%
5187   \def\TH{TH}%
5188   \def\aa{aa}%
5189   \def\ae{ae}%
5190   \def\dh{dzz}%
5191   \def\exclamdown{!}%
5192   \def\l{l}%
5193   \def\oe{oe}%
5194   \def\ordf{a}%
5195   \def\ordm{o}%
5196   \def\o{o}%
5197   \def\questiondown{?}%
5198   \def\ss{ss}%
5199   \def\th{th}%
5200   %
5201   \def\LaTeX{LaTeX}%
5202   \def\TeX{TeX}%
5203   %
5204   % Assorted special characters.  \defglyph gives the control sequence a
5205   % definition that removes the {} that follows its use.
5206   \defglyph\atchar{@}%
5207   \defglyph\arrow{->}%
5208   \defglyph\bullet{bullet}%
5209   \defglyph\comma{,}%
5210   \defglyph\copyright{copyright}%
5211   \defglyph\dots{...}%
5212   \defglyph\enddots{...}%
5213   \defglyph\equiv{==}%
5214   \defglyph\error{error}%
5215   \defglyph\euro{euro}%
5216   \defglyph\expansion{==>}%
5217   \defglyph\geq{>=}%
5218   \defglyph\guillemetleft{<<}%
5219   \defglyph\guillemetright{>>}%
5220   \defglyph\guilsinglleft{<}%
5221   \defglyph\guilsinglright{>}%
5222   \defglyph\leq{<=}%
5223   \defglyph\lbracechar{\{}%
5224   \defglyph\minus{-}%
5225   \defglyph\point{.}%
5226   \defglyph\pounds{pounds}%
5227   \defglyph\print{-|}%
5228   \defglyph\quotedblbase{"}%
5229   \defglyph\quotedblleft{"}%
5230   \defglyph\quotedblright{"}%
5231   \defglyph\quoteleft{`}%
5232   \defglyph\quoteright{'}%
5233   \defglyph\quotesinglbase{,}%
5234   \defglyph\rbracechar{\}}%
5235   \defglyph\registeredsymbol{R}%
5236   \defglyph\result{=>}%
5237   \defglyph\textdegree{o}%
5238   %
5239   % We need to get rid of all macros, leaving only the arguments (if present).
5240   % Of course this is not nearly correct, but it is the best we can do for now.
5241   % makeinfo does not expand macros in the argument to @deffn, which ends up
5242   % writing an index entry, and texindex isn't prepared for an index sort entry
5243   % that starts with \.
5244   %
5245   % Since macro invocations are followed by braces, we can just redefine them
5246   % to take a single TeX argument.  The case of a macro invocation that
5247   % goes to end-of-line is not handled.
5248   %
5249   \macrolist
5250   \let\value\indexnofontsvalue
5251 }
5252 \def\defglyph#1#2{\def#1##1{#2}} % see above
5253
5254 \f
5255
5256
5257 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
5258
5259 % Most index entries go through here, but \dosubind is the general case.
5260 % #1 is the index name, #2 is the entry text.
5261 \def\doind#1#2{\dosubind{#1}{#2}{}}
5262
5263 % There is also \dosubind {index}{topic}{subtopic}
5264 % which makes an entry in a two-level index such as the operation index.
5265 % TODO: Two-level index?  Operation index?
5266
5267 % Workhorse for all indexes.
5268 % #1 is name of index, #2 is stuff to put there, #3 is subentry --
5269 % empty if called from \doind, as we usually are (the main exception
5270 % is with most defuns, which call us directly).
5271 %
5272 \def\dosubind#1#2#3{%
5273   \iflinks
5274   {%
5275     \requireopenindexfile{#1}%
5276     % Store the main index entry text (including the third arg).
5277     \toks0 = {#2}%
5278     % If third arg is present, precede it with a space.
5279     \def\thirdarg{#3}%
5280     \ifx\thirdarg\empty \else
5281       \toks0 = \expandafter{\the\toks0 \space #3}%
5282     \fi
5283     %
5284     \edef\writeto{\csname#1indfile\endcsname}%
5285     %
5286     \safewhatsit\dosubindwrite
5287   }%
5288   \fi
5289 }
5290
5291 % Check if an index file has been opened, and if not, open it.
5292 \def\requireopenindexfile#1{%
5293 \ifnum\csname #1indfile\endcsname=0
5294   \expandafter\newwrite \csname#1indfile\endcsname
5295   \edef\suffix{#1}%
5296   % A .fls suffix would conflict with the file extension for the output
5297   % of -recorder, so use .f1s instead.
5298   \ifx\suffix\indexisfl\def\suffix{f1}\fi
5299   % Open the file
5300   \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
5301   % Using \immediate above here prevents an object entering into the current 
5302   % box, which could confound checks such as those in \safewhatsit for
5303   % preceding skips.
5304   \typeout{Writing index file \jobname.\suffix}%
5305 \fi}
5306 \def\indexisfl{fl}
5307
5308 % Output \ as {\indexbackslash}, because \ is an escape character in
5309 % the index files.
5310 \let\indexbackslash=\relax
5311 {\catcode`\@=0 \catcode`\\=\active
5312   @gdef@useindexbackslash{@def\{{@indexbackslash}}}
5313 }
5314
5315 % Definition for writing index entry text.
5316 \def\sortas#1{\ignorespaces}%
5317
5318 % Definition for writing index entry sort key.  Should occur at the at
5319 % the beginning of the index entry, like
5320 %     @cindex @sortas{september} \september
5321 % The \ignorespaces takes care of following space, but there's no way
5322 % to remove space before it.
5323 {
5324 \catcode`\-=13
5325 \gdef\indexwritesortas{%
5326   \begingroup
5327   \indexnonalnumreappear
5328   \indexwritesortasxxx}
5329 \gdef\indexwritesortasxxx#1{%
5330   \xdef\indexsortkey{#1}\endgroup}
5331 }
5332
5333
5334 % Write the entry in \toks0 to the index file.
5335 %
5336 \def\dosubindwrite{%
5337   % Put the index entry in the margin if desired.
5338   \ifx\SETmarginindex\relax\else
5339     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
5340   \fi
5341   %
5342   % Remember, we are within a group.
5343   \indexdummies % Must do this here, since \bf, etc expand at this stage
5344   \useindexbackslash % \indexbackslash isn't defined now so it will be output 
5345                      % as is; and it will print as backslash.
5346   % The braces around \indexbrace are recognized by texindex.
5347   %
5348   % Get the string to sort by, by processing the index entry with all
5349   % font commands turned off.
5350   {\indexnofonts
5351    \def\lbracechar{{\indexlbrace}}%
5352    \def\rbracechar{{\indexrbrace}}%
5353    \let\{=\lbracechar
5354    \let\}=\rbracechar
5355    \indexnonalnumdisappear
5356    \xdef\indexsortkey{}%
5357    \let\sortas=\indexwritesortas
5358    \edef\temp{\the\toks0}%
5359    \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas
5360    \ifx\indexsortkey\empty
5361      \xdef\indexsortkey{\temp}%
5362      \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
5363    \fi
5364   }%
5365   %
5366   % Set up the complete index entry, with both the sort key and
5367   % the original text, including any font commands.  We write
5368   % three arguments to \entry to the .?? file (four in the
5369   % subentry case), texindex reduces to two when writing the .??s
5370   % sorted result.
5371   \edef\temp{%
5372     \write\writeto{%
5373       \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}%
5374   }%
5375   \temp
5376 }
5377 \newbox\dummybox % used above
5378
5379 % Take care of unwanted page breaks/skips around a whatsit:
5380 %
5381 % If a skip is the last thing on the list now, preserve it
5382 % by backing up by \lastskip, doing the \write, then inserting
5383 % the skip again.  Otherwise, the whatsit generated by the
5384 % \write or \pdfdest will make \lastskip zero.  The result is that
5385 % sequences like this:
5386 % @end defun
5387 % @tindex whatever
5388 % @defun ...
5389 % will have extra space inserted, because the \medbreak in the
5390 % start of the @defun won't see the skip inserted by the @end of
5391 % the previous defun.
5392 %
5393 % But don't do any of this if we're not in vertical mode.  We
5394 % don't want to do a \vskip and prematurely end a paragraph.
5395 %
5396 % Avoid page breaks due to these extra skips, too.
5397 %
5398 % But wait, there is a catch there:
5399 % We'll have to check whether \lastskip is zero skip.  \ifdim is not
5400 % sufficient for this purpose, as it ignores stretch and shrink parts
5401 % of the skip.  The only way seems to be to check the textual
5402 % representation of the skip.
5403 %
5404 % The following is almost like \def\zeroskipmacro{0.0pt} except that
5405 % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
5406 %
5407 \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
5408 %
5409 \newskip\whatsitskip
5410 \newcount\whatsitpenalty
5411 %
5412 % ..., ready, GO:
5413 %
5414 \def\safewhatsit#1{\ifhmode
5415   #1%
5416  \else
5417   % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
5418   \whatsitskip = \lastskip
5419   \edef\lastskipmacro{\the\lastskip}%
5420   \whatsitpenalty = \lastpenalty
5421   %
5422   % If \lastskip is nonzero, that means the last item was a
5423   % skip.  And since a skip is discardable, that means this
5424   % -\whatsitskip glue we're inserting is preceded by a
5425   % non-discardable item, therefore it is not a potential
5426   % breakpoint, therefore no \nobreak needed.
5427   \ifx\lastskipmacro\zeroskipmacro
5428   \else
5429     \vskip-\whatsitskip
5430   \fi
5431   %
5432   #1%
5433   %
5434   \ifx\lastskipmacro\zeroskipmacro
5435     % If \lastskip was zero, perhaps the last item was a penalty, and
5436     % perhaps it was >=10000, e.g., a \nobreak.  In that case, we want
5437     % to re-insert the same penalty (values >10000 are used for various
5438     % signals); since we just inserted a non-discardable item, any
5439     % following glue (such as a \parskip) would be a breakpoint.  For example:
5440     %   @deffn deffn-whatever
5441     %   @vindex index-whatever
5442     %   Description.
5443     % would allow a break between the index-whatever whatsit
5444     % and the "Description." paragraph.
5445     \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
5446   \else
5447     % On the other hand, if we had a nonzero \lastskip,
5448     % this make-up glue would be preceded by a non-discardable item
5449     % (the whatsit from the \write), so we must insert a \nobreak.
5450     \nobreak\vskip\whatsitskip
5451   \fi
5452 \fi}
5453
5454 % The index entry written in the file actually looks like
5455 %  \entry {sortstring}{page}{topic}
5456 % or
5457 %  \entry {sortstring}{page}{topic}{subtopic}
5458 % The texindex program reads in these files and writes files
5459 % containing these kinds of lines:
5460 %  \initial {c}
5461 %     before the first topic whose initial is c
5462 %  \entry {topic}{pagelist}
5463 %     for a topic that is used without subtopics
5464 %  \primary {topic}
5465 %     for the beginning of a topic that is used with subtopics
5466 %  \secondary {subtopic}{pagelist}
5467 %     for each subtopic.
5468
5469 % Define the user-accessible indexing commands
5470 % @findex, @vindex, @kindex, @cindex.
5471
5472 \def\findex {\fnindex}
5473 \def\kindex {\kyindex}
5474 \def\cindex {\cpindex}
5475 \def\vindex {\vrindex}
5476 \def\tindex {\tpindex}
5477 \def\pindex {\pgindex}
5478
5479 \def\cindexsub {\begingroup\obeylines\cindexsub}
5480 {\obeylines %
5481 \gdef\cindexsub "#1" #2^^M{\endgroup %
5482 \dosubind{cp}{#2}{#1}}}
5483
5484 % Define the macros used in formatting output of the sorted index material.
5485
5486 % @printindex causes a particular index (the ??s file) to get printed.
5487 % It does not print any chapter heading (usually an @unnumbered).
5488 %
5489 \parseargdef\printindex{\begingroup
5490   \dobreak \chapheadingskip{10000}%
5491   %
5492   \smallfonts \rm
5493   \tolerance = 9500
5494   \plainfrenchspacing
5495   \everypar = {}% don't want the \kern\-parindent from indentation suppression.
5496   %
5497   % See if the index file exists and is nonempty.
5498   % Change catcode of @ here so that if the index file contains
5499   % \initial {@}
5500   % as its first line, TeX doesn't complain about mismatched braces
5501   % (because it thinks @} is a control sequence).
5502   \catcode`\@ = 12
5503   % See comment in \requireopenindexfile.
5504   \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
5505   \openin 1 \jobname.\indexname s
5506   \ifeof 1
5507     % \enddoublecolumns gets confused if there is no text in the index,
5508     % and it loses the chapter title and the aux file entries for the
5509     % index.  The easiest way to prevent this problem is to make sure
5510     % there is some text.
5511     \putwordIndexNonexistent
5512     \typeout{No file \jobname.\indexname s.}%
5513   \else
5514     \catcode`\\ = 0
5515     %
5516     % If the index file exists but is empty, then \openin leaves \ifeof
5517     % false.  We have to make TeX try to read something from the file, so
5518     % it can discover if there is anything in it.
5519     \read 1 to \thisline
5520     \ifeof 1
5521       \putwordIndexIsEmpty
5522     \else
5523       % Index files are almost Texinfo source, but we use \ as the escape
5524       % character.  It would be better to use @, but that's too big a change
5525       % to make right now.
5526       \def\indexbackslash{\ttbackslash}%
5527       \let\indexlbrace\{   % Likewise, set these sequences for braces
5528       \let\indexrbrace\}   % used in the sort key.
5529       \begindoublecolumns
5530       \let\dotheinsertentrybox\dotheinsertentryboxwithpenalty
5531       %
5532       % Read input from the index file line by line.
5533       \loopdo
5534         \ifeof1 \else
5535           \read 1 to \nextline
5536         \fi
5537         %
5538         \indexinputprocessing
5539         \thisline
5540         %
5541         \ifeof1\else
5542         \let\thisline\nextline
5543       \repeat
5544       %%
5545       \enddoublecolumns
5546     \fi
5547   \fi
5548   \closein 1
5549 \endgroup}
5550 \def\loopdo#1\repeat{\def\body{#1}\loopdoxxx}
5551 \def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next}
5552
5553 \def\indexinputprocessing{%
5554   \ifeof1
5555     \let\firsttoken\relax
5556   \else
5557     \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}%
5558     \act
5559   \fi
5560 }
5561 \def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken}
5562 \long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1}
5563
5564
5565 % These macros are used by the sorted index file itself.
5566 % Change them to control the appearance of the index.
5567
5568 {\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
5569 \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
5570 \catcode`\$=3
5571 \gdef\initialglyphs{%
5572   % Some changes for non-alphabetic characters.  Using the glyphs from the
5573   % math fonts looks more consistent than the typewriter font used elsewhere
5574   % for these characters.
5575   \def\indexbackslash{\math{\backslash}}%
5576   \let\\=\indexbackslash
5577   %
5578   % Can't get bold backslash so don't use bold forward slash
5579   \catcode`\/=13
5580   \def/{{\secrmnotbold \normalslash}}%
5581   \def-{{\normaldash\normaldash}}% en dash `--'
5582   \def^{{\chapbf \normalcaret}}%
5583   \def~{{\chapbf \normaltilde}}%
5584   \def\_{%
5585      \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
5586   \def|{$\vert$}%
5587   \def<{$\less$}%
5588   \def>{$\gtr$}%
5589   \def+{$\normalplus$}%
5590 }}
5591
5592 \def\initial{%
5593   \bgroup
5594   \initialglyphs
5595   \initialx
5596 }
5597
5598 \def\initialx#1{%
5599   % Remove any glue we may have, we'll be inserting our own.
5600   \removelastskip
5601   %
5602   % We like breaks before the index initials, so insert a bonus.
5603   % The glue before the bonus allows a little bit of space at the
5604   % bottom of a column to reduce an increase in inter-line spacing.
5605   \nobreak
5606   \vskip 0pt plus 5\baselineskip
5607   \penalty -300 
5608   \vskip 0pt plus -5\baselineskip
5609   %
5610   % Typeset the initial.  Making this add up to a whole number of
5611   % baselineskips increases the chance of the dots lining up from column
5612   % to column.  It still won't often be perfect, because of the stretch
5613   % we need before each entry, but it's better.
5614   %
5615   % No shrink because it confuses \balancecolumns.
5616   \vskip 1.67\baselineskip plus 1\baselineskip
5617   \leftline{\secfonts \kern-0.05em \secbf #1}%
5618   % \secfonts is inside the argument of \leftline so that the change of
5619   % \baselineskip will not affect any glue inserted before the vbox that
5620   % \leftline creates.
5621   % Do our best not to break after the initial.
5622   \nobreak
5623   \vskip .33\baselineskip plus .1\baselineskip
5624   \egroup % \initialglyphs
5625 }
5626
5627 \newdimen\entryrightmargin
5628 \entryrightmargin=0pt
5629
5630 % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
5631 % then page number (#2) flushed to the right margin.  It is used for index
5632 % and table of contents entries.  The paragraph is indented by \leftskip.
5633 %
5634 \def\entry{%
5635   \begingroup
5636     %
5637     % For pdfTeX and XeTeX.
5638     % The redefinition of \domark stops marks being added in \pdflink to 
5639     % preserve coloured links across page boundaries.  Otherwise the marks
5640     % would get in the way of \lastbox in \insertentrybox.
5641     \let\domark\relax
5642     %
5643     % Start a new paragraph if necessary, so our assignments below can't
5644     % affect previous text.
5645     \par
5646     %
5647     % No extra space above this paragraph.
5648     \parskip = 0in
5649     %
5650     % When reading the text of entry, convert explicit line breaks
5651     % from @* into spaces.  The user might give these in long section
5652     % titles, for instance.
5653     \def\*{\unskip\space\ignorespaces}%
5654     \def\entrybreak{\hfil\break}% An undocumented command
5655     %
5656     % Swallow the left brace of the text (first parameter):
5657     \afterassignment\doentry
5658     \let\temp =
5659 }
5660 \def\entrybreak{\unskip\space\ignorespaces}%
5661 \def\doentry{%
5662     % Save the text of the entry
5663     \global\setbox\boxA=\hbox\bgroup
5664     \bgroup % Instead of the swallowed brace.
5665       \noindent
5666       \aftergroup\finishentry
5667       % And now comes the text of the entry.
5668       % Not absorbing as a macro argument reduces the chance of problems
5669       % with catcodes occurring.
5670 }
5671 {\catcode`\@=11
5672 \gdef\finishentry#1{%
5673     \egroup % end box A
5674     \dimen@ = \wd\boxA % Length of text of entry
5675     \global\setbox\boxA=\hbox\bgroup\unhbox\boxA
5676     % #1 is the page number.
5677     %
5678     % Get the width of the page numbers, and only use
5679     % leaders if they are present.
5680     \global\setbox\boxB = \hbox{#1}%
5681     \ifdim\wd\boxB = 0pt
5682       \null\nobreak\hfill\ %
5683     \else
5684       %
5685       \null\nobreak\indexdotfill % Have leaders before the page number.
5686       %
5687       \ifpdf
5688         \pdfgettoks#1.%
5689         \hskip\skip\thinshrinkable\the\toksA
5690       \else
5691         \ifx\XeTeXrevision\thisisundefined
5692           \hskip\skip\thinshrinkable #1%
5693         \else
5694           \pdfgettoks#1.%
5695           \hskip\skip\thinshrinkable\the\toksA
5696         \fi
5697       \fi
5698     \fi
5699     \egroup % end \boxA
5700     \ifdim\wd\boxB = 0pt
5701       \global\setbox\entrybox=\vbox{\unhbox\boxA}%
5702     \else
5703     \global\setbox\entrybox=\vbox\bgroup
5704       % We want the text of the entries to be aligned to the left, and the
5705       % page numbers to be aligned to the right.
5706       %
5707       \parindent = 0pt
5708       \advance\leftskip by 0pt plus 1fil
5709       \advance\leftskip by 0pt plus -1fill
5710       \rightskip = 0pt plus -1fil
5711       \advance\rightskip by 0pt plus 1fill
5712       % Cause last line, which could consist of page numbers on their own
5713       % if the list of page numbers is long, to be aligned to the right.
5714       \parfillskip=0pt plus -1fill
5715       %
5716       \advance\rightskip by \entryrightmargin
5717       % Determine how far we can stretch into the margin.
5718       % This allows, e.g., "Appendix H  GNU Free Documentation License" to
5719       % fit on one line in @letterpaper format.
5720       \ifdim\entryrightmargin>2.1em
5721         \dimen@i=2.1em
5722       \else
5723         \dimen@i=0em
5724       \fi
5725       \advance \parfillskip by 0pt minus 1\dimen@i
5726       %
5727       \dimen@ii = \hsize
5728       \advance\dimen@ii by -1\leftskip
5729       \advance\dimen@ii by -1\entryrightmargin
5730       \advance\dimen@ii by 1\dimen@i
5731       \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
5732       \ifdim\dimen@ > 0.8\dimen@ii   % due to long index text
5733         % Try to split the text roughly evenly.  \dimen@ will be the length of 
5734         % the first line.
5735         \dimen@ = 0.7\dimen@
5736         \dimen@ii = \hsize
5737         \ifnum\dimen@>\dimen@ii
5738           % If the entry is too long (for example, if it needs more than
5739           % two lines), use all the space in the first line.
5740           \dimen@ = \dimen@ii
5741         \fi
5742         \advance\leftskip by 0pt plus 1fill % ragged right
5743         \advance \dimen@ by 1\rightskip
5744         \parshape = 2 0pt \dimen@ 0em \dimen@ii
5745         % Ideally we'd add a finite glue at the end of the first line only,
5746         % instead of using \parshape with explicit line lengths, but TeX
5747         % doesn't seem to provide a way to do such a thing.
5748         %
5749         % Indent all lines but the first one.
5750         \advance\leftskip by 1em
5751         \advance\parindent by -1em
5752       \fi\fi
5753       \indent % start paragraph
5754       \unhbox\boxA
5755       %
5756       % Do not prefer a separate line ending with a hyphen to fewer lines.
5757       \finalhyphendemerits = 0
5758       %
5759       % Word spacing - no stretch
5760       \spaceskip=\fontdimen2\font minus \fontdimen4\font
5761       %
5762       \linepenalty=1000  % Discourage line breaks.
5763       \hyphenpenalty=5000  % Discourage hyphenation.
5764       %
5765       \par % format the paragraph
5766     \egroup % The \vbox
5767     \fi
5768   \endgroup
5769   \dotheinsertentrybox
5770 }}
5771
5772 \newskip\thinshrinkable
5773 \skip\thinshrinkable=.15em minus .15em
5774
5775 \newbox\entrybox
5776 \def\insertentrybox{%
5777   \ourunvbox\entrybox
5778 }
5779
5780 % default definition
5781 \let\dotheinsertentrybox\insertentrybox
5782
5783 % Use \lastbox to take apart vbox box by box, and add each sub-box
5784 % to the current vertical list.
5785 \def\ourunvbox#1{%
5786 \bgroup % for local binding of \delayedbox
5787   % Remove the last box from box #1
5788   \global\setbox#1=\vbox{%
5789     \unvbox#1%
5790     \unskip % remove any glue
5791     \unpenalty
5792     \global\setbox\interbox=\lastbox
5793   }%
5794   \setbox\delayedbox=\box\interbox
5795   \ifdim\ht#1=0pt\else
5796     \ourunvbox#1 % Repeat on what's left of the box
5797     \nobreak
5798   \fi
5799   \box\delayedbox
5800 \egroup
5801 }
5802 \newbox\delayedbox
5803 \newbox\interbox
5804
5805 % Used from \printindex.  \firsttoken should be the first token
5806 % after the \entry.  If it's not another \entry, we are at the last
5807 % line of a group of index entries, so insert a penalty to discourage
5808 % widowed index entries.
5809 \def\dotheinsertentryboxwithpenalty{%
5810   \ifx\firsttoken\isentry
5811   \else
5812     \penalty 9000
5813   \fi
5814   \insertentrybox
5815 }
5816 \def\isentry{\entry}%
5817
5818 % Like plain.tex's \dotfill, except uses up at least 1 em.
5819 % The filll stretch here overpowers both the fil and fill stretch to push
5820 % the page number to the right.
5821 \def\indexdotfill{\cleaders
5822   \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
5823
5824
5825 \def\primary #1{\line{#1\hfil}}
5826
5827 \newskip\secondaryindent \secondaryindent=0.5cm
5828 \def\secondary#1#2{{%
5829   \parfillskip=0in
5830   \parskip=0in
5831   \hangindent=1in
5832   \hangafter=1
5833   \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
5834   \ifpdf
5835     \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5836   \else
5837     \ifx\XeTeXrevision\thisisundefined
5838       #2
5839     \else
5840       \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5841     \fi
5842   \fi
5843   \par
5844 }}
5845
5846 % Define two-column mode, which we use to typeset indexes.
5847 % Adapted from the TeXbook, page 416, which is to say,
5848 % the manmac.tex format used to print the TeXbook itself.
5849 \catcode`\@=11  % private names
5850
5851 \newbox\partialpage
5852 \newdimen\doublecolumnhsize
5853
5854 % Use inside an output routine to save \topmark and \firstmark
5855 \def\savemarks{%
5856   \global\savedtopmark=\expandafter{\topmark }%
5857   \global\savedfirstmark=\expandafter{\firstmark }%
5858 }
5859 \newtoks\savedtopmark
5860 \newtoks\savedfirstmark
5861
5862 % Set \topmark and \firstmark for next time \output runs.
5863 % Can't be run from withinside \output (because any material
5864 % added while an output routine is active, including 
5865 % penalties, is saved for after it finishes).  The page so far
5866 % should be empty, otherwise what's on it will be thrown away.
5867 \def\restoremarks{%
5868   \mark{\the\savedtopmark}%
5869   \bgroup\output = {%
5870     \setbox\dummybox=\box\PAGE
5871   }abc\eject\egroup
5872   % "abc" because output routine doesn't fire for a completely empty page.
5873   \mark{\the\savedfirstmark}%
5874 }
5875
5876 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
5877   % If not much space left on page, start a new page.
5878   \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
5879   %
5880   % Grab any single-column material above us.
5881   \output = {%
5882     %
5883     % Here is a possibility not foreseen in manmac: if we accumulate a
5884     % whole lot of material, we might end up calling this \output
5885     % routine twice in a row (see the doublecol-lose test, which is
5886     % essentially a couple of indexes with @setchapternewpage off).  In
5887     % that case we just ship out what is in \partialpage with the normal
5888     % output routine.  Generally, \partialpage will be empty when this
5889     % runs and this will be a no-op.  See the indexspread.tex test case.
5890     \ifvoid\partialpage \else
5891       \onepageout{\pagecontents\partialpage}%
5892     \fi
5893     %
5894     \global\setbox\partialpage = \vbox{%
5895       % Unvbox the main output page.
5896       \unvbox\PAGE
5897       \kern-\topskip \kern\baselineskip
5898     }%
5899     \savemarks
5900   }%
5901   \eject % run that output routine to set \partialpage
5902   \restoremarks
5903   %
5904   % We recover the two marks that the last output routine saved in order
5905   % to propagate the information in marks added around a chapter heading,
5906   % which could be otherwise be lost by the time the final page is output.
5907   %
5908   %
5909   % Use the double-column output routine for subsequent pages.
5910   \output = {\doublecolumnout}%
5911   %
5912   % Change the page size parameters.  We could do this once outside this
5913   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5914   % format, but then we repeat the same computation.  Repeating a couple
5915   % of assignments once per index is clearly meaningless for the
5916   % execution time, so we may as well do it in one place.
5917   %
5918   % First we halve the line length, less a little for the gutter between
5919   % the columns.  We compute the gutter based on the line length, so it
5920   % changes automatically with the paper format.  The magic constant
5921   % below is chosen so that the gutter has the same value (well, +-<1pt)
5922   % as it did when we hard-coded it.
5923   %
5924   % We put the result in a separate register, \doublecolumhsize, so we
5925   % can restore it in \pagesofar, after \hsize itself has (potentially)
5926   % been clobbered.
5927   %
5928   \doublecolumnhsize = \hsize
5929     \advance\doublecolumnhsize by -.04154\hsize
5930     \divide\doublecolumnhsize by 2
5931   \hsize = \doublecolumnhsize
5932   %
5933   % Double the \vsize as well.
5934   \advance\vsize by -\ht\partialpage
5935   \vsize = 2\vsize
5936   %
5937   % For the benefit of balancing columns
5938   \advance\baselineskip by 0pt plus 0.5pt
5939 }
5940
5941 % The double-column output routine for all double-column pages except
5942 % the last, which is done by \balancecolumns.
5943 %
5944 \def\doublecolumnout{%
5945   %
5946   \splittopskip=\topskip \splitmaxdepth=\maxdepth
5947   % Get the available space for the double columns -- the normal
5948   % (undoubled) page height minus any material left over from the
5949   % previous page.
5950   \dimen@ = \vsize
5951   \divide\dimen@ by 2
5952   %
5953   % box0 will be the left-hand column, box2 the right.
5954   \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@
5955   \global\advance\vsize by 2\ht\partialpage
5956   \onepageout\pagesofar
5957   \unvbox\PAGE
5958   \penalty\outputpenalty
5959 }
5960 %
5961 % Re-output the contents of the output page -- any previous material,
5962 % followed by the two boxes we just split, in box0 and box2.
5963 \def\pagesofar{%
5964   \unvbox\partialpage
5965   %
5966   \hsize = \doublecolumnhsize
5967   \wd0=\hsize \wd2=\hsize
5968   \hbox to\txipagewidth{\box0\hfil\box2}%
5969 }
5970
5971
5972 % Finished with with double columns.
5973 \def\enddoublecolumns{%
5974   % The following penalty ensures that the page builder is exercised
5975   % _before_ we change the output routine.  This is necessary in the
5976   % following situation:
5977   %
5978   % The last section of the index consists only of a single entry.
5979   % Before this section, \pagetotal is less than \pagegoal, so no
5980   % break occurs before the last section starts.  However, the last
5981   % section, consisting of \initial and the single \entry, does not
5982   % fit on the page and has to be broken off.  Without the following
5983   % penalty the page builder will not be exercised until \eject
5984   % below, and by that time we'll already have changed the output
5985   % routine to the \balancecolumns version, so the next-to-last
5986   % double-column page will be processed with \balancecolumns, which
5987   % is wrong:  The two columns will go to the main vertical list, with
5988   % the broken-off section in the recent contributions.  As soon as
5989   % the output routine finishes, TeX starts reconsidering the page
5990   % break.  The two columns and the broken-off section both fit on the
5991   % page, because the two columns now take up only half of the page
5992   % goal.  When TeX sees \eject from below which follows the final
5993   % section, it invokes the new output routine that we've set after
5994   % \balancecolumns below; \onepageout will try to fit the two columns
5995   % and the final section into the vbox of \txipageheight (see
5996   % \pagebody), causing an overfull box.
5997   %
5998   % Note that glue won't work here, because glue does not exercise the
5999   % page builder, unlike penalties (see The TeXbook, pp. 280-281).
6000   \penalty0
6001   %
6002   \output = {%
6003     % Split the last of the double-column material.
6004     \savemarks
6005     \balancecolumns
6006   }%
6007   \eject % call the \output just set
6008   \ifdim\pagetotal=0pt
6009     % Having called \balancecolumns once, we do not
6010     % want to call it again.  Therefore, reset \output to its normal
6011     % definition right away.
6012     \global\output = {\onepageout{\pagecontents\PAGE}}%
6013     %
6014     \endgroup % started in \begindoublecolumns
6015     \restoremarks
6016     % Leave the double-column material on the current page, no automatic
6017     % page break.
6018     \box\balancedcolumns
6019     %
6020     % \pagegoal was set to the doubled \vsize above, since we restarted
6021     % the current page.  We're now back to normal single-column
6022     % typesetting, so reset \pagegoal to the normal \vsize.
6023     \global\vsize = \txipageheight %
6024     \pagegoal = \txipageheight %
6025   \else
6026     % We had some left-over material.  This might happen when \doublecolumnout
6027     % is called in \balancecolumns.  Try again.
6028     \expandafter\enddoublecolumns
6029   \fi
6030 }
6031 \newbox\balancedcolumns
6032 \setbox\balancedcolumns=\vbox{shouldnt see this}%
6033 %
6034 % Only called for the last of the double column material.  \doublecolumnout 
6035 % does the others.
6036 \def\balancecolumns{%
6037   \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120.
6038   \dimen@ = \ht0
6039   \advance\dimen@ by \topskip
6040   \advance\dimen@ by-\baselineskip
6041   \ifdim\dimen@<5\baselineskip
6042     % Don't split a short final column in two.
6043     \setbox2=\vbox{}%
6044     \global\setbox\balancedcolumns=\vbox{\pagesofar}%
6045   \else
6046     \divide\dimen@ by 2 % target to split to
6047     \dimen@ii = \dimen@
6048     \splittopskip = \topskip
6049     % Loop until left column is at least as high as the right column.
6050     {%
6051       \vbadness = 10000
6052       \loop
6053         \global\setbox3 = \copy0
6054         \global\setbox1 = \vsplit3 to \dimen@
6055       \ifdim\ht1<\ht3
6056         \global\advance\dimen@ by 1pt
6057       \repeat
6058     }%
6059     % Now the left column is in box 1, and the right column in box 3.
6060     %
6061     % Check whether the left column has come out higher than the page itself.  
6062     % (Note that we have doubled \vsize for the double columns, so
6063     % the actual height of the page is 0.5\vsize).
6064     \ifdim2\ht1>\vsize
6065       % It appears that we have been called upon to balance too much material.
6066       % Output some of it with \doublecolumnout, leaving the rest on the page.
6067       \setbox\PAGE=\box0
6068       \doublecolumnout
6069     \else
6070       % Compare the heights of the two columns.
6071       \ifdim4\ht1>5\ht3
6072         % Column heights are too different, so don't make their bottoms
6073         % flush with each other.
6074         \setbox2=\vbox to \ht1 {\unvbox3\vfill}%
6075         \setbox0=\vbox to \ht1 {\unvbox1\vfill}%
6076       \else
6077         % Make column bottoms flush with each other.
6078         \setbox2=\vbox to\ht1{\unvbox3\unskip}%
6079         \setbox0=\vbox to\ht1{\unvbox1\unskip}%
6080       \fi
6081       \global\setbox\balancedcolumns=\vbox{\pagesofar}%
6082     \fi
6083   \fi
6084   %
6085 }
6086 \catcode`\@ = \other
6087
6088
6089 \message{sectioning,}
6090 % Chapters, sections, etc.
6091
6092 % Let's start with @part.
6093 \outer\parseargdef\part{\partzzz{#1}}
6094 \def\partzzz#1{%
6095   \chapoddpage
6096   \null
6097   \vskip.3\vsize  % move it down on the page a bit
6098   \begingroup
6099     \noindent \titlefonts\rm #1\par % the text
6100     \let\lastnode=\empty      % no node to associate with
6101     \writetocentry{part}{#1}{}% but put it in the toc
6102     \headingsoff              % no headline or footline on the part page
6103     % This outputs a mark at the end of the page that clears \thischapter
6104     % and \thissection, as is done in \startcontents.
6105     \let\pchapsepmacro\relax
6106     \chapmacro{}{Yomitfromtoc}{}%
6107     \chapoddpage
6108   \endgroup
6109 }
6110
6111 % \unnumberedno is an oxymoron.  But we count the unnumbered
6112 % sections so that we can refer to them unambiguously in the pdf
6113 % outlines by their "section number".  We avoid collisions with chapter
6114 % numbers by starting them at 10000.  (If a document ever has 10000
6115 % chapters, we're in trouble anyway, I'm sure.)
6116 \newcount\unnumberedno \unnumberedno = 10000
6117 \newcount\chapno
6118 \newcount\secno        \secno=0
6119 \newcount\subsecno     \subsecno=0
6120 \newcount\subsubsecno  \subsubsecno=0
6121
6122 % This counter is funny since it counts through charcodes of letters A, B, ...
6123 \newcount\appendixno  \appendixno = `\@
6124 %
6125 % \def\appendixletter{\char\the\appendixno}
6126 % We do the following ugly conditional instead of the above simple
6127 % construct for the sake of pdftex, which needs the actual
6128 % letter in the expansion, not just typeset.
6129 %
6130 \def\appendixletter{%
6131   \ifnum\appendixno=`A A%
6132   \else\ifnum\appendixno=`B B%
6133   \else\ifnum\appendixno=`C C%
6134   \else\ifnum\appendixno=`D D%
6135   \else\ifnum\appendixno=`E E%
6136   \else\ifnum\appendixno=`F F%
6137   \else\ifnum\appendixno=`G G%
6138   \else\ifnum\appendixno=`H H%
6139   \else\ifnum\appendixno=`I I%
6140   \else\ifnum\appendixno=`J J%
6141   \else\ifnum\appendixno=`K K%
6142   \else\ifnum\appendixno=`L L%
6143   \else\ifnum\appendixno=`M M%
6144   \else\ifnum\appendixno=`N N%
6145   \else\ifnum\appendixno=`O O%
6146   \else\ifnum\appendixno=`P P%
6147   \else\ifnum\appendixno=`Q Q%
6148   \else\ifnum\appendixno=`R R%
6149   \else\ifnum\appendixno=`S S%
6150   \else\ifnum\appendixno=`T T%
6151   \else\ifnum\appendixno=`U U%
6152   \else\ifnum\appendixno=`V V%
6153   \else\ifnum\appendixno=`W W%
6154   \else\ifnum\appendixno=`X X%
6155   \else\ifnum\appendixno=`Y Y%
6156   \else\ifnum\appendixno=`Z Z%
6157   % The \the is necessary, despite appearances, because \appendixletter is
6158   % expanded while writing the .toc file.  \char\appendixno is not
6159   % expandable, thus it is written literally, thus all appendixes come out
6160   % with the same letter (or @) in the toc without it.
6161   \else\char\the\appendixno
6162   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
6163   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
6164
6165 % Each @chapter defines these (using marks) as the number+name, number
6166 % and name of the chapter.  Page headings and footings can use
6167 % these.  @section does likewise.
6168 \def\thischapter{}
6169 \def\thischapternum{}
6170 \def\thischaptername{}
6171 \def\thissection{}
6172 \def\thissectionnum{}
6173 \def\thissectionname{}
6174
6175 \newcount\absseclevel % used to calculate proper heading level
6176 \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
6177
6178 % @raisesections: treat @section as chapter, @subsection as section, etc.
6179 \def\raisesections{\global\advance\secbase by -1}
6180 \let\up=\raisesections % original BFox name
6181
6182 % @lowersections: treat @chapter as section, @section as subsection, etc.
6183 \def\lowersections{\global\advance\secbase by 1}
6184 \let\down=\lowersections % original BFox name
6185
6186 % we only have subsub.
6187 \chardef\maxseclevel = 3
6188 %
6189 % A numbered section within an unnumbered changes to unnumbered too.
6190 % To achieve this, remember the "biggest" unnum. sec. we are currently in:
6191 \chardef\unnlevel = \maxseclevel
6192 %
6193 % Trace whether the current chapter is an appendix or not:
6194 % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
6195 \def\chapheadtype{N}
6196
6197 % Choose a heading macro
6198 % #1 is heading type
6199 % #2 is heading level
6200 % #3 is text for heading
6201 \def\genhead#1#2#3{%
6202   % Compute the abs. sec. level:
6203   \absseclevel=#2
6204   \advance\absseclevel by \secbase
6205   % Make sure \absseclevel doesn't fall outside the range:
6206   \ifnum \absseclevel < 0
6207     \absseclevel = 0
6208   \else
6209     \ifnum \absseclevel > 3
6210       \absseclevel = 3
6211     \fi
6212   \fi
6213   % The heading type:
6214   \def\headtype{#1}%
6215   \if \headtype U%
6216     \ifnum \absseclevel < \unnlevel
6217       \chardef\unnlevel = \absseclevel
6218     \fi
6219   \else
6220     % Check for appendix sections:
6221     \ifnum \absseclevel = 0
6222       \edef\chapheadtype{\headtype}%
6223     \else
6224       \if \headtype A\if \chapheadtype N%
6225         \errmessage{@appendix... within a non-appendix chapter}%
6226       \fi\fi
6227     \fi
6228     % Check for numbered within unnumbered:
6229     \ifnum \absseclevel > \unnlevel
6230       \def\headtype{U}%
6231     \else
6232       \chardef\unnlevel = 3
6233     \fi
6234   \fi
6235   % Now print the heading:
6236   \if \headtype U%
6237     \ifcase\absseclevel
6238         \unnumberedzzz{#3}%
6239     \or \unnumberedseczzz{#3}%
6240     \or \unnumberedsubseczzz{#3}%
6241     \or \unnumberedsubsubseczzz{#3}%
6242     \fi
6243   \else
6244     \if \headtype A%
6245       \ifcase\absseclevel
6246           \appendixzzz{#3}%
6247       \or \appendixsectionzzz{#3}%
6248       \or \appendixsubseczzz{#3}%
6249       \or \appendixsubsubseczzz{#3}%
6250       \fi
6251     \else
6252       \ifcase\absseclevel
6253           \chapterzzz{#3}%
6254       \or \seczzz{#3}%
6255       \or \numberedsubseczzz{#3}%
6256       \or \numberedsubsubseczzz{#3}%
6257       \fi
6258     \fi
6259   \fi
6260   \suppressfirstparagraphindent
6261 }
6262
6263 % an interface:
6264 \def\numhead{\genhead N}
6265 \def\apphead{\genhead A}
6266 \def\unnmhead{\genhead U}
6267
6268 % @chapter, @appendix, @unnumbered.  Increment top-level counter, reset
6269 % all lower-level sectioning counters to zero.
6270 %
6271 % Also set \chaplevelprefix, which we prepend to @float sequence numbers
6272 % (e.g., figures), q.v.  By default (before any chapter), that is empty.
6273 \let\chaplevelprefix = \empty
6274 %
6275 \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
6276 \def\chapterzzz#1{%
6277   % section resetting is \global in case the chapter is in a group, such
6278   % as an @include file.
6279   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6280     \global\advance\chapno by 1
6281   %
6282   % Used for \float.
6283   \gdef\chaplevelprefix{\the\chapno.}%
6284   \resetallfloatnos
6285   %
6286   % \putwordChapter can contain complex things in translations.
6287   \toks0=\expandafter{\putwordChapter}%
6288   \message{\the\toks0 \space \the\chapno}%
6289   %
6290   % Write the actual heading.
6291   \chapmacro{#1}{Ynumbered}{\the\chapno}%
6292   %
6293   % So @section and the like are numbered underneath this chapter.
6294   \global\let\section = \numberedsec
6295   \global\let\subsection = \numberedsubsec
6296   \global\let\subsubsection = \numberedsubsubsec
6297 }
6298
6299 \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
6300 %
6301 \def\appendixzzz#1{%
6302   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6303     \global\advance\appendixno by 1
6304   \gdef\chaplevelprefix{\appendixletter.}%
6305   \resetallfloatnos
6306   %
6307   % \putwordAppendix can contain complex things in translations.
6308   \toks0=\expandafter{\putwordAppendix}%
6309   \message{\the\toks0 \space \appendixletter}%
6310   %
6311   \chapmacro{#1}{Yappendix}{\appendixletter}%
6312   %
6313   \global\let\section = \appendixsec
6314   \global\let\subsection = \appendixsubsec
6315   \global\let\subsubsection = \appendixsubsubsec
6316 }
6317
6318 % normally unnmhead0 calls unnumberedzzz:
6319 \outer\parseargdef\unnumbered{\unnmhead0{#1}}
6320 \def\unnumberedzzz#1{%
6321   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6322     \global\advance\unnumberedno by 1
6323   %
6324   % Since an unnumbered has no number, no prefix for figures.
6325   \global\let\chaplevelprefix = \empty
6326   \resetallfloatnos
6327   %
6328   % This used to be simply \message{#1}, but TeX fully expands the
6329   % argument to \message.  Therefore, if #1 contained @-commands, TeX
6330   % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
6331   % expanded @cite (which turns out to cause errors because \cite is meant
6332   % to be executed, not expanded).
6333   %
6334   % Anyway, we don't want the fully-expanded definition of @cite to appear
6335   % as a result of the \message, we just want `@cite' itself.  We use
6336   % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6337   % simply yielding the contents of <toks register>.  (We also do this for
6338   % the toc entries.)
6339   \toks0 = {#1}%
6340   \message{(\the\toks0)}%
6341   %
6342   \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
6343   %
6344   \global\let\section = \unnumberedsec
6345   \global\let\subsection = \unnumberedsubsec
6346   \global\let\subsubsection = \unnumberedsubsubsec
6347 }
6348
6349 % @centerchap is like @unnumbered, but the heading is centered.
6350 \outer\parseargdef\centerchap{%
6351   \let\centerparametersmaybe = \centerparameters
6352   \unnmhead0{#1}%
6353   \let\centerparametersmaybe = \relax
6354 }
6355
6356 % @top is like @unnumbered.
6357 \let\top\unnumbered
6358
6359 % Sections.
6360
6361 \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6362 \def\seczzz#1{%
6363   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6364   \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
6365 }
6366
6367 % normally calls appendixsectionzzz:
6368 \outer\parseargdef\appendixsection{\apphead1{#1}}
6369 \def\appendixsectionzzz#1{%
6370   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6371   \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
6372 }
6373 \let\appendixsec\appendixsection
6374
6375 % normally calls unnumberedseczzz:
6376 \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
6377 \def\unnumberedseczzz#1{%
6378   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6379   \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
6380 }
6381
6382 % Subsections.
6383
6384 % normally calls numberedsubseczzz:
6385 \outer\parseargdef\numberedsubsec{\numhead2{#1}}
6386 \def\numberedsubseczzz#1{%
6387   \global\subsubsecno=0  \global\advance\subsecno by 1
6388   \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
6389 }
6390
6391 % normally calls appendixsubseczzz:
6392 \outer\parseargdef\appendixsubsec{\apphead2{#1}}
6393 \def\appendixsubseczzz#1{%
6394   \global\subsubsecno=0  \global\advance\subsecno by 1
6395   \sectionheading{#1}{subsec}{Yappendix}%
6396                  {\appendixletter.\the\secno.\the\subsecno}%
6397 }
6398
6399 % normally calls unnumberedsubseczzz:
6400 \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
6401 \def\unnumberedsubseczzz#1{%
6402   \global\subsubsecno=0  \global\advance\subsecno by 1
6403   \sectionheading{#1}{subsec}{Ynothing}%
6404                  {\the\unnumberedno.\the\secno.\the\subsecno}%
6405 }
6406
6407 % Subsubsections.
6408
6409 % normally numberedsubsubseczzz:
6410 \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
6411 \def\numberedsubsubseczzz#1{%
6412   \global\advance\subsubsecno by 1
6413   \sectionheading{#1}{subsubsec}{Ynumbered}%
6414                  {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
6415 }
6416
6417 % normally appendixsubsubseczzz:
6418 \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
6419 \def\appendixsubsubseczzz#1{%
6420   \global\advance\subsubsecno by 1
6421   \sectionheading{#1}{subsubsec}{Yappendix}%
6422                  {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
6423 }
6424
6425 % normally unnumberedsubsubseczzz:
6426 \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
6427 \def\unnumberedsubsubseczzz#1{%
6428   \global\advance\subsubsecno by 1
6429   \sectionheading{#1}{subsubsec}{Ynothing}%
6430                  {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
6431 }
6432
6433 % These macros control what the section commands do, according
6434 % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6435 % Define them by default for a numbered chapter.
6436 \let\section = \numberedsec
6437 \let\subsection = \numberedsubsec
6438 \let\subsubsection = \numberedsubsubsec
6439
6440 % Define @majorheading, @heading and @subheading
6441
6442 \def\majorheading{%
6443   {\advance\chapheadingskip by 10pt \chapbreak }%
6444   \parsearg\chapheadingzzz
6445 }
6446
6447 \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6448 \def\chapheadingzzz#1{%
6449   \vbox{\chapfonts \raggedtitlesettings #1\par}%
6450   \nobreak\bigskip \nobreak
6451   \suppressfirstparagraphindent
6452 }
6453
6454 % @heading, @subheading, @subsubheading.
6455 \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6456   \suppressfirstparagraphindent}
6457 \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6458   \suppressfirstparagraphindent}
6459 \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6460   \suppressfirstparagraphindent}
6461
6462 % These macros generate a chapter, section, etc. heading only
6463 % (including whitespace, linebreaking, etc. around it),
6464 % given all the information in convenient, parsed form.
6465
6466 % Args are the skip and penalty (usually negative)
6467 \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6468
6469 % Parameter controlling skip before chapter headings (if needed)
6470 \newskip\chapheadingskip
6471
6472 % Define plain chapter starts, and page on/off switching for it.
6473 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
6474
6475 % Start a new page
6476 \def\chappager{\par\vfill\supereject}
6477
6478 % \chapoddpage - start on an odd page for a new chapter
6479 % Because \domark is called before \chapoddpage, the filler page will
6480 % get the headings for the next chapter, which is wrong.  But we don't
6481 % care -- we just disable all headings on the filler page.
6482 \def\chapoddpage{%
6483   \chappager
6484   \ifodd\pageno \else
6485     \begingroup
6486       \headingsoff
6487       \null
6488       \chappager
6489     \endgroup
6490   \fi
6491 }
6492
6493 \parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
6494
6495 \def\CHAPPAGoff{%
6496 \global\let\contentsalignmacro = \chappager
6497 \global\let\pchapsepmacro=\chapbreak
6498 \global\let\pagealignmacro=\chappager}
6499
6500 \def\CHAPPAGon{%
6501 \global\let\contentsalignmacro = \chappager
6502 \global\let\pchapsepmacro=\chappager
6503 \global\let\pagealignmacro=\chappager
6504 \global\def\HEADINGSon{\HEADINGSsingle}}
6505
6506 \def\CHAPPAGodd{%
6507 \global\let\contentsalignmacro = \chapoddpage
6508 \global\let\pchapsepmacro=\chapoddpage
6509 \global\let\pagealignmacro=\chapoddpage
6510 \global\def\HEADINGSon{\HEADINGSdouble}}
6511
6512 \CHAPPAGon
6513
6514 % \chapmacro - Chapter opening.
6515 %
6516 % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6517 % Yappendix, Yomitfromtoc), #3 the chapter number.
6518 % Not used for @heading series.
6519 %
6520 % To test against our argument.
6521 \def\Ynothingkeyword{Ynothing}
6522 \def\Yappendixkeyword{Yappendix}
6523 \def\Yomitfromtockeyword{Yomitfromtoc}
6524 %
6525 \def\chapmacro#1#2#3{%
6526   \expandafter\ifx\thisenv\titlepage\else
6527     \checkenv{}% chapters, etc., should not start inside an environment.
6528   \fi
6529   % FIXME: \chapmacro is currently called from inside \titlepage when
6530   % \setcontentsaftertitlepage to print the "Table of Contents" heading, but
6531   % this should probably be done by \sectionheading with an option to print
6532   % in chapter size.
6533   %
6534   % Insert the first mark before the heading break (see notes for \domark).
6535   \let\prevchapterdefs=\lastchapterdefs
6536   \let\prevsectiondefs=\lastsectiondefs
6537   \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6538                         \gdef\thissection{}}%
6539   %
6540   \def\temptype{#2}%
6541   \ifx\temptype\Ynothingkeyword
6542     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6543                           \gdef\thischapter{\thischaptername}}%
6544   \else\ifx\temptype\Yomitfromtockeyword
6545     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6546                           \gdef\thischapter{}}%
6547   \else\ifx\temptype\Yappendixkeyword
6548     \toks0={#1}%
6549     \xdef\lastchapterdefs{%
6550       \gdef\noexpand\thischaptername{\the\toks0}%
6551       \gdef\noexpand\thischapternum{\appendixletter}%
6552       % \noexpand\putwordAppendix avoids expanding indigestible
6553       % commands in some of the translations.
6554       \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
6555                                  \noexpand\thischapternum:
6556                                  \noexpand\thischaptername}%
6557     }%
6558   \else
6559     \toks0={#1}%
6560     \xdef\lastchapterdefs{%
6561       \gdef\noexpand\thischaptername{\the\toks0}%
6562       \gdef\noexpand\thischapternum{\the\chapno}%
6563       % \noexpand\putwordChapter avoids expanding indigestible
6564       % commands in some of the translations.
6565       \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
6566                                  \noexpand\thischapternum:
6567                                  \noexpand\thischaptername}%
6568     }%
6569   \fi\fi\fi
6570   %
6571   % Output the mark.  Pass it through \safewhatsit, to take care of
6572   % the preceding space.
6573   \safewhatsit\domark
6574   %
6575   % Insert the chapter heading break.
6576   \pchapsepmacro
6577   %
6578   % Now the second mark, after the heading break.  No break points
6579   % between here and the heading.
6580   \let\prevchapterdefs=\lastchapterdefs
6581   \let\prevsectiondefs=\lastsectiondefs
6582   \domark
6583   %
6584   {%
6585     \chapfonts \rm
6586     \let\footnote=\errfootnoteheading % give better error message
6587     %
6588     % Have to define \lastsection before calling \donoderef, because the
6589     % xref code eventually uses it.  On the other hand, it has to be called
6590     % after \pchapsepmacro, or the headline will change too soon.
6591     \gdef\lastsection{#1}%
6592     %
6593     % Only insert the separating space if we have a chapter/appendix
6594     % number, and don't print the unnumbered ``number''.
6595     \ifx\temptype\Ynothingkeyword
6596       \setbox0 = \hbox{}%
6597       \def\toctype{unnchap}%
6598     \else\ifx\temptype\Yomitfromtockeyword
6599       \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6600       \def\toctype{omit}%
6601     \else\ifx\temptype\Yappendixkeyword
6602       \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6603       \def\toctype{app}%
6604     \else
6605       \setbox0 = \hbox{#3\enspace}%
6606       \def\toctype{numchap}%
6607     \fi\fi\fi
6608     %
6609     % Write the toc entry for this chapter.  Must come before the
6610     % \donoderef, because we include the current node name in the toc
6611     % entry, and \donoderef resets it to empty.
6612     \writetocentry{\toctype}{#1}{#3}%
6613     %
6614     % For pdftex, we have to write out the node definition (aka, make
6615     % the pdfdest) after any page break, but before the actual text has
6616     % been typeset.  If the destination for the pdf outline is after the
6617     % text, then jumping from the outline may wind up with the text not
6618     % being visible, for instance under high magnification.
6619     \donoderef{#2}%
6620     %
6621     % Typeset the actual heading.
6622     \nobreak % Avoid page breaks at the interline glue.
6623     \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
6624           \unhbox0 #1\par}%
6625   }%
6626   \nobreak\bigskip % no page break after a chapter title
6627   \nobreak
6628 }
6629
6630 % @centerchap -- centered and unnumbered.
6631 \let\centerparametersmaybe = \relax
6632 \def\centerparameters{%
6633   \advance\rightskip by 3\rightskip
6634   \leftskip = \rightskip
6635   \parfillskip = 0pt
6636 }
6637
6638
6639 % Section titles.  These macros combine the section number parts and
6640 % call the generic \sectionheading to do the printing.
6641 %
6642 \newskip\secheadingskip
6643 \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
6644
6645 % Subsection titles.
6646 \newskip\subsecheadingskip
6647 \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
6648
6649 % Subsubsection titles.
6650 \def\subsubsecheadingskip{\subsecheadingskip}
6651 \def\subsubsecheadingbreak{\subsecheadingbreak}
6652
6653
6654 % Print any size, any type, section title.
6655 %
6656 % #1 is the text of the title,
6657 % #2 is the section level (sec/subsec/subsubsec),
6658 % #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6659 % #4 is the section number.
6660 %
6661 \def\seckeyword{sec}
6662 %
6663 \def\sectionheading#1#2#3#4{%
6664   {%
6665     \def\sectionlevel{#2}%
6666     \def\temptype{#3}%
6667     %
6668     % It is ok for the @heading series commands to appear inside an
6669     % environment (it's been historically allowed, though the logic is
6670     % dubious), but not the others.
6671     \ifx\temptype\Yomitfromtockeyword\else
6672       \checkenv{}% non-@*heading should not be in an environment.
6673     \fi
6674     \let\footnote=\errfootnoteheading
6675     %
6676     % Switch to the right set of fonts.
6677     \csname #2fonts\endcsname \rm
6678     %
6679     % Insert first mark before the heading break (see notes for \domark).
6680     \let\prevsectiondefs=\lastsectiondefs
6681     \ifx\temptype\Ynothingkeyword
6682       \ifx\sectionlevel\seckeyword
6683         \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6684                               \gdef\thissection{\thissectionname}}%
6685       \fi
6686     \else\ifx\temptype\Yomitfromtockeyword
6687       % Don't redefine \thissection.
6688     \else\ifx\temptype\Yappendixkeyword
6689       \ifx\sectionlevel\seckeyword
6690         \toks0={#1}%
6691         \xdef\lastsectiondefs{%
6692           \gdef\noexpand\thissectionname{\the\toks0}%
6693           \gdef\noexpand\thissectionnum{#4}%
6694           % \noexpand\putwordSection avoids expanding indigestible
6695           % commands in some of the translations.
6696           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6697                                      \noexpand\thissectionnum:
6698                                      \noexpand\thissectionname}%
6699         }%
6700       \fi
6701     \else
6702       \ifx\sectionlevel\seckeyword
6703         \toks0={#1}%
6704         \xdef\lastsectiondefs{%
6705           \gdef\noexpand\thissectionname{\the\toks0}%
6706           \gdef\noexpand\thissectionnum{#4}%
6707           % \noexpand\putwordSection avoids expanding indigestible
6708           % commands in some of the translations.
6709           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6710                                      \noexpand\thissectionnum:
6711                                      \noexpand\thissectionname}%
6712         }%
6713       \fi
6714     \fi\fi\fi
6715     %
6716     % Go into vertical mode.  Usually we'll already be there, but we
6717     % don't want the following whatsit to end up in a preceding paragraph
6718     % if the document didn't happen to have a blank line.
6719     \par
6720     %
6721     % Output the mark.  Pass it through \safewhatsit, to take care of
6722     % the preceding space.
6723     \safewhatsit\domark
6724     %
6725     % Insert space above the heading.
6726     \csname #2headingbreak\endcsname
6727     %
6728     % Now the second mark, after the heading break.  No break points
6729     % between here and the heading.
6730     \global\let\prevsectiondefs=\lastsectiondefs
6731     \domark
6732     %
6733     % Only insert the space after the number if we have a section number.
6734     \ifx\temptype\Ynothingkeyword
6735       \setbox0 = \hbox{}%
6736       \def\toctype{unn}%
6737       \gdef\lastsection{#1}%
6738     \else\ifx\temptype\Yomitfromtockeyword
6739       % for @headings -- no section number, don't include in toc,
6740       % and don't redefine \lastsection.
6741       \setbox0 = \hbox{}%
6742       \def\toctype{omit}%
6743       \let\sectionlevel=\empty
6744     \else\ifx\temptype\Yappendixkeyword
6745       \setbox0 = \hbox{#4\enspace}%
6746       \def\toctype{app}%
6747       \gdef\lastsection{#1}%
6748     \else
6749       \setbox0 = \hbox{#4\enspace}%
6750       \def\toctype{num}%
6751       \gdef\lastsection{#1}%
6752     \fi\fi\fi
6753     %
6754     % Write the toc entry (before \donoderef).  See comments in \chapmacro.
6755     \writetocentry{\toctype\sectionlevel}{#1}{#4}%
6756     %
6757     % Write the node reference (= pdf destination for pdftex).
6758     % Again, see comments in \chapmacro.
6759     \donoderef{#3}%
6760     %
6761     % Interline glue will be inserted when the vbox is completed.
6762     % That glue will be a valid breakpoint for the page, since it'll be
6763     % preceded by a whatsit (usually from the \donoderef, or from the
6764     % \writetocentry if there was no node).  We don't want to allow that
6765     % break, since then the whatsits could end up on page n while the
6766     % section is on page n+1, thus toc/etc. are wrong.  Debian bug 276000.
6767     \nobreak
6768     %
6769     % Output the actual section heading.
6770     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
6771           \hangindent=\wd0  % zero if no section number
6772           \unhbox0 #1}%
6773   }%
6774   % Add extra space after the heading -- half of whatever came above it.
6775   % Don't allow stretch, though.
6776   \kern .5 \csname #2headingskip\endcsname
6777   %
6778   % Do not let the kern be a potential breakpoint, as it would be if it
6779   % was followed by glue.
6780   \nobreak
6781   %
6782   % We'll almost certainly start a paragraph next, so don't let that
6783   % glue accumulate.  (Not a breakpoint because it's preceded by a
6784   % discardable item.)  However, when a paragraph is not started next
6785   % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6786   % or the negative glue will cause weirdly wrong output, typically
6787   % obscuring the section heading with something else.
6788   \vskip-\parskip
6789   %
6790   % This is so the last item on the main vertical list is a known
6791   % \penalty > 10000, so \startdefun, etc., can recognize the situation
6792   % and do the needful.
6793   \penalty 10001
6794 }
6795
6796
6797 \message{toc,}
6798 % Table of contents.
6799 \newwrite\tocfile
6800
6801 % Write an entry to the toc file, opening it if necessary.
6802 % Called from @chapter, etc.
6803 %
6804 % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6805 % We append the current node name (if any) and page number as additional
6806 % arguments for the \{chap,sec,...}entry macros which will eventually
6807 % read this.  The node name is used in the pdf outlines as the
6808 % destination to jump to.
6809 %
6810 % We open the .toc file for writing here instead of at @setfilename (or
6811 % any other fixed time) so that @contents can be anywhere in the document.
6812 % But if #1 is `omit', then we don't do anything.  This is used for the
6813 % table of contents chapter openings themselves.
6814 %
6815 \newif\iftocfileopened
6816 \def\omitkeyword{omit}%
6817 %
6818 \def\writetocentry#1#2#3{%
6819   \edef\writetoctype{#1}%
6820   \ifx\writetoctype\omitkeyword \else
6821     \iftocfileopened\else
6822       \immediate\openout\tocfile = \jobname.toc
6823       \global\tocfileopenedtrue
6824     \fi
6825     %
6826     \iflinks
6827       {\atdummies
6828        \edef\temp{%
6829          \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6830        \temp
6831       }%
6832     \fi
6833   \fi
6834   %
6835   % Tell \shipout to create a pdf destination on each page, if we're
6836   % writing pdf.  These are used in the table of contents.  We can't
6837   % just write one on every page because the title pages are numbered
6838   % 1 and 2 (the page numbers aren't printed), and so are the first
6839   % two pages of the document.  Thus, we'd have two destinations named
6840   % `1', and two named `2'.
6841   \ifpdf
6842     \global\pdfmakepagedesttrue
6843   \else
6844     \ifx\XeTeXrevision\thisisundefined
6845     \else
6846       \global\pdfmakepagedesttrue
6847     \fi
6848   \fi
6849 }
6850
6851
6852 % These characters do not print properly in the Computer Modern roman
6853 % fonts, so we must take special care.  This is more or less redundant
6854 % with the Texinfo input format setup at the end of this file.
6855 %
6856 \def\activecatcodes{%
6857   \catcode`\"=\active
6858   \catcode`\$=\active
6859   \catcode`\<=\active
6860   \catcode`\>=\active
6861   \catcode`\\=\active
6862   \catcode`\^=\active
6863   \catcode`\_=\active
6864   \catcode`\|=\active
6865   \catcode`\~=\active
6866 }
6867
6868
6869 % Read the toc file, which is essentially Texinfo input.
6870 \def\readtocfile{%
6871   \setupdatafile
6872   \activecatcodes
6873   \input \tocreadfilename
6874 }
6875
6876 \newskip\contentsrightmargin \contentsrightmargin=1in
6877 \newcount\savepageno
6878 \newcount\lastnegativepageno \lastnegativepageno = -1
6879
6880 % Prepare to read what we've written to \tocfile.
6881 %
6882 \def\startcontents#1{%
6883   % If @setchapternewpage on, and @headings double, the contents should
6884   % start on an odd page, unlike chapters.  Thus, we maintain
6885   % \contentsalignmacro in parallel with \pagealignmacro.
6886   % From: Torbjorn Granlund <tege@matematik.su.se>
6887   \contentsalignmacro
6888   \immediate\closeout\tocfile
6889   %
6890   % Don't need to put `Contents' or `Short Contents' in the headline.
6891   % It is abundantly clear what they are.
6892   \chapmacro{#1}{Yomitfromtoc}{}%
6893   %
6894   \savepageno = \pageno
6895   \begingroup                  % Set up to handle contents files properly.
6896     \raggedbottom              % Worry more about breakpoints than the bottom.
6897     \entryrightmargin=\contentsrightmargin % Don't use the full line length.
6898     %
6899     % Roman numerals for page numbers.
6900     \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
6901 }
6902
6903 % redefined for the two-volume lispref.  We always output on
6904 % \jobname.toc even if this is redefined.
6905 %
6906 \def\tocreadfilename{\jobname.toc}
6907
6908 % Normal (long) toc.
6909 %
6910 \def\contents{%
6911   \startcontents{\putwordTOC}%
6912     \openin 1 \tocreadfilename\space
6913     \ifeof 1 \else
6914       \readtocfile
6915     \fi
6916     \vfill \eject
6917     \contentsalignmacro % in case @setchapternewpage odd is in effect
6918     \ifeof 1 \else
6919       \pdfmakeoutlines
6920     \fi
6921     \closein 1
6922   \endgroup
6923   \lastnegativepageno = \pageno
6924   \global\pageno = \savepageno
6925 }
6926
6927 % And just the chapters.
6928 \def\summarycontents{%
6929   \startcontents{\putwordShortTOC}%
6930     %
6931     \let\partentry = \shortpartentry
6932     \let\numchapentry = \shortchapentry
6933     \let\appentry = \shortchapentry
6934     \let\unnchapentry = \shortunnchapentry
6935     % We want a true roman here for the page numbers.
6936     \secfonts
6937     \let\rm=\shortcontrm \let\bf=\shortcontbf
6938     \let\sl=\shortcontsl \let\tt=\shortconttt
6939     \rm
6940     \hyphenpenalty = 10000
6941     \advance\baselineskip by 1pt % Open it up a little.
6942     \def\numsecentry##1##2##3##4{}
6943     \let\appsecentry = \numsecentry
6944     \let\unnsecentry = \numsecentry
6945     \let\numsubsecentry = \numsecentry
6946     \let\appsubsecentry = \numsecentry
6947     \let\unnsubsecentry = \numsecentry
6948     \let\numsubsubsecentry = \numsecentry
6949     \let\appsubsubsecentry = \numsecentry
6950     \let\unnsubsubsecentry = \numsecentry
6951     \openin 1 \tocreadfilename\space
6952     \ifeof 1 \else
6953       \readtocfile
6954     \fi
6955     \closein 1
6956     \vfill \eject
6957     \contentsalignmacro % in case @setchapternewpage odd is in effect
6958   \endgroup
6959   \lastnegativepageno = \pageno
6960   \global\pageno = \savepageno
6961 }
6962 \let\shortcontents = \summarycontents
6963
6964 % Typeset the label for a chapter or appendix for the short contents.
6965 % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6966 %
6967 \def\shortchaplabel#1{%
6968   % This space should be enough, since a single number is .5em, and the
6969   % widest letter (M) is 1em, at least in the Computer Modern fonts.
6970   % But use \hss just in case.
6971   % (This space doesn't include the extra space that gets added after
6972   % the label; that gets put in by \shortchapentry above.)
6973   %
6974   % We'd like to right-justify chapter numbers, but that looks strange
6975   % with appendix letters.  And right-justifying numbers and
6976   % left-justifying letters looks strange when there is less than 10
6977   % chapters.  Have to read the whole toc once to know how many chapters
6978   % there are before deciding ...
6979   \hbox to 1em{#1\hss}%
6980 }
6981
6982 % These macros generate individual entries in the table of contents.
6983 % The first argument is the chapter or section name.
6984 % The last argument is the page number.
6985 % The arguments in between are the chapter number, section number, ...
6986
6987 % Parts, in the main contents.  Replace the part number, which doesn't
6988 % exist, with an empty box.  Let's hope all the numbers have the same width.
6989 % Also ignore the page number, which is conventionally not printed.
6990 \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6991 \def\partentry#1#2#3#4{%
6992   % Add stretch and a bonus for breaking the page before the part heading.
6993   % This reduces the chance of the page being broken immediately after the
6994   % part heading, before a following chapter heading.
6995   \vskip 0pt plus 5\baselineskip
6996   \penalty-300
6997   \vskip 0pt plus -5\baselineskip
6998   \dochapentry{\numeralbox\labelspace#1}{}%
6999 }
7000 %
7001 % Parts, in the short toc.
7002 \def\shortpartentry#1#2#3#4{%
7003   \penalty-300
7004   \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
7005   \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
7006 }
7007
7008 % Chapters, in the main contents.
7009 \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
7010
7011 % Chapters, in the short toc.
7012 % See comments in \dochapentry re vbox and related settings.
7013 \def\shortchapentry#1#2#3#4{%
7014   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
7015 }
7016
7017 % Appendices, in the main contents.
7018 % Need the word Appendix, and a fixed-size box.
7019 %
7020 \def\appendixbox#1{%
7021   % We use M since it's probably the widest letter.
7022   \setbox0 = \hbox{\putwordAppendix{} M}%
7023   \hbox to \wd0{\putwordAppendix{} #1\hss}}
7024 %
7025 \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
7026
7027 % Unnumbered chapters.
7028 \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
7029 \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
7030
7031 % Sections.
7032 \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
7033 \let\appsecentry=\numsecentry
7034 \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
7035
7036 % Subsections.
7037 \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
7038 \let\appsubsecentry=\numsubsecentry
7039 \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
7040
7041 % And subsubsections.
7042 \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
7043 \let\appsubsubsecentry=\numsubsubsecentry
7044 \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
7045
7046 % This parameter controls the indentation of the various levels.
7047 % Same as \defaultparindent.
7048 \newdimen\tocindent \tocindent = 15pt
7049
7050 % Now for the actual typesetting. In all these, #1 is the text and #2 is the
7051 % page number.
7052 %
7053 % If the toc has to be broken over pages, we want it to be at chapters
7054 % if at all possible; hence the \penalty.
7055 \def\dochapentry#1#2{%
7056    \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
7057    \begingroup
7058      % Move the page numbers slightly to the right
7059      \advance\entryrightmargin by -0.05em
7060      \chapentryfonts
7061      \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7062    \endgroup
7063    \nobreak\vskip .25\baselineskip plus.1\baselineskip
7064 }
7065
7066 \def\dosecentry#1#2{\begingroup
7067   \secentryfonts \leftskip=\tocindent
7068   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7069 \endgroup}
7070
7071 \def\dosubsecentry#1#2{\begingroup
7072   \subsecentryfonts \leftskip=2\tocindent
7073   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7074 \endgroup}
7075
7076 \def\dosubsubsecentry#1#2{\begingroup
7077   \subsubsecentryfonts \leftskip=3\tocindent
7078   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7079 \endgroup}
7080
7081 % We use the same \entry macro as for the index entries.
7082 \let\tocentry = \entry
7083
7084 % Space between chapter (or whatever) number and the title.
7085 \def\labelspace{\hskip1em \relax}
7086
7087 \def\dopageno#1{{\rm #1}}
7088 \def\doshortpageno#1{{\rm #1}}
7089
7090 \def\chapentryfonts{\secfonts \rm}
7091 \def\secentryfonts{\textfonts}
7092 \def\subsecentryfonts{\textfonts}
7093 \def\subsubsecentryfonts{\textfonts}
7094
7095
7096 \message{environments,}
7097 % @foo ... @end foo.
7098
7099 % @tex ... @end tex    escapes into raw TeX temporarily.
7100 % One exception: @ is still an escape character, so that @end tex works.
7101 % But \@ or @@ will get a plain @ character.
7102
7103 \envdef\tex{%
7104   \setupmarkupstyle{tex}%
7105   \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
7106   \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
7107   \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
7108   \catcode `\%=14
7109   \catcode `\+=\other
7110   \catcode `\"=\other
7111   \catcode `\|=\other
7112   \catcode `\<=\other
7113   \catcode `\>=\other
7114   \catcode `\`=\other
7115   \catcode `\'=\other
7116   %
7117   % ' is active in math mode (mathcode"8000).  So reset it, and all our
7118   % other math active characters (just in case), to plain's definitions.
7119   \mathactive
7120   %
7121   % Inverse of the list at the beginning of the file.
7122   \let\b=\ptexb
7123   \let\bullet=\ptexbullet
7124   \let\c=\ptexc
7125   \let\,=\ptexcomma
7126   \let\.=\ptexdot
7127   \let\dots=\ptexdots
7128   \let\equiv=\ptexequiv
7129   \let\!=\ptexexclam
7130   \let\i=\ptexi
7131   \let\indent=\ptexindent
7132   \let\noindent=\ptexnoindent
7133   \let\{=\ptexlbrace
7134   \let\+=\tabalign
7135   \let\}=\ptexrbrace
7136   \let\/=\ptexslash
7137   \let\sp=\ptexsp
7138   \let\*=\ptexstar
7139   %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
7140   \let\t=\ptext
7141   \expandafter \let\csname top\endcsname=\ptextop  % we've made it outer
7142   \let\frenchspacing=\plainfrenchspacing
7143   %
7144   \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
7145   \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
7146   \def\@{@}%
7147 }
7148 % There is no need to define \Etex.
7149
7150 % Define @lisp ... @end lisp.
7151 % @lisp environment forms a group so it can rebind things,
7152 % including the definition of @end lisp (which normally is erroneous).
7153
7154 % Amount to narrow the margins by for @lisp.
7155 \newskip\lispnarrowing \lispnarrowing=0.4in
7156
7157 % This is the definition that ^^M gets inside @lisp, @example, and other
7158 % such environments.  \null is better than a space, since it doesn't
7159 % have any width.
7160 \def\lisppar{\null\endgraf}
7161
7162 % This space is always present above and below environments.
7163 \newskip\envskipamount \envskipamount = 0pt
7164
7165 % Make spacing and below environment symmetrical.  We use \parskip here
7166 % to help in doing that, since in @example-like environments \parskip
7167 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
7168 % start of the next paragraph will insert \parskip.
7169 %
7170 \def\aboveenvbreak{{%
7171   % =10000 instead of <10000 because of a special case in \itemzzz and
7172   % \sectionheading, q.v.
7173   \ifnum \lastpenalty=10000 \else
7174     \advance\envskipamount by \parskip
7175     \endgraf
7176     \ifdim\lastskip<\envskipamount
7177       \removelastskip
7178       \ifnum\lastpenalty<10000
7179         % Penalize breaking before the environment, because preceding text
7180         % often leads into it.
7181         \penalty100
7182       \fi
7183       \vskip\envskipamount
7184     \fi
7185   \fi
7186 }}
7187
7188 \def\afterenvbreak{{%
7189   % =10000 instead of <10000 because of a special case in \itemzzz and
7190   % \sectionheading, q.v.
7191   \ifnum \lastpenalty=10000 \else
7192     \advance\envskipamount by \parskip
7193     \endgraf
7194     \ifdim\lastskip<\envskipamount
7195       \removelastskip
7196       % it's not a good place to break if the last penalty was \nobreak
7197       % or better ...
7198       \ifnum\lastpenalty<10000 \penalty-50 \fi
7199       \vskip\envskipamount
7200     \fi
7201   \fi
7202 }}
7203
7204 % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins; it will
7205 % also clear it, so that its embedded environments do the narrowing again.
7206 \let\nonarrowing=\relax
7207
7208 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
7209 % environment contents.
7210 \font\circle=lcircle10
7211 \newdimen\circthick
7212 \newdimen\cartouter\newdimen\cartinner
7213 \newskip\normbskip\newskip\normpskip\newskip\normlskip
7214 \circthick=\fontdimen8\circle
7215 %
7216 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
7217 \def\ctr{{\hskip 6pt\circle\char'010}}
7218 \def\cbl{{\circle\char'012\hskip -6pt}}
7219 \def\cbr{{\hskip 6pt\circle\char'011}}
7220 \def\carttop{\hbox to \cartouter{\hskip\lskip
7221         \ctl\leaders\hrule height\circthick\hfil\ctr
7222         \hskip\rskip}}
7223 \def\cartbot{\hbox to \cartouter{\hskip\lskip
7224         \cbl\leaders\hrule height\circthick\hfil\cbr
7225         \hskip\rskip}}
7226 %
7227 \newskip\lskip\newskip\rskip
7228
7229 \envdef\cartouche{%
7230   \ifhmode\par\fi  % can't be in the midst of a paragraph.
7231   \startsavinginserts
7232   \lskip=\leftskip \rskip=\rightskip
7233   \leftskip=0pt\rightskip=0pt % we want these *outside*.
7234   \cartinner=\hsize \advance\cartinner by-\lskip
7235   \advance\cartinner by-\rskip
7236   \cartouter=\hsize
7237   \advance\cartouter by 18.4pt  % allow for 3pt kerns on either
7238                                 % side, and for 6pt waste from
7239                                 % each corner char, and rule thickness
7240   \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
7241   %
7242   % If this cartouche directly follows a sectioning command, we need the
7243   % \parskip glue (backspaced over by default) or the cartouche can
7244   % collide with the section heading.
7245   \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
7246   %
7247   \setbox\groupbox=\vbox\bgroup
7248       \baselineskip=0pt\parskip=0pt\lineskip=0pt
7249       \carttop
7250       \hbox\bgroup
7251           \hskip\lskip
7252           \vrule\kern3pt
7253           \vbox\bgroup
7254               \kern3pt
7255               \hsize=\cartinner
7256               \baselineskip=\normbskip
7257               \lineskip=\normlskip
7258               \parskip=\normpskip
7259               \vskip -\parskip
7260               \comment % For explanation, see the end of def\group.
7261 }
7262 \def\Ecartouche{%
7263               \ifhmode\par\fi
7264               \kern3pt
7265           \egroup
7266           \kern3pt\vrule
7267           \hskip\rskip
7268       \egroup
7269       \cartbot
7270   \egroup
7271   \addgroupbox
7272   \checkinserts
7273 }
7274
7275
7276 % This macro is called at the beginning of all the @example variants,
7277 % inside a group.
7278 \newdimen\nonfillparindent
7279 \def\nonfillstart{%
7280   \aboveenvbreak
7281   \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
7282   \sepspaces % Make spaces be word-separators rather than space tokens.
7283   \let\par = \lisppar % don't ignore blank lines
7284   \obeylines % each line of input is a line of output
7285   \parskip = 0pt
7286   % Turn off paragraph indentation but redefine \indent to emulate
7287   % the normal \indent.
7288   \nonfillparindent=\parindent
7289   \parindent = 0pt
7290   \let\indent\nonfillindent
7291   %
7292   \emergencystretch = 0pt % don't try to avoid overfull boxes
7293   \ifx\nonarrowing\relax
7294     \advance \leftskip by \lispnarrowing
7295     \exdentamount=\lispnarrowing
7296   \else
7297     \let\nonarrowing = \relax
7298   \fi
7299   \let\exdent=\nofillexdent
7300 }
7301
7302 \begingroup
7303 \obeyspaces
7304 % We want to swallow spaces (but not other tokens) after the fake
7305 % @indent in our nonfill-environments, where spaces are normally
7306 % active and set to @tie, resulting in them not being ignored after
7307 % @indent.
7308 \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
7309 \gdef\nonfillindentcheck{%
7310 \ifx\temp %
7311 \expandafter\nonfillindentgobble%
7312 \else%
7313 \leavevmode\nonfillindentbox%
7314 \fi%
7315 }%
7316 \endgroup
7317 \def\nonfillindentgobble#1{\nonfillindent}
7318 \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7319
7320 % If you want all examples etc. small: @set dispenvsize small.
7321 % If you want even small examples the full size: @set dispenvsize nosmall.
7322 % This affects the following displayed environments:
7323 %    @example, @display, @format, @lisp
7324 %
7325 \def\smallword{small}
7326 \def\nosmallword{nosmall}
7327 \let\SETdispenvsize\relax
7328 \def\setnormaldispenv{%
7329   \ifx\SETdispenvsize\smallword
7330     % end paragraph for sake of leading, in case document has no blank
7331     % line.  This is redundant with what happens in \aboveenvbreak, but
7332     % we need to do it before changing the fonts, and it's inconvenient
7333     % to change the fonts afterward.
7334     \ifnum \lastpenalty=10000 \else \endgraf \fi
7335     \smallexamplefonts \rm
7336   \fi
7337 }
7338 \def\setsmalldispenv{%
7339   \ifx\SETdispenvsize\nosmallword
7340   \else
7341     \ifnum \lastpenalty=10000 \else \endgraf \fi
7342     \smallexamplefonts \rm
7343   \fi
7344 }
7345
7346 % We often define two environments, @foo and @smallfoo.
7347 % Let's do it in one command.  #1 is the env name, #2 the definition.
7348 \def\makedispenvdef#1#2{%
7349   \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7350   \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
7351   \expandafter\let\csname E#1\endcsname \afterenvbreak
7352   \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
7353 }
7354
7355 % Define two environment synonyms (#1 and #2) for an environment.
7356 \def\maketwodispenvdef#1#2#3{%
7357   \makedispenvdef{#1}{#3}%
7358   \makedispenvdef{#2}{#3}%
7359 }
7360 %
7361 % @lisp: indented, narrowed, typewriter font;
7362 % @example: same as @lisp.
7363 %
7364 % @smallexample and @smalllisp: use smaller fonts.
7365 % Originally contributed by Pavel@xerox.
7366 %
7367 \maketwodispenvdef{lisp}{example}{%
7368   \nonfillstart
7369   \tt\setupmarkupstyle{example}%
7370   \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
7371   \gobble % eat return
7372 }
7373 % @display/@smalldisplay: same as @lisp except keep current font.
7374 %
7375 \makedispenvdef{display}{%
7376   \nonfillstart
7377   \gobble
7378 }
7379
7380 % @format/@smallformat: same as @display except don't narrow margins.
7381 %
7382 \makedispenvdef{format}{%
7383   \let\nonarrowing = t%
7384   \nonfillstart
7385   \gobble
7386 }
7387
7388 % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7389 \envdef\flushleft{%
7390   \let\nonarrowing = t%
7391   \nonfillstart
7392   \gobble
7393 }
7394 \let\Eflushleft = \afterenvbreak
7395
7396 % @flushright.
7397 %
7398 \envdef\flushright{%
7399   \let\nonarrowing = t%
7400   \nonfillstart
7401   \advance\leftskip by 0pt plus 1fill\relax
7402   \gobble
7403 }
7404 \let\Eflushright = \afterenvbreak
7405
7406
7407 % @raggedright does more-or-less normal line breaking but no right
7408 % justification.  From plain.tex.  Don't stretch around special
7409 % characters in urls in this environment, since the stretch at the right
7410 % should be enough.
7411 \envdef\raggedright{%
7412   \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7413   \def\urefprestretchamount{0pt}%
7414   \def\urefpoststretchamount{0pt}%
7415 }
7416 \let\Eraggedright\par
7417
7418 \envdef\raggedleft{%
7419   \parindent=0pt \leftskip0pt plus2em
7420   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7421   \hbadness=10000 % Last line will usually be underfull, so turn off
7422                   % badness reporting.
7423 }
7424 \let\Eraggedleft\par
7425
7426 \envdef\raggedcenter{%
7427   \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
7428   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7429   \hbadness=10000 % Last line will usually be underfull, so turn off
7430                   % badness reporting.
7431 }
7432 \let\Eraggedcenter\par
7433
7434
7435 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
7436 % and narrows the margins.  We keep \parskip nonzero in general, since
7437 % we're doing normal filling.  So, when using \aboveenvbreak and
7438 % \afterenvbreak, temporarily make \parskip 0.
7439 %
7440 \makedispenvdef{quotation}{\quotationstart}
7441 %
7442 \def\quotationstart{%
7443   \indentedblockstart % same as \indentedblock, but increase right margin too.
7444   \ifx\nonarrowing\relax
7445     \advance\rightskip by \lispnarrowing
7446   \fi
7447   \parsearg\quotationlabel
7448 }
7449
7450 % We have retained a nonzero parskip for the environment, since we're
7451 % doing normal filling.
7452 %
7453 \def\Equotation{%
7454   \par
7455   \ifx\quotationauthor\thisisundefined\else
7456     % indent a bit.
7457     \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7458   \fi
7459   {\parskip=0pt \afterenvbreak}%
7460 }
7461 \def\Esmallquotation{\Equotation}
7462
7463 % If we're given an argument, typeset it in bold with a colon after.
7464 \def\quotationlabel#1{%
7465   \def\temp{#1}%
7466   \ifx\temp\empty \else
7467     {\bf #1: }%
7468   \fi
7469 }
7470
7471 % @indentedblock is like @quotation, but indents only on the left and
7472 % has no optional argument.
7473
7474 \makedispenvdef{indentedblock}{\indentedblockstart}
7475 %
7476 \def\indentedblockstart{%
7477   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7478   \parindent=0pt
7479   %
7480   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7481   \ifx\nonarrowing\relax
7482     \advance\leftskip by \lispnarrowing
7483     \exdentamount = \lispnarrowing
7484   \else
7485     \let\nonarrowing = \relax
7486   \fi
7487 }
7488
7489 % Keep a nonzero parskip for the environment, since we're doing normal filling.
7490 %
7491 \def\Eindentedblock{%
7492   \par
7493   {\parskip=0pt \afterenvbreak}%
7494 }
7495 \def\Esmallindentedblock{\Eindentedblock}
7496
7497
7498 % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7499 % If we want to allow any <char> as delimiter,
7500 % we need the curly braces so that makeinfo sees the @verb command, eg:
7501 % `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
7502 %
7503 % [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
7504 %
7505 % [Knuth] p.344; only we need to do the other characters Texinfo sets
7506 % active too.  Otherwise, they get lost as the first character on a
7507 % verbatim line.
7508 \def\dospecials{%
7509   \do\ \do\\\do\{\do\}\do\$\do\&%
7510   \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7511   \do\<\do\>\do\|\do\@\do+\do\"%
7512   % Don't do the quotes -- if we do, @set txicodequoteundirected and
7513   % @set txicodequotebacktick will not have effect on @verb and
7514   % @verbatim, and ?` and !` ligatures won't get disabled.
7515   %\do\`\do\'%
7516 }
7517 %
7518 % [Knuth] p. 380
7519 \def\uncatcodespecials{%
7520   \def\do##1{\catcode`##1=\other}\dospecials}
7521 %
7522 % Setup for the @verb command.
7523 %
7524 % Eight spaces for a tab
7525 \begingroup
7526   \catcode`\^^I=\active
7527   \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7528 \endgroup
7529 %
7530 \def\setupverb{%
7531   \tt  % easiest (and conventionally used) font for verbatim
7532   \def\par{\leavevmode\endgraf}%
7533   \setupmarkupstyle{verb}%
7534   \tabeightspaces
7535   % Respect line breaks,
7536   % print special symbols as themselves, and
7537   % make each space count
7538   % must do in this order:
7539   \obeylines \uncatcodespecials \sepspaces
7540 }
7541
7542 % Setup for the @verbatim environment
7543 %
7544 % Real tab expansion.
7545 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7546 %
7547 % We typeset each line of the verbatim in an \hbox, so we can handle
7548 % tabs.  The \global is in case the verbatim line starts with an accent,
7549 % or some other command that starts with a begin-group.  Otherwise, the
7550 % entire \verbbox would disappear at the corresponding end-group, before
7551 % it is typeset.  Meanwhile, we can't have nested verbatim commands
7552 % (can we?), so the \global won't be overwriting itself.
7553 \newbox\verbbox
7554 \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
7555 %
7556 \begingroup
7557   \catcode`\^^I=\active
7558   \gdef\tabexpand{%
7559     \catcode`\^^I=\active
7560     \def^^I{\leavevmode\egroup
7561       \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7562       \divide\dimen\verbbox by\tabw
7563       \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7564       \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
7565       \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
7566     }%
7567   }
7568 \endgroup
7569
7570 % start the verbatim environment.
7571 \def\setupverbatim{%
7572   \let\nonarrowing = t%
7573   \nonfillstart
7574   \tt % easiest (and conventionally used) font for verbatim
7575   % The \leavevmode here is for blank lines.  Otherwise, we would
7576   % never \starttabox and the \egroup would end verbatim mode.
7577   \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
7578   \tabexpand
7579   \setupmarkupstyle{verbatim}%
7580   % Respect line breaks,
7581   % print special symbols as themselves, and
7582   % make each space count.
7583   % Must do in this order:
7584   \obeylines \uncatcodespecials \sepspaces
7585   \everypar{\starttabbox}%
7586 }
7587
7588 % Do the @verb magic: verbatim text is quoted by unique
7589 % delimiter characters.  Before first delimiter expect a
7590 % right brace, after last delimiter expect closing brace:
7591 %
7592 %    \def\doverb'{'<char>#1<char>'}'{#1}
7593 %
7594 % [Knuth] p. 382; only eat outer {}
7595 \begingroup
7596   \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
7597   \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7598 \endgroup
7599 %
7600 \def\verb{\begingroup\setupverb\doverb}
7601 %
7602 %
7603 % Do the @verbatim magic: define the macro \doverbatim so that
7604 % the (first) argument ends when '@end verbatim' is reached, ie:
7605 %
7606 %     \def\doverbatim#1@end verbatim{#1}
7607 %
7608 % For Texinfo it's a lot easier than for LaTeX,
7609 % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
7610 % we need not redefine '\', '{' and '}'.
7611 %
7612 % Inspired by LaTeX's verbatim command set [latex.ltx]
7613 %
7614 \begingroup
7615   \catcode`\ =\active
7616   \obeylines %
7617   % ignore everything up to the first ^^M, that's the newline at the end
7618   % of the @verbatim input line itself.  Otherwise we get an extra blank
7619   % line in the output.
7620   \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
7621   % We really want {...\end verbatim} in the body of the macro, but
7622   % without the active space; thus we have to use \xdef and \gobble.
7623 \endgroup
7624 %
7625 \envdef\verbatim{%
7626     \setupverbatim\doverbatim
7627 }
7628 \let\Everbatim = \afterenvbreak
7629
7630
7631 % @verbatiminclude FILE - insert text of file in verbatim environment.
7632 %
7633 \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
7634 %
7635 \def\doverbatiminclude#1{%
7636   {%
7637     \makevalueexpandable
7638     \setupverbatim
7639     \indexnofonts       % Allow `@@' and other weird things in file names.
7640     \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
7641     \input #1
7642     \afterenvbreak
7643   }%
7644 }
7645
7646 % @copying ... @end copying.
7647 % Save the text away for @insertcopying later.
7648 %
7649 % We save the uninterpreted tokens, rather than creating a box.
7650 % Saving the text in a box would be much easier, but then all the
7651 % typesetting commands (@smallbook, font changes, etc.) have to be done
7652 % beforehand -- and a) we want @copying to be done first in the source
7653 % file; b) letting users define the frontmatter in as flexible order as
7654 % possible is desirable.
7655 %
7656 \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
7657 \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
7658 %
7659 \def\insertcopying{%
7660   \begingroup
7661     \parindent = 0pt  % paragraph indentation looks wrong on title page
7662     \scanexp\copyingtext
7663   \endgroup
7664 }
7665
7666
7667 \message{defuns,}
7668 % @defun etc.
7669
7670 \newskip\defbodyindent \defbodyindent=.4in
7671 \newskip\defargsindent \defargsindent=50pt
7672 \newskip\deflastargmargin \deflastargmargin=18pt
7673 \newcount\defunpenalty
7674
7675 % Start the processing of @deffn:
7676 \def\startdefun{%
7677   \ifnum\lastpenalty<10000
7678     \medbreak
7679     \defunpenalty=10003 % Will keep this @deffn together with the
7680                         % following @def command, see below.
7681   \else
7682     % If there are two @def commands in a row, we'll have a \nobreak,
7683     % which is there to keep the function description together with its
7684     % header.  But if there's nothing but headers, we need to allow a
7685     % break somewhere.  Check specifically for penalty 10002, inserted
7686     % by \printdefunline, instead of 10000, since the sectioning
7687     % commands also insert a nobreak penalty, and we don't want to allow
7688     % a break between a section heading and a defun.
7689     %
7690     % As a further refinement, we avoid "club" headers by signalling
7691     % with penalty of 10003 after the very first @deffn in the
7692     % sequence (see above), and penalty of 10002 after any following
7693     % @def command.
7694     \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
7695     %
7696     % Similarly, after a section heading, do not allow a break.
7697     % But do insert the glue.
7698     \medskip  % preceded by discardable penalty, so not a breakpoint
7699   \fi
7700   %
7701   \parindent=0in
7702   \advance\leftskip by \defbodyindent
7703   \exdentamount=\defbodyindent
7704 }
7705
7706 \def\dodefunx#1{%
7707   % First, check whether we are in the right environment:
7708   \checkenv#1%
7709   %
7710   % As above, allow line break if we have multiple x headers in a row.
7711   % It's not a great place, though.
7712   \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
7713   %
7714   % And now, it's time to reuse the body of the original defun:
7715   \expandafter\gobbledefun#1%
7716 }
7717 \def\gobbledefun#1\startdefun{}
7718
7719 % \printdefunline \deffnheader{text}
7720 %
7721 \def\printdefunline#1#2{%
7722   \begingroup
7723     % call \deffnheader:
7724     #1#2 \endheader
7725     % common ending:
7726     \interlinepenalty = 10000
7727     \advance\rightskip by 0pt plus 1fil\relax
7728     \endgraf
7729     \nobreak\vskip -\parskip
7730     \penalty\defunpenalty  % signal to \startdefun and \dodefunx
7731     % Some of the @defun-type tags do not enable magic parentheses,
7732     % rendering the following check redundant.  But we don't optimize.
7733     \checkparencounts
7734   \endgroup
7735 }
7736
7737 \def\Edefun{\endgraf\medbreak}
7738
7739 % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
7740 % the only thing remaining is to define \deffnheader.
7741 %
7742 \def\makedefun#1{%
7743   \expandafter\let\csname E#1\endcsname = \Edefun
7744   \edef\temp{\noexpand\domakedefun
7745     \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7746   \temp
7747 }
7748
7749 % \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
7750 %
7751 % Define \deffn and \deffnx, without parameters.
7752 % \deffnheader has to be defined explicitly.
7753 %
7754 \def\domakedefun#1#2#3{%
7755   \envdef#1{%
7756     \startdefun
7757     \doingtypefnfalse    % distinguish typed functions from all else
7758     \parseargusing\activeparens{\printdefunline#3}%
7759   }%
7760   \def#2{\dodefunx#1}%
7761   \def#3%
7762 }
7763
7764 \newif\ifdoingtypefn       % doing typed function?
7765 \newif\ifrettypeownline    % typeset return type on its own line?
7766
7767 % @deftypefnnewline on|off says whether the return type of typed functions
7768 % are printed on their own line.  This affects @deftypefn, @deftypefun,
7769 % @deftypeop, and @deftypemethod.
7770
7771 \parseargdef\deftypefnnewline{%
7772   \def\temp{#1}%
7773   \ifx\temp\onword
7774     \expandafter\let\csname SETtxideftypefnnl\endcsname
7775       = \empty
7776   \else\ifx\temp\offword
7777     \expandafter\let\csname SETtxideftypefnnl\endcsname
7778       = \relax
7779   \else
7780     \errhelp = \EMsimple
7781     \errmessage{Unknown @txideftypefnnl value `\temp',
7782                 must be on|off}%
7783   \fi\fi
7784 }
7785
7786 % Untyped functions:
7787
7788 % @deffn category name args
7789 \makedefun{deffn}{\deffngeneral{}}
7790
7791 % @deffn category class name args
7792 \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
7793
7794 % \defopon {category on}class name args
7795 \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7796
7797 % \deffngeneral {subind}category name args
7798 %
7799 \def\deffngeneral#1#2 #3 #4\endheader{%
7800   % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
7801   \dosubind{fn}{\code{#3}}{#1}%
7802   \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
7803 }
7804
7805 % Typed functions:
7806
7807 % @deftypefn category type name args
7808 \makedefun{deftypefn}{\deftypefngeneral{}}
7809
7810 % @deftypeop category class type name args
7811 \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
7812
7813 % \deftypeopon {category on}class type name args
7814 \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7815
7816 % \deftypefngeneral {subind}category type name args
7817 %
7818 \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
7819   \dosubind{fn}{\code{#4}}{#1}%
7820   \doingtypefntrue
7821   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7822 }
7823
7824 % Typed variables:
7825
7826 % @deftypevr category type var args
7827 \makedefun{deftypevr}{\deftypecvgeneral{}}
7828
7829 % @deftypecv category class type var args
7830 \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
7831
7832 % \deftypecvof {category of}class type var args
7833 \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
7834
7835 % \deftypecvgeneral {subind}category type var args
7836 %
7837 \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
7838   \dosubind{vr}{\code{#4}}{#1}%
7839   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7840 }
7841
7842 % Untyped variables:
7843
7844 % @defvr category var args
7845 \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
7846
7847 % @defcv category class var args
7848 \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
7849
7850 % \defcvof {category of}class var args
7851 \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
7852
7853 % Types:
7854
7855 % @deftp category name args
7856 \makedefun{deftp}#1 #2 #3\endheader{%
7857   \doind{tp}{\code{#2}}%
7858   \defname{#1}{}{#2}\defunargs{#3\unskip}%
7859 }
7860
7861 % Remaining @defun-like shortcuts:
7862 \makedefun{defun}{\deffnheader{\putwordDeffunc} }
7863 \makedefun{defmac}{\deffnheader{\putwordDefmac} }
7864 \makedefun{defspec}{\deffnheader{\putwordDefspec} }
7865 \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7866 \makedefun{defvar}{\defvrheader{\putwordDefvar} }
7867 \makedefun{defopt}{\defvrheader{\putwordDefopt} }
7868 \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
7869 \makedefun{defmethod}{\defopon\putwordMethodon}
7870 \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
7871 \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
7872 \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
7873
7874 % \defname, which formats the name of the @def (not the args).
7875 % #1 is the category, such as "Function".
7876 % #2 is the return type, if any.
7877 % #3 is the function name.
7878 %
7879 % We are followed by (but not passed) the arguments, if any.
7880 %
7881 \def\defname#1#2#3{%
7882   \par
7883   % Get the values of \leftskip and \rightskip as they were outside the @def...
7884   \advance\leftskip by -\defbodyindent
7885   %
7886   % Determine if we are typesetting the return type of a typed function
7887   % on a line by itself.
7888   \rettypeownlinefalse
7889   \ifdoingtypefn  % doing a typed function specifically?
7890     % then check user option for putting return type on its own line:
7891     \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
7892       \rettypeownlinetrue
7893     \fi
7894   \fi
7895   %
7896   % How we'll format the category name.  Putting it in brackets helps
7897   % distinguish it from the body text that may end up on the next line
7898   % just below it.
7899   \def\temp{#1}%
7900   \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7901   %
7902   % Figure out line sizes for the paragraph shape.  We'll always have at
7903   % least two.
7904   \tempnum = 2
7905   %
7906   % The first line needs space for \box0; but if \rightskip is nonzero,
7907   % we need only space for the part of \box0 which exceeds it:
7908   \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
7909   %
7910   % If doing a return type on its own line, we'll have another line.
7911   \ifrettypeownline
7912     \advance\tempnum by 1
7913     \def\maybeshapeline{0in \hsize}%
7914   \else
7915     \def\maybeshapeline{}%
7916   \fi
7917   %
7918   % The continuations:
7919   \dimen2=\hsize  \advance\dimen2 by -\defargsindent
7920   %
7921   % The final paragraph shape:
7922   \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
7923   %
7924   % Put the category name at the right margin.
7925   \noindent
7926   \hbox to 0pt{%
7927     \hfil\box0 \kern-\hsize
7928     % \hsize has to be shortened this way:
7929     \kern\leftskip
7930     % Intentionally do not respect \rightskip, since we need the space.
7931   }%
7932   %
7933   % Allow all lines to be underfull without complaint:
7934   \tolerance=10000 \hbadness=10000
7935   \exdentamount=\defbodyindent
7936   {%
7937     % defun fonts. We use typewriter by default (used to be bold) because:
7938     % . we're printing identifiers, they should be in tt in principle.
7939     % . in languages with many accents, such as Czech or French, it's
7940     %   common to leave accents off identifiers.  The result looks ok in
7941     %   tt, but exceedingly strange in rm.
7942     % . we don't want -- and --- to be treated as ligatures.
7943     % . this still does not fix the ?` and !` ligatures, but so far no
7944     %   one has made identifiers using them :).
7945     \df \tt
7946     \def\temp{#2}% text of the return type
7947     \ifx\temp\empty\else
7948       \tclose{\temp}% typeset the return type
7949       \ifrettypeownline
7950         % put return type on its own line; prohibit line break following:
7951         \hfil\vadjust{\nobreak}\break  
7952       \else
7953         \space  % type on same line, so just followed by a space
7954       \fi
7955     \fi           % no return type
7956     #3% output function name
7957   }%
7958   {\rm\enskip}% hskip 0.5 em of \rmfont
7959   %
7960   \boldbrax
7961   % arguments will be output next, if any.
7962 }
7963
7964 % Print arguments in slanted roman (not ttsl), inconsistently with using
7965 % tt for the name.  This is because literal text is sometimes needed in
7966 % the argument list (groff manual), and ttsl and tt are not very
7967 % distinguishable.  Prevent hyphenation at `-' chars.
7968 %
7969 \def\defunargs#1{%
7970   % use sl by default (not ttsl),
7971   % tt for the names.
7972   \df \sl \hyphenchar\font=0
7973   %
7974   % On the other hand, if an argument has two dashes (for instance), we
7975   % want a way to get ttsl.  We used to recommend @var for that, so
7976   % leave the code in, but it's strange for @var to lead to typewriter.
7977   % Nowadays we recommend @code, since the difference between a ttsl hyphen
7978   % and a tt hyphen is pretty tiny.  @code also disables ?` !`.
7979   \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
7980   #1%
7981   \sl\hyphenchar\font=45
7982 }
7983
7984 % We want ()&[] to print specially on the defun line.
7985 %
7986 \def\activeparens{%
7987   \catcode`\(=\active \catcode`\)=\active
7988   \catcode`\[=\active \catcode`\]=\active
7989   \catcode`\&=\active
7990 }
7991
7992 % Make control sequences which act like normal parenthesis chars.
7993 \let\lparen = ( \let\rparen = )
7994
7995 % Be sure that we always have a definition for `(', etc.  For example,
7996 % if the fn name has parens in it, \boldbrax will not be in effect yet,
7997 % so TeX would otherwise complain about undefined control sequence.
7998 {
7999   \activeparens
8000   \global\let(=\lparen \global\let)=\rparen
8001   \global\let[=\lbrack \global\let]=\rbrack
8002   \global\let& = \&
8003
8004   \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
8005   \gdef\magicamp{\let&=\amprm}
8006 }
8007 \let\ampchar\&
8008
8009 \newcount\parencount
8010
8011 % If we encounter &foo, then turn on ()-hacking afterwards
8012 \newif\ifampseen
8013 \def\amprm#1 {\ampseentrue{\bf\&#1 }}
8014
8015 \def\parenfont{%
8016   \ifampseen
8017     % At the first level, print parens in roman,
8018     % otherwise use the default font.
8019     \ifnum \parencount=1 \rm \fi
8020   \else
8021     % The \sf parens (in \boldbrax) actually are a little bolder than
8022     % the contained text.  This is especially needed for [ and ] .
8023     \sf
8024   \fi
8025 }
8026 \def\infirstlevel#1{%
8027   \ifampseen
8028     \ifnum\parencount=1
8029       #1%
8030     \fi
8031   \fi
8032 }
8033 \def\bfafterword#1 {#1 \bf}
8034
8035 \def\opnr{%
8036   \global\advance\parencount by 1
8037   {\parenfont(}%
8038   \infirstlevel \bfafterword
8039 }
8040 \def\clnr{%
8041   {\parenfont)}%
8042   \infirstlevel \sl
8043   \global\advance\parencount by -1
8044 }
8045
8046 \newcount\brackcount
8047 \def\lbrb{%
8048   \global\advance\brackcount by 1
8049   {\bf[}%
8050 }
8051 \def\rbrb{%
8052   {\bf]}%
8053   \global\advance\brackcount by -1
8054 }
8055
8056 \def\checkparencounts{%
8057   \ifnum\parencount=0 \else \badparencount \fi
8058   \ifnum\brackcount=0 \else \badbrackcount \fi
8059 }
8060 % these should not use \errmessage; the glibc manual, at least, actually
8061 % has such constructs (when documenting function pointers).
8062 \def\badparencount{%
8063   \message{Warning: unbalanced parentheses in @def...}%
8064   \global\parencount=0
8065 }
8066 \def\badbrackcount{%
8067   \message{Warning: unbalanced square brackets in @def...}%
8068   \global\brackcount=0
8069 }
8070
8071
8072 \message{macros,}
8073 % @macro.
8074
8075 % To do this right we need a feature of e-TeX, \scantokens,
8076 % which we arrange to emulate with a temporary file in ordinary TeX.
8077 \ifx\eTeXversion\thisisundefined
8078   \newwrite\macscribble
8079   \def\scantokens#1{%
8080     \toks0={#1}%
8081     \immediate\openout\macscribble=\jobname.tmp
8082     \immediate\write\macscribble{\the\toks0}%
8083     \immediate\closeout\macscribble
8084     \input \jobname.tmp
8085   }
8086 \fi
8087
8088 % alias because \c means cedilla in @tex or @math
8089 \let\texinfoc=\c
8090
8091 \newcount\savedcatcodeone
8092 \newcount\savedcatcodetwo
8093
8094 % Used at the time of macro expansion.
8095 % Argument is macro body with arguments substituted
8096 \def\scanmacro#1{%
8097   \newlinechar`\^^M
8098   \def\xeatspaces{\eatspaces}%
8099   %
8100   % Temporarily undo catcode changes of \printindex.  Set catcode of @ to
8101   % 0 so that @-commands in macro expansions aren't printed literally when 
8102   % formatting an index file, where \ is used as the escape character.
8103   \savedcatcodeone=\catcode`\@
8104   \savedcatcodetwo=\catcode`\\
8105   \catcode`\@=0
8106   \catcode`\\=\active
8107   %
8108   % Process the macro body under the current catcode regime.
8109   \scantokens{#1@texinfoc}%
8110   %
8111   \catcode`\@=\savedcatcodeone
8112   \catcode`\\=\savedcatcodetwo
8113   %
8114   % The \texinfoc is to remove the \newlinechar added by \scantokens, and
8115   % can be noticed by \parsearg.
8116   %   We avoid surrounding the call to \scantokens with \bgroup and \egroup
8117   % to allow macros to open or close groups themselves.
8118 }
8119
8120 % Used for copying and captions
8121 \def\scanexp#1{%
8122   \expandafter\scanmacro\expandafter{#1}%
8123 }
8124
8125 \newcount\paramno   % Count of parameters
8126 \newtoks\macname    % Macro name
8127 \newif\ifrecursive  % Is it recursive?
8128
8129 % List of all defined macros in the form
8130 %    \commondummyword\macro1\commondummyword\macro2...
8131 % Currently is also contains all @aliases; the list can be split
8132 % if there is a need.
8133 \def\macrolist{}
8134
8135 % Add the macro to \macrolist
8136 \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
8137 \def\addtomacrolistxxx#1{%
8138      \toks0 = \expandafter{\macrolist\commondummyword#1}%
8139      \xdef\macrolist{\the\toks0}%
8140 }
8141
8142 % Utility routines.
8143 % This does \let #1 = #2, with \csnames; that is,
8144 %   \let \csname#1\endcsname = \csname#2\endcsname
8145 % (except of course we have to play expansion games).
8146 %
8147 \def\cslet#1#2{%
8148   \expandafter\let
8149   \csname#1\expandafter\endcsname
8150   \csname#2\endcsname
8151 }
8152
8153 % Trim leading and trailing spaces off a string.
8154 % Concepts from aro-bend problem 15 (see CTAN).
8155 {\catcode`\@=11
8156 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
8157 \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
8158 \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
8159 \def\unbrace#1{#1}
8160 \unbrace{\gdef\trim@@@ #1 } #2@{#1}
8161 }
8162
8163 % Trim a single trailing ^^M off a string.
8164 {\catcode`\^^M=\other \catcode`\Q=3%
8165 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
8166 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
8167 \gdef\eatcrb#1Q#2Q{#1}%
8168 }
8169
8170 % Macro bodies are absorbed as an argument in a context where
8171 % all characters are catcode 10, 11 or 12, except \ which is active
8172 % (as in normal texinfo). It is necessary to change the definition of \
8173 % to recognize macro arguments; this is the job of \mbodybackslash.
8174 %
8175 % Non-ASCII encodings make 8-bit characters active, so un-activate
8176 % them to avoid their expansion.  Must do this non-globally, to
8177 % confine the change to the current group.
8178 %
8179 % It's necessary to have hard CRs when the macro is executed. This is
8180 % done by making ^^M (\endlinechar) catcode 12 when reading the macro
8181 % body, and then making it the \newlinechar in \scanmacro.
8182 %
8183 \def\scanctxt{% used as subroutine
8184   \catcode`\"=\other
8185   \catcode`\+=\other
8186   \catcode`\<=\other
8187   \catcode`\>=\other
8188   \catcode`\^=\other
8189   \catcode`\_=\other
8190   \catcode`\|=\other
8191   \catcode`\~=\other
8192   \passthroughcharstrue
8193 }
8194
8195 \def\scanargctxt{% used for copying and captions, not macros.
8196   \scanctxt
8197   \catcode`\@=\other
8198   \catcode`\\=\other
8199   \catcode`\^^M=\other
8200 }
8201
8202 \def\macrobodyctxt{% used for @macro definitions
8203   \scanctxt
8204   \catcode`\ =\other
8205   \catcode`\@=\other
8206   \catcode`\{=\other
8207   \catcode`\}=\other
8208   \catcode`\^^M=\other
8209   \usembodybackslash
8210 }
8211
8212 % Used when scanning braced macro arguments.  Note, however, that catcode
8213 % changes here are ineffectual if the macro invocation was nested inside
8214 % an argument to another Texinfo command.
8215 \def\macroargctxt{%
8216   \scanctxt
8217   \catcode`\ =\active
8218   \catcode`\^^M=\other
8219   \catcode`\\=\active
8220 }
8221
8222 \def\macrolineargctxt{% used for whole-line arguments without braces
8223   \scanctxt
8224   \catcode`\{=\other
8225   \catcode`\}=\other
8226 }
8227
8228 % \mbodybackslash is the definition of \ in @macro bodies.
8229 % It maps \foo\ => \csname macarg.foo\endcsname => #N
8230 % where N is the macro parameter number.
8231 % We define \csname macarg.\endcsname to be \realbackslash, so
8232 % \\ in macro replacement text gets you a backslash.
8233 %
8234 {\catcode`@=0 @catcode`@\=@active
8235  @gdef@usembodybackslash{@let\=@mbodybackslash}
8236  @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
8237 }
8238 \expandafter\def\csname macarg.\endcsname{\realbackslash}
8239
8240 \def\margbackslash#1{\char`\#1 }
8241
8242 \def\macro{\recursivefalse\parsearg\macroxxx}
8243 \def\rmacro{\recursivetrue\parsearg\macroxxx}
8244
8245 \def\macroxxx#1{%
8246   \getargs{#1}% now \macname is the macname and \argl the arglist
8247   \ifx\argl\empty       % no arguments
8248      \paramno=0\relax
8249   \else
8250      \expandafter\parsemargdef \argl;%
8251      \if\paramno>256\relax
8252        \ifx\eTeXversion\thisisundefined
8253          \errhelp = \EMsimple
8254          \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
8255        \fi
8256      \fi
8257   \fi
8258   \if1\csname ismacro.\the\macname\endcsname
8259      \message{Warning: redefining \the\macname}%
8260   \else
8261      \expandafter\ifx\csname \the\macname\endcsname \relax
8262      \else \errmessage{Macro name \the\macname\space already defined}\fi
8263      \global\cslet{macsave.\the\macname}{\the\macname}%
8264      \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
8265      \addtomacrolist{\the\macname}%
8266   \fi
8267   \begingroup \macrobodyctxt
8268   \ifrecursive \expandafter\parsermacbody
8269   \else \expandafter\parsemacbody
8270   \fi}
8271
8272 \parseargdef\unmacro{%
8273   \if1\csname ismacro.#1\endcsname
8274     \global\cslet{#1}{macsave.#1}%
8275     \global\expandafter\let \csname ismacro.#1\endcsname=0%
8276     % Remove the macro name from \macrolist:
8277     \begingroup
8278       \expandafter\let\csname#1\endcsname \relax
8279       \let\commondummyword\unmacrodo
8280       \xdef\macrolist{\macrolist}%
8281     \endgroup
8282   \else
8283     \errmessage{Macro #1 not defined}%
8284   \fi
8285 }
8286
8287 % Called by \do from \dounmacro on each macro.  The idea is to omit any
8288 % macro definitions that have been changed to \relax.
8289 %
8290 \def\unmacrodo#1{%
8291   \ifx #1\relax
8292     % remove this
8293   \else
8294     \noexpand\commondummyword \noexpand#1%
8295   \fi
8296 }
8297
8298 % \getargs -- Parse the arguments to a @macro line.  Set \macname to
8299 % the name of the macro, and \argl to the braced argument list.
8300 \def\getargs#1{\getargsxxx#1{}}
8301 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
8302 \def\getmacname#1 #2\relax{\macname={#1}}
8303 \def\getmacargs#1{\def\argl{#1}}
8304 % This made use of the feature that if the last token of a
8305 % <parameter list> is #, then the preceding argument is delimited by
8306 % an opening brace, and that opening brace is not consumed.
8307
8308 % Parse the optional {params} list to @macro or @rmacro.
8309 % Set \paramno to the number of arguments,
8310 % and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
8311 % three-param macro.)  Define \macarg.BLAH for each BLAH in the params
8312 % list to some hook where the argument is to be expanded.  If there are
8313 % less than 10 arguments that hook is to be replaced by ##N where N
8314 % is the position in that list, that is to say the macro arguments are to be
8315 % defined `a la TeX in the macro body.  
8316 %
8317 % That gets used by \mbodybackslash (above).
8318 %
8319 % If there are 10 or more arguments, a different technique is used: see
8320 % \parsemmanyargdef.
8321 %
8322 \def\parsemargdef#1;{%
8323   \paramno=0\def\paramlist{}%
8324   \let\hash\relax
8325   % \hash is redefined to `#' later to get it into definitions
8326   \let\xeatspaces\relax
8327   \parsemargdefxxx#1,;,%
8328   \ifnum\paramno<10\relax\else
8329     \paramno0\relax
8330     \parsemmanyargdef@@#1,;,% 10 or more arguments
8331   \fi
8332 }
8333 \def\parsemargdefxxx#1,{%
8334   \if#1;\let\next=\relax
8335   \else \let\next=\parsemargdefxxx
8336     \advance\paramno by 1
8337     \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
8338         {\xeatspaces{\hash\the\paramno}}%
8339     \edef\paramlist{\paramlist\hash\the\paramno,}%
8340   \fi\next}
8341
8342 % \parsemacbody, \parsermacbody
8343 %
8344 % Read recursive and nonrecursive macro bodies. (They're different since
8345 % rec and nonrec macros end differently.)
8346
8347 % We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro 
8348 % body to be transformed.
8349 % Set \macrobody to the body of the macro, and call \defmacro.
8350 %
8351 {\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{%
8352 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8353 {\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
8354 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8355
8356 % Make @ a letter, so that we can make private-to-Texinfo macro names.
8357 \edef\texiatcatcode{\the\catcode`\@}
8358 \catcode `@=11\relax
8359
8360 %%%%%%%%%%%%%% Code for > 10 arguments only   %%%%%%%%%%%%%%%%%%
8361
8362 % If there are 10 or more arguments, a different technique is used, where the
8363 % hook remains in the body, and when macro is to be expanded the body is
8364 % processed again to replace the arguments.
8365 %
8366 % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
8367 % argument N value and then \edef the body (nothing else will expand because of
8368 % the catcode regime under which the body was input).
8369 %
8370 % If you compile with TeX (not eTeX), and you have macros with 10 or more
8371 % arguments, no macro can have more than 256 arguments (else error).
8372 %
8373 % In case that there are 10 or more arguments we parse again the arguments
8374 % list to set new definitions for the \macarg.BLAH macros corresponding to
8375 % each BLAH argument. It was anyhow needed to parse already once this list
8376 % in order to count the arguments, and as macros with at most 9 arguments
8377 % are by far more frequent than macro with 10 or more arguments, defining
8378 % twice the \macarg.BLAH macros does not cost too much processing power.
8379 \def\parsemmanyargdef@@#1,{%
8380   \if#1;\let\next=\relax
8381   \else 
8382     \let\next=\parsemmanyargdef@@
8383     \edef\tempb{\eatspaces{#1}}%
8384     \expandafter\def\expandafter\tempa
8385        \expandafter{\csname macarg.\tempb\endcsname}%
8386     % Note that we need some extra \noexpand\noexpand, this is because we
8387     % don't want \the  to be expanded in the \parsermacbody  as it uses an
8388     % \xdef .
8389     \expandafter\edef\tempa
8390       {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
8391     \advance\paramno by 1\relax
8392   \fi\next}
8393
8394
8395 \let\endargs@\relax
8396 \let\nil@\relax
8397 \def\nilm@{\nil@}%
8398 \long\def\nillm@{\nil@}%
8399
8400 % This macro is expanded during the Texinfo macro expansion, not during its
8401 % definition.  It gets all the arguments' values and assigns them to macros
8402 % macarg.ARGNAME
8403 %
8404 % #1 is the macro name
8405 % #2 is the list of argument names
8406 % #3 is the list of argument values
8407 \def\getargvals@#1#2#3{%
8408   \def\macargdeflist@{}%
8409   \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
8410   \def\paramlist{#2,\nil@}%
8411   \def\macroname{#1}%
8412   \begingroup
8413   \macroargctxt
8414   \def\argvaluelist{#3,\nil@}%
8415   \def\@tempa{#3}%
8416   \ifx\@tempa\empty
8417     \setemptyargvalues@
8418   \else
8419     \getargvals@@
8420   \fi
8421 }
8422 \def\getargvals@@{%
8423   \ifx\paramlist\nilm@
8424       % Some sanity check needed here that \argvaluelist is also empty.
8425       \ifx\argvaluelist\nillm@
8426       \else
8427         \errhelp = \EMsimple
8428         \errmessage{Too many arguments in macro `\macroname'!}%
8429       \fi
8430       \let\next\macargexpandinbody@
8431   \else
8432     \ifx\argvaluelist\nillm@
8433        % No more arguments values passed to macro.  Set remaining named-arg
8434        % macros to empty.
8435        \let\next\setemptyargvalues@
8436     \else
8437       % pop current arg name into \@tempb
8438       \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
8439       \expandafter\@tempa\expandafter{\paramlist}%
8440        % pop current argument value into \@tempc
8441       \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
8442       \expandafter\@tempa\expandafter{\argvaluelist}%
8443        % Here \@tempb is the current arg name and \@tempc is the current arg value.
8444        % First place the new argument macro definition into \@tempd
8445        \expandafter\macname\expandafter{\@tempc}%
8446        \expandafter\let\csname macarg.\@tempb\endcsname\relax
8447        \expandafter\def\expandafter\@tempe\expandafter{%
8448          \csname macarg.\@tempb\endcsname}%
8449        \edef\@tempd{\long\def\@tempe{\the\macname}}%
8450        \push@\@tempd\macargdeflist@
8451        \let\next\getargvals@@
8452     \fi
8453   \fi
8454   \next
8455 }
8456
8457 \def\push@#1#2{%
8458   \expandafter\expandafter\expandafter\def
8459   \expandafter\expandafter\expandafter#2%
8460   \expandafter\expandafter\expandafter{%
8461   \expandafter#1#2}%
8462 }
8463
8464 % Replace arguments by their values in the macro body, and place the result
8465 % in macro \@tempa.
8466
8467 \def\macvalstoargs@{%
8468   %  To do this we use the property that token registers that are \the'ed
8469   % within an \edef  expand only once. So we are going to place all argument
8470   % values into respective token registers.
8471   %
8472   % First we save the token context, and initialize argument numbering.
8473   \begingroup
8474     \paramno0\relax
8475     % Then, for each argument number #N, we place the corresponding argument
8476     % value into a new token list register \toks#N
8477     \expandafter\putargsintokens@\saveparamlist@,;,%
8478     % Then, we expand the body so that argument are replaced by their
8479     % values. The trick for values not to be expanded themselves is that they
8480     % are within tokens and that tokens expand only once in an \edef .
8481     \edef\@tempc{\csname mac.\macroname .body\endcsname}%
8482     % Now we restore the token stack pointer to free the token list registers
8483     % which we have used, but we make sure that expanded body is saved after
8484     % group.
8485     \expandafter
8486   \endgroup
8487   \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
8488   }
8489
8490 % Define the named-macro outside of this group and then close this group. 
8491
8492 \def\macargexpandinbody@{% 
8493   \expandafter
8494   \endgroup
8495   \macargdeflist@
8496   % First the replace in body the macro arguments by their values, the result
8497   % is in \@tempa .
8498   \macvalstoargs@
8499   % Then we point at the \norecurse or \gobble (for recursive) macro value
8500   % with \@tempb .
8501   \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
8502   % Depending on whether it is recursive or not, we need some tailing
8503   % \egroup .
8504   \ifx\@tempb\gobble
8505      \let\@tempc\relax
8506   \else
8507      \let\@tempc\egroup
8508   \fi
8509   % And now we do the real job:
8510   \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
8511   \@tempd
8512 }
8513
8514 \def\putargsintokens@#1,{%
8515   \if#1;\let\next\relax
8516   \else
8517     \let\next\putargsintokens@
8518     % First we allocate the new token list register, and give it a temporary
8519     % alias \@tempb .
8520     \toksdef\@tempb\the\paramno
8521     % Then we place the argument value into that token list register.
8522     \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
8523     \expandafter\@tempb\expandafter{\@tempa}%
8524     \advance\paramno by 1\relax
8525   \fi
8526   \next
8527 }
8528
8529 % Trailing missing arguments are set to empty.
8530
8531 \def\setemptyargvalues@{%
8532   \ifx\paramlist\nilm@
8533     \let\next\macargexpandinbody@
8534   \else
8535     \expandafter\setemptyargvaluesparser@\paramlist\endargs@
8536     \let\next\setemptyargvalues@
8537   \fi
8538   \next
8539 }
8540
8541 \def\setemptyargvaluesparser@#1,#2\endargs@{%
8542   \expandafter\def\expandafter\@tempa\expandafter{%
8543     \expandafter\def\csname macarg.#1\endcsname{}}%
8544   \push@\@tempa\macargdeflist@
8545   \def\paramlist{#2}%
8546 }
8547
8548 % #1 is the element target macro
8549 % #2 is the list macro
8550 % #3,#4\endargs@ is the list value
8551 \def\pop@#1#2#3,#4\endargs@{%
8552    \def#1{#3}%
8553    \def#2{#4}%
8554 }
8555 \long\def\longpop@#1#2#3,#4\endargs@{%
8556    \long\def#1{#3}%
8557    \long\def#2{#4}%
8558 }
8559
8560
8561 %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
8562
8563
8564 % This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
8565 %    \macrobody has the body of the macro in it, with placeholders for
8566 % its parameters, looking like "\xeatspaces{\hash 1}".
8567 %    \paramno is the number of parameters
8568 %    \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
8569 % There are four cases: macros of zero, one, up to nine, and many arguments.
8570 % \xdef is used so that macro definitions will survive the file
8571 % they're defined in: @include reads the file inside a group.
8572 %
8573 \def\defmacro{%
8574   \let\hash=##% convert placeholders to macro parameter chars
8575   \ifnum\paramno=1
8576     \def\xeatspaces##1{##1}%
8577     % This removes the pair of braces around the argument.  We don't
8578     % use \eatspaces, because this can cause ends of lines to be lost
8579     % when the argument to \eatspaces is read, leading to line-based
8580     % commands like "@itemize" not being read correctly.
8581   \else
8582     \let\xeatspaces\relax % suppress expansion
8583   \fi
8584   \ifcase\paramno
8585   % 0
8586     \expandafter\xdef\csname\the\macname\endcsname{%
8587       \bgroup
8588         \noexpand\spaceisspace
8589         \noexpand\endlineisspace
8590         \noexpand\expandafter % skip any whitespace after the macro name.
8591         \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8592     \expandafter\xdef\csname\the\macname @@@\endcsname{%
8593       \egroup
8594       \noexpand\scanmacro{\macrobody}}%
8595   \or % 1
8596     \expandafter\xdef\csname\the\macname\endcsname{%
8597        \bgroup
8598        \noexpand\braceorline
8599        \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8600     \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8601       \egroup
8602       \noexpand\scanmacro{\macrobody}%
8603       }%
8604   \else % at most 9
8605     \ifnum\paramno<10\relax
8606       % @MACNAME sets the context for reading the macro argument
8607       % @MACNAME@@ gets the argument, processes backslashes and appends a 
8608       % comma.
8609       % @MACNAME@@@ removes braces surrounding the argument list.
8610       % @MACNAME@@@@ scans the macro body with arguments substituted.
8611       \expandafter\xdef\csname\the\macname\endcsname{%
8612         \bgroup
8613         \noexpand\expandafter  % This \expandafter skip any spaces after the
8614         \noexpand\macroargctxt % macro before we change the catcode of space.
8615         \noexpand\expandafter
8616         \expandafter\noexpand\csname\the\macname @@\endcsname}%
8617       \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8618           \noexpand\passargtomacro
8619           \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8620       \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8621           \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8622       \expandafter\expandafter
8623       \expandafter\xdef
8624       \expandafter\expandafter
8625         \csname\the\macname @@@@\endcsname\paramlist{%
8626           \egroup\noexpand\scanmacro{\macrobody}}%
8627     \else % 10 or more:
8628       \expandafter\xdef\csname\the\macname\endcsname{%
8629         \noexpand\getargvals@{\the\macname}{\argl}%
8630       }%
8631       \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8632       \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
8633     \fi
8634   \fi}
8635
8636 \catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
8637
8638 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
8639
8640
8641 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8642 %
8643 {\catcode`\@=0 \catcode`\\=13  % We need to manipulate \ so use @ as escape
8644 @catcode`@_=11  % private names
8645 @catcode`@!=11  % used as argument separator
8646
8647 % \passargtomacro#1#2 -
8648 % Call #1 with a list of tokens #2, with any doubled backslashes in #2
8649 % compressed to one.
8650 %
8651 % This implementation works by expansion, and not execution (so we cannot use 
8652 % \def or similar).  This reduces the risk of this failing in contexts where 
8653 % complete expansion is done with no execution (for example, in writing out to 
8654 % an auxiliary file for an index entry).
8655
8656 % State is kept in the input stream: the argument passed to
8657 % @look_ahead, @gobble_and_check_finish and @add_segment is
8658 %
8659 % THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN  (... rest of input)
8660 %
8661 % where:
8662 % THE_MACRO - name of the macro we want to call
8663 % ARG_RESULT - argument list we build to pass to that macro
8664 % PENDING_BS - either a backslash or nothing
8665 % NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
8666
8667 @gdef@passargtomacro#1#2{%
8668   @add_segment #1!{}@relax#2\@_finish\%
8669 }
8670 @gdef@_finish{@_finishx} @global@let@_finishx@relax
8671
8672 % #1 - THE_MACRO ARG_RESULT
8673 % #2 - PENDING_BS
8674 % #3 - NEXT_TOKEN
8675 % #4 used to look ahead
8676 %
8677 % If the next token is not a backslash, process the rest of the argument; 
8678 % otherwise, remove the next token.
8679 @gdef@look_ahead#1!#2#3#4{%
8680   @ifx#4\%
8681    @expandafter@gobble_and_check_finish 
8682   @else
8683    @expandafter@add_segment
8684   @fi#1!{#2}#4#4%
8685 }
8686
8687 % #1 - THE_MACRO ARG_RESULT
8688 % #2 - PENDING_BS
8689 % #3 - NEXT_TOKEN
8690 % #4 should be a backslash, which is gobbled.
8691 % #5 looks ahead
8692 %
8693 % Double backslash found.  Add a single backslash, and look ahead.
8694 @gdef@gobble_and_check_finish#1!#2#3#4#5{%
8695   @add_segment#1\!{}#5#5%
8696 }
8697
8698 @gdef@is_fi{@fi}
8699
8700 % #1 - THE_MACRO ARG_RESULT
8701 % #2 - PENDING_BS
8702 % #3 - NEXT_TOKEN
8703 % #4 is input stream until next backslash
8704 %
8705 % Input stream is either at the start of the argument, or just after a 
8706 % backslash sequence, either a lone backslash, or a doubled backslash.  
8707 % NEXT_TOKEN contains the first token in the input stream: if it is \finish, 
8708 % finish; otherwise, append to ARG_RESULT the segment of the argument up until
8709 % the next backslash.  PENDING_BACKSLASH contains a backslash to represent
8710 % a backslash just before the start of the input stream that has not been
8711 % added to ARG_RESULT.
8712 @gdef@add_segment#1!#2#3#4\{%
8713 @ifx#3@_finish
8714   @call_the_macro#1!%
8715 @else
8716   % append the pending backslash to the result, followed by the next segment
8717   @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
8718   % this @fi is discarded by @look_ahead.
8719   % we can't get rid of it with \expandafter because we don't know how 
8720   % long #4 is.
8721 }
8722
8723 % #1 - THE_MACRO
8724 % #2 - ARG_RESULT
8725 % #3 discards the res of the conditional in @add_segment, and @is_fi ends the 
8726 % conditional.
8727 @gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
8728
8729 }
8730 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8731
8732 % \braceorline MAC is used for a one-argument macro MAC.  It checks
8733 % whether the next non-whitespace character is a {.  It sets the context
8734 % for reading the argument (slightly different in the two cases).  Then,
8735 % to read the argument, in the whole-line case, it then calls the regular
8736 % \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
8737
8738 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
8739 \def\braceorlinexxx{%
8740   \ifx\nchar\bgroup
8741     \macroargctxt
8742     \expandafter\passargtomacro
8743   \else
8744     \macrolineargctxt\expandafter\parsearg
8745   \fi \macnamexxx}
8746
8747
8748 % @alias.
8749 % We need some trickery to remove the optional spaces around the equal
8750 % sign.  Make them active and then expand them all to nothing.
8751 %
8752 \def\alias{\parseargusing\obeyspaces\aliasxxx}
8753 \def\aliasxxx #1{\aliasyyy#1\relax}
8754 \def\aliasyyy #1=#2\relax{%
8755   {%
8756     \expandafter\let\obeyedspace=\empty
8757     \addtomacrolist{#1}%
8758     \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
8759   }%
8760   \next
8761 }
8762
8763
8764 \message{cross references,}
8765
8766 \newwrite\auxfile
8767 \newif\ifhavexrefs    % True if xref values are known.
8768 \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
8769
8770 % @inforef is relatively simple.
8771 \def\inforef #1{\inforefzzz #1,,,,**}
8772 \def\inforefzzz #1,#2,#3,#4**{%
8773   \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
8774   node \samp{\ignorespaces#1{}}}
8775
8776 % @node's only job in TeX is to define \lastnode, which is used in
8777 % cross-references.  The @node line might or might not have commas, and
8778 % might or might not have spaces before the first comma, like:
8779 % @node foo , bar , ...
8780 % We don't want such trailing spaces in the node name.
8781 %
8782 \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
8783 %
8784 % also remove a trailing comma, in case of something like this:
8785 % @node Help-Cross,  ,  , Cross-refs
8786 \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
8787 \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
8788
8789 \let\nwnode=\node
8790 \let\lastnode=\empty
8791
8792 % Write a cross-reference definition for the current node.  #1 is the
8793 % type (Ynumbered, Yappendix, Ynothing).
8794 %
8795 \def\donoderef#1{%
8796   \ifx\lastnode\empty\else
8797     \setref{\lastnode}{#1}%
8798     \global\let\lastnode=\empty
8799   \fi
8800 }
8801
8802 % @anchor{NAME} -- define xref target at arbitrary point.
8803 %
8804 \newcount\savesfregister
8805 %
8806 \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
8807 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
8808 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
8809
8810 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
8811 % anchor), which consists of three parts:
8812 % 1) NAME-title - the current sectioning name taken from \lastsection,
8813 %                 or the anchor name.
8814 % 2) NAME-snt   - section number and type, passed as the SNT arg, or
8815 %                 empty for anchors.
8816 % 3) NAME-pg    - the page number.
8817 %
8818 % This is called from \donoderef, \anchor, and \dofloat.  In the case of
8819 % floats, there is an additional part, which is not written here:
8820 % 4) NAME-lof   - the text as it should appear in a @listoffloats.
8821 %
8822 \def\setref#1#2{%
8823   \pdfmkdest{#1}%
8824   \iflinks
8825     {%
8826       \requireauxfile
8827       \atdummies  % preserve commands, but don't expand them
8828       % match definition in \xrdef, \refx, \xrefX.
8829       \def\value##1{##1}%
8830       \edef\writexrdef##1##2{%
8831         \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
8832           ##1}{##2}}% these are parameters of \writexrdef
8833       }%
8834       \toks0 = \expandafter{\lastsection}%
8835       \immediate \writexrdef{title}{\the\toks0 }%
8836       \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
8837       \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
8838     }%
8839   \fi
8840 }
8841
8842 % @xrefautosectiontitle on|off says whether @section(ing) names are used
8843 % automatically in xrefs, if the third arg is not explicitly specified.
8844 % This was provided as a "secret" @set xref-automatic-section-title
8845 % variable, now it's official.
8846
8847 \parseargdef\xrefautomaticsectiontitle{%
8848   \def\temp{#1}%
8849   \ifx\temp\onword
8850     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8851       = \empty
8852   \else\ifx\temp\offword
8853     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8854       = \relax
8855   \else
8856     \errhelp = \EMsimple
8857     \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
8858                 must be on|off}%
8859   \fi\fi
8860 }
8861
8862\f
8863 % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
8864 % the node name, #2 the name of the Info cross-reference, #3 the printed
8865 % node name, #4 the name of the Info file, #5 the name of the printed
8866 % manual.  All but the node name can be omitted.
8867 %
8868 \def\pxref{\putwordsee{} \xrefXX}
8869 \def\xref{\putwordSee{} \xrefXX}
8870 \def\ref{\xrefXX}
8871
8872 \def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
8873 \def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
8874 %
8875 \newbox\toprefbox
8876 \newbox\printedrefnamebox
8877 \newbox\infofilenamebox
8878 \newbox\printedmanualbox
8879 %
8880 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
8881   \unsepspaces
8882   %
8883   % Get args without leading/trailing spaces.
8884   \def\printedrefname{\ignorespaces #3}%
8885   \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
8886   %
8887   \def\infofilename{\ignorespaces #4}%
8888   \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
8889   %
8890   \def\printedmanual{\ignorespaces #5}%
8891   \setbox\printedmanualbox  = \hbox{\printedmanual\unskip}%
8892   %
8893   % If the printed reference name (arg #3) was not explicitly given in
8894   % the @xref, figure out what we want to use.
8895   \ifdim \wd\printedrefnamebox = 0pt
8896     % No printed node name was explicitly given.
8897     \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
8898       % Not auto section-title: use node name inside the square brackets.
8899       \def\printedrefname{\ignorespaces #1}%
8900     \else
8901       % Auto section-title: use chapter/section title inside
8902       % the square brackets if we have it.
8903       \ifdim \wd\printedmanualbox > 0pt
8904         % It is in another manual, so we don't have it; use node name.
8905         \def\printedrefname{\ignorespaces #1}%
8906       \else
8907         \ifhavexrefs
8908           % We (should) know the real title if we have the xref values.
8909           \def\printedrefname{\refx{#1-title}{}}%
8910         \else
8911           % Otherwise just copy the Info node name.
8912           \def\printedrefname{\ignorespaces #1}%
8913         \fi%
8914       \fi
8915     \fi
8916   \fi
8917   %
8918   % Make link in pdf output.
8919   \ifpdf
8920     % For pdfTeX and LuaTeX
8921     {\indexnofonts
8922      \makevalueexpandable
8923      \turnoffactive
8924      % This expands tokens, so do it after making catcode changes, so _
8925      % etc. don't get their TeX definitions.  This ignores all spaces in
8926      % #4, including (wrongly) those in the middle of the filename.
8927      \getfilename{#4}%
8928      %
8929      % This (wrongly) does not take account of leading or trailing
8930      % spaces in #1, which should be ignored.
8931      \setpdfdestname{#1}%
8932      %
8933      \ifx\pdfdestname\empty
8934        \def\pdfdestname{Top}% no empty targets
8935      \fi
8936      %
8937      \leavevmode
8938      \startlink attr{/Border [0 0 0]}%
8939      \ifnum\filenamelength>0
8940        goto file{\the\filename.pdf} name{\pdfdestname}%
8941      \else
8942        goto name{\pdfmkpgn{\pdfdestname}}%
8943      \fi
8944     }%
8945     \setcolor{\linkcolor}%
8946   \else
8947     \ifx\XeTeXrevision\thisisundefined
8948     \else
8949       % For XeTeX
8950       {\indexnofonts
8951        \makevalueexpandable
8952        \turnoffactive
8953        % This expands tokens, so do it after making catcode changes, so _
8954        % etc. don't get their TeX definitions.  This ignores all spaces in
8955        % #4, including (wrongly) those in the middle of the filename.
8956        \getfilename{#4}%
8957        %
8958        % This (wrongly) does not take account of leading or trailing
8959        % spaces in #1, which should be ignored.
8960        \setpdfdestname{#1}%
8961        %
8962        \ifx\pdfdestname\empty
8963          \def\pdfdestname{Top}% no empty targets
8964        \fi
8965        %
8966        \leavevmode
8967        \ifnum\filenamelength>0
8968          % With default settings,
8969          % XeTeX (xdvipdfmx) replaces link destination names with integers.
8970          % In this case, the replaced destination names of
8971          % remote PDFs are no longer known.  In order to avoid a replacement,
8972          % you can use xdvipdfmx's command line option `-C 0x0010'.
8973          % If you use XeTeX 0.99996+ (TeX Live 2016+),
8974          % this command line option is no longer necessary
8975          % because we can use the `dvipdfmx:config' special.
8976          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8977            << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}%
8978        \else
8979          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8980            << /S /GoTo /D (\pdfdestname) >> >>}%
8981        \fi
8982       }%
8983       \setcolor{\linkcolor}%
8984     \fi
8985   \fi
8986   {%
8987     % Have to otherify everything special to allow the \csname to
8988     % include an _ in the xref name, etc.
8989     \indexnofonts
8990     \turnoffactive
8991     \def\value##1{##1}%
8992     \expandafter\global\expandafter\let\expandafter\Xthisreftitle
8993       \csname XR#1-title\endcsname
8994   }%
8995   %
8996   % Float references are printed completely differently: "Figure 1.2"
8997   % instead of "[somenode], p.3".  \iffloat distinguishes them by
8998   % \Xthisreftitle being set to a magic string.
8999   \iffloat\Xthisreftitle
9000     % If the user specified the print name (third arg) to the ref,
9001     % print it instead of our usual "Figure 1.2".
9002     \ifdim\wd\printedrefnamebox = 0pt
9003       \refx{#1-snt}{}%
9004     \else
9005       \printedrefname
9006     \fi
9007     %
9008     % If the user also gave the printed manual name (fifth arg), append
9009     % "in MANUALNAME".
9010     \ifdim \wd\printedmanualbox > 0pt
9011       \space \putwordin{} \cite{\printedmanual}%
9012     \fi
9013   \else
9014     % node/anchor (non-float) references.
9015     % 
9016     % If we use \unhbox to print the node names, TeX does not insert
9017     % empty discretionaries after hyphens, which means that it will not
9018     % find a line break at a hyphen in a node names.  Since some manuals
9019     % are best written with fairly long node names, containing hyphens,
9020     % this is a loss.  Therefore, we give the text of the node name
9021     % again, so it is as if TeX is seeing it for the first time.
9022     % 
9023     \ifdim \wd\printedmanualbox > 0pt
9024       % Cross-manual reference with a printed manual name.
9025       % 
9026       \crossmanualxref{\cite{\printedmanual\unskip}}%
9027     %
9028     \else\ifdim \wd\infofilenamebox > 0pt
9029       % Cross-manual reference with only an info filename (arg 4), no
9030       % printed manual name (arg 5).  This is essentially the same as
9031       % the case above; we output the filename, since we have nothing else.
9032       % 
9033       \crossmanualxref{\code{\infofilename\unskip}}%
9034     %
9035     \else
9036       % Reference within this manual.
9037       %
9038       % _ (for example) has to be the character _ for the purposes of the
9039       % control sequence corresponding to the node, but it has to expand
9040       % into the usual \leavevmode...\vrule stuff for purposes of
9041       % printing. So we \turnoffactive for the \refx-snt, back on for the
9042       % printing, back off for the \refx-pg.
9043       {\turnoffactive
9044        % Only output a following space if the -snt ref is nonempty; for
9045        % @unnumbered and @anchor, it won't be.
9046        \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
9047        \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
9048       }%
9049       % output the `[mynode]' via the macro below so it can be overridden.
9050       \xrefprintnodename\printedrefname
9051       %
9052       % But we always want a comma and a space:
9053       ,\space
9054       %
9055       % output the `page 3'.
9056       \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
9057       % Add a , if xref followed by a space
9058       \if\space\noexpand\tokenafterxref ,%
9059       \else\ifx\        \tokenafterxref ,% @TAB
9060       \else\ifx\*\tokenafterxref ,%   @*
9061       \else\ifx\ \tokenafterxref ,%   @SPACE
9062       \else\ifx\
9063                 \tokenafterxref ,%    @NL
9064       \else\ifx\tie\tokenafterxref ,% @tie
9065       \fi\fi\fi\fi\fi\fi
9066     \fi\fi
9067   \fi
9068   \endlink
9069 \endgroup}
9070
9071 % Output a cross-manual xref to #1.  Used just above (twice).
9072
9073 % Only include the text "Section ``foo'' in" if the foo is neither
9074 % missing or Top.  Thus, @xref{,,,foo,The Foo Manual} outputs simply
9075 % "see The Foo Manual", the idea being to refer to the whole manual.
9076
9077 % But, this being TeX, we can't easily compare our node name against the
9078 % string "Top" while ignoring the possible spaces before and after in
9079 % the input.  By adding the arbitrary 7sp below, we make it much less
9080 % likely that a real node name would have the same width as "Top" (e.g.,
9081 % in a monospaced font).  Hopefully it will never happen in practice.
9082
9083 % For the same basic reason, we retypeset the "Top" at every
9084 % reference, since the current font is indeterminate.
9085
9086 \def\crossmanualxref#1{%
9087   \setbox\toprefbox = \hbox{Top\kern7sp}%
9088   \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
9089   \ifdim \wd2 > 7sp  % nonempty?
9090     \ifdim \wd2 = \wd\toprefbox \else  % same as Top?
9091       \putwordSection{} ``\printedrefname'' \putwordin{}\space
9092     \fi
9093   \fi
9094   #1%
9095 }
9096
9097 % This macro is called from \xrefX for the `[nodename]' part of xref
9098 % output.  It's a separate macro only so it can be changed more easily,
9099 % since square brackets don't work well in some documents.  Particularly
9100 % one that Bob is working on :).
9101 %
9102 \def\xrefprintnodename#1{[#1]}
9103
9104 % Things referred to by \setref.
9105 %
9106 \def\Ynothing{}
9107 \def\Yomitfromtoc{}
9108 \def\Ynumbered{%
9109   \ifnum\secno=0
9110     \putwordChapter@tie \the\chapno
9111   \else \ifnum\subsecno=0
9112     \putwordSection@tie \the\chapno.\the\secno
9113   \else \ifnum\subsubsecno=0
9114     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
9115   \else
9116     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
9117   \fi\fi\fi
9118 }
9119 \def\Yappendix{%
9120   \ifnum\secno=0
9121      \putwordAppendix@tie @char\the\appendixno{}%
9122   \else \ifnum\subsecno=0
9123      \putwordSection@tie @char\the\appendixno.\the\secno
9124   \else \ifnum\subsubsecno=0
9125     \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
9126   \else
9127     \putwordSection@tie
9128       @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
9129   \fi\fi\fi
9130 }
9131
9132 % \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME.  SUFFIX 
9133 % is output afterwards if non-empty.
9134 \def\refx#1#2{%
9135   \requireauxfile
9136   {%
9137     \indexnofonts
9138     \otherbackslash
9139     \def\value##1{##1}%
9140     \expandafter\global\expandafter\let\expandafter\thisrefX
9141       \csname XR#1\endcsname
9142   }%
9143   \ifx\thisrefX\relax
9144     % If not defined, say something at least.
9145     \angleleft un\-de\-fined\angleright
9146     \iflinks
9147       \ifhavexrefs
9148         {\toks0 = {#1}% avoid expansion of possibly-complex value
9149          \message{\linenumber Undefined cross reference `\the\toks0'.}}%
9150       \else
9151         \ifwarnedxrefs\else
9152           \global\warnedxrefstrue
9153           \message{Cross reference values unknown; you must run TeX again.}%
9154         \fi
9155       \fi
9156     \fi
9157   \else
9158     % It's defined, so just use it.
9159     \thisrefX
9160   \fi
9161   #2% Output the suffix in any case.
9162 }
9163
9164 % This is the macro invoked by entries in the aux file.  Define a control 
9165 % sequence for a cross-reference target (we prepend XR to the control sequence 
9166 % name to avoid collisions).  The value is the page number.  If this is a float 
9167 % type, we have more work to do.
9168 %
9169 \def\xrdef#1#2{%
9170   {% Expand the node or anchor name to remove control sequences.
9171    % \turnoffactive stops 8-bit characters being changed to commands
9172    % like @'e.  \refx does the same to retrieve the value in the definition.
9173     \indexnofonts
9174     \turnoffactive
9175     \def\value##1{##1}%
9176     \xdef\safexrefname{#1}%
9177   }%
9178   %
9179   \bgroup
9180     \expandafter\gdef\csname XR\safexrefname\endcsname{#2}%
9181   \egroup
9182   % We put the \gdef inside a group to avoid the definitions building up on 
9183   % TeX's save stack, which can cause it to run out of space for aux files with 
9184   % thousands of lines.  \gdef doesn't use the save stack, but \csname does
9185   % when it defines an unknown control sequence as \relax. 
9186   %
9187   % Was that xref control sequence that we just defined for a float?
9188   \expandafter\iffloat\csname XR\safexrefname\endcsname
9189     % it was a float, and we have the (safe) float type in \iffloattype.
9190     \expandafter\let\expandafter\floatlist
9191       \csname floatlist\iffloattype\endcsname
9192     %
9193     % Is this the first time we've seen this float type?
9194     \expandafter\ifx\floatlist\relax
9195       \toks0 = {\do}% yes, so just \do
9196     \else
9197       % had it before, so preserve previous elements in list.
9198       \toks0 = \expandafter{\floatlist\do}%
9199     \fi
9200     %
9201     % Remember this xref in the control sequence \floatlistFLOATTYPE,
9202     % for later use in \listoffloats.
9203     \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
9204       {\safexrefname}}%
9205   \fi
9206 }
9207
9208 % If working on a large document in chapters, it is convenient to
9209 % be able to disable indexing, cross-referencing, and contents, for test runs.
9210 % This is done with @novalidate at the beginning of the file.
9211 %
9212 \newif\iflinks \linkstrue % by default we want the aux files.
9213 \let\novalidate = \linksfalse
9214
9215 % Used when writing to the aux file, or when using data from it.
9216 \def\requireauxfile{%
9217   \iflinks
9218     \tryauxfile
9219     % Open the new aux file.  TeX will close it automatically at exit.
9220     \immediate\openout\auxfile=\jobname.aux
9221   \fi
9222   \global\let\requireauxfile=\relax   % Only do this once.
9223 }
9224
9225 % Read the last existing aux file, if any.  No error if none exists.
9226 %
9227 \def\tryauxfile{%
9228   \openin 1 \jobname.aux
9229   \ifeof 1 \else
9230     \readdatafile{aux}%
9231     \global\havexrefstrue
9232   \fi
9233   \closein 1
9234 }
9235
9236 \def\setupdatafile{%
9237   \catcode`\^^@=\other
9238   \catcode`\^^A=\other
9239   \catcode`\^^B=\other
9240   \catcode`\^^C=\other
9241   \catcode`\^^D=\other
9242   \catcode`\^^E=\other
9243   \catcode`\^^F=\other
9244   \catcode`\^^G=\other
9245   \catcode`\^^H=\other
9246   \catcode`\^^K=\other
9247   \catcode`\^^L=\other
9248   \catcode`\^^N=\other
9249   \catcode`\^^P=\other
9250   \catcode`\^^Q=\other
9251   \catcode`\^^R=\other
9252   \catcode`\^^S=\other
9253   \catcode`\^^T=\other
9254   \catcode`\^^U=\other
9255   \catcode`\^^V=\other
9256   \catcode`\^^W=\other
9257   \catcode`\^^X=\other
9258   \catcode`\^^Z=\other
9259   \catcode`\^^[=\other
9260   \catcode`\^^\=\other
9261   \catcode`\^^]=\other
9262   \catcode`\^^^=\other
9263   \catcode`\^^_=\other
9264   % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
9265   % in xref tags, i.e., node names.  But since ^^e4 notation isn't
9266   % supported in the main text, it doesn't seem desirable.  Furthermore,
9267   % that is not enough: for node names that actually contain a ^
9268   % character, we would end up writing a line like this: 'xrdef {'hat
9269   % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
9270   % argument, and \hat is not an expandable control sequence.  It could
9271   % all be worked out, but why?  Either we support ^^ or we don't.
9272   %
9273   % The other change necessary for this was to define \auxhat:
9274   % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
9275   % and then to call \auxhat in \setq.
9276   %
9277   \catcode`\^=\other
9278   %
9279   % Special characters.  Should be turned off anyway, but...
9280   \catcode`\~=\other
9281   \catcode`\[=\other
9282   \catcode`\]=\other
9283   \catcode`\"=\other
9284   \catcode`\_=\other
9285   \catcode`\|=\other
9286   \catcode`\<=\other
9287   \catcode`\>=\other
9288   \catcode`\$=\other
9289   \catcode`\#=\other
9290   \catcode`\&=\other
9291   \catcode`\%=\other
9292   \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
9293   %
9294   % This is to support \ in node names and titles, since the \
9295   % characters end up in a \csname.  It's easier than
9296   % leaving it active and making its active definition an actual \
9297   % character.  What I don't understand is why it works in the *value*
9298   % of the xrdef.  Seems like it should be a catcode12 \, and that
9299   % should not typeset properly.  But it works, so I'm moving on for
9300   % now.  --karl, 15jan04.
9301   \catcode`\\=\other
9302   %
9303   % @ is our escape character in .aux files, and we need braces.
9304   \catcode`\{=1
9305   \catcode`\}=2
9306   \catcode`\@=0
9307 }
9308
9309 \def\readdatafile#1{%
9310 \begingroup
9311   \setupdatafile
9312   \input\jobname.#1
9313 \endgroup}
9314
9315
9316 \message{insertions,}
9317 % including footnotes.
9318
9319 \newcount \footnoteno
9320
9321 % The trailing space in the following definition for supereject is
9322 % vital for proper filling; pages come out unaligned when you do a
9323 % pagealignmacro call if that space before the closing brace is
9324 % removed. (Generally, numeric constants should always be followed by a
9325 % space to prevent strange expansion errors.)
9326 \def\supereject{\par\penalty -20000\footnoteno =0 }
9327
9328 % @footnotestyle is meaningful for Info output only.
9329 \let\footnotestyle=\comment
9330
9331 {\catcode `\@=11
9332 %
9333 % Auto-number footnotes.  Otherwise like plain.
9334 \gdef\footnote{%
9335   \global\advance\footnoteno by \@ne
9336   \edef\thisfootno{$^{\the\footnoteno}$}%
9337   %
9338   % In case the footnote comes at the end of a sentence, preserve the
9339   % extra spacing after we do the footnote number.
9340   \let\@sf\empty
9341   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9342   %
9343   % Remove inadvertent blank space before typesetting the footnote number.
9344   \unskip
9345   \thisfootno\@sf
9346   \dofootnote
9347 }%
9348
9349 % Don't bother with the trickery in plain.tex to not require the
9350 % footnote text as a parameter.  Our footnotes don't need to be so general.
9351 %
9352 % Oh yes, they do; otherwise, @ifset (and anything else that uses
9353 % \parseargline) fails inside footnotes because the tokens are fixed when
9354 % the footnote is read.  --karl, 16nov96.
9355 %
9356 \gdef\dofootnote{%
9357   \insert\footins\bgroup
9358   %
9359   % Nested footnotes are not supported in TeX, that would take a lot
9360   % more work.  (\startsavinginserts does not suffice.)
9361   \let\footnote=\errfootnotenest
9362   %
9363   % We want to typeset this text as a normal paragraph, even if the
9364   % footnote reference occurs in (for example) a display environment.
9365   % So reset some parameters.
9366   \hsize=\txipagewidth
9367   \interlinepenalty\interfootnotelinepenalty
9368   \splittopskip\ht\strutbox % top baseline for broken footnotes
9369   \splitmaxdepth\dp\strutbox
9370   \floatingpenalty\@MM
9371   \leftskip\z@skip
9372   \rightskip\z@skip
9373   \spaceskip\z@skip
9374   \xspaceskip\z@skip
9375   \parindent\defaultparindent
9376   %
9377   \smallfonts \rm
9378   %
9379   % Because we use hanging indentation in footnotes, a @noindent appears
9380   % to exdent this text, so make it be a no-op.  makeinfo does not use
9381   % hanging indentation so @noindent can still be needed within footnote
9382   % text after an @example or the like (not that this is good style).
9383   \let\noindent = \relax
9384   %
9385   % Hang the footnote text off the number.  Use \everypar in case the
9386   % footnote extends for more than one paragraph.
9387   \everypar = {\hang}%
9388   \textindent{\thisfootno}%
9389   %
9390   % Don't crash into the line above the footnote text.  Since this
9391   % expands into a box, it must come within the paragraph, lest it
9392   % provide a place where TeX can split the footnote.
9393   \footstrut
9394   %
9395   % Invoke rest of plain TeX footnote routine.
9396   \futurelet\next\fo@t
9397 }
9398 }%end \catcode `\@=11
9399
9400 \def\errfootnotenest{%
9401   \errhelp=\EMsimple
9402   \errmessage{Nested footnotes not supported in texinfo.tex,
9403     even though they work in makeinfo; sorry}
9404 }
9405
9406 \def\errfootnoteheading{%
9407   \errhelp=\EMsimple
9408   \errmessage{Footnotes in chapters, sections, etc., are not supported}
9409 }
9410
9411 % In case a @footnote appears in a vbox, save the footnote text and create
9412 % the real \insert just after the vbox finished.  Otherwise, the insertion
9413 % would be lost.
9414 % Similarly, if a @footnote appears inside an alignment, save the footnote
9415 % text to a box and make the \insert when a row of the table is finished.
9416 % And the same can be done for other insert classes.  --kasal, 16nov03.
9417 %
9418 % Replace the \insert primitive by a cheating macro.
9419 % Deeper inside, just make sure that the saved insertions are not spilled
9420 % out prematurely.
9421 %
9422 \def\startsavinginserts{%
9423   \ifx \insert\ptexinsert
9424     \let\insert\saveinsert
9425   \else
9426     \let\checkinserts\relax
9427   \fi
9428 }
9429
9430 % This \insert replacement works for both \insert\footins{foo} and
9431 % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9432 %
9433 \def\saveinsert#1{%
9434   \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9435   \afterassignment\next
9436   % swallow the left brace
9437   \let\temp =
9438 }
9439 \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9440 \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9441
9442 \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9443
9444 \def\placesaveins#1{%
9445   \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9446     {\box#1}%
9447 }
9448
9449 % eat @SAVE -- beware, all of them have catcode \other:
9450 {
9451   \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials  %  ;-)
9452   \gdef\gobblesave @SAVE{}
9453 }
9454
9455 % initialization:
9456 \def\newsaveins #1{%
9457   \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9458   \next
9459 }
9460 \def\newsaveinsX #1{%
9461   \csname newbox\endcsname #1%
9462   \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9463     \checksaveins #1}%
9464 }
9465
9466 % initialize:
9467 \let\checkinserts\empty
9468 \newsaveins\footins
9469 \newsaveins\margin
9470
9471
9472 % @image.  We use the macros from epsf.tex to support this.
9473 % If epsf.tex is not installed and @image is used, we complain.
9474 %
9475 % Check for and read epsf.tex up front.  If we read it only at @image
9476 % time, we might be inside a group, and then its definitions would get
9477 % undone and the next image would fail.
9478 \openin 1 = epsf.tex
9479 \ifeof 1 \else
9480   % Do not bother showing banner with epsf.tex v2.7k (available in
9481   % doc/epsf.tex and on ctan).
9482   \def\epsfannounce{\toks0 = }%
9483   \input epsf.tex
9484 \fi
9485 \closein 1
9486 %
9487 % We will only complain once about lack of epsf.tex.
9488 \newif\ifwarnednoepsf
9489 \newhelp\noepsfhelp{epsf.tex must be installed for images to
9490   work.  It is also included in the Texinfo distribution, or you can get
9491   it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.}
9492 %
9493 \def\image#1{%
9494   \ifx\epsfbox\thisisundefined
9495     \ifwarnednoepsf \else
9496       \errhelp = \noepsfhelp
9497       \errmessage{epsf.tex not found, images will be ignored}%
9498       \global\warnednoepsftrue
9499     \fi
9500   \else
9501     \imagexxx #1,,,,,\finish
9502   \fi
9503 }
9504 %
9505 % Arguments to @image:
9506 % #1 is (mandatory) image filename; we tack on .eps extension.
9507 % #2 is (optional) width, #3 is (optional) height.
9508 % #4 is (ignored optional) html alt text.
9509 % #5 is (ignored optional) extension.
9510 % #6 is just the usual extra ignored arg for parsing stuff.
9511 \newif\ifimagevmode
9512 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
9513   \catcode`\^^M = 5     % in case we're inside an example
9514   \normalturnoffactive  % allow _ et al. in names
9515   \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
9516   % If the image is by itself, center it.
9517   \ifvmode
9518     \imagevmodetrue
9519   \else \ifx\centersub\centerV
9520     % for @center @image, we need a vbox so we can have our vertical space
9521     \imagevmodetrue
9522     \vbox\bgroup % vbox has better behavior than vtop herev
9523   \fi\fi
9524   %
9525   \ifimagevmode
9526     \nobreak\medskip
9527     % Usually we'll have text after the image which will insert
9528     % \parskip glue, so insert it here too to equalize the space
9529     % above and below.
9530     \nobreak\vskip\parskip
9531     \nobreak
9532   \fi
9533   %
9534   % Leave vertical mode so that indentation from an enclosing
9535   %  environment such as @quotation is respected.
9536   % However, if we're at the top level, we don't want the
9537   %  normal paragraph indentation.
9538   % On the other hand, if we are in the case of @center @image, we don't
9539   %  want to start a paragraph, which will create a hsize-width box and
9540   %  eradicate the centering.
9541   \ifx\centersub\centerV\else \noindent \fi
9542   %
9543   % Output the image.
9544   \ifpdf
9545     % For pdfTeX and LuaTeX <= 0.80
9546     \dopdfimage{#1}{#2}{#3}%
9547   \else
9548     \ifx\XeTeXrevision\thisisundefined
9549       % For epsf.tex
9550       % \epsfbox itself resets \epsf?size at each figure.
9551       \setbox0 = \hbox{\ignorespaces #2}%
9552         \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9553       \setbox0 = \hbox{\ignorespaces #3}%
9554         \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9555       \epsfbox{#1.eps}%
9556     \else
9557       % For XeTeX
9558       \doxeteximage{#1}{#2}{#3}%
9559     \fi
9560   \fi
9561   %
9562   \ifimagevmode
9563     \medskip  % space after a standalone image
9564   \fi  
9565   \ifx\centersub\centerV \egroup \fi
9566 \endgroup}
9567
9568
9569 % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9570 % etc.  We don't actually implement floating yet, we always include the
9571 % float "here".  But it seemed the best name for the future.
9572 %
9573 \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9574
9575 % There may be a space before second and/or third parameter; delete it.
9576 \def\eatcommaspace#1, {#1,}
9577
9578 % #1 is the optional FLOATTYPE, the text label for this float, typically
9579 % "Figure", "Table", "Example", etc.  Can't contain commas.  If omitted,
9580 % this float will not be numbered and cannot be referred to.
9581 %
9582 % #2 is the optional xref label.  Also must be present for the float to
9583 % be referable.
9584 %
9585 % #3 is the optional positioning argument; for now, it is ignored.  It
9586 % will somehow specify the positions allowed to float to (here, top, bottom).
9587 %
9588 % We keep a separate counter for each FLOATTYPE, which we reset at each
9589 % chapter-level command.
9590 \let\resetallfloatnos=\empty
9591 %
9592 \def\dofloat#1,#2,#3,#4\finish{%
9593   \let\thiscaption=\empty
9594   \let\thisshortcaption=\empty
9595   %
9596   % don't lose footnotes inside @float.
9597   %
9598   % BEWARE: when the floats start float, we have to issue warning whenever an
9599   % insert appears inside a float which could possibly float. --kasal, 26may04
9600   %
9601   \startsavinginserts
9602   %
9603   % We can't be used inside a paragraph.
9604   \par
9605   %
9606   \vtop\bgroup
9607     \def\floattype{#1}%
9608     \def\floatlabel{#2}%
9609     \def\floatloc{#3}% we do nothing with this yet.
9610     %
9611     \ifx\floattype\empty
9612       \let\safefloattype=\empty
9613     \else
9614       {%
9615         % the floattype might have accents or other special characters,
9616         % but we need to use it in a control sequence name.
9617         \indexnofonts
9618         \turnoffactive
9619         \xdef\safefloattype{\floattype}%
9620       }%
9621     \fi
9622     %
9623     % If label is given but no type, we handle that as the empty type.
9624     \ifx\floatlabel\empty \else
9625       % We want each FLOATTYPE to be numbered separately (Figure 1,
9626       % Table 1, Figure 2, ...).  (And if no label, no number.)
9627       %
9628       \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9629       \global\advance\floatno by 1
9630       %
9631       {%
9632         % This magic value for \lastsection is output by \setref as the
9633         % XREFLABEL-title value.  \xrefX uses it to distinguish float
9634         % labels (which have a completely different output format) from
9635         % node and anchor labels.  And \xrdef uses it to construct the
9636         % lists of floats.
9637         %
9638         \edef\lastsection{\floatmagic=\safefloattype}%
9639         \setref{\floatlabel}{Yfloat}%
9640       }%
9641     \fi
9642     %
9643     % start with \parskip glue, I guess.
9644     \vskip\parskip
9645     %
9646     % Don't suppress indentation if a float happens to start a section.
9647     \restorefirstparagraphindent
9648 }
9649
9650 % we have these possibilities:
9651 % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9652 % @float Foo,lbl & no caption:    Foo 1.1
9653 % @float Foo & @caption{Cap}:     Foo: Cap
9654 % @float Foo & no caption:        Foo
9655 % @float ,lbl & Caption{Cap}:     1.1: Cap
9656 % @float ,lbl & no caption:       1.1
9657 % @float & @caption{Cap}:         Cap
9658 % @float & no caption:
9659 %
9660 \def\Efloat{%
9661     \let\floatident = \empty
9662     %
9663     % In all cases, if we have a float type, it comes first.
9664     \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9665     %
9666     % If we have an xref label, the number comes next.
9667     \ifx\floatlabel\empty \else
9668       \ifx\floattype\empty \else % if also had float type, need tie first.
9669         \appendtomacro\floatident{\tie}%
9670       \fi
9671       % the number.
9672       \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9673     \fi
9674     %
9675     % Start the printed caption with what we've constructed in
9676     % \floatident, but keep it separate; we need \floatident again.
9677     \let\captionline = \floatident
9678     %
9679     \ifx\thiscaption\empty \else
9680       \ifx\floatident\empty \else
9681         \appendtomacro\captionline{: }% had ident, so need a colon between
9682       \fi
9683       %
9684       % caption text.
9685       \appendtomacro\captionline{\scanexp\thiscaption}%
9686     \fi
9687     %
9688     % If we have anything to print, print it, with space before.
9689     % Eventually this needs to become an \insert.
9690     \ifx\captionline\empty \else
9691       \vskip.5\parskip
9692       \captionline
9693       %
9694       % Space below caption.
9695       \vskip\parskip
9696     \fi
9697     %
9698     % If have an xref label, write the list of floats info.  Do this
9699     % after the caption, to avoid chance of it being a breakpoint.
9700     \ifx\floatlabel\empty \else
9701       % Write the text that goes in the lof to the aux file as
9702       % \floatlabel-lof.  Besides \floatident, we include the short
9703       % caption if specified, else the full caption if specified, else nothing.
9704       {%
9705         \requireauxfile
9706         \atdummies
9707         %
9708         \ifx\thisshortcaption\empty
9709           \def\gtemp{\thiscaption}%
9710         \else
9711           \def\gtemp{\thisshortcaption}%
9712         \fi
9713         \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
9714           \ifx\gtemp\empty \else : \gtemp \fi}}%
9715       }%
9716     \fi
9717   \egroup  % end of \vtop
9718   %
9719   \checkinserts
9720 }
9721
9722 % Append the tokens #2 to the definition of macro #1, not expanding either.
9723 %
9724 \def\appendtomacro#1#2{%
9725   \expandafter\def\expandafter#1\expandafter{#1#2}%
9726 }
9727
9728 % @caption, @shortcaption
9729 %
9730 \def\caption{\docaption\thiscaption}
9731 \def\shortcaption{\docaption\thisshortcaption}
9732 \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
9733 \def\defcaption#1#2{\egroup \def#1{#2}}
9734
9735 % The parameter is the control sequence identifying the counter we are
9736 % going to use.  Create it if it doesn't exist and assign it to \floatno.
9737 \def\getfloatno#1{%
9738   \ifx#1\relax
9739       % Haven't seen this figure type before.
9740       \csname newcount\endcsname #1%
9741       %
9742       % Remember to reset this floatno at the next chap.
9743       \expandafter\gdef\expandafter\resetallfloatnos
9744         \expandafter{\resetallfloatnos #1=0 }%
9745   \fi
9746   \let\floatno#1%
9747 }
9748
9749 % \setref calls this to get the XREFLABEL-snt value.  We want an @xref
9750 % to the FLOATLABEL to expand to "Figure 3.1".  We call \setref when we
9751 % first read the @float command.
9752 %
9753 \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9754
9755 % Magic string used for the XREFLABEL-title value, so \xrefX can
9756 % distinguish floats from other xref types.
9757 \def\floatmagic{!!float!!}
9758
9759 % #1 is the control sequence we are passed; we expand into a conditional
9760 % which is true if #1 represents a float ref.  That is, the magic
9761 % \lastsection value which we \setref above.
9762 %
9763 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
9764 %
9765 % #1 is (maybe) the \floatmagic string.  If so, #2 will be the
9766 % (safe) float type for this float.  We set \iffloattype to #2.
9767 %
9768 \def\doiffloat#1=#2=#3\finish{%
9769   \def\temp{#1}%
9770   \def\iffloattype{#2}%
9771   \ifx\temp\floatmagic
9772 }
9773
9774 % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9775 %
9776 \parseargdef\listoffloats{%
9777   \def\floattype{#1}% floattype
9778   {%
9779     % the floattype might have accents or other special characters,
9780     % but we need to use it in a control sequence name.
9781     \indexnofonts
9782     \turnoffactive
9783     \xdef\safefloattype{\floattype}%
9784   }%
9785   %
9786   % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9787   \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9788     \ifhavexrefs
9789       % if the user said @listoffloats foo but never @float foo.
9790       \message{\linenumber No `\safefloattype' floats to list.}%
9791     \fi
9792   \else
9793     \begingroup
9794       \leftskip=\tocindent  % indent these entries like a toc
9795       \let\do=\listoffloatsdo
9796       \csname floatlist\safefloattype\endcsname
9797     \endgroup
9798   \fi
9799 }
9800
9801 % This is called on each entry in a list of floats.  We're passed the
9802 % xref label, in the form LABEL-title, which is how we save it in the
9803 % aux file.  We strip off the -title and look up \XRLABEL-lof, which
9804 % has the text we're supposed to typeset here.
9805 %
9806 % Figures without xref labels will not be included in the list (since
9807 % they won't appear in the aux file).
9808 %
9809 \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9810 \def\listoffloatsdoentry#1-title\finish{{%
9811   % Can't fully expand XR#1-lof because it can contain anything.  Just
9812   % pass the control sequence.  On the other hand, XR#1-pg is just the
9813   % page number, and we want to fully expand that so we can get a link
9814   % in pdf output.
9815   \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9816   %
9817   % use the same \entry macro we use to generate the TOC and index.
9818   \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9819   \writeentry
9820 }}
9821
9822
9823 \message{localization,}
9824
9825 % For single-language documents, @documentlanguage is usually given very
9826 % early, just after @documentencoding.  Single argument is the language
9827 % (de) or locale (de_DE) abbreviation.
9828 %
9829 {
9830   \catcode`\_ = \active
9831   \globaldefs=1
9832 \parseargdef\documentlanguage{%
9833   \tex % read txi-??.tex file in plain TeX.
9834     % Read the file by the name they passed if it exists.
9835     \let_ = \normalunderscore  % normal _ character for filename test
9836     \openin 1 txi-#1.tex
9837     \ifeof 1
9838       \documentlanguagetrywithoutunderscore #1_\finish
9839     \else
9840       \globaldefs = 1  % everything in the txi-LL files needs to persist
9841       \input txi-#1.tex
9842     \fi
9843     \closein 1
9844   \endgroup % end raw TeX
9845 }
9846 %
9847 % If they passed de_DE, and txi-de_DE.tex doesn't exist,
9848 % try txi-de.tex.
9849 %
9850 \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
9851   \openin 1 txi-#1.tex
9852   \ifeof 1
9853     \errhelp = \nolanghelp
9854     \errmessage{Cannot read language file txi-#1.tex}%
9855   \else
9856     \globaldefs = 1  % everything in the txi-LL files needs to persist
9857     \input txi-#1.tex
9858   \fi
9859   \closein 1
9860 }
9861 }% end of special _ catcode
9862 %
9863 \newhelp\nolanghelp{The given language definition file cannot be found or
9864 is empty.  Maybe you need to install it?  Putting it in the current
9865 directory should work if nowhere else does.}
9866
9867 % This macro is called from txi-??.tex files; the first argument is the
9868 % \language name to set (without the "\lang@" prefix), the second and
9869 % third args are \{left,right}hyphenmin.
9870 %
9871 % The language names to pass are determined when the format is built.
9872 % See the etex.log file created at that time, e.g.,
9873 % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9874 %
9875 % With TeX Live 2008, etex now includes hyphenation patterns for all
9876 % available languages.  This means we can support hyphenation in
9877 % Texinfo, at least to some extent.  (This still doesn't solve the
9878 % accented characters problem.)
9879 %
9880 \catcode`@=11
9881 \def\txisetlanguage#1#2#3{%
9882   % do not set the language if the name is undefined in the current TeX.
9883   \expandafter\ifx\csname lang@#1\endcsname \relax
9884     \message{no patterns for #1}%
9885   \else
9886     \global\language = \csname lang@#1\endcsname
9887   \fi
9888   % but there is no harm in adjusting the hyphenmin values regardless.
9889   \global\lefthyphenmin = #2\relax
9890   \global\righthyphenmin = #3\relax
9891 }
9892
9893 % XeTeX and LuaTeX can handle Unicode natively.
9894 % Their default I/O uses UTF-8 sequences instead of a byte-wise operation.
9895 % Other TeX engines' I/O (pdfTeX, etc.) is byte-wise.
9896 %
9897 \newif\iftxinativeunicodecapable
9898 \newif\iftxiusebytewiseio
9899
9900 \ifx\XeTeXrevision\thisisundefined
9901   \ifx\luatexversion\thisisundefined
9902     \txinativeunicodecapablefalse
9903     \txiusebytewiseiotrue
9904   \else
9905     \txinativeunicodecapabletrue
9906     \txiusebytewiseiofalse
9907   \fi
9908 \else
9909   \txinativeunicodecapabletrue
9910   \txiusebytewiseiofalse
9911 \fi
9912
9913 % Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9914 % for non-UTF-8 (byte-wise) encodings.
9915 %
9916 \def\setbytewiseio{%
9917   \ifx\XeTeXrevision\thisisundefined
9918   \else
9919     \XeTeXdefaultencoding "bytes"  % For subsequent files to be read
9920     \XeTeXinputencoding "bytes"  % For document root file
9921     % Unfortunately, there seems to be no corresponding XeTeX command for
9922     % output encoding.  This is a problem for auxiliary index and TOC files.
9923     % The only solution would be perhaps to write out @U{...} sequences in
9924     % place of non-ASCII characters.
9925   \fi
9926
9927   \ifx\luatexversion\thisisundefined
9928   \else
9929     \directlua{
9930     local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9931     local function convert_char (char)
9932       return utf8_char(byte(char))
9933     end
9934
9935     local function convert_line (line)
9936       return gsub(line, ".", convert_char)
9937     end
9938
9939     callback.register("process_input_buffer", convert_line)
9940
9941     local function convert_line_out (line)
9942       local line_out = ""
9943       for c in string.utfvalues(line) do
9944          line_out = line_out .. string.char(c)
9945       end
9946       return line_out
9947     end
9948
9949     callback.register("process_output_buffer", convert_line_out)
9950     }
9951   \fi
9952
9953   \txiusebytewiseiotrue
9954 }
9955
9956
9957 % Helpers for encodings.
9958 % Set the catcode of characters 128 through 255 to the specified number.
9959 %
9960 \def\setnonasciicharscatcode#1{%
9961    \count255=128
9962    \loop\ifnum\count255<256
9963       \global\catcode\count255=#1\relax
9964       \advance\count255 by 1
9965    \repeat
9966 }
9967
9968 \def\setnonasciicharscatcodenonglobal#1{%
9969    \count255=128
9970    \loop\ifnum\count255<256
9971       \catcode\count255=#1\relax
9972       \advance\count255 by 1
9973    \repeat
9974 }
9975
9976 % @documentencoding sets the definition of non-ASCII characters
9977 % according to the specified encoding.
9978 %
9979 \def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9980 \def\documentencodingzzz#1{%
9981   %
9982   % Encoding being declared for the document.
9983   \def\declaredencoding{\csname #1.enc\endcsname}%
9984   %
9985   % Supported encodings: names converted to tokens in order to be able
9986   % to compare them with \ifx.
9987   \def\ascii{\csname US-ASCII.enc\endcsname}%
9988   \def\latnine{\csname ISO-8859-15.enc\endcsname}%
9989   \def\latone{\csname ISO-8859-1.enc\endcsname}%
9990   \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
9991   \def\utfeight{\csname UTF-8.enc\endcsname}%
9992   %
9993   \ifx \declaredencoding \ascii
9994      \asciichardefs
9995   %
9996   \else \ifx \declaredencoding \lattwo
9997      \iftxinativeunicodecapable
9998        \setbytewiseio
9999      \fi
10000      \setnonasciicharscatcode\active
10001      \lattwochardefs
10002   %
10003   \else \ifx \declaredencoding \latone
10004      \iftxinativeunicodecapable
10005        \setbytewiseio
10006      \fi
10007      \setnonasciicharscatcode\active
10008      \latonechardefs
10009   %
10010   \else \ifx \declaredencoding \latnine
10011      \iftxinativeunicodecapable
10012        \setbytewiseio
10013      \fi
10014      \setnonasciicharscatcode\active
10015      \latninechardefs
10016   %
10017   \else \ifx \declaredencoding \utfeight
10018      \iftxinativeunicodecapable
10019        % For native Unicode handling (XeTeX and LuaTeX)
10020        \nativeunicodechardefs
10021      \else
10022        % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX)
10023        \setnonasciicharscatcode\active
10024        % since we already invoked \utfeightchardefs at the top level
10025        % (below), do not re-invoke it, otherwise our check for duplicated
10026        % definitions gets triggered.  Making non-ascii chars active is
10027        % sufficient.
10028      \fi
10029   %
10030   \else
10031     \message{Ignoring unknown document encoding: #1.}%
10032   %
10033   \fi % utfeight
10034   \fi % latnine
10035   \fi % latone
10036   \fi % lattwo
10037   \fi % ascii
10038   %
10039   \ifx\XeTeXrevision\thisisundefined
10040   \else
10041     \ifx \declaredencoding \utfeight
10042     \else
10043       \ifx \declaredencoding \ascii
10044       \else
10045         \message{Warning: XeTeX with non-UTF-8 encodings cannot handle %
10046         non-ASCII characters in auxiliary files.}%
10047       \fi
10048     \fi
10049   \fi
10050 }
10051
10052 % emacs-page
10053 % A message to be logged when using a character that isn't available
10054 % the default font encoding (OT1).
10055 %
10056 \def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
10057
10058 % Take account of \c (plain) vs. \, (Texinfo) difference.
10059 \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
10060
10061 % First, make active non-ASCII characters in order for them to be
10062 % correctly categorized when TeX reads the replacement text of
10063 % macros containing the character definitions.
10064 \setnonasciicharscatcode\active
10065 %
10066
10067 \def\gdefchar#1#2{%
10068 \gdef#1{%
10069    \ifpassthroughchars
10070      \string#1%
10071    \else
10072      #2%
10073    \fi
10074 }}
10075
10076 % Latin1 (ISO-8859-1) character definitions.
10077 \def\latonechardefs{%
10078   \gdefchar^^a0{\tie}
10079   \gdefchar^^a1{\exclamdown}
10080   \gdefchar^^a2{{\tcfont \char162}} % cent
10081   \gdefchar^^a3{\pounds{}}
10082   \gdefchar^^a4{{\tcfont \char164}} % currency
10083   \gdefchar^^a5{{\tcfont \char165}} % yen
10084   \gdefchar^^a6{{\tcfont \char166}} % broken bar
10085   \gdefchar^^a7{\S}
10086   \gdefchar^^a8{\"{}}
10087   \gdefchar^^a9{\copyright{}}
10088   \gdefchar^^aa{\ordf}
10089   \gdefchar^^ab{\guillemetleft{}}
10090   \gdefchar^^ac{\ensuremath\lnot}
10091   \gdefchar^^ad{\-}
10092   \gdefchar^^ae{\registeredsymbol{}}
10093   \gdefchar^^af{\={}}
10094   %
10095   \gdefchar^^b0{\textdegree}
10096   \gdefchar^^b1{$\pm$}
10097   \gdefchar^^b2{$^2$}
10098   \gdefchar^^b3{$^3$}
10099   \gdefchar^^b4{\'{}}
10100   \gdefchar^^b5{$\mu$}
10101   \gdefchar^^b6{\P}
10102   \gdefchar^^b7{\ensuremath\cdot}
10103   \gdefchar^^b8{\cedilla\ }
10104   \gdefchar^^b9{$^1$}
10105   \gdefchar^^ba{\ordm}
10106   \gdefchar^^bb{\guillemetright{}}
10107   \gdefchar^^bc{$1\over4$}
10108   \gdefchar^^bd{$1\over2$}
10109   \gdefchar^^be{$3\over4$}
10110   \gdefchar^^bf{\questiondown}
10111   %
10112   \gdefchar^^c0{\`A}
10113   \gdefchar^^c1{\'A}
10114   \gdefchar^^c2{\^A}
10115   \gdefchar^^c3{\~A}
10116   \gdefchar^^c4{\"A}
10117   \gdefchar^^c5{\ringaccent A}
10118   \gdefchar^^c6{\AE}
10119   \gdefchar^^c7{\cedilla C}
10120   \gdefchar^^c8{\`E}
10121   \gdefchar^^c9{\'E}
10122   \gdefchar^^ca{\^E}
10123   \gdefchar^^cb{\"E}
10124   \gdefchar^^cc{\`I}
10125   \gdefchar^^cd{\'I}
10126   \gdefchar^^ce{\^I}
10127   \gdefchar^^cf{\"I}
10128   %
10129   \gdefchar^^d0{\DH}
10130   \gdefchar^^d1{\~N}
10131   \gdefchar^^d2{\`O}
10132   \gdefchar^^d3{\'O}
10133   \gdefchar^^d4{\^O}
10134   \gdefchar^^d5{\~O}
10135   \gdefchar^^d6{\"O}
10136   \gdefchar^^d7{$\times$}
10137   \gdefchar^^d8{\O}
10138   \gdefchar^^d9{\`U}
10139   \gdefchar^^da{\'U}
10140   \gdefchar^^db{\^U}
10141   \gdefchar^^dc{\"U}
10142   \gdefchar^^dd{\'Y}
10143   \gdefchar^^de{\TH}
10144   \gdefchar^^df{\ss}
10145   %
10146   \gdefchar^^e0{\`a}
10147   \gdefchar^^e1{\'a}
10148   \gdefchar^^e2{\^a}
10149   \gdefchar^^e3{\~a}
10150   \gdefchar^^e4{\"a}
10151   \gdefchar^^e5{\ringaccent a}
10152   \gdefchar^^e6{\ae}
10153   \gdefchar^^e7{\cedilla c}
10154   \gdefchar^^e8{\`e}
10155   \gdefchar^^e9{\'e}
10156   \gdefchar^^ea{\^e}
10157   \gdefchar^^eb{\"e}
10158   \gdefchar^^ec{\`{\dotless i}}
10159   \gdefchar^^ed{\'{\dotless i}}
10160   \gdefchar^^ee{\^{\dotless i}}
10161   \gdefchar^^ef{\"{\dotless i}}
10162   %
10163   \gdefchar^^f0{\dh}
10164   \gdefchar^^f1{\~n}
10165   \gdefchar^^f2{\`o}
10166   \gdefchar^^f3{\'o}
10167   \gdefchar^^f4{\^o}
10168   \gdefchar^^f5{\~o}
10169   \gdefchar^^f6{\"o}
10170   \gdefchar^^f7{$\div$}
10171   \gdefchar^^f8{\o}
10172   \gdefchar^^f9{\`u}
10173   \gdefchar^^fa{\'u}
10174   \gdefchar^^fb{\^u}
10175   \gdefchar^^fc{\"u}
10176   \gdefchar^^fd{\'y}
10177   \gdefchar^^fe{\th}
10178   \gdefchar^^ff{\"y}
10179 }
10180
10181 % Latin9 (ISO-8859-15) encoding character definitions.
10182 \def\latninechardefs{%
10183   % Encoding is almost identical to Latin1.
10184   \latonechardefs
10185   %
10186   \gdefchar^^a4{\euro{}}
10187   \gdefchar^^a6{\v S}
10188   \gdefchar^^a8{\v s}
10189   \gdefchar^^b4{\v Z}
10190   \gdefchar^^b8{\v z}
10191   \gdefchar^^bc{\OE}
10192   \gdefchar^^bd{\oe}
10193   \gdefchar^^be{\"Y}
10194 }
10195
10196 % Latin2 (ISO-8859-2) character definitions.
10197 \def\lattwochardefs{%
10198   \gdefchar^^a0{\tie}
10199   \gdefchar^^a1{\ogonek{A}}
10200   \gdefchar^^a2{\u{}}
10201   \gdefchar^^a3{\L}
10202   \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
10203   \gdefchar^^a5{\v L}
10204   \gdefchar^^a6{\'S}
10205   \gdefchar^^a7{\S}
10206   \gdefchar^^a8{\"{}}
10207   \gdefchar^^a9{\v S}
10208   \gdefchar^^aa{\cedilla S}
10209   \gdefchar^^ab{\v T}
10210   \gdefchar^^ac{\'Z}
10211   \gdefchar^^ad{\-}
10212   \gdefchar^^ae{\v Z}
10213   \gdefchar^^af{\dotaccent Z}
10214   %
10215   \gdefchar^^b0{\textdegree{}}
10216   \gdefchar^^b1{\ogonek{a}}
10217   \gdefchar^^b2{\ogonek{ }}
10218   \gdefchar^^b3{\l}
10219   \gdefchar^^b4{\'{}}
10220   \gdefchar^^b5{\v l}
10221   \gdefchar^^b6{\'s}
10222   \gdefchar^^b7{\v{}}
10223   \gdefchar^^b8{\cedilla\ }
10224   \gdefchar^^b9{\v s}
10225   \gdefchar^^ba{\cedilla s}
10226   \gdefchar^^bb{\v t}
10227   \gdefchar^^bc{\'z}
10228   \gdefchar^^bd{\H{}}
10229   \gdefchar^^be{\v z}
10230   \gdefchar^^bf{\dotaccent z}
10231   %
10232   \gdefchar^^c0{\'R}
10233   \gdefchar^^c1{\'A}
10234   \gdefchar^^c2{\^A}
10235   \gdefchar^^c3{\u A}
10236   \gdefchar^^c4{\"A}
10237   \gdefchar^^c5{\'L}
10238   \gdefchar^^c6{\'C}
10239   \gdefchar^^c7{\cedilla C}
10240   \gdefchar^^c8{\v C}
10241   \gdefchar^^c9{\'E}
10242   \gdefchar^^ca{\ogonek{E}}
10243   \gdefchar^^cb{\"E}
10244   \gdefchar^^cc{\v E}
10245   \gdefchar^^cd{\'I}
10246   \gdefchar^^ce{\^I}
10247   \gdefchar^^cf{\v D}
10248   %
10249   \gdefchar^^d0{\DH}
10250   \gdefchar^^d1{\'N}
10251   \gdefchar^^d2{\v N}
10252   \gdefchar^^d3{\'O}
10253   \gdefchar^^d4{\^O}
10254   \gdefchar^^d5{\H O}
10255   \gdefchar^^d6{\"O}
10256   \gdefchar^^d7{$\times$}
10257   \gdefchar^^d8{\v R}
10258   \gdefchar^^d9{\ringaccent U}
10259   \gdefchar^^da{\'U}
10260   \gdefchar^^db{\H U}
10261   \gdefchar^^dc{\"U}
10262   \gdefchar^^dd{\'Y}
10263   \gdefchar^^de{\cedilla T}
10264   \gdefchar^^df{\ss}
10265   %
10266   \gdefchar^^e0{\'r}
10267   \gdefchar^^e1{\'a}
10268   \gdefchar^^e2{\^a}
10269   \gdefchar^^e3{\u a}
10270   \gdefchar^^e4{\"a}
10271   \gdefchar^^e5{\'l}
10272   \gdefchar^^e6{\'c}
10273   \gdefchar^^e7{\cedilla c}
10274   \gdefchar^^e8{\v c}
10275   \gdefchar^^e9{\'e}
10276   \gdefchar^^ea{\ogonek{e}}
10277   \gdefchar^^eb{\"e}
10278   \gdefchar^^ec{\v e}
10279   \gdefchar^^ed{\'{\dotless{i}}}
10280   \gdefchar^^ee{\^{\dotless{i}}}
10281   \gdefchar^^ef{\v d}
10282   %
10283   \gdefchar^^f0{\dh}
10284   \gdefchar^^f1{\'n}
10285   \gdefchar^^f2{\v n}
10286   \gdefchar^^f3{\'o}
10287   \gdefchar^^f4{\^o}
10288   \gdefchar^^f5{\H o}
10289   \gdefchar^^f6{\"o}
10290   \gdefchar^^f7{$\div$}
10291   \gdefchar^^f8{\v r}
10292   \gdefchar^^f9{\ringaccent u}
10293   \gdefchar^^fa{\'u}
10294   \gdefchar^^fb{\H u}
10295   \gdefchar^^fc{\"u}
10296   \gdefchar^^fd{\'y}
10297   \gdefchar^^fe{\cedilla t}
10298   \gdefchar^^ff{\dotaccent{}}
10299 }
10300
10301 % UTF-8 character definitions.
10302 %
10303 % This code to support UTF-8 is based on LaTeX's utf8.def, with some
10304 % changes for Texinfo conventions.  It is included here under the GPL by
10305 % permission from Frank Mittelbach and the LaTeX team.
10306 %
10307 \newcount\countUTFx
10308 \newcount\countUTFy
10309 \newcount\countUTFz
10310
10311 \gdef\UTFviiiTwoOctets#1#2{\expandafter
10312    \UTFviiiDefined\csname u8:#1\string #2\endcsname}
10313 %
10314 \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
10315    \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
10316 %
10317 \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
10318    \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
10319
10320 \gdef\UTFviiiDefined#1{%
10321   \ifx #1\relax
10322     \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10323   \else
10324     \expandafter #1%
10325   \fi
10326 }
10327
10328 % Give non-ASCII bytes the active definitions for processing UTF-8 sequences
10329 \begingroup
10330   \catcode`\~13
10331   \catcode`\$12
10332   \catcode`\"12
10333
10334   % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
10335   % substituting ~ and $ with a character token of that value.
10336   \def\UTFviiiLoop{%
10337     \global\catcode\countUTFx\active
10338     \uccode`\~\countUTFx
10339     \uccode`\$\countUTFx
10340     \uppercase\expandafter{\UTFviiiTmp}%
10341     \advance\countUTFx by 1
10342     \ifnum\countUTFx < \countUTFy
10343       \expandafter\UTFviiiLoop
10344     \fi}
10345
10346   % For bytes other than the first in a UTF-8 sequence.  Not expected to
10347   % be expanded except when writing to auxiliary files.
10348   \countUTFx = "80
10349   \countUTFy = "C2
10350   \def\UTFviiiTmp{%
10351     \gdef~{%
10352         \ifpassthroughchars $\fi}}%
10353   \UTFviiiLoop
10354
10355   \countUTFx = "C2
10356   \countUTFy = "E0
10357   \def\UTFviiiTmp{%
10358     \gdef~{%
10359         \ifpassthroughchars $%
10360         \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
10361   \UTFviiiLoop
10362
10363   \countUTFx = "E0
10364   \countUTFy = "F0
10365   \def\UTFviiiTmp{%
10366     \gdef~{%
10367         \ifpassthroughchars $%
10368         \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
10369   \UTFviiiLoop
10370
10371   \countUTFx = "F0
10372   \countUTFy = "F4
10373   \def\UTFviiiTmp{%
10374     \gdef~{%
10375         \ifpassthroughchars $%
10376         \else\expandafter\UTFviiiFourOctets\expandafter$\fi
10377         }}%
10378   \UTFviiiLoop
10379 \endgroup
10380
10381 \def\globallet{\global\let} % save some \expandafter's below
10382
10383 % @U{xxxx} to produce U+xxxx, if we support it.
10384 \def\U#1{%
10385   \expandafter\ifx\csname uni:#1\endcsname \relax
10386     \iftxinativeunicodecapable
10387       % All Unicode characters can be used if native Unicode handling is
10388       % active.  However, if the font does not have the glyph,
10389       % letters are missing.
10390       \begingroup
10391         \uccode`\.="#1\relax
10392         \uppercase{.}
10393       \endgroup
10394     \else
10395       \errhelp = \EMsimple      
10396       \errmessage{Unicode character U+#1 not supported, sorry}%
10397     \fi
10398   \else
10399     \csname uni:#1\endcsname
10400   \fi
10401 }
10402
10403 % These macros are used here to construct the name of a control
10404 % sequence to be defined.
10405 \def\UTFviiiTwoOctetsName#1#2{%
10406   \csname u8:#1\string #2\endcsname}%
10407 \def\UTFviiiThreeOctetsName#1#2#3{%
10408   \csname u8:#1\string #2\string #3\endcsname}%
10409 \def\UTFviiiFourOctetsName#1#2#3#4{%
10410   \csname u8:#1\string #2\string #3\string #4\endcsname}%
10411
10412 % For UTF-8 byte sequences (TeX, e-TeX and pdfTeX),
10413 % provide a definition macro to replace a Unicode character;
10414 % this gets used by the @U command
10415 %
10416 \begingroup
10417   \catcode`\"=12
10418   \catcode`\<=12
10419   \catcode`\.=12
10420   \catcode`\,=12
10421   \catcode`\;=12
10422   \catcode`\!=12
10423   \catcode`\~=13
10424   \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
10425     \countUTFz = "#1\relax
10426     \begingroup
10427       \parseXMLCharref
10428     
10429       % Give \u8:... its definition.  The sequence of seven \expandafter's
10430       % expands after the \gdef three times, e.g.
10431       %
10432       % 1.  \UTFviiTwoOctetsName B1 B2
10433       % 2.  \csname u8:B1 \string B2 \endcsname
10434       % 3.  \u8: B1 B2  (a single control sequence token)
10435       %
10436       \expandafter\expandafter
10437       \expandafter\expandafter
10438       \expandafter\expandafter
10439       \expandafter\gdef       \UTFviiiTmp{#2}%
10440       % 
10441       \expandafter\ifx\csname uni:#1\endcsname \relax \else
10442        \message{Internal error, already defined: #1}%
10443       \fi
10444       %
10445       % define an additional control sequence for this code point.
10446       \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
10447     \endgroup}
10448   %
10449   % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp
10450   % to the corresponding UTF-8 sequence.
10451   \gdef\parseXMLCharref{%
10452     \ifnum\countUTFz < "A0\relax
10453       \errhelp = \EMsimple
10454       \errmessage{Cannot define Unicode char value < 00A0}%
10455     \else\ifnum\countUTFz < "800\relax
10456       \parseUTFviiiA,%
10457       \parseUTFviiiB C\UTFviiiTwoOctetsName.,%
10458     \else\ifnum\countUTFz < "10000\relax
10459       \parseUTFviiiA;%
10460       \parseUTFviiiA,%
10461       \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}%
10462     \else
10463       \parseUTFviiiA;%
10464       \parseUTFviiiA,%
10465       \parseUTFviiiA!%
10466       \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}%
10467     \fi\fi\fi
10468   }
10469
10470   % Extract a byte from the end of the UTF-8 representation of \countUTFx.
10471   % It must be a non-initial byte in the sequence.
10472   % Change \uccode of #1 for it to be used in \parseUTFviiiB as one
10473   % of the bytes.
10474   \gdef\parseUTFviiiA#1{%
10475     \countUTFx = \countUTFz
10476     \divide\countUTFz by 64
10477     \countUTFy = \countUTFz  % Save to be the future value of \countUTFz.
10478     \multiply\countUTFz by 64
10479     
10480     % \countUTFz is now \countUTFx with the last 5 bits cleared.  Subtract
10481     % in order to get the last five bits.
10482     \advance\countUTFx by -\countUTFz
10483
10484     % Convert this to the byte in the UTF-8 sequence.
10485     \advance\countUTFx by 128
10486     \uccode `#1\countUTFx
10487     \countUTFz = \countUTFy}
10488
10489   % Used to put a UTF-8 byte sequence into \UTFviiiTmp
10490   % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8
10491   %    sequence.
10492   % #2 is one of the \UTFviii*OctetsName macros.
10493   % #3 is always a full stop (.)
10494   % #4 is a template for the other bytes in the sequence.  The values for these
10495   %    bytes is substituted in here with \uppercase using the \uccode's.
10496   \gdef\parseUTFviiiB#1#2#3#4{%
10497     \advance\countUTFz by "#10\relax
10498     \uccode `#3\countUTFz
10499     \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10500 \endgroup
10501
10502 % For native Unicode handling (XeTeX and LuaTeX),
10503 % provide a definition macro that sets a catcode to `other' non-globally
10504 %
10505 \def\DeclareUnicodeCharacterNativeOther#1#2{%
10506   \catcode"#1=\other
10507 }
10508
10509 % https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10510 % U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10511 % U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10512 % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10513 % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10514
10515 % Many of our renditions are less than wonderful, and all the missing
10516 % characters are available somewhere.  Loading the necessary fonts
10517 % awaits user request.  We can't truly support Unicode without
10518 % reimplementing everything that's been done in LaTeX for many years,
10519 % plus probably using luatex or xetex, and who knows what else.
10520 % We won't be doing that here in this simple file.  But we can try to at
10521 % least make most of the characters not bomb out.
10522 %
10523 \def\unicodechardefs{%
10524   \DeclareUnicodeCharacter{00A0}{\tie}%
10525   \DeclareUnicodeCharacter{00A1}{\exclamdown}%
10526   \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
10527   \DeclareUnicodeCharacter{00A3}{\pounds{}}%
10528   \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10529   \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10530   \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
10531   \DeclareUnicodeCharacter{00A7}{\S}%
10532   \DeclareUnicodeCharacter{00A8}{\"{ }}%
10533   \DeclareUnicodeCharacter{00A9}{\copyright{}}%
10534   \DeclareUnicodeCharacter{00AA}{\ordf}%
10535   \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}%
10536   \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10537   \DeclareUnicodeCharacter{00AD}{\-}%
10538   \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}%
10539   \DeclareUnicodeCharacter{00AF}{\={ }}%
10540   %
10541   \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
10542   \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10543   \DeclareUnicodeCharacter{00B2}{$^2$}%
10544   \DeclareUnicodeCharacter{00B3}{$^3$}%
10545   \DeclareUnicodeCharacter{00B4}{\'{ }}%
10546   \DeclareUnicodeCharacter{00B5}{$\mu$}%
10547   \DeclareUnicodeCharacter{00B6}{\P}%
10548   \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10549   \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10550   \DeclareUnicodeCharacter{00B9}{$^1$}%
10551   \DeclareUnicodeCharacter{00BA}{\ordm}%
10552   \DeclareUnicodeCharacter{00BB}{\guillemetright{}}%
10553   \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10554   \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10555   \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10556   \DeclareUnicodeCharacter{00BF}{\questiondown}%
10557   %
10558   \DeclareUnicodeCharacter{00C0}{\`A}%
10559   \DeclareUnicodeCharacter{00C1}{\'A}%
10560   \DeclareUnicodeCharacter{00C2}{\^A}%
10561   \DeclareUnicodeCharacter{00C3}{\~A}%
10562   \DeclareUnicodeCharacter{00C4}{\"A}%
10563   \DeclareUnicodeCharacter{00C5}{\AA}%
10564   \DeclareUnicodeCharacter{00C6}{\AE}%
10565   \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10566   \DeclareUnicodeCharacter{00C8}{\`E}%
10567   \DeclareUnicodeCharacter{00C9}{\'E}%
10568   \DeclareUnicodeCharacter{00CA}{\^E}%
10569   \DeclareUnicodeCharacter{00CB}{\"E}%
10570   \DeclareUnicodeCharacter{00CC}{\`I}%
10571   \DeclareUnicodeCharacter{00CD}{\'I}%
10572   \DeclareUnicodeCharacter{00CE}{\^I}%
10573   \DeclareUnicodeCharacter{00CF}{\"I}%
10574   %
10575   \DeclareUnicodeCharacter{00D0}{\DH}%
10576   \DeclareUnicodeCharacter{00D1}{\~N}%
10577   \DeclareUnicodeCharacter{00D2}{\`O}%
10578   \DeclareUnicodeCharacter{00D3}{\'O}%
10579   \DeclareUnicodeCharacter{00D4}{\^O}%
10580   \DeclareUnicodeCharacter{00D5}{\~O}%
10581   \DeclareUnicodeCharacter{00D6}{\"O}%
10582   \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10583   \DeclareUnicodeCharacter{00D8}{\O}%
10584   \DeclareUnicodeCharacter{00D9}{\`U}%
10585   \DeclareUnicodeCharacter{00DA}{\'U}%
10586   \DeclareUnicodeCharacter{00DB}{\^U}%
10587   \DeclareUnicodeCharacter{00DC}{\"U}%
10588   \DeclareUnicodeCharacter{00DD}{\'Y}%
10589   \DeclareUnicodeCharacter{00DE}{\TH}%
10590   \DeclareUnicodeCharacter{00DF}{\ss}%
10591   %
10592   \DeclareUnicodeCharacter{00E0}{\`a}%
10593   \DeclareUnicodeCharacter{00E1}{\'a}%
10594   \DeclareUnicodeCharacter{00E2}{\^a}%
10595   \DeclareUnicodeCharacter{00E3}{\~a}%
10596   \DeclareUnicodeCharacter{00E4}{\"a}%
10597   \DeclareUnicodeCharacter{00E5}{\aa}%
10598   \DeclareUnicodeCharacter{00E6}{\ae}%
10599   \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10600   \DeclareUnicodeCharacter{00E8}{\`e}%
10601   \DeclareUnicodeCharacter{00E9}{\'e}%
10602   \DeclareUnicodeCharacter{00EA}{\^e}%
10603   \DeclareUnicodeCharacter{00EB}{\"e}%
10604   \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10605   \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10606   \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10607   \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10608   %
10609   \DeclareUnicodeCharacter{00F0}{\dh}%
10610   \DeclareUnicodeCharacter{00F1}{\~n}%
10611   \DeclareUnicodeCharacter{00F2}{\`o}%
10612   \DeclareUnicodeCharacter{00F3}{\'o}%
10613   \DeclareUnicodeCharacter{00F4}{\^o}%
10614   \DeclareUnicodeCharacter{00F5}{\~o}%
10615   \DeclareUnicodeCharacter{00F6}{\"o}%
10616   \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10617   \DeclareUnicodeCharacter{00F8}{\o}%
10618   \DeclareUnicodeCharacter{00F9}{\`u}%
10619   \DeclareUnicodeCharacter{00FA}{\'u}%
10620   \DeclareUnicodeCharacter{00FB}{\^u}%
10621   \DeclareUnicodeCharacter{00FC}{\"u}%
10622   \DeclareUnicodeCharacter{00FD}{\'y}%
10623   \DeclareUnicodeCharacter{00FE}{\th}%
10624   \DeclareUnicodeCharacter{00FF}{\"y}%
10625   %
10626   \DeclareUnicodeCharacter{0100}{\=A}%
10627   \DeclareUnicodeCharacter{0101}{\=a}%
10628   \DeclareUnicodeCharacter{0102}{\u{A}}%
10629   \DeclareUnicodeCharacter{0103}{\u{a}}%
10630   \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10631   \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10632   \DeclareUnicodeCharacter{0106}{\'C}%
10633   \DeclareUnicodeCharacter{0107}{\'c}%
10634   \DeclareUnicodeCharacter{0108}{\^C}%
10635   \DeclareUnicodeCharacter{0109}{\^c}%
10636   \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10637   \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10638   \DeclareUnicodeCharacter{010C}{\v{C}}%
10639   \DeclareUnicodeCharacter{010D}{\v{c}}%
10640   \DeclareUnicodeCharacter{010E}{\v{D}}%
10641   \DeclareUnicodeCharacter{010F}{d'}%
10642   %
10643   \DeclareUnicodeCharacter{0110}{\DH}%
10644   \DeclareUnicodeCharacter{0111}{\dh}%
10645   \DeclareUnicodeCharacter{0112}{\=E}%
10646   \DeclareUnicodeCharacter{0113}{\=e}%
10647   \DeclareUnicodeCharacter{0114}{\u{E}}%
10648   \DeclareUnicodeCharacter{0115}{\u{e}}%
10649   \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10650   \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10651   \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10652   \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10653   \DeclareUnicodeCharacter{011A}{\v{E}}%
10654   \DeclareUnicodeCharacter{011B}{\v{e}}%
10655   \DeclareUnicodeCharacter{011C}{\^G}%
10656   \DeclareUnicodeCharacter{011D}{\^g}%
10657   \DeclareUnicodeCharacter{011E}{\u{G}}%
10658   \DeclareUnicodeCharacter{011F}{\u{g}}%
10659   %
10660   \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10661   \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10662   \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10663   \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10664   \DeclareUnicodeCharacter{0124}{\^H}%
10665   \DeclareUnicodeCharacter{0125}{\^h}%
10666   \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10667   \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10668   \DeclareUnicodeCharacter{0128}{\~I}%
10669   \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10670   \DeclareUnicodeCharacter{012A}{\=I}%
10671   \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10672   \DeclareUnicodeCharacter{012C}{\u{I}}%
10673   \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10674   \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10675   \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10676   %
10677   \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10678   \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10679   \DeclareUnicodeCharacter{0132}{IJ}%
10680   \DeclareUnicodeCharacter{0133}{ij}%
10681   \DeclareUnicodeCharacter{0134}{\^J}%
10682   \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10683   \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10684   \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10685   \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10686   \DeclareUnicodeCharacter{0139}{\'L}%
10687   \DeclareUnicodeCharacter{013A}{\'l}%
10688   \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10689   \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
10690   \DeclareUnicodeCharacter{013D}{L'}% should kern
10691   \DeclareUnicodeCharacter{013E}{l'}% should kern
10692   \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10693   %
10694   \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10695   \DeclareUnicodeCharacter{0141}{\L}%
10696   \DeclareUnicodeCharacter{0142}{\l}%
10697   \DeclareUnicodeCharacter{0143}{\'N}%
10698   \DeclareUnicodeCharacter{0144}{\'n}%
10699   \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10700   \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10701   \DeclareUnicodeCharacter{0147}{\v{N}}%
10702   \DeclareUnicodeCharacter{0148}{\v{n}}%
10703   \DeclareUnicodeCharacter{0149}{'n}%
10704   \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10705   \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10706   \DeclareUnicodeCharacter{014C}{\=O}%
10707   \DeclareUnicodeCharacter{014D}{\=o}%
10708   \DeclareUnicodeCharacter{014E}{\u{O}}%
10709   \DeclareUnicodeCharacter{014F}{\u{o}}%
10710   %
10711   \DeclareUnicodeCharacter{0150}{\H{O}}%
10712   \DeclareUnicodeCharacter{0151}{\H{o}}%
10713   \DeclareUnicodeCharacter{0152}{\OE}%
10714   \DeclareUnicodeCharacter{0153}{\oe}%
10715   \DeclareUnicodeCharacter{0154}{\'R}%
10716   \DeclareUnicodeCharacter{0155}{\'r}%
10717   \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10718   \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10719   \DeclareUnicodeCharacter{0158}{\v{R}}%
10720   \DeclareUnicodeCharacter{0159}{\v{r}}%
10721   \DeclareUnicodeCharacter{015A}{\'S}%
10722   \DeclareUnicodeCharacter{015B}{\'s}%
10723   \DeclareUnicodeCharacter{015C}{\^S}%
10724   \DeclareUnicodeCharacter{015D}{\^s}%
10725   \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10726   \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10727   %
10728   \DeclareUnicodeCharacter{0160}{\v{S}}%
10729   \DeclareUnicodeCharacter{0161}{\v{s}}%
10730   \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10731   \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10732   \DeclareUnicodeCharacter{0164}{\v{T}}%
10733   \DeclareUnicodeCharacter{0165}{\v{t}}%
10734   \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10735   \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10736   \DeclareUnicodeCharacter{0168}{\~U}%
10737   \DeclareUnicodeCharacter{0169}{\~u}%
10738   \DeclareUnicodeCharacter{016A}{\=U}%
10739   \DeclareUnicodeCharacter{016B}{\=u}%
10740   \DeclareUnicodeCharacter{016C}{\u{U}}%
10741   \DeclareUnicodeCharacter{016D}{\u{u}}%
10742   \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10743   \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10744   %
10745   \DeclareUnicodeCharacter{0170}{\H{U}}%
10746   \DeclareUnicodeCharacter{0171}{\H{u}}%
10747   \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10748   \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10749   \DeclareUnicodeCharacter{0174}{\^W}%
10750   \DeclareUnicodeCharacter{0175}{\^w}%
10751   \DeclareUnicodeCharacter{0176}{\^Y}%
10752   \DeclareUnicodeCharacter{0177}{\^y}%
10753   \DeclareUnicodeCharacter{0178}{\"Y}%
10754   \DeclareUnicodeCharacter{0179}{\'Z}%
10755   \DeclareUnicodeCharacter{017A}{\'z}%
10756   \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10757   \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10758   \DeclareUnicodeCharacter{017D}{\v{Z}}%
10759   \DeclareUnicodeCharacter{017E}{\v{z}}%
10760   \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10761   %
10762   \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10763   \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10764   \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10765   \DeclareUnicodeCharacter{01C7}{LJ}%
10766   \DeclareUnicodeCharacter{01C8}{Lj}%
10767   \DeclareUnicodeCharacter{01C9}{lj}%
10768   \DeclareUnicodeCharacter{01CA}{NJ}%
10769   \DeclareUnicodeCharacter{01CB}{Nj}%
10770   \DeclareUnicodeCharacter{01CC}{nj}%
10771   \DeclareUnicodeCharacter{01CD}{\v{A}}%
10772   \DeclareUnicodeCharacter{01CE}{\v{a}}%
10773   \DeclareUnicodeCharacter{01CF}{\v{I}}%
10774   %
10775   \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10776   \DeclareUnicodeCharacter{01D1}{\v{O}}%
10777   \DeclareUnicodeCharacter{01D2}{\v{o}}%
10778   \DeclareUnicodeCharacter{01D3}{\v{U}}%
10779   \DeclareUnicodeCharacter{01D4}{\v{u}}%
10780   %
10781   \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10782   \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10783   \DeclareUnicodeCharacter{01E6}{\v{G}}%
10784   \DeclareUnicodeCharacter{01E7}{\v{g}}%
10785   \DeclareUnicodeCharacter{01E8}{\v{K}}%
10786   \DeclareUnicodeCharacter{01E9}{\v{k}}%
10787   %
10788   \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10789   \DeclareUnicodeCharacter{01F1}{DZ}%
10790   \DeclareUnicodeCharacter{01F2}{Dz}%
10791   \DeclareUnicodeCharacter{01F3}{dz}%
10792   \DeclareUnicodeCharacter{01F4}{\'G}%
10793   \DeclareUnicodeCharacter{01F5}{\'g}%
10794   \DeclareUnicodeCharacter{01F8}{\`N}%
10795   \DeclareUnicodeCharacter{01F9}{\`n}%
10796   \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10797   \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10798   \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10799   \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10800   %
10801   \DeclareUnicodeCharacter{021E}{\v{H}}%
10802   \DeclareUnicodeCharacter{021F}{\v{h}}%
10803   %
10804   \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10805   \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10806   \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10807   \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10808   \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10809   \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10810   %
10811   \DeclareUnicodeCharacter{0232}{\=Y}%
10812   \DeclareUnicodeCharacter{0233}{\=y}%
10813   \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10814   %
10815   \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10816   %
10817   % Greek letters upper case
10818   \DeclareUnicodeCharacter{0391}{{\it A}}%
10819   \DeclareUnicodeCharacter{0392}{{\it B}}%
10820   \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10821   \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10822   \DeclareUnicodeCharacter{0395}{{\it E}}%
10823   \DeclareUnicodeCharacter{0396}{{\it Z}}%
10824   \DeclareUnicodeCharacter{0397}{{\it H}}%
10825   \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10826   \DeclareUnicodeCharacter{0399}{{\it I}}%
10827   \DeclareUnicodeCharacter{039A}{{\it K}}%
10828   \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10829   \DeclareUnicodeCharacter{039C}{{\it M}}%
10830   \DeclareUnicodeCharacter{039D}{{\it N}}%
10831   \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10832   \DeclareUnicodeCharacter{039F}{{\it O}}%
10833   \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10834   \DeclareUnicodeCharacter{03A1}{{\it P}}%
10835   %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
10836   \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10837   \DeclareUnicodeCharacter{03A4}{{\it T}}%
10838   \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10839   \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10840   \DeclareUnicodeCharacter{03A7}{{\it X}}%
10841   \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10842   \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10843   %
10844   % Vowels with accents
10845   \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10846   \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10847   \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10848   \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10849   \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10850   \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10851   %
10852   % Standalone accent
10853   \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10854   %
10855   % Greek letters lower case
10856   \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10857   \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10858   \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10859   \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10860   \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10861   \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10862   \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10863   \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10864   \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10865   \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10866   \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10867   \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10868   \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10869   \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10870   \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10871   \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10872   \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10873   \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10874   \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10875   \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10876   \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10877   \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10878   \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10879   \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10880   \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10881   %
10882   % More Greek vowels with accents
10883   \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10884   \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10885   \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10886   \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10887   \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10888   %
10889   % Variant Greek letters
10890   \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10891   \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10892   \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10893   %
10894   \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10895   \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10896   \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10897   \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10898   \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10899   \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10900   \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10901   \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10902   \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10903   \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10904   \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10905   \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10906   %
10907   \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10908   \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10909   %
10910   \DeclareUnicodeCharacter{1E20}{\=G}%
10911   \DeclareUnicodeCharacter{1E21}{\=g}%
10912   \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10913   \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10914   \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10915   \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10916   \DeclareUnicodeCharacter{1E26}{\"H}%
10917   \DeclareUnicodeCharacter{1E27}{\"h}%
10918   %
10919   \DeclareUnicodeCharacter{1E30}{\'K}%
10920   \DeclareUnicodeCharacter{1E31}{\'k}%
10921   \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10922   \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10923   \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10924   \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10925   \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10926   \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10927   \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10928   \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10929   \DeclareUnicodeCharacter{1E3E}{\'M}%
10930   \DeclareUnicodeCharacter{1E3F}{\'m}%
10931   %
10932   \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10933   \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10934   \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10935   \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10936   \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10937   \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10938   \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10939   \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10940   \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10941   \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10942   %
10943   \DeclareUnicodeCharacter{1E54}{\'P}%
10944   \DeclareUnicodeCharacter{1E55}{\'p}%
10945   \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10946   \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10947   \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10948   \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10949   \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10950   \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10951   \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10952   \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10953   %
10954   \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10955   \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10956   \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10957   \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10958   \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10959   \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10960   \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10961   \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10962   \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10963   \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10964   %
10965   \DeclareUnicodeCharacter{1E7C}{\~V}%
10966   \DeclareUnicodeCharacter{1E7D}{\~v}%
10967   \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10968   \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10969   %
10970   \DeclareUnicodeCharacter{1E80}{\`W}%
10971   \DeclareUnicodeCharacter{1E81}{\`w}%
10972   \DeclareUnicodeCharacter{1E82}{\'W}%
10973   \DeclareUnicodeCharacter{1E83}{\'w}%
10974   \DeclareUnicodeCharacter{1E84}{\"W}%
10975   \DeclareUnicodeCharacter{1E85}{\"w}%
10976   \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10977   \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10978   \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10979   \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10980   \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10981   \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10982   \DeclareUnicodeCharacter{1E8C}{\"X}%
10983   \DeclareUnicodeCharacter{1E8D}{\"x}%
10984   \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10985   \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10986   %
10987   \DeclareUnicodeCharacter{1E90}{\^Z}%
10988   \DeclareUnicodeCharacter{1E91}{\^z}%
10989   \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
10990   \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
10991   \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
10992   \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
10993   \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
10994   \DeclareUnicodeCharacter{1E97}{\"t}%
10995   \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
10996   \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
10997   %
10998   \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
10999   \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
11000   %
11001   \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
11002   \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
11003   \DeclareUnicodeCharacter{1EBC}{\~E}%
11004   \DeclareUnicodeCharacter{1EBD}{\~e}%
11005   %
11006   \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
11007   \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
11008   \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
11009   \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
11010   %
11011   \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
11012   \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
11013   %
11014   \DeclareUnicodeCharacter{1EF2}{\`Y}%
11015   \DeclareUnicodeCharacter{1EF3}{\`y}%
11016   \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
11017   %
11018   \DeclareUnicodeCharacter{1EF8}{\~Y}%
11019   \DeclareUnicodeCharacter{1EF9}{\~y}%
11020   %
11021   % Punctuation
11022   \DeclareUnicodeCharacter{2013}{--}%
11023   \DeclareUnicodeCharacter{2014}{---}%
11024   \DeclareUnicodeCharacter{2018}{\quoteleft{}}%
11025   \DeclareUnicodeCharacter{2019}{\quoteright{}}%
11026   \DeclareUnicodeCharacter{201A}{\quotesinglbase{}}%
11027   \DeclareUnicodeCharacter{201C}{\quotedblleft{}}%
11028   \DeclareUnicodeCharacter{201D}{\quotedblright{}}%
11029   \DeclareUnicodeCharacter{201E}{\quotedblbase{}}%
11030   \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}%
11031   \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}%
11032   \DeclareUnicodeCharacter{2022}{\bullet{}}%
11033   \DeclareUnicodeCharacter{202F}{\thinspace}%
11034   \DeclareUnicodeCharacter{2026}{\dots{}}%
11035   \DeclareUnicodeCharacter{2039}{\guilsinglleft{}}%
11036   \DeclareUnicodeCharacter{203A}{\guilsinglright{}}%
11037   %
11038   \DeclareUnicodeCharacter{20AC}{\euro{}}%
11039   %
11040   \DeclareUnicodeCharacter{2192}{\expansion{}}%
11041   \DeclareUnicodeCharacter{21D2}{\result{}}%
11042   %
11043   % Mathematical symbols
11044   \DeclareUnicodeCharacter{2200}{\ensuremath\forall}%
11045   \DeclareUnicodeCharacter{2203}{\ensuremath\exists}%
11046   \DeclareUnicodeCharacter{2208}{\ensuremath\in}%
11047   \DeclareUnicodeCharacter{2212}{\minus{}}%
11048   \DeclareUnicodeCharacter{2217}{\ast}%
11049   \DeclareUnicodeCharacter{221E}{\ensuremath\infty}%
11050   \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}%
11051   \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}%
11052   \DeclareUnicodeCharacter{2229}{\ensuremath\cap}%
11053   \DeclareUnicodeCharacter{2261}{\equiv{}}%
11054   \DeclareUnicodeCharacter{2264}{\ensuremath\leq}%
11055   \DeclareUnicodeCharacter{2265}{\ensuremath\geq}%
11056   \DeclareUnicodeCharacter{2282}{\ensuremath\subset}%
11057   \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}%
11058   %
11059   \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}%
11060   \DeclareUnicodeCharacter{2032}{\ensuremath\prime}%
11061   \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}%
11062   \DeclareUnicodeCharacter{2111}{\ensuremath\Im}%
11063   \DeclareUnicodeCharacter{2113}{\ensuremath\ell}%
11064   \DeclareUnicodeCharacter{2118}{\ensuremath\wp}%
11065   \DeclareUnicodeCharacter{211C}{\ensuremath\Re}%
11066   \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}%
11067   \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}%
11068   \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}%
11069   \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}%
11070   \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}%
11071   \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}%
11072   \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}%
11073   \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}%
11074   \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}%
11075   \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}%
11076   \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}%
11077   \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}%
11078   \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}%
11079   \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}%
11080   \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}%
11081   \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}%
11082   \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}%
11083   \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}%
11084   \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}%
11085   \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}%
11086   \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}%
11087   \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}%
11088   \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}%
11089   \DeclareUnicodeCharacter{2202}{\ensuremath\partial}%
11090   \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}%
11091   \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}%
11092   \DeclareUnicodeCharacter{2209}{\ensuremath\notin}%
11093   \DeclareUnicodeCharacter{220B}{\ensuremath\owns}%
11094   \DeclareUnicodeCharacter{220F}{\ensuremath\prod}%
11095   \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}%
11096   \DeclareUnicodeCharacter{2211}{\ensuremath\sum}%
11097   \DeclareUnicodeCharacter{2213}{\ensuremath\mp}%
11098   \DeclareUnicodeCharacter{2218}{\ensuremath\circ}%
11099   \DeclareUnicodeCharacter{221A}{\ensuremath\surd}%
11100   \DeclareUnicodeCharacter{221D}{\ensuremath\propto}%
11101   \DeclareUnicodeCharacter{2220}{\ensuremath\angle}%
11102   \DeclareUnicodeCharacter{2223}{\ensuremath\mid}%
11103   \DeclareUnicodeCharacter{2228}{\ensuremath\vee}%
11104   \DeclareUnicodeCharacter{222A}{\ensuremath\cup}%
11105   \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}%
11106   \DeclareUnicodeCharacter{222E}{\ensuremath\oint}%
11107   \DeclareUnicodeCharacter{223C}{\ensuremath\sim}%
11108   \DeclareUnicodeCharacter{2240}{\ensuremath\wr}%
11109   \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}%
11110   \DeclareUnicodeCharacter{2245}{\ensuremath\cong}%
11111   \DeclareUnicodeCharacter{2248}{\ensuremath\approx}%
11112   \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}%
11113   \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}%
11114   \DeclareUnicodeCharacter{2260}{\ensuremath\neq}%
11115   \DeclareUnicodeCharacter{226A}{\ensuremath\ll}%
11116   \DeclareUnicodeCharacter{226B}{\ensuremath\gg}%
11117   \DeclareUnicodeCharacter{227A}{\ensuremath\prec}%
11118   \DeclareUnicodeCharacter{227B}{\ensuremath\succ}%
11119   \DeclareUnicodeCharacter{2283}{\ensuremath\supset}%
11120   \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}%
11121   \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}%
11122   \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}%
11123   \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}%
11124   \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}%
11125   \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}%
11126   \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}%
11127   \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}%
11128   \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}%
11129   \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}%
11130   \DeclareUnicodeCharacter{2299}{\ensuremath\odot}%
11131   \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}%
11132   \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}%
11133   \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}%
11134   \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}%
11135   \DeclareUnicodeCharacter{22A8}{\ensuremath\models}%
11136   \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}%
11137   \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}%
11138   \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}%
11139   \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}%
11140   \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}%
11141   \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}%
11142   \DeclareUnicodeCharacter{22C6}{\ensuremath\star}%
11143   \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}%
11144   \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}%
11145   \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}%
11146   \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}%
11147   \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}%
11148   \DeclareUnicodeCharacter{2322}{\ensuremath\frown}%
11149   \DeclareUnicodeCharacter{2323}{\ensuremath\smile}%
11150   %
11151   \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
11152   \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
11153   \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
11154   \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
11155   \DeclareUnicodeCharacter{25C7}{\ensuremath\diamond}%
11156   \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}%
11157   \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}%
11158   \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}%
11159   \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}%
11160   \DeclareUnicodeCharacter{266D}{\ensuremath\flat}%
11161   \DeclareUnicodeCharacter{266E}{\ensuremath\natural}%
11162   \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}%
11163   \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}%
11164   \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}%
11165   \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}%
11166   \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}%
11167   \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}%
11168   \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}%
11169   \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}%
11170   \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}%
11171   \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}%
11172   \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}%
11173   \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}%
11174   \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}%
11175   \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}%
11176   \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}%
11177   \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}%
11178   \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}%
11179   \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}%
11180   %
11181   \global\mathchardef\checkmark="1370% actually the square root sign
11182   \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}%
11183 }% end of \unicodechardefs
11184
11185 % UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
11186 % It makes the setting that replace UTF-8 byte sequence.
11187 \def\utfeightchardefs{%
11188   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
11189   \unicodechardefs
11190 }
11191
11192 % Whether the active definitions of non-ASCII characters expand to
11193 % non-active tokens with the same character code.  This is used to
11194 % write characters literally, instead of using active definitions for
11195 % printing the correct glyphs.
11196 \newif\ifpassthroughchars
11197 \passthroughcharsfalse
11198
11199 % For native Unicode handling (XeTeX and LuaTeX),
11200 % provide a definition macro to replace/pass-through a Unicode character
11201 %
11202 \def\DeclareUnicodeCharacterNative#1#2{%
11203   \catcode"#1=\active
11204   \def\dodeclareunicodecharacternative##1##2##3{%
11205     \begingroup
11206       \uccode`\~="##2\relax
11207       \uppercase{\gdef~}{%
11208         \ifpassthroughchars
11209           ##1%
11210         \else
11211           ##3%
11212         \fi
11213       }
11214     \endgroup
11215   }
11216   \begingroup
11217     \uccode`\.="#1\relax
11218     \uppercase{\def\UTFNativeTmp{.}}%
11219     \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
11220   \endgroup
11221 }
11222
11223 % Native Unicode handling (XeTeX and LuaTeX) character replacing definition.
11224 % It activates the setting that replaces Unicode characters.
11225 \def\nativeunicodechardefs{%
11226   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
11227   \unicodechardefs
11228 }
11229
11230 % For native Unicode handling (XeTeX and LuaTeX),
11231 % make the character token expand
11232 % to the sequences given in \unicodechardefs for printing.
11233 \def\DeclareUnicodeCharacterNativeAtU#1#2{%
11234   \def\UTFAtUTmp{#2}
11235   \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
11236 }
11237
11238 % @U command definitions for native Unicode handling (XeTeX and LuaTeX).
11239 \def\nativeunicodechardefsatu{%
11240   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
11241   \unicodechardefs
11242 }
11243
11244 % US-ASCII character definitions.
11245 \def\asciichardefs{% nothing need be done
11246    \relax
11247 }
11248
11249 % define all Unicode characters we know about, for the sake of @U.
11250 \iftxinativeunicodecapable
11251   \nativeunicodechardefsatu
11252 \else
11253   \utfeightchardefs
11254 \fi
11255
11256
11257 % Make non-ASCII characters printable again for compatibility with
11258 % existing Texinfo documents that may use them, even without declaring a
11259 % document encoding.
11260 %
11261 \setnonasciicharscatcode \other
11262
11263
11264 \message{formatting,}
11265
11266 \newdimen\defaultparindent \defaultparindent = 15pt
11267
11268 \chapheadingskip = 15pt plus 4pt minus 2pt
11269 \secheadingskip = 12pt plus 3pt minus 2pt
11270 \subsecheadingskip = 9pt plus 2pt minus 2pt
11271
11272 % Prevent underfull vbox error messages.
11273 \vbadness = 10000
11274
11275 % Don't be very finicky about underfull hboxes, either.
11276 \hbadness = 6666
11277
11278 % Following George Bush, get rid of widows and orphans.
11279 \widowpenalty=10000
11280 \clubpenalty=10000
11281
11282 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
11283 % using an old version of TeX, don't do anything.  We want the amount of
11284 % stretch added to depend on the line length, hence the dependence on
11285 % \hsize.  We call this whenever the paper size is set.
11286 %
11287 \def\setemergencystretch{%
11288   \ifx\emergencystretch\thisisundefined
11289     % Allow us to assign to \emergencystretch anyway.
11290     \def\emergencystretch{\dimen0}%
11291   \else
11292     \emergencystretch = .15\hsize
11293   \fi
11294 }
11295
11296 % Parameters in order: 1) textheight; 2) textwidth;
11297 % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11298 % 7) physical page height; 8) physical page width.
11299 %
11300 % We also call \setleading{\textleading}, so the caller should define
11301 % \textleading.  The caller should also set \parskip.
11302 %
11303 \def\internalpagesizes#1#2#3#4#5#6#7#8{%
11304   \voffset = #3\relax
11305   \topskip = #6\relax
11306   \splittopskip = \topskip
11307   %
11308   \vsize = #1\relax
11309   \advance\vsize by \topskip
11310   \outervsize = \vsize
11311   \advance\outervsize by 2\topandbottommargin
11312   \txipageheight = \vsize
11313   %
11314   \hsize = #2\relax
11315   \outerhsize = \hsize
11316   \advance\outerhsize by 0.5in
11317   \txipagewidth = \hsize
11318   %
11319   \normaloffset = #4\relax
11320   \bindingoffset = #5\relax
11321   %
11322   \ifpdf
11323     \pdfpageheight #7\relax
11324     \pdfpagewidth #8\relax
11325     % if we don't reset these, they will remain at "1 true in" of
11326     % whatever layout pdftex was dumped with.
11327     \pdfhorigin = 1 true in
11328     \pdfvorigin = 1 true in
11329   \else
11330     \ifx\XeTeXrevision\thisisundefined
11331       \special{papersize=#8,#7}%
11332     \else
11333       \pdfpageheight #7\relax
11334       \pdfpagewidth #8\relax
11335       % XeTeX does not have \pdfhorigin and \pdfvorigin.
11336     \fi
11337   \fi
11338   %
11339   \setleading{\textleading}
11340   %
11341   \parindent = \defaultparindent
11342   \setemergencystretch
11343 }
11344
11345 % @letterpaper (the default).
11346 \def\letterpaper{{\globaldefs = 1
11347   \parskip = 3pt plus 2pt minus 1pt
11348   \textleading = 13.2pt
11349   %
11350   % If page is nothing but text, make it come out even.
11351   \internalpagesizes{607.2pt}{6in}% that's 46 lines
11352                     {\voffset}{.25in}%
11353                     {\bindingoffset}{36pt}%
11354                     {11in}{8.5in}%
11355 }}
11356
11357 % Use @smallbook to reset parameters for 7x9.25 trim size.
11358 \def\smallbook{{\globaldefs = 1
11359   \parskip = 2pt plus 1pt
11360   \textleading = 12pt
11361   %
11362   \internalpagesizes{7.5in}{5in}%
11363                     {-.2in}{0in}%
11364                     {\bindingoffset}{16pt}%
11365                     {9.25in}{7in}%
11366   %
11367   \lispnarrowing = 0.3in
11368   \tolerance = 700
11369   \contentsrightmargin = 0pt
11370   \defbodyindent = .5cm
11371 }}
11372
11373 % Use @smallerbook to reset parameters for 6x9 trim size.
11374 % (Just testing, parameters still in flux.)
11375 \def\smallerbook{{\globaldefs = 1
11376   \parskip = 1.5pt plus 1pt
11377   \textleading = 12pt
11378   %
11379   \internalpagesizes{7.4in}{4.8in}%
11380                     {-.2in}{-.4in}%
11381                     {0pt}{14pt}%
11382                     {9in}{6in}%
11383   %
11384   \lispnarrowing = 0.25in
11385   \tolerance = 700
11386   \contentsrightmargin = 0pt
11387   \defbodyindent = .4cm
11388 }}
11389
11390 % Use @afourpaper to print on European A4 paper.
11391 \def\afourpaper{{\globaldefs = 1
11392   \parskip = 3pt plus 2pt minus 1pt
11393   \textleading = 13.2pt
11394   %
11395   % Double-side printing via postscript on Laserjet 4050
11396   % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11397   % To change the settings for a different printer or situation, adjust
11398   % \normaloffset until the front-side and back-side texts align.  Then
11399   % do the same for \bindingoffset.  You can set these for testing in
11400   % your texinfo source file like this:
11401   % @tex
11402   % \global\normaloffset = -6mm
11403   % \global\bindingoffset = 10mm
11404   % @end tex
11405   \internalpagesizes{673.2pt}{160mm}% that's 51 lines
11406                     {\voffset}{\hoffset}%
11407                     {\bindingoffset}{44pt}%
11408                     {297mm}{210mm}%
11409   %
11410   \tolerance = 700
11411   \contentsrightmargin = 0pt
11412   \defbodyindent = 5mm
11413 }}
11414
11415 % Use @afivepaper to print on European A5 paper.
11416 % From romildo@urano.iceb.ufop.br, 2 July 2000.
11417 % He also recommends making @example and @lisp be small.
11418 \def\afivepaper{{\globaldefs = 1
11419   \parskip = 2pt plus 1pt minus 0.1pt
11420   \textleading = 12.5pt
11421   %
11422   \internalpagesizes{160mm}{120mm}%
11423                     {\voffset}{\hoffset}%
11424                     {\bindingoffset}{8pt}%
11425                     {210mm}{148mm}%
11426   %
11427   \lispnarrowing = 0.2in
11428   \tolerance = 800
11429   \contentsrightmargin = 0pt
11430   \defbodyindent = 2mm
11431   \tableindent = 12mm
11432 }}
11433
11434 % A specific text layout, 24x15cm overall, intended for A4 paper.
11435 \def\afourlatex{{\globaldefs = 1
11436   \afourpaper
11437   \internalpagesizes{237mm}{150mm}%
11438                     {\voffset}{4.6mm}%
11439                     {\bindingoffset}{7mm}%
11440                     {297mm}{210mm}%
11441   %
11442   % Must explicitly reset to 0 because we call \afourpaper.
11443   \globaldefs = 0
11444 }}
11445
11446 % Use @afourwide to print on A4 paper in landscape format.
11447 \def\afourwide{{\globaldefs = 1
11448   \afourpaper
11449   \internalpagesizes{241mm}{165mm}%
11450                     {\voffset}{-2.95mm}%
11451                     {\bindingoffset}{7mm}%
11452                     {297mm}{210mm}%
11453   \globaldefs = 0
11454 }}
11455
11456 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11457 % Perhaps we should allow setting the margins, \topskip, \parskip,
11458 % and/or leading, also. Or perhaps we should compute them somehow.
11459 %
11460 \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
11461 \def\pagesizesyyy#1,#2,#3\finish{{%
11462   \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11463   \globaldefs = 1
11464   %
11465   \parskip = 3pt plus 2pt minus 1pt
11466   \setleading{\textleading}%
11467   %
11468   \dimen0 = #1\relax
11469   \advance\dimen0 by \voffset
11470   \advance\dimen0 by 1in % reference point for DVI is 1 inch from top of page
11471   %
11472   \dimen2 = \hsize
11473   \advance\dimen2 by \normaloffset
11474   \advance\dimen2 by 1in % reference point is 1 inch from left edge of page
11475   %
11476   \internalpagesizes{#1}{\hsize}%
11477                     {\voffset}{\normaloffset}%
11478                     {\bindingoffset}{44pt}%
11479                     {\dimen0}{\dimen2}%
11480 }}
11481
11482 % Set default to letter.
11483 %
11484 \letterpaper
11485
11486 % Default value of \hfuzz, for suppressing warnings about overfull hboxes.
11487 \hfuzz = 1pt
11488
11489
11490 \message{and turning on texinfo input format.}
11491
11492 \def^^L{\par} % remove \outer, so ^L can appear in an @comment
11493
11494 % DEL is a comment character, in case @c does not suffice.
11495 \catcode`\^^? = 14
11496
11497 % Define macros to output various characters with catcode for normal text.
11498 \catcode`\"=\other \def\normaldoublequote{"}
11499 \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11500 \catcode`\+=\other \def\normalplus{+}
11501 \catcode`\<=\other \def\normalless{<}
11502 \catcode`\>=\other \def\normalgreater{>}
11503 \catcode`\^=\other \def\normalcaret{^}
11504 \catcode`\_=\other \def\normalunderscore{_}
11505 \catcode`\|=\other \def\normalverticalbar{|}
11506 \catcode`\~=\other \def\normaltilde{~}
11507
11508 % This macro is used to make a character print one way in \tt
11509 % (where it can probably be output as-is), and another way in other fonts,
11510 % where something hairier probably needs to be done.
11511 %
11512 % #1 is what to print if we are indeed using \tt; #2 is what to print
11513 % otherwise.  Since all the Computer Modern typewriter fonts have zero
11514 % interword stretch (and shrink), and it is reasonable to expect all
11515 % typewriter fonts to have this, we can check that font parameter.
11516 %
11517 \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
11518
11519 % Same as above, but check for italic font.  Actually this also catches
11520 % non-italic slanted fonts since it is impossible to distinguish them from
11521 % italic fonts.  But since this is only used by $ and it uses \sl anyway
11522 % this is not a problem.
11523 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
11524
11525 % Set catcodes for Texinfo file
11526
11527 % Active characters for printing the wanted glyph.
11528 % Most of these we simply print from the \tt font, but for some, we can
11529 % use math or other variants that look better in normal text.
11530 %
11531 \catcode`\"=\active
11532 \def\activedoublequote{{\tt\char34}}
11533 \let"=\activedoublequote
11534 \catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
11535 \chardef\hatchar=`\^
11536 \catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
11537
11538 \catcode`\_=\active
11539 \def_{\ifusingtt\normalunderscore\_}
11540 \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
11541 \let\realunder=_
11542
11543 \catcode`\|=\active \def|{{\tt\char124}}
11544
11545 \chardef \less=`\<
11546 \catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
11547 \chardef \gtr=`\>
11548 \catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11549 \catcode`\+=\active \def+{{\tt \char 43}}
11550 \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
11551 \catcode`\-=\active \let-=\normaldash
11552
11553
11554 % used for headline/footline in the output routine, in case the page
11555 % breaks in the middle of an @tex block.
11556 \def\texinfochars{%
11557   \let< = \activeless
11558   \let> = \activegtr
11559   \let~ = \activetilde 
11560   \let^ = \activehat
11561   \markupsetuplqdefault \markupsetuprqdefault 
11562   \let\b = \strong
11563   \let\i = \smartitalic
11564   % in principle, all other definitions in \tex have to be undone too.
11565 }
11566
11567 % Used sometimes to turn off (effectively) the active characters even after
11568 % parsing them.
11569 \def\turnoffactive{%
11570   \normalturnoffactive
11571   \otherbackslash
11572 }
11573
11574 \catcode`\@=0
11575
11576 % \backslashcurfont outputs one backslash character in current font,
11577 % as in \char`\\.
11578 \global\chardef\backslashcurfont=`\\
11579 \global\let\rawbackslashxx=\backslashcurfont  % let existing .??s files work
11580
11581 % \realbackslash is an actual character `\' with catcode other, and
11582 % \doublebackslash is two of them (for the pdf outlines).
11583 {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
11584
11585 % In Texinfo, backslash is an active character; it prints the backslash
11586 % in fixed width font.
11587 \catcode`\\=\active  % @ for escape char from now on.
11588
11589 % Print a typewriter backslash.  For math mode, we can't simply use
11590 % \backslashcurfont: the story here is that in math mode, the \char
11591 % of \backslashcurfont ends up printing the roman \ from the math symbol
11592 % font (because \char in math mode uses the \mathcode, and plain.tex
11593 % sets \mathcode`\\="026E).  Hence we use an explicit \mathchar,
11594 % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11595 % ignored family value; char position "5C).  We can't use " for the
11596 % usual hex value because it has already been made active.
11597
11598 @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
11599 @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
11600
11601 % \rawbackslash defines an active \ to do \backslashcurfont.
11602 % \otherbackslash defines an active \ to be a literal `\' character with
11603 % catcode other.  We switch back and forth between these.
11604 @gdef@rawbackslash{@let\=@backslashcurfont}
11605 @gdef@otherbackslash{@let\=@realbackslash}
11606
11607 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
11608 % the literal character `\'.
11609 %
11610 {@catcode`- = @active
11611  @gdef@normalturnoffactive{%
11612    @passthroughcharstrue
11613    @let-=@normaldash
11614    @let"=@normaldoublequote
11615    @let$=@normaldollar %$ font-lock fix
11616    @let+=@normalplus
11617    @let<=@normalless
11618    @let>=@normalgreater
11619    @let^=@normalcaret
11620    @let_=@normalunderscore
11621    @let|=@normalverticalbar
11622    @let~=@normaltilde
11623    @let\=@ttbackslash
11624    @markupsetuplqdefault
11625    @markupsetuprqdefault
11626    @unsepspaces
11627  }
11628 }
11629
11630 % If a .fmt file is being used, characters that might appear in a file
11631 % name cannot be active until we have parsed the command line.
11632 % So turn them off again, and have @fixbackslash turn them back on.
11633 @catcode`+=@other @catcode`@_=@other
11634
11635 % \enablebackslashhack - allow file to begin `\input texinfo'
11636 %
11637 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
11638 % That is what \eatinput is for; after that, the `\' should revert to printing
11639 % a backslash.
11640 % If the file did not have a `\input texinfo', then it is turned off after
11641 % the first line; otherwise the first `\' in the file would cause an error.
11642 % This is used on the very last line of this file, texinfo.tex.
11643 % We also use @c to call @fixbackslash, in case ends of lines are hidden.
11644 {
11645 @catcode`@^=7
11646 @catcode`@^^M=13@gdef@enablebackslashhack{%
11647   @global@let\ = @eatinput%
11648   @catcode`@^^M=13%
11649   @def@c{@fixbackslash@c}%
11650   % Definition for the newline at the end of this file.
11651   @def ^^M{@let^^M@secondlinenl}%
11652   % Definition for a newline in the main Texinfo file.
11653   @gdef @secondlinenl{@fixbackslash}%
11654   % In case the first line has a whole-line command on it
11655   @let@originalparsearg@parsearg
11656   @def@parsearg{@fixbackslash@originalparsearg}
11657 }}
11658
11659 {@catcode`@^=7 @catcode`@^^M=13%
11660 @gdef@eatinput input texinfo#1^^M{@fixbackslash}}
11661
11662 % Emergency active definition of newline, in case an active newline token
11663 % appears by mistake.
11664 {@catcode`@^=7 @catcode13=13%
11665 @gdef@enableemergencynewline{%
11666   @gdef^^M{%
11667     @par%
11668     %<warning: active newline>@par%
11669 }}}
11670
11671
11672 @gdef@fixbackslash{%
11673   @ifx\@eatinput @let\ = @ttbackslash @fi
11674   @catcode13=5 % regular end of line
11675   @enableemergencynewline
11676   @let@c=@texinfoc
11677   @let@parsearg@originalparsearg
11678   % Also turn back on active characters that might appear in the input
11679   % file name, in case not using a pre-dumped format.
11680   @catcode`+=@active
11681   @catcode`@_=@active
11682   %
11683   % If texinfo.cnf is present on the system, read it.
11684   % Useful for site-wide @afourpaper, etc.  This macro, @fixbackslash, gets
11685   % called at the beginning of every Texinfo file.  Not opening texinfo.cnf
11686   % directly in this file, texinfo.tex, makes it possible to make a format
11687   % file for Texinfo.
11688   %
11689   @openin 1 texinfo.cnf
11690   @ifeof 1 @else @input texinfo.cnf @fi
11691   @closein 1
11692 }
11693
11694
11695 % Say @foo, not \foo, in error messages.
11696 @escapechar = `@@
11697
11698 % These (along with & and #) are made active for url-breaking, so need
11699 % active definitions as the normal characters.
11700 @def@normaldot{.}
11701 @def@normalquest{?}
11702 @def@normalslash{/}
11703
11704 % These look ok in all fonts, so just make them not special.
11705 % @hashchar{} gets its own user-level command, because of #line.
11706 @catcode`@& = @other @def@normalamp{&}
11707 @catcode`@# = @other @def@normalhash{#}
11708 @catcode`@% = @other @def@normalpercent{%}
11709
11710 @let @hashchar = @normalhash
11711
11712 @c Finally, make ` and ' active, so that txicodequoteundirected and
11713 @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
11714 @c don't make ` and ' active, @code will not get them as active chars.
11715 @c Do this last of all since we use ` in the previous @catcode assignments.
11716 @catcode`@'=@active
11717 @catcode`@`=@active
11718 @markupsetuplqdefault
11719 @markupsetuprqdefault
11720
11721 @c Local variables:
11722 @c eval: (add-hook 'before-save-hook 'time-stamp)
11723 @c page-delimiter: "^\\\\message\\|emacs-page"
11724 @c time-stamp-start: "def\\\\texinfoversion{"
11725 @c time-stamp-format: "%:y-%02m-%02d.%02H"
11726 @c time-stamp-end: "}"
11727 @c End:
11728
11729 @c vim:sw=2:
11730
11731 @enablebackslashhack