]> git.donarmstrong.com Git - lilypond.git/blob - tex/texinfo.tex
Merge branch 'master' into translation
[lilypond.git] / tex / texinfo.tex
1 % texinfo.tex -- TeX macros to handle Texinfo files.
2
3 % Load plain if necessary, i.e., if running under initex.
4 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5 %
6 \def\texinfoversion{2016-09-17.16}
7 %
8 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
9 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
10 % 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
11 % Free Software Foundation, Inc.
12 %
13 % This texinfo.tex file is free software: you can redistribute it and/or
14 % modify it under the terms of the GNU General Public License as
15 % published by the Free Software Foundation, either version 3 of the
16 % License, or (at your option) any later version.
17 %
18 % This texinfo.tex file is distributed in the hope that it will be
19 % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
20 % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 % General Public License for more details.
22 %
23 % You should have received a copy of the GNU General Public License
24 % along with this program.  If not, see <http://www.gnu.org/licenses/>.
25 %
26 % As a special exception, when this file is read by TeX when processing
27 % a Texinfo source document, you may use the result without
28 % restriction. This Exception is an additional permission under section 7
29 % of the GNU General Public License, version 3 ("GPLv3").
30 %
31 % Please try the latest version of texinfo.tex before submitting bug
32 % reports; you can get the latest version from:
33 %   http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
34 %   http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
35 %   http://www.gnu.org/software/texinfo/ (the Texinfo home page)
36 % The texinfo.tex in any given distribution could well be out
37 % of date, so if that's what you're using, please check.
38 %
39 % Send bug reports to bug-texinfo@gnu.org.  Please include including a
40 % complete document in each bug report with which we can reproduce the
41 % problem.  Patches are, of course, greatly appreciated.
42 %
43 % To process a Texinfo manual with TeX, it's most reliable to use the
44 % texi2dvi shell script that comes with the distribution.  For a simple
45 % manual foo.texi, however, you can get away with this:
46 %   tex foo.texi
47 %   texindex foo.??
48 %   tex foo.texi
49 %   tex foo.texi
50 %   dvips foo.dvi -o  # or whatever; this makes foo.ps.
51 % The extra TeX runs get the cross-reference information correct.
52 % Sometimes one run after texindex suffices, and sometimes you need more
53 % than two; texi2dvi does it as many times as necessary.
54 %
55 % It is possible to adapt texinfo.tex for other languages, to some
56 % extent.  You can get the existing language-specific files from the
57 % full Texinfo distribution.
58 %
59 % The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
60
61
62 \message{Loading texinfo [version \texinfoversion]:}
63
64 % If in a .fmt file, print the version number
65 % and turn on active characters that we couldn't do earlier because
66 % they might have appeared in the input file name.
67 \everyjob{\message{[Texinfo version \texinfoversion]}%
68   \catcode`+=\active \catcode`\_=\active}
69
70 % LaTeX's \typeout.  This ensures that the messages it is used for
71 % are identical in format to the corresponding ones from latex/pdflatex.
72 \def\typeout{\immediate\write17}%
73
74 \chardef\other=12
75
76 % We never want plain's \outer definition of \+ in Texinfo.
77 % For @tex, we can use \tabalign.
78 \let\+ = \relax
79
80 % Save some plain tex macros whose names we will redefine.
81 \let\ptexb=\b
82 \let\ptexbullet=\bullet
83 \let\ptexc=\c
84 \let\ptexcomma=\,
85 \let\ptexdot=\.
86 \let\ptexdots=\dots
87 \let\ptexend=\end
88 \let\ptexequiv=\equiv
89 \let\ptexexclam=\!
90 \let\ptexfootnote=\footnote
91 \let\ptexgtr=>
92 \let\ptexhat=^
93 \let\ptexi=\i
94 \let\ptexindent=\indent
95 \let\ptexinsert=\insert
96 \let\ptexlbrace=\{
97 \let\ptexless=<
98 \let\ptexnewwrite\newwrite
99 \let\ptexnoindent=\noindent
100 \let\ptexplus=+
101 \let\ptexraggedright=\raggedright
102 \let\ptexrbrace=\}
103 \let\ptexslash=\/
104 \let\ptexsp=\sp
105 \let\ptexstar=\*
106 \let\ptexsup=\sup
107 \let\ptext=\t
108 \let\ptextop=\top
109 {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
110
111 % If this character appears in an error message or help string, it
112 % starts a new line in the output.
113 \newlinechar = `^^J
114
115 % Use TeX 3.0's \inputlineno to get the line number, for better error
116 % messages, but if we're using an old version of TeX, don't do anything.
117 %
118 \ifx\inputlineno\thisisundefined
119   \let\linenumber = \empty % Pre-3.0.
120 \else
121   \def\linenumber{l.\the\inputlineno:\space}
122 \fi
123
124 % Set up fixed words for English if not already set.
125 \ifx\putwordAppendix\undefined  \gdef\putwordAppendix{Appendix}\fi
126 \ifx\putwordChapter\undefined   \gdef\putwordChapter{Chapter}\fi
127 \ifx\putworderror\undefined     \gdef\putworderror{error}\fi
128 \ifx\putwordfile\undefined      \gdef\putwordfile{file}\fi
129 \ifx\putwordin\undefined        \gdef\putwordin{in}\fi
130 \ifx\putwordIndexIsEmpty\undefined       \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
131 \ifx\putwordIndexNonexistent\undefined   \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
132 \ifx\putwordInfo\undefined      \gdef\putwordInfo{Info}\fi
133 \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
134 \ifx\putwordMethodon\undefined  \gdef\putwordMethodon{Method on}\fi
135 \ifx\putwordNoTitle\undefined   \gdef\putwordNoTitle{No Title}\fi
136 \ifx\putwordof\undefined        \gdef\putwordof{of}\fi
137 \ifx\putwordon\undefined        \gdef\putwordon{on}\fi
138 \ifx\putwordpage\undefined      \gdef\putwordpage{page}\fi
139 \ifx\putwordsection\undefined   \gdef\putwordsection{section}\fi
140 \ifx\putwordSection\undefined   \gdef\putwordSection{Section}\fi
141 \ifx\putwordsee\undefined       \gdef\putwordsee{see}\fi
142 \ifx\putwordSee\undefined       \gdef\putwordSee{See}\fi
143 \ifx\putwordShortTOC\undefined  \gdef\putwordShortTOC{Short Contents}\fi
144 \ifx\putwordTOC\undefined       \gdef\putwordTOC{Table of Contents}\fi
145 %
146 \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
147 \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
148 \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
149 \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
150 \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
151 \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
152 \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
153 \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
154 \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
155 \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
156 \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
157 \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
158 %
159 \ifx\putwordDefmac\undefined    \gdef\putwordDefmac{Macro}\fi
160 \ifx\putwordDefspec\undefined   \gdef\putwordDefspec{Special Form}\fi
161 \ifx\putwordDefvar\undefined    \gdef\putwordDefvar{Variable}\fi
162 \ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
163 \ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
164
165 % Give the space character the catcode for a space.
166 \def\spaceisspace{\catcode`\ =10\relax}
167
168 \chardef\dashChar  = `\-
169 \chardef\slashChar = `\/
170 \chardef\underChar = `\_
171
172 % Ignore a token.
173 %
174 \def\gobble#1{}
175
176 % The following is used inside several \edef's.
177 \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
178
179 % Hyphenation fixes.
180 \hyphenation{
181   Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
182   ap-pen-dix bit-map bit-maps
183   data-base data-bases eshell fall-ing half-way long-est man-u-script
184   man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
185   par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
186   spell-ing spell-ings
187   stand-alone strong-est time-stamp time-stamps which-ever white-space
188   wide-spread wrap-around
189 }
190
191 % Sometimes it is convenient to have everything in the transcript file
192 % and nothing on the terminal.  We don't just call \tracingall here,
193 % since that produces some useless output on the terminal.  We also make
194 % some effort to order the tracing commands to reduce output in the log
195 % file; cf. trace.sty in LaTeX.
196 %
197 \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
198 \def\loggingall{%
199   \tracingstats2
200   \tracingpages1
201   \tracinglostchars2  % 2 gives us more in etex
202   \tracingparagraphs1
203   \tracingoutput1
204   \tracingmacros2
205   \tracingrestores1
206   \showboxbreadth\maxdimen \showboxdepth\maxdimen
207   \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
208     \tracingscantokens1
209     \tracingifs1
210     \tracinggroups1
211     \tracingnesting2
212     \tracingassigns1
213   \fi
214   \tracingcommands3  % 3 gives us more in etex
215   \errorcontextlines16
216 }%
217
218 % @errormsg{MSG}.  Do the index-like expansions on MSG, but if things
219 % aren't perfect, it's not the end of the world, being an error message,
220 % after all.
221
222 \def\errormsg{\begingroup \indexnofonts \doerrormsg}
223 \def\doerrormsg#1{\errmessage{#1}}
224
225 % add check for \lastpenalty to plain's definitions.  If the last thing
226 % we did was a \nobreak, we don't want to insert more space.
227 %
228 \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
229   \removelastskip\penalty-50\smallskip\fi\fi}
230 \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
231   \removelastskip\penalty-100\medskip\fi\fi}
232 \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
233   \removelastskip\penalty-200\bigskip\fi\fi}
234
235 %\f Output routine
236 %
237
238 % For a final copy, take out the rectangles
239 % that mark overfull boxes (in case you have decided
240 % that the text looks ok even though it passes the margin).
241 %
242 \def\finalout{\overfullrule=0pt }
243
244 % Do @cropmarks to get crop marks.
245 %
246 \newif\ifcropmarks
247 \let\cropmarks = \cropmarkstrue
248 %
249 % Dimensions to add cropmarks at corners.
250 % Added by P. A. MacKay, 12 Nov. 1986
251 %
252 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
253 \newdimen\cornerlong  \cornerlong=1pc
254 \newdimen\cornerthick \cornerthick=.3pt
255 \newdimen\topandbottommargin \topandbottommargin=.75in
256
257 % Output a mark which sets \thischapter, \thissection and \thiscolor.
258 % We dump everything together because we only have one kind of mark.
259 % This works because we only use \botmark / \topmark, not \firstmark.
260 %
261 % A mark contains a subexpression of the \ifcase ... \fi construct.
262 % \get*marks macros below extract the needed part using \ifcase.
263 %
264 % Another complication is to let the user choose whether \thischapter
265 % (\thissection) refers to the chapter (section) in effect at the top
266 % of a page, or that at the bottom of a page.
267
268 % \domark is called twice inside \chapmacro, to add one
269 % mark before the section break, and one after.
270 %   In the second call \prevchapterdefs is the same as \lastchapterdefs,
271 % and \prevsectiondefs is the same as \lastsectiondefs.
272 %   Then if the page is not broken at the mark, some of the previous
273 % section appears on the page, and we can get the name of this section
274 % from \firstmark for @everyheadingmarks top.
275 %   @everyheadingmarks bottom uses \botmark.
276 %
277 % See page 260 of The TeXbook.
278 \def\domark{%
279   \toks0=\expandafter{\lastchapterdefs}%
280   \toks2=\expandafter{\lastsectiondefs}%
281   \toks4=\expandafter{\prevchapterdefs}%
282   \toks6=\expandafter{\prevsectiondefs}%
283   \toks8=\expandafter{\lastcolordefs}%
284   \mark{%
285                    \the\toks0 \the\toks2  % 0: marks for @everyheadingmarks top
286       \noexpand\or \the\toks4 \the\toks6  % 1: for @everyheadingmarks bottom
287     \noexpand\else \the\toks8             % 2: color marks
288   }%
289 }
290
291 % \gettopheadingmarks, \getbottomheadingmarks,
292 % \getcolormarks - extract needed part of mark.
293 %
294 % \topmark doesn't work for the very first chapter (after the title
295 % page or the contents), so we use \firstmark there -- this gets us
296 % the mark with the chapter defs, unless the user sneaks in, e.g.,
297 % @setcolor (or @url, or @link, etc.) between @contents and the very
298 % first @chapter.
299 \def\gettopheadingmarks{%
300   \ifcase0\topmark\fi
301   \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
302 }
303 \def\getbottomheadingmarks{\ifcase1\botmark\fi}
304 \def\getcolormarks{\ifcase2\topmark\fi}
305
306 % Avoid "undefined control sequence" errors.
307 \def\lastchapterdefs{}
308 \def\lastsectiondefs{}
309 \def\lastsection{}
310 \def\prevchapterdefs{}
311 \def\prevsectiondefs{}
312 \def\lastcolordefs{}
313
314 % Margin to add to right of even pages, to left of odd pages.
315 \newdimen\bindingoffset
316 \newdimen\normaloffset
317 \newdimen\txipagewidth \newdimen\txipageheight
318
319 % Main output routine.
320 %
321 \chardef\PAGE = 255
322 \output = {\onepageout{\pagecontents\PAGE}}
323
324 \newbox\headlinebox
325 \newbox\footlinebox
326
327 % \onepageout takes a vbox as an argument.
328 % \shipout a vbox for a single page, adding an optional header, footer,
329 % cropmarks, and footnote.  This also causes index entries for this page
330 % to be written to the auxiliary files.
331 %
332 \def\onepageout#1{%
333   \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
334   %
335   \ifodd\pageno  \advance\hoffset by \bindingoffset
336   \else \advance\hoffset by -\bindingoffset\fi
337   %
338   % Common context changes for both heading and footing.
339   % Do this outside of the \shipout so @code etc. will be expanded in
340   % the headline as they should be, not taken literally (outputting ''code).
341   \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars}
342   %
343   % Retrieve the information for the headings from the marks in the page,
344   % and call Plain TeX's \makeheadline and \makefootline, which use the
345   % values in \headline and \footline.
346   %
347   % This is used to check if we are on the first page of a chapter.
348   \ifcase1\topmark\fi
349   \let\prevchaptername\thischaptername
350   \ifcase0\firstmark\fi
351   \let\curchaptername\thischaptername
352   %
353   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
354   \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
355   %
356   \ifx\curchaptername\prevchaptername
357     \let\thischapterheading\thischapter
358   \else
359     % \thischapterheading is the same as \thischapter except it is blank
360     % for the first page of a chapter.  This is to prevent the chapter name 
361     % being shown twice.
362     \def\thischapterheading{}%
363   \fi
364   %
365   \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}%
366   \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}%
367   %
368   {%
369     % Set context for writing to auxiliary files like index files.
370     % Have to do this stuff outside the \shipout because we want it to
371     % take effect in \write's, yet the group defined by the \vbox ends
372     % before the \shipout runs.
373     %
374     \indexdummies         % don't expand commands in the output.
375     \normalturnoffactive  % \ in index entries must not stay \, e.g., if
376                % the page break happens to be in the middle of an example.
377                % We don't want .vr (or whatever) entries like this:
378                % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}}
379                % "\acronym" won't work when it's read back in;
380                % it needs to be
381                % {\code {{\backslashcurfont }acronym}
382     \shipout\vbox{%
383       % Do this early so pdf references go to the beginning of the page.
384       \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
385       %
386       \ifcropmarks \vbox to \outervsize\bgroup
387         \hsize = \outerhsize
388         \vskip-\topandbottommargin
389         \vtop to0pt{%
390           \line{\ewtop\hfil\ewtop}%
391           \nointerlineskip
392           \line{%
393             \vbox{\moveleft\cornerthick\nstop}%
394             \hfill
395             \vbox{\moveright\cornerthick\nstop}%
396           }%
397           \vss}%
398         \vskip\topandbottommargin
399         \line\bgroup
400           \hfil % center the page within the outer (page) hsize.
401           \ifodd\pageno\hskip\bindingoffset\fi
402           \vbox\bgroup
403       \fi
404       %
405       \unvbox\headlinebox
406       \pagebody{#1}%
407       \ifdim\ht\footlinebox > 0pt
408         % Only leave this space if the footline is nonempty.
409         % (We lessened \vsize for it in \oddfootingyyy.)
410         % The \baselineskip=24pt in plain's \makefootline has no effect.
411         \vskip 24pt
412         \unvbox\footlinebox
413       \fi
414       %
415       \ifcropmarks
416           \egroup % end of \vbox\bgroup
417         \hfil\egroup % end of (centering) \line\bgroup
418         \vskip\topandbottommargin plus1fill minus1fill
419         \boxmaxdepth = \cornerthick
420         \vbox to0pt{\vss
421           \line{%
422             \vbox{\moveleft\cornerthick\nsbot}%
423             \hfill
424             \vbox{\moveright\cornerthick\nsbot}%
425           }%
426           \nointerlineskip
427           \line{\ewbot\hfil\ewbot}%
428         }%
429       \egroup % \vbox from first cropmarks clause
430       \fi
431     }% end of \shipout\vbox
432   }% end of group with \indexdummies
433   \advancepageno
434   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
435 }
436
437 \newinsert\margin \dimen\margin=\maxdimen
438
439 % Main part of page, including any footnotes
440 \def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
441 {\catcode`\@ =11
442 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
443 % marginal hacks, juha@viisa.uucp (Juha Takala)
444 \ifvoid\margin\else % marginal info is present
445   \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
446 \dimen@=\dp#1\relax \unvbox#1\relax
447 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
448 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
449 }
450
451 % Here are the rules for the cropmarks.  Note that they are
452 % offset so that the space between them is truly \outerhsize or \outervsize
453 % (P. A. MacKay, 12 November, 1986)
454 %
455 \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
456 \def\nstop{\vbox
457   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
458 \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
459 \def\nsbot{\vbox
460   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
461
462
463 % Argument parsing
464
465 % Parse an argument, then pass it to #1.  The argument is the rest of
466 % the input line (except we remove a trailing comment).  #1 should be a
467 % macro which expects an ordinary undelimited TeX argument.
468 % For example, \def\foo{\parsearg\fooxxx}.
469 %
470 \def\parsearg{\parseargusing{}}
471 \def\parseargusing#1#2{%
472   \def\argtorun{#2}%
473   \begingroup
474     \obeylines
475     \spaceisspace
476     #1%
477     \parseargline\empty% Insert the \empty token, see \finishparsearg below.
478 }
479
480 {\obeylines %
481   \gdef\parseargline#1^^M{%
482     \endgroup % End of the group started in \parsearg.
483     \argremovecomment #1\comment\ArgTerm%
484   }%
485 }
486
487 % First remove any @comment, then any @c comment.  Also remove a @texinfoc
488 % comment (see \scanmacro for details).  Pass the result on to \argcheckspaces.
489 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
490 \def\argremovec#1\c#2\ArgTerm{\argremovetexinfoc #1\texinfoc\ArgTerm}
491 \def\argremovetexinfoc#1\texinfoc#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
492
493 % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
494 %
495 % \argremovec might leave us with trailing space, e.g.,
496 %    @end itemize  @c foo
497 % This space token undergoes the same procedure and is eventually removed
498 % by \finishparsearg.
499 %
500 \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
501 \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
502 \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
503   \def\temp{#3}%
504   \ifx\temp\empty
505     % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
506     \let\temp\finishparsearg
507   \else
508     \let\temp\argcheckspaces
509   \fi
510   % Put the space token in:
511   \temp#1 #3\ArgTerm
512 }
513
514 % If a _delimited_ argument is enclosed in braces, they get stripped; so
515 % to get _exactly_ the rest of the line, we had to prevent such situation.
516 % We prepended an \empty token at the very beginning and we expand it now,
517 % just before passing the control to \argtorun.
518 % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
519 % either the null string, or it ends with \^^M---thus there is no danger
520 % that a pair of braces would be stripped.
521 %
522 % But first, we have to remove the trailing space token.
523 %
524 \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
525
526
527 % \parseargdef - define a command taking an argument on the line
528 %
529 % \parseargdef\foo{...}
530 %       is roughly equivalent to
531 % \def\foo{\parsearg\Xfoo}
532 % \def\Xfoo#1{...}
533 \def\parseargdef#1{%
534   \expandafter \doparseargdef \csname\string#1\endcsname #1%
535 }
536 \def\doparseargdef#1#2{%
537   \def#2{\parsearg#1}%
538   \def#1##1%
539 }
540
541 % Several utility definitions with active space:
542 {
543   \obeyspaces
544   \gdef\obeyedspace{ }
545
546   % Make each space character in the input produce a normal interword
547   % space in the output.  Don't allow a line break at this space, as this
548   % is used only in environments like @example, where each line of input
549   % should produce a line of output anyway.
550   %
551   \gdef\sepspaces{\obeyspaces\let =\tie}
552
553   % If an index command is used in an @example environment, any spaces
554   % therein should become regular spaces in the raw index file, not the
555   % expansion of \tie (\leavevmode \penalty \@M \ ).
556   \gdef\unsepspaces{\let =\space}
557 }
558
559
560 \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
561
562 % Define the framework for environments in texinfo.tex.  It's used like this:
563 %
564 %   \envdef\foo{...}
565 %   \def\Efoo{...}
566 %
567 % It's the responsibility of \envdef to insert \begingroup before the
568 % actual body; @end closes the group after calling \Efoo.  \envdef also
569 % defines \thisenv, so the current environment is known; @end checks
570 % whether the environment name matches.  The \checkenv macro can also be
571 % used to check whether the current environment is the one expected.
572 %
573 % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
574 % are not treated as environments; they don't open a group.  (The
575 % implementation of @end takes care not to call \endgroup in this
576 % special case.)
577
578
579 % At run-time, environments start with this:
580 \def\startenvironment#1{\begingroup\def\thisenv{#1}}
581 % initialize
582 \let\thisenv\empty
583
584 % ... but they get defined via ``\envdef\foo{...}'':
585 \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
586 \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
587
588 % Check whether we're in the right environment:
589 \def\checkenv#1{%
590   \def\temp{#1}%
591   \ifx\thisenv\temp
592   \else
593     \badenverr
594   \fi
595 }
596
597 % Environment mismatch, #1 expected:
598 \def\badenverr{%
599   \errhelp = \EMsimple
600   \errmessage{This command can appear only \inenvironment\temp,
601     not \inenvironment\thisenv}%
602 }
603 \def\inenvironment#1{%
604   \ifx#1\empty
605     outside of any environment%
606   \else
607     in environment \expandafter\string#1%
608   \fi
609 }
610
611 % @end foo executes the definition of \Efoo.
612 % But first, it executes a specialized version of \checkenv
613 %
614 \parseargdef\end{%
615   \if 1\csname iscond.#1\endcsname
616   \else
617     % The general wording of \badenverr may not be ideal.
618     \expandafter\checkenv\csname#1\endcsname
619     \csname E#1\endcsname
620     \endgroup
621   \fi
622 }
623
624 \newhelp\EMsimple{Press RETURN to continue.}
625
626
627 % Be sure we're in horizontal mode when doing a tie, since we make space
628 % equivalent to this in @example-like environments. Otherwise, a space
629 % at the beginning of a line will start with \penalty -- and
630 % since \penalty is valid in vertical mode, we'd end up putting the
631 % penalty on the vertical list instead of in the new paragraph.
632 {\catcode`@ = 11
633  % Avoid using \@M directly, because that causes trouble
634  % if the definition is written into an index file.
635  \global\let\tiepenalty = \@M
636  \gdef\tie{\leavevmode\penalty\tiepenalty\ }
637 }
638
639 % @: forces normal size whitespace following.
640 \def\:{\spacefactor=1000 }
641
642 % @* forces a line break.
643 \def\*{\unskip\hfil\break\hbox{}\ignorespaces}
644
645 % @/ allows a line break.
646 \let\/=\allowbreak
647
648 % @. is an end-of-sentence period.
649 \def\.{.\spacefactor=\endofsentencespacefactor\space}
650
651 % @! is an end-of-sentence bang.
652 \def\!{!\spacefactor=\endofsentencespacefactor\space}
653
654 % @? is an end-of-sentence query.
655 \def\?{?\spacefactor=\endofsentencespacefactor\space}
656
657 % @frenchspacing on|off  says whether to put extra space after punctuation.
658 %
659 \def\onword{on}
660 \def\offword{off}
661 %
662 \parseargdef\frenchspacing{%
663   \def\temp{#1}%
664   \ifx\temp\onword \plainfrenchspacing
665   \else\ifx\temp\offword \plainnonfrenchspacing
666   \else
667     \errhelp = \EMsimple
668     \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
669   \fi\fi
670 }
671
672 % @w prevents a word break.  Without the \leavevmode, @w at the
673 % beginning of a paragraph, when TeX is still in vertical mode, would
674 % produce a whole line of output instead of starting the paragraph.
675 \def\w#1{\leavevmode\hbox{#1}}
676
677 % @group ... @end group forces ... to be all on one page, by enclosing
678 % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
679 % to keep its height that of a normal line.  According to the rules for
680 % \topskip (p.114 of the TeXbook), the glue inserted is
681 % max (\topskip - \ht (first item), 0).  If that height is large,
682 % therefore, no glue is inserted, and the space between the headline and
683 % the text is small, which looks bad.
684 %
685 % Another complication is that the group might be very large.  This can
686 % cause the glue on the previous page to be unduly stretched, because it
687 % does not have much material.  In this case, it's better to add an
688 % explicit \vfill so that the extra space is at the bottom.  The
689 % threshold for doing this is if the group is more than \vfilllimit
690 % percent of a page (\vfilllimit can be changed inside of @tex).
691 %
692 \newbox\groupbox
693 \def\vfilllimit{0.7}
694 %
695 \envdef\group{%
696   \ifnum\catcode`\^^M=\active \else
697     \errhelp = \groupinvalidhelp
698     \errmessage{@group invalid in context where filling is enabled}%
699   \fi
700   \startsavinginserts
701   %
702   \setbox\groupbox = \vtop\bgroup
703     % Do @comment since we are called inside an environment such as
704     % @example, where each end-of-line in the input causes an
705     % end-of-line in the output.  We don't want the end-of-line after
706     % the `@group' to put extra space in the output.  Since @group
707     % should appear on a line by itself (according to the Texinfo
708     % manual), we don't worry about eating any user text.
709     \comment
710 }
711 %
712 % The \vtop produces a box with normal height and large depth; thus, TeX puts
713 % \baselineskip glue before it, and (when the next line of text is done)
714 % \lineskip glue after it.  Thus, space below is not quite equal to space
715 % above.  But it's pretty close.
716 \def\Egroup{%
717     % To get correct interline space between the last line of the group
718     % and the first line afterwards, we have to propagate \prevdepth.
719     \endgraf % Not \par, as it may have been set to \lisppar.
720     \global\dimen1 = \prevdepth
721   \egroup           % End the \vtop.
722   \addgroupbox
723   \prevdepth = \dimen1
724   \checkinserts
725 }
726
727 \def\addgroupbox{
728   % \dimen0 is the vertical size of the group's box.
729   \dimen0 = \ht\groupbox  \advance\dimen0 by \dp\groupbox
730   % \dimen2 is how much space is left on the page (more or less).
731   \dimen2 = \txipageheight   \advance\dimen2 by -\pagetotal
732   % if the group doesn't fit on the current page, and it's a big big
733   % group, force a page break.
734   \ifdim \dimen0 > \dimen2
735     \ifdim \pagetotal < \vfilllimit\txipageheight
736       \page
737     \fi
738   \fi
739   \box\groupbox
740 }
741
742 %
743 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
744 % message, so this ends up printing `@group can only ...'.
745 %
746 \newhelp\groupinvalidhelp{%
747 group can only be used in environments such as @example,^^J%
748 where each line of input produces a line of output.}
749
750 % @need space-in-mils
751 % forces a page break if there is not space-in-mils remaining.
752
753 \newdimen\mil  \mil=0.001in
754
755 \parseargdef\need{%
756   % Ensure vertical mode, so we don't make a big box in the middle of a
757   % paragraph.
758   \par
759   %
760   % If the @need value is less than one line space, it's useless.
761   \dimen0 = #1\mil
762   \dimen2 = \ht\strutbox
763   \advance\dimen2 by \dp\strutbox
764   \ifdim\dimen0 > \dimen2
765     %
766     % Do a \strut just to make the height of this box be normal, so the
767     % normal leading is inserted relative to the preceding line.
768     % And a page break here is fine.
769     \vtop to #1\mil{\strut\vfil}%
770     %
771     % TeX does not even consider page breaks if a penalty added to the
772     % main vertical list is 10000 or more.  But in order to see if the
773     % empty box we just added fits on the page, we must make it consider
774     % page breaks.  On the other hand, we don't want to actually break the
775     % page after the empty box.  So we use a penalty of 9999.
776     %
777     % There is an extremely small chance that TeX will actually break the
778     % page at this \penalty, if there are no other feasible breakpoints in
779     % sight.  (If the user is using lots of big @group commands, which
780     % almost-but-not-quite fill up a page, TeX will have a hard time doing
781     % good page breaking, for example.)  However, I could not construct an
782     % example where a page broke at this \penalty; if it happens in a real
783     % document, then we can reconsider our strategy.
784     \penalty9999
785     %
786     % Back up by the size of the box, whether we did a page break or not.
787     \kern -#1\mil
788     %
789     % Do not allow a page break right after this kern.
790     \nobreak
791   \fi
792 }
793
794 % @br   forces paragraph break (and is undocumented).
795
796 \let\br = \par
797
798 % @page forces the start of a new page.
799 %
800 \def\page{\par\vfill\supereject}
801
802 % @exdent text....
803 % outputs text on separate line in roman font, starting at standard page margin
804
805 % This records the amount of indent in the innermost environment.
806 % That's how much \exdent should take out.
807 \newskip\exdentamount
808
809 % This defn is used inside fill environments such as @defun.
810 \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
811
812 % This defn is used inside nofill environments such as @example.
813 \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
814   \leftline{\hskip\leftskip{\rm#1}}}}
815
816 % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
817 % paragraph.  For more general purposes, use the \margin insertion
818 % class.  WHICH is `l' or `r'.  Not documented, written for gawk manual.
819 %
820 \newskip\inmarginspacing \inmarginspacing=1cm
821 \def\strutdepth{\dp\strutbox}
822 %
823 \def\doinmargin#1#2{\strut\vadjust{%
824   \nobreak
825   \kern-\strutdepth
826   \vtop to \strutdepth{%
827     \baselineskip=\strutdepth
828     \vss
829     % if you have multiple lines of stuff to put here, you'll need to
830     % make the vbox yourself of the appropriate size.
831     \ifx#1l%
832       \llap{\ignorespaces #2\hskip\inmarginspacing}%
833     \else
834       \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
835     \fi
836     \null
837   }%
838 }}
839 \def\inleftmargin{\doinmargin l}
840 \def\inrightmargin{\doinmargin r}
841 %
842 % @inmargin{TEXT [, RIGHT-TEXT]}
843 % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
844 % else use TEXT for both).
845 %
846 \def\inmargin#1{\parseinmargin #1,,\finish}
847 \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
848   \setbox0 = \hbox{\ignorespaces #2}%
849   \ifdim\wd0 > 0pt
850     \def\lefttext{#1}%  have both texts
851     \def\righttext{#2}%
852   \else
853     \def\lefttext{#1}%  have only one text
854     \def\righttext{#1}%
855   \fi
856   %
857   \ifodd\pageno
858     \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
859   \else
860     \def\temp{\inleftmargin\lefttext}%
861   \fi
862   \temp
863 }
864
865 % @include FILE -- \input text of FILE.
866 %
867 \def\include{\parseargusing\filenamecatcodes\includezzz}
868 \def\includezzz#1{%
869   \pushthisfilestack
870   \def\thisfile{#1}%
871   {%
872     \makevalueexpandable  % we want to expand any @value in FILE.
873     \turnoffactive        % and allow special characters in the expansion
874     \indexnofonts         % Allow `@@' and other weird things in file names.
875     \wlog{texinfo.tex: doing @include of #1^^J}%
876     \edef\temp{\noexpand\input #1 }%
877     %
878     % This trickery is to read FILE outside of a group, in case it makes
879     % definitions, etc.
880     \expandafter
881   }\temp
882   \popthisfilestack
883 }
884 \def\filenamecatcodes{%
885   \catcode`\\=\other
886   \catcode`~=\other
887   \catcode`^=\other
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 }
897
898 \def\pushthisfilestack{%
899   \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
900 }
901 \def\pushthisfilestackX{%
902   \expandafter\pushthisfilestackY\thisfile\StackTerm
903 }
904 \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
905   \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
906 }
907
908 \def\popthisfilestack{\errthisfilestackempty}
909 \def\errthisfilestackempty{\errmessage{Internal error:
910   the stack of filenames is empty.}}
911 %
912 \def\thisfile{}
913
914 % @center line
915 % outputs that line, centered.
916 %
917 \parseargdef\center{%
918   \ifhmode
919     \let\centersub\centerH
920   \else
921     \let\centersub\centerV
922   \fi
923   \centersub{\hfil \ignorespaces#1\unskip \hfil}%
924   \let\centersub\relax % don't let the definition persist, just in case
925 }
926 \def\centerH#1{{%
927   \hfil\break
928   \advance\hsize by -\leftskip
929   \advance\hsize by -\rightskip
930   \line{#1}%
931   \break
932 }}
933 %
934 \newcount\centerpenalty
935 \def\centerV#1{%
936   % The idea here is the same as in \startdefun, \cartouche, etc.: if
937   % @center is the first thing after a section heading, we need to wipe
938   % out the negative parskip inserted by \sectionheading, but still
939   % prevent a page break here.
940   \centerpenalty = \lastpenalty
941   \ifnum\centerpenalty>10000 \vskip\parskip \fi
942   \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
943   \line{\kern\leftskip #1\kern\rightskip}%
944 }
945
946 % @sp n   outputs n lines of vertical space
947 %
948 \parseargdef\sp{\vskip #1\baselineskip}
949
950 % @comment ...line which is ignored...
951 % @c is the same as @comment
952 % @ignore ... @end ignore  is another way to write a comment
953 %
954 \def\comment{\begingroup \catcode`\^^M=\active%
955 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other\commentxxx}%
956
957 {\catcode`\^^M=\active%
958 \gdef\commentxxx#1^^M{\endgroup%
959 \futurelet\nexttoken\commentxxxx}%
960 \gdef\commentxxxx{\ifx\nexttoken\aftermacro\expandafter\comment\fi}%
961 }
962
963 \def\c{\begingroup \catcode`\^^M=\active%
964 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
965 \cxxx}
966 {\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
967 % See comment in \scanmacro about why the definitions of @c and @comment differ
968
969 % @paragraphindent NCHARS
970 % We'll use ems for NCHARS, close enough.
971 % NCHARS can also be the word `asis' or `none'.
972 % We cannot feasibly implement @paragraphindent asis, though.
973 %
974 \def\asisword{asis} % no translation, these are keywords
975 \def\noneword{none}
976 %
977 \parseargdef\paragraphindent{%
978   \def\temp{#1}%
979   \ifx\temp\asisword
980   \else
981     \ifx\temp\noneword
982       \defaultparindent = 0pt
983     \else
984       \defaultparindent = #1em
985     \fi
986   \fi
987   \parindent = \defaultparindent
988 }
989
990 % @exampleindent NCHARS
991 % We'll use ems for NCHARS like @paragraphindent.
992 % It seems @exampleindent asis isn't necessary, but
993 % I preserve it to make it similar to @paragraphindent.
994 \parseargdef\exampleindent{%
995   \def\temp{#1}%
996   \ifx\temp\asisword
997   \else
998     \ifx\temp\noneword
999       \lispnarrowing = 0pt
1000     \else
1001       \lispnarrowing = #1em
1002     \fi
1003   \fi
1004 }
1005
1006 % @firstparagraphindent WORD
1007 % If WORD is `none', then suppress indentation of the first paragraph
1008 % after a section heading.  If WORD is `insert', then do indent at such
1009 % paragraphs.
1010 %
1011 % The paragraph indentation is suppressed or not by calling
1012 % \suppressfirstparagraphindent, which the sectioning commands do.
1013 % We switch the definition of this back and forth according to WORD.
1014 % By default, we suppress indentation.
1015 %
1016 \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
1017 \def\insertword{insert}
1018 %
1019 \parseargdef\firstparagraphindent{%
1020   \def\temp{#1}%
1021   \ifx\temp\noneword
1022     \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
1023   \else\ifx\temp\insertword
1024     \let\suppressfirstparagraphindent = \relax
1025   \else
1026     \errhelp = \EMsimple
1027     \errmessage{Unknown @firstparagraphindent option `\temp'}%
1028   \fi\fi
1029 }
1030
1031 % Here is how we actually suppress indentation.  Redefine \everypar to
1032 % \kern backwards by \parindent, and then reset itself to empty.
1033 %
1034 % We also make \indent itself not actually do anything until the next
1035 % paragraph.
1036 %
1037 \gdef\dosuppressfirstparagraphindent{%
1038   \gdef\indent  {\restorefirstparagraphindent \indent}%
1039   \gdef\noindent{\restorefirstparagraphindent \noindent}%
1040   \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
1041 }
1042 %
1043 \gdef\restorefirstparagraphindent{%
1044   \global\let\indent = \ptexindent
1045   \global\let\noindent = \ptexnoindent
1046   \global\everypar = {}%
1047 }
1048
1049
1050 % @refill is a no-op.
1051 \let\refill=\relax
1052
1053 % @setfilename INFO-FILENAME - ignored
1054 \let\setfilename=\comment
1055
1056 % @bye.
1057 \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
1058
1059
1060 \message{pdf,}
1061 % adobe `portable' document format
1062 \newcount\tempnum
1063 \newcount\lnkcount
1064 \newtoks\filename
1065 \newcount\filenamelength
1066 \newcount\pgn
1067 \newtoks\toksA
1068 \newtoks\toksB
1069 \newtoks\toksC
1070 \newtoks\toksD
1071 \newbox\boxA
1072 \newbox\boxB
1073 \newcount\countA
1074 \newif\ifpdf
1075 \newif\ifpdfmakepagedest
1076
1077 %
1078 % For LuaTeX
1079 %
1080
1081 \newif\iftxiuseunicodedestname
1082 \txiuseunicodedestnamefalse % For pdfTeX etc.
1083
1084 \ifx\luatexversion\thisisundefined
1085 \else
1086   % Use Unicode destination names
1087   \txiuseunicodedestnametrue
1088   % Escape PDF strings with converting UTF-16 from UTF-8
1089   \begingroup
1090     \catcode`\%=12
1091     \directlua{
1092       function UTF16oct(str)
1093         tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
1094         for c in string.utfvalues(str) do
1095           if c < 0x10000 then
1096             tex.sprint(
1097               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1098                             string.char(0x5c) .. string.char(0x25) .. '03o',
1099                             (c / 256), (c % 256)))
1100           else
1101             c = c - 0x10000
1102             local c_hi = c / 1024 + 0xd800
1103             local c_lo = c % 1024 + 0xdc00
1104             tex.sprint(
1105               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1106                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
1107                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
1108                             string.char(0x5c) .. string.char(0x25) .. '03o',
1109                             (c_hi / 256), (c_hi % 256),
1110                             (c_lo / 256), (c_lo % 256)))
1111           end
1112         end
1113       end
1114     }
1115   \endgroup
1116   \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
1117   % Escape PDF strings without converting
1118   \begingroup
1119     \directlua{
1120       function PDFescstr(str)
1121         for c in string.bytes(str) do
1122           if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
1123             tex.sprint(
1124               string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
1125                             c))
1126           else
1127             tex.sprint(string.char(c))
1128           end
1129         end
1130       end
1131     }
1132   \endgroup
1133   \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
1134   \ifnum\luatexversion>84
1135     % For LuaTeX >= 0.85
1136     \def\pdfdest{\pdfextension dest}
1137     \let\pdfoutput\outputmode
1138     \def\pdfliteral{\pdfextension literal}
1139     \def\pdfcatalog{\pdfextension catalog}
1140     \def\pdftexversion{\numexpr\pdffeedback version\relax}
1141     \let\pdfximage\saveimageresource
1142     \let\pdfrefximage\useimageresource
1143     \let\pdflastximage\lastsavedimageresourceindex
1144     \def\pdfendlink{\pdfextension endlink\relax}
1145     \def\pdfoutline{\pdfextension outline}
1146     \def\pdfstartlink{\pdfextension startlink}
1147     \def\pdffontattr{\pdfextension fontattr}
1148     \def\pdfobj{\pdfextension obj}
1149     \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
1150     \let\pdfpagewidth\pagewidth
1151     \let\pdfpageheight\pageheight
1152     \edef\pdfhorigin{\pdfvariable horigin}
1153     \edef\pdfvorigin{\pdfvariable vorigin}
1154   \fi
1155 \fi
1156
1157 % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1158 % can be set).  So we test for \relax and 0 as well as being undefined.
1159 \ifx\pdfoutput\thisisundefined
1160 \else
1161   \ifx\pdfoutput\relax
1162   \else
1163     \ifcase\pdfoutput
1164     \else
1165       \pdftrue
1166     \fi
1167   \fi
1168 \fi
1169
1170 % PDF uses PostScript string constants for the names of xref targets,
1171 % for display in the outlines, and in other places.  Thus, we have to
1172 % double any backslashes.  Otherwise, a name like "\node" will be
1173 % interpreted as a newline (\n), followed by o, d, e.  Not good.
1174
1175 % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
1176 % related messages.  The final outcome is that it is up to the TeX user
1177 % to double the backslashes and otherwise make the string valid, so
1178 % that's what we do.  pdftex 1.30.0 (ca.2005) introduced a primitive to
1179 % do this reliably, so we use it.
1180
1181 % #1 is a control sequence in which to do the replacements,
1182 % which we \xdef.
1183 \def\txiescapepdf#1{%
1184   \ifx\pdfescapestring\thisisundefined
1185     % No primitive available; should we give a warning or log?
1186     % Many times it won't matter.
1187     \xdef#1{#1}%
1188   \else
1189     % The expandable \pdfescapestring primitive escapes parentheses,
1190     % backslashes, and other special chars.
1191     \xdef#1{\pdfescapestring{#1}}%
1192   \fi
1193 }
1194 \def\txiescapepdfutfsixteen#1{%
1195   \ifx\pdfescapestrutfsixteen\thisisundefined
1196     % No UTF-16 converting macro available.
1197     \txiescapepdf{#1}%
1198   \else
1199     \xdef#1{\pdfescapestrutfsixteen{#1}}%
1200   \fi
1201 }
1202
1203 \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1204 with PDF output, and none of those formats could be found.  (.eps cannot
1205 be supported due to the design of the PDF format; use regular TeX (DVI
1206 output) for that.)}
1207
1208 \ifpdf
1209   %
1210   % Color manipulation macros using ideas from pdfcolor.tex,
1211   % except using rgb instead of cmyk; the latter is said to render as a
1212   % very dark gray on-screen and a very dark halftone in print, instead
1213   % of actual black. The dark red here is dark enough to print on paper as
1214   % nearly black, but still distinguishable for online viewing.  We use
1215   % black by default, though.
1216   \def\rgbDarkRed{0.50 0.09 0.12}
1217   \def\rgbBlack{0 0 0}
1218   %
1219   % rg sets the color for filling (usual text, etc.);
1220   % RG sets the color for stroking (thin rules, e.g., normal _'s).
1221   \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
1222   %
1223   % Set color, and create a mark which defines \thiscolor accordingly,
1224   % so that \makeheadline knows which color to restore.
1225   \def\setcolor#1{%
1226     \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
1227     \domark
1228     \pdfsetcolor{#1}%
1229   }
1230   %
1231   \def\maincolor{\rgbBlack}
1232   \pdfsetcolor{\maincolor}
1233   \edef\thiscolor{\maincolor}
1234   \def\lastcolordefs{}
1235   %
1236   \def\makefootline{%
1237     \baselineskip24pt
1238     \line{\pdfsetcolor{\maincolor}\the\footline}%
1239   }
1240   %
1241   \def\makeheadline{%
1242     \vbox to 0pt{%
1243       \vskip-22.5pt
1244       \line{%
1245         \vbox to8.5pt{}%
1246         % Extract \thiscolor definition from the marks.
1247         \getcolormarks
1248         % Typeset the headline with \maincolor, then restore the color.
1249         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1250       }%
1251       \vss
1252     }%
1253     \nointerlineskip
1254   }
1255   %
1256   %
1257   \pdfcatalog{/PageMode /UseOutlines}
1258   %
1259   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1260   \def\dopdfimage#1#2#3{%
1261     \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1262     \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1263     %
1264     % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1265     % others).  Let's try in that order, PDF first since if
1266     % someone has a scalable image, presumably better to use that than a
1267     % bitmap.
1268     \let\pdfimgext=\empty
1269     \begingroup
1270       \openin 1 #1.pdf \ifeof 1
1271         \openin 1 #1.PDF \ifeof 1
1272           \openin 1 #1.png \ifeof 1
1273             \openin 1 #1.jpg \ifeof 1
1274               \openin 1 #1.jpeg \ifeof 1
1275                 \openin 1 #1.JPG \ifeof 1
1276                   \errhelp = \nopdfimagehelp
1277                   \errmessage{Could not find image file #1 for pdf}%
1278                 \else \gdef\pdfimgext{JPG}%
1279                 \fi
1280               \else \gdef\pdfimgext{jpeg}%
1281               \fi
1282             \else \gdef\pdfimgext{jpg}%
1283             \fi
1284           \else \gdef\pdfimgext{png}%
1285           \fi
1286         \else \gdef\pdfimgext{PDF}%
1287         \fi
1288       \else \gdef\pdfimgext{pdf}%
1289       \fi
1290       \closein 1
1291     \endgroup
1292     %
1293     % without \immediate, ancient pdftex seg faults when the same image is
1294     % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
1295     \ifnum\pdftexversion < 14
1296       \immediate\pdfimage
1297     \else
1298       \immediate\pdfximage
1299     \fi
1300       \ifdim \wd0 >0pt width \pdfimagewidth \fi
1301       \ifdim \wd2 >0pt height \pdfimageheight \fi
1302       \ifnum\pdftexversion<13
1303          #1.\pdfimgext
1304        \else
1305          {#1.\pdfimgext}%
1306        \fi
1307     \ifnum\pdftexversion < 14 \else
1308       \pdfrefximage \pdflastximage
1309     \fi}
1310   %
1311   \def\setpdfdestname#1{{%
1312     % We have to set dummies so commands such as @code, and characters
1313     % such as \, aren't expanded when present in a section title.
1314     \indexnofonts
1315     \makevalueexpandable
1316     \turnoffactive
1317     \iftxiuseunicodedestname
1318       \ifx \declaredencoding \latone
1319         % Pass through Latin-1 characters.
1320         % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode.
1321       \else
1322         \ifx \declaredencoding \utfeight
1323           % Pass through Unicode characters.
1324         \else
1325           % Use ASCII approximations in destination names.
1326           \passthroughcharsfalse
1327         \fi
1328       \fi
1329     \else
1330       % Use ASCII approximations in destination names.
1331       \passthroughcharsfalse
1332     \fi
1333     \def\pdfdestname{#1}%
1334     \txiescapepdf\pdfdestname
1335   }}
1336   %
1337   \def\setpdfoutlinetext#1{{%
1338     \indexnofonts
1339     \makevalueexpandable
1340     \turnoffactive
1341     \ifx \declaredencoding \latone
1342       % The PDF format can use an extended form of Latin-1 in bookmark
1343       % strings.  See Appendix D of the PDF Reference, Sixth Edition, for
1344       % the "PDFDocEncoding".
1345       \passthroughcharstrue
1346       % Pass through Latin-1 characters.
1347       %   LuaTeX: Convert to Unicode
1348       %   pdfTeX: Use Latin-1 as PDFDocEncoding
1349       \def\pdfoutlinetext{#1}%
1350     \else
1351       \ifx \declaredencoding \utfeight
1352         \ifx\luatexversion\thisisundefined
1353           % For pdfTeX  with UTF-8.
1354           % TODO: the PDF format can use UTF-16 in bookmark strings,
1355           % but the code for this isn't done yet.
1356           % Use ASCII approximations.
1357           \passthroughcharsfalse
1358           \def\pdfoutlinetext{#1}%
1359         \else
1360           % For LuaTeX with UTF-8.
1361           % Pass through Unicode characters for title texts.
1362           \passthroughcharstrue
1363           \def\pdfoutlinetext{#1}%
1364         \fi
1365       \else
1366         % For non-Latin-1 or non-UTF-8 encodings.
1367         % Use ASCII approximations.
1368         \passthroughcharsfalse
1369         \def\pdfoutlinetext{#1}%
1370       \fi
1371     \fi
1372     % LuaTeX: Convert to UTF-16
1373     % pdfTeX: Use Latin-1 as PDFDocEncoding
1374     \txiescapepdfutfsixteen\pdfoutlinetext
1375   }}
1376   %
1377   \def\pdfmkdest#1{%
1378     \setpdfdestname{#1}%
1379     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1380   }
1381   %
1382   % used to mark target names; must be expandable.
1383   \def\pdfmkpgn#1{#1}
1384   %
1385   % by default, use black for everything.
1386   \def\urlcolor{\rgbBlack}
1387   \def\linkcolor{\rgbBlack}
1388   \def\endlink{\setcolor{\maincolor}\pdfendlink}
1389   %
1390   % Adding outlines to PDF; macros for calculating structure of outlines
1391   % come from Petr Olsak
1392   \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1393     \else \csname#1\endcsname \fi}
1394   \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1395     \advance\tempnum by 1
1396     \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1397   %
1398   % #1 is the section text, which is what will be displayed in the
1399   % outline by the pdf viewer.  #2 is the pdf expression for the number
1400   % of subentries (or empty, for subsubsections).  #3 is the node text,
1401   % which might be empty if this toc entry had no corresponding node.
1402   % #4 is the page number
1403   %
1404   \def\dopdfoutline#1#2#3#4{%
1405     % Generate a link to the node text if that exists; else, use the
1406     % page number.  We could generate a destination for the section
1407     % text in the case where a section has no node, but it doesn't
1408     % seem worth the trouble, since most documents are normally structured.
1409     \setpdfoutlinetext{#1}
1410     \setpdfdestname{#3}
1411     \ifx\pdfdestname\empty
1412       \def\pdfdestname{#4}%
1413     \fi
1414     %
1415     \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}%
1416   }
1417   %
1418   \def\pdfmakeoutlines{%
1419     \begingroup
1420       % Read toc silently, to get counts of subentries for \pdfoutline.
1421       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1422       \def\numchapentry##1##2##3##4{%
1423         \def\thischapnum{##2}%
1424         \def\thissecnum{0}%
1425         \def\thissubsecnum{0}%
1426       }%
1427       \def\numsecentry##1##2##3##4{%
1428         \advancenumber{chap\thischapnum}%
1429         \def\thissecnum{##2}%
1430         \def\thissubsecnum{0}%
1431       }%
1432       \def\numsubsecentry##1##2##3##4{%
1433         \advancenumber{sec\thissecnum}%
1434         \def\thissubsecnum{##2}%
1435       }%
1436       \def\numsubsubsecentry##1##2##3##4{%
1437         \advancenumber{subsec\thissubsecnum}%
1438       }%
1439       \def\thischapnum{0}%
1440       \def\thissecnum{0}%
1441       \def\thissubsecnum{0}%
1442       %
1443       % use \def rather than \let here because we redefine \chapentry et
1444       % al. a second time, below.
1445       \def\appentry{\numchapentry}%
1446       \def\appsecentry{\numsecentry}%
1447       \def\appsubsecentry{\numsubsecentry}%
1448       \def\appsubsubsecentry{\numsubsubsecentry}%
1449       \def\unnchapentry{\numchapentry}%
1450       \def\unnsecentry{\numsecentry}%
1451       \def\unnsubsecentry{\numsubsecentry}%
1452       \def\unnsubsubsecentry{\numsubsubsecentry}%
1453       \readdatafile{toc}%
1454       %
1455       % Read toc second time, this time actually producing the outlines.
1456       % The `-' means take the \expnumber as the absolute number of
1457       % subentries, which we calculated on our first read of the .toc above.
1458       %
1459       % We use the node names as the destinations.
1460       \def\numchapentry##1##2##3##4{%
1461         \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1462       \def\numsecentry##1##2##3##4{%
1463         \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1464       \def\numsubsecentry##1##2##3##4{%
1465         \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1466       \def\numsubsubsecentry##1##2##3##4{% count is always zero
1467         \dopdfoutline{##1}{}{##3}{##4}}%
1468       %
1469       % PDF outlines are displayed using system fonts, instead of
1470       % document fonts.  Therefore we cannot use special characters,
1471       % since the encoding is unknown.  For example, the eogonek from
1472       % Latin 2 (0xea) gets translated to a | character.  Info from
1473       % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1474       %
1475       % TODO this right, we have to translate 8-bit characters to
1476       % their "best" equivalent, based on the @documentencoding.  Too
1477       % much work for too little return.  Just use the ASCII equivalents
1478       % we use for the index sort strings.
1479       % 
1480       \indexnofonts
1481       \setupdatafile
1482       % We can have normal brace characters in the PDF outlines, unlike
1483       % Texinfo index files.  So set that up.
1484       \def\{{\lbracecharliteral}%
1485       \def\}{\rbracecharliteral}%
1486       \catcode`\\=\active \otherbackslash
1487       \input \tocreadfilename
1488     \endgroup
1489   }
1490   {\catcode`[=1 \catcode`]=2
1491    \catcode`{=\other \catcode`}=\other
1492    \gdef\lbracecharliteral[{]%
1493    \gdef\rbracecharliteral[}]%
1494   ]
1495   %
1496   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1497     \ifx\PP\D\let\nextsp\relax
1498     \else\let\nextsp\skipspaces
1499       \addtokens{\filename}{\PP}%
1500       \advance\filenamelength by 1
1501     \fi
1502     \nextsp}
1503   \def\getfilename#1{%
1504     \filenamelength=0
1505     % If we don't expand the argument now, \skipspaces will get
1506     % snagged on things like "@value{foo}".
1507     \edef\temp{#1}%
1508     \expandafter\skipspaces\temp|\relax
1509   }
1510   \ifnum\pdftexversion < 14
1511     \let \startlink \pdfannotlink
1512   \else
1513     \let \startlink \pdfstartlink
1514   \fi
1515   % make a live url in pdf output.
1516   \def\pdfurl#1{%
1517     \begingroup
1518       % it seems we really need yet another set of dummies; have not
1519       % tried to figure out what each command should do in the context
1520       % of @url.  for now, just make @/ a no-op, that's the only one
1521       % people have actually reported a problem with.
1522       %
1523       \normalturnoffactive
1524       \def\@{@}%
1525       \let\/=\empty
1526       \makevalueexpandable
1527       % do we want to go so far as to use \indexnofonts instead of just
1528       % special-casing \var here?
1529       \def\var##1{##1}%
1530       %
1531       \leavevmode\setcolor{\urlcolor}%
1532       \startlink attr{/Border [0 0 0]}%
1533         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1534     \endgroup}
1535   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1536   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1537   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1538   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1539   \def\maketoks{%
1540     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1541     \ifx\first0\adn0
1542     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1543     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1544     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1545     \else
1546       \ifnum0=\countA\else\makelink\fi
1547       \ifx\first.\let\next=\done\else
1548         \let\next=\maketoks
1549         \addtokens{\toksB}{\the\toksD}
1550         \ifx\first,\addtokens{\toksB}{\space}\fi
1551       \fi
1552     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1553     \next}
1554   \def\makelink{\addtokens{\toksB}%
1555     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1556   \def\pdflink#1{%
1557     \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1558     \setcolor{\linkcolor}#1\endlink}
1559   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1560 \else
1561   % non-pdf mode
1562   \let\pdfmkdest = \gobble
1563   \let\pdfurl = \gobble
1564   \let\endlink = \relax
1565   \let\setcolor = \gobble
1566   \let\pdfsetcolor = \gobble
1567   \let\pdfmakeoutlines = \relax
1568 \fi  % \ifx\pdfoutput
1569
1570 %
1571 % For XeTeX
1572 %
1573 \ifx\XeTeXrevision\thisisundefined
1574 \else
1575   %
1576   % XeTeX version check
1577   %
1578   \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1
1579     % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307.
1580     % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941).
1581     % For avoiding PDF destination name replacement, we use this special
1582     % instead of xdvipdfmx's command line option `-C 0x0010'.
1583     \special{dvipdfmx:config C 0x0010}
1584     % XeTeX 0.99995+ comes with xdvipdfmx 20160307+.
1585     % It can handle Unicode destination names for PDF.
1586     \txiuseunicodedestnametrue
1587   \else
1588     % XeTeX < 0.99996 (TeX Live < 2016) cannot use the
1589     % `dvipdfmx:config' special.
1590     % So for avoiding PDF destination name replacement,
1591     % xdvipdfmx's command line option `-C 0x0010' is necessary.
1592     %
1593     % XeTeX < 0.99995 can not handle Unicode destination names for PDF
1594     % because xdvipdfmx 20150315 has a UTF-16 conversion issue.
1595     % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1596     \txiuseunicodedestnamefalse
1597   \fi
1598   %
1599   % Color support
1600   %
1601   \def\rgbDarkRed{0.50 0.09 0.12}
1602   \def\rgbBlack{0 0 0}
1603   %
1604   \def\pdfsetcolor#1{\special{pdf:scolor [#1]}}
1605   %
1606   % Set color, and create a mark which defines \thiscolor accordingly,
1607   % so that \makeheadline knows which color to restore.
1608   \def\setcolor#1{%
1609     \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
1610     \domark
1611     \pdfsetcolor{#1}%
1612   }
1613   %
1614   \def\maincolor{\rgbBlack}
1615   \pdfsetcolor{\maincolor}
1616   \edef\thiscolor{\maincolor}
1617   \def\lastcolordefs{}
1618   %
1619   \def\makefootline{%
1620     \baselineskip24pt
1621     \line{\pdfsetcolor{\maincolor}\the\footline}%
1622   }
1623   %
1624   \def\makeheadline{%
1625     \vbox to 0pt{%
1626       \vskip-22.5pt
1627       \line{%
1628         \vbox to8.5pt{}%
1629         % Extract \thiscolor definition from the marks.
1630         \getcolormarks
1631         % Typeset the headline with \maincolor, then restore the color.
1632         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1633       }%
1634       \vss
1635     }%
1636     \nointerlineskip
1637   }
1638   %
1639   % PDF outline support
1640   %
1641   % Emulate pdfTeX primitive
1642   \def\pdfdest name#1 xyz{%
1643     \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}%
1644   }
1645   %
1646   \def\setpdfdestname#1{{%
1647     % We have to set dummies so commands such as @code, and characters
1648     % such as \, aren't expanded when present in a section title.
1649     \indexnofonts
1650     \makevalueexpandable
1651     \turnoffactive
1652     \iftxiuseunicodedestname
1653       % Pass through Unicode characters.
1654     \else
1655       % Use ASCII approximations in destination names.
1656       \passthroughcharsfalse
1657     \fi
1658     \def\pdfdestname{#1}%
1659     \txiescapepdf\pdfdestname
1660   }}
1661   %
1662   \def\setpdfoutlinetext#1{{%
1663     \turnoffactive
1664     % Always use Unicode characters in title texts.
1665     \def\pdfoutlinetext{#1}%
1666     % For XeTeX, xdvipdfmx converts to UTF-16.
1667     % So we do not convert.
1668     \txiescapepdf\pdfoutlinetext
1669   }}
1670   %
1671   \def\pdfmkdest#1{%
1672     \setpdfdestname{#1}%
1673     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1674   }
1675   %
1676   % by default, use black for everything.
1677   \def\urlcolor{\rgbBlack}
1678   \def\linkcolor{\rgbBlack}
1679   \def\endlink{\setcolor{\maincolor}\pdfendlink}
1680   %
1681   \def\dopdfoutline#1#2#3#4{%
1682     \setpdfoutlinetext{#1}
1683     \setpdfdestname{#3}
1684     \ifx\pdfdestname\empty
1685       \def\pdfdestname{#4}%
1686     \fi
1687     %
1688     \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
1689       << /S /GoTo /D (\pdfdestname) >> >> }%
1690   }
1691   %
1692   \def\pdfmakeoutlines{%
1693     \begingroup
1694       %
1695       % For XeTeX, counts of subentries are not necessary.
1696       % Therefore, we read toc only once.
1697       %
1698       % We use node names as destinations.
1699       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1700       \def\numchapentry##1##2##3##4{%
1701         \dopdfoutline{##1}{1}{##3}{##4}}%
1702       \def\numsecentry##1##2##3##4{%
1703         \dopdfoutline{##1}{2}{##3}{##4}}%
1704       \def\numsubsecentry##1##2##3##4{%
1705         \dopdfoutline{##1}{3}{##3}{##4}}%
1706       \def\numsubsubsecentry##1##2##3##4{%
1707         \dopdfoutline{##1}{4}{##3}{##4}}%
1708       %
1709       \let\appentry\numchapentry%
1710       \let\appsecentry\numsecentry%
1711       \let\appsubsecentry\numsubsecentry%
1712       \let\appsubsubsecentry\numsubsubsecentry%
1713       \let\unnchapentry\numchapentry%
1714       \let\unnsecentry\numsecentry%
1715       \let\unnsubsecentry\numsubsecentry%
1716       \let\unnsubsubsecentry\numsubsubsecentry%
1717       %
1718       % For XeTeX, xdvipdfmx converts strings to UTF-16.
1719       % Therefore, the encoding and the language may not be considered.
1720       %
1721       \indexnofonts
1722       \setupdatafile
1723       % We can have normal brace characters in the PDF outlines, unlike
1724       % Texinfo index files.  So set that up.
1725       \def\{{\lbracecharliteral}%
1726       \def\}{\rbracecharliteral}%
1727       \catcode`\\=\active \otherbackslash
1728       \input \tocreadfilename
1729     \endgroup
1730   }
1731   {\catcode`[=1 \catcode`]=2
1732    \catcode`{=\other \catcode`}=\other
1733    \gdef\lbracecharliteral[{]%
1734    \gdef\rbracecharliteral[}]%
1735   ]
1736
1737   \special{pdf:docview << /PageMode /UseOutlines >> }
1738   % ``\special{pdf:tounicode ...}'' is not necessary
1739   % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
1740   % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315,
1741   % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings.
1742   % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1743 %
1744   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1745     \ifx\PP\D\let\nextsp\relax
1746     \else\let\nextsp\skipspaces
1747       \addtokens{\filename}{\PP}%
1748       \advance\filenamelength by 1
1749     \fi
1750     \nextsp}
1751   \def\getfilename#1{%
1752     \filenamelength=0
1753     % If we don't expand the argument now, \skipspaces will get
1754     % snagged on things like "@value{foo}".
1755     \edef\temp{#1}%
1756     \expandafter\skipspaces\temp|\relax
1757   }
1758   % make a live url in pdf output.
1759   \def\pdfurl#1{%
1760     \begingroup
1761       % it seems we really need yet another set of dummies; have not
1762       % tried to figure out what each command should do in the context
1763       % of @url.  for now, just make @/ a no-op, that's the only one
1764       % people have actually reported a problem with.
1765       %
1766       \normalturnoffactive
1767       \def\@{@}%
1768       \let\/=\empty
1769       \makevalueexpandable
1770       % do we want to go so far as to use \indexnofonts instead of just
1771       % special-casing \var here?
1772       \def\var##1{##1}%
1773       %
1774       \leavevmode\setcolor{\urlcolor}%
1775       \special{pdf:bann << /Border [0 0 0]
1776         /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
1777     \endgroup}
1778   \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
1779   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1780   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1781   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1782   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1783   \def\maketoks{%
1784     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1785     \ifx\first0\adn0
1786     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1787     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1788     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1789     \else
1790       \ifnum0=\countA\else\makelink\fi
1791       \ifx\first.\let\next=\done\else
1792         \let\next=\maketoks
1793         \addtokens{\toksB}{\the\toksD}
1794         \ifx\first,\addtokens{\toksB}{\space}\fi
1795       \fi
1796     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1797     \next}
1798   \def\makelink{\addtokens{\toksB}%
1799     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1800   \def\pdflink#1{%
1801     \special{pdf:bann << /Border [0 0 0]
1802       /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}%
1803     \setcolor{\linkcolor}#1\endlink}
1804   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1805 %
1806   %
1807   % @image support
1808   %
1809   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1810   \def\doxeteximage#1#2#3{%
1811     \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1812     \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1813     %
1814     % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among
1815     % others).  Let's try in that order, PDF first since if
1816     % someone has a scalable image, presumably better to use that than a
1817     % bitmap.
1818     \let\xeteximgext=\empty
1819     \begingroup
1820       \openin 1 #1.pdf \ifeof 1
1821         \openin 1 #1.PDF \ifeof 1
1822           \openin 1 #1.png \ifeof 1
1823             \openin 1 #1.jpg \ifeof 1
1824               \openin 1 #1.jpeg \ifeof 1
1825                 \openin 1 #1.JPG \ifeof 1
1826                   \errmessage{Could not find image file #1 for XeTeX}%
1827                 \else \gdef\xeteximgext{JPG}%
1828                 \fi
1829               \else \gdef\xeteximgext{jpeg}%
1830               \fi
1831             \else \gdef\xeteximgext{jpg}%
1832             \fi
1833           \else \gdef\xeteximgext{png}%
1834           \fi
1835         \else \gdef\xeteximgext{PDF}%
1836         \fi
1837       \else \gdef\xeteximgext{pdf}%
1838       \fi
1839       \closein 1
1840     \endgroup
1841     %
1842     \def\xetexpdfext{pdf}%
1843     \ifx\xeteximgext\xetexpdfext
1844       \XeTeXpdffile "#1".\xeteximgext ""
1845     \else
1846       \def\xetexpdfext{PDF}%
1847       \ifx\xeteximgext\xetexpdfext
1848         \XeTeXpdffile "#1".\xeteximgext ""
1849       \else
1850         \XeTeXpicfile "#1".\xeteximgext ""
1851       \fi
1852     \fi
1853     \ifdim \wd0 >0pt width \xeteximagewidth \fi
1854     \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1855   }
1856 \fi
1857
1858
1859 %
1860 \message{fonts,}
1861
1862 % Set the baselineskip to #1, and the lineskip and strut size
1863 % correspondingly.  There is no deep meaning behind these magic numbers
1864 % used as factors; they just match (closely enough) what Knuth defined.
1865 %
1866 \def\lineskipfactor{.08333}
1867 \def\strutheightpercent{.70833}
1868 \def\strutdepthpercent {.29167}
1869 %
1870 % can get a sort of poor man's double spacing by redefining this.
1871 \def\baselinefactor{1}
1872 %
1873 \newdimen\textleading
1874 \def\setleading#1{%
1875   \dimen0 = #1\relax
1876   \normalbaselineskip = \baselinefactor\dimen0
1877   \normallineskip = \lineskipfactor\normalbaselineskip
1878   \normalbaselines
1879   \setbox\strutbox =\hbox{%
1880     \vrule width0pt height\strutheightpercent\baselineskip
1881                     depth \strutdepthpercent \baselineskip
1882   }%
1883 }
1884
1885 % PDF CMaps.  See also LaTeX's t1.cmap.
1886 %
1887 % do nothing with this by default.
1888 \expandafter\let\csname cmapOT1\endcsname\gobble
1889 \expandafter\let\csname cmapOT1IT\endcsname\gobble
1890 \expandafter\let\csname cmapOT1TT\endcsname\gobble
1891
1892 % if we are producing pdf, and we have \pdffontattr, then define cmaps.
1893 % (\pdffontattr was introduced many years ago, but people still run
1894 % older pdftex's; it's easy to conditionalize, so we do.)
1895 \ifpdf \ifx\pdffontattr\thisisundefined \else
1896   \begingroup
1897     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1898     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1899 %%DocumentNeededResources: ProcSet (CIDInit)
1900 %%IncludeResource: ProcSet (CIDInit)
1901 %%BeginResource: CMap (TeX-OT1-0)
1902 %%Title: (TeX-OT1-0 TeX OT1 0)
1903 %%Version: 1.000
1904 %%EndComments
1905 /CIDInit /ProcSet findresource begin
1906 12 dict begin
1907 begincmap
1908 /CIDSystemInfo
1909 << /Registry (TeX)
1910 /Ordering (OT1)
1911 /Supplement 0
1912 >> def
1913 /CMapName /TeX-OT1-0 def
1914 /CMapType 2 def
1915 1 begincodespacerange
1916 <00> <7F>
1917 endcodespacerange
1918 8 beginbfrange
1919 <00> <01> <0393>
1920 <09> <0A> <03A8>
1921 <23> <26> <0023>
1922 <28> <3B> <0028>
1923 <3F> <5B> <003F>
1924 <5D> <5E> <005D>
1925 <61> <7A> <0061>
1926 <7B> <7C> <2013>
1927 endbfrange
1928 40 beginbfchar
1929 <02> <0398>
1930 <03> <039B>
1931 <04> <039E>
1932 <05> <03A0>
1933 <06> <03A3>
1934 <07> <03D2>
1935 <08> <03A6>
1936 <0B> <00660066>
1937 <0C> <00660069>
1938 <0D> <0066006C>
1939 <0E> <006600660069>
1940 <0F> <00660066006C>
1941 <10> <0131>
1942 <11> <0237>
1943 <12> <0060>
1944 <13> <00B4>
1945 <14> <02C7>
1946 <15> <02D8>
1947 <16> <00AF>
1948 <17> <02DA>
1949 <18> <00B8>
1950 <19> <00DF>
1951 <1A> <00E6>
1952 <1B> <0153>
1953 <1C> <00F8>
1954 <1D> <00C6>
1955 <1E> <0152>
1956 <1F> <00D8>
1957 <21> <0021>
1958 <22> <201D>
1959 <27> <2019>
1960 <3C> <00A1>
1961 <3D> <003D>
1962 <3E> <00BF>
1963 <5C> <201C>
1964 <5F> <02D9>
1965 <60> <2018>
1966 <7D> <02DD>
1967 <7E> <007E>
1968 <7F> <00A8>
1969 endbfchar
1970 endcmap
1971 CMapName currentdict /CMap defineresource pop
1972 end
1973 end
1974 %%EndResource
1975 %%EOF
1976     }\endgroup
1977   \expandafter\edef\csname cmapOT1\endcsname#1{%
1978     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1979   }%
1980 %
1981 % \cmapOT1IT
1982   \begingroup
1983     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1984     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1985 %%DocumentNeededResources: ProcSet (CIDInit)
1986 %%IncludeResource: ProcSet (CIDInit)
1987 %%BeginResource: CMap (TeX-OT1IT-0)
1988 %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
1989 %%Version: 1.000
1990 %%EndComments
1991 /CIDInit /ProcSet findresource begin
1992 12 dict begin
1993 begincmap
1994 /CIDSystemInfo
1995 << /Registry (TeX)
1996 /Ordering (OT1IT)
1997 /Supplement 0
1998 >> def
1999 /CMapName /TeX-OT1IT-0 def
2000 /CMapType 2 def
2001 1 begincodespacerange
2002 <00> <7F>
2003 endcodespacerange
2004 8 beginbfrange
2005 <00> <01> <0393>
2006 <09> <0A> <03A8>
2007 <25> <26> <0025>
2008 <28> <3B> <0028>
2009 <3F> <5B> <003F>
2010 <5D> <5E> <005D>
2011 <61> <7A> <0061>
2012 <7B> <7C> <2013>
2013 endbfrange
2014 42 beginbfchar
2015 <02> <0398>
2016 <03> <039B>
2017 <04> <039E>
2018 <05> <03A0>
2019 <06> <03A3>
2020 <07> <03D2>
2021 <08> <03A6>
2022 <0B> <00660066>
2023 <0C> <00660069>
2024 <0D> <0066006C>
2025 <0E> <006600660069>
2026 <0F> <00660066006C>
2027 <10> <0131>
2028 <11> <0237>
2029 <12> <0060>
2030 <13> <00B4>
2031 <14> <02C7>
2032 <15> <02D8>
2033 <16> <00AF>
2034 <17> <02DA>
2035 <18> <00B8>
2036 <19> <00DF>
2037 <1A> <00E6>
2038 <1B> <0153>
2039 <1C> <00F8>
2040 <1D> <00C6>
2041 <1E> <0152>
2042 <1F> <00D8>
2043 <21> <0021>
2044 <22> <201D>
2045 <23> <0023>
2046 <24> <00A3>
2047 <27> <2019>
2048 <3C> <00A1>
2049 <3D> <003D>
2050 <3E> <00BF>
2051 <5C> <201C>
2052 <5F> <02D9>
2053 <60> <2018>
2054 <7D> <02DD>
2055 <7E> <007E>
2056 <7F> <00A8>
2057 endbfchar
2058 endcmap
2059 CMapName currentdict /CMap defineresource pop
2060 end
2061 end
2062 %%EndResource
2063 %%EOF
2064     }\endgroup
2065   \expandafter\edef\csname cmapOT1IT\endcsname#1{%
2066     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2067   }%
2068 %
2069 % \cmapOT1TT
2070   \begingroup
2071     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2072     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2073 %%DocumentNeededResources: ProcSet (CIDInit)
2074 %%IncludeResource: ProcSet (CIDInit)
2075 %%BeginResource: CMap (TeX-OT1TT-0)
2076 %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
2077 %%Version: 1.000
2078 %%EndComments
2079 /CIDInit /ProcSet findresource begin
2080 12 dict begin
2081 begincmap
2082 /CIDSystemInfo
2083 << /Registry (TeX)
2084 /Ordering (OT1TT)
2085 /Supplement 0
2086 >> def
2087 /CMapName /TeX-OT1TT-0 def
2088 /CMapType 2 def
2089 1 begincodespacerange
2090 <00> <7F>
2091 endcodespacerange
2092 5 beginbfrange
2093 <00> <01> <0393>
2094 <09> <0A> <03A8>
2095 <21> <26> <0021>
2096 <28> <5F> <0028>
2097 <61> <7E> <0061>
2098 endbfrange
2099 32 beginbfchar
2100 <02> <0398>
2101 <03> <039B>
2102 <04> <039E>
2103 <05> <03A0>
2104 <06> <03A3>
2105 <07> <03D2>
2106 <08> <03A6>
2107 <0B> <2191>
2108 <0C> <2193>
2109 <0D> <0027>
2110 <0E> <00A1>
2111 <0F> <00BF>
2112 <10> <0131>
2113 <11> <0237>
2114 <12> <0060>
2115 <13> <00B4>
2116 <14> <02C7>
2117 <15> <02D8>
2118 <16> <00AF>
2119 <17> <02DA>
2120 <18> <00B8>
2121 <19> <00DF>
2122 <1A> <00E6>
2123 <1B> <0153>
2124 <1C> <00F8>
2125 <1D> <00C6>
2126 <1E> <0152>
2127 <1F> <00D8>
2128 <20> <2423>
2129 <27> <2019>
2130 <60> <2018>
2131 <7F> <00A8>
2132 endbfchar
2133 endcmap
2134 CMapName currentdict /CMap defineresource pop
2135 end
2136 end
2137 %%EndResource
2138 %%EOF
2139     }\endgroup
2140   \expandafter\edef\csname cmapOT1TT\endcsname#1{%
2141     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2142   }%
2143 \fi\fi
2144
2145
2146 % Set the font macro #1 to the font named \fontprefix#2.
2147 % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
2148 % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
2149 % Example:
2150 % #1 = \textrm
2151 % #2 = \rmshape
2152 % #3 = 10
2153 % #4 = \mainmagstep
2154 % #5 = OT1
2155 %
2156 \def\setfont#1#2#3#4#5{%
2157   \font#1=\fontprefix#2#3 scaled #4
2158   \csname cmap#5\endcsname#1%
2159 }
2160 % This is what gets called when #5 of \setfont is empty.
2161 \let\cmap\gobble
2162 %
2163 % (end of cmaps)
2164
2165 % Use cm as the default font prefix.
2166 % To specify the font prefix, you must define \fontprefix
2167 % before you read in texinfo.tex.
2168 \ifx\fontprefix\thisisundefined
2169 \def\fontprefix{cm}
2170 \fi
2171 % Support font families that don't use the same naming scheme as CM.
2172 \def\rmshape{r}
2173 \def\rmbshape{bx}               % where the normal face is bold
2174 \def\bfshape{b}
2175 \def\bxshape{bx}
2176 \def\ttshape{tt}
2177 \def\ttbshape{tt}
2178 \def\ttslshape{sltt}
2179 \def\itshape{ti}
2180 \def\itbshape{bxti}
2181 \def\slshape{sl}
2182 \def\slbshape{bxsl}
2183 \def\sfshape{ss}
2184 \def\sfbshape{ss}
2185 \def\scshape{csc}
2186 \def\scbshape{csc}
2187
2188 % Definitions for a main text size of 11pt.  (The default in Texinfo.)
2189 %
2190 \def\definetextfontsizexi{%
2191 % Text fonts (11.2pt, magstep1).
2192 \def\textnominalsize{11pt}
2193 \edef\mainmagstep{\magstephalf}
2194 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2195 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2196 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2197 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2198 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2199 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2200 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2201 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2202 \font\texti=cmmi10 scaled \mainmagstep
2203 \font\textsy=cmsy10 scaled \mainmagstep
2204 \def\textecsize{1095}
2205
2206 % A few fonts for @defun names and args.
2207 \setfont\defbf\bfshape{10}{\magstep1}{OT1}
2208 \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
2209 \setfont\defsl\slshape{10}{\magstep1}{OT1TT}
2210 \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
2211 \def\df{\let\ttfont=\deftt \let\bffont = \defbf
2212 \let\ttfontsl=\defttsl \let\slfont=\defsl \bf}
2213
2214 % Fonts for indices, footnotes, small examples (9pt).
2215 \def\smallnominalsize{9pt}
2216 \setfont\smallrm\rmshape{9}{1000}{OT1}
2217 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2218 \setfont\smallbf\bfshape{10}{900}{OT1}
2219 \setfont\smallit\itshape{9}{1000}{OT1IT}
2220 \setfont\smallsl\slshape{9}{1000}{OT1}
2221 \setfont\smallsf\sfshape{9}{1000}{OT1}
2222 \setfont\smallsc\scshape{10}{900}{OT1}
2223 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2224 \font\smalli=cmmi9
2225 \font\smallsy=cmsy9
2226 \def\smallecsize{0900}
2227
2228 % Fonts for small examples (8pt).
2229 \def\smallernominalsize{8pt}
2230 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2231 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2232 \setfont\smallerbf\bfshape{10}{800}{OT1}
2233 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2234 \setfont\smallersl\slshape{8}{1000}{OT1}
2235 \setfont\smallersf\sfshape{8}{1000}{OT1}
2236 \setfont\smallersc\scshape{10}{800}{OT1}
2237 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2238 \font\smalleri=cmmi8
2239 \font\smallersy=cmsy8
2240 \def\smallerecsize{0800}
2241
2242 % Fonts for title page (20.4pt):
2243 \def\titlenominalsize{20pt}
2244 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2245 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2246 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2247 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2248 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2249 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2250 \let\titlebf=\titlerm
2251 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2252 \font\titlei=cmmi12 scaled \magstep3
2253 \font\titlesy=cmsy10 scaled \magstep4
2254 \def\titleecsize{2074}
2255
2256 % Chapter (and unnumbered) fonts (17.28pt).
2257 \def\chapnominalsize{17pt}
2258 \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2259 \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2260 \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2261 \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2262 \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2263 \setfont\chapsf\sfbshape{17}{1000}{OT1}
2264 \let\chapbf=\chaprm
2265 \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
2266 \font\chapi=cmmi12 scaled \magstep2
2267 \font\chapsy=cmsy10 scaled \magstep3
2268 \def\chapecsize{1728}
2269
2270 % Section fonts (14.4pt).
2271 \def\secnominalsize{14pt}
2272 \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
2273 \setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
2274 \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2275 \setfont\secsl\slbshape{10}{\magstep2}{OT1}
2276 \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2277 \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2278 \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
2279 \let\secbf\secrm
2280 \setfont\secsc\scbshape{10}{\magstep2}{OT1}
2281 \font\seci=cmmi12 scaled \magstep1
2282 \font\secsy=cmsy10 scaled \magstep2
2283 \def\sececsize{1440}
2284
2285 % Subsection fonts (13.15pt).
2286 \def\ssecnominalsize{13pt}
2287 \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2288 \setfont\ssecit\itbshape{10}{1315}{OT1IT}
2289 \setfont\ssecsl\slbshape{10}{1315}{OT1}
2290 \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2291 \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2292 \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
2293 \let\ssecbf\ssecrm
2294 \setfont\ssecsc\scbshape{10}{1315}{OT1}
2295 \font\sseci=cmmi12 scaled \magstephalf
2296 \font\ssecsy=cmsy10 scaled 1315
2297 \def\ssececsize{1200}
2298
2299 % Reduced fonts for @acro in text (10pt).
2300 \def\reducednominalsize{10pt}
2301 \setfont\reducedrm\rmshape{10}{1000}{OT1}
2302 \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2303 \setfont\reducedbf\bfshape{10}{1000}{OT1}
2304 \setfont\reducedit\itshape{10}{1000}{OT1IT}
2305 \setfont\reducedsl\slshape{10}{1000}{OT1}
2306 \setfont\reducedsf\sfshape{10}{1000}{OT1}
2307 \setfont\reducedsc\scshape{10}{1000}{OT1}
2308 \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
2309 \font\reducedi=cmmi10
2310 \font\reducedsy=cmsy10
2311 \def\reducedecsize{1000}
2312
2313 \textleading = 13.2pt % line spacing for 11pt CM
2314 \textfonts            % reset the current fonts
2315 \rm
2316 } % end of 11pt text font size definitions, \definetextfontsizexi
2317
2318
2319 % Definitions to make the main text be 10pt Computer Modern, with
2320 % section, chapter, etc., sizes following suit.  This is for the GNU
2321 % Press printing of the Emacs 22 manual.  Maybe other manuals in the
2322 % future.  Used with @smallbook, which sets the leading to 12pt.
2323 %
2324 \def\definetextfontsizex{%
2325 % Text fonts (10pt).
2326 \def\textnominalsize{10pt}
2327 \edef\mainmagstep{1000}
2328 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2329 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2330 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2331 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2332 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2333 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2334 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2335 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2336 \font\texti=cmmi10 scaled \mainmagstep
2337 \font\textsy=cmsy10 scaled \mainmagstep
2338 \def\textecsize{1000}
2339
2340 % A few fonts for @defun names and args.
2341 \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2342 \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
2343 \setfont\defsl\slshape{10}{\magstephalf}{OT1TT}
2344 \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
2345 \def\df{\let\ttfont=\deftt \let\bffont = \defbf
2346 \let\slfont=\defsl \let\ttfontsl=\defttsl \bf}
2347
2348 % Fonts for indices, footnotes, small examples (9pt).
2349 \def\smallnominalsize{9pt}
2350 \setfont\smallrm\rmshape{9}{1000}{OT1}
2351 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2352 \setfont\smallbf\bfshape{10}{900}{OT1}
2353 \setfont\smallit\itshape{9}{1000}{OT1IT}
2354 \setfont\smallsl\slshape{9}{1000}{OT1}
2355 \setfont\smallsf\sfshape{9}{1000}{OT1}
2356 \setfont\smallsc\scshape{10}{900}{OT1}
2357 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2358 \font\smalli=cmmi9
2359 \font\smallsy=cmsy9
2360 \def\smallecsize{0900}
2361
2362 % Fonts for small examples (8pt).
2363 \def\smallernominalsize{8pt}
2364 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2365 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2366 \setfont\smallerbf\bfshape{10}{800}{OT1}
2367 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2368 \setfont\smallersl\slshape{8}{1000}{OT1}
2369 \setfont\smallersf\sfshape{8}{1000}{OT1}
2370 \setfont\smallersc\scshape{10}{800}{OT1}
2371 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2372 \font\smalleri=cmmi8
2373 \font\smallersy=cmsy8
2374 \def\smallerecsize{0800}
2375
2376 % Fonts for title page (20.4pt):
2377 \def\titlenominalsize{20pt}
2378 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2379 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2380 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2381 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2382 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2383 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2384 \let\titlebf=\titlerm
2385 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2386 \font\titlei=cmmi12 scaled \magstep3
2387 \font\titlesy=cmsy10 scaled \magstep4
2388 \def\titleecsize{2074}
2389
2390 % Chapter fonts (14.4pt).
2391 \def\chapnominalsize{14pt}
2392 \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2393 \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2394 \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2395 \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2396 \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2397 \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2398 \let\chapbf\chaprm
2399 \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2400 \font\chapi=cmmi12 scaled \magstep1
2401 \font\chapsy=cmsy10 scaled \magstep2
2402 \def\chapecsize{1440}
2403
2404 % Section fonts (12pt).
2405 \def\secnominalsize{12pt}
2406 \setfont\secrm\rmbshape{12}{1000}{OT1}
2407 \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2408 \setfont\secsl\slbshape{10}{\magstep1}{OT1}
2409 \setfont\sectt\ttbshape{12}{1000}{OT1TT}
2410 \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2411 \setfont\secsf\sfbshape{12}{1000}{OT1}
2412 \let\secbf\secrm
2413 \setfont\secsc\scbshape{10}{\magstep1}{OT1}
2414 \font\seci=cmmi12
2415 \font\secsy=cmsy10 scaled \magstep1
2416 \def\sececsize{1200}
2417
2418 % Subsection fonts (10pt).
2419 \def\ssecnominalsize{10pt}
2420 \setfont\ssecrm\rmbshape{10}{1000}{OT1}
2421 \setfont\ssecit\itbshape{10}{1000}{OT1IT}
2422 \setfont\ssecsl\slbshape{10}{1000}{OT1}
2423 \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2424 \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2425 \setfont\ssecsf\sfbshape{10}{1000}{OT1}
2426 \let\ssecbf\ssecrm
2427 \setfont\ssecsc\scbshape{10}{1000}{OT1}
2428 \font\sseci=cmmi10
2429 \font\ssecsy=cmsy10
2430 \def\ssececsize{1000}
2431
2432 % Reduced fonts for @acro in text (9pt).
2433 \def\reducednominalsize{9pt}
2434 \setfont\reducedrm\rmshape{9}{1000}{OT1}
2435 \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2436 \setfont\reducedbf\bfshape{10}{900}{OT1}
2437 \setfont\reducedit\itshape{9}{1000}{OT1IT}
2438 \setfont\reducedsl\slshape{9}{1000}{OT1}
2439 \setfont\reducedsf\sfshape{9}{1000}{OT1}
2440 \setfont\reducedsc\scshape{10}{900}{OT1}
2441 \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2442 \font\reducedi=cmmi9
2443 \font\reducedsy=cmsy9
2444 \def\reducedecsize{0900}
2445
2446 \divide\parskip by 2  % reduce space between paragraphs
2447 \textleading = 12pt   % line spacing for 10pt CM
2448 \textfonts            % reset the current fonts
2449 \rm
2450 } % end of 10pt text font size definitions, \definetextfontsizex
2451
2452 % Fonts for short table of contents.
2453 \setfont\shortcontrm\rmshape{12}{1000}{OT1}
2454 \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
2455 \setfont\shortcontsl\slshape{12}{1000}{OT1}
2456 \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2457
2458
2459 % We provide the user-level command
2460 %   @fonttextsize 10
2461 % (or 11) to redefine the text font size.  pt is assumed.
2462 %
2463 \def\xiword{11}
2464 \def\xword{10}
2465 \def\xwordpt{10pt}
2466 %
2467 \parseargdef\fonttextsize{%
2468   \def\textsizearg{#1}%
2469   %\wlog{doing @fonttextsize \textsizearg}%
2470   %
2471   % Set \globaldefs so that documents can use this inside @tex, since
2472   % makeinfo 4.8 does not support it, but we need it nonetheless.
2473   %
2474  \begingroup \globaldefs=1
2475   \ifx\textsizearg\xword \definetextfontsizex
2476   \else \ifx\textsizearg\xiword \definetextfontsizexi
2477   \else
2478     \errhelp=\EMsimple
2479     \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2480   \fi\fi
2481  \endgroup
2482 }
2483
2484 %
2485 % Change the current font style to #1, remembering it in \curfontstyle.
2486 % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
2487 % italics, not bold italics.
2488 %
2489 \def\setfontstyle#1{%
2490   \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
2491   \csname #1font\endcsname  % change the current font
2492 }
2493
2494 \def\rm{\fam=0 \setfontstyle{rm}}
2495 \def\it{\fam=\itfam \setfontstyle{it}}
2496 \def\sl{\fam=\slfam \setfontstyle{sl}}
2497 \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
2498 \def\tt{\fam=\ttfam \setfontstyle{tt}}
2499
2500 % Unfortunately, we have to override this for titles and the like, since
2501 % in those cases "rm" is bold.  Sigh.
2502 \def\rmisbold{\rm\def\curfontstyle{bf}}
2503
2504 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
2505 % So we set up a \sf.
2506 \newfam\sffam
2507 \def\sf{\fam=\sffam \setfontstyle{sf}}
2508
2509 % We don't need math for this font style.
2510 \def\ttsl{\setfontstyle{ttsl}}
2511
2512
2513 % In order for the font changes to affect most math symbols and letters,
2514 % we have to define the \textfont of the standard families.  We don't
2515 % bother to reset \scriptfont and \scriptscriptfont; awaiting user need.
2516 %
2517 \def\resetmathfonts{%
2518   \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont
2519   \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont
2520   \textfont\ttfam=\ttfont \textfont\sffam=\sffont
2521 }
2522
2523 % Select #1 fonts with the current style.  Used to change font size
2524 % in, e.g., the LaTeX logo and acronyms.
2525 %
2526 \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
2527
2528 % The font-changing commands (all called \...fonts) redefine the meanings of 
2529 % \STYLEfont, instead
2530 % of just \STYLE.  We do this because \STYLE needs to also set the
2531 % current \fam for math mode.  Our \STYLE (e.g., \rm) commands hardwire
2532 % \STYLEfont to set the current font.
2533 %
2534 % Each font-changing command also sets the names \lsize (one size lower)
2535 % and \lllsize (three sizes lower).  These relative commands are used
2536 % in, e.g., the LaTeX logo and acronyms.
2537 %
2538 % This all needs generalizing, badly.
2539 %
2540 \def\textfonts{%
2541   \let\rmfont=\textrm \let\itfont=\textit \let\slfont=\textsl
2542   \let\bffont=\textbf \let\ttfont=\texttt \let\smallcaps=\textsc
2543   \let\sffont=\textsf \let\ifont=\texti \let\syfont=\textsy
2544   \let\ttfontsl=\textttsl
2545   \def\curfontsize{text}%
2546   \def\lsize{reduced}\def\lllsize{smaller}%
2547   \resetmathfonts \setleading{\textleading}}
2548 \def\titlefonts{%
2549   \let\rmfont=\titlerm \let\itfont=\titleit \let\slfont=\titlesl
2550   \let\bffont=\titlebf \let\ttfont=\titlett \let\smallcaps=\titlesc
2551   \let\sffont=\titlesf \let\ifont=\titlei \let\syfont=\titlesy
2552   \let\ttfontsl=\titlettsl
2553   \def\curfontsize{title}%
2554   \def\lsize{chap}\def\lllsize{subsec}%
2555   \resetmathfonts \setleading{27pt}}
2556 \def\titlefont#1{{\titlefonts\rmisbold #1}}
2557 \def\chapfonts{%
2558   \let\rmfont=\chaprm \let\itfont=\chapit \let\slfont=\chapsl
2559   \let\bffont=\chapbf \let\ttfont=\chaptt \let\smallcaps=\chapsc
2560   \let\sffont=\chapsf \let\ifont=\chapi \let\syfont=\chapsy
2561   \let\ttfontsl=\chapttsl
2562   \def\curfontsize{chap}%
2563   \def\lsize{sec}\def\lllsize{text}%
2564   \resetmathfonts \setleading{19pt}}
2565 \def\secfonts{%
2566   \let\rmfont=\secrm \let\itfont=\secit \let\slfont=\secsl
2567   \let\bffont=\secbf \let\ttfont=\sectt \let\smallcaps=\secsc
2568   \let\sffont=\secsf \let\ifont=\seci \let\syfont=\secsy
2569   \let\ttfontsl=\secttsl
2570   \def\curfontsize{sec}%
2571   \def\lsize{subsec}\def\lllsize{reduced}%
2572   \resetmathfonts \setleading{17pt}}
2573 \def\subsecfonts{%
2574   \let\rmfont=\ssecrm \let\itfont=\ssecit \let\slfont=\ssecsl
2575   \let\bffont=\ssecbf \let\ttfont=\ssectt \let\smallcaps=\ssecsc
2576   \let\sffont=\ssecsf \let\ifont=\sseci \let\syfont=\ssecsy
2577   \let\ttfontsl=\ssecttsl
2578   \def\curfontsize{ssec}%
2579   \def\lsize{text}\def\lllsize{small}%
2580   \resetmathfonts \setleading{15pt}}
2581 \let\subsubsecfonts = \subsecfonts
2582 \def\reducedfonts{%
2583   \let\rmfont=\reducedrm \let\itfont=\reducedit \let\slfont=\reducedsl
2584   \let\bffont=\reducedbf \let\ttfont=\reducedtt \let\reducedcaps=\reducedsc
2585   \let\sffont=\reducedsf \let\ifont=\reducedi \let\syfont=\reducedsy
2586   \let\ttfontsl=\reducedttsl
2587   \def\curfontsize{reduced}%
2588   \def\lsize{small}\def\lllsize{smaller}%
2589   \resetmathfonts \setleading{10.5pt}}
2590 \def\smallfonts{%
2591   \let\rmfont=\smallrm \let\itfont=\smallit \let\slfont=\smallsl
2592   \let\bffont=\smallbf \let\ttfont=\smalltt \let\smallcaps=\smallsc
2593   \let\sffont=\smallsf \let\ifont=\smalli \let\syfont=\smallsy
2594   \let\ttfontsl=\smallttsl
2595   \def\curfontsize{small}%
2596   \def\lsize{smaller}\def\lllsize{smaller}%
2597   \resetmathfonts \setleading{10.5pt}}
2598 \def\smallerfonts{%
2599   \let\rmfont=\smallerrm \let\itfont=\smallerit \let\slfont=\smallersl
2600   \let\bffont=\smallerbf \let\ttfont=\smallertt \let\smallcaps=\smallersc
2601   \let\sffont=\smallersf \let\ifont=\smalleri \let\syfont=\smallersy
2602   \let\ttfontsl=\smallerttsl
2603   \def\curfontsize{smaller}%
2604   \def\lsize{smaller}\def\lllsize{smaller}%
2605   \resetmathfonts \setleading{9.5pt}}
2606
2607 % Define these just so they can be easily changed for other fonts.
2608 \def\angleleft{$\langle$}
2609 \def\angleright{$\rangle$}
2610
2611 % Set the fonts to use with the @small... environments.
2612 \let\smallexamplefonts = \smallfonts
2613
2614 % About \smallexamplefonts.  If we use \smallfonts (9pt), @smallexample
2615 % can fit this many characters:
2616 %   8.5x11=86   smallbook=72  a4=90  a5=69
2617 % If we use \scriptfonts (8pt), then we can fit this many characters:
2618 %   8.5x11=90+  smallbook=80  a4=90+  a5=77
2619 % For me, subjectively, the few extra characters that fit aren't worth
2620 % the additional smallness of 8pt.  So I'm making the default 9pt.
2621 %
2622 % By the way, for comparison, here's what fits with @example (10pt):
2623 %   8.5x11=71  smallbook=60  a4=75  a5=58
2624 % --karl, 24jan03.
2625
2626 % Set up the default fonts, so we can use them for creating boxes.
2627 %
2628 \definetextfontsizexi
2629
2630
2631 \message{markup,}
2632
2633 % Check if we are currently using a typewriter font.  Since all the
2634 % Computer Modern typewriter fonts have zero interword stretch (and
2635 % shrink), and it is reasonable to expect all typewriter fonts to have
2636 % this property, we can check that font parameter.
2637 %
2638 \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
2639
2640 % Markup style infrastructure.  \defmarkupstylesetup\INITMACRO will
2641 % define and register \INITMACRO to be called on markup style changes.
2642 % \INITMACRO can check \currentmarkupstyle for the innermost
2643 % style and the set of \ifmarkupSTYLE switches for all styles
2644 % currently in effect.
2645 \newif\ifmarkupvar
2646 \newif\ifmarkupsamp
2647 \newif\ifmarkupkey
2648 %\newif\ifmarkupfile % @file == @samp.
2649 %\newif\ifmarkupoption % @option == @samp.
2650 \newif\ifmarkupcode
2651 \newif\ifmarkupkbd
2652 %\newif\ifmarkupenv % @env == @code.
2653 %\newif\ifmarkupcommand % @command == @code.
2654 \newif\ifmarkuptex % @tex (and part of @math, for now).
2655 \newif\ifmarkupexample
2656 \newif\ifmarkupverb
2657 \newif\ifmarkupverbatim
2658
2659 \let\currentmarkupstyle\empty
2660
2661 \def\setupmarkupstyle#1{%
2662   \csname markup#1true\endcsname
2663   \def\currentmarkupstyle{#1}%
2664   \markupstylesetup
2665 }
2666
2667 \let\markupstylesetup\empty
2668
2669 \def\defmarkupstylesetup#1{%
2670   \expandafter\def\expandafter\markupstylesetup
2671     \expandafter{\markupstylesetup #1}%
2672   \def#1%
2673 }
2674
2675 % Markup style setup for left and right quotes.
2676 \defmarkupstylesetup\markupsetuplq{%
2677   \expandafter\let\expandafter \temp
2678     \csname markupsetuplq\currentmarkupstyle\endcsname
2679   \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
2680 }
2681
2682 \defmarkupstylesetup\markupsetuprq{%
2683   \expandafter\let\expandafter \temp
2684     \csname markupsetuprq\currentmarkupstyle\endcsname
2685   \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
2686 }
2687
2688 {
2689 \catcode`\'=\active
2690 \catcode`\`=\active
2691
2692 \gdef\markupsetuplqdefault{\let`\lq}
2693 \gdef\markupsetuprqdefault{\let'\rq}
2694
2695 \gdef\markupsetcodequoteleft{\let`\codequoteleft}
2696 \gdef\markupsetcodequoteright{\let'\codequoteright}
2697 }
2698
2699 \let\markupsetuplqcode \markupsetcodequoteleft
2700 \let\markupsetuprqcode \markupsetcodequoteright
2701 %
2702 \let\markupsetuplqexample \markupsetcodequoteleft
2703 \let\markupsetuprqexample \markupsetcodequoteright
2704 %
2705 \let\markupsetuplqkbd     \markupsetcodequoteleft
2706 \let\markupsetuprqkbd     \markupsetcodequoteright
2707 %
2708 \let\markupsetuplqsamp \markupsetcodequoteleft
2709 \let\markupsetuprqsamp \markupsetcodequoteright
2710 %
2711 \let\markupsetuplqverb \markupsetcodequoteleft
2712 \let\markupsetuprqverb \markupsetcodequoteright
2713 %
2714 \let\markupsetuplqverbatim \markupsetcodequoteleft
2715 \let\markupsetuprqverbatim \markupsetcodequoteright
2716
2717 % Allow an option to not use regular directed right quote/apostrophe
2718 % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2719 % The undirected quote is ugly, so don't make it the default, but it
2720 % works for pasting with more pdf viewers (at least evince), the
2721 % lilypond developers report.  xpdf does work with the regular 0x27.
2722 %
2723 \def\codequoteright{%
2724   \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
2725     \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
2726       '%
2727     \else \char'15 \fi
2728   \else \char'15 \fi
2729 }
2730 %
2731 % and a similar option for the left quote char vs. a grave accent.
2732 % Modern fonts display ASCII 0x60 as a grave accent, so some people like
2733 % the code environments to do likewise.
2734 %
2735 \def\codequoteleft{%
2736   \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
2737     \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
2738       % [Knuth] pp. 380,381,391
2739       % \relax disables Spanish ligatures ?` and !` of \tt font.
2740       \relax`%
2741     \else \char'22 \fi
2742   \else \char'22 \fi
2743 }
2744
2745 % Commands to set the quote options.
2746
2747 \parseargdef\codequoteundirected{%
2748   \def\temp{#1}%
2749   \ifx\temp\onword
2750     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2751       = t%
2752   \else\ifx\temp\offword
2753     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2754       = \relax
2755   \else
2756     \errhelp = \EMsimple
2757     \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2758   \fi\fi
2759 }
2760 %
2761 \parseargdef\codequotebacktick{%
2762   \def\temp{#1}%
2763   \ifx\temp\onword
2764     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2765       = t%
2766   \else\ifx\temp\offword
2767     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2768       = \relax
2769   \else
2770     \errhelp = \EMsimple
2771     \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2772   \fi\fi
2773 }
2774
2775 % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2776 \def\noligaturesquoteleft{\relax\lq}
2777
2778 % Count depth in font-changes, for error checks
2779 \newcount\fontdepth \fontdepth=0
2780
2781 % Font commands.
2782
2783 % #1 is the font command (\sl or \it), #2 is the text to slant.
2784 % If we are in a monospaced environment, however, 1) always use \ttsl,
2785 % and 2) do not add an italic correction.
2786 \def\dosmartslant#1#2{%
2787   \ifusingtt 
2788     {{\ttsl #2}\let\next=\relax}%
2789     {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
2790   \next
2791 }
2792 \def\smartslanted{\dosmartslant\sl}
2793 \def\smartitalic{\dosmartslant\it}
2794
2795 % Output an italic correction unless \next (presumed to be the following
2796 % character) is such as not to need one.
2797 \def\smartitaliccorrection{%
2798   \ifx\next,%
2799   \else\ifx\next-%
2800   \else\ifx\next.%
2801   \else\ifx\next\.%
2802   \else\ifx\next\comma%
2803   \else\ptexslash
2804   \fi\fi\fi\fi\fi
2805   \aftersmartic
2806 }
2807
2808 % Unconditional use \ttsl, and no ic.  @var is set to this for defuns.
2809 \def\ttslanted#1{{\ttsl #1}}
2810
2811 % @cite is like \smartslanted except unconditionally use \sl.  We never want
2812 % ttsl for book titles, do we?
2813 \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
2814
2815 \def\aftersmartic{}
2816 \def\var#1{%
2817   \let\saveaftersmartic = \aftersmartic
2818   \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
2819   \smartslanted{#1}%
2820 }
2821
2822 \let\i=\smartitalic
2823 \let\slanted=\smartslanted
2824 \let\dfn=\smartslanted
2825 \let\emph=\smartitalic
2826
2827 % Explicit font changes: @r, @sc, undocumented @ii.
2828 \def\r#1{{\rm #1}}              % roman font
2829 \def\sc#1{{\smallcaps#1}}       % smallcaps font
2830 \def\ii#1{{\it #1}}             % italic font
2831
2832 % @b, explicit bold.  Also @strong.
2833 \def\b#1{{\bf #1}}
2834 \let\strong=\b
2835
2836 % @sansserif, explicit sans.
2837 \def\sansserif#1{{\sf #1}}
2838
2839 % We can't just use \exhyphenpenalty, because that only has effect at
2840 % the end of a paragraph.  Restore normal hyphenation at the end of the
2841 % group within which \nohyphenation is presumably called.
2842 %
2843 \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
2844 \def\restorehyphenation{\hyphenchar\font = `- }
2845
2846 % Set sfcode to normal for the chars that usually have another value.
2847 % Can't use plain's \frenchspacing because it uses the `\x notation, and
2848 % sometimes \x has an active definition that messes things up.
2849 %
2850 \catcode`@=11
2851   \def\plainfrenchspacing{%
2852     \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
2853     \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
2854     \def\endofsentencespacefactor{1000}% for @. and friends
2855   }
2856   \def\plainnonfrenchspacing{%
2857     \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2858     \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2859     \def\endofsentencespacefactor{3000}% for @. and friends
2860   }
2861 \catcode`@=\other
2862 \def\endofsentencespacefactor{3000}% default
2863
2864 % @t, explicit typewriter.
2865 \def\t#1{%
2866   {\tt \rawbackslash \plainfrenchspacing #1}%
2867   \null
2868 }
2869
2870 % @samp.
2871 \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
2872
2873 % @indicateurl is \samp, that is, with quotes.
2874 \let\indicateurl=\samp
2875
2876 % @code (and similar) prints in typewriter, but with spaces the same
2877 % size as normal in the surrounding text, without hyphenation, etc.
2878 % This is a subroutine for that.
2879 \def\tclose#1{%
2880   {%
2881     % Change normal interword space to be same as for the current font.
2882     \spaceskip = \fontdimen2\font
2883     %
2884     % Switch to typewriter.
2885     \tt
2886     %
2887     % But `\ ' produces the large typewriter interword space.
2888     \def\ {{\spaceskip = 0pt{} }}%
2889     %
2890     % Turn off hyphenation.
2891     \nohyphenation
2892     %
2893     \rawbackslash
2894     \plainfrenchspacing
2895     #1%
2896   }%
2897   \null % reset spacefactor to 1000
2898 }
2899
2900 % We *must* turn on hyphenation at `-' and `_' in @code.
2901 % (But see \codedashfinish below.)
2902 % Otherwise, it is too hard to avoid overfull hboxes
2903 % in the Emacs manual, the Library manual, etc.
2904 %
2905 % Unfortunately, TeX uses one parameter (\hyphenchar) to control
2906 % both hyphenation at - and hyphenation within words.
2907 % We must therefore turn them both off (\tclose does that)
2908 % and arrange explicitly to hyphenate at a dash. -- rms.
2909 {
2910   \catcode`\-=\active \catcode`\_=\active
2911   \catcode`\'=\active \catcode`\`=\active
2912   \global\let'=\rq \global\let`=\lq  % default definitions
2913   %
2914   \global\def\code{\begingroup
2915     \setupmarkupstyle{code}%
2916     % The following should really be moved into \setupmarkupstyle handlers.
2917     \catcode\dashChar=\active  \catcode\underChar=\active
2918     \ifallowcodebreaks
2919      \let-\codedash
2920      \let_\codeunder
2921     \else
2922      \let-\normaldash
2923      \let_\realunder
2924     \fi
2925     % Given -foo (with a single dash), we do not want to allow a break
2926     % after the hyphen.
2927     \global\let\codedashprev=\codedash
2928     %
2929     \codex
2930   }
2931   %
2932   \gdef\codedash{\futurelet\next\codedashfinish}
2933   \gdef\codedashfinish{%
2934     \normaldash % always output the dash character itself.
2935     % 
2936     % Now, output a discretionary to allow a line break, unless
2937     % (a) the next character is a -, or
2938     % (b) the preceding character is a -.
2939     % E.g., given --posix, we do not want to allow a break after either -.
2940     % Given --foo-bar, we do want to allow a break between the - and the b.
2941     \ifx\next\codedash \else
2942       \ifx\codedashprev\codedash 
2943       \else \discretionary{}{}{}\fi
2944     \fi
2945     % we need the space after the = for the case when \next itself is a
2946     % space token; it would get swallowed otherwise.  As in @code{- a}.
2947     \global\let\codedashprev= \next
2948   }
2949 }
2950 \def\normaldash{-}
2951 %
2952 \def\codex #1{\tclose{#1}\endgroup}
2953
2954 \def\codeunder{%
2955   % this is all so @math{@code{var_name}+1} can work.  In math mode, _
2956   % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2957   % will therefore expand the active definition of _, which is us
2958   % (inside @code that is), therefore an endless loop.
2959   \ifusingtt{\ifmmode
2960                \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2961              \else\normalunderscore \fi
2962              \discretionary{}{}{}}%
2963             {\_}%
2964 }
2965
2966 % An additional complication: the above will allow breaks after, e.g.,
2967 % each of the four underscores in __typeof__.  This is bad.
2968 % @allowcodebreaks provides a document-level way to turn breaking at -
2969 % and _ on and off.
2970 %
2971 \newif\ifallowcodebreaks  \allowcodebreakstrue
2972
2973 \def\keywordtrue{true}
2974 \def\keywordfalse{false}
2975
2976 \parseargdef\allowcodebreaks{%
2977   \def\txiarg{#1}%
2978   \ifx\txiarg\keywordtrue
2979     \allowcodebreakstrue
2980   \else\ifx\txiarg\keywordfalse
2981     \allowcodebreaksfalse
2982   \else
2983     \errhelp = \EMsimple
2984     \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
2985   \fi\fi
2986 }
2987
2988 % For @command, @env, @file, @option quotes seem unnecessary,
2989 % so use \code rather than \samp.
2990 \let\command=\code
2991 \let\env=\code
2992 \let\file=\code
2993 \let\option=\code
2994
2995 % @uref (abbreviation for `urlref') aka @url takes an optional
2996 % (comma-separated) second argument specifying the text to display and
2997 % an optional third arg as text to display instead of (rather than in
2998 % addition to) the url itself.  First (mandatory) arg is the url.
2999
3000 % TeX-only option to allow changing PDF output to show only the second
3001 % arg (if given), and not the url (which is then just the link target).
3002 \newif\ifurefurlonlylink
3003
3004 % The main macro is \urefbreak, which allows breaking at expected
3005 % places within the url.  (There used to be another version, which
3006 % didn't support automatic breaking.)
3007 \def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
3008 \let\uref=\urefbreak
3009 %
3010 \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
3011 \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
3012   \unsepspaces
3013   \pdfurl{#1}%
3014   \setbox0 = \hbox{\ignorespaces #3}%
3015   \ifdim\wd0 > 0pt
3016     \unhbox0 % third arg given, show only that
3017   \else
3018     \setbox0 = \hbox{\ignorespaces #2}% look for second arg
3019     \ifdim\wd0 > 0pt
3020       \ifpdf
3021         % For pdfTeX and LuaTeX
3022         \ifurefurlonlylink
3023           % PDF plus option to not display url, show just arg
3024           \unhbox0             
3025         \else
3026           % PDF, normally display both arg and url for consistency,
3027           % visibility, if the pdf is eventually used to print, etc.
3028           \unhbox0\ (\urefcode{#1})%
3029         \fi
3030       \else
3031         \ifx\XeTeXrevision\thisisundefined
3032           \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
3033         \else
3034           % For XeTeX
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         \fi
3044       \fi
3045     \else
3046       \urefcode{#1}% only url given, so show it
3047     \fi
3048   \fi
3049   \endlink
3050 \endgroup}
3051
3052 % Allow line breaks around only a few characters (only).
3053 \def\urefcatcodes{%
3054   \catcode`\&=\active \catcode`\.=\active
3055   \catcode`\#=\active \catcode`\?=\active
3056   \catcode`\/=\active
3057 }
3058 {
3059   \urefcatcodes
3060   %
3061   \global\def\urefcode{\begingroup
3062     \setupmarkupstyle{code}%
3063     \urefcatcodes
3064     \let&\urefcodeamp
3065     \let.\urefcodedot
3066     \let#\urefcodehash
3067     \let?\urefcodequest
3068     \let/\urefcodeslash
3069     \codex
3070   }
3071   %
3072   % By default, they are just regular characters.
3073   \global\def&{\normalamp}
3074   \global\def.{\normaldot}
3075   \global\def#{\normalhash}
3076   \global\def?{\normalquest}
3077   \global\def/{\normalslash}
3078 }
3079
3080 % we put a little stretch before and after the breakable chars, to help
3081 % line breaking of long url's.  The unequal skips make look better in
3082 % cmtt at least, especially for dots.
3083 \def\urefprestretchamount{.13em}
3084 \def\urefpoststretchamount{.1em}
3085 \def\urefprestretch{\urefprebreak \hskip0pt plus\urefprestretchamount\relax}
3086 \def\urefpoststretch{\urefpostbreak \hskip0pt plus\urefprestretchamount\relax}
3087 %
3088 \def\urefcodeamp{\urefprestretch \&\urefpoststretch}
3089 \def\urefcodedot{\urefprestretch .\urefpoststretch}
3090 \def\urefcodehash{\urefprestretch \#\urefpoststretch}
3091 \def\urefcodequest{\urefprestretch ?\urefpoststretch}
3092 \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
3093 {
3094   \catcode`\/=\active
3095   \global\def\urefcodeslashfinish{%
3096     \urefprestretch \slashChar
3097     % Allow line break only after the final / in a sequence of
3098     % slashes, to avoid line break between the slashes in http://.
3099     \ifx\next/\else \urefpoststretch \fi
3100   }
3101 }
3102
3103 % One more complication: by default we'll break after the special
3104 % characters, but some people like to break before the special chars, so
3105 % allow that.  Also allow no breaking at all, for manual control.
3106
3107 \parseargdef\urefbreakstyle{%
3108   \def\txiarg{#1}%
3109   \ifx\txiarg\wordnone
3110     \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
3111   \else\ifx\txiarg\wordbefore
3112     \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
3113   \else\ifx\txiarg\wordafter
3114     \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
3115   \else
3116     \errhelp = \EMsimple
3117     \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
3118   \fi\fi\fi
3119 }
3120 \def\wordafter{after}
3121 \def\wordbefore{before}
3122 \def\wordnone{none}
3123
3124 \urefbreakstyle after
3125
3126 % @url synonym for @uref, since that's how everyone uses it.
3127 %
3128 \let\url=\uref
3129
3130 % rms does not like angle brackets --karl, 17may97.
3131 % So now @email is just like @uref, unless we are pdf.
3132 %
3133 %\def\email#1{\angleleft{\tt #1}\angleright}
3134 \ifpdf
3135   \def\email#1{\doemail#1,,\finish}
3136   \def\doemail#1,#2,#3\finish{\begingroup
3137     \unsepspaces
3138     \pdfurl{mailto:#1}%
3139     \setbox0 = \hbox{\ignorespaces #2}%
3140     \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3141     \endlink
3142   \endgroup}
3143 \else
3144   \ifx\XeTeXrevision\thisisundefined
3145     \let\email=\uref
3146   \else
3147     \def\email#1{\doemail#1,,\finish}
3148     \def\doemail#1,#2,#3\finish{\begingroup
3149       \unsepspaces
3150       \pdfurl{mailto:#1}%
3151       \setbox0 = \hbox{\ignorespaces #2}%
3152       \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3153       \endlink
3154     \endgroup}
3155   \fi
3156 \fi
3157
3158 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
3159 %   `example' (@kbd uses ttsl only inside of @example and friends),
3160 %   or `code' (@kbd uses normal tty font always).
3161 \parseargdef\kbdinputstyle{%
3162   \def\txiarg{#1}%
3163   \ifx\txiarg\worddistinct
3164     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
3165   \else\ifx\txiarg\wordexample
3166     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
3167   \else\ifx\txiarg\wordcode
3168     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
3169   \else
3170     \errhelp = \EMsimple
3171     \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
3172   \fi\fi\fi
3173 }
3174 \def\worddistinct{distinct}
3175 \def\wordexample{example}
3176 \def\wordcode{code}
3177
3178 % Default is `distinct'.
3179 \kbdinputstyle distinct
3180
3181 % @kbd is like @code, except that if the argument is just one @key command,
3182 % then @kbd has no effect.
3183 \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
3184
3185 \def\xkey{\key}
3186 \def\kbdsub#1#2#3\par{%
3187   \def\one{#1}\def\three{#3}\def\threex{??}%
3188   \ifx\one\xkey\ifx\threex\three \key{#2}%
3189   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3190   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3191 }
3192
3193 % definition of @key that produces a lozenge.  Doesn't adjust to text size.
3194 %\setfont\keyrm\rmshape{8}{1000}{OT1}
3195 %\font\keysy=cmsy9
3196 %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
3197 %  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
3198 %    \vbox{\hrule\kern-0.4pt
3199 %     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
3200 %    \kern-0.4pt\hrule}%
3201 %  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
3202
3203 % definition of @key with no lozenge.  If the current font is already
3204 % monospace, don't change it; that way, we respect @kbdinputstyle.  But
3205 % if it isn't monospace, then use \tt.
3206 %
3207 \def\key#1{{\setupmarkupstyle{key}%
3208   \nohyphenation
3209   \ifmonospace\else\tt\fi
3210   #1}\null}
3211
3212 % @clicksequence{File @click{} Open ...}
3213 \def\clicksequence#1{\begingroup #1\endgroup}
3214
3215 % @clickstyle @arrow   (by default)
3216 \parseargdef\clickstyle{\def\click{#1}}
3217 \def\click{\arrow}
3218
3219 % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
3220 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
3221 %
3222 \def\dmn#1{\thinspace #1}
3223
3224 % @acronym for "FBI", "NATO", and the like.
3225 % We print this one point size smaller, since it's intended for
3226 % all-uppercase.
3227 %
3228 \def\acronym#1{\doacronym #1,,\finish}
3229 \def\doacronym#1,#2,#3\finish{%
3230   {\selectfonts\lsize #1}%
3231   \def\temp{#2}%
3232   \ifx\temp\empty \else
3233     \space ({\unsepspaces \ignorespaces \temp \unskip})%
3234   \fi
3235   \null % reset \spacefactor=1000
3236 }
3237
3238 % @abbr for "Comput. J." and the like.
3239 % No font change, but don't do end-of-sentence spacing.
3240 %
3241 \def\abbr#1{\doabbr #1,,\finish}
3242 \def\doabbr#1,#2,#3\finish{%
3243   {\plainfrenchspacing #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 % @asis just yields its argument.  Used with @table, for example.
3252 %
3253 \def\asis#1{#1}
3254
3255 % @math outputs its argument in math mode.
3256 %
3257 % One complication: _ usually means subscripts, but it could also mean
3258 % an actual _ character, as in @math{@var{some_variable} + 1}.  So make
3259 % _ active, and distinguish by seeing if the current family is \slfam,
3260 % which is what @var uses.
3261 {
3262   \catcode`\_ = \active
3263   \gdef\mathunderscore{%
3264     \catcode`\_=\active
3265     \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
3266   }
3267 }
3268 % Another complication: we want \\ (and @\) to output a math (or tt) \.
3269 % FYI, plain.tex uses \\ as a temporary control sequence (for no
3270 % particular reason), but this is not advertised and we don't care.
3271 %
3272 % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
3273 \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
3274 %
3275 \def\math{%
3276   \ifmmode\else % only go into math if not in math mode already
3277     \tex
3278     \mathunderscore
3279     \let\\ = \mathbackslash
3280     \mathactive
3281     % make the texinfo accent commands work in math mode
3282     \let\"=\ddot
3283     \let\'=\acute
3284     \let\==\bar
3285     \let\^=\hat
3286     \let\`=\grave
3287     \let\u=\breve
3288     \let\v=\check
3289     \let\~=\tilde
3290     \let\dotaccent=\dot
3291     % have to provide another name for sup operator
3292     \let\mathopsup=\sup
3293   $\expandafter\finishmath\fi
3294 }
3295 \def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
3296
3297 % Some active characters (such as <) are spaced differently in math.
3298 % We have to reset their definitions in case the @math was an argument
3299 % to a command which sets the catcodes (such as @item or @section).
3300 %
3301 {
3302   \catcode`^ = \active
3303   \catcode`< = \active
3304   \catcode`> = \active
3305   \catcode`+ = \active
3306   \catcode`' = \active
3307   \gdef\mathactive{%
3308     \let^ = \ptexhat
3309     \let< = \ptexless
3310     \let> = \ptexgtr
3311     \let+ = \ptexplus
3312     \let' = \ptexquoteright
3313   }
3314 }
3315
3316 % for @sub and @sup, if in math mode, just do a normal sub/superscript.
3317 % If in text, use math to place as sub/superscript, but switch
3318 % into text mode, with smaller fonts.  This is a different font than the
3319 % one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3320 % fix it (significant additions to font machinery) until someone notices.
3321 %
3322 \def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
3323 \def\finishsub#1{$\sb{\hbox{\selectfonts\lllsize #1}}$}%
3324 %
3325 \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
3326 \def\finishsup#1{$\ptexsp{\hbox{\selectfonts\lllsize #1}}$}%
3327
3328 % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3329 % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3330 % except specified as a normal braced arg, so no newlines to worry about.
3331
3332 \def\outfmtnametex{tex}
3333 %
3334 \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3335 \long\def\doinlinefmt#1,#2,\finish{%
3336   \def\inlinefmtname{#1}%
3337   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3338 }
3339
3340 % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3341 % FMTNAME is tex, else ELSE-TEXT.
3342 \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3343 \long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3344   \def\inlinefmtname{#1}%
3345   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3346 }
3347 %
3348 % For raw, must switch into @tex before parsing the argument, to avoid
3349 % setting catcodes prematurely.  Doing it this way means that, for
3350 % example, @inlineraw{html, foo{bar} gets a parse error instead of being
3351 % ignored.  But this isn't important because if people want a literal
3352 % *right* brace they would have to use a command anyway, so they may as
3353 % well use a command to get a left brace too.  We could re-use the
3354 % delimiter character idea from \verb, but it seems like overkill.
3355
3356 \long\def\inlineraw{\tex \doinlineraw}
3357 \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3358 \def\doinlinerawtwo#1,#2,\finish{%
3359   \def\inlinerawname{#1}%
3360   \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3361   \endgroup % close group opened by \tex.
3362 }
3363
3364 % @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3365 %
3366 \long\def\inlineifset#1{\doinlineifset #1,\finish}
3367 \long\def\doinlineifset#1,#2,\finish{%
3368   \def\inlinevarname{#1}%
3369   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3370   \else\ignorespaces#2\fi
3371 }
3372
3373 % @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3374 %
3375 \long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3376 \long\def\doinlineifclear#1,#2,\finish{%
3377   \def\inlinevarname{#1}%
3378   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3379 }
3380
3381
3382 \message{glyphs,}
3383 % and logos.
3384
3385 % @@ prints an @, as does @atchar{}.
3386 \def\@{\char64 }
3387 \let\atchar=\@
3388
3389 % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
3390 \def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}}
3391 \def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}}
3392 \let\{=\lbracechar
3393 \let\}=\rbracechar
3394
3395 % @comma{} to avoid , parsing problems.
3396 \let\comma = ,
3397
3398 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3399 % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3400 \let\, = \ptexc
3401 \let\dotaccent = \ptexdot
3402 \def\ringaccent#1{{\accent23 #1}}
3403 \let\tieaccent = \ptext
3404 \let\ubaraccent = \ptexb
3405 \let\udotaccent = \d
3406
3407 % Other special characters: @questiondown @exclamdown @ordf @ordm
3408 % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3409 \def\questiondown{?`}
3410 \def\exclamdown{!`}
3411 \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
3412 \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
3413
3414 % Dotless i and dotless j, used for accents.
3415 \def\imacro{i}
3416 \def\jmacro{j}
3417 \def\dotless#1{%
3418   \def\temp{#1}%
3419   \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3420   \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3421   \else \errmessage{@dotless can be used only with i or j}%
3422   \fi\fi
3423 }
3424
3425 % The \TeX{} logo, as in plain, but resetting the spacing so that a
3426 % period following counts as ending a sentence.  (Idea found in latex.)
3427 %
3428 \edef\TeX{\TeX \spacefactor=1000 }
3429
3430 % @LaTeX{} logo.  Not quite the same results as the definition in
3431 % latex.ltx, since we use a different font for the raised A; it's most
3432 % convenient for us to use an explicitly smaller font, rather than using
3433 % the \scriptstyle font (since we don't reset \scriptstyle and
3434 % \scriptscriptstyle).
3435 %
3436 \def\LaTeX{%
3437   L\kern-.36em
3438   {\setbox0=\hbox{T}%
3439    \vbox to \ht0{\hbox{%
3440      \ifx\textnominalsize\xwordpt
3441        % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX.
3442        % Revert to plain's \scriptsize, which is 7pt.
3443        \count255=\the\fam $\fam\count255 \scriptstyle A$%
3444      \else
3445        % For 11pt, we can use our lllsize.
3446        \selectfonts\lllsize A%
3447      \fi
3448      }%
3449      \vss
3450   }}%
3451   \kern-.15em
3452   \TeX
3453 }
3454
3455 % Some math mode symbols.  Define \ensuremath to switch into math mode
3456 % unless we are already there.  Expansion tricks may not be needed here,
3457 % but safer, and can't hurt.
3458 \def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3459 \def\ensuredmath#1{$\relax#1$}
3460 %
3461 \def\bullet{\ensuremath\ptexbullet}
3462 \def\geq{\ensuremath\ge}
3463 \def\leq{\ensuremath\le}
3464 \def\minus{\ensuremath-}
3465
3466 % @dots{} outputs an ellipsis using the current font.
3467 % We do .5em per period so that it has the same spacing in the cm
3468 % typewriter fonts as three actual period characters; on the other hand,
3469 % in other typewriter fonts three periods are wider than 1.5em.  So do
3470 % whichever is larger.
3471 %
3472 \def\dots{%
3473   \leavevmode
3474   \setbox0=\hbox{...}% get width of three periods
3475   \ifdim\wd0 > 1.5em
3476     \dimen0 = \wd0
3477   \else
3478     \dimen0 = 1.5em
3479   \fi
3480   \hbox to \dimen0{%
3481     \hskip 0pt plus.25fil
3482     .\hskip 0pt plus1fil
3483     .\hskip 0pt plus1fil
3484     .\hskip 0pt plus.5fil
3485   }%
3486 }
3487
3488 % @enddots{} is an end-of-sentence ellipsis.
3489 %
3490 \def\enddots{%
3491   \dots
3492   \spacefactor=\endofsentencespacefactor
3493 }
3494
3495 % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3496 %
3497 % Since these characters are used in examples, they should be an even number of
3498 % \tt widths. Each \tt character is 1en, so two makes it 1em.
3499 %
3500 \def\point{$\star$}
3501 \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3502 \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3503 \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3504 \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3505 \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3506
3507 % The @error{} command.
3508 % Adapted from the TeXbook's \boxit.
3509 %
3510 \newbox\errorbox
3511 %
3512 {\ttfont \global\dimen0 = 3em}% Width of the box.
3513 \dimen2 = .55pt % Thickness of rules
3514 % The text. (`r' is open on the right, `e' somewhat less so on the left.)
3515 \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3516 %
3517 \setbox\errorbox=\hbox to \dimen0{\hfil
3518    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3519    \advance\hsize by -2\dimen2 % Rules.
3520    \vbox{%
3521       \hrule height\dimen2
3522       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
3523          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3524          \kern3pt\vrule width\dimen2}% Space to right.
3525       \hrule height\dimen2}
3526     \hfil}
3527 %
3528 \def\error{\leavevmode\lower.7ex\copy\errorbox}
3529
3530 % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3531 %
3532 \def\pounds{{\it\$}}
3533
3534 % @euro{} comes from a separate font, depending on the current style.
3535 % We use the free feym* fonts from the eurosym package by Henrik
3536 % Theiling, which support regular, slanted, bold and bold slanted (and
3537 % "outlined" (blackboard board, sort of) versions, which we don't need).
3538 % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3539 %
3540 % Although only regular is the truly official Euro symbol, we ignore
3541 % that.  The Euro is designed to be slightly taller than the regular
3542 % font height.
3543 %
3544 % feymr - regular
3545 % feymo - slanted
3546 % feybr - bold
3547 % feybo - bold slanted
3548 %
3549 % There is no good (free) typewriter version, to my knowledge.
3550 % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3551 % Hmm.
3552 %
3553 % Also doesn't work in math.  Do we need to do math with euro symbols?
3554 % Hope not.
3555 %
3556 %
3557 \def\euro{{\eurofont e}}
3558 \def\eurofont{%
3559   % We set the font at each command, rather than predefining it in
3560   % \textfonts and the other font-switching commands, so that
3561   % installations which never need the symbol don't have to have the
3562   % font installed.
3563   %
3564   % There is only one designed size (nominal 10pt), so we always scale
3565   % that to the current nominal size.
3566   %
3567   % By the way, simply using "at 1em" works for cmr10 and the like, but
3568   % does not work for cmbx10 and other extended/shrunken fonts.
3569   %
3570   \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3571   %
3572   \ifx\curfontstyle\bfstylename
3573     % bold:
3574     \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3575   \else
3576     % regular:
3577     \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3578   \fi
3579   \thiseurofont
3580 }
3581
3582 % Glyphs from the EC fonts.  We don't use \let for the aliases, because
3583 % sometimes we redefine the original macro, and the alias should reflect
3584 % the redefinition.
3585 %
3586 % Use LaTeX names for the Icelandic letters.
3587 \def\DH{{\ecfont \char"D0}} % Eth
3588 \def\dh{{\ecfont \char"F0}} % eth
3589 \def\TH{{\ecfont \char"DE}} % Thorn
3590 \def\th{{\ecfont \char"FE}} % thorn
3591 %
3592 \def\guillemetleft{{\ecfont \char"13}}
3593 \def\guillemotleft{\guillemetleft}
3594 \def\guillemetright{{\ecfont \char"14}}
3595 \def\guillemotright{\guillemetright}
3596 \def\guilsinglleft{{\ecfont \char"0E}}
3597 \def\guilsinglright{{\ecfont \char"0F}}
3598 \def\quotedblbase{{\ecfont \char"12}}
3599 \def\quotesinglbase{{\ecfont \char"0D}}
3600 %
3601 % This positioning is not perfect (see the ogonek LaTeX package), but
3602 % we have the precomposed glyphs for the most common cases.  We put the
3603 % tests to use those glyphs in the single \ogonek macro so we have fewer
3604 % dummy definitions to worry about for index entries, etc.
3605 %
3606 % ogonek is also used with other letters in Lithuanian (IOU), but using
3607 % the precomposed glyphs for those is not so easy since they aren't in
3608 % the same EC font.
3609 \def\ogonek#1{{%
3610   \def\temp{#1}%
3611   \ifx\temp\macrocharA\Aogonek
3612   \else\ifx\temp\macrochara\aogonek
3613   \else\ifx\temp\macrocharE\Eogonek
3614   \else\ifx\temp\macrochare\eogonek
3615   \else
3616     \ecfont \setbox0=\hbox{#1}%
3617     \ifdim\ht0=1ex\accent"0C #1%
3618     \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3619     \fi
3620   \fi\fi\fi\fi
3621   }%
3622 }
3623 \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3624 \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3625 \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3626 \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3627 %
3628 % Use the European Computer Modern fonts (cm-super in outline format)
3629 % for non-CM glyphs.  That is ec* for regular text and tc* for the text
3630 % companion symbols (LaTeX TS1 encoding).  Both are part of the ec
3631 % package and follow the same conventions.
3632
3633 \def\ecfont{\etcfont{e}}
3634 \def\tcfont{\etcfont{t}}
3635 %
3636 \def\etcfont#1{%
3637   % We can't distinguish serif/sans and italic/slanted, but this
3638   % is used for crude hacks anyway (like adding French and German
3639   % quotes to documents typeset with CM, where we lose kerning), so
3640   % hopefully nobody will notice/care.
3641   \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3642   \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
3643   \ifmonospace
3644     % typewriter:
3645     \font\thisecfont = #1ctt\ecsize \space at \nominalsize
3646   \else
3647     \ifx\curfontstyle\bfstylename
3648       % bold:
3649       \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
3650     \else
3651       % regular:
3652       \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
3653     \fi
3654   \fi
3655   \thisecfont
3656 }
3657
3658 % @registeredsymbol - R in a circle.  The font for the R should really
3659 % be smaller yet, but lllsize is the best we can do for now.
3660 % Adapted from the plain.tex definition of \copyright.
3661 %
3662 \def\registeredsymbol{%
3663   $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
3664                \hfil\crcr\Orb}}%
3665     }$%
3666 }
3667
3668 % @textdegree - the normal degrees sign.
3669 %
3670 \def\textdegree{$^\circ$}
3671
3672 % Laurent Siebenmann reports \Orb undefined with:
3673 %  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
3674 % so we'll define it if necessary.
3675 %
3676 \ifx\Orb\thisisundefined
3677 \def\Orb{\mathhexbox20D}
3678 \fi
3679
3680 % Quotes.
3681 \chardef\quotedblleft="5C
3682 \chardef\quotedblright=`\"
3683 \chardef\quoteleft=`\`
3684 \chardef\quoteright=`\'
3685
3686
3687 \message{page headings,}
3688
3689 \newskip\titlepagetopglue \titlepagetopglue = 1.5in
3690 \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3691
3692 % First the title page.  Must do @settitle before @titlepage.
3693 \newif\ifseenauthor
3694 \newif\iffinishedtitlepage
3695
3696 % @setcontentsaftertitlepage used to do an implicit @contents or
3697 % @shortcontents after @end titlepage, but it is now obsolete.
3698 \def\setcontentsaftertitlepage{%
3699   \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
3700               command; move your @contents command if you want the contents
3701               after the title page.}}%
3702 \def\setshortcontentsaftertitlepage{%
3703   \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
3704               command; move your @shortcontents and @contents commands if you 
3705               want the contents after the title page.}}%
3706
3707 \parseargdef\shorttitlepage{%
3708   \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3709   \endgroup\page\hbox{}\page}
3710
3711 \envdef\titlepage{%
3712   % Open one extra group, as we want to close it in the middle of \Etitlepage.
3713   \begingroup
3714     \parindent=0pt \textfonts
3715     % Leave some space at the very top of the page.
3716     \vglue\titlepagetopglue
3717     % No rule at page bottom unless we print one at the top with @title.
3718     \finishedtitlepagetrue
3719     %
3720     % Most title ``pages'' are actually two pages long, with space
3721     % at the top of the second.  We don't want the ragged left on the second.
3722     \let\oldpage = \page
3723     \def\page{%
3724       \iffinishedtitlepage\else
3725          \finishtitlepage
3726       \fi
3727       \let\page = \oldpage
3728       \page
3729       \null
3730     }%
3731 }
3732
3733 \def\Etitlepage{%
3734     \iffinishedtitlepage\else
3735         \finishtitlepage
3736     \fi
3737     % It is important to do the page break before ending the group,
3738     % because the headline and footline are only empty inside the group.
3739     % If we use the new definition of \page, we always get a blank page
3740     % after the title page, which we certainly don't want.
3741     \oldpage
3742   \endgroup
3743   %
3744   % Need this before the \...aftertitlepage checks so that if they are
3745   % in effect the toc pages will come out with page numbers.
3746   \HEADINGSon
3747 }
3748
3749 \def\finishtitlepage{%
3750   \vskip4pt \hrule height 2pt width \hsize
3751   \vskip\titlepagebottomglue
3752   \finishedtitlepagetrue
3753 }
3754
3755 % Settings used for typesetting titles: no hyphenation, no indentation,
3756 % don't worry much about spacing, ragged right.  This should be used
3757 % inside a \vbox, and fonts need to be set appropriately first.  Because
3758 % it is always used for titles, nothing else, we call \rmisbold.  \par
3759 % should be specified before the end of the \vbox, since a vbox is a group.
3760
3761 \def\raggedtitlesettings{%
3762   \rmisbold
3763   \hyphenpenalty=10000
3764   \parindent=0pt
3765   \tolerance=5000
3766   \ptexraggedright
3767 }
3768
3769 % Macros to be used within @titlepage:
3770
3771 \let\subtitlerm=\rmfont
3772 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3773
3774 \parseargdef\title{%
3775   \checkenv\titlepage
3776   \vbox{\titlefonts \raggedtitlesettings #1\par}%
3777   % print a rule at the page bottom also.
3778   \finishedtitlepagefalse
3779   \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3780 }
3781
3782 \parseargdef\subtitle{%
3783   \checkenv\titlepage
3784   {\subtitlefont \rightline{#1}}%
3785 }
3786
3787 % @author should come last, but may come many times.
3788 % It can also be used inside @quotation.
3789 %
3790 \parseargdef\author{%
3791   \def\temp{\quotation}%
3792   \ifx\thisenv\temp
3793     \def\quotationauthor{#1}% printed in \Equotation.
3794   \else
3795     \checkenv\titlepage
3796     \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3797     {\secfonts\rmisbold \leftline{#1}}%
3798   \fi
3799 }
3800
3801
3802 % Set up page headings and footings.
3803
3804 \let\thispage=\folio
3805
3806 \newtoks\evenheadline    % headline on even pages
3807 \newtoks\oddheadline     % headline on odd pages
3808 \newtoks\evenfootline    % footline on even pages
3809 \newtoks\oddfootline     % footline on odd pages
3810
3811 % Now make \makeheadline and \makefootline in Plain TeX use those variables
3812 \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
3813                             \else \the\evenheadline \fi}}
3814 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
3815                             \else \the\evenfootline \fi}\HEADINGShook}
3816 \let\HEADINGShook=\relax
3817
3818 % Commands to set those variables.
3819 % For example, this is what  @headings on  does
3820 % @evenheading @thistitle|@thispage|@thischapter
3821 % @oddheading @thischapter|@thispage|@thistitle
3822 % @evenfooting @thisfile||
3823 % @oddfooting ||@thisfile
3824
3825
3826 \def\evenheading{\parsearg\evenheadingxxx}
3827 \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3828 \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
3829 \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3830
3831 \def\oddheading{\parsearg\oddheadingxxx}
3832 \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3833 \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
3834 \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3835
3836 \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3837
3838 \def\evenfooting{\parsearg\evenfootingxxx}
3839 \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3840 \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3841 \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3842
3843 \def\oddfooting{\parsearg\oddfootingxxx}
3844 \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3845 \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3846   \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3847   %
3848   % Leave some space for the footline.  Hopefully ok to assume
3849   % @evenfooting will not be used by itself.
3850   \global\advance\txipageheight by -12pt
3851   \global\advance\vsize by -12pt
3852 }
3853
3854 \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3855
3856 % @evenheadingmarks top     \thischapter <- chapter at the top of a page
3857 % @evenheadingmarks bottom  \thischapter <- chapter at the bottom of a page
3858 %
3859 % The same set of arguments for:
3860 %
3861 % @oddheadingmarks
3862 % @evenfootingmarks
3863 % @oddfootingmarks
3864 % @everyheadingmarks
3865 % @everyfootingmarks
3866
3867 % These define \getoddheadingmarks, \getevenheadingmarks,
3868 % \getoddfootingmarks, and \getevenfootingmarks, each to one of
3869 % \gettopheadingmarks, \getbottomheadingmarks.
3870 %
3871 \def\evenheadingmarks{\headingmarks{even}{heading}}
3872 \def\oddheadingmarks{\headingmarks{odd}{heading}}
3873 \def\evenfootingmarks{\headingmarks{even}{footing}}
3874 \def\oddfootingmarks{\headingmarks{odd}{footing}}
3875 \parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
3876                           \headingmarks{odd}{heading}{#1} }
3877 \parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
3878                           \headingmarks{odd}{footing}{#1} }
3879 % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3880 \def\headingmarks#1#2#3 {%
3881   \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3882   \global\expandafter\let\csname get#1#2marks\endcsname \temp
3883 }
3884
3885 \everyheadingmarks bottom
3886 \everyfootingmarks bottom
3887
3888 % @headings double      turns headings on for double-sided printing.
3889 % @headings single      turns headings on for single-sided printing.
3890 % @headings off         turns them off.
3891 % @headings on          same as @headings double, retained for compatibility.
3892 % @headings after       turns on double-sided headings after this page.
3893 % @headings doubleafter turns on double-sided headings after this page.
3894 % @headings singleafter turns on single-sided headings after this page.
3895 % By default, they are off at the start of a document,
3896 % and turned `on' after @end titlepage.
3897
3898 \parseargdef\headings{\csname HEADINGS#1\endcsname}
3899
3900 \def\headingsoff{% non-global headings elimination
3901   \evenheadline={\hfil}\evenfootline={\hfil}%
3902    \oddheadline={\hfil}\oddfootline={\hfil}%
3903 }
3904
3905 \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3906 \HEADINGSoff  % it's the default
3907
3908 % When we turn headings on, set the page number to 1.
3909 % For double-sided printing, put current file name in lower left corner,
3910 % chapter name on inside top of right hand pages, document
3911 % title on inside top of left hand pages, and page numbers on outside top
3912 % edge of all pages.
3913 \def\HEADINGSdouble{%
3914 \global\pageno=1
3915 \global\evenfootline={\hfil}
3916 \global\oddfootline={\hfil}
3917 \global\evenheadline={\line{\folio\hfil\thistitle}}
3918 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3919 \global\let\contentsalignmacro = \chapoddpage
3920 }
3921 \let\contentsalignmacro = \chappager
3922
3923 % For single-sided printing, chapter title goes across top left of page,
3924 % page number on top right.
3925 \def\HEADINGSsingle{%
3926 \global\pageno=1
3927 \global\evenfootline={\hfil}
3928 \global\oddfootline={\hfil}
3929 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
3930 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3931 \global\let\contentsalignmacro = \chappager
3932 }
3933 \def\HEADINGSon{\HEADINGSdouble}
3934
3935 \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
3936 \let\HEADINGSdoubleafter=\HEADINGSafter
3937 \def\HEADINGSdoublex{%
3938 \global\evenfootline={\hfil}
3939 \global\oddfootline={\hfil}
3940 \global\evenheadline={\line{\folio\hfil\thistitle}}
3941 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3942 \global\let\contentsalignmacro = \chapoddpage
3943 }
3944
3945 \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
3946 \def\HEADINGSsinglex{%
3947 \global\evenfootline={\hfil}
3948 \global\oddfootline={\hfil}
3949 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
3950 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3951 \global\let\contentsalignmacro = \chappager
3952 }
3953
3954 % Subroutines used in generating headings
3955 % This produces Day Month Year style of output.
3956 % Only define if not already defined, in case a txi-??.tex file has set
3957 % up a different format (e.g., txi-cs.tex does this).
3958 \ifx\today\thisisundefined
3959 \def\today{%
3960   \number\day\space
3961   \ifcase\month
3962   \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
3963   \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
3964   \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
3965   \fi
3966   \space\number\year}
3967 \fi
3968
3969 % @settitle line...  specifies the title of the document, for headings.
3970 % It generates no output of its own.
3971 \def\thistitle{\putwordNoTitle}
3972 \def\settitle{\parsearg{\gdef\thistitle}}
3973
3974
3975 \message{tables,}
3976 % Tables -- @table, @ftable, @vtable, @item(x).
3977
3978 % default indentation of table text
3979 \newdimen\tableindent \tableindent=.8in
3980 % default indentation of @itemize and @enumerate text
3981 \newdimen\itemindent  \itemindent=.3in
3982 % margin between end of table item and start of table text.
3983 \newdimen\itemmargin  \itemmargin=.1in
3984
3985 % used internally for \itemindent minus \itemmargin
3986 \newdimen\itemmax
3987
3988 % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
3989 % these defs.
3990 % They also define \itemindex
3991 % to index the item name in whatever manner is desired (perhaps none).
3992
3993 \newif\ifitemxneedsnegativevskip
3994
3995 \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
3996
3997 \def\internalBitem{\smallbreak \parsearg\itemzzz}
3998 \def\internalBitemx{\itemxpar \parsearg\itemzzz}
3999
4000 \def\itemzzz #1{\begingroup %
4001   \advance\hsize by -\rightskip
4002   \advance\hsize by -\tableindent
4003   \setbox0=\hbox{\itemindicate{#1}}%
4004   \itemindex{#1}%
4005   \nobreak % This prevents a break before @itemx.
4006   %
4007   % If the item text does not fit in the space we have, put it on a line
4008   % by itself, and do not allow a page break either before or after that
4009   % line.  We do not start a paragraph here because then if the next
4010   % command is, e.g., @kindex, the whatsit would get put into the
4011   % horizontal list on a line by itself, resulting in extra blank space.
4012   \ifdim \wd0>\itemmax
4013     %
4014     % Make this a paragraph so we get the \parskip glue and wrapping,
4015     % but leave it ragged-right.
4016     \begingroup
4017       \advance\leftskip by-\tableindent
4018       \advance\hsize by\tableindent
4019       \advance\rightskip by0pt plus1fil\relax
4020       \leavevmode\unhbox0\par
4021     \endgroup
4022     %
4023     % We're going to be starting a paragraph, but we don't want the
4024     % \parskip glue -- logically it's part of the @item we just started.
4025     \nobreak \vskip-\parskip
4026     %
4027     % Stop a page break at the \parskip glue coming up.  However, if
4028     % what follows is an environment such as @example, there will be no
4029     % \parskip glue; then the negative vskip we just inserted would
4030     % cause the example and the item to crash together.  So we use this
4031     % bizarre value of 10001 as a signal to \aboveenvbreak to insert
4032     % \parskip glue after all.  Section titles are handled this way also.
4033     %
4034     \penalty 10001
4035     \endgroup
4036     \itemxneedsnegativevskipfalse
4037   \else
4038     % The item text fits into the space.  Start a paragraph, so that the
4039     % following text (if any) will end up on the same line.
4040     \noindent
4041     % Do this with kerns and \unhbox so that if there is a footnote in
4042     % the item text, it can migrate to the main vertical list and
4043     % eventually be printed.
4044     \nobreak\kern-\tableindent
4045     \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
4046     \unhbox0
4047     \nobreak\kern\dimen0
4048     \endgroup
4049     \itemxneedsnegativevskiptrue
4050   \fi
4051 }
4052
4053 \def\item{\errmessage{@item while not in a list environment}}
4054 \def\itemx{\errmessage{@itemx while not in a list environment}}
4055
4056 % @table, @ftable, @vtable.
4057 \envdef\table{%
4058   \let\itemindex\gobble
4059   \tablecheck{table}%
4060 }
4061 \envdef\ftable{%
4062   \def\itemindex ##1{\doind {fn}{\code{##1}}}%
4063   \tablecheck{ftable}%
4064 }
4065 \envdef\vtable{%
4066   \def\itemindex ##1{\doind {vr}{\code{##1}}}%
4067   \tablecheck{vtable}%
4068 }
4069 \def\tablecheck#1{%
4070   \ifnum \the\catcode`\^^M=\active
4071     \endgroup
4072     \errmessage{This command won't work in this context; perhaps the problem is
4073       that we are \inenvironment\thisenv}%
4074     \def\next{\doignore{#1}}%
4075   \else
4076     \let\next\tablex
4077   \fi
4078   \next
4079 }
4080 \def\tablex#1{%
4081   \def\itemindicate{#1}%
4082   \parsearg\tabley
4083 }
4084 \def\tabley#1{%
4085   {%
4086     \makevalueexpandable
4087     \edef\temp{\noexpand\tablez #1\space\space\space}%
4088     \expandafter
4089   }\temp \endtablez
4090 }
4091 \def\tablez #1 #2 #3 #4\endtablez{%
4092   \aboveenvbreak
4093   \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
4094   \ifnum 0#2>0 \tableindent=#2\mil \fi
4095   \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
4096   \itemmax=\tableindent
4097   \advance \itemmax by -\itemmargin
4098   \advance \leftskip by \tableindent
4099   \exdentamount=\tableindent
4100   \parindent = 0pt
4101   \parskip = \smallskipamount
4102   \ifdim \parskip=0pt \parskip=2pt \fi
4103   \let\item = \internalBitem
4104   \let\itemx = \internalBitemx
4105 }
4106 \def\Etable{\endgraf\afterenvbreak}
4107 \let\Eftable\Etable
4108 \let\Evtable\Etable
4109 \let\Eitemize\Etable
4110 \let\Eenumerate\Etable
4111
4112 % This is the counter used by @enumerate, which is really @itemize
4113
4114 \newcount \itemno
4115
4116 \envdef\itemize{\parsearg\doitemize}
4117
4118 \def\doitemize#1{%
4119   \aboveenvbreak
4120   \itemmax=\itemindent
4121   \advance\itemmax by -\itemmargin
4122   \advance\leftskip by \itemindent
4123   \exdentamount=\itemindent
4124   \parindent=0pt
4125   \parskip=\smallskipamount
4126   \ifdim\parskip=0pt \parskip=2pt \fi
4127   %
4128   % Try typesetting the item mark so that if the document erroneously says
4129   % something like @itemize @samp (intending @table), there's an error
4130   % right away at the @itemize.  It's not the best error message in the
4131   % world, but it's better than leaving it to the @item.  This means if
4132   % the user wants an empty mark, they have to say @w{} not just @w.
4133   \def\itemcontents{#1}%
4134   \setbox0 = \hbox{\itemcontents}%
4135   %
4136   % @itemize with no arg is equivalent to @itemize @bullet.
4137   \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
4138   %
4139   \let\item=\itemizeitem
4140 }
4141
4142 % Definition of @item while inside @itemize and @enumerate.
4143 %
4144 \def\itemizeitem{%
4145   \advance\itemno by 1  % for enumerations
4146   {\let\par=\endgraf \smallbreak}% reasonable place to break
4147   {%
4148    % If the document has an @itemize directly after a section title, a
4149    % \nobreak will be last on the list, and \sectionheading will have
4150    % done a \vskip-\parskip.  In that case, we don't want to zero
4151    % parskip, or the item text will crash with the heading.  On the
4152    % other hand, when there is normal text preceding the item (as there
4153    % usually is), we do want to zero parskip, or there would be too much
4154    % space.  In that case, we won't have a \nobreak before.  At least
4155    % that's the theory.
4156    \ifnum\lastpenalty<10000 \parskip=0in \fi
4157    \noindent
4158    \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
4159    %
4160    \ifinner\else
4161      \vadjust{\penalty 1200}% not good to break after first line of item.
4162    \fi
4163    % We can be in inner vertical mode in a footnote, although an
4164    % @itemize looks awful there.
4165   }%
4166   \flushcr
4167 }
4168
4169 % \splitoff TOKENS\endmark defines \first to be the first token in
4170 % TOKENS, and \rest to be the remainder.
4171 %
4172 \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
4173
4174 % Allow an optional argument of an uppercase letter, lowercase letter,
4175 % or number, to specify the first label in the enumerated list.  No
4176 % argument is the same as `1'.
4177 %
4178 \envparseargdef\enumerate{\enumeratey #1  \endenumeratey}
4179 \def\enumeratey #1 #2\endenumeratey{%
4180   % If we were given no argument, pretend we were given `1'.
4181   \def\thearg{#1}%
4182   \ifx\thearg\empty \def\thearg{1}\fi
4183   %
4184   % Detect if the argument is a single token.  If so, it might be a
4185   % letter.  Otherwise, the only valid thing it can be is a number.
4186   % (We will always have one token, because of the test we just made.
4187   % This is a good thing, since \splitoff doesn't work given nothing at
4188   % all -- the first parameter is undelimited.)
4189   \expandafter\splitoff\thearg\endmark
4190   \ifx\rest\empty
4191     % Only one token in the argument.  It could still be anything.
4192     % A ``lowercase letter'' is one whose \lccode is nonzero.
4193     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
4194     %   not equal to itself.
4195     % Otherwise, we assume it's a number.
4196     %
4197     % We need the \relax at the end of the \ifnum lines to stop TeX from
4198     % continuing to look for a <number>.
4199     %
4200     \ifnum\lccode\expandafter`\thearg=0\relax
4201       \numericenumerate % a number (we hope)
4202     \else
4203       % It's a letter.
4204       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
4205         \lowercaseenumerate % lowercase letter
4206       \else
4207         \uppercaseenumerate % uppercase letter
4208       \fi
4209     \fi
4210   \else
4211     % Multiple tokens in the argument.  We hope it's a number.
4212     \numericenumerate
4213   \fi
4214 }
4215
4216 % An @enumerate whose labels are integers.  The starting integer is
4217 % given in \thearg.
4218 %
4219 \def\numericenumerate{%
4220   \itemno = \thearg
4221   \startenumeration{\the\itemno}%
4222 }
4223
4224 % The starting (lowercase) letter is in \thearg.
4225 \def\lowercaseenumerate{%
4226   \itemno = \expandafter`\thearg
4227   \startenumeration{%
4228     % Be sure we're not beyond the end of the alphabet.
4229     \ifnum\itemno=0
4230       \errmessage{No more lowercase letters in @enumerate; get a bigger
4231                   alphabet}%
4232     \fi
4233     \char\lccode\itemno
4234   }%
4235 }
4236
4237 % The starting (uppercase) letter is in \thearg.
4238 \def\uppercaseenumerate{%
4239   \itemno = \expandafter`\thearg
4240   \startenumeration{%
4241     % Be sure we're not beyond the end of the alphabet.
4242     \ifnum\itemno=0
4243       \errmessage{No more uppercase letters in @enumerate; get a bigger
4244                   alphabet}
4245     \fi
4246     \char\uccode\itemno
4247   }%
4248 }
4249
4250 % Call \doitemize, adding a period to the first argument and supplying the
4251 % common last two arguments.  Also subtract one from the initial value in
4252 % \itemno, since @item increments \itemno.
4253 %
4254 \def\startenumeration#1{%
4255   \advance\itemno by -1
4256   \doitemize{#1.}\flushcr
4257 }
4258
4259 % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
4260 % to @enumerate.
4261 %
4262 \def\alphaenumerate{\enumerate{a}}
4263 \def\capsenumerate{\enumerate{A}}
4264 \def\Ealphaenumerate{\Eenumerate}
4265 \def\Ecapsenumerate{\Eenumerate}
4266
4267
4268 % @multitable macros
4269 % Amy Hendrickson, 8/18/94, 3/6/96
4270 %
4271 % @multitable ... @end multitable will make as many columns as desired.
4272 % Contents of each column will wrap at width given in preamble.  Width
4273 % can be specified either with sample text given in a template line,
4274 % or in percent of \hsize, the current width of text on page.
4275
4276 % Table can continue over pages but will only break between lines.
4277
4278 % To make preamble:
4279 %
4280 % Either define widths of columns in terms of percent of \hsize:
4281 %   @multitable @columnfractions .25 .3 .45
4282 %   @item ...
4283 %
4284 %   Numbers following @columnfractions are the percent of the total
4285 %   current hsize to be used for each column. You may use as many
4286 %   columns as desired.
4287
4288
4289 % Or use a template:
4290 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4291 %   @item ...
4292 %   using the widest term desired in each column.
4293
4294 % Each new table line starts with @item, each subsequent new column
4295 % starts with @tab. Empty columns may be produced by supplying @tab's
4296 % with nothing between them for as many times as empty columns are needed,
4297 % ie, @tab@tab@tab will produce two empty columns.
4298
4299 % @item, @tab do not need to be on their own lines, but it will not hurt
4300 % if they are.
4301
4302 % Sample multitable:
4303
4304 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4305 %   @item first col stuff @tab second col stuff @tab third col
4306 %   @item
4307 %   first col stuff
4308 %   @tab
4309 %   second col stuff
4310 %   @tab
4311 %   third col
4312 %   @item first col stuff @tab second col stuff
4313 %   @tab Many paragraphs of text may be used in any column.
4314 %
4315 %         They will wrap at the width determined by the template.
4316 %   @item@tab@tab This will be in third column.
4317 %   @end multitable
4318
4319 % Default dimensions may be reset by user.
4320 % @multitableparskip is vertical space between paragraphs in table.
4321 % @multitableparindent is paragraph indent in table.
4322 % @multitablecolmargin is horizontal space to be left between columns.
4323 % @multitablelinespace is space to leave between table items, baseline
4324 %                                                            to baseline.
4325 %   0pt means it depends on current normal line spacing.
4326 %
4327 \newskip\multitableparskip
4328 \newskip\multitableparindent
4329 \newdimen\multitablecolspace
4330 \newskip\multitablelinespace
4331 \multitableparskip=0pt
4332 \multitableparindent=6pt
4333 \multitablecolspace=12pt
4334 \multitablelinespace=0pt
4335
4336 % Macros used to set up halign preamble:
4337 %
4338 \let\endsetuptable\relax
4339 \def\xendsetuptable{\endsetuptable}
4340 \let\columnfractions\relax
4341 \def\xcolumnfractions{\columnfractions}
4342 \newif\ifsetpercent
4343
4344 % #1 is the @columnfraction, usually a decimal number like .5, but might
4345 % be just 1.  We just use it, whatever it is.
4346 %
4347 \def\pickupwholefraction#1 {%
4348   \global\advance\colcount by 1
4349   \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
4350   \setuptable
4351 }
4352
4353 \newcount\colcount
4354 \def\setuptable#1{%
4355   \def\firstarg{#1}%
4356   \ifx\firstarg\xendsetuptable
4357     \let\go = \relax
4358   \else
4359     \ifx\firstarg\xcolumnfractions
4360       \global\setpercenttrue
4361     \else
4362       \ifsetpercent
4363          \let\go\pickupwholefraction
4364       \else
4365          \global\advance\colcount by 1
4366          \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
4367                    % separator; typically that is always in the input, anyway.
4368          \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
4369       \fi
4370     \fi
4371     \ifx\go\pickupwholefraction
4372       % Put the argument back for the \pickupwholefraction call, so
4373       % we'll always have a period there to be parsed.
4374       \def\go{\pickupwholefraction#1}%
4375     \else
4376       \let\go = \setuptable
4377     \fi%
4378   \fi
4379   \go
4380 }
4381
4382 % multitable-only commands.
4383
4384 % @headitem starts a heading row, which we typeset in bold.  Assignments
4385 % have to be global since we are inside the implicit group of an
4386 % alignment entry.  \everycr below resets \everytab so we don't have to
4387 % undo it ourselves.
4388 \def\headitemfont{\b}% for people to use in the template row; not changeable
4389 \def\headitem{%
4390   \checkenv\multitable
4391   \crcr
4392   \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
4393   \global\everytab={\bf}% can't use \headitemfont since the parsing differs
4394   \the\everytab % for the first item
4395 }%
4396 %
4397 % default for tables with no headings.
4398 \let\headitemcrhook=\relax
4399 %
4400 % A \tab used to include \hskip1sp.  But then the space in a template
4401 % line is not enough.  That is bad.  So let's go back to just `&' until
4402 % we again encounter the problem the 1sp was intended to solve.
4403 %                                       --karl, nathan@acm.org, 20apr99.
4404 \def\tab{\checkenv\multitable &\the\everytab}%
4405
4406 % @multitable ... @end multitable definitions:
4407 %
4408 \newtoks\everytab  % insert after every tab.
4409 %
4410 \envdef\multitable{%
4411   \vskip\parskip
4412   \startsavinginserts
4413   %
4414   % @item within a multitable starts a normal row.
4415   % We use \def instead of \let so that if one of the multitable entries
4416   % contains an @itemize, we don't choke on the \item (seen as \crcr aka
4417   % \endtemplate) expanding \doitemize.
4418   \def\item{\crcr}%
4419   %
4420   \tolerance=9500
4421   \hbadness=9500
4422   \setmultitablespacing
4423   \parskip=\multitableparskip
4424   \parindent=\multitableparindent
4425   \overfullrule=0pt
4426   \global\colcount=0
4427   %
4428   \everycr = {%
4429     \noalign{%
4430       \global\everytab={}% Reset from possible headitem.
4431       \global\colcount=0 % Reset the column counter.
4432       %
4433       % Check for saved footnotes, etc.:
4434       \checkinserts
4435       %
4436       % Perhaps a \nobreak, then reset:
4437       \headitemcrhook
4438       \global\let\headitemcrhook=\relax
4439     }%
4440   }%
4441   %
4442   \parsearg\domultitable
4443 }
4444 \def\domultitable#1{%
4445   % To parse everything between @multitable and @item:
4446   \setuptable#1 \endsetuptable
4447   %
4448   % This preamble sets up a generic column definition, which will
4449   % be used as many times as user calls for columns.
4450   % \vtop will set a single line and will also let text wrap and
4451   % continue for many paragraphs if desired.
4452   \halign\bgroup &%
4453     \global\advance\colcount by 1
4454     \multistrut
4455     \vtop{%
4456       % Use the current \colcount to find the correct column width:
4457       \hsize=\expandafter\csname col\the\colcount\endcsname
4458       %
4459       % In order to keep entries from bumping into each other
4460       % we will add a \leftskip of \multitablecolspace to all columns after
4461       % the first one.
4462       %
4463       % If a template has been used, we will add \multitablecolspace
4464       % to the width of each template entry.
4465       %
4466       % If the user has set preamble in terms of percent of \hsize we will
4467       % use that dimension as the width of the column, and the \leftskip
4468       % will keep entries from bumping into each other.  Table will start at
4469       % left margin and final column will justify at right margin.
4470       %
4471       % Make sure we don't inherit \rightskip from the outer environment.
4472       \rightskip=0pt
4473       \ifnum\colcount=1
4474         % The first column will be indented with the surrounding text.
4475         \advance\hsize by\leftskip
4476       \else
4477         \ifsetpercent \else
4478           % If user has not set preamble in terms of percent of \hsize
4479           % we will advance \hsize by \multitablecolspace.
4480           \advance\hsize by \multitablecolspace
4481         \fi
4482        % In either case we will make \leftskip=\multitablecolspace:
4483       \leftskip=\multitablecolspace
4484       \fi
4485       % Ignoring space at the beginning and end avoids an occasional spurious
4486       % blank line, when TeX decides to break the line at the space before the
4487       % box from the multistrut, so the strut ends up on a line by itself.
4488       % For example:
4489       % @multitable @columnfractions .11 .89
4490       % @item @code{#}
4491       % @tab Legal holiday which is valid in major parts of the whole country.
4492       % Is automatically provided with highlighting sequences respectively
4493       % marking characters.
4494       \noindent\ignorespaces##\unskip\multistrut
4495     }\cr
4496 }
4497 \def\Emultitable{%
4498   \crcr
4499   \egroup % end the \halign
4500   \global\setpercentfalse
4501 }
4502
4503 \def\setmultitablespacing{%
4504   \def\multistrut{\strut}% just use the standard line spacing
4505   %
4506   % Compute \multitablelinespace (if not defined by user) for use in
4507   % \multitableparskip calculation.  We used define \multistrut based on
4508   % this, but (ironically) that caused the spacing to be off.
4509   % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
4510 \ifdim\multitablelinespace=0pt
4511 \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
4512 \global\advance\multitablelinespace by-\ht0
4513 \fi
4514 % Test to see if parskip is larger than space between lines of
4515 % table. If not, do nothing.
4516 %        If so, set to same dimension as multitablelinespace.
4517 \ifdim\multitableparskip>\multitablelinespace
4518 \global\multitableparskip=\multitablelinespace
4519 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4520                                       % than skip between lines in the table.
4521 \fi%
4522 \ifdim\multitableparskip=0pt
4523 \global\multitableparskip=\multitablelinespace
4524 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4525                                       % than skip between lines in the table.
4526 \fi}
4527
4528
4529 \message{conditionals,}
4530
4531 % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
4532 % @ifnotxml always succeed.  They currently do nothing; we don't
4533 % attempt to check whether the conditionals are properly nested.  But we
4534 % have to remember that they are conditionals, so that @end doesn't
4535 % attempt to close an environment group.
4536 %
4537 \def\makecond#1{%
4538   \expandafter\let\csname #1\endcsname = \relax
4539   \expandafter\let\csname iscond.#1\endcsname = 1
4540 }
4541 \makecond{iftex}
4542 \makecond{ifnotdocbook}
4543 \makecond{ifnothtml}
4544 \makecond{ifnotinfo}
4545 \makecond{ifnotplaintext}
4546 \makecond{ifnotxml}
4547
4548 % Ignore @ignore, @ifhtml, @ifinfo, and the like.
4549 %
4550 \def\direntry{\doignore{direntry}}
4551 \def\documentdescription{\doignore{documentdescription}}
4552 \def\docbook{\doignore{docbook}}
4553 \def\html{\doignore{html}}
4554 \def\ifdocbook{\doignore{ifdocbook}}
4555 \def\ifhtml{\doignore{ifhtml}}
4556 \def\ifinfo{\doignore{ifinfo}}
4557 \def\ifnottex{\doignore{ifnottex}}
4558 \def\ifplaintext{\doignore{ifplaintext}}
4559 \def\ifxml{\doignore{ifxml}}
4560 \def\ignore{\doignore{ignore}}
4561 \def\menu{\doignore{menu}}
4562 \def\xml{\doignore{xml}}
4563
4564 % Ignore text until a line `@end #1', keeping track of nested conditionals.
4565 %
4566 % A count to remember the depth of nesting.
4567 \newcount\doignorecount
4568
4569 \def\doignore#1{\begingroup
4570   % Scan in ``verbatim'' mode:
4571   \obeylines
4572   \catcode`\@ = \other
4573   \catcode`\{ = \other
4574   \catcode`\} = \other
4575   %
4576   % Make sure that spaces turn into tokens that match what \doignoretext wants.
4577   \spaceisspace
4578   %
4579   % Count number of #1's that we've seen.
4580   \doignorecount = 0
4581   %
4582   % Swallow text until we reach the matching `@end #1'.
4583   \dodoignore{#1}%
4584 }
4585
4586 { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4587   \obeylines %
4588   %
4589   \gdef\dodoignore#1{%
4590     % #1 contains the command name as a string, e.g., `ifinfo'.
4591     %
4592     % Define a command to find the next `@end #1'.
4593     \long\def\doignoretext##1^^M@end #1{%
4594       \doignoretextyyy##1^^M@#1\_STOP_}%
4595     %
4596     % And this command to find another #1 command, at the beginning of a
4597     % line.  (Otherwise, we would consider a line `@c @ifset', for
4598     % example, to count as an @ifset for nesting.)
4599     \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
4600     %
4601     % And now expand that command.
4602     \doignoretext ^^M%
4603   }%
4604 }
4605
4606 \def\doignoreyyy#1{%
4607   \def\temp{#1}%
4608   \ifx\temp\empty                       % Nothing found.
4609     \let\next\doignoretextzzz
4610   \else                                 % Found a nested condition, ...
4611     \advance\doignorecount by 1
4612     \let\next\doignoretextyyy           % ..., look for another.
4613     % If we're here, #1 ends with ^^M\ifinfo (for example).
4614   \fi
4615   \next #1% the token \_STOP_ is present just after this macro.
4616 }
4617
4618 % We have to swallow the remaining "\_STOP_".
4619 %
4620 \def\doignoretextzzz#1{%
4621   \ifnum\doignorecount = 0      % We have just found the outermost @end.
4622     \let\next\enddoignore
4623   \else                         % Still inside a nested condition.
4624     \advance\doignorecount by -1
4625     \let\next\doignoretext      % Look for the next @end.
4626   \fi
4627   \next
4628 }
4629
4630 % Finish off ignored text.
4631 { \obeylines%
4632   % Ignore anything after the last `@end #1'; this matters in verbatim
4633   % environments, where otherwise the newline after an ignored conditional
4634   % would result in a blank line in the output.
4635   \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4636 }
4637
4638
4639 % @set VAR sets the variable VAR to an empty value.
4640 % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4641 %
4642 % Since we want to separate VAR from REST-OF-LINE (which might be
4643 % empty), we can't just use \parsearg; we have to insert a space of our
4644 % own to delimit the rest of the line, and then take it out again if we
4645 % didn't need it.
4646 % We rely on the fact that \parsearg sets \catcode`\ =10.
4647 %
4648 \parseargdef\set{\setyyy#1 \endsetyyy}
4649 \def\setyyy#1 #2\endsetyyy{%
4650   {%
4651     \makevalueexpandable
4652     \def\temp{#2}%
4653     \edef\next{\gdef\makecsname{SET#1}}%
4654     \ifx\temp\empty
4655       \next{}%
4656     \else
4657       \setzzz#2\endsetzzz
4658     \fi
4659   }%
4660 }
4661 % Remove the trailing space \setxxx inserted.
4662 \def\setzzz#1 \endsetzzz{\next{#1}}
4663
4664 % @clear VAR clears (i.e., unsets) the variable VAR.
4665 %
4666 \parseargdef\clear{%
4667   {%
4668     \makevalueexpandable
4669     \global\expandafter\let\csname SET#1\endcsname=\relax
4670   }%
4671 }
4672
4673 % @value{foo} gets the text saved in variable foo.
4674 \def\value{\begingroup\makevalueexpandable\valuexxx}
4675 \def\valuexxx#1{\expandablevalue{#1}\endgroup}
4676 {
4677   \catcode`\-=\active \catcode`\_=\active
4678   %
4679   \gdef\makevalueexpandable{%
4680     \let\value = \expandablevalue
4681     % We don't want these characters active, ...
4682     \catcode`\-=\other \catcode`\_=\other
4683     % ..., but we might end up with active ones in the argument if
4684     % we're called from @code, as @code{@value{foo-bar_}}, though.
4685     % So \let them to their normal equivalents.
4686     \let-\normaldash \let_\normalunderscore
4687   }
4688 }
4689
4690 % We have this subroutine so that we can handle at least some @value's
4691 % properly in indexes (we call \makevalueexpandable in \indexdummies).
4692 % The command has to be fully expandable (if the variable is set), since
4693 % the result winds up in the index file.  This means that if the
4694 % variable's value contains other Texinfo commands, it's almost certain
4695 % it will fail (although perhaps we could fix that with sufficient work
4696 % to do a one-level expansion on the result, instead of complete).
4697
4698 % Unfortunately, this has the consequence that when _ is in the *value*
4699 % of an @set, it does not print properly in the roman fonts (get the cmr
4700 % dot accent at position 126 instead).  No fix comes to mind, and it's
4701 % been this way since 2003 or earlier, so just ignore it.
4702
4703 \def\expandablevalue#1{%
4704   \expandafter\ifx\csname SET#1\endcsname\relax
4705     {[No value for ``#1'']}%
4706     \message{Variable `#1', used in @value, is not set.}%
4707   \else
4708     \csname SET#1\endcsname
4709   \fi
4710 }
4711
4712 % Like \expandablevalue, but completely expandable (the \message in the
4713 % definition above operates at the execution level of TeX).  Used when
4714 % writing to auxiliary files, due to the expansion that \write does.
4715 % If flag is undefined, pass through an unexpanded @value command: maybe it 
4716 % will be set by the time it is read back in.
4717 %
4718 % NB flag names containing - or _ may not work here.
4719 \def\dummyvalue#1{%
4720   \expandafter\ifx\csname SET#1\endcsname\relax
4721     \noexpand\value{#1}%
4722   \else
4723     \csname SET#1\endcsname
4724   \fi
4725 }
4726
4727 % Used for @value's in index entries to form the sort key: expand the @value
4728 % if possible, otherwise sort late.
4729 \def\indexnofontsvalue#1{%
4730   \expandafter\ifx\csname SET#1\endcsname\relax
4731     ZZZZZZZ
4732   \else
4733     \csname SET#1\endcsname
4734   \fi
4735 }
4736
4737 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4738 % with @set.
4739
4740 % To get the special treatment we need for `@end ifset,' we call
4741 % \makecond and then redefine.
4742 %
4743 \makecond{ifset}
4744 \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4745 \def\doifset#1#2{%
4746   {%
4747     \makevalueexpandable
4748     \let\next=\empty
4749     \expandafter\ifx\csname SET#2\endcsname\relax
4750       #1% If not set, redefine \next.
4751     \fi
4752     \expandafter
4753   }\next
4754 }
4755 \def\ifsetfail{\doignore{ifset}}
4756
4757 % @ifclear VAR ... @end executes the `...' iff VAR has never been
4758 % defined with @set, or has been undefined with @clear.
4759 %
4760 % The `\else' inside the `\doifset' parameter is a trick to reuse the
4761 % above code: if the variable is not set, do nothing, if it is set,
4762 % then redefine \next to \ifclearfail.
4763 %
4764 \makecond{ifclear}
4765 \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4766 \def\ifclearfail{\doignore{ifclear}}
4767
4768 % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
4769 % without the @) is in fact defined.  We can only feasibly check at the
4770 % TeX level, so something like `mathcode' is going to considered
4771 % defined even though it is not a Texinfo command.
4772
4773 \makecond{ifcommanddefined}
4774 \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
4775 %
4776 \def\doifcmddefined#1#2{{%
4777     \makevalueexpandable
4778     \let\next=\empty
4779     \expandafter\ifx\csname #2\endcsname\relax
4780       #1% If not defined, \let\next as above.
4781     \fi
4782     \expandafter
4783   }\next
4784 }
4785 \def\ifcmddefinedfail{\doignore{ifcommanddefined}}
4786
4787 % @ifcommandnotdefined CMD ... handled similar to @ifclear above.
4788 \makecond{ifcommandnotdefined}
4789 \def\ifcommandnotdefined{%
4790   \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
4791 \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
4792
4793 % Set the `txicommandconditionals' variable, so documents have a way to
4794 % test if the @ifcommand...defined conditionals are available.
4795 \set txicommandconditionals
4796
4797 % @dircategory CATEGORY  -- specify a category of the dir file
4798 % which this file should belong to.  Ignore this in TeX.
4799 \let\dircategory=\comment
4800
4801 % @defininfoenclose.
4802 \let\definfoenclose=\comment
4803
4804
4805 \message{indexing,}
4806 % Index generation facilities
4807
4808 % Define \newwrite to be identical to plain tex's \newwrite
4809 % except not \outer, so it can be used within macros and \if's.
4810 \edef\newwrite{\makecsname{ptexnewwrite}}
4811
4812 % \newindex {foo} defines an index named IX.
4813 % It automatically defines \IXindex such that
4814 % \IXindex ...rest of line... puts an entry in the index IX.
4815 % It also defines \IXindfile to be the number of the output channel for
4816 % the file that accumulates this index.  The file's extension is IX.
4817 % The name of an index should be no more than 2 characters long
4818 % for the sake of vms.
4819 %
4820 \def\newindex#1{%
4821   \expandafter\chardef\csname#1indfile\endcsname=0
4822   \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
4823     \noexpand\doindex{#1}}
4824 }
4825
4826 % @defindex foo  ==  \newindex{foo}
4827 %
4828 \def\defindex{\parsearg\newindex}
4829
4830 % Define @defcodeindex, like @defindex except put all entries in @code.
4831 %
4832 \def\defcodeindex{\parsearg\newcodeindex}
4833 %
4834 \def\newcodeindex#1{%
4835   \expandafter\chardef\csname#1indfile\endcsname=0
4836   \expandafter\xdef\csname#1index\endcsname{%
4837     \noexpand\docodeindex{#1}}%
4838 }
4839
4840 % The default indices:
4841 \newindex{cp}%      concepts,
4842 \newcodeindex{fn}%  functions,
4843 \newcodeindex{vr}%  variables,
4844 \newcodeindex{tp}%  types,
4845 \newcodeindex{ky}%  keys
4846 \newcodeindex{pg}%  and programs.
4847
4848
4849 % @synindex foo bar    makes index foo feed into index bar.
4850 % Do this instead of @defindex foo if you don't want it as a separate index.
4851 %
4852 % @syncodeindex foo bar   similar, but put all entries made for index foo
4853 % inside @code.
4854 %
4855 \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4856 \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4857
4858 % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4859 % #3 the target index (bar).
4860 \def\dosynindex#1#2#3{%
4861   \requireopenindexfile{#3}%
4862   % redefine \fooindfile:
4863   \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4864   \expandafter\let\csname#2indfile\endcsname=\temp
4865   % redefine \fooindex:
4866   \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
4867 }
4868
4869 % Define \doindex, the driver for all index macros.
4870 % Argument #1 is generated by the calling \fooindex macro,
4871 % and it is the two-letter name of the index.
4872
4873 \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
4874 \def\doindexxxx #1{\doind{\indexname}{#1}}
4875
4876 % like the previous two, but they put @code around the argument.
4877 \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
4878 \def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
4879
4880 \f
4881 % Used when writing an index entry out to an index file to prevent
4882 % expansion of Texinfo commands that can appear in an index entry.
4883 %
4884 \def\indexdummies{%
4885   \escapechar = `\\     % use backslash in output files.
4886   \definedummyletter\@%
4887   \definedummyletter\ %
4888   %
4889   % For texindex which always views { and } as separators.
4890   \def\{{\lbracechar{}}%
4891   \def\}{\rbracechar{}}%
4892   %
4893   % Do the redefinitions.
4894   \definedummies
4895 }
4896
4897 % Used for the aux and toc files, where @ is the escape character.
4898 %
4899 \def\atdummies{%
4900   \definedummyletter\@%
4901   \definedummyletter\ %
4902   \definedummyletter\{%
4903   \definedummyletter\}%
4904   %
4905   % Do the redefinitions.
4906   \definedummies
4907   \otherbackslash
4908 }
4909
4910 % \definedummyword defines \#1 as \string\#1\space, thus effectively
4911 % preventing its expansion.  This is used only for control words,
4912 % not control letters, because the \space would be incorrect for
4913 % control characters, but is needed to separate the control word
4914 % from whatever follows.
4915 %
4916 % These can be used both for control words that take an argument and
4917 % those that do not.  If it is followed by {arg} in the input, then
4918 % that will dutifully get written to the index (or wherever).
4919 %
4920 % For control letters, we have \definedummyletter, which omits the
4921 % space.
4922 %
4923 \def\definedummyword  #1{\def#1{\string#1\space}}%
4924 \def\definedummyletter#1{\def#1{\string#1}}%
4925 \let\definedummyaccent\definedummyletter
4926
4927 % Called from \indexdummies and \atdummies, to effectively prevent
4928 % the expansion of commands.
4929 %
4930 \def\definedummies{%
4931   %
4932   \let\commondummyword\definedummyword
4933   \let\commondummyletter\definedummyletter
4934   \let\commondummyaccent\definedummyaccent
4935   \commondummiesnofonts
4936   %
4937   \definedummyletter\_%
4938   \definedummyletter\-%
4939   %
4940   % Non-English letters.
4941   \definedummyword\AA
4942   \definedummyword\AE
4943   \definedummyword\DH
4944   \definedummyword\L
4945   \definedummyword\O
4946   \definedummyword\OE
4947   \definedummyword\TH
4948   \definedummyword\aa
4949   \definedummyword\ae
4950   \definedummyword\dh
4951   \definedummyword\exclamdown
4952   \definedummyword\l
4953   \definedummyword\o
4954   \definedummyword\oe
4955   \definedummyword\ordf
4956   \definedummyword\ordm
4957   \definedummyword\questiondown
4958   \definedummyword\ss
4959   \definedummyword\th
4960   %
4961   % Although these internal commands shouldn't show up, sometimes they do.
4962   \definedummyword\bf
4963   \definedummyword\gtr
4964   \definedummyword\hat
4965   \definedummyword\less
4966   \definedummyword\sf
4967   \definedummyword\sl
4968   \definedummyword\tclose
4969   \definedummyword\tt
4970   %
4971   \definedummyword\LaTeX
4972   \definedummyword\TeX
4973   %
4974   % Assorted special characters.
4975   \definedummyword\atchar
4976   \definedummyword\arrow
4977   \definedummyword\bullet
4978   \definedummyword\comma
4979   \definedummyword\copyright
4980   \definedummyword\registeredsymbol
4981   \definedummyword\dots
4982   \definedummyword\enddots
4983   \definedummyword\entrybreak
4984   \definedummyword\equiv
4985   \definedummyword\error
4986   \definedummyword\euro
4987   \definedummyword\expansion
4988   \definedummyword\geq
4989   \definedummyword\guillemetleft
4990   \definedummyword\guillemetright
4991   \definedummyword\guilsinglleft
4992   \definedummyword\guilsinglright
4993   \definedummyword\lbracechar
4994   \definedummyword\leq
4995   \definedummyword\mathopsup
4996   \definedummyword\minus
4997   \definedummyword\ogonek
4998   \definedummyword\pounds
4999   \definedummyword\point
5000   \definedummyword\print
5001   \definedummyword\quotedblbase
5002   \definedummyword\quotedblleft
5003   \definedummyword\quotedblright
5004   \definedummyword\quoteleft
5005   \definedummyword\quoteright
5006   \definedummyword\quotesinglbase
5007   \definedummyword\rbracechar
5008   \definedummyword\result
5009   \definedummyword\sub
5010   \definedummyword\sup
5011   \definedummyword\textdegree
5012   %
5013   % We want to disable all macros so that they are not expanded by \write.
5014   \macrolist
5015   \let\value\dummyvalue
5016   %
5017   \normalturnoffactive
5018 }
5019
5020 % \commondummiesnofonts: common to \definedummies and \indexnofonts.
5021 % Define \commondummyletter, \commondummyaccent and \commondummyword before
5022 % using.  Used for accents, font commands, and various control letters.
5023 %
5024 \def\commondummiesnofonts{%
5025   % Control letters and accents.
5026   \commondummyletter\!%
5027   \commondummyaccent\"%
5028   \commondummyaccent\'%
5029   \commondummyletter\*%
5030   \commondummyaccent\,%
5031   \commondummyletter\.%
5032   \commondummyletter\/%
5033   \commondummyletter\:%
5034   \commondummyaccent\=%
5035   \commondummyletter\?%
5036   \commondummyaccent\^%
5037   \commondummyaccent\`%
5038   \commondummyaccent\~%
5039   \commondummyword\u
5040   \commondummyword\v
5041   \commondummyword\H
5042   \commondummyword\dotaccent
5043   \commondummyword\ogonek
5044   \commondummyword\ringaccent
5045   \commondummyword\tieaccent
5046   \commondummyword\ubaraccent
5047   \commondummyword\udotaccent
5048   \commondummyword\dotless
5049   %
5050   % Texinfo font commands.
5051   \commondummyword\b
5052   \commondummyword\i
5053   \commondummyword\r
5054   \commondummyword\sansserif
5055   \commondummyword\sc
5056   \commondummyword\slanted
5057   \commondummyword\t
5058   %
5059   % Commands that take arguments.
5060   \commondummyword\abbr
5061   \commondummyword\acronym
5062   \commondummyword\anchor
5063   \commondummyword\cite
5064   \commondummyword\code
5065   \commondummyword\command
5066   \commondummyword\dfn
5067   \commondummyword\dmn
5068   \commondummyword\email
5069   \commondummyword\emph
5070   \commondummyword\env
5071   \commondummyword\file
5072   \commondummyword\image
5073   \commondummyword\indicateurl
5074   \commondummyword\inforef
5075   \commondummyword\kbd
5076   \commondummyword\key
5077   \commondummyword\math
5078   \commondummyword\option
5079   \commondummyword\pxref
5080   \commondummyword\ref
5081   \commondummyword\samp
5082   \commondummyword\strong
5083   \commondummyword\tie
5084   \commondummyword\U
5085   \commondummyword\uref
5086   \commondummyword\url
5087   \commondummyword\var
5088   \commondummyword\verb
5089   \commondummyword\w
5090   \commondummyword\xref
5091 }
5092
5093 % For testing: output @{ and @} in index sort strings as \{ and \}.
5094 \newif\ifusebracesinindexes
5095
5096 \let\indexlbrace\relax
5097 \let\indexrbrace\relax
5098
5099 {\catcode`\@=0
5100 \catcode`\\=13
5101   @gdef@backslashdisappear{@def\{}}
5102 }
5103
5104 {
5105 \catcode`\<=13
5106 \catcode`\-=13
5107 \catcode`\`=13
5108   \gdef\indexnonalnumdisappear{%
5109     \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
5110       % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
5111       % (Introduced for FSFS 2nd ed.)
5112       \let`=\empty
5113     \fi
5114     %
5115     \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
5116       \backslashdisappear
5117     \fi
5118     %
5119     \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
5120       \def-{}%
5121     \fi
5122     \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
5123       \def<{}%
5124     \fi
5125     \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
5126       \def\@{}%
5127     \fi
5128   }
5129
5130   \gdef\indexnonalnumreappear{%
5131     \useindexbackslash
5132     \let-\normaldash
5133     \let<\normalless
5134     \def\@{@}%
5135   }
5136 }
5137
5138
5139 % \indexnofonts is used when outputting the strings to sort the index
5140 % by, and when constructing control sequence names.  It eliminates all
5141 % control sequences and just writes whatever the best ASCII sort string
5142 % would be for a given command (usually its argument).
5143 %
5144 \def\indexnofonts{%
5145   % Accent commands should become @asis.
5146   \def\commondummyaccent##1{\let##1\asis}%
5147   % We can just ignore other control letters.
5148   \def\commondummyletter##1{\let##1\empty}%
5149   % All control words become @asis by default; overrides below.
5150   \let\commondummyword\commondummyaccent
5151   \commondummiesnofonts
5152   %
5153   % Don't no-op \tt, since it isn't a user-level command
5154   % and is used in the definitions of the active chars like <, >, |, etc.
5155   % Likewise with the other plain tex font commands.
5156   %\let\tt=\asis
5157   %
5158   \def\ { }%
5159   \def\@{@}%
5160   \def\_{\normalunderscore}%
5161   \def\-{}% @- shouldn't affect sorting
5162   %
5163   \uccode`\1=`\{ \uppercase{\def\{{1}}%
5164   \uccode`\1=`\} \uppercase{\def\}{1}}%
5165   \let\lbracechar\{%
5166   \let\rbracechar\}%
5167   %
5168   % Non-English letters.
5169   \def\AA{AA}%
5170   \def\AE{AE}%
5171   \def\DH{DZZ}%
5172   \def\L{L}%
5173   \def\OE{OE}%
5174   \def\O{O}%
5175   \def\TH{TH}%
5176   \def\aa{aa}%
5177   \def\ae{ae}%
5178   \def\dh{dzz}%
5179   \def\exclamdown{!}%
5180   \def\l{l}%
5181   \def\oe{oe}%
5182   \def\ordf{a}%
5183   \def\ordm{o}%
5184   \def\o{o}%
5185   \def\questiondown{?}%
5186   \def\ss{ss}%
5187   \def\th{th}%
5188   %
5189   \def\LaTeX{LaTeX}%
5190   \def\TeX{TeX}%
5191   %
5192   % Assorted special characters.  \defglyph gives the control sequence a
5193   % definition that removes the {} that follows its use.
5194   \defglyph\atchar{@}%
5195   \defglyph\arrow{->}%
5196   \defglyph\bullet{bullet}%
5197   \defglyph\comma{,}%
5198   \defglyph\copyright{copyright}%
5199   \defglyph\dots{...}%
5200   \defglyph\enddots{...}%
5201   \defglyph\equiv{==}%
5202   \defglyph\error{error}%
5203   \defglyph\euro{euro}%
5204   \defglyph\expansion{==>}%
5205   \defglyph\geq{>=}%
5206   \defglyph\guillemetleft{<<}%
5207   \defglyph\guillemetright{>>}%
5208   \defglyph\guilsinglleft{<}%
5209   \defglyph\guilsinglright{>}%
5210   \defglyph\leq{<=}%
5211   \defglyph\lbracechar{\{}%
5212   \defglyph\minus{-}%
5213   \defglyph\point{.}%
5214   \defglyph\pounds{pounds}%
5215   \defglyph\print{-|}%
5216   \defglyph\quotedblbase{"}%
5217   \defglyph\quotedblleft{"}%
5218   \defglyph\quotedblright{"}%
5219   \defglyph\quoteleft{`}%
5220   \defglyph\quoteright{'}%
5221   \defglyph\quotesinglbase{,}%
5222   \defglyph\rbracechar{\}}%
5223   \defglyph\registeredsymbol{R}%
5224   \defglyph\result{=>}%
5225   \defglyph\textdegree{o}%
5226   %
5227   % We need to get rid of all macros, leaving only the arguments (if present).
5228   % Of course this is not nearly correct, but it is the best we can do for now.
5229   % makeinfo does not expand macros in the argument to @deffn, which ends up
5230   % writing an index entry, and texindex isn't prepared for an index sort entry
5231   % that starts with \.
5232   %
5233   % Since macro invocations are followed by braces, we can just redefine them
5234   % to take a single TeX argument.  The case of a macro invocation that
5235   % goes to end-of-line is not handled.
5236   %
5237   \macrolist
5238   \let\value\indexnofontsvalue
5239 }
5240 \def\defglyph#1#2{\def#1##1{#2}} % see above
5241
5242 \f
5243
5244
5245 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
5246
5247 % Most index entries go through here, but \dosubind is the general case.
5248 % #1 is the index name, #2 is the entry text.
5249 \def\doind#1#2{\dosubind{#1}{#2}{}}
5250
5251 % There is also \dosubind {index}{topic}{subtopic}
5252 % which makes an entry in a two-level index such as the operation index.
5253 % TODO: Two-level index?  Operation index?
5254
5255 % Workhorse for all indexes.
5256 % #1 is name of index, #2 is stuff to put there, #3 is subentry --
5257 % empty if called from \doind, as we usually are (the main exception
5258 % is with most defuns, which call us directly).
5259 %
5260 \def\dosubind#1#2#3{%
5261   \iflinks
5262   {%
5263     \requireopenindexfile{#1}%
5264     % Store the main index entry text (including the third arg).
5265     \toks0 = {#2}%
5266     % If third arg is present, precede it with a space.
5267     \def\thirdarg{#3}%
5268     \ifx\thirdarg\empty \else
5269       \toks0 = \expandafter{\the\toks0 \space #3}%
5270     \fi
5271     %
5272     \edef\writeto{\csname#1indfile\endcsname}%
5273     %
5274     \safewhatsit\dosubindwrite
5275   }%
5276   \fi
5277 }
5278
5279 % Check if an index file has been opened, and if not, open it.
5280 \def\requireopenindexfile#1{%
5281 \ifnum\csname #1indfile\endcsname=0
5282   \expandafter\newwrite \csname#1indfile\endcsname
5283   \edef\suffix{#1}%
5284   % A .fls suffix would conflict with the file extension for the output
5285   % of -recorder, so use .f1s instead.
5286   \ifx\suffix\indexisfl\def\suffix{f1}\fi
5287   % Open the file
5288   \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
5289   % Using \immediate above here prevents an object entering into the current 
5290   % box, which could confound checks such as those in \safewhatsit for
5291   % preceding skips.
5292   \typeout{Writing index file \jobname.\suffix}%
5293 \fi}
5294 \def\indexisfl{fl}
5295
5296 % Output \ as {\indexbackslash}, because \ is an escape character in
5297 % the index files.
5298 \let\indexbackslash=\relax
5299 {\catcode`\@=0 \catcode`\\=\active
5300   @gdef@useindexbackslash{@def\{{@indexbackslash}}}
5301 }
5302
5303 % Definition for writing index entry text.
5304 \def\sortas#1{\ignorespaces}%
5305
5306 % Definition for writing index entry sort key.  Should occur at the at
5307 % the beginning of the index entry, like
5308 %     @cindex @sortas{september} \september
5309 % The \ignorespaces takes care of following space, but there's no way
5310 % to remove space before it.
5311 {
5312 \catcode`\-=13
5313 \gdef\indexwritesortas{%
5314   \begingroup
5315   \indexnonalnumreappear
5316   \indexwritesortasxxx}
5317 \gdef\indexwritesortasxxx#1{%
5318   \xdef\indexsortkey{#1}\endgroup}
5319 }
5320
5321
5322 % Write the entry in \toks0 to the index file.
5323 %
5324 \def\dosubindwrite{%
5325   % Put the index entry in the margin if desired.
5326   \ifx\SETmarginindex\relax\else
5327     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
5328   \fi
5329   %
5330   % Remember, we are within a group.
5331   \indexdummies % Must do this here, since \bf, etc expand at this stage
5332   \useindexbackslash % \indexbackslash isn't defined now so it will be output 
5333                      % as is; and it will print as backslash.
5334   % The braces around \indexbrace are recognized by texindex.
5335   %
5336   % Get the string to sort by, by processing the index entry with all
5337   % font commands turned off.
5338   {\indexnofonts
5339    \def\lbracechar{{\indexlbrace}}%
5340    \def\rbracechar{{\indexrbrace}}%
5341    \let\{=\lbracechar
5342    \let\}=\rbracechar
5343    \indexnonalnumdisappear
5344    \xdef\indexsortkey{}%
5345    \let\sortas=\indexwritesortas
5346    \edef\temp{\the\toks0}%
5347    \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas
5348    \ifx\indexsortkey\empty
5349      \xdef\indexsortkey{\temp}%
5350      \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
5351    \fi
5352   }%
5353   %
5354   % Set up the complete index entry, with both the sort key and
5355   % the original text, including any font commands.  We write
5356   % three arguments to \entry to the .?? file (four in the
5357   % subentry case), texindex reduces to two when writing the .??s
5358   % sorted result.
5359   \edef\temp{%
5360     \write\writeto{%
5361       \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}%
5362   }%
5363   \temp
5364 }
5365 \newbox\dummybox % used above
5366
5367 % Take care of unwanted page breaks/skips around a whatsit:
5368 %
5369 % If a skip is the last thing on the list now, preserve it
5370 % by backing up by \lastskip, doing the \write, then inserting
5371 % the skip again.  Otherwise, the whatsit generated by the
5372 % \write or \pdfdest will make \lastskip zero.  The result is that
5373 % sequences like this:
5374 % @end defun
5375 % @tindex whatever
5376 % @defun ...
5377 % will have extra space inserted, because the \medbreak in the
5378 % start of the @defun won't see the skip inserted by the @end of
5379 % the previous defun.
5380 %
5381 % But don't do any of this if we're not in vertical mode.  We
5382 % don't want to do a \vskip and prematurely end a paragraph.
5383 %
5384 % Avoid page breaks due to these extra skips, too.
5385 %
5386 % But wait, there is a catch there:
5387 % We'll have to check whether \lastskip is zero skip.  \ifdim is not
5388 % sufficient for this purpose, as it ignores stretch and shrink parts
5389 % of the skip.  The only way seems to be to check the textual
5390 % representation of the skip.
5391 %
5392 % The following is almost like \def\zeroskipmacro{0.0pt} except that
5393 % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
5394 %
5395 \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
5396 %
5397 \newskip\whatsitskip
5398 \newcount\whatsitpenalty
5399 %
5400 % ..., ready, GO:
5401 %
5402 \def\safewhatsit#1{\ifhmode
5403   #1%
5404  \else
5405   % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
5406   \whatsitskip = \lastskip
5407   \edef\lastskipmacro{\the\lastskip}%
5408   \whatsitpenalty = \lastpenalty
5409   %
5410   % If \lastskip is nonzero, that means the last item was a
5411   % skip.  And since a skip is discardable, that means this
5412   % -\whatsitskip glue we're inserting is preceded by a
5413   % non-discardable item, therefore it is not a potential
5414   % breakpoint, therefore no \nobreak needed.
5415   \ifx\lastskipmacro\zeroskipmacro
5416   \else
5417     \vskip-\whatsitskip
5418   \fi
5419   %
5420   #1%
5421   %
5422   \ifx\lastskipmacro\zeroskipmacro
5423     % If \lastskip was zero, perhaps the last item was a penalty, and
5424     % perhaps it was >=10000, e.g., a \nobreak.  In that case, we want
5425     % to re-insert the same penalty (values >10000 are used for various
5426     % signals); since we just inserted a non-discardable item, any
5427     % following glue (such as a \parskip) would be a breakpoint.  For example:
5428     %   @deffn deffn-whatever
5429     %   @vindex index-whatever
5430     %   Description.
5431     % would allow a break between the index-whatever whatsit
5432     % and the "Description." paragraph.
5433     \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
5434   \else
5435     % On the other hand, if we had a nonzero \lastskip,
5436     % this make-up glue would be preceded by a non-discardable item
5437     % (the whatsit from the \write), so we must insert a \nobreak.
5438     \nobreak\vskip\whatsitskip
5439   \fi
5440 \fi}
5441
5442 % The index entry written in the file actually looks like
5443 %  \entry {sortstring}{page}{topic}
5444 % or
5445 %  \entry {sortstring}{page}{topic}{subtopic}
5446 % The texindex program reads in these files and writes files
5447 % containing these kinds of lines:
5448 %  \initial {c}
5449 %     before the first topic whose initial is c
5450 %  \entry {topic}{pagelist}
5451 %     for a topic that is used without subtopics
5452 %  \primary {topic}
5453 %     for the beginning of a topic that is used with subtopics
5454 %  \secondary {subtopic}{pagelist}
5455 %     for each subtopic.
5456
5457 % Define the user-accessible indexing commands
5458 % @findex, @vindex, @kindex, @cindex.
5459
5460 \def\findex {\fnindex}
5461 \def\kindex {\kyindex}
5462 \def\cindex {\cpindex}
5463 \def\vindex {\vrindex}
5464 \def\tindex {\tpindex}
5465 \def\pindex {\pgindex}
5466
5467 \def\cindexsub {\begingroup\obeylines\cindexsub}
5468 {\obeylines %
5469 \gdef\cindexsub "#1" #2^^M{\endgroup %
5470 \dosubind{cp}{#2}{#1}}}
5471
5472 % Define the macros used in formatting output of the sorted index material.
5473
5474 % @printindex causes a particular index (the ??s file) to get printed.
5475 % It does not print any chapter heading (usually an @unnumbered).
5476 %
5477 \parseargdef\printindex{\begingroup
5478   \dobreak \chapheadingskip{10000}%
5479   %
5480   \smallfonts \rm
5481   \tolerance = 9500
5482   \plainfrenchspacing
5483   \everypar = {}% don't want the \kern\-parindent from indentation suppression.
5484   %
5485   % See if the index file exists and is nonempty.
5486   % Change catcode of @ here so that if the index file contains
5487   % \initial {@}
5488   % as its first line, TeX doesn't complain about mismatched braces
5489   % (because it thinks @} is a control sequence).
5490   \catcode`\@ = 12
5491   % See comment in \requireopenindexfile.
5492   \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
5493   \openin 1 \jobname.\indexname s
5494   \ifeof 1
5495     % \enddoublecolumns gets confused if there is no text in the index,
5496     % and it loses the chapter title and the aux file entries for the
5497     % index.  The easiest way to prevent this problem is to make sure
5498     % there is some text.
5499     \putwordIndexNonexistent
5500     \typeout{No file \jobname.\indexname s.}%
5501   \else
5502     \catcode`\\ = 0
5503     %
5504     % If the index file exists but is empty, then \openin leaves \ifeof
5505     % false.  We have to make TeX try to read something from the file, so
5506     % it can discover if there is anything in it.
5507     \read 1 to \thisline
5508     \ifeof 1
5509       \putwordIndexIsEmpty
5510     \else
5511       % Index files are almost Texinfo source, but we use \ as the escape
5512       % character.  It would be better to use @, but that's too big a change
5513       % to make right now.
5514       \def\indexbackslash{\ttbackslash}%
5515       \let\indexlbrace\{   % Likewise, set these sequences for braces
5516       \let\indexrbrace\}   % used in the sort key.
5517       \begindoublecolumns
5518       \let\entrywidowpenalty=\indexwidowpenalty
5519       %
5520       % Read input from the index file line by line.
5521       \loopdo
5522         \ifeof1
5523           \let\firsttoken\relax
5524         \else
5525           \read 1 to \nextline
5526           \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}%
5527           \act
5528         \fi
5529         \thisline
5530         %
5531         \ifeof1\else
5532         \let\thisline\nextline
5533       \repeat
5534       %%
5535       \enddoublecolumns
5536     \fi
5537   \fi
5538   \closein 1
5539 \endgroup}
5540
5541 \def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken}
5542 \long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1}
5543
5544 \def\loopdo#1\repeat{\def\body{#1}\loopdoxxx}
5545 \def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next}
5546
5547 % These macros are used by the sorted index file itself.
5548 % Change them to control the appearance of the index.
5549
5550 {\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
5551 \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
5552 \catcode`\$=3
5553 \gdef\initialglyphs{%
5554   % Some changes for non-alphabetic characters.  Using the glyphs from the
5555   % math fonts looks more consistent than the typewriter font used elsewhere
5556   % for these characters.
5557   \def\indexbackslash{\math{\backslash}}%
5558   \let\\=\indexbackslash
5559   %
5560   % Can't get bold backslash so don't use bold forward slash
5561   \catcode`\/=13
5562   \def/{{\secrmnotbold \normalslash}}%
5563   \def-{{\normaldash\normaldash}}% en dash `--'
5564   \def^{{\chapbf \normalcaret}}%
5565   \def~{{\chapbf \normaltilde}}%
5566   \def\_{%
5567      \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
5568   \def|{$\vert$}%
5569   \def<{$\less$}%
5570   \def>{$\gtr$}%
5571   \def+{$\normalplus$}%
5572 }}
5573
5574 \def\initial{%
5575   \bgroup
5576   \initialglyphs
5577   \initialx
5578 }
5579
5580 \def\initialx#1{%
5581   % Remove any glue we may have, we'll be inserting our own.
5582   \removelastskip
5583   %
5584   % We like breaks before the index initials, so insert a bonus.
5585   % The glue before the bonus allows a little bit of space at the
5586   % bottom of a column to reduce an increase in inter-line spacing.
5587   \nobreak
5588   \vskip 0pt plus 5\baselineskip
5589   \penalty -300 
5590   \vskip 0pt plus -5\baselineskip
5591   %
5592   % Typeset the initial.  Making this add up to a whole number of
5593   % baselineskips increases the chance of the dots lining up from column
5594   % to column.  It still won't often be perfect, because of the stretch
5595   % we need before each entry, but it's better.
5596   %
5597   % No shrink because it confuses \balancecolumns.
5598   \vskip 1.67\baselineskip plus 1\baselineskip
5599   \leftline{\secfonts \kern-0.05em \secbf #1}%
5600   % \secfonts is inside the argument of \leftline so that the change of
5601   % \baselineskip will not affect any glue inserted before the vbox that
5602   % \leftline creates.
5603   % Do our best not to break after the initial.
5604   \nobreak
5605   \vskip .33\baselineskip plus .1\baselineskip
5606   \egroup % \initialglyphs
5607 }
5608
5609 \newdimen\entryrightmargin
5610 \entryrightmargin=0pt
5611
5612 % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
5613 % then page number (#2) flushed to the right margin.  It is used for index
5614 % and table of contents entries.  The paragraph is indented by \leftskip.
5615 %
5616 \def\entry{%
5617   \begingroup
5618     %
5619     % For pdfTeX and XeTeX.
5620     % The redefinition of \domark stops marks being added in \pdflink to 
5621     % preserve coloured links across page boundaries.  Otherwise the marks
5622     % would get in the way of \lastbox in \insertindexentrybox.
5623     \let\domark\relax
5624     %
5625     % Start a new paragraph if necessary, so our assignments below can't
5626     % affect previous text.
5627     \par
5628     %
5629     % No extra space above this paragraph.
5630     \parskip = 0in
5631     %
5632     % When reading the text of entry, convert explicit line breaks
5633     % from @* into spaces.  The user might give these in long section
5634     % titles, for instance.
5635     \def\*{\unskip\space\ignorespaces}%
5636     \def\entrybreak{\hfil\break}% An undocumented command
5637     %
5638     % Swallow the left brace of the text (first parameter):
5639     \afterassignment\doentry
5640     \let\temp =
5641 }
5642 \def\entrybreak{\unskip\space\ignorespaces}%
5643 \def\doentry{%
5644     % Save the text of the entry
5645     \global\setbox\boxA=\hbox\bgroup
5646     \bgroup % Instead of the swallowed brace.
5647       \noindent
5648       \aftergroup\finishentry
5649       % And now comes the text of the entry.
5650       % Not absorbing as a macro argument reduces the chance of problems
5651       % with catcodes occurring.
5652 }
5653 {\catcode`\@=11
5654 \gdef\finishentry#1{%
5655     \egroup % end box A
5656     \dimen@ = \wd\boxA % Length of text of entry
5657     \global\setbox\boxA=\hbox\bgroup\unhbox\boxA
5658     % #1 is the page number.
5659     %
5660     % Get the width of the page numbers, and only use
5661     % leaders if they are present.
5662     \global\setbox\boxB = \hbox{#1}%
5663     \ifdim\wd\boxB = 0pt
5664       \null\nobreak\hfill\ %
5665     \else
5666       %
5667       \null\nobreak\indexdotfill % Have leaders before the page number.
5668       %
5669       \ifpdf
5670         \pdfgettoks#1.%
5671         \hskip\skip\thinshrinkable\the\toksA
5672       \else
5673         \ifx\XeTeXrevision\thisisundefined
5674           \hskip\skip\thinshrinkable #1%
5675         \else
5676           \pdfgettoks#1.%
5677           \hskip\skip\thinshrinkable\the\toksA
5678         \fi
5679       \fi
5680     \fi
5681     \egroup % end \boxA
5682     \ifdim\wd\boxB = 0pt
5683       \global\setbox\entryindexbox=\vbox{\unhbox\boxA}%
5684     \else
5685     \global\setbox\entryindexbox=\vbox\bgroup
5686       % We want the text of the entries to be aligned to the left, and the
5687       % page numbers to be aligned to the right.
5688       %
5689       \parindent = 0pt
5690       \advance\leftskip by 0pt plus 1fil
5691       \advance\leftskip by 0pt plus -1fill
5692       \rightskip = 0pt plus -1fil
5693       \advance\rightskip by 0pt plus 1fill
5694       % Cause last line, which could consist of page numbers on their own
5695       % if the list of page numbers is long, to be aligned to the right.
5696       \parfillskip=0pt plus -1fill
5697       %
5698       \advance\rightskip by \entryrightmargin
5699       % Determine how far we can stretch into the margin.
5700       % This allows, e.g., "Appendix H  GNU Free Documentation License" to
5701       % fit on one line in @letterpaper format.
5702       \ifdim\entryrightmargin>2.1em
5703         \dimen@i=2.1em
5704       \else
5705         \dimen@i=0em
5706       \fi
5707       \advance \parfillskip by 0pt minus 1\dimen@i
5708       %
5709       \dimen@ii = \hsize
5710       \advance\dimen@ii by -1\leftskip
5711       \advance\dimen@ii by -1\entryrightmargin
5712       \advance\dimen@ii by 1\dimen@i
5713       \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
5714       \ifdim\dimen@ > 0.8\dimen@ii   % due to long index text
5715         \dimen@ = 0.7\dimen@ % Try to split the text roughly evenly
5716         \dimen@ii = \hsize
5717         \ifnum\dimen@>\dimen@ii
5718           % If the entry is too long, use the whole line
5719           \dimen@ = \dimen@ii
5720         \fi
5721         \advance\leftskip by 0pt plus 1fill % ragged right
5722         \advance \dimen@ by 1\rightskip
5723         \parshape = 2 0pt \dimen@ 0em \dimen@ii
5724         % Ideally we'd add a finite glue at the end of the first line only,
5725         % instead of using \parshape with explicit line lengths, but TeX
5726         % doesn't seem to provide a way to do such a thing.
5727         %
5728         \leftskip = 1em
5729         \parindent = -1em
5730       \fi\fi
5731       \indent % start paragraph
5732       \unhbox\boxA
5733       %
5734       % Do not prefer a separate line ending with a hyphen to fewer lines.
5735       \finalhyphendemerits = 0
5736       %
5737       % Word spacing - no stretch
5738       \spaceskip=\fontdimen2\font minus \fontdimen4\font
5739       %
5740       \linepenalty=1000  % Discourage line breaks.
5741       \hyphenpenalty=5000  % Discourage hyphenation.
5742       %
5743       \par % format the paragraph
5744     \egroup % The \vbox
5745     \fi
5746   \endgroup
5747   % delay text of entry until after penalty
5748   \bgroup\aftergroup\insertindexentrybox
5749   \entrywidowpenalty
5750 }}
5751
5752 \newskip\thinshrinkable
5753 \skip\thinshrinkable=.15em minus .15em
5754
5755 \newbox\entryindexbox
5756 \def\insertindexentrybox{%
5757   \ourunvbox\entryindexbox
5758 }
5759
5760 % Use \lastbox to take apart vbox box by box, and add each sub-box
5761 % to the current vertical list.
5762 \def\ourunvbox#1{%
5763 \bgroup % for local binding of \delayedbox
5764   % Remove the last box from box #1
5765   \global\setbox#1=\vbox{%
5766     \unvbox#1%
5767     \unskip % remove any glue
5768     \unpenalty
5769     \global\setbox\interbox=\lastbox
5770   }%
5771   \setbox\delayedbox=\box\interbox
5772   \ifdim\ht#1=0pt\else
5773     \ourunvbox#1 % Repeat on what's left of the box
5774     \nobreak
5775   \fi
5776   \box\delayedbox
5777 \egroup
5778 }
5779 \newbox\delayedbox
5780 \newbox\interbox
5781
5782 % Default is no penalty
5783 \let\entrywidowpenalty\egroup
5784
5785 % Used from \printindex.  \firsttoken should be the first token
5786 % after the \entry.  If it's not another \entry, we are at the last
5787 % line of a group of index entries, so insert a penalty to discourage
5788 % widowed index entries.
5789 \long\def\indexwidowpenalty{%
5790   \def\isentry{\entry}%
5791   \ifx\firsttoken\isentry
5792   \else
5793     \penalty 9000
5794   \fi
5795   \egroup % now comes the box added with \aftergroup
5796 }
5797
5798 % Like plain.tex's \dotfill, except uses up at least 1 em.
5799 % The filll stretch here overpowers both the fil and fill stretch to push
5800 % the page number to the right.
5801 \def\indexdotfill{\cleaders
5802   \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
5803
5804
5805 \def\primary #1{\line{#1\hfil}}
5806
5807 \newskip\secondaryindent \secondaryindent=0.5cm
5808 \def\secondary#1#2{{%
5809   \parfillskip=0in
5810   \parskip=0in
5811   \hangindent=1in
5812   \hangafter=1
5813   \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
5814   \ifpdf
5815     \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5816   \else
5817     \ifx\XeTeXrevision\thisisundefined
5818       #2
5819     \else
5820       \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5821     \fi
5822   \fi
5823   \par
5824 }}
5825
5826 % Define two-column mode, which we use to typeset indexes.
5827 % Adapted from the TeXbook, page 416, which is to say,
5828 % the manmac.tex format used to print the TeXbook itself.
5829 \catcode`\@=11  % private names
5830
5831 \newbox\partialpage
5832 \newdimen\doublecolumnhsize
5833
5834 % Use inside an output routine to save \topmark and \firstmark
5835 \def\savemarks{%
5836   \global\savedtopmark=\expandafter{\topmark }%
5837   \global\savedfirstmark=\expandafter{\firstmark }%
5838 }
5839 \newtoks\savedtopmark
5840 \newtoks\savedfirstmark
5841
5842 % Set \topmark and \firstmark for next time \output runs.
5843 % Can't be run from withinside \output (because any material
5844 % added while an output routine is active, including 
5845 % penalties, is saved for after it finishes).  The page so far
5846 % should be empty, otherwise what's on it will be thrown away.
5847 \def\restoremarks{%
5848   \mark{\the\savedtopmark}%
5849   \bgroup\output = {%
5850     \setbox\dummybox=\box\PAGE
5851   }abc\eject\egroup
5852   % "abc" because output routine doesn't fire for a completely empty page.
5853   \mark{\the\savedfirstmark}%
5854 }
5855
5856 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
5857   % If not much space left on page, start a new page.
5858   \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
5859   %
5860   % Grab any single-column material above us.
5861   \output = {%
5862     %
5863     % Here is a possibility not foreseen in manmac: if we accumulate a
5864     % whole lot of material, we might end up calling this \output
5865     % routine twice in a row (see the doublecol-lose test, which is
5866     % essentially a couple of indexes with @setchapternewpage off).  In
5867     % that case we just ship out what is in \partialpage with the normal
5868     % output routine.  Generally, \partialpage will be empty when this
5869     % runs and this will be a no-op.  See the indexspread.tex test case.
5870     \ifvoid\partialpage \else
5871       \onepageout{\pagecontents\partialpage}%
5872     \fi
5873     %
5874     \global\setbox\partialpage = \vbox{%
5875       % Unvbox the main output page.
5876       \unvbox\PAGE
5877       \kern-\topskip \kern\baselineskip
5878     }%
5879     \savemarks
5880   }%
5881   \eject % run that output routine to set \partialpage
5882   \restoremarks
5883   %
5884   % We recover the two marks that the last output routine saved in order
5885   % to propagate the information in marks added around a chapter heading,
5886   % which could be otherwise be lost by the time the final page is output.
5887   %
5888   %
5889   % Use the double-column output routine for subsequent pages.
5890   \output = {\doublecolumnout}%
5891   %
5892   % Change the page size parameters.  We could do this once outside this
5893   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5894   % format, but then we repeat the same computation.  Repeating a couple
5895   % of assignments once per index is clearly meaningless for the
5896   % execution time, so we may as well do it in one place.
5897   %
5898   % First we halve the line length, less a little for the gutter between
5899   % the columns.  We compute the gutter based on the line length, so it
5900   % changes automatically with the paper format.  The magic constant
5901   % below is chosen so that the gutter has the same value (well, +-<1pt)
5902   % as it did when we hard-coded it.
5903   %
5904   % We put the result in a separate register, \doublecolumhsize, so we
5905   % can restore it in \pagesofar, after \hsize itself has (potentially)
5906   % been clobbered.
5907   %
5908   \doublecolumnhsize = \hsize
5909     \advance\doublecolumnhsize by -.04154\hsize
5910     \divide\doublecolumnhsize by 2
5911   \hsize = \doublecolumnhsize
5912   %
5913   % Double the \vsize as well.  (We don't need a separate register here,
5914   % since nobody clobbers \vsize.)
5915   \vsize = 2\vsize
5916   %
5917   % For the benefit of balancing columns
5918   \advance\baselineskip by 0pt plus 0.5pt
5919 }
5920
5921 % The double-column output routine for all double-column pages except
5922 % the last, which is done by \balancecolumns.
5923 %
5924 \def\doublecolumnout{%
5925   %
5926   \splittopskip=\topskip \splitmaxdepth=\maxdepth
5927   % Get the available space for the double columns -- the normal
5928   % (undoubled) page height minus any material left over from the
5929   % previous page.
5930   \dimen@ = \vsize
5931   \divide\dimen@ by 2
5932   \advance\dimen@ by -\ht\partialpage
5933   %
5934   % box0 will be the left-hand column, box2 the right.
5935   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
5936   \onepageout\pagesofar
5937   \unvbox255
5938   \penalty\outputpenalty
5939 }
5940 %
5941 % Re-output the contents of the output page -- any previous material,
5942 % followed by the two boxes we just split, in box0 and box2.
5943 \def\pagesofar{%
5944   \unvbox\partialpage
5945   %
5946   \hsize = \doublecolumnhsize
5947   \wd0=\hsize \wd2=\hsize
5948   \hbox to\txipagewidth{\box0\hfil\box2}%
5949 }
5950
5951
5952 % Finished with with double columns.
5953 \def\enddoublecolumns{%
5954   % The following penalty ensures that the page builder is exercised
5955   % _before_ we change the output routine.  This is necessary in the
5956   % following situation:
5957   %
5958   % The last section of the index consists only of a single entry.
5959   % Before this section, \pagetotal is less than \pagegoal, so no
5960   % break occurs before the last section starts.  However, the last
5961   % section, consisting of \initial and the single \entry, does not
5962   % fit on the page and has to be broken off.  Without the following
5963   % penalty the page builder will not be exercised until \eject
5964   % below, and by that time we'll already have changed the output
5965   % routine to the \balancecolumns version, so the next-to-last
5966   % double-column page will be processed with \balancecolumns, which
5967   % is wrong:  The two columns will go to the main vertical list, with
5968   % the broken-off section in the recent contributions.  As soon as
5969   % the output routine finishes, TeX starts reconsidering the page
5970   % break.  The two columns and the broken-off section both fit on the
5971   % page, because the two columns now take up only half of the page
5972   % goal.  When TeX sees \eject from below which follows the final
5973   % section, it invokes the new output routine that we've set after
5974   % \balancecolumns below; \onepageout will try to fit the two columns
5975   % and the final section into the vbox of \txipageheight (see
5976   % \pagebody), causing an overfull box.
5977   %
5978   % Note that glue won't work here, because glue does not exercise the
5979   % page builder, unlike penalties (see The TeXbook, pp. 280-281).
5980   \penalty0
5981   %
5982   \output = {%
5983     % Split the last of the double-column material.
5984     \savemarks
5985     \balancecolumns
5986     %
5987     % Having called \balancecolumns once, we do not
5988     % want to call it again.  Therefore, reset \output to its normal
5989     % definition right away.
5990     \global\output = {\onepageout{\pagecontents\PAGE}}%
5991   }%
5992   \eject
5993   \endgroup % started in \begindoublecolumns
5994   \restoremarks
5995   % Leave the double-column material on the current page, no automatic
5996   % page break.
5997   \box\balancedcolumns
5998   %
5999   % \pagegoal was set to the doubled \vsize above, since we restarted
6000   % the current page.  We're now back to normal single-column
6001   % typesetting, so reset \pagegoal to the normal \vsize (after the
6002   % \endgroup where \vsize got restored).
6003   \pagegoal = \vsize
6004 }
6005 \newbox\balancedcolumns
6006 \setbox\balancedcolumns=\vbox{shouldnt see this}%
6007 %
6008 % Only called for the last of the double column material.  \doublecolumnout 
6009 % does the others.
6010 \def\balancecolumns{%
6011   \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
6012   \dimen@ = \ht0
6013   \advance\dimen@ by \topskip
6014   \advance\dimen@ by-\baselineskip
6015   \ifdim\dimen@<5\baselineskip
6016     % Don't split a short final column in two.
6017     \setbox2=\vbox{}%
6018   \else
6019     \divide\dimen@ by 2 % target to split to
6020     \dimen@ii = \dimen@
6021     \splittopskip = \topskip
6022     % Loop until left column is at least as high as the right column.
6023     {%
6024       \vbadness = 10000
6025       \loop
6026         \global\setbox3 = \copy0
6027         \global\setbox1 = \vsplit3 to \dimen@
6028       \ifdim\ht1<\ht3
6029         \global\advance\dimen@ by 1pt
6030       \repeat
6031     }%
6032     % Now the left column is in box 1, and the right column in box 3.
6033     % Check whether the left column has come out higher than the page itself.  
6034     % (Note that we have doubled \vsize for the double columns, so
6035     % the actual height of the page is 0.5\vsize).
6036     \ifdim2\ht1>\vsize
6037       % Just split the last of the double column material roughly in half.
6038       \setbox2=\box0
6039       \setbox0 = \vsplit2 to \dimen@ii
6040       \setbox0=\vbox to \dimen@ii {\unvbox0\vfill}%
6041       \setbox2=\vbox to \dimen@ii {\unvbox2\vfill}%
6042     \else
6043       % Compare the heights of the two columns.
6044       \ifdim4\ht1>5\ht3
6045         % Column heights are too different, so don't make their bottoms
6046         % flush with each other.
6047         \setbox2=\vbox to \ht1 {\unvbox3\vfill}%
6048         \setbox0=\vbox to \ht1 {\unvbox1\vfill}%
6049       \else
6050         % Make column bottoms flush with each other.
6051         \setbox2=\vbox to\ht1{\unvbox3\unskip}%
6052         \setbox0=\vbox to\ht1{\unvbox1\unskip}%
6053       \fi
6054     \fi
6055   \fi
6056   %
6057   \global\setbox\balancedcolumns=\vbox{\pagesofar}%
6058 }
6059 \catcode`\@ = \other
6060
6061
6062 \message{sectioning,}
6063 % Chapters, sections, etc.
6064
6065 % Let's start with @part.
6066 \outer\parseargdef\part{\partzzz{#1}}
6067 \def\partzzz#1{%
6068   \chapoddpage
6069   \null
6070   \vskip.3\vsize  % move it down on the page a bit
6071   \begingroup
6072     \noindent \titlefonts\rmisbold #1\par % the text
6073     \let\lastnode=\empty      % no node to associate with
6074     \writetocentry{part}{#1}{}% but put it in the toc
6075     \headingsoff              % no headline or footline on the part page
6076     % This outputs a mark at the end of the page that clears \thischapter
6077     % and \thissection, as is done in \startcontents.
6078     \let\pchapsepmacro\relax
6079     \chapmacro{}{Yomitfromtoc}{}%
6080     \chapoddpage
6081   \endgroup
6082 }
6083
6084 % \unnumberedno is an oxymoron.  But we count the unnumbered
6085 % sections so that we can refer to them unambiguously in the pdf
6086 % outlines by their "section number".  We avoid collisions with chapter
6087 % numbers by starting them at 10000.  (If a document ever has 10000
6088 % chapters, we're in trouble anyway, I'm sure.)
6089 \newcount\unnumberedno \unnumberedno = 10000
6090 \newcount\chapno
6091 \newcount\secno        \secno=0
6092 \newcount\subsecno     \subsecno=0
6093 \newcount\subsubsecno  \subsubsecno=0
6094
6095 % This counter is funny since it counts through charcodes of letters A, B, ...
6096 \newcount\appendixno  \appendixno = `\@
6097 %
6098 % \def\appendixletter{\char\the\appendixno}
6099 % We do the following ugly conditional instead of the above simple
6100 % construct for the sake of pdftex, which needs the actual
6101 % letter in the expansion, not just typeset.
6102 %
6103 \def\appendixletter{%
6104   \ifnum\appendixno=`A A%
6105   \else\ifnum\appendixno=`B B%
6106   \else\ifnum\appendixno=`C C%
6107   \else\ifnum\appendixno=`D D%
6108   \else\ifnum\appendixno=`E E%
6109   \else\ifnum\appendixno=`F F%
6110   \else\ifnum\appendixno=`G G%
6111   \else\ifnum\appendixno=`H H%
6112   \else\ifnum\appendixno=`I I%
6113   \else\ifnum\appendixno=`J J%
6114   \else\ifnum\appendixno=`K K%
6115   \else\ifnum\appendixno=`L L%
6116   \else\ifnum\appendixno=`M M%
6117   \else\ifnum\appendixno=`N N%
6118   \else\ifnum\appendixno=`O O%
6119   \else\ifnum\appendixno=`P P%
6120   \else\ifnum\appendixno=`Q Q%
6121   \else\ifnum\appendixno=`R R%
6122   \else\ifnum\appendixno=`S S%
6123   \else\ifnum\appendixno=`T T%
6124   \else\ifnum\appendixno=`U U%
6125   \else\ifnum\appendixno=`V V%
6126   \else\ifnum\appendixno=`W W%
6127   \else\ifnum\appendixno=`X X%
6128   \else\ifnum\appendixno=`Y Y%
6129   \else\ifnum\appendixno=`Z Z%
6130   % The \the is necessary, despite appearances, because \appendixletter is
6131   % expanded while writing the .toc file.  \char\appendixno is not
6132   % expandable, thus it is written literally, thus all appendixes come out
6133   % with the same letter (or @) in the toc without it.
6134   \else\char\the\appendixno
6135   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
6136   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
6137
6138 % Each @chapter defines these (using marks) as the number+name, number
6139 % and name of the chapter.  Page headings and footings can use
6140 % these.  @section does likewise.
6141 \def\thischapter{}
6142 \def\thischapternum{}
6143 \def\thischaptername{}
6144 \def\thissection{}
6145 \def\thissectionnum{}
6146 \def\thissectionname{}
6147
6148 \newcount\absseclevel % used to calculate proper heading level
6149 \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
6150
6151 % @raisesections: treat @section as chapter, @subsection as section, etc.
6152 \def\raisesections{\global\advance\secbase by -1}
6153 \let\up=\raisesections % original BFox name
6154
6155 % @lowersections: treat @chapter as section, @section as subsection, etc.
6156 \def\lowersections{\global\advance\secbase by 1}
6157 \let\down=\lowersections % original BFox name
6158
6159 % we only have subsub.
6160 \chardef\maxseclevel = 3
6161 %
6162 % A numbered section within an unnumbered changes to unnumbered too.
6163 % To achieve this, remember the "biggest" unnum. sec. we are currently in:
6164 \chardef\unnlevel = \maxseclevel
6165 %
6166 % Trace whether the current chapter is an appendix or not:
6167 % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
6168 \def\chapheadtype{N}
6169
6170 % Choose a heading macro
6171 % #1 is heading type
6172 % #2 is heading level
6173 % #3 is text for heading
6174 \def\genhead#1#2#3{%
6175   % Compute the abs. sec. level:
6176   \absseclevel=#2
6177   \advance\absseclevel by \secbase
6178   % Make sure \absseclevel doesn't fall outside the range:
6179   \ifnum \absseclevel < 0
6180     \absseclevel = 0
6181   \else
6182     \ifnum \absseclevel > 3
6183       \absseclevel = 3
6184     \fi
6185   \fi
6186   % The heading type:
6187   \def\headtype{#1}%
6188   \if \headtype U%
6189     \ifnum \absseclevel < \unnlevel
6190       \chardef\unnlevel = \absseclevel
6191     \fi
6192   \else
6193     % Check for appendix sections:
6194     \ifnum \absseclevel = 0
6195       \edef\chapheadtype{\headtype}%
6196     \else
6197       \if \headtype A\if \chapheadtype N%
6198         \errmessage{@appendix... within a non-appendix chapter}%
6199       \fi\fi
6200     \fi
6201     % Check for numbered within unnumbered:
6202     \ifnum \absseclevel > \unnlevel
6203       \def\headtype{U}%
6204     \else
6205       \chardef\unnlevel = 3
6206     \fi
6207   \fi
6208   % Now print the heading:
6209   \if \headtype U%
6210     \ifcase\absseclevel
6211         \unnumberedzzz{#3}%
6212     \or \unnumberedseczzz{#3}%
6213     \or \unnumberedsubseczzz{#3}%
6214     \or \unnumberedsubsubseczzz{#3}%
6215     \fi
6216   \else
6217     \if \headtype A%
6218       \ifcase\absseclevel
6219           \appendixzzz{#3}%
6220       \or \appendixsectionzzz{#3}%
6221       \or \appendixsubseczzz{#3}%
6222       \or \appendixsubsubseczzz{#3}%
6223       \fi
6224     \else
6225       \ifcase\absseclevel
6226           \chapterzzz{#3}%
6227       \or \seczzz{#3}%
6228       \or \numberedsubseczzz{#3}%
6229       \or \numberedsubsubseczzz{#3}%
6230       \fi
6231     \fi
6232   \fi
6233   \suppressfirstparagraphindent
6234 }
6235
6236 % an interface:
6237 \def\numhead{\genhead N}
6238 \def\apphead{\genhead A}
6239 \def\unnmhead{\genhead U}
6240
6241 % @chapter, @appendix, @unnumbered.  Increment top-level counter, reset
6242 % all lower-level sectioning counters to zero.
6243 %
6244 % Also set \chaplevelprefix, which we prepend to @float sequence numbers
6245 % (e.g., figures), q.v.  By default (before any chapter), that is empty.
6246 \let\chaplevelprefix = \empty
6247 %
6248 \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
6249 \def\chapterzzz#1{%
6250   % section resetting is \global in case the chapter is in a group, such
6251   % as an @include file.
6252   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6253     \global\advance\chapno by 1
6254   %
6255   % Used for \float.
6256   \gdef\chaplevelprefix{\the\chapno.}%
6257   \resetallfloatnos
6258   %
6259   % \putwordChapter can contain complex things in translations.
6260   \toks0=\expandafter{\putwordChapter}%
6261   \message{\the\toks0 \space \the\chapno}%
6262   %
6263   % Write the actual heading.
6264   \chapmacro{#1}{Ynumbered}{\the\chapno}%
6265   %
6266   % So @section and the like are numbered underneath this chapter.
6267   \global\let\section = \numberedsec
6268   \global\let\subsection = \numberedsubsec
6269   \global\let\subsubsection = \numberedsubsubsec
6270 }
6271
6272 \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
6273 %
6274 \def\appendixzzz#1{%
6275   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6276     \global\advance\appendixno by 1
6277   \gdef\chaplevelprefix{\appendixletter.}%
6278   \resetallfloatnos
6279   %
6280   % \putwordAppendix can contain complex things in translations.
6281   \toks0=\expandafter{\putwordAppendix}%
6282   \message{\the\toks0 \space \appendixletter}%
6283   %
6284   \chapmacro{#1}{Yappendix}{\appendixletter}%
6285   %
6286   \global\let\section = \appendixsec
6287   \global\let\subsection = \appendixsubsec
6288   \global\let\subsubsection = \appendixsubsubsec
6289 }
6290
6291 % normally unnmhead0 calls unnumberedzzz:
6292 \outer\parseargdef\unnumbered{\unnmhead0{#1}}
6293 \def\unnumberedzzz#1{%
6294   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6295     \global\advance\unnumberedno by 1
6296   %
6297   % Since an unnumbered has no number, no prefix for figures.
6298   \global\let\chaplevelprefix = \empty
6299   \resetallfloatnos
6300   %
6301   % This used to be simply \message{#1}, but TeX fully expands the
6302   % argument to \message.  Therefore, if #1 contained @-commands, TeX
6303   % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
6304   % expanded @cite (which turns out to cause errors because \cite is meant
6305   % to be executed, not expanded).
6306   %
6307   % Anyway, we don't want the fully-expanded definition of @cite to appear
6308   % as a result of the \message, we just want `@cite' itself.  We use
6309   % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6310   % simply yielding the contents of <toks register>.  (We also do this for
6311   % the toc entries.)
6312   \toks0 = {#1}%
6313   \message{(\the\toks0)}%
6314   %
6315   \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
6316   %
6317   \global\let\section = \unnumberedsec
6318   \global\let\subsection = \unnumberedsubsec
6319   \global\let\subsubsection = \unnumberedsubsubsec
6320 }
6321
6322 % @centerchap is like @unnumbered, but the heading is centered.
6323 \outer\parseargdef\centerchap{%
6324   \let\centerparametersmaybe = \centerparameters
6325   \unnmhead0{#1}%
6326   \let\centerparametersmaybe = \relax
6327 }
6328
6329 % @top is like @unnumbered.
6330 \let\top\unnumbered
6331
6332 % Sections.
6333
6334 \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6335 \def\seczzz#1{%
6336   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6337   \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
6338 }
6339
6340 % normally calls appendixsectionzzz:
6341 \outer\parseargdef\appendixsection{\apphead1{#1}}
6342 \def\appendixsectionzzz#1{%
6343   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6344   \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
6345 }
6346 \let\appendixsec\appendixsection
6347
6348 % normally calls unnumberedseczzz:
6349 \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
6350 \def\unnumberedseczzz#1{%
6351   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6352   \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
6353 }
6354
6355 % Subsections.
6356
6357 % normally calls numberedsubseczzz:
6358 \outer\parseargdef\numberedsubsec{\numhead2{#1}}
6359 \def\numberedsubseczzz#1{%
6360   \global\subsubsecno=0  \global\advance\subsecno by 1
6361   \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
6362 }
6363
6364 % normally calls appendixsubseczzz:
6365 \outer\parseargdef\appendixsubsec{\apphead2{#1}}
6366 \def\appendixsubseczzz#1{%
6367   \global\subsubsecno=0  \global\advance\subsecno by 1
6368   \sectionheading{#1}{subsec}{Yappendix}%
6369                  {\appendixletter.\the\secno.\the\subsecno}%
6370 }
6371
6372 % normally calls unnumberedsubseczzz:
6373 \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
6374 \def\unnumberedsubseczzz#1{%
6375   \global\subsubsecno=0  \global\advance\subsecno by 1
6376   \sectionheading{#1}{subsec}{Ynothing}%
6377                  {\the\unnumberedno.\the\secno.\the\subsecno}%
6378 }
6379
6380 % Subsubsections.
6381
6382 % normally numberedsubsubseczzz:
6383 \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
6384 \def\numberedsubsubseczzz#1{%
6385   \global\advance\subsubsecno by 1
6386   \sectionheading{#1}{subsubsec}{Ynumbered}%
6387                  {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
6388 }
6389
6390 % normally appendixsubsubseczzz:
6391 \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
6392 \def\appendixsubsubseczzz#1{%
6393   \global\advance\subsubsecno by 1
6394   \sectionheading{#1}{subsubsec}{Yappendix}%
6395                  {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
6396 }
6397
6398 % normally unnumberedsubsubseczzz:
6399 \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
6400 \def\unnumberedsubsubseczzz#1{%
6401   \global\advance\subsubsecno by 1
6402   \sectionheading{#1}{subsubsec}{Ynothing}%
6403                  {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
6404 }
6405
6406 % These macros control what the section commands do, according
6407 % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6408 % Define them by default for a numbered chapter.
6409 \let\section = \numberedsec
6410 \let\subsection = \numberedsubsec
6411 \let\subsubsection = \numberedsubsubsec
6412
6413 % Define @majorheading, @heading and @subheading
6414
6415 \def\majorheading{%
6416   {\advance\chapheadingskip by 10pt \chapbreak }%
6417   \parsearg\chapheadingzzz
6418 }
6419
6420 \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6421 \def\chapheadingzzz#1{%
6422   \vbox{\chapfonts \raggedtitlesettings #1\par}%
6423   \nobreak\bigskip \nobreak
6424   \suppressfirstparagraphindent
6425 }
6426
6427 % @heading, @subheading, @subsubheading.
6428 \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6429   \suppressfirstparagraphindent}
6430 \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6431   \suppressfirstparagraphindent}
6432 \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6433   \suppressfirstparagraphindent}
6434
6435 % These macros generate a chapter, section, etc. heading only
6436 % (including whitespace, linebreaking, etc. around it),
6437 % given all the information in convenient, parsed form.
6438
6439 % Args are the skip and penalty (usually negative)
6440 \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6441
6442 % Parameter controlling skip before chapter headings (if needed)
6443 \newskip\chapheadingskip
6444
6445 % Define plain chapter starts, and page on/off switching for it.
6446 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
6447
6448 % Start a new page
6449 \def\chappager{\par\vfill\supereject}
6450
6451 % \chapoddpage - start on an odd page for a new chapter
6452 % Because \domark is called before \chapoddpage, the filler page will
6453 % get the headings for the next chapter, which is wrong.  But we don't
6454 % care -- we just disable all headings on the filler page.
6455 \def\chapoddpage{%
6456   \chappager
6457   \ifodd\pageno \else
6458     \begingroup
6459       \headingsoff
6460       \null
6461       \chappager
6462     \endgroup
6463   \fi
6464 }
6465
6466 \parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
6467
6468 \def\CHAPPAGoff{%
6469 \global\let\contentsalignmacro = \chappager
6470 \global\let\pchapsepmacro=\chapbreak
6471 \global\let\pagealignmacro=\chappager}
6472
6473 \def\CHAPPAGon{%
6474 \global\let\contentsalignmacro = \chappager
6475 \global\let\pchapsepmacro=\chappager
6476 \global\let\pagealignmacro=\chappager
6477 \global\def\HEADINGSon{\HEADINGSsingle}}
6478
6479 \def\CHAPPAGodd{%
6480 \global\let\contentsalignmacro = \chapoddpage
6481 \global\let\pchapsepmacro=\chapoddpage
6482 \global\let\pagealignmacro=\chapoddpage
6483 \global\def\HEADINGSon{\HEADINGSdouble}}
6484
6485 \CHAPPAGon
6486
6487 % \chapmacro - Chapter opening.
6488 %
6489 % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6490 % Yappendix, Yomitfromtoc), #3 the chapter number.
6491 % Not used for @heading series.
6492 %
6493 % To test against our argument.
6494 \def\Ynothingkeyword{Ynothing}
6495 \def\Yappendixkeyword{Yappendix}
6496 \def\Yomitfromtockeyword{Yomitfromtoc}
6497 %
6498 \def\chapmacro#1#2#3{%
6499   \expandafter\ifx\thisenv\titlepage\else
6500     \checkenv{}% chapters, etc., should not start inside an environment.
6501   \fi
6502   % FIXME: \chapmacro is currently called from inside \titlepage when
6503   % \setcontentsaftertitlepage to print the "Table of Contents" heading, but
6504   % this should probably be done by \sectionheading with an option to print
6505   % in chapter size.
6506   %
6507   % Insert the first mark before the heading break (see notes for \domark).
6508   \let\prevchapterdefs=\lastchapterdefs
6509   \let\prevsectiondefs=\lastsectiondefs
6510   \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6511                         \gdef\thissection{}}%
6512   %
6513   \def\temptype{#2}%
6514   \ifx\temptype\Ynothingkeyword
6515     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6516                           \gdef\thischapter{\thischaptername}}%
6517   \else\ifx\temptype\Yomitfromtockeyword
6518     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6519                           \gdef\thischapter{}}%
6520   \else\ifx\temptype\Yappendixkeyword
6521     \toks0={#1}%
6522     \xdef\lastchapterdefs{%
6523       \gdef\noexpand\thischaptername{\the\toks0}%
6524       \gdef\noexpand\thischapternum{\appendixletter}%
6525       % \noexpand\putwordAppendix avoids expanding indigestible
6526       % commands in some of the translations.
6527       \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
6528                                  \noexpand\thischapternum:
6529                                  \noexpand\thischaptername}%
6530     }%
6531   \else
6532     \toks0={#1}%
6533     \xdef\lastchapterdefs{%
6534       \gdef\noexpand\thischaptername{\the\toks0}%
6535       \gdef\noexpand\thischapternum{\the\chapno}%
6536       % \noexpand\putwordChapter avoids expanding indigestible
6537       % commands in some of the translations.
6538       \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
6539                                  \noexpand\thischapternum:
6540                                  \noexpand\thischaptername}%
6541     }%
6542   \fi\fi\fi
6543   %
6544   % Output the mark.  Pass it through \safewhatsit, to take care of
6545   % the preceding space.
6546   \safewhatsit\domark
6547   %
6548   % Insert the chapter heading break.
6549   \pchapsepmacro
6550   %
6551   % Now the second mark, after the heading break.  No break points
6552   % between here and the heading.
6553   \let\prevchapterdefs=\lastchapterdefs
6554   \let\prevsectiondefs=\lastsectiondefs
6555   \domark
6556   %
6557   {%
6558     \chapfonts \rmisbold
6559     \let\footnote=\errfootnoteheading % give better error message
6560     %
6561     % Have to define \lastsection before calling \donoderef, because the
6562     % xref code eventually uses it.  On the other hand, it has to be called
6563     % after \pchapsepmacro, or the headline will change too soon.
6564     \gdef\lastsection{#1}%
6565     %
6566     % Only insert the separating space if we have a chapter/appendix
6567     % number, and don't print the unnumbered ``number''.
6568     \ifx\temptype\Ynothingkeyword
6569       \setbox0 = \hbox{}%
6570       \def\toctype{unnchap}%
6571     \else\ifx\temptype\Yomitfromtockeyword
6572       \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6573       \def\toctype{omit}%
6574     \else\ifx\temptype\Yappendixkeyword
6575       \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6576       \def\toctype{app}%
6577     \else
6578       \setbox0 = \hbox{#3\enspace}%
6579       \def\toctype{numchap}%
6580     \fi\fi\fi
6581     %
6582     % Write the toc entry for this chapter.  Must come before the
6583     % \donoderef, because we include the current node name in the toc
6584     % entry, and \donoderef resets it to empty.
6585     \writetocentry{\toctype}{#1}{#3}%
6586     %
6587     % For pdftex, we have to write out the node definition (aka, make
6588     % the pdfdest) after any page break, but before the actual text has
6589     % been typeset.  If the destination for the pdf outline is after the
6590     % text, then jumping from the outline may wind up with the text not
6591     % being visible, for instance under high magnification.
6592     \donoderef{#2}%
6593     %
6594     % Typeset the actual heading.
6595     \nobreak % Avoid page breaks at the interline glue.
6596     \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
6597           \unhbox0 #1\par}%
6598   }%
6599   \nobreak\bigskip % no page break after a chapter title
6600   \nobreak
6601 }
6602
6603 % @centerchap -- centered and unnumbered.
6604 \let\centerparametersmaybe = \relax
6605 \def\centerparameters{%
6606   \advance\rightskip by 3\rightskip
6607   \leftskip = \rightskip
6608   \parfillskip = 0pt
6609 }
6610
6611
6612 % Section titles.  These macros combine the section number parts and
6613 % call the generic \sectionheading to do the printing.
6614 %
6615 \newskip\secheadingskip
6616 \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
6617
6618 % Subsection titles.
6619 \newskip\subsecheadingskip
6620 \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
6621
6622 % Subsubsection titles.
6623 \def\subsubsecheadingskip{\subsecheadingskip}
6624 \def\subsubsecheadingbreak{\subsecheadingbreak}
6625
6626
6627 % Print any size, any type, section title.
6628 %
6629 % #1 is the text of the title,
6630 % #2 is the section level (sec/subsec/subsubsec),
6631 % #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6632 % #4 is the section number.
6633 %
6634 \def\seckeyword{sec}
6635 %
6636 \def\sectionheading#1#2#3#4{%
6637   {%
6638     \def\sectionlevel{#2}%
6639     \def\temptype{#3}%
6640     %
6641     % It is ok for the @heading series commands to appear inside an
6642     % environment (it's been historically allowed, though the logic is
6643     % dubious), but not the others.
6644     \ifx\temptype\Yomitfromtockeyword\else
6645       \checkenv{}% non-@*heading should not be in an environment.
6646     \fi
6647     \let\footnote=\errfootnoteheading
6648     %
6649     % Switch to the right set of fonts.
6650     \csname #2fonts\endcsname \rmisbold
6651     %
6652     % Insert first mark before the heading break (see notes for \domark).
6653     \let\prevsectiondefs=\lastsectiondefs
6654     \ifx\temptype\Ynothingkeyword
6655       \ifx\sectionlevel\seckeyword
6656         \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6657                               \gdef\thissection{\thissectionname}}%
6658       \fi
6659     \else\ifx\temptype\Yomitfromtockeyword
6660       % Don't redefine \thissection.
6661     \else\ifx\temptype\Yappendixkeyword
6662       \ifx\sectionlevel\seckeyword
6663         \toks0={#1}%
6664         \xdef\lastsectiondefs{%
6665           \gdef\noexpand\thissectionname{\the\toks0}%
6666           \gdef\noexpand\thissectionnum{#4}%
6667           % \noexpand\putwordSection avoids expanding indigestible
6668           % commands in some of the translations.
6669           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6670                                      \noexpand\thissectionnum:
6671                                      \noexpand\thissectionname}%
6672         }%
6673       \fi
6674     \else
6675       \ifx\sectionlevel\seckeyword
6676         \toks0={#1}%
6677         \xdef\lastsectiondefs{%
6678           \gdef\noexpand\thissectionname{\the\toks0}%
6679           \gdef\noexpand\thissectionnum{#4}%
6680           % \noexpand\putwordSection avoids expanding indigestible
6681           % commands in some of the translations.
6682           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6683                                      \noexpand\thissectionnum:
6684                                      \noexpand\thissectionname}%
6685         }%
6686       \fi
6687     \fi\fi\fi
6688     %
6689     % Go into vertical mode.  Usually we'll already be there, but we
6690     % don't want the following whatsit to end up in a preceding paragraph
6691     % if the document didn't happen to have a blank line.
6692     \par
6693     %
6694     % Output the mark.  Pass it through \safewhatsit, to take care of
6695     % the preceding space.
6696     \safewhatsit\domark
6697     %
6698     % Insert space above the heading.
6699     \csname #2headingbreak\endcsname
6700     %
6701     % Now the second mark, after the heading break.  No break points
6702     % between here and the heading.
6703     \global\let\prevsectiondefs=\lastsectiondefs
6704     \domark
6705     %
6706     % Only insert the space after the number if we have a section number.
6707     \ifx\temptype\Ynothingkeyword
6708       \setbox0 = \hbox{}%
6709       \def\toctype{unn}%
6710       \gdef\lastsection{#1}%
6711     \else\ifx\temptype\Yomitfromtockeyword
6712       % for @headings -- no section number, don't include in toc,
6713       % and don't redefine \lastsection.
6714       \setbox0 = \hbox{}%
6715       \def\toctype{omit}%
6716       \let\sectionlevel=\empty
6717     \else\ifx\temptype\Yappendixkeyword
6718       \setbox0 = \hbox{#4\enspace}%
6719       \def\toctype{app}%
6720       \gdef\lastsection{#1}%
6721     \else
6722       \setbox0 = \hbox{#4\enspace}%
6723       \def\toctype{num}%
6724       \gdef\lastsection{#1}%
6725     \fi\fi\fi
6726     %
6727     % Write the toc entry (before \donoderef).  See comments in \chapmacro.
6728     \writetocentry{\toctype\sectionlevel}{#1}{#4}%
6729     %
6730     % Write the node reference (= pdf destination for pdftex).
6731     % Again, see comments in \chapmacro.
6732     \donoderef{#3}%
6733     %
6734     % Interline glue will be inserted when the vbox is completed.
6735     % That glue will be a valid breakpoint for the page, since it'll be
6736     % preceded by a whatsit (usually from the \donoderef, or from the
6737     % \writetocentry if there was no node).  We don't want to allow that
6738     % break, since then the whatsits could end up on page n while the
6739     % section is on page n+1, thus toc/etc. are wrong.  Debian bug 276000.
6740     \nobreak
6741     %
6742     % Output the actual section heading.
6743     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
6744           \hangindent=\wd0  % zero if no section number
6745           \unhbox0 #1}%
6746   }%
6747   % Add extra space after the heading -- half of whatever came above it.
6748   % Don't allow stretch, though.
6749   \kern .5 \csname #2headingskip\endcsname
6750   %
6751   % Do not let the kern be a potential breakpoint, as it would be if it
6752   % was followed by glue.
6753   \nobreak
6754   %
6755   % We'll almost certainly start a paragraph next, so don't let that
6756   % glue accumulate.  (Not a breakpoint because it's preceded by a
6757   % discardable item.)  However, when a paragraph is not started next
6758   % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6759   % or the negative glue will cause weirdly wrong output, typically
6760   % obscuring the section heading with something else.
6761   \vskip-\parskip
6762   %
6763   % This is so the last item on the main vertical list is a known
6764   % \penalty > 10000, so \startdefun, etc., can recognize the situation
6765   % and do the needful.
6766   \penalty 10001
6767 }
6768
6769
6770 \message{toc,}
6771 % Table of contents.
6772 \newwrite\tocfile
6773
6774 % Write an entry to the toc file, opening it if necessary.
6775 % Called from @chapter, etc.
6776 %
6777 % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6778 % We append the current node name (if any) and page number as additional
6779 % arguments for the \{chap,sec,...}entry macros which will eventually
6780 % read this.  The node name is used in the pdf outlines as the
6781 % destination to jump to.
6782 %
6783 % We open the .toc file for writing here instead of at @setfilename (or
6784 % any other fixed time) so that @contents can be anywhere in the document.
6785 % But if #1 is `omit', then we don't do anything.  This is used for the
6786 % table of contents chapter openings themselves.
6787 %
6788 \newif\iftocfileopened
6789 \def\omitkeyword{omit}%
6790 %
6791 \def\writetocentry#1#2#3{%
6792   \edef\writetoctype{#1}%
6793   \ifx\writetoctype\omitkeyword \else
6794     \iftocfileopened\else
6795       \immediate\openout\tocfile = \jobname.toc
6796       \global\tocfileopenedtrue
6797     \fi
6798     %
6799     \iflinks
6800       {\atdummies
6801        \edef\temp{%
6802          \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6803        \temp
6804       }%
6805     \fi
6806   \fi
6807   %
6808   % Tell \shipout to create a pdf destination on each page, if we're
6809   % writing pdf.  These are used in the table of contents.  We can't
6810   % just write one on every page because the title pages are numbered
6811   % 1 and 2 (the page numbers aren't printed), and so are the first
6812   % two pages of the document.  Thus, we'd have two destinations named
6813   % `1', and two named `2'.
6814   \ifpdf
6815     \global\pdfmakepagedesttrue
6816   \else
6817     \ifx\XeTeXrevision\thisisundefined
6818     \else
6819       \global\pdfmakepagedesttrue
6820     \fi
6821   \fi
6822 }
6823
6824
6825 % These characters do not print properly in the Computer Modern roman
6826 % fonts, so we must take special care.  This is more or less redundant
6827 % with the Texinfo input format setup at the end of this file.
6828 %
6829 \def\activecatcodes{%
6830   \catcode`\"=\active
6831   \catcode`\$=\active
6832   \catcode`\<=\active
6833   \catcode`\>=\active
6834   \catcode`\\=\active
6835   \catcode`\^=\active
6836   \catcode`\_=\active
6837   \catcode`\|=\active
6838   \catcode`\~=\active
6839 }
6840
6841
6842 % Read the toc file, which is essentially Texinfo input.
6843 \def\readtocfile{%
6844   \setupdatafile
6845   \activecatcodes
6846   \input \tocreadfilename
6847 }
6848
6849 \newskip\contentsrightmargin \contentsrightmargin=1in
6850 \newcount\savepageno
6851 \newcount\lastnegativepageno \lastnegativepageno = -1
6852
6853 % Prepare to read what we've written to \tocfile.
6854 %
6855 \def\startcontents#1{%
6856   % If @setchapternewpage on, and @headings double, the contents should
6857   % start on an odd page, unlike chapters.  Thus, we maintain
6858   % \contentsalignmacro in parallel with \pagealignmacro.
6859   % From: Torbjorn Granlund <tege@matematik.su.se>
6860   \contentsalignmacro
6861   \immediate\closeout\tocfile
6862   %
6863   % Don't need to put `Contents' or `Short Contents' in the headline.
6864   % It is abundantly clear what they are.
6865   \chapmacro{#1}{Yomitfromtoc}{}%
6866   %
6867   \savepageno = \pageno
6868   \begingroup                  % Set up to handle contents files properly.
6869     \raggedbottom              % Worry more about breakpoints than the bottom.
6870     \entryrightmargin=\contentsrightmargin % Don't use the full line length.
6871     %
6872     % Roman numerals for page numbers.
6873     \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
6874 }
6875
6876 % redefined for the two-volume lispref.  We always output on
6877 % \jobname.toc even if this is redefined.
6878 %
6879 \def\tocreadfilename{\jobname.toc}
6880
6881 % Normal (long) toc.
6882 %
6883 \def\contents{%
6884   \startcontents{\putwordTOC}%
6885     \openin 1 \tocreadfilename\space
6886     \ifeof 1 \else
6887       \readtocfile
6888     \fi
6889     \vfill \eject
6890     \contentsalignmacro % in case @setchapternewpage odd is in effect
6891     \ifeof 1 \else
6892       \pdfmakeoutlines
6893     \fi
6894     \closein 1
6895   \endgroup
6896   \lastnegativepageno = \pageno
6897   \global\pageno = \savepageno
6898 }
6899
6900 % And just the chapters.
6901 \def\summarycontents{%
6902   \startcontents{\putwordShortTOC}%
6903     %
6904     \let\partentry = \shortpartentry
6905     \let\numchapentry = \shortchapentry
6906     \let\appentry = \shortchapentry
6907     \let\unnchapentry = \shortunnchapentry
6908     % We want a true roman here for the page numbers.
6909     \secfonts
6910     \let\rm=\shortcontrm \let\bf=\shortcontbf
6911     \let\sl=\shortcontsl \let\tt=\shortconttt
6912     \rm
6913     \hyphenpenalty = 10000
6914     \advance\baselineskip by 1pt % Open it up a little.
6915     \def\numsecentry##1##2##3##4{}
6916     \let\appsecentry = \numsecentry
6917     \let\unnsecentry = \numsecentry
6918     \let\numsubsecentry = \numsecentry
6919     \let\appsubsecentry = \numsecentry
6920     \let\unnsubsecentry = \numsecentry
6921     \let\numsubsubsecentry = \numsecentry
6922     \let\appsubsubsecentry = \numsecentry
6923     \let\unnsubsubsecentry = \numsecentry
6924     \openin 1 \tocreadfilename\space
6925     \ifeof 1 \else
6926       \readtocfile
6927     \fi
6928     \closein 1
6929     \vfill \eject
6930     \contentsalignmacro % in case @setchapternewpage odd is in effect
6931   \endgroup
6932   \lastnegativepageno = \pageno
6933   \global\pageno = \savepageno
6934 }
6935 \let\shortcontents = \summarycontents
6936
6937 % Typeset the label for a chapter or appendix for the short contents.
6938 % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6939 %
6940 \def\shortchaplabel#1{%
6941   % This space should be enough, since a single number is .5em, and the
6942   % widest letter (M) is 1em, at least in the Computer Modern fonts.
6943   % But use \hss just in case.
6944   % (This space doesn't include the extra space that gets added after
6945   % the label; that gets put in by \shortchapentry above.)
6946   %
6947   % We'd like to right-justify chapter numbers, but that looks strange
6948   % with appendix letters.  And right-justifying numbers and
6949   % left-justifying letters looks strange when there is less than 10
6950   % chapters.  Have to read the whole toc once to know how many chapters
6951   % there are before deciding ...
6952   \hbox to 1em{#1\hss}%
6953 }
6954
6955 % These macros generate individual entries in the table of contents.
6956 % The first argument is the chapter or section name.
6957 % The last argument is the page number.
6958 % The arguments in between are the chapter number, section number, ...
6959
6960 % Parts, in the main contents.  Replace the part number, which doesn't
6961 % exist, with an empty box.  Let's hope all the numbers have the same width.
6962 % Also ignore the page number, which is conventionally not printed.
6963 \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6964 \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}}
6965 %
6966 % Parts, in the short toc.
6967 \def\shortpartentry#1#2#3#4{%
6968   \penalty-300
6969   \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
6970   \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
6971 }
6972
6973 % Chapters, in the main contents.
6974 \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
6975
6976 % Chapters, in the short toc.
6977 % See comments in \dochapentry re vbox and related settings.
6978 \def\shortchapentry#1#2#3#4{%
6979   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
6980 }
6981
6982 % Appendices, in the main contents.
6983 % Need the word Appendix, and a fixed-size box.
6984 %
6985 \def\appendixbox#1{%
6986   % We use M since it's probably the widest letter.
6987   \setbox0 = \hbox{\putwordAppendix{} M}%
6988   \hbox to \wd0{\putwordAppendix{} #1\hss}}
6989 %
6990 \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
6991
6992 % Unnumbered chapters.
6993 \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
6994 \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
6995
6996 % Sections.
6997 \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
6998 \let\appsecentry=\numsecentry
6999 \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
7000
7001 % Subsections.
7002 \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
7003 \let\appsubsecentry=\numsubsecentry
7004 \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
7005
7006 % And subsubsections.
7007 \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
7008 \let\appsubsubsecentry=\numsubsubsecentry
7009 \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
7010
7011 % This parameter controls the indentation of the various levels.
7012 % Same as \defaultparindent.
7013 \newdimen\tocindent \tocindent = 15pt
7014
7015 % Now for the actual typesetting. In all these, #1 is the text and #2 is the
7016 % page number.
7017 %
7018 % If the toc has to be broken over pages, we want it to be at chapters
7019 % if at all possible; hence the \penalty.
7020 \def\dochapentry#1#2{%
7021    \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
7022    \begingroup
7023      % Move the page numbers slightly to the right
7024      \advance\entryrightmargin by -0.05em
7025      \chapentryfonts
7026      \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7027    \endgroup
7028    \nobreak\vskip .25\baselineskip plus.1\baselineskip
7029 }
7030
7031 \def\dosecentry#1#2{\begingroup
7032   \secentryfonts \leftskip=\tocindent
7033   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7034 \endgroup}
7035
7036 \def\dosubsecentry#1#2{\begingroup
7037   \subsecentryfonts \leftskip=2\tocindent
7038   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7039 \endgroup}
7040
7041 \def\dosubsubsecentry#1#2{\begingroup
7042   \subsubsecentryfonts \leftskip=3\tocindent
7043   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7044 \endgroup}
7045
7046 % We use the same \entry macro as for the index entries.
7047 \let\tocentry = \entry
7048
7049 % Space between chapter (or whatever) number and the title.
7050 \def\labelspace{\hskip1em \relax}
7051
7052 \def\dopageno#1{{\rm #1}}
7053 \def\doshortpageno#1{{\rm #1}}
7054
7055 \def\chapentryfonts{\secfonts \rm}
7056 \def\secentryfonts{\textfonts}
7057 \def\subsecentryfonts{\textfonts}
7058 \def\subsubsecentryfonts{\textfonts}
7059
7060
7061 \message{environments,}
7062 % @foo ... @end foo.
7063
7064 % @tex ... @end tex    escapes into raw TeX temporarily.
7065 % One exception: @ is still an escape character, so that @end tex works.
7066 % But \@ or @@ will get a plain @ character.
7067
7068 \envdef\tex{%
7069   \setupmarkupstyle{tex}%
7070   \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
7071   \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
7072   \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
7073   \catcode `\%=14
7074   \catcode `\+=\other
7075   \catcode `\"=\other
7076   \catcode `\|=\other
7077   \catcode `\<=\other
7078   \catcode `\>=\other
7079   \catcode `\`=\other
7080   \catcode `\'=\other
7081   %
7082   % ' is active in math mode (mathcode"8000).  So reset it, and all our
7083   % other math active characters (just in case), to plain's definitions.
7084   \mathactive
7085   %
7086   % Inverse of the list at the beginning of the file.
7087   \let\b=\ptexb
7088   \let\bullet=\ptexbullet
7089   \let\c=\ptexc
7090   \let\,=\ptexcomma
7091   \let\.=\ptexdot
7092   \let\dots=\ptexdots
7093   \let\equiv=\ptexequiv
7094   \let\!=\ptexexclam
7095   \let\i=\ptexi
7096   \let\indent=\ptexindent
7097   \let\noindent=\ptexnoindent
7098   \let\{=\ptexlbrace
7099   \let\+=\tabalign
7100   \let\}=\ptexrbrace
7101   \let\/=\ptexslash
7102   \let\sp=\ptexsp
7103   \let\*=\ptexstar
7104   %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
7105   \let\t=\ptext
7106   \expandafter \let\csname top\endcsname=\ptextop  % we've made it outer
7107   \let\frenchspacing=\plainfrenchspacing
7108   %
7109   \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
7110   \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
7111   \def\@{@}%
7112 }
7113 % There is no need to define \Etex.
7114
7115 % Define @lisp ... @end lisp.
7116 % @lisp environment forms a group so it can rebind things,
7117 % including the definition of @end lisp (which normally is erroneous).
7118
7119 % Amount to narrow the margins by for @lisp.
7120 \newskip\lispnarrowing \lispnarrowing=0.4in
7121
7122 % This is the definition that ^^M gets inside @lisp, @example, and other
7123 % such environments.  \null is better than a space, since it doesn't
7124 % have any width.
7125 \def\lisppar{\null\endgraf}
7126
7127 % This space is always present above and below environments.
7128 \newskip\envskipamount \envskipamount = 0pt
7129
7130 % Make spacing and below environment symmetrical.  We use \parskip here
7131 % to help in doing that, since in @example-like environments \parskip
7132 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
7133 % start of the next paragraph will insert \parskip.
7134 %
7135 \def\aboveenvbreak{{%
7136   % =10000 instead of <10000 because of a special case in \itemzzz and
7137   % \sectionheading, q.v.
7138   \ifnum \lastpenalty=10000 \else
7139     \advance\envskipamount by \parskip
7140     \endgraf
7141     \ifdim\lastskip<\envskipamount
7142       \removelastskip
7143       \ifnum\lastpenalty<10000
7144         % Penalize breaking before the environment, because preceding text
7145         % often leads into it.
7146         \penalty100
7147       \fi
7148       \vskip\envskipamount
7149     \fi
7150   \fi
7151 }}
7152
7153 \def\afterenvbreak{{%
7154   % =10000 instead of <10000 because of a special case in \itemzzz and
7155   % \sectionheading, q.v.
7156   \ifnum \lastpenalty=10000 \else
7157     \advance\envskipamount by \parskip
7158     \endgraf
7159     \ifdim\lastskip<\envskipamount
7160       \removelastskip
7161       % it's not a good place to break if the last penalty was \nobreak
7162       % or better ...
7163       \ifnum\lastpenalty<10000 \penalty-50 \fi
7164       \vskip\envskipamount
7165     \fi
7166   \fi
7167 }}
7168
7169 % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins; it will
7170 % also clear it, so that its embedded environments do the narrowing again.
7171 \let\nonarrowing=\relax
7172
7173 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
7174 % environment contents.
7175 \font\circle=lcircle10
7176 \newdimen\circthick
7177 \newdimen\cartouter\newdimen\cartinner
7178 \newskip\normbskip\newskip\normpskip\newskip\normlskip
7179 \circthick=\fontdimen8\circle
7180 %
7181 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
7182 \def\ctr{{\hskip 6pt\circle\char'010}}
7183 \def\cbl{{\circle\char'012\hskip -6pt}}
7184 \def\cbr{{\hskip 6pt\circle\char'011}}
7185 \def\carttop{\hbox to \cartouter{\hskip\lskip
7186         \ctl\leaders\hrule height\circthick\hfil\ctr
7187         \hskip\rskip}}
7188 \def\cartbot{\hbox to \cartouter{\hskip\lskip
7189         \cbl\leaders\hrule height\circthick\hfil\cbr
7190         \hskip\rskip}}
7191 %
7192 \newskip\lskip\newskip\rskip
7193
7194 \envdef\cartouche{%
7195   \ifhmode\par\fi  % can't be in the midst of a paragraph.
7196   \startsavinginserts
7197   \lskip=\leftskip \rskip=\rightskip
7198   \leftskip=0pt\rightskip=0pt % we want these *outside*.
7199   \cartinner=\hsize \advance\cartinner by-\lskip
7200   \advance\cartinner by-\rskip
7201   \cartouter=\hsize
7202   \advance\cartouter by 18.4pt  % allow for 3pt kerns on either
7203                                 % side, and for 6pt waste from
7204                                 % each corner char, and rule thickness
7205   \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
7206   %
7207   % If this cartouche directly follows a sectioning command, we need the
7208   % \parskip glue (backspaced over by default) or the cartouche can
7209   % collide with the section heading.
7210   \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
7211   %
7212   \setbox\groupbox=\vbox\bgroup
7213       \baselineskip=0pt\parskip=0pt\lineskip=0pt
7214       \carttop
7215       \hbox\bgroup
7216           \hskip\lskip
7217           \vrule\kern3pt
7218           \vbox\bgroup
7219               \kern3pt
7220               \hsize=\cartinner
7221               \baselineskip=\normbskip
7222               \lineskip=\normlskip
7223               \parskip=\normpskip
7224               \vskip -\parskip
7225               \comment % For explanation, see the end of def\group.
7226 }
7227 \def\Ecartouche{%
7228               \ifhmode\par\fi
7229               \kern3pt
7230           \egroup
7231           \kern3pt\vrule
7232           \hskip\rskip
7233       \egroup
7234       \cartbot
7235   \egroup
7236   \addgroupbox
7237   \checkinserts
7238 }
7239
7240
7241 % This macro is called at the beginning of all the @example variants,
7242 % inside a group.
7243 \newdimen\nonfillparindent
7244 \def\nonfillstart{%
7245   \aboveenvbreak
7246   \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
7247   \sepspaces % Make spaces be word-separators rather than space tokens.
7248   \let\par = \lisppar % don't ignore blank lines
7249   \obeylines % each line of input is a line of output
7250   \parskip = 0pt
7251   % Turn off paragraph indentation but redefine \indent to emulate
7252   % the normal \indent.
7253   \nonfillparindent=\parindent
7254   \parindent = 0pt
7255   \let\indent\nonfillindent
7256   %
7257   \emergencystretch = 0pt % don't try to avoid overfull boxes
7258   \ifx\nonarrowing\relax
7259     \advance \leftskip by \lispnarrowing
7260     \exdentamount=\lispnarrowing
7261   \else
7262     \let\nonarrowing = \relax
7263   \fi
7264   \let\exdent=\nofillexdent
7265 }
7266
7267 \begingroup
7268 \obeyspaces
7269 % We want to swallow spaces (but not other tokens) after the fake
7270 % @indent in our nonfill-environments, where spaces are normally
7271 % active and set to @tie, resulting in them not being ignored after
7272 % @indent.
7273 \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
7274 \gdef\nonfillindentcheck{%
7275 \ifx\temp %
7276 \expandafter\nonfillindentgobble%
7277 \else%
7278 \leavevmode\nonfillindentbox%
7279 \fi%
7280 }%
7281 \endgroup
7282 \def\nonfillindentgobble#1{\nonfillindent}
7283 \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7284
7285 % If you want all examples etc. small: @set dispenvsize small.
7286 % If you want even small examples the full size: @set dispenvsize nosmall.
7287 % This affects the following displayed environments:
7288 %    @example, @display, @format, @lisp
7289 %
7290 \def\smallword{small}
7291 \def\nosmallword{nosmall}
7292 \let\SETdispenvsize\relax
7293 \def\setnormaldispenv{%
7294   \ifx\SETdispenvsize\smallword
7295     % end paragraph for sake of leading, in case document has no blank
7296     % line.  This is redundant with what happens in \aboveenvbreak, but
7297     % we need to do it before changing the fonts, and it's inconvenient
7298     % to change the fonts afterward.
7299     \ifnum \lastpenalty=10000 \else \endgraf \fi
7300     \smallexamplefonts \rm
7301   \fi
7302 }
7303 \def\setsmalldispenv{%
7304   \ifx\SETdispenvsize\nosmallword
7305   \else
7306     \ifnum \lastpenalty=10000 \else \endgraf \fi
7307     \smallexamplefonts \rm
7308   \fi
7309 }
7310
7311 % We often define two environments, @foo and @smallfoo.
7312 % Let's do it in one command.  #1 is the env name, #2 the definition.
7313 \def\makedispenvdef#1#2{%
7314   \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7315   \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
7316   \expandafter\let\csname E#1\endcsname \afterenvbreak
7317   \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
7318 }
7319
7320 % Define two environment synonyms (#1 and #2) for an environment.
7321 \def\maketwodispenvdef#1#2#3{%
7322   \makedispenvdef{#1}{#3}%
7323   \makedispenvdef{#2}{#3}%
7324 }
7325 %
7326 % @lisp: indented, narrowed, typewriter font;
7327 % @example: same as @lisp.
7328 %
7329 % @smallexample and @smalllisp: use smaller fonts.
7330 % Originally contributed by Pavel@xerox.
7331 %
7332 \maketwodispenvdef{lisp}{example}{%
7333   \nonfillstart
7334   \tt\setupmarkupstyle{example}%
7335   \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
7336   \gobble % eat return
7337 }
7338 % @display/@smalldisplay: same as @lisp except keep current font.
7339 %
7340 \makedispenvdef{display}{%
7341   \nonfillstart
7342   \gobble
7343 }
7344
7345 % @format/@smallformat: same as @display except don't narrow margins.
7346 %
7347 \makedispenvdef{format}{%
7348   \let\nonarrowing = t%
7349   \nonfillstart
7350   \gobble
7351 }
7352
7353 % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7354 \envdef\flushleft{%
7355   \let\nonarrowing = t%
7356   \nonfillstart
7357   \gobble
7358 }
7359 \let\Eflushleft = \afterenvbreak
7360
7361 % @flushright.
7362 %
7363 \envdef\flushright{%
7364   \let\nonarrowing = t%
7365   \nonfillstart
7366   \advance\leftskip by 0pt plus 1fill\relax
7367   \gobble
7368 }
7369 \let\Eflushright = \afterenvbreak
7370
7371
7372 % @raggedright does more-or-less normal line breaking but no right
7373 % justification.  From plain.tex.  Don't stretch around special
7374 % characters in urls in this environment, since the stretch at the right
7375 % should be enough.
7376 \envdef\raggedright{%
7377   \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7378   \def\urefprestretchamount{0pt}%
7379   \def\urefpoststretchamount{0pt}%
7380 }
7381 \let\Eraggedright\par
7382
7383 \envdef\raggedleft{%
7384   \parindent=0pt \leftskip0pt plus2em
7385   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7386   \hbadness=10000 % Last line will usually be underfull, so turn off
7387                   % badness reporting.
7388 }
7389 \let\Eraggedleft\par
7390
7391 \envdef\raggedcenter{%
7392   \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
7393   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7394   \hbadness=10000 % Last line will usually be underfull, so turn off
7395                   % badness reporting.
7396 }
7397 \let\Eraggedcenter\par
7398
7399
7400 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
7401 % and narrows the margins.  We keep \parskip nonzero in general, since
7402 % we're doing normal filling.  So, when using \aboveenvbreak and
7403 % \afterenvbreak, temporarily make \parskip 0.
7404 %
7405 \makedispenvdef{quotation}{\quotationstart}
7406 %
7407 \def\quotationstart{%
7408   \indentedblockstart % same as \indentedblock, but increase right margin too.
7409   \ifx\nonarrowing\relax
7410     \advance\rightskip by \lispnarrowing
7411   \fi
7412   \parsearg\quotationlabel
7413 }
7414
7415 % We have retained a nonzero parskip for the environment, since we're
7416 % doing normal filling.
7417 %
7418 \def\Equotation{%
7419   \par
7420   \ifx\quotationauthor\thisisundefined\else
7421     % indent a bit.
7422     \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7423   \fi
7424   {\parskip=0pt \afterenvbreak}%
7425 }
7426 \def\Esmallquotation{\Equotation}
7427
7428 % If we're given an argument, typeset it in bold with a colon after.
7429 \def\quotationlabel#1{%
7430   \def\temp{#1}%
7431   \ifx\temp\empty \else
7432     {\bf #1: }%
7433   \fi
7434 }
7435
7436 % @indentedblock is like @quotation, but indents only on the left and
7437 % has no optional argument.
7438
7439 \makedispenvdef{indentedblock}{\indentedblockstart}
7440 %
7441 \def\indentedblockstart{%
7442   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7443   \parindent=0pt
7444   %
7445   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7446   \ifx\nonarrowing\relax
7447     \advance\leftskip by \lispnarrowing
7448     \exdentamount = \lispnarrowing
7449   \else
7450     \let\nonarrowing = \relax
7451   \fi
7452 }
7453
7454 % Keep a nonzero parskip for the environment, since we're doing normal filling.
7455 %
7456 \def\Eindentedblock{%
7457   \par
7458   {\parskip=0pt \afterenvbreak}%
7459 }
7460 \def\Esmallindentedblock{\Eindentedblock}
7461
7462
7463 % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7464 % If we want to allow any <char> as delimiter,
7465 % we need the curly braces so that makeinfo sees the @verb command, eg:
7466 % `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
7467 %
7468 % [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
7469 %
7470 % [Knuth] p.344; only we need to do the other characters Texinfo sets
7471 % active too.  Otherwise, they get lost as the first character on a
7472 % verbatim line.
7473 \def\dospecials{%
7474   \do\ \do\\\do\{\do\}\do\$\do\&%
7475   \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7476   \do\<\do\>\do\|\do\@\do+\do\"%
7477   % Don't do the quotes -- if we do, @set txicodequoteundirected and
7478   % @set txicodequotebacktick will not have effect on @verb and
7479   % @verbatim, and ?` and !` ligatures won't get disabled.
7480   %\do\`\do\'%
7481 }
7482 %
7483 % [Knuth] p. 380
7484 \def\uncatcodespecials{%
7485   \def\do##1{\catcode`##1=\other}\dospecials}
7486 %
7487 % Setup for the @verb command.
7488 %
7489 % Eight spaces for a tab
7490 \begingroup
7491   \catcode`\^^I=\active
7492   \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7493 \endgroup
7494 %
7495 \def\setupverb{%
7496   \tt  % easiest (and conventionally used) font for verbatim
7497   \def\par{\leavevmode\endgraf}%
7498   \setupmarkupstyle{verb}%
7499   \tabeightspaces
7500   % Respect line breaks,
7501   % print special symbols as themselves, and
7502   % make each space count
7503   % must do in this order:
7504   \obeylines \uncatcodespecials \sepspaces
7505 }
7506
7507 % Setup for the @verbatim environment
7508 %
7509 % Real tab expansion.
7510 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7511 %
7512 % We typeset each line of the verbatim in an \hbox, so we can handle
7513 % tabs.  The \global is in case the verbatim line starts with an accent,
7514 % or some other command that starts with a begin-group.  Otherwise, the
7515 % entire \verbbox would disappear at the corresponding end-group, before
7516 % it is typeset.  Meanwhile, we can't have nested verbatim commands
7517 % (can we?), so the \global won't be overwriting itself.
7518 \newbox\verbbox
7519 \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
7520 %
7521 \begingroup
7522   \catcode`\^^I=\active
7523   \gdef\tabexpand{%
7524     \catcode`\^^I=\active
7525     \def^^I{\leavevmode\egroup
7526       \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7527       \divide\dimen\verbbox by\tabw
7528       \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7529       \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
7530       \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
7531     }%
7532   }
7533 \endgroup
7534
7535 % start the verbatim environment.
7536 \def\setupverbatim{%
7537   \let\nonarrowing = t%
7538   \nonfillstart
7539   \tt % easiest (and conventionally used) font for verbatim
7540   % The \leavevmode here is for blank lines.  Otherwise, we would
7541   % never \starttabox and the \egroup would end verbatim mode.
7542   \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
7543   \tabexpand
7544   \setupmarkupstyle{verbatim}%
7545   % Respect line breaks,
7546   % print special symbols as themselves, and
7547   % make each space count.
7548   % Must do in this order:
7549   \obeylines \uncatcodespecials \sepspaces
7550   \everypar{\starttabbox}%
7551 }
7552
7553 % Do the @verb magic: verbatim text is quoted by unique
7554 % delimiter characters.  Before first delimiter expect a
7555 % right brace, after last delimiter expect closing brace:
7556 %
7557 %    \def\doverb'{'<char>#1<char>'}'{#1}
7558 %
7559 % [Knuth] p. 382; only eat outer {}
7560 \begingroup
7561   \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
7562   \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7563 \endgroup
7564 %
7565 \def\verb{\begingroup\setupverb\doverb}
7566 %
7567 %
7568 % Do the @verbatim magic: define the macro \doverbatim so that
7569 % the (first) argument ends when '@end verbatim' is reached, ie:
7570 %
7571 %     \def\doverbatim#1@end verbatim{#1}
7572 %
7573 % For Texinfo it's a lot easier than for LaTeX,
7574 % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
7575 % we need not redefine '\', '{' and '}'.
7576 %
7577 % Inspired by LaTeX's verbatim command set [latex.ltx]
7578 %
7579 \begingroup
7580   \catcode`\ =\active
7581   \obeylines %
7582   % ignore everything up to the first ^^M, that's the newline at the end
7583   % of the @verbatim input line itself.  Otherwise we get an extra blank
7584   % line in the output.
7585   \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
7586   % We really want {...\end verbatim} in the body of the macro, but
7587   % without the active space; thus we have to use \xdef and \gobble.
7588 \endgroup
7589 %
7590 \envdef\verbatim{%
7591     \setupverbatim\doverbatim
7592 }
7593 \let\Everbatim = \afterenvbreak
7594
7595
7596 % @verbatiminclude FILE - insert text of file in verbatim environment.
7597 %
7598 \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
7599 %
7600 \def\doverbatiminclude#1{%
7601   {%
7602     \makevalueexpandable
7603     \setupverbatim
7604     \indexnofonts       % Allow `@@' and other weird things in file names.
7605     \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
7606     \input #1
7607     \afterenvbreak
7608   }%
7609 }
7610
7611 % @copying ... @end copying.
7612 % Save the text away for @insertcopying later.
7613 %
7614 % We save the uninterpreted tokens, rather than creating a box.
7615 % Saving the text in a box would be much easier, but then all the
7616 % typesetting commands (@smallbook, font changes, etc.) have to be done
7617 % beforehand -- and a) we want @copying to be done first in the source
7618 % file; b) letting users define the frontmatter in as flexible order as
7619 % possible is desirable.
7620 %
7621 \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
7622 \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
7623 %
7624 \def\insertcopying{%
7625   \begingroup
7626     \parindent = 0pt  % paragraph indentation looks wrong on title page
7627     \scanexp\copyingtext
7628   \endgroup
7629 }
7630
7631
7632 \message{defuns,}
7633 % @defun etc.
7634
7635 \newskip\defbodyindent \defbodyindent=.4in
7636 \newskip\defargsindent \defargsindent=50pt
7637 \newskip\deflastargmargin \deflastargmargin=18pt
7638 \newcount\defunpenalty
7639
7640 % Start the processing of @deffn:
7641 \def\startdefun{%
7642   \ifnum\lastpenalty<10000
7643     \medbreak
7644     \defunpenalty=10003 % Will keep this @deffn together with the
7645                         % following @def command, see below.
7646   \else
7647     % If there are two @def commands in a row, we'll have a \nobreak,
7648     % which is there to keep the function description together with its
7649     % header.  But if there's nothing but headers, we need to allow a
7650     % break somewhere.  Check specifically for penalty 10002, inserted
7651     % by \printdefunline, instead of 10000, since the sectioning
7652     % commands also insert a nobreak penalty, and we don't want to allow
7653     % a break between a section heading and a defun.
7654     %
7655     % As a further refinement, we avoid "club" headers by signalling
7656     % with penalty of 10003 after the very first @deffn in the
7657     % sequence (see above), and penalty of 10002 after any following
7658     % @def command.
7659     \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
7660     %
7661     % Similarly, after a section heading, do not allow a break.
7662     % But do insert the glue.
7663     \medskip  % preceded by discardable penalty, so not a breakpoint
7664   \fi
7665   %
7666   \parindent=0in
7667   \advance\leftskip by \defbodyindent
7668   \exdentamount=\defbodyindent
7669 }
7670
7671 \def\dodefunx#1{%
7672   % First, check whether we are in the right environment:
7673   \checkenv#1%
7674   %
7675   % As above, allow line break if we have multiple x headers in a row.
7676   % It's not a great place, though.
7677   \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
7678   %
7679   % And now, it's time to reuse the body of the original defun:
7680   \expandafter\gobbledefun#1%
7681 }
7682 \def\gobbledefun#1\startdefun{}
7683
7684 % \printdefunline \deffnheader{text}
7685 %
7686 \def\printdefunline#1#2{%
7687   \begingroup
7688     % call \deffnheader:
7689     #1#2 \endheader
7690     % common ending:
7691     \interlinepenalty = 10000
7692     \advance\rightskip by 0pt plus 1fil\relax
7693     \endgraf
7694     \nobreak\vskip -\parskip
7695     \penalty\defunpenalty  % signal to \startdefun and \dodefunx
7696     % Some of the @defun-type tags do not enable magic parentheses,
7697     % rendering the following check redundant.  But we don't optimize.
7698     \checkparencounts
7699   \endgroup
7700 }
7701
7702 \def\Edefun{\endgraf\medbreak}
7703
7704 % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
7705 % the only thing remaining is to define \deffnheader.
7706 %
7707 \def\makedefun#1{%
7708   \expandafter\let\csname E#1\endcsname = \Edefun
7709   \edef\temp{\noexpand\domakedefun
7710     \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7711   \temp
7712 }
7713
7714 % \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
7715 %
7716 % Define \deffn and \deffnx, without parameters.
7717 % \deffnheader has to be defined explicitly.
7718 %
7719 \def\domakedefun#1#2#3{%
7720   \envdef#1{%
7721     \startdefun
7722     \doingtypefnfalse    % distinguish typed functions from all else
7723     \parseargusing\activeparens{\printdefunline#3}%
7724   }%
7725   \def#2{\dodefunx#1}%
7726   \def#3%
7727 }
7728
7729 \newif\ifdoingtypefn       % doing typed function?
7730 \newif\ifrettypeownline    % typeset return type on its own line?
7731
7732 % @deftypefnnewline on|off says whether the return type of typed functions
7733 % are printed on their own line.  This affects @deftypefn, @deftypefun,
7734 % @deftypeop, and @deftypemethod.
7735
7736 \parseargdef\deftypefnnewline{%
7737   \def\temp{#1}%
7738   \ifx\temp\onword
7739     \expandafter\let\csname SETtxideftypefnnl\endcsname
7740       = \empty
7741   \else\ifx\temp\offword
7742     \expandafter\let\csname SETtxideftypefnnl\endcsname
7743       = \relax
7744   \else
7745     \errhelp = \EMsimple
7746     \errmessage{Unknown @txideftypefnnl value `\temp',
7747                 must be on|off}%
7748   \fi\fi
7749 }
7750
7751 % Untyped functions:
7752
7753 % @deffn category name args
7754 \makedefun{deffn}{\deffngeneral{}}
7755
7756 % @deffn category class name args
7757 \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
7758
7759 % \defopon {category on}class name args
7760 \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7761
7762 % \deffngeneral {subind}category name args
7763 %
7764 \def\deffngeneral#1#2 #3 #4\endheader{%
7765   % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
7766   \dosubind{fn}{\code{#3}}{#1}%
7767   \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
7768 }
7769
7770 % Typed functions:
7771
7772 % @deftypefn category type name args
7773 \makedefun{deftypefn}{\deftypefngeneral{}}
7774
7775 % @deftypeop category class type name args
7776 \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
7777
7778 % \deftypeopon {category on}class type name args
7779 \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7780
7781 % \deftypefngeneral {subind}category type name args
7782 %
7783 \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
7784   \dosubind{fn}{\code{#4}}{#1}%
7785   \doingtypefntrue
7786   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7787 }
7788
7789 % Typed variables:
7790
7791 % @deftypevr category type var args
7792 \makedefun{deftypevr}{\deftypecvgeneral{}}
7793
7794 % @deftypecv category class type var args
7795 \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
7796
7797 % \deftypecvof {category of}class type var args
7798 \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
7799
7800 % \deftypecvgeneral {subind}category type var args
7801 %
7802 \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
7803   \dosubind{vr}{\code{#4}}{#1}%
7804   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7805 }
7806
7807 % Untyped variables:
7808
7809 % @defvr category var args
7810 \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
7811
7812 % @defcv category class var args
7813 \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
7814
7815 % \defcvof {category of}class var args
7816 \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
7817
7818 % Types:
7819
7820 % @deftp category name args
7821 \makedefun{deftp}#1 #2 #3\endheader{%
7822   \doind{tp}{\code{#2}}%
7823   \defname{#1}{}{#2}\defunargs{#3\unskip}%
7824 }
7825
7826 % Remaining @defun-like shortcuts:
7827 \makedefun{defun}{\deffnheader{\putwordDeffunc} }
7828 \makedefun{defmac}{\deffnheader{\putwordDefmac} }
7829 \makedefun{defspec}{\deffnheader{\putwordDefspec} }
7830 \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7831 \makedefun{defvar}{\defvrheader{\putwordDefvar} }
7832 \makedefun{defopt}{\defvrheader{\putwordDefopt} }
7833 \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
7834 \makedefun{defmethod}{\defopon\putwordMethodon}
7835 \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
7836 \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
7837 \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
7838
7839 % \defname, which formats the name of the @def (not the args).
7840 % #1 is the category, such as "Function".
7841 % #2 is the return type, if any.
7842 % #3 is the function name.
7843 %
7844 % We are followed by (but not passed) the arguments, if any.
7845 %
7846 \def\defname#1#2#3{%
7847   \par
7848   % Get the values of \leftskip and \rightskip as they were outside the @def...
7849   \advance\leftskip by -\defbodyindent
7850   %
7851   % Determine if we are typesetting the return type of a typed function
7852   % on a line by itself.
7853   \rettypeownlinefalse
7854   \ifdoingtypefn  % doing a typed function specifically?
7855     % then check user option for putting return type on its own line:
7856     \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
7857       \rettypeownlinetrue
7858     \fi
7859   \fi
7860   %
7861   % How we'll format the category name.  Putting it in brackets helps
7862   % distinguish it from the body text that may end up on the next line
7863   % just below it.
7864   \def\temp{#1}%
7865   \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7866   %
7867   % Figure out line sizes for the paragraph shape.  We'll always have at
7868   % least two.
7869   \tempnum = 2
7870   %
7871   % The first line needs space for \box0; but if \rightskip is nonzero,
7872   % we need only space for the part of \box0 which exceeds it:
7873   \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
7874   %
7875   % If doing a return type on its own line, we'll have another line.
7876   \ifrettypeownline
7877     \advance\tempnum by 1
7878     \def\maybeshapeline{0in \hsize}%
7879   \else
7880     \def\maybeshapeline{}%
7881   \fi
7882   %
7883   % The continuations:
7884   \dimen2=\hsize  \advance\dimen2 by -\defargsindent
7885   %
7886   % The final paragraph shape:
7887   \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
7888   %
7889   % Put the category name at the right margin.
7890   \noindent
7891   \hbox to 0pt{%
7892     \hfil\box0 \kern-\hsize
7893     % \hsize has to be shortened this way:
7894     \kern\leftskip
7895     % Intentionally do not respect \rightskip, since we need the space.
7896   }%
7897   %
7898   % Allow all lines to be underfull without complaint:
7899   \tolerance=10000 \hbadness=10000
7900   \exdentamount=\defbodyindent
7901   {%
7902     % defun fonts. We use typewriter by default (used to be bold) because:
7903     % . we're printing identifiers, they should be in tt in principle.
7904     % . in languages with many accents, such as Czech or French, it's
7905     %   common to leave accents off identifiers.  The result looks ok in
7906     %   tt, but exceedingly strange in rm.
7907     % . we don't want -- and --- to be treated as ligatures.
7908     % . this still does not fix the ?` and !` ligatures, but so far no
7909     %   one has made identifiers using them :).
7910     \df \tt
7911     \def\temp{#2}% text of the return type
7912     \ifx\temp\empty\else
7913       \tclose{\temp}% typeset the return type
7914       \ifrettypeownline
7915         % put return type on its own line; prohibit line break following:
7916         \hfil\vadjust{\nobreak}\break  
7917       \else
7918         \space  % type on same line, so just followed by a space
7919       \fi
7920     \fi           % no return type
7921     #3% output function name
7922   }%
7923   {\rm\enskip}% hskip 0.5 em of \rmfont
7924   %
7925   \boldbrax
7926   % arguments will be output next, if any.
7927 }
7928
7929 % Print arguments in slanted roman (not ttsl), inconsistently with using
7930 % tt for the name.  This is because literal text is sometimes needed in
7931 % the argument list (groff manual), and ttsl and tt are not very
7932 % distinguishable.  Prevent hyphenation at `-' chars.
7933 %
7934 \def\defunargs#1{%
7935   % use sl by default (not ttsl),
7936   % tt for the names.
7937   \df \sl \hyphenchar\font=0
7938   %
7939   % On the other hand, if an argument has two dashes (for instance), we
7940   % want a way to get ttsl.  We used to recommend @var for that, so
7941   % leave the code in, but it's strange for @var to lead to typewriter.
7942   % Nowadays we recommend @code, since the difference between a ttsl hyphen
7943   % and a tt hyphen is pretty tiny.  @code also disables ?` !`.
7944   \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
7945   #1%
7946   \sl\hyphenchar\font=45
7947 }
7948
7949 % We want ()&[] to print specially on the defun line.
7950 %
7951 \def\activeparens{%
7952   \catcode`\(=\active \catcode`\)=\active
7953   \catcode`\[=\active \catcode`\]=\active
7954   \catcode`\&=\active
7955 }
7956
7957 % Make control sequences which act like normal parenthesis chars.
7958 \let\lparen = ( \let\rparen = )
7959
7960 % Be sure that we always have a definition for `(', etc.  For example,
7961 % if the fn name has parens in it, \boldbrax will not be in effect yet,
7962 % so TeX would otherwise complain about undefined control sequence.
7963 {
7964   \activeparens
7965   \global\let(=\lparen \global\let)=\rparen
7966   \global\let[=\lbrack \global\let]=\rbrack
7967   \global\let& = \&
7968
7969   \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
7970   \gdef\magicamp{\let&=\amprm}
7971 }
7972
7973 \newcount\parencount
7974
7975 % If we encounter &foo, then turn on ()-hacking afterwards
7976 \newif\ifampseen
7977 \def\amprm#1 {\ampseentrue{\bf\&#1 }}
7978
7979 \def\parenfont{%
7980   \ifampseen
7981     % At the first level, print parens in roman,
7982     % otherwise use the default font.
7983     \ifnum \parencount=1 \rm \fi
7984   \else
7985     % The \sf parens (in \boldbrax) actually are a little bolder than
7986     % the contained text.  This is especially needed for [ and ] .
7987     \sf
7988   \fi
7989 }
7990 \def\infirstlevel#1{%
7991   \ifampseen
7992     \ifnum\parencount=1
7993       #1%
7994     \fi
7995   \fi
7996 }
7997 \def\bfafterword#1 {#1 \bf}
7998
7999 \def\opnr{%
8000   \global\advance\parencount by 1
8001   {\parenfont(}%
8002   \infirstlevel \bfafterword
8003 }
8004 \def\clnr{%
8005   {\parenfont)}%
8006   \infirstlevel \sl
8007   \global\advance\parencount by -1
8008 }
8009
8010 \newcount\brackcount
8011 \def\lbrb{%
8012   \global\advance\brackcount by 1
8013   {\bf[}%
8014 }
8015 \def\rbrb{%
8016   {\bf]}%
8017   \global\advance\brackcount by -1
8018 }
8019
8020 \def\checkparencounts{%
8021   \ifnum\parencount=0 \else \badparencount \fi
8022   \ifnum\brackcount=0 \else \badbrackcount \fi
8023 }
8024 % these should not use \errmessage; the glibc manual, at least, actually
8025 % has such constructs (when documenting function pointers).
8026 \def\badparencount{%
8027   \message{Warning: unbalanced parentheses in @def...}%
8028   \global\parencount=0
8029 }
8030 \def\badbrackcount{%
8031   \message{Warning: unbalanced square brackets in @def...}%
8032   \global\brackcount=0
8033 }
8034
8035
8036 \message{macros,}
8037 % @macro.
8038
8039 % To do this right we need a feature of e-TeX, \scantokens,
8040 % which we arrange to emulate with a temporary file in ordinary TeX.
8041 \ifx\eTeXversion\thisisundefined
8042   \newwrite\macscribble
8043   \def\scantokens#1{%
8044     \toks0={#1}%
8045     \immediate\openout\macscribble=\jobname.tmp
8046     \immediate\write\macscribble{\the\toks0}%
8047     \immediate\closeout\macscribble
8048     \input \jobname.tmp
8049   }
8050 \fi
8051
8052 \let\aftermacroxxx\relax
8053 \def\aftermacro{\aftermacroxxx}
8054
8055 % alias because \c means cedilla in @tex or @math
8056 \let\texinfoc=\c
8057
8058 \newcount\savedcatcodeone
8059 \newcount\savedcatcodetwo
8060
8061 % Used at the time of macro expansion.
8062 % Argument is macro body with arguments substituted
8063 \def\scanmacro#1{%
8064   \newlinechar`\^^M
8065   \def\xeatspaces{\eatspaces}%
8066   %
8067   % Temporarily undo catcode changes of \printindex.  Set catcode of @ to
8068   % 0 so that @-commands in macro expansions aren't printed literally when 
8069   % formatting an index file, where \ is used as the escape character.
8070   \savedcatcodeone=\catcode`\@
8071   \savedcatcodetwo=\catcode`\\
8072   \catcode`\@=0
8073   \catcode`\\=\active
8074   %
8075   % Process the macro body under the current catcode regime.
8076   \scantokens{#1@texinfoc}\aftermacro%
8077   %
8078   \catcode`\@=\savedcatcodeone
8079   \catcode`\\=\savedcatcodetwo
8080   %
8081   % The \texinfoc is to remove the \newlinechar added by \scantokens, and
8082   % can be noticed by \parsearg.
8083   %   The \aftermacro allows a \comment at the end of the macro definition
8084   % to duplicate itself past the final \newlinechar added by \scantokens:
8085   % this is used in the definition of \group to comment out a newline.  We
8086   % don't do the same for \c to support Texinfo files with macros that ended
8087   % with a @c, which should no longer be necessary.
8088   %   We avoid surrounding the call to \scantokens with \bgroup and \egroup
8089   % to allow macros to open or close groups themselves.
8090 }
8091
8092 % Used for copying and captions
8093 \def\scanexp#1{%
8094   \expandafter\scanmacro\expandafter{#1}%
8095 }
8096
8097 \newcount\paramno   % Count of parameters
8098 \newtoks\macname    % Macro name
8099 \newif\ifrecursive  % Is it recursive?
8100
8101 % List of all defined macros in the form
8102 %    \commondummyword\macro1\commondummyword\macro2...
8103 % Currently is also contains all @aliases; the list can be split
8104 % if there is a need.
8105 \def\macrolist{}
8106
8107 % Add the macro to \macrolist
8108 \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
8109 \def\addtomacrolistxxx#1{%
8110      \toks0 = \expandafter{\macrolist\commondummyword#1}%
8111      \xdef\macrolist{\the\toks0}%
8112 }
8113
8114 % Utility routines.
8115 % This does \let #1 = #2, with \csnames; that is,
8116 %   \let \csname#1\endcsname = \csname#2\endcsname
8117 % (except of course we have to play expansion games).
8118 %
8119 \def\cslet#1#2{%
8120   \expandafter\let
8121   \csname#1\expandafter\endcsname
8122   \csname#2\endcsname
8123 }
8124
8125 % Trim leading and trailing spaces off a string.
8126 % Concepts from aro-bend problem 15 (see CTAN).
8127 {\catcode`\@=11
8128 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
8129 \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
8130 \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
8131 \def\unbrace#1{#1}
8132 \unbrace{\gdef\trim@@@ #1 } #2@{#1}
8133 }
8134
8135 % Trim a single trailing ^^M off a string.
8136 {\catcode`\^^M=\other \catcode`\Q=3%
8137 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
8138 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
8139 \gdef\eatcrb#1Q#2Q{#1}%
8140 }
8141
8142 % Macro bodies are absorbed as an argument in a context where
8143 % all characters are catcode 10, 11 or 12, except \ which is active
8144 % (as in normal texinfo). It is necessary to change the definition of \
8145 % to recognize macro arguments; this is the job of \mbodybackslash.
8146 %
8147 % Non-ASCII encodings make 8-bit characters active, so un-activate
8148 % them to avoid their expansion.  Must do this non-globally, to
8149 % confine the change to the current group.
8150 %
8151 % It's necessary to have hard CRs when the macro is executed. This is
8152 % done by making ^^M (\endlinechar) catcode 12 when reading the macro
8153 % body, and then making it the \newlinechar in \scanmacro.
8154 %
8155 \def\scanctxt{% used as subroutine
8156   \catcode`\"=\other
8157   \catcode`\+=\other
8158   \catcode`\<=\other
8159   \catcode`\>=\other
8160   \catcode`\^=\other
8161   \catcode`\_=\other
8162   \catcode`\|=\other
8163   \catcode`\~=\other
8164   \passthroughcharstrue
8165 }
8166
8167 \def\scanargctxt{% used for copying and captions, not macros.
8168   \scanctxt
8169   \catcode`\@=\other
8170   \catcode`\\=\other
8171   \catcode`\^^M=\other
8172 }
8173
8174 \def\macrobodyctxt{% used for @macro definitions
8175   \scanctxt
8176   \catcode`\ =\other
8177   \catcode`\@=\other
8178   \catcode`\{=\other
8179   \catcode`\}=\other
8180   \catcode`\^^M=\other
8181   \usembodybackslash
8182 }
8183
8184 % Used when scanning braced macro arguments.  Note, however, that catcode
8185 % changes here are ineffectual if the macro invocation was nested inside
8186 % an argument to another Texinfo command.
8187 \def\macroargctxt{%
8188   \scanctxt
8189   \catcode`\ =\active
8190   \catcode`\^^M=\other
8191   \catcode`\\=\active
8192 }
8193
8194 \def\macrolineargctxt{% used for whole-line arguments without braces
8195   \scanctxt
8196   \catcode`\{=\other
8197   \catcode`\}=\other
8198 }
8199
8200 % \mbodybackslash is the definition of \ in @macro bodies.
8201 % It maps \foo\ => \csname macarg.foo\endcsname => #N
8202 % where N is the macro parameter number.
8203 % We define \csname macarg.\endcsname to be \realbackslash, so
8204 % \\ in macro replacement text gets you a backslash.
8205 %
8206 {\catcode`@=0 @catcode`@\=@active
8207  @gdef@usembodybackslash{@let\=@mbodybackslash}
8208  @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
8209 }
8210 \expandafter\def\csname macarg.\endcsname{\realbackslash}
8211
8212 \def\margbackslash#1{\char`\#1 }
8213
8214 \def\macro{\recursivefalse\parsearg\macroxxx}
8215 \def\rmacro{\recursivetrue\parsearg\macroxxx}
8216
8217 \def\macroxxx#1{%
8218   \getargs{#1}% now \macname is the macname and \argl the arglist
8219   \ifx\argl\empty       % no arguments
8220      \paramno=0\relax
8221   \else
8222      \expandafter\parsemargdef \argl;%
8223      \if\paramno>256\relax
8224        \ifx\eTeXversion\thisisundefined
8225          \errhelp = \EMsimple
8226          \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
8227        \fi
8228      \fi
8229   \fi
8230   \if1\csname ismacro.\the\macname\endcsname
8231      \message{Warning: redefining \the\macname}%
8232   \else
8233      \expandafter\ifx\csname \the\macname\endcsname \relax
8234      \else \errmessage{Macro name \the\macname\space already defined}\fi
8235      \global\cslet{macsave.\the\macname}{\the\macname}%
8236      \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
8237      \addtomacrolist{\the\macname}%
8238   \fi
8239   \begingroup \macrobodyctxt
8240   \ifrecursive \expandafter\parsermacbody
8241   \else \expandafter\parsemacbody
8242   \fi}
8243
8244 \parseargdef\unmacro{%
8245   \if1\csname ismacro.#1\endcsname
8246     \global\cslet{#1}{macsave.#1}%
8247     \global\expandafter\let \csname ismacro.#1\endcsname=0%
8248     % Remove the macro name from \macrolist:
8249     \begingroup
8250       \expandafter\let\csname#1\endcsname \relax
8251       \let\commondummyword\unmacrodo
8252       \xdef\macrolist{\macrolist}%
8253     \endgroup
8254   \else
8255     \errmessage{Macro #1 not defined}%
8256   \fi
8257 }
8258
8259 % Called by \do from \dounmacro on each macro.  The idea is to omit any
8260 % macro definitions that have been changed to \relax.
8261 %
8262 \def\unmacrodo#1{%
8263   \ifx #1\relax
8264     % remove this
8265   \else
8266     \noexpand\commondummyword \noexpand#1%
8267   \fi
8268 }
8269
8270 % \getargs -- Parse the arguments to a @macro line.  Set \macname to
8271 % the name of the macro, and \argl to the braced argument list.
8272 \def\getargs#1{\getargsxxx#1{}}
8273 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
8274 \def\getmacname#1 #2\relax{\macname={#1}}
8275 \def\getmacargs#1{\def\argl{#1}}
8276 % This made use of the feature that if the last token of a
8277 % <parameter list> is #, then the preceding argument is delimited by
8278 % an opening brace, and that opening brace is not consumed.
8279
8280 % Parse the optional {params} list to @macro or @rmacro.
8281 % Set \paramno to the number of arguments,
8282 % and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
8283 % three-param macro.)  Define \macarg.BLAH for each BLAH in the params
8284 % list to some hook where the argument is to be expanded.  If there are
8285 % less than 10 arguments that hook is to be replaced by ##N where N
8286 % is the position in that list, that is to say the macro arguments are to be
8287 % defined `a la TeX in the macro body.  
8288 %
8289 % That gets used by \mbodybackslash (above).
8290 %
8291 % If there are 10 or more arguments, a different technique is used: see
8292 % \parsemmanyargdef.
8293 %
8294 \def\parsemargdef#1;{%
8295   \paramno=0\def\paramlist{}%
8296   \let\hash\relax
8297   % \hash is redefined to `#' later to get it into definitions
8298   \let\xeatspaces\relax
8299   \parsemargdefxxx#1,;,%
8300   \ifnum\paramno<10\relax\else
8301     \paramno0\relax
8302     \parsemmanyargdef@@#1,;,% 10 or more arguments
8303   \fi
8304 }
8305 \def\parsemargdefxxx#1,{%
8306   \if#1;\let\next=\relax
8307   \else \let\next=\parsemargdefxxx
8308     \advance\paramno by 1
8309     \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
8310         {\xeatspaces{\hash\the\paramno}}%
8311     \edef\paramlist{\paramlist\hash\the\paramno,}%
8312   \fi\next}
8313
8314 % \parsemacbody, \parsermacbody
8315 %
8316 % Read recursive and nonrecursive macro bodies. (They're different since
8317 % rec and nonrec macros end differently.)
8318
8319 % We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro 
8320 % body to be transformed.
8321 % Set \macrobody to the body of the macro, and call \defmacro.
8322 %
8323 {\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{%
8324 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8325 {\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
8326 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8327
8328 % Make @ a letter, so that we can make private-to-Texinfo macro names.
8329 \edef\texiatcatcode{\the\catcode`\@}
8330 \catcode `@=11\relax
8331
8332 %%%%%%%%%%%%%% Code for > 10 arguments only   %%%%%%%%%%%%%%%%%%
8333
8334 % If there are 10 or more arguments, a different technique is used, where the
8335 % hook remains in the body, and when macro is to be expanded the body is
8336 % processed again to replace the arguments.
8337 %
8338 % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
8339 % argument N value and then \edef the body (nothing else will expand because of
8340 % the catcode regime under which the body was input).
8341 %
8342 % If you compile with TeX (not eTeX), and you have macros with 10 or more
8343 % arguments, no macro can have more than 256 arguments (else error).
8344 %
8345 % In case that there are 10 or more arguments we parse again the arguments
8346 % list to set new definitions for the \macarg.BLAH macros corresponding to
8347 % each BLAH argument. It was anyhow needed to parse already once this list
8348 % in order to count the arguments, and as macros with at most 9 arguments
8349 % are by far more frequent than macro with 10 or more arguments, defining
8350 % twice the \macarg.BLAH macros does not cost too much processing power.
8351 \def\parsemmanyargdef@@#1,{%
8352   \if#1;\let\next=\relax
8353   \else 
8354     \let\next=\parsemmanyargdef@@
8355     \edef\tempb{\eatspaces{#1}}%
8356     \expandafter\def\expandafter\tempa
8357        \expandafter{\csname macarg.\tempb\endcsname}%
8358     % Note that we need some extra \noexpand\noexpand, this is because we
8359     % don't want \the  to be expanded in the \parsermacbody  as it uses an
8360     % \xdef .
8361     \expandafter\edef\tempa
8362       {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
8363     \advance\paramno by 1\relax
8364   \fi\next}
8365
8366
8367 \let\endargs@\relax
8368 \let\nil@\relax
8369 \def\nilm@{\nil@}%
8370 \long\def\nillm@{\nil@}%
8371
8372 % This macro is expanded during the Texinfo macro expansion, not during its
8373 % definition.  It gets all the arguments' values and assigns them to macros
8374 % macarg.ARGNAME
8375 %
8376 % #1 is the macro name
8377 % #2 is the list of argument names
8378 % #3 is the list of argument values
8379 \def\getargvals@#1#2#3{%
8380   \def\macargdeflist@{}%
8381   \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
8382   \def\paramlist{#2,\nil@}%
8383   \def\macroname{#1}%
8384   \begingroup
8385   \macroargctxt
8386   \def\argvaluelist{#3,\nil@}%
8387   \def\@tempa{#3}%
8388   \ifx\@tempa\empty
8389     \setemptyargvalues@
8390   \else
8391     \getargvals@@
8392   \fi
8393 }
8394 \def\getargvals@@{%
8395   \ifx\paramlist\nilm@
8396       % Some sanity check needed here that \argvaluelist is also empty.
8397       \ifx\argvaluelist\nillm@
8398       \else
8399         \errhelp = \EMsimple
8400         \errmessage{Too many arguments in macro `\macroname'!}%
8401       \fi
8402       \let\next\macargexpandinbody@
8403   \else
8404     \ifx\argvaluelist\nillm@
8405        % No more arguments values passed to macro.  Set remaining named-arg
8406        % macros to empty.
8407        \let\next\setemptyargvalues@
8408     \else
8409       % pop current arg name into \@tempb
8410       \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
8411       \expandafter\@tempa\expandafter{\paramlist}%
8412        % pop current argument value into \@tempc
8413       \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
8414       \expandafter\@tempa\expandafter{\argvaluelist}%
8415        % Here \@tempb is the current arg name and \@tempc is the current arg value.
8416        % First place the new argument macro definition into \@tempd
8417        \expandafter\macname\expandafter{\@tempc}%
8418        \expandafter\let\csname macarg.\@tempb\endcsname\relax
8419        \expandafter\def\expandafter\@tempe\expandafter{%
8420          \csname macarg.\@tempb\endcsname}%
8421        \edef\@tempd{\long\def\@tempe{\the\macname}}%
8422        \push@\@tempd\macargdeflist@
8423        \let\next\getargvals@@
8424     \fi
8425   \fi
8426   \next
8427 }
8428
8429 \def\push@#1#2{%
8430   \expandafter\expandafter\expandafter\def
8431   \expandafter\expandafter\expandafter#2%
8432   \expandafter\expandafter\expandafter{%
8433   \expandafter#1#2}%
8434 }
8435
8436 % Replace arguments by their values in the macro body, and place the result
8437 % in macro \@tempa.
8438
8439 \def\macvalstoargs@{%
8440   %  To do this we use the property that token registers that are \the'ed
8441   % within an \edef  expand only once. So we are going to place all argument
8442   % values into respective token registers.
8443   %
8444   % First we save the token context, and initialize argument numbering.
8445   \begingroup
8446     \paramno0\relax
8447     % Then, for each argument number #N, we place the corresponding argument
8448     % value into a new token list register \toks#N
8449     \expandafter\putargsintokens@\saveparamlist@,;,%
8450     % Then, we expand the body so that argument are replaced by their
8451     % values. The trick for values not to be expanded themselves is that they
8452     % are within tokens and that tokens expand only once in an \edef .
8453     \edef\@tempc{\csname mac.\macroname .body\endcsname}%
8454     % Now we restore the token stack pointer to free the token list registers
8455     % which we have used, but we make sure that expanded body is saved after
8456     % group.
8457     \expandafter
8458   \endgroup
8459   \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
8460   }
8461
8462 % Define the named-macro outside of this group and then close this group. 
8463
8464 \def\macargexpandinbody@{% 
8465   \expandafter
8466   \endgroup
8467   \macargdeflist@
8468   % First the replace in body the macro arguments by their values, the result
8469   % is in \@tempa .
8470   \macvalstoargs@
8471   % Then we point at the \norecurse or \gobble (for recursive) macro value
8472   % with \@tempb .
8473   \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
8474   % Depending on whether it is recursive or not, we need some tailing
8475   % \egroup .
8476   \ifx\@tempb\gobble
8477      \let\@tempc\relax
8478   \else
8479      \let\@tempc\egroup
8480   \fi
8481   % And now we do the real job:
8482   \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
8483   \@tempd
8484 }
8485
8486 \def\putargsintokens@#1,{%
8487   \if#1;\let\next\relax
8488   \else
8489     \let\next\putargsintokens@
8490     % First we allocate the new token list register, and give it a temporary
8491     % alias \@tempb .
8492     \toksdef\@tempb\the\paramno
8493     % Then we place the argument value into that token list register.
8494     \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
8495     \expandafter\@tempb\expandafter{\@tempa}%
8496     \advance\paramno by 1\relax
8497   \fi
8498   \next
8499 }
8500
8501 % Trailing missing arguments are set to empty.
8502
8503 \def\setemptyargvalues@{%
8504   \ifx\paramlist\nilm@
8505     \let\next\macargexpandinbody@
8506   \else
8507     \expandafter\setemptyargvaluesparser@\paramlist\endargs@
8508     \let\next\setemptyargvalues@
8509   \fi
8510   \next
8511 }
8512
8513 \def\setemptyargvaluesparser@#1,#2\endargs@{%
8514   \expandafter\def\expandafter\@tempa\expandafter{%
8515     \expandafter\def\csname macarg.#1\endcsname{}}%
8516   \push@\@tempa\macargdeflist@
8517   \def\paramlist{#2}%
8518 }
8519
8520 % #1 is the element target macro
8521 % #2 is the list macro
8522 % #3,#4\endargs@ is the list value
8523 \def\pop@#1#2#3,#4\endargs@{%
8524    \def#1{#3}%
8525    \def#2{#4}%
8526 }
8527 \long\def\longpop@#1#2#3,#4\endargs@{%
8528    \long\def#1{#3}%
8529    \long\def#2{#4}%
8530 }
8531
8532
8533 %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
8534
8535
8536 % This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
8537 %    \macrobody has the body of the macro in it, with placeholders for
8538 % its parameters, looking like "\xeatspaces{\hash 1}".
8539 %    \paramno is the number of parameters
8540 %    \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
8541 % There are four cases: macros of zero, one, up to nine, and many arguments.
8542 % \xdef is used so that macro definitions will survive the file
8543 % they're defined in: @include reads the file inside a group.
8544 %
8545 \def\defmacro{%
8546   \let\hash=##% convert placeholders to macro parameter chars
8547   \ifnum\paramno=1
8548     \def\xeatspaces##1{##1}%
8549     % This removes the pair of braces around the argument.  We don't
8550     % use \eatspaces, because this can cause ends of lines to be lost
8551     % when the argument to \eatspaces is read, leading to line-based
8552     % commands like "@itemize" not being read correctly.
8553   \else
8554     \let\xeatspaces\relax % suppress expansion
8555   \fi
8556   \ifcase\paramno
8557   % 0
8558     \expandafter\xdef\csname\the\macname\endcsname{%
8559       \noexpand\scanmacro{\macrobody}}%
8560   \or % 1
8561     \expandafter\xdef\csname\the\macname\endcsname{%
8562        \bgroup
8563        \noexpand\braceorline
8564        \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8565     \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8566       \egroup
8567       \noexpand\scanmacro{\macrobody}%
8568       }%
8569   \else % at most 9
8570     \ifnum\paramno<10\relax
8571       % @MACNAME sets the context for reading the macro argument
8572       % @MACNAME@@ gets the argument, processes backslashes and appends a 
8573       % comma.
8574       % @MACNAME@@@ removes braces surrounding the argument list.
8575       % @MACNAME@@@@ scans the macro body with arguments substituted.
8576       \expandafter\xdef\csname\the\macname\endcsname{%
8577         \bgroup
8578         \noexpand\expandafter  % This \expandafter skip any spaces after the
8579         \noexpand\macroargctxt % macro before we change the catcode of space.
8580         \noexpand\expandafter
8581         \expandafter\noexpand\csname\the\macname @@\endcsname}%
8582       \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8583           \noexpand\passargtomacro
8584           \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8585       \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8586           \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8587       \expandafter\expandafter
8588       \expandafter\xdef
8589       \expandafter\expandafter
8590         \csname\the\macname @@@@\endcsname\paramlist{%
8591           \egroup\noexpand\scanmacro{\macrobody}}%
8592     \else % 10 or more:
8593       \expandafter\xdef\csname\the\macname\endcsname{%
8594         \noexpand\getargvals@{\the\macname}{\argl}%
8595       }%
8596       \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8597       \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
8598     \fi
8599   \fi}
8600
8601 \catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
8602
8603 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
8604
8605
8606 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8607 %
8608 {\catcode`\@=0 \catcode`\\=13  % We need to manipulate \ so use @ as escape
8609 @catcode`@_=11  % private names
8610 @catcode`@!=11  % used as argument separator
8611
8612 % \passargtomacro#1#2 -
8613 % Call #1 with a list of tokens #2, with any doubled backslashes in #2
8614 % compressed to one.
8615 %
8616 % This implementation works by expansion, and not execution (so we cannot use 
8617 % \def or similar).  This reduces the risk of this failing in contexts where 
8618 % complete expansion is done with no execution (for example, in writing out to 
8619 % an auxiliary file for an index entry).
8620
8621 % State is kept in the input stream: the argument passed to
8622 % @look_ahead, @gobble_and_check_finish and @add_segment is
8623 %
8624 % THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN  (... rest of input)
8625 %
8626 % where:
8627 % THE_MACRO - name of the macro we want to call
8628 % ARG_RESULT - argument list we build to pass to that macro
8629 % PENDING_BS - either a backslash or nothing
8630 % NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
8631
8632 @gdef@passargtomacro#1#2{%
8633   @add_segment #1!{}@relax#2\@_finish\%
8634 }
8635 @gdef@_finish{@_finishx} @global@let@_finishx@relax
8636
8637 % #1 - THE_MACRO ARG_RESULT
8638 % #2 - PENDING_BS
8639 % #3 - NEXT_TOKEN
8640 % #4 used to look ahead
8641 %
8642 % If the next token is not a backslash, process the rest of the argument; 
8643 % otherwise, remove the next token.
8644 @gdef@look_ahead#1!#2#3#4{%
8645   @ifx#4\%
8646    @expandafter@gobble_and_check_finish 
8647   @else
8648    @expandafter@add_segment
8649   @fi#1!{#2}#4#4%
8650 }
8651
8652 % #1 - THE_MACRO ARG_RESULT
8653 % #2 - PENDING_BS
8654 % #3 - NEXT_TOKEN
8655 % #4 should be a backslash, which is gobbled.
8656 % #5 looks ahead
8657 %
8658 % Double backslash found.  Add a single backslash, and look ahead.
8659 @gdef@gobble_and_check_finish#1!#2#3#4#5{%
8660   @add_segment#1\!{}#5#5%
8661 }
8662
8663 @gdef@is_fi{@fi}
8664
8665 % #1 - THE_MACRO ARG_RESULT
8666 % #2 - PENDING_BS
8667 % #3 - NEXT_TOKEN
8668 % #4 is input stream until next backslash
8669 %
8670 % Input stream is either at the start of the argument, or just after a 
8671 % backslash sequence, either a lone backslash, or a doubled backslash.  
8672 % NEXT_TOKEN contains the first token in the input stream: if it is \finish, 
8673 % finish; otherwise, append to ARG_RESULT the segment of the argument up until
8674 % the next backslash.  PENDING_BACKSLASH contains a backslash to represent
8675 % a backslash just before the start of the input stream that has not been
8676 % added to ARG_RESULT.
8677 @gdef@add_segment#1!#2#3#4\{%
8678 @ifx#3@_finish
8679   @call_the_macro#1!%
8680 @else
8681   % append the pending backslash to the result, followed by the next segment
8682   @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
8683   % this @fi is discarded by @look_ahead.
8684   % we can't get rid of it with \expandafter because we don't know how 
8685   % long #4 is.
8686 }
8687
8688 % #1 - THE_MACRO
8689 % #2 - ARG_RESULT
8690 % #3 discards the res of the conditional in @add_segment, and @is_fi ends the 
8691 % conditional.
8692 @gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
8693
8694 }
8695 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8696
8697 % \braceorline MAC is used for a one-argument macro MAC.  It checks
8698 % whether the next non-whitespace character is a {.  It sets the context
8699 % for reading the argument (slightly different in the two cases).  Then,
8700 % to read the argument, in the whole-line case, it then calls the regular
8701 % \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
8702
8703 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
8704 \def\braceorlinexxx{%
8705   \ifx\nchar\bgroup
8706     \macroargctxt
8707     \expandafter\passargtomacro
8708   \else
8709     \macrolineargctxt\expandafter\parsearg
8710   \fi \macnamexxx}
8711
8712
8713 % @alias.
8714 % We need some trickery to remove the optional spaces around the equal
8715 % sign.  Make them active and then expand them all to nothing.
8716 %
8717 \def\alias{\parseargusing\obeyspaces\aliasxxx}
8718 \def\aliasxxx #1{\aliasyyy#1\relax}
8719 \def\aliasyyy #1=#2\relax{%
8720   {%
8721     \expandafter\let\obeyedspace=\empty
8722     \addtomacrolist{#1}%
8723     \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
8724   }%
8725   \next
8726 }
8727
8728
8729 \message{cross references,}
8730
8731 \newwrite\auxfile
8732 \newif\ifhavexrefs    % True if xref values are known.
8733 \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
8734
8735 % @inforef is relatively simple.
8736 \def\inforef #1{\inforefzzz #1,,,,**}
8737 \def\inforefzzz #1,#2,#3,#4**{%
8738   \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
8739   node \samp{\ignorespaces#1{}}}
8740
8741 % @node's only job in TeX is to define \lastnode, which is used in
8742 % cross-references.  The @node line might or might not have commas, and
8743 % might or might not have spaces before the first comma, like:
8744 % @node foo , bar , ...
8745 % We don't want such trailing spaces in the node name.
8746 %
8747 \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
8748 %
8749 % also remove a trailing comma, in case of something like this:
8750 % @node Help-Cross,  ,  , Cross-refs
8751 \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
8752 \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
8753
8754 \let\nwnode=\node
8755 \let\lastnode=\empty
8756
8757 % Write a cross-reference definition for the current node.  #1 is the
8758 % type (Ynumbered, Yappendix, Ynothing).
8759 %
8760 \def\donoderef#1{%
8761   \ifx\lastnode\empty\else
8762     \setref{\lastnode}{#1}%
8763     \global\let\lastnode=\empty
8764   \fi
8765 }
8766
8767 % @anchor{NAME} -- define xref target at arbitrary point.
8768 %
8769 \newcount\savesfregister
8770 %
8771 \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
8772 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
8773 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
8774
8775 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
8776 % anchor), which consists of three parts:
8777 % 1) NAME-title - the current sectioning name taken from \lastsection,
8778 %                 or the anchor name.
8779 % 2) NAME-snt   - section number and type, passed as the SNT arg, or
8780 %                 empty for anchors.
8781 % 3) NAME-pg    - the page number.
8782 %
8783 % This is called from \donoderef, \anchor, and \dofloat.  In the case of
8784 % floats, there is an additional part, which is not written here:
8785 % 4) NAME-lof   - the text as it should appear in a @listoffloats.
8786 %
8787 \def\setref#1#2{%
8788   \pdfmkdest{#1}%
8789   \iflinks
8790     {%
8791       \requireauxfile
8792       \atdummies  % preserve commands, but don't expand them
8793       % match definition in \xrdef, \refx, \xrefX.
8794       \def\value##1{##1}%
8795       \edef\writexrdef##1##2{%
8796         \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
8797           ##1}{##2}}% these are parameters of \writexrdef
8798       }%
8799       \toks0 = \expandafter{\lastsection}%
8800       \immediate \writexrdef{title}{\the\toks0 }%
8801       \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
8802       \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
8803     }%
8804   \fi
8805 }
8806
8807 % @xrefautosectiontitle on|off says whether @section(ing) names are used
8808 % automatically in xrefs, if the third arg is not explicitly specified.
8809 % This was provided as a "secret" @set xref-automatic-section-title
8810 % variable, now it's official.
8811
8812 \parseargdef\xrefautomaticsectiontitle{%
8813   \def\temp{#1}%
8814   \ifx\temp\onword
8815     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8816       = \empty
8817   \else\ifx\temp\offword
8818     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8819       = \relax
8820   \else
8821     \errhelp = \EMsimple
8822     \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
8823                 must be on|off}%
8824   \fi\fi
8825 }
8826
8827\f
8828 % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
8829 % the node name, #2 the name of the Info cross-reference, #3 the printed
8830 % node name, #4 the name of the Info file, #5 the name of the printed
8831 % manual.  All but the node name can be omitted.
8832 %
8833 \def\pxref{\putwordsee{} \xrefXX}
8834 \def\xref{\putwordSee{} \xrefXX}
8835 \def\ref{\xrefXX}
8836
8837 \def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
8838 \def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
8839 %
8840 \newbox\toprefbox
8841 \newbox\printedrefnamebox
8842 \newbox\infofilenamebox
8843 \newbox\printedmanualbox
8844 %
8845 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
8846   \unsepspaces
8847   %
8848   % Get args without leading/trailing spaces.
8849   \def\printedrefname{\ignorespaces #3}%
8850   \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
8851   %
8852   \def\infofilename{\ignorespaces #4}%
8853   \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
8854   %
8855   \def\printedmanual{\ignorespaces #5}%
8856   \setbox\printedmanualbox  = \hbox{\printedmanual\unskip}%
8857   %
8858   % If the printed reference name (arg #3) was not explicitly given in
8859   % the @xref, figure out what we want to use.
8860   \ifdim \wd\printedrefnamebox = 0pt
8861     % No printed node name was explicitly given.
8862     \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
8863       % Not auto section-title: use node name inside the square brackets.
8864       \def\printedrefname{\ignorespaces #1}%
8865     \else
8866       % Auto section-title: use chapter/section title inside
8867       % the square brackets if we have it.
8868       \ifdim \wd\printedmanualbox > 0pt
8869         % It is in another manual, so we don't have it; use node name.
8870         \def\printedrefname{\ignorespaces #1}%
8871       \else
8872         \ifhavexrefs
8873           % We (should) know the real title if we have the xref values.
8874           \def\printedrefname{\refx{#1-title}{}}%
8875         \else
8876           % Otherwise just copy the Info node name.
8877           \def\printedrefname{\ignorespaces #1}%
8878         \fi%
8879       \fi
8880     \fi
8881   \fi
8882   %
8883   % Make link in pdf output.
8884   \ifpdf
8885     % For pdfTeX and LuaTeX
8886     {\indexnofonts
8887      \makevalueexpandable
8888      \turnoffactive
8889      % This expands tokens, so do it after making catcode changes, so _
8890      % etc. don't get their TeX definitions.  This ignores all spaces in
8891      % #4, including (wrongly) those in the middle of the filename.
8892      \getfilename{#4}%
8893      %
8894      % This (wrongly) does not take account of leading or trailing
8895      % spaces in #1, which should be ignored.
8896      \setpdfdestname{#1}%
8897      %
8898      \ifx\pdfdestname\empty
8899        \def\pdfdestname{Top}% no empty targets
8900      \fi
8901      %
8902      \leavevmode
8903      \startlink attr{/Border [0 0 0]}%
8904      \ifnum\filenamelength>0
8905        goto file{\the\filename.pdf} name{\pdfdestname}%
8906      \else
8907        goto name{\pdfmkpgn{\pdfdestname}}%
8908      \fi
8909     }%
8910     \setcolor{\linkcolor}%
8911   \else
8912     \ifx\XeTeXrevision\thisisundefined
8913     \else
8914       % For XeTeX
8915       {\indexnofonts
8916        \makevalueexpandable
8917        \turnoffactive
8918        % This expands tokens, so do it after making catcode changes, so _
8919        % etc. don't get their TeX definitions.  This ignores all spaces in
8920        % #4, including (wrongly) those in the middle of the filename.
8921        \getfilename{#4}%
8922        %
8923        % This (wrongly) does not take account of leading or trailing
8924        % spaces in #1, which should be ignored.
8925        \setpdfdestname{#1}%
8926        %
8927        \ifx\pdfdestname\empty
8928          \def\pdfdestname{Top}% no empty targets
8929        \fi
8930        %
8931        \leavevmode
8932        \ifnum\filenamelength>0
8933          % With default settings,
8934          % XeTeX (xdvipdfmx) replaces link destination names with integers.
8935          % In this case, the replaced destination names of
8936          % remote PDFs are no longer known.  In order to avoid a replacement,
8937          % you can use xdvipdfmx's command line option `-C 0x0010'.
8938          % If you use XeTeX 0.99996+ (TeX Live 2016+),
8939          % this command line option is no longer necessary
8940          % because we can use the `dvipdfmx:config' special.
8941          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8942            << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}%
8943        \else
8944          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8945            << /S /GoTo /D (\pdfdestname) >> >>}%
8946        \fi
8947       }%
8948       \setcolor{\linkcolor}%
8949     \fi
8950   \fi
8951   {%
8952     % Have to otherify everything special to allow the \csname to
8953     % include an _ in the xref name, etc.
8954     \indexnofonts
8955     \turnoffactive
8956     \def\value##1{##1}%
8957     \expandafter\global\expandafter\let\expandafter\Xthisreftitle
8958       \csname XR#1-title\endcsname
8959   }%
8960   %
8961   % Float references are printed completely differently: "Figure 1.2"
8962   % instead of "[somenode], p.3".  \iffloat distinguishes them by
8963   % \Xthisreftitle being set to a magic string.
8964   \iffloat\Xthisreftitle
8965     % If the user specified the print name (third arg) to the ref,
8966     % print it instead of our usual "Figure 1.2".
8967     \ifdim\wd\printedrefnamebox = 0pt
8968       \refx{#1-snt}{}%
8969     \else
8970       \printedrefname
8971     \fi
8972     %
8973     % If the user also gave the printed manual name (fifth arg), append
8974     % "in MANUALNAME".
8975     \ifdim \wd\printedmanualbox > 0pt
8976       \space \putwordin{} \cite{\printedmanual}%
8977     \fi
8978   \else
8979     % node/anchor (non-float) references.
8980     % 
8981     % If we use \unhbox to print the node names, TeX does not insert
8982     % empty discretionaries after hyphens, which means that it will not
8983     % find a line break at a hyphen in a node names.  Since some manuals
8984     % are best written with fairly long node names, containing hyphens,
8985     % this is a loss.  Therefore, we give the text of the node name
8986     % again, so it is as if TeX is seeing it for the first time.
8987     % 
8988     \ifdim \wd\printedmanualbox > 0pt
8989       % Cross-manual reference with a printed manual name.
8990       % 
8991       \crossmanualxref{\cite{\printedmanual\unskip}}%
8992     %
8993     \else\ifdim \wd\infofilenamebox > 0pt
8994       % Cross-manual reference with only an info filename (arg 4), no
8995       % printed manual name (arg 5).  This is essentially the same as
8996       % the case above; we output the filename, since we have nothing else.
8997       % 
8998       \crossmanualxref{\code{\infofilename\unskip}}%
8999     %
9000     \else
9001       % Reference within this manual.
9002       %
9003       % _ (for example) has to be the character _ for the purposes of the
9004       % control sequence corresponding to the node, but it has to expand
9005       % into the usual \leavevmode...\vrule stuff for purposes of
9006       % printing. So we \turnoffactive for the \refx-snt, back on for the
9007       % printing, back off for the \refx-pg.
9008       {\turnoffactive
9009        % Only output a following space if the -snt ref is nonempty; for
9010        % @unnumbered and @anchor, it won't be.
9011        \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
9012        \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
9013       }%
9014       % output the `[mynode]' via the macro below so it can be overridden.
9015       \xrefprintnodename\printedrefname
9016       %
9017       % But we always want a comma and a space:
9018       ,\space
9019       %
9020       % output the `page 3'.
9021       \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
9022       % Add a , if xref followed by a space
9023       \if\space\noexpand\tokenafterxref ,%
9024       \else\ifx\        \tokenafterxref ,% @TAB
9025       \else\ifx\*\tokenafterxref ,%   @*
9026       \else\ifx\ \tokenafterxref ,%   @SPACE
9027       \else\ifx\
9028                 \tokenafterxref ,%    @NL
9029       \else\ifx\tie\tokenafterxref ,% @tie
9030       \fi\fi\fi\fi\fi\fi
9031     \fi\fi
9032   \fi
9033   \endlink
9034 \endgroup}
9035
9036 % Output a cross-manual xref to #1.  Used just above (twice).
9037
9038 % Only include the text "Section ``foo'' in" if the foo is neither
9039 % missing or Top.  Thus, @xref{,,,foo,The Foo Manual} outputs simply
9040 % "see The Foo Manual", the idea being to refer to the whole manual.
9041
9042 % But, this being TeX, we can't easily compare our node name against the
9043 % string "Top" while ignoring the possible spaces before and after in
9044 % the input.  By adding the arbitrary 7sp below, we make it much less
9045 % likely that a real node name would have the same width as "Top" (e.g.,
9046 % in a monospaced font).  Hopefully it will never happen in practice.
9047
9048 % For the same basic reason, we retypeset the "Top" at every
9049 % reference, since the current font is indeterminate.
9050
9051 \def\crossmanualxref#1{%
9052   \setbox\toprefbox = \hbox{Top\kern7sp}%
9053   \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
9054   \ifdim \wd2 > 7sp  % nonempty?
9055     \ifdim \wd2 = \wd\toprefbox \else  % same as Top?
9056       \putwordSection{} ``\printedrefname'' \putwordin{}\space
9057     \fi
9058   \fi
9059   #1%
9060 }
9061
9062 % This macro is called from \xrefX for the `[nodename]' part of xref
9063 % output.  It's a separate macro only so it can be changed more easily,
9064 % since square brackets don't work well in some documents.  Particularly
9065 % one that Bob is working on :).
9066 %
9067 \def\xrefprintnodename#1{[#1]}
9068
9069 % Things referred to by \setref.
9070 %
9071 \def\Ynothing{}
9072 \def\Yomitfromtoc{}
9073 \def\Ynumbered{%
9074   \ifnum\secno=0
9075     \putwordChapter@tie \the\chapno
9076   \else \ifnum\subsecno=0
9077     \putwordSection@tie \the\chapno.\the\secno
9078   \else \ifnum\subsubsecno=0
9079     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
9080   \else
9081     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
9082   \fi\fi\fi
9083 }
9084 \def\Yappendix{%
9085   \ifnum\secno=0
9086      \putwordAppendix@tie @char\the\appendixno{}%
9087   \else \ifnum\subsecno=0
9088      \putwordSection@tie @char\the\appendixno.\the\secno
9089   \else \ifnum\subsubsecno=0
9090     \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
9091   \else
9092     \putwordSection@tie
9093       @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
9094   \fi\fi\fi
9095 }
9096
9097 % \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME.  SUFFIX 
9098 % is output afterwards if non-empty.
9099 \def\refx#1#2{%
9100   \requireauxfile
9101   {%
9102     \indexnofonts
9103     \otherbackslash
9104     \def\value##1{##1}%
9105     \expandafter\global\expandafter\let\expandafter\thisrefX
9106       \csname XR#1\endcsname
9107   }%
9108   \ifx\thisrefX\relax
9109     % If not defined, say something at least.
9110     \angleleft un\-de\-fined\angleright
9111     \iflinks
9112       \ifhavexrefs
9113         {\toks0 = {#1}% avoid expansion of possibly-complex value
9114          \message{\linenumber Undefined cross reference `\the\toks0'.}}%
9115       \else
9116         \ifwarnedxrefs\else
9117           \global\warnedxrefstrue
9118           \message{Cross reference values unknown; you must run TeX again.}%
9119         \fi
9120       \fi
9121     \fi
9122   \else
9123     % It's defined, so just use it.
9124     \thisrefX
9125   \fi
9126   #2% Output the suffix in any case.
9127 }
9128
9129 % This is the macro invoked by entries in the aux file.  Define a control 
9130 % sequence for a cross-reference target (we prepend XR to the control sequence 
9131 % name to avoid collisions).  The value is the page number.  If this is a float 
9132 % type, we have more work to do.
9133 %
9134 \def\xrdef#1#2{%
9135   {% Expand the node or anchor name to remove control sequences.
9136    % \turnoffactive stops 8-bit characters being changed to commands
9137    % like @'e.  \refx does the same to retrieve the value in the definition.
9138     \indexnofonts
9139     \turnoffactive
9140     \def\value##1{##1}%
9141     \xdef\safexrefname{#1}%
9142   }%
9143   %
9144   \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref
9145   %
9146   % Was that xref control sequence that we just defined for a float?
9147   \expandafter\iffloat\csname XR\safexrefname\endcsname
9148     % it was a float, and we have the (safe) float type in \iffloattype.
9149     \expandafter\let\expandafter\floatlist
9150       \csname floatlist\iffloattype\endcsname
9151     %
9152     % Is this the first time we've seen this float type?
9153     \expandafter\ifx\floatlist\relax
9154       \toks0 = {\do}% yes, so just \do
9155     \else
9156       % had it before, so preserve previous elements in list.
9157       \toks0 = \expandafter{\floatlist\do}%
9158     \fi
9159     %
9160     % Remember this xref in the control sequence \floatlistFLOATTYPE,
9161     % for later use in \listoffloats.
9162     \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
9163       {\safexrefname}}%
9164   \fi
9165 }
9166
9167 % If working on a large document in chapters, it is convenient to
9168 % be able to disable indexing, cross-referencing, and contents, for test runs.
9169 % This is done with @novalidate at the beginning of the file.
9170 %
9171 \newif\iflinks \linkstrue % by default we want the aux files.
9172 \let\novalidate = \linksfalse
9173
9174 % Used when writing to the aux file, or when using data from it.
9175 \def\requireauxfile{%
9176   \iflinks
9177     \tryauxfile
9178     % Open the new aux file.  TeX will close it automatically at exit.
9179     \immediate\openout\auxfile=\jobname.aux
9180   \fi
9181   \global\let\requireauxfile=\relax   % Only do this once.
9182 }
9183
9184 % Read the last existing aux file, if any.  No error if none exists.
9185 %
9186 \def\tryauxfile{%
9187   \openin 1 \jobname.aux
9188   \ifeof 1 \else
9189     \readdatafile{aux}%
9190     \global\havexrefstrue
9191   \fi
9192   \closein 1
9193 }
9194
9195 \def\setupdatafile{%
9196   \catcode`\^^@=\other
9197   \catcode`\^^A=\other
9198   \catcode`\^^B=\other
9199   \catcode`\^^C=\other
9200   \catcode`\^^D=\other
9201   \catcode`\^^E=\other
9202   \catcode`\^^F=\other
9203   \catcode`\^^G=\other
9204   \catcode`\^^H=\other
9205   \catcode`\^^K=\other
9206   \catcode`\^^L=\other
9207   \catcode`\^^N=\other
9208   \catcode`\^^P=\other
9209   \catcode`\^^Q=\other
9210   \catcode`\^^R=\other
9211   \catcode`\^^S=\other
9212   \catcode`\^^T=\other
9213   \catcode`\^^U=\other
9214   \catcode`\^^V=\other
9215   \catcode`\^^W=\other
9216   \catcode`\^^X=\other
9217   \catcode`\^^Z=\other
9218   \catcode`\^^[=\other
9219   \catcode`\^^\=\other
9220   \catcode`\^^]=\other
9221   \catcode`\^^^=\other
9222   \catcode`\^^_=\other
9223   % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
9224   % in xref tags, i.e., node names.  But since ^^e4 notation isn't
9225   % supported in the main text, it doesn't seem desirable.  Furthermore,
9226   % that is not enough: for node names that actually contain a ^
9227   % character, we would end up writing a line like this: 'xrdef {'hat
9228   % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
9229   % argument, and \hat is not an expandable control sequence.  It could
9230   % all be worked out, but why?  Either we support ^^ or we don't.
9231   %
9232   % The other change necessary for this was to define \auxhat:
9233   % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
9234   % and then to call \auxhat in \setq.
9235   %
9236   \catcode`\^=\other
9237   %
9238   % Special characters.  Should be turned off anyway, but...
9239   \catcode`\~=\other
9240   \catcode`\[=\other
9241   \catcode`\]=\other
9242   \catcode`\"=\other
9243   \catcode`\_=\other
9244   \catcode`\|=\other
9245   \catcode`\<=\other
9246   \catcode`\>=\other
9247   \catcode`\$=\other
9248   \catcode`\#=\other
9249   \catcode`\&=\other
9250   \catcode`\%=\other
9251   \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
9252   %
9253   % This is to support \ in node names and titles, since the \
9254   % characters end up in a \csname.  It's easier than
9255   % leaving it active and making its active definition an actual \
9256   % character.  What I don't understand is why it works in the *value*
9257   % of the xrdef.  Seems like it should be a catcode12 \, and that
9258   % should not typeset properly.  But it works, so I'm moving on for
9259   % now.  --karl, 15jan04.
9260   \catcode`\\=\other
9261   %
9262   % @ is our escape character in .aux files, and we need braces.
9263   \catcode`\{=1
9264   \catcode`\}=2
9265   \catcode`\@=0
9266 }
9267
9268 \def\readdatafile#1{%
9269 \begingroup
9270   \setupdatafile
9271   \input\jobname.#1
9272 \endgroup}
9273
9274
9275 \message{insertions,}
9276 % including footnotes.
9277
9278 \newcount \footnoteno
9279
9280 % The trailing space in the following definition for supereject is
9281 % vital for proper filling; pages come out unaligned when you do a
9282 % pagealignmacro call if that space before the closing brace is
9283 % removed. (Generally, numeric constants should always be followed by a
9284 % space to prevent strange expansion errors.)
9285 \def\supereject{\par\penalty -20000\footnoteno =0 }
9286
9287 % @footnotestyle is meaningful for Info output only.
9288 \let\footnotestyle=\comment
9289
9290 {\catcode `\@=11
9291 %
9292 % Auto-number footnotes.  Otherwise like plain.
9293 \gdef\footnote{%
9294   \global\advance\footnoteno by \@ne
9295   \edef\thisfootno{$^{\the\footnoteno}$}%
9296   %
9297   % In case the footnote comes at the end of a sentence, preserve the
9298   % extra spacing after we do the footnote number.
9299   \let\@sf\empty
9300   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9301   %
9302   % Remove inadvertent blank space before typesetting the footnote number.
9303   \unskip
9304   \thisfootno\@sf
9305   \dofootnote
9306 }%
9307
9308 % Don't bother with the trickery in plain.tex to not require the
9309 % footnote text as a parameter.  Our footnotes don't need to be so general.
9310 %
9311 % Oh yes, they do; otherwise, @ifset (and anything else that uses
9312 % \parseargline) fails inside footnotes because the tokens are fixed when
9313 % the footnote is read.  --karl, 16nov96.
9314 %
9315 \gdef\dofootnote{%
9316   \insert\footins\bgroup
9317   %
9318   % Nested footnotes are not supported in TeX, that would take a lot
9319   % more work.  (\startsavinginserts does not suffice.)
9320   \let\footnote=\errfootnotenest
9321   %
9322   % We want to typeset this text as a normal paragraph, even if the
9323   % footnote reference occurs in (for example) a display environment.
9324   % So reset some parameters.
9325   \hsize=\txipagewidth
9326   \interlinepenalty\interfootnotelinepenalty
9327   \splittopskip\ht\strutbox % top baseline for broken footnotes
9328   \splitmaxdepth\dp\strutbox
9329   \floatingpenalty\@MM
9330   \leftskip\z@skip
9331   \rightskip\z@skip
9332   \spaceskip\z@skip
9333   \xspaceskip\z@skip
9334   \parindent\defaultparindent
9335   %
9336   \smallfonts \rm
9337   %
9338   % Because we use hanging indentation in footnotes, a @noindent appears
9339   % to exdent this text, so make it be a no-op.  makeinfo does not use
9340   % hanging indentation so @noindent can still be needed within footnote
9341   % text after an @example or the like (not that this is good style).
9342   \let\noindent = \relax
9343   %
9344   % Hang the footnote text off the number.  Use \everypar in case the
9345   % footnote extends for more than one paragraph.
9346   \everypar = {\hang}%
9347   \textindent{\thisfootno}%
9348   %
9349   % Don't crash into the line above the footnote text.  Since this
9350   % expands into a box, it must come within the paragraph, lest it
9351   % provide a place where TeX can split the footnote.
9352   \footstrut
9353   %
9354   % Invoke rest of plain TeX footnote routine.
9355   \futurelet\next\fo@t
9356 }
9357 }%end \catcode `\@=11
9358
9359 \def\errfootnotenest{%
9360   \errhelp=\EMsimple
9361   \errmessage{Nested footnotes not supported in texinfo.tex,
9362     even though they work in makeinfo; sorry}
9363 }
9364
9365 \def\errfootnoteheading{%
9366   \errhelp=\EMsimple
9367   \errmessage{Footnotes in chapters, sections, etc., are not supported}
9368 }
9369
9370 % In case a @footnote appears in a vbox, save the footnote text and create
9371 % the real \insert just after the vbox finished.  Otherwise, the insertion
9372 % would be lost.
9373 % Similarly, if a @footnote appears inside an alignment, save the footnote
9374 % text to a box and make the \insert when a row of the table is finished.
9375 % And the same can be done for other insert classes.  --kasal, 16nov03.
9376 %
9377 % Replace the \insert primitive by a cheating macro.
9378 % Deeper inside, just make sure that the saved insertions are not spilled
9379 % out prematurely.
9380 %
9381 \def\startsavinginserts{%
9382   \ifx \insert\ptexinsert
9383     \let\insert\saveinsert
9384   \else
9385     \let\checkinserts\relax
9386   \fi
9387 }
9388
9389 % This \insert replacement works for both \insert\footins{foo} and
9390 % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9391 %
9392 \def\saveinsert#1{%
9393   \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9394   \afterassignment\next
9395   % swallow the left brace
9396   \let\temp =
9397 }
9398 \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9399 \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9400
9401 \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9402
9403 \def\placesaveins#1{%
9404   \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9405     {\box#1}%
9406 }
9407
9408 % eat @SAVE -- beware, all of them have catcode \other:
9409 {
9410   \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials  %  ;-)
9411   \gdef\gobblesave @SAVE{}
9412 }
9413
9414 % initialization:
9415 \def\newsaveins #1{%
9416   \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9417   \next
9418 }
9419 \def\newsaveinsX #1{%
9420   \csname newbox\endcsname #1%
9421   \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9422     \checksaveins #1}%
9423 }
9424
9425 % initialize:
9426 \let\checkinserts\empty
9427 \newsaveins\footins
9428 \newsaveins\margin
9429
9430
9431 % @image.  We use the macros from epsf.tex to support this.
9432 % If epsf.tex is not installed and @image is used, we complain.
9433 %
9434 % Check for and read epsf.tex up front.  If we read it only at @image
9435 % time, we might be inside a group, and then its definitions would get
9436 % undone and the next image would fail.
9437 \openin 1 = epsf.tex
9438 \ifeof 1 \else
9439   % Do not bother showing banner with epsf.tex v2.7k (available in
9440   % doc/epsf.tex and on ctan).
9441   \def\epsfannounce{\toks0 = }%
9442   \input epsf.tex
9443 \fi
9444 \closein 1
9445 %
9446 % We will only complain once about lack of epsf.tex.
9447 \newif\ifwarnednoepsf
9448 \newhelp\noepsfhelp{epsf.tex must be installed for images to
9449   work.  It is also included in the Texinfo distribution, or you can get
9450   it from ftp://tug.org/tex/epsf.tex.}
9451 %
9452 \def\image#1{%
9453   \ifx\epsfbox\thisisundefined
9454     \ifwarnednoepsf \else
9455       \errhelp = \noepsfhelp
9456       \errmessage{epsf.tex not found, images will be ignored}%
9457       \global\warnednoepsftrue
9458     \fi
9459   \else
9460     \imagexxx #1,,,,,\finish
9461   \fi
9462 }
9463 %
9464 % Arguments to @image:
9465 % #1 is (mandatory) image filename; we tack on .eps extension.
9466 % #2 is (optional) width, #3 is (optional) height.
9467 % #4 is (ignored optional) html alt text.
9468 % #5 is (ignored optional) extension.
9469 % #6 is just the usual extra ignored arg for parsing stuff.
9470 \newif\ifimagevmode
9471 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
9472   \catcode`\^^M = 5     % in case we're inside an example
9473   \normalturnoffactive  % allow _ et al. in names
9474   \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
9475   % If the image is by itself, center it.
9476   \ifvmode
9477     \imagevmodetrue
9478   \else \ifx\centersub\centerV
9479     % for @center @image, we need a vbox so we can have our vertical space
9480     \imagevmodetrue
9481     \vbox\bgroup % vbox has better behavior than vtop herev
9482   \fi\fi
9483   %
9484   \ifimagevmode
9485     \nobreak\medskip
9486     % Usually we'll have text after the image which will insert
9487     % \parskip glue, so insert it here too to equalize the space
9488     % above and below.
9489     \nobreak\vskip\parskip
9490     \nobreak
9491   \fi
9492   %
9493   % Leave vertical mode so that indentation from an enclosing
9494   %  environment such as @quotation is respected.
9495   % However, if we're at the top level, we don't want the
9496   %  normal paragraph indentation.
9497   % On the other hand, if we are in the case of @center @image, we don't
9498   %  want to start a paragraph, which will create a hsize-width box and
9499   %  eradicate the centering.
9500   \ifx\centersub\centerV\else \noindent \fi
9501   %
9502   % Output the image.
9503   \ifpdf
9504     % For pdfTeX and LuaTeX <= 0.80
9505     \dopdfimage{#1}{#2}{#3}%
9506   \else
9507     \ifx\XeTeXrevision\thisisundefined
9508       % For epsf.tex
9509       % \epsfbox itself resets \epsf?size at each figure.
9510       \setbox0 = \hbox{\ignorespaces #2}%
9511         \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9512       \setbox0 = \hbox{\ignorespaces #3}%
9513         \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9514       \epsfbox{#1.eps}%
9515     \else
9516       % For XeTeX
9517       \doxeteximage{#1}{#2}{#3}%
9518     \fi
9519   \fi
9520   %
9521   \ifimagevmode
9522     \medskip  % space after a standalone image
9523   \fi  
9524   \ifx\centersub\centerV \egroup \fi
9525 \endgroup}
9526
9527
9528 % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9529 % etc.  We don't actually implement floating yet, we always include the
9530 % float "here".  But it seemed the best name for the future.
9531 %
9532 \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9533
9534 % There may be a space before second and/or third parameter; delete it.
9535 \def\eatcommaspace#1, {#1,}
9536
9537 % #1 is the optional FLOATTYPE, the text label for this float, typically
9538 % "Figure", "Table", "Example", etc.  Can't contain commas.  If omitted,
9539 % this float will not be numbered and cannot be referred to.
9540 %
9541 % #2 is the optional xref label.  Also must be present for the float to
9542 % be referable.
9543 %
9544 % #3 is the optional positioning argument; for now, it is ignored.  It
9545 % will somehow specify the positions allowed to float to (here, top, bottom).
9546 %
9547 % We keep a separate counter for each FLOATTYPE, which we reset at each
9548 % chapter-level command.
9549 \let\resetallfloatnos=\empty
9550 %
9551 \def\dofloat#1,#2,#3,#4\finish{%
9552   \let\thiscaption=\empty
9553   \let\thisshortcaption=\empty
9554   %
9555   % don't lose footnotes inside @float.
9556   %
9557   % BEWARE: when the floats start float, we have to issue warning whenever an
9558   % insert appears inside a float which could possibly float. --kasal, 26may04
9559   %
9560   \startsavinginserts
9561   %
9562   % We can't be used inside a paragraph.
9563   \par
9564   %
9565   \vtop\bgroup
9566     \def\floattype{#1}%
9567     \def\floatlabel{#2}%
9568     \def\floatloc{#3}% we do nothing with this yet.
9569     %
9570     \ifx\floattype\empty
9571       \let\safefloattype=\empty
9572     \else
9573       {%
9574         % the floattype might have accents or other special characters,
9575         % but we need to use it in a control sequence name.
9576         \indexnofonts
9577         \turnoffactive
9578         \xdef\safefloattype{\floattype}%
9579       }%
9580     \fi
9581     %
9582     % If label is given but no type, we handle that as the empty type.
9583     \ifx\floatlabel\empty \else
9584       % We want each FLOATTYPE to be numbered separately (Figure 1,
9585       % Table 1, Figure 2, ...).  (And if no label, no number.)
9586       %
9587       \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9588       \global\advance\floatno by 1
9589       %
9590       {%
9591         % This magic value for \lastsection is output by \setref as the
9592         % XREFLABEL-title value.  \xrefX uses it to distinguish float
9593         % labels (which have a completely different output format) from
9594         % node and anchor labels.  And \xrdef uses it to construct the
9595         % lists of floats.
9596         %
9597         \edef\lastsection{\floatmagic=\safefloattype}%
9598         \setref{\floatlabel}{Yfloat}%
9599       }%
9600     \fi
9601     %
9602     % start with \parskip glue, I guess.
9603     \vskip\parskip
9604     %
9605     % Don't suppress indentation if a float happens to start a section.
9606     \restorefirstparagraphindent
9607 }
9608
9609 % we have these possibilities:
9610 % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9611 % @float Foo,lbl & no caption:    Foo 1.1
9612 % @float Foo & @caption{Cap}:     Foo: Cap
9613 % @float Foo & no caption:        Foo
9614 % @float ,lbl & Caption{Cap}:     1.1: Cap
9615 % @float ,lbl & no caption:       1.1
9616 % @float & @caption{Cap}:         Cap
9617 % @float & no caption:
9618 %
9619 \def\Efloat{%
9620     \let\floatident = \empty
9621     %
9622     % In all cases, if we have a float type, it comes first.
9623     \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9624     %
9625     % If we have an xref label, the number comes next.
9626     \ifx\floatlabel\empty \else
9627       \ifx\floattype\empty \else % if also had float type, need tie first.
9628         \appendtomacro\floatident{\tie}%
9629       \fi
9630       % the number.
9631       \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9632     \fi
9633     %
9634     % Start the printed caption with what we've constructed in
9635     % \floatident, but keep it separate; we need \floatident again.
9636     \let\captionline = \floatident
9637     %
9638     \ifx\thiscaption\empty \else
9639       \ifx\floatident\empty \else
9640         \appendtomacro\captionline{: }% had ident, so need a colon between
9641       \fi
9642       %
9643       % caption text.
9644       \appendtomacro\captionline{\scanexp\thiscaption}%
9645     \fi
9646     %
9647     % If we have anything to print, print it, with space before.
9648     % Eventually this needs to become an \insert.
9649     \ifx\captionline\empty \else
9650       \vskip.5\parskip
9651       \captionline
9652       %
9653       % Space below caption.
9654       \vskip\parskip
9655     \fi
9656     %
9657     % If have an xref label, write the list of floats info.  Do this
9658     % after the caption, to avoid chance of it being a breakpoint.
9659     \ifx\floatlabel\empty \else
9660       % Write the text that goes in the lof to the aux file as
9661       % \floatlabel-lof.  Besides \floatident, we include the short
9662       % caption if specified, else the full caption if specified, else nothing.
9663       {%
9664         \requireauxfile
9665         \atdummies
9666         %
9667         \ifx\thisshortcaption\empty
9668           \def\gtemp{\thiscaption}%
9669         \else
9670           \def\gtemp{\thisshortcaption}%
9671         \fi
9672         \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
9673           \ifx\gtemp\empty \else : \gtemp \fi}}%
9674       }%
9675     \fi
9676   \egroup  % end of \vtop
9677   %
9678   \checkinserts
9679 }
9680
9681 % Append the tokens #2 to the definition of macro #1, not expanding either.
9682 %
9683 \def\appendtomacro#1#2{%
9684   \expandafter\def\expandafter#1\expandafter{#1#2}%
9685 }
9686
9687 % @caption, @shortcaption
9688 %
9689 \def\caption{\docaption\thiscaption}
9690 \def\shortcaption{\docaption\thisshortcaption}
9691 \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
9692 \def\defcaption#1#2{\egroup \def#1{#2}}
9693
9694 % The parameter is the control sequence identifying the counter we are
9695 % going to use.  Create it if it doesn't exist and assign it to \floatno.
9696 \def\getfloatno#1{%
9697   \ifx#1\relax
9698       % Haven't seen this figure type before.
9699       \csname newcount\endcsname #1%
9700       %
9701       % Remember to reset this floatno at the next chap.
9702       \expandafter\gdef\expandafter\resetallfloatnos
9703         \expandafter{\resetallfloatnos #1=0 }%
9704   \fi
9705   \let\floatno#1%
9706 }
9707
9708 % \setref calls this to get the XREFLABEL-snt value.  We want an @xref
9709 % to the FLOATLABEL to expand to "Figure 3.1".  We call \setref when we
9710 % first read the @float command.
9711 %
9712 \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9713
9714 % Magic string used for the XREFLABEL-title value, so \xrefX can
9715 % distinguish floats from other xref types.
9716 \def\floatmagic{!!float!!}
9717
9718 % #1 is the control sequence we are passed; we expand into a conditional
9719 % which is true if #1 represents a float ref.  That is, the magic
9720 % \lastsection value which we \setref above.
9721 %
9722 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
9723 %
9724 % #1 is (maybe) the \floatmagic string.  If so, #2 will be the
9725 % (safe) float type for this float.  We set \iffloattype to #2.
9726 %
9727 \def\doiffloat#1=#2=#3\finish{%
9728   \def\temp{#1}%
9729   \def\iffloattype{#2}%
9730   \ifx\temp\floatmagic
9731 }
9732
9733 % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9734 %
9735 \parseargdef\listoffloats{%
9736   \def\floattype{#1}% floattype
9737   {%
9738     % the floattype might have accents or other special characters,
9739     % but we need to use it in a control sequence name.
9740     \indexnofonts
9741     \turnoffactive
9742     \xdef\safefloattype{\floattype}%
9743   }%
9744   %
9745   % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9746   \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9747     \ifhavexrefs
9748       % if the user said @listoffloats foo but never @float foo.
9749       \message{\linenumber No `\safefloattype' floats to list.}%
9750     \fi
9751   \else
9752     \begingroup
9753       \leftskip=\tocindent  % indent these entries like a toc
9754       \let\do=\listoffloatsdo
9755       \csname floatlist\safefloattype\endcsname
9756     \endgroup
9757   \fi
9758 }
9759
9760 % This is called on each entry in a list of floats.  We're passed the
9761 % xref label, in the form LABEL-title, which is how we save it in the
9762 % aux file.  We strip off the -title and look up \XRLABEL-lof, which
9763 % has the text we're supposed to typeset here.
9764 %
9765 % Figures without xref labels will not be included in the list (since
9766 % they won't appear in the aux file).
9767 %
9768 \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9769 \def\listoffloatsdoentry#1-title\finish{{%
9770   % Can't fully expand XR#1-lof because it can contain anything.  Just
9771   % pass the control sequence.  On the other hand, XR#1-pg is just the
9772   % page number, and we want to fully expand that so we can get a link
9773   % in pdf output.
9774   \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9775   %
9776   % use the same \entry macro we use to generate the TOC and index.
9777   \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9778   \writeentry
9779 }}
9780
9781
9782 \message{localization,}
9783
9784 % For single-language documents, @documentlanguage is usually given very
9785 % early, just after @documentencoding.  Single argument is the language
9786 % (de) or locale (de_DE) abbreviation.
9787 %
9788 {
9789   \catcode`\_ = \active
9790   \globaldefs=1
9791 \parseargdef\documentlanguage{%
9792   \tex % read txi-??.tex file in plain TeX.
9793     % Read the file by the name they passed if it exists.
9794     \let_ = \normalunderscore  % normal _ character for filename test
9795     \openin 1 txi-#1.tex
9796     \ifeof 1
9797       \documentlanguagetrywithoutunderscore #1_\finish
9798     \else
9799       \globaldefs = 1  % everything in the txi-LL files needs to persist
9800       \input txi-#1.tex
9801     \fi
9802     \closein 1
9803   \endgroup % end raw TeX
9804 }
9805 %
9806 % If they passed de_DE, and txi-de_DE.tex doesn't exist,
9807 % try txi-de.tex.
9808 %
9809 \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
9810   \openin 1 txi-#1.tex
9811   \ifeof 1
9812     \errhelp = \nolanghelp
9813     \errmessage{Cannot read language file txi-#1.tex}%
9814   \else
9815     \globaldefs = 1  % everything in the txi-LL files needs to persist
9816     \input txi-#1.tex
9817   \fi
9818   \closein 1
9819 }
9820 }% end of special _ catcode
9821 %
9822 \newhelp\nolanghelp{The given language definition file cannot be found or
9823 is empty.  Maybe you need to install it?  Putting it in the current
9824 directory should work if nowhere else does.}
9825
9826 % This macro is called from txi-??.tex files; the first argument is the
9827 % \language name to set (without the "\lang@" prefix), the second and
9828 % third args are \{left,right}hyphenmin.
9829 %
9830 % The language names to pass are determined when the format is built.
9831 % See the etex.log file created at that time, e.g.,
9832 % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9833 %
9834 % With TeX Live 2008, etex now includes hyphenation patterns for all
9835 % available languages.  This means we can support hyphenation in
9836 % Texinfo, at least to some extent.  (This still doesn't solve the
9837 % accented characters problem.)
9838 %
9839 \catcode`@=11
9840 \def\txisetlanguage#1#2#3{%
9841   % do not set the language if the name is undefined in the current TeX.
9842   \expandafter\ifx\csname lang@#1\endcsname \relax
9843     \message{no patterns for #1}%
9844   \else
9845     \global\language = \csname lang@#1\endcsname
9846   \fi
9847   % but there is no harm in adjusting the hyphenmin values regardless.
9848   \global\lefthyphenmin = #2\relax
9849   \global\righthyphenmin = #3\relax
9850 }
9851
9852 % XeTeX and LuaTeX can handle Unicode natively.
9853 % Their default I/O uses UTF-8 sequences instead of a byte-wise operation.
9854 % Other TeX engines' I/O (pdfTeX, etc.) is byte-wise.
9855 %
9856 \newif\iftxinativeunicodecapable
9857 \newif\iftxiusebytewiseio
9858
9859 \ifx\XeTeXrevision\thisisundefined
9860   \ifx\luatexversion\thisisundefined
9861     \txinativeunicodecapablefalse
9862     \txiusebytewiseiotrue
9863   \else
9864     \txinativeunicodecapabletrue
9865     \txiusebytewiseiofalse
9866   \fi
9867 \else
9868   \txinativeunicodecapabletrue
9869   \txiusebytewiseiofalse
9870 \fi
9871
9872 % Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9873 % for non-UTF-8 (byte-wise) encodings.
9874 %
9875 \def\setbytewiseio{%
9876   \ifx\XeTeXrevision\thisisundefined
9877   \else
9878     \XeTeXdefaultencoding "bytes"  % For subsequent files to be read
9879     \XeTeXinputencoding "bytes"  % For document root file
9880     % Unfortunately, there seems to be no corresponding XeTeX command for
9881     % output encoding.  This is a problem for auxiliary index and TOC files.
9882     % The only solution would be perhaps to write out @U{...} sequences in
9883     % place of non-ASCII characters.
9884   \fi
9885
9886   \ifx\luatexversion\thisisundefined
9887   \else
9888     \directlua{
9889     local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9890     local function convert_char (char)
9891       return utf8_char(byte(char))
9892     end
9893
9894     local function convert_line (line)
9895       return gsub(line, ".", convert_char)
9896     end
9897
9898     callback.register("process_input_buffer", convert_line)
9899
9900     local function convert_line_out (line)
9901       local line_out = ""
9902       for c in string.utfvalues(line) do
9903          line_out = line_out .. string.char(c)
9904       end
9905       return line_out
9906     end
9907
9908     callback.register("process_output_buffer", convert_line_out)
9909     }
9910   \fi
9911
9912   \txiusebytewiseiotrue
9913 }
9914
9915
9916 % Helpers for encodings.
9917 % Set the catcode of characters 128 through 255 to the specified number.
9918 %
9919 \def\setnonasciicharscatcode#1{%
9920    \count255=128
9921    \loop\ifnum\count255<256
9922       \global\catcode\count255=#1\relax
9923       \advance\count255 by 1
9924    \repeat
9925 }
9926
9927 \def\setnonasciicharscatcodenonglobal#1{%
9928    \count255=128
9929    \loop\ifnum\count255<256
9930       \catcode\count255=#1\relax
9931       \advance\count255 by 1
9932    \repeat
9933 }
9934
9935 % @documentencoding sets the definition of non-ASCII characters
9936 % according to the specified encoding.
9937 %
9938 \def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9939 \def\documentencodingzzz#1{%
9940   %
9941   % Encoding being declared for the document.
9942   \def\declaredencoding{\csname #1.enc\endcsname}%
9943   %
9944   % Supported encodings: names converted to tokens in order to be able
9945   % to compare them with \ifx.
9946   \def\ascii{\csname US-ASCII.enc\endcsname}%
9947   \def\latnine{\csname ISO-8859-15.enc\endcsname}%
9948   \def\latone{\csname ISO-8859-1.enc\endcsname}%
9949   \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
9950   \def\utfeight{\csname UTF-8.enc\endcsname}%
9951   %
9952   \ifx \declaredencoding \ascii
9953      \asciichardefs
9954   %
9955   \else \ifx \declaredencoding \lattwo
9956      \iftxinativeunicodecapable
9957        \setbytewiseio
9958      \fi
9959      \setnonasciicharscatcode\active
9960      \lattwochardefs
9961   %
9962   \else \ifx \declaredencoding \latone
9963      \iftxinativeunicodecapable
9964        \setbytewiseio
9965      \fi
9966      \setnonasciicharscatcode\active
9967      \latonechardefs
9968   %
9969   \else \ifx \declaredencoding \latnine
9970      \iftxinativeunicodecapable
9971        \setbytewiseio
9972      \fi
9973      \setnonasciicharscatcode\active
9974      \latninechardefs
9975   %
9976   \else \ifx \declaredencoding \utfeight
9977      \iftxinativeunicodecapable
9978        % For native Unicode handling (XeTeX and LuaTeX)
9979        \nativeunicodechardefs
9980      \else
9981        % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX)
9982        \setnonasciicharscatcode\active
9983        % since we already invoked \utfeightchardefs at the top level
9984        % (below), do not re-invoke it, otherwise our check for duplicated
9985        % definitions gets triggered.  Making non-ascii chars active is
9986        % sufficient.
9987      \fi
9988   %
9989   \else
9990     \message{Ignoring unknown document encoding: #1.}%
9991   %
9992   \fi % utfeight
9993   \fi % latnine
9994   \fi % latone
9995   \fi % lattwo
9996   \fi % ascii
9997   %
9998   \ifx\XeTeXrevision\thisisundefined
9999   \else
10000     \ifx \declaredencoding \utfeight
10001     \else
10002       \ifx \declaredencoding \ascii
10003       \else
10004         \message{Warning: XeTeX with non-UTF-8 encodings cannot handle %
10005         non-ASCII characters in auxiliary files.}%
10006       \fi
10007     \fi
10008   \fi
10009 }
10010
10011 % emacs-page
10012 % A message to be logged when using a character that isn't available
10013 % the default font encoding (OT1).
10014 %
10015 \def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
10016
10017 % Take account of \c (plain) vs. \, (Texinfo) difference.
10018 \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
10019
10020 % First, make active non-ASCII characters in order for them to be
10021 % correctly categorized when TeX reads the replacement text of
10022 % macros containing the character definitions.
10023 \setnonasciicharscatcode\active
10024 %
10025
10026 \def\gdefchar#1#2{%
10027 \gdef#1{%
10028    \ifpassthroughchars
10029      \string#1%
10030    \else
10031      #2%
10032    \fi
10033 }}
10034
10035 % Latin1 (ISO-8859-1) character definitions.
10036 \def\latonechardefs{%
10037   \gdefchar^^a0{\tie}
10038   \gdefchar^^a1{\exclamdown}
10039   \gdefchar^^a2{{\tcfont \char162}} % cent
10040   \gdefchar^^a3{\pounds{}}
10041   \gdefchar^^a4{{\tcfont \char164}} % currency
10042   \gdefchar^^a5{{\tcfont \char165}} % yen
10043   \gdefchar^^a6{{\tcfont \char166}} % broken bar
10044   \gdefchar^^a7{\S}
10045   \gdefchar^^a8{\"{}}
10046   \gdefchar^^a9{\copyright{}}
10047   \gdefchar^^aa{\ordf}
10048   \gdefchar^^ab{\guillemetleft{}}
10049   \gdefchar^^ac{\ensuremath\lnot}
10050   \gdefchar^^ad{\-}
10051   \gdefchar^^ae{\registeredsymbol{}}
10052   \gdefchar^^af{\={}}
10053   %
10054   \gdefchar^^b0{\textdegree}
10055   \gdefchar^^b1{$\pm$}
10056   \gdefchar^^b2{$^2$}
10057   \gdefchar^^b3{$^3$}
10058   \gdefchar^^b4{\'{}}
10059   \gdefchar^^b5{$\mu$}
10060   \gdefchar^^b6{\P}
10061   \gdefchar^^b7{\ensuremath\cdot}
10062   \gdefchar^^b8{\cedilla\ }
10063   \gdefchar^^b9{$^1$}
10064   \gdefchar^^ba{\ordm}
10065   \gdefchar^^bb{\guillemetright{}}
10066   \gdefchar^^bc{$1\over4$}
10067   \gdefchar^^bd{$1\over2$}
10068   \gdefchar^^be{$3\over4$}
10069   \gdefchar^^bf{\questiondown}
10070   %
10071   \gdefchar^^c0{\`A}
10072   \gdefchar^^c1{\'A}
10073   \gdefchar^^c2{\^A}
10074   \gdefchar^^c3{\~A}
10075   \gdefchar^^c4{\"A}
10076   \gdefchar^^c5{\ringaccent A}
10077   \gdefchar^^c6{\AE}
10078   \gdefchar^^c7{\cedilla C}
10079   \gdefchar^^c8{\`E}
10080   \gdefchar^^c9{\'E}
10081   \gdefchar^^ca{\^E}
10082   \gdefchar^^cb{\"E}
10083   \gdefchar^^cc{\`I}
10084   \gdefchar^^cd{\'I}
10085   \gdefchar^^ce{\^I}
10086   \gdefchar^^cf{\"I}
10087   %
10088   \gdefchar^^d0{\DH}
10089   \gdefchar^^d1{\~N}
10090   \gdefchar^^d2{\`O}
10091   \gdefchar^^d3{\'O}
10092   \gdefchar^^d4{\^O}
10093   \gdefchar^^d5{\~O}
10094   \gdefchar^^d6{\"O}
10095   \gdefchar^^d7{$\times$}
10096   \gdefchar^^d8{\O}
10097   \gdefchar^^d9{\`U}
10098   \gdefchar^^da{\'U}
10099   \gdefchar^^db{\^U}
10100   \gdefchar^^dc{\"U}
10101   \gdefchar^^dd{\'Y}
10102   \gdefchar^^de{\TH}
10103   \gdefchar^^df{\ss}
10104   %
10105   \gdefchar^^e0{\`a}
10106   \gdefchar^^e1{\'a}
10107   \gdefchar^^e2{\^a}
10108   \gdefchar^^e3{\~a}
10109   \gdefchar^^e4{\"a}
10110   \gdefchar^^e5{\ringaccent a}
10111   \gdefchar^^e6{\ae}
10112   \gdefchar^^e7{\cedilla c}
10113   \gdefchar^^e8{\`e}
10114   \gdefchar^^e9{\'e}
10115   \gdefchar^^ea{\^e}
10116   \gdefchar^^eb{\"e}
10117   \gdefchar^^ec{\`{\dotless i}}
10118   \gdefchar^^ed{\'{\dotless i}}
10119   \gdefchar^^ee{\^{\dotless i}}
10120   \gdefchar^^ef{\"{\dotless i}}
10121   %
10122   \gdefchar^^f0{\dh}
10123   \gdefchar^^f1{\~n}
10124   \gdefchar^^f2{\`o}
10125   \gdefchar^^f3{\'o}
10126   \gdefchar^^f4{\^o}
10127   \gdefchar^^f5{\~o}
10128   \gdefchar^^f6{\"o}
10129   \gdefchar^^f7{$\div$}
10130   \gdefchar^^f8{\o}
10131   \gdefchar^^f9{\`u}
10132   \gdefchar^^fa{\'u}
10133   \gdefchar^^fb{\^u}
10134   \gdefchar^^fc{\"u}
10135   \gdefchar^^fd{\'y}
10136   \gdefchar^^fe{\th}
10137   \gdefchar^^ff{\"y}
10138 }
10139
10140 % Latin9 (ISO-8859-15) encoding character definitions.
10141 \def\latninechardefs{%
10142   % Encoding is almost identical to Latin1.
10143   \latonechardefs
10144   %
10145   \gdefchar^^a4{\euro{}}
10146   \gdefchar^^a6{\v S}
10147   \gdefchar^^a8{\v s}
10148   \gdefchar^^b4{\v Z}
10149   \gdefchar^^b8{\v z}
10150   \gdefchar^^bc{\OE}
10151   \gdefchar^^bd{\oe}
10152   \gdefchar^^be{\"Y}
10153 }
10154
10155 % Latin2 (ISO-8859-2) character definitions.
10156 \def\lattwochardefs{%
10157   \gdefchar^^a0{\tie}
10158   \gdefchar^^a1{\ogonek{A}}
10159   \gdefchar^^a2{\u{}}
10160   \gdefchar^^a3{\L}
10161   \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
10162   \gdefchar^^a5{\v L}
10163   \gdefchar^^a6{\'S}
10164   \gdefchar^^a7{\S}
10165   \gdefchar^^a8{\"{}}
10166   \gdefchar^^a9{\v S}
10167   \gdefchar^^aa{\cedilla S}
10168   \gdefchar^^ab{\v T}
10169   \gdefchar^^ac{\'Z}
10170   \gdefchar^^ad{\-}
10171   \gdefchar^^ae{\v Z}
10172   \gdefchar^^af{\dotaccent Z}
10173   %
10174   \gdefchar^^b0{\textdegree{}}
10175   \gdefchar^^b1{\ogonek{a}}
10176   \gdefchar^^b2{\ogonek{ }}
10177   \gdefchar^^b3{\l}
10178   \gdefchar^^b4{\'{}}
10179   \gdefchar^^b5{\v l}
10180   \gdefchar^^b6{\'s}
10181   \gdefchar^^b7{\v{}}
10182   \gdefchar^^b8{\cedilla\ }
10183   \gdefchar^^b9{\v s}
10184   \gdefchar^^ba{\cedilla s}
10185   \gdefchar^^bb{\v t}
10186   \gdefchar^^bc{\'z}
10187   \gdefchar^^bd{\H{}}
10188   \gdefchar^^be{\v z}
10189   \gdefchar^^bf{\dotaccent z}
10190   %
10191   \gdefchar^^c0{\'R}
10192   \gdefchar^^c1{\'A}
10193   \gdefchar^^c2{\^A}
10194   \gdefchar^^c3{\u A}
10195   \gdefchar^^c4{\"A}
10196   \gdefchar^^c5{\'L}
10197   \gdefchar^^c6{\'C}
10198   \gdefchar^^c7{\cedilla C}
10199   \gdefchar^^c8{\v C}
10200   \gdefchar^^c9{\'E}
10201   \gdefchar^^ca{\ogonek{E}}
10202   \gdefchar^^cb{\"E}
10203   \gdefchar^^cc{\v E}
10204   \gdefchar^^cd{\'I}
10205   \gdefchar^^ce{\^I}
10206   \gdefchar^^cf{\v D}
10207   %
10208   \gdefchar^^d0{\DH}
10209   \gdefchar^^d1{\'N}
10210   \gdefchar^^d2{\v N}
10211   \gdefchar^^d3{\'O}
10212   \gdefchar^^d4{\^O}
10213   \gdefchar^^d5{\H O}
10214   \gdefchar^^d6{\"O}
10215   \gdefchar^^d7{$\times$}
10216   \gdefchar^^d8{\v R}
10217   \gdefchar^^d9{\ringaccent U}
10218   \gdefchar^^da{\'U}
10219   \gdefchar^^db{\H U}
10220   \gdefchar^^dc{\"U}
10221   \gdefchar^^dd{\'Y}
10222   \gdefchar^^de{\cedilla T}
10223   \gdefchar^^df{\ss}
10224   %
10225   \gdefchar^^e0{\'r}
10226   \gdefchar^^e1{\'a}
10227   \gdefchar^^e2{\^a}
10228   \gdefchar^^e3{\u a}
10229   \gdefchar^^e4{\"a}
10230   \gdefchar^^e5{\'l}
10231   \gdefchar^^e6{\'c}
10232   \gdefchar^^e7{\cedilla c}
10233   \gdefchar^^e8{\v c}
10234   \gdefchar^^e9{\'e}
10235   \gdefchar^^ea{\ogonek{e}}
10236   \gdefchar^^eb{\"e}
10237   \gdefchar^^ec{\v e}
10238   \gdefchar^^ed{\'{\dotless{i}}}
10239   \gdefchar^^ee{\^{\dotless{i}}}
10240   \gdefchar^^ef{\v d}
10241   %
10242   \gdefchar^^f0{\dh}
10243   \gdefchar^^f1{\'n}
10244   \gdefchar^^f2{\v n}
10245   \gdefchar^^f3{\'o}
10246   \gdefchar^^f4{\^o}
10247   \gdefchar^^f5{\H o}
10248   \gdefchar^^f6{\"o}
10249   \gdefchar^^f7{$\div$}
10250   \gdefchar^^f8{\v r}
10251   \gdefchar^^f9{\ringaccent u}
10252   \gdefchar^^fa{\'u}
10253   \gdefchar^^fb{\H u}
10254   \gdefchar^^fc{\"u}
10255   \gdefchar^^fd{\'y}
10256   \gdefchar^^fe{\cedilla t}
10257   \gdefchar^^ff{\dotaccent{}}
10258 }
10259
10260 % UTF-8 character definitions.
10261 %
10262 % This code to support UTF-8 is based on LaTeX's utf8.def, with some
10263 % changes for Texinfo conventions.  It is included here under the GPL by
10264 % permission from Frank Mittelbach and the LaTeX team.
10265 %
10266 \newcount\countUTFx
10267 \newcount\countUTFy
10268 \newcount\countUTFz
10269
10270 \gdef\UTFviiiTwoOctets#1#2{\expandafter
10271    \UTFviiiDefined\csname u8:#1\string #2\endcsname}
10272 %
10273 \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
10274    \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
10275 %
10276 \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
10277    \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
10278
10279 \gdef\UTFviiiDefined#1{%
10280   \ifx #1\relax
10281     \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10282   \else
10283     \expandafter #1%
10284   \fi
10285 }
10286
10287 % Give non-ASCII bytes the active definitions for processing UTF-8 sequences
10288 \begingroup
10289   \catcode`\~13
10290   \catcode`\$12
10291   \catcode`\"12
10292
10293   % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
10294   % substituting ~ and $ with a character token of that value.
10295   \def\UTFviiiLoop{%
10296     \global\catcode\countUTFx\active
10297     \uccode`\~\countUTFx
10298     \uccode`\$\countUTFx
10299     \uppercase\expandafter{\UTFviiiTmp}%
10300     \advance\countUTFx by 1
10301     \ifnum\countUTFx < \countUTFy
10302       \expandafter\UTFviiiLoop
10303     \fi}
10304
10305   % For bytes other than the first in a UTF-8 sequence.  Not expected to
10306   % be expanded except when writing to auxiliary files.
10307   \countUTFx = "80
10308   \countUTFy = "C2
10309   \def\UTFviiiTmp{%
10310     \gdef~{%
10311         \ifpassthroughchars $\fi}}%
10312   \UTFviiiLoop
10313
10314   \countUTFx = "C2
10315   \countUTFy = "E0
10316   \def\UTFviiiTmp{%
10317     \gdef~{%
10318         \ifpassthroughchars $%
10319         \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
10320   \UTFviiiLoop
10321
10322   \countUTFx = "E0
10323   \countUTFy = "F0
10324   \def\UTFviiiTmp{%
10325     \gdef~{%
10326         \ifpassthroughchars $%
10327         \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
10328   \UTFviiiLoop
10329
10330   \countUTFx = "F0
10331   \countUTFy = "F4
10332   \def\UTFviiiTmp{%
10333     \gdef~{%
10334         \ifpassthroughchars $%
10335         \else\expandafter\UTFviiiFourOctets\expandafter$\fi
10336         }}%
10337   \UTFviiiLoop
10338 \endgroup
10339
10340 \def\globallet{\global\let} % save some \expandafter's below
10341
10342 % @U{xxxx} to produce U+xxxx, if we support it.
10343 \def\U#1{%
10344   \expandafter\ifx\csname uni:#1\endcsname \relax
10345     \iftxinativeunicodecapable
10346       % All Unicode characters can be used if native Unicode handling is
10347       % active.  However, if the font does not have the glyph,
10348       % letters are missing.
10349       \begingroup
10350         \uccode`\.="#1\relax
10351         \uppercase{.}
10352       \endgroup
10353     \else
10354       \errhelp = \EMsimple      
10355       \errmessage{Unicode character U+#1 not supported, sorry}%
10356     \fi
10357   \else
10358     \csname uni:#1\endcsname
10359   \fi
10360 }
10361
10362 % These macros are used here to construct the name of a control
10363 % sequence to be defined.
10364 \def\UTFviiiTwoOctetsName#1#2{%
10365   \csname u8:#1\string #2\endcsname}%
10366 \def\UTFviiiThreeOctetsName#1#2#3{%
10367   \csname u8:#1\string #2\string #3\endcsname}%
10368 \def\UTFviiiFourOctetsName#1#2#3#4{%
10369   \csname u8:#1\string #2\string #3\string #4\endcsname}%
10370
10371 % For UTF-8 byte sequences (TeX, e-TeX and pdfTeX),
10372 % provide a definition macro to replace a Unicode character;
10373 % this gets used by the @U command
10374 %
10375 \begingroup
10376   \catcode`\"=12
10377   \catcode`\<=12
10378   \catcode`\.=12
10379   \catcode`\,=12
10380   \catcode`\;=12
10381   \catcode`\!=12
10382   \catcode`\~=13
10383   \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
10384     \countUTFz = "#1\relax
10385     \begingroup
10386       \parseXMLCharref
10387     
10388       % Give \u8:... its definition.  The sequence of seven \expandafter's
10389       % expands after the \gdef three times, e.g.
10390       %
10391       % 1.  \UTFviiTwoOctetsName B1 B2
10392       % 2.  \csname u8:B1 \string B2 \endcsname
10393       % 3.  \u8: B1 B2  (a single control sequence token)
10394       %
10395       \expandafter\expandafter
10396       \expandafter\expandafter
10397       \expandafter\expandafter
10398       \expandafter\gdef       \UTFviiiTmp{#2}%
10399       % 
10400       \expandafter\ifx\csname uni:#1\endcsname \relax \else
10401        \message{Internal error, already defined: #1}%
10402       \fi
10403       %
10404       % define an additional control sequence for this code point.
10405       \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
10406     \endgroup}
10407   %
10408   % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp
10409   % to the corresponding UTF-8 sequence.
10410   \gdef\parseXMLCharref{%
10411     \ifnum\countUTFz < "A0\relax
10412       \errhelp = \EMsimple
10413       \errmessage{Cannot define Unicode char value < 00A0}%
10414     \else\ifnum\countUTFz < "800\relax
10415       \parseUTFviiiA,%
10416       \parseUTFviiiB C\UTFviiiTwoOctetsName.,%
10417     \else\ifnum\countUTFz < "10000\relax
10418       \parseUTFviiiA;%
10419       \parseUTFviiiA,%
10420       \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}%
10421     \else
10422       \parseUTFviiiA;%
10423       \parseUTFviiiA,%
10424       \parseUTFviiiA!%
10425       \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}%
10426     \fi\fi\fi
10427   }
10428
10429   % Extract a byte from the end of the UTF-8 representation of \countUTFx.
10430   % It must be a non-initial byte in the sequence.
10431   % Change \uccode of #1 for it to be used in \parseUTFviiiB as one
10432   % of the bytes.
10433   \gdef\parseUTFviiiA#1{%
10434     \countUTFx = \countUTFz
10435     \divide\countUTFz by 64
10436     \countUTFy = \countUTFz  % Save to be the future value of \countUTFz.
10437     \multiply\countUTFz by 64
10438     
10439     % \countUTFz is now \countUTFx with the last 5 bits cleared.  Subtract
10440     % in order to get the last five bits.
10441     \advance\countUTFx by -\countUTFz
10442
10443     % Convert this to the byte in the UTF-8 sequence.
10444     \advance\countUTFx by 128
10445     \uccode `#1\countUTFx
10446     \countUTFz = \countUTFy}
10447
10448   % Used to put a UTF-8 byte sequence into \UTFviiiTmp
10449   % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8
10450   %    sequence.
10451   % #2 is one of the \UTFviii*OctetsName macros.
10452   % #3 is always a full stop (.)
10453   % #4 is a template for the other bytes in the sequence.  The values for these
10454   %    bytes is substituted in here with \uppercase using the \uccode's.
10455   \gdef\parseUTFviiiB#1#2#3#4{%
10456     \advance\countUTFz by "#10\relax
10457     \uccode `#3\countUTFz
10458     \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10459 \endgroup
10460
10461 % For native Unicode handling (XeTeX and LuaTeX),
10462 % provide a definition macro that sets a catcode to `other' non-globally
10463 %
10464 \def\DeclareUnicodeCharacterNativeOther#1#2{%
10465   \catcode"#1=\other
10466 }
10467
10468 % https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10469 % U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10470 % U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10471 % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10472 % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10473
10474 % Many of our renditions are less than wonderful, and all the missing
10475 % characters are available somewhere.  Loading the necessary fonts
10476 % awaits user request.  We can't truly support Unicode without
10477 % reimplementing everything that's been done in LaTeX for many years,
10478 % plus probably using luatex or xetex, and who knows what else.
10479 % We won't be doing that here in this simple file.  But we can try to at
10480 % least make most of the characters not bomb out.
10481 %
10482 \def\unicodechardefs{%
10483   \DeclareUnicodeCharacter{00A0}{\tie}%
10484   \DeclareUnicodeCharacter{00A1}{\exclamdown}%
10485   \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
10486   \DeclareUnicodeCharacter{00A3}{\pounds{}}%
10487   \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10488   \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10489   \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
10490   \DeclareUnicodeCharacter{00A7}{\S}%
10491   \DeclareUnicodeCharacter{00A8}{\"{ }}%
10492   \DeclareUnicodeCharacter{00A9}{\copyright{}}%
10493   \DeclareUnicodeCharacter{00AA}{\ordf}%
10494   \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}%
10495   \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10496   \DeclareUnicodeCharacter{00AD}{\-}%
10497   \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}%
10498   \DeclareUnicodeCharacter{00AF}{\={ }}%
10499   %
10500   \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
10501   \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10502   \DeclareUnicodeCharacter{00B2}{$^2$}%
10503   \DeclareUnicodeCharacter{00B3}{$^3$}%
10504   \DeclareUnicodeCharacter{00B4}{\'{ }}%
10505   \DeclareUnicodeCharacter{00B5}{$\mu$}%
10506   \DeclareUnicodeCharacter{00B6}{\P}%
10507   \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10508   \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10509   \DeclareUnicodeCharacter{00B9}{$^1$}%
10510   \DeclareUnicodeCharacter{00BA}{\ordm}%
10511   \DeclareUnicodeCharacter{00BB}{\guillemetright{}}%
10512   \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10513   \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10514   \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10515   \DeclareUnicodeCharacter{00BF}{\questiondown}%
10516   %
10517   \DeclareUnicodeCharacter{00C0}{\`A}%
10518   \DeclareUnicodeCharacter{00C1}{\'A}%
10519   \DeclareUnicodeCharacter{00C2}{\^A}%
10520   \DeclareUnicodeCharacter{00C3}{\~A}%
10521   \DeclareUnicodeCharacter{00C4}{\"A}%
10522   \DeclareUnicodeCharacter{00C5}{\AA}%
10523   \DeclareUnicodeCharacter{00C6}{\AE}%
10524   \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10525   \DeclareUnicodeCharacter{00C8}{\`E}%
10526   \DeclareUnicodeCharacter{00C9}{\'E}%
10527   \DeclareUnicodeCharacter{00CA}{\^E}%
10528   \DeclareUnicodeCharacter{00CB}{\"E}%
10529   \DeclareUnicodeCharacter{00CC}{\`I}%
10530   \DeclareUnicodeCharacter{00CD}{\'I}%
10531   \DeclareUnicodeCharacter{00CE}{\^I}%
10532   \DeclareUnicodeCharacter{00CF}{\"I}%
10533   %
10534   \DeclareUnicodeCharacter{00D0}{\DH}%
10535   \DeclareUnicodeCharacter{00D1}{\~N}%
10536   \DeclareUnicodeCharacter{00D2}{\`O}%
10537   \DeclareUnicodeCharacter{00D3}{\'O}%
10538   \DeclareUnicodeCharacter{00D4}{\^O}%
10539   \DeclareUnicodeCharacter{00D5}{\~O}%
10540   \DeclareUnicodeCharacter{00D6}{\"O}%
10541   \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10542   \DeclareUnicodeCharacter{00D8}{\O}%
10543   \DeclareUnicodeCharacter{00D9}{\`U}%
10544   \DeclareUnicodeCharacter{00DA}{\'U}%
10545   \DeclareUnicodeCharacter{00DB}{\^U}%
10546   \DeclareUnicodeCharacter{00DC}{\"U}%
10547   \DeclareUnicodeCharacter{00DD}{\'Y}%
10548   \DeclareUnicodeCharacter{00DE}{\TH}%
10549   \DeclareUnicodeCharacter{00DF}{\ss}%
10550   %
10551   \DeclareUnicodeCharacter{00E0}{\`a}%
10552   \DeclareUnicodeCharacter{00E1}{\'a}%
10553   \DeclareUnicodeCharacter{00E2}{\^a}%
10554   \DeclareUnicodeCharacter{00E3}{\~a}%
10555   \DeclareUnicodeCharacter{00E4}{\"a}%
10556   \DeclareUnicodeCharacter{00E5}{\aa}%
10557   \DeclareUnicodeCharacter{00E6}{\ae}%
10558   \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10559   \DeclareUnicodeCharacter{00E8}{\`e}%
10560   \DeclareUnicodeCharacter{00E9}{\'e}%
10561   \DeclareUnicodeCharacter{00EA}{\^e}%
10562   \DeclareUnicodeCharacter{00EB}{\"e}%
10563   \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10564   \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10565   \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10566   \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10567   %
10568   \DeclareUnicodeCharacter{00F0}{\dh}%
10569   \DeclareUnicodeCharacter{00F1}{\~n}%
10570   \DeclareUnicodeCharacter{00F2}{\`o}%
10571   \DeclareUnicodeCharacter{00F3}{\'o}%
10572   \DeclareUnicodeCharacter{00F4}{\^o}%
10573   \DeclareUnicodeCharacter{00F5}{\~o}%
10574   \DeclareUnicodeCharacter{00F6}{\"o}%
10575   \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10576   \DeclareUnicodeCharacter{00F8}{\o}%
10577   \DeclareUnicodeCharacter{00F9}{\`u}%
10578   \DeclareUnicodeCharacter{00FA}{\'u}%
10579   \DeclareUnicodeCharacter{00FB}{\^u}%
10580   \DeclareUnicodeCharacter{00FC}{\"u}%
10581   \DeclareUnicodeCharacter{00FD}{\'y}%
10582   \DeclareUnicodeCharacter{00FE}{\th}%
10583   \DeclareUnicodeCharacter{00FF}{\"y}%
10584   %
10585   \DeclareUnicodeCharacter{0100}{\=A}%
10586   \DeclareUnicodeCharacter{0101}{\=a}%
10587   \DeclareUnicodeCharacter{0102}{\u{A}}%
10588   \DeclareUnicodeCharacter{0103}{\u{a}}%
10589   \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10590   \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10591   \DeclareUnicodeCharacter{0106}{\'C}%
10592   \DeclareUnicodeCharacter{0107}{\'c}%
10593   \DeclareUnicodeCharacter{0108}{\^C}%
10594   \DeclareUnicodeCharacter{0109}{\^c}%
10595   \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10596   \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10597   \DeclareUnicodeCharacter{010C}{\v{C}}%
10598   \DeclareUnicodeCharacter{010D}{\v{c}}%
10599   \DeclareUnicodeCharacter{010E}{\v{D}}%
10600   \DeclareUnicodeCharacter{010F}{d'}%
10601   %
10602   \DeclareUnicodeCharacter{0110}{\DH}%
10603   \DeclareUnicodeCharacter{0111}{\dh}%
10604   \DeclareUnicodeCharacter{0112}{\=E}%
10605   \DeclareUnicodeCharacter{0113}{\=e}%
10606   \DeclareUnicodeCharacter{0114}{\u{E}}%
10607   \DeclareUnicodeCharacter{0115}{\u{e}}%
10608   \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10609   \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10610   \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10611   \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10612   \DeclareUnicodeCharacter{011A}{\v{E}}%
10613   \DeclareUnicodeCharacter{011B}{\v{e}}%
10614   \DeclareUnicodeCharacter{011C}{\^G}%
10615   \DeclareUnicodeCharacter{011D}{\^g}%
10616   \DeclareUnicodeCharacter{011E}{\u{G}}%
10617   \DeclareUnicodeCharacter{011F}{\u{g}}%
10618   %
10619   \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10620   \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10621   \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10622   \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10623   \DeclareUnicodeCharacter{0124}{\^H}%
10624   \DeclareUnicodeCharacter{0125}{\^h}%
10625   \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10626   \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10627   \DeclareUnicodeCharacter{0128}{\~I}%
10628   \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10629   \DeclareUnicodeCharacter{012A}{\=I}%
10630   \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10631   \DeclareUnicodeCharacter{012C}{\u{I}}%
10632   \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10633   \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10634   \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10635   %
10636   \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10637   \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10638   \DeclareUnicodeCharacter{0132}{IJ}%
10639   \DeclareUnicodeCharacter{0133}{ij}%
10640   \DeclareUnicodeCharacter{0134}{\^J}%
10641   \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10642   \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10643   \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10644   \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10645   \DeclareUnicodeCharacter{0139}{\'L}%
10646   \DeclareUnicodeCharacter{013A}{\'l}%
10647   \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10648   \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
10649   \DeclareUnicodeCharacter{013D}{L'}% should kern
10650   \DeclareUnicodeCharacter{013E}{l'}% should kern
10651   \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10652   %
10653   \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10654   \DeclareUnicodeCharacter{0141}{\L}%
10655   \DeclareUnicodeCharacter{0142}{\l}%
10656   \DeclareUnicodeCharacter{0143}{\'N}%
10657   \DeclareUnicodeCharacter{0144}{\'n}%
10658   \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10659   \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10660   \DeclareUnicodeCharacter{0147}{\v{N}}%
10661   \DeclareUnicodeCharacter{0148}{\v{n}}%
10662   \DeclareUnicodeCharacter{0149}{'n}%
10663   \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10664   \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10665   \DeclareUnicodeCharacter{014C}{\=O}%
10666   \DeclareUnicodeCharacter{014D}{\=o}%
10667   \DeclareUnicodeCharacter{014E}{\u{O}}%
10668   \DeclareUnicodeCharacter{014F}{\u{o}}%
10669   %
10670   \DeclareUnicodeCharacter{0150}{\H{O}}%
10671   \DeclareUnicodeCharacter{0151}{\H{o}}%
10672   \DeclareUnicodeCharacter{0152}{\OE}%
10673   \DeclareUnicodeCharacter{0153}{\oe}%
10674   \DeclareUnicodeCharacter{0154}{\'R}%
10675   \DeclareUnicodeCharacter{0155}{\'r}%
10676   \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10677   \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10678   \DeclareUnicodeCharacter{0158}{\v{R}}%
10679   \DeclareUnicodeCharacter{0159}{\v{r}}%
10680   \DeclareUnicodeCharacter{015A}{\'S}%
10681   \DeclareUnicodeCharacter{015B}{\'s}%
10682   \DeclareUnicodeCharacter{015C}{\^S}%
10683   \DeclareUnicodeCharacter{015D}{\^s}%
10684   \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10685   \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10686   %
10687   \DeclareUnicodeCharacter{0160}{\v{S}}%
10688   \DeclareUnicodeCharacter{0161}{\v{s}}%
10689   \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10690   \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10691   \DeclareUnicodeCharacter{0164}{\v{T}}%
10692   \DeclareUnicodeCharacter{0165}{\v{t}}%
10693   \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10694   \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10695   \DeclareUnicodeCharacter{0168}{\~U}%
10696   \DeclareUnicodeCharacter{0169}{\~u}%
10697   \DeclareUnicodeCharacter{016A}{\=U}%
10698   \DeclareUnicodeCharacter{016B}{\=u}%
10699   \DeclareUnicodeCharacter{016C}{\u{U}}%
10700   \DeclareUnicodeCharacter{016D}{\u{u}}%
10701   \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10702   \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10703   %
10704   \DeclareUnicodeCharacter{0170}{\H{U}}%
10705   \DeclareUnicodeCharacter{0171}{\H{u}}%
10706   \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10707   \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10708   \DeclareUnicodeCharacter{0174}{\^W}%
10709   \DeclareUnicodeCharacter{0175}{\^w}%
10710   \DeclareUnicodeCharacter{0176}{\^Y}%
10711   \DeclareUnicodeCharacter{0177}{\^y}%
10712   \DeclareUnicodeCharacter{0178}{\"Y}%
10713   \DeclareUnicodeCharacter{0179}{\'Z}%
10714   \DeclareUnicodeCharacter{017A}{\'z}%
10715   \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10716   \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10717   \DeclareUnicodeCharacter{017D}{\v{Z}}%
10718   \DeclareUnicodeCharacter{017E}{\v{z}}%
10719   \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10720   %
10721   \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10722   \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10723   \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10724   \DeclareUnicodeCharacter{01C7}{LJ}%
10725   \DeclareUnicodeCharacter{01C8}{Lj}%
10726   \DeclareUnicodeCharacter{01C9}{lj}%
10727   \DeclareUnicodeCharacter{01CA}{NJ}%
10728   \DeclareUnicodeCharacter{01CB}{Nj}%
10729   \DeclareUnicodeCharacter{01CC}{nj}%
10730   \DeclareUnicodeCharacter{01CD}{\v{A}}%
10731   \DeclareUnicodeCharacter{01CE}{\v{a}}%
10732   \DeclareUnicodeCharacter{01CF}{\v{I}}%
10733   %
10734   \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10735   \DeclareUnicodeCharacter{01D1}{\v{O}}%
10736   \DeclareUnicodeCharacter{01D2}{\v{o}}%
10737   \DeclareUnicodeCharacter{01D3}{\v{U}}%
10738   \DeclareUnicodeCharacter{01D4}{\v{u}}%
10739   %
10740   \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10741   \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10742   \DeclareUnicodeCharacter{01E6}{\v{G}}%
10743   \DeclareUnicodeCharacter{01E7}{\v{g}}%
10744   \DeclareUnicodeCharacter{01E8}{\v{K}}%
10745   \DeclareUnicodeCharacter{01E9}{\v{k}}%
10746   %
10747   \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10748   \DeclareUnicodeCharacter{01F1}{DZ}%
10749   \DeclareUnicodeCharacter{01F2}{Dz}%
10750   \DeclareUnicodeCharacter{01F3}{dz}%
10751   \DeclareUnicodeCharacter{01F4}{\'G}%
10752   \DeclareUnicodeCharacter{01F5}{\'g}%
10753   \DeclareUnicodeCharacter{01F8}{\`N}%
10754   \DeclareUnicodeCharacter{01F9}{\`n}%
10755   \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10756   \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10757   \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10758   \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10759   %
10760   \DeclareUnicodeCharacter{021E}{\v{H}}%
10761   \DeclareUnicodeCharacter{021F}{\v{h}}%
10762   %
10763   \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10764   \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10765   \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10766   \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10767   \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10768   \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10769   %
10770   \DeclareUnicodeCharacter{0232}{\=Y}%
10771   \DeclareUnicodeCharacter{0233}{\=y}%
10772   \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10773   %
10774   \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10775   %
10776   % Greek letters upper case
10777   \DeclareUnicodeCharacter{0391}{{\it A}}%
10778   \DeclareUnicodeCharacter{0392}{{\it B}}%
10779   \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10780   \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10781   \DeclareUnicodeCharacter{0395}{{\it E}}%
10782   \DeclareUnicodeCharacter{0396}{{\it Z}}%
10783   \DeclareUnicodeCharacter{0397}{{\it H}}%
10784   \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10785   \DeclareUnicodeCharacter{0399}{{\it I}}%
10786   \DeclareUnicodeCharacter{039A}{{\it K}}%
10787   \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10788   \DeclareUnicodeCharacter{039C}{{\it M}}%
10789   \DeclareUnicodeCharacter{039D}{{\it N}}%
10790   \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10791   \DeclareUnicodeCharacter{039F}{{\it O}}%
10792   \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10793   \DeclareUnicodeCharacter{03A1}{{\it P}}%
10794   %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
10795   \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10796   \DeclareUnicodeCharacter{03A4}{{\it T}}%
10797   \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10798   \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10799   \DeclareUnicodeCharacter{03A7}{{\it X}}%
10800   \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10801   \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10802   %
10803   % Vowels with accents
10804   \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10805   \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10806   \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10807   \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10808   \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10809   \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10810   %
10811   % Standalone accent
10812   \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10813   %
10814   % Greek letters lower case
10815   \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10816   \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10817   \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10818   \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10819   \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10820   \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10821   \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10822   \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10823   \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10824   \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10825   \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10826   \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10827   \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10828   \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10829   \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10830   \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10831   \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10832   \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10833   \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10834   \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10835   \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10836   \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10837   \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10838   \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10839   \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10840   %
10841   % More Greek vowels with accents
10842   \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10843   \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10844   \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10845   \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10846   \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10847   %
10848   % Variant Greek letters
10849   \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10850   \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10851   \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10852   %
10853   \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10854   \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10855   \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10856   \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10857   \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10858   \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10859   \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10860   \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10861   \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10862   \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10863   \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10864   \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10865   %
10866   \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10867   \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10868   %
10869   \DeclareUnicodeCharacter{1E20}{\=G}%
10870   \DeclareUnicodeCharacter{1E21}{\=g}%
10871   \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10872   \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10873   \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10874   \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10875   \DeclareUnicodeCharacter{1E26}{\"H}%
10876   \DeclareUnicodeCharacter{1E27}{\"h}%
10877   %
10878   \DeclareUnicodeCharacter{1E30}{\'K}%
10879   \DeclareUnicodeCharacter{1E31}{\'k}%
10880   \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10881   \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10882   \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10883   \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10884   \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10885   \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10886   \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10887   \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10888   \DeclareUnicodeCharacter{1E3E}{\'M}%
10889   \DeclareUnicodeCharacter{1E3F}{\'m}%
10890   %
10891   \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10892   \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10893   \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10894   \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10895   \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10896   \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10897   \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10898   \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10899   \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10900   \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10901   %
10902   \DeclareUnicodeCharacter{1E54}{\'P}%
10903   \DeclareUnicodeCharacter{1E55}{\'p}%
10904   \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10905   \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10906   \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10907   \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10908   \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10909   \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10910   \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10911   \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10912   %
10913   \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10914   \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10915   \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10916   \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10917   \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10918   \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10919   \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10920   \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10921   \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10922   \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10923   %
10924   \DeclareUnicodeCharacter{1E7C}{\~V}%
10925   \DeclareUnicodeCharacter{1E7D}{\~v}%
10926   \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10927   \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10928   %
10929   \DeclareUnicodeCharacter{1E80}{\`W}%
10930   \DeclareUnicodeCharacter{1E81}{\`w}%
10931   \DeclareUnicodeCharacter{1E82}{\'W}%
10932   \DeclareUnicodeCharacter{1E83}{\'w}%
10933   \DeclareUnicodeCharacter{1E84}{\"W}%
10934   \DeclareUnicodeCharacter{1E85}{\"w}%
10935   \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10936   \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10937   \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10938   \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10939   \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10940   \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10941   \DeclareUnicodeCharacter{1E8C}{\"X}%
10942   \DeclareUnicodeCharacter{1E8D}{\"x}%
10943   \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10944   \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10945   %
10946   \DeclareUnicodeCharacter{1E90}{\^Z}%
10947   \DeclareUnicodeCharacter{1E91}{\^z}%
10948   \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
10949   \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
10950   \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
10951   \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
10952   \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
10953   \DeclareUnicodeCharacter{1E97}{\"t}%
10954   \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
10955   \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
10956   %
10957   \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
10958   \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
10959   %
10960   \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
10961   \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
10962   \DeclareUnicodeCharacter{1EBC}{\~E}%
10963   \DeclareUnicodeCharacter{1EBD}{\~e}%
10964   %
10965   \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
10966   \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
10967   \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
10968   \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
10969   %
10970   \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
10971   \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
10972   %
10973   \DeclareUnicodeCharacter{1EF2}{\`Y}%
10974   \DeclareUnicodeCharacter{1EF3}{\`y}%
10975   \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
10976   %
10977   \DeclareUnicodeCharacter{1EF8}{\~Y}%
10978   \DeclareUnicodeCharacter{1EF9}{\~y}%
10979   %
10980   % Punctuation
10981   \DeclareUnicodeCharacter{2013}{--}%
10982   \DeclareUnicodeCharacter{2014}{---}%
10983   \DeclareUnicodeCharacter{2018}{\quoteleft{}}%
10984   \DeclareUnicodeCharacter{2019}{\quoteright{}}%
10985   \DeclareUnicodeCharacter{201A}{\quotesinglbase{}}%
10986   \DeclareUnicodeCharacter{201C}{\quotedblleft{}}%
10987   \DeclareUnicodeCharacter{201D}{\quotedblright{}}%
10988   \DeclareUnicodeCharacter{201E}{\quotedblbase{}}%
10989   \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}%
10990   \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}%
10991   \DeclareUnicodeCharacter{2022}{\bullet{}}%
10992   \DeclareUnicodeCharacter{202F}{\thinspace}%
10993   \DeclareUnicodeCharacter{2026}{\dots{}}%
10994   \DeclareUnicodeCharacter{2039}{\guilsinglleft{}}%
10995   \DeclareUnicodeCharacter{203A}{\guilsinglright{}}%
10996   %
10997   \DeclareUnicodeCharacter{20AC}{\euro{}}%
10998   %
10999   \DeclareUnicodeCharacter{2192}{\expansion{}}%
11000   \DeclareUnicodeCharacter{21D2}{\result{}}%
11001   %
11002   % Mathematical symbols
11003   \DeclareUnicodeCharacter{2200}{\ensuremath\forall}%
11004   \DeclareUnicodeCharacter{2203}{\ensuremath\exists}%
11005   \DeclareUnicodeCharacter{2208}{\ensuremath\in}%
11006   \DeclareUnicodeCharacter{2212}{\minus{}}%
11007   \DeclareUnicodeCharacter{2217}{\ast}%
11008   \DeclareUnicodeCharacter{221E}{\ensuremath\infty}%
11009   \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}%
11010   \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}%
11011   \DeclareUnicodeCharacter{2229}{\ensuremath\cap}%
11012   \DeclareUnicodeCharacter{2261}{\equiv{}}%
11013   \DeclareUnicodeCharacter{2264}{\ensuremath\leq}%
11014   \DeclareUnicodeCharacter{2265}{\ensuremath\geq}%
11015   \DeclareUnicodeCharacter{2282}{\ensuremath\subset}%
11016   \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}%
11017   %
11018   \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}%
11019   \DeclareUnicodeCharacter{2032}{\ensuremath\prime}%
11020   \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}%
11021   \DeclareUnicodeCharacter{2111}{\ensuremath\Im}%
11022   \DeclareUnicodeCharacter{2113}{\ensuremath\ell}%
11023   \DeclareUnicodeCharacter{2118}{\ensuremath\wp}%
11024   \DeclareUnicodeCharacter{211C}{\ensuremath\Re}%
11025   \DeclareUnicodeCharacter{2127}{\ensuremath\mho}%
11026   \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}%
11027   \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}%
11028   \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}%
11029   \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}%
11030   \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}%
11031   \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}%
11032   \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}%
11033   \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}%
11034   \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}%
11035   \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}%
11036   \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}%
11037   \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}%
11038   \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}%
11039   \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}%
11040   \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}%
11041   \DeclareUnicodeCharacter{21BE}{\ensuremath\upharpoonright}%
11042   \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}%
11043   \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}%
11044   \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}%
11045   \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}%
11046   \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}%
11047   \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}%
11048   \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}%
11049   \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}%
11050   \DeclareUnicodeCharacter{21DD}{\ensuremath\leadsto}%
11051   \DeclareUnicodeCharacter{2201}{\ensuremath\complement}%
11052   \DeclareUnicodeCharacter{2202}{\ensuremath\partial}%
11053   \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}%
11054   \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}%
11055   \DeclareUnicodeCharacter{2209}{\ensuremath\notin}%
11056   \DeclareUnicodeCharacter{220B}{\ensuremath\owns}%
11057   \DeclareUnicodeCharacter{220F}{\ensuremath\prod}%
11058   \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}%
11059   \DeclareUnicodeCharacter{2211}{\ensuremath\sum}%
11060   \DeclareUnicodeCharacter{2213}{\ensuremath\mp}%
11061   \DeclareUnicodeCharacter{2218}{\ensuremath\circ}%
11062   \DeclareUnicodeCharacter{221A}{\ensuremath\surd}%
11063   \DeclareUnicodeCharacter{221D}{\ensuremath\propto}%
11064   \DeclareUnicodeCharacter{2220}{\ensuremath\angle}%
11065   \DeclareUnicodeCharacter{2223}{\ensuremath\mid}%
11066   \DeclareUnicodeCharacter{2228}{\ensuremath\vee}%
11067   \DeclareUnicodeCharacter{222A}{\ensuremath\cup}%
11068   \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}%
11069   \DeclareUnicodeCharacter{222E}{\ensuremath\oint}%
11070   \DeclareUnicodeCharacter{223C}{\ensuremath\sim}%
11071   \DeclareUnicodeCharacter{2240}{\ensuremath\wr}%
11072   \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}%
11073   \DeclareUnicodeCharacter{2245}{\ensuremath\cong}%
11074   \DeclareUnicodeCharacter{2248}{\ensuremath\approx}%
11075   \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}%
11076   \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}%
11077   \DeclareUnicodeCharacter{2260}{\ensuremath\neq}%
11078   \DeclareUnicodeCharacter{226A}{\ensuremath\ll}%
11079   \DeclareUnicodeCharacter{226B}{\ensuremath\gg}%
11080   \DeclareUnicodeCharacter{227A}{\ensuremath\prec}%
11081   \DeclareUnicodeCharacter{227B}{\ensuremath\succ}%
11082   \DeclareUnicodeCharacter{2283}{\ensuremath\supset}%
11083   \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}%
11084   \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}%
11085   \DeclareUnicodeCharacter{228F}{\ensuremath\sqsubset}%
11086   \DeclareUnicodeCharacter{2290}{\ensuremath\sqsupset}%
11087   \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}%
11088   \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}%
11089   \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}%
11090   \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}%
11091   \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}%
11092   \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}%
11093   \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}%
11094   \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}%
11095   \DeclareUnicodeCharacter{2299}{\ensuremath\odot}%
11096   \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}%
11097   \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}%
11098   \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}%
11099   \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}%
11100   \DeclareUnicodeCharacter{22A8}{\ensuremath\models}%
11101   \DeclareUnicodeCharacter{22B4}{\ensuremath\unlhd}%
11102   \DeclareUnicodeCharacter{22B5}{\ensuremath\unrhd}%
11103   \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}%
11104   \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}%
11105   \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}%
11106   \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}%
11107   \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}%
11108   \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}%
11109   \DeclareUnicodeCharacter{22C6}{\ensuremath\star}%
11110   \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}%
11111   \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}%
11112   \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}%
11113   \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}%
11114   \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}%
11115   \DeclareUnicodeCharacter{2322}{\ensuremath\frown}%
11116   \DeclareUnicodeCharacter{2323}{\ensuremath\smile}%
11117   %
11118   \DeclareUnicodeCharacter{25A1}{\ensuremath\Box}%
11119   \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
11120   \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
11121   \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
11122   \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
11123   \DeclareUnicodeCharacter{25C7}{\ensuremath\Diamond}%
11124   \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}%
11125   \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}%
11126   \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}%
11127   \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}%
11128   \DeclareUnicodeCharacter{266D}{\ensuremath\flat}%
11129   \DeclareUnicodeCharacter{266E}{\ensuremath\natural}%
11130   \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}%
11131   \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}%
11132   \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}%
11133   \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}%
11134   \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}%
11135   \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}%
11136   \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}%
11137   \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}%
11138   \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}%
11139   \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}%
11140   \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}%
11141   \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}%
11142   \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}%
11143   \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}%
11144   \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}%
11145   \DeclareUnicodeCharacter{2A1D}{\ensuremath\Join}%
11146   \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}%
11147   \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}%
11148   \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}%
11149   %
11150   \global\mathchardef\checkmark="1370% actually the square root sign
11151   \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}%
11152 }% end of \unicodechardefs
11153
11154 % UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
11155 % It makes the setting that replace UTF-8 byte sequence.
11156 \def\utfeightchardefs{%
11157   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
11158   \unicodechardefs
11159 }
11160
11161 % Whether the active definitions of non-ASCII characters expand to
11162 % non-active tokens with the same character code.  This is used to
11163 % write characters literally, instead of using active definitions for
11164 % printing the correct glyphs.
11165 \newif\ifpassthroughchars
11166 \passthroughcharsfalse
11167
11168 % For native Unicode handling (XeTeX and LuaTeX),
11169 % provide a definition macro to replace/pass-through a Unicode character
11170 %
11171 \def\DeclareUnicodeCharacterNative#1#2{%
11172   \catcode"#1=\active
11173   \def\dodeclareunicodecharacternative##1##2##3{%
11174     \begingroup
11175       \uccode`\~="##2\relax
11176       \uppercase{\gdef~}{%
11177         \ifpassthroughchars
11178           ##1%
11179         \else
11180           ##3%
11181         \fi
11182       }
11183     \endgroup
11184   }
11185   \begingroup
11186     \uccode`\.="#1\relax
11187     \uppercase{\def\UTFNativeTmp{.}}%
11188     \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
11189   \endgroup
11190 }
11191
11192 % Native Unicode handling (XeTeX and LuaTeX) character replacing definition.
11193 % It activates the setting that replaces Unicode characters.
11194 \def\nativeunicodechardefs{%
11195   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
11196   \unicodechardefs
11197 }
11198
11199 % For native Unicode handling (XeTeX and LuaTeX),
11200 % make the character token expand
11201 % to the sequences given in \unicodechardefs for printing.
11202 \def\DeclareUnicodeCharacterNativeAtU#1#2{%
11203   \def\UTFAtUTmp{#2}
11204   \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
11205 }
11206
11207 % @U command definitions for native Unicode handling (XeTeX and LuaTeX).
11208 \def\nativeunicodechardefsatu{%
11209   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
11210   \unicodechardefs
11211 }
11212
11213 % US-ASCII character definitions.
11214 \def\asciichardefs{% nothing need be done
11215    \relax
11216 }
11217
11218 % define all Unicode characters we know about, for the sake of @U.
11219 \iftxinativeunicodecapable
11220   \nativeunicodechardefsatu
11221 \else
11222   \utfeightchardefs
11223 \fi
11224
11225
11226 % Make non-ASCII characters printable again for compatibility with
11227 % existing Texinfo documents that may use them, even without declaring a
11228 % document encoding.
11229 %
11230 \setnonasciicharscatcode \other
11231
11232
11233 \message{formatting,}
11234
11235 \newdimen\defaultparindent \defaultparindent = 15pt
11236
11237 \chapheadingskip = 15pt plus 4pt minus 2pt
11238 \secheadingskip = 12pt plus 3pt minus 2pt
11239 \subsecheadingskip = 9pt plus 2pt minus 2pt
11240
11241 % Prevent underfull vbox error messages.
11242 \vbadness = 10000
11243
11244 % Don't be very finicky about underfull hboxes, either.
11245 \hbadness = 6666
11246
11247 % Following George Bush, get rid of widows and orphans.
11248 \widowpenalty=10000
11249 \clubpenalty=10000
11250
11251 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
11252 % using an old version of TeX, don't do anything.  We want the amount of
11253 % stretch added to depend on the line length, hence the dependence on
11254 % \hsize.  We call this whenever the paper size is set.
11255 %
11256 \def\setemergencystretch{%
11257   \ifx\emergencystretch\thisisundefined
11258     % Allow us to assign to \emergencystretch anyway.
11259     \def\emergencystretch{\dimen0}%
11260   \else
11261     \emergencystretch = .15\hsize
11262   \fi
11263 }
11264
11265 % Parameters in order: 1) textheight; 2) textwidth;
11266 % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11267 % 7) physical page height; 8) physical page width.
11268 %
11269 % We also call \setleading{\textleading}, so the caller should define
11270 % \textleading.  The caller should also set \parskip.
11271 %
11272 \def\internalpagesizes#1#2#3#4#5#6#7#8{%
11273   \voffset = #3\relax
11274   \topskip = #6\relax
11275   \splittopskip = \topskip
11276   %
11277   \vsize = #1\relax
11278   \advance\vsize by \topskip
11279   \outervsize = \vsize
11280   \advance\outervsize by 2\topandbottommargin
11281   \txipageheight = \vsize
11282   %
11283   \hsize = #2\relax
11284   \outerhsize = \hsize
11285   \advance\outerhsize by 0.5in
11286   \txipagewidth = \hsize
11287   %
11288   \normaloffset = #4\relax
11289   \bindingoffset = #5\relax
11290   %
11291   \ifpdf
11292     \pdfpageheight #7\relax
11293     \pdfpagewidth #8\relax
11294     % if we don't reset these, they will remain at "1 true in" of
11295     % whatever layout pdftex was dumped with.
11296     \pdfhorigin = 1 true in
11297     \pdfvorigin = 1 true in
11298   \else
11299     \ifx\XeTeXrevision\thisisundefined
11300     \else
11301       \pdfpageheight #7\relax
11302       \pdfpagewidth #8\relax
11303       % XeTeX does not have \pdfhorigin and \pdfvorigin.
11304     \fi
11305   \fi
11306   %
11307   \setleading{\textleading}
11308   %
11309   \parindent = \defaultparindent
11310   \setemergencystretch
11311 }
11312
11313 % @letterpaper (the default).
11314 \def\letterpaper{{\globaldefs = 1
11315   \parskip = 3pt plus 2pt minus 1pt
11316   \textleading = 13.2pt
11317   %
11318   % If page is nothing but text, make it come out even.
11319   \internalpagesizes{607.2pt}{6in}% that's 46 lines
11320                     {\voffset}{.25in}%
11321                     {\bindingoffset}{36pt}%
11322                     {11in}{8.5in}%
11323 }}
11324
11325 % Use @smallbook to reset parameters for 7x9.25 trim size.
11326 \def\smallbook{{\globaldefs = 1
11327   \parskip = 2pt plus 1pt
11328   \textleading = 12pt
11329   %
11330   \internalpagesizes{7.5in}{5in}%
11331                     {-.2in}{0in}%
11332                     {\bindingoffset}{16pt}%
11333                     {9.25in}{7in}%
11334   %
11335   \lispnarrowing = 0.3in
11336   \tolerance = 700
11337   \hfuzz = 1pt
11338   \contentsrightmargin = 0pt
11339   \defbodyindent = .5cm
11340 }}
11341
11342 % Use @smallerbook to reset parameters for 6x9 trim size.
11343 % (Just testing, parameters still in flux.)
11344 \def\smallerbook{{\globaldefs = 1
11345   \parskip = 1.5pt plus 1pt
11346   \textleading = 12pt
11347   %
11348   \internalpagesizes{7.4in}{4.8in}%
11349                     {-.2in}{-.4in}%
11350                     {0pt}{14pt}%
11351                     {9in}{6in}%
11352   %
11353   \lispnarrowing = 0.25in
11354   \tolerance = 700
11355   \hfuzz = 1pt
11356   \contentsrightmargin = 0pt
11357   \defbodyindent = .4cm
11358 }}
11359
11360 % Use @afourpaper to print on European A4 paper.
11361 \def\afourpaper{{\globaldefs = 1
11362   \parskip = 3pt plus 2pt minus 1pt
11363   \textleading = 13.2pt
11364   %
11365   % Double-side printing via postscript on Laserjet 4050
11366   % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11367   % To change the settings for a different printer or situation, adjust
11368   % \normaloffset until the front-side and back-side texts align.  Then
11369   % do the same for \bindingoffset.  You can set these for testing in
11370   % your texinfo source file like this:
11371   % @tex
11372   % \global\normaloffset = -6mm
11373   % \global\bindingoffset = 10mm
11374   % @end tex
11375   \internalpagesizes{673.2pt}{160mm}% that's 51 lines
11376                     {\voffset}{\hoffset}%
11377                     {\bindingoffset}{44pt}%
11378                     {297mm}{210mm}%
11379   %
11380   \tolerance = 700
11381   \hfuzz = 1pt
11382   \contentsrightmargin = 0pt
11383   \defbodyindent = 5mm
11384 }}
11385
11386 % Use @afivepaper to print on European A5 paper.
11387 % From romildo@urano.iceb.ufop.br, 2 July 2000.
11388 % He also recommends making @example and @lisp be small.
11389 \def\afivepaper{{\globaldefs = 1
11390   \parskip = 2pt plus 1pt minus 0.1pt
11391   \textleading = 12.5pt
11392   %
11393   \internalpagesizes{160mm}{120mm}%
11394                     {\voffset}{\hoffset}%
11395                     {\bindingoffset}{8pt}%
11396                     {210mm}{148mm}%
11397   %
11398   \lispnarrowing = 0.2in
11399   \tolerance = 800
11400   \hfuzz = 1.2pt
11401   \contentsrightmargin = 0pt
11402   \defbodyindent = 2mm
11403   \tableindent = 12mm
11404 }}
11405
11406 % A specific text layout, 24x15cm overall, intended for A4 paper.
11407 \def\afourlatex{{\globaldefs = 1
11408   \afourpaper
11409   \internalpagesizes{237mm}{150mm}%
11410                     {\voffset}{4.6mm}%
11411                     {\bindingoffset}{7mm}%
11412                     {297mm}{210mm}%
11413   %
11414   % Must explicitly reset to 0 because we call \afourpaper.
11415   \globaldefs = 0
11416 }}
11417
11418 % Use @afourwide to print on A4 paper in landscape format.
11419 \def\afourwide{{\globaldefs = 1
11420   \afourpaper
11421   \internalpagesizes{241mm}{165mm}%
11422                     {\voffset}{-2.95mm}%
11423                     {\bindingoffset}{7mm}%
11424                     {297mm}{210mm}%
11425   \globaldefs = 0
11426 }}
11427
11428 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11429 % Perhaps we should allow setting the margins, \topskip, \parskip,
11430 % and/or leading, also. Or perhaps we should compute them somehow.
11431 %
11432 \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
11433 \def\pagesizesyyy#1,#2,#3\finish{{%
11434   \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11435   \globaldefs = 1
11436   %
11437   \parskip = 3pt plus 2pt minus 1pt
11438   \setleading{\textleading}%
11439   %
11440   \dimen0 = #1\relax
11441   \advance\dimen0 by \voffset
11442   %
11443   \dimen2 = \hsize
11444   \advance\dimen2 by \normaloffset
11445   %
11446   \internalpagesizes{#1}{\hsize}%
11447                     {\voffset}{\normaloffset}%
11448                     {\bindingoffset}{44pt}%
11449                     {\dimen0}{\dimen2}%
11450 }}
11451
11452 % Set default to letter.
11453 %
11454 \letterpaper
11455
11456
11457 \message{and turning on texinfo input format.}
11458
11459 \def^^L{\par} % remove \outer, so ^L can appear in an @comment
11460
11461 % DEL is a comment character, in case @c does not suffice.
11462 \catcode`\^^? = 14
11463
11464 % Define macros to output various characters with catcode for normal text.
11465 \catcode`\"=\other \def\normaldoublequote{"}
11466 \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11467 \catcode`\+=\other \def\normalplus{+}
11468 \catcode`\<=\other \def\normalless{<}
11469 \catcode`\>=\other \def\normalgreater{>}
11470 \catcode`\^=\other \def\normalcaret{^}
11471 \catcode`\_=\other \def\normalunderscore{_}
11472 \catcode`\|=\other \def\normalverticalbar{|}
11473 \catcode`\~=\other \def\normaltilde{~}
11474
11475 % This macro is used to make a character print one way in \tt
11476 % (where it can probably be output as-is), and another way in other fonts,
11477 % where something hairier probably needs to be done.
11478 %
11479 % #1 is what to print if we are indeed using \tt; #2 is what to print
11480 % otherwise.  Since all the Computer Modern typewriter fonts have zero
11481 % interword stretch (and shrink), and it is reasonable to expect all
11482 % typewriter fonts to have this, we can check that font parameter.
11483 %
11484 \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
11485
11486 % Same as above, but check for italic font.  Actually this also catches
11487 % non-italic slanted fonts since it is impossible to distinguish them from
11488 % italic fonts.  But since this is only used by $ and it uses \sl anyway
11489 % this is not a problem.
11490 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
11491
11492 % Set catcodes for Texinfo file
11493
11494 % Active characters for printing the wanted glyph.
11495 % Most of these we simply print from the \tt font, but for some, we can
11496 % use math or other variants that look better in normal text.
11497 %
11498 \catcode`\"=\active
11499 \def\activedoublequote{{\tt\char34}}
11500 \let"=\activedoublequote
11501 \catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
11502 \chardef\hatchar=`\^
11503 \catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
11504
11505 \catcode`\_=\active
11506 \def_{\ifusingtt\normalunderscore\_}
11507 \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
11508 \let\realunder=_
11509
11510 \catcode`\|=\active \def|{{\tt\char124}}
11511
11512 \chardef \less=`\<
11513 \catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
11514 \chardef \gtr=`\>
11515 \catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11516 \catcode`\+=\active \def+{{\tt \char 43}}
11517 \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
11518 \catcode`\-=\active \let-=\normaldash
11519
11520
11521 % used for headline/footline in the output routine, in case the page
11522 % breaks in the middle of an @tex block.
11523 \def\texinfochars{%
11524   \let< = \activeless
11525   \let> = \activegtr
11526   \let~ = \activetilde 
11527   \let^ = \activehat
11528   \markupsetuplqdefault \markupsetuprqdefault 
11529   \let\b = \strong
11530   \let\i = \smartitalic
11531   % in principle, all other definitions in \tex have to be undone too.
11532 }
11533
11534 % Used sometimes to turn off (effectively) the active characters even after
11535 % parsing them.
11536 \def\turnoffactive{%
11537   \normalturnoffactive
11538   \otherbackslash
11539 }
11540
11541 \catcode`\@=0
11542
11543 % \backslashcurfont outputs one backslash character in current font,
11544 % as in \char`\\.
11545 \global\chardef\backslashcurfont=`\\
11546 \global\let\rawbackslashxx=\backslashcurfont  % let existing .??s files work
11547
11548 % \realbackslash is an actual character `\' with catcode other, and
11549 % \doublebackslash is two of them (for the pdf outlines).
11550 {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
11551
11552 % In Texinfo, backslash is an active character; it prints the backslash
11553 % in fixed width font.
11554 \catcode`\\=\active  % @ for escape char from now on.
11555
11556 % Print a typewriter backslash.  For math mode, we can't simply use
11557 % \backslashcurfont: the story here is that in math mode, the \char
11558 % of \backslashcurfont ends up printing the roman \ from the math symbol
11559 % font (because \char in math mode uses the \mathcode, and plain.tex
11560 % sets \mathcode`\\="026E).  Hence we use an explicit \mathchar,
11561 % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11562 % ignored family value; char position "5C).  We can't use " for the
11563 % usual hex value because it has already been made active.
11564
11565 @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
11566 @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
11567
11568 % \rawbackslash defines an active \ to do \backslashcurfont.
11569 % \otherbackslash defines an active \ to be a literal `\' character with
11570 % catcode other.  We switch back and forth between these.
11571 @gdef@rawbackslash{@let\=@backslashcurfont}
11572 @gdef@otherbackslash{@let\=@realbackslash}
11573
11574 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
11575 % the literal character `\'.
11576 %
11577 {@catcode`- = @active
11578  @gdef@normalturnoffactive{%
11579    @passthroughcharstrue
11580    @let-=@normaldash
11581    @let"=@normaldoublequote
11582    @let$=@normaldollar %$ font-lock fix
11583    @let+=@normalplus
11584    @let<=@normalless
11585    @let>=@normalgreater
11586    @let^=@normalcaret
11587    @let_=@normalunderscore
11588    @let|=@normalverticalbar
11589    @let~=@normaltilde
11590    @let\=@ttbackslash
11591    @markupsetuplqdefault
11592    @markupsetuprqdefault
11593    @unsepspaces
11594  }
11595 }
11596
11597 % If a .fmt file is being used, characters that might appear in a file
11598 % name cannot be active until we have parsed the command line.
11599 % So turn them off again, and have @fixbackslash turn them back on.
11600 @catcode`+=@other @catcode`@_=@other
11601
11602 % \enablebackslashhack - allow file to begin `\input texinfo'
11603 %
11604 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
11605 % That is what \eatinput is for; after that, the `\' should revert to printing
11606 % a backslash.
11607 % If the file did not have a `\input texinfo', then it is turned off after
11608 % the first line; otherwise the first `\' in the file would cause an error.
11609 % This is used on the very last line of this file, texinfo.tex.
11610 % We also use @c to call @fixbackslash, in case ends of lines are hidden.
11611 {
11612 @catcode`@^=7
11613 @catcode`@^^M=13@gdef@enablebackslashhack{%
11614   @global@let\ = @eatinput%
11615   @catcode`@^^M=13%
11616   @def@c{@fixbackslash@c}%
11617   % Definition for the newline at the end of this file.
11618   @def ^^M{@let^^M@secondlinenl}%
11619   % Definition for a newline in the main Texinfo file.
11620   @gdef @secondlinenl{@fixbackslash}%
11621 }}
11622
11623 {@catcode`@^=7 @catcode`@^^M=13%
11624 @gdef@eatinput input texinfo#1^^M{@fixbackslash}}
11625
11626 % Emergency active definition of newline, in case an active newline token
11627 % appears by mistake.
11628 {@catcode`@^=7 @catcode13=13%
11629 @gdef@enableemergencynewline{%
11630   @gdef^^M{%
11631     @par%
11632     %<warning: active newline>@par%
11633 }}}
11634
11635
11636 @gdef@fixbackslash{%
11637   @ifx\@eatinput @let\ = @ttbackslash @fi
11638   @catcode13=5 % regular end of line
11639   @enableemergencynewline
11640   @let@c=@texinfoc
11641   % Also turn back on active characters that might appear in the input
11642   % file name, in case not using a pre-dumped format.
11643   @catcode`+=@active
11644   @catcode`@_=@active
11645   %
11646   % If texinfo.cnf is present on the system, read it.
11647   % Useful for site-wide @afourpaper, etc.  This macro, @fixbackslash, gets
11648   % called at the beginning of every Texinfo file.  Not opening texinfo.cnf
11649   % directly in this file, texinfo.tex, makes it possible to make a format
11650   % file for Texinfo.
11651   %
11652   @openin 1 texinfo.cnf
11653   @ifeof 1 @else @input texinfo.cnf @fi
11654   @closein 1
11655 }
11656
11657
11658 % Say @foo, not \foo, in error messages.
11659 @escapechar = `@@
11660
11661 % These (along with & and #) are made active for url-breaking, so need
11662 % active definitions as the normal characters.
11663 @def@normaldot{.}
11664 @def@normalquest{?}
11665 @def@normalslash{/}
11666
11667 % These look ok in all fonts, so just make them not special.
11668 % @hashchar{} gets its own user-level command, because of #line.
11669 @catcode`@& = @other @def@normalamp{&}
11670 @catcode`@# = @other @def@normalhash{#}
11671 @catcode`@% = @other @def@normalpercent{%}
11672
11673 @let @hashchar = @normalhash
11674
11675 @c Finally, make ` and ' active, so that txicodequoteundirected and
11676 @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
11677 @c don't make ` and ' active, @code will not get them as active chars.
11678 @c Do this last of all since we use ` in the previous @catcode assignments.
11679 @catcode`@'=@active
11680 @catcode`@`=@active
11681 @markupsetuplqdefault
11682 @markupsetuprqdefault
11683
11684 @c Local variables:
11685 @c eval: (add-hook 'write-file-hooks 'time-stamp)
11686 @c page-delimiter: "^\\\\message\\|emacs-page"
11687 @c time-stamp-start: "def\\\\texinfoversion{"
11688 @c time-stamp-format: "%:y-%02m-%02d.%02H"
11689 @c time-stamp-end: "}"
11690 @c End:
11691
11692 @c vim:sw=2:
11693
11694 @enablebackslashhack