New upstream version 1.9
[debian/gzip] / build-aux / texinfo.tex
1 % texinfo.tex -- TeX macros to handle Texinfo files.
2
3 % Load plain if necessary, i.e., if running under initex.
4 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5 %
6 \def\texinfoversion{2017-12-26.21}
7 %
8 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
9 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
10 % 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
11 % Free Software Foundation, Inc.
12 %
13 % This texinfo.tex file is free software: you can redistribute it and/or
14 % modify it under the terms of the GNU General Public License as
15 % published by the Free Software Foundation, either version 3 of the
16 % License, or (at your option) any later version.
17 %
18 % This texinfo.tex file is distributed in the hope that it will be
19 % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
20 % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 % General Public License for more details.
22 %
23 % You should have received a copy of the GNU General Public License
24 % along with this program.  If not, see <https://www.gnu.org/licenses/>.
25 %
26 % As a special exception, when this file is read by TeX when processing
27 % a Texinfo source document, you may use the result without
28 % restriction. This Exception is an additional permission under section 7
29 % of the GNU General Public License, version 3 ("GPLv3").
30 %
31 % Please try the latest version of texinfo.tex before submitting bug
32 % reports; you can get the latest version from:
33 %   https://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
34 %   https://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
35 %   https://www.gnu.org/software/texinfo/ (the Texinfo home page)
36 % The texinfo.tex in any given distribution could well be out
37 % of date, so if that's what you're using, please check.
38 %
39 % Send bug reports to bug-texinfo@gnu.org.  Please include including a
40 % complete document in each bug report with which we can reproduce the
41 % problem.  Patches are, of course, greatly appreciated.
42 %
43 % To process a Texinfo manual with TeX, it's most reliable to use the
44 % texi2dvi shell script that comes with the distribution.  For a simple
45 % manual foo.texi, however, you can get away with this:
46 %   tex foo.texi
47 %   texindex foo.??
48 %   tex foo.texi
49 %   tex foo.texi
50 %   dvips foo.dvi -o  # or whatever; this makes foo.ps.
51 % The extra TeX runs get the cross-reference information correct.
52 % Sometimes one run after texindex suffices, and sometimes you need more
53 % than two; texi2dvi does it as many times as necessary.
54 %
55 % It is possible to adapt texinfo.tex for other languages, to some
56 % extent.  You can get the existing language-specific files from the
57 % full Texinfo distribution.
58 %
59 % The GNU Texinfo home page is https://www.gnu.org/software/texinfo.
60
61
62 \message{Loading texinfo [version \texinfoversion]:}
63
64 % If in a .fmt file, print the version number
65 % and turn on active characters that we couldn't do earlier because
66 % they might have appeared in the input file name.
67 \everyjob{\message{[Texinfo version \texinfoversion]}%
68   \catcode`+=\active \catcode`\_=\active}
69
70 % LaTeX's \typeout.  This ensures that the messages it is used for
71 % are identical in format to the corresponding ones from latex/pdflatex.
72 \def\typeout{\immediate\write17}%
73
74 \chardef\other=12
75
76 % We never want plain's \outer definition of \+ in Texinfo.
77 % For @tex, we can use \tabalign.
78 \let\+ = \relax
79
80 % Save some plain tex macros whose names we will redefine.
81 \let\ptexb=\b
82 \let\ptexbullet=\bullet
83 \let\ptexc=\c
84 \let\ptexcomma=\,
85 \let\ptexdot=\.
86 \let\ptexdots=\dots
87 \let\ptexend=\end
88 \let\ptexequiv=\equiv
89 \let\ptexexclam=\!
90 \let\ptexfootnote=\footnote
91 \let\ptexgtr=>
92 \let\ptexhat=^
93 \let\ptexi=\i
94 \let\ptexindent=\indent
95 \let\ptexinsert=\insert
96 \let\ptexlbrace=\{
97 \let\ptexless=<
98 \let\ptexnewwrite\newwrite
99 \let\ptexnoindent=\noindent
100 \let\ptexplus=+
101 \let\ptexraggedright=\raggedright
102 \let\ptexrbrace=\}
103 \let\ptexslash=\/
104 \let\ptexsp=\sp
105 \let\ptexstar=\*
106 \let\ptexsup=\sup
107 \let\ptext=\t
108 \let\ptextop=\top
109 {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
110
111 % If this character appears in an error message or help string, it
112 % starts a new line in the output.
113 \newlinechar = `^^J
114
115 % Use TeX 3.0's \inputlineno to get the line number, for better error
116 % messages, but if we're using an old version of TeX, don't do anything.
117 %
118 \ifx\inputlineno\thisisundefined
119   \let\linenumber = \empty % Pre-3.0.
120 \else
121   \def\linenumber{l.\the\inputlineno:\space}
122 \fi
123
124 % Set up fixed words for English if not already set.
125 \ifx\putwordAppendix\undefined  \gdef\putwordAppendix{Appendix}\fi
126 \ifx\putwordChapter\undefined   \gdef\putwordChapter{Chapter}\fi
127 \ifx\putworderror\undefined     \gdef\putworderror{error}\fi
128 \ifx\putwordfile\undefined      \gdef\putwordfile{file}\fi
129 \ifx\putwordin\undefined        \gdef\putwordin{in}\fi
130 \ifx\putwordIndexIsEmpty\undefined       \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
131 \ifx\putwordIndexNonexistent\undefined   \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
132 \ifx\putwordInfo\undefined      \gdef\putwordInfo{Info}\fi
133 \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
134 \ifx\putwordMethodon\undefined  \gdef\putwordMethodon{Method on}\fi
135 \ifx\putwordNoTitle\undefined   \gdef\putwordNoTitle{No Title}\fi
136 \ifx\putwordof\undefined        \gdef\putwordof{of}\fi
137 \ifx\putwordon\undefined        \gdef\putwordon{on}\fi
138 \ifx\putwordpage\undefined      \gdef\putwordpage{page}\fi
139 \ifx\putwordsection\undefined   \gdef\putwordsection{section}\fi
140 \ifx\putwordSection\undefined   \gdef\putwordSection{Section}\fi
141 \ifx\putwordsee\undefined       \gdef\putwordsee{see}\fi
142 \ifx\putwordSee\undefined       \gdef\putwordSee{See}\fi
143 \ifx\putwordShortTOC\undefined  \gdef\putwordShortTOC{Short Contents}\fi
144 \ifx\putwordTOC\undefined       \gdef\putwordTOC{Table of Contents}\fi
145 %
146 \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
147 \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
148 \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
149 \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
150 \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
151 \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
152 \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
153 \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
154 \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
155 \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
156 \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
157 \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
158 %
159 \ifx\putwordDefmac\undefined    \gdef\putwordDefmac{Macro}\fi
160 \ifx\putwordDefspec\undefined   \gdef\putwordDefspec{Special Form}\fi
161 \ifx\putwordDefvar\undefined    \gdef\putwordDefvar{Variable}\fi
162 \ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
163 \ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
164
165 % Give the space character the catcode for a space.
166 \def\spaceisspace{\catcode`\ =10\relax}
167
168 % Likewise for ^^M, the end of line character.
169 \def\endlineisspace{\catcode13=10\relax}
170
171 \chardef\dashChar  = `\-
172 \chardef\slashChar = `\/
173 \chardef\underChar = `\_
174
175 % Ignore a token.
176 %
177 \def\gobble#1{}
178
179 % The following is used inside several \edef's.
180 \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
181
182 % Hyphenation fixes.
183 \hyphenation{
184   Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
185   ap-pen-dix bit-map bit-maps
186   data-base data-bases eshell fall-ing half-way long-est man-u-script
187   man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
188   par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
189   spell-ing spell-ings
190   stand-alone strong-est time-stamp time-stamps which-ever white-space
191   wide-spread wrap-around
192 }
193
194 % Sometimes it is convenient to have everything in the transcript file
195 % and nothing on the terminal.  We don't just call \tracingall here,
196 % since that produces some useless output on the terminal.  We also make
197 % some effort to order the tracing commands to reduce output in the log
198 % file; cf. trace.sty in LaTeX.
199 %
200 \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
201 \def\loggingall{%
202   \tracingstats2
203   \tracingpages1
204   \tracinglostchars2  % 2 gives us more in etex
205   \tracingparagraphs1
206   \tracingoutput1
207   \tracingmacros2
208   \tracingrestores1
209   \showboxbreadth\maxdimen \showboxdepth\maxdimen
210   \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
211     \tracingscantokens1
212     \tracingifs1
213     \tracinggroups1
214     \tracingnesting2
215     \tracingassigns1
216   \fi
217   \tracingcommands3  % 3 gives us more in etex
218   \errorcontextlines16
219 }%
220
221 % @errormsg{MSG}.  Do the index-like expansions on MSG, but if things
222 % aren't perfect, it's not the end of the world, being an error message,
223 % after all.
224
225 \def\errormsg{\begingroup \indexnofonts \doerrormsg}
226 \def\doerrormsg#1{\errmessage{#1}}
227
228 % add check for \lastpenalty to plain's definitions.  If the last thing
229 % we did was a \nobreak, we don't want to insert more space.
230 %
231 \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
232   \removelastskip\penalty-50\smallskip\fi\fi}
233 \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
234   \removelastskip\penalty-100\medskip\fi\fi}
235 \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
236   \removelastskip\penalty-200\bigskip\fi\fi}
237
238 %\f Output routine
239 %
240
241 % For a final copy, take out the rectangles
242 % that mark overfull boxes (in case you have decided
243 % that the text looks ok even though it passes the margin).
244 %
245 \def\finalout{\overfullrule=0pt }
246
247 % Do @cropmarks to get crop marks.
248 %
249 \newif\ifcropmarks
250 \let\cropmarks = \cropmarkstrue
251 %
252 % Dimensions to add cropmarks at corners.
253 % Added by P. A. MacKay, 12 Nov. 1986
254 %
255 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
256 \newdimen\cornerlong  \cornerlong=1pc
257 \newdimen\cornerthick \cornerthick=.3pt
258 \newdimen\topandbottommargin \topandbottommargin=.75in
259
260 % Output a mark which sets \thischapter, \thissection and \thiscolor.
261 % We dump everything together because we only have one kind of mark.
262 % This works because we only use \botmark / \topmark, not \firstmark.
263 %
264 % A mark contains a subexpression of the \ifcase ... \fi construct.
265 % \get*marks macros below extract the needed part using \ifcase.
266 %
267 % Another complication is to let the user choose whether \thischapter
268 % (\thissection) refers to the chapter (section) in effect at the top
269 % of a page, or that at the bottom of a page.
270
271 % \domark is called twice inside \chapmacro, to add one
272 % mark before the section break, and one after.
273 %   In the second call \prevchapterdefs is the same as \lastchapterdefs,
274 % and \prevsectiondefs is the same as \lastsectiondefs.
275 %   Then if the page is not broken at the mark, some of the previous
276 % section appears on the page, and we can get the name of this section
277 % from \firstmark for @everyheadingmarks top.
278 %   @everyheadingmarks bottom uses \botmark.
279 %
280 % See page 260 of The TeXbook.
281 \def\domark{%
282   \toks0=\expandafter{\lastchapterdefs}%
283   \toks2=\expandafter{\lastsectiondefs}%
284   \toks4=\expandafter{\prevchapterdefs}%
285   \toks6=\expandafter{\prevsectiondefs}%
286   \toks8=\expandafter{\lastcolordefs}%
287   \mark{%
288                    \the\toks0 \the\toks2  % 0: marks for @everyheadingmarks top
289       \noexpand\or \the\toks4 \the\toks6  % 1: for @everyheadingmarks bottom
290     \noexpand\else \the\toks8             % 2: color marks
291   }%
292 }
293
294 % \gettopheadingmarks, \getbottomheadingmarks,
295 % \getcolormarks - extract needed part of mark.
296 %
297 % \topmark doesn't work for the very first chapter (after the title
298 % page or the contents), so we use \firstmark there -- this gets us
299 % the mark with the chapter defs, unless the user sneaks in, e.g.,
300 % @setcolor (or @url, or @link, etc.) between @contents and the very
301 % first @chapter.
302 \def\gettopheadingmarks{%
303   \ifcase0\topmark\fi
304   \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
305 }
306 \def\getbottomheadingmarks{\ifcase1\botmark\fi}
307 \def\getcolormarks{\ifcase2\topmark\fi}
308
309 % Avoid "undefined control sequence" errors.
310 \def\lastchapterdefs{}
311 \def\lastsectiondefs{}
312 \def\lastsection{}
313 \def\prevchapterdefs{}
314 \def\prevsectiondefs{}
315 \def\lastcolordefs{}
316
317 % Margin to add to right of even pages, to left of odd pages.
318 \newdimen\bindingoffset
319 \newdimen\normaloffset
320 \newdimen\txipagewidth \newdimen\txipageheight
321
322 % Main output routine.
323 %
324 \chardef\PAGE = 255
325 \output = {\onepageout{\pagecontents\PAGE}}
326
327 \newbox\headlinebox
328 \newbox\footlinebox
329
330 % \onepageout takes a vbox as an argument.
331 % \shipout a vbox for a single page, adding an optional header, footer,
332 % cropmarks, and footnote.  This also causes index entries for this page
333 % to be written to the auxiliary files.
334 %
335 \def\onepageout#1{%
336   \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
337   %
338   \ifodd\pageno  \advance\hoffset by \bindingoffset
339   \else \advance\hoffset by -\bindingoffset\fi
340   %
341   % Common context changes for both heading and footing.
342   % Do this outside of the \shipout so @code etc. will be expanded in
343   % the headline as they should be, not taken literally (outputting ''code).
344   \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars}
345   %
346   % Retrieve the information for the headings from the marks in the page,
347   % and call Plain TeX's \makeheadline and \makefootline, which use the
348   % values in \headline and \footline.
349   %
350   % This is used to check if we are on the first page of a chapter.
351   \ifcase1\topmark\fi
352   \let\prevchaptername\thischaptername
353   \ifcase0\firstmark\fi
354   \let\curchaptername\thischaptername
355   %
356   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
357   \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
358   %
359   \ifx\curchaptername\prevchaptername
360     \let\thischapterheading\thischapter
361   \else
362     % \thischapterheading is the same as \thischapter except it is blank
363     % for the first page of a chapter.  This is to prevent the chapter name 
364     % being shown twice.
365     \def\thischapterheading{}%
366   \fi
367   %
368   \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}%
369   \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}%
370   %
371   {%
372     % Set context for writing to auxiliary files like index files.
373     % Have to do this stuff outside the \shipout because we want it to
374     % take effect in \write's, yet the group defined by the \vbox ends
375     % before the \shipout runs.
376     %
377     \indexdummies         % don't expand commands in the output.
378     \normalturnoffactive  % \ in index entries must not stay \, e.g., if
379                % the page break happens to be in the middle of an example.
380                % We don't want .vr (or whatever) entries like this:
381                % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}}
382                % "\acronym" won't work when it's read back in;
383                % it needs to be
384                % {\code {{\backslashcurfont }acronym}
385     \shipout\vbox{%
386       % Do this early so pdf references go to the beginning of the page.
387       \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
388       %
389       \ifcropmarks \vbox to \outervsize\bgroup
390         \hsize = \outerhsize
391         \vskip-\topandbottommargin
392         \vtop to0pt{%
393           \line{\ewtop\hfil\ewtop}%
394           \nointerlineskip
395           \line{%
396             \vbox{\moveleft\cornerthick\nstop}%
397             \hfill
398             \vbox{\moveright\cornerthick\nstop}%
399           }%
400           \vss}%
401         \vskip\topandbottommargin
402         \line\bgroup
403           \hfil % center the page within the outer (page) hsize.
404           \ifodd\pageno\hskip\bindingoffset\fi
405           \vbox\bgroup
406       \fi
407       %
408       \unvbox\headlinebox
409       \pagebody{#1}%
410       \ifdim\ht\footlinebox > 0pt
411         % Only leave this space if the footline is nonempty.
412         % (We lessened \vsize for it in \oddfootingyyy.)
413         % The \baselineskip=24pt in plain's \makefootline has no effect.
414         \vskip 24pt
415         \unvbox\footlinebox
416       \fi
417       %
418       \ifcropmarks
419           \egroup % end of \vbox\bgroup
420         \hfil\egroup % end of (centering) \line\bgroup
421         \vskip\topandbottommargin plus1fill minus1fill
422         \boxmaxdepth = \cornerthick
423         \vbox to0pt{\vss
424           \line{%
425             \vbox{\moveleft\cornerthick\nsbot}%
426             \hfill
427             \vbox{\moveright\cornerthick\nsbot}%
428           }%
429           \nointerlineskip
430           \line{\ewbot\hfil\ewbot}%
431         }%
432       \egroup % \vbox from first cropmarks clause
433       \fi
434     }% end of \shipout\vbox
435   }% end of group with \indexdummies
436   \advancepageno
437   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
438 }
439
440 \newinsert\margin \dimen\margin=\maxdimen
441
442 % Main part of page, including any footnotes
443 \def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
444 {\catcode`\@ =11
445 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
446 % marginal hacks, juha@viisa.uucp (Juha Takala)
447 \ifvoid\margin\else % marginal info is present
448   \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
449 \dimen@=\dp#1\relax \unvbox#1\relax
450 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
451 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
452 }
453
454 % Here are the rules for the cropmarks.  Note that they are
455 % offset so that the space between them is truly \outerhsize or \outervsize
456 % (P. A. MacKay, 12 November, 1986)
457 %
458 \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
459 \def\nstop{\vbox
460   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
461 \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
462 \def\nsbot{\vbox
463   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
464
465
466 % Argument parsing
467
468 % Parse an argument, then pass it to #1.  The argument is the rest of
469 % the input line (except we remove a trailing comment).  #1 should be a
470 % macro which expects an ordinary undelimited TeX argument.
471 % For example, \def\foo{\parsearg\fooxxx}.
472 %
473 \def\parsearg{\parseargusing{}}
474 \def\parseargusing#1#2{%
475   \def\argtorun{#2}%
476   \begingroup
477     \obeylines
478     \spaceisspace
479     #1%
480     \parseargline\empty% Insert the \empty token, see \finishparsearg below.
481 }
482
483 {\obeylines %
484   \gdef\parseargline#1^^M{%
485     \endgroup % End of the group started in \parsearg.
486     \argremovecomment #1\comment\ArgTerm%
487   }%
488 }
489
490 % First remove any @comment, then any @c comment.  Also remove a @texinfoc
491 % comment (see \scanmacro for details).  Pass the result on to \argcheckspaces.
492 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
493 \def\argremovec#1\c#2\ArgTerm{\argremovetexinfoc #1\texinfoc\ArgTerm}
494 \def\argremovetexinfoc#1\texinfoc#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
495
496 % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
497 %
498 % \argremovec might leave us with trailing space, e.g.,
499 %    @end itemize  @c foo
500 % This space token undergoes the same procedure and is eventually removed
501 % by \finishparsearg.
502 %
503 \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
504 \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
505 \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
506   \def\temp{#3}%
507   \ifx\temp\empty
508     % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
509     \let\temp\finishparsearg
510   \else
511     \let\temp\argcheckspaces
512   \fi
513   % Put the space token in:
514   \temp#1 #3\ArgTerm
515 }
516
517 % If a _delimited_ argument is enclosed in braces, they get stripped; so
518 % to get _exactly_ the rest of the line, we had to prevent such situation.
519 % We prepended an \empty token at the very beginning and we expand it now,
520 % just before passing the control to \argtorun.
521 % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
522 % either the null string, or it ends with \^^M---thus there is no danger
523 % that a pair of braces would be stripped.
524 %
525 % But first, we have to remove the trailing space token.
526 %
527 \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
528
529
530 % \parseargdef - define a command taking an argument on the line
531 %
532 % \parseargdef\foo{...}
533 %       is roughly equivalent to
534 % \def\foo{\parsearg\Xfoo}
535 % \def\Xfoo#1{...}
536 \def\parseargdef#1{%
537   \expandafter \doparseargdef \csname\string#1\endcsname #1%
538 }
539 \def\doparseargdef#1#2{%
540   \def#2{\parsearg#1}%
541   \def#1##1%
542 }
543
544 % Several utility definitions with active space:
545 {
546   \obeyspaces
547   \gdef\obeyedspace{ }
548
549   % Make each space character in the input produce a normal interword
550   % space in the output.  Don't allow a line break at this space, as this
551   % is used only in environments like @example, where each line of input
552   % should produce a line of output anyway.
553   %
554   \gdef\sepspaces{\obeyspaces\let =\tie}
555
556   % If an index command is used in an @example environment, any spaces
557   % therein should become regular spaces in the raw index file, not the
558   % expansion of \tie (\leavevmode \penalty \@M \ ).
559   \gdef\unsepspaces{\let =\space}
560 }
561
562
563 \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
564
565 % Define the framework for environments in texinfo.tex.  It's used like this:
566 %
567 %   \envdef\foo{...}
568 %   \def\Efoo{...}
569 %
570 % It's the responsibility of \envdef to insert \begingroup before the
571 % actual body; @end closes the group after calling \Efoo.  \envdef also
572 % defines \thisenv, so the current environment is known; @end checks
573 % whether the environment name matches.  The \checkenv macro can also be
574 % used to check whether the current environment is the one expected.
575 %
576 % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
577 % are not treated as environments; they don't open a group.  (The
578 % implementation of @end takes care not to call \endgroup in this
579 % special case.)
580
581
582 % At run-time, environments start with this:
583 \def\startenvironment#1{\begingroup\def\thisenv{#1}}
584 % initialize
585 \let\thisenv\empty
586
587 % ... but they get defined via ``\envdef\foo{...}'':
588 \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
589 \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
590
591 % Check whether we're in the right environment:
592 \def\checkenv#1{%
593   \def\temp{#1}%
594   \ifx\thisenv\temp
595   \else
596     \badenverr
597   \fi
598 }
599
600 % Environment mismatch, #1 expected:
601 \def\badenverr{%
602   \errhelp = \EMsimple
603   \errmessage{This command can appear only \inenvironment\temp,
604     not \inenvironment\thisenv}%
605 }
606 \def\inenvironment#1{%
607   \ifx#1\empty
608     outside of any environment%
609   \else
610     in environment \expandafter\string#1%
611   \fi
612 }
613
614 % @end foo executes the definition of \Efoo.
615 % But first, it executes a specialized version of \checkenv
616 %
617 \parseargdef\end{%
618   \if 1\csname iscond.#1\endcsname
619   \else
620     % The general wording of \badenverr may not be ideal.
621     \expandafter\checkenv\csname#1\endcsname
622     \csname E#1\endcsname
623     \endgroup
624   \fi
625 }
626
627 \newhelp\EMsimple{Press RETURN to continue.}
628
629
630 % Be sure we're in horizontal mode when doing a tie, since we make space
631 % equivalent to this in @example-like environments. Otherwise, a space
632 % at the beginning of a line will start with \penalty -- and
633 % since \penalty is valid in vertical mode, we'd end up putting the
634 % penalty on the vertical list instead of in the new paragraph.
635 {\catcode`@ = 11
636  % Avoid using \@M directly, because that causes trouble
637  % if the definition is written into an index file.
638  \global\let\tiepenalty = \@M
639  \gdef\tie{\leavevmode\penalty\tiepenalty\ }
640 }
641
642 % @: forces normal size whitespace following.
643 \def\:{\spacefactor=1000 }
644
645 % @* forces a line break.
646 \def\*{\unskip\hfil\break\hbox{}\ignorespaces}
647
648 % @/ allows a line break.
649 \let\/=\allowbreak
650
651 % @. is an end-of-sentence period.
652 \def\.{.\spacefactor=\endofsentencespacefactor\space}
653
654 % @! is an end-of-sentence bang.
655 \def\!{!\spacefactor=\endofsentencespacefactor\space}
656
657 % @? is an end-of-sentence query.
658 \def\?{?\spacefactor=\endofsentencespacefactor\space}
659
660 % @frenchspacing on|off  says whether to put extra space after punctuation.
661 %
662 \def\onword{on}
663 \def\offword{off}
664 %
665 \parseargdef\frenchspacing{%
666   \def\temp{#1}%
667   \ifx\temp\onword \plainfrenchspacing
668   \else\ifx\temp\offword \plainnonfrenchspacing
669   \else
670     \errhelp = \EMsimple
671     \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
672   \fi\fi
673 }
674
675 % @w prevents a word break.  Without the \leavevmode, @w at the
676 % beginning of a paragraph, when TeX is still in vertical mode, would
677 % produce a whole line of output instead of starting the paragraph.
678 \def\w#1{\leavevmode\hbox{#1}}
679
680 % @group ... @end group forces ... to be all on one page, by enclosing
681 % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
682 % to keep its height that of a normal line.  According to the rules for
683 % \topskip (p.114 of the TeXbook), the glue inserted is
684 % max (\topskip - \ht (first item), 0).  If that height is large,
685 % therefore, no glue is inserted, and the space between the headline and
686 % the text is small, which looks bad.
687 %
688 % Another complication is that the group might be very large.  This can
689 % cause the glue on the previous page to be unduly stretched, because it
690 % does not have much material.  In this case, it's better to add an
691 % explicit \vfill so that the extra space is at the bottom.  The
692 % threshold for doing this is if the group is more than \vfilllimit
693 % percent of a page (\vfilllimit can be changed inside of @tex).
694 %
695 \newbox\groupbox
696 \def\vfilllimit{0.7}
697 %
698 \envdef\group{%
699   \ifnum\catcode`\^^M=\active \else
700     \errhelp = \groupinvalidhelp
701     \errmessage{@group invalid in context where filling is enabled}%
702   \fi
703   \startsavinginserts
704   %
705   \setbox\groupbox = \vtop\bgroup
706     % Do @comment since we are called inside an environment such as
707     % @example, where each end-of-line in the input causes an
708     % end-of-line in the output.  We don't want the end-of-line after
709     % the `@group' to put extra space in the output.  Since @group
710     % should appear on a line by itself (according to the Texinfo
711     % manual), we don't worry about eating any user text.
712     \comment
713 }
714 %
715 % The \vtop produces a box with normal height and large depth; thus, TeX puts
716 % \baselineskip glue before it, and (when the next line of text is done)
717 % \lineskip glue after it.  Thus, space below is not quite equal to space
718 % above.  But it's pretty close.
719 \def\Egroup{%
720     % To get correct interline space between the last line of the group
721     % and the first line afterwards, we have to propagate \prevdepth.
722     \endgraf % Not \par, as it may have been set to \lisppar.
723     \global\dimen1 = \prevdepth
724   \egroup           % End the \vtop.
725   \addgroupbox
726   \prevdepth = \dimen1
727   \checkinserts
728 }
729
730 \def\addgroupbox{
731   % \dimen0 is the vertical size of the group's box.
732   \dimen0 = \ht\groupbox  \advance\dimen0 by \dp\groupbox
733   % \dimen2 is how much space is left on the page (more or less).
734   \dimen2 = \txipageheight   \advance\dimen2 by -\pagetotal
735   % if the group doesn't fit on the current page, and it's a big big
736   % group, force a page break.
737   \ifdim \dimen0 > \dimen2
738     \ifdim \pagetotal < \vfilllimit\txipageheight
739       \page
740     \fi
741   \fi
742   \box\groupbox
743 }
744
745 %
746 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
747 % message, so this ends up printing `@group can only ...'.
748 %
749 \newhelp\groupinvalidhelp{%
750 group can only be used in environments such as @example,^^J%
751 where each line of input produces a line of output.}
752
753 % @need space-in-mils
754 % forces a page break if there is not space-in-mils remaining.
755
756 \newdimen\mil  \mil=0.001in
757
758 \parseargdef\need{%
759   % Ensure vertical mode, so we don't make a big box in the middle of a
760   % paragraph.
761   \par
762   %
763   % If the @need value is less than one line space, it's useless.
764   \dimen0 = #1\mil
765   \dimen2 = \ht\strutbox
766   \advance\dimen2 by \dp\strutbox
767   \ifdim\dimen0 > \dimen2
768     %
769     % Do a \strut just to make the height of this box be normal, so the
770     % normal leading is inserted relative to the preceding line.
771     % And a page break here is fine.
772     \vtop to #1\mil{\strut\vfil}%
773     %
774     % TeX does not even consider page breaks if a penalty added to the
775     % main vertical list is 10000 or more.  But in order to see if the
776     % empty box we just added fits on the page, we must make it consider
777     % page breaks.  On the other hand, we don't want to actually break the
778     % page after the empty box.  So we use a penalty of 9999.
779     %
780     % There is an extremely small chance that TeX will actually break the
781     % page at this \penalty, if there are no other feasible breakpoints in
782     % sight.  (If the user is using lots of big @group commands, which
783     % almost-but-not-quite fill up a page, TeX will have a hard time doing
784     % good page breaking, for example.)  However, I could not construct an
785     % example where a page broke at this \penalty; if it happens in a real
786     % document, then we can reconsider our strategy.
787     \penalty9999
788     %
789     % Back up by the size of the box, whether we did a page break or not.
790     \kern -#1\mil
791     %
792     % Do not allow a page break right after this kern.
793     \nobreak
794   \fi
795 }
796
797 % @br   forces paragraph break (and is undocumented).
798
799 \let\br = \par
800
801 % @page forces the start of a new page.
802 %
803 \def\page{\par\vfill\supereject}
804
805 % @exdent text....
806 % outputs text on separate line in roman font, starting at standard page margin
807
808 % This records the amount of indent in the innermost environment.
809 % That's how much \exdent should take out.
810 \newskip\exdentamount
811
812 % This defn is used inside fill environments such as @defun.
813 \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
814
815 % This defn is used inside nofill environments such as @example.
816 \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
817   \leftline{\hskip\leftskip{\rm#1}}}}
818
819 % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
820 % paragraph.  For more general purposes, use the \margin insertion
821 % class.  WHICH is `l' or `r'.  Not documented, written for gawk manual.
822 %
823 \newskip\inmarginspacing \inmarginspacing=1cm
824 \def\strutdepth{\dp\strutbox}
825 %
826 \def\doinmargin#1#2{\strut\vadjust{%
827   \nobreak
828   \kern-\strutdepth
829   \vtop to \strutdepth{%
830     \baselineskip=\strutdepth
831     \vss
832     % if you have multiple lines of stuff to put here, you'll need to
833     % make the vbox yourself of the appropriate size.
834     \ifx#1l%
835       \llap{\ignorespaces #2\hskip\inmarginspacing}%
836     \else
837       \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
838     \fi
839     \null
840   }%
841 }}
842 \def\inleftmargin{\doinmargin l}
843 \def\inrightmargin{\doinmargin r}
844 %
845 % @inmargin{TEXT [, RIGHT-TEXT]}
846 % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
847 % else use TEXT for both).
848 %
849 \def\inmargin#1{\parseinmargin #1,,\finish}
850 \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
851   \setbox0 = \hbox{\ignorespaces #2}%
852   \ifdim\wd0 > 0pt
853     \def\lefttext{#1}%  have both texts
854     \def\righttext{#2}%
855   \else
856     \def\lefttext{#1}%  have only one text
857     \def\righttext{#1}%
858   \fi
859   %
860   \ifodd\pageno
861     \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
862   \else
863     \def\temp{\inleftmargin\lefttext}%
864   \fi
865   \temp
866 }
867
868 % @include FILE -- \input text of FILE.
869 %
870 \def\include{\parseargusing\filenamecatcodes\includezzz}
871 \def\includezzz#1{%
872   \pushthisfilestack
873   \def\thisfile{#1}%
874   {%
875     \makevalueexpandable  % we want to expand any @value in FILE.
876     \turnoffactive        % and allow special characters in the expansion
877     \indexnofonts         % Allow `@@' and other weird things in file names.
878     \wlog{texinfo.tex: doing @include of #1^^J}%
879     \edef\temp{\noexpand\input #1 }%
880     %
881     % This trickery is to read FILE outside of a group, in case it makes
882     % definitions, etc.
883     \expandafter
884   }\temp
885   \popthisfilestack
886 }
887 \def\filenamecatcodes{%
888   \catcode`\\=\other
889   \catcode`~=\other
890   \catcode`^=\other
891   \catcode`_=\other
892   \catcode`|=\other
893   \catcode`<=\other
894   \catcode`>=\other
895   \catcode`+=\other
896   \catcode`-=\other
897   \catcode`\`=\other
898   \catcode`\'=\other
899 }
900
901 \def\pushthisfilestack{%
902   \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
903 }
904 \def\pushthisfilestackX{%
905   \expandafter\pushthisfilestackY\thisfile\StackTerm
906 }
907 \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
908   \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
909 }
910
911 \def\popthisfilestack{\errthisfilestackempty}
912 \def\errthisfilestackempty{\errmessage{Internal error:
913   the stack of filenames is empty.}}
914 %
915 \def\thisfile{}
916
917 % @center line
918 % outputs that line, centered.
919 %
920 \parseargdef\center{%
921   \ifhmode
922     \let\centersub\centerH
923   \else
924     \let\centersub\centerV
925   \fi
926   \centersub{\hfil \ignorespaces#1\unskip \hfil}%
927   \let\centersub\relax % don't let the definition persist, just in case
928 }
929 \def\centerH#1{{%
930   \hfil\break
931   \advance\hsize by -\leftskip
932   \advance\hsize by -\rightskip
933   \line{#1}%
934   \break
935 }}
936 %
937 \newcount\centerpenalty
938 \def\centerV#1{%
939   % The idea here is the same as in \startdefun, \cartouche, etc.: if
940   % @center is the first thing after a section heading, we need to wipe
941   % out the negative parskip inserted by \sectionheading, but still
942   % prevent a page break here.
943   \centerpenalty = \lastpenalty
944   \ifnum\centerpenalty>10000 \vskip\parskip \fi
945   \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
946   \line{\kern\leftskip #1\kern\rightskip}%
947 }
948
949 % @sp n   outputs n lines of vertical space
950 %
951 \parseargdef\sp{\vskip #1\baselineskip}
952
953 % @comment ...line which is ignored...
954 % @c is the same as @comment
955 % @ignore ... @end ignore  is another way to write a comment
956
957
958 \def\c{\begingroup \catcode`\^^M=\active%
959 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
960 \cxxx}
961 {\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
962 %
963 \let\comment\c
964
965 % @paragraphindent NCHARS
966 % We'll use ems for NCHARS, close enough.
967 % NCHARS can also be the word `asis' or `none'.
968 % We cannot feasibly implement @paragraphindent asis, though.
969 %
970 \def\asisword{asis} % no translation, these are keywords
971 \def\noneword{none}
972 %
973 \parseargdef\paragraphindent{%
974   \def\temp{#1}%
975   \ifx\temp\asisword
976   \else
977     \ifx\temp\noneword
978       \defaultparindent = 0pt
979     \else
980       \defaultparindent = #1em
981     \fi
982   \fi
983   \parindent = \defaultparindent
984 }
985
986 % @exampleindent NCHARS
987 % We'll use ems for NCHARS like @paragraphindent.
988 % It seems @exampleindent asis isn't necessary, but
989 % I preserve it to make it similar to @paragraphindent.
990 \parseargdef\exampleindent{%
991   \def\temp{#1}%
992   \ifx\temp\asisword
993   \else
994     \ifx\temp\noneword
995       \lispnarrowing = 0pt
996     \else
997       \lispnarrowing = #1em
998     \fi
999   \fi
1000 }
1001
1002 % @firstparagraphindent WORD
1003 % If WORD is `none', then suppress indentation of the first paragraph
1004 % after a section heading.  If WORD is `insert', then do indent at such
1005 % paragraphs.
1006 %
1007 % The paragraph indentation is suppressed or not by calling
1008 % \suppressfirstparagraphindent, which the sectioning commands do.
1009 % We switch the definition of this back and forth according to WORD.
1010 % By default, we suppress indentation.
1011 %
1012 \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
1013 \def\insertword{insert}
1014 %
1015 \parseargdef\firstparagraphindent{%
1016   \def\temp{#1}%
1017   \ifx\temp\noneword
1018     \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
1019   \else\ifx\temp\insertword
1020     \let\suppressfirstparagraphindent = \relax
1021   \else
1022     \errhelp = \EMsimple
1023     \errmessage{Unknown @firstparagraphindent option `\temp'}%
1024   \fi\fi
1025 }
1026
1027 % Here is how we actually suppress indentation.  Redefine \everypar to
1028 % \kern backwards by \parindent, and then reset itself to empty.
1029 %
1030 % We also make \indent itself not actually do anything until the next
1031 % paragraph.
1032 %
1033 \gdef\dosuppressfirstparagraphindent{%
1034   \gdef\indent  {\restorefirstparagraphindent \indent}%
1035   \gdef\noindent{\restorefirstparagraphindent \noindent}%
1036   \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
1037 }
1038 %
1039 \gdef\restorefirstparagraphindent{%
1040   \global\let\indent = \ptexindent
1041   \global\let\noindent = \ptexnoindent
1042   \global\everypar = {}%
1043 }
1044
1045
1046 % @refill is a no-op.
1047 \let\refill=\relax
1048
1049 % @setfilename INFO-FILENAME - ignored
1050 \let\setfilename=\comment
1051
1052 % @bye.
1053 \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
1054
1055
1056 \message{pdf,}
1057 % adobe `portable' document format
1058 \newcount\tempnum
1059 \newcount\lnkcount
1060 \newtoks\filename
1061 \newcount\filenamelength
1062 \newcount\pgn
1063 \newtoks\toksA
1064 \newtoks\toksB
1065 \newtoks\toksC
1066 \newtoks\toksD
1067 \newbox\boxA
1068 \newbox\boxB
1069 \newcount\countA
1070 \newif\ifpdf
1071 \newif\ifpdfmakepagedest
1072
1073 %
1074 % For LuaTeX
1075 %
1076
1077 \newif\iftxiuseunicodedestname
1078 \txiuseunicodedestnamefalse % For pdfTeX etc.
1079
1080 \ifx\luatexversion\thisisundefined
1081 \else
1082   % Use Unicode destination names
1083   \txiuseunicodedestnametrue
1084   % Escape PDF strings with converting UTF-16 from UTF-8
1085   \begingroup
1086     \catcode`\%=12
1087     \directlua{
1088       function UTF16oct(str)
1089         tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
1090         for c in string.utfvalues(str) do
1091           if c < 0x10000 then
1092             tex.sprint(
1093               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1094                             string.char(0x5c) .. string.char(0x25) .. '03o',
1095                             (c / 256), (c % 256)))
1096           else
1097             c = c - 0x10000
1098             local c_hi = c / 1024 + 0xd800
1099             local c_lo = c % 1024 + 0xdc00
1100             tex.sprint(
1101               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1102                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
1103                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
1104                             string.char(0x5c) .. string.char(0x25) .. '03o',
1105                             (c_hi / 256), (c_hi % 256),
1106                             (c_lo / 256), (c_lo % 256)))
1107           end
1108         end
1109       end
1110     }
1111   \endgroup
1112   \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
1113   % Escape PDF strings without converting
1114   \begingroup
1115     \directlua{
1116       function PDFescstr(str)
1117         for c in string.bytes(str) do
1118           if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
1119             tex.sprint(
1120               string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
1121                             c))
1122           else
1123             tex.sprint(string.char(c))
1124           end
1125         end
1126       end
1127     }
1128   \endgroup
1129   \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
1130   \ifnum\luatexversion>84
1131     % For LuaTeX >= 0.85
1132     \def\pdfdest{\pdfextension dest}
1133     \let\pdfoutput\outputmode
1134     \def\pdfliteral{\pdfextension literal}
1135     \def\pdfcatalog{\pdfextension catalog}
1136     \def\pdftexversion{\numexpr\pdffeedback version\relax}
1137     \let\pdfximage\saveimageresource
1138     \let\pdfrefximage\useimageresource
1139     \let\pdflastximage\lastsavedimageresourceindex
1140     \def\pdfendlink{\pdfextension endlink\relax}
1141     \def\pdfoutline{\pdfextension outline}
1142     \def\pdfstartlink{\pdfextension startlink}
1143     \def\pdffontattr{\pdfextension fontattr}
1144     \def\pdfobj{\pdfextension obj}
1145     \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
1146     \let\pdfpagewidth\pagewidth
1147     \let\pdfpageheight\pageheight
1148     \edef\pdfhorigin{\pdfvariable horigin}
1149     \edef\pdfvorigin{\pdfvariable vorigin}
1150   \fi
1151 \fi
1152
1153 % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1154 % can be set).  So we test for \relax and 0 as well as being undefined.
1155 \ifx\pdfoutput\thisisundefined
1156 \else
1157   \ifx\pdfoutput\relax
1158   \else
1159     \ifcase\pdfoutput
1160     \else
1161       \pdftrue
1162     \fi
1163   \fi
1164 \fi
1165
1166 % PDF uses PostScript string constants for the names of xref targets,
1167 % for display in the outlines, and in other places.  Thus, we have to
1168 % double any backslashes.  Otherwise, a name like "\node" will be
1169 % interpreted as a newline (\n), followed by o, d, e.  Not good.
1170
1171 % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
1172 % related messages.  The final outcome is that it is up to the TeX user
1173 % to double the backslashes and otherwise make the string valid, so
1174 % that's what we do.  pdftex 1.30.0 (ca.2005) introduced a primitive to
1175 % do this reliably, so we use it.
1176
1177 % #1 is a control sequence in which to do the replacements,
1178 % which we \xdef.
1179 \def\txiescapepdf#1{%
1180   \ifx\pdfescapestring\thisisundefined
1181     % No primitive available; should we give a warning or log?
1182     % Many times it won't matter.
1183     \xdef#1{#1}%
1184   \else
1185     % The expandable \pdfescapestring primitive escapes parentheses,
1186     % backslashes, and other special chars.
1187     \xdef#1{\pdfescapestring{#1}}%
1188   \fi
1189 }
1190 \def\txiescapepdfutfsixteen#1{%
1191   \ifx\pdfescapestrutfsixteen\thisisundefined
1192     % No UTF-16 converting macro available.
1193     \txiescapepdf{#1}%
1194   \else
1195     \xdef#1{\pdfescapestrutfsixteen{#1}}%
1196   \fi
1197 }
1198
1199 \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1200 with PDF output, and none of those formats could be found.  (.eps cannot
1201 be supported due to the design of the PDF format; use regular TeX (DVI
1202 output) for that.)}
1203
1204 \ifpdf
1205   %
1206   % Color manipulation macros using ideas from pdfcolor.tex,
1207   % except using rgb instead of cmyk; the latter is said to render as a
1208   % very dark gray on-screen and a very dark halftone in print, instead
1209   % of actual black. The dark red here is dark enough to print on paper as
1210   % nearly black, but still distinguishable for online viewing.  We use
1211   % black by default, though.
1212   \def\rgbDarkRed{0.50 0.09 0.12}
1213   \def\rgbBlack{0 0 0}
1214   %
1215   % rg sets the color for filling (usual text, etc.);
1216   % RG sets the color for stroking (thin rules, e.g., normal _'s).
1217   \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
1218   %
1219   % Set color, and create a mark which defines \thiscolor accordingly,
1220   % so that \makeheadline knows which color to restore.
1221   \def\setcolor#1{%
1222     \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
1223     \domark
1224     \pdfsetcolor{#1}%
1225   }
1226   %
1227   \def\maincolor{\rgbBlack}
1228   \pdfsetcolor{\maincolor}
1229   \edef\thiscolor{\maincolor}
1230   \def\lastcolordefs{}
1231   %
1232   \def\makefootline{%
1233     \baselineskip24pt
1234     \line{\pdfsetcolor{\maincolor}\the\footline}%
1235   }
1236   %
1237   \def\makeheadline{%
1238     \vbox to 0pt{%
1239       \vskip-22.5pt
1240       \line{%
1241         \vbox to8.5pt{}%
1242         % Extract \thiscolor definition from the marks.
1243         \getcolormarks
1244         % Typeset the headline with \maincolor, then restore the color.
1245         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1246       }%
1247       \vss
1248     }%
1249     \nointerlineskip
1250   }
1251   %
1252   %
1253   \pdfcatalog{/PageMode /UseOutlines}
1254   %
1255   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1256   \def\dopdfimage#1#2#3{%
1257     \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1258     \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1259     %
1260     % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1261     % others).  Let's try in that order, PDF first since if
1262     % someone has a scalable image, presumably better to use that than a
1263     % bitmap.
1264     \let\pdfimgext=\empty
1265     \begingroup
1266       \openin 1 #1.pdf \ifeof 1
1267         \openin 1 #1.PDF \ifeof 1
1268           \openin 1 #1.png \ifeof 1
1269             \openin 1 #1.jpg \ifeof 1
1270               \openin 1 #1.jpeg \ifeof 1
1271                 \openin 1 #1.JPG \ifeof 1
1272                   \errhelp = \nopdfimagehelp
1273                   \errmessage{Could not find image file #1 for pdf}%
1274                 \else \gdef\pdfimgext{JPG}%
1275                 \fi
1276               \else \gdef\pdfimgext{jpeg}%
1277               \fi
1278             \else \gdef\pdfimgext{jpg}%
1279             \fi
1280           \else \gdef\pdfimgext{png}%
1281           \fi
1282         \else \gdef\pdfimgext{PDF}%
1283         \fi
1284       \else \gdef\pdfimgext{pdf}%
1285       \fi
1286       \closein 1
1287     \endgroup
1288     %
1289     % without \immediate, ancient pdftex seg faults when the same image is
1290     % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
1291     \ifnum\pdftexversion < 14
1292       \immediate\pdfimage
1293     \else
1294       \immediate\pdfximage
1295     \fi
1296       \ifdim \wd0 >0pt width \pdfimagewidth \fi
1297       \ifdim \wd2 >0pt height \pdfimageheight \fi
1298       \ifnum\pdftexversion<13
1299          #1.\pdfimgext
1300        \else
1301          {#1.\pdfimgext}%
1302        \fi
1303     \ifnum\pdftexversion < 14 \else
1304       \pdfrefximage \pdflastximage
1305     \fi}
1306   %
1307   \def\setpdfdestname#1{{%
1308     % We have to set dummies so commands such as @code, and characters
1309     % such as \, aren't expanded when present in a section title.
1310     \indexnofonts
1311     \makevalueexpandable
1312     \turnoffactive
1313     \iftxiuseunicodedestname
1314       \ifx \declaredencoding \latone
1315         % Pass through Latin-1 characters.
1316         % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode.
1317       \else
1318         \ifx \declaredencoding \utfeight
1319           % Pass through Unicode characters.
1320         \else
1321           % Use ASCII approximations in destination names.
1322           \passthroughcharsfalse
1323         \fi
1324       \fi
1325     \else
1326       % Use ASCII approximations in destination names.
1327       \passthroughcharsfalse
1328     \fi
1329     \def\pdfdestname{#1}%
1330     \txiescapepdf\pdfdestname
1331   }}
1332   %
1333   \def\setpdfoutlinetext#1{{%
1334     \indexnofonts
1335     \makevalueexpandable
1336     \turnoffactive
1337     \ifx \declaredencoding \latone
1338       % The PDF format can use an extended form of Latin-1 in bookmark
1339       % strings.  See Appendix D of the PDF Reference, Sixth Edition, for
1340       % the "PDFDocEncoding".
1341       \passthroughcharstrue
1342       % Pass through Latin-1 characters.
1343       %   LuaTeX: Convert to Unicode
1344       %   pdfTeX: Use Latin-1 as PDFDocEncoding
1345       \def\pdfoutlinetext{#1}%
1346     \else
1347       \ifx \declaredencoding \utfeight
1348         \ifx\luatexversion\thisisundefined
1349           % For pdfTeX  with UTF-8.
1350           % TODO: the PDF format can use UTF-16 in bookmark strings,
1351           % but the code for this isn't done yet.
1352           % Use ASCII approximations.
1353           \passthroughcharsfalse
1354           \def\pdfoutlinetext{#1}%
1355         \else
1356           % For LuaTeX with UTF-8.
1357           % Pass through Unicode characters for title texts.
1358           \passthroughcharstrue
1359           \def\pdfoutlinetext{#1}%
1360         \fi
1361       \else
1362         % For non-Latin-1 or non-UTF-8 encodings.
1363         % Use ASCII approximations.
1364         \passthroughcharsfalse
1365         \def\pdfoutlinetext{#1}%
1366       \fi
1367     \fi
1368     % LuaTeX: Convert to UTF-16
1369     % pdfTeX: Use Latin-1 as PDFDocEncoding
1370     \txiescapepdfutfsixteen\pdfoutlinetext
1371   }}
1372   %
1373   \def\pdfmkdest#1{%
1374     \setpdfdestname{#1}%
1375     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1376   }
1377   %
1378   % used to mark target names; must be expandable.
1379   \def\pdfmkpgn#1{#1}
1380   %
1381   % by default, use black for everything.
1382   \def\urlcolor{\rgbBlack}
1383   \def\linkcolor{\rgbBlack}
1384   \def\endlink{\setcolor{\maincolor}\pdfendlink}
1385   %
1386   % Adding outlines to PDF; macros for calculating structure of outlines
1387   % come from Petr Olsak
1388   \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1389     \else \csname#1\endcsname \fi}
1390   \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1391     \advance\tempnum by 1
1392     \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1393   %
1394   % #1 is the section text, which is what will be displayed in the
1395   % outline by the pdf viewer.  #2 is the pdf expression for the number
1396   % of subentries (or empty, for subsubsections).  #3 is the node text,
1397   % which might be empty if this toc entry had no corresponding node.
1398   % #4 is the page number
1399   %
1400   \def\dopdfoutline#1#2#3#4{%
1401     % Generate a link to the node text if that exists; else, use the
1402     % page number.  We could generate a destination for the section
1403     % text in the case where a section has no node, but it doesn't
1404     % seem worth the trouble, since most documents are normally structured.
1405     \setpdfoutlinetext{#1}
1406     \setpdfdestname{#3}
1407     \ifx\pdfdestname\empty
1408       \def\pdfdestname{#4}%
1409     \fi
1410     %
1411     \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}%
1412   }
1413   %
1414   \def\pdfmakeoutlines{%
1415     \begingroup
1416       % Read toc silently, to get counts of subentries for \pdfoutline.
1417       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1418       \def\numchapentry##1##2##3##4{%
1419         \def\thischapnum{##2}%
1420         \def\thissecnum{0}%
1421         \def\thissubsecnum{0}%
1422       }%
1423       \def\numsecentry##1##2##3##4{%
1424         \advancenumber{chap\thischapnum}%
1425         \def\thissecnum{##2}%
1426         \def\thissubsecnum{0}%
1427       }%
1428       \def\numsubsecentry##1##2##3##4{%
1429         \advancenumber{sec\thissecnum}%
1430         \def\thissubsecnum{##2}%
1431       }%
1432       \def\numsubsubsecentry##1##2##3##4{%
1433         \advancenumber{subsec\thissubsecnum}%
1434       }%
1435       \def\thischapnum{0}%
1436       \def\thissecnum{0}%
1437       \def\thissubsecnum{0}%
1438       %
1439       % use \def rather than \let here because we redefine \chapentry et
1440       % al. a second time, below.
1441       \def\appentry{\numchapentry}%
1442       \def\appsecentry{\numsecentry}%
1443       \def\appsubsecentry{\numsubsecentry}%
1444       \def\appsubsubsecentry{\numsubsubsecentry}%
1445       \def\unnchapentry{\numchapentry}%
1446       \def\unnsecentry{\numsecentry}%
1447       \def\unnsubsecentry{\numsubsecentry}%
1448       \def\unnsubsubsecentry{\numsubsubsecentry}%
1449       \readdatafile{toc}%
1450       %
1451       % Read toc second time, this time actually producing the outlines.
1452       % The `-' means take the \expnumber as the absolute number of
1453       % subentries, which we calculated on our first read of the .toc above.
1454       %
1455       % We use the node names as the destinations.
1456       \def\numchapentry##1##2##3##4{%
1457         \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1458       \def\numsecentry##1##2##3##4{%
1459         \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1460       \def\numsubsecentry##1##2##3##4{%
1461         \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1462       \def\numsubsubsecentry##1##2##3##4{% count is always zero
1463         \dopdfoutline{##1}{}{##3}{##4}}%
1464       %
1465       % PDF outlines are displayed using system fonts, instead of
1466       % document fonts.  Therefore we cannot use special characters,
1467       % since the encoding is unknown.  For example, the eogonek from
1468       % Latin 2 (0xea) gets translated to a | character.  Info from
1469       % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1470       %
1471       % TODO this right, we have to translate 8-bit characters to
1472       % their "best" equivalent, based on the @documentencoding.  Too
1473       % much work for too little return.  Just use the ASCII equivalents
1474       % we use for the index sort strings.
1475       % 
1476       \indexnofonts
1477       \setupdatafile
1478       % We can have normal brace characters in the PDF outlines, unlike
1479       % Texinfo index files.  So set that up.
1480       \def\{{\lbracecharliteral}%
1481       \def\}{\rbracecharliteral}%
1482       \catcode`\\=\active \otherbackslash
1483       \input \tocreadfilename
1484     \endgroup
1485   }
1486   {\catcode`[=1 \catcode`]=2
1487    \catcode`{=\other \catcode`}=\other
1488    \gdef\lbracecharliteral[{]%
1489    \gdef\rbracecharliteral[}]%
1490   ]
1491   %
1492   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1493     \ifx\PP\D\let\nextsp\relax
1494     \else\let\nextsp\skipspaces
1495       \addtokens{\filename}{\PP}%
1496       \advance\filenamelength by 1
1497     \fi
1498     \nextsp}
1499   \def\getfilename#1{%
1500     \filenamelength=0
1501     % If we don't expand the argument now, \skipspaces will get
1502     % snagged on things like "@value{foo}".
1503     \edef\temp{#1}%
1504     \expandafter\skipspaces\temp|\relax
1505   }
1506   \ifnum\pdftexversion < 14
1507     \let \startlink \pdfannotlink
1508   \else
1509     \let \startlink \pdfstartlink
1510   \fi
1511   % make a live url in pdf output.
1512   \def\pdfurl#1{%
1513     \begingroup
1514       % it seems we really need yet another set of dummies; have not
1515       % tried to figure out what each command should do in the context
1516       % of @url.  for now, just make @/ a no-op, that's the only one
1517       % people have actually reported a problem with.
1518       %
1519       \normalturnoffactive
1520       \def\@{@}%
1521       \let\/=\empty
1522       \makevalueexpandable
1523       % do we want to go so far as to use \indexnofonts instead of just
1524       % special-casing \var here?
1525       \def\var##1{##1}%
1526       %
1527       \leavevmode\setcolor{\urlcolor}%
1528       \startlink attr{/Border [0 0 0]}%
1529         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1530     \endgroup}
1531   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1532   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1533   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1534   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1535   \def\maketoks{%
1536     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1537     \ifx\first0\adn0
1538     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1539     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1540     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1541     \else
1542       \ifnum0=\countA\else\makelink\fi
1543       \ifx\first.\let\next=\done\else
1544         \let\next=\maketoks
1545         \addtokens{\toksB}{\the\toksD}
1546         \ifx\first,\addtokens{\toksB}{\space}\fi
1547       \fi
1548     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1549     \next}
1550   \def\makelink{\addtokens{\toksB}%
1551     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1552   \def\pdflink#1{%
1553     \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1554     \setcolor{\linkcolor}#1\endlink}
1555   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1556 \else
1557   % non-pdf mode
1558   \let\pdfmkdest = \gobble
1559   \let\pdfurl = \gobble
1560   \let\endlink = \relax
1561   \let\setcolor = \gobble
1562   \let\pdfsetcolor = \gobble
1563   \let\pdfmakeoutlines = \relax
1564 \fi  % \ifx\pdfoutput
1565
1566 %
1567 % For XeTeX
1568 %
1569 \ifx\XeTeXrevision\thisisundefined
1570 \else
1571   %
1572   % XeTeX version check
1573   %
1574   \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1
1575     % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307.
1576     % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941).
1577     % For avoiding PDF destination name replacement, we use this special
1578     % instead of xdvipdfmx's command line option `-C 0x0010'.
1579     \special{dvipdfmx:config C 0x0010}
1580     % XeTeX 0.99995+ comes with xdvipdfmx 20160307+.
1581     % It can handle Unicode destination names for PDF.
1582     \txiuseunicodedestnametrue
1583   \else
1584     % XeTeX < 0.99996 (TeX Live < 2016) cannot use the
1585     % `dvipdfmx:config' special.
1586     % So for avoiding PDF destination name replacement,
1587     % xdvipdfmx's command line option `-C 0x0010' is necessary.
1588     %
1589     % XeTeX < 0.99995 can not handle Unicode destination names for PDF
1590     % because xdvipdfmx 20150315 has a UTF-16 conversion issue.
1591     % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1592     \txiuseunicodedestnamefalse
1593   \fi
1594   %
1595   % Color support
1596   %
1597   \def\rgbDarkRed{0.50 0.09 0.12}
1598   \def\rgbBlack{0 0 0}
1599   %
1600   \def\pdfsetcolor#1{\special{pdf:scolor [#1]}}
1601   %
1602   % Set color, and create a mark which defines \thiscolor accordingly,
1603   % so that \makeheadline knows which color to restore.
1604   \def\setcolor#1{%
1605     \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
1606     \domark
1607     \pdfsetcolor{#1}%
1608   }
1609   %
1610   \def\maincolor{\rgbBlack}
1611   \pdfsetcolor{\maincolor}
1612   \edef\thiscolor{\maincolor}
1613   \def\lastcolordefs{}
1614   %
1615   \def\makefootline{%
1616     \baselineskip24pt
1617     \line{\pdfsetcolor{\maincolor}\the\footline}%
1618   }
1619   %
1620   \def\makeheadline{%
1621     \vbox to 0pt{%
1622       \vskip-22.5pt
1623       \line{%
1624         \vbox to8.5pt{}%
1625         % Extract \thiscolor definition from the marks.
1626         \getcolormarks
1627         % Typeset the headline with \maincolor, then restore the color.
1628         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1629       }%
1630       \vss
1631     }%
1632     \nointerlineskip
1633   }
1634   %
1635   % PDF outline support
1636   %
1637   % Emulate pdfTeX primitive
1638   \def\pdfdest name#1 xyz{%
1639     \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}%
1640   }
1641   %
1642   \def\setpdfdestname#1{{%
1643     % We have to set dummies so commands such as @code, and characters
1644     % such as \, aren't expanded when present in a section title.
1645     \indexnofonts
1646     \makevalueexpandable
1647     \turnoffactive
1648     \iftxiuseunicodedestname
1649       % Pass through Unicode characters.
1650     \else
1651       % Use ASCII approximations in destination names.
1652       \passthroughcharsfalse
1653     \fi
1654     \def\pdfdestname{#1}%
1655     \txiescapepdf\pdfdestname
1656   }}
1657   %
1658   \def\setpdfoutlinetext#1{{%
1659     \turnoffactive
1660     % Always use Unicode characters in title texts.
1661     \def\pdfoutlinetext{#1}%
1662     % For XeTeX, xdvipdfmx converts to UTF-16.
1663     % So we do not convert.
1664     \txiescapepdf\pdfoutlinetext
1665   }}
1666   %
1667   \def\pdfmkdest#1{%
1668     \setpdfdestname{#1}%
1669     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1670   }
1671   %
1672   % by default, use black for everything.
1673   \def\urlcolor{\rgbBlack}
1674   \def\linkcolor{\rgbBlack}
1675   \def\endlink{\setcolor{\maincolor}\pdfendlink}
1676   %
1677   \def\dopdfoutline#1#2#3#4{%
1678     \setpdfoutlinetext{#1}
1679     \setpdfdestname{#3}
1680     \ifx\pdfdestname\empty
1681       \def\pdfdestname{#4}%
1682     \fi
1683     %
1684     \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
1685       << /S /GoTo /D (\pdfdestname) >> >> }%
1686   }
1687   %
1688   \def\pdfmakeoutlines{%
1689     \begingroup
1690       %
1691       % For XeTeX, counts of subentries are not necessary.
1692       % Therefore, we read toc only once.
1693       %
1694       % We use node names as destinations.
1695       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1696       \def\numchapentry##1##2##3##4{%
1697         \dopdfoutline{##1}{1}{##3}{##4}}%
1698       \def\numsecentry##1##2##3##4{%
1699         \dopdfoutline{##1}{2}{##3}{##4}}%
1700       \def\numsubsecentry##1##2##3##4{%
1701         \dopdfoutline{##1}{3}{##3}{##4}}%
1702       \def\numsubsubsecentry##1##2##3##4{%
1703         \dopdfoutline{##1}{4}{##3}{##4}}%
1704       %
1705       \let\appentry\numchapentry%
1706       \let\appsecentry\numsecentry%
1707       \let\appsubsecentry\numsubsecentry%
1708       \let\appsubsubsecentry\numsubsubsecentry%
1709       \let\unnchapentry\numchapentry%
1710       \let\unnsecentry\numsecentry%
1711       \let\unnsubsecentry\numsubsecentry%
1712       \let\unnsubsubsecentry\numsubsubsecentry%
1713       %
1714       % For XeTeX, xdvipdfmx converts strings to UTF-16.
1715       % Therefore, the encoding and the language may not be considered.
1716       %
1717       \indexnofonts
1718       \setupdatafile
1719       % We can have normal brace characters in the PDF outlines, unlike
1720       % Texinfo index files.  So set that up.
1721       \def\{{\lbracecharliteral}%
1722       \def\}{\rbracecharliteral}%
1723       \catcode`\\=\active \otherbackslash
1724       \input \tocreadfilename
1725     \endgroup
1726   }
1727   {\catcode`[=1 \catcode`]=2
1728    \catcode`{=\other \catcode`}=\other
1729    \gdef\lbracecharliteral[{]%
1730    \gdef\rbracecharliteral[}]%
1731   ]
1732
1733   \special{pdf:docview << /PageMode /UseOutlines >> }
1734   % ``\special{pdf:tounicode ...}'' is not necessary
1735   % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
1736   % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315,
1737   % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings.
1738   % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1739 %
1740   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1741     \ifx\PP\D\let\nextsp\relax
1742     \else\let\nextsp\skipspaces
1743       \addtokens{\filename}{\PP}%
1744       \advance\filenamelength by 1
1745     \fi
1746     \nextsp}
1747   \def\getfilename#1{%
1748     \filenamelength=0
1749     % If we don't expand the argument now, \skipspaces will get
1750     % snagged on things like "@value{foo}".
1751     \edef\temp{#1}%
1752     \expandafter\skipspaces\temp|\relax
1753   }
1754   % make a live url in pdf output.
1755   \def\pdfurl#1{%
1756     \begingroup
1757       % it seems we really need yet another set of dummies; have not
1758       % tried to figure out what each command should do in the context
1759       % of @url.  for now, just make @/ a no-op, that's the only one
1760       % people have actually reported a problem with.
1761       %
1762       \normalturnoffactive
1763       \def\@{@}%
1764       \let\/=\empty
1765       \makevalueexpandable
1766       % do we want to go so far as to use \indexnofonts instead of just
1767       % special-casing \var here?
1768       \def\var##1{##1}%
1769       %
1770       \leavevmode\setcolor{\urlcolor}%
1771       \special{pdf:bann << /Border [0 0 0]
1772         /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
1773     \endgroup}
1774   \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
1775   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1776   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1777   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1778   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1779   \def\maketoks{%
1780     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1781     \ifx\first0\adn0
1782     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1783     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1784     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1785     \else
1786       \ifnum0=\countA\else\makelink\fi
1787       \ifx\first.\let\next=\done\else
1788         \let\next=\maketoks
1789         \addtokens{\toksB}{\the\toksD}
1790         \ifx\first,\addtokens{\toksB}{\space}\fi
1791       \fi
1792     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1793     \next}
1794   \def\makelink{\addtokens{\toksB}%
1795     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1796   \def\pdflink#1{%
1797     \special{pdf:bann << /Border [0 0 0]
1798       /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}%
1799     \setcolor{\linkcolor}#1\endlink}
1800   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1801 %
1802   %
1803   % @image support
1804   %
1805   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1806   \def\doxeteximage#1#2#3{%
1807     \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1808     \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1809     %
1810     % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among
1811     % others).  Let's try in that order, PDF first since if
1812     % someone has a scalable image, presumably better to use that than a
1813     % bitmap.
1814     \let\xeteximgext=\empty
1815     \begingroup
1816       \openin 1 #1.pdf \ifeof 1
1817         \openin 1 #1.PDF \ifeof 1
1818           \openin 1 #1.png \ifeof 1
1819             \openin 1 #1.jpg \ifeof 1
1820               \openin 1 #1.jpeg \ifeof 1
1821                 \openin 1 #1.JPG \ifeof 1
1822                   \errmessage{Could not find image file #1 for XeTeX}%
1823                 \else \gdef\xeteximgext{JPG}%
1824                 \fi
1825               \else \gdef\xeteximgext{jpeg}%
1826               \fi
1827             \else \gdef\xeteximgext{jpg}%
1828             \fi
1829           \else \gdef\xeteximgext{png}%
1830           \fi
1831         \else \gdef\xeteximgext{PDF}%
1832         \fi
1833       \else \gdef\xeteximgext{pdf}%
1834       \fi
1835       \closein 1
1836     \endgroup
1837     %
1838     \def\xetexpdfext{pdf}%
1839     \ifx\xeteximgext\xetexpdfext
1840       \XeTeXpdffile "#1".\xeteximgext ""
1841     \else
1842       \def\xetexpdfext{PDF}%
1843       \ifx\xeteximgext\xetexpdfext
1844         \XeTeXpdffile "#1".\xeteximgext ""
1845       \else
1846         \XeTeXpicfile "#1".\xeteximgext ""
1847       \fi
1848     \fi
1849     \ifdim \wd0 >0pt width \xeteximagewidth \fi
1850     \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1851   }
1852 \fi
1853
1854
1855 %
1856 \message{fonts,}
1857
1858 % Set the baselineskip to #1, and the lineskip and strut size
1859 % correspondingly.  There is no deep meaning behind these magic numbers
1860 % used as factors; they just match (closely enough) what Knuth defined.
1861 %
1862 \def\lineskipfactor{.08333}
1863 \def\strutheightpercent{.70833}
1864 \def\strutdepthpercent {.29167}
1865 %
1866 % can get a sort of poor man's double spacing by redefining this.
1867 \def\baselinefactor{1}
1868 %
1869 \newdimen\textleading
1870 \def\setleading#1{%
1871   \dimen0 = #1\relax
1872   \normalbaselineskip = \baselinefactor\dimen0
1873   \normallineskip = \lineskipfactor\normalbaselineskip
1874   \normalbaselines
1875   \setbox\strutbox =\hbox{%
1876     \vrule width0pt height\strutheightpercent\baselineskip
1877                     depth \strutdepthpercent \baselineskip
1878   }%
1879 }
1880
1881 % PDF CMaps.  See also LaTeX's t1.cmap.
1882 %
1883 % do nothing with this by default.
1884 \expandafter\let\csname cmapOT1\endcsname\gobble
1885 \expandafter\let\csname cmapOT1IT\endcsname\gobble
1886 \expandafter\let\csname cmapOT1TT\endcsname\gobble
1887
1888 % if we are producing pdf, and we have \pdffontattr, then define cmaps.
1889 % (\pdffontattr was introduced many years ago, but people still run
1890 % older pdftex's; it's easy to conditionalize, so we do.)
1891 \ifpdf \ifx\pdffontattr\thisisundefined \else
1892   \begingroup
1893     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1894     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1895 %%DocumentNeededResources: ProcSet (CIDInit)
1896 %%IncludeResource: ProcSet (CIDInit)
1897 %%BeginResource: CMap (TeX-OT1-0)
1898 %%Title: (TeX-OT1-0 TeX OT1 0)
1899 %%Version: 1.000
1900 %%EndComments
1901 /CIDInit /ProcSet findresource begin
1902 12 dict begin
1903 begincmap
1904 /CIDSystemInfo
1905 << /Registry (TeX)
1906 /Ordering (OT1)
1907 /Supplement 0
1908 >> def
1909 /CMapName /TeX-OT1-0 def
1910 /CMapType 2 def
1911 1 begincodespacerange
1912 <00> <7F>
1913 endcodespacerange
1914 8 beginbfrange
1915 <00> <01> <0393>
1916 <09> <0A> <03A8>
1917 <23> <26> <0023>
1918 <28> <3B> <0028>
1919 <3F> <5B> <003F>
1920 <5D> <5E> <005D>
1921 <61> <7A> <0061>
1922 <7B> <7C> <2013>
1923 endbfrange
1924 40 beginbfchar
1925 <02> <0398>
1926 <03> <039B>
1927 <04> <039E>
1928 <05> <03A0>
1929 <06> <03A3>
1930 <07> <03D2>
1931 <08> <03A6>
1932 <0B> <00660066>
1933 <0C> <00660069>
1934 <0D> <0066006C>
1935 <0E> <006600660069>
1936 <0F> <00660066006C>
1937 <10> <0131>
1938 <11> <0237>
1939 <12> <0060>
1940 <13> <00B4>
1941 <14> <02C7>
1942 <15> <02D8>
1943 <16> <00AF>
1944 <17> <02DA>
1945 <18> <00B8>
1946 <19> <00DF>
1947 <1A> <00E6>
1948 <1B> <0153>
1949 <1C> <00F8>
1950 <1D> <00C6>
1951 <1E> <0152>
1952 <1F> <00D8>
1953 <21> <0021>
1954 <22> <201D>
1955 <27> <2019>
1956 <3C> <00A1>
1957 <3D> <003D>
1958 <3E> <00BF>
1959 <5C> <201C>
1960 <5F> <02D9>
1961 <60> <2018>
1962 <7D> <02DD>
1963 <7E> <007E>
1964 <7F> <00A8>
1965 endbfchar
1966 endcmap
1967 CMapName currentdict /CMap defineresource pop
1968 end
1969 end
1970 %%EndResource
1971 %%EOF
1972     }\endgroup
1973   \expandafter\edef\csname cmapOT1\endcsname#1{%
1974     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1975   }%
1976 %
1977 % \cmapOT1IT
1978   \begingroup
1979     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1980     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1981 %%DocumentNeededResources: ProcSet (CIDInit)
1982 %%IncludeResource: ProcSet (CIDInit)
1983 %%BeginResource: CMap (TeX-OT1IT-0)
1984 %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
1985 %%Version: 1.000
1986 %%EndComments
1987 /CIDInit /ProcSet findresource begin
1988 12 dict begin
1989 begincmap
1990 /CIDSystemInfo
1991 << /Registry (TeX)
1992 /Ordering (OT1IT)
1993 /Supplement 0
1994 >> def
1995 /CMapName /TeX-OT1IT-0 def
1996 /CMapType 2 def
1997 1 begincodespacerange
1998 <00> <7F>
1999 endcodespacerange
2000 8 beginbfrange
2001 <00> <01> <0393>
2002 <09> <0A> <03A8>
2003 <25> <26> <0025>
2004 <28> <3B> <0028>
2005 <3F> <5B> <003F>
2006 <5D> <5E> <005D>
2007 <61> <7A> <0061>
2008 <7B> <7C> <2013>
2009 endbfrange
2010 42 beginbfchar
2011 <02> <0398>
2012 <03> <039B>
2013 <04> <039E>
2014 <05> <03A0>
2015 <06> <03A3>
2016 <07> <03D2>
2017 <08> <03A6>
2018 <0B> <00660066>
2019 <0C> <00660069>
2020 <0D> <0066006C>
2021 <0E> <006600660069>
2022 <0F> <00660066006C>
2023 <10> <0131>
2024 <11> <0237>
2025 <12> <0060>
2026 <13> <00B4>
2027 <14> <02C7>
2028 <15> <02D8>
2029 <16> <00AF>
2030 <17> <02DA>
2031 <18> <00B8>
2032 <19> <00DF>
2033 <1A> <00E6>
2034 <1B> <0153>
2035 <1C> <00F8>
2036 <1D> <00C6>
2037 <1E> <0152>
2038 <1F> <00D8>
2039 <21> <0021>
2040 <22> <201D>
2041 <23> <0023>
2042 <24> <00A3>
2043 <27> <2019>
2044 <3C> <00A1>
2045 <3D> <003D>
2046 <3E> <00BF>
2047 <5C> <201C>
2048 <5F> <02D9>
2049 <60> <2018>
2050 <7D> <02DD>
2051 <7E> <007E>
2052 <7F> <00A8>
2053 endbfchar
2054 endcmap
2055 CMapName currentdict /CMap defineresource pop
2056 end
2057 end
2058 %%EndResource
2059 %%EOF
2060     }\endgroup
2061   \expandafter\edef\csname cmapOT1IT\endcsname#1{%
2062     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2063   }%
2064 %
2065 % \cmapOT1TT
2066   \begingroup
2067     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2068     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2069 %%DocumentNeededResources: ProcSet (CIDInit)
2070 %%IncludeResource: ProcSet (CIDInit)
2071 %%BeginResource: CMap (TeX-OT1TT-0)
2072 %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
2073 %%Version: 1.000
2074 %%EndComments
2075 /CIDInit /ProcSet findresource begin
2076 12 dict begin
2077 begincmap
2078 /CIDSystemInfo
2079 << /Registry (TeX)
2080 /Ordering (OT1TT)
2081 /Supplement 0
2082 >> def
2083 /CMapName /TeX-OT1TT-0 def
2084 /CMapType 2 def
2085 1 begincodespacerange
2086 <00> <7F>
2087 endcodespacerange
2088 5 beginbfrange
2089 <00> <01> <0393>
2090 <09> <0A> <03A8>
2091 <21> <26> <0021>
2092 <28> <5F> <0028>
2093 <61> <7E> <0061>
2094 endbfrange
2095 32 beginbfchar
2096 <02> <0398>
2097 <03> <039B>
2098 <04> <039E>
2099 <05> <03A0>
2100 <06> <03A3>
2101 <07> <03D2>
2102 <08> <03A6>
2103 <0B> <2191>
2104 <0C> <2193>
2105 <0D> <0027>
2106 <0E> <00A1>
2107 <0F> <00BF>
2108 <10> <0131>
2109 <11> <0237>
2110 <12> <0060>
2111 <13> <00B4>
2112 <14> <02C7>
2113 <15> <02D8>
2114 <16> <00AF>
2115 <17> <02DA>
2116 <18> <00B8>
2117 <19> <00DF>
2118 <1A> <00E6>
2119 <1B> <0153>
2120 <1C> <00F8>
2121 <1D> <00C6>
2122 <1E> <0152>
2123 <1F> <00D8>
2124 <20> <2423>
2125 <27> <2019>
2126 <60> <2018>
2127 <7F> <00A8>
2128 endbfchar
2129 endcmap
2130 CMapName currentdict /CMap defineresource pop
2131 end
2132 end
2133 %%EndResource
2134 %%EOF
2135     }\endgroup
2136   \expandafter\edef\csname cmapOT1TT\endcsname#1{%
2137     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2138   }%
2139 \fi\fi
2140
2141
2142 % Set the font macro #1 to the font named \fontprefix#2.
2143 % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
2144 % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
2145 % Example:
2146 % #1 = \textrm
2147 % #2 = \rmshape
2148 % #3 = 10
2149 % #4 = \mainmagstep
2150 % #5 = OT1
2151 %
2152 \def\setfont#1#2#3#4#5{%
2153   \font#1=\fontprefix#2#3 scaled #4
2154   \csname cmap#5\endcsname#1%
2155 }
2156 % This is what gets called when #5 of \setfont is empty.
2157 \let\cmap\gobble
2158 %
2159 % (end of cmaps)
2160
2161 % Use cm as the default font prefix.
2162 % To specify the font prefix, you must define \fontprefix
2163 % before you read in texinfo.tex.
2164 \ifx\fontprefix\thisisundefined
2165 \def\fontprefix{cm}
2166 \fi
2167 % Support font families that don't use the same naming scheme as CM.
2168 \def\rmshape{r}
2169 \def\rmbshape{bx}               % where the normal face is bold
2170 \def\bfshape{b}
2171 \def\bxshape{bx}
2172 \def\ttshape{tt}
2173 \def\ttbshape{tt}
2174 \def\ttslshape{sltt}
2175 \def\itshape{ti}
2176 \def\itbshape{bxti}
2177 \def\slshape{sl}
2178 \def\slbshape{bxsl}
2179 \def\sfshape{ss}
2180 \def\sfbshape{ss}
2181 \def\scshape{csc}
2182 \def\scbshape{csc}
2183
2184 % Definitions for a main text size of 11pt.  (The default in Texinfo.)
2185 %
2186 \def\definetextfontsizexi{%
2187 % Text fonts (11.2pt, magstep1).
2188 \def\textnominalsize{11pt}
2189 \edef\mainmagstep{\magstephalf}
2190 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2191 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2192 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2193 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2194 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2195 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2196 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2197 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2198 \font\texti=cmmi10 scaled \mainmagstep
2199 \font\textsy=cmsy10 scaled \mainmagstep
2200 \def\textecsize{1095}
2201
2202 % A few fonts for @defun names and args.
2203 \setfont\defbf\bfshape{10}{\magstep1}{OT1}
2204 \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
2205 \setfont\defsl\slshape{10}{\magstep1}{OT1TT}
2206 \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
2207 \def\df{\let\ttfont=\deftt \let\bffont = \defbf
2208 \let\ttslfont=\defttsl \let\slfont=\defsl \bf}
2209
2210 % Fonts for indices, footnotes, small examples (9pt).
2211 \def\smallnominalsize{9pt}
2212 \setfont\smallrm\rmshape{9}{1000}{OT1}
2213 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2214 \setfont\smallbf\bfshape{10}{900}{OT1}
2215 \setfont\smallit\itshape{9}{1000}{OT1IT}
2216 \setfont\smallsl\slshape{9}{1000}{OT1}
2217 \setfont\smallsf\sfshape{9}{1000}{OT1}
2218 \setfont\smallsc\scshape{10}{900}{OT1}
2219 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2220 \font\smalli=cmmi9
2221 \font\smallsy=cmsy9
2222 \def\smallecsize{0900}
2223
2224 % Fonts for small examples (8pt).
2225 \def\smallernominalsize{8pt}
2226 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2227 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2228 \setfont\smallerbf\bfshape{10}{800}{OT1}
2229 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2230 \setfont\smallersl\slshape{8}{1000}{OT1}
2231 \setfont\smallersf\sfshape{8}{1000}{OT1}
2232 \setfont\smallersc\scshape{10}{800}{OT1}
2233 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2234 \font\smalleri=cmmi8
2235 \font\smallersy=cmsy8
2236 \def\smallerecsize{0800}
2237
2238 % Fonts for title page (20.4pt):
2239 \def\titlenominalsize{20pt}
2240 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2241 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2242 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2243 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2244 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2245 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2246 \let\titlebf=\titlerm
2247 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2248 \font\titlei=cmmi12 scaled \magstep3
2249 \font\titlesy=cmsy10 scaled \magstep4
2250 \def\titleecsize{2074}
2251
2252 % Chapter (and unnumbered) fonts (17.28pt).
2253 \def\chapnominalsize{17pt}
2254 \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2255 \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2256 \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2257 \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2258 \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2259 \setfont\chapsf\sfbshape{17}{1000}{OT1}
2260 \let\chapbf=\chaprm
2261 \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
2262 \font\chapi=cmmi12 scaled \magstep2
2263 \font\chapsy=cmsy10 scaled \magstep3
2264 \def\chapecsize{1728}
2265
2266 % Section fonts (14.4pt).
2267 \def\secnominalsize{14pt}
2268 \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
2269 \setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
2270 \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2271 \setfont\secsl\slbshape{10}{\magstep2}{OT1}
2272 \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2273 \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2274 \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
2275 \let\secbf\secrm
2276 \setfont\secsc\scbshape{10}{\magstep2}{OT1}
2277 \font\seci=cmmi12 scaled \magstep1
2278 \font\secsy=cmsy10 scaled \magstep2
2279 \def\sececsize{1440}
2280
2281 % Subsection fonts (13.15pt).
2282 \def\ssecnominalsize{13pt}
2283 \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2284 \setfont\ssecit\itbshape{10}{1315}{OT1IT}
2285 \setfont\ssecsl\slbshape{10}{1315}{OT1}
2286 \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2287 \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2288 \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
2289 \let\ssecbf\ssecrm
2290 \setfont\ssecsc\scbshape{10}{1315}{OT1}
2291 \font\sseci=cmmi12 scaled \magstephalf
2292 \font\ssecsy=cmsy10 scaled 1315
2293 \def\ssececsize{1200}
2294
2295 % Reduced fonts for @acronym in text (10pt).
2296 \def\reducednominalsize{10pt}
2297 \setfont\reducedrm\rmshape{10}{1000}{OT1}
2298 \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2299 \setfont\reducedbf\bfshape{10}{1000}{OT1}
2300 \setfont\reducedit\itshape{10}{1000}{OT1IT}
2301 \setfont\reducedsl\slshape{10}{1000}{OT1}
2302 \setfont\reducedsf\sfshape{10}{1000}{OT1}
2303 \setfont\reducedsc\scshape{10}{1000}{OT1}
2304 \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
2305 \font\reducedi=cmmi10
2306 \font\reducedsy=cmsy10
2307 \def\reducedecsize{1000}
2308
2309 \textleading = 13.2pt % line spacing for 11pt CM
2310 \textfonts            % reset the current fonts
2311 \rm
2312 } % end of 11pt text font size definitions, \definetextfontsizexi
2313
2314
2315 % Definitions to make the main text be 10pt Computer Modern, with
2316 % section, chapter, etc., sizes following suit.  This is for the GNU
2317 % Press printing of the Emacs 22 manual.  Maybe other manuals in the
2318 % future.  Used with @smallbook, which sets the leading to 12pt.
2319 %
2320 \def\definetextfontsizex{%
2321 % Text fonts (10pt).
2322 \def\textnominalsize{10pt}
2323 \edef\mainmagstep{1000}
2324 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2325 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2326 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2327 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2328 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2329 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2330 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2331 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2332 \font\texti=cmmi10 scaled \mainmagstep
2333 \font\textsy=cmsy10 scaled \mainmagstep
2334 \def\textecsize{1000}
2335
2336 % A few fonts for @defun names and args.
2337 \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2338 \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
2339 \setfont\defsl\slshape{10}{\magstephalf}{OT1TT}
2340 \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
2341 \def\df{\let\ttfont=\deftt \let\bffont = \defbf
2342 \let\slfont=\defsl \let\ttslfont=\defttsl \bf}
2343
2344 % Fonts for indices, footnotes, small examples (9pt).
2345 \def\smallnominalsize{9pt}
2346 \setfont\smallrm\rmshape{9}{1000}{OT1}
2347 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2348 \setfont\smallbf\bfshape{10}{900}{OT1}
2349 \setfont\smallit\itshape{9}{1000}{OT1IT}
2350 \setfont\smallsl\slshape{9}{1000}{OT1}
2351 \setfont\smallsf\sfshape{9}{1000}{OT1}
2352 \setfont\smallsc\scshape{10}{900}{OT1}
2353 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2354 \font\smalli=cmmi9
2355 \font\smallsy=cmsy9
2356 \def\smallecsize{0900}
2357
2358 % Fonts for small examples (8pt).
2359 \def\smallernominalsize{8pt}
2360 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2361 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2362 \setfont\smallerbf\bfshape{10}{800}{OT1}
2363 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2364 \setfont\smallersl\slshape{8}{1000}{OT1}
2365 \setfont\smallersf\sfshape{8}{1000}{OT1}
2366 \setfont\smallersc\scshape{10}{800}{OT1}
2367 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2368 \font\smalleri=cmmi8
2369 \font\smallersy=cmsy8
2370 \def\smallerecsize{0800}
2371
2372 % Fonts for title page (20.4pt):
2373 \def\titlenominalsize{20pt}
2374 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2375 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2376 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2377 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2378 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2379 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2380 \let\titlebf=\titlerm
2381 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2382 \font\titlei=cmmi12 scaled \magstep3
2383 \font\titlesy=cmsy10 scaled \magstep4
2384 \def\titleecsize{2074}
2385
2386 % Chapter fonts (14.4pt).
2387 \def\chapnominalsize{14pt}
2388 \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2389 \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2390 \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2391 \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2392 \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2393 \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2394 \let\chapbf\chaprm
2395 \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2396 \font\chapi=cmmi12 scaled \magstep1
2397 \font\chapsy=cmsy10 scaled \magstep2
2398 \def\chapecsize{1440}
2399
2400 % Section fonts (12pt).
2401 \def\secnominalsize{12pt}
2402 \setfont\secrm\rmbshape{12}{1000}{OT1}
2403 \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2404 \setfont\secsl\slbshape{10}{\magstep1}{OT1}
2405 \setfont\sectt\ttbshape{12}{1000}{OT1TT}
2406 \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2407 \setfont\secsf\sfbshape{12}{1000}{OT1}
2408 \let\secbf\secrm
2409 \setfont\secsc\scbshape{10}{\magstep1}{OT1}
2410 \font\seci=cmmi12
2411 \font\secsy=cmsy10 scaled \magstep1
2412 \def\sececsize{1200}
2413
2414 % Subsection fonts (10pt).
2415 \def\ssecnominalsize{10pt}
2416 \setfont\ssecrm\rmbshape{10}{1000}{OT1}
2417 \setfont\ssecit\itbshape{10}{1000}{OT1IT}
2418 \setfont\ssecsl\slbshape{10}{1000}{OT1}
2419 \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2420 \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2421 \setfont\ssecsf\sfbshape{10}{1000}{OT1}
2422 \let\ssecbf\ssecrm
2423 \setfont\ssecsc\scbshape{10}{1000}{OT1}
2424 \font\sseci=cmmi10
2425 \font\ssecsy=cmsy10
2426 \def\ssececsize{1000}
2427
2428 % Reduced fonts for @acronym in text (9pt).
2429 \def\reducednominalsize{9pt}
2430 \setfont\reducedrm\rmshape{9}{1000}{OT1}
2431 \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2432 \setfont\reducedbf\bfshape{10}{900}{OT1}
2433 \setfont\reducedit\itshape{9}{1000}{OT1IT}
2434 \setfont\reducedsl\slshape{9}{1000}{OT1}
2435 \setfont\reducedsf\sfshape{9}{1000}{OT1}
2436 \setfont\reducedsc\scshape{10}{900}{OT1}
2437 \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2438 \font\reducedi=cmmi9
2439 \font\reducedsy=cmsy9
2440 \def\reducedecsize{0900}
2441
2442 \divide\parskip by 2  % reduce space between paragraphs
2443 \textleading = 12pt   % line spacing for 10pt CM
2444 \textfonts            % reset the current fonts
2445 \rm
2446 } % end of 10pt text font size definitions, \definetextfontsizex
2447
2448 % Fonts for short table of contents.
2449 \setfont\shortcontrm\rmshape{12}{1000}{OT1}
2450 \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
2451 \setfont\shortcontsl\slshape{12}{1000}{OT1}
2452 \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2453
2454
2455 % We provide the user-level command
2456 %   @fonttextsize 10
2457 % (or 11) to redefine the text font size.  pt is assumed.
2458 %
2459 \def\xiword{11}
2460 \def\xword{10}
2461 \def\xwordpt{10pt}
2462 %
2463 \parseargdef\fonttextsize{%
2464   \def\textsizearg{#1}%
2465   %\wlog{doing @fonttextsize \textsizearg}%
2466   %
2467   % Set \globaldefs so that documents can use this inside @tex, since
2468   % makeinfo 4.8 does not support it, but we need it nonetheless.
2469   %
2470  \begingroup \globaldefs=1
2471   \ifx\textsizearg\xword \definetextfontsizex
2472   \else \ifx\textsizearg\xiword \definetextfontsizexi
2473   \else
2474     \errhelp=\EMsimple
2475     \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2476   \fi\fi
2477  \endgroup
2478 }
2479
2480 %
2481 % Change the current font style to #1, remembering it in \curfontstyle.
2482 % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
2483 % italics, not bold italics.
2484 %
2485 \def\setfontstyle#1{%
2486   \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
2487   \csname #1font\endcsname  % change the current font
2488 }
2489
2490 \def\rm{\fam=0 \setfontstyle{rm}}
2491 \def\it{\fam=\itfam \setfontstyle{it}}
2492 \def\sl{\fam=\slfam \setfontstyle{sl}}
2493 \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
2494 \def\tt{\fam=\ttfam \setfontstyle{tt}}
2495
2496 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
2497 % So we set up a \sf.
2498 \newfam\sffam
2499 \def\sf{\fam=\sffam \setfontstyle{sf}}
2500
2501 % We don't need math for this font style.
2502 \def\ttsl{\setfontstyle{ttsl}}
2503
2504
2505 % In order for the font changes to affect most math symbols and letters,
2506 % we have to define the \textfont of the standard families.  We don't
2507 % bother to reset \scriptfont and \scriptscriptfont; awaiting user need.
2508 %
2509 \def\resetmathfonts{%
2510   \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont
2511   \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont
2512   \textfont\ttfam=\ttfont \textfont\sffam=\sffont
2513 }
2514
2515 %
2516
2517 % The font-changing commands (all called \...fonts) redefine the meanings
2518 % of \STYLEfont, instead of just \STYLE.  We do this because \STYLE needs
2519 % to also set the current \fam for math mode.  Our \STYLE (e.g., \rm)
2520 % commands hardwire \STYLEfont to set the current font.
2521 %
2522 % Each font-changing command also sets the names \lsize (one size lower)
2523 % and \lllsize (three sizes lower).  These relative commands are used
2524 % in, e.g., the LaTeX logo and acronyms.
2525 %
2526 % This all needs generalizing, badly.
2527 %
2528
2529 \def\assignfonts#1{%
2530   \expandafter\let\expandafter\rmfont\csname #1rm\endcsname
2531   \expandafter\let\expandafter\itfont\csname #1it\endcsname
2532   \expandafter\let\expandafter\slfont\csname #1sl\endcsname
2533   \expandafter\let\expandafter\bffont\csname #1bf\endcsname
2534   \expandafter\let\expandafter\ttfont\csname #1tt\endcsname
2535   \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname
2536   \expandafter\let\expandafter\sffont  \csname #1sf\endcsname
2537   \expandafter\let\expandafter\ifont   \csname #1i\endcsname
2538   \expandafter\let\expandafter\syfont  \csname #1sy\endcsname
2539   \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname
2540 }
2541
2542 \newif\ifrmisbold
2543
2544 % Select smaller font size with the current style.  Used to change font size
2545 % in, e.g., the LaTeX logo and acronyms.  If we are using bold fonts for
2546 % normal roman text, also use bold fonts for roman text in the smaller size.
2547 \def\switchtolllsize{%
2548    \expandafter\assignfonts\expandafter{\lllsize}%
2549    \ifrmisbold
2550      \let\rmfont\bffont
2551    \fi
2552    \csname\curfontstyle\endcsname
2553 }%
2554
2555 \def\switchtolsize{%
2556    \expandafter\assignfonts\expandafter{\lsize}%
2557    \ifrmisbold
2558      \let\rmfont\bffont
2559    \fi
2560    \csname\curfontstyle\endcsname
2561 }%
2562
2563 \def\definefontsetatsize#1#2#3#4#5{%
2564 \expandafter\def\csname #1fonts\endcsname{%
2565   \def\curfontsize{#1}%
2566   \def\lsize{#2}\def\lllsize{#3}%
2567   \csname rmisbold#5\endcsname
2568   \assignfonts{#1}%
2569   \resetmathfonts
2570   \setleading{#4}%
2571 }}
2572
2573 \definefontsetatsize{text}   {reduced}{smaller}{\textleading}{false}
2574 \definefontsetatsize{title}  {chap}   {subsec} {27pt}  {true}
2575 \definefontsetatsize{chap}   {sec}    {text}   {19pt}  {true}
2576 \definefontsetatsize{sec}    {subsec} {reduced}{17pt}  {true}
2577 \definefontsetatsize{ssec}   {text}   {small}  {15pt}  {true}
2578 \definefontsetatsize{reduced}{small}  {smaller}{10.5pt}{false}
2579 \definefontsetatsize{small}  {smaller}{smaller}{10.5pt}{false}
2580 \definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false}
2581
2582 \def\titlefont#1{{\titlefonts\rm #1}}
2583 \let\subsecfonts = \ssecfonts
2584 \let\subsubsecfonts = \ssecfonts
2585
2586 % Define these just so they can be easily changed for other fonts.
2587 \def\angleleft{$\langle$}
2588 \def\angleright{$\rangle$}
2589
2590 % Set the fonts to use with the @small... environments.
2591 \let\smallexamplefonts = \smallfonts
2592
2593 % About \smallexamplefonts.  If we use \smallfonts (9pt), @smallexample
2594 % can fit this many characters:
2595 %   8.5x11=86   smallbook=72  a4=90  a5=69
2596 % If we use \scriptfonts (8pt), then we can fit this many characters:
2597 %   8.5x11=90+  smallbook=80  a4=90+  a5=77
2598 % For me, subjectively, the few extra characters that fit aren't worth
2599 % the additional smallness of 8pt.  So I'm making the default 9pt.
2600 %
2601 % By the way, for comparison, here's what fits with @example (10pt):
2602 %   8.5x11=71  smallbook=60  a4=75  a5=58
2603 % --karl, 24jan03.
2604
2605 % Set up the default fonts, so we can use them for creating boxes.
2606 %
2607 \definetextfontsizexi
2608
2609
2610 \message{markup,}
2611
2612 % Check if we are currently using a typewriter font.  Since all the
2613 % Computer Modern typewriter fonts have zero interword stretch (and
2614 % shrink), and it is reasonable to expect all typewriter fonts to have
2615 % this property, we can check that font parameter.
2616 %
2617 \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
2618
2619 % Markup style infrastructure.  \defmarkupstylesetup\INITMACRO will
2620 % define and register \INITMACRO to be called on markup style changes.
2621 % \INITMACRO can check \currentmarkupstyle for the innermost
2622 % style.
2623
2624 \let\currentmarkupstyle\empty
2625
2626 \def\setupmarkupstyle#1{%
2627   \def\currentmarkupstyle{#1}%
2628   \markupstylesetup
2629 }
2630
2631 \let\markupstylesetup\empty
2632
2633 \def\defmarkupstylesetup#1{%
2634   \expandafter\def\expandafter\markupstylesetup
2635     \expandafter{\markupstylesetup #1}%
2636   \def#1%
2637 }
2638
2639 % Markup style setup for left and right quotes.
2640 \defmarkupstylesetup\markupsetuplq{%
2641   \expandafter\let\expandafter \temp
2642     \csname markupsetuplq\currentmarkupstyle\endcsname
2643   \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
2644 }
2645
2646 \defmarkupstylesetup\markupsetuprq{%
2647   \expandafter\let\expandafter \temp
2648     \csname markupsetuprq\currentmarkupstyle\endcsname
2649   \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
2650 }
2651
2652 {
2653 \catcode`\'=\active
2654 \catcode`\`=\active
2655
2656 \gdef\markupsetuplqdefault{\let`\lq}
2657 \gdef\markupsetuprqdefault{\let'\rq}
2658
2659 \gdef\markupsetcodequoteleft{\let`\codequoteleft}
2660 \gdef\markupsetcodequoteright{\let'\codequoteright}
2661 }
2662
2663 \let\markupsetuplqcode \markupsetcodequoteleft
2664 \let\markupsetuprqcode \markupsetcodequoteright
2665 %
2666 \let\markupsetuplqexample \markupsetcodequoteleft
2667 \let\markupsetuprqexample \markupsetcodequoteright
2668 %
2669 \let\markupsetuplqkbd     \markupsetcodequoteleft
2670 \let\markupsetuprqkbd     \markupsetcodequoteright
2671 %
2672 \let\markupsetuplqsamp \markupsetcodequoteleft
2673 \let\markupsetuprqsamp \markupsetcodequoteright
2674 %
2675 \let\markupsetuplqverb \markupsetcodequoteleft
2676 \let\markupsetuprqverb \markupsetcodequoteright
2677 %
2678 \let\markupsetuplqverbatim \markupsetcodequoteleft
2679 \let\markupsetuprqverbatim \markupsetcodequoteright
2680
2681 % Allow an option to not use regular directed right quote/apostrophe
2682 % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2683 % The undirected quote is ugly, so don't make it the default, but it
2684 % works for pasting with more pdf viewers (at least evince), the
2685 % lilypond developers report.  xpdf does work with the regular 0x27.
2686 %
2687 \def\codequoteright{%
2688   \ifmonospace
2689     \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
2690       \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
2691         '%
2692       \else \char'15 \fi
2693     \else \char'15 \fi
2694    \else
2695      '%
2696    \fi
2697 }
2698 %
2699 % and a similar option for the left quote char vs. a grave accent.
2700 % Modern fonts display ASCII 0x60 as a grave accent, so some people like
2701 % the code environments to do likewise.
2702 %
2703 \def\codequoteleft{%
2704   \ifmonospace
2705     \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
2706       \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
2707         % [Knuth] pp. 380,381,391
2708         % \relax disables Spanish ligatures ?` and !` of \tt font.
2709         \relax`%
2710       \else \char'22 \fi
2711     \else \char'22 \fi
2712    \else
2713      \relax`%
2714    \fi
2715 }
2716
2717 % Commands to set the quote options.
2718
2719 \parseargdef\codequoteundirected{%
2720   \def\temp{#1}%
2721   \ifx\temp\onword
2722     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2723       = t%
2724   \else\ifx\temp\offword
2725     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2726       = \relax
2727   \else
2728     \errhelp = \EMsimple
2729     \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2730   \fi\fi
2731 }
2732 %
2733 \parseargdef\codequotebacktick{%
2734   \def\temp{#1}%
2735   \ifx\temp\onword
2736     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2737       = t%
2738   \else\ifx\temp\offword
2739     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2740       = \relax
2741   \else
2742     \errhelp = \EMsimple
2743     \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2744   \fi\fi
2745 }
2746
2747 % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2748 \def\noligaturesquoteleft{\relax\lq}
2749
2750 % Count depth in font-changes, for error checks
2751 \newcount\fontdepth \fontdepth=0
2752
2753 % Font commands.
2754
2755 % #1 is the font command (\sl or \it), #2 is the text to slant.
2756 % If we are in a monospaced environment, however, 1) always use \ttsl,
2757 % and 2) do not add an italic correction.
2758 \def\dosmartslant#1#2{%
2759   \ifusingtt 
2760     {{\ttsl #2}\let\next=\relax}%
2761     {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
2762   \next
2763 }
2764 \def\smartslanted{\dosmartslant\sl}
2765 \def\smartitalic{\dosmartslant\it}
2766
2767 % Output an italic correction unless \next (presumed to be the following
2768 % character) is such as not to need one.
2769 \def\smartitaliccorrection{%
2770   \ifx\next,%
2771   \else\ifx\next-%
2772   \else\ifx\next.%
2773   \else\ifx\next\.%
2774   \else\ifx\next\comma%
2775   \else\ptexslash
2776   \fi\fi\fi\fi\fi
2777   \aftersmartic
2778 }
2779
2780 % Unconditional use \ttsl, and no ic.  @var is set to this for defuns.
2781 \def\ttslanted#1{{\ttsl #1}}
2782
2783 % @cite is like \smartslanted except unconditionally use \sl.  We never want
2784 % ttsl for book titles, do we?
2785 \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
2786
2787 \def\aftersmartic{}
2788 \def\var#1{%
2789   \let\saveaftersmartic = \aftersmartic
2790   \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
2791   \smartslanted{#1}%
2792 }
2793
2794 \let\i=\smartitalic
2795 \let\slanted=\smartslanted
2796 \let\dfn=\smartslanted
2797 \let\emph=\smartitalic
2798
2799 % Explicit font changes: @r, @sc, undocumented @ii.
2800 \def\r#1{{\rm #1}}              % roman font
2801 \def\sc#1{{\smallcaps#1}}       % smallcaps font
2802 \def\ii#1{{\it #1}}             % italic font
2803
2804 % @b, explicit bold.  Also @strong.
2805 \def\b#1{{\bf #1}}
2806 \let\strong=\b
2807
2808 % @sansserif, explicit sans.
2809 \def\sansserif#1{{\sf #1}}
2810
2811 % We can't just use \exhyphenpenalty, because that only has effect at
2812 % the end of a paragraph.  Restore normal hyphenation at the end of the
2813 % group within which \nohyphenation is presumably called.
2814 %
2815 \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
2816 \def\restorehyphenation{\hyphenchar\font = `- }
2817
2818 % Set sfcode to normal for the chars that usually have another value.
2819 % Can't use plain's \frenchspacing because it uses the `\x notation, and
2820 % sometimes \x has an active definition that messes things up.
2821 %
2822 \catcode`@=11
2823   \def\plainfrenchspacing{%
2824     \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
2825     \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
2826     \def\endofsentencespacefactor{1000}% for @. and friends
2827   }
2828   \def\plainnonfrenchspacing{%
2829     \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2830     \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2831     \def\endofsentencespacefactor{3000}% for @. and friends
2832   }
2833 \catcode`@=\other
2834 \def\endofsentencespacefactor{3000}% default
2835
2836 % @t, explicit typewriter.
2837 \def\t#1{%
2838   {\tt \rawbackslash \plainfrenchspacing #1}%
2839   \null
2840 }
2841
2842 % @samp.
2843 \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
2844
2845 % @indicateurl is \samp, that is, with quotes.
2846 \let\indicateurl=\samp
2847
2848 % @code (and similar) prints in typewriter, but with spaces the same
2849 % size as normal in the surrounding text, without hyphenation, etc.
2850 % This is a subroutine for that.
2851 \def\tclose#1{%
2852   {%
2853     % Change normal interword space to be same as for the current font.
2854     \spaceskip = \fontdimen2\font
2855     %
2856     % Switch to typewriter.
2857     \tt
2858     %
2859     % But `\ ' produces the large typewriter interword space.
2860     \def\ {{\spaceskip = 0pt{} }}%
2861     %
2862     % Turn off hyphenation.
2863     \nohyphenation
2864     %
2865     \rawbackslash
2866     \plainfrenchspacing
2867     #1%
2868   }%
2869   \null % reset spacefactor to 1000
2870 }
2871
2872 % We *must* turn on hyphenation at `-' and `_' in @code.
2873 % (But see \codedashfinish below.)
2874 % Otherwise, it is too hard to avoid overfull hboxes
2875 % in the Emacs manual, the Library manual, etc.
2876 %
2877 % Unfortunately, TeX uses one parameter (\hyphenchar) to control
2878 % both hyphenation at - and hyphenation within words.
2879 % We must therefore turn them both off (\tclose does that)
2880 % and arrange explicitly to hyphenate at a dash. -- rms.
2881 {
2882   \catcode`\-=\active \catcode`\_=\active
2883   \catcode`\'=\active \catcode`\`=\active
2884   \global\let'=\rq \global\let`=\lq  % default definitions
2885   %
2886   \global\def\code{\begingroup
2887     \setupmarkupstyle{code}%
2888     % The following should really be moved into \setupmarkupstyle handlers.
2889     \catcode\dashChar=\active  \catcode\underChar=\active
2890     \ifallowcodebreaks
2891      \let-\codedash
2892      \let_\codeunder
2893     \else
2894      \let-\normaldash
2895      \let_\realunder
2896     \fi
2897     % Given -foo (with a single dash), we do not want to allow a break
2898     % after the hyphen.
2899     \global\let\codedashprev=\codedash
2900     %
2901     \codex
2902   }
2903   %
2904   \gdef\codedash{\futurelet\next\codedashfinish}
2905   \gdef\codedashfinish{%
2906     \normaldash % always output the dash character itself.
2907     % 
2908     % Now, output a discretionary to allow a line break, unless
2909     % (a) the next character is a -, or
2910     % (b) the preceding character is a -.
2911     % E.g., given --posix, we do not want to allow a break after either -.
2912     % Given --foo-bar, we do want to allow a break between the - and the b.
2913     \ifx\next\codedash \else
2914       \ifx\codedashprev\codedash 
2915       \else \discretionary{}{}{}\fi
2916     \fi
2917     % we need the space after the = for the case when \next itself is a
2918     % space token; it would get swallowed otherwise.  As in @code{- a}.
2919     \global\let\codedashprev= \next
2920   }
2921 }
2922 \def\normaldash{-}
2923 %
2924 \def\codex #1{\tclose{#1}\endgroup}
2925
2926 \def\codeunder{%
2927   % this is all so @math{@code{var_name}+1} can work.  In math mode, _
2928   % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2929   % will therefore expand the active definition of _, which is us
2930   % (inside @code that is), therefore an endless loop.
2931   \ifusingtt{\ifmmode
2932                \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2933              \else\normalunderscore \fi
2934              \discretionary{}{}{}}%
2935             {\_}%
2936 }
2937
2938 % An additional complication: the above will allow breaks after, e.g.,
2939 % each of the four underscores in __typeof__.  This is bad.
2940 % @allowcodebreaks provides a document-level way to turn breaking at -
2941 % and _ on and off.
2942 %
2943 \newif\ifallowcodebreaks  \allowcodebreakstrue
2944
2945 \def\keywordtrue{true}
2946 \def\keywordfalse{false}
2947
2948 \parseargdef\allowcodebreaks{%
2949   \def\txiarg{#1}%
2950   \ifx\txiarg\keywordtrue
2951     \allowcodebreakstrue
2952   \else\ifx\txiarg\keywordfalse
2953     \allowcodebreaksfalse
2954   \else
2955     \errhelp = \EMsimple
2956     \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
2957   \fi\fi
2958 }
2959
2960 % For @command, @env, @file, @option quotes seem unnecessary,
2961 % so use \code rather than \samp.
2962 \let\command=\code
2963 \let\env=\code
2964 \let\file=\code
2965 \let\option=\code
2966
2967 % @uref (abbreviation for `urlref') aka @url takes an optional
2968 % (comma-separated) second argument specifying the text to display and
2969 % an optional third arg as text to display instead of (rather than in
2970 % addition to) the url itself.  First (mandatory) arg is the url.
2971
2972 % TeX-only option to allow changing PDF output to show only the second
2973 % arg (if given), and not the url (which is then just the link target).
2974 \newif\ifurefurlonlylink
2975
2976 % The main macro is \urefbreak, which allows breaking at expected
2977 % places within the url.  (There used to be another version, which
2978 % didn't support automatic breaking.)
2979 \def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
2980 \let\uref=\urefbreak
2981 %
2982 \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
2983 \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
2984   \unsepspaces
2985   \pdfurl{#1}%
2986   \setbox0 = \hbox{\ignorespaces #3}%
2987   \ifdim\wd0 > 0pt
2988     \unhbox0 % third arg given, show only that
2989   \else
2990     \setbox0 = \hbox{\ignorespaces #2}% look for second arg
2991     \ifdim\wd0 > 0pt
2992       \ifpdf
2993         % For pdfTeX and LuaTeX
2994         \ifurefurlonlylink
2995           % PDF plus option to not display url, show just arg
2996           \unhbox0             
2997         \else
2998           % PDF, normally display both arg and url for consistency,
2999           % visibility, if the pdf is eventually used to print, etc.
3000           \unhbox0\ (\urefcode{#1})%
3001         \fi
3002       \else
3003         \ifx\XeTeXrevision\thisisundefined
3004           \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
3005         \else
3006           % For XeTeX
3007           \ifurefurlonlylink
3008             % PDF plus option to not display url, show just arg
3009             \unhbox0             
3010           \else
3011             % PDF, normally display both arg and url for consistency,
3012             % visibility, if the pdf is eventually used to print, etc.
3013             \unhbox0\ (\urefcode{#1})%
3014           \fi
3015         \fi
3016       \fi
3017     \else
3018       \urefcode{#1}% only url given, so show it
3019     \fi
3020   \fi
3021   \endlink
3022 \endgroup}
3023
3024 % Allow line breaks around only a few characters (only).
3025 \def\urefcatcodes{%
3026   \catcode`\&=\active \catcode`\.=\active
3027   \catcode`\#=\active \catcode`\?=\active
3028   \catcode`\/=\active
3029 }
3030 {
3031   \urefcatcodes
3032   %
3033   \global\def\urefcode{\begingroup
3034     \setupmarkupstyle{code}%
3035     \urefcatcodes
3036     \let&\urefcodeamp
3037     \let.\urefcodedot
3038     \let#\urefcodehash
3039     \let?\urefcodequest
3040     \let/\urefcodeslash
3041     \codex
3042   }
3043   %
3044   % By default, they are just regular characters.
3045   \global\def&{\normalamp}
3046   \global\def.{\normaldot}
3047   \global\def#{\normalhash}
3048   \global\def?{\normalquest}
3049   \global\def/{\normalslash}
3050 }
3051
3052 % we put a little stretch before and after the breakable chars, to help
3053 % line breaking of long url's.  The unequal skips make look better in
3054 % cmtt at least, especially for dots.
3055 \def\urefprestretchamount{.13em}
3056 \def\urefpoststretchamount{.1em}
3057 \def\urefprestretch{\urefprebreak \hskip0pt plus\urefprestretchamount\relax}
3058 \def\urefpoststretch{\urefpostbreak \hskip0pt plus\urefprestretchamount\relax}
3059 %
3060 \def\urefcodeamp{\urefprestretch \&\urefpoststretch}
3061 \def\urefcodedot{\urefprestretch .\urefpoststretch}
3062 \def\urefcodehash{\urefprestretch \#\urefpoststretch}
3063 \def\urefcodequest{\urefprestretch ?\urefpoststretch}
3064 \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
3065 {
3066   \catcode`\/=\active
3067   \global\def\urefcodeslashfinish{%
3068     \urefprestretch \slashChar
3069     % Allow line break only after the final / in a sequence of
3070     % slashes, to avoid line break between the slashes in http://.
3071     \ifx\next/\else \urefpoststretch \fi
3072   }
3073 }
3074
3075 % One more complication: by default we'll break after the special
3076 % characters, but some people like to break before the special chars, so
3077 % allow that.  Also allow no breaking at all, for manual control.
3078
3079 \parseargdef\urefbreakstyle{%
3080   \def\txiarg{#1}%
3081   \ifx\txiarg\wordnone
3082     \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
3083   \else\ifx\txiarg\wordbefore
3084     \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
3085   \else\ifx\txiarg\wordafter
3086     \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
3087   \else
3088     \errhelp = \EMsimple
3089     \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
3090   \fi\fi\fi
3091 }
3092 \def\wordafter{after}
3093 \def\wordbefore{before}
3094 \def\wordnone{none}
3095
3096 \urefbreakstyle after
3097
3098 % @url synonym for @uref, since that's how everyone uses it.
3099 %
3100 \let\url=\uref
3101
3102 % rms does not like angle brackets --karl, 17may97.
3103 % So now @email is just like @uref, unless we are pdf.
3104 %
3105 %\def\email#1{\angleleft{\tt #1}\angleright}
3106 \ifpdf
3107   \def\email#1{\doemail#1,,\finish}
3108   \def\doemail#1,#2,#3\finish{\begingroup
3109     \unsepspaces
3110     \pdfurl{mailto:#1}%
3111     \setbox0 = \hbox{\ignorespaces #2}%
3112     \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3113     \endlink
3114   \endgroup}
3115 \else
3116   \ifx\XeTeXrevision\thisisundefined
3117     \let\email=\uref
3118   \else
3119     \def\email#1{\doemail#1,,\finish}
3120     \def\doemail#1,#2,#3\finish{\begingroup
3121       \unsepspaces
3122       \pdfurl{mailto:#1}%
3123       \setbox0 = \hbox{\ignorespaces #2}%
3124       \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3125       \endlink
3126     \endgroup}
3127   \fi
3128 \fi
3129
3130 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
3131 %   `example' (@kbd uses ttsl only inside of @example and friends),
3132 %   or `code' (@kbd uses normal tty font always).
3133 \parseargdef\kbdinputstyle{%
3134   \def\txiarg{#1}%
3135   \ifx\txiarg\worddistinct
3136     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
3137   \else\ifx\txiarg\wordexample
3138     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
3139   \else\ifx\txiarg\wordcode
3140     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
3141   \else
3142     \errhelp = \EMsimple
3143     \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
3144   \fi\fi\fi
3145 }
3146 \def\worddistinct{distinct}
3147 \def\wordexample{example}
3148 \def\wordcode{code}
3149
3150 % Default is `distinct'.
3151 \kbdinputstyle distinct
3152
3153 % @kbd is like @code, except that if the argument is just one @key command,
3154 % then @kbd has no effect.
3155 \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
3156
3157 \def\xkey{\key}
3158 \def\kbdsub#1#2#3\par{%
3159   \def\one{#1}\def\three{#3}\def\threex{??}%
3160   \ifx\one\xkey\ifx\threex\three \key{#2}%
3161   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3162   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3163 }
3164
3165 % definition of @key that produces a lozenge.  Doesn't adjust to text size.
3166 %\setfont\keyrm\rmshape{8}{1000}{OT1}
3167 %\font\keysy=cmsy9
3168 %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
3169 %  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
3170 %    \vbox{\hrule\kern-0.4pt
3171 %     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
3172 %    \kern-0.4pt\hrule}%
3173 %  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
3174
3175 % definition of @key with no lozenge.  If the current font is already
3176 % monospace, don't change it; that way, we respect @kbdinputstyle.  But
3177 % if it isn't monospace, then use \tt.
3178 %
3179 \def\key#1{{\setupmarkupstyle{key}%
3180   \nohyphenation
3181   \ifmonospace\else\tt\fi
3182   #1}\null}
3183
3184 % @clicksequence{File @click{} Open ...}
3185 \def\clicksequence#1{\begingroup #1\endgroup}
3186
3187 % @clickstyle @arrow   (by default)
3188 \parseargdef\clickstyle{\def\click{#1}}
3189 \def\click{\arrow}
3190
3191 % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
3192 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
3193 %
3194 \def\dmn#1{\thinspace #1}
3195
3196 % @acronym for "FBI", "NATO", and the like.
3197 % We print this one point size smaller, since it's intended for
3198 % all-uppercase.
3199 %
3200 \def\acronym#1{\doacronym #1,,\finish}
3201 \def\doacronym#1,#2,#3\finish{%
3202   {\switchtolsize #1}%
3203   \def\temp{#2}%
3204   \ifx\temp\empty \else
3205     \space ({\unsepspaces \ignorespaces \temp \unskip})%
3206   \fi
3207   \null % reset \spacefactor=1000
3208 }
3209
3210 % @abbr for "Comput. J." and the like.
3211 % No font change, but don't do end-of-sentence spacing.
3212 %
3213 \def\abbr#1{\doabbr #1,,\finish}
3214 \def\doabbr#1,#2,#3\finish{%
3215   {\plainfrenchspacing #1}%
3216   \def\temp{#2}%
3217   \ifx\temp\empty \else
3218     \space ({\unsepspaces \ignorespaces \temp \unskip})%
3219   \fi
3220   \null % reset \spacefactor=1000
3221 }
3222
3223 % @asis just yields its argument.  Used with @table, for example.
3224 %
3225 \def\asis#1{#1}
3226
3227 % @math outputs its argument in math mode.
3228 %
3229 % One complication: _ usually means subscripts, but it could also mean
3230 % an actual _ character, as in @math{@var{some_variable} + 1}.  So make
3231 % _ active, and distinguish by seeing if the current family is \slfam,
3232 % which is what @var uses.
3233 {
3234   \catcode`\_ = \active
3235   \gdef\mathunderscore{%
3236     \catcode`\_=\active
3237     \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
3238   }
3239 }
3240 % Another complication: we want \\ (and @\) to output a math (or tt) \.
3241 % FYI, plain.tex uses \\ as a temporary control sequence (for no
3242 % particular reason), but this is not advertised and we don't care.
3243 %
3244 % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
3245 \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
3246 %
3247 \def\math{%
3248   \ifmmode\else % only go into math if not in math mode already
3249     \tex
3250     \mathunderscore
3251     \let\\ = \mathbackslash
3252     \mathactive
3253     % make the texinfo accent commands work in math mode
3254     \let\"=\ddot
3255     \let\'=\acute
3256     \let\==\bar
3257     \let\^=\hat
3258     \let\`=\grave
3259     \let\u=\breve
3260     \let\v=\check
3261     \let\~=\tilde
3262     \let\dotaccent=\dot
3263     % have to provide another name for sup operator
3264     \let\mathopsup=\sup
3265   $\expandafter\finishmath\fi
3266 }
3267 \def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
3268
3269 % Some active characters (such as <) are spaced differently in math.
3270 % We have to reset their definitions in case the @math was an argument
3271 % to a command which sets the catcodes (such as @item or @section).
3272 %
3273 {
3274   \catcode`^ = \active
3275   \catcode`< = \active
3276   \catcode`> = \active
3277   \catcode`+ = \active
3278   \catcode`' = \active
3279   \gdef\mathactive{%
3280     \let^ = \ptexhat
3281     \let< = \ptexless
3282     \let> = \ptexgtr
3283     \let+ = \ptexplus
3284     \let' = \ptexquoteright
3285   }
3286 }
3287
3288 % for @sub and @sup, if in math mode, just do a normal sub/superscript.
3289 % If in text, use math to place as sub/superscript, but switch
3290 % into text mode, with smaller fonts.  This is a different font than the
3291 % one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3292 % fix it (significant additions to font machinery) until someone notices.
3293 %
3294 \def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
3295 \def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}%
3296 %
3297 \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
3298 \def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}%
3299
3300 % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3301 % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3302 % except specified as a normal braced arg, so no newlines to worry about.
3303
3304 \def\outfmtnametex{tex}
3305 %
3306 \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3307 \long\def\doinlinefmt#1,#2,\finish{%
3308   \def\inlinefmtname{#1}%
3309   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3310 }
3311
3312 % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3313 % FMTNAME is tex, else ELSE-TEXT.
3314 \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3315 \long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3316   \def\inlinefmtname{#1}%
3317   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3318 }
3319 %
3320 % For raw, must switch into @tex before parsing the argument, to avoid
3321 % setting catcodes prematurely.  Doing it this way means that, for
3322 % example, @inlineraw{html, foo{bar} gets a parse error instead of being
3323 % ignored.  But this isn't important because if people want a literal
3324 % *right* brace they would have to use a command anyway, so they may as
3325 % well use a command to get a left brace too.  We could re-use the
3326 % delimiter character idea from \verb, but it seems like overkill.
3327
3328 \long\def\inlineraw{\tex \doinlineraw}
3329 \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3330 \def\doinlinerawtwo#1,#2,\finish{%
3331   \def\inlinerawname{#1}%
3332   \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3333   \endgroup % close group opened by \tex.
3334 }
3335
3336 % @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3337 %
3338 \long\def\inlineifset#1{\doinlineifset #1,\finish}
3339 \long\def\doinlineifset#1,#2,\finish{%
3340   \def\inlinevarname{#1}%
3341   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3342   \else\ignorespaces#2\fi
3343 }
3344
3345 % @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3346 %
3347 \long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3348 \long\def\doinlineifclear#1,#2,\finish{%
3349   \def\inlinevarname{#1}%
3350   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3351 }
3352
3353
3354 \message{glyphs,}
3355 % and logos.
3356
3357 % @@ prints an @, as does @atchar{}.
3358 \def\@{\char64 }
3359 \let\atchar=\@
3360
3361 % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
3362 \def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}}
3363 \def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}}
3364 \let\{=\lbracechar
3365 \let\}=\rbracechar
3366
3367 % @comma{} to avoid , parsing problems.
3368 \let\comma = ,
3369
3370 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3371 % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3372 \let\, = \ptexc
3373 \let\dotaccent = \ptexdot
3374 \def\ringaccent#1{{\accent23 #1}}
3375 \let\tieaccent = \ptext
3376 \let\ubaraccent = \ptexb
3377 \let\udotaccent = \d
3378
3379 % Other special characters: @questiondown @exclamdown @ordf @ordm
3380 % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3381 \def\questiondown{?`}
3382 \def\exclamdown{!`}
3383 \def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}}
3384 \def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}}
3385
3386 % Dotless i and dotless j, used for accents.
3387 \def\imacro{i}
3388 \def\jmacro{j}
3389 \def\dotless#1{%
3390   \def\temp{#1}%
3391   \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3392   \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3393   \else \errmessage{@dotless can be used only with i or j}%
3394   \fi\fi
3395 }
3396
3397 % The \TeX{} logo, as in plain, but resetting the spacing so that a
3398 % period following counts as ending a sentence.  (Idea found in latex.)
3399 %
3400 \edef\TeX{\TeX \spacefactor=1000 }
3401
3402 % @LaTeX{} logo.  Not quite the same results as the definition in
3403 % latex.ltx, since we use a different font for the raised A; it's most
3404 % convenient for us to use an explicitly smaller font, rather than using
3405 % the \scriptstyle font (since we don't reset \scriptstyle and
3406 % \scriptscriptstyle).
3407 %
3408 \def\LaTeX{%
3409   L\kern-.36em
3410   {\setbox0=\hbox{T}%
3411    \vbox to \ht0{\hbox{%
3412      \ifx\textnominalsize\xwordpt
3413        % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX.
3414        % Revert to plain's \scriptsize, which is 7pt.
3415        \count255=\the\fam $\fam\count255 \scriptstyle A$%
3416      \else
3417        % For 11pt, we can use our lllsize.
3418        \switchtolllsize A%
3419      \fi
3420      }%
3421      \vss
3422   }}%
3423   \kern-.15em
3424   \TeX
3425 }
3426
3427 % Some math mode symbols.  Define \ensuremath to switch into math mode
3428 % unless we are already there.  Expansion tricks may not be needed here,
3429 % but safer, and can't hurt.
3430 \def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3431 \def\ensuredmath#1{$\relax#1$}
3432 %
3433 \def\bullet{\ensuremath\ptexbullet}
3434 \def\geq{\ensuremath\ge}
3435 \def\leq{\ensuremath\le}
3436 \def\minus{\ensuremath-}
3437
3438 % @dots{} outputs an ellipsis using the current font.
3439 % We do .5em per period so that it has the same spacing in the cm
3440 % typewriter fonts as three actual period characters; on the other hand,
3441 % in other typewriter fonts three periods are wider than 1.5em.  So do
3442 % whichever is larger.
3443 %
3444 \def\dots{%
3445   \leavevmode
3446   \setbox0=\hbox{...}% get width of three periods
3447   \ifdim\wd0 > 1.5em
3448     \dimen0 = \wd0
3449   \else
3450     \dimen0 = 1.5em
3451   \fi
3452   \hbox to \dimen0{%
3453     \hskip 0pt plus.25fil
3454     .\hskip 0pt plus1fil
3455     .\hskip 0pt plus1fil
3456     .\hskip 0pt plus.5fil
3457   }%
3458 }
3459
3460 % @enddots{} is an end-of-sentence ellipsis.
3461 %
3462 \def\enddots{%
3463   \dots
3464   \spacefactor=\endofsentencespacefactor
3465 }
3466
3467 % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3468 %
3469 % Since these characters are used in examples, they should be an even number of
3470 % \tt widths. Each \tt character is 1en, so two makes it 1em.
3471 %
3472 \def\point{$\star$}
3473 \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3474 \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3475 \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3476 \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3477 \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3478
3479 % The @error{} command.
3480 % Adapted from the TeXbook's \boxit.
3481 %
3482 \newbox\errorbox
3483 %
3484 {\ttfont \global\dimen0 = 3em}% Width of the box.
3485 \dimen2 = .55pt % Thickness of rules
3486 % The text. (`r' is open on the right, `e' somewhat less so on the left.)
3487 \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3488 %
3489 \setbox\errorbox=\hbox to \dimen0{\hfil
3490    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3491    \advance\hsize by -2\dimen2 % Rules.
3492    \vbox{%
3493       \hrule height\dimen2
3494       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
3495          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3496          \kern3pt\vrule width\dimen2}% Space to right.
3497       \hrule height\dimen2}
3498     \hfil}
3499 %
3500 \def\error{\leavevmode\lower.7ex\copy\errorbox}
3501
3502 % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3503 %
3504 \def\pounds{{\it\$}}
3505
3506 % @euro{} comes from a separate font, depending on the current style.
3507 % We use the free feym* fonts from the eurosym package by Henrik
3508 % Theiling, which support regular, slanted, bold and bold slanted (and
3509 % "outlined" (blackboard board, sort of) versions, which we don't need).
3510 % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3511 %
3512 % Although only regular is the truly official Euro symbol, we ignore
3513 % that.  The Euro is designed to be slightly taller than the regular
3514 % font height.
3515 %
3516 % feymr - regular
3517 % feymo - slanted
3518 % feybr - bold
3519 % feybo - bold slanted
3520 %
3521 % There is no good (free) typewriter version, to my knowledge.
3522 % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3523 % Hmm.
3524 %
3525 % Also doesn't work in math.  Do we need to do math with euro symbols?
3526 % Hope not.
3527 %
3528 %
3529 \def\euro{{\eurofont e}}
3530 \def\eurofont{%
3531   % We set the font at each command, rather than predefining it in
3532   % \textfonts and the other font-switching commands, so that
3533   % installations which never need the symbol don't have to have the
3534   % font installed.
3535   %
3536   % There is only one designed size (nominal 10pt), so we always scale
3537   % that to the current nominal size.
3538   %
3539   % By the way, simply using "at 1em" works for cmr10 and the like, but
3540   % does not work for cmbx10 and other extended/shrunken fonts.
3541   %
3542   \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3543   %
3544   \ifx\curfontstyle\bfstylename
3545     % bold:
3546     \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3547   \else
3548     % regular:
3549     \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3550   \fi
3551   \thiseurofont
3552 }
3553
3554 % Glyphs from the EC fonts.  We don't use \let for the aliases, because
3555 % sometimes we redefine the original macro, and the alias should reflect
3556 % the redefinition.
3557 %
3558 % Use LaTeX names for the Icelandic letters.
3559 \def\DH{{\ecfont \char"D0}} % Eth
3560 \def\dh{{\ecfont \char"F0}} % eth
3561 \def\TH{{\ecfont \char"DE}} % Thorn
3562 \def\th{{\ecfont \char"FE}} % thorn
3563 %
3564 \def\guillemetleft{{\ecfont \char"13}}
3565 \def\guillemotleft{\guillemetleft}
3566 \def\guillemetright{{\ecfont \char"14}}
3567 \def\guillemotright{\guillemetright}
3568 \def\guilsinglleft{{\ecfont \char"0E}}
3569 \def\guilsinglright{{\ecfont \char"0F}}
3570 \def\quotedblbase{{\ecfont \char"12}}
3571 \def\quotesinglbase{{\ecfont \char"0D}}
3572 %
3573 % This positioning is not perfect (see the ogonek LaTeX package), but
3574 % we have the precomposed glyphs for the most common cases.  We put the
3575 % tests to use those glyphs in the single \ogonek macro so we have fewer
3576 % dummy definitions to worry about for index entries, etc.
3577 %
3578 % ogonek is also used with other letters in Lithuanian (IOU), but using
3579 % the precomposed glyphs for those is not so easy since they aren't in
3580 % the same EC font.
3581 \def\ogonek#1{{%
3582   \def\temp{#1}%
3583   \ifx\temp\macrocharA\Aogonek
3584   \else\ifx\temp\macrochara\aogonek
3585   \else\ifx\temp\macrocharE\Eogonek
3586   \else\ifx\temp\macrochare\eogonek
3587   \else
3588     \ecfont \setbox0=\hbox{#1}%
3589     \ifdim\ht0=1ex\accent"0C #1%
3590     \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3591     \fi
3592   \fi\fi\fi\fi
3593   }%
3594 }
3595 \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3596 \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3597 \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3598 \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3599 %
3600 % Use the European Computer Modern fonts (cm-super in outline format)
3601 % for non-CM glyphs.  That is ec* for regular text and tc* for the text
3602 % companion symbols (LaTeX TS1 encoding).  Both are part of the ec
3603 % package and follow the same conventions.
3604
3605 \def\ecfont{\etcfont{e}}
3606 \def\tcfont{\etcfont{t}}
3607 %
3608 \def\etcfont#1{%
3609   % We can't distinguish serif/sans and italic/slanted, but this
3610   % is used for crude hacks anyway (like adding French and German
3611   % quotes to documents typeset with CM, where we lose kerning), so
3612   % hopefully nobody will notice/care.
3613   \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3614   \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
3615   \ifmonospace
3616     % typewriter:
3617     \font\thisecfont = #1ctt\ecsize \space at \nominalsize
3618   \else
3619     \ifx\curfontstyle\bfstylename
3620       % bold:
3621       \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
3622     \else
3623       % regular:
3624       \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
3625     \fi
3626   \fi
3627   \thisecfont
3628 }
3629
3630 % @registeredsymbol - R in a circle.  The font for the R should really
3631 % be smaller yet, but lllsize is the best we can do for now.
3632 % Adapted from the plain.tex definition of \copyright.
3633 %
3634 \def\registeredsymbol{%
3635   $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}%
3636                \hfil\crcr\Orb}}%
3637     }$%
3638 }
3639
3640 % @textdegree - the normal degrees sign.
3641 %
3642 \def\textdegree{$^\circ$}
3643
3644 % Laurent Siebenmann reports \Orb undefined with:
3645 %  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
3646 % so we'll define it if necessary.
3647 %
3648 \ifx\Orb\thisisundefined
3649 \def\Orb{\mathhexbox20D}
3650 \fi
3651
3652 % Quotes.
3653 \chardef\quotedblleft="5C
3654 \chardef\quotedblright=`\"
3655 \chardef\quoteleft=`\`
3656 \chardef\quoteright=`\'
3657
3658
3659 \message{page headings,}
3660
3661 \newskip\titlepagetopglue \titlepagetopglue = 1.5in
3662 \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3663
3664 % First the title page.  Must do @settitle before @titlepage.
3665 \newif\ifseenauthor
3666 \newif\iffinishedtitlepage
3667
3668 % @setcontentsaftertitlepage used to do an implicit @contents or
3669 % @shortcontents after @end titlepage, but it is now obsolete.
3670 \def\setcontentsaftertitlepage{%
3671   \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
3672               command; move your @contents command if you want the contents
3673               after the title page.}}%
3674 \def\setshortcontentsaftertitlepage{%
3675   \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
3676               command; move your @shortcontents and @contents commands if you 
3677               want the contents after the title page.}}%
3678
3679 \parseargdef\shorttitlepage{%
3680   \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3681   \endgroup\page\hbox{}\page}
3682
3683 \envdef\titlepage{%
3684   % Open one extra group, as we want to close it in the middle of \Etitlepage.
3685   \begingroup
3686     \parindent=0pt \textfonts
3687     % Leave some space at the very top of the page.
3688     \vglue\titlepagetopglue
3689     % No rule at page bottom unless we print one at the top with @title.
3690     \finishedtitlepagetrue
3691     %
3692     % Most title ``pages'' are actually two pages long, with space
3693     % at the top of the second.  We don't want the ragged left on the second.
3694     \let\oldpage = \page
3695     \def\page{%
3696       \iffinishedtitlepage\else
3697          \finishtitlepage
3698       \fi
3699       \let\page = \oldpage
3700       \page
3701       \null
3702     }%
3703 }
3704
3705 \def\Etitlepage{%
3706     \iffinishedtitlepage\else
3707         \finishtitlepage
3708     \fi
3709     % It is important to do the page break before ending the group,
3710     % because the headline and footline are only empty inside the group.
3711     % If we use the new definition of \page, we always get a blank page
3712     % after the title page, which we certainly don't want.
3713     \oldpage
3714   \endgroup
3715   %
3716   % Need this before the \...aftertitlepage checks so that if they are
3717   % in effect the toc pages will come out with page numbers.
3718   \HEADINGSon
3719 }
3720
3721 \def\finishtitlepage{%
3722   \vskip4pt \hrule height 2pt width \hsize
3723   \vskip\titlepagebottomglue
3724   \finishedtitlepagetrue
3725 }
3726
3727 % Settings used for typesetting titles: no hyphenation, no indentation,
3728 % don't worry much about spacing, ragged right.  This should be used
3729 % inside a \vbox, and fonts need to be set appropriately first. \par should
3730 % be specified before the end of the \vbox, since a vbox is a group.
3731
3732 \def\raggedtitlesettings{%
3733   \rm
3734   \hyphenpenalty=10000
3735   \parindent=0pt
3736   \tolerance=5000
3737   \ptexraggedright
3738 }
3739
3740 % Macros to be used within @titlepage:
3741
3742 \let\subtitlerm=\rmfont
3743 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3744
3745 \parseargdef\title{%
3746   \checkenv\titlepage
3747   \vbox{\titlefonts \raggedtitlesettings #1\par}%
3748   % print a rule at the page bottom also.
3749   \finishedtitlepagefalse
3750   \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3751 }
3752
3753 \parseargdef\subtitle{%
3754   \checkenv\titlepage
3755   {\subtitlefont \rightline{#1}}%
3756 }
3757
3758 % @author should come last, but may come many times.
3759 % It can also be used inside @quotation.
3760 %
3761 \parseargdef\author{%
3762   \def\temp{\quotation}%
3763   \ifx\thisenv\temp
3764     \def\quotationauthor{#1}% printed in \Equotation.
3765   \else
3766     \checkenv\titlepage
3767     \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3768     {\secfonts\rm \leftline{#1}}%
3769   \fi
3770 }
3771
3772
3773 % Set up page headings and footings.
3774
3775 \let\thispage=\folio
3776
3777 \newtoks\evenheadline    % headline on even pages
3778 \newtoks\oddheadline     % headline on odd pages
3779 \newtoks\evenfootline    % footline on even pages
3780 \newtoks\oddfootline     % footline on odd pages
3781
3782 % Now make \makeheadline and \makefootline in Plain TeX use those variables
3783 \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
3784                             \else \the\evenheadline \fi}}
3785 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
3786                             \else \the\evenfootline \fi}\HEADINGShook}
3787 \let\HEADINGShook=\relax
3788
3789 % Commands to set those variables.
3790 % For example, this is what  @headings on  does
3791 % @evenheading @thistitle|@thispage|@thischapter
3792 % @oddheading @thischapter|@thispage|@thistitle
3793 % @evenfooting @thisfile||
3794 % @oddfooting ||@thisfile
3795
3796
3797 \def\evenheading{\parsearg\evenheadingxxx}
3798 \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3799 \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
3800 \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3801
3802 \def\oddheading{\parsearg\oddheadingxxx}
3803 \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3804 \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
3805 \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3806
3807 \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3808
3809 \def\evenfooting{\parsearg\evenfootingxxx}
3810 \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3811 \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3812 \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3813
3814 \def\oddfooting{\parsearg\oddfootingxxx}
3815 \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3816 \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3817   \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3818   %
3819   % Leave some space for the footline.  Hopefully ok to assume
3820   % @evenfooting will not be used by itself.
3821   \global\advance\txipageheight by -12pt
3822   \global\advance\vsize by -12pt
3823 }
3824
3825 \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3826
3827 % @evenheadingmarks top     \thischapter <- chapter at the top of a page
3828 % @evenheadingmarks bottom  \thischapter <- chapter at the bottom of a page
3829 %
3830 % The same set of arguments for:
3831 %
3832 % @oddheadingmarks
3833 % @evenfootingmarks
3834 % @oddfootingmarks
3835 % @everyheadingmarks
3836 % @everyfootingmarks
3837
3838 % These define \getoddheadingmarks, \getevenheadingmarks,
3839 % \getoddfootingmarks, and \getevenfootingmarks, each to one of
3840 % \gettopheadingmarks, \getbottomheadingmarks.
3841 %
3842 \def\evenheadingmarks{\headingmarks{even}{heading}}
3843 \def\oddheadingmarks{\headingmarks{odd}{heading}}
3844 \def\evenfootingmarks{\headingmarks{even}{footing}}
3845 \def\oddfootingmarks{\headingmarks{odd}{footing}}
3846 \parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
3847                           \headingmarks{odd}{heading}{#1} }
3848 \parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
3849                           \headingmarks{odd}{footing}{#1} }
3850 % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3851 \def\headingmarks#1#2#3 {%
3852   \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3853   \global\expandafter\let\csname get#1#2marks\endcsname \temp
3854 }
3855
3856 \everyheadingmarks bottom
3857 \everyfootingmarks bottom
3858
3859 % @headings double      turns headings on for double-sided printing.
3860 % @headings single      turns headings on for single-sided printing.
3861 % @headings off         turns them off.
3862 % @headings on          same as @headings double, retained for compatibility.
3863 % @headings after       turns on double-sided headings after this page.
3864 % @headings doubleafter turns on double-sided headings after this page.
3865 % @headings singleafter turns on single-sided headings after this page.
3866 % By default, they are off at the start of a document,
3867 % and turned `on' after @end titlepage.
3868
3869 \parseargdef\headings{\csname HEADINGS#1\endcsname}
3870
3871 \def\headingsoff{% non-global headings elimination
3872   \evenheadline={\hfil}\evenfootline={\hfil}%
3873    \oddheadline={\hfil}\oddfootline={\hfil}%
3874 }
3875
3876 \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3877 \HEADINGSoff  % it's the default
3878
3879 % When we turn headings on, set the page number to 1.
3880 % For double-sided printing, put current file name in lower left corner,
3881 % chapter name on inside top of right hand pages, document
3882 % title on inside top of left hand pages, and page numbers on outside top
3883 % edge of all pages.
3884 \def\HEADINGSdouble{%
3885 \global\pageno=1
3886 \global\evenfootline={\hfil}
3887 \global\oddfootline={\hfil}
3888 \global\evenheadline={\line{\folio\hfil\thistitle}}
3889 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3890 \global\let\contentsalignmacro = \chapoddpage
3891 }
3892 \let\contentsalignmacro = \chappager
3893
3894 % For single-sided printing, chapter title goes across top left of page,
3895 % page number on top right.
3896 \def\HEADINGSsingle{%
3897 \global\pageno=1
3898 \global\evenfootline={\hfil}
3899 \global\oddfootline={\hfil}
3900 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
3901 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3902 \global\let\contentsalignmacro = \chappager
3903 }
3904 \def\HEADINGSon{\HEADINGSdouble}
3905
3906 \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
3907 \let\HEADINGSdoubleafter=\HEADINGSafter
3908 \def\HEADINGSdoublex{%
3909 \global\evenfootline={\hfil}
3910 \global\oddfootline={\hfil}
3911 \global\evenheadline={\line{\folio\hfil\thistitle}}
3912 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3913 \global\let\contentsalignmacro = \chapoddpage
3914 }
3915
3916 \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
3917 \def\HEADINGSsinglex{%
3918 \global\evenfootline={\hfil}
3919 \global\oddfootline={\hfil}
3920 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
3921 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3922 \global\let\contentsalignmacro = \chappager
3923 }
3924
3925 % Subroutines used in generating headings
3926 % This produces Day Month Year style of output.
3927 % Only define if not already defined, in case a txi-??.tex file has set
3928 % up a different format (e.g., txi-cs.tex does this).
3929 \ifx\today\thisisundefined
3930 \def\today{%
3931   \number\day\space
3932   \ifcase\month
3933   \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
3934   \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
3935   \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
3936   \fi
3937   \space\number\year}
3938 \fi
3939
3940 % @settitle line...  specifies the title of the document, for headings.
3941 % It generates no output of its own.
3942 \def\thistitle{\putwordNoTitle}
3943 \def\settitle{\parsearg{\gdef\thistitle}}
3944
3945
3946 \message{tables,}
3947 % Tables -- @table, @ftable, @vtable, @item(x).
3948
3949 % default indentation of table text
3950 \newdimen\tableindent \tableindent=.8in
3951 % default indentation of @itemize and @enumerate text
3952 \newdimen\itemindent  \itemindent=.3in
3953 % margin between end of table item and start of table text.
3954 \newdimen\itemmargin  \itemmargin=.1in
3955
3956 % used internally for \itemindent minus \itemmargin
3957 \newdimen\itemmax
3958
3959 % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
3960 % these defs.
3961 % They also define \itemindex
3962 % to index the item name in whatever manner is desired (perhaps none).
3963
3964 \newif\ifitemxneedsnegativevskip
3965
3966 \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
3967
3968 \def\internalBitem{\smallbreak \parsearg\itemzzz}
3969 \def\internalBitemx{\itemxpar \parsearg\itemzzz}
3970
3971 \def\itemzzz #1{\begingroup %
3972   \advance\hsize by -\rightskip
3973   \advance\hsize by -\tableindent
3974   \setbox0=\hbox{\itemindicate{#1}}%
3975   \itemindex{#1}%
3976   \nobreak % This prevents a break before @itemx.
3977   %
3978   % If the item text does not fit in the space we have, put it on a line
3979   % by itself, and do not allow a page break either before or after that
3980   % line.  We do not start a paragraph here because then if the next
3981   % command is, e.g., @kindex, the whatsit would get put into the
3982   % horizontal list on a line by itself, resulting in extra blank space.
3983   \ifdim \wd0>\itemmax
3984     %
3985     % Make this a paragraph so we get the \parskip glue and wrapping,
3986     % but leave it ragged-right.
3987     \begingroup
3988       \advance\leftskip by-\tableindent
3989       \advance\hsize by\tableindent
3990       \advance\rightskip by0pt plus1fil\relax
3991       \leavevmode\unhbox0\par
3992     \endgroup
3993     %
3994     % We're going to be starting a paragraph, but we don't want the
3995     % \parskip glue -- logically it's part of the @item we just started.
3996     \nobreak \vskip-\parskip
3997     %
3998     % Stop a page break at the \parskip glue coming up.  However, if
3999     % what follows is an environment such as @example, there will be no
4000     % \parskip glue; then the negative vskip we just inserted would
4001     % cause the example and the item to crash together.  So we use this
4002     % bizarre value of 10001 as a signal to \aboveenvbreak to insert
4003     % \parskip glue after all.  Section titles are handled this way also.
4004     %
4005     \penalty 10001
4006     \endgroup
4007     \itemxneedsnegativevskipfalse
4008   \else
4009     % The item text fits into the space.  Start a paragraph, so that the
4010     % following text (if any) will end up on the same line.
4011     \noindent
4012     % Do this with kerns and \unhbox so that if there is a footnote in
4013     % the item text, it can migrate to the main vertical list and
4014     % eventually be printed.
4015     \nobreak\kern-\tableindent
4016     \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
4017     \unhbox0
4018     \nobreak\kern\dimen0
4019     \endgroup
4020     \itemxneedsnegativevskiptrue
4021   \fi
4022 }
4023
4024 \def\item{\errmessage{@item while not in a list environment}}
4025 \def\itemx{\errmessage{@itemx while not in a list environment}}
4026
4027 % @table, @ftable, @vtable.
4028 \envdef\table{%
4029   \let\itemindex\gobble
4030   \tablecheck{table}%
4031 }
4032 \envdef\ftable{%
4033   \def\itemindex ##1{\doind {fn}{\code{##1}}}%
4034   \tablecheck{ftable}%
4035 }
4036 \envdef\vtable{%
4037   \def\itemindex ##1{\doind {vr}{\code{##1}}}%
4038   \tablecheck{vtable}%
4039 }
4040 \def\tablecheck#1{%
4041   \ifnum \the\catcode`\^^M=\active
4042     \endgroup
4043     \errmessage{This command won't work in this context; perhaps the problem is
4044       that we are \inenvironment\thisenv}%
4045     \def\next{\doignore{#1}}%
4046   \else
4047     \let\next\tablex
4048   \fi
4049   \next
4050 }
4051 \def\tablex#1{%
4052   \def\itemindicate{#1}%
4053   \parsearg\tabley
4054 }
4055 \def\tabley#1{%
4056   {%
4057     \makevalueexpandable
4058     \edef\temp{\noexpand\tablez #1\space\space\space}%
4059     \expandafter
4060   }\temp \endtablez
4061 }
4062 \def\tablez #1 #2 #3 #4\endtablez{%
4063   \aboveenvbreak
4064   \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
4065   \ifnum 0#2>0 \tableindent=#2\mil \fi
4066   \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
4067   \itemmax=\tableindent
4068   \advance \itemmax by -\itemmargin
4069   \advance \leftskip by \tableindent
4070   \exdentamount=\tableindent
4071   \parindent = 0pt
4072   \parskip = \smallskipamount
4073   \ifdim \parskip=0pt \parskip=2pt \fi
4074   \let\item = \internalBitem
4075   \let\itemx = \internalBitemx
4076 }
4077 \def\Etable{\endgraf\afterenvbreak}
4078 \let\Eftable\Etable
4079 \let\Evtable\Etable
4080 \let\Eitemize\Etable
4081 \let\Eenumerate\Etable
4082
4083 % This is the counter used by @enumerate, which is really @itemize
4084
4085 \newcount \itemno
4086
4087 \envdef\itemize{\parsearg\doitemize}
4088
4089 \def\doitemize#1{%
4090   \aboveenvbreak
4091   \itemmax=\itemindent
4092   \advance\itemmax by -\itemmargin
4093   \advance\leftskip by \itemindent
4094   \exdentamount=\itemindent
4095   \parindent=0pt
4096   \parskip=\smallskipamount
4097   \ifdim\parskip=0pt \parskip=2pt \fi
4098   %
4099   % Try typesetting the item mark so that if the document erroneously says
4100   % something like @itemize @samp (intending @table), there's an error
4101   % right away at the @itemize.  It's not the best error message in the
4102   % world, but it's better than leaving it to the @item.  This means if
4103   % the user wants an empty mark, they have to say @w{} not just @w.
4104   \def\itemcontents{#1}%
4105   \setbox0 = \hbox{\itemcontents}%
4106   %
4107   % @itemize with no arg is equivalent to @itemize @bullet.
4108   \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
4109   %
4110   \let\item=\itemizeitem
4111 }
4112
4113 % Definition of @item while inside @itemize and @enumerate.
4114 %
4115 \def\itemizeitem{%
4116   \advance\itemno by 1  % for enumerations
4117   {\let\par=\endgraf \smallbreak}% reasonable place to break
4118   {%
4119    % If the document has an @itemize directly after a section title, a
4120    % \nobreak will be last on the list, and \sectionheading will have
4121    % done a \vskip-\parskip.  In that case, we don't want to zero
4122    % parskip, or the item text will crash with the heading.  On the
4123    % other hand, when there is normal text preceding the item (as there
4124    % usually is), we do want to zero parskip, or there would be too much
4125    % space.  In that case, we won't have a \nobreak before.  At least
4126    % that's the theory.
4127    \ifnum\lastpenalty<10000 \parskip=0in \fi
4128    \noindent
4129    \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
4130    %
4131    \ifinner\else
4132      \vadjust{\penalty 1200}% not good to break after first line of item.
4133    \fi
4134    % We can be in inner vertical mode in a footnote, although an
4135    % @itemize looks awful there.
4136   }%
4137   \flushcr
4138 }
4139
4140 % \splitoff TOKENS\endmark defines \first to be the first token in
4141 % TOKENS, and \rest to be the remainder.
4142 %
4143 \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
4144
4145 % Allow an optional argument of an uppercase letter, lowercase letter,
4146 % or number, to specify the first label in the enumerated list.  No
4147 % argument is the same as `1'.
4148 %
4149 \envparseargdef\enumerate{\enumeratey #1  \endenumeratey}
4150 \def\enumeratey #1 #2\endenumeratey{%
4151   % If we were given no argument, pretend we were given `1'.
4152   \def\thearg{#1}%
4153   \ifx\thearg\empty \def\thearg{1}\fi
4154   %
4155   % Detect if the argument is a single token.  If so, it might be a
4156   % letter.  Otherwise, the only valid thing it can be is a number.
4157   % (We will always have one token, because of the test we just made.
4158   % This is a good thing, since \splitoff doesn't work given nothing at
4159   % all -- the first parameter is undelimited.)
4160   \expandafter\splitoff\thearg\endmark
4161   \ifx\rest\empty
4162     % Only one token in the argument.  It could still be anything.
4163     % A ``lowercase letter'' is one whose \lccode is nonzero.
4164     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
4165     %   not equal to itself.
4166     % Otherwise, we assume it's a number.
4167     %
4168     % We need the \relax at the end of the \ifnum lines to stop TeX from
4169     % continuing to look for a <number>.
4170     %
4171     \ifnum\lccode\expandafter`\thearg=0\relax
4172       \numericenumerate % a number (we hope)
4173     \else
4174       % It's a letter.
4175       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
4176         \lowercaseenumerate % lowercase letter
4177       \else
4178         \uppercaseenumerate % uppercase letter
4179       \fi
4180     \fi
4181   \else
4182     % Multiple tokens in the argument.  We hope it's a number.
4183     \numericenumerate
4184   \fi
4185 }
4186
4187 % An @enumerate whose labels are integers.  The starting integer is
4188 % given in \thearg.
4189 %
4190 \def\numericenumerate{%
4191   \itemno = \thearg
4192   \startenumeration{\the\itemno}%
4193 }
4194
4195 % The starting (lowercase) letter is in \thearg.
4196 \def\lowercaseenumerate{%
4197   \itemno = \expandafter`\thearg
4198   \startenumeration{%
4199     % Be sure we're not beyond the end of the alphabet.
4200     \ifnum\itemno=0
4201       \errmessage{No more lowercase letters in @enumerate; get a bigger
4202                   alphabet}%
4203     \fi
4204     \char\lccode\itemno
4205   }%
4206 }
4207
4208 % The starting (uppercase) letter is in \thearg.
4209 \def\uppercaseenumerate{%
4210   \itemno = \expandafter`\thearg
4211   \startenumeration{%
4212     % Be sure we're not beyond the end of the alphabet.
4213     \ifnum\itemno=0
4214       \errmessage{No more uppercase letters in @enumerate; get a bigger
4215                   alphabet}
4216     \fi
4217     \char\uccode\itemno
4218   }%
4219 }
4220
4221 % Call \doitemize, adding a period to the first argument and supplying the
4222 % common last two arguments.  Also subtract one from the initial value in
4223 % \itemno, since @item increments \itemno.
4224 %
4225 \def\startenumeration#1{%
4226   \advance\itemno by -1
4227   \doitemize{#1.}\flushcr
4228 }
4229
4230 % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
4231 % to @enumerate.
4232 %
4233 \def\alphaenumerate{\enumerate{a}}
4234 \def\capsenumerate{\enumerate{A}}
4235 \def\Ealphaenumerate{\Eenumerate}
4236 \def\Ecapsenumerate{\Eenumerate}
4237
4238
4239 % @multitable macros
4240 % Amy Hendrickson, 8/18/94, 3/6/96
4241 %
4242 % @multitable ... @end multitable will make as many columns as desired.
4243 % Contents of each column will wrap at width given in preamble.  Width
4244 % can be specified either with sample text given in a template line,
4245 % or in percent of \hsize, the current width of text on page.
4246
4247 % Table can continue over pages but will only break between lines.
4248
4249 % To make preamble:
4250 %
4251 % Either define widths of columns in terms of percent of \hsize:
4252 %   @multitable @columnfractions .25 .3 .45
4253 %   @item ...
4254 %
4255 %   Numbers following @columnfractions are the percent of the total
4256 %   current hsize to be used for each column. You may use as many
4257 %   columns as desired.
4258
4259
4260 % Or use a template:
4261 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4262 %   @item ...
4263 %   using the widest term desired in each column.
4264
4265 % Each new table line starts with @item, each subsequent new column
4266 % starts with @tab. Empty columns may be produced by supplying @tab's
4267 % with nothing between them for as many times as empty columns are needed,
4268 % ie, @tab@tab@tab will produce two empty columns.
4269
4270 % @item, @tab do not need to be on their own lines, but it will not hurt
4271 % if they are.
4272
4273 % Sample multitable:
4274
4275 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4276 %   @item first col stuff @tab second col stuff @tab third col
4277 %   @item
4278 %   first col stuff
4279 %   @tab
4280 %   second col stuff
4281 %   @tab
4282 %   third col
4283 %   @item first col stuff @tab second col stuff
4284 %   @tab Many paragraphs of text may be used in any column.
4285 %
4286 %         They will wrap at the width determined by the template.
4287 %   @item@tab@tab This will be in third column.
4288 %   @end multitable
4289
4290 % Default dimensions may be reset by user.
4291 % @multitableparskip is vertical space between paragraphs in table.
4292 % @multitableparindent is paragraph indent in table.
4293 % @multitablecolmargin is horizontal space to be left between columns.
4294 % @multitablelinespace is space to leave between table items, baseline
4295 %                                                            to baseline.
4296 %   0pt means it depends on current normal line spacing.
4297 %
4298 \newskip\multitableparskip
4299 \newskip\multitableparindent
4300 \newdimen\multitablecolspace
4301 \newskip\multitablelinespace
4302 \multitableparskip=0pt
4303 \multitableparindent=6pt
4304 \multitablecolspace=12pt
4305 \multitablelinespace=0pt
4306
4307 % Macros used to set up halign preamble:
4308 %
4309 \let\endsetuptable\relax
4310 \def\xendsetuptable{\endsetuptable}
4311 \let\columnfractions\relax
4312 \def\xcolumnfractions{\columnfractions}
4313 \newif\ifsetpercent
4314
4315 % #1 is the @columnfraction, usually a decimal number like .5, but might
4316 % be just 1.  We just use it, whatever it is.
4317 %
4318 \def\pickupwholefraction#1 {%
4319   \global\advance\colcount by 1
4320   \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
4321   \setuptable
4322 }
4323
4324 \newcount\colcount
4325 \def\setuptable#1{%
4326   \def\firstarg{#1}%
4327   \ifx\firstarg\xendsetuptable
4328     \let\go = \relax
4329   \else
4330     \ifx\firstarg\xcolumnfractions
4331       \global\setpercenttrue
4332     \else
4333       \ifsetpercent
4334          \let\go\pickupwholefraction
4335       \else
4336          \global\advance\colcount by 1
4337          \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
4338                    % separator; typically that is always in the input, anyway.
4339          \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
4340       \fi
4341     \fi
4342     \ifx\go\pickupwholefraction
4343       % Put the argument back for the \pickupwholefraction call, so
4344       % we'll always have a period there to be parsed.
4345       \def\go{\pickupwholefraction#1}%
4346     \else
4347       \let\go = \setuptable
4348     \fi%
4349   \fi
4350   \go
4351 }
4352
4353 % multitable-only commands.
4354
4355 % @headitem starts a heading row, which we typeset in bold.  Assignments
4356 % have to be global since we are inside the implicit group of an
4357 % alignment entry.  \everycr below resets \everytab so we don't have to
4358 % undo it ourselves.
4359 \def\headitemfont{\b}% for people to use in the template row; not changeable
4360 \def\headitem{%
4361   \checkenv\multitable
4362   \crcr
4363   \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
4364   \global\everytab={\bf}% can't use \headitemfont since the parsing differs
4365   \the\everytab % for the first item
4366 }%
4367 %
4368 % default for tables with no headings.
4369 \let\headitemcrhook=\relax
4370 %
4371 % A \tab used to include \hskip1sp.  But then the space in a template
4372 % line is not enough.  That is bad.  So let's go back to just `&' until
4373 % we again encounter the problem the 1sp was intended to solve.
4374 %                                       --karl, nathan@acm.org, 20apr99.
4375 \def\tab{\checkenv\multitable &\the\everytab}%
4376
4377 % @multitable ... @end multitable definitions:
4378 %
4379 \newtoks\everytab  % insert after every tab.
4380 %
4381 \envdef\multitable{%
4382   \vskip\parskip
4383   \startsavinginserts
4384   %
4385   % @item within a multitable starts a normal row.
4386   % We use \def instead of \let so that if one of the multitable entries
4387   % contains an @itemize, we don't choke on the \item (seen as \crcr aka
4388   % \endtemplate) expanding \doitemize.
4389   \def\item{\crcr}%
4390   %
4391   \tolerance=9500
4392   \hbadness=9500
4393   \setmultitablespacing
4394   \parskip=\multitableparskip
4395   \parindent=\multitableparindent
4396   \overfullrule=0pt
4397   \global\colcount=0
4398   %
4399   \everycr = {%
4400     \noalign{%
4401       \global\everytab={}% Reset from possible headitem.
4402       \global\colcount=0 % Reset the column counter.
4403       %
4404       % Check for saved footnotes, etc.:
4405       \checkinserts
4406       %
4407       % Perhaps a \nobreak, then reset:
4408       \headitemcrhook
4409       \global\let\headitemcrhook=\relax
4410     }%
4411   }%
4412   %
4413   \parsearg\domultitable
4414 }
4415 \def\domultitable#1{%
4416   % To parse everything between @multitable and @item:
4417   \setuptable#1 \endsetuptable
4418   %
4419   % This preamble sets up a generic column definition, which will
4420   % be used as many times as user calls for columns.
4421   % \vtop will set a single line and will also let text wrap and
4422   % continue for many paragraphs if desired.
4423   \halign\bgroup &%
4424     \global\advance\colcount by 1
4425     \multistrut
4426     \vtop{%
4427       % Use the current \colcount to find the correct column width:
4428       \hsize=\expandafter\csname col\the\colcount\endcsname
4429       %
4430       % In order to keep entries from bumping into each other
4431       % we will add a \leftskip of \multitablecolspace to all columns after
4432       % the first one.
4433       %
4434       % If a template has been used, we will add \multitablecolspace
4435       % to the width of each template entry.
4436       %
4437       % If the user has set preamble in terms of percent of \hsize we will
4438       % use that dimension as the width of the column, and the \leftskip
4439       % will keep entries from bumping into each other.  Table will start at
4440       % left margin and final column will justify at right margin.
4441       %
4442       % Make sure we don't inherit \rightskip from the outer environment.
4443       \rightskip=0pt
4444       \ifnum\colcount=1
4445         % The first column will be indented with the surrounding text.
4446         \advance\hsize by\leftskip
4447       \else
4448         \ifsetpercent \else
4449           % If user has not set preamble in terms of percent of \hsize
4450           % we will advance \hsize by \multitablecolspace.
4451           \advance\hsize by \multitablecolspace
4452         \fi
4453        % In either case we will make \leftskip=\multitablecolspace:
4454       \leftskip=\multitablecolspace
4455       \fi
4456       % Ignoring space at the beginning and end avoids an occasional spurious
4457       % blank line, when TeX decides to break the line at the space before the
4458       % box from the multistrut, so the strut ends up on a line by itself.
4459       % For example:
4460       % @multitable @columnfractions .11 .89
4461       % @item @code{#}
4462       % @tab Legal holiday which is valid in major parts of the whole country.
4463       % Is automatically provided with highlighting sequences respectively
4464       % marking characters.
4465       \noindent\ignorespaces##\unskip\multistrut
4466     }\cr
4467 }
4468 \def\Emultitable{%
4469   \crcr
4470   \egroup % end the \halign
4471   \global\setpercentfalse
4472 }
4473
4474 \def\setmultitablespacing{%
4475   \def\multistrut{\strut}% just use the standard line spacing
4476   %
4477   % Compute \multitablelinespace (if not defined by user) for use in
4478   % \multitableparskip calculation.  We used define \multistrut based on
4479   % this, but (ironically) that caused the spacing to be off.
4480   % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
4481 \ifdim\multitablelinespace=0pt
4482 \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
4483 \global\advance\multitablelinespace by-\ht0
4484 \fi
4485 % Test to see if parskip is larger than space between lines of
4486 % table. If not, do nothing.
4487 %        If so, set to same dimension as multitablelinespace.
4488 \ifdim\multitableparskip>\multitablelinespace
4489 \global\multitableparskip=\multitablelinespace
4490 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4491                                       % than skip between lines in the table.
4492 \fi%
4493 \ifdim\multitableparskip=0pt
4494 \global\multitableparskip=\multitablelinespace
4495 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4496                                       % than skip between lines in the table.
4497 \fi}
4498
4499
4500 \message{conditionals,}
4501
4502 % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
4503 % @ifnotxml always succeed.  They currently do nothing; we don't
4504 % attempt to check whether the conditionals are properly nested.  But we
4505 % have to remember that they are conditionals, so that @end doesn't
4506 % attempt to close an environment group.
4507 %
4508 \def\makecond#1{%
4509   \expandafter\let\csname #1\endcsname = \relax
4510   \expandafter\let\csname iscond.#1\endcsname = 1
4511 }
4512 \makecond{iftex}
4513 \makecond{ifnotdocbook}
4514 \makecond{ifnothtml}
4515 \makecond{ifnotinfo}
4516 \makecond{ifnotplaintext}
4517 \makecond{ifnotxml}
4518
4519 % Ignore @ignore, @ifhtml, @ifinfo, and the like.
4520 %
4521 \def\direntry{\doignore{direntry}}
4522 \def\documentdescription{\doignore{documentdescription}}
4523 \def\docbook{\doignore{docbook}}
4524 \def\html{\doignore{html}}
4525 \def\ifdocbook{\doignore{ifdocbook}}
4526 \def\ifhtml{\doignore{ifhtml}}
4527 \def\ifinfo{\doignore{ifinfo}}
4528 \def\ifnottex{\doignore{ifnottex}}
4529 \def\ifplaintext{\doignore{ifplaintext}}
4530 \def\ifxml{\doignore{ifxml}}
4531 \def\ignore{\doignore{ignore}}
4532 \def\menu{\doignore{menu}}
4533 \def\xml{\doignore{xml}}
4534
4535 % Ignore text until a line `@end #1', keeping track of nested conditionals.
4536 %
4537 % A count to remember the depth of nesting.
4538 \newcount\doignorecount
4539
4540 \def\doignore#1{\begingroup
4541   % Scan in ``verbatim'' mode:
4542   \obeylines
4543   \catcode`\@ = \other
4544   \catcode`\{ = \other
4545   \catcode`\} = \other
4546   %
4547   % Make sure that spaces turn into tokens that match what \doignoretext wants.
4548   \spaceisspace
4549   %
4550   % Count number of #1's that we've seen.
4551   \doignorecount = 0
4552   %
4553   % Swallow text until we reach the matching `@end #1'.
4554   \dodoignore{#1}%
4555 }
4556
4557 { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4558   \obeylines %
4559   %
4560   \gdef\dodoignore#1{%
4561     % #1 contains the command name as a string, e.g., `ifinfo'.
4562     %
4563     % Define a command to find the next `@end #1'.
4564     \long\def\doignoretext##1^^M@end #1{%
4565       \doignoretextyyy##1^^M@#1\_STOP_}%
4566     %
4567     % And this command to find another #1 command, at the beginning of a
4568     % line.  (Otherwise, we would consider a line `@c @ifset', for
4569     % example, to count as an @ifset for nesting.)
4570     \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
4571     %
4572     % And now expand that command.
4573     \doignoretext ^^M%
4574   }%
4575 }
4576
4577 \def\doignoreyyy#1{%
4578   \def\temp{#1}%
4579   \ifx\temp\empty                       % Nothing found.
4580     \let\next\doignoretextzzz
4581   \else                                 % Found a nested condition, ...
4582     \advance\doignorecount by 1
4583     \let\next\doignoretextyyy           % ..., look for another.
4584     % If we're here, #1 ends with ^^M\ifinfo (for example).
4585   \fi
4586   \next #1% the token \_STOP_ is present just after this macro.
4587 }
4588
4589 % We have to swallow the remaining "\_STOP_".
4590 %
4591 \def\doignoretextzzz#1{%
4592   \ifnum\doignorecount = 0      % We have just found the outermost @end.
4593     \let\next\enddoignore
4594   \else                         % Still inside a nested condition.
4595     \advance\doignorecount by -1
4596     \let\next\doignoretext      % Look for the next @end.
4597   \fi
4598   \next
4599 }
4600
4601 % Finish off ignored text.
4602 { \obeylines%
4603   % Ignore anything after the last `@end #1'; this matters in verbatim
4604   % environments, where otherwise the newline after an ignored conditional
4605   % would result in a blank line in the output.
4606   \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4607 }
4608
4609
4610 % @set VAR sets the variable VAR to an empty value.
4611 % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4612 %
4613 % Since we want to separate VAR from REST-OF-LINE (which might be
4614 % empty), we can't just use \parsearg; we have to insert a space of our
4615 % own to delimit the rest of the line, and then take it out again if we
4616 % didn't need it.
4617 % We rely on the fact that \parsearg sets \catcode`\ =10.
4618 %
4619 \parseargdef\set{\setyyy#1 \endsetyyy}
4620 \def\setyyy#1 #2\endsetyyy{%
4621   {%
4622     \makevalueexpandable
4623     \def\temp{#2}%
4624     \edef\next{\gdef\makecsname{SET#1}}%
4625     \ifx\temp\empty
4626       \next{}%
4627     \else
4628       \setzzz#2\endsetzzz
4629     \fi
4630   }%
4631 }
4632 % Remove the trailing space \setxxx inserted.
4633 \def\setzzz#1 \endsetzzz{\next{#1}}
4634
4635 % @clear VAR clears (i.e., unsets) the variable VAR.
4636 %
4637 \parseargdef\clear{%
4638   {%
4639     \makevalueexpandable
4640     \global\expandafter\let\csname SET#1\endcsname=\relax
4641   }%
4642 }
4643
4644 % @value{foo} gets the text saved in variable foo.
4645 \def\value{\begingroup\makevalueexpandable\valuexxx}
4646 \def\valuexxx#1{\expandablevalue{#1}\endgroup}
4647 {
4648   \catcode`\-=\active \catcode`\_=\active
4649   %
4650   \gdef\makevalueexpandable{%
4651     \let\value = \expandablevalue
4652     % We don't want these characters active, ...
4653     \catcode`\-=\other \catcode`\_=\other
4654     % ..., but we might end up with active ones in the argument if
4655     % we're called from @code, as @code{@value{foo-bar_}}, though.
4656     % So \let them to their normal equivalents.
4657     \let-\normaldash \let_\normalunderscore
4658   }
4659 }
4660
4661 % We have this subroutine so that we can handle at least some @value's
4662 % properly in indexes (we call \makevalueexpandable in \indexdummies).
4663 % The command has to be fully expandable (if the variable is set), since
4664 % the result winds up in the index file.  This means that if the
4665 % variable's value contains other Texinfo commands, it's almost certain
4666 % it will fail (although perhaps we could fix that with sufficient work
4667 % to do a one-level expansion on the result, instead of complete).
4668
4669 % Unfortunately, this has the consequence that when _ is in the *value*
4670 % of an @set, it does not print properly in the roman fonts (get the cmr
4671 % dot accent at position 126 instead).  No fix comes to mind, and it's
4672 % been this way since 2003 or earlier, so just ignore it.
4673
4674 \def\expandablevalue#1{%
4675   \expandafter\ifx\csname SET#1\endcsname\relax
4676     {[No value for ``#1'']}%
4677     \message{Variable `#1', used in @value, is not set.}%
4678   \else
4679     \csname SET#1\endcsname
4680   \fi
4681 }
4682
4683 % Like \expandablevalue, but completely expandable (the \message in the
4684 % definition above operates at the execution level of TeX).  Used when
4685 % writing to auxiliary files, due to the expansion that \write does.
4686 % If flag is undefined, pass through an unexpanded @value command: maybe it 
4687 % will be set by the time it is read back in.
4688 %
4689 % NB flag names containing - or _ may not work here.
4690 \def\dummyvalue#1{%
4691   \expandafter\ifx\csname SET#1\endcsname\relax
4692     \noexpand\value{#1}%
4693   \else
4694     \csname SET#1\endcsname
4695   \fi
4696 }
4697
4698 % Used for @value's in index entries to form the sort key: expand the @value
4699 % if possible, otherwise sort late.
4700 \def\indexnofontsvalue#1{%
4701   \expandafter\ifx\csname SET#1\endcsname\relax
4702     ZZZZZZZ
4703   \else
4704     \csname SET#1\endcsname
4705   \fi
4706 }
4707
4708 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4709 % with @set.
4710
4711 % To get the special treatment we need for `@end ifset,' we call
4712 % \makecond and then redefine.
4713 %
4714 \makecond{ifset}
4715 \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4716 \def\doifset#1#2{%
4717   {%
4718     \makevalueexpandable
4719     \let\next=\empty
4720     \expandafter\ifx\csname SET#2\endcsname\relax
4721       #1% If not set, redefine \next.
4722     \fi
4723     \expandafter
4724   }\next
4725 }
4726 \def\ifsetfail{\doignore{ifset}}
4727
4728 % @ifclear VAR ... @end executes the `...' iff VAR has never been
4729 % defined with @set, or has been undefined with @clear.
4730 %
4731 % The `\else' inside the `\doifset' parameter is a trick to reuse the
4732 % above code: if the variable is not set, do nothing, if it is set,
4733 % then redefine \next to \ifclearfail.
4734 %
4735 \makecond{ifclear}
4736 \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4737 \def\ifclearfail{\doignore{ifclear}}
4738
4739 % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
4740 % without the @) is in fact defined.  We can only feasibly check at the
4741 % TeX level, so something like `mathcode' is going to considered
4742 % defined even though it is not a Texinfo command.
4743
4744 \makecond{ifcommanddefined}
4745 \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
4746 %
4747 \def\doifcmddefined#1#2{{%
4748     \makevalueexpandable
4749     \let\next=\empty
4750     \expandafter\ifx\csname #2\endcsname\relax
4751       #1% If not defined, \let\next as above.
4752     \fi
4753     \expandafter
4754   }\next
4755 }
4756 \def\ifcmddefinedfail{\doignore{ifcommanddefined}}
4757
4758 % @ifcommandnotdefined CMD ... handled similar to @ifclear above.
4759 \makecond{ifcommandnotdefined}
4760 \def\ifcommandnotdefined{%
4761   \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
4762 \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
4763
4764 % Set the `txicommandconditionals' variable, so documents have a way to
4765 % test if the @ifcommand...defined conditionals are available.
4766 \set txicommandconditionals
4767
4768 % @dircategory CATEGORY  -- specify a category of the dir file
4769 % which this file should belong to.  Ignore this in TeX.
4770 \let\dircategory=\comment
4771
4772 % @defininfoenclose.
4773 \let\definfoenclose=\comment
4774
4775
4776 \message{indexing,}
4777 % Index generation facilities
4778
4779 % Define \newwrite to be identical to plain tex's \newwrite
4780 % except not \outer, so it can be used within macros and \if's.
4781 \edef\newwrite{\makecsname{ptexnewwrite}}
4782
4783 % \newindex {foo} defines an index named IX.
4784 % It automatically defines \IXindex such that
4785 % \IXindex ...rest of line... puts an entry in the index IX.
4786 % It also defines \IXindfile to be the number of the output channel for
4787 % the file that accumulates this index.  The file's extension is IX.
4788 % The name of an index should be no more than 2 characters long
4789 % for the sake of vms.
4790 %
4791 \def\newindex#1{%
4792   \expandafter\chardef\csname#1indfile\endcsname=0
4793   \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
4794     \noexpand\doindex{#1}}
4795 }
4796
4797 % @defindex foo  ==  \newindex{foo}
4798 %
4799 \def\defindex{\parsearg\newindex}
4800
4801 % Define @defcodeindex, like @defindex except put all entries in @code.
4802 %
4803 \def\defcodeindex{\parsearg\newcodeindex}
4804 %
4805 \def\newcodeindex#1{%
4806   \expandafter\chardef\csname#1indfile\endcsname=0
4807   \expandafter\xdef\csname#1index\endcsname{%
4808     \noexpand\docodeindex{#1}}%
4809 }
4810
4811 % The default indices:
4812 \newindex{cp}%      concepts,
4813 \newcodeindex{fn}%  functions,
4814 \newcodeindex{vr}%  variables,
4815 \newcodeindex{tp}%  types,
4816 \newcodeindex{ky}%  keys
4817 \newcodeindex{pg}%  and programs.
4818
4819
4820 % @synindex foo bar    makes index foo feed into index bar.
4821 % Do this instead of @defindex foo if you don't want it as a separate index.
4822 %
4823 % @syncodeindex foo bar   similar, but put all entries made for index foo
4824 % inside @code.
4825 %
4826 \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4827 \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4828
4829 % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4830 % #3 the target index (bar).
4831 \def\dosynindex#1#2#3{%
4832   \requireopenindexfile{#3}%
4833   % redefine \fooindfile:
4834   \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4835   \expandafter\let\csname#2indfile\endcsname=\temp
4836   % redefine \fooindex:
4837   \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
4838 }
4839
4840 % Define \doindex, the driver for all index macros.
4841 % Argument #1 is generated by the calling \fooindex macro,
4842 % and it is the two-letter name of the index.
4843
4844 \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
4845 \def\doindexxxx #1{\doind{\indexname}{#1}}
4846
4847 % like the previous two, but they put @code around the argument.
4848 \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
4849 \def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
4850
4851 \f
4852 % Used when writing an index entry out to an index file to prevent
4853 % expansion of Texinfo commands that can appear in an index entry.
4854 %
4855 \def\indexdummies{%
4856   \escapechar = `\\     % use backslash in output files.
4857   \definedummyletter\@%
4858   \definedummyletter\ %
4859   %
4860   % For texindex which always views { and } as separators.
4861   \def\{{\lbracechar{}}%
4862   \def\}{\rbracechar{}}%
4863   %
4864   % Do the redefinitions.
4865   \definedummies
4866 }
4867
4868 % Used for the aux and toc files, where @ is the escape character.
4869 %
4870 \def\atdummies{%
4871   \definedummyletter\@%
4872   \definedummyletter\ %
4873   \definedummyletter\{%
4874   \definedummyletter\}%
4875   %
4876   % Do the redefinitions.
4877   \definedummies
4878   \otherbackslash
4879 }
4880
4881 % \definedummyword defines \#1 as \string\#1\space, thus effectively
4882 % preventing its expansion.  This is used only for control words,
4883 % not control letters, because the \space would be incorrect for
4884 % control characters, but is needed to separate the control word
4885 % from whatever follows.
4886 %
4887 % These can be used both for control words that take an argument and
4888 % those that do not.  If it is followed by {arg} in the input, then
4889 % that will dutifully get written to the index (or wherever).
4890 %
4891 % For control letters, we have \definedummyletter, which omits the
4892 % space.
4893 %
4894 \def\definedummyword  #1{\def#1{\string#1\space}}%
4895 \def\definedummyletter#1{\def#1{\string#1}}%
4896 \let\definedummyaccent\definedummyletter
4897
4898 % Called from \indexdummies and \atdummies, to effectively prevent
4899 % the expansion of commands.
4900 %
4901 \def\definedummies{%
4902   %
4903   \let\commondummyword\definedummyword
4904   \let\commondummyletter\definedummyletter
4905   \let\commondummyaccent\definedummyaccent
4906   \commondummiesnofonts
4907   %
4908   \definedummyletter\_%
4909   \definedummyletter\-%
4910   %
4911   % Non-English letters.
4912   \definedummyword\AA
4913   \definedummyword\AE
4914   \definedummyword\DH
4915   \definedummyword\L
4916   \definedummyword\O
4917   \definedummyword\OE
4918   \definedummyword\TH
4919   \definedummyword\aa
4920   \definedummyword\ae
4921   \definedummyword\dh
4922   \definedummyword\exclamdown
4923   \definedummyword\l
4924   \definedummyword\o
4925   \definedummyword\oe
4926   \definedummyword\ordf
4927   \definedummyword\ordm
4928   \definedummyword\questiondown
4929   \definedummyword\ss
4930   \definedummyword\th
4931   %
4932   % Although these internal commands shouldn't show up, sometimes they do.
4933   \definedummyword\bf
4934   \definedummyword\gtr
4935   \definedummyword\hat
4936   \definedummyword\less
4937   \definedummyword\sf
4938   \definedummyword\sl
4939   \definedummyword\tclose
4940   \definedummyword\tt
4941   %
4942   \definedummyword\LaTeX
4943   \definedummyword\TeX
4944   %
4945   % Assorted special characters.
4946   \definedummyword\atchar
4947   \definedummyword\arrow
4948   \definedummyword\bullet
4949   \definedummyword\comma
4950   \definedummyword\copyright
4951   \definedummyword\registeredsymbol
4952   \definedummyword\dots
4953   \definedummyword\enddots
4954   \definedummyword\entrybreak
4955   \definedummyword\equiv
4956   \definedummyword\error
4957   \definedummyword\euro
4958   \definedummyword\expansion
4959   \definedummyword\geq
4960   \definedummyword\guillemetleft
4961   \definedummyword\guillemetright
4962   \definedummyword\guilsinglleft
4963   \definedummyword\guilsinglright
4964   \definedummyword\lbracechar
4965   \definedummyword\leq
4966   \definedummyword\mathopsup
4967   \definedummyword\minus
4968   \definedummyword\ogonek
4969   \definedummyword\pounds
4970   \definedummyword\point
4971   \definedummyword\print
4972   \definedummyword\quotedblbase
4973   \definedummyword\quotedblleft
4974   \definedummyword\quotedblright
4975   \definedummyword\quoteleft
4976   \definedummyword\quoteright
4977   \definedummyword\quotesinglbase
4978   \definedummyword\rbracechar
4979   \definedummyword\result
4980   \definedummyword\sub
4981   \definedummyword\sup
4982   \definedummyword\textdegree
4983   %
4984   % We want to disable all macros so that they are not expanded by \write.
4985   \macrolist
4986   \let\value\dummyvalue
4987   %
4988   \normalturnoffactive
4989 }
4990
4991 % \commondummiesnofonts: common to \definedummies and \indexnofonts.
4992 % Define \commondummyletter, \commondummyaccent and \commondummyword before
4993 % using.  Used for accents, font commands, and various control letters.
4994 %
4995 \def\commondummiesnofonts{%
4996   % Control letters and accents.
4997   \commondummyletter\!%
4998   \commondummyaccent\"%
4999   \commondummyaccent\'%
5000   \commondummyletter\*%
5001   \commondummyaccent\,%
5002   \commondummyletter\.%
5003   \commondummyletter\/%
5004   \commondummyletter\:%
5005   \commondummyaccent\=%
5006   \commondummyletter\?%
5007   \commondummyaccent\^%
5008   \commondummyaccent\`%
5009   \commondummyaccent\~%
5010   \commondummyword\u
5011   \commondummyword\v
5012   \commondummyword\H
5013   \commondummyword\dotaccent
5014   \commondummyword\ogonek
5015   \commondummyword\ringaccent
5016   \commondummyword\tieaccent
5017   \commondummyword\ubaraccent
5018   \commondummyword\udotaccent
5019   \commondummyword\dotless
5020   %
5021   % Texinfo font commands.
5022   \commondummyword\b
5023   \commondummyword\i
5024   \commondummyword\r
5025   \commondummyword\sansserif
5026   \commondummyword\sc
5027   \commondummyword\slanted
5028   \commondummyword\t
5029   %
5030   % Commands that take arguments.
5031   \commondummyword\abbr
5032   \commondummyword\acronym
5033   \commondummyword\anchor
5034   \commondummyword\cite
5035   \commondummyword\code
5036   \commondummyword\command
5037   \commondummyword\dfn
5038   \commondummyword\dmn
5039   \commondummyword\email
5040   \commondummyword\emph
5041   \commondummyword\env
5042   \commondummyword\file
5043   \commondummyword\image
5044   \commondummyword\indicateurl
5045   \commondummyword\inforef
5046   \commondummyword\kbd
5047   \commondummyword\key
5048   \commondummyword\math
5049   \commondummyword\option
5050   \commondummyword\pxref
5051   \commondummyword\ref
5052   \commondummyword\samp
5053   \commondummyword\strong
5054   \commondummyword\tie
5055   \commondummyword\U
5056   \commondummyword\uref
5057   \commondummyword\url
5058   \commondummyword\var
5059   \commondummyword\verb
5060   \commondummyword\w
5061   \commondummyword\xref
5062 }
5063
5064 % For testing: output @{ and @} in index sort strings as \{ and \}.
5065 \newif\ifusebracesinindexes
5066
5067 \let\indexlbrace\relax
5068 \let\indexrbrace\relax
5069
5070 {\catcode`\@=0
5071 \catcode`\\=13
5072   @gdef@backslashdisappear{@def\{}}
5073 }
5074
5075 {
5076 \catcode`\<=13
5077 \catcode`\-=13
5078 \catcode`\`=13
5079   \gdef\indexnonalnumdisappear{%
5080     \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
5081       % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
5082       % (Introduced for FSFS 2nd ed.)
5083       \let`=\empty
5084     \fi
5085     %
5086     \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
5087       \backslashdisappear
5088     \fi
5089     %
5090     \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
5091       \def-{}%
5092     \fi
5093     \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
5094       \def<{}%
5095     \fi
5096     \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
5097       \def\@{}%
5098     \fi
5099   }
5100
5101   \gdef\indexnonalnumreappear{%
5102     \useindexbackslash
5103     \let-\normaldash
5104     \let<\normalless
5105     \def\@{@}%
5106   }
5107 }
5108
5109
5110 % \indexnofonts is used when outputting the strings to sort the index
5111 % by, and when constructing control sequence names.  It eliminates all
5112 % control sequences and just writes whatever the best ASCII sort string
5113 % would be for a given command (usually its argument).
5114 %
5115 \def\indexnofonts{%
5116   % Accent commands should become @asis.
5117   \def\commondummyaccent##1{\let##1\asis}%
5118   % We can just ignore other control letters.
5119   \def\commondummyletter##1{\let##1\empty}%
5120   % All control words become @asis by default; overrides below.
5121   \let\commondummyword\commondummyaccent
5122   \commondummiesnofonts
5123   %
5124   % Don't no-op \tt, since it isn't a user-level command
5125   % and is used in the definitions of the active chars like <, >, |, etc.
5126   % Likewise with the other plain tex font commands.
5127   %\let\tt=\asis
5128   %
5129   \def\ { }%
5130   \def\@{@}%
5131   \def\_{\normalunderscore}%
5132   \def\-{}% @- shouldn't affect sorting
5133   %
5134   \uccode`\1=`\{ \uppercase{\def\{{1}}%
5135   \uccode`\1=`\} \uppercase{\def\}{1}}%
5136   \let\lbracechar\{%
5137   \let\rbracechar\}%
5138   %
5139   % Non-English letters.
5140   \def\AA{AA}%
5141   \def\AE{AE}%
5142   \def\DH{DZZ}%
5143   \def\L{L}%
5144   \def\OE{OE}%
5145   \def\O{O}%
5146   \def\TH{TH}%
5147   \def\aa{aa}%
5148   \def\ae{ae}%
5149   \def\dh{dzz}%
5150   \def\exclamdown{!}%
5151   \def\l{l}%
5152   \def\oe{oe}%
5153   \def\ordf{a}%
5154   \def\ordm{o}%
5155   \def\o{o}%
5156   \def\questiondown{?}%
5157   \def\ss{ss}%
5158   \def\th{th}%
5159   %
5160   \def\LaTeX{LaTeX}%
5161   \def\TeX{TeX}%
5162   %
5163   % Assorted special characters.  \defglyph gives the control sequence a
5164   % definition that removes the {} that follows its use.
5165   \defglyph\atchar{@}%
5166   \defglyph\arrow{->}%
5167   \defglyph\bullet{bullet}%
5168   \defglyph\comma{,}%
5169   \defglyph\copyright{copyright}%
5170   \defglyph\dots{...}%
5171   \defglyph\enddots{...}%
5172   \defglyph\equiv{==}%
5173   \defglyph\error{error}%
5174   \defglyph\euro{euro}%
5175   \defglyph\expansion{==>}%
5176   \defglyph\geq{>=}%
5177   \defglyph\guillemetleft{<<}%
5178   \defglyph\guillemetright{>>}%
5179   \defglyph\guilsinglleft{<}%
5180   \defglyph\guilsinglright{>}%
5181   \defglyph\leq{<=}%
5182   \defglyph\lbracechar{\{}%
5183   \defglyph\minus{-}%
5184   \defglyph\point{.}%
5185   \defglyph\pounds{pounds}%
5186   \defglyph\print{-|}%
5187   \defglyph\quotedblbase{"}%
5188   \defglyph\quotedblleft{"}%
5189   \defglyph\quotedblright{"}%
5190   \defglyph\quoteleft{`}%
5191   \defglyph\quoteright{'}%
5192   \defglyph\quotesinglbase{,}%
5193   \defglyph\rbracechar{\}}%
5194   \defglyph\registeredsymbol{R}%
5195   \defglyph\result{=>}%
5196   \defglyph\textdegree{o}%
5197   %
5198   % We need to get rid of all macros, leaving only the arguments (if present).
5199   % Of course this is not nearly correct, but it is the best we can do for now.
5200   % makeinfo does not expand macros in the argument to @deffn, which ends up
5201   % writing an index entry, and texindex isn't prepared for an index sort entry
5202   % that starts with \.
5203   %
5204   % Since macro invocations are followed by braces, we can just redefine them
5205   % to take a single TeX argument.  The case of a macro invocation that
5206   % goes to end-of-line is not handled.
5207   %
5208   \macrolist
5209   \let\value\indexnofontsvalue
5210 }
5211 \def\defglyph#1#2{\def#1##1{#2}} % see above
5212
5213 \f
5214
5215
5216 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
5217
5218 % Most index entries go through here, but \dosubind is the general case.
5219 % #1 is the index name, #2 is the entry text.
5220 \def\doind#1#2{\dosubind{#1}{#2}{}}
5221
5222 % There is also \dosubind {index}{topic}{subtopic}
5223 % which makes an entry in a two-level index such as the operation index.
5224 % TODO: Two-level index?  Operation index?
5225
5226 % Workhorse for all indexes.
5227 % #1 is name of index, #2 is stuff to put there, #3 is subentry --
5228 % empty if called from \doind, as we usually are (the main exception
5229 % is with most defuns, which call us directly).
5230 %
5231 \def\dosubind#1#2#3{%
5232   \iflinks
5233   {%
5234     \requireopenindexfile{#1}%
5235     % Store the main index entry text (including the third arg).
5236     \toks0 = {#2}%
5237     % If third arg is present, precede it with a space.
5238     \def\thirdarg{#3}%
5239     \ifx\thirdarg\empty \else
5240       \toks0 = \expandafter{\the\toks0 \space #3}%
5241     \fi
5242     %
5243     \edef\writeto{\csname#1indfile\endcsname}%
5244     %
5245     \safewhatsit\dosubindwrite
5246   }%
5247   \fi
5248 }
5249
5250 % Check if an index file has been opened, and if not, open it.
5251 \def\requireopenindexfile#1{%
5252 \ifnum\csname #1indfile\endcsname=0
5253   \expandafter\newwrite \csname#1indfile\endcsname
5254   \edef\suffix{#1}%
5255   % A .fls suffix would conflict with the file extension for the output
5256   % of -recorder, so use .f1s instead.
5257   \ifx\suffix\indexisfl\def\suffix{f1}\fi
5258   % Open the file
5259   \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
5260   % Using \immediate above here prevents an object entering into the current 
5261   % box, which could confound checks such as those in \safewhatsit for
5262   % preceding skips.
5263   \typeout{Writing index file \jobname.\suffix}%
5264 \fi}
5265 \def\indexisfl{fl}
5266
5267 % Output \ as {\indexbackslash}, because \ is an escape character in
5268 % the index files.
5269 \let\indexbackslash=\relax
5270 {\catcode`\@=0 \catcode`\\=\active
5271   @gdef@useindexbackslash{@def\{{@indexbackslash}}}
5272 }
5273
5274 % Definition for writing index entry text.
5275 \def\sortas#1{\ignorespaces}%
5276
5277 % Definition for writing index entry sort key.  Should occur at the at
5278 % the beginning of the index entry, like
5279 %     @cindex @sortas{september} \september
5280 % The \ignorespaces takes care of following space, but there's no way
5281 % to remove space before it.
5282 {
5283 \catcode`\-=13
5284 \gdef\indexwritesortas{%
5285   \begingroup
5286   \indexnonalnumreappear
5287   \indexwritesortasxxx}
5288 \gdef\indexwritesortasxxx#1{%
5289   \xdef\indexsortkey{#1}\endgroup}
5290 }
5291
5292
5293 % Write the entry in \toks0 to the index file.
5294 %
5295 \def\dosubindwrite{%
5296   % Put the index entry in the margin if desired.
5297   \ifx\SETmarginindex\relax\else
5298     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
5299   \fi
5300   %
5301   % Remember, we are within a group.
5302   \indexdummies % Must do this here, since \bf, etc expand at this stage
5303   \useindexbackslash % \indexbackslash isn't defined now so it will be output 
5304                      % as is; and it will print as backslash.
5305   % The braces around \indexbrace are recognized by texindex.
5306   %
5307   % Get the string to sort by, by processing the index entry with all
5308   % font commands turned off.
5309   {\indexnofonts
5310    \def\lbracechar{{\indexlbrace}}%
5311    \def\rbracechar{{\indexrbrace}}%
5312    \let\{=\lbracechar
5313    \let\}=\rbracechar
5314    \indexnonalnumdisappear
5315    \xdef\indexsortkey{}%
5316    \let\sortas=\indexwritesortas
5317    \edef\temp{\the\toks0}%
5318    \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas
5319    \ifx\indexsortkey\empty
5320      \xdef\indexsortkey{\temp}%
5321      \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
5322    \fi
5323   }%
5324   %
5325   % Set up the complete index entry, with both the sort key and
5326   % the original text, including any font commands.  We write
5327   % three arguments to \entry to the .?? file (four in the
5328   % subentry case), texindex reduces to two when writing the .??s
5329   % sorted result.
5330   \edef\temp{%
5331     \write\writeto{%
5332       \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}%
5333   }%
5334   \temp
5335 }
5336 \newbox\dummybox % used above
5337
5338 % Take care of unwanted page breaks/skips around a whatsit:
5339 %
5340 % If a skip is the last thing on the list now, preserve it
5341 % by backing up by \lastskip, doing the \write, then inserting
5342 % the skip again.  Otherwise, the whatsit generated by the
5343 % \write or \pdfdest will make \lastskip zero.  The result is that
5344 % sequences like this:
5345 % @end defun
5346 % @tindex whatever
5347 % @defun ...
5348 % will have extra space inserted, because the \medbreak in the
5349 % start of the @defun won't see the skip inserted by the @end of
5350 % the previous defun.
5351 %
5352 % But don't do any of this if we're not in vertical mode.  We
5353 % don't want to do a \vskip and prematurely end a paragraph.
5354 %
5355 % Avoid page breaks due to these extra skips, too.
5356 %
5357 % But wait, there is a catch there:
5358 % We'll have to check whether \lastskip is zero skip.  \ifdim is not
5359 % sufficient for this purpose, as it ignores stretch and shrink parts
5360 % of the skip.  The only way seems to be to check the textual
5361 % representation of the skip.
5362 %
5363 % The following is almost like \def\zeroskipmacro{0.0pt} except that
5364 % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
5365 %
5366 \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
5367 %
5368 \newskip\whatsitskip
5369 \newcount\whatsitpenalty
5370 %
5371 % ..., ready, GO:
5372 %
5373 \def\safewhatsit#1{\ifhmode
5374   #1%
5375  \else
5376   % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
5377   \whatsitskip = \lastskip
5378   \edef\lastskipmacro{\the\lastskip}%
5379   \whatsitpenalty = \lastpenalty
5380   %
5381   % If \lastskip is nonzero, that means the last item was a
5382   % skip.  And since a skip is discardable, that means this
5383   % -\whatsitskip glue we're inserting is preceded by a
5384   % non-discardable item, therefore it is not a potential
5385   % breakpoint, therefore no \nobreak needed.
5386   \ifx\lastskipmacro\zeroskipmacro
5387   \else
5388     \vskip-\whatsitskip
5389   \fi
5390   %
5391   #1%
5392   %
5393   \ifx\lastskipmacro\zeroskipmacro
5394     % If \lastskip was zero, perhaps the last item was a penalty, and
5395     % perhaps it was >=10000, e.g., a \nobreak.  In that case, we want
5396     % to re-insert the same penalty (values >10000 are used for various
5397     % signals); since we just inserted a non-discardable item, any
5398     % following glue (such as a \parskip) would be a breakpoint.  For example:
5399     %   @deffn deffn-whatever
5400     %   @vindex index-whatever
5401     %   Description.
5402     % would allow a break between the index-whatever whatsit
5403     % and the "Description." paragraph.
5404     \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
5405   \else
5406     % On the other hand, if we had a nonzero \lastskip,
5407     % this make-up glue would be preceded by a non-discardable item
5408     % (the whatsit from the \write), so we must insert a \nobreak.
5409     \nobreak\vskip\whatsitskip
5410   \fi
5411 \fi}
5412
5413 % The index entry written in the file actually looks like
5414 %  \entry {sortstring}{page}{topic}
5415 % or
5416 %  \entry {sortstring}{page}{topic}{subtopic}
5417 % The texindex program reads in these files and writes files
5418 % containing these kinds of lines:
5419 %  \initial {c}
5420 %     before the first topic whose initial is c
5421 %  \entry {topic}{pagelist}
5422 %     for a topic that is used without subtopics
5423 %  \primary {topic}
5424 %     for the beginning of a topic that is used with subtopics
5425 %  \secondary {subtopic}{pagelist}
5426 %     for each subtopic.
5427
5428 % Define the user-accessible indexing commands
5429 % @findex, @vindex, @kindex, @cindex.
5430
5431 \def\findex {\fnindex}
5432 \def\kindex {\kyindex}
5433 \def\cindex {\cpindex}
5434 \def\vindex {\vrindex}
5435 \def\tindex {\tpindex}
5436 \def\pindex {\pgindex}
5437
5438 \def\cindexsub {\begingroup\obeylines\cindexsub}
5439 {\obeylines %
5440 \gdef\cindexsub "#1" #2^^M{\endgroup %
5441 \dosubind{cp}{#2}{#1}}}
5442
5443 % Define the macros used in formatting output of the sorted index material.
5444
5445 % @printindex causes a particular index (the ??s file) to get printed.
5446 % It does not print any chapter heading (usually an @unnumbered).
5447 %
5448 \parseargdef\printindex{\begingroup
5449   \dobreak \chapheadingskip{10000}%
5450   %
5451   \smallfonts \rm
5452   \tolerance = 9500
5453   \plainfrenchspacing
5454   \everypar = {}% don't want the \kern\-parindent from indentation suppression.
5455   %
5456   % See if the index file exists and is nonempty.
5457   % Change catcode of @ here so that if the index file contains
5458   % \initial {@}
5459   % as its first line, TeX doesn't complain about mismatched braces
5460   % (because it thinks @} is a control sequence).
5461   \catcode`\@ = 12
5462   % See comment in \requireopenindexfile.
5463   \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
5464   \openin 1 \jobname.\indexname s
5465   \ifeof 1
5466     % \enddoublecolumns gets confused if there is no text in the index,
5467     % and it loses the chapter title and the aux file entries for the
5468     % index.  The easiest way to prevent this problem is to make sure
5469     % there is some text.
5470     \putwordIndexNonexistent
5471     \typeout{No file \jobname.\indexname s.}%
5472   \else
5473     \catcode`\\ = 0
5474     %
5475     % If the index file exists but is empty, then \openin leaves \ifeof
5476     % false.  We have to make TeX try to read something from the file, so
5477     % it can discover if there is anything in it.
5478     \read 1 to \thisline
5479     \ifeof 1
5480       \putwordIndexIsEmpty
5481     \else
5482       % Index files are almost Texinfo source, but we use \ as the escape
5483       % character.  It would be better to use @, but that's too big a change
5484       % to make right now.
5485       \def\indexbackslash{\ttbackslash}%
5486       \let\indexlbrace\{   % Likewise, set these sequences for braces
5487       \let\indexrbrace\}   % used in the sort key.
5488       \begindoublecolumns
5489       \let\dotheinsertentrybox\dotheinsertentryboxwithpenalty
5490       %
5491       % Read input from the index file line by line.
5492       \loopdo
5493         \ifeof1 \else
5494           \read 1 to \nextline
5495         \fi
5496         %
5497         \indexinputprocessing
5498         \thisline
5499         %
5500         \ifeof1\else
5501         \let\thisline\nextline
5502       \repeat
5503       %%
5504       \enddoublecolumns
5505     \fi
5506   \fi
5507   \closein 1
5508 \endgroup}
5509 \def\loopdo#1\repeat{\def\body{#1}\loopdoxxx}
5510 \def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next}
5511
5512 \def\indexinputprocessing{%
5513   \ifeof1
5514     \let\firsttoken\relax
5515   \else
5516     \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}%
5517     \act
5518   \fi
5519 }
5520 \def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken}
5521 \long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1}
5522
5523
5524 % These macros are used by the sorted index file itself.
5525 % Change them to control the appearance of the index.
5526
5527 {\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
5528 \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
5529 \catcode`\$=3
5530 \gdef\initialglyphs{%
5531   % Some changes for non-alphabetic characters.  Using the glyphs from the
5532   % math fonts looks more consistent than the typewriter font used elsewhere
5533   % for these characters.
5534   \def\indexbackslash{\math{\backslash}}%
5535   \let\\=\indexbackslash
5536   %
5537   % Can't get bold backslash so don't use bold forward slash
5538   \catcode`\/=13
5539   \def/{{\secrmnotbold \normalslash}}%
5540   \def-{{\normaldash\normaldash}}% en dash `--'
5541   \def^{{\chapbf \normalcaret}}%
5542   \def~{{\chapbf \normaltilde}}%
5543   \def\_{%
5544      \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
5545   \def|{$\vert$}%
5546   \def<{$\less$}%
5547   \def>{$\gtr$}%
5548   \def+{$\normalplus$}%
5549 }}
5550
5551 \def\initial{%
5552   \bgroup
5553   \initialglyphs
5554   \initialx
5555 }
5556
5557 \def\initialx#1{%
5558   % Remove any glue we may have, we'll be inserting our own.
5559   \removelastskip
5560   %
5561   % We like breaks before the index initials, so insert a bonus.
5562   % The glue before the bonus allows a little bit of space at the
5563   % bottom of a column to reduce an increase in inter-line spacing.
5564   \nobreak
5565   \vskip 0pt plus 5\baselineskip
5566   \penalty -300 
5567   \vskip 0pt plus -5\baselineskip
5568   %
5569   % Typeset the initial.  Making this add up to a whole number of
5570   % baselineskips increases the chance of the dots lining up from column
5571   % to column.  It still won't often be perfect, because of the stretch
5572   % we need before each entry, but it's better.
5573   %
5574   % No shrink because it confuses \balancecolumns.
5575   \vskip 1.67\baselineskip plus 1\baselineskip
5576   \leftline{\secfonts \kern-0.05em \secbf #1}%
5577   % \secfonts is inside the argument of \leftline so that the change of
5578   % \baselineskip will not affect any glue inserted before the vbox that
5579   % \leftline creates.
5580   % Do our best not to break after the initial.
5581   \nobreak
5582   \vskip .33\baselineskip plus .1\baselineskip
5583   \egroup % \initialglyphs
5584 }
5585
5586 \newdimen\entryrightmargin
5587 \entryrightmargin=0pt
5588
5589 % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
5590 % then page number (#2) flushed to the right margin.  It is used for index
5591 % and table of contents entries.  The paragraph is indented by \leftskip.
5592 %
5593 \def\entry{%
5594   \begingroup
5595     %
5596     % For pdfTeX and XeTeX.
5597     % The redefinition of \domark stops marks being added in \pdflink to 
5598     % preserve coloured links across page boundaries.  Otherwise the marks
5599     % would get in the way of \lastbox in \insertentrybox.
5600     \let\domark\relax
5601     %
5602     % Start a new paragraph if necessary, so our assignments below can't
5603     % affect previous text.
5604     \par
5605     %
5606     % No extra space above this paragraph.
5607     \parskip = 0in
5608     %
5609     % When reading the text of entry, convert explicit line breaks
5610     % from @* into spaces.  The user might give these in long section
5611     % titles, for instance.
5612     \def\*{\unskip\space\ignorespaces}%
5613     \def\entrybreak{\hfil\break}% An undocumented command
5614     %
5615     % Swallow the left brace of the text (first parameter):
5616     \afterassignment\doentry
5617     \let\temp =
5618 }
5619 \def\entrybreak{\unskip\space\ignorespaces}%
5620 \def\doentry{%
5621     % Save the text of the entry
5622     \global\setbox\boxA=\hbox\bgroup
5623     \bgroup % Instead of the swallowed brace.
5624       \noindent
5625       \aftergroup\finishentry
5626       % And now comes the text of the entry.
5627       % Not absorbing as a macro argument reduces the chance of problems
5628       % with catcodes occurring.
5629 }
5630 {\catcode`\@=11
5631 \gdef\finishentry#1{%
5632     \egroup % end box A
5633     \dimen@ = \wd\boxA % Length of text of entry
5634     \global\setbox\boxA=\hbox\bgroup\unhbox\boxA
5635     % #1 is the page number.
5636     %
5637     % Get the width of the page numbers, and only use
5638     % leaders if they are present.
5639     \global\setbox\boxB = \hbox{#1}%
5640     \ifdim\wd\boxB = 0pt
5641       \null\nobreak\hfill\ %
5642     \else
5643       %
5644       \null\nobreak\indexdotfill % Have leaders before the page number.
5645       %
5646       \ifpdf
5647         \pdfgettoks#1.%
5648         \hskip\skip\thinshrinkable\the\toksA
5649       \else
5650         \ifx\XeTeXrevision\thisisundefined
5651           \hskip\skip\thinshrinkable #1%
5652         \else
5653           \pdfgettoks#1.%
5654           \hskip\skip\thinshrinkable\the\toksA
5655         \fi
5656       \fi
5657     \fi
5658     \egroup % end \boxA
5659     \ifdim\wd\boxB = 0pt
5660       \global\setbox\entrybox=\vbox{\unhbox\boxA}%
5661     \else
5662     \global\setbox\entrybox=\vbox\bgroup
5663       % We want the text of the entries to be aligned to the left, and the
5664       % page numbers to be aligned to the right.
5665       %
5666       \parindent = 0pt
5667       \advance\leftskip by 0pt plus 1fil
5668       \advance\leftskip by 0pt plus -1fill
5669       \rightskip = 0pt plus -1fil
5670       \advance\rightskip by 0pt plus 1fill
5671       % Cause last line, which could consist of page numbers on their own
5672       % if the list of page numbers is long, to be aligned to the right.
5673       \parfillskip=0pt plus -1fill
5674       %
5675       \advance\rightskip by \entryrightmargin
5676       % Determine how far we can stretch into the margin.
5677       % This allows, e.g., "Appendix H  GNU Free Documentation License" to
5678       % fit on one line in @letterpaper format.
5679       \ifdim\entryrightmargin>2.1em
5680         \dimen@i=2.1em
5681       \else
5682         \dimen@i=0em
5683       \fi
5684       \advance \parfillskip by 0pt minus 1\dimen@i
5685       %
5686       \dimen@ii = \hsize
5687       \advance\dimen@ii by -1\leftskip
5688       \advance\dimen@ii by -1\entryrightmargin
5689       \advance\dimen@ii by 1\dimen@i
5690       \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
5691       \ifdim\dimen@ > 0.8\dimen@ii   % due to long index text
5692         % Try to split the text roughly evenly.  \dimen@ will be the length of 
5693         % the first line.
5694         \dimen@ = 0.7\dimen@
5695         \dimen@ii = \hsize
5696         \ifnum\dimen@>\dimen@ii
5697           % If the entry is too long (for example, if it needs more than
5698           % two lines), use all the space in the first line.
5699           \dimen@ = \dimen@ii
5700         \fi
5701         \advance\leftskip by 0pt plus 1fill % ragged right
5702         \advance \dimen@ by 1\rightskip
5703         \parshape = 2 0pt \dimen@ 0em \dimen@ii
5704         % Ideally we'd add a finite glue at the end of the first line only,
5705         % instead of using \parshape with explicit line lengths, but TeX
5706         % doesn't seem to provide a way to do such a thing.
5707         %
5708         % Indent all lines but the first one.
5709         \advance\leftskip by 1em
5710         \advance\parindent by -1em
5711       \fi\fi
5712       \indent % start paragraph
5713       \unhbox\boxA
5714       %
5715       % Do not prefer a separate line ending with a hyphen to fewer lines.
5716       \finalhyphendemerits = 0
5717       %
5718       % Word spacing - no stretch
5719       \spaceskip=\fontdimen2\font minus \fontdimen4\font
5720       %
5721       \linepenalty=1000  % Discourage line breaks.
5722       \hyphenpenalty=5000  % Discourage hyphenation.
5723       %
5724       \par % format the paragraph
5725     \egroup % The \vbox
5726     \fi
5727   \endgroup
5728   \dotheinsertentrybox
5729 }}
5730
5731 \newskip\thinshrinkable
5732 \skip\thinshrinkable=.15em minus .15em
5733
5734 \newbox\entrybox
5735 \def\insertentrybox{%
5736   \ourunvbox\entrybox
5737 }
5738
5739 % default definition
5740 \let\dotheinsertentrybox\insertentrybox
5741
5742 % Use \lastbox to take apart vbox box by box, and add each sub-box
5743 % to the current vertical list.
5744 \def\ourunvbox#1{%
5745 \bgroup % for local binding of \delayedbox
5746   % Remove the last box from box #1
5747   \global\setbox#1=\vbox{%
5748     \unvbox#1%
5749     \unskip % remove any glue
5750     \unpenalty
5751     \global\setbox\interbox=\lastbox
5752   }%
5753   \setbox\delayedbox=\box\interbox
5754   \ifdim\ht#1=0pt\else
5755     \ourunvbox#1 % Repeat on what's left of the box
5756     \nobreak
5757   \fi
5758   \box\delayedbox
5759 \egroup
5760 }
5761 \newbox\delayedbox
5762 \newbox\interbox
5763
5764 % Used from \printindex.  \firsttoken should be the first token
5765 % after the \entry.  If it's not another \entry, we are at the last
5766 % line of a group of index entries, so insert a penalty to discourage
5767 % widowed index entries.
5768 \def\dotheinsertentryboxwithpenalty{%
5769   \ifx\firsttoken\isentry
5770   \else
5771     \penalty 9000
5772   \fi
5773   \insertentrybox
5774 }
5775 \def\isentry{\entry}%
5776
5777 % Like plain.tex's \dotfill, except uses up at least 1 em.
5778 % The filll stretch here overpowers both the fil and fill stretch to push
5779 % the page number to the right.
5780 \def\indexdotfill{\cleaders
5781   \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
5782
5783
5784 \def\primary #1{\line{#1\hfil}}
5785
5786 \newskip\secondaryindent \secondaryindent=0.5cm
5787 \def\secondary#1#2{{%
5788   \parfillskip=0in
5789   \parskip=0in
5790   \hangindent=1in
5791   \hangafter=1
5792   \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
5793   \ifpdf
5794     \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5795   \else
5796     \ifx\XeTeXrevision\thisisundefined
5797       #2
5798     \else
5799       \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5800     \fi
5801   \fi
5802   \par
5803 }}
5804
5805 % Define two-column mode, which we use to typeset indexes.
5806 % Adapted from the TeXbook, page 416, which is to say,
5807 % the manmac.tex format used to print the TeXbook itself.
5808 \catcode`\@=11  % private names
5809
5810 \newbox\partialpage
5811 \newdimen\doublecolumnhsize
5812
5813 % Use inside an output routine to save \topmark and \firstmark
5814 \def\savemarks{%
5815   \global\savedtopmark=\expandafter{\topmark }%
5816   \global\savedfirstmark=\expandafter{\firstmark }%
5817 }
5818 \newtoks\savedtopmark
5819 \newtoks\savedfirstmark
5820
5821 % Set \topmark and \firstmark for next time \output runs.
5822 % Can't be run from withinside \output (because any material
5823 % added while an output routine is active, including 
5824 % penalties, is saved for after it finishes).  The page so far
5825 % should be empty, otherwise what's on it will be thrown away.
5826 \def\restoremarks{%
5827   \mark{\the\savedtopmark}%
5828   \bgroup\output = {%
5829     \setbox\dummybox=\box\PAGE
5830   }abc\eject\egroup
5831   % "abc" because output routine doesn't fire for a completely empty page.
5832   \mark{\the\savedfirstmark}%
5833 }
5834
5835 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
5836   % If not much space left on page, start a new page.
5837   \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
5838   %
5839   % Grab any single-column material above us.
5840   \output = {%
5841     %
5842     % Here is a possibility not foreseen in manmac: if we accumulate a
5843     % whole lot of material, we might end up calling this \output
5844     % routine twice in a row (see the doublecol-lose test, which is
5845     % essentially a couple of indexes with @setchapternewpage off).  In
5846     % that case we just ship out what is in \partialpage with the normal
5847     % output routine.  Generally, \partialpage will be empty when this
5848     % runs and this will be a no-op.  See the indexspread.tex test case.
5849     \ifvoid\partialpage \else
5850       \onepageout{\pagecontents\partialpage}%
5851     \fi
5852     %
5853     \global\setbox\partialpage = \vbox{%
5854       % Unvbox the main output page.
5855       \unvbox\PAGE
5856       \kern-\topskip \kern\baselineskip
5857     }%
5858     \savemarks
5859   }%
5860   \eject % run that output routine to set \partialpage
5861   \restoremarks
5862   %
5863   % We recover the two marks that the last output routine saved in order
5864   % to propagate the information in marks added around a chapter heading,
5865   % which could be otherwise be lost by the time the final page is output.
5866   %
5867   %
5868   % Use the double-column output routine for subsequent pages.
5869   \output = {\doublecolumnout}%
5870   %
5871   % Change the page size parameters.  We could do this once outside this
5872   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5873   % format, but then we repeat the same computation.  Repeating a couple
5874   % of assignments once per index is clearly meaningless for the
5875   % execution time, so we may as well do it in one place.
5876   %
5877   % First we halve the line length, less a little for the gutter between
5878   % the columns.  We compute the gutter based on the line length, so it
5879   % changes automatically with the paper format.  The magic constant
5880   % below is chosen so that the gutter has the same value (well, +-<1pt)
5881   % as it did when we hard-coded it.
5882   %
5883   % We put the result in a separate register, \doublecolumhsize, so we
5884   % can restore it in \pagesofar, after \hsize itself has (potentially)
5885   % been clobbered.
5886   %
5887   \doublecolumnhsize = \hsize
5888     \advance\doublecolumnhsize by -.04154\hsize
5889     \divide\doublecolumnhsize by 2
5890   \hsize = \doublecolumnhsize
5891   %
5892   % Double the \vsize as well.
5893   \advance\vsize by -\ht\partialpage
5894   \vsize = 2\vsize
5895   %
5896   % For the benefit of balancing columns
5897   \advance\baselineskip by 0pt plus 0.5pt
5898 }
5899
5900 % The double-column output routine for all double-column pages except
5901 % the last, which is done by \balancecolumns.
5902 %
5903 \def\doublecolumnout{%
5904   %
5905   \splittopskip=\topskip \splitmaxdepth=\maxdepth
5906   % Get the available space for the double columns -- the normal
5907   % (undoubled) page height minus any material left over from the
5908   % previous page.
5909   \dimen@ = \vsize
5910   \divide\dimen@ by 2
5911   %
5912   % box0 will be the left-hand column, box2 the right.
5913   \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@
5914   \global\advance\vsize by 2\ht\partialpage
5915   \onepageout\pagesofar
5916   \unvbox\PAGE
5917   \penalty\outputpenalty
5918 }
5919 %
5920 % Re-output the contents of the output page -- any previous material,
5921 % followed by the two boxes we just split, in box0 and box2.
5922 \def\pagesofar{%
5923   \unvbox\partialpage
5924   %
5925   \hsize = \doublecolumnhsize
5926   \wd0=\hsize \wd2=\hsize
5927   \hbox to\txipagewidth{\box0\hfil\box2}%
5928 }
5929
5930
5931 % Finished with with double columns.
5932 \def\enddoublecolumns{%
5933   % The following penalty ensures that the page builder is exercised
5934   % _before_ we change the output routine.  This is necessary in the
5935   % following situation:
5936   %
5937   % The last section of the index consists only of a single entry.
5938   % Before this section, \pagetotal is less than \pagegoal, so no
5939   % break occurs before the last section starts.  However, the last
5940   % section, consisting of \initial and the single \entry, does not
5941   % fit on the page and has to be broken off.  Without the following
5942   % penalty the page builder will not be exercised until \eject
5943   % below, and by that time we'll already have changed the output
5944   % routine to the \balancecolumns version, so the next-to-last
5945   % double-column page will be processed with \balancecolumns, which
5946   % is wrong:  The two columns will go to the main vertical list, with
5947   % the broken-off section in the recent contributions.  As soon as
5948   % the output routine finishes, TeX starts reconsidering the page
5949   % break.  The two columns and the broken-off section both fit on the
5950   % page, because the two columns now take up only half of the page
5951   % goal.  When TeX sees \eject from below which follows the final
5952   % section, it invokes the new output routine that we've set after
5953   % \balancecolumns below; \onepageout will try to fit the two columns
5954   % and the final section into the vbox of \txipageheight (see
5955   % \pagebody), causing an overfull box.
5956   %
5957   % Note that glue won't work here, because glue does not exercise the
5958   % page builder, unlike penalties (see The TeXbook, pp. 280-281).
5959   \penalty0
5960   %
5961   \output = {%
5962     % Split the last of the double-column material.
5963     \savemarks
5964     \balancecolumns
5965   }%
5966   \eject % call the \output just set
5967   \ifdim\pagetotal=0pt
5968     % Having called \balancecolumns once, we do not
5969     % want to call it again.  Therefore, reset \output to its normal
5970     % definition right away.
5971     \global\output = {\onepageout{\pagecontents\PAGE}}%
5972     %
5973     \endgroup % started in \begindoublecolumns
5974     \restoremarks
5975     % Leave the double-column material on the current page, no automatic
5976     % page break.
5977     \box\balancedcolumns
5978     %
5979     % \pagegoal was set to the doubled \vsize above, since we restarted
5980     % the current page.  We're now back to normal single-column
5981     % typesetting, so reset \pagegoal to the normal \vsize.
5982     \global\vsize = \txipageheight %
5983     \pagegoal = \txipageheight %
5984   \else
5985     % We had some left-over material.  This might happen when \doublecolumnout
5986     % is called in \balancecolumns.  Try again.
5987     \expandafter\enddoublecolumns
5988   \fi
5989 }
5990 \newbox\balancedcolumns
5991 \setbox\balancedcolumns=\vbox{shouldnt see this}%
5992 %
5993 % Only called for the last of the double column material.  \doublecolumnout 
5994 % does the others.
5995 \def\balancecolumns{%
5996   \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120.
5997   \dimen@ = \ht0
5998   \advance\dimen@ by \topskip
5999   \advance\dimen@ by-\baselineskip
6000   \ifdim\dimen@<5\baselineskip
6001     % Don't split a short final column in two.
6002     \setbox2=\vbox{}%
6003     \global\setbox\balancedcolumns=\vbox{\pagesofar}%
6004   \else
6005     \divide\dimen@ by 2 % target to split to
6006     \dimen@ii = \dimen@
6007     \splittopskip = \topskip
6008     % Loop until left column is at least as high as the right column.
6009     {%
6010       \vbadness = 10000
6011       \loop
6012         \global\setbox3 = \copy0
6013         \global\setbox1 = \vsplit3 to \dimen@
6014       \ifdim\ht1<\ht3
6015         \global\advance\dimen@ by 1pt
6016       \repeat
6017     }%
6018     % Now the left column is in box 1, and the right column in box 3.
6019     %
6020     % Check whether the left column has come out higher than the page itself.  
6021     % (Note that we have doubled \vsize for the double columns, so
6022     % the actual height of the page is 0.5\vsize).
6023     \ifdim2\ht1>\vsize
6024       % It appears that we have been called upon to balance too much material.
6025       % Output some of it with \doublecolumnout, leaving the rest on the page.
6026       \setbox\PAGE=\box0
6027       \doublecolumnout
6028     \else
6029       % Compare the heights of the two columns.
6030       \ifdim4\ht1>5\ht3
6031         % Column heights are too different, so don't make their bottoms
6032         % flush with each other.
6033         \setbox2=\vbox to \ht1 {\unvbox3\vfill}%
6034         \setbox0=\vbox to \ht1 {\unvbox1\vfill}%
6035       \else
6036         % Make column bottoms flush with each other.
6037         \setbox2=\vbox to\ht1{\unvbox3\unskip}%
6038         \setbox0=\vbox to\ht1{\unvbox1\unskip}%
6039       \fi
6040       \global\setbox\balancedcolumns=\vbox{\pagesofar}%
6041     \fi
6042   \fi
6043   %
6044 }
6045 \catcode`\@ = \other
6046
6047
6048 \message{sectioning,}
6049 % Chapters, sections, etc.
6050
6051 % Let's start with @part.
6052 \outer\parseargdef\part{\partzzz{#1}}
6053 \def\partzzz#1{%
6054   \chapoddpage
6055   \null
6056   \vskip.3\vsize  % move it down on the page a bit
6057   \begingroup
6058     \noindent \titlefonts\rm #1\par % the text
6059     \let\lastnode=\empty      % no node to associate with
6060     \writetocentry{part}{#1}{}% but put it in the toc
6061     \headingsoff              % no headline or footline on the part page
6062     % This outputs a mark at the end of the page that clears \thischapter
6063     % and \thissection, as is done in \startcontents.
6064     \let\pchapsepmacro\relax
6065     \chapmacro{}{Yomitfromtoc}{}%
6066     \chapoddpage
6067   \endgroup
6068 }
6069
6070 % \unnumberedno is an oxymoron.  But we count the unnumbered
6071 % sections so that we can refer to them unambiguously in the pdf
6072 % outlines by their "section number".  We avoid collisions with chapter
6073 % numbers by starting them at 10000.  (If a document ever has 10000
6074 % chapters, we're in trouble anyway, I'm sure.)
6075 \newcount\unnumberedno \unnumberedno = 10000
6076 \newcount\chapno
6077 \newcount\secno        \secno=0
6078 \newcount\subsecno     \subsecno=0
6079 \newcount\subsubsecno  \subsubsecno=0
6080
6081 % This counter is funny since it counts through charcodes of letters A, B, ...
6082 \newcount\appendixno  \appendixno = `\@
6083 %
6084 % \def\appendixletter{\char\the\appendixno}
6085 % We do the following ugly conditional instead of the above simple
6086 % construct for the sake of pdftex, which needs the actual
6087 % letter in the expansion, not just typeset.
6088 %
6089 \def\appendixletter{%
6090   \ifnum\appendixno=`A A%
6091   \else\ifnum\appendixno=`B B%
6092   \else\ifnum\appendixno=`C C%
6093   \else\ifnum\appendixno=`D D%
6094   \else\ifnum\appendixno=`E E%
6095   \else\ifnum\appendixno=`F F%
6096   \else\ifnum\appendixno=`G G%
6097   \else\ifnum\appendixno=`H H%
6098   \else\ifnum\appendixno=`I I%
6099   \else\ifnum\appendixno=`J J%
6100   \else\ifnum\appendixno=`K K%
6101   \else\ifnum\appendixno=`L L%
6102   \else\ifnum\appendixno=`M M%
6103   \else\ifnum\appendixno=`N N%
6104   \else\ifnum\appendixno=`O O%
6105   \else\ifnum\appendixno=`P P%
6106   \else\ifnum\appendixno=`Q Q%
6107   \else\ifnum\appendixno=`R R%
6108   \else\ifnum\appendixno=`S S%
6109   \else\ifnum\appendixno=`T T%
6110   \else\ifnum\appendixno=`U U%
6111   \else\ifnum\appendixno=`V V%
6112   \else\ifnum\appendixno=`W W%
6113   \else\ifnum\appendixno=`X X%
6114   \else\ifnum\appendixno=`Y Y%
6115   \else\ifnum\appendixno=`Z Z%
6116   % The \the is necessary, despite appearances, because \appendixletter is
6117   % expanded while writing the .toc file.  \char\appendixno is not
6118   % expandable, thus it is written literally, thus all appendixes come out
6119   % with the same letter (or @) in the toc without it.
6120   \else\char\the\appendixno
6121   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
6122   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
6123
6124 % Each @chapter defines these (using marks) as the number+name, number
6125 % and name of the chapter.  Page headings and footings can use
6126 % these.  @section does likewise.
6127 \def\thischapter{}
6128 \def\thischapternum{}
6129 \def\thischaptername{}
6130 \def\thissection{}
6131 \def\thissectionnum{}
6132 \def\thissectionname{}
6133
6134 \newcount\absseclevel % used to calculate proper heading level
6135 \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
6136
6137 % @raisesections: treat @section as chapter, @subsection as section, etc.
6138 \def\raisesections{\global\advance\secbase by -1}
6139 \let\up=\raisesections % original BFox name
6140
6141 % @lowersections: treat @chapter as section, @section as subsection, etc.
6142 \def\lowersections{\global\advance\secbase by 1}
6143 \let\down=\lowersections % original BFox name
6144
6145 % we only have subsub.
6146 \chardef\maxseclevel = 3
6147 %
6148 % A numbered section within an unnumbered changes to unnumbered too.
6149 % To achieve this, remember the "biggest" unnum. sec. we are currently in:
6150 \chardef\unnlevel = \maxseclevel
6151 %
6152 % Trace whether the current chapter is an appendix or not:
6153 % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
6154 \def\chapheadtype{N}
6155
6156 % Choose a heading macro
6157 % #1 is heading type
6158 % #2 is heading level
6159 % #3 is text for heading
6160 \def\genhead#1#2#3{%
6161   % Compute the abs. sec. level:
6162   \absseclevel=#2
6163   \advance\absseclevel by \secbase
6164   % Make sure \absseclevel doesn't fall outside the range:
6165   \ifnum \absseclevel < 0
6166     \absseclevel = 0
6167   \else
6168     \ifnum \absseclevel > 3
6169       \absseclevel = 3
6170     \fi
6171   \fi
6172   % The heading type:
6173   \def\headtype{#1}%
6174   \if \headtype U%
6175     \ifnum \absseclevel < \unnlevel
6176       \chardef\unnlevel = \absseclevel
6177     \fi
6178   \else
6179     % Check for appendix sections:
6180     \ifnum \absseclevel = 0
6181       \edef\chapheadtype{\headtype}%
6182     \else
6183       \if \headtype A\if \chapheadtype N%
6184         \errmessage{@appendix... within a non-appendix chapter}%
6185       \fi\fi
6186     \fi
6187     % Check for numbered within unnumbered:
6188     \ifnum \absseclevel > \unnlevel
6189       \def\headtype{U}%
6190     \else
6191       \chardef\unnlevel = 3
6192     \fi
6193   \fi
6194   % Now print the heading:
6195   \if \headtype U%
6196     \ifcase\absseclevel
6197         \unnumberedzzz{#3}%
6198     \or \unnumberedseczzz{#3}%
6199     \or \unnumberedsubseczzz{#3}%
6200     \or \unnumberedsubsubseczzz{#3}%
6201     \fi
6202   \else
6203     \if \headtype A%
6204       \ifcase\absseclevel
6205           \appendixzzz{#3}%
6206       \or \appendixsectionzzz{#3}%
6207       \or \appendixsubseczzz{#3}%
6208       \or \appendixsubsubseczzz{#3}%
6209       \fi
6210     \else
6211       \ifcase\absseclevel
6212           \chapterzzz{#3}%
6213       \or \seczzz{#3}%
6214       \or \numberedsubseczzz{#3}%
6215       \or \numberedsubsubseczzz{#3}%
6216       \fi
6217     \fi
6218   \fi
6219   \suppressfirstparagraphindent
6220 }
6221
6222 % an interface:
6223 \def\numhead{\genhead N}
6224 \def\apphead{\genhead A}
6225 \def\unnmhead{\genhead U}
6226
6227 % @chapter, @appendix, @unnumbered.  Increment top-level counter, reset
6228 % all lower-level sectioning counters to zero.
6229 %
6230 % Also set \chaplevelprefix, which we prepend to @float sequence numbers
6231 % (e.g., figures), q.v.  By default (before any chapter), that is empty.
6232 \let\chaplevelprefix = \empty
6233 %
6234 \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
6235 \def\chapterzzz#1{%
6236   % section resetting is \global in case the chapter is in a group, such
6237   % as an @include file.
6238   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6239     \global\advance\chapno by 1
6240   %
6241   % Used for \float.
6242   \gdef\chaplevelprefix{\the\chapno.}%
6243   \resetallfloatnos
6244   %
6245   % \putwordChapter can contain complex things in translations.
6246   \toks0=\expandafter{\putwordChapter}%
6247   \message{\the\toks0 \space \the\chapno}%
6248   %
6249   % Write the actual heading.
6250   \chapmacro{#1}{Ynumbered}{\the\chapno}%
6251   %
6252   % So @section and the like are numbered underneath this chapter.
6253   \global\let\section = \numberedsec
6254   \global\let\subsection = \numberedsubsec
6255   \global\let\subsubsection = \numberedsubsubsec
6256 }
6257
6258 \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
6259 %
6260 \def\appendixzzz#1{%
6261   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6262     \global\advance\appendixno by 1
6263   \gdef\chaplevelprefix{\appendixletter.}%
6264   \resetallfloatnos
6265   %
6266   % \putwordAppendix can contain complex things in translations.
6267   \toks0=\expandafter{\putwordAppendix}%
6268   \message{\the\toks0 \space \appendixletter}%
6269   %
6270   \chapmacro{#1}{Yappendix}{\appendixletter}%
6271   %
6272   \global\let\section = \appendixsec
6273   \global\let\subsection = \appendixsubsec
6274   \global\let\subsubsection = \appendixsubsubsec
6275 }
6276
6277 % normally unnmhead0 calls unnumberedzzz:
6278 \outer\parseargdef\unnumbered{\unnmhead0{#1}}
6279 \def\unnumberedzzz#1{%
6280   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6281     \global\advance\unnumberedno by 1
6282   %
6283   % Since an unnumbered has no number, no prefix for figures.
6284   \global\let\chaplevelprefix = \empty
6285   \resetallfloatnos
6286   %
6287   % This used to be simply \message{#1}, but TeX fully expands the
6288   % argument to \message.  Therefore, if #1 contained @-commands, TeX
6289   % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
6290   % expanded @cite (which turns out to cause errors because \cite is meant
6291   % to be executed, not expanded).
6292   %
6293   % Anyway, we don't want the fully-expanded definition of @cite to appear
6294   % as a result of the \message, we just want `@cite' itself.  We use
6295   % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6296   % simply yielding the contents of <toks register>.  (We also do this for
6297   % the toc entries.)
6298   \toks0 = {#1}%
6299   \message{(\the\toks0)}%
6300   %
6301   \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
6302   %
6303   \global\let\section = \unnumberedsec
6304   \global\let\subsection = \unnumberedsubsec
6305   \global\let\subsubsection = \unnumberedsubsubsec
6306 }
6307
6308 % @centerchap is like @unnumbered, but the heading is centered.
6309 \outer\parseargdef\centerchap{%
6310   \let\centerparametersmaybe = \centerparameters
6311   \unnmhead0{#1}%
6312   \let\centerparametersmaybe = \relax
6313 }
6314
6315 % @top is like @unnumbered.
6316 \let\top\unnumbered
6317
6318 % Sections.
6319
6320 \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6321 \def\seczzz#1{%
6322   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6323   \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
6324 }
6325
6326 % normally calls appendixsectionzzz:
6327 \outer\parseargdef\appendixsection{\apphead1{#1}}
6328 \def\appendixsectionzzz#1{%
6329   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6330   \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
6331 }
6332 \let\appendixsec\appendixsection
6333
6334 % normally calls unnumberedseczzz:
6335 \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
6336 \def\unnumberedseczzz#1{%
6337   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6338   \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
6339 }
6340
6341 % Subsections.
6342
6343 % normally calls numberedsubseczzz:
6344 \outer\parseargdef\numberedsubsec{\numhead2{#1}}
6345 \def\numberedsubseczzz#1{%
6346   \global\subsubsecno=0  \global\advance\subsecno by 1
6347   \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
6348 }
6349
6350 % normally calls appendixsubseczzz:
6351 \outer\parseargdef\appendixsubsec{\apphead2{#1}}
6352 \def\appendixsubseczzz#1{%
6353   \global\subsubsecno=0  \global\advance\subsecno by 1
6354   \sectionheading{#1}{subsec}{Yappendix}%
6355                  {\appendixletter.\the\secno.\the\subsecno}%
6356 }
6357
6358 % normally calls unnumberedsubseczzz:
6359 \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
6360 \def\unnumberedsubseczzz#1{%
6361   \global\subsubsecno=0  \global\advance\subsecno by 1
6362   \sectionheading{#1}{subsec}{Ynothing}%
6363                  {\the\unnumberedno.\the\secno.\the\subsecno}%
6364 }
6365
6366 % Subsubsections.
6367
6368 % normally numberedsubsubseczzz:
6369 \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
6370 \def\numberedsubsubseczzz#1{%
6371   \global\advance\subsubsecno by 1
6372   \sectionheading{#1}{subsubsec}{Ynumbered}%
6373                  {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
6374 }
6375
6376 % normally appendixsubsubseczzz:
6377 \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
6378 \def\appendixsubsubseczzz#1{%
6379   \global\advance\subsubsecno by 1
6380   \sectionheading{#1}{subsubsec}{Yappendix}%
6381                  {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
6382 }
6383
6384 % normally unnumberedsubsubseczzz:
6385 \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
6386 \def\unnumberedsubsubseczzz#1{%
6387   \global\advance\subsubsecno by 1
6388   \sectionheading{#1}{subsubsec}{Ynothing}%
6389                  {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
6390 }
6391
6392 % These macros control what the section commands do, according
6393 % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6394 % Define them by default for a numbered chapter.
6395 \let\section = \numberedsec
6396 \let\subsection = \numberedsubsec
6397 \let\subsubsection = \numberedsubsubsec
6398
6399 % Define @majorheading, @heading and @subheading
6400
6401 \def\majorheading{%
6402   {\advance\chapheadingskip by 10pt \chapbreak }%
6403   \parsearg\chapheadingzzz
6404 }
6405
6406 \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6407 \def\chapheadingzzz#1{%
6408   \vbox{\chapfonts \raggedtitlesettings #1\par}%
6409   \nobreak\bigskip \nobreak
6410   \suppressfirstparagraphindent
6411 }
6412
6413 % @heading, @subheading, @subsubheading.
6414 \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6415   \suppressfirstparagraphindent}
6416 \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6417   \suppressfirstparagraphindent}
6418 \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6419   \suppressfirstparagraphindent}
6420
6421 % These macros generate a chapter, section, etc. heading only
6422 % (including whitespace, linebreaking, etc. around it),
6423 % given all the information in convenient, parsed form.
6424
6425 % Args are the skip and penalty (usually negative)
6426 \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6427
6428 % Parameter controlling skip before chapter headings (if needed)
6429 \newskip\chapheadingskip
6430
6431 % Define plain chapter starts, and page on/off switching for it.
6432 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
6433
6434 % Start a new page
6435 \def\chappager{\par\vfill\supereject}
6436
6437 % \chapoddpage - start on an odd page for a new chapter
6438 % Because \domark is called before \chapoddpage, the filler page will
6439 % get the headings for the next chapter, which is wrong.  But we don't
6440 % care -- we just disable all headings on the filler page.
6441 \def\chapoddpage{%
6442   \chappager
6443   \ifodd\pageno \else
6444     \begingroup
6445       \headingsoff
6446       \null
6447       \chappager
6448     \endgroup
6449   \fi
6450 }
6451
6452 \parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
6453
6454 \def\CHAPPAGoff{%
6455 \global\let\contentsalignmacro = \chappager
6456 \global\let\pchapsepmacro=\chapbreak
6457 \global\let\pagealignmacro=\chappager}
6458
6459 \def\CHAPPAGon{%
6460 \global\let\contentsalignmacro = \chappager
6461 \global\let\pchapsepmacro=\chappager
6462 \global\let\pagealignmacro=\chappager
6463 \global\def\HEADINGSon{\HEADINGSsingle}}
6464
6465 \def\CHAPPAGodd{%
6466 \global\let\contentsalignmacro = \chapoddpage
6467 \global\let\pchapsepmacro=\chapoddpage
6468 \global\let\pagealignmacro=\chapoddpage
6469 \global\def\HEADINGSon{\HEADINGSdouble}}
6470
6471 \CHAPPAGon
6472
6473 % \chapmacro - Chapter opening.
6474 %
6475 % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6476 % Yappendix, Yomitfromtoc), #3 the chapter number.
6477 % Not used for @heading series.
6478 %
6479 % To test against our argument.
6480 \def\Ynothingkeyword{Ynothing}
6481 \def\Yappendixkeyword{Yappendix}
6482 \def\Yomitfromtockeyword{Yomitfromtoc}
6483 %
6484 \def\chapmacro#1#2#3{%
6485   \expandafter\ifx\thisenv\titlepage\else
6486     \checkenv{}% chapters, etc., should not start inside an environment.
6487   \fi
6488   % FIXME: \chapmacro is currently called from inside \titlepage when
6489   % \setcontentsaftertitlepage to print the "Table of Contents" heading, but
6490   % this should probably be done by \sectionheading with an option to print
6491   % in chapter size.
6492   %
6493   % Insert the first mark before the heading break (see notes for \domark).
6494   \let\prevchapterdefs=\lastchapterdefs
6495   \let\prevsectiondefs=\lastsectiondefs
6496   \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6497                         \gdef\thissection{}}%
6498   %
6499   \def\temptype{#2}%
6500   \ifx\temptype\Ynothingkeyword
6501     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6502                           \gdef\thischapter{\thischaptername}}%
6503   \else\ifx\temptype\Yomitfromtockeyword
6504     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6505                           \gdef\thischapter{}}%
6506   \else\ifx\temptype\Yappendixkeyword
6507     \toks0={#1}%
6508     \xdef\lastchapterdefs{%
6509       \gdef\noexpand\thischaptername{\the\toks0}%
6510       \gdef\noexpand\thischapternum{\appendixletter}%
6511       % \noexpand\putwordAppendix avoids expanding indigestible
6512       % commands in some of the translations.
6513       \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
6514                                  \noexpand\thischapternum:
6515                                  \noexpand\thischaptername}%
6516     }%
6517   \else
6518     \toks0={#1}%
6519     \xdef\lastchapterdefs{%
6520       \gdef\noexpand\thischaptername{\the\toks0}%
6521       \gdef\noexpand\thischapternum{\the\chapno}%
6522       % \noexpand\putwordChapter avoids expanding indigestible
6523       % commands in some of the translations.
6524       \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
6525                                  \noexpand\thischapternum:
6526                                  \noexpand\thischaptername}%
6527     }%
6528   \fi\fi\fi
6529   %
6530   % Output the mark.  Pass it through \safewhatsit, to take care of
6531   % the preceding space.
6532   \safewhatsit\domark
6533   %
6534   % Insert the chapter heading break.
6535   \pchapsepmacro
6536   %
6537   % Now the second mark, after the heading break.  No break points
6538   % between here and the heading.
6539   \let\prevchapterdefs=\lastchapterdefs
6540   \let\prevsectiondefs=\lastsectiondefs
6541   \domark
6542   %
6543   {%
6544     \chapfonts \rm
6545     \let\footnote=\errfootnoteheading % give better error message
6546     %
6547     % Have to define \lastsection before calling \donoderef, because the
6548     % xref code eventually uses it.  On the other hand, it has to be called
6549     % after \pchapsepmacro, or the headline will change too soon.
6550     \gdef\lastsection{#1}%
6551     %
6552     % Only insert the separating space if we have a chapter/appendix
6553     % number, and don't print the unnumbered ``number''.
6554     \ifx\temptype\Ynothingkeyword
6555       \setbox0 = \hbox{}%
6556       \def\toctype{unnchap}%
6557     \else\ifx\temptype\Yomitfromtockeyword
6558       \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6559       \def\toctype{omit}%
6560     \else\ifx\temptype\Yappendixkeyword
6561       \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6562       \def\toctype{app}%
6563     \else
6564       \setbox0 = \hbox{#3\enspace}%
6565       \def\toctype{numchap}%
6566     \fi\fi\fi
6567     %
6568     % Write the toc entry for this chapter.  Must come before the
6569     % \donoderef, because we include the current node name in the toc
6570     % entry, and \donoderef resets it to empty.
6571     \writetocentry{\toctype}{#1}{#3}%
6572     %
6573     % For pdftex, we have to write out the node definition (aka, make
6574     % the pdfdest) after any page break, but before the actual text has
6575     % been typeset.  If the destination for the pdf outline is after the
6576     % text, then jumping from the outline may wind up with the text not
6577     % being visible, for instance under high magnification.
6578     \donoderef{#2}%
6579     %
6580     % Typeset the actual heading.
6581     \nobreak % Avoid page breaks at the interline glue.
6582     \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
6583           \unhbox0 #1\par}%
6584   }%
6585   \nobreak\bigskip % no page break after a chapter title
6586   \nobreak
6587 }
6588
6589 % @centerchap -- centered and unnumbered.
6590 \let\centerparametersmaybe = \relax
6591 \def\centerparameters{%
6592   \advance\rightskip by 3\rightskip
6593   \leftskip = \rightskip
6594   \parfillskip = 0pt
6595 }
6596
6597
6598 % Section titles.  These macros combine the section number parts and
6599 % call the generic \sectionheading to do the printing.
6600 %
6601 \newskip\secheadingskip
6602 \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
6603
6604 % Subsection titles.
6605 \newskip\subsecheadingskip
6606 \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
6607
6608 % Subsubsection titles.
6609 \def\subsubsecheadingskip{\subsecheadingskip}
6610 \def\subsubsecheadingbreak{\subsecheadingbreak}
6611
6612
6613 % Print any size, any type, section title.
6614 %
6615 % #1 is the text of the title,
6616 % #2 is the section level (sec/subsec/subsubsec),
6617 % #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6618 % #4 is the section number.
6619 %
6620 \def\seckeyword{sec}
6621 %
6622 \def\sectionheading#1#2#3#4{%
6623   {%
6624     \def\sectionlevel{#2}%
6625     \def\temptype{#3}%
6626     %
6627     % It is ok for the @heading series commands to appear inside an
6628     % environment (it's been historically allowed, though the logic is
6629     % dubious), but not the others.
6630     \ifx\temptype\Yomitfromtockeyword\else
6631       \checkenv{}% non-@*heading should not be in an environment.
6632     \fi
6633     \let\footnote=\errfootnoteheading
6634     %
6635     % Switch to the right set of fonts.
6636     \csname #2fonts\endcsname \rm
6637     %
6638     % Insert first mark before the heading break (see notes for \domark).
6639     \let\prevsectiondefs=\lastsectiondefs
6640     \ifx\temptype\Ynothingkeyword
6641       \ifx\sectionlevel\seckeyword
6642         \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6643                               \gdef\thissection{\thissectionname}}%
6644       \fi
6645     \else\ifx\temptype\Yomitfromtockeyword
6646       % Don't redefine \thissection.
6647     \else\ifx\temptype\Yappendixkeyword
6648       \ifx\sectionlevel\seckeyword
6649         \toks0={#1}%
6650         \xdef\lastsectiondefs{%
6651           \gdef\noexpand\thissectionname{\the\toks0}%
6652           \gdef\noexpand\thissectionnum{#4}%
6653           % \noexpand\putwordSection avoids expanding indigestible
6654           % commands in some of the translations.
6655           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6656                                      \noexpand\thissectionnum:
6657                                      \noexpand\thissectionname}%
6658         }%
6659       \fi
6660     \else
6661       \ifx\sectionlevel\seckeyword
6662         \toks0={#1}%
6663         \xdef\lastsectiondefs{%
6664           \gdef\noexpand\thissectionname{\the\toks0}%
6665           \gdef\noexpand\thissectionnum{#4}%
6666           % \noexpand\putwordSection avoids expanding indigestible
6667           % commands in some of the translations.
6668           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6669                                      \noexpand\thissectionnum:
6670                                      \noexpand\thissectionname}%
6671         }%
6672       \fi
6673     \fi\fi\fi
6674     %
6675     % Go into vertical mode.  Usually we'll already be there, but we
6676     % don't want the following whatsit to end up in a preceding paragraph
6677     % if the document didn't happen to have a blank line.
6678     \par
6679     %
6680     % Output the mark.  Pass it through \safewhatsit, to take care of
6681     % the preceding space.
6682     \safewhatsit\domark
6683     %
6684     % Insert space above the heading.
6685     \csname #2headingbreak\endcsname
6686     %
6687     % Now the second mark, after the heading break.  No break points
6688     % between here and the heading.
6689     \global\let\prevsectiondefs=\lastsectiondefs
6690     \domark
6691     %
6692     % Only insert the space after the number if we have a section number.
6693     \ifx\temptype\Ynothingkeyword
6694       \setbox0 = \hbox{}%
6695       \def\toctype{unn}%
6696       \gdef\lastsection{#1}%
6697     \else\ifx\temptype\Yomitfromtockeyword
6698       % for @headings -- no section number, don't include in toc,
6699       % and don't redefine \lastsection.
6700       \setbox0 = \hbox{}%
6701       \def\toctype{omit}%
6702       \let\sectionlevel=\empty
6703     \else\ifx\temptype\Yappendixkeyword
6704       \setbox0 = \hbox{#4\enspace}%
6705       \def\toctype{app}%
6706       \gdef\lastsection{#1}%
6707     \else
6708       \setbox0 = \hbox{#4\enspace}%
6709       \def\toctype{num}%
6710       \gdef\lastsection{#1}%
6711     \fi\fi\fi
6712     %
6713     % Write the toc entry (before \donoderef).  See comments in \chapmacro.
6714     \writetocentry{\toctype\sectionlevel}{#1}{#4}%
6715     %
6716     % Write the node reference (= pdf destination for pdftex).
6717     % Again, see comments in \chapmacro.
6718     \donoderef{#3}%
6719     %
6720     % Interline glue will be inserted when the vbox is completed.
6721     % That glue will be a valid breakpoint for the page, since it'll be
6722     % preceded by a whatsit (usually from the \donoderef, or from the
6723     % \writetocentry if there was no node).  We don't want to allow that
6724     % break, since then the whatsits could end up on page n while the
6725     % section is on page n+1, thus toc/etc. are wrong.  Debian bug 276000.
6726     \nobreak
6727     %
6728     % Output the actual section heading.
6729     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
6730           \hangindent=\wd0  % zero if no section number
6731           \unhbox0 #1}%
6732   }%
6733   % Add extra space after the heading -- half of whatever came above it.
6734   % Don't allow stretch, though.
6735   \kern .5 \csname #2headingskip\endcsname
6736   %
6737   % Do not let the kern be a potential breakpoint, as it would be if it
6738   % was followed by glue.
6739   \nobreak
6740   %
6741   % We'll almost certainly start a paragraph next, so don't let that
6742   % glue accumulate.  (Not a breakpoint because it's preceded by a
6743   % discardable item.)  However, when a paragraph is not started next
6744   % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6745   % or the negative glue will cause weirdly wrong output, typically
6746   % obscuring the section heading with something else.
6747   \vskip-\parskip
6748   %
6749   % This is so the last item on the main vertical list is a known
6750   % \penalty > 10000, so \startdefun, etc., can recognize the situation
6751   % and do the needful.
6752   \penalty 10001
6753 }
6754
6755
6756 \message{toc,}
6757 % Table of contents.
6758 \newwrite\tocfile
6759
6760 % Write an entry to the toc file, opening it if necessary.
6761 % Called from @chapter, etc.
6762 %
6763 % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6764 % We append the current node name (if any) and page number as additional
6765 % arguments for the \{chap,sec,...}entry macros which will eventually
6766 % read this.  The node name is used in the pdf outlines as the
6767 % destination to jump to.
6768 %
6769 % We open the .toc file for writing here instead of at @setfilename (or
6770 % any other fixed time) so that @contents can be anywhere in the document.
6771 % But if #1 is `omit', then we don't do anything.  This is used for the
6772 % table of contents chapter openings themselves.
6773 %
6774 \newif\iftocfileopened
6775 \def\omitkeyword{omit}%
6776 %
6777 \def\writetocentry#1#2#3{%
6778   \edef\writetoctype{#1}%
6779   \ifx\writetoctype\omitkeyword \else
6780     \iftocfileopened\else
6781       \immediate\openout\tocfile = \jobname.toc
6782       \global\tocfileopenedtrue
6783     \fi
6784     %
6785     \iflinks
6786       {\atdummies
6787        \edef\temp{%
6788          \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6789        \temp
6790       }%
6791     \fi
6792   \fi
6793   %
6794   % Tell \shipout to create a pdf destination on each page, if we're
6795   % writing pdf.  These are used in the table of contents.  We can't
6796   % just write one on every page because the title pages are numbered
6797   % 1 and 2 (the page numbers aren't printed), and so are the first
6798   % two pages of the document.  Thus, we'd have two destinations named
6799   % `1', and two named `2'.
6800   \ifpdf
6801     \global\pdfmakepagedesttrue
6802   \else
6803     \ifx\XeTeXrevision\thisisundefined
6804     \else
6805       \global\pdfmakepagedesttrue
6806     \fi
6807   \fi
6808 }
6809
6810
6811 % These characters do not print properly in the Computer Modern roman
6812 % fonts, so we must take special care.  This is more or less redundant
6813 % with the Texinfo input format setup at the end of this file.
6814 %
6815 \def\activecatcodes{%
6816   \catcode`\"=\active
6817   \catcode`\$=\active
6818   \catcode`\<=\active
6819   \catcode`\>=\active
6820   \catcode`\\=\active
6821   \catcode`\^=\active
6822   \catcode`\_=\active
6823   \catcode`\|=\active
6824   \catcode`\~=\active
6825 }
6826
6827
6828 % Read the toc file, which is essentially Texinfo input.
6829 \def\readtocfile{%
6830   \setupdatafile
6831   \activecatcodes
6832   \input \tocreadfilename
6833 }
6834
6835 \newskip\contentsrightmargin \contentsrightmargin=1in
6836 \newcount\savepageno
6837 \newcount\lastnegativepageno \lastnegativepageno = -1
6838
6839 % Prepare to read what we've written to \tocfile.
6840 %
6841 \def\startcontents#1{%
6842   % If @setchapternewpage on, and @headings double, the contents should
6843   % start on an odd page, unlike chapters.  Thus, we maintain
6844   % \contentsalignmacro in parallel with \pagealignmacro.
6845   % From: Torbjorn Granlund <tege@matematik.su.se>
6846   \contentsalignmacro
6847   \immediate\closeout\tocfile
6848   %
6849   % Don't need to put `Contents' or `Short Contents' in the headline.
6850   % It is abundantly clear what they are.
6851   \chapmacro{#1}{Yomitfromtoc}{}%
6852   %
6853   \savepageno = \pageno
6854   \begingroup                  % Set up to handle contents files properly.
6855     \raggedbottom              % Worry more about breakpoints than the bottom.
6856     \entryrightmargin=\contentsrightmargin % Don't use the full line length.
6857     %
6858     % Roman numerals for page numbers.
6859     \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
6860 }
6861
6862 % redefined for the two-volume lispref.  We always output on
6863 % \jobname.toc even if this is redefined.
6864 %
6865 \def\tocreadfilename{\jobname.toc}
6866
6867 % Normal (long) toc.
6868 %
6869 \def\contents{%
6870   \startcontents{\putwordTOC}%
6871     \openin 1 \tocreadfilename\space
6872     \ifeof 1 \else
6873       \readtocfile
6874     \fi
6875     \vfill \eject
6876     \contentsalignmacro % in case @setchapternewpage odd is in effect
6877     \ifeof 1 \else
6878       \pdfmakeoutlines
6879     \fi
6880     \closein 1
6881   \endgroup
6882   \lastnegativepageno = \pageno
6883   \global\pageno = \savepageno
6884 }
6885
6886 % And just the chapters.
6887 \def\summarycontents{%
6888   \startcontents{\putwordShortTOC}%
6889     %
6890     \let\partentry = \shortpartentry
6891     \let\numchapentry = \shortchapentry
6892     \let\appentry = \shortchapentry
6893     \let\unnchapentry = \shortunnchapentry
6894     % We want a true roman here for the page numbers.
6895     \secfonts
6896     \let\rm=\shortcontrm \let\bf=\shortcontbf
6897     \let\sl=\shortcontsl \let\tt=\shortconttt
6898     \rm
6899     \hyphenpenalty = 10000
6900     \advance\baselineskip by 1pt % Open it up a little.
6901     \def\numsecentry##1##2##3##4{}
6902     \let\appsecentry = \numsecentry
6903     \let\unnsecentry = \numsecentry
6904     \let\numsubsecentry = \numsecentry
6905     \let\appsubsecentry = \numsecentry
6906     \let\unnsubsecentry = \numsecentry
6907     \let\numsubsubsecentry = \numsecentry
6908     \let\appsubsubsecentry = \numsecentry
6909     \let\unnsubsubsecentry = \numsecentry
6910     \openin 1 \tocreadfilename\space
6911     \ifeof 1 \else
6912       \readtocfile
6913     \fi
6914     \closein 1
6915     \vfill \eject
6916     \contentsalignmacro % in case @setchapternewpage odd is in effect
6917   \endgroup
6918   \lastnegativepageno = \pageno
6919   \global\pageno = \savepageno
6920 }
6921 \let\shortcontents = \summarycontents
6922
6923 % Typeset the label for a chapter or appendix for the short contents.
6924 % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6925 %
6926 \def\shortchaplabel#1{%
6927   % This space should be enough, since a single number is .5em, and the
6928   % widest letter (M) is 1em, at least in the Computer Modern fonts.
6929   % But use \hss just in case.
6930   % (This space doesn't include the extra space that gets added after
6931   % the label; that gets put in by \shortchapentry above.)
6932   %
6933   % We'd like to right-justify chapter numbers, but that looks strange
6934   % with appendix letters.  And right-justifying numbers and
6935   % left-justifying letters looks strange when there is less than 10
6936   % chapters.  Have to read the whole toc once to know how many chapters
6937   % there are before deciding ...
6938   \hbox to 1em{#1\hss}%
6939 }
6940
6941 % These macros generate individual entries in the table of contents.
6942 % The first argument is the chapter or section name.
6943 % The last argument is the page number.
6944 % The arguments in between are the chapter number, section number, ...
6945
6946 % Parts, in the main contents.  Replace the part number, which doesn't
6947 % exist, with an empty box.  Let's hope all the numbers have the same width.
6948 % Also ignore the page number, which is conventionally not printed.
6949 \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6950 \def\partentry#1#2#3#4{%
6951   % Add stretch and a bonus for breaking the page before the part heading.
6952   % This reduces the chance of the page being broken immediately after the
6953   % part heading, before a following chapter heading.
6954   \vskip 0pt plus 5\baselineskip
6955   \penalty-300
6956   \vskip 0pt plus -5\baselineskip
6957   \dochapentry{\numeralbox\labelspace#1}{}%
6958 }
6959 %
6960 % Parts, in the short toc.
6961 \def\shortpartentry#1#2#3#4{%
6962   \penalty-300
6963   \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
6964   \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
6965 }
6966
6967 % Chapters, in the main contents.
6968 \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
6969
6970 % Chapters, in the short toc.
6971 % See comments in \dochapentry re vbox and related settings.
6972 \def\shortchapentry#1#2#3#4{%
6973   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
6974 }
6975
6976 % Appendices, in the main contents.
6977 % Need the word Appendix, and a fixed-size box.
6978 %
6979 \def\appendixbox#1{%
6980   % We use M since it's probably the widest letter.
6981   \setbox0 = \hbox{\putwordAppendix{} M}%
6982   \hbox to \wd0{\putwordAppendix{} #1\hss}}
6983 %
6984 \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
6985
6986 % Unnumbered chapters.
6987 \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
6988 \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
6989
6990 % Sections.
6991 \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
6992 \let\appsecentry=\numsecentry
6993 \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
6994
6995 % Subsections.
6996 \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
6997 \let\appsubsecentry=\numsubsecentry
6998 \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
6999
7000 % And subsubsections.
7001 \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
7002 \let\appsubsubsecentry=\numsubsubsecentry
7003 \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
7004
7005 % This parameter controls the indentation of the various levels.
7006 % Same as \defaultparindent.
7007 \newdimen\tocindent \tocindent = 15pt
7008
7009 % Now for the actual typesetting. In all these, #1 is the text and #2 is the
7010 % page number.
7011 %
7012 % If the toc has to be broken over pages, we want it to be at chapters
7013 % if at all possible; hence the \penalty.
7014 \def\dochapentry#1#2{%
7015    \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
7016    \begingroup
7017      % Move the page numbers slightly to the right
7018      \advance\entryrightmargin by -0.05em
7019      \chapentryfonts
7020      \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7021    \endgroup
7022    \nobreak\vskip .25\baselineskip plus.1\baselineskip
7023 }
7024
7025 \def\dosecentry#1#2{\begingroup
7026   \secentryfonts \leftskip=\tocindent
7027   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7028 \endgroup}
7029
7030 \def\dosubsecentry#1#2{\begingroup
7031   \subsecentryfonts \leftskip=2\tocindent
7032   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7033 \endgroup}
7034
7035 \def\dosubsubsecentry#1#2{\begingroup
7036   \subsubsecentryfonts \leftskip=3\tocindent
7037   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7038 \endgroup}
7039
7040 % We use the same \entry macro as for the index entries.
7041 \let\tocentry = \entry
7042
7043 % Space between chapter (or whatever) number and the title.
7044 \def\labelspace{\hskip1em \relax}
7045
7046 \def\dopageno#1{{\rm #1}}
7047 \def\doshortpageno#1{{\rm #1}}
7048
7049 \def\chapentryfonts{\secfonts \rm}
7050 \def\secentryfonts{\textfonts}
7051 \def\subsecentryfonts{\textfonts}
7052 \def\subsubsecentryfonts{\textfonts}
7053
7054
7055 \message{environments,}
7056 % @foo ... @end foo.
7057
7058 % @tex ... @end tex    escapes into raw TeX temporarily.
7059 % One exception: @ is still an escape character, so that @end tex works.
7060 % But \@ or @@ will get a plain @ character.
7061
7062 \envdef\tex{%
7063   \setupmarkupstyle{tex}%
7064   \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
7065   \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
7066   \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
7067   \catcode `\%=14
7068   \catcode `\+=\other
7069   \catcode `\"=\other
7070   \catcode `\|=\other
7071   \catcode `\<=\other
7072   \catcode `\>=\other
7073   \catcode `\`=\other
7074   \catcode `\'=\other
7075   %
7076   % ' is active in math mode (mathcode"8000).  So reset it, and all our
7077   % other math active characters (just in case), to plain's definitions.
7078   \mathactive
7079   %
7080   % Inverse of the list at the beginning of the file.
7081   \let\b=\ptexb
7082   \let\bullet=\ptexbullet
7083   \let\c=\ptexc
7084   \let\,=\ptexcomma
7085   \let\.=\ptexdot
7086   \let\dots=\ptexdots
7087   \let\equiv=\ptexequiv
7088   \let\!=\ptexexclam
7089   \let\i=\ptexi
7090   \let\indent=\ptexindent
7091   \let\noindent=\ptexnoindent
7092   \let\{=\ptexlbrace
7093   \let\+=\tabalign
7094   \let\}=\ptexrbrace
7095   \let\/=\ptexslash
7096   \let\sp=\ptexsp
7097   \let\*=\ptexstar
7098   %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
7099   \let\t=\ptext
7100   \expandafter \let\csname top\endcsname=\ptextop  % we've made it outer
7101   \let\frenchspacing=\plainfrenchspacing
7102   %
7103   \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
7104   \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
7105   \def\@{@}%
7106 }
7107 % There is no need to define \Etex.
7108
7109 % Define @lisp ... @end lisp.
7110 % @lisp environment forms a group so it can rebind things,
7111 % including the definition of @end lisp (which normally is erroneous).
7112
7113 % Amount to narrow the margins by for @lisp.
7114 \newskip\lispnarrowing \lispnarrowing=0.4in
7115
7116 % This is the definition that ^^M gets inside @lisp, @example, and other
7117 % such environments.  \null is better than a space, since it doesn't
7118 % have any width.
7119 \def\lisppar{\null\endgraf}
7120
7121 % This space is always present above and below environments.
7122 \newskip\envskipamount \envskipamount = 0pt
7123
7124 % Make spacing and below environment symmetrical.  We use \parskip here
7125 % to help in doing that, since in @example-like environments \parskip
7126 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
7127 % start of the next paragraph will insert \parskip.
7128 %
7129 \def\aboveenvbreak{{%
7130   % =10000 instead of <10000 because of a special case in \itemzzz and
7131   % \sectionheading, q.v.
7132   \ifnum \lastpenalty=10000 \else
7133     \advance\envskipamount by \parskip
7134     \endgraf
7135     \ifdim\lastskip<\envskipamount
7136       \removelastskip
7137       \ifnum\lastpenalty<10000
7138         % Penalize breaking before the environment, because preceding text
7139         % often leads into it.
7140         \penalty100
7141       \fi
7142       \vskip\envskipamount
7143     \fi
7144   \fi
7145 }}
7146
7147 \def\afterenvbreak{{%
7148   % =10000 instead of <10000 because of a special case in \itemzzz and
7149   % \sectionheading, q.v.
7150   \ifnum \lastpenalty=10000 \else
7151     \advance\envskipamount by \parskip
7152     \endgraf
7153     \ifdim\lastskip<\envskipamount
7154       \removelastskip
7155       % it's not a good place to break if the last penalty was \nobreak
7156       % or better ...
7157       \ifnum\lastpenalty<10000 \penalty-50 \fi
7158       \vskip\envskipamount
7159     \fi
7160   \fi
7161 }}
7162
7163 % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins; it will
7164 % also clear it, so that its embedded environments do the narrowing again.
7165 \let\nonarrowing=\relax
7166
7167 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
7168 % environment contents.
7169 \font\circle=lcircle10
7170 \newdimen\circthick
7171 \newdimen\cartouter\newdimen\cartinner
7172 \newskip\normbskip\newskip\normpskip\newskip\normlskip
7173 \circthick=\fontdimen8\circle
7174 %
7175 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
7176 \def\ctr{{\hskip 6pt\circle\char'010}}
7177 \def\cbl{{\circle\char'012\hskip -6pt}}
7178 \def\cbr{{\hskip 6pt\circle\char'011}}
7179 \def\carttop{\hbox to \cartouter{\hskip\lskip
7180         \ctl\leaders\hrule height\circthick\hfil\ctr
7181         \hskip\rskip}}
7182 \def\cartbot{\hbox to \cartouter{\hskip\lskip
7183         \cbl\leaders\hrule height\circthick\hfil\cbr
7184         \hskip\rskip}}
7185 %
7186 \newskip\lskip\newskip\rskip
7187
7188 \envdef\cartouche{%
7189   \ifhmode\par\fi  % can't be in the midst of a paragraph.
7190   \startsavinginserts
7191   \lskip=\leftskip \rskip=\rightskip
7192   \leftskip=0pt\rightskip=0pt % we want these *outside*.
7193   \cartinner=\hsize \advance\cartinner by-\lskip
7194   \advance\cartinner by-\rskip
7195   \cartouter=\hsize
7196   \advance\cartouter by 18.4pt  % allow for 3pt kerns on either
7197                                 % side, and for 6pt waste from
7198                                 % each corner char, and rule thickness
7199   \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
7200   %
7201   % If this cartouche directly follows a sectioning command, we need the
7202   % \parskip glue (backspaced over by default) or the cartouche can
7203   % collide with the section heading.
7204   \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
7205   %
7206   \setbox\groupbox=\vbox\bgroup
7207       \baselineskip=0pt\parskip=0pt\lineskip=0pt
7208       \carttop
7209       \hbox\bgroup
7210           \hskip\lskip
7211           \vrule\kern3pt
7212           \vbox\bgroup
7213               \kern3pt
7214               \hsize=\cartinner
7215               \baselineskip=\normbskip
7216               \lineskip=\normlskip
7217               \parskip=\normpskip
7218               \vskip -\parskip
7219               \comment % For explanation, see the end of def\group.
7220 }
7221 \def\Ecartouche{%
7222               \ifhmode\par\fi
7223               \kern3pt
7224           \egroup
7225           \kern3pt\vrule
7226           \hskip\rskip
7227       \egroup
7228       \cartbot
7229   \egroup
7230   \addgroupbox
7231   \checkinserts
7232 }
7233
7234
7235 % This macro is called at the beginning of all the @example variants,
7236 % inside a group.
7237 \newdimen\nonfillparindent
7238 \def\nonfillstart{%
7239   \aboveenvbreak
7240   \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
7241   \sepspaces % Make spaces be word-separators rather than space tokens.
7242   \let\par = \lisppar % don't ignore blank lines
7243   \obeylines % each line of input is a line of output
7244   \parskip = 0pt
7245   % Turn off paragraph indentation but redefine \indent to emulate
7246   % the normal \indent.
7247   \nonfillparindent=\parindent
7248   \parindent = 0pt
7249   \let\indent\nonfillindent
7250   %
7251   \emergencystretch = 0pt % don't try to avoid overfull boxes
7252   \ifx\nonarrowing\relax
7253     \advance \leftskip by \lispnarrowing
7254     \exdentamount=\lispnarrowing
7255   \else
7256     \let\nonarrowing = \relax
7257   \fi
7258   \let\exdent=\nofillexdent
7259 }
7260
7261 \begingroup
7262 \obeyspaces
7263 % We want to swallow spaces (but not other tokens) after the fake
7264 % @indent in our nonfill-environments, where spaces are normally
7265 % active and set to @tie, resulting in them not being ignored after
7266 % @indent.
7267 \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
7268 \gdef\nonfillindentcheck{%
7269 \ifx\temp %
7270 \expandafter\nonfillindentgobble%
7271 \else%
7272 \leavevmode\nonfillindentbox%
7273 \fi%
7274 }%
7275 \endgroup
7276 \def\nonfillindentgobble#1{\nonfillindent}
7277 \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7278
7279 % If you want all examples etc. small: @set dispenvsize small.
7280 % If you want even small examples the full size: @set dispenvsize nosmall.
7281 % This affects the following displayed environments:
7282 %    @example, @display, @format, @lisp
7283 %
7284 \def\smallword{small}
7285 \def\nosmallword{nosmall}
7286 \let\SETdispenvsize\relax
7287 \def\setnormaldispenv{%
7288   \ifx\SETdispenvsize\smallword
7289     % end paragraph for sake of leading, in case document has no blank
7290     % line.  This is redundant with what happens in \aboveenvbreak, but
7291     % we need to do it before changing the fonts, and it's inconvenient
7292     % to change the fonts afterward.
7293     \ifnum \lastpenalty=10000 \else \endgraf \fi
7294     \smallexamplefonts \rm
7295   \fi
7296 }
7297 \def\setsmalldispenv{%
7298   \ifx\SETdispenvsize\nosmallword
7299   \else
7300     \ifnum \lastpenalty=10000 \else \endgraf \fi
7301     \smallexamplefonts \rm
7302   \fi
7303 }
7304
7305 % We often define two environments, @foo and @smallfoo.
7306 % Let's do it in one command.  #1 is the env name, #2 the definition.
7307 \def\makedispenvdef#1#2{%
7308   \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7309   \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
7310   \expandafter\let\csname E#1\endcsname \afterenvbreak
7311   \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
7312 }
7313
7314 % Define two environment synonyms (#1 and #2) for an environment.
7315 \def\maketwodispenvdef#1#2#3{%
7316   \makedispenvdef{#1}{#3}%
7317   \makedispenvdef{#2}{#3}%
7318 }
7319 %
7320 % @lisp: indented, narrowed, typewriter font;
7321 % @example: same as @lisp.
7322 %
7323 % @smallexample and @smalllisp: use smaller fonts.
7324 % Originally contributed by Pavel@xerox.
7325 %
7326 \maketwodispenvdef{lisp}{example}{%
7327   \nonfillstart
7328   \tt\setupmarkupstyle{example}%
7329   \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
7330   \gobble % eat return
7331 }
7332 % @display/@smalldisplay: same as @lisp except keep current font.
7333 %
7334 \makedispenvdef{display}{%
7335   \nonfillstart
7336   \gobble
7337 }
7338
7339 % @format/@smallformat: same as @display except don't narrow margins.
7340 %
7341 \makedispenvdef{format}{%
7342   \let\nonarrowing = t%
7343   \nonfillstart
7344   \gobble
7345 }
7346
7347 % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7348 \envdef\flushleft{%
7349   \let\nonarrowing = t%
7350   \nonfillstart
7351   \gobble
7352 }
7353 \let\Eflushleft = \afterenvbreak
7354
7355 % @flushright.
7356 %
7357 \envdef\flushright{%
7358   \let\nonarrowing = t%
7359   \nonfillstart
7360   \advance\leftskip by 0pt plus 1fill\relax
7361   \gobble
7362 }
7363 \let\Eflushright = \afterenvbreak
7364
7365
7366 % @raggedright does more-or-less normal line breaking but no right
7367 % justification.  From plain.tex.  Don't stretch around special
7368 % characters in urls in this environment, since the stretch at the right
7369 % should be enough.
7370 \envdef\raggedright{%
7371   \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7372   \def\urefprestretchamount{0pt}%
7373   \def\urefpoststretchamount{0pt}%
7374 }
7375 \let\Eraggedright\par
7376
7377 \envdef\raggedleft{%
7378   \parindent=0pt \leftskip0pt plus2em
7379   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7380   \hbadness=10000 % Last line will usually be underfull, so turn off
7381                   % badness reporting.
7382 }
7383 \let\Eraggedleft\par
7384
7385 \envdef\raggedcenter{%
7386   \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
7387   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7388   \hbadness=10000 % Last line will usually be underfull, so turn off
7389                   % badness reporting.
7390 }
7391 \let\Eraggedcenter\par
7392
7393
7394 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
7395 % and narrows the margins.  We keep \parskip nonzero in general, since
7396 % we're doing normal filling.  So, when using \aboveenvbreak and
7397 % \afterenvbreak, temporarily make \parskip 0.
7398 %
7399 \makedispenvdef{quotation}{\quotationstart}
7400 %
7401 \def\quotationstart{%
7402   \indentedblockstart % same as \indentedblock, but increase right margin too.
7403   \ifx\nonarrowing\relax
7404     \advance\rightskip by \lispnarrowing
7405   \fi
7406   \parsearg\quotationlabel
7407 }
7408
7409 % We have retained a nonzero parskip for the environment, since we're
7410 % doing normal filling.
7411 %
7412 \def\Equotation{%
7413   \par
7414   \ifx\quotationauthor\thisisundefined\else
7415     % indent a bit.
7416     \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7417   \fi
7418   {\parskip=0pt \afterenvbreak}%
7419 }
7420 \def\Esmallquotation{\Equotation}
7421
7422 % If we're given an argument, typeset it in bold with a colon after.
7423 \def\quotationlabel#1{%
7424   \def\temp{#1}%
7425   \ifx\temp\empty \else
7426     {\bf #1: }%
7427   \fi
7428 }
7429
7430 % @indentedblock is like @quotation, but indents only on the left and
7431 % has no optional argument.
7432
7433 \makedispenvdef{indentedblock}{\indentedblockstart}
7434 %
7435 \def\indentedblockstart{%
7436   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7437   \parindent=0pt
7438   %
7439   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7440   \ifx\nonarrowing\relax
7441     \advance\leftskip by \lispnarrowing
7442     \exdentamount = \lispnarrowing
7443   \else
7444     \let\nonarrowing = \relax
7445   \fi
7446 }
7447
7448 % Keep a nonzero parskip for the environment, since we're doing normal filling.
7449 %
7450 \def\Eindentedblock{%
7451   \par
7452   {\parskip=0pt \afterenvbreak}%
7453 }
7454 \def\Esmallindentedblock{\Eindentedblock}
7455
7456
7457 % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7458 % If we want to allow any <char> as delimiter,
7459 % we need the curly braces so that makeinfo sees the @verb command, eg:
7460 % `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
7461 %
7462 % [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
7463 %
7464 % [Knuth] p.344; only we need to do the other characters Texinfo sets
7465 % active too.  Otherwise, they get lost as the first character on a
7466 % verbatim line.
7467 \def\dospecials{%
7468   \do\ \do\\\do\{\do\}\do\$\do\&%
7469   \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7470   \do\<\do\>\do\|\do\@\do+\do\"%
7471   % Don't do the quotes -- if we do, @set txicodequoteundirected and
7472   % @set txicodequotebacktick will not have effect on @verb and
7473   % @verbatim, and ?` and !` ligatures won't get disabled.
7474   %\do\`\do\'%
7475 }
7476 %
7477 % [Knuth] p. 380
7478 \def\uncatcodespecials{%
7479   \def\do##1{\catcode`##1=\other}\dospecials}
7480 %
7481 % Setup for the @verb command.
7482 %
7483 % Eight spaces for a tab
7484 \begingroup
7485   \catcode`\^^I=\active
7486   \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7487 \endgroup
7488 %
7489 \def\setupverb{%
7490   \tt  % easiest (and conventionally used) font for verbatim
7491   \def\par{\leavevmode\endgraf}%
7492   \setupmarkupstyle{verb}%
7493   \tabeightspaces
7494   % Respect line breaks,
7495   % print special symbols as themselves, and
7496   % make each space count
7497   % must do in this order:
7498   \obeylines \uncatcodespecials \sepspaces
7499 }
7500
7501 % Setup for the @verbatim environment
7502 %
7503 % Real tab expansion.
7504 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7505 %
7506 % We typeset each line of the verbatim in an \hbox, so we can handle
7507 % tabs.  The \global is in case the verbatim line starts with an accent,
7508 % or some other command that starts with a begin-group.  Otherwise, the
7509 % entire \verbbox would disappear at the corresponding end-group, before
7510 % it is typeset.  Meanwhile, we can't have nested verbatim commands
7511 % (can we?), so the \global won't be overwriting itself.
7512 \newbox\verbbox
7513 \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
7514 %
7515 \begingroup
7516   \catcode`\^^I=\active
7517   \gdef\tabexpand{%
7518     \catcode`\^^I=\active
7519     \def^^I{\leavevmode\egroup
7520       \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7521       \divide\dimen\verbbox by\tabw
7522       \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7523       \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
7524       \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
7525     }%
7526   }
7527 \endgroup
7528
7529 % start the verbatim environment.
7530 \def\setupverbatim{%
7531   \let\nonarrowing = t%
7532   \nonfillstart
7533   \tt % easiest (and conventionally used) font for verbatim
7534   % The \leavevmode here is for blank lines.  Otherwise, we would
7535   % never \starttabox and the \egroup would end verbatim mode.
7536   \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
7537   \tabexpand
7538   \setupmarkupstyle{verbatim}%
7539   % Respect line breaks,
7540   % print special symbols as themselves, and
7541   % make each space count.
7542   % Must do in this order:
7543   \obeylines \uncatcodespecials \sepspaces
7544   \everypar{\starttabbox}%
7545 }
7546
7547 % Do the @verb magic: verbatim text is quoted by unique
7548 % delimiter characters.  Before first delimiter expect a
7549 % right brace, after last delimiter expect closing brace:
7550 %
7551 %    \def\doverb'{'<char>#1<char>'}'{#1}
7552 %
7553 % [Knuth] p. 382; only eat outer {}
7554 \begingroup
7555   \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
7556   \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7557 \endgroup
7558 %
7559 \def\verb{\begingroup\setupverb\doverb}
7560 %
7561 %
7562 % Do the @verbatim magic: define the macro \doverbatim so that
7563 % the (first) argument ends when '@end verbatim' is reached, ie:
7564 %
7565 %     \def\doverbatim#1@end verbatim{#1}
7566 %
7567 % For Texinfo it's a lot easier than for LaTeX,
7568 % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
7569 % we need not redefine '\', '{' and '}'.
7570 %
7571 % Inspired by LaTeX's verbatim command set [latex.ltx]
7572 %
7573 \begingroup
7574   \catcode`\ =\active
7575   \obeylines %
7576   % ignore everything up to the first ^^M, that's the newline at the end
7577   % of the @verbatim input line itself.  Otherwise we get an extra blank
7578   % line in the output.
7579   \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
7580   % We really want {...\end verbatim} in the body of the macro, but
7581   % without the active space; thus we have to use \xdef and \gobble.
7582 \endgroup
7583 %
7584 \envdef\verbatim{%
7585     \setupverbatim\doverbatim
7586 }
7587 \let\Everbatim = \afterenvbreak
7588
7589
7590 % @verbatiminclude FILE - insert text of file in verbatim environment.
7591 %
7592 \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
7593 %
7594 \def\doverbatiminclude#1{%
7595   {%
7596     \makevalueexpandable
7597     \setupverbatim
7598     \indexnofonts       % Allow `@@' and other weird things in file names.
7599     \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
7600     \input #1
7601     \afterenvbreak
7602   }%
7603 }
7604
7605 % @copying ... @end copying.
7606 % Save the text away for @insertcopying later.
7607 %
7608 % We save the uninterpreted tokens, rather than creating a box.
7609 % Saving the text in a box would be much easier, but then all the
7610 % typesetting commands (@smallbook, font changes, etc.) have to be done
7611 % beforehand -- and a) we want @copying to be done first in the source
7612 % file; b) letting users define the frontmatter in as flexible order as
7613 % possible is desirable.
7614 %
7615 \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
7616 \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
7617 %
7618 \def\insertcopying{%
7619   \begingroup
7620     \parindent = 0pt  % paragraph indentation looks wrong on title page
7621     \scanexp\copyingtext
7622   \endgroup
7623 }
7624
7625
7626 \message{defuns,}
7627 % @defun etc.
7628
7629 \newskip\defbodyindent \defbodyindent=.4in
7630 \newskip\defargsindent \defargsindent=50pt
7631 \newskip\deflastargmargin \deflastargmargin=18pt
7632 \newcount\defunpenalty
7633
7634 % Start the processing of @deffn:
7635 \def\startdefun{%
7636   \ifnum\lastpenalty<10000
7637     \medbreak
7638     \defunpenalty=10003 % Will keep this @deffn together with the
7639                         % following @def command, see below.
7640   \else
7641     % If there are two @def commands in a row, we'll have a \nobreak,
7642     % which is there to keep the function description together with its
7643     % header.  But if there's nothing but headers, we need to allow a
7644     % break somewhere.  Check specifically for penalty 10002, inserted
7645     % by \printdefunline, instead of 10000, since the sectioning
7646     % commands also insert a nobreak penalty, and we don't want to allow
7647     % a break between a section heading and a defun.
7648     %
7649     % As a further refinement, we avoid "club" headers by signalling
7650     % with penalty of 10003 after the very first @deffn in the
7651     % sequence (see above), and penalty of 10002 after any following
7652     % @def command.
7653     \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
7654     %
7655     % Similarly, after a section heading, do not allow a break.
7656     % But do insert the glue.
7657     \medskip  % preceded by discardable penalty, so not a breakpoint
7658   \fi
7659   %
7660   \parindent=0in
7661   \advance\leftskip by \defbodyindent
7662   \exdentamount=\defbodyindent
7663 }
7664
7665 \def\dodefunx#1{%
7666   % First, check whether we are in the right environment:
7667   \checkenv#1%
7668   %
7669   % As above, allow line break if we have multiple x headers in a row.
7670   % It's not a great place, though.
7671   \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
7672   %
7673   % And now, it's time to reuse the body of the original defun:
7674   \expandafter\gobbledefun#1%
7675 }
7676 \def\gobbledefun#1\startdefun{}
7677
7678 % \printdefunline \deffnheader{text}
7679 %
7680 \def\printdefunline#1#2{%
7681   \begingroup
7682     % call \deffnheader:
7683     #1#2 \endheader
7684     % common ending:
7685     \interlinepenalty = 10000
7686     \advance\rightskip by 0pt plus 1fil\relax
7687     \endgraf
7688     \nobreak\vskip -\parskip
7689     \penalty\defunpenalty  % signal to \startdefun and \dodefunx
7690     % Some of the @defun-type tags do not enable magic parentheses,
7691     % rendering the following check redundant.  But we don't optimize.
7692     \checkparencounts
7693   \endgroup
7694 }
7695
7696 \def\Edefun{\endgraf\medbreak}
7697
7698 % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
7699 % the only thing remaining is to define \deffnheader.
7700 %
7701 \def\makedefun#1{%
7702   \expandafter\let\csname E#1\endcsname = \Edefun
7703   \edef\temp{\noexpand\domakedefun
7704     \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7705   \temp
7706 }
7707
7708 % \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
7709 %
7710 % Define \deffn and \deffnx, without parameters.
7711 % \deffnheader has to be defined explicitly.
7712 %
7713 \def\domakedefun#1#2#3{%
7714   \envdef#1{%
7715     \startdefun
7716     \doingtypefnfalse    % distinguish typed functions from all else
7717     \parseargusing\activeparens{\printdefunline#3}%
7718   }%
7719   \def#2{\dodefunx#1}%
7720   \def#3%
7721 }
7722
7723 \newif\ifdoingtypefn       % doing typed function?
7724 \newif\ifrettypeownline    % typeset return type on its own line?
7725
7726 % @deftypefnnewline on|off says whether the return type of typed functions
7727 % are printed on their own line.  This affects @deftypefn, @deftypefun,
7728 % @deftypeop, and @deftypemethod.
7729
7730 \parseargdef\deftypefnnewline{%
7731   \def\temp{#1}%
7732   \ifx\temp\onword
7733     \expandafter\let\csname SETtxideftypefnnl\endcsname
7734       = \empty
7735   \else\ifx\temp\offword
7736     \expandafter\let\csname SETtxideftypefnnl\endcsname
7737       = \relax
7738   \else
7739     \errhelp = \EMsimple
7740     \errmessage{Unknown @txideftypefnnl value `\temp',
7741                 must be on|off}%
7742   \fi\fi
7743 }
7744
7745 % Untyped functions:
7746
7747 % @deffn category name args
7748 \makedefun{deffn}{\deffngeneral{}}
7749
7750 % @deffn category class name args
7751 \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
7752
7753 % \defopon {category on}class name args
7754 \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7755
7756 % \deffngeneral {subind}category name args
7757 %
7758 \def\deffngeneral#1#2 #3 #4\endheader{%
7759   % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
7760   \dosubind{fn}{\code{#3}}{#1}%
7761   \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
7762 }
7763
7764 % Typed functions:
7765
7766 % @deftypefn category type name args
7767 \makedefun{deftypefn}{\deftypefngeneral{}}
7768
7769 % @deftypeop category class type name args
7770 \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
7771
7772 % \deftypeopon {category on}class type name args
7773 \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7774
7775 % \deftypefngeneral {subind}category type name args
7776 %
7777 \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
7778   \dosubind{fn}{\code{#4}}{#1}%
7779   \doingtypefntrue
7780   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7781 }
7782
7783 % Typed variables:
7784
7785 % @deftypevr category type var args
7786 \makedefun{deftypevr}{\deftypecvgeneral{}}
7787
7788 % @deftypecv category class type var args
7789 \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
7790
7791 % \deftypecvof {category of}class type var args
7792 \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
7793
7794 % \deftypecvgeneral {subind}category type var args
7795 %
7796 \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
7797   \dosubind{vr}{\code{#4}}{#1}%
7798   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7799 }
7800
7801 % Untyped variables:
7802
7803 % @defvr category var args
7804 \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
7805
7806 % @defcv category class var args
7807 \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
7808
7809 % \defcvof {category of}class var args
7810 \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
7811
7812 % Types:
7813
7814 % @deftp category name args
7815 \makedefun{deftp}#1 #2 #3\endheader{%
7816   \doind{tp}{\code{#2}}%
7817   \defname{#1}{}{#2}\defunargs{#3\unskip}%
7818 }
7819
7820 % Remaining @defun-like shortcuts:
7821 \makedefun{defun}{\deffnheader{\putwordDeffunc} }
7822 \makedefun{defmac}{\deffnheader{\putwordDefmac} }
7823 \makedefun{defspec}{\deffnheader{\putwordDefspec} }
7824 \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7825 \makedefun{defvar}{\defvrheader{\putwordDefvar} }
7826 \makedefun{defopt}{\defvrheader{\putwordDefopt} }
7827 \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
7828 \makedefun{defmethod}{\defopon\putwordMethodon}
7829 \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
7830 \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
7831 \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
7832
7833 % \defname, which formats the name of the @def (not the args).
7834 % #1 is the category, such as "Function".
7835 % #2 is the return type, if any.
7836 % #3 is the function name.
7837 %
7838 % We are followed by (but not passed) the arguments, if any.
7839 %
7840 \def\defname#1#2#3{%
7841   \par
7842   % Get the values of \leftskip and \rightskip as they were outside the @def...
7843   \advance\leftskip by -\defbodyindent
7844   %
7845   % Determine if we are typesetting the return type of a typed function
7846   % on a line by itself.
7847   \rettypeownlinefalse
7848   \ifdoingtypefn  % doing a typed function specifically?
7849     % then check user option for putting return type on its own line:
7850     \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
7851       \rettypeownlinetrue
7852     \fi
7853   \fi
7854   %
7855   % How we'll format the category name.  Putting it in brackets helps
7856   % distinguish it from the body text that may end up on the next line
7857   % just below it.
7858   \def\temp{#1}%
7859   \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7860   %
7861   % Figure out line sizes for the paragraph shape.  We'll always have at
7862   % least two.
7863   \tempnum = 2
7864   %
7865   % The first line needs space for \box0; but if \rightskip is nonzero,
7866   % we need only space for the part of \box0 which exceeds it:
7867   \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
7868   %
7869   % If doing a return type on its own line, we'll have another line.
7870   \ifrettypeownline
7871     \advance\tempnum by 1
7872     \def\maybeshapeline{0in \hsize}%
7873   \else
7874     \def\maybeshapeline{}%
7875   \fi
7876   %
7877   % The continuations:
7878   \dimen2=\hsize  \advance\dimen2 by -\defargsindent
7879   %
7880   % The final paragraph shape:
7881   \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
7882   %
7883   % Put the category name at the right margin.
7884   \noindent
7885   \hbox to 0pt{%
7886     \hfil\box0 \kern-\hsize
7887     % \hsize has to be shortened this way:
7888     \kern\leftskip
7889     % Intentionally do not respect \rightskip, since we need the space.
7890   }%
7891   %
7892   % Allow all lines to be underfull without complaint:
7893   \tolerance=10000 \hbadness=10000
7894   \exdentamount=\defbodyindent
7895   {%
7896     % defun fonts. We use typewriter by default (used to be bold) because:
7897     % . we're printing identifiers, they should be in tt in principle.
7898     % . in languages with many accents, such as Czech or French, it's
7899     %   common to leave accents off identifiers.  The result looks ok in
7900     %   tt, but exceedingly strange in rm.
7901     % . we don't want -- and --- to be treated as ligatures.
7902     % . this still does not fix the ?` and !` ligatures, but so far no
7903     %   one has made identifiers using them :).
7904     \df \tt
7905     \def\temp{#2}% text of the return type
7906     \ifx\temp\empty\else
7907       \tclose{\temp}% typeset the return type
7908       \ifrettypeownline
7909         % put return type on its own line; prohibit line break following:
7910         \hfil\vadjust{\nobreak}\break  
7911       \else
7912         \space  % type on same line, so just followed by a space
7913       \fi
7914     \fi           % no return type
7915     #3% output function name
7916   }%
7917   {\rm\enskip}% hskip 0.5 em of \rmfont
7918   %
7919   \boldbrax
7920   % arguments will be output next, if any.
7921 }
7922
7923 % Print arguments in slanted roman (not ttsl), inconsistently with using
7924 % tt for the name.  This is because literal text is sometimes needed in
7925 % the argument list (groff manual), and ttsl and tt are not very
7926 % distinguishable.  Prevent hyphenation at `-' chars.
7927 %
7928 \def\defunargs#1{%
7929   % use sl by default (not ttsl),
7930   % tt for the names.
7931   \df \sl \hyphenchar\font=0
7932   %
7933   % On the other hand, if an argument has two dashes (for instance), we
7934   % want a way to get ttsl.  We used to recommend @var for that, so
7935   % leave the code in, but it's strange for @var to lead to typewriter.
7936   % Nowadays we recommend @code, since the difference between a ttsl hyphen
7937   % and a tt hyphen is pretty tiny.  @code also disables ?` !`.
7938   \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
7939   #1%
7940   \sl\hyphenchar\font=45
7941 }
7942
7943 % We want ()&[] to print specially on the defun line.
7944 %
7945 \def\activeparens{%
7946   \catcode`\(=\active \catcode`\)=\active
7947   \catcode`\[=\active \catcode`\]=\active
7948   \catcode`\&=\active
7949 }
7950
7951 % Make control sequences which act like normal parenthesis chars.
7952 \let\lparen = ( \let\rparen = )
7953
7954 % Be sure that we always have a definition for `(', etc.  For example,
7955 % if the fn name has parens in it, \boldbrax will not be in effect yet,
7956 % so TeX would otherwise complain about undefined control sequence.
7957 {
7958   \activeparens
7959   \global\let(=\lparen \global\let)=\rparen
7960   \global\let[=\lbrack \global\let]=\rbrack
7961   \global\let& = \&
7962
7963   \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
7964   \gdef\magicamp{\let&=\amprm}
7965 }
7966
7967 \newcount\parencount
7968
7969 % If we encounter &foo, then turn on ()-hacking afterwards
7970 \newif\ifampseen
7971 \def\amprm#1 {\ampseentrue{\bf\&#1 }}
7972
7973 \def\parenfont{%
7974   \ifampseen
7975     % At the first level, print parens in roman,
7976     % otherwise use the default font.
7977     \ifnum \parencount=1 \rm \fi
7978   \else
7979     % The \sf parens (in \boldbrax) actually are a little bolder than
7980     % the contained text.  This is especially needed for [ and ] .
7981     \sf
7982   \fi
7983 }
7984 \def\infirstlevel#1{%
7985   \ifampseen
7986     \ifnum\parencount=1
7987       #1%
7988     \fi
7989   \fi
7990 }
7991 \def\bfafterword#1 {#1 \bf}
7992
7993 \def\opnr{%
7994   \global\advance\parencount by 1
7995   {\parenfont(}%
7996   \infirstlevel \bfafterword
7997 }
7998 \def\clnr{%
7999   {\parenfont)}%
8000   \infirstlevel \sl
8001   \global\advance\parencount by -1
8002 }
8003
8004 \newcount\brackcount
8005 \def\lbrb{%
8006   \global\advance\brackcount by 1
8007   {\bf[}%
8008 }
8009 \def\rbrb{%
8010   {\bf]}%
8011   \global\advance\brackcount by -1
8012 }
8013
8014 \def\checkparencounts{%
8015   \ifnum\parencount=0 \else \badparencount \fi
8016   \ifnum\brackcount=0 \else \badbrackcount \fi
8017 }
8018 % these should not use \errmessage; the glibc manual, at least, actually
8019 % has such constructs (when documenting function pointers).
8020 \def\badparencount{%
8021   \message{Warning: unbalanced parentheses in @def...}%
8022   \global\parencount=0
8023 }
8024 \def\badbrackcount{%
8025   \message{Warning: unbalanced square brackets in @def...}%
8026   \global\brackcount=0
8027 }
8028
8029
8030 \message{macros,}
8031 % @macro.
8032
8033 % To do this right we need a feature of e-TeX, \scantokens,
8034 % which we arrange to emulate with a temporary file in ordinary TeX.
8035 \ifx\eTeXversion\thisisundefined
8036   \newwrite\macscribble
8037   \def\scantokens#1{%
8038     \toks0={#1}%
8039     \immediate\openout\macscribble=\jobname.tmp
8040     \immediate\write\macscribble{\the\toks0}%
8041     \immediate\closeout\macscribble
8042     \input \jobname.tmp
8043   }
8044 \fi
8045
8046 % alias because \c means cedilla in @tex or @math
8047 \let\texinfoc=\c
8048
8049 \newcount\savedcatcodeone
8050 \newcount\savedcatcodetwo
8051
8052 % Used at the time of macro expansion.
8053 % Argument is macro body with arguments substituted
8054 \def\scanmacro#1{%
8055   \newlinechar`\^^M
8056   \def\xeatspaces{\eatspaces}%
8057   %
8058   % Temporarily undo catcode changes of \printindex.  Set catcode of @ to
8059   % 0 so that @-commands in macro expansions aren't printed literally when 
8060   % formatting an index file, where \ is used as the escape character.
8061   \savedcatcodeone=\catcode`\@
8062   \savedcatcodetwo=\catcode`\\
8063   \catcode`\@=0
8064   \catcode`\\=\active
8065   %
8066   % Process the macro body under the current catcode regime.
8067   \scantokens{#1@texinfoc}%
8068   %
8069   \catcode`\@=\savedcatcodeone
8070   \catcode`\\=\savedcatcodetwo
8071   %
8072   % The \texinfoc is to remove the \newlinechar added by \scantokens, and
8073   % can be noticed by \parsearg.
8074   %   We avoid surrounding the call to \scantokens with \bgroup and \egroup
8075   % to allow macros to open or close groups themselves.
8076 }
8077
8078 % Used for copying and captions
8079 \def\scanexp#1{%
8080   \expandafter\scanmacro\expandafter{#1}%
8081 }
8082
8083 \newcount\paramno   % Count of parameters
8084 \newtoks\macname    % Macro name
8085 \newif\ifrecursive  % Is it recursive?
8086
8087 % List of all defined macros in the form
8088 %    \commondummyword\macro1\commondummyword\macro2...
8089 % Currently is also contains all @aliases; the list can be split
8090 % if there is a need.
8091 \def\macrolist{}
8092
8093 % Add the macro to \macrolist
8094 \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
8095 \def\addtomacrolistxxx#1{%
8096      \toks0 = \expandafter{\macrolist\commondummyword#1}%
8097      \xdef\macrolist{\the\toks0}%
8098 }
8099
8100 % Utility routines.
8101 % This does \let #1 = #2, with \csnames; that is,
8102 %   \let \csname#1\endcsname = \csname#2\endcsname
8103 % (except of course we have to play expansion games).
8104 %
8105 \def\cslet#1#2{%
8106   \expandafter\let
8107   \csname#1\expandafter\endcsname
8108   \csname#2\endcsname
8109 }
8110
8111 % Trim leading and trailing spaces off a string.
8112 % Concepts from aro-bend problem 15 (see CTAN).
8113 {\catcode`\@=11
8114 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
8115 \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
8116 \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
8117 \def\unbrace#1{#1}
8118 \unbrace{\gdef\trim@@@ #1 } #2@{#1}
8119 }
8120
8121 % Trim a single trailing ^^M off a string.
8122 {\catcode`\^^M=\other \catcode`\Q=3%
8123 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
8124 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
8125 \gdef\eatcrb#1Q#2Q{#1}%
8126 }
8127
8128 % Macro bodies are absorbed as an argument in a context where
8129 % all characters are catcode 10, 11 or 12, except \ which is active
8130 % (as in normal texinfo). It is necessary to change the definition of \
8131 % to recognize macro arguments; this is the job of \mbodybackslash.
8132 %
8133 % Non-ASCII encodings make 8-bit characters active, so un-activate
8134 % them to avoid their expansion.  Must do this non-globally, to
8135 % confine the change to the current group.
8136 %
8137 % It's necessary to have hard CRs when the macro is executed. This is
8138 % done by making ^^M (\endlinechar) catcode 12 when reading the macro
8139 % body, and then making it the \newlinechar in \scanmacro.
8140 %
8141 \def\scanctxt{% used as subroutine
8142   \catcode`\"=\other
8143   \catcode`\+=\other
8144   \catcode`\<=\other
8145   \catcode`\>=\other
8146   \catcode`\^=\other
8147   \catcode`\_=\other
8148   \catcode`\|=\other
8149   \catcode`\~=\other
8150   \passthroughcharstrue
8151 }
8152
8153 \def\scanargctxt{% used for copying and captions, not macros.
8154   \scanctxt
8155   \catcode`\@=\other
8156   \catcode`\\=\other
8157   \catcode`\^^M=\other
8158 }
8159
8160 \def\macrobodyctxt{% used for @macro definitions
8161   \scanctxt
8162   \catcode`\ =\other
8163   \catcode`\@=\other
8164   \catcode`\{=\other
8165   \catcode`\}=\other
8166   \catcode`\^^M=\other
8167   \usembodybackslash
8168 }
8169
8170 % Used when scanning braced macro arguments.  Note, however, that catcode
8171 % changes here are ineffectual if the macro invocation was nested inside
8172 % an argument to another Texinfo command.
8173 \def\macroargctxt{%
8174   \scanctxt
8175   \catcode`\ =\active
8176   \catcode`\^^M=\other
8177   \catcode`\\=\active
8178 }
8179
8180 \def\macrolineargctxt{% used for whole-line arguments without braces
8181   \scanctxt
8182   \catcode`\{=\other
8183   \catcode`\}=\other
8184 }
8185
8186 % \mbodybackslash is the definition of \ in @macro bodies.
8187 % It maps \foo\ => \csname macarg.foo\endcsname => #N
8188 % where N is the macro parameter number.
8189 % We define \csname macarg.\endcsname to be \realbackslash, so
8190 % \\ in macro replacement text gets you a backslash.
8191 %
8192 {\catcode`@=0 @catcode`@\=@active
8193  @gdef@usembodybackslash{@let\=@mbodybackslash}
8194  @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
8195 }
8196 \expandafter\def\csname macarg.\endcsname{\realbackslash}
8197
8198 \def\margbackslash#1{\char`\#1 }
8199
8200 \def\macro{\recursivefalse\parsearg\macroxxx}
8201 \def\rmacro{\recursivetrue\parsearg\macroxxx}
8202
8203 \def\macroxxx#1{%
8204   \getargs{#1}% now \macname is the macname and \argl the arglist
8205   \ifx\argl\empty       % no arguments
8206      \paramno=0\relax
8207   \else
8208      \expandafter\parsemargdef \argl;%
8209      \if\paramno>256\relax
8210        \ifx\eTeXversion\thisisundefined
8211          \errhelp = \EMsimple
8212          \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
8213        \fi
8214      \fi
8215   \fi
8216   \if1\csname ismacro.\the\macname\endcsname
8217      \message{Warning: redefining \the\macname}%
8218   \else
8219      \expandafter\ifx\csname \the\macname\endcsname \relax
8220      \else \errmessage{Macro name \the\macname\space already defined}\fi
8221      \global\cslet{macsave.\the\macname}{\the\macname}%
8222      \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
8223      \addtomacrolist{\the\macname}%
8224   \fi
8225   \begingroup \macrobodyctxt
8226   \ifrecursive \expandafter\parsermacbody
8227   \else \expandafter\parsemacbody
8228   \fi}
8229
8230 \parseargdef\unmacro{%
8231   \if1\csname ismacro.#1\endcsname
8232     \global\cslet{#1}{macsave.#1}%
8233     \global\expandafter\let \csname ismacro.#1\endcsname=0%
8234     % Remove the macro name from \macrolist:
8235     \begingroup
8236       \expandafter\let\csname#1\endcsname \relax
8237       \let\commondummyword\unmacrodo
8238       \xdef\macrolist{\macrolist}%
8239     \endgroup
8240   \else
8241     \errmessage{Macro #1 not defined}%
8242   \fi
8243 }
8244
8245 % Called by \do from \dounmacro on each macro.  The idea is to omit any
8246 % macro definitions that have been changed to \relax.
8247 %
8248 \def\unmacrodo#1{%
8249   \ifx #1\relax
8250     % remove this
8251   \else
8252     \noexpand\commondummyword \noexpand#1%
8253   \fi
8254 }
8255
8256 % \getargs -- Parse the arguments to a @macro line.  Set \macname to
8257 % the name of the macro, and \argl to the braced argument list.
8258 \def\getargs#1{\getargsxxx#1{}}
8259 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
8260 \def\getmacname#1 #2\relax{\macname={#1}}
8261 \def\getmacargs#1{\def\argl{#1}}
8262 % This made use of the feature that if the last token of a
8263 % <parameter list> is #, then the preceding argument is delimited by
8264 % an opening brace, and that opening brace is not consumed.
8265
8266 % Parse the optional {params} list to @macro or @rmacro.
8267 % Set \paramno to the number of arguments,
8268 % and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
8269 % three-param macro.)  Define \macarg.BLAH for each BLAH in the params
8270 % list to some hook where the argument is to be expanded.  If there are
8271 % less than 10 arguments that hook is to be replaced by ##N where N
8272 % is the position in that list, that is to say the macro arguments are to be
8273 % defined `a la TeX in the macro body.  
8274 %
8275 % That gets used by \mbodybackslash (above).
8276 %
8277 % If there are 10 or more arguments, a different technique is used: see
8278 % \parsemmanyargdef.
8279 %
8280 \def\parsemargdef#1;{%
8281   \paramno=0\def\paramlist{}%
8282   \let\hash\relax
8283   % \hash is redefined to `#' later to get it into definitions
8284   \let\xeatspaces\relax
8285   \parsemargdefxxx#1,;,%
8286   \ifnum\paramno<10\relax\else
8287     \paramno0\relax
8288     \parsemmanyargdef@@#1,;,% 10 or more arguments
8289   \fi
8290 }
8291 \def\parsemargdefxxx#1,{%
8292   \if#1;\let\next=\relax
8293   \else \let\next=\parsemargdefxxx
8294     \advance\paramno by 1
8295     \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
8296         {\xeatspaces{\hash\the\paramno}}%
8297     \edef\paramlist{\paramlist\hash\the\paramno,}%
8298   \fi\next}
8299
8300 % \parsemacbody, \parsermacbody
8301 %
8302 % Read recursive and nonrecursive macro bodies. (They're different since
8303 % rec and nonrec macros end differently.)
8304
8305 % We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro 
8306 % body to be transformed.
8307 % Set \macrobody to the body of the macro, and call \defmacro.
8308 %
8309 {\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{%
8310 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8311 {\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
8312 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8313
8314 % Make @ a letter, so that we can make private-to-Texinfo macro names.
8315 \edef\texiatcatcode{\the\catcode`\@}
8316 \catcode `@=11\relax
8317
8318 %%%%%%%%%%%%%% Code for > 10 arguments only   %%%%%%%%%%%%%%%%%%
8319
8320 % If there are 10 or more arguments, a different technique is used, where the
8321 % hook remains in the body, and when macro is to be expanded the body is
8322 % processed again to replace the arguments.
8323 %
8324 % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
8325 % argument N value and then \edef the body (nothing else will expand because of
8326 % the catcode regime under which the body was input).
8327 %
8328 % If you compile with TeX (not eTeX), and you have macros with 10 or more
8329 % arguments, no macro can have more than 256 arguments (else error).
8330 %
8331 % In case that there are 10 or more arguments we parse again the arguments
8332 % list to set new definitions for the \macarg.BLAH macros corresponding to
8333 % each BLAH argument. It was anyhow needed to parse already once this list
8334 % in order to count the arguments, and as macros with at most 9 arguments
8335 % are by far more frequent than macro with 10 or more arguments, defining
8336 % twice the \macarg.BLAH macros does not cost too much processing power.
8337 \def\parsemmanyargdef@@#1,{%
8338   \if#1;\let\next=\relax
8339   \else 
8340     \let\next=\parsemmanyargdef@@
8341     \edef\tempb{\eatspaces{#1}}%
8342     \expandafter\def\expandafter\tempa
8343        \expandafter{\csname macarg.\tempb\endcsname}%
8344     % Note that we need some extra \noexpand\noexpand, this is because we
8345     % don't want \the  to be expanded in the \parsermacbody  as it uses an
8346     % \xdef .
8347     \expandafter\edef\tempa
8348       {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
8349     \advance\paramno by 1\relax
8350   \fi\next}
8351
8352
8353 \let\endargs@\relax
8354 \let\nil@\relax
8355 \def\nilm@{\nil@}%
8356 \long\def\nillm@{\nil@}%
8357
8358 % This macro is expanded during the Texinfo macro expansion, not during its
8359 % definition.  It gets all the arguments' values and assigns them to macros
8360 % macarg.ARGNAME
8361 %
8362 % #1 is the macro name
8363 % #2 is the list of argument names
8364 % #3 is the list of argument values
8365 \def\getargvals@#1#2#3{%
8366   \def\macargdeflist@{}%
8367   \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
8368   \def\paramlist{#2,\nil@}%
8369   \def\macroname{#1}%
8370   \begingroup
8371   \macroargctxt
8372   \def\argvaluelist{#3,\nil@}%
8373   \def\@tempa{#3}%
8374   \ifx\@tempa\empty
8375     \setemptyargvalues@
8376   \else
8377     \getargvals@@
8378   \fi
8379 }
8380 \def\getargvals@@{%
8381   \ifx\paramlist\nilm@
8382       % Some sanity check needed here that \argvaluelist is also empty.
8383       \ifx\argvaluelist\nillm@
8384       \else
8385         \errhelp = \EMsimple
8386         \errmessage{Too many arguments in macro `\macroname'!}%
8387       \fi
8388       \let\next\macargexpandinbody@
8389   \else
8390     \ifx\argvaluelist\nillm@
8391        % No more arguments values passed to macro.  Set remaining named-arg
8392        % macros to empty.
8393        \let\next\setemptyargvalues@
8394     \else
8395       % pop current arg name into \@tempb
8396       \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
8397       \expandafter\@tempa\expandafter{\paramlist}%
8398        % pop current argument value into \@tempc
8399       \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
8400       \expandafter\@tempa\expandafter{\argvaluelist}%
8401        % Here \@tempb is the current arg name and \@tempc is the current arg value.
8402        % First place the new argument macro definition into \@tempd
8403        \expandafter\macname\expandafter{\@tempc}%
8404        \expandafter\let\csname macarg.\@tempb\endcsname\relax
8405        \expandafter\def\expandafter\@tempe\expandafter{%
8406          \csname macarg.\@tempb\endcsname}%
8407        \edef\@tempd{\long\def\@tempe{\the\macname}}%
8408        \push@\@tempd\macargdeflist@
8409        \let\next\getargvals@@
8410     \fi
8411   \fi
8412   \next
8413 }
8414
8415 \def\push@#1#2{%
8416   \expandafter\expandafter\expandafter\def
8417   \expandafter\expandafter\expandafter#2%
8418   \expandafter\expandafter\expandafter{%
8419   \expandafter#1#2}%
8420 }
8421
8422 % Replace arguments by their values in the macro body, and place the result
8423 % in macro \@tempa.
8424
8425 \def\macvalstoargs@{%
8426   %  To do this we use the property that token registers that are \the'ed
8427   % within an \edef  expand only once. So we are going to place all argument
8428   % values into respective token registers.
8429   %
8430   % First we save the token context, and initialize argument numbering.
8431   \begingroup
8432     \paramno0\relax
8433     % Then, for each argument number #N, we place the corresponding argument
8434     % value into a new token list register \toks#N
8435     \expandafter\putargsintokens@\saveparamlist@,;,%
8436     % Then, we expand the body so that argument are replaced by their
8437     % values. The trick for values not to be expanded themselves is that they
8438     % are within tokens and that tokens expand only once in an \edef .
8439     \edef\@tempc{\csname mac.\macroname .body\endcsname}%
8440     % Now we restore the token stack pointer to free the token list registers
8441     % which we have used, but we make sure that expanded body is saved after
8442     % group.
8443     \expandafter
8444   \endgroup
8445   \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
8446   }
8447
8448 % Define the named-macro outside of this group and then close this group. 
8449
8450 \def\macargexpandinbody@{% 
8451   \expandafter
8452   \endgroup
8453   \macargdeflist@
8454   % First the replace in body the macro arguments by their values, the result
8455   % is in \@tempa .
8456   \macvalstoargs@
8457   % Then we point at the \norecurse or \gobble (for recursive) macro value
8458   % with \@tempb .
8459   \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
8460   % Depending on whether it is recursive or not, we need some tailing
8461   % \egroup .
8462   \ifx\@tempb\gobble
8463      \let\@tempc\relax
8464   \else
8465      \let\@tempc\egroup
8466   \fi
8467   % And now we do the real job:
8468   \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
8469   \@tempd
8470 }
8471
8472 \def\putargsintokens@#1,{%
8473   \if#1;\let\next\relax
8474   \else
8475     \let\next\putargsintokens@
8476     % First we allocate the new token list register, and give it a temporary
8477     % alias \@tempb .
8478     \toksdef\@tempb\the\paramno
8479     % Then we place the argument value into that token list register.
8480     \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
8481     \expandafter\@tempb\expandafter{\@tempa}%
8482     \advance\paramno by 1\relax
8483   \fi
8484   \next
8485 }
8486
8487 % Trailing missing arguments are set to empty.
8488
8489 \def\setemptyargvalues@{%
8490   \ifx\paramlist\nilm@
8491     \let\next\macargexpandinbody@
8492   \else
8493     \expandafter\setemptyargvaluesparser@\paramlist\endargs@
8494     \let\next\setemptyargvalues@
8495   \fi
8496   \next
8497 }
8498
8499 \def\setemptyargvaluesparser@#1,#2\endargs@{%
8500   \expandafter\def\expandafter\@tempa\expandafter{%
8501     \expandafter\def\csname macarg.#1\endcsname{}}%
8502   \push@\@tempa\macargdeflist@
8503   \def\paramlist{#2}%
8504 }
8505
8506 % #1 is the element target macro
8507 % #2 is the list macro
8508 % #3,#4\endargs@ is the list value
8509 \def\pop@#1#2#3,#4\endargs@{%
8510    \def#1{#3}%
8511    \def#2{#4}%
8512 }
8513 \long\def\longpop@#1#2#3,#4\endargs@{%
8514    \long\def#1{#3}%
8515    \long\def#2{#4}%
8516 }
8517
8518
8519 %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
8520
8521
8522 % This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
8523 %    \macrobody has the body of the macro in it, with placeholders for
8524 % its parameters, looking like "\xeatspaces{\hash 1}".
8525 %    \paramno is the number of parameters
8526 %    \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
8527 % There are four cases: macros of zero, one, up to nine, and many arguments.
8528 % \xdef is used so that macro definitions will survive the file
8529 % they're defined in: @include reads the file inside a group.
8530 %
8531 \def\defmacro{%
8532   \let\hash=##% convert placeholders to macro parameter chars
8533   \ifnum\paramno=1
8534     \def\xeatspaces##1{##1}%
8535     % This removes the pair of braces around the argument.  We don't
8536     % use \eatspaces, because this can cause ends of lines to be lost
8537     % when the argument to \eatspaces is read, leading to line-based
8538     % commands like "@itemize" not being read correctly.
8539   \else
8540     \let\xeatspaces\relax % suppress expansion
8541   \fi
8542   \ifcase\paramno
8543   % 0
8544     \expandafter\xdef\csname\the\macname\endcsname{%
8545       \bgroup
8546         \noexpand\spaceisspace
8547         \noexpand\endlineisspace
8548         \noexpand\expandafter % skip any whitespace after the macro name.
8549         \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8550     \expandafter\xdef\csname\the\macname @@@\endcsname{%
8551       \egroup
8552       \noexpand\scanmacro{\macrobody}}%
8553   \or % 1
8554     \expandafter\xdef\csname\the\macname\endcsname{%
8555        \bgroup
8556        \noexpand\braceorline
8557        \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8558     \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8559       \egroup
8560       \noexpand\scanmacro{\macrobody}%
8561       }%
8562   \else % at most 9
8563     \ifnum\paramno<10\relax
8564       % @MACNAME sets the context for reading the macro argument
8565       % @MACNAME@@ gets the argument, processes backslashes and appends a 
8566       % comma.
8567       % @MACNAME@@@ removes braces surrounding the argument list.
8568       % @MACNAME@@@@ scans the macro body with arguments substituted.
8569       \expandafter\xdef\csname\the\macname\endcsname{%
8570         \bgroup
8571         \noexpand\expandafter  % This \expandafter skip any spaces after the
8572         \noexpand\macroargctxt % macro before we change the catcode of space.
8573         \noexpand\expandafter
8574         \expandafter\noexpand\csname\the\macname @@\endcsname}%
8575       \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8576           \noexpand\passargtomacro
8577           \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8578       \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8579           \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8580       \expandafter\expandafter
8581       \expandafter\xdef
8582       \expandafter\expandafter
8583         \csname\the\macname @@@@\endcsname\paramlist{%
8584           \egroup\noexpand\scanmacro{\macrobody}}%
8585     \else % 10 or more:
8586       \expandafter\xdef\csname\the\macname\endcsname{%
8587         \noexpand\getargvals@{\the\macname}{\argl}%
8588       }%
8589       \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8590       \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
8591     \fi
8592   \fi}
8593
8594 \catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
8595
8596 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
8597
8598
8599 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8600 %
8601 {\catcode`\@=0 \catcode`\\=13  % We need to manipulate \ so use @ as escape
8602 @catcode`@_=11  % private names
8603 @catcode`@!=11  % used as argument separator
8604
8605 % \passargtomacro#1#2 -
8606 % Call #1 with a list of tokens #2, with any doubled backslashes in #2
8607 % compressed to one.
8608 %
8609 % This implementation works by expansion, and not execution (so we cannot use 
8610 % \def or similar).  This reduces the risk of this failing in contexts where 
8611 % complete expansion is done with no execution (for example, in writing out to 
8612 % an auxiliary file for an index entry).
8613
8614 % State is kept in the input stream: the argument passed to
8615 % @look_ahead, @gobble_and_check_finish and @add_segment is
8616 %
8617 % THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN  (... rest of input)
8618 %
8619 % where:
8620 % THE_MACRO - name of the macro we want to call
8621 % ARG_RESULT - argument list we build to pass to that macro
8622 % PENDING_BS - either a backslash or nothing
8623 % NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
8624
8625 @gdef@passargtomacro#1#2{%
8626   @add_segment #1!{}@relax#2\@_finish\%
8627 }
8628 @gdef@_finish{@_finishx} @global@let@_finishx@relax
8629
8630 % #1 - THE_MACRO ARG_RESULT
8631 % #2 - PENDING_BS
8632 % #3 - NEXT_TOKEN
8633 % #4 used to look ahead
8634 %
8635 % If the next token is not a backslash, process the rest of the argument; 
8636 % otherwise, remove the next token.
8637 @gdef@look_ahead#1!#2#3#4{%
8638   @ifx#4\%
8639    @expandafter@gobble_and_check_finish 
8640   @else
8641    @expandafter@add_segment
8642   @fi#1!{#2}#4#4%
8643 }
8644
8645 % #1 - THE_MACRO ARG_RESULT
8646 % #2 - PENDING_BS
8647 % #3 - NEXT_TOKEN
8648 % #4 should be a backslash, which is gobbled.
8649 % #5 looks ahead
8650 %
8651 % Double backslash found.  Add a single backslash, and look ahead.
8652 @gdef@gobble_and_check_finish#1!#2#3#4#5{%
8653   @add_segment#1\!{}#5#5%
8654 }
8655
8656 @gdef@is_fi{@fi}
8657
8658 % #1 - THE_MACRO ARG_RESULT
8659 % #2 - PENDING_BS
8660 % #3 - NEXT_TOKEN
8661 % #4 is input stream until next backslash
8662 %
8663 % Input stream is either at the start of the argument, or just after a 
8664 % backslash sequence, either a lone backslash, or a doubled backslash.  
8665 % NEXT_TOKEN contains the first token in the input stream: if it is \finish, 
8666 % finish; otherwise, append to ARG_RESULT the segment of the argument up until
8667 % the next backslash.  PENDING_BACKSLASH contains a backslash to represent
8668 % a backslash just before the start of the input stream that has not been
8669 % added to ARG_RESULT.
8670 @gdef@add_segment#1!#2#3#4\{%
8671 @ifx#3@_finish
8672   @call_the_macro#1!%
8673 @else
8674   % append the pending backslash to the result, followed by the next segment
8675   @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
8676   % this @fi is discarded by @look_ahead.
8677   % we can't get rid of it with \expandafter because we don't know how 
8678   % long #4 is.
8679 }
8680
8681 % #1 - THE_MACRO
8682 % #2 - ARG_RESULT
8683 % #3 discards the res of the conditional in @add_segment, and @is_fi ends the 
8684 % conditional.
8685 @gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
8686
8687 }
8688 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8689
8690 % \braceorline MAC is used for a one-argument macro MAC.  It checks
8691 % whether the next non-whitespace character is a {.  It sets the context
8692 % for reading the argument (slightly different in the two cases).  Then,
8693 % to read the argument, in the whole-line case, it then calls the regular
8694 % \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
8695
8696 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
8697 \def\braceorlinexxx{%
8698   \ifx\nchar\bgroup
8699     \macroargctxt
8700     \expandafter\passargtomacro
8701   \else
8702     \macrolineargctxt\expandafter\parsearg
8703   \fi \macnamexxx}
8704
8705
8706 % @alias.
8707 % We need some trickery to remove the optional spaces around the equal
8708 % sign.  Make them active and then expand them all to nothing.
8709 %
8710 \def\alias{\parseargusing\obeyspaces\aliasxxx}
8711 \def\aliasxxx #1{\aliasyyy#1\relax}
8712 \def\aliasyyy #1=#2\relax{%
8713   {%
8714     \expandafter\let\obeyedspace=\empty
8715     \addtomacrolist{#1}%
8716     \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
8717   }%
8718   \next
8719 }
8720
8721
8722 \message{cross references,}
8723
8724 \newwrite\auxfile
8725 \newif\ifhavexrefs    % True if xref values are known.
8726 \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
8727
8728 % @inforef is relatively simple.
8729 \def\inforef #1{\inforefzzz #1,,,,**}
8730 \def\inforefzzz #1,#2,#3,#4**{%
8731   \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
8732   node \samp{\ignorespaces#1{}}}
8733
8734 % @node's only job in TeX is to define \lastnode, which is used in
8735 % cross-references.  The @node line might or might not have commas, and
8736 % might or might not have spaces before the first comma, like:
8737 % @node foo , bar , ...
8738 % We don't want such trailing spaces in the node name.
8739 %
8740 \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
8741 %
8742 % also remove a trailing comma, in case of something like this:
8743 % @node Help-Cross,  ,  , Cross-refs
8744 \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
8745 \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
8746
8747 \let\nwnode=\node
8748 \let\lastnode=\empty
8749
8750 % Write a cross-reference definition for the current node.  #1 is the
8751 % type (Ynumbered, Yappendix, Ynothing).
8752 %
8753 \def\donoderef#1{%
8754   \ifx\lastnode\empty\else
8755     \setref{\lastnode}{#1}%
8756     \global\let\lastnode=\empty
8757   \fi
8758 }
8759
8760 % @anchor{NAME} -- define xref target at arbitrary point.
8761 %
8762 \newcount\savesfregister
8763 %
8764 \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
8765 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
8766 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
8767
8768 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
8769 % anchor), which consists of three parts:
8770 % 1) NAME-title - the current sectioning name taken from \lastsection,
8771 %                 or the anchor name.
8772 % 2) NAME-snt   - section number and type, passed as the SNT arg, or
8773 %                 empty for anchors.
8774 % 3) NAME-pg    - the page number.
8775 %
8776 % This is called from \donoderef, \anchor, and \dofloat.  In the case of
8777 % floats, there is an additional part, which is not written here:
8778 % 4) NAME-lof   - the text as it should appear in a @listoffloats.
8779 %
8780 \def\setref#1#2{%
8781   \pdfmkdest{#1}%
8782   \iflinks
8783     {%
8784       \requireauxfile
8785       \atdummies  % preserve commands, but don't expand them
8786       % match definition in \xrdef, \refx, \xrefX.
8787       \def\value##1{##1}%
8788       \edef\writexrdef##1##2{%
8789         \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
8790           ##1}{##2}}% these are parameters of \writexrdef
8791       }%
8792       \toks0 = \expandafter{\lastsection}%
8793       \immediate \writexrdef{title}{\the\toks0 }%
8794       \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
8795       \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
8796     }%
8797   \fi
8798 }
8799
8800 % @xrefautosectiontitle on|off says whether @section(ing) names are used
8801 % automatically in xrefs, if the third arg is not explicitly specified.
8802 % This was provided as a "secret" @set xref-automatic-section-title
8803 % variable, now it's official.
8804
8805 \parseargdef\xrefautomaticsectiontitle{%
8806   \def\temp{#1}%
8807   \ifx\temp\onword
8808     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8809       = \empty
8810   \else\ifx\temp\offword
8811     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8812       = \relax
8813   \else
8814     \errhelp = \EMsimple
8815     \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
8816                 must be on|off}%
8817   \fi\fi
8818 }
8819
8820\f
8821 % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
8822 % the node name, #2 the name of the Info cross-reference, #3 the printed
8823 % node name, #4 the name of the Info file, #5 the name of the printed
8824 % manual.  All but the node name can be omitted.
8825 %
8826 \def\pxref{\putwordsee{} \xrefXX}
8827 \def\xref{\putwordSee{} \xrefXX}
8828 \def\ref{\xrefXX}
8829
8830 \def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
8831 \def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
8832 %
8833 \newbox\toprefbox
8834 \newbox\printedrefnamebox
8835 \newbox\infofilenamebox
8836 \newbox\printedmanualbox
8837 %
8838 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
8839   \unsepspaces
8840   %
8841   % Get args without leading/trailing spaces.
8842   \def\printedrefname{\ignorespaces #3}%
8843   \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
8844   %
8845   \def\infofilename{\ignorespaces #4}%
8846   \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
8847   %
8848   \def\printedmanual{\ignorespaces #5}%
8849   \setbox\printedmanualbox  = \hbox{\printedmanual\unskip}%
8850   %
8851   % If the printed reference name (arg #3) was not explicitly given in
8852   % the @xref, figure out what we want to use.
8853   \ifdim \wd\printedrefnamebox = 0pt
8854     % No printed node name was explicitly given.
8855     \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
8856       % Not auto section-title: use node name inside the square brackets.
8857       \def\printedrefname{\ignorespaces #1}%
8858     \else
8859       % Auto section-title: use chapter/section title inside
8860       % the square brackets if we have it.
8861       \ifdim \wd\printedmanualbox > 0pt
8862         % It is in another manual, so we don't have it; use node name.
8863         \def\printedrefname{\ignorespaces #1}%
8864       \else
8865         \ifhavexrefs
8866           % We (should) know the real title if we have the xref values.
8867           \def\printedrefname{\refx{#1-title}{}}%
8868         \else
8869           % Otherwise just copy the Info node name.
8870           \def\printedrefname{\ignorespaces #1}%
8871         \fi%
8872       \fi
8873     \fi
8874   \fi
8875   %
8876   % Make link in pdf output.
8877   \ifpdf
8878     % For pdfTeX and LuaTeX
8879     {\indexnofonts
8880      \makevalueexpandable
8881      \turnoffactive
8882      % This expands tokens, so do it after making catcode changes, so _
8883      % etc. don't get their TeX definitions.  This ignores all spaces in
8884      % #4, including (wrongly) those in the middle of the filename.
8885      \getfilename{#4}%
8886      %
8887      % This (wrongly) does not take account of leading or trailing
8888      % spaces in #1, which should be ignored.
8889      \setpdfdestname{#1}%
8890      %
8891      \ifx\pdfdestname\empty
8892        \def\pdfdestname{Top}% no empty targets
8893      \fi
8894      %
8895      \leavevmode
8896      \startlink attr{/Border [0 0 0]}%
8897      \ifnum\filenamelength>0
8898        goto file{\the\filename.pdf} name{\pdfdestname}%
8899      \else
8900        goto name{\pdfmkpgn{\pdfdestname}}%
8901      \fi
8902     }%
8903     \setcolor{\linkcolor}%
8904   \else
8905     \ifx\XeTeXrevision\thisisundefined
8906     \else
8907       % For XeTeX
8908       {\indexnofonts
8909        \makevalueexpandable
8910        \turnoffactive
8911        % This expands tokens, so do it after making catcode changes, so _
8912        % etc. don't get their TeX definitions.  This ignores all spaces in
8913        % #4, including (wrongly) those in the middle of the filename.
8914        \getfilename{#4}%
8915        %
8916        % This (wrongly) does not take account of leading or trailing
8917        % spaces in #1, which should be ignored.
8918        \setpdfdestname{#1}%
8919        %
8920        \ifx\pdfdestname\empty
8921          \def\pdfdestname{Top}% no empty targets
8922        \fi
8923        %
8924        \leavevmode
8925        \ifnum\filenamelength>0
8926          % With default settings,
8927          % XeTeX (xdvipdfmx) replaces link destination names with integers.
8928          % In this case, the replaced destination names of
8929          % remote PDFs are no longer known.  In order to avoid a replacement,
8930          % you can use xdvipdfmx's command line option `-C 0x0010'.
8931          % If you use XeTeX 0.99996+ (TeX Live 2016+),
8932          % this command line option is no longer necessary
8933          % because we can use the `dvipdfmx:config' special.
8934          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8935            << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}%
8936        \else
8937          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8938            << /S /GoTo /D (\pdfdestname) >> >>}%
8939        \fi
8940       }%
8941       \setcolor{\linkcolor}%
8942     \fi
8943   \fi
8944   {%
8945     % Have to otherify everything special to allow the \csname to
8946     % include an _ in the xref name, etc.
8947     \indexnofonts
8948     \turnoffactive
8949     \def\value##1{##1}%
8950     \expandafter\global\expandafter\let\expandafter\Xthisreftitle
8951       \csname XR#1-title\endcsname
8952   }%
8953   %
8954   % Float references are printed completely differently: "Figure 1.2"
8955   % instead of "[somenode], p.3".  \iffloat distinguishes them by
8956   % \Xthisreftitle being set to a magic string.
8957   \iffloat\Xthisreftitle
8958     % If the user specified the print name (third arg) to the ref,
8959     % print it instead of our usual "Figure 1.2".
8960     \ifdim\wd\printedrefnamebox = 0pt
8961       \refx{#1-snt}{}%
8962     \else
8963       \printedrefname
8964     \fi
8965     %
8966     % If the user also gave the printed manual name (fifth arg), append
8967     % "in MANUALNAME".
8968     \ifdim \wd\printedmanualbox > 0pt
8969       \space \putwordin{} \cite{\printedmanual}%
8970     \fi
8971   \else
8972     % node/anchor (non-float) references.
8973     % 
8974     % If we use \unhbox to print the node names, TeX does not insert
8975     % empty discretionaries after hyphens, which means that it will not
8976     % find a line break at a hyphen in a node names.  Since some manuals
8977     % are best written with fairly long node names, containing hyphens,
8978     % this is a loss.  Therefore, we give the text of the node name
8979     % again, so it is as if TeX is seeing it for the first time.
8980     % 
8981     \ifdim \wd\printedmanualbox > 0pt
8982       % Cross-manual reference with a printed manual name.
8983       % 
8984       \crossmanualxref{\cite{\printedmanual\unskip}}%
8985     %
8986     \else\ifdim \wd\infofilenamebox > 0pt
8987       % Cross-manual reference with only an info filename (arg 4), no
8988       % printed manual name (arg 5).  This is essentially the same as
8989       % the case above; we output the filename, since we have nothing else.
8990       % 
8991       \crossmanualxref{\code{\infofilename\unskip}}%
8992     %
8993     \else
8994       % Reference within this manual.
8995       %
8996       % _ (for example) has to be the character _ for the purposes of the
8997       % control sequence corresponding to the node, but it has to expand
8998       % into the usual \leavevmode...\vrule stuff for purposes of
8999       % printing. So we \turnoffactive for the \refx-snt, back on for the
9000       % printing, back off for the \refx-pg.
9001       {\turnoffactive
9002        % Only output a following space if the -snt ref is nonempty; for
9003        % @unnumbered and @anchor, it won't be.
9004        \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
9005        \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
9006       }%
9007       % output the `[mynode]' via the macro below so it can be overridden.
9008       \xrefprintnodename\printedrefname
9009       %
9010       % But we always want a comma and a space:
9011       ,\space
9012       %
9013       % output the `page 3'.
9014       \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
9015       % Add a , if xref followed by a space
9016       \if\space\noexpand\tokenafterxref ,%
9017       \else\ifx\        \tokenafterxref ,% @TAB
9018       \else\ifx\*\tokenafterxref ,%   @*
9019       \else\ifx\ \tokenafterxref ,%   @SPACE
9020       \else\ifx\
9021                 \tokenafterxref ,%    @NL
9022       \else\ifx\tie\tokenafterxref ,% @tie
9023       \fi\fi\fi\fi\fi\fi
9024     \fi\fi
9025   \fi
9026   \endlink
9027 \endgroup}
9028
9029 % Output a cross-manual xref to #1.  Used just above (twice).
9030
9031 % Only include the text "Section ``foo'' in" if the foo is neither
9032 % missing or Top.  Thus, @xref{,,,foo,The Foo Manual} outputs simply
9033 % "see The Foo Manual", the idea being to refer to the whole manual.
9034
9035 % But, this being TeX, we can't easily compare our node name against the
9036 % string "Top" while ignoring the possible spaces before and after in
9037 % the input.  By adding the arbitrary 7sp below, we make it much less
9038 % likely that a real node name would have the same width as "Top" (e.g.,
9039 % in a monospaced font).  Hopefully it will never happen in practice.
9040
9041 % For the same basic reason, we retypeset the "Top" at every
9042 % reference, since the current font is indeterminate.
9043
9044 \def\crossmanualxref#1{%
9045   \setbox\toprefbox = \hbox{Top\kern7sp}%
9046   \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
9047   \ifdim \wd2 > 7sp  % nonempty?
9048     \ifdim \wd2 = \wd\toprefbox \else  % same as Top?
9049       \putwordSection{} ``\printedrefname'' \putwordin{}\space
9050     \fi
9051   \fi
9052   #1%
9053 }
9054
9055 % This macro is called from \xrefX for the `[nodename]' part of xref
9056 % output.  It's a separate macro only so it can be changed more easily,
9057 % since square brackets don't work well in some documents.  Particularly
9058 % one that Bob is working on :).
9059 %
9060 \def\xrefprintnodename#1{[#1]}
9061
9062 % Things referred to by \setref.
9063 %
9064 \def\Ynothing{}
9065 \def\Yomitfromtoc{}
9066 \def\Ynumbered{%
9067   \ifnum\secno=0
9068     \putwordChapter@tie \the\chapno
9069   \else \ifnum\subsecno=0
9070     \putwordSection@tie \the\chapno.\the\secno
9071   \else \ifnum\subsubsecno=0
9072     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
9073   \else
9074     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
9075   \fi\fi\fi
9076 }
9077 \def\Yappendix{%
9078   \ifnum\secno=0
9079      \putwordAppendix@tie @char\the\appendixno{}%
9080   \else \ifnum\subsecno=0
9081      \putwordSection@tie @char\the\appendixno.\the\secno
9082   \else \ifnum\subsubsecno=0
9083     \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
9084   \else
9085     \putwordSection@tie
9086       @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
9087   \fi\fi\fi
9088 }
9089
9090 % \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME.  SUFFIX 
9091 % is output afterwards if non-empty.
9092 \def\refx#1#2{%
9093   \requireauxfile
9094   {%
9095     \indexnofonts
9096     \otherbackslash
9097     \def\value##1{##1}%
9098     \expandafter\global\expandafter\let\expandafter\thisrefX
9099       \csname XR#1\endcsname
9100   }%
9101   \ifx\thisrefX\relax
9102     % If not defined, say something at least.
9103     \angleleft un\-de\-fined\angleright
9104     \iflinks
9105       \ifhavexrefs
9106         {\toks0 = {#1}% avoid expansion of possibly-complex value
9107          \message{\linenumber Undefined cross reference `\the\toks0'.}}%
9108       \else
9109         \ifwarnedxrefs\else
9110           \global\warnedxrefstrue
9111           \message{Cross reference values unknown; you must run TeX again.}%
9112         \fi
9113       \fi
9114     \fi
9115   \else
9116     % It's defined, so just use it.
9117     \thisrefX
9118   \fi
9119   #2% Output the suffix in any case.
9120 }
9121
9122 % This is the macro invoked by entries in the aux file.  Define a control 
9123 % sequence for a cross-reference target (we prepend XR to the control sequence 
9124 % name to avoid collisions).  The value is the page number.  If this is a float 
9125 % type, we have more work to do.
9126 %
9127 \def\xrdef#1#2{%
9128   {% Expand the node or anchor name to remove control sequences.
9129    % \turnoffactive stops 8-bit characters being changed to commands
9130    % like @'e.  \refx does the same to retrieve the value in the definition.
9131     \indexnofonts
9132     \turnoffactive
9133     \def\value##1{##1}%
9134     \xdef\safexrefname{#1}%
9135   }%
9136   %
9137   \bgroup
9138     \expandafter\gdef\csname XR\safexrefname\endcsname{#2}%
9139   \egroup
9140   % We put the \gdef inside a group to avoid the definitions building up on 
9141   % TeX's save stack, which can cause it to run out of space for aux files with 
9142   % thousands of lines.  \gdef doesn't use the save stack, but \csname does
9143   % when it defines an unknown control sequence as \relax. 
9144   %
9145   % Was that xref control sequence that we just defined for a float?
9146   \expandafter\iffloat\csname XR\safexrefname\endcsname
9147     % it was a float, and we have the (safe) float type in \iffloattype.
9148     \expandafter\let\expandafter\floatlist
9149       \csname floatlist\iffloattype\endcsname
9150     %
9151     % Is this the first time we've seen this float type?
9152     \expandafter\ifx\floatlist\relax
9153       \toks0 = {\do}% yes, so just \do
9154     \else
9155       % had it before, so preserve previous elements in list.
9156       \toks0 = \expandafter{\floatlist\do}%
9157     \fi
9158     %
9159     % Remember this xref in the control sequence \floatlistFLOATTYPE,
9160     % for later use in \listoffloats.
9161     \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
9162       {\safexrefname}}%
9163   \fi
9164 }
9165
9166 % If working on a large document in chapters, it is convenient to
9167 % be able to disable indexing, cross-referencing, and contents, for test runs.
9168 % This is done with @novalidate at the beginning of the file.
9169 %
9170 \newif\iflinks \linkstrue % by default we want the aux files.
9171 \let\novalidate = \linksfalse
9172
9173 % Used when writing to the aux file, or when using data from it.
9174 \def\requireauxfile{%
9175   \iflinks
9176     \tryauxfile
9177     % Open the new aux file.  TeX will close it automatically at exit.
9178     \immediate\openout\auxfile=\jobname.aux
9179   \fi
9180   \global\let\requireauxfile=\relax   % Only do this once.
9181 }
9182
9183 % Read the last existing aux file, if any.  No error if none exists.
9184 %
9185 \def\tryauxfile{%
9186   \openin 1 \jobname.aux
9187   \ifeof 1 \else
9188     \readdatafile{aux}%
9189     \global\havexrefstrue
9190   \fi
9191   \closein 1
9192 }
9193
9194 \def\setupdatafile{%
9195   \catcode`\^^@=\other
9196   \catcode`\^^A=\other
9197   \catcode`\^^B=\other
9198   \catcode`\^^C=\other
9199   \catcode`\^^D=\other
9200   \catcode`\^^E=\other
9201   \catcode`\^^F=\other
9202   \catcode`\^^G=\other
9203   \catcode`\^^H=\other
9204   \catcode`\^^K=\other
9205   \catcode`\^^L=\other
9206   \catcode`\^^N=\other
9207   \catcode`\^^P=\other
9208   \catcode`\^^Q=\other
9209   \catcode`\^^R=\other
9210   \catcode`\^^S=\other
9211   \catcode`\^^T=\other
9212   \catcode`\^^U=\other
9213   \catcode`\^^V=\other
9214   \catcode`\^^W=\other
9215   \catcode`\^^X=\other
9216   \catcode`\^^Z=\other
9217   \catcode`\^^[=\other
9218   \catcode`\^^\=\other
9219   \catcode`\^^]=\other
9220   \catcode`\^^^=\other
9221   \catcode`\^^_=\other
9222   % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
9223   % in xref tags, i.e., node names.  But since ^^e4 notation isn't
9224   % supported in the main text, it doesn't seem desirable.  Furthermore,
9225   % that is not enough: for node names that actually contain a ^
9226   % character, we would end up writing a line like this: 'xrdef {'hat
9227   % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
9228   % argument, and \hat is not an expandable control sequence.  It could
9229   % all be worked out, but why?  Either we support ^^ or we don't.
9230   %
9231   % The other change necessary for this was to define \auxhat:
9232   % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
9233   % and then to call \auxhat in \setq.
9234   %
9235   \catcode`\^=\other
9236   %
9237   % Special characters.  Should be turned off anyway, but...
9238   \catcode`\~=\other
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 % avoid \+ for paranoia even though we've turned it off
9251   %
9252   % This is to support \ in node names and titles, since the \
9253   % characters end up in a \csname.  It's easier than
9254   % leaving it active and making its active definition an actual \
9255   % character.  What I don't understand is why it works in the *value*
9256   % of the xrdef.  Seems like it should be a catcode12 \, and that
9257   % should not typeset properly.  But it works, so I'm moving on for
9258   % now.  --karl, 15jan04.
9259   \catcode`\\=\other
9260   %
9261   % @ is our escape character in .aux files, and we need braces.
9262   \catcode`\{=1
9263   \catcode`\}=2
9264   \catcode`\@=0
9265 }
9266
9267 \def\readdatafile#1{%
9268 \begingroup
9269   \setupdatafile
9270   \input\jobname.#1
9271 \endgroup}
9272
9273
9274 \message{insertions,}
9275 % including footnotes.
9276
9277 \newcount \footnoteno
9278
9279 % The trailing space in the following definition for supereject is
9280 % vital for proper filling; pages come out unaligned when you do a
9281 % pagealignmacro call if that space before the closing brace is
9282 % removed. (Generally, numeric constants should always be followed by a
9283 % space to prevent strange expansion errors.)
9284 \def\supereject{\par\penalty -20000\footnoteno =0 }
9285
9286 % @footnotestyle is meaningful for Info output only.
9287 \let\footnotestyle=\comment
9288
9289 {\catcode `\@=11
9290 %
9291 % Auto-number footnotes.  Otherwise like plain.
9292 \gdef\footnote{%
9293   \global\advance\footnoteno by \@ne
9294   \edef\thisfootno{$^{\the\footnoteno}$}%
9295   %
9296   % In case the footnote comes at the end of a sentence, preserve the
9297   % extra spacing after we do the footnote number.
9298   \let\@sf\empty
9299   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9300   %
9301   % Remove inadvertent blank space before typesetting the footnote number.
9302   \unskip
9303   \thisfootno\@sf
9304   \dofootnote
9305 }%
9306
9307 % Don't bother with the trickery in plain.tex to not require the
9308 % footnote text as a parameter.  Our footnotes don't need to be so general.
9309 %
9310 % Oh yes, they do; otherwise, @ifset (and anything else that uses
9311 % \parseargline) fails inside footnotes because the tokens are fixed when
9312 % the footnote is read.  --karl, 16nov96.
9313 %
9314 \gdef\dofootnote{%
9315   \insert\footins\bgroup
9316   %
9317   % Nested footnotes are not supported in TeX, that would take a lot
9318   % more work.  (\startsavinginserts does not suffice.)
9319   \let\footnote=\errfootnotenest
9320   %
9321   % We want to typeset this text as a normal paragraph, even if the
9322   % footnote reference occurs in (for example) a display environment.
9323   % So reset some parameters.
9324   \hsize=\txipagewidth
9325   \interlinepenalty\interfootnotelinepenalty
9326   \splittopskip\ht\strutbox % top baseline for broken footnotes
9327   \splitmaxdepth\dp\strutbox
9328   \floatingpenalty\@MM
9329   \leftskip\z@skip
9330   \rightskip\z@skip
9331   \spaceskip\z@skip
9332   \xspaceskip\z@skip
9333   \parindent\defaultparindent
9334   %
9335   \smallfonts \rm
9336   %
9337   % Because we use hanging indentation in footnotes, a @noindent appears
9338   % to exdent this text, so make it be a no-op.  makeinfo does not use
9339   % hanging indentation so @noindent can still be needed within footnote
9340   % text after an @example or the like (not that this is good style).
9341   \let\noindent = \relax
9342   %
9343   % Hang the footnote text off the number.  Use \everypar in case the
9344   % footnote extends for more than one paragraph.
9345   \everypar = {\hang}%
9346   \textindent{\thisfootno}%
9347   %
9348   % Don't crash into the line above the footnote text.  Since this
9349   % expands into a box, it must come within the paragraph, lest it
9350   % provide a place where TeX can split the footnote.
9351   \footstrut
9352   %
9353   % Invoke rest of plain TeX footnote routine.
9354   \futurelet\next\fo@t
9355 }
9356 }%end \catcode `\@=11
9357
9358 \def\errfootnotenest{%
9359   \errhelp=\EMsimple
9360   \errmessage{Nested footnotes not supported in texinfo.tex,
9361     even though they work in makeinfo; sorry}
9362 }
9363
9364 \def\errfootnoteheading{%
9365   \errhelp=\EMsimple
9366   \errmessage{Footnotes in chapters, sections, etc., are not supported}
9367 }
9368
9369 % In case a @footnote appears in a vbox, save the footnote text and create
9370 % the real \insert just after the vbox finished.  Otherwise, the insertion
9371 % would be lost.
9372 % Similarly, if a @footnote appears inside an alignment, save the footnote
9373 % text to a box and make the \insert when a row of the table is finished.
9374 % And the same can be done for other insert classes.  --kasal, 16nov03.
9375 %
9376 % Replace the \insert primitive by a cheating macro.
9377 % Deeper inside, just make sure that the saved insertions are not spilled
9378 % out prematurely.
9379 %
9380 \def\startsavinginserts{%
9381   \ifx \insert\ptexinsert
9382     \let\insert\saveinsert
9383   \else
9384     \let\checkinserts\relax
9385   \fi
9386 }
9387
9388 % This \insert replacement works for both \insert\footins{foo} and
9389 % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9390 %
9391 \def\saveinsert#1{%
9392   \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9393   \afterassignment\next
9394   % swallow the left brace
9395   \let\temp =
9396 }
9397 \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9398 \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9399
9400 \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9401
9402 \def\placesaveins#1{%
9403   \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9404     {\box#1}%
9405 }
9406
9407 % eat @SAVE -- beware, all of them have catcode \other:
9408 {
9409   \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials  %  ;-)
9410   \gdef\gobblesave @SAVE{}
9411 }
9412
9413 % initialization:
9414 \def\newsaveins #1{%
9415   \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9416   \next
9417 }
9418 \def\newsaveinsX #1{%
9419   \csname newbox\endcsname #1%
9420   \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9421     \checksaveins #1}%
9422 }
9423
9424 % initialize:
9425 \let\checkinserts\empty
9426 \newsaveins\footins
9427 \newsaveins\margin
9428
9429
9430 % @image.  We use the macros from epsf.tex to support this.
9431 % If epsf.tex is not installed and @image is used, we complain.
9432 %
9433 % Check for and read epsf.tex up front.  If we read it only at @image
9434 % time, we might be inside a group, and then its definitions would get
9435 % undone and the next image would fail.
9436 \openin 1 = epsf.tex
9437 \ifeof 1 \else
9438   % Do not bother showing banner with epsf.tex v2.7k (available in
9439   % doc/epsf.tex and on ctan).
9440   \def\epsfannounce{\toks0 = }%
9441   \input epsf.tex
9442 \fi
9443 \closein 1
9444 %
9445 % We will only complain once about lack of epsf.tex.
9446 \newif\ifwarnednoepsf
9447 \newhelp\noepsfhelp{epsf.tex must be installed for images to
9448   work.  It is also included in the Texinfo distribution, or you can get
9449   it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.}
9450 %
9451 \def\image#1{%
9452   \ifx\epsfbox\thisisundefined
9453     \ifwarnednoepsf \else
9454       \errhelp = \noepsfhelp
9455       \errmessage{epsf.tex not found, images will be ignored}%
9456       \global\warnednoepsftrue
9457     \fi
9458   \else
9459     \imagexxx #1,,,,,\finish
9460   \fi
9461 }
9462 %
9463 % Arguments to @image:
9464 % #1 is (mandatory) image filename; we tack on .eps extension.
9465 % #2 is (optional) width, #3 is (optional) height.
9466 % #4 is (ignored optional) html alt text.
9467 % #5 is (ignored optional) extension.
9468 % #6 is just the usual extra ignored arg for parsing stuff.
9469 \newif\ifimagevmode
9470 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
9471   \catcode`\^^M = 5     % in case we're inside an example
9472   \normalturnoffactive  % allow _ et al. in names
9473   \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
9474   % If the image is by itself, center it.
9475   \ifvmode
9476     \imagevmodetrue
9477   \else \ifx\centersub\centerV
9478     % for @center @image, we need a vbox so we can have our vertical space
9479     \imagevmodetrue
9480     \vbox\bgroup % vbox has better behavior than vtop herev
9481   \fi\fi
9482   %
9483   \ifimagevmode
9484     \nobreak\medskip
9485     % Usually we'll have text after the image which will insert
9486     % \parskip glue, so insert it here too to equalize the space
9487     % above and below.
9488     \nobreak\vskip\parskip
9489     \nobreak
9490   \fi
9491   %
9492   % Leave vertical mode so that indentation from an enclosing
9493   %  environment such as @quotation is respected.
9494   % However, if we're at the top level, we don't want the
9495   %  normal paragraph indentation.
9496   % On the other hand, if we are in the case of @center @image, we don't
9497   %  want to start a paragraph, which will create a hsize-width box and
9498   %  eradicate the centering.
9499   \ifx\centersub\centerV\else \noindent \fi
9500   %
9501   % Output the image.
9502   \ifpdf
9503     % For pdfTeX and LuaTeX <= 0.80
9504     \dopdfimage{#1}{#2}{#3}%
9505   \else
9506     \ifx\XeTeXrevision\thisisundefined
9507       % For epsf.tex
9508       % \epsfbox itself resets \epsf?size at each figure.
9509       \setbox0 = \hbox{\ignorespaces #2}%
9510         \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9511       \setbox0 = \hbox{\ignorespaces #3}%
9512         \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9513       \epsfbox{#1.eps}%
9514     \else
9515       % For XeTeX
9516       \doxeteximage{#1}{#2}{#3}%
9517     \fi
9518   \fi
9519   %
9520   \ifimagevmode
9521     \medskip  % space after a standalone image
9522   \fi  
9523   \ifx\centersub\centerV \egroup \fi
9524 \endgroup}
9525
9526
9527 % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9528 % etc.  We don't actually implement floating yet, we always include the
9529 % float "here".  But it seemed the best name for the future.
9530 %
9531 \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9532
9533 % There may be a space before second and/or third parameter; delete it.
9534 \def\eatcommaspace#1, {#1,}
9535
9536 % #1 is the optional FLOATTYPE, the text label for this float, typically
9537 % "Figure", "Table", "Example", etc.  Can't contain commas.  If omitted,
9538 % this float will not be numbered and cannot be referred to.
9539 %
9540 % #2 is the optional xref label.  Also must be present for the float to
9541 % be referable.
9542 %
9543 % #3 is the optional positioning argument; for now, it is ignored.  It
9544 % will somehow specify the positions allowed to float to (here, top, bottom).
9545 %
9546 % We keep a separate counter for each FLOATTYPE, which we reset at each
9547 % chapter-level command.
9548 \let\resetallfloatnos=\empty
9549 %
9550 \def\dofloat#1,#2,#3,#4\finish{%
9551   \let\thiscaption=\empty
9552   \let\thisshortcaption=\empty
9553   %
9554   % don't lose footnotes inside @float.
9555   %
9556   % BEWARE: when the floats start float, we have to issue warning whenever an
9557   % insert appears inside a float which could possibly float. --kasal, 26may04
9558   %
9559   \startsavinginserts
9560   %
9561   % We can't be used inside a paragraph.
9562   \par
9563   %
9564   \vtop\bgroup
9565     \def\floattype{#1}%
9566     \def\floatlabel{#2}%
9567     \def\floatloc{#3}% we do nothing with this yet.
9568     %
9569     \ifx\floattype\empty
9570       \let\safefloattype=\empty
9571     \else
9572       {%
9573         % the floattype might have accents or other special characters,
9574         % but we need to use it in a control sequence name.
9575         \indexnofonts
9576         \turnoffactive
9577         \xdef\safefloattype{\floattype}%
9578       }%
9579     \fi
9580     %
9581     % If label is given but no type, we handle that as the empty type.
9582     \ifx\floatlabel\empty \else
9583       % We want each FLOATTYPE to be numbered separately (Figure 1,
9584       % Table 1, Figure 2, ...).  (And if no label, no number.)
9585       %
9586       \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9587       \global\advance\floatno by 1
9588       %
9589       {%
9590         % This magic value for \lastsection is output by \setref as the
9591         % XREFLABEL-title value.  \xrefX uses it to distinguish float
9592         % labels (which have a completely different output format) from
9593         % node and anchor labels.  And \xrdef uses it to construct the
9594         % lists of floats.
9595         %
9596         \edef\lastsection{\floatmagic=\safefloattype}%
9597         \setref{\floatlabel}{Yfloat}%
9598       }%
9599     \fi
9600     %
9601     % start with \parskip glue, I guess.
9602     \vskip\parskip
9603     %
9604     % Don't suppress indentation if a float happens to start a section.
9605     \restorefirstparagraphindent
9606 }
9607
9608 % we have these possibilities:
9609 % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9610 % @float Foo,lbl & no caption:    Foo 1.1
9611 % @float Foo & @caption{Cap}:     Foo: Cap
9612 % @float Foo & no caption:        Foo
9613 % @float ,lbl & Caption{Cap}:     1.1: Cap
9614 % @float ,lbl & no caption:       1.1
9615 % @float & @caption{Cap}:         Cap
9616 % @float & no caption:
9617 %
9618 \def\Efloat{%
9619     \let\floatident = \empty
9620     %
9621     % In all cases, if we have a float type, it comes first.
9622     \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9623     %
9624     % If we have an xref label, the number comes next.
9625     \ifx\floatlabel\empty \else
9626       \ifx\floattype\empty \else % if also had float type, need tie first.
9627         \appendtomacro\floatident{\tie}%
9628       \fi
9629       % the number.
9630       \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9631     \fi
9632     %
9633     % Start the printed caption with what we've constructed in
9634     % \floatident, but keep it separate; we need \floatident again.
9635     \let\captionline = \floatident
9636     %
9637     \ifx\thiscaption\empty \else
9638       \ifx\floatident\empty \else
9639         \appendtomacro\captionline{: }% had ident, so need a colon between
9640       \fi
9641       %
9642       % caption text.
9643       \appendtomacro\captionline{\scanexp\thiscaption}%
9644     \fi
9645     %
9646     % If we have anything to print, print it, with space before.
9647     % Eventually this needs to become an \insert.
9648     \ifx\captionline\empty \else
9649       \vskip.5\parskip
9650       \captionline
9651       %
9652       % Space below caption.
9653       \vskip\parskip
9654     \fi
9655     %
9656     % If have an xref label, write the list of floats info.  Do this
9657     % after the caption, to avoid chance of it being a breakpoint.
9658     \ifx\floatlabel\empty \else
9659       % Write the text that goes in the lof to the aux file as
9660       % \floatlabel-lof.  Besides \floatident, we include the short
9661       % caption if specified, else the full caption if specified, else nothing.
9662       {%
9663         \requireauxfile
9664         \atdummies
9665         %
9666         \ifx\thisshortcaption\empty
9667           \def\gtemp{\thiscaption}%
9668         \else
9669           \def\gtemp{\thisshortcaption}%
9670         \fi
9671         \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
9672           \ifx\gtemp\empty \else : \gtemp \fi}}%
9673       }%
9674     \fi
9675   \egroup  % end of \vtop
9676   %
9677   \checkinserts
9678 }
9679
9680 % Append the tokens #2 to the definition of macro #1, not expanding either.
9681 %
9682 \def\appendtomacro#1#2{%
9683   \expandafter\def\expandafter#1\expandafter{#1#2}%
9684 }
9685
9686 % @caption, @shortcaption
9687 %
9688 \def\caption{\docaption\thiscaption}
9689 \def\shortcaption{\docaption\thisshortcaption}
9690 \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
9691 \def\defcaption#1#2{\egroup \def#1{#2}}
9692
9693 % The parameter is the control sequence identifying the counter we are
9694 % going to use.  Create it if it doesn't exist and assign it to \floatno.
9695 \def\getfloatno#1{%
9696   \ifx#1\relax
9697       % Haven't seen this figure type before.
9698       \csname newcount\endcsname #1%
9699       %
9700       % Remember to reset this floatno at the next chap.
9701       \expandafter\gdef\expandafter\resetallfloatnos
9702         \expandafter{\resetallfloatnos #1=0 }%
9703   \fi
9704   \let\floatno#1%
9705 }
9706
9707 % \setref calls this to get the XREFLABEL-snt value.  We want an @xref
9708 % to the FLOATLABEL to expand to "Figure 3.1".  We call \setref when we
9709 % first read the @float command.
9710 %
9711 \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9712
9713 % Magic string used for the XREFLABEL-title value, so \xrefX can
9714 % distinguish floats from other xref types.
9715 \def\floatmagic{!!float!!}
9716
9717 % #1 is the control sequence we are passed; we expand into a conditional
9718 % which is true if #1 represents a float ref.  That is, the magic
9719 % \lastsection value which we \setref above.
9720 %
9721 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
9722 %
9723 % #1 is (maybe) the \floatmagic string.  If so, #2 will be the
9724 % (safe) float type for this float.  We set \iffloattype to #2.
9725 %
9726 \def\doiffloat#1=#2=#3\finish{%
9727   \def\temp{#1}%
9728   \def\iffloattype{#2}%
9729   \ifx\temp\floatmagic
9730 }
9731
9732 % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9733 %
9734 \parseargdef\listoffloats{%
9735   \def\floattype{#1}% floattype
9736   {%
9737     % the floattype might have accents or other special characters,
9738     % but we need to use it in a control sequence name.
9739     \indexnofonts
9740     \turnoffactive
9741     \xdef\safefloattype{\floattype}%
9742   }%
9743   %
9744   % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9745   \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9746     \ifhavexrefs
9747       % if the user said @listoffloats foo but never @float foo.
9748       \message{\linenumber No `\safefloattype' floats to list.}%
9749     \fi
9750   \else
9751     \begingroup
9752       \leftskip=\tocindent  % indent these entries like a toc
9753       \let\do=\listoffloatsdo
9754       \csname floatlist\safefloattype\endcsname
9755     \endgroup
9756   \fi
9757 }
9758
9759 % This is called on each entry in a list of floats.  We're passed the
9760 % xref label, in the form LABEL-title, which is how we save it in the
9761 % aux file.  We strip off the -title and look up \XRLABEL-lof, which
9762 % has the text we're supposed to typeset here.
9763 %
9764 % Figures without xref labels will not be included in the list (since
9765 % they won't appear in the aux file).
9766 %
9767 \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9768 \def\listoffloatsdoentry#1-title\finish{{%
9769   % Can't fully expand XR#1-lof because it can contain anything.  Just
9770   % pass the control sequence.  On the other hand, XR#1-pg is just the
9771   % page number, and we want to fully expand that so we can get a link
9772   % in pdf output.
9773   \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9774   %
9775   % use the same \entry macro we use to generate the TOC and index.
9776   \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9777   \writeentry
9778 }}
9779
9780
9781 \message{localization,}
9782
9783 % For single-language documents, @documentlanguage is usually given very
9784 % early, just after @documentencoding.  Single argument is the language
9785 % (de) or locale (de_DE) abbreviation.
9786 %
9787 {
9788   \catcode`\_ = \active
9789   \globaldefs=1
9790 \parseargdef\documentlanguage{%
9791   \tex % read txi-??.tex file in plain TeX.
9792     % Read the file by the name they passed if it exists.
9793     \let_ = \normalunderscore  % normal _ character for filename test
9794     \openin 1 txi-#1.tex
9795     \ifeof 1
9796       \documentlanguagetrywithoutunderscore #1_\finish
9797     \else
9798       \globaldefs = 1  % everything in the txi-LL files needs to persist
9799       \input txi-#1.tex
9800     \fi
9801     \closein 1
9802   \endgroup % end raw TeX
9803 }
9804 %
9805 % If they passed de_DE, and txi-de_DE.tex doesn't exist,
9806 % try txi-de.tex.
9807 %
9808 \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
9809   \openin 1 txi-#1.tex
9810   \ifeof 1
9811     \errhelp = \nolanghelp
9812     \errmessage{Cannot read language file txi-#1.tex}%
9813   \else
9814     \globaldefs = 1  % everything in the txi-LL files needs to persist
9815     \input txi-#1.tex
9816   \fi
9817   \closein 1
9818 }
9819 }% end of special _ catcode
9820 %
9821 \newhelp\nolanghelp{The given language definition file cannot be found or
9822 is empty.  Maybe you need to install it?  Putting it in the current
9823 directory should work if nowhere else does.}
9824
9825 % This macro is called from txi-??.tex files; the first argument is the
9826 % \language name to set (without the "\lang@" prefix), the second and
9827 % third args are \{left,right}hyphenmin.
9828 %
9829 % The language names to pass are determined when the format is built.
9830 % See the etex.log file created at that time, e.g.,
9831 % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9832 %
9833 % With TeX Live 2008, etex now includes hyphenation patterns for all
9834 % available languages.  This means we can support hyphenation in
9835 % Texinfo, at least to some extent.  (This still doesn't solve the
9836 % accented characters problem.)
9837 %
9838 \catcode`@=11
9839 \def\txisetlanguage#1#2#3{%
9840   % do not set the language if the name is undefined in the current TeX.
9841   \expandafter\ifx\csname lang@#1\endcsname \relax
9842     \message{no patterns for #1}%
9843   \else
9844     \global\language = \csname lang@#1\endcsname
9845   \fi
9846   % but there is no harm in adjusting the hyphenmin values regardless.
9847   \global\lefthyphenmin = #2\relax
9848   \global\righthyphenmin = #3\relax
9849 }
9850
9851 % XeTeX and LuaTeX can handle Unicode natively.
9852 % Their default I/O uses UTF-8 sequences instead of a byte-wise operation.
9853 % Other TeX engines' I/O (pdfTeX, etc.) is byte-wise.
9854 %
9855 \newif\iftxinativeunicodecapable
9856 \newif\iftxiusebytewiseio
9857
9858 \ifx\XeTeXrevision\thisisundefined
9859   \ifx\luatexversion\thisisundefined
9860     \txinativeunicodecapablefalse
9861     \txiusebytewiseiotrue
9862   \else
9863     \txinativeunicodecapabletrue
9864     \txiusebytewiseiofalse
9865   \fi
9866 \else
9867   \txinativeunicodecapabletrue
9868   \txiusebytewiseiofalse
9869 \fi
9870
9871 % Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9872 % for non-UTF-8 (byte-wise) encodings.
9873 %
9874 \def\setbytewiseio{%
9875   \ifx\XeTeXrevision\thisisundefined
9876   \else
9877     \XeTeXdefaultencoding "bytes"  % For subsequent files to be read
9878     \XeTeXinputencoding "bytes"  % For document root file
9879     % Unfortunately, there seems to be no corresponding XeTeX command for
9880     % output encoding.  This is a problem for auxiliary index and TOC files.
9881     % The only solution would be perhaps to write out @U{...} sequences in
9882     % place of non-ASCII characters.
9883   \fi
9884
9885   \ifx\luatexversion\thisisundefined
9886   \else
9887     \directlua{
9888     local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9889     local function convert_char (char)
9890       return utf8_char(byte(char))
9891     end
9892
9893     local function convert_line (line)
9894       return gsub(line, ".", convert_char)
9895     end
9896
9897     callback.register("process_input_buffer", convert_line)
9898
9899     local function convert_line_out (line)
9900       local line_out = ""
9901       for c in string.utfvalues(line) do
9902          line_out = line_out .. string.char(c)
9903       end
9904       return line_out
9905     end
9906
9907     callback.register("process_output_buffer", convert_line_out)
9908     }
9909   \fi
9910
9911   \txiusebytewiseiotrue
9912 }
9913
9914
9915 % Helpers for encodings.
9916 % Set the catcode of characters 128 through 255 to the specified number.
9917 %
9918 \def\setnonasciicharscatcode#1{%
9919    \count255=128
9920    \loop\ifnum\count255<256
9921       \global\catcode\count255=#1\relax
9922       \advance\count255 by 1
9923    \repeat
9924 }
9925
9926 \def\setnonasciicharscatcodenonglobal#1{%
9927    \count255=128
9928    \loop\ifnum\count255<256
9929       \catcode\count255=#1\relax
9930       \advance\count255 by 1
9931    \repeat
9932 }
9933
9934 % @documentencoding sets the definition of non-ASCII characters
9935 % according to the specified encoding.
9936 %
9937 \def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9938 \def\documentencodingzzz#1{%
9939   %
9940   % Encoding being declared for the document.
9941   \def\declaredencoding{\csname #1.enc\endcsname}%
9942   %
9943   % Supported encodings: names converted to tokens in order to be able
9944   % to compare them with \ifx.
9945   \def\ascii{\csname US-ASCII.enc\endcsname}%
9946   \def\latnine{\csname ISO-8859-15.enc\endcsname}%
9947   \def\latone{\csname ISO-8859-1.enc\endcsname}%
9948   \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
9949   \def\utfeight{\csname UTF-8.enc\endcsname}%
9950   %
9951   \ifx \declaredencoding \ascii
9952      \asciichardefs
9953   %
9954   \else \ifx \declaredencoding \lattwo
9955      \iftxinativeunicodecapable
9956        \setbytewiseio
9957      \fi
9958      \setnonasciicharscatcode\active
9959      \lattwochardefs
9960   %
9961   \else \ifx \declaredencoding \latone
9962      \iftxinativeunicodecapable
9963        \setbytewiseio
9964      \fi
9965      \setnonasciicharscatcode\active
9966      \latonechardefs
9967   %
9968   \else \ifx \declaredencoding \latnine
9969      \iftxinativeunicodecapable
9970        \setbytewiseio
9971      \fi
9972      \setnonasciicharscatcode\active
9973      \latninechardefs
9974   %
9975   \else \ifx \declaredencoding \utfeight
9976      \iftxinativeunicodecapable
9977        % For native Unicode handling (XeTeX and LuaTeX)
9978        \nativeunicodechardefs
9979      \else
9980        % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX)
9981        \setnonasciicharscatcode\active
9982        % since we already invoked \utfeightchardefs at the top level
9983        % (below), do not re-invoke it, otherwise our check for duplicated
9984        % definitions gets triggered.  Making non-ascii chars active is
9985        % sufficient.
9986      \fi
9987   %
9988   \else
9989     \message{Ignoring unknown document encoding: #1.}%
9990   %
9991   \fi % utfeight
9992   \fi % latnine
9993   \fi % latone
9994   \fi % lattwo
9995   \fi % ascii
9996   %
9997   \ifx\XeTeXrevision\thisisundefined
9998   \else
9999     \ifx \declaredencoding \utfeight
10000     \else
10001       \ifx \declaredencoding \ascii
10002       \else
10003         \message{Warning: XeTeX with non-UTF-8 encodings cannot handle %
10004         non-ASCII characters in auxiliary files.}%
10005       \fi
10006     \fi
10007   \fi
10008 }
10009
10010 % emacs-page
10011 % A message to be logged when using a character that isn't available
10012 % the default font encoding (OT1).
10013 %
10014 \def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
10015
10016 % Take account of \c (plain) vs. \, (Texinfo) difference.
10017 \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
10018
10019 % First, make active non-ASCII characters in order for them to be
10020 % correctly categorized when TeX reads the replacement text of
10021 % macros containing the character definitions.
10022 \setnonasciicharscatcode\active
10023 %
10024
10025 \def\gdefchar#1#2{%
10026 \gdef#1{%
10027    \ifpassthroughchars
10028      \string#1%
10029    \else
10030      #2%
10031    \fi
10032 }}
10033
10034 % Latin1 (ISO-8859-1) character definitions.
10035 \def\latonechardefs{%
10036   \gdefchar^^a0{\tie}
10037   \gdefchar^^a1{\exclamdown}
10038   \gdefchar^^a2{{\tcfont \char162}} % cent
10039   \gdefchar^^a3{\pounds{}}
10040   \gdefchar^^a4{{\tcfont \char164}} % currency
10041   \gdefchar^^a5{{\tcfont \char165}} % yen
10042   \gdefchar^^a6{{\tcfont \char166}} % broken bar
10043   \gdefchar^^a7{\S}
10044   \gdefchar^^a8{\"{}}
10045   \gdefchar^^a9{\copyright{}}
10046   \gdefchar^^aa{\ordf}
10047   \gdefchar^^ab{\guillemetleft{}}
10048   \gdefchar^^ac{\ensuremath\lnot}
10049   \gdefchar^^ad{\-}
10050   \gdefchar^^ae{\registeredsymbol{}}
10051   \gdefchar^^af{\={}}
10052   %
10053   \gdefchar^^b0{\textdegree}
10054   \gdefchar^^b1{$\pm$}
10055   \gdefchar^^b2{$^2$}
10056   \gdefchar^^b3{$^3$}
10057   \gdefchar^^b4{\'{}}
10058   \gdefchar^^b5{$\mu$}
10059   \gdefchar^^b6{\P}
10060   \gdefchar^^b7{\ensuremath\cdot}
10061   \gdefchar^^b8{\cedilla\ }
10062   \gdefchar^^b9{$^1$}
10063   \gdefchar^^ba{\ordm}
10064   \gdefchar^^bb{\guillemetright{}}
10065   \gdefchar^^bc{$1\over4$}
10066   \gdefchar^^bd{$1\over2$}
10067   \gdefchar^^be{$3\over4$}
10068   \gdefchar^^bf{\questiondown}
10069   %
10070   \gdefchar^^c0{\`A}
10071   \gdefchar^^c1{\'A}
10072   \gdefchar^^c2{\^A}
10073   \gdefchar^^c3{\~A}
10074   \gdefchar^^c4{\"A}
10075   \gdefchar^^c5{\ringaccent A}
10076   \gdefchar^^c6{\AE}
10077   \gdefchar^^c7{\cedilla C}
10078   \gdefchar^^c8{\`E}
10079   \gdefchar^^c9{\'E}
10080   \gdefchar^^ca{\^E}
10081   \gdefchar^^cb{\"E}
10082   \gdefchar^^cc{\`I}
10083   \gdefchar^^cd{\'I}
10084   \gdefchar^^ce{\^I}
10085   \gdefchar^^cf{\"I}
10086   %
10087   \gdefchar^^d0{\DH}
10088   \gdefchar^^d1{\~N}
10089   \gdefchar^^d2{\`O}
10090   \gdefchar^^d3{\'O}
10091   \gdefchar^^d4{\^O}
10092   \gdefchar^^d5{\~O}
10093   \gdefchar^^d6{\"O}
10094   \gdefchar^^d7{$\times$}
10095   \gdefchar^^d8{\O}
10096   \gdefchar^^d9{\`U}
10097   \gdefchar^^da{\'U}
10098   \gdefchar^^db{\^U}
10099   \gdefchar^^dc{\"U}
10100   \gdefchar^^dd{\'Y}
10101   \gdefchar^^de{\TH}
10102   \gdefchar^^df{\ss}
10103   %
10104   \gdefchar^^e0{\`a}
10105   \gdefchar^^e1{\'a}
10106   \gdefchar^^e2{\^a}
10107   \gdefchar^^e3{\~a}
10108   \gdefchar^^e4{\"a}
10109   \gdefchar^^e5{\ringaccent a}
10110   \gdefchar^^e6{\ae}
10111   \gdefchar^^e7{\cedilla c}
10112   \gdefchar^^e8{\`e}
10113   \gdefchar^^e9{\'e}
10114   \gdefchar^^ea{\^e}
10115   \gdefchar^^eb{\"e}
10116   \gdefchar^^ec{\`{\dotless i}}
10117   \gdefchar^^ed{\'{\dotless i}}
10118   \gdefchar^^ee{\^{\dotless i}}
10119   \gdefchar^^ef{\"{\dotless i}}
10120   %
10121   \gdefchar^^f0{\dh}
10122   \gdefchar^^f1{\~n}
10123   \gdefchar^^f2{\`o}
10124   \gdefchar^^f3{\'o}
10125   \gdefchar^^f4{\^o}
10126   \gdefchar^^f5{\~o}
10127   \gdefchar^^f6{\"o}
10128   \gdefchar^^f7{$\div$}
10129   \gdefchar^^f8{\o}
10130   \gdefchar^^f9{\`u}
10131   \gdefchar^^fa{\'u}
10132   \gdefchar^^fb{\^u}
10133   \gdefchar^^fc{\"u}
10134   \gdefchar^^fd{\'y}
10135   \gdefchar^^fe{\th}
10136   \gdefchar^^ff{\"y}
10137 }
10138
10139 % Latin9 (ISO-8859-15) encoding character definitions.
10140 \def\latninechardefs{%
10141   % Encoding is almost identical to Latin1.
10142   \latonechardefs
10143   %
10144   \gdefchar^^a4{\euro{}}
10145   \gdefchar^^a6{\v S}
10146   \gdefchar^^a8{\v s}
10147   \gdefchar^^b4{\v Z}
10148   \gdefchar^^b8{\v z}
10149   \gdefchar^^bc{\OE}
10150   \gdefchar^^bd{\oe}
10151   \gdefchar^^be{\"Y}
10152 }
10153
10154 % Latin2 (ISO-8859-2) character definitions.
10155 \def\lattwochardefs{%
10156   \gdefchar^^a0{\tie}
10157   \gdefchar^^a1{\ogonek{A}}
10158   \gdefchar^^a2{\u{}}
10159   \gdefchar^^a3{\L}
10160   \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
10161   \gdefchar^^a5{\v L}
10162   \gdefchar^^a6{\'S}
10163   \gdefchar^^a7{\S}
10164   \gdefchar^^a8{\"{}}
10165   \gdefchar^^a9{\v S}
10166   \gdefchar^^aa{\cedilla S}
10167   \gdefchar^^ab{\v T}
10168   \gdefchar^^ac{\'Z}
10169   \gdefchar^^ad{\-}
10170   \gdefchar^^ae{\v Z}
10171   \gdefchar^^af{\dotaccent Z}
10172   %
10173   \gdefchar^^b0{\textdegree{}}
10174   \gdefchar^^b1{\ogonek{a}}
10175   \gdefchar^^b2{\ogonek{ }}
10176   \gdefchar^^b3{\l}
10177   \gdefchar^^b4{\'{}}
10178   \gdefchar^^b5{\v l}
10179   \gdefchar^^b6{\'s}
10180   \gdefchar^^b7{\v{}}
10181   \gdefchar^^b8{\cedilla\ }
10182   \gdefchar^^b9{\v s}
10183   \gdefchar^^ba{\cedilla s}
10184   \gdefchar^^bb{\v t}
10185   \gdefchar^^bc{\'z}
10186   \gdefchar^^bd{\H{}}
10187   \gdefchar^^be{\v z}
10188   \gdefchar^^bf{\dotaccent z}
10189   %
10190   \gdefchar^^c0{\'R}
10191   \gdefchar^^c1{\'A}
10192   \gdefchar^^c2{\^A}
10193   \gdefchar^^c3{\u A}
10194   \gdefchar^^c4{\"A}
10195   \gdefchar^^c5{\'L}
10196   \gdefchar^^c6{\'C}
10197   \gdefchar^^c7{\cedilla C}
10198   \gdefchar^^c8{\v C}
10199   \gdefchar^^c9{\'E}
10200   \gdefchar^^ca{\ogonek{E}}
10201   \gdefchar^^cb{\"E}
10202   \gdefchar^^cc{\v E}
10203   \gdefchar^^cd{\'I}
10204   \gdefchar^^ce{\^I}
10205   \gdefchar^^cf{\v D}
10206   %
10207   \gdefchar^^d0{\DH}
10208   \gdefchar^^d1{\'N}
10209   \gdefchar^^d2{\v N}
10210   \gdefchar^^d3{\'O}
10211   \gdefchar^^d4{\^O}
10212   \gdefchar^^d5{\H O}
10213   \gdefchar^^d6{\"O}
10214   \gdefchar^^d7{$\times$}
10215   \gdefchar^^d8{\v R}
10216   \gdefchar^^d9{\ringaccent U}
10217   \gdefchar^^da{\'U}
10218   \gdefchar^^db{\H U}
10219   \gdefchar^^dc{\"U}
10220   \gdefchar^^dd{\'Y}
10221   \gdefchar^^de{\cedilla T}
10222   \gdefchar^^df{\ss}
10223   %
10224   \gdefchar^^e0{\'r}
10225   \gdefchar^^e1{\'a}
10226   \gdefchar^^e2{\^a}
10227   \gdefchar^^e3{\u a}
10228   \gdefchar^^e4{\"a}
10229   \gdefchar^^e5{\'l}
10230   \gdefchar^^e6{\'c}
10231   \gdefchar^^e7{\cedilla c}
10232   \gdefchar^^e8{\v c}
10233   \gdefchar^^e9{\'e}
10234   \gdefchar^^ea{\ogonek{e}}
10235   \gdefchar^^eb{\"e}
10236   \gdefchar^^ec{\v e}
10237   \gdefchar^^ed{\'{\dotless{i}}}
10238   \gdefchar^^ee{\^{\dotless{i}}}
10239   \gdefchar^^ef{\v d}
10240   %
10241   \gdefchar^^f0{\dh}
10242   \gdefchar^^f1{\'n}
10243   \gdefchar^^f2{\v n}
10244   \gdefchar^^f3{\'o}
10245   \gdefchar^^f4{\^o}
10246   \gdefchar^^f5{\H o}
10247   \gdefchar^^f6{\"o}
10248   \gdefchar^^f7{$\div$}
10249   \gdefchar^^f8{\v r}
10250   \gdefchar^^f9{\ringaccent u}
10251   \gdefchar^^fa{\'u}
10252   \gdefchar^^fb{\H u}
10253   \gdefchar^^fc{\"u}
10254   \gdefchar^^fd{\'y}
10255   \gdefchar^^fe{\cedilla t}
10256   \gdefchar^^ff{\dotaccent{}}
10257 }
10258
10259 % UTF-8 character definitions.
10260 %
10261 % This code to support UTF-8 is based on LaTeX's utf8.def, with some
10262 % changes for Texinfo conventions.  It is included here under the GPL by
10263 % permission from Frank Mittelbach and the LaTeX team.
10264 %
10265 \newcount\countUTFx
10266 \newcount\countUTFy
10267 \newcount\countUTFz
10268
10269 \gdef\UTFviiiTwoOctets#1#2{\expandafter
10270    \UTFviiiDefined\csname u8:#1\string #2\endcsname}
10271 %
10272 \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
10273    \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
10274 %
10275 \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
10276    \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
10277
10278 \gdef\UTFviiiDefined#1{%
10279   \ifx #1\relax
10280     \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10281   \else
10282     \expandafter #1%
10283   \fi
10284 }
10285
10286 % Give non-ASCII bytes the active definitions for processing UTF-8 sequences
10287 \begingroup
10288   \catcode`\~13
10289   \catcode`\$12
10290   \catcode`\"12
10291
10292   % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
10293   % substituting ~ and $ with a character token of that value.
10294   \def\UTFviiiLoop{%
10295     \global\catcode\countUTFx\active
10296     \uccode`\~\countUTFx
10297     \uccode`\$\countUTFx
10298     \uppercase\expandafter{\UTFviiiTmp}%
10299     \advance\countUTFx by 1
10300     \ifnum\countUTFx < \countUTFy
10301       \expandafter\UTFviiiLoop
10302     \fi}
10303
10304   % For bytes other than the first in a UTF-8 sequence.  Not expected to
10305   % be expanded except when writing to auxiliary files.
10306   \countUTFx = "80
10307   \countUTFy = "C2
10308   \def\UTFviiiTmp{%
10309     \gdef~{%
10310         \ifpassthroughchars $\fi}}%
10311   \UTFviiiLoop
10312
10313   \countUTFx = "C2
10314   \countUTFy = "E0
10315   \def\UTFviiiTmp{%
10316     \gdef~{%
10317         \ifpassthroughchars $%
10318         \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
10319   \UTFviiiLoop
10320
10321   \countUTFx = "E0
10322   \countUTFy = "F0
10323   \def\UTFviiiTmp{%
10324     \gdef~{%
10325         \ifpassthroughchars $%
10326         \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
10327   \UTFviiiLoop
10328
10329   \countUTFx = "F0
10330   \countUTFy = "F4
10331   \def\UTFviiiTmp{%
10332     \gdef~{%
10333         \ifpassthroughchars $%
10334         \else\expandafter\UTFviiiFourOctets\expandafter$\fi
10335         }}%
10336   \UTFviiiLoop
10337 \endgroup
10338
10339 \def\globallet{\global\let} % save some \expandafter's below
10340
10341 % @U{xxxx} to produce U+xxxx, if we support it.
10342 \def\U#1{%
10343   \expandafter\ifx\csname uni:#1\endcsname \relax
10344     \iftxinativeunicodecapable
10345       % All Unicode characters can be used if native Unicode handling is
10346       % active.  However, if the font does not have the glyph,
10347       % letters are missing.
10348       \begingroup
10349         \uccode`\.="#1\relax
10350         \uppercase{.}
10351       \endgroup
10352     \else
10353       \errhelp = \EMsimple      
10354       \errmessage{Unicode character U+#1 not supported, sorry}%
10355     \fi
10356   \else
10357     \csname uni:#1\endcsname
10358   \fi
10359 }
10360
10361 % These macros are used here to construct the name of a control
10362 % sequence to be defined.
10363 \def\UTFviiiTwoOctetsName#1#2{%
10364   \csname u8:#1\string #2\endcsname}%
10365 \def\UTFviiiThreeOctetsName#1#2#3{%
10366   \csname u8:#1\string #2\string #3\endcsname}%
10367 \def\UTFviiiFourOctetsName#1#2#3#4{%
10368   \csname u8:#1\string #2\string #3\string #4\endcsname}%
10369
10370 % For UTF-8 byte sequences (TeX, e-TeX and pdfTeX),
10371 % provide a definition macro to replace a Unicode character;
10372 % this gets used by the @U command
10373 %
10374 \begingroup
10375   \catcode`\"=12
10376   \catcode`\<=12
10377   \catcode`\.=12
10378   \catcode`\,=12
10379   \catcode`\;=12
10380   \catcode`\!=12
10381   \catcode`\~=13
10382   \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
10383     \countUTFz = "#1\relax
10384     \begingroup
10385       \parseXMLCharref
10386     
10387       % Give \u8:... its definition.  The sequence of seven \expandafter's
10388       % expands after the \gdef three times, e.g.
10389       %
10390       % 1.  \UTFviiTwoOctetsName B1 B2
10391       % 2.  \csname u8:B1 \string B2 \endcsname
10392       % 3.  \u8: B1 B2  (a single control sequence token)
10393       %
10394       \expandafter\expandafter
10395       \expandafter\expandafter
10396       \expandafter\expandafter
10397       \expandafter\gdef       \UTFviiiTmp{#2}%
10398       % 
10399       \expandafter\ifx\csname uni:#1\endcsname \relax \else
10400        \message{Internal error, already defined: #1}%
10401       \fi
10402       %
10403       % define an additional control sequence for this code point.
10404       \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
10405     \endgroup}
10406   %
10407   % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp
10408   % to the corresponding UTF-8 sequence.
10409   \gdef\parseXMLCharref{%
10410     \ifnum\countUTFz < "A0\relax
10411       \errhelp = \EMsimple
10412       \errmessage{Cannot define Unicode char value < 00A0}%
10413     \else\ifnum\countUTFz < "800\relax
10414       \parseUTFviiiA,%
10415       \parseUTFviiiB C\UTFviiiTwoOctetsName.,%
10416     \else\ifnum\countUTFz < "10000\relax
10417       \parseUTFviiiA;%
10418       \parseUTFviiiA,%
10419       \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}%
10420     \else
10421       \parseUTFviiiA;%
10422       \parseUTFviiiA,%
10423       \parseUTFviiiA!%
10424       \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}%
10425     \fi\fi\fi
10426   }
10427
10428   % Extract a byte from the end of the UTF-8 representation of \countUTFx.
10429   % It must be a non-initial byte in the sequence.
10430   % Change \uccode of #1 for it to be used in \parseUTFviiiB as one
10431   % of the bytes.
10432   \gdef\parseUTFviiiA#1{%
10433     \countUTFx = \countUTFz
10434     \divide\countUTFz by 64
10435     \countUTFy = \countUTFz  % Save to be the future value of \countUTFz.
10436     \multiply\countUTFz by 64
10437     
10438     % \countUTFz is now \countUTFx with the last 5 bits cleared.  Subtract
10439     % in order to get the last five bits.
10440     \advance\countUTFx by -\countUTFz
10441
10442     % Convert this to the byte in the UTF-8 sequence.
10443     \advance\countUTFx by 128
10444     \uccode `#1\countUTFx
10445     \countUTFz = \countUTFy}
10446
10447   % Used to put a UTF-8 byte sequence into \UTFviiiTmp
10448   % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8
10449   %    sequence.
10450   % #2 is one of the \UTFviii*OctetsName macros.
10451   % #3 is always a full stop (.)
10452   % #4 is a template for the other bytes in the sequence.  The values for these
10453   %    bytes is substituted in here with \uppercase using the \uccode's.
10454   \gdef\parseUTFviiiB#1#2#3#4{%
10455     \advance\countUTFz by "#10\relax
10456     \uccode `#3\countUTFz
10457     \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10458 \endgroup
10459
10460 % For native Unicode handling (XeTeX and LuaTeX),
10461 % provide a definition macro that sets a catcode to `other' non-globally
10462 %
10463 \def\DeclareUnicodeCharacterNativeOther#1#2{%
10464   \catcode"#1=\other
10465 }
10466
10467 % https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10468 % U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10469 % U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10470 % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10471 % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10472
10473 % Many of our renditions are less than wonderful, and all the missing
10474 % characters are available somewhere.  Loading the necessary fonts
10475 % awaits user request.  We can't truly support Unicode without
10476 % reimplementing everything that's been done in LaTeX for many years,
10477 % plus probably using luatex or xetex, and who knows what else.
10478 % We won't be doing that here in this simple file.  But we can try to at
10479 % least make most of the characters not bomb out.
10480 %
10481 \def\unicodechardefs{%
10482   \DeclareUnicodeCharacter{00A0}{\tie}%
10483   \DeclareUnicodeCharacter{00A1}{\exclamdown}%
10484   \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
10485   \DeclareUnicodeCharacter{00A3}{\pounds{}}%
10486   \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10487   \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10488   \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
10489   \DeclareUnicodeCharacter{00A7}{\S}%
10490   \DeclareUnicodeCharacter{00A8}{\"{ }}%
10491   \DeclareUnicodeCharacter{00A9}{\copyright{}}%
10492   \DeclareUnicodeCharacter{00AA}{\ordf}%
10493   \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}%
10494   \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10495   \DeclareUnicodeCharacter{00AD}{\-}%
10496   \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}%
10497   \DeclareUnicodeCharacter{00AF}{\={ }}%
10498   %
10499   \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
10500   \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10501   \DeclareUnicodeCharacter{00B2}{$^2$}%
10502   \DeclareUnicodeCharacter{00B3}{$^3$}%
10503   \DeclareUnicodeCharacter{00B4}{\'{ }}%
10504   \DeclareUnicodeCharacter{00B5}{$\mu$}%
10505   \DeclareUnicodeCharacter{00B6}{\P}%
10506   \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10507   \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10508   \DeclareUnicodeCharacter{00B9}{$^1$}%
10509   \DeclareUnicodeCharacter{00BA}{\ordm}%
10510   \DeclareUnicodeCharacter{00BB}{\guillemetright{}}%
10511   \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10512   \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10513   \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10514   \DeclareUnicodeCharacter{00BF}{\questiondown}%
10515   %
10516   \DeclareUnicodeCharacter{00C0}{\`A}%
10517   \DeclareUnicodeCharacter{00C1}{\'A}%
10518   \DeclareUnicodeCharacter{00C2}{\^A}%
10519   \DeclareUnicodeCharacter{00C3}{\~A}%
10520   \DeclareUnicodeCharacter{00C4}{\"A}%
10521   \DeclareUnicodeCharacter{00C5}{\AA}%
10522   \DeclareUnicodeCharacter{00C6}{\AE}%
10523   \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10524   \DeclareUnicodeCharacter{00C8}{\`E}%
10525   \DeclareUnicodeCharacter{00C9}{\'E}%
10526   \DeclareUnicodeCharacter{00CA}{\^E}%
10527   \DeclareUnicodeCharacter{00CB}{\"E}%
10528   \DeclareUnicodeCharacter{00CC}{\`I}%
10529   \DeclareUnicodeCharacter{00CD}{\'I}%
10530   \DeclareUnicodeCharacter{00CE}{\^I}%
10531   \DeclareUnicodeCharacter{00CF}{\"I}%
10532   %
10533   \DeclareUnicodeCharacter{00D0}{\DH}%
10534   \DeclareUnicodeCharacter{00D1}{\~N}%
10535   \DeclareUnicodeCharacter{00D2}{\`O}%
10536   \DeclareUnicodeCharacter{00D3}{\'O}%
10537   \DeclareUnicodeCharacter{00D4}{\^O}%
10538   \DeclareUnicodeCharacter{00D5}{\~O}%
10539   \DeclareUnicodeCharacter{00D6}{\"O}%
10540   \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10541   \DeclareUnicodeCharacter{00D8}{\O}%
10542   \DeclareUnicodeCharacter{00D9}{\`U}%
10543   \DeclareUnicodeCharacter{00DA}{\'U}%
10544   \DeclareUnicodeCharacter{00DB}{\^U}%
10545   \DeclareUnicodeCharacter{00DC}{\"U}%
10546   \DeclareUnicodeCharacter{00DD}{\'Y}%
10547   \DeclareUnicodeCharacter{00DE}{\TH}%
10548   \DeclareUnicodeCharacter{00DF}{\ss}%
10549   %
10550   \DeclareUnicodeCharacter{00E0}{\`a}%
10551   \DeclareUnicodeCharacter{00E1}{\'a}%
10552   \DeclareUnicodeCharacter{00E2}{\^a}%
10553   \DeclareUnicodeCharacter{00E3}{\~a}%
10554   \DeclareUnicodeCharacter{00E4}{\"a}%
10555   \DeclareUnicodeCharacter{00E5}{\aa}%
10556   \DeclareUnicodeCharacter{00E6}{\ae}%
10557   \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10558   \DeclareUnicodeCharacter{00E8}{\`e}%
10559   \DeclareUnicodeCharacter{00E9}{\'e}%
10560   \DeclareUnicodeCharacter{00EA}{\^e}%
10561   \DeclareUnicodeCharacter{00EB}{\"e}%
10562   \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10563   \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10564   \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10565   \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10566   %
10567   \DeclareUnicodeCharacter{00F0}{\dh}%
10568   \DeclareUnicodeCharacter{00F1}{\~n}%
10569   \DeclareUnicodeCharacter{00F2}{\`o}%
10570   \DeclareUnicodeCharacter{00F3}{\'o}%
10571   \DeclareUnicodeCharacter{00F4}{\^o}%
10572   \DeclareUnicodeCharacter{00F5}{\~o}%
10573   \DeclareUnicodeCharacter{00F6}{\"o}%
10574   \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10575   \DeclareUnicodeCharacter{00F8}{\o}%
10576   \DeclareUnicodeCharacter{00F9}{\`u}%
10577   \DeclareUnicodeCharacter{00FA}{\'u}%
10578   \DeclareUnicodeCharacter{00FB}{\^u}%
10579   \DeclareUnicodeCharacter{00FC}{\"u}%
10580   \DeclareUnicodeCharacter{00FD}{\'y}%
10581   \DeclareUnicodeCharacter{00FE}{\th}%
10582   \DeclareUnicodeCharacter{00FF}{\"y}%
10583   %
10584   \DeclareUnicodeCharacter{0100}{\=A}%
10585   \DeclareUnicodeCharacter{0101}{\=a}%
10586   \DeclareUnicodeCharacter{0102}{\u{A}}%
10587   \DeclareUnicodeCharacter{0103}{\u{a}}%
10588   \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10589   \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10590   \DeclareUnicodeCharacter{0106}{\'C}%
10591   \DeclareUnicodeCharacter{0107}{\'c}%
10592   \DeclareUnicodeCharacter{0108}{\^C}%
10593   \DeclareUnicodeCharacter{0109}{\^c}%
10594   \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10595   \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10596   \DeclareUnicodeCharacter{010C}{\v{C}}%
10597   \DeclareUnicodeCharacter{010D}{\v{c}}%
10598   \DeclareUnicodeCharacter{010E}{\v{D}}%
10599   \DeclareUnicodeCharacter{010F}{d'}%
10600   %
10601   \DeclareUnicodeCharacter{0110}{\DH}%
10602   \DeclareUnicodeCharacter{0111}{\dh}%
10603   \DeclareUnicodeCharacter{0112}{\=E}%
10604   \DeclareUnicodeCharacter{0113}{\=e}%
10605   \DeclareUnicodeCharacter{0114}{\u{E}}%
10606   \DeclareUnicodeCharacter{0115}{\u{e}}%
10607   \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10608   \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10609   \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10610   \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10611   \DeclareUnicodeCharacter{011A}{\v{E}}%
10612   \DeclareUnicodeCharacter{011B}{\v{e}}%
10613   \DeclareUnicodeCharacter{011C}{\^G}%
10614   \DeclareUnicodeCharacter{011D}{\^g}%
10615   \DeclareUnicodeCharacter{011E}{\u{G}}%
10616   \DeclareUnicodeCharacter{011F}{\u{g}}%
10617   %
10618   \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10619   \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10620   \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10621   \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10622   \DeclareUnicodeCharacter{0124}{\^H}%
10623   \DeclareUnicodeCharacter{0125}{\^h}%
10624   \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10625   \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10626   \DeclareUnicodeCharacter{0128}{\~I}%
10627   \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10628   \DeclareUnicodeCharacter{012A}{\=I}%
10629   \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10630   \DeclareUnicodeCharacter{012C}{\u{I}}%
10631   \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10632   \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10633   \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10634   %
10635   \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10636   \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10637   \DeclareUnicodeCharacter{0132}{IJ}%
10638   \DeclareUnicodeCharacter{0133}{ij}%
10639   \DeclareUnicodeCharacter{0134}{\^J}%
10640   \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10641   \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10642   \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10643   \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10644   \DeclareUnicodeCharacter{0139}{\'L}%
10645   \DeclareUnicodeCharacter{013A}{\'l}%
10646   \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10647   \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
10648   \DeclareUnicodeCharacter{013D}{L'}% should kern
10649   \DeclareUnicodeCharacter{013E}{l'}% should kern
10650   \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10651   %
10652   \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10653   \DeclareUnicodeCharacter{0141}{\L}%
10654   \DeclareUnicodeCharacter{0142}{\l}%
10655   \DeclareUnicodeCharacter{0143}{\'N}%
10656   \DeclareUnicodeCharacter{0144}{\'n}%
10657   \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10658   \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10659   \DeclareUnicodeCharacter{0147}{\v{N}}%
10660   \DeclareUnicodeCharacter{0148}{\v{n}}%
10661   \DeclareUnicodeCharacter{0149}{'n}%
10662   \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10663   \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10664   \DeclareUnicodeCharacter{014C}{\=O}%
10665   \DeclareUnicodeCharacter{014D}{\=o}%
10666   \DeclareUnicodeCharacter{014E}{\u{O}}%
10667   \DeclareUnicodeCharacter{014F}{\u{o}}%
10668   %
10669   \DeclareUnicodeCharacter{0150}{\H{O}}%
10670   \DeclareUnicodeCharacter{0151}{\H{o}}%
10671   \DeclareUnicodeCharacter{0152}{\OE}%
10672   \DeclareUnicodeCharacter{0153}{\oe}%
10673   \DeclareUnicodeCharacter{0154}{\'R}%
10674   \DeclareUnicodeCharacter{0155}{\'r}%
10675   \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10676   \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10677   \DeclareUnicodeCharacter{0158}{\v{R}}%
10678   \DeclareUnicodeCharacter{0159}{\v{r}}%
10679   \DeclareUnicodeCharacter{015A}{\'S}%
10680   \DeclareUnicodeCharacter{015B}{\'s}%
10681   \DeclareUnicodeCharacter{015C}{\^S}%
10682   \DeclareUnicodeCharacter{015D}{\^s}%
10683   \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10684   \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10685   %
10686   \DeclareUnicodeCharacter{0160}{\v{S}}%
10687   \DeclareUnicodeCharacter{0161}{\v{s}}%
10688   \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10689   \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10690   \DeclareUnicodeCharacter{0164}{\v{T}}%
10691   \DeclareUnicodeCharacter{0165}{\v{t}}%
10692   \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10693   \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10694   \DeclareUnicodeCharacter{0168}{\~U}%
10695   \DeclareUnicodeCharacter{0169}{\~u}%
10696   \DeclareUnicodeCharacter{016A}{\=U}%
10697   \DeclareUnicodeCharacter{016B}{\=u}%
10698   \DeclareUnicodeCharacter{016C}{\u{U}}%
10699   \DeclareUnicodeCharacter{016D}{\u{u}}%
10700   \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10701   \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10702   %
10703   \DeclareUnicodeCharacter{0170}{\H{U}}%
10704   \DeclareUnicodeCharacter{0171}{\H{u}}%
10705   \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10706   \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10707   \DeclareUnicodeCharacter{0174}{\^W}%
10708   \DeclareUnicodeCharacter{0175}{\^w}%
10709   \DeclareUnicodeCharacter{0176}{\^Y}%
10710   \DeclareUnicodeCharacter{0177}{\^y}%
10711   \DeclareUnicodeCharacter{0178}{\"Y}%
10712   \DeclareUnicodeCharacter{0179}{\'Z}%
10713   \DeclareUnicodeCharacter{017A}{\'z}%
10714   \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10715   \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10716   \DeclareUnicodeCharacter{017D}{\v{Z}}%
10717   \DeclareUnicodeCharacter{017E}{\v{z}}%
10718   \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10719   %
10720   \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10721   \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10722   \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10723   \DeclareUnicodeCharacter{01C7}{LJ}%
10724   \DeclareUnicodeCharacter{01C8}{Lj}%
10725   \DeclareUnicodeCharacter{01C9}{lj}%
10726   \DeclareUnicodeCharacter{01CA}{NJ}%
10727   \DeclareUnicodeCharacter{01CB}{Nj}%
10728   \DeclareUnicodeCharacter{01CC}{nj}%
10729   \DeclareUnicodeCharacter{01CD}{\v{A}}%
10730   \DeclareUnicodeCharacter{01CE}{\v{a}}%
10731   \DeclareUnicodeCharacter{01CF}{\v{I}}%
10732   %
10733   \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10734   \DeclareUnicodeCharacter{01D1}{\v{O}}%
10735   \DeclareUnicodeCharacter{01D2}{\v{o}}%
10736   \DeclareUnicodeCharacter{01D3}{\v{U}}%
10737   \DeclareUnicodeCharacter{01D4}{\v{u}}%
10738   %
10739   \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10740   \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10741   \DeclareUnicodeCharacter{01E6}{\v{G}}%
10742   \DeclareUnicodeCharacter{01E7}{\v{g}}%
10743   \DeclareUnicodeCharacter{01E8}{\v{K}}%
10744   \DeclareUnicodeCharacter{01E9}{\v{k}}%
10745   %
10746   \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10747   \DeclareUnicodeCharacter{01F1}{DZ}%
10748   \DeclareUnicodeCharacter{01F2}{Dz}%
10749   \DeclareUnicodeCharacter{01F3}{dz}%
10750   \DeclareUnicodeCharacter{01F4}{\'G}%
10751   \DeclareUnicodeCharacter{01F5}{\'g}%
10752   \DeclareUnicodeCharacter{01F8}{\`N}%
10753   \DeclareUnicodeCharacter{01F9}{\`n}%
10754   \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10755   \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10756   \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10757   \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10758   %
10759   \DeclareUnicodeCharacter{021E}{\v{H}}%
10760   \DeclareUnicodeCharacter{021F}{\v{h}}%
10761   %
10762   \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10763   \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10764   \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10765   \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10766   \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10767   \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10768   %
10769   \DeclareUnicodeCharacter{0232}{\=Y}%
10770   \DeclareUnicodeCharacter{0233}{\=y}%
10771   \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10772   %
10773   \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10774   %
10775   % Greek letters upper case
10776   \DeclareUnicodeCharacter{0391}{{\it A}}%
10777   \DeclareUnicodeCharacter{0392}{{\it B}}%
10778   \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10779   \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10780   \DeclareUnicodeCharacter{0395}{{\it E}}%
10781   \DeclareUnicodeCharacter{0396}{{\it Z}}%
10782   \DeclareUnicodeCharacter{0397}{{\it H}}%
10783   \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10784   \DeclareUnicodeCharacter{0399}{{\it I}}%
10785   \DeclareUnicodeCharacter{039A}{{\it K}}%
10786   \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10787   \DeclareUnicodeCharacter{039C}{{\it M}}%
10788   \DeclareUnicodeCharacter{039D}{{\it N}}%
10789   \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10790   \DeclareUnicodeCharacter{039F}{{\it O}}%
10791   \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10792   \DeclareUnicodeCharacter{03A1}{{\it P}}%
10793   %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
10794   \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10795   \DeclareUnicodeCharacter{03A4}{{\it T}}%
10796   \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10797   \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10798   \DeclareUnicodeCharacter{03A7}{{\it X}}%
10799   \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10800   \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10801   %
10802   % Vowels with accents
10803   \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10804   \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10805   \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10806   \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10807   \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10808   \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10809   %
10810   % Standalone accent
10811   \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10812   %
10813   % Greek letters lower case
10814   \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10815   \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10816   \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10817   \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10818   \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10819   \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10820   \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10821   \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10822   \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10823   \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10824   \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10825   \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10826   \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10827   \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10828   \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10829   \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10830   \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10831   \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10832   \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10833   \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10834   \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10835   \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10836   \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10837   \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10838   \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10839   %
10840   % More Greek vowels with accents
10841   \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10842   \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10843   \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10844   \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10845   \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10846   %
10847   % Variant Greek letters
10848   \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10849   \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10850   \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10851   %
10852   \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10853   \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10854   \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10855   \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10856   \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10857   \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10858   \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10859   \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10860   \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10861   \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10862   \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10863   \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10864   %
10865   \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10866   \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10867   %
10868   \DeclareUnicodeCharacter{1E20}{\=G}%
10869   \DeclareUnicodeCharacter{1E21}{\=g}%
10870   \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10871   \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10872   \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10873   \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10874   \DeclareUnicodeCharacter{1E26}{\"H}%
10875   \DeclareUnicodeCharacter{1E27}{\"h}%
10876   %
10877   \DeclareUnicodeCharacter{1E30}{\'K}%
10878   \DeclareUnicodeCharacter{1E31}{\'k}%
10879   \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10880   \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10881   \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10882   \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10883   \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10884   \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10885   \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10886   \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10887   \DeclareUnicodeCharacter{1E3E}{\'M}%
10888   \DeclareUnicodeCharacter{1E3F}{\'m}%
10889   %
10890   \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10891   \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10892   \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10893   \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10894   \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10895   \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10896   \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10897   \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10898   \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10899   \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10900   %
10901   \DeclareUnicodeCharacter{1E54}{\'P}%
10902   \DeclareUnicodeCharacter{1E55}{\'p}%
10903   \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10904   \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10905   \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10906   \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10907   \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10908   \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10909   \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10910   \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10911   %
10912   \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10913   \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10914   \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10915   \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10916   \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10917   \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10918   \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10919   \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10920   \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10921   \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10922   %
10923   \DeclareUnicodeCharacter{1E7C}{\~V}%
10924   \DeclareUnicodeCharacter{1E7D}{\~v}%
10925   \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10926   \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10927   %
10928   \DeclareUnicodeCharacter{1E80}{\`W}%
10929   \DeclareUnicodeCharacter{1E81}{\`w}%
10930   \DeclareUnicodeCharacter{1E82}{\'W}%
10931   \DeclareUnicodeCharacter{1E83}{\'w}%
10932   \DeclareUnicodeCharacter{1E84}{\"W}%
10933   \DeclareUnicodeCharacter{1E85}{\"w}%
10934   \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10935   \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10936   \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10937   \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10938   \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10939   \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10940   \DeclareUnicodeCharacter{1E8C}{\"X}%
10941   \DeclareUnicodeCharacter{1E8D}{\"x}%
10942   \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10943   \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10944   %
10945   \DeclareUnicodeCharacter{1E90}{\^Z}%
10946   \DeclareUnicodeCharacter{1E91}{\^z}%
10947   \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
10948   \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
10949   \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
10950   \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
10951   \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
10952   \DeclareUnicodeCharacter{1E97}{\"t}%
10953   \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
10954   \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
10955   %
10956   \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
10957   \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
10958   %
10959   \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
10960   \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
10961   \DeclareUnicodeCharacter{1EBC}{\~E}%
10962   \DeclareUnicodeCharacter{1EBD}{\~e}%
10963   %
10964   \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
10965   \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
10966   \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
10967   \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
10968   %
10969   \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
10970   \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
10971   %
10972   \DeclareUnicodeCharacter{1EF2}{\`Y}%
10973   \DeclareUnicodeCharacter{1EF3}{\`y}%
10974   \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
10975   %
10976   \DeclareUnicodeCharacter{1EF8}{\~Y}%
10977   \DeclareUnicodeCharacter{1EF9}{\~y}%
10978   %
10979   % Punctuation
10980   \DeclareUnicodeCharacter{2013}{--}%
10981   \DeclareUnicodeCharacter{2014}{---}%
10982   \DeclareUnicodeCharacter{2018}{\quoteleft{}}%
10983   \DeclareUnicodeCharacter{2019}{\quoteright{}}%
10984   \DeclareUnicodeCharacter{201A}{\quotesinglbase{}}%
10985   \DeclareUnicodeCharacter{201C}{\quotedblleft{}}%
10986   \DeclareUnicodeCharacter{201D}{\quotedblright{}}%
10987   \DeclareUnicodeCharacter{201E}{\quotedblbase{}}%
10988   \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}%
10989   \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}%
10990   \DeclareUnicodeCharacter{2022}{\bullet{}}%
10991   \DeclareUnicodeCharacter{202F}{\thinspace}%
10992   \DeclareUnicodeCharacter{2026}{\dots{}}%
10993   \DeclareUnicodeCharacter{2039}{\guilsinglleft{}}%
10994   \DeclareUnicodeCharacter{203A}{\guilsinglright{}}%
10995   %
10996   \DeclareUnicodeCharacter{20AC}{\euro{}}%
10997   %
10998   \DeclareUnicodeCharacter{2192}{\expansion{}}%
10999   \DeclareUnicodeCharacter{21D2}{\result{}}%
11000   %
11001   % Mathematical symbols
11002   \DeclareUnicodeCharacter{2200}{\ensuremath\forall}%
11003   \DeclareUnicodeCharacter{2203}{\ensuremath\exists}%
11004   \DeclareUnicodeCharacter{2208}{\ensuremath\in}%
11005   \DeclareUnicodeCharacter{2212}{\minus{}}%
11006   \DeclareUnicodeCharacter{2217}{\ast}%
11007   \DeclareUnicodeCharacter{221E}{\ensuremath\infty}%
11008   \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}%
11009   \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}%
11010   \DeclareUnicodeCharacter{2229}{\ensuremath\cap}%
11011   \DeclareUnicodeCharacter{2261}{\equiv{}}%
11012   \DeclareUnicodeCharacter{2264}{\ensuremath\leq}%
11013   \DeclareUnicodeCharacter{2265}{\ensuremath\geq}%
11014   \DeclareUnicodeCharacter{2282}{\ensuremath\subset}%
11015   \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}%
11016   %
11017   \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}%
11018   \DeclareUnicodeCharacter{2032}{\ensuremath\prime}%
11019   \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}%
11020   \DeclareUnicodeCharacter{2111}{\ensuremath\Im}%
11021   \DeclareUnicodeCharacter{2113}{\ensuremath\ell}%
11022   \DeclareUnicodeCharacter{2118}{\ensuremath\wp}%
11023   \DeclareUnicodeCharacter{211C}{\ensuremath\Re}%
11024   \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}%
11025   \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}%
11026   \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}%
11027   \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}%
11028   \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}%
11029   \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}%
11030   \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}%
11031   \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}%
11032   \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}%
11033   \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}%
11034   \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}%
11035   \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}%
11036   \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}%
11037   \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}%
11038   \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}%
11039   \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}%
11040   \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}%
11041   \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}%
11042   \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}%
11043   \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}%
11044   \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}%
11045   \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}%
11046   \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}%
11047   \DeclareUnicodeCharacter{2202}{\ensuremath\partial}%
11048   \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}%
11049   \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}%
11050   \DeclareUnicodeCharacter{2209}{\ensuremath\notin}%
11051   \DeclareUnicodeCharacter{220B}{\ensuremath\owns}%
11052   \DeclareUnicodeCharacter{220F}{\ensuremath\prod}%
11053   \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}%
11054   \DeclareUnicodeCharacter{2211}{\ensuremath\sum}%
11055   \DeclareUnicodeCharacter{2213}{\ensuremath\mp}%
11056   \DeclareUnicodeCharacter{2218}{\ensuremath\circ}%
11057   \DeclareUnicodeCharacter{221A}{\ensuremath\surd}%
11058   \DeclareUnicodeCharacter{221D}{\ensuremath\propto}%
11059   \DeclareUnicodeCharacter{2220}{\ensuremath\angle}%
11060   \DeclareUnicodeCharacter{2223}{\ensuremath\mid}%
11061   \DeclareUnicodeCharacter{2228}{\ensuremath\vee}%
11062   \DeclareUnicodeCharacter{222A}{\ensuremath\cup}%
11063   \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}%
11064   \DeclareUnicodeCharacter{222E}{\ensuremath\oint}%
11065   \DeclareUnicodeCharacter{223C}{\ensuremath\sim}%
11066   \DeclareUnicodeCharacter{2240}{\ensuremath\wr}%
11067   \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}%
11068   \DeclareUnicodeCharacter{2245}{\ensuremath\cong}%
11069   \DeclareUnicodeCharacter{2248}{\ensuremath\approx}%
11070   \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}%
11071   \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}%
11072   \DeclareUnicodeCharacter{2260}{\ensuremath\neq}%
11073   \DeclareUnicodeCharacter{226A}{\ensuremath\ll}%
11074   \DeclareUnicodeCharacter{226B}{\ensuremath\gg}%
11075   \DeclareUnicodeCharacter{227A}{\ensuremath\prec}%
11076   \DeclareUnicodeCharacter{227B}{\ensuremath\succ}%
11077   \DeclareUnicodeCharacter{2283}{\ensuremath\supset}%
11078   \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}%
11079   \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}%
11080   \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}%
11081   \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}%
11082   \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}%
11083   \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}%
11084   \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}%
11085   \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}%
11086   \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}%
11087   \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}%
11088   \DeclareUnicodeCharacter{2299}{\ensuremath\odot}%
11089   \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}%
11090   \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}%
11091   \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}%
11092   \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}%
11093   \DeclareUnicodeCharacter{22A8}{\ensuremath\models}%
11094   \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}%
11095   \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}%
11096   \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}%
11097   \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}%
11098   \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}%
11099   \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}%
11100   \DeclareUnicodeCharacter{22C6}{\ensuremath\star}%
11101   \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}%
11102   \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}%
11103   \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}%
11104   \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}%
11105   \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}%
11106   \DeclareUnicodeCharacter{2322}{\ensuremath\frown}%
11107   \DeclareUnicodeCharacter{2323}{\ensuremath\smile}%
11108   %
11109   \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
11110   \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
11111   \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
11112   \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
11113   \DeclareUnicodeCharacter{25C7}{\ensuremath\diamond}%
11114   \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}%
11115   \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}%
11116   \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}%
11117   \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}%
11118   \DeclareUnicodeCharacter{266D}{\ensuremath\flat}%
11119   \DeclareUnicodeCharacter{266E}{\ensuremath\natural}%
11120   \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}%
11121   \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}%
11122   \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}%
11123   \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}%
11124   \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}%
11125   \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}%
11126   \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}%
11127   \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}%
11128   \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}%
11129   \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}%
11130   \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}%
11131   \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}%
11132   \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}%
11133   \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}%
11134   \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}%
11135   \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}%
11136   \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}%
11137   \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}%
11138   %
11139   \global\mathchardef\checkmark="1370% actually the square root sign
11140   \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}%
11141 }% end of \unicodechardefs
11142
11143 % UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
11144 % It makes the setting that replace UTF-8 byte sequence.
11145 \def\utfeightchardefs{%
11146   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
11147   \unicodechardefs
11148 }
11149
11150 % Whether the active definitions of non-ASCII characters expand to
11151 % non-active tokens with the same character code.  This is used to
11152 % write characters literally, instead of using active definitions for
11153 % printing the correct glyphs.
11154 \newif\ifpassthroughchars
11155 \passthroughcharsfalse
11156
11157 % For native Unicode handling (XeTeX and LuaTeX),
11158 % provide a definition macro to replace/pass-through a Unicode character
11159 %
11160 \def\DeclareUnicodeCharacterNative#1#2{%
11161   \catcode"#1=\active
11162   \def\dodeclareunicodecharacternative##1##2##3{%
11163     \begingroup
11164       \uccode`\~="##2\relax
11165       \uppercase{\gdef~}{%
11166         \ifpassthroughchars
11167           ##1%
11168         \else
11169           ##3%
11170         \fi
11171       }
11172     \endgroup
11173   }
11174   \begingroup
11175     \uccode`\.="#1\relax
11176     \uppercase{\def\UTFNativeTmp{.}}%
11177     \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
11178   \endgroup
11179 }
11180
11181 % Native Unicode handling (XeTeX and LuaTeX) character replacing definition.
11182 % It activates the setting that replaces Unicode characters.
11183 \def\nativeunicodechardefs{%
11184   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
11185   \unicodechardefs
11186 }
11187
11188 % For native Unicode handling (XeTeX and LuaTeX),
11189 % make the character token expand
11190 % to the sequences given in \unicodechardefs for printing.
11191 \def\DeclareUnicodeCharacterNativeAtU#1#2{%
11192   \def\UTFAtUTmp{#2}
11193   \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
11194 }
11195
11196 % @U command definitions for native Unicode handling (XeTeX and LuaTeX).
11197 \def\nativeunicodechardefsatu{%
11198   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
11199   \unicodechardefs
11200 }
11201
11202 % US-ASCII character definitions.
11203 \def\asciichardefs{% nothing need be done
11204    \relax
11205 }
11206
11207 % define all Unicode characters we know about, for the sake of @U.
11208 \iftxinativeunicodecapable
11209   \nativeunicodechardefsatu
11210 \else
11211   \utfeightchardefs
11212 \fi
11213
11214
11215 % Make non-ASCII characters printable again for compatibility with
11216 % existing Texinfo documents that may use them, even without declaring a
11217 % document encoding.
11218 %
11219 \setnonasciicharscatcode \other
11220
11221
11222 \message{formatting,}
11223
11224 \newdimen\defaultparindent \defaultparindent = 15pt
11225
11226 \chapheadingskip = 15pt plus 4pt minus 2pt
11227 \secheadingskip = 12pt plus 3pt minus 2pt
11228 \subsecheadingskip = 9pt plus 2pt minus 2pt
11229
11230 % Prevent underfull vbox error messages.
11231 \vbadness = 10000
11232
11233 % Don't be very finicky about underfull hboxes, either.
11234 \hbadness = 6666
11235
11236 % Following George Bush, get rid of widows and orphans.
11237 \widowpenalty=10000
11238 \clubpenalty=10000
11239
11240 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
11241 % using an old version of TeX, don't do anything.  We want the amount of
11242 % stretch added to depend on the line length, hence the dependence on
11243 % \hsize.  We call this whenever the paper size is set.
11244 %
11245 \def\setemergencystretch{%
11246   \ifx\emergencystretch\thisisundefined
11247     % Allow us to assign to \emergencystretch anyway.
11248     \def\emergencystretch{\dimen0}%
11249   \else
11250     \emergencystretch = .15\hsize
11251   \fi
11252 }
11253
11254 % Parameters in order: 1) textheight; 2) textwidth;
11255 % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11256 % 7) physical page height; 8) physical page width.
11257 %
11258 % We also call \setleading{\textleading}, so the caller should define
11259 % \textleading.  The caller should also set \parskip.
11260 %
11261 \def\internalpagesizes#1#2#3#4#5#6#7#8{%
11262   \voffset = #3\relax
11263   \topskip = #6\relax
11264   \splittopskip = \topskip
11265   %
11266   \vsize = #1\relax
11267   \advance\vsize by \topskip
11268   \outervsize = \vsize
11269   \advance\outervsize by 2\topandbottommargin
11270   \txipageheight = \vsize
11271   %
11272   \hsize = #2\relax
11273   \outerhsize = \hsize
11274   \advance\outerhsize by 0.5in
11275   \txipagewidth = \hsize
11276   %
11277   \normaloffset = #4\relax
11278   \bindingoffset = #5\relax
11279   %
11280   \ifpdf
11281     \pdfpageheight #7\relax
11282     \pdfpagewidth #8\relax
11283     % if we don't reset these, they will remain at "1 true in" of
11284     % whatever layout pdftex was dumped with.
11285     \pdfhorigin = 1 true in
11286     \pdfvorigin = 1 true in
11287   \else
11288     \ifx\XeTeXrevision\thisisundefined
11289       \special{papersize=#8,#7}%
11290     \else
11291       \pdfpageheight #7\relax
11292       \pdfpagewidth #8\relax
11293       % XeTeX does not have \pdfhorigin and \pdfvorigin.
11294     \fi
11295   \fi
11296   %
11297   \setleading{\textleading}
11298   %
11299   \parindent = \defaultparindent
11300   \setemergencystretch
11301 }
11302
11303 % @letterpaper (the default).
11304 \def\letterpaper{{\globaldefs = 1
11305   \parskip = 3pt plus 2pt minus 1pt
11306   \textleading = 13.2pt
11307   %
11308   % If page is nothing but text, make it come out even.
11309   \internalpagesizes{607.2pt}{6in}% that's 46 lines
11310                     {\voffset}{.25in}%
11311                     {\bindingoffset}{36pt}%
11312                     {11in}{8.5in}%
11313 }}
11314
11315 % Use @smallbook to reset parameters for 7x9.25 trim size.
11316 \def\smallbook{{\globaldefs = 1
11317   \parskip = 2pt plus 1pt
11318   \textleading = 12pt
11319   %
11320   \internalpagesizes{7.5in}{5in}%
11321                     {-.2in}{0in}%
11322                     {\bindingoffset}{16pt}%
11323                     {9.25in}{7in}%
11324   %
11325   \lispnarrowing = 0.3in
11326   \tolerance = 700
11327   \contentsrightmargin = 0pt
11328   \defbodyindent = .5cm
11329 }}
11330
11331 % Use @smallerbook to reset parameters for 6x9 trim size.
11332 % (Just testing, parameters still in flux.)
11333 \def\smallerbook{{\globaldefs = 1
11334   \parskip = 1.5pt plus 1pt
11335   \textleading = 12pt
11336   %
11337   \internalpagesizes{7.4in}{4.8in}%
11338                     {-.2in}{-.4in}%
11339                     {0pt}{14pt}%
11340                     {9in}{6in}%
11341   %
11342   \lispnarrowing = 0.25in
11343   \tolerance = 700
11344   \contentsrightmargin = 0pt
11345   \defbodyindent = .4cm
11346 }}
11347
11348 % Use @afourpaper to print on European A4 paper.
11349 \def\afourpaper{{\globaldefs = 1
11350   \parskip = 3pt plus 2pt minus 1pt
11351   \textleading = 13.2pt
11352   %
11353   % Double-side printing via postscript on Laserjet 4050
11354   % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11355   % To change the settings for a different printer or situation, adjust
11356   % \normaloffset until the front-side and back-side texts align.  Then
11357   % do the same for \bindingoffset.  You can set these for testing in
11358   % your texinfo source file like this:
11359   % @tex
11360   % \global\normaloffset = -6mm
11361   % \global\bindingoffset = 10mm
11362   % @end tex
11363   \internalpagesizes{673.2pt}{160mm}% that's 51 lines
11364                     {\voffset}{\hoffset}%
11365                     {\bindingoffset}{44pt}%
11366                     {297mm}{210mm}%
11367   %
11368   \tolerance = 700
11369   \contentsrightmargin = 0pt
11370   \defbodyindent = 5mm
11371 }}
11372
11373 % Use @afivepaper to print on European A5 paper.
11374 % From romildo@urano.iceb.ufop.br, 2 July 2000.
11375 % He also recommends making @example and @lisp be small.
11376 \def\afivepaper{{\globaldefs = 1
11377   \parskip = 2pt plus 1pt minus 0.1pt
11378   \textleading = 12.5pt
11379   %
11380   \internalpagesizes{160mm}{120mm}%
11381                     {\voffset}{\hoffset}%
11382                     {\bindingoffset}{8pt}%
11383                     {210mm}{148mm}%
11384   %
11385   \lispnarrowing = 0.2in
11386   \tolerance = 800
11387   \contentsrightmargin = 0pt
11388   \defbodyindent = 2mm
11389   \tableindent = 12mm
11390 }}
11391
11392 % A specific text layout, 24x15cm overall, intended for A4 paper.
11393 \def\afourlatex{{\globaldefs = 1
11394   \afourpaper
11395   \internalpagesizes{237mm}{150mm}%
11396                     {\voffset}{4.6mm}%
11397                     {\bindingoffset}{7mm}%
11398                     {297mm}{210mm}%
11399   %
11400   % Must explicitly reset to 0 because we call \afourpaper.
11401   \globaldefs = 0
11402 }}
11403
11404 % Use @afourwide to print on A4 paper in landscape format.
11405 \def\afourwide{{\globaldefs = 1
11406   \afourpaper
11407   \internalpagesizes{241mm}{165mm}%
11408                     {\voffset}{-2.95mm}%
11409                     {\bindingoffset}{7mm}%
11410                     {297mm}{210mm}%
11411   \globaldefs = 0
11412 }}
11413
11414 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11415 % Perhaps we should allow setting the margins, \topskip, \parskip,
11416 % and/or leading, also. Or perhaps we should compute them somehow.
11417 %
11418 \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
11419 \def\pagesizesyyy#1,#2,#3\finish{{%
11420   \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11421   \globaldefs = 1
11422   %
11423   \parskip = 3pt plus 2pt minus 1pt
11424   \setleading{\textleading}%
11425   %
11426   \dimen0 = #1\relax
11427   \advance\dimen0 by \voffset
11428   \advance\dimen0 by 1in % reference point for DVI is 1 inch from top of page
11429   %
11430   \dimen2 = \hsize
11431   \advance\dimen2 by \normaloffset
11432   \advance\dimen2 by 1in % reference point is 1 inch from left edge of page
11433   %
11434   \internalpagesizes{#1}{\hsize}%
11435                     {\voffset}{\normaloffset}%
11436                     {\bindingoffset}{44pt}%
11437                     {\dimen0}{\dimen2}%
11438 }}
11439
11440 % Set default to letter.
11441 %
11442 \letterpaper
11443
11444 % Default value of \hfuzz, for suppressing warnings about overfull hboxes.
11445 \hfuzz = 1pt
11446
11447
11448 \message{and turning on texinfo input format.}
11449
11450 \def^^L{\par} % remove \outer, so ^L can appear in an @comment
11451
11452 % DEL is a comment character, in case @c does not suffice.
11453 \catcode`\^^? = 14
11454
11455 % Define macros to output various characters with catcode for normal text.
11456 \catcode`\"=\other \def\normaldoublequote{"}
11457 \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11458 \catcode`\+=\other \def\normalplus{+}
11459 \catcode`\<=\other \def\normalless{<}
11460 \catcode`\>=\other \def\normalgreater{>}
11461 \catcode`\^=\other \def\normalcaret{^}
11462 \catcode`\_=\other \def\normalunderscore{_}
11463 \catcode`\|=\other \def\normalverticalbar{|}
11464 \catcode`\~=\other \def\normaltilde{~}
11465
11466 % This macro is used to make a character print one way in \tt
11467 % (where it can probably be output as-is), and another way in other fonts,
11468 % where something hairier probably needs to be done.
11469 %
11470 % #1 is what to print if we are indeed using \tt; #2 is what to print
11471 % otherwise.  Since all the Computer Modern typewriter fonts have zero
11472 % interword stretch (and shrink), and it is reasonable to expect all
11473 % typewriter fonts to have this, we can check that font parameter.
11474 %
11475 \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
11476
11477 % Same as above, but check for italic font.  Actually this also catches
11478 % non-italic slanted fonts since it is impossible to distinguish them from
11479 % italic fonts.  But since this is only used by $ and it uses \sl anyway
11480 % this is not a problem.
11481 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
11482
11483 % Set catcodes for Texinfo file
11484
11485 % Active characters for printing the wanted glyph.
11486 % Most of these we simply print from the \tt font, but for some, we can
11487 % use math or other variants that look better in normal text.
11488 %
11489 \catcode`\"=\active
11490 \def\activedoublequote{{\tt\char34}}
11491 \let"=\activedoublequote
11492 \catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
11493 \chardef\hatchar=`\^
11494 \catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
11495
11496 \catcode`\_=\active
11497 \def_{\ifusingtt\normalunderscore\_}
11498 \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
11499 \let\realunder=_
11500
11501 \catcode`\|=\active \def|{{\tt\char124}}
11502
11503 \chardef \less=`\<
11504 \catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
11505 \chardef \gtr=`\>
11506 \catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11507 \catcode`\+=\active \def+{{\tt \char 43}}
11508 \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
11509 \catcode`\-=\active \let-=\normaldash
11510
11511
11512 % used for headline/footline in the output routine, in case the page
11513 % breaks in the middle of an @tex block.
11514 \def\texinfochars{%
11515   \let< = \activeless
11516   \let> = \activegtr
11517   \let~ = \activetilde 
11518   \let^ = \activehat
11519   \markupsetuplqdefault \markupsetuprqdefault 
11520   \let\b = \strong
11521   \let\i = \smartitalic
11522   % in principle, all other definitions in \tex have to be undone too.
11523 }
11524
11525 % Used sometimes to turn off (effectively) the active characters even after
11526 % parsing them.
11527 \def\turnoffactive{%
11528   \normalturnoffactive
11529   \otherbackslash
11530 }
11531
11532 \catcode`\@=0
11533
11534 % \backslashcurfont outputs one backslash character in current font,
11535 % as in \char`\\.
11536 \global\chardef\backslashcurfont=`\\
11537 \global\let\rawbackslashxx=\backslashcurfont  % let existing .??s files work
11538
11539 % \realbackslash is an actual character `\' with catcode other, and
11540 % \doublebackslash is two of them (for the pdf outlines).
11541 {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
11542
11543 % In Texinfo, backslash is an active character; it prints the backslash
11544 % in fixed width font.
11545 \catcode`\\=\active  % @ for escape char from now on.
11546
11547 % Print a typewriter backslash.  For math mode, we can't simply use
11548 % \backslashcurfont: the story here is that in math mode, the \char
11549 % of \backslashcurfont ends up printing the roman \ from the math symbol
11550 % font (because \char in math mode uses the \mathcode, and plain.tex
11551 % sets \mathcode`\\="026E).  Hence we use an explicit \mathchar,
11552 % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11553 % ignored family value; char position "5C).  We can't use " for the
11554 % usual hex value because it has already been made active.
11555
11556 @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
11557 @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
11558
11559 % \rawbackslash defines an active \ to do \backslashcurfont.
11560 % \otherbackslash defines an active \ to be a literal `\' character with
11561 % catcode other.  We switch back and forth between these.
11562 @gdef@rawbackslash{@let\=@backslashcurfont}
11563 @gdef@otherbackslash{@let\=@realbackslash}
11564
11565 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
11566 % the literal character `\'.
11567 %
11568 {@catcode`- = @active
11569  @gdef@normalturnoffactive{%
11570    @passthroughcharstrue
11571    @let-=@normaldash
11572    @let"=@normaldoublequote
11573    @let$=@normaldollar %$ font-lock fix
11574    @let+=@normalplus
11575    @let<=@normalless
11576    @let>=@normalgreater
11577    @let^=@normalcaret
11578    @let_=@normalunderscore
11579    @let|=@normalverticalbar
11580    @let~=@normaltilde
11581    @let\=@ttbackslash
11582    @markupsetuplqdefault
11583    @markupsetuprqdefault
11584    @unsepspaces
11585  }
11586 }
11587
11588 % If a .fmt file is being used, characters that might appear in a file
11589 % name cannot be active until we have parsed the command line.
11590 % So turn them off again, and have @fixbackslash turn them back on.
11591 @catcode`+=@other @catcode`@_=@other
11592
11593 % \enablebackslashhack - allow file to begin `\input texinfo'
11594 %
11595 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
11596 % That is what \eatinput is for; after that, the `\' should revert to printing
11597 % a backslash.
11598 % If the file did not have a `\input texinfo', then it is turned off after
11599 % the first line; otherwise the first `\' in the file would cause an error.
11600 % This is used on the very last line of this file, texinfo.tex.
11601 % We also use @c to call @fixbackslash, in case ends of lines are hidden.
11602 {
11603 @catcode`@^=7
11604 @catcode`@^^M=13@gdef@enablebackslashhack{%
11605   @global@let\ = @eatinput%
11606   @catcode`@^^M=13%
11607   @def@c{@fixbackslash@c}%
11608   % Definition for the newline at the end of this file.
11609   @def ^^M{@let^^M@secondlinenl}%
11610   % Definition for a newline in the main Texinfo file.
11611   @gdef @secondlinenl{@fixbackslash}%
11612   % In case the first line has a whole-line command on it
11613   @let@originalparsearg@parsearg
11614   @def@parsearg{@fixbackslash@originalparsearg}
11615 }}
11616
11617 {@catcode`@^=7 @catcode`@^^M=13%
11618 @gdef@eatinput input texinfo#1^^M{@fixbackslash}}
11619
11620 % Emergency active definition of newline, in case an active newline token
11621 % appears by mistake.
11622 {@catcode`@^=7 @catcode13=13%
11623 @gdef@enableemergencynewline{%
11624   @gdef^^M{%
11625     @par%
11626     %<warning: active newline>@par%
11627 }}}
11628
11629
11630 @gdef@fixbackslash{%
11631   @ifx\@eatinput @let\ = @ttbackslash @fi
11632   @catcode13=5 % regular end of line
11633   @enableemergencynewline
11634   @let@c=@texinfoc
11635   @let@parsearg@originalparsearg
11636   % Also turn back on active characters that might appear in the input
11637   % file name, in case not using a pre-dumped format.
11638   @catcode`+=@active
11639   @catcode`@_=@active
11640   %
11641   % If texinfo.cnf is present on the system, read it.
11642   % Useful for site-wide @afourpaper, etc.  This macro, @fixbackslash, gets
11643   % called at the beginning of every Texinfo file.  Not opening texinfo.cnf
11644   % directly in this file, texinfo.tex, makes it possible to make a format
11645   % file for Texinfo.
11646   %
11647   @openin 1 texinfo.cnf
11648   @ifeof 1 @else @input texinfo.cnf @fi
11649   @closein 1
11650 }
11651
11652
11653 % Say @foo, not \foo, in error messages.
11654 @escapechar = `@@
11655
11656 % These (along with & and #) are made active for url-breaking, so need
11657 % active definitions as the normal characters.
11658 @def@normaldot{.}
11659 @def@normalquest{?}
11660 @def@normalslash{/}
11661
11662 % These look ok in all fonts, so just make them not special.
11663 % @hashchar{} gets its own user-level command, because of #line.
11664 @catcode`@& = @other @def@normalamp{&}
11665 @catcode`@# = @other @def@normalhash{#}
11666 @catcode`@% = @other @def@normalpercent{%}
11667
11668 @let @hashchar = @normalhash
11669
11670 @c Finally, make ` and ' active, so that txicodequoteundirected and
11671 @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
11672 @c don't make ` and ' active, @code will not get them as active chars.
11673 @c Do this last of all since we use ` in the previous @catcode assignments.
11674 @catcode`@'=@active
11675 @catcode`@`=@active
11676 @markupsetuplqdefault
11677 @markupsetuprqdefault
11678
11679 @c Local variables:
11680 @c eval: (add-hook 'write-file-hooks 'time-stamp)
11681 @c page-delimiter: "^\\\\message\\|emacs-page"
11682 @c time-stamp-start: "def\\\\texinfoversion{"
11683 @c time-stamp-format: "%:y-%02m-%02d.%02H"
11684 @c time-stamp-end: "}"
11685 @c End:
11686
11687 @c vim:sw=2:
11688
11689 @enablebackslashhack