New upstream version 1.8
[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{2016-04-14.07}
7 %
8 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
9 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
10 % 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
11 % Free Software Foundation, Inc.
12 %
13 % This texinfo.tex file is free software: you can redistribute it and/or
14 % modify it under the terms of the GNU General Public License as
15 % published by the Free Software Foundation, either version 3 of the
16 % License, or (at your option) any later version.
17 %
18 % This texinfo.tex file is distributed in the hope that it will be
19 % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
20 % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 % General Public License for more details.
22 %
23 % You should have received a copy of the GNU General Public License
24 % along with this program.  If not, see <http://www.gnu.org/licenses/>.
25 %
26 % As a special exception, when this file is read by TeX when processing
27 % a Texinfo source document, you may use the result without
28 % restriction. This Exception is an additional permission under section 7
29 % of the GNU General Public License, version 3 ("GPLv3").
30 %
31 % Please try the latest version of texinfo.tex before submitting bug
32 % reports; you can get the latest version from:
33 %   http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
34 %   http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
35 %   http://www.gnu.org/software/texinfo/ (the Texinfo home page)
36 % The texinfo.tex in any given distribution could well be out
37 % of date, so if that's what you're using, please check.
38 %
39 % Send bug reports to bug-texinfo@gnu.org.  Please include including a
40 % complete document in each bug report with which we can reproduce the
41 % problem.  Patches are, of course, greatly appreciated.
42 %
43 % To process a Texinfo manual with TeX, it's most reliable to use the
44 % texi2dvi shell script that comes with the distribution.  For a simple
45 % manual foo.texi, however, you can get away with this:
46 %   tex foo.texi
47 %   texindex foo.??
48 %   tex foo.texi
49 %   tex foo.texi
50 %   dvips foo.dvi -o  # or whatever; this makes foo.ps.
51 % The extra TeX runs get the cross-reference information correct.
52 % Sometimes one run after texindex suffices, and sometimes you need more
53 % than two; texi2dvi does it as many times as necessary.
54 %
55 % It is possible to adapt texinfo.tex for other languages, to some
56 % extent.  You can get the existing language-specific files from the
57 % full Texinfo distribution.
58 %
59 % The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
60
61
62 \message{Loading texinfo [version \texinfoversion]:}
63
64 % If in a .fmt file, print the version number
65 % and turn on active characters that we couldn't do earlier because
66 % they might have appeared in the input file name.
67 \everyjob{\message{[Texinfo version \texinfoversion]}%
68   \catcode`+=\active \catcode`\_=\active}
69
70 \chardef\other=12
71
72 % We never want plain's \outer definition of \+ in Texinfo.
73 % For @tex, we can use \tabalign.
74 \let\+ = \relax
75
76 % Save some plain tex macros whose names we will redefine.
77 \let\ptexb=\b
78 \let\ptexbullet=\bullet
79 \let\ptexc=\c
80 \let\ptexcomma=\,
81 \let\ptexdot=\.
82 \let\ptexdots=\dots
83 \let\ptexend=\end
84 \let\ptexequiv=\equiv
85 \let\ptexexclam=\!
86 \let\ptexfootnote=\footnote
87 \let\ptexgtr=>
88 \let\ptexhat=^
89 \let\ptexi=\i
90 \let\ptexindent=\indent
91 \let\ptexinsert=\insert
92 \let\ptexlbrace=\{
93 \let\ptexless=<
94 \let\ptexnewwrite\newwrite
95 \let\ptexnoindent=\noindent
96 \let\ptexplus=+
97 \let\ptexraggedright=\raggedright
98 \let\ptexrbrace=\}
99 \let\ptexslash=\/
100 \let\ptexsp=\sp
101 \let\ptexstar=\*
102 \let\ptexsup=\sup
103 \let\ptext=\t
104 \let\ptextop=\top
105 {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
106
107 % If this character appears in an error message or help string, it
108 % starts a new line in the output.
109 \newlinechar = `^^J
110
111 % Use TeX 3.0's \inputlineno to get the line number, for better error
112 % messages, but if we're using an old version of TeX, don't do anything.
113 %
114 \ifx\inputlineno\thisisundefined
115   \let\linenumber = \empty % Pre-3.0.
116 \else
117   \def\linenumber{l.\the\inputlineno:\space}
118 \fi
119
120 % Set up fixed words for English if not already set.
121 \ifx\putwordAppendix\undefined  \gdef\putwordAppendix{Appendix}\fi
122 \ifx\putwordChapter\undefined   \gdef\putwordChapter{Chapter}\fi
123 \ifx\putworderror\undefined     \gdef\putworderror{error}\fi
124 \ifx\putwordfile\undefined      \gdef\putwordfile{file}\fi
125 \ifx\putwordin\undefined        \gdef\putwordin{in}\fi
126 \ifx\putwordIndexIsEmpty\undefined       \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
127 \ifx\putwordIndexNonexistent\undefined   \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
128 \ifx\putwordInfo\undefined      \gdef\putwordInfo{Info}\fi
129 \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
130 \ifx\putwordMethodon\undefined  \gdef\putwordMethodon{Method on}\fi
131 \ifx\putwordNoTitle\undefined   \gdef\putwordNoTitle{No Title}\fi
132 \ifx\putwordof\undefined        \gdef\putwordof{of}\fi
133 \ifx\putwordon\undefined        \gdef\putwordon{on}\fi
134 \ifx\putwordpage\undefined      \gdef\putwordpage{page}\fi
135 \ifx\putwordsection\undefined   \gdef\putwordsection{section}\fi
136 \ifx\putwordSection\undefined   \gdef\putwordSection{Section}\fi
137 \ifx\putwordsee\undefined       \gdef\putwordsee{see}\fi
138 \ifx\putwordSee\undefined       \gdef\putwordSee{See}\fi
139 \ifx\putwordShortTOC\undefined  \gdef\putwordShortTOC{Short Contents}\fi
140 \ifx\putwordTOC\undefined       \gdef\putwordTOC{Table of Contents}\fi
141 %
142 \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
143 \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
144 \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
145 \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
146 \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
147 \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
148 \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
149 \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
150 \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
151 \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
152 \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
153 \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
154 %
155 \ifx\putwordDefmac\undefined    \gdef\putwordDefmac{Macro}\fi
156 \ifx\putwordDefspec\undefined   \gdef\putwordDefspec{Special Form}\fi
157 \ifx\putwordDefvar\undefined    \gdef\putwordDefvar{Variable}\fi
158 \ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
159 \ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
160
161 % Give the space character the catcode for a space.
162 \def\spaceisspace{\catcode`\ =10\relax}
163
164 \chardef\dashChar  = `\-
165 \chardef\slashChar = `\/
166 \chardef\underChar = `\_
167
168 % Ignore a token.
169 %
170 \def\gobble#1{}
171
172 % The following is used inside several \edef's.
173 \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
174
175 % Hyphenation fixes.
176 \hyphenation{
177   Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
178   ap-pen-dix bit-map bit-maps
179   data-base data-bases eshell fall-ing half-way long-est man-u-script
180   man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
181   par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
182   spell-ing spell-ings
183   stand-alone strong-est time-stamp time-stamps which-ever white-space
184   wide-spread wrap-around
185 }
186
187 % Sometimes it is convenient to have everything in the transcript file
188 % and nothing on the terminal.  We don't just call \tracingall here,
189 % since that produces some useless output on the terminal.  We also make
190 % some effort to order the tracing commands to reduce output in the log
191 % file; cf. trace.sty in LaTeX.
192 %
193 \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
194 \def\loggingall{%
195   \tracingstats2
196   \tracingpages1
197   \tracinglostchars2  % 2 gives us more in etex
198   \tracingparagraphs1
199   \tracingoutput1
200   \tracingmacros2
201   \tracingrestores1
202   \showboxbreadth\maxdimen \showboxdepth\maxdimen
203   \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
204     \tracingscantokens1
205     \tracingifs1
206     \tracinggroups1
207     \tracingnesting2
208     \tracingassigns1
209   \fi
210   \tracingcommands3  % 3 gives us more in etex
211   \errorcontextlines16
212 }%
213
214 % @errormsg{MSG}.  Do the index-like expansions on MSG, but if things
215 % aren't perfect, it's not the end of the world, being an error message,
216 % after all.
217
218 \def\errormsg{\begingroup \indexnofonts \doerrormsg}
219 \def\doerrormsg#1{\errmessage{#1}}
220
221 % add check for \lastpenalty to plain's definitions.  If the last thing
222 % we did was a \nobreak, we don't want to insert more space.
223 %
224 \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
225   \removelastskip\penalty-50\smallskip\fi\fi}
226 \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
227   \removelastskip\penalty-100\medskip\fi\fi}
228 \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
229   \removelastskip\penalty-200\bigskip\fi\fi}
230
231 %\f Output routine
232 %
233
234 % For a final copy, take out the rectangles
235 % that mark overfull boxes (in case you have decided
236 % that the text looks ok even though it passes the margin).
237 %
238 \def\finalout{\overfullrule=0pt }
239
240 % Do @cropmarks to get crop marks.
241 %
242 \newif\ifcropmarks
243 \let\cropmarks = \cropmarkstrue
244 %
245 % Dimensions to add cropmarks at corners.
246 % Added by P. A. MacKay, 12 Nov. 1986
247 %
248 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
249 \newdimen\cornerlong  \cornerlong=1pc
250 \newdimen\cornerthick \cornerthick=.3pt
251 \newdimen\topandbottommargin \topandbottommargin=.75in
252
253 % Output a mark which sets \thischapter, \thissection and \thiscolor.
254 % We dump everything together because we only have one kind of mark.
255 % This works because we only use \botmark / \topmark, not \firstmark.
256 %
257 % A mark contains a subexpression of the \ifcase ... \fi construct.
258 % \get*marks macros below extract the needed part using \ifcase.
259 %
260 % Another complication is to let the user choose whether \thischapter
261 % (\thissection) refers to the chapter (section) in effect at the top
262 % of a page, or that at the bottom of a page.
263
264 % \domark is called twice inside \chapmacro, to add one
265 % mark before the section break, and one after.
266 %   In the second call \prevchapterdefs is the same as \lastchapterdefs,
267 % and \prevsectiondefs is the same as \lastsectiondefs.
268 %   Then if the page is not broken at the mark, some of the previous
269 % section appears on the page, and we can get the name of this section
270 % from \firstmark for @everyheadingmarks top.
271 %   @everyheadingmarks bottom uses \botmark.
272 %
273 % See page 260 of The TeXbook.
274 \def\domark{%
275   \toks0=\expandafter{\lastchapterdefs}%
276   \toks2=\expandafter{\lastsectiondefs}%
277   \toks4=\expandafter{\prevchapterdefs}%
278   \toks6=\expandafter{\prevsectiondefs}%
279   \toks8=\expandafter{\lastcolordefs}%
280   \mark{%
281                    \the\toks0 \the\toks2  % 0: marks for @everyheadingmarks top
282       \noexpand\or \the\toks4 \the\toks6  % 1: for @everyheadingmarks bottom
283     \noexpand\else \the\toks8             % 2: color marks
284   }%
285 }
286
287 % \gettopheadingmarks, \getbottomheadingmarks,
288 % \getcolormarks - extract needed part of mark.
289 %
290 % \topmark doesn't work for the very first chapter (after the title
291 % page or the contents), so we use \firstmark there -- this gets us
292 % the mark with the chapter defs, unless the user sneaks in, e.g.,
293 % @setcolor (or @url, or @link, etc.) between @contents and the very
294 % first @chapter.
295 \def\gettopheadingmarks{%
296   \ifcase0\topmark\fi
297   \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
298 }
299 \def\getbottomheadingmarks{\ifcase1\botmark\fi}
300 \def\getcolormarks{\ifcase2\topmark\fi}
301
302 % Avoid "undefined control sequence" errors.
303 \def\lastchapterdefs{}
304 \def\lastsectiondefs{}
305 \def\lastsection{}
306 \def\prevchapterdefs{}
307 \def\prevsectiondefs{}
308 \def\lastcolordefs{}
309
310 % Margin to add to right of even pages, to left of odd pages.
311 \newdimen\bindingoffset
312 \newdimen\normaloffset
313 \newdimen\txipagewidth \newdimen\txipageheight
314
315 % Main output routine.
316 %
317 \chardef\PAGE = 255
318 \output = {\onepageout{\pagecontents\PAGE}}
319
320 \newbox\headlinebox
321 \newbox\footlinebox
322
323 % \onepageout takes a vbox as an argument.
324 % \shipout a vbox for a single page, adding an optional header, footer,
325 % cropmarks, and footnote.  This also causes index entries for this page
326 % to be written to the auxiliary files.
327 %
328 \def\onepageout#1{%
329   \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
330   %
331   \ifodd\pageno  \advance\hoffset by \bindingoffset
332   \else \advance\hoffset by -\bindingoffset\fi
333   %
334   % Common context changes for both heading and footing.
335   % Do this outside of the \shipout so @code etc. will be expanded in
336   % the headline as they should be, not taken literally (outputting ''code).
337   \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars}
338   %
339   % Retrieve the information for the headings from the marks in the page,
340   % and call Plain TeX's \makeheadline and \makefootline, which use the
341   % values in \headline and \footline.
342   %
343   % This is used to check if we are on the first page of a chapter.
344   \ifcase1\topmark\fi
345   \let\prevchaptername\thischaptername
346   \ifcase0\firstmark\fi
347   \let\curchaptername\thischaptername
348   %
349   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
350   \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
351   %
352   \ifx\curchaptername\prevchaptername
353     \let\thischapterheading\thischapter
354   \else
355     % \thischapterheading is the same as \thischapter except it is blank
356     % for the first page of a chapter.  This is to prevent the chapter name 
357     % being shown twice.
358     \def\thischapterheading{}%
359   \fi
360   %
361   \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}%
362   \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}%
363   %
364   {%
365     % Set context for writing to auxiliary files like index files.
366     % Have to do this stuff outside the \shipout because we want it to
367     % take effect in \write's, yet the group defined by the \vbox ends
368     % before the \shipout runs.
369     %
370     \indexdummies         % don't expand commands in the output.
371     \normalturnoffactive  % \ in index entries must not stay \, e.g., if
372                % the page break happens to be in the middle of an example.
373                % We don't want .vr (or whatever) entries like this:
374                % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}}
375                % "\acronym" won't work when it's read back in;
376                % it needs to be
377                % {\code {{\backslashcurfont }acronym}
378     \shipout\vbox{%
379       % Do this early so pdf references go to the beginning of the page.
380       \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
381       %
382       \ifcropmarks \vbox to \outervsize\bgroup
383         \hsize = \outerhsize
384         \vskip-\topandbottommargin
385         \vtop to0pt{%
386           \line{\ewtop\hfil\ewtop}%
387           \nointerlineskip
388           \line{%
389             \vbox{\moveleft\cornerthick\nstop}%
390             \hfill
391             \vbox{\moveright\cornerthick\nstop}%
392           }%
393           \vss}%
394         \vskip\topandbottommargin
395         \line\bgroup
396           \hfil % center the page within the outer (page) hsize.
397           \ifodd\pageno\hskip\bindingoffset\fi
398           \vbox\bgroup
399       \fi
400       %
401       \unvbox\headlinebox
402       \pagebody{#1}%
403       \ifdim\ht\footlinebox > 0pt
404         % Only leave this space if the footline is nonempty.
405         % (We lessened \vsize for it in \oddfootingyyy.)
406         % The \baselineskip=24pt in plain's \makefootline has no effect.
407         \vskip 24pt
408         \unvbox\footlinebox
409       \fi
410       %
411       \ifcropmarks
412           \egroup % end of \vbox\bgroup
413         \hfil\egroup % end of (centering) \line\bgroup
414         \vskip\topandbottommargin plus1fill minus1fill
415         \boxmaxdepth = \cornerthick
416         \vbox to0pt{\vss
417           \line{%
418             \vbox{\moveleft\cornerthick\nsbot}%
419             \hfill
420             \vbox{\moveright\cornerthick\nsbot}%
421           }%
422           \nointerlineskip
423           \line{\ewbot\hfil\ewbot}%
424         }%
425       \egroup % \vbox from first cropmarks clause
426       \fi
427     }% end of \shipout\vbox
428   }% end of group with \indexdummies
429   \advancepageno
430   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
431 }
432
433 \newinsert\margin \dimen\margin=\maxdimen
434
435 % Main part of page, including any footnotes
436 \def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
437 {\catcode`\@ =11
438 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
439 % marginal hacks, juha@viisa.uucp (Juha Takala)
440 \ifvoid\margin\else % marginal info is present
441   \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
442 \dimen@=\dp#1\relax \unvbox#1\relax
443 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
444 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
445 }
446
447 % Here are the rules for the cropmarks.  Note that they are
448 % offset so that the space between them is truly \outerhsize or \outervsize
449 % (P. A. MacKay, 12 November, 1986)
450 %
451 \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
452 \def\nstop{\vbox
453   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
454 \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
455 \def\nsbot{\vbox
456   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
457
458
459 % Argument parsing
460
461 % Parse an argument, then pass it to #1.  The argument is the rest of
462 % the input line (except we remove a trailing comment).  #1 should be a
463 % macro which expects an ordinary undelimited TeX argument.
464 % For example, \def\foo{\parsearg\fooxxx}.
465 %
466 \def\parsearg{\parseargusing{}}
467 \def\parseargusing#1#2{%
468   \def\argtorun{#2}%
469   \begingroup
470     \obeylines
471     \spaceisspace
472     #1%
473     \parseargline\empty% Insert the \empty token, see \finishparsearg below.
474 }
475
476 {\obeylines %
477   \gdef\parseargline#1^^M{%
478     \endgroup % End of the group started in \parsearg.
479     \argremovecomment #1\comment\ArgTerm%
480   }%
481 }
482
483 % First remove any @comment, then any @c comment.  Also remove a @texinfoc
484 % comment (see \scanmacro for details).  Pass the result on to \argcheckspaces.
485 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
486 \def\argremovec#1\c#2\ArgTerm{\argremovetexinfoc #1\texinfoc\ArgTerm}
487 \def\argremovetexinfoc#1\texinfoc#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
488
489 % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
490 %
491 % \argremovec might leave us with trailing space, e.g.,
492 %    @end itemize  @c foo
493 % This space token undergoes the same procedure and is eventually removed
494 % by \finishparsearg.
495 %
496 \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
497 \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
498 \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
499   \def\temp{#3}%
500   \ifx\temp\empty
501     % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
502     \let\temp\finishparsearg
503   \else
504     \let\temp\argcheckspaces
505   \fi
506   % Put the space token in:
507   \temp#1 #3\ArgTerm
508 }
509
510 % If a _delimited_ argument is enclosed in braces, they get stripped; so
511 % to get _exactly_ the rest of the line, we had to prevent such situation.
512 % We prepended an \empty token at the very beginning and we expand it now,
513 % just before passing the control to \argtorun.
514 % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
515 % either the null string, or it ends with \^^M---thus there is no danger
516 % that a pair of braces would be stripped.
517 %
518 % But first, we have to remove the trailing space token.
519 %
520 \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
521
522
523 % \parseargdef - define a command taking an argument on the line
524 %
525 % \parseargdef\foo{...}
526 %       is roughly equivalent to
527 % \def\foo{\parsearg\Xfoo}
528 % \def\Xfoo#1{...}
529 \def\parseargdef#1{%
530   \expandafter \doparseargdef \csname\string#1\endcsname #1%
531 }
532 \def\doparseargdef#1#2{%
533   \def#2{\parsearg#1}%
534   \def#1##1%
535 }
536
537 % Several utility definitions with active space:
538 {
539   \obeyspaces
540   \gdef\obeyedspace{ }
541
542   % Make each space character in the input produce a normal interword
543   % space in the output.  Don't allow a line break at this space, as this
544   % is used only in environments like @example, where each line of input
545   % should produce a line of output anyway.
546   %
547   \gdef\sepspaces{\obeyspaces\let =\tie}
548
549   % If an index command is used in an @example environment, any spaces
550   % therein should become regular spaces in the raw index file, not the
551   % expansion of \tie (\leavevmode \penalty \@M \ ).
552   \gdef\unsepspaces{\let =\space}
553 }
554
555
556 \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
557
558 % Define the framework for environments in texinfo.tex.  It's used like this:
559 %
560 %   \envdef\foo{...}
561 %   \def\Efoo{...}
562 %
563 % It's the responsibility of \envdef to insert \begingroup before the
564 % actual body; @end closes the group after calling \Efoo.  \envdef also
565 % defines \thisenv, so the current environment is known; @end checks
566 % whether the environment name matches.  The \checkenv macro can also be
567 % used to check whether the current environment is the one expected.
568 %
569 % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
570 % are not treated as environments; they don't open a group.  (The
571 % implementation of @end takes care not to call \endgroup in this
572 % special case.)
573
574
575 % At run-time, environments start with this:
576 \def\startenvironment#1{\begingroup\def\thisenv{#1}}
577 % initialize
578 \let\thisenv\empty
579
580 % ... but they get defined via ``\envdef\foo{...}'':
581 \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
582 \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
583
584 % Check whether we're in the right environment:
585 \def\checkenv#1{%
586   \def\temp{#1}%
587   \ifx\thisenv\temp
588   \else
589     \badenverr
590   \fi
591 }
592
593 % Environment mismatch, #1 expected:
594 \def\badenverr{%
595   \errhelp = \EMsimple
596   \errmessage{This command can appear only \inenvironment\temp,
597     not \inenvironment\thisenv}%
598 }
599 \def\inenvironment#1{%
600   \ifx#1\empty
601     outside of any environment%
602   \else
603     in environment \expandafter\string#1%
604   \fi
605 }
606
607 % @end foo executes the definition of \Efoo.
608 % But first, it executes a specialized version of \checkenv
609 %
610 \parseargdef\end{%
611   \if 1\csname iscond.#1\endcsname
612   \else
613     % The general wording of \badenverr may not be ideal.
614     \expandafter\checkenv\csname#1\endcsname
615     \csname E#1\endcsname
616     \endgroup
617   \fi
618 }
619
620 \newhelp\EMsimple{Press RETURN to continue.}
621
622
623 % Be sure we're in horizontal mode when doing a tie, since we make space
624 % equivalent to this in @example-like environments. Otherwise, a space
625 % at the beginning of a line will start with \penalty -- and
626 % since \penalty is valid in vertical mode, we'd end up putting the
627 % penalty on the vertical list instead of in the new paragraph.
628 {\catcode`@ = 11
629  % Avoid using \@M directly, because that causes trouble
630  % if the definition is written into an index file.
631  \global\let\tiepenalty = \@M
632  \gdef\tie{\leavevmode\penalty\tiepenalty\ }
633 }
634
635 % @: forces normal size whitespace following.
636 \def\:{\spacefactor=1000 }
637
638 % @* forces a line break.
639 \def\*{\unskip\hfil\break\hbox{}\ignorespaces}
640
641 % @/ allows a line break.
642 \let\/=\allowbreak
643
644 % @. is an end-of-sentence period.
645 \def\.{.\spacefactor=\endofsentencespacefactor\space}
646
647 % @! is an end-of-sentence bang.
648 \def\!{!\spacefactor=\endofsentencespacefactor\space}
649
650 % @? is an end-of-sentence query.
651 \def\?{?\spacefactor=\endofsentencespacefactor\space}
652
653 % @frenchspacing on|off  says whether to put extra space after punctuation.
654 %
655 \def\onword{on}
656 \def\offword{off}
657 %
658 \parseargdef\frenchspacing{%
659   \def\temp{#1}%
660   \ifx\temp\onword \plainfrenchspacing
661   \else\ifx\temp\offword \plainnonfrenchspacing
662   \else
663     \errhelp = \EMsimple
664     \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
665   \fi\fi
666 }
667
668 % @w prevents a word break.  Without the \leavevmode, @w at the
669 % beginning of a paragraph, when TeX is still in vertical mode, would
670 % produce a whole line of output instead of starting the paragraph.
671 \def\w#1{\leavevmode\hbox{#1}}
672
673 % @group ... @end group forces ... to be all on one page, by enclosing
674 % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
675 % to keep its height that of a normal line.  According to the rules for
676 % \topskip (p.114 of the TeXbook), the glue inserted is
677 % max (\topskip - \ht (first item), 0).  If that height is large,
678 % therefore, no glue is inserted, and the space between the headline and
679 % the text is small, which looks bad.
680 %
681 % Another complication is that the group might be very large.  This can
682 % cause the glue on the previous page to be unduly stretched, because it
683 % does not have much material.  In this case, it's better to add an
684 % explicit \vfill so that the extra space is at the bottom.  The
685 % threshold for doing this is if the group is more than \vfilllimit
686 % percent of a page (\vfilllimit can be changed inside of @tex).
687 %
688 \newbox\groupbox
689 \def\vfilllimit{0.7}
690 %
691 \envdef\group{%
692   \ifnum\catcode`\^^M=\active \else
693     \errhelp = \groupinvalidhelp
694     \errmessage{@group invalid in context where filling is enabled}%
695   \fi
696   \startsavinginserts
697   %
698   \setbox\groupbox = \vtop\bgroup
699     % Do @comment since we are called inside an environment such as
700     % @example, where each end-of-line in the input causes an
701     % end-of-line in the output.  We don't want the end-of-line after
702     % the `@group' to put extra space in the output.  Since @group
703     % should appear on a line by itself (according to the Texinfo
704     % manual), we don't worry about eating any user text.
705     \comment
706 }
707 %
708 % The \vtop produces a box with normal height and large depth; thus, TeX puts
709 % \baselineskip glue before it, and (when the next line of text is done)
710 % \lineskip glue after it.  Thus, space below is not quite equal to space
711 % above.  But it's pretty close.
712 \def\Egroup{%
713     % To get correct interline space between the last line of the group
714     % and the first line afterwards, we have to propagate \prevdepth.
715     \endgraf % Not \par, as it may have been set to \lisppar.
716     \global\dimen1 = \prevdepth
717   \egroup           % End the \vtop.
718   \addgroupbox
719   \prevdepth = \dimen1
720   \checkinserts
721 }
722
723 \def\addgroupbox{
724   % \dimen0 is the vertical size of the group's box.
725   \dimen0 = \ht\groupbox  \advance\dimen0 by \dp\groupbox
726   % \dimen2 is how much space is left on the page (more or less).
727   \dimen2 = \txipageheight   \advance\dimen2 by -\pagetotal
728   % if the group doesn't fit on the current page, and it's a big big
729   % group, force a page break.
730   \ifdim \dimen0 > \dimen2
731     \ifdim \pagetotal < \vfilllimit\txipageheight
732       \page
733     \fi
734   \fi
735   \box\groupbox
736 }
737
738 %
739 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
740 % message, so this ends up printing `@group can only ...'.
741 %
742 \newhelp\groupinvalidhelp{%
743 group can only be used in environments such as @example,^^J%
744 where each line of input produces a line of output.}
745
746 % @need space-in-mils
747 % forces a page break if there is not space-in-mils remaining.
748
749 \newdimen\mil  \mil=0.001in
750
751 \parseargdef\need{%
752   % Ensure vertical mode, so we don't make a big box in the middle of a
753   % paragraph.
754   \par
755   %
756   % If the @need value is less than one line space, it's useless.
757   \dimen0 = #1\mil
758   \dimen2 = \ht\strutbox
759   \advance\dimen2 by \dp\strutbox
760   \ifdim\dimen0 > \dimen2
761     %
762     % Do a \strut just to make the height of this box be normal, so the
763     % normal leading is inserted relative to the preceding line.
764     % And a page break here is fine.
765     \vtop to #1\mil{\strut\vfil}%
766     %
767     % TeX does not even consider page breaks if a penalty added to the
768     % main vertical list is 10000 or more.  But in order to see if the
769     % empty box we just added fits on the page, we must make it consider
770     % page breaks.  On the other hand, we don't want to actually break the
771     % page after the empty box.  So we use a penalty of 9999.
772     %
773     % There is an extremely small chance that TeX will actually break the
774     % page at this \penalty, if there are no other feasible breakpoints in
775     % sight.  (If the user is using lots of big @group commands, which
776     % almost-but-not-quite fill up a page, TeX will have a hard time doing
777     % good page breaking, for example.)  However, I could not construct an
778     % example where a page broke at this \penalty; if it happens in a real
779     % document, then we can reconsider our strategy.
780     \penalty9999
781     %
782     % Back up by the size of the box, whether we did a page break or not.
783     \kern -#1\mil
784     %
785     % Do not allow a page break right after this kern.
786     \nobreak
787   \fi
788 }
789
790 % @br   forces paragraph break (and is undocumented).
791
792 \let\br = \par
793
794 % @page forces the start of a new page.
795 %
796 \def\page{\par\vfill\supereject}
797
798 % @exdent text....
799 % outputs text on separate line in roman font, starting at standard page margin
800
801 % This records the amount of indent in the innermost environment.
802 % That's how much \exdent should take out.
803 \newskip\exdentamount
804
805 % This defn is used inside fill environments such as @defun.
806 \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
807
808 % This defn is used inside nofill environments such as @example.
809 \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
810   \leftline{\hskip\leftskip{\rm#1}}}}
811
812 % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
813 % paragraph.  For more general purposes, use the \margin insertion
814 % class.  WHICH is `l' or `r'.  Not documented, written for gawk manual.
815 %
816 \newskip\inmarginspacing \inmarginspacing=1cm
817 \def\strutdepth{\dp\strutbox}
818 %
819 \def\doinmargin#1#2{\strut\vadjust{%
820   \nobreak
821   \kern-\strutdepth
822   \vtop to \strutdepth{%
823     \baselineskip=\strutdepth
824     \vss
825     % if you have multiple lines of stuff to put here, you'll need to
826     % make the vbox yourself of the appropriate size.
827     \ifx#1l%
828       \llap{\ignorespaces #2\hskip\inmarginspacing}%
829     \else
830       \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
831     \fi
832     \null
833   }%
834 }}
835 \def\inleftmargin{\doinmargin l}
836 \def\inrightmargin{\doinmargin r}
837 %
838 % @inmargin{TEXT [, RIGHT-TEXT]}
839 % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
840 % else use TEXT for both).
841 %
842 \def\inmargin#1{\parseinmargin #1,,\finish}
843 \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
844   \setbox0 = \hbox{\ignorespaces #2}%
845   \ifdim\wd0 > 0pt
846     \def\lefttext{#1}%  have both texts
847     \def\righttext{#2}%
848   \else
849     \def\lefttext{#1}%  have only one text
850     \def\righttext{#1}%
851   \fi
852   %
853   \ifodd\pageno
854     \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
855   \else
856     \def\temp{\inleftmargin\lefttext}%
857   \fi
858   \temp
859 }
860
861 % @| inserts a changebar to the left of the current line.  It should
862 % surround any changed text.  This approach does *not* work if the
863 % change spans more than two lines of output.  To handle that, we would
864 % have adopt a much more difficult approach (putting marks into the main
865 % vertical list for the beginning and end of each change).  This command
866 % is not documented, not supported, and doesn't work.
867 %
868 \def\|{%
869   % \vadjust can only be used in horizontal mode.
870   \leavevmode
871   %
872   % Append this vertical mode material after the current line in the output.
873   \vadjust{%
874     % We want to insert a rule with the height and depth of the current
875     % leading; that is exactly what \strutbox is supposed to record.
876     \vskip-\baselineskip
877     %
878     % \vadjust-items are inserted at the left edge of the type.  So
879     % the \llap here moves out into the left-hand margin.
880     \llap{%
881       %
882       % For a thicker or thinner bar, change the `1pt'.
883       \vrule height\baselineskip width1pt
884       %
885       % This is the space between the bar and the text.
886       \hskip 12pt
887     }%
888   }%
889 }
890
891 % @include FILE -- \input text of FILE.
892 %
893 \def\include{\parseargusing\filenamecatcodes\includezzz}
894 \def\includezzz#1{%
895   \pushthisfilestack
896   \def\thisfile{#1}%
897   {%
898     \makevalueexpandable  % we want to expand any @value in FILE.
899     \turnoffactive        % and allow special characters in the expansion
900     \indexnofonts         % Allow `@@' and other weird things in file names.
901     \wlog{texinfo.tex: doing @include of #1^^J}%
902     \edef\temp{\noexpand\input #1 }%
903     %
904     % This trickery is to read FILE outside of a group, in case it makes
905     % definitions, etc.
906     \expandafter
907   }\temp
908   \popthisfilestack
909 }
910 \def\filenamecatcodes{%
911   \catcode`\\=\other
912   \catcode`~=\other
913   \catcode`^=\other
914   \catcode`_=\other
915   \catcode`|=\other
916   \catcode`<=\other
917   \catcode`>=\other
918   \catcode`+=\other
919   \catcode`-=\other
920   \catcode`\`=\other
921   \catcode`\'=\other
922 }
923
924 \def\pushthisfilestack{%
925   \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
926 }
927 \def\pushthisfilestackX{%
928   \expandafter\pushthisfilestackY\thisfile\StackTerm
929 }
930 \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
931   \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
932 }
933
934 \def\popthisfilestack{\errthisfilestackempty}
935 \def\errthisfilestackempty{\errmessage{Internal error:
936   the stack of filenames is empty.}}
937 %
938 \def\thisfile{}
939
940 % @center line
941 % outputs that line, centered.
942 %
943 \parseargdef\center{%
944   \ifhmode
945     \let\centersub\centerH
946   \else
947     \let\centersub\centerV
948   \fi
949   \centersub{\hfil \ignorespaces#1\unskip \hfil}%
950   \let\centersub\relax % don't let the definition persist, just in case
951 }
952 \def\centerH#1{{%
953   \hfil\break
954   \advance\hsize by -\leftskip
955   \advance\hsize by -\rightskip
956   \line{#1}%
957   \break
958 }}
959 %
960 \newcount\centerpenalty
961 \def\centerV#1{%
962   % The idea here is the same as in \startdefun, \cartouche, etc.: if
963   % @center is the first thing after a section heading, we need to wipe
964   % out the negative parskip inserted by \sectionheading, but still
965   % prevent a page break here.
966   \centerpenalty = \lastpenalty
967   \ifnum\centerpenalty>10000 \vskip\parskip \fi
968   \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
969   \line{\kern\leftskip #1\kern\rightskip}%
970 }
971
972 % @sp n   outputs n lines of vertical space
973 %
974 \parseargdef\sp{\vskip #1\baselineskip}
975
976 % @comment ...line which is ignored...
977 % @c is the same as @comment
978 % @ignore ... @end ignore  is another way to write a comment
979 %
980 \def\comment{\begingroup \catcode`\^^M=\active%
981 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other\commentxxx}%
982
983 {\catcode`\^^M=\active%
984 \gdef\commentxxx#1^^M{\endgroup%
985 \futurelet\nexttoken\commentxxxx}%
986 \gdef\commentxxxx{\ifx\nexttoken\aftermacro\expandafter\comment\fi}%
987 }
988
989 \def\c{\begingroup \catcode`\^^M=\active%
990 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
991 \cxxx}
992 {\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
993 % See comment in \scanmacro about why the definitions of @c and @comment differ
994
995 % @paragraphindent NCHARS
996 % We'll use ems for NCHARS, close enough.
997 % NCHARS can also be the word `asis' or `none'.
998 % We cannot feasibly implement @paragraphindent asis, though.
999 %
1000 \def\asisword{asis} % no translation, these are keywords
1001 \def\noneword{none}
1002 %
1003 \parseargdef\paragraphindent{%
1004   \def\temp{#1}%
1005   \ifx\temp\asisword
1006   \else
1007     \ifx\temp\noneword
1008       \defaultparindent = 0pt
1009     \else
1010       \defaultparindent = #1em
1011     \fi
1012   \fi
1013   \parindent = \defaultparindent
1014 }
1015
1016 % @exampleindent NCHARS
1017 % We'll use ems for NCHARS like @paragraphindent.
1018 % It seems @exampleindent asis isn't necessary, but
1019 % I preserve it to make it similar to @paragraphindent.
1020 \parseargdef\exampleindent{%
1021   \def\temp{#1}%
1022   \ifx\temp\asisword
1023   \else
1024     \ifx\temp\noneword
1025       \lispnarrowing = 0pt
1026     \else
1027       \lispnarrowing = #1em
1028     \fi
1029   \fi
1030 }
1031
1032 % @firstparagraphindent WORD
1033 % If WORD is `none', then suppress indentation of the first paragraph
1034 % after a section heading.  If WORD is `insert', then do indent at such
1035 % paragraphs.
1036 %
1037 % The paragraph indentation is suppressed or not by calling
1038 % \suppressfirstparagraphindent, which the sectioning commands do.
1039 % We switch the definition of this back and forth according to WORD.
1040 % By default, we suppress indentation.
1041 %
1042 \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
1043 \def\insertword{insert}
1044 %
1045 \parseargdef\firstparagraphindent{%
1046   \def\temp{#1}%
1047   \ifx\temp\noneword
1048     \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
1049   \else\ifx\temp\insertword
1050     \let\suppressfirstparagraphindent = \relax
1051   \else
1052     \errhelp = \EMsimple
1053     \errmessage{Unknown @firstparagraphindent option `\temp'}%
1054   \fi\fi
1055 }
1056
1057 % Here is how we actually suppress indentation.  Redefine \everypar to
1058 % \kern backwards by \parindent, and then reset itself to empty.
1059 %
1060 % We also make \indent itself not actually do anything until the next
1061 % paragraph.
1062 %
1063 \gdef\dosuppressfirstparagraphindent{%
1064   \gdef\indent  {\restorefirstparagraphindent \indent}%
1065   \gdef\noindent{\restorefirstparagraphindent \noindent}%
1066   \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
1067 }
1068 %
1069 \gdef\restorefirstparagraphindent{%
1070   \global\let\indent = \ptexindent
1071   \global\let\noindent = \ptexnoindent
1072   \global\everypar = {}%
1073 }
1074
1075
1076 % @refill is a no-op.
1077 \let\refill=\relax
1078
1079 % @setfilename INFO-FILENAME - ignored
1080 \let\setfilename=\comment
1081
1082 % @bye.
1083 \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
1084
1085
1086 \message{pdf,}
1087 % adobe `portable' document format
1088 \newcount\tempnum
1089 \newcount\lnkcount
1090 \newtoks\filename
1091 \newcount\filenamelength
1092 \newcount\pgn
1093 \newtoks\toksA
1094 \newtoks\toksB
1095 \newtoks\toksC
1096 \newtoks\toksD
1097 \newbox\boxA
1098 \newbox\boxB
1099 \newcount\countA
1100 \newif\ifpdf
1101 \newif\ifpdfmakepagedest
1102
1103 %
1104 % For LuaTeX
1105 %
1106
1107 \ifx\luatexversion\thisisundefined
1108 \else
1109   % Escape PDF strings UTF-8 to UTF-16
1110   \begingroup
1111     \catcode`\%=12
1112     \directlua{
1113       function UTF16oct(str)
1114         tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
1115         for c in string.utfvalues(str) do
1116           if c < 0x10000 then
1117             tex.sprint(
1118               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1119                             string.char(0x5c) .. string.char(0x25) .. '03o',
1120                             (c / 256), (c % 256)))
1121           else
1122             c = c - 0x10000
1123             local c_hi = c / 1024 + 0xd800
1124             local c_lo = c % 1024 + 0xdc00
1125             tex.sprint(
1126               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1127                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
1128                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
1129                             string.char(0x5c) .. string.char(0x25) .. '03o',
1130                             (c_hi / 256), (c_hi % 256),
1131                             (c_lo / 256), (c_lo % 256)))
1132           end
1133         end
1134       end
1135     }
1136   \endgroup
1137   \def\pdfescapestring#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
1138   \ifnum\luatexversion>84
1139     % For LuaTeX >= 0.85
1140     \def\pdfdest{\pdfextension dest}
1141     \let\pdfoutput\outputmode
1142     \def\pdfliteral{\pdfextension literal}
1143     \def\pdfcatalog{\pdfextension catalog}
1144     \def\pdftexversion{\numexpr\pdffeedback version\relax}
1145     \let\pdfximage\saveimageresource
1146     \let\pdfrefximage\useimageresource
1147     \let\pdflastximage\lastsavedimageresourceindex
1148     \def\pdfendlink{\pdfextension endlink\relax}
1149     \def\pdfoutline{\pdfextension outline}
1150     \def\pdfstartlink{\pdfextension startlink}
1151     \def\pdffontattr{\pdfextension fontattr}
1152     \def\pdfobj{\pdfextension obj}
1153     \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
1154     \let\pdfpagewidth\pagewidth
1155     \let\pdfpageheight\pageheight
1156     \edef\pdfhorigin{\pdfvariable horigin}
1157     \edef\pdfvorigin{\pdfvariable vorigin}
1158   \fi
1159 \fi
1160
1161 % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1162 % can be set).  So we test for \relax and 0 as well as being undefined.
1163 \ifx\pdfoutput\thisisundefined
1164 \else
1165   \ifx\pdfoutput\relax
1166   \else
1167     \ifcase\pdfoutput
1168     \else
1169       \pdftrue
1170     \fi
1171   \fi
1172 \fi
1173
1174 % PDF uses PostScript string constants for the names of xref targets,
1175 % for display in the outlines, and in other places.  Thus, we have to
1176 % double any backslashes.  Otherwise, a name like "\node" will be
1177 % interpreted as a newline (\n), followed by o, d, e.  Not good.
1178
1179 % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
1180 % related messages.  The final outcome is that it is up to the TeX user
1181 % to double the backslashes and otherwise make the string valid, so
1182 % that's what we do.  pdftex 1.30.0 (ca.2005) introduced a primitive to
1183 % do this reliably, so we use it.
1184
1185 % #1 is a control sequence in which to do the replacements,
1186 % which we \xdef.
1187 \def\txiescapepdf#1{%
1188   \ifx\pdfescapestring\thisisundefined
1189     % No primitive available; should we give a warning or log?
1190     % Many times it won't matter.
1191   \else
1192     % The expandable \pdfescapestring primitive escapes parentheses,
1193     % backslashes, and other special chars.
1194     \xdef#1{\pdfescapestring{#1}}%
1195   \fi
1196 }
1197
1198 \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1199 with PDF output, and none of those formats could be found.  (.eps cannot
1200 be supported due to the design of the PDF format; use regular TeX (DVI
1201 output) for that.)}
1202
1203 \ifpdf
1204   %
1205   % Color manipulation macros using ideas from pdfcolor.tex,
1206   % except using rgb instead of cmyk; the latter is said to render as a
1207   % very dark gray on-screen and a very dark halftone in print, instead
1208   % of actual black. The dark red here is dark enough to print on paper as
1209   % nearly black, but still distinguishable for online viewing.  We use
1210   % black by default, though.
1211   \def\rgbDarkRed{0.50 0.09 0.12}
1212   \def\rgbBlack{0 0 0}
1213   %
1214   % rg sets the color for filling (usual text, etc.);
1215   % RG sets the color for stroking (thin rules, e.g., normal _'s).
1216   \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
1217   %
1218   % Set color, and create a mark which defines \thiscolor accordingly,
1219   % so that \makeheadline knows which color to restore.
1220   \def\setcolor#1{%
1221     \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
1222     \domark
1223     \pdfsetcolor{#1}%
1224   }
1225   %
1226   \def\maincolor{\rgbBlack}
1227   \pdfsetcolor{\maincolor}
1228   \edef\thiscolor{\maincolor}
1229   \def\lastcolordefs{}
1230   %
1231   \def\makefootline{%
1232     \baselineskip24pt
1233     \line{\pdfsetcolor{\maincolor}\the\footline}%
1234   }
1235   %
1236   \def\makeheadline{%
1237     \vbox to 0pt{%
1238       \vskip-22.5pt
1239       \line{%
1240         \vbox to8.5pt{}%
1241         % Extract \thiscolor definition from the marks.
1242         \getcolormarks
1243         % Typeset the headline with \maincolor, then restore the color.
1244         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1245       }%
1246       \vss
1247     }%
1248     \nointerlineskip
1249   }
1250   %
1251   %
1252   \pdfcatalog{/PageMode /UseOutlines}
1253   %
1254   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1255   \def\dopdfimage#1#2#3{%
1256     \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1257     \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1258     %
1259     % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1260     % others).  Let's try in that order, PDF first since if
1261     % someone has a scalable image, presumably better to use that than a
1262     % bitmap.
1263     \let\pdfimgext=\empty
1264     \begingroup
1265       \openin 1 #1.pdf \ifeof 1
1266         \openin 1 #1.PDF \ifeof 1
1267           \openin 1 #1.png \ifeof 1
1268             \openin 1 #1.jpg \ifeof 1
1269               \openin 1 #1.jpeg \ifeof 1
1270                 \openin 1 #1.JPG \ifeof 1
1271                   \errhelp = \nopdfimagehelp
1272                   \errmessage{Could not find image file #1 for pdf}%
1273                 \else \gdef\pdfimgext{JPG}%
1274                 \fi
1275               \else \gdef\pdfimgext{jpeg}%
1276               \fi
1277             \else \gdef\pdfimgext{jpg}%
1278             \fi
1279           \else \gdef\pdfimgext{png}%
1280           \fi
1281         \else \gdef\pdfimgext{PDF}%
1282         \fi
1283       \else \gdef\pdfimgext{pdf}%
1284       \fi
1285       \closein 1
1286     \endgroup
1287     %
1288     % without \immediate, ancient pdftex seg faults when the same image is
1289     % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
1290     \ifnum\pdftexversion < 14
1291       \immediate\pdfimage
1292     \else
1293       \immediate\pdfximage
1294     \fi
1295       \ifdim \wd0 >0pt width \pdfimagewidth \fi
1296       \ifdim \wd2 >0pt height \pdfimageheight \fi
1297       \ifnum\pdftexversion<13
1298          #1.\pdfimgext
1299        \else
1300          {#1.\pdfimgext}%
1301        \fi
1302     \ifnum\pdftexversion < 14 \else
1303       \pdfrefximage \pdflastximage
1304     \fi}
1305   %
1306   \def\pdfmkdest#1{{%
1307     % We have to set dummies so commands such as @code, and characters
1308     % such as \, aren't expanded when present in a section title.
1309     \indexnofonts
1310     \turnoffactive
1311     \makevalueexpandable
1312     \def\pdfdestname{#1}%
1313     \txiescapepdf\pdfdestname
1314     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1315   }}
1316   %
1317   % used to mark target names; must be expandable.
1318   \def\pdfmkpgn#1{#1}
1319   %
1320   % by default, use black for everything.
1321   \def\urlcolor{\rgbBlack}
1322   \def\linkcolor{\rgbBlack}
1323   \def\endlink{\setcolor{\maincolor}\pdfendlink}
1324   %
1325   % Adding outlines to PDF; macros for calculating structure of outlines
1326   % come from Petr Olsak
1327   \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1328     \else \csname#1\endcsname \fi}
1329   \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1330     \advance\tempnum by 1
1331     \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1332   %
1333   % #1 is the section text, which is what will be displayed in the
1334   % outline by the pdf viewer.  #2 is the pdf expression for the number
1335   % of subentries (or empty, for subsubsections).  #3 is the node text,
1336   % which might be empty if this toc entry had no corresponding node.
1337   % #4 is the page number
1338   %
1339   \def\dopdfoutline#1#2#3#4{%
1340     % Generate a link to the node text if that exists; else, use the
1341     % page number.  We could generate a destination for the section
1342     % text in the case where a section has no node, but it doesn't
1343     % seem worth the trouble, since most documents are normally structured.
1344     {
1345       \ifx\luatexversion\thisisundefined \else
1346         \turnoffactive % LuaTeX can use Unicode strings for PDF
1347       \fi
1348       \edef\pdfoutlinedest{#3}%
1349       \ifx\pdfoutlinedest\empty
1350         \def\pdfoutlinedest{#4}%
1351       \else
1352         \txiescapepdf\pdfoutlinedest
1353       \fi
1354       %
1355       % Also escape PDF chars in the display string.
1356       \edef\pdfoutlinetext{#1}%
1357       \txiescapepdf\pdfoutlinetext
1358       %
1359       \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
1360     }
1361   }
1362   %
1363   \def\pdfmakeoutlines{%
1364     \begingroup
1365       % Read toc silently, to get counts of subentries for \pdfoutline.
1366       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1367       \def\numchapentry##1##2##3##4{%
1368         \def\thischapnum{##2}%
1369         \def\thissecnum{0}%
1370         \def\thissubsecnum{0}%
1371       }%
1372       \def\numsecentry##1##2##3##4{%
1373         \advancenumber{chap\thischapnum}%
1374         \def\thissecnum{##2}%
1375         \def\thissubsecnum{0}%
1376       }%
1377       \def\numsubsecentry##1##2##3##4{%
1378         \advancenumber{sec\thissecnum}%
1379         \def\thissubsecnum{##2}%
1380       }%
1381       \def\numsubsubsecentry##1##2##3##4{%
1382         \advancenumber{subsec\thissubsecnum}%
1383       }%
1384       \def\thischapnum{0}%
1385       \def\thissecnum{0}%
1386       \def\thissubsecnum{0}%
1387       %
1388       % use \def rather than \let here because we redefine \chapentry et
1389       % al. a second time, below.
1390       \def\appentry{\numchapentry}%
1391       \def\appsecentry{\numsecentry}%
1392       \def\appsubsecentry{\numsubsecentry}%
1393       \def\appsubsubsecentry{\numsubsubsecentry}%
1394       \def\unnchapentry{\numchapentry}%
1395       \def\unnsecentry{\numsecentry}%
1396       \def\unnsubsecentry{\numsubsecentry}%
1397       \def\unnsubsubsecentry{\numsubsubsecentry}%
1398       \readdatafile{toc}%
1399       %
1400       % Read toc second time, this time actually producing the outlines.
1401       % The `-' means take the \expnumber as the absolute number of
1402       % subentries, which we calculated on our first read of the .toc above.
1403       %
1404       % We use the node names as the destinations.
1405       \def\numchapentry##1##2##3##4{%
1406         \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1407       \def\numsecentry##1##2##3##4{%
1408         \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1409       \def\numsubsecentry##1##2##3##4{%
1410         \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1411       \def\numsubsubsecentry##1##2##3##4{% count is always zero
1412         \dopdfoutline{##1}{}{##3}{##4}}%
1413       %
1414       % PDF outlines are displayed using system fonts, instead of
1415       % document fonts.  Therefore we cannot use special characters,
1416       % since the encoding is unknown.  For example, the eogonek from
1417       % Latin 2 (0xea) gets translated to a | character.  Info from
1418       % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1419       %
1420       % TODO this right, we have to translate 8-bit characters to
1421       % their "best" equivalent, based on the @documentencoding.  Too
1422       % much work for too little return.  Just use the ASCII equivalents
1423       % we use for the index sort strings.
1424       % 
1425       \indexnofonts
1426       \setupdatafile
1427       % We can have normal brace characters in the PDF outlines, unlike
1428       % Texinfo index files.  So set that up.
1429       \def\{{\lbracecharliteral}%
1430       \def\}{\rbracecharliteral}%
1431       \catcode`\\=\active \otherbackslash
1432       \input \tocreadfilename
1433     \endgroup
1434   }
1435   {\catcode`[=1 \catcode`]=2
1436    \catcode`{=\other \catcode`}=\other
1437    \gdef\lbracecharliteral[{]%
1438    \gdef\rbracecharliteral[}]%
1439   ]
1440   %
1441   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1442     \ifx\PP\D\let\nextsp\relax
1443     \else\let\nextsp\skipspaces
1444       \addtokens{\filename}{\PP}%
1445       \advance\filenamelength by 1
1446     \fi
1447     \nextsp}
1448   \def\getfilename#1{%
1449     \filenamelength=0
1450     % If we don't expand the argument now, \skipspaces will get
1451     % snagged on things like "@value{foo}".
1452     \edef\temp{#1}%
1453     \expandafter\skipspaces\temp|\relax
1454   }
1455   \ifnum\pdftexversion < 14
1456     \let \startlink \pdfannotlink
1457   \else
1458     \let \startlink \pdfstartlink
1459   \fi
1460   % make a live url in pdf output.
1461   \def\pdfurl#1{%
1462     \begingroup
1463       % it seems we really need yet another set of dummies; have not
1464       % tried to figure out what each command should do in the context
1465       % of @url.  for now, just make @/ a no-op, that's the only one
1466       % people have actually reported a problem with.
1467       %
1468       \normalturnoffactive
1469       \def\@{@}%
1470       \let\/=\empty
1471       \makevalueexpandable
1472       % do we want to go so far as to use \indexnofonts instead of just
1473       % special-casing \var here?
1474       \def\var##1{##1}%
1475       %
1476       \leavevmode\setcolor{\urlcolor}%
1477       \startlink attr{/Border [0 0 0]}%
1478         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1479     \endgroup}
1480   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1481   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1482   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1483   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1484   \def\maketoks{%
1485     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1486     \ifx\first0\adn0
1487     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1488     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1489     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1490     \else
1491       \ifnum0=\countA\else\makelink\fi
1492       \ifx\first.\let\next=\done\else
1493         \let\next=\maketoks
1494         \addtokens{\toksB}{\the\toksD}
1495         \ifx\first,\addtokens{\toksB}{\space}\fi
1496       \fi
1497     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1498     \next}
1499   \def\makelink{\addtokens{\toksB}%
1500     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1501   \def\pdflink#1{%
1502     \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1503     \setcolor{\linkcolor}#1\endlink}
1504   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1505 \else
1506   % non-pdf mode
1507   \let\pdfmkdest = \gobble
1508   \let\pdfurl = \gobble
1509   \let\endlink = \relax
1510   \let\setcolor = \gobble
1511   \let\pdfsetcolor = \gobble
1512   \let\pdfmakeoutlines = \relax
1513 \fi  % \ifx\pdfoutput
1514
1515 %
1516 % For XeTeX
1517 %
1518 \newif\iftxiuseunicodedestname
1519 \ifx\XeTeXrevision\thisisundefined
1520 \else
1521   %
1522   % XeTeX version check
1523   %
1524   \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99995}>-1
1525     % XeTeX 0.99995+ contains xdvipdfmx 20160307+.
1526     % It can handle Unicode destination name for PDF.
1527     \txiuseunicodedestnametrue
1528   \else
1529     % XeTeX < 0.99995 can not handle Unicode destination name for PDF
1530     % because xdvipdfmx 20150315 has UTF-16 convert issue.
1531     % It fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1532     \txiuseunicodedestnamefalse
1533   \fi
1534   %
1535   % PDF outline support
1536   %
1537   \pdfmakepagedesttrue \relax
1538   % Emulate the primitive of pdfTeX
1539   \def\pdfdest name#1 xyz{%
1540     \special{pdf:dest (name#1) [@thispage /XYZ @xpos @ypos]}%
1541   }
1542   \def\pdfmkdest#1{{%
1543     % We have to set dummies so commands such as @code, and characters
1544     % such as \, aren't expanded when present in a section title.
1545     \indexnofonts
1546     \iftxiuseunicodedestname
1547       \def\pdfdestname{#1}% Pass through Unicode characters.
1548     \else
1549       \edef\pdfdestname{#1}% Replace Unicode characters to ASCII.
1550     \fi
1551     \turnoffactive
1552     \makevalueexpandable
1553     \txiescapepdf\pdfdestname
1554     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1555   }}
1556   %
1557   \def\dopdfoutline#1#2#3#4{%
1558     \iftxiuseunicodedestname
1559       \def\pdfoutlinedest{#3}% Pass through Unicode characters.
1560     \else
1561       \edef\pdfoutlinedest{#3}% Replace Unicode characters to ASCII.
1562     \fi
1563     \ifx\pdfoutlinedest\empty
1564       \def\pdfoutlinedest{#4}%
1565     \fi
1566     {
1567       \turnoffactive
1568       \txiescapepdf\pdfoutlinedest
1569       \edef\pdfoutlinetext{#1}%
1570       \txiescapepdf\pdfoutlinetext
1571       %
1572       \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
1573         << /S /GoTo /D (name\pdfoutlinedest) >> >> }%
1574     }
1575   }
1576   %
1577   \def\pdfmakeoutlines{%
1578     \begingroup
1579       %
1580       % In the case of XeTeX, counts of subentries is not necesary.
1581       % Therefore, read toc only once.
1582       %
1583       % We use the node names as the destinations.
1584       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1585       \def\numchapentry##1##2##3##4{%
1586         \dopdfoutline{##1}{1}{##3}{##4}}%
1587       \def\numsecentry##1##2##3##4{%
1588         \dopdfoutline{##1}{2}{##3}{##4}}%
1589       \def\numsubsecentry##1##2##3##4{%
1590         \dopdfoutline{##1}{3}{##3}{##4}}%
1591       \def\numsubsubsecentry##1##2##3##4{%
1592         \dopdfoutline{##1}{4}{##3}{##4}}%
1593       %
1594       \let\appentry\numchapentry%
1595       \let\appsecentry\numsecentry%
1596       \let\appsubsecentry\numsubsecentry%
1597       \let\appsubsubsecentry\numsubsubsecentry%
1598       \let\unnchapentry\numchapentry%
1599       \let\unnsecentry\numsecentry%
1600       \let\unnsubsecentry\numsubsecentry%
1601       \let\unnsubsubsecentry\numsubsubsecentry%
1602       %
1603       % In the case of XeTeX, xdvipdfmx converts strings to UTF-16.
1604       % Therefore, the encoding and the language may not be considered.
1605       %
1606       \indexnofonts
1607       \setupdatafile
1608       % We can have normal brace characters in the PDF outlines, unlike
1609       % Texinfo index files.  So set that up.
1610       \def\{{\lbracecharliteral}%
1611       \def\}{\rbracecharliteral}%
1612       \catcode`\\=\active \otherbackslash
1613       \input \tocreadfilename
1614     \endgroup
1615   }
1616   {\catcode`[=1 \catcode`]=2
1617    \catcode`{=\other \catcode`}=\other
1618    \gdef\lbracecharliteral[{]%
1619    \gdef\rbracecharliteral[}]%
1620   ]
1621
1622   \special{pdf:docview << /PageMode /UseOutlines >> }
1623   % ``\special{pdf:tounicode ...}'' is not necessary
1624   % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
1625   % However, due to UTF-16 convert issue of xdvipdfmx 20150315,
1626   % ``\special{pdf:dest ...}'' can not handle non-ASCII strings.
1627   % It fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1628 %
1629   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1630     \ifx\PP\D\let\nextsp\relax
1631     \else\let\nextsp\skipspaces
1632       \addtokens{\filename}{\PP}%
1633       \advance\filenamelength by 1
1634     \fi
1635     \nextsp}
1636   \def\getfilename#1{%
1637     \filenamelength=0
1638     % If we don't expand the argument now, \skipspaces will get
1639     % snagged on things like "@value{foo}".
1640     \edef\temp{#1}%
1641     \expandafter\skipspaces\temp|\relax
1642   }
1643   % make a live url in pdf output.
1644   \def\pdfurl#1{%
1645     \begingroup
1646       % it seems we really need yet another set of dummies; have not
1647       % tried to figure out what each command should do in the context
1648       % of @url.  for now, just make @/ a no-op, that's the only one
1649       % people have actually reported a problem with.
1650       %
1651       \normalturnoffactive
1652       \def\@{@}%
1653       \let\/=\empty
1654       \makevalueexpandable
1655       % do we want to go so far as to use \indexnofonts instead of just
1656       % special-casing \var here?
1657       \def\var##1{##1}%
1658       %
1659       \leavevmode\setcolor{\urlcolor}%
1660       \special{pdf:bann << /Border [0 0 0]
1661         /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
1662     \endgroup}
1663   \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
1664   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1665   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1666   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1667   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1668   \def\maketoks{%
1669     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1670     \ifx\first0\adn0
1671     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1672     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1673     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1674     \else
1675       \ifnum0=\countA\else\makelink\fi
1676       \ifx\first.\let\next=\done\else
1677         \let\next=\maketoks
1678         \addtokens{\toksB}{\the\toksD}
1679         \ifx\first,\addtokens{\toksB}{\space}\fi
1680       \fi
1681     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1682     \next}
1683   \def\makelink{\addtokens{\toksB}%
1684     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1685   \def\pdflink#1{%
1686     \special{pdf:bann << /Border [0 0 0]
1687       /Type /Annot /Subtype /Link /A << /S /GoTo /D (name#1) >> >>}%
1688     \setcolor{\linkcolor}#1\endlink}
1689   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1690 %
1691   %
1692   % @image support
1693   %
1694   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1695   \def\doxeteximage#1#2#3{%
1696     \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1697     \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1698     %
1699     % XeTeX (and the PDF format) support .pdf, .png, .jpg (among
1700     % others).  Let's try in that order, PDF first since if
1701     % someone has a scalable image, presumably better to use that than a
1702     % bitmap.
1703     \let\xeteximgext=\empty
1704     \begingroup
1705       \openin 1 #1.pdf \ifeof 1
1706         \openin 1 #1.PDF \ifeof 1
1707           \openin 1 #1.png \ifeof 1
1708             \openin 1 #1.jpg \ifeof 1
1709               \openin 1 #1.jpeg \ifeof 1
1710                 \openin 1 #1.JPG \ifeof 1
1711                   \errmessage{Could not find image file #1 for XeTeX}%
1712                 \else \gdef\xeteximgext{JPG}%
1713                 \fi
1714               \else \gdef\xeteximgext{jpeg}%
1715               \fi
1716             \else \gdef\xeteximgext{jpg}%
1717             \fi
1718           \else \gdef\xeteximgext{png}%
1719           \fi
1720         \else \gdef\xeteximgext{PDF}%
1721         \fi
1722       \else \gdef\xeteximgext{pdf}%
1723       \fi
1724       \closein 1
1725     \endgroup
1726     %
1727     \def\xetexpdfext{pdf}%
1728     \ifx\xeteximgext\xetexpdfext
1729       \XeTeXpdffile "#1".\xeteximgext ""
1730     \else
1731       \def\xetexpdfext{PDF}%
1732       \ifx\xeteximgext\xetexpdfext
1733         \XeTeXpdffile "#1".\xeteximgext ""
1734       \else
1735         \XeTeXpicfile "#1".\xeteximgext ""
1736       \fi
1737     \fi
1738     \ifdim \wd0 >0pt width \xeteximagewidth \fi
1739     \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1740   }
1741 \fi
1742
1743 \message{fonts,}
1744
1745 % Change the current font style to #1, remembering it in \curfontstyle.
1746 % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
1747 % italics, not bold italics.
1748 %
1749 \def\setfontstyle#1{%
1750   \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
1751   \csname ten#1\endcsname  % change the current font
1752 }
1753
1754 % Select #1 fonts with the current style.
1755 %
1756 \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
1757
1758 \def\rm{\fam=0 \setfontstyle{rm}}
1759 \def\it{\fam=\itfam \setfontstyle{it}}
1760 \def\sl{\fam=\slfam \setfontstyle{sl}}
1761 \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
1762 \def\tt{\fam=\ttfam \setfontstyle{tt}}
1763
1764 % Unfortunately, we have to override this for titles and the like, since
1765 % in those cases "rm" is bold.  Sigh.
1766 \def\rmisbold{\rm\def\curfontstyle{bf}}
1767
1768 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
1769 % So we set up a \sf.
1770 \newfam\sffam
1771 \def\sf{\fam=\sffam \setfontstyle{sf}}
1772 \let\li = \sf % Sometimes we call it \li, not \sf.
1773
1774 % We don't need math for this font style.
1775 \def\ttsl{\setfontstyle{ttsl}}
1776
1777
1778 % Set the baselineskip to #1, and the lineskip and strut size
1779 % correspondingly.  There is no deep meaning behind these magic numbers
1780 % used as factors; they just match (closely enough) what Knuth defined.
1781 %
1782 \def\lineskipfactor{.08333}
1783 \def\strutheightpercent{.70833}
1784 \def\strutdepthpercent {.29167}
1785 %
1786 % can get a sort of poor man's double spacing by redefining this.
1787 \def\baselinefactor{1}
1788 %
1789 \newdimen\textleading
1790 \def\setleading#1{%
1791   \dimen0 = #1\relax
1792   \normalbaselineskip = \baselinefactor\dimen0
1793   \normallineskip = \lineskipfactor\normalbaselineskip
1794   \normalbaselines
1795   \setbox\strutbox =\hbox{%
1796     \vrule width0pt height\strutheightpercent\baselineskip
1797                     depth \strutdepthpercent \baselineskip
1798   }%
1799 }
1800
1801 % PDF CMaps.  See also LaTeX's t1.cmap.
1802 %
1803 % do nothing with this by default.
1804 \expandafter\let\csname cmapOT1\endcsname\gobble
1805 \expandafter\let\csname cmapOT1IT\endcsname\gobble
1806 \expandafter\let\csname cmapOT1TT\endcsname\gobble
1807
1808 % if we are producing pdf, and we have \pdffontattr, then define cmaps.
1809 % (\pdffontattr was introduced many years ago, but people still run
1810 % older pdftex's; it's easy to conditionalize, so we do.)
1811 \ifpdf \ifx\pdffontattr\thisisundefined \else
1812   \begingroup
1813     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1814     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1815 %%DocumentNeededResources: ProcSet (CIDInit)
1816 %%IncludeResource: ProcSet (CIDInit)
1817 %%BeginResource: CMap (TeX-OT1-0)
1818 %%Title: (TeX-OT1-0 TeX OT1 0)
1819 %%Version: 1.000
1820 %%EndComments
1821 /CIDInit /ProcSet findresource begin
1822 12 dict begin
1823 begincmap
1824 /CIDSystemInfo
1825 << /Registry (TeX)
1826 /Ordering (OT1)
1827 /Supplement 0
1828 >> def
1829 /CMapName /TeX-OT1-0 def
1830 /CMapType 2 def
1831 1 begincodespacerange
1832 <00> <7F>
1833 endcodespacerange
1834 8 beginbfrange
1835 <00> <01> <0393>
1836 <09> <0A> <03A8>
1837 <23> <26> <0023>
1838 <28> <3B> <0028>
1839 <3F> <5B> <003F>
1840 <5D> <5E> <005D>
1841 <61> <7A> <0061>
1842 <7B> <7C> <2013>
1843 endbfrange
1844 40 beginbfchar
1845 <02> <0398>
1846 <03> <039B>
1847 <04> <039E>
1848 <05> <03A0>
1849 <06> <03A3>
1850 <07> <03D2>
1851 <08> <03A6>
1852 <0B> <00660066>
1853 <0C> <00660069>
1854 <0D> <0066006C>
1855 <0E> <006600660069>
1856 <0F> <00660066006C>
1857 <10> <0131>
1858 <11> <0237>
1859 <12> <0060>
1860 <13> <00B4>
1861 <14> <02C7>
1862 <15> <02D8>
1863 <16> <00AF>
1864 <17> <02DA>
1865 <18> <00B8>
1866 <19> <00DF>
1867 <1A> <00E6>
1868 <1B> <0153>
1869 <1C> <00F8>
1870 <1D> <00C6>
1871 <1E> <0152>
1872 <1F> <00D8>
1873 <21> <0021>
1874 <22> <201D>
1875 <27> <2019>
1876 <3C> <00A1>
1877 <3D> <003D>
1878 <3E> <00BF>
1879 <5C> <201C>
1880 <5F> <02D9>
1881 <60> <2018>
1882 <7D> <02DD>
1883 <7E> <007E>
1884 <7F> <00A8>
1885 endbfchar
1886 endcmap
1887 CMapName currentdict /CMap defineresource pop
1888 end
1889 end
1890 %%EndResource
1891 %%EOF
1892     }\endgroup
1893   \expandafter\edef\csname cmapOT1\endcsname#1{%
1894     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1895   }%
1896 %
1897 % \cmapOT1IT
1898   \begingroup
1899     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1900     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1901 %%DocumentNeededResources: ProcSet (CIDInit)
1902 %%IncludeResource: ProcSet (CIDInit)
1903 %%BeginResource: CMap (TeX-OT1IT-0)
1904 %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
1905 %%Version: 1.000
1906 %%EndComments
1907 /CIDInit /ProcSet findresource begin
1908 12 dict begin
1909 begincmap
1910 /CIDSystemInfo
1911 << /Registry (TeX)
1912 /Ordering (OT1IT)
1913 /Supplement 0
1914 >> def
1915 /CMapName /TeX-OT1IT-0 def
1916 /CMapType 2 def
1917 1 begincodespacerange
1918 <00> <7F>
1919 endcodespacerange
1920 8 beginbfrange
1921 <00> <01> <0393>
1922 <09> <0A> <03A8>
1923 <25> <26> <0025>
1924 <28> <3B> <0028>
1925 <3F> <5B> <003F>
1926 <5D> <5E> <005D>
1927 <61> <7A> <0061>
1928 <7B> <7C> <2013>
1929 endbfrange
1930 42 beginbfchar
1931 <02> <0398>
1932 <03> <039B>
1933 <04> <039E>
1934 <05> <03A0>
1935 <06> <03A3>
1936 <07> <03D2>
1937 <08> <03A6>
1938 <0B> <00660066>
1939 <0C> <00660069>
1940 <0D> <0066006C>
1941 <0E> <006600660069>
1942 <0F> <00660066006C>
1943 <10> <0131>
1944 <11> <0237>
1945 <12> <0060>
1946 <13> <00B4>
1947 <14> <02C7>
1948 <15> <02D8>
1949 <16> <00AF>
1950 <17> <02DA>
1951 <18> <00B8>
1952 <19> <00DF>
1953 <1A> <00E6>
1954 <1B> <0153>
1955 <1C> <00F8>
1956 <1D> <00C6>
1957 <1E> <0152>
1958 <1F> <00D8>
1959 <21> <0021>
1960 <22> <201D>
1961 <23> <0023>
1962 <24> <00A3>
1963 <27> <2019>
1964 <3C> <00A1>
1965 <3D> <003D>
1966 <3E> <00BF>
1967 <5C> <201C>
1968 <5F> <02D9>
1969 <60> <2018>
1970 <7D> <02DD>
1971 <7E> <007E>
1972 <7F> <00A8>
1973 endbfchar
1974 endcmap
1975 CMapName currentdict /CMap defineresource pop
1976 end
1977 end
1978 %%EndResource
1979 %%EOF
1980     }\endgroup
1981   \expandafter\edef\csname cmapOT1IT\endcsname#1{%
1982     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1983   }%
1984 %
1985 % \cmapOT1TT
1986   \begingroup
1987     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1988     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1989 %%DocumentNeededResources: ProcSet (CIDInit)
1990 %%IncludeResource: ProcSet (CIDInit)
1991 %%BeginResource: CMap (TeX-OT1TT-0)
1992 %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
1993 %%Version: 1.000
1994 %%EndComments
1995 /CIDInit /ProcSet findresource begin
1996 12 dict begin
1997 begincmap
1998 /CIDSystemInfo
1999 << /Registry (TeX)
2000 /Ordering (OT1TT)
2001 /Supplement 0
2002 >> def
2003 /CMapName /TeX-OT1TT-0 def
2004 /CMapType 2 def
2005 1 begincodespacerange
2006 <00> <7F>
2007 endcodespacerange
2008 5 beginbfrange
2009 <00> <01> <0393>
2010 <09> <0A> <03A8>
2011 <21> <26> <0021>
2012 <28> <5F> <0028>
2013 <61> <7E> <0061>
2014 endbfrange
2015 32 beginbfchar
2016 <02> <0398>
2017 <03> <039B>
2018 <04> <039E>
2019 <05> <03A0>
2020 <06> <03A3>
2021 <07> <03D2>
2022 <08> <03A6>
2023 <0B> <2191>
2024 <0C> <2193>
2025 <0D> <0027>
2026 <0E> <00A1>
2027 <0F> <00BF>
2028 <10> <0131>
2029 <11> <0237>
2030 <12> <0060>
2031 <13> <00B4>
2032 <14> <02C7>
2033 <15> <02D8>
2034 <16> <00AF>
2035 <17> <02DA>
2036 <18> <00B8>
2037 <19> <00DF>
2038 <1A> <00E6>
2039 <1B> <0153>
2040 <1C> <00F8>
2041 <1D> <00C6>
2042 <1E> <0152>
2043 <1F> <00D8>
2044 <20> <2423>
2045 <27> <2019>
2046 <60> <2018>
2047 <7F> <00A8>
2048 endbfchar
2049 endcmap
2050 CMapName currentdict /CMap defineresource pop
2051 end
2052 end
2053 %%EndResource
2054 %%EOF
2055     }\endgroup
2056   \expandafter\edef\csname cmapOT1TT\endcsname#1{%
2057     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2058   }%
2059 \fi\fi
2060
2061
2062 % Set the font macro #1 to the font named \fontprefix#2.
2063 % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
2064 % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
2065 % Example:
2066 % #1 = \textrm
2067 % #2 = \rmshape
2068 % #3 = 10
2069 % #4 = \mainmagstep
2070 % #5 = OT1
2071 %
2072 \def\setfont#1#2#3#4#5{%
2073   \font#1=\fontprefix#2#3 scaled #4
2074   \csname cmap#5\endcsname#1%
2075 }
2076 % This is what gets called when #5 of \setfont is empty.
2077 \let\cmap\gobble
2078 %
2079 % (end of cmaps)
2080
2081 % Use cm as the default font prefix.
2082 % To specify the font prefix, you must define \fontprefix
2083 % before you read in texinfo.tex.
2084 \ifx\fontprefix\thisisundefined
2085 \def\fontprefix{cm}
2086 \fi
2087 % Support font families that don't use the same naming scheme as CM.
2088 \def\rmshape{r}
2089 \def\rmbshape{bx}               % where the normal face is bold
2090 \def\bfshape{b}
2091 \def\bxshape{bx}
2092 \def\ttshape{tt}
2093 \def\ttbshape{tt}
2094 \def\ttslshape{sltt}
2095 \def\itshape{ti}
2096 \def\itbshape{bxti}
2097 \def\slshape{sl}
2098 \def\slbshape{bxsl}
2099 \def\sfshape{ss}
2100 \def\sfbshape{ss}
2101 \def\scshape{csc}
2102 \def\scbshape{csc}
2103
2104 % Definitions for a main text size of 11pt.  (The default in Texinfo.)
2105 %
2106 \def\definetextfontsizexi{%
2107 % Text fonts (11.2pt, magstep1).
2108 \def\textnominalsize{11pt}
2109 \edef\mainmagstep{\magstephalf}
2110 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2111 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2112 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2113 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2114 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2115 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2116 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2117 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2118 \font\texti=cmmi10 scaled \mainmagstep
2119 \font\textsy=cmsy10 scaled \mainmagstep
2120 \def\textecsize{1095}
2121
2122 % A few fonts for @defun names and args.
2123 \setfont\defbf\bfshape{10}{\magstep1}{OT1}
2124 \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
2125 \setfont\defsl\slshape{10}{\magstep1}{OT1TT}
2126 \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
2127 \def\df{\let\tentt=\deftt \let\tenbf = \defbf
2128 \let\tenttsl=\defttsl \let\tensl=\defsl \bf}
2129
2130 % Fonts for indices, footnotes, small examples (9pt).
2131 \def\smallnominalsize{9pt}
2132 \setfont\smallrm\rmshape{9}{1000}{OT1}
2133 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2134 \setfont\smallbf\bfshape{10}{900}{OT1}
2135 \setfont\smallit\itshape{9}{1000}{OT1IT}
2136 \setfont\smallsl\slshape{9}{1000}{OT1}
2137 \setfont\smallsf\sfshape{9}{1000}{OT1}
2138 \setfont\smallsc\scshape{10}{900}{OT1}
2139 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2140 \font\smalli=cmmi9
2141 \font\smallsy=cmsy9
2142 \def\smallecsize{0900}
2143
2144 % Fonts for small examples (8pt).
2145 \def\smallernominalsize{8pt}
2146 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2147 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2148 \setfont\smallerbf\bfshape{10}{800}{OT1}
2149 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2150 \setfont\smallersl\slshape{8}{1000}{OT1}
2151 \setfont\smallersf\sfshape{8}{1000}{OT1}
2152 \setfont\smallersc\scshape{10}{800}{OT1}
2153 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2154 \font\smalleri=cmmi8
2155 \font\smallersy=cmsy8
2156 \def\smallerecsize{0800}
2157
2158 % Fonts for title page (20.4pt):
2159 \def\titlenominalsize{20pt}
2160 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2161 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2162 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2163 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2164 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2165 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2166 \let\titlebf=\titlerm
2167 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2168 \font\titlei=cmmi12 scaled \magstep3
2169 \font\titlesy=cmsy10 scaled \magstep4
2170 \def\titleecsize{2074}
2171
2172 % Chapter (and unnumbered) fonts (17.28pt).
2173 \def\chapnominalsize{17pt}
2174 \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2175 \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2176 \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2177 \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2178 \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2179 \setfont\chapsf\sfbshape{17}{1000}{OT1}
2180 \let\chapbf=\chaprm
2181 \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
2182 \font\chapi=cmmi12 scaled \magstep2
2183 \font\chapsy=cmsy10 scaled \magstep3
2184 \def\chapecsize{1728}
2185
2186 % Section fonts (14.4pt).
2187 \def\secnominalsize{14pt}
2188 \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
2189 \setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
2190 \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2191 \setfont\secsl\slbshape{10}{\magstep2}{OT1}
2192 \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2193 \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2194 \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
2195 \let\secbf\secrm
2196 \setfont\secsc\scbshape{10}{\magstep2}{OT1}
2197 \font\seci=cmmi12 scaled \magstep1
2198 \font\secsy=cmsy10 scaled \magstep2
2199 \def\sececsize{1440}
2200
2201 % Subsection fonts (13.15pt).
2202 \def\ssecnominalsize{13pt}
2203 \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2204 \setfont\ssecit\itbshape{10}{1315}{OT1IT}
2205 \setfont\ssecsl\slbshape{10}{1315}{OT1}
2206 \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2207 \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2208 \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
2209 \let\ssecbf\ssecrm
2210 \setfont\ssecsc\scbshape{10}{1315}{OT1}
2211 \font\sseci=cmmi12 scaled \magstephalf
2212 \font\ssecsy=cmsy10 scaled 1315
2213 \def\ssececsize{1200}
2214
2215 % Reduced fonts for @acro in text (10pt).
2216 \def\reducednominalsize{10pt}
2217 \setfont\reducedrm\rmshape{10}{1000}{OT1}
2218 \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2219 \setfont\reducedbf\bfshape{10}{1000}{OT1}
2220 \setfont\reducedit\itshape{10}{1000}{OT1IT}
2221 \setfont\reducedsl\slshape{10}{1000}{OT1}
2222 \setfont\reducedsf\sfshape{10}{1000}{OT1}
2223 \setfont\reducedsc\scshape{10}{1000}{OT1}
2224 \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
2225 \font\reducedi=cmmi10
2226 \font\reducedsy=cmsy10
2227 \def\reducedecsize{1000}
2228
2229 \textleading = 13.2pt % line spacing for 11pt CM
2230 \textfonts            % reset the current fonts
2231 \rm
2232 } % end of 11pt text font size definitions, \definetextfontsizexi
2233
2234
2235 % Definitions to make the main text be 10pt Computer Modern, with
2236 % section, chapter, etc., sizes following suit.  This is for the GNU
2237 % Press printing of the Emacs 22 manual.  Maybe other manuals in the
2238 % future.  Used with @smallbook, which sets the leading to 12pt.
2239 %
2240 \def\definetextfontsizex{%
2241 % Text fonts (10pt).
2242 \def\textnominalsize{10pt}
2243 \edef\mainmagstep{1000}
2244 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2245 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2246 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2247 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2248 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2249 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2250 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2251 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2252 \font\texti=cmmi10 scaled \mainmagstep
2253 \font\textsy=cmsy10 scaled \mainmagstep
2254 \def\textecsize{1000}
2255
2256 % A few fonts for @defun names and args.
2257 \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2258 \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
2259 \setfont\defsl\slshape{10}{\magstephalf}{OT1TT}
2260 \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
2261 \def\df{\let\tentt=\deftt \let\tenbf = \defbf
2262 \let\tensl=\defsl \let\tenttsl=\defttsl \bf}
2263
2264 % Fonts for indices, footnotes, small examples (9pt).
2265 \def\smallnominalsize{9pt}
2266 \setfont\smallrm\rmshape{9}{1000}{OT1}
2267 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2268 \setfont\smallbf\bfshape{10}{900}{OT1}
2269 \setfont\smallit\itshape{9}{1000}{OT1IT}
2270 \setfont\smallsl\slshape{9}{1000}{OT1}
2271 \setfont\smallsf\sfshape{9}{1000}{OT1}
2272 \setfont\smallsc\scshape{10}{900}{OT1}
2273 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2274 \font\smalli=cmmi9
2275 \font\smallsy=cmsy9
2276 \def\smallecsize{0900}
2277
2278 % Fonts for small examples (8pt).
2279 \def\smallernominalsize{8pt}
2280 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2281 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2282 \setfont\smallerbf\bfshape{10}{800}{OT1}
2283 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2284 \setfont\smallersl\slshape{8}{1000}{OT1}
2285 \setfont\smallersf\sfshape{8}{1000}{OT1}
2286 \setfont\smallersc\scshape{10}{800}{OT1}
2287 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2288 \font\smalleri=cmmi8
2289 \font\smallersy=cmsy8
2290 \def\smallerecsize{0800}
2291
2292 % Fonts for title page (20.4pt):
2293 \def\titlenominalsize{20pt}
2294 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2295 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2296 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2297 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2298 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2299 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2300 \let\titlebf=\titlerm
2301 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2302 \font\titlei=cmmi12 scaled \magstep3
2303 \font\titlesy=cmsy10 scaled \magstep4
2304 \def\titleecsize{2074}
2305
2306 % Chapter fonts (14.4pt).
2307 \def\chapnominalsize{14pt}
2308 \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2309 \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2310 \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2311 \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2312 \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2313 \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2314 \let\chapbf\chaprm
2315 \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2316 \font\chapi=cmmi12 scaled \magstep1
2317 \font\chapsy=cmsy10 scaled \magstep2
2318 \def\chapecsize{1440}
2319
2320 % Section fonts (12pt).
2321 \def\secnominalsize{12pt}
2322 \setfont\secrm\rmbshape{12}{1000}{OT1}
2323 \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2324 \setfont\secsl\slbshape{10}{\magstep1}{OT1}
2325 \setfont\sectt\ttbshape{12}{1000}{OT1TT}
2326 \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2327 \setfont\secsf\sfbshape{12}{1000}{OT1}
2328 \let\secbf\secrm
2329 \setfont\secsc\scbshape{10}{\magstep1}{OT1}
2330 \font\seci=cmmi12
2331 \font\secsy=cmsy10 scaled \magstep1
2332 \def\sececsize{1200}
2333
2334 % Subsection fonts (10pt).
2335 \def\ssecnominalsize{10pt}
2336 \setfont\ssecrm\rmbshape{10}{1000}{OT1}
2337 \setfont\ssecit\itbshape{10}{1000}{OT1IT}
2338 \setfont\ssecsl\slbshape{10}{1000}{OT1}
2339 \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2340 \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2341 \setfont\ssecsf\sfbshape{10}{1000}{OT1}
2342 \let\ssecbf\ssecrm
2343 \setfont\ssecsc\scbshape{10}{1000}{OT1}
2344 \font\sseci=cmmi10
2345 \font\ssecsy=cmsy10
2346 \def\ssececsize{1000}
2347
2348 % Reduced fonts for @acro in text (9pt).
2349 \def\reducednominalsize{9pt}
2350 \setfont\reducedrm\rmshape{9}{1000}{OT1}
2351 \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2352 \setfont\reducedbf\bfshape{10}{900}{OT1}
2353 \setfont\reducedit\itshape{9}{1000}{OT1IT}
2354 \setfont\reducedsl\slshape{9}{1000}{OT1}
2355 \setfont\reducedsf\sfshape{9}{1000}{OT1}
2356 \setfont\reducedsc\scshape{10}{900}{OT1}
2357 \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2358 \font\reducedi=cmmi9
2359 \font\reducedsy=cmsy9
2360 \def\reducedecsize{0900}
2361
2362 \divide\parskip by 2  % reduce space between paragraphs
2363 \textleading = 12pt   % line spacing for 10pt CM
2364 \textfonts            % reset the current fonts
2365 \rm
2366 } % end of 10pt text font size definitions, \definetextfontsizex
2367
2368
2369 % We provide the user-level command
2370 %   @fonttextsize 10
2371 % (or 11) to redefine the text font size.  pt is assumed.
2372 %
2373 \def\xiword{11}
2374 \def\xword{10}
2375 \def\xwordpt{10pt}
2376 %
2377 \parseargdef\fonttextsize{%
2378   \def\textsizearg{#1}%
2379   %\wlog{doing @fonttextsize \textsizearg}%
2380   %
2381   % Set \globaldefs so that documents can use this inside @tex, since
2382   % makeinfo 4.8 does not support it, but we need it nonetheless.
2383   %
2384  \begingroup \globaldefs=1
2385   \ifx\textsizearg\xword \definetextfontsizex
2386   \else \ifx\textsizearg\xiword \definetextfontsizexi
2387   \else
2388     \errhelp=\EMsimple
2389     \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2390   \fi\fi
2391  \endgroup
2392 }
2393
2394 % In order for the font changes to affect most math symbols and letters,
2395 % we have to define the \textfont of the standard families.  We don't
2396 % bother to reset \scriptfont and \scriptscriptfont; awaiting user need.
2397 %
2398 \def\resetmathfonts{%
2399   \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
2400   \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
2401   \textfont\ttfam=\tentt \textfont\sffam=\tensf
2402 }
2403
2404 % The font-changing commands redefine the meanings of \tenSTYLE, instead
2405 % of just \STYLE.  We do this because \STYLE needs to also set the
2406 % current \fam for math mode.  Our \STYLE (e.g., \rm) commands hardwire
2407 % \tenSTYLE to set the current font.
2408 %
2409 % Each font-changing command also sets the names \lsize (one size lower)
2410 % and \lllsize (three sizes lower).  These relative commands are used
2411 % in, e.g., the LaTeX logo and acronyms.
2412 %
2413 % This all needs generalizing, badly.
2414 %
2415 \def\textfonts{%
2416   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
2417   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
2418   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
2419   \let\tenttsl=\textttsl
2420   \def\curfontsize{text}%
2421   \def\lsize{reduced}\def\lllsize{smaller}%
2422   \resetmathfonts \setleading{\textleading}}
2423 \def\titlefonts{%
2424   \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
2425   \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
2426   \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
2427   \let\tenttsl=\titlettsl
2428   \def\curfontsize{title}%
2429   \def\lsize{chap}\def\lllsize{subsec}%
2430   \resetmathfonts \setleading{27pt}}
2431 \def\titlefont#1{{\titlefonts\rmisbold #1}}
2432 \def\chapfonts{%
2433   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
2434   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
2435   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
2436   \let\tenttsl=\chapttsl
2437   \def\curfontsize{chap}%
2438   \def\lsize{sec}\def\lllsize{text}%
2439   \resetmathfonts \setleading{19pt}}
2440 \def\secfonts{%
2441   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
2442   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
2443   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
2444   \let\tenttsl=\secttsl
2445   \def\curfontsize{sec}%
2446   \def\lsize{subsec}\def\lllsize{reduced}%
2447   \resetmathfonts \setleading{17pt}}
2448 \def\subsecfonts{%
2449   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
2450   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
2451   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
2452   \let\tenttsl=\ssecttsl
2453   \def\curfontsize{ssec}%
2454   \def\lsize{text}\def\lllsize{small}%
2455   \resetmathfonts \setleading{15pt}}
2456 \let\subsubsecfonts = \subsecfonts
2457 \def\reducedfonts{%
2458   \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl
2459   \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc
2460   \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy
2461   \let\tenttsl=\reducedttsl
2462   \def\curfontsize{reduced}%
2463   \def\lsize{small}\def\lllsize{smaller}%
2464   \resetmathfonts \setleading{10.5pt}}
2465 \def\smallfonts{%
2466   \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
2467   \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
2468   \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
2469   \let\tenttsl=\smallttsl
2470   \def\curfontsize{small}%
2471   \def\lsize{smaller}\def\lllsize{smaller}%
2472   \resetmathfonts \setleading{10.5pt}}
2473 \def\smallerfonts{%
2474   \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
2475   \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
2476   \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
2477   \let\tenttsl=\smallerttsl
2478   \def\curfontsize{smaller}%
2479   \def\lsize{smaller}\def\lllsize{smaller}%
2480   \resetmathfonts \setleading{9.5pt}}
2481
2482 % Fonts for short table of contents.
2483 \setfont\shortcontrm\rmshape{12}{1000}{OT1}
2484 \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
2485 \setfont\shortcontsl\slshape{12}{1000}{OT1}
2486 \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2487
2488 % Define these just so they can be easily changed for other fonts.
2489 \def\angleleft{$\langle$}
2490 \def\angleright{$\rangle$}
2491
2492 % Set the fonts to use with the @small... environments.
2493 \let\smallexamplefonts = \smallfonts
2494
2495 % About \smallexamplefonts.  If we use \smallfonts (9pt), @smallexample
2496 % can fit this many characters:
2497 %   8.5x11=86   smallbook=72  a4=90  a5=69
2498 % If we use \scriptfonts (8pt), then we can fit this many characters:
2499 %   8.5x11=90+  smallbook=80  a4=90+  a5=77
2500 % For me, subjectively, the few extra characters that fit aren't worth
2501 % the additional smallness of 8pt.  So I'm making the default 9pt.
2502 %
2503 % By the way, for comparison, here's what fits with @example (10pt):
2504 %   8.5x11=71  smallbook=60  a4=75  a5=58
2505 % --karl, 24jan03.
2506
2507 % Set up the default fonts, so we can use them for creating boxes.
2508 %
2509 \definetextfontsizexi
2510
2511
2512 \message{markup,}
2513
2514 % Check if we are currently using a typewriter font.  Since all the
2515 % Computer Modern typewriter fonts have zero interword stretch (and
2516 % shrink), and it is reasonable to expect all typewriter fonts to have
2517 % this property, we can check that font parameter.
2518 %
2519 \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
2520
2521 % Markup style infrastructure.  \defmarkupstylesetup\INITMACRO will
2522 % define and register \INITMACRO to be called on markup style changes.
2523 % \INITMACRO can check \currentmarkupstyle for the innermost
2524 % style and the set of \ifmarkupSTYLE switches for all styles
2525 % currently in effect.
2526 \newif\ifmarkupvar
2527 \newif\ifmarkupsamp
2528 \newif\ifmarkupkey
2529 %\newif\ifmarkupfile % @file == @samp.
2530 %\newif\ifmarkupoption % @option == @samp.
2531 \newif\ifmarkupcode
2532 \newif\ifmarkupkbd
2533 %\newif\ifmarkupenv % @env == @code.
2534 %\newif\ifmarkupcommand % @command == @code.
2535 \newif\ifmarkuptex % @tex (and part of @math, for now).
2536 \newif\ifmarkupexample
2537 \newif\ifmarkupverb
2538 \newif\ifmarkupverbatim
2539
2540 \let\currentmarkupstyle\empty
2541
2542 \def\setupmarkupstyle#1{%
2543   \csname markup#1true\endcsname
2544   \def\currentmarkupstyle{#1}%
2545   \markupstylesetup
2546 }
2547
2548 \let\markupstylesetup\empty
2549
2550 \def\defmarkupstylesetup#1{%
2551   \expandafter\def\expandafter\markupstylesetup
2552     \expandafter{\markupstylesetup #1}%
2553   \def#1%
2554 }
2555
2556 % Markup style setup for left and right quotes.
2557 \defmarkupstylesetup\markupsetuplq{%
2558   \expandafter\let\expandafter \temp
2559     \csname markupsetuplq\currentmarkupstyle\endcsname
2560   \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
2561 }
2562
2563 \defmarkupstylesetup\markupsetuprq{%
2564   \expandafter\let\expandafter \temp
2565     \csname markupsetuprq\currentmarkupstyle\endcsname
2566   \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
2567 }
2568
2569 {
2570 \catcode`\'=\active
2571 \catcode`\`=\active
2572
2573 \gdef\markupsetuplqdefault{\let`\lq}
2574 \gdef\markupsetuprqdefault{\let'\rq}
2575
2576 \gdef\markupsetcodequoteleft{\let`\codequoteleft}
2577 \gdef\markupsetcodequoteright{\let'\codequoteright}
2578 }
2579
2580 \let\markupsetuplqcode \markupsetcodequoteleft
2581 \let\markupsetuprqcode \markupsetcodequoteright
2582 %
2583 \let\markupsetuplqexample \markupsetcodequoteleft
2584 \let\markupsetuprqexample \markupsetcodequoteright
2585 %
2586 \let\markupsetuplqkbd     \markupsetcodequoteleft
2587 \let\markupsetuprqkbd     \markupsetcodequoteright
2588 %
2589 \let\markupsetuplqsamp \markupsetcodequoteleft
2590 \let\markupsetuprqsamp \markupsetcodequoteright
2591 %
2592 \let\markupsetuplqverb \markupsetcodequoteleft
2593 \let\markupsetuprqverb \markupsetcodequoteright
2594 %
2595 \let\markupsetuplqverbatim \markupsetcodequoteleft
2596 \let\markupsetuprqverbatim \markupsetcodequoteright
2597
2598 % Allow an option to not use regular directed right quote/apostrophe
2599 % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2600 % The undirected quote is ugly, so don't make it the default, but it
2601 % works for pasting with more pdf viewers (at least evince), the
2602 % lilypond developers report.  xpdf does work with the regular 0x27.
2603 %
2604 \def\codequoteright{%
2605   \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
2606     \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
2607       '%
2608     \else \char'15 \fi
2609   \else \char'15 \fi
2610 }
2611 %
2612 % and a similar option for the left quote char vs. a grave accent.
2613 % Modern fonts display ASCII 0x60 as a grave accent, so some people like
2614 % the code environments to do likewise.
2615 %
2616 \def\codequoteleft{%
2617   \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
2618     \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
2619       % [Knuth] pp. 380,381,391
2620       % \relax disables Spanish ligatures ?` and !` of \tt font.
2621       \relax`%
2622     \else \char'22 \fi
2623   \else \char'22 \fi
2624 }
2625
2626 % Commands to set the quote options.
2627
2628 \parseargdef\codequoteundirected{%
2629   \def\temp{#1}%
2630   \ifx\temp\onword
2631     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2632       = t%
2633   \else\ifx\temp\offword
2634     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2635       = \relax
2636   \else
2637     \errhelp = \EMsimple
2638     \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2639   \fi\fi
2640 }
2641 %
2642 \parseargdef\codequotebacktick{%
2643   \def\temp{#1}%
2644   \ifx\temp\onword
2645     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2646       = t%
2647   \else\ifx\temp\offword
2648     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2649       = \relax
2650   \else
2651     \errhelp = \EMsimple
2652     \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2653   \fi\fi
2654 }
2655
2656 % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2657 \def\noligaturesquoteleft{\relax\lq}
2658
2659 % Count depth in font-changes, for error checks
2660 \newcount\fontdepth \fontdepth=0
2661
2662 % Font commands.
2663
2664 % #1 is the font command (\sl or \it), #2 is the text to slant.
2665 % If we are in a monospaced environment, however, 1) always use \ttsl,
2666 % and 2) do not add an italic correction.
2667 \def\dosmartslant#1#2{%
2668   \ifusingtt 
2669     {{\ttsl #2}\let\next=\relax}%
2670     {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
2671   \next
2672 }
2673 \def\smartslanted{\dosmartslant\sl}
2674 \def\smartitalic{\dosmartslant\it}
2675
2676 % Output an italic correction unless \next (presumed to be the following
2677 % character) is such as not to need one.
2678 \def\smartitaliccorrection{%
2679   \ifx\next,%
2680   \else\ifx\next-%
2681   \else\ifx\next.%
2682   \else\ifx\next\.%
2683   \else\ifx\next\comma%
2684   \else\ptexslash
2685   \fi\fi\fi\fi\fi
2686   \aftersmartic
2687 }
2688
2689 % Unconditional use \ttsl, and no ic.  @var is set to this for defuns.
2690 \def\ttslanted#1{{\ttsl #1}}
2691
2692 % @cite is like \smartslanted except unconditionally use \sl.  We never want
2693 % ttsl for book titles, do we?
2694 \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
2695
2696 \def\aftersmartic{}
2697 \def\var#1{%
2698   \let\saveaftersmartic = \aftersmartic
2699   \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
2700   \smartslanted{#1}%
2701 }
2702
2703 \let\i=\smartitalic
2704 \let\slanted=\smartslanted
2705 \let\dfn=\smartslanted
2706 \let\emph=\smartitalic
2707
2708 % Explicit font changes: @r, @sc, undocumented @ii.
2709 \def\r#1{{\rm #1}}              % roman font
2710 \def\sc#1{{\smallcaps#1}}       % smallcaps font
2711 \def\ii#1{{\it #1}}             % italic font
2712
2713 % @b, explicit bold.  Also @strong.
2714 \def\b#1{{\bf #1}}
2715 \let\strong=\b
2716
2717 % @sansserif, explicit sans.
2718 \def\sansserif#1{{\sf #1}}
2719
2720 % We can't just use \exhyphenpenalty, because that only has effect at
2721 % the end of a paragraph.  Restore normal hyphenation at the end of the
2722 % group within which \nohyphenation is presumably called.
2723 %
2724 \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
2725 \def\restorehyphenation{\hyphenchar\font = `- }
2726
2727 % Set sfcode to normal for the chars that usually have another value.
2728 % Can't use plain's \frenchspacing because it uses the `\x notation, and
2729 % sometimes \x has an active definition that messes things up.
2730 %
2731 \catcode`@=11
2732   \def\plainfrenchspacing{%
2733     \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
2734     \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
2735     \def\endofsentencespacefactor{1000}% for @. and friends
2736   }
2737   \def\plainnonfrenchspacing{%
2738     \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2739     \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2740     \def\endofsentencespacefactor{3000}% for @. and friends
2741   }
2742 \catcode`@=\other
2743 \def\endofsentencespacefactor{3000}% default
2744
2745 % @t, explicit typewriter.
2746 \def\t#1{%
2747   {\tt \rawbackslash \plainfrenchspacing #1}%
2748   \null
2749 }
2750
2751 % @samp.
2752 \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
2753
2754 % @indicateurl is \samp, that is, with quotes.
2755 \let\indicateurl=\samp
2756
2757 % @code (and similar) prints in typewriter, but with spaces the same
2758 % size as normal in the surrounding text, without hyphenation, etc.
2759 % This is a subroutine for that.
2760 \def\tclose#1{%
2761   {%
2762     % Change normal interword space to be same as for the current font.
2763     \spaceskip = \fontdimen2\font
2764     %
2765     % Switch to typewriter.
2766     \tt
2767     %
2768     % But `\ ' produces the large typewriter interword space.
2769     \def\ {{\spaceskip = 0pt{} }}%
2770     %
2771     % Turn off hyphenation.
2772     \nohyphenation
2773     %
2774     \rawbackslash
2775     \plainfrenchspacing
2776     #1%
2777   }%
2778   \null % reset spacefactor to 1000
2779 }
2780
2781 % We *must* turn on hyphenation at `-' and `_' in @code.
2782 % (But see \codedashfinish below.)
2783 % Otherwise, it is too hard to avoid overfull hboxes
2784 % in the Emacs manual, the Library manual, etc.
2785 %
2786 % Unfortunately, TeX uses one parameter (\hyphenchar) to control
2787 % both hyphenation at - and hyphenation within words.
2788 % We must therefore turn them both off (\tclose does that)
2789 % and arrange explicitly to hyphenate at a dash. -- rms.
2790 {
2791   \catcode`\-=\active \catcode`\_=\active
2792   \catcode`\'=\active \catcode`\`=\active
2793   \global\let'=\rq \global\let`=\lq  % default definitions
2794   %
2795   \global\def\code{\begingroup
2796     \setupmarkupstyle{code}%
2797     % The following should really be moved into \setupmarkupstyle handlers.
2798     \catcode\dashChar=\active  \catcode\underChar=\active
2799     \ifallowcodebreaks
2800      \let-\codedash
2801      \let_\codeunder
2802     \else
2803      \let-\normaldash
2804      \let_\realunder
2805     \fi
2806     % Given -foo (with a single dash), we do not want to allow a break
2807     % after the hyphen.
2808     \global\let\codedashprev=\codedash
2809     %
2810     \codex
2811   }
2812   %
2813   \gdef\codedash{\futurelet\next\codedashfinish}
2814   \gdef\codedashfinish{%
2815     \normaldash % always output the dash character itself.
2816     % 
2817     % Now, output a discretionary to allow a line break, unless
2818     % (a) the next character is a -, or
2819     % (b) the preceding character is a -.
2820     % E.g., given --posix, we do not want to allow a break after either -.
2821     % Given --foo-bar, we do want to allow a break between the - and the b.
2822     \ifx\next\codedash \else
2823       \ifx\codedashprev\codedash 
2824       \else \discretionary{}{}{}\fi
2825     \fi
2826     % we need the space after the = for the case when \next itself is a
2827     % space token; it would get swallowed otherwise.  As in @code{- a}.
2828     \global\let\codedashprev= \next
2829   }
2830 }
2831 \def\normaldash{-}
2832 %
2833 \def\codex #1{\tclose{#1}\endgroup}
2834
2835 \def\codeunder{%
2836   % this is all so @math{@code{var_name}+1} can work.  In math mode, _
2837   % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2838   % will therefore expand the active definition of _, which is us
2839   % (inside @code that is), therefore an endless loop.
2840   \ifusingtt{\ifmmode
2841                \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2842              \else\normalunderscore \fi
2843              \discretionary{}{}{}}%
2844             {\_}%
2845 }
2846
2847 % An additional complication: the above will allow breaks after, e.g.,
2848 % each of the four underscores in __typeof__.  This is bad.
2849 % @allowcodebreaks provides a document-level way to turn breaking at -
2850 % and _ on and off.
2851 %
2852 \newif\ifallowcodebreaks  \allowcodebreakstrue
2853
2854 \def\keywordtrue{true}
2855 \def\keywordfalse{false}
2856
2857 \parseargdef\allowcodebreaks{%
2858   \def\txiarg{#1}%
2859   \ifx\txiarg\keywordtrue
2860     \allowcodebreakstrue
2861   \else\ifx\txiarg\keywordfalse
2862     \allowcodebreaksfalse
2863   \else
2864     \errhelp = \EMsimple
2865     \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
2866   \fi\fi
2867 }
2868
2869 % For @command, @env, @file, @option quotes seem unnecessary,
2870 % so use \code rather than \samp.
2871 \let\command=\code
2872 \let\env=\code
2873 \let\file=\code
2874 \let\option=\code
2875
2876 % @uref (abbreviation for `urlref') aka @url takes an optional
2877 % (comma-separated) second argument specifying the text to display and
2878 % an optional third arg as text to display instead of (rather than in
2879 % addition to) the url itself.  First (mandatory) arg is the url.
2880
2881 % TeX-only option to allow changing PDF output to show only the second
2882 % arg (if given), and not the url (which is then just the link target).
2883 \newif\ifurefurlonlylink
2884
2885 % The main macro is \urefbreak, which allows breaking at expected
2886 % places within the url.  (There used to be another version, which
2887 % didn't support automatic breaking.)
2888 \def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
2889 \let\uref=\urefbreak
2890 %
2891 \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
2892 \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
2893   \unsepspaces
2894   \pdfurl{#1}%
2895   \setbox0 = \hbox{\ignorespaces #3}%
2896   \ifdim\wd0 > 0pt
2897     \unhbox0 % third arg given, show only that
2898   \else
2899     \setbox0 = \hbox{\ignorespaces #2}% look for second arg
2900     \ifdim\wd0 > 0pt
2901       \ifpdf
2902         % For pdfTeX and LuaTeX
2903         \ifurefurlonlylink
2904           % PDF plus option to not display url, show just arg
2905           \unhbox0             
2906         \else
2907           % PDF, normally display both arg and url for consistency,
2908           % visibility, if the pdf is eventually used to print, etc.
2909           \unhbox0\ (\urefcode{#1})%
2910         \fi
2911       \else
2912         \ifx\XeTeXrevision\thisisundefined
2913           \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
2914         \else
2915           % For XeTeX
2916           \ifurefurlonlylink
2917             % PDF plus option to not display url, show just arg
2918             \unhbox0             
2919           \else
2920             % PDF, normally display both arg and url for consistency,
2921             % visibility, if the pdf is eventually used to print, etc.
2922             \unhbox0\ (\urefcode{#1})%
2923           \fi
2924         \fi
2925       \fi
2926     \else
2927       \urefcode{#1}% only url given, so show it
2928     \fi
2929   \fi
2930   \endlink
2931 \endgroup}
2932
2933 % Allow line breaks around only a few characters (only).
2934 \def\urefcatcodes{%
2935   \catcode`\&=\active \catcode`\.=\active
2936   \catcode`\#=\active \catcode`\?=\active
2937   \catcode`\/=\active
2938 }
2939 {
2940   \urefcatcodes
2941   %
2942   \global\def\urefcode{\begingroup
2943     \setupmarkupstyle{code}%
2944     \urefcatcodes
2945     \let&\urefcodeamp
2946     \let.\urefcodedot
2947     \let#\urefcodehash
2948     \let?\urefcodequest
2949     \let/\urefcodeslash
2950     \codex
2951   }
2952   %
2953   % By default, they are just regular characters.
2954   \global\def&{\normalamp}
2955   \global\def.{\normaldot}
2956   \global\def#{\normalhash}
2957   \global\def?{\normalquest}
2958   \global\def/{\normalslash}
2959 }
2960
2961 % we put a little stretch before and after the breakable chars, to help
2962 % line breaking of long url's.  The unequal skips make look better in
2963 % cmtt at least, especially for dots.
2964 \def\urefprestretchamount{.13em}
2965 \def\urefpoststretchamount{.1em}
2966 \def\urefprestretch{\urefprebreak \hskip0pt plus\urefprestretchamount\relax}
2967 \def\urefpoststretch{\urefpostbreak \hskip0pt plus\urefprestretchamount\relax}
2968 %
2969 \def\urefcodeamp{\urefprestretch \&\urefpoststretch}
2970 \def\urefcodedot{\urefprestretch .\urefpoststretch}
2971 \def\urefcodehash{\urefprestretch \#\urefpoststretch}
2972 \def\urefcodequest{\urefprestretch ?\urefpoststretch}
2973 \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
2974 {
2975   \catcode`\/=\active
2976   \global\def\urefcodeslashfinish{%
2977     \urefprestretch \slashChar
2978     % Allow line break only after the final / in a sequence of
2979     % slashes, to avoid line break between the slashes in http://.
2980     \ifx\next/\else \urefpoststretch \fi
2981   }
2982 }
2983
2984 % One more complication: by default we'll break after the special
2985 % characters, but some people like to break before the special chars, so
2986 % allow that.  Also allow no breaking at all, for manual control.
2987
2988 \parseargdef\urefbreakstyle{%
2989   \def\txiarg{#1}%
2990   \ifx\txiarg\wordnone
2991     \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
2992   \else\ifx\txiarg\wordbefore
2993     \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
2994   \else\ifx\txiarg\wordafter
2995     \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
2996   \else
2997     \errhelp = \EMsimple
2998     \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
2999   \fi\fi\fi
3000 }
3001 \def\wordafter{after}
3002 \def\wordbefore{before}
3003 \def\wordnone{none}
3004
3005 \urefbreakstyle after
3006
3007 % @url synonym for @uref, since that's how everyone uses it.
3008 %
3009 \let\url=\uref
3010
3011 % rms does not like angle brackets --karl, 17may97.
3012 % So now @email is just like @uref, unless we are pdf.
3013 %
3014 %\def\email#1{\angleleft{\tt #1}\angleright}
3015 \ifpdf
3016   \def\email#1{\doemail#1,,\finish}
3017   \def\doemail#1,#2,#3\finish{\begingroup
3018     \unsepspaces
3019     \pdfurl{mailto:#1}%
3020     \setbox0 = \hbox{\ignorespaces #2}%
3021     \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3022     \endlink
3023   \endgroup}
3024 \else
3025   \ifx\XeTeXrevision\thisisundefined
3026     \let\email=\uref
3027   \else
3028     \def\email#1{\doemail#1,,\finish}
3029     \def\doemail#1,#2,#3\finish{\begingroup
3030       \unsepspaces
3031       \pdfurl{mailto:#1}%
3032       \setbox0 = \hbox{\ignorespaces #2}%
3033       \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3034       \endlink
3035     \endgroup}
3036   \fi
3037 \fi
3038
3039 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
3040 %   `example' (@kbd uses ttsl only inside of @example and friends),
3041 %   or `code' (@kbd uses normal tty font always).
3042 \parseargdef\kbdinputstyle{%
3043   \def\txiarg{#1}%
3044   \ifx\txiarg\worddistinct
3045     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
3046   \else\ifx\txiarg\wordexample
3047     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
3048   \else\ifx\txiarg\wordcode
3049     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
3050   \else
3051     \errhelp = \EMsimple
3052     \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
3053   \fi\fi\fi
3054 }
3055 \def\worddistinct{distinct}
3056 \def\wordexample{example}
3057 \def\wordcode{code}
3058
3059 % Default is `distinct'.
3060 \kbdinputstyle distinct
3061
3062 % @kbd is like @code, except that if the argument is just one @key command,
3063 % then @kbd has no effect.
3064 \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
3065
3066 \def\xkey{\key}
3067 \def\kbdsub#1#2#3\par{%
3068   \def\one{#1}\def\three{#3}\def\threex{??}%
3069   \ifx\one\xkey\ifx\threex\three \key{#2}%
3070   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3071   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3072 }
3073
3074 % definition of @key that produces a lozenge.  Doesn't adjust to text size.
3075 %\setfont\keyrm\rmshape{8}{1000}{OT1}
3076 %\font\keysy=cmsy9
3077 %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
3078 %  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
3079 %    \vbox{\hrule\kern-0.4pt
3080 %     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
3081 %    \kern-0.4pt\hrule}%
3082 %  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
3083
3084 % definition of @key with no lozenge.  If the current font is already
3085 % monospace, don't change it; that way, we respect @kbdinputstyle.  But
3086 % if it isn't monospace, then use \tt.
3087 %
3088 \def\key#1{{\setupmarkupstyle{key}%
3089   \nohyphenation
3090   \ifmonospace\else\tt\fi
3091   #1}\null}
3092
3093 % @clicksequence{File @click{} Open ...}
3094 \def\clicksequence#1{\begingroup #1\endgroup}
3095
3096 % @clickstyle @arrow   (by default)
3097 \parseargdef\clickstyle{\def\click{#1}}
3098 \def\click{\arrow}
3099
3100 % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
3101 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
3102 %
3103 \def\dmn#1{\thinspace #1}
3104
3105 % @acronym for "FBI", "NATO", and the like.
3106 % We print this one point size smaller, since it's intended for
3107 % all-uppercase.
3108 %
3109 \def\acronym#1{\doacronym #1,,\finish}
3110 \def\doacronym#1,#2,#3\finish{%
3111   {\selectfonts\lsize #1}%
3112   \def\temp{#2}%
3113   \ifx\temp\empty \else
3114     \space ({\unsepspaces \ignorespaces \temp \unskip})%
3115   \fi
3116   \null % reset \spacefactor=1000
3117 }
3118
3119 % @abbr for "Comput. J." and the like.
3120 % No font change, but don't do end-of-sentence spacing.
3121 %
3122 \def\abbr#1{\doabbr #1,,\finish}
3123 \def\doabbr#1,#2,#3\finish{%
3124   {\plainfrenchspacing #1}%
3125   \def\temp{#2}%
3126   \ifx\temp\empty \else
3127     \space ({\unsepspaces \ignorespaces \temp \unskip})%
3128   \fi
3129   \null % reset \spacefactor=1000
3130 }
3131
3132 % @asis just yields its argument.  Used with @table, for example.
3133 %
3134 \def\asis#1{#1}
3135
3136 % @math outputs its argument in math mode.
3137 %
3138 % One complication: _ usually means subscripts, but it could also mean
3139 % an actual _ character, as in @math{@var{some_variable} + 1}.  So make
3140 % _ active, and distinguish by seeing if the current family is \slfam,
3141 % which is what @var uses.
3142 {
3143   \catcode`\_ = \active
3144   \gdef\mathunderscore{%
3145     \catcode`\_=\active
3146     \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
3147   }
3148 }
3149 % Another complication: we want \\ (and @\) to output a math (or tt) \.
3150 % FYI, plain.tex uses \\ as a temporary control sequence (for no
3151 % particular reason), but this is not advertised and we don't care.
3152 %
3153 % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
3154 \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
3155 %
3156 \def\math{%
3157   \ifmmode\else % only go into math if not in math mode already
3158     \tex
3159     \mathunderscore
3160     \let\\ = \mathbackslash
3161     \mathactive
3162     % make the texinfo accent commands work in math mode
3163     \let\"=\ddot
3164     \let\'=\acute
3165     \let\==\bar
3166     \let\^=\hat
3167     \let\`=\grave
3168     \let\u=\breve
3169     \let\v=\check
3170     \let\~=\tilde
3171     \let\dotaccent=\dot
3172     % have to provide another name for sup operator
3173     \let\mathopsup=\sup
3174   $\expandafter\finishmath\fi
3175 }
3176 \def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
3177
3178 % Some active characters (such as <) are spaced differently in math.
3179 % We have to reset their definitions in case the @math was an argument
3180 % to a command which sets the catcodes (such as @item or @section).
3181 %
3182 {
3183   \catcode`^ = \active
3184   \catcode`< = \active
3185   \catcode`> = \active
3186   \catcode`+ = \active
3187   \catcode`' = \active
3188   \gdef\mathactive{%
3189     \let^ = \ptexhat
3190     \let< = \ptexless
3191     \let> = \ptexgtr
3192     \let+ = \ptexplus
3193     \let' = \ptexquoteright
3194   }
3195 }
3196
3197 % for @sub and @sup, if in math mode, just do a normal sub/superscript.
3198 % If in text, use math to place as sub/superscript, but switch
3199 % into text mode, with smaller fonts.  This is a different font than the
3200 % one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3201 % fix it (significant additions to font machinery) until someone notices.
3202 %
3203 \def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
3204 \def\finishsub#1{$\sb{\hbox{\selectfonts\lllsize #1}}$}%
3205 %
3206 \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
3207 \def\finishsup#1{$\ptexsp{\hbox{\selectfonts\lllsize #1}}$}%
3208
3209 % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3210 % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3211 % except specified as a normal braced arg, so no newlines to worry about.
3212
3213 \def\outfmtnametex{tex}
3214 %
3215 \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3216 \long\def\doinlinefmt#1,#2,\finish{%
3217   \def\inlinefmtname{#1}%
3218   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3219 }
3220
3221 % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3222 % FMTNAME is tex, else ELSE-TEXT.
3223 \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3224 \long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3225   \def\inlinefmtname{#1}%
3226   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3227 }
3228 %
3229 % For raw, must switch into @tex before parsing the argument, to avoid
3230 % setting catcodes prematurely.  Doing it this way means that, for
3231 % example, @inlineraw{html, foo{bar} gets a parse error instead of being
3232 % ignored.  But this isn't important because if people want a literal
3233 % *right* brace they would have to use a command anyway, so they may as
3234 % well use a command to get a left brace too.  We could re-use the
3235 % delimiter character idea from \verb, but it seems like overkill.
3236
3237 \long\def\inlineraw{\tex \doinlineraw}
3238 \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3239 \def\doinlinerawtwo#1,#2,\finish{%
3240   \def\inlinerawname{#1}%
3241   \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3242   \endgroup % close group opened by \tex.
3243 }
3244
3245 % @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3246 %
3247 \long\def\inlineifset#1{\doinlineifset #1,\finish}
3248 \long\def\doinlineifset#1,#2,\finish{%
3249   \def\inlinevarname{#1}%
3250   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3251   \else\ignorespaces#2\fi
3252 }
3253
3254 % @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3255 %
3256 \long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3257 \long\def\doinlineifclear#1,#2,\finish{%
3258   \def\inlinevarname{#1}%
3259   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3260 }
3261
3262
3263 \message{glyphs,}
3264 % and logos.
3265
3266 % @@ prints an @, as does @atchar{}.
3267 \def\@{\char64 }
3268 \let\atchar=\@
3269
3270 % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
3271 % Unless we're in typewriter, use \ecfont because the CM text fonts do
3272 % not have braces, and we don't want to switch into math.
3273 \def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}}
3274 \def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}}
3275 \let\{=\mylbrace \let\lbracechar=\{
3276 \let\}=\myrbrace \let\rbracechar=\}
3277 \begingroup
3278   % Definitions to produce \{ and \} commands for indices,
3279   % and @{ and @} for the aux/toc files.
3280   \catcode`\{ = \other \catcode`\} = \other
3281   \catcode`\[ = 1 \catcode`\] = 2
3282   \catcode`\! = 0 \catcode`\\ = \other
3283   !gdef!lbracecmd[\{]%
3284   !gdef!rbracecmd[\}]%
3285   !gdef!lbraceatcmd[@{]%
3286   !gdef!rbraceatcmd[@}]%
3287 !endgroup
3288
3289 % @comma{} to avoid , parsing problems.
3290 \let\comma = ,
3291
3292 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3293 % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3294 \let\, = \ptexc
3295 \let\dotaccent = \ptexdot
3296 \def\ringaccent#1{{\accent23 #1}}
3297 \let\tieaccent = \ptext
3298 \let\ubaraccent = \ptexb
3299 \let\udotaccent = \d
3300
3301 % Other special characters: @questiondown @exclamdown @ordf @ordm
3302 % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3303 \def\questiondown{?`}
3304 \def\exclamdown{!`}
3305 \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
3306 \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
3307
3308 % Dotless i and dotless j, used for accents.
3309 \def\imacro{i}
3310 \def\jmacro{j}
3311 \def\dotless#1{%
3312   \def\temp{#1}%
3313   \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3314   \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3315   \else \errmessage{@dotless can be used only with i or j}%
3316   \fi\fi
3317 }
3318
3319 % The \TeX{} logo, as in plain, but resetting the spacing so that a
3320 % period following counts as ending a sentence.  (Idea found in latex.)
3321 %
3322 \edef\TeX{\TeX \spacefactor=1000 }
3323
3324 % @LaTeX{} logo.  Not quite the same results as the definition in
3325 % latex.ltx, since we use a different font for the raised A; it's most
3326 % convenient for us to use an explicitly smaller font, rather than using
3327 % the \scriptstyle font (since we don't reset \scriptstyle and
3328 % \scriptscriptstyle).
3329 %
3330 \def\LaTeX{%
3331   L\kern-.36em
3332   {\setbox0=\hbox{T}%
3333    \vbox to \ht0{\hbox{%
3334      \ifx\textnominalsize\xwordpt
3335        % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX.
3336        % Revert to plain's \scriptsize, which is 7pt.
3337        \count255=\the\fam $\fam\count255 \scriptstyle A$%
3338      \else
3339        % For 11pt, we can use our lllsize.
3340        \selectfonts\lllsize A%
3341      \fi
3342      }%
3343      \vss
3344   }}%
3345   \kern-.15em
3346   \TeX
3347 }
3348
3349 % Some math mode symbols.  Define \ensuremath to switch into math mode
3350 % unless we are already there.  Expansion tricks may not be needed here,
3351 % but safer, and can't hurt.
3352 \def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3353 \def\ensuredmath#1{$\relax#1$}
3354 %
3355 \def\bullet{\ensuremath\ptexbullet}
3356 \def\geq{\ensuremath\ge}
3357 \def\leq{\ensuremath\le}
3358 \def\minus{\ensuremath-}
3359
3360 % @dots{} outputs an ellipsis using the current font.
3361 % We do .5em per period so that it has the same spacing in the cm
3362 % typewriter fonts as three actual period characters; on the other hand,
3363 % in other typewriter fonts three periods are wider than 1.5em.  So do
3364 % whichever is larger.
3365 %
3366 \def\dots{%
3367   \leavevmode
3368   \setbox0=\hbox{...}% get width of three periods
3369   \ifdim\wd0 > 1.5em
3370     \dimen0 = \wd0
3371   \else
3372     \dimen0 = 1.5em
3373   \fi
3374   \hbox to \dimen0{%
3375     \hskip 0pt plus.25fil
3376     .\hskip 0pt plus1fil
3377     .\hskip 0pt plus1fil
3378     .\hskip 0pt plus.5fil
3379   }%
3380 }
3381
3382 % @enddots{} is an end-of-sentence ellipsis.
3383 %
3384 \def\enddots{%
3385   \dots
3386   \spacefactor=\endofsentencespacefactor
3387 }
3388
3389 % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3390 %
3391 % Since these characters are used in examples, they should be an even number of
3392 % \tt widths. Each \tt character is 1en, so two makes it 1em.
3393 %
3394 \def\point{$\star$}
3395 \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3396 \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3397 \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3398 \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3399 \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3400
3401 % The @error{} command.
3402 % Adapted from the TeXbook's \boxit.
3403 %
3404 \newbox\errorbox
3405 %
3406 {\tentt \global\dimen0 = 3em}% Width of the box.
3407 \dimen2 = .55pt % Thickness of rules
3408 % The text. (`r' is open on the right, `e' somewhat less so on the left.)
3409 \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3410 %
3411 \setbox\errorbox=\hbox to \dimen0{\hfil
3412    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3413    \advance\hsize by -2\dimen2 % Rules.
3414    \vbox{%
3415       \hrule height\dimen2
3416       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
3417          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3418          \kern3pt\vrule width\dimen2}% Space to right.
3419       \hrule height\dimen2}
3420     \hfil}
3421 %
3422 \def\error{\leavevmode\lower.7ex\copy\errorbox}
3423
3424 % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3425 %
3426 \def\pounds{{\it\$}}
3427
3428 % @euro{} comes from a separate font, depending on the current style.
3429 % We use the free feym* fonts from the eurosym package by Henrik
3430 % Theiling, which support regular, slanted, bold and bold slanted (and
3431 % "outlined" (blackboard board, sort of) versions, which we don't need).
3432 % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3433 %
3434 % Although only regular is the truly official Euro symbol, we ignore
3435 % that.  The Euro is designed to be slightly taller than the regular
3436 % font height.
3437 %
3438 % feymr - regular
3439 % feymo - slanted
3440 % feybr - bold
3441 % feybo - bold slanted
3442 %
3443 % There is no good (free) typewriter version, to my knowledge.
3444 % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3445 % Hmm.
3446 %
3447 % Also doesn't work in math.  Do we need to do math with euro symbols?
3448 % Hope not.
3449 %
3450 %
3451 \def\euro{{\eurofont e}}
3452 \def\eurofont{%
3453   % We set the font at each command, rather than predefining it in
3454   % \textfonts and the other font-switching commands, so that
3455   % installations which never need the symbol don't have to have the
3456   % font installed.
3457   %
3458   % There is only one designed size (nominal 10pt), so we always scale
3459   % that to the current nominal size.
3460   %
3461   % By the way, simply using "at 1em" works for cmr10 and the like, but
3462   % does not work for cmbx10 and other extended/shrunken fonts.
3463   %
3464   \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3465   %
3466   \ifx\curfontstyle\bfstylename
3467     % bold:
3468     \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3469   \else
3470     % regular:
3471     \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3472   \fi
3473   \thiseurofont
3474 }
3475
3476 % Glyphs from the EC fonts.  We don't use \let for the aliases, because
3477 % sometimes we redefine the original macro, and the alias should reflect
3478 % the redefinition.
3479 %
3480 % Use LaTeX names for the Icelandic letters.
3481 \def\DH{{\ecfont \char"D0}} % Eth
3482 \def\dh{{\ecfont \char"F0}} % eth
3483 \def\TH{{\ecfont \char"DE}} % Thorn
3484 \def\th{{\ecfont \char"FE}} % thorn
3485 %
3486 \def\guillemetleft{{\ecfont \char"13}}
3487 \def\guillemotleft{\guillemetleft}
3488 \def\guillemetright{{\ecfont \char"14}}
3489 \def\guillemotright{\guillemetright}
3490 \def\guilsinglleft{{\ecfont \char"0E}}
3491 \def\guilsinglright{{\ecfont \char"0F}}
3492 \def\quotedblbase{{\ecfont \char"12}}
3493 \def\quotesinglbase{{\ecfont \char"0D}}
3494 %
3495 % This positioning is not perfect (see the ogonek LaTeX package), but
3496 % we have the precomposed glyphs for the most common cases.  We put the
3497 % tests to use those glyphs in the single \ogonek macro so we have fewer
3498 % dummy definitions to worry about for index entries, etc.
3499 %
3500 % ogonek is also used with other letters in Lithuanian (IOU), but using
3501 % the precomposed glyphs for those is not so easy since they aren't in
3502 % the same EC font.
3503 \def\ogonek#1{{%
3504   \def\temp{#1}%
3505   \ifx\temp\macrocharA\Aogonek
3506   \else\ifx\temp\macrochara\aogonek
3507   \else\ifx\temp\macrocharE\Eogonek
3508   \else\ifx\temp\macrochare\eogonek
3509   \else
3510     \ecfont \setbox0=\hbox{#1}%
3511     \ifdim\ht0=1ex\accent"0C #1%
3512     \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3513     \fi
3514   \fi\fi\fi\fi
3515   }%
3516 }
3517 \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3518 \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3519 \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3520 \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3521 %
3522 % Use the European Computer Modern fonts (cm-super in outline format)
3523 % for non-CM glyphs.  That is ec* for regular text and tc* for the text
3524 % companion symbols (LaTeX TS1 encoding).  Both are part of the ec
3525 % package and follow the same conventions.
3526
3527 \def\ecfont{\etcfont{e}}
3528 \def\tcfont{\etcfont{t}}
3529 %
3530 \def\etcfont#1{%
3531   % We can't distinguish serif/sans and italic/slanted, but this
3532   % is used for crude hacks anyway (like adding French and German
3533   % quotes to documents typeset with CM, where we lose kerning), so
3534   % hopefully nobody will notice/care.
3535   \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3536   \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
3537   \ifmonospace
3538     % typewriter:
3539     \font\thisecfont = #1ctt\ecsize \space at \nominalsize
3540   \else
3541     \ifx\curfontstyle\bfstylename
3542       % bold:
3543       \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
3544     \else
3545       % regular:
3546       \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
3547     \fi
3548   \fi
3549   \thisecfont
3550 }
3551
3552 % @registeredsymbol - R in a circle.  The font for the R should really
3553 % be smaller yet, but lllsize is the best we can do for now.
3554 % Adapted from the plain.tex definition of \copyright.
3555 %
3556 \def\registeredsymbol{%
3557   $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
3558                \hfil\crcr\Orb}}%
3559     }$%
3560 }
3561
3562 % @textdegree - the normal degrees sign.
3563 %
3564 \def\textdegree{$^\circ$}
3565
3566 % Laurent Siebenmann reports \Orb undefined with:
3567 %  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
3568 % so we'll define it if necessary.
3569 %
3570 \ifx\Orb\thisisundefined
3571 \def\Orb{\mathhexbox20D}
3572 \fi
3573
3574 % Quotes.
3575 \chardef\quotedblleft="5C
3576 \chardef\quotedblright=`\"
3577 \chardef\quoteleft=`\`
3578 \chardef\quoteright=`\'
3579
3580
3581 \message{page headings,}
3582
3583 \newskip\titlepagetopglue \titlepagetopglue = 1.5in
3584 \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3585
3586 % First the title page.  Must do @settitle before @titlepage.
3587 \newif\ifseenauthor
3588 \newif\iffinishedtitlepage
3589
3590 % @setcontentsaftertitlepage used to do an implicit @contents or
3591 % @shortcontents after @end titlepage, but it is now obsolete.
3592 \def\setcontentsaftertitlepage{%
3593   \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
3594               command; move your @contents command if you want the contents
3595               after the title page.}}%
3596 \def\setshortcontentsaftertitlepage{%
3597   \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
3598               command; move your @shortcontents and @contents commands if you 
3599               want the contents after the title page.}}%
3600
3601 \parseargdef\shorttitlepage{%
3602   \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3603   \endgroup\page\hbox{}\page}
3604
3605 \envdef\titlepage{%
3606   % Open one extra group, as we want to close it in the middle of \Etitlepage.
3607   \begingroup
3608     \parindent=0pt \textfonts
3609     % Leave some space at the very top of the page.
3610     \vglue\titlepagetopglue
3611     % No rule at page bottom unless we print one at the top with @title.
3612     \finishedtitlepagetrue
3613     %
3614     % Most title ``pages'' are actually two pages long, with space
3615     % at the top of the second.  We don't want the ragged left on the second.
3616     \let\oldpage = \page
3617     \def\page{%
3618       \iffinishedtitlepage\else
3619          \finishtitlepage
3620       \fi
3621       \let\page = \oldpage
3622       \page
3623       \null
3624     }%
3625 }
3626
3627 \def\Etitlepage{%
3628     \iffinishedtitlepage\else
3629         \finishtitlepage
3630     \fi
3631     % It is important to do the page break before ending the group,
3632     % because the headline and footline are only empty inside the group.
3633     % If we use the new definition of \page, we always get a blank page
3634     % after the title page, which we certainly don't want.
3635     \oldpage
3636   \endgroup
3637   %
3638   % Need this before the \...aftertitlepage checks so that if they are
3639   % in effect the toc pages will come out with page numbers.
3640   \HEADINGSon
3641 }
3642
3643 \def\finishtitlepage{%
3644   \vskip4pt \hrule height 2pt width \hsize
3645   \vskip\titlepagebottomglue
3646   \finishedtitlepagetrue
3647 }
3648
3649 % Settings used for typesetting titles: no hyphenation, no indentation,
3650 % don't worry much about spacing, ragged right.  This should be used
3651 % inside a \vbox, and fonts need to be set appropriately first.  Because
3652 % it is always used for titles, nothing else, we call \rmisbold.  \par
3653 % should be specified before the end of the \vbox, since a vbox is a group.
3654
3655 \def\raggedtitlesettings{%
3656   \rmisbold
3657   \hyphenpenalty=10000
3658   \parindent=0pt
3659   \tolerance=5000
3660   \ptexraggedright
3661 }
3662
3663 % Macros to be used within @titlepage:
3664
3665 \let\subtitlerm=\tenrm
3666 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3667
3668 \parseargdef\title{%
3669   \checkenv\titlepage
3670   \vbox{\titlefonts \raggedtitlesettings #1\par}%
3671   % print a rule at the page bottom also.
3672   \finishedtitlepagefalse
3673   \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3674 }
3675
3676 \parseargdef\subtitle{%
3677   \checkenv\titlepage
3678   {\subtitlefont \rightline{#1}}%
3679 }
3680
3681 % @author should come last, but may come many times.
3682 % It can also be used inside @quotation.
3683 %
3684 \parseargdef\author{%
3685   \def\temp{\quotation}%
3686   \ifx\thisenv\temp
3687     \def\quotationauthor{#1}% printed in \Equotation.
3688   \else
3689     \checkenv\titlepage
3690     \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3691     {\secfonts\rmisbold \leftline{#1}}%
3692   \fi
3693 }
3694
3695
3696 % Set up page headings and footings.
3697
3698 \let\thispage=\folio
3699
3700 \newtoks\evenheadline    % headline on even pages
3701 \newtoks\oddheadline     % headline on odd pages
3702 \newtoks\evenfootline    % footline on even pages
3703 \newtoks\oddfootline     % footline on odd pages
3704
3705 % Now make \makeheadline and \makefootline in Plain TeX use those variables
3706 \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
3707                             \else \the\evenheadline \fi}}
3708 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
3709                             \else \the\evenfootline \fi}\HEADINGShook}
3710 \let\HEADINGShook=\relax
3711
3712 % Commands to set those variables.
3713 % For example, this is what  @headings on  does
3714 % @evenheading @thistitle|@thispage|@thischapter
3715 % @oddheading @thischapter|@thispage|@thistitle
3716 % @evenfooting @thisfile||
3717 % @oddfooting ||@thisfile
3718
3719
3720 \def\evenheading{\parsearg\evenheadingxxx}
3721 \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3722 \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
3723 \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3724
3725 \def\oddheading{\parsearg\oddheadingxxx}
3726 \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3727 \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
3728 \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3729
3730 \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3731
3732 \def\evenfooting{\parsearg\evenfootingxxx}
3733 \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3734 \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3735 \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3736
3737 \def\oddfooting{\parsearg\oddfootingxxx}
3738 \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3739 \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3740   \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3741   %
3742   % Leave some space for the footline.  Hopefully ok to assume
3743   % @evenfooting will not be used by itself.
3744   \global\advance\txipageheight by -12pt
3745   \global\advance\vsize by -12pt
3746 }
3747
3748 \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3749
3750 % @evenheadingmarks top     \thischapter <- chapter at the top of a page
3751 % @evenheadingmarks bottom  \thischapter <- chapter at the bottom of a page
3752 %
3753 % The same set of arguments for:
3754 %
3755 % @oddheadingmarks
3756 % @evenfootingmarks
3757 % @oddfootingmarks
3758 % @everyheadingmarks
3759 % @everyfootingmarks
3760
3761 % These define \getoddheadingmarks, \getevenheadingmarks,
3762 % \getoddfootingmarks, and \getevenfootingmarks, each to one of
3763 % \gettopheadingmarks, \getbottomheadingmarks.
3764 %
3765 \def\evenheadingmarks{\headingmarks{even}{heading}}
3766 \def\oddheadingmarks{\headingmarks{odd}{heading}}
3767 \def\evenfootingmarks{\headingmarks{even}{footing}}
3768 \def\oddfootingmarks{\headingmarks{odd}{footing}}
3769 \parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
3770                           \headingmarks{odd}{heading}{#1} }
3771 \parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
3772                           \headingmarks{odd}{footing}{#1} }
3773 % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3774 \def\headingmarks#1#2#3 {%
3775   \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3776   \global\expandafter\let\csname get#1#2marks\endcsname \temp
3777 }
3778
3779 \everyheadingmarks bottom
3780 \everyfootingmarks bottom
3781
3782 % @headings double      turns headings on for double-sided printing.
3783 % @headings single      turns headings on for single-sided printing.
3784 % @headings off         turns them off.
3785 % @headings on          same as @headings double, retained for compatibility.
3786 % @headings after       turns on double-sided headings after this page.
3787 % @headings doubleafter turns on double-sided headings after this page.
3788 % @headings singleafter turns on single-sided headings after this page.
3789 % By default, they are off at the start of a document,
3790 % and turned `on' after @end titlepage.
3791
3792 \parseargdef\headings{\csname HEADINGS#1\endcsname}
3793
3794 \def\headingsoff{% non-global headings elimination
3795   \evenheadline={\hfil}\evenfootline={\hfil}%
3796    \oddheadline={\hfil}\oddfootline={\hfil}%
3797 }
3798
3799 \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3800 \HEADINGSoff  % it's the default
3801
3802 % When we turn headings on, set the page number to 1.
3803 % For double-sided printing, put current file name in lower left corner,
3804 % chapter name on inside top of right hand pages, document
3805 % title on inside top of left hand pages, and page numbers on outside top
3806 % edge of all pages.
3807 \def\HEADINGSdouble{%
3808 \global\pageno=1
3809 \global\evenfootline={\hfil}
3810 \global\oddfootline={\hfil}
3811 \global\evenheadline={\line{\folio\hfil\thistitle}}
3812 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3813 \global\let\contentsalignmacro = \chapoddpage
3814 }
3815 \let\contentsalignmacro = \chappager
3816
3817 % For single-sided printing, chapter title goes across top left of page,
3818 % page number on top right.
3819 \def\HEADINGSsingle{%
3820 \global\pageno=1
3821 \global\evenfootline={\hfil}
3822 \global\oddfootline={\hfil}
3823 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
3824 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3825 \global\let\contentsalignmacro = \chappager
3826 }
3827 \def\HEADINGSon{\HEADINGSdouble}
3828
3829 \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
3830 \let\HEADINGSdoubleafter=\HEADINGSafter
3831 \def\HEADINGSdoublex{%
3832 \global\evenfootline={\hfil}
3833 \global\oddfootline={\hfil}
3834 \global\evenheadline={\line{\folio\hfil\thistitle}}
3835 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3836 \global\let\contentsalignmacro = \chapoddpage
3837 }
3838
3839 \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
3840 \def\HEADINGSsinglex{%
3841 \global\evenfootline={\hfil}
3842 \global\oddfootline={\hfil}
3843 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
3844 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3845 \global\let\contentsalignmacro = \chappager
3846 }
3847
3848 % Subroutines used in generating headings
3849 % This produces Day Month Year style of output.
3850 % Only define if not already defined, in case a txi-??.tex file has set
3851 % up a different format (e.g., txi-cs.tex does this).
3852 \ifx\today\thisisundefined
3853 \def\today{%
3854   \number\day\space
3855   \ifcase\month
3856   \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
3857   \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
3858   \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
3859   \fi
3860   \space\number\year}
3861 \fi
3862
3863 % @settitle line...  specifies the title of the document, for headings.
3864 % It generates no output of its own.
3865 \def\thistitle{\putwordNoTitle}
3866 \def\settitle{\parsearg{\gdef\thistitle}}
3867
3868
3869 \message{tables,}
3870 % Tables -- @table, @ftable, @vtable, @item(x).
3871
3872 % default indentation of table text
3873 \newdimen\tableindent \tableindent=.8in
3874 % default indentation of @itemize and @enumerate text
3875 \newdimen\itemindent  \itemindent=.3in
3876 % margin between end of table item and start of table text.
3877 \newdimen\itemmargin  \itemmargin=.1in
3878
3879 % used internally for \itemindent minus \itemmargin
3880 \newdimen\itemmax
3881
3882 % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
3883 % these defs.
3884 % They also define \itemindex
3885 % to index the item name in whatever manner is desired (perhaps none).
3886
3887 \newif\ifitemxneedsnegativevskip
3888
3889 \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
3890
3891 \def\internalBitem{\smallbreak \parsearg\itemzzz}
3892 \def\internalBitemx{\itemxpar \parsearg\itemzzz}
3893
3894 \def\itemzzz #1{\begingroup %
3895   \advance\hsize by -\rightskip
3896   \advance\hsize by -\tableindent
3897   \setbox0=\hbox{\itemindicate{#1}}%
3898   \itemindex{#1}%
3899   \nobreak % This prevents a break before @itemx.
3900   %
3901   % If the item text does not fit in the space we have, put it on a line
3902   % by itself, and do not allow a page break either before or after that
3903   % line.  We do not start a paragraph here because then if the next
3904   % command is, e.g., @kindex, the whatsit would get put into the
3905   % horizontal list on a line by itself, resulting in extra blank space.
3906   \ifdim \wd0>\itemmax
3907     %
3908     % Make this a paragraph so we get the \parskip glue and wrapping,
3909     % but leave it ragged-right.
3910     \begingroup
3911       \advance\leftskip by-\tableindent
3912       \advance\hsize by\tableindent
3913       \advance\rightskip by0pt plus1fil\relax
3914       \leavevmode\unhbox0\par
3915     \endgroup
3916     %
3917     % We're going to be starting a paragraph, but we don't want the
3918     % \parskip glue -- logically it's part of the @item we just started.
3919     \nobreak \vskip-\parskip
3920     %
3921     % Stop a page break at the \parskip glue coming up.  However, if
3922     % what follows is an environment such as @example, there will be no
3923     % \parskip glue; then the negative vskip we just inserted would
3924     % cause the example and the item to crash together.  So we use this
3925     % bizarre value of 10001 as a signal to \aboveenvbreak to insert
3926     % \parskip glue after all.  Section titles are handled this way also.
3927     %
3928     \penalty 10001
3929     \endgroup
3930     \itemxneedsnegativevskipfalse
3931   \else
3932     % The item text fits into the space.  Start a paragraph, so that the
3933     % following text (if any) will end up on the same line.
3934     \noindent
3935     % Do this with kerns and \unhbox so that if there is a footnote in
3936     % the item text, it can migrate to the main vertical list and
3937     % eventually be printed.
3938     \nobreak\kern-\tableindent
3939     \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
3940     \unhbox0
3941     \nobreak\kern\dimen0
3942     \endgroup
3943     \itemxneedsnegativevskiptrue
3944   \fi
3945 }
3946
3947 \def\item{\errmessage{@item while not in a list environment}}
3948 \def\itemx{\errmessage{@itemx while not in a list environment}}
3949
3950 % @table, @ftable, @vtable.
3951 \envdef\table{%
3952   \let\itemindex\gobble
3953   \tablecheck{table}%
3954 }
3955 \envdef\ftable{%
3956   \def\itemindex ##1{\doind {fn}{\code{##1}}}%
3957   \tablecheck{ftable}%
3958 }
3959 \envdef\vtable{%
3960   \def\itemindex ##1{\doind {vr}{\code{##1}}}%
3961   \tablecheck{vtable}%
3962 }
3963 \def\tablecheck#1{%
3964   \ifnum \the\catcode`\^^M=\active
3965     \endgroup
3966     \errmessage{This command won't work in this context; perhaps the problem is
3967       that we are \inenvironment\thisenv}%
3968     \def\next{\doignore{#1}}%
3969   \else
3970     \let\next\tablex
3971   \fi
3972   \next
3973 }
3974 \def\tablex#1{%
3975   \def\itemindicate{#1}%
3976   \parsearg\tabley
3977 }
3978 \def\tabley#1{%
3979   {%
3980     \makevalueexpandable
3981     \edef\temp{\noexpand\tablez #1\space\space\space}%
3982     \expandafter
3983   }\temp \endtablez
3984 }
3985 \def\tablez #1 #2 #3 #4\endtablez{%
3986   \aboveenvbreak
3987   \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
3988   \ifnum 0#2>0 \tableindent=#2\mil \fi
3989   \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
3990   \itemmax=\tableindent
3991   \advance \itemmax by -\itemmargin
3992   \advance \leftskip by \tableindent
3993   \exdentamount=\tableindent
3994   \parindent = 0pt
3995   \parskip = \smallskipamount
3996   \ifdim \parskip=0pt \parskip=2pt \fi
3997   \let\item = \internalBitem
3998   \let\itemx = \internalBitemx
3999 }
4000 \def\Etable{\endgraf\afterenvbreak}
4001 \let\Eftable\Etable
4002 \let\Evtable\Etable
4003 \let\Eitemize\Etable
4004 \let\Eenumerate\Etable
4005
4006 % This is the counter used by @enumerate, which is really @itemize
4007
4008 \newcount \itemno
4009
4010 \envdef\itemize{\parsearg\doitemize}
4011
4012 \def\doitemize#1{%
4013   \aboveenvbreak
4014   \itemmax=\itemindent
4015   \advance\itemmax by -\itemmargin
4016   \advance\leftskip by \itemindent
4017   \exdentamount=\itemindent
4018   \parindent=0pt
4019   \parskip=\smallskipamount
4020   \ifdim\parskip=0pt \parskip=2pt \fi
4021   %
4022   % Try typesetting the item mark so that if the document erroneously says
4023   % something like @itemize @samp (intending @table), there's an error
4024   % right away at the @itemize.  It's not the best error message in the
4025   % world, but it's better than leaving it to the @item.  This means if
4026   % the user wants an empty mark, they have to say @w{} not just @w.
4027   \def\itemcontents{#1}%
4028   \setbox0 = \hbox{\itemcontents}%
4029   %
4030   % @itemize with no arg is equivalent to @itemize @bullet.
4031   \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
4032   %
4033   \let\item=\itemizeitem
4034 }
4035
4036 % Definition of @item while inside @itemize and @enumerate.
4037 %
4038 \def\itemizeitem{%
4039   \advance\itemno by 1  % for enumerations
4040   {\let\par=\endgraf \smallbreak}% reasonable place to break
4041   {%
4042    % If the document has an @itemize directly after a section title, a
4043    % \nobreak will be last on the list, and \sectionheading will have
4044    % done a \vskip-\parskip.  In that case, we don't want to zero
4045    % parskip, or the item text will crash with the heading.  On the
4046    % other hand, when there is normal text preceding the item (as there
4047    % usually is), we do want to zero parskip, or there would be too much
4048    % space.  In that case, we won't have a \nobreak before.  At least
4049    % that's the theory.
4050    \ifnum\lastpenalty<10000 \parskip=0in \fi
4051    \noindent
4052    \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
4053    %
4054    \ifinner\else
4055      \vadjust{\penalty 1200}% not good to break after first line of item.
4056    \fi
4057    % We can be in inner vertical mode in a footnote, although an
4058    % @itemize looks awful there.
4059   }%
4060   \flushcr
4061 }
4062
4063 % \splitoff TOKENS\endmark defines \first to be the first token in
4064 % TOKENS, and \rest to be the remainder.
4065 %
4066 \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
4067
4068 % Allow an optional argument of an uppercase letter, lowercase letter,
4069 % or number, to specify the first label in the enumerated list.  No
4070 % argument is the same as `1'.
4071 %
4072 \envparseargdef\enumerate{\enumeratey #1  \endenumeratey}
4073 \def\enumeratey #1 #2\endenumeratey{%
4074   % If we were given no argument, pretend we were given `1'.
4075   \def\thearg{#1}%
4076   \ifx\thearg\empty \def\thearg{1}\fi
4077   %
4078   % Detect if the argument is a single token.  If so, it might be a
4079   % letter.  Otherwise, the only valid thing it can be is a number.
4080   % (We will always have one token, because of the test we just made.
4081   % This is a good thing, since \splitoff doesn't work given nothing at
4082   % all -- the first parameter is undelimited.)
4083   \expandafter\splitoff\thearg\endmark
4084   \ifx\rest\empty
4085     % Only one token in the argument.  It could still be anything.
4086     % A ``lowercase letter'' is one whose \lccode is nonzero.
4087     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
4088     %   not equal to itself.
4089     % Otherwise, we assume it's a number.
4090     %
4091     % We need the \relax at the end of the \ifnum lines to stop TeX from
4092     % continuing to look for a <number>.
4093     %
4094     \ifnum\lccode\expandafter`\thearg=0\relax
4095       \numericenumerate % a number (we hope)
4096     \else
4097       % It's a letter.
4098       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
4099         \lowercaseenumerate % lowercase letter
4100       \else
4101         \uppercaseenumerate % uppercase letter
4102       \fi
4103     \fi
4104   \else
4105     % Multiple tokens in the argument.  We hope it's a number.
4106     \numericenumerate
4107   \fi
4108 }
4109
4110 % An @enumerate whose labels are integers.  The starting integer is
4111 % given in \thearg.
4112 %
4113 \def\numericenumerate{%
4114   \itemno = \thearg
4115   \startenumeration{\the\itemno}%
4116 }
4117
4118 % The starting (lowercase) letter is in \thearg.
4119 \def\lowercaseenumerate{%
4120   \itemno = \expandafter`\thearg
4121   \startenumeration{%
4122     % Be sure we're not beyond the end of the alphabet.
4123     \ifnum\itemno=0
4124       \errmessage{No more lowercase letters in @enumerate; get a bigger
4125                   alphabet}%
4126     \fi
4127     \char\lccode\itemno
4128   }%
4129 }
4130
4131 % The starting (uppercase) letter is in \thearg.
4132 \def\uppercaseenumerate{%
4133   \itemno = \expandafter`\thearg
4134   \startenumeration{%
4135     % Be sure we're not beyond the end of the alphabet.
4136     \ifnum\itemno=0
4137       \errmessage{No more uppercase letters in @enumerate; get a bigger
4138                   alphabet}
4139     \fi
4140     \char\uccode\itemno
4141   }%
4142 }
4143
4144 % Call \doitemize, adding a period to the first argument and supplying the
4145 % common last two arguments.  Also subtract one from the initial value in
4146 % \itemno, since @item increments \itemno.
4147 %
4148 \def\startenumeration#1{%
4149   \advance\itemno by -1
4150   \doitemize{#1.}\flushcr
4151 }
4152
4153 % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
4154 % to @enumerate.
4155 %
4156 \def\alphaenumerate{\enumerate{a}}
4157 \def\capsenumerate{\enumerate{A}}
4158 \def\Ealphaenumerate{\Eenumerate}
4159 \def\Ecapsenumerate{\Eenumerate}
4160
4161
4162 % @multitable macros
4163 % Amy Hendrickson, 8/18/94, 3/6/96
4164 %
4165 % @multitable ... @end multitable will make as many columns as desired.
4166 % Contents of each column will wrap at width given in preamble.  Width
4167 % can be specified either with sample text given in a template line,
4168 % or in percent of \hsize, the current width of text on page.
4169
4170 % Table can continue over pages but will only break between lines.
4171
4172 % To make preamble:
4173 %
4174 % Either define widths of columns in terms of percent of \hsize:
4175 %   @multitable @columnfractions .25 .3 .45
4176 %   @item ...
4177 %
4178 %   Numbers following @columnfractions are the percent of the total
4179 %   current hsize to be used for each column. You may use as many
4180 %   columns as desired.
4181
4182
4183 % Or use a template:
4184 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4185 %   @item ...
4186 %   using the widest term desired in each column.
4187
4188 % Each new table line starts with @item, each subsequent new column
4189 % starts with @tab. Empty columns may be produced by supplying @tab's
4190 % with nothing between them for as many times as empty columns are needed,
4191 % ie, @tab@tab@tab will produce two empty columns.
4192
4193 % @item, @tab do not need to be on their own lines, but it will not hurt
4194 % if they are.
4195
4196 % Sample multitable:
4197
4198 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4199 %   @item first col stuff @tab second col stuff @tab third col
4200 %   @item
4201 %   first col stuff
4202 %   @tab
4203 %   second col stuff
4204 %   @tab
4205 %   third col
4206 %   @item first col stuff @tab second col stuff
4207 %   @tab Many paragraphs of text may be used in any column.
4208 %
4209 %         They will wrap at the width determined by the template.
4210 %   @item@tab@tab This will be in third column.
4211 %   @end multitable
4212
4213 % Default dimensions may be reset by user.
4214 % @multitableparskip is vertical space between paragraphs in table.
4215 % @multitableparindent is paragraph indent in table.
4216 % @multitablecolmargin is horizontal space to be left between columns.
4217 % @multitablelinespace is space to leave between table items, baseline
4218 %                                                            to baseline.
4219 %   0pt means it depends on current normal line spacing.
4220 %
4221 \newskip\multitableparskip
4222 \newskip\multitableparindent
4223 \newdimen\multitablecolspace
4224 \newskip\multitablelinespace
4225 \multitableparskip=0pt
4226 \multitableparindent=6pt
4227 \multitablecolspace=12pt
4228 \multitablelinespace=0pt
4229
4230 % Macros used to set up halign preamble:
4231 %
4232 \let\endsetuptable\relax
4233 \def\xendsetuptable{\endsetuptable}
4234 \let\columnfractions\relax
4235 \def\xcolumnfractions{\columnfractions}
4236 \newif\ifsetpercent
4237
4238 % #1 is the @columnfraction, usually a decimal number like .5, but might
4239 % be just 1.  We just use it, whatever it is.
4240 %
4241 \def\pickupwholefraction#1 {%
4242   \global\advance\colcount by 1
4243   \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
4244   \setuptable
4245 }
4246
4247 \newcount\colcount
4248 \def\setuptable#1{%
4249   \def\firstarg{#1}%
4250   \ifx\firstarg\xendsetuptable
4251     \let\go = \relax
4252   \else
4253     \ifx\firstarg\xcolumnfractions
4254       \global\setpercenttrue
4255     \else
4256       \ifsetpercent
4257          \let\go\pickupwholefraction
4258       \else
4259          \global\advance\colcount by 1
4260          \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
4261                    % separator; typically that is always in the input, anyway.
4262          \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
4263       \fi
4264     \fi
4265     \ifx\go\pickupwholefraction
4266       % Put the argument back for the \pickupwholefraction call, so
4267       % we'll always have a period there to be parsed.
4268       \def\go{\pickupwholefraction#1}%
4269     \else
4270       \let\go = \setuptable
4271     \fi%
4272   \fi
4273   \go
4274 }
4275
4276 % multitable-only commands.
4277
4278 % @headitem starts a heading row, which we typeset in bold.  Assignments
4279 % have to be global since we are inside the implicit group of an
4280 % alignment entry.  \everycr below resets \everytab so we don't have to
4281 % undo it ourselves.
4282 \def\headitemfont{\b}% for people to use in the template row; not changeable
4283 \def\headitem{%
4284   \checkenv\multitable
4285   \crcr
4286   \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
4287   \global\everytab={\bf}% can't use \headitemfont since the parsing differs
4288   \the\everytab % for the first item
4289 }%
4290 %
4291 % default for tables with no headings.
4292 \let\headitemcrhook=\relax
4293 %
4294 % A \tab used to include \hskip1sp.  But then the space in a template
4295 % line is not enough.  That is bad.  So let's go back to just `&' until
4296 % we again encounter the problem the 1sp was intended to solve.
4297 %                                       --karl, nathan@acm.org, 20apr99.
4298 \def\tab{\checkenv\multitable &\the\everytab}%
4299
4300 % @multitable ... @end multitable definitions:
4301 %
4302 \newtoks\everytab  % insert after every tab.
4303 %
4304 \envdef\multitable{%
4305   \vskip\parskip
4306   \startsavinginserts
4307   %
4308   % @item within a multitable starts a normal row.
4309   % We use \def instead of \let so that if one of the multitable entries
4310   % contains an @itemize, we don't choke on the \item (seen as \crcr aka
4311   % \endtemplate) expanding \doitemize.
4312   \def\item{\crcr}%
4313   %
4314   \tolerance=9500
4315   \hbadness=9500
4316   \setmultitablespacing
4317   \parskip=\multitableparskip
4318   \parindent=\multitableparindent
4319   \overfullrule=0pt
4320   \global\colcount=0
4321   %
4322   \everycr = {%
4323     \noalign{%
4324       \global\everytab={}% Reset from possible headitem.
4325       \global\colcount=0 % Reset the column counter.
4326       %
4327       % Check for saved footnotes, etc.:
4328       \checkinserts
4329       %
4330       % Perhaps a \nobreak, then reset:
4331       \headitemcrhook
4332       \global\let\headitemcrhook=\relax
4333     }%
4334   }%
4335   %
4336   \parsearg\domultitable
4337 }
4338 \def\domultitable#1{%
4339   % To parse everything between @multitable and @item:
4340   \setuptable#1 \endsetuptable
4341   %
4342   % This preamble sets up a generic column definition, which will
4343   % be used as many times as user calls for columns.
4344   % \vtop will set a single line and will also let text wrap and
4345   % continue for many paragraphs if desired.
4346   \halign\bgroup &%
4347     \global\advance\colcount by 1
4348     \multistrut
4349     \vtop{%
4350       % Use the current \colcount to find the correct column width:
4351       \hsize=\expandafter\csname col\the\colcount\endcsname
4352       %
4353       % In order to keep entries from bumping into each other
4354       % we will add a \leftskip of \multitablecolspace to all columns after
4355       % the first one.
4356       %
4357       % If a template has been used, we will add \multitablecolspace
4358       % to the width of each template entry.
4359       %
4360       % If the user has set preamble in terms of percent of \hsize we will
4361       % use that dimension as the width of the column, and the \leftskip
4362       % will keep entries from bumping into each other.  Table will start at
4363       % left margin and final column will justify at right margin.
4364       %
4365       % Make sure we don't inherit \rightskip from the outer environment.
4366       \rightskip=0pt
4367       \ifnum\colcount=1
4368         % The first column will be indented with the surrounding text.
4369         \advance\hsize by\leftskip
4370       \else
4371         \ifsetpercent \else
4372           % If user has not set preamble in terms of percent of \hsize
4373           % we will advance \hsize by \multitablecolspace.
4374           \advance\hsize by \multitablecolspace
4375         \fi
4376        % In either case we will make \leftskip=\multitablecolspace:
4377       \leftskip=\multitablecolspace
4378       \fi
4379       % Ignoring space at the beginning and end avoids an occasional spurious
4380       % blank line, when TeX decides to break the line at the space before the
4381       % box from the multistrut, so the strut ends up on a line by itself.
4382       % For example:
4383       % @multitable @columnfractions .11 .89
4384       % @item @code{#}
4385       % @tab Legal holiday which is valid in major parts of the whole country.
4386       % Is automatically provided with highlighting sequences respectively
4387       % marking characters.
4388       \noindent\ignorespaces##\unskip\multistrut
4389     }\cr
4390 }
4391 \def\Emultitable{%
4392   \crcr
4393   \egroup % end the \halign
4394   \global\setpercentfalse
4395 }
4396
4397 \def\setmultitablespacing{%
4398   \def\multistrut{\strut}% just use the standard line spacing
4399   %
4400   % Compute \multitablelinespace (if not defined by user) for use in
4401   % \multitableparskip calculation.  We used define \multistrut based on
4402   % this, but (ironically) that caused the spacing to be off.
4403   % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
4404 \ifdim\multitablelinespace=0pt
4405 \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
4406 \global\advance\multitablelinespace by-\ht0
4407 \fi
4408 % Test to see if parskip is larger than space between lines of
4409 % table. If not, do nothing.
4410 %        If so, set to same dimension as multitablelinespace.
4411 \ifdim\multitableparskip>\multitablelinespace
4412 \global\multitableparskip=\multitablelinespace
4413 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4414                                       % than skip between lines in the table.
4415 \fi%
4416 \ifdim\multitableparskip=0pt
4417 \global\multitableparskip=\multitablelinespace
4418 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4419                                       % than skip between lines in the table.
4420 \fi}
4421
4422
4423 \message{conditionals,}
4424
4425 % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
4426 % @ifnotxml always succeed.  They currently do nothing; we don't
4427 % attempt to check whether the conditionals are properly nested.  But we
4428 % have to remember that they are conditionals, so that @end doesn't
4429 % attempt to close an environment group.
4430 %
4431 \def\makecond#1{%
4432   \expandafter\let\csname #1\endcsname = \relax
4433   \expandafter\let\csname iscond.#1\endcsname = 1
4434 }
4435 \makecond{iftex}
4436 \makecond{ifnotdocbook}
4437 \makecond{ifnothtml}
4438 \makecond{ifnotinfo}
4439 \makecond{ifnotplaintext}
4440 \makecond{ifnotxml}
4441
4442 % Ignore @ignore, @ifhtml, @ifinfo, and the like.
4443 %
4444 \def\direntry{\doignore{direntry}}
4445 \def\documentdescription{\doignore{documentdescription}}
4446 \def\docbook{\doignore{docbook}}
4447 \def\html{\doignore{html}}
4448 \def\ifdocbook{\doignore{ifdocbook}}
4449 \def\ifhtml{\doignore{ifhtml}}
4450 \def\ifinfo{\doignore{ifinfo}}
4451 \def\ifnottex{\doignore{ifnottex}}
4452 \def\ifplaintext{\doignore{ifplaintext}}
4453 \def\ifxml{\doignore{ifxml}}
4454 \def\ignore{\doignore{ignore}}
4455 \def\menu{\doignore{menu}}
4456 \def\xml{\doignore{xml}}
4457
4458 % Ignore text until a line `@end #1', keeping track of nested conditionals.
4459 %
4460 % A count to remember the depth of nesting.
4461 \newcount\doignorecount
4462
4463 \def\doignore#1{\begingroup
4464   % Scan in ``verbatim'' mode:
4465   \obeylines
4466   \catcode`\@ = \other
4467   \catcode`\{ = \other
4468   \catcode`\} = \other
4469   %
4470   % Make sure that spaces turn into tokens that match what \doignoretext wants.
4471   \spaceisspace
4472   %
4473   % Count number of #1's that we've seen.
4474   \doignorecount = 0
4475   %
4476   % Swallow text until we reach the matching `@end #1'.
4477   \dodoignore{#1}%
4478 }
4479
4480 { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4481   \obeylines %
4482   %
4483   \gdef\dodoignore#1{%
4484     % #1 contains the command name as a string, e.g., `ifinfo'.
4485     %
4486     % Define a command to find the next `@end #1'.
4487     \long\def\doignoretext##1^^M@end #1{%
4488       \doignoretextyyy##1^^M@#1\_STOP_}%
4489     %
4490     % And this command to find another #1 command, at the beginning of a
4491     % line.  (Otherwise, we would consider a line `@c @ifset', for
4492     % example, to count as an @ifset for nesting.)
4493     \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
4494     %
4495     % And now expand that command.
4496     \doignoretext ^^M%
4497   }%
4498 }
4499
4500 \def\doignoreyyy#1{%
4501   \def\temp{#1}%
4502   \ifx\temp\empty                       % Nothing found.
4503     \let\next\doignoretextzzz
4504   \else                                 % Found a nested condition, ...
4505     \advance\doignorecount by 1
4506     \let\next\doignoretextyyy           % ..., look for another.
4507     % If we're here, #1 ends with ^^M\ifinfo (for example).
4508   \fi
4509   \next #1% the token \_STOP_ is present just after this macro.
4510 }
4511
4512 % We have to swallow the remaining "\_STOP_".
4513 %
4514 \def\doignoretextzzz#1{%
4515   \ifnum\doignorecount = 0      % We have just found the outermost @end.
4516     \let\next\enddoignore
4517   \else                         % Still inside a nested condition.
4518     \advance\doignorecount by -1
4519     \let\next\doignoretext      % Look for the next @end.
4520   \fi
4521   \next
4522 }
4523
4524 % Finish off ignored text.
4525 { \obeylines%
4526   % Ignore anything after the last `@end #1'; this matters in verbatim
4527   % environments, where otherwise the newline after an ignored conditional
4528   % would result in a blank line in the output.
4529   \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4530 }
4531
4532
4533 % @set VAR sets the variable VAR to an empty value.
4534 % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4535 %
4536 % Since we want to separate VAR from REST-OF-LINE (which might be
4537 % empty), we can't just use \parsearg; we have to insert a space of our
4538 % own to delimit the rest of the line, and then take it out again if we
4539 % didn't need it.
4540 % We rely on the fact that \parsearg sets \catcode`\ =10.
4541 %
4542 \parseargdef\set{\setyyy#1 \endsetyyy}
4543 \def\setyyy#1 #2\endsetyyy{%
4544   {%
4545     \makevalueexpandable
4546     \def\temp{#2}%
4547     \edef\next{\gdef\makecsname{SET#1}}%
4548     \ifx\temp\empty
4549       \next{}%
4550     \else
4551       \setzzz#2\endsetzzz
4552     \fi
4553   }%
4554 }
4555 % Remove the trailing space \setxxx inserted.
4556 \def\setzzz#1 \endsetzzz{\next{#1}}
4557
4558 % @clear VAR clears (i.e., unsets) the variable VAR.
4559 %
4560 \parseargdef\clear{%
4561   {%
4562     \makevalueexpandable
4563     \global\expandafter\let\csname SET#1\endcsname=\relax
4564   }%
4565 }
4566
4567 % @value{foo} gets the text saved in variable foo.
4568 \def\value{\begingroup\makevalueexpandable\valuexxx}
4569 \def\valuexxx#1{\expandablevalue{#1}\endgroup}
4570 {
4571   \catcode`\-=\active \catcode`\_=\active
4572   %
4573   \gdef\makevalueexpandable{%
4574     \let\value = \expandablevalue
4575     % We don't want these characters active, ...
4576     \catcode`\-=\other \catcode`\_=\other
4577     % ..., but we might end up with active ones in the argument if
4578     % we're called from @code, as @code{@value{foo-bar_}}, though.
4579     % So \let them to their normal equivalents.
4580     \let-\normaldash \let_\normalunderscore
4581   }
4582 }
4583
4584 % We have this subroutine so that we can handle at least some @value's
4585 % properly in indexes (we call \makevalueexpandable in \indexdummies).
4586 % The command has to be fully expandable (if the variable is set), since
4587 % the result winds up in the index file.  This means that if the
4588 % variable's value contains other Texinfo commands, it's almost certain
4589 % it will fail (although perhaps we could fix that with sufficient work
4590 % to do a one-level expansion on the result, instead of complete).
4591
4592 % Unfortunately, this has the consequence that when _ is in the *value*
4593 % of an @set, it does not print properly in the roman fonts (get the cmr
4594 % dot accent at position 126 instead).  No fix comes to mind, and it's
4595 % been this way since 2003 or earlier, so just ignore it.
4596
4597 \def\expandablevalue#1{%
4598   \expandafter\ifx\csname SET#1\endcsname\relax
4599     {[No value for ``#1'']}%
4600     \message{Variable `#1', used in @value, is not set.}%
4601   \else
4602     \csname SET#1\endcsname
4603   \fi
4604 }
4605
4606 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4607 % with @set.
4608
4609 % To get the special treatment we need for `@end ifset,' we call
4610 % \makecond and then redefine.
4611 %
4612 \makecond{ifset}
4613 \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4614 \def\doifset#1#2{%
4615   {%
4616     \makevalueexpandable
4617     \let\next=\empty
4618     \expandafter\ifx\csname SET#2\endcsname\relax
4619       #1% If not set, redefine \next.
4620     \fi
4621     \expandafter
4622   }\next
4623 }
4624 \def\ifsetfail{\doignore{ifset}}
4625
4626 % @ifclear VAR ... @end executes the `...' iff VAR has never been
4627 % defined with @set, or has been undefined with @clear.
4628 %
4629 % The `\else' inside the `\doifset' parameter is a trick to reuse the
4630 % above code: if the variable is not set, do nothing, if it is set,
4631 % then redefine \next to \ifclearfail.
4632 %
4633 \makecond{ifclear}
4634 \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4635 \def\ifclearfail{\doignore{ifclear}}
4636
4637 % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
4638 % without the @) is in fact defined.  We can only feasibly check at the
4639 % TeX level, so something like `mathcode' is going to considered
4640 % defined even though it is not a Texinfo command.
4641
4642 \makecond{ifcommanddefined}
4643 \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
4644 %
4645 \def\doifcmddefined#1#2{{%
4646     \makevalueexpandable
4647     \let\next=\empty
4648     \expandafter\ifx\csname #2\endcsname\relax
4649       #1% If not defined, \let\next as above.
4650     \fi
4651     \expandafter
4652   }\next
4653 }
4654 \def\ifcmddefinedfail{\doignore{ifcommanddefined}}
4655
4656 % @ifcommandnotdefined CMD ... handled similar to @ifclear above.
4657 \makecond{ifcommandnotdefined}
4658 \def\ifcommandnotdefined{%
4659   \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
4660 \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
4661
4662 % Set the `txicommandconditionals' variable, so documents have a way to
4663 % test if the @ifcommand...defined conditionals are available.
4664 \set txicommandconditionals
4665
4666 % @dircategory CATEGORY  -- specify a category of the dir file
4667 % which this file should belong to.  Ignore this in TeX.
4668 \let\dircategory=\comment
4669
4670 % @defininfoenclose.
4671 \let\definfoenclose=\comment
4672
4673
4674 \message{indexing,}
4675 % Index generation facilities
4676
4677 % Define \newwrite to be identical to plain tex's \newwrite
4678 % except not \outer, so it can be used within macros and \if's.
4679 \edef\newwrite{\makecsname{ptexnewwrite}}
4680
4681 % \newindex {foo} defines an index named IX.
4682 % It automatically defines \IXindex such that
4683 % \IXindex ...rest of line... puts an entry in the index IX.
4684 % It also defines \IXindfile to be the number of the output channel for
4685 % the file that accumulates this index.  The file's extension is IX.
4686 % The name of an index should be no more than 2 characters long
4687 % for the sake of vms.
4688 %
4689 \def\newindex#1{%
4690   \expandafter\chardef\csname#1indfile\endcsname=0
4691   \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
4692     \noexpand\doindex{#1}}
4693 }
4694
4695 % @defindex foo  ==  \newindex{foo}
4696 %
4697 \def\defindex{\parsearg\newindex}
4698
4699 % Define @defcodeindex, like @defindex except put all entries in @code.
4700 %
4701 \def\defcodeindex{\parsearg\newcodeindex}
4702 %
4703 \def\newcodeindex#1{%
4704   \expandafter\chardef\csname#1indfile\endcsname=0
4705   \expandafter\xdef\csname#1index\endcsname{%
4706     \noexpand\docodeindex{#1}}%
4707 }
4708
4709 % The default indices:
4710 \newindex{cp}%      concepts,
4711 \newcodeindex{fn}%  functions,
4712 \newcodeindex{vr}%  variables,
4713 \newcodeindex{tp}%  types,
4714 \newcodeindex{ky}%  keys
4715 \newcodeindex{pg}%  and programs.
4716
4717
4718 % @synindex foo bar    makes index foo feed into index bar.
4719 % Do this instead of @defindex foo if you don't want it as a separate index.
4720 %
4721 % @syncodeindex foo bar   similar, but put all entries made for index foo
4722 % inside @code.
4723 %
4724 \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4725 \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4726
4727 % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4728 % #3 the target index (bar).
4729 \def\dosynindex#1#2#3{%
4730   % Only do \closeout if we haven't already done it, else we'll end up
4731   % closing the target index.
4732   \expandafter \ifx\csname donesynindex#2\endcsname \relax
4733     % The \closeout helps reduce unnecessary open files; the limit on the
4734     % Acorn RISC OS is a mere 16 files.
4735     \expandafter\closeout\csname#2indfile\endcsname
4736     \expandafter\let\csname donesynindex#2\endcsname = 1
4737   \fi
4738   % redefine \fooindfile:
4739   \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4740   \expandafter\let\csname#2indfile\endcsname=\temp
4741   % redefine \fooindex:
4742   \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
4743 }
4744
4745 % Define \doindex, the driver for all index macros.
4746 % Argument #1 is generated by the calling \fooindex macro,
4747 % and it the two-letter name of the index.
4748
4749 \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
4750 \def\doindexxxx #1{\doind{\indexname}{#1}}
4751
4752 % like the previous two, but they put @code around the argument.
4753 \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
4754 \def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
4755
4756 % Used when writing an index entry out to an index file, to prevent
4757 % expansion of Texinfo commands that can appear in an index entry.
4758 %
4759 \def\indexdummies{%
4760   \escapechar = `\\     % use backslash in output files.
4761   \def\@{@}% change to @@ when we switch to @ as escape char in index files.
4762   \def\ {\realbackslash\space }%
4763   %
4764   % Need these unexpandable (because we define \tt as a dummy)
4765   % definitions when @{ or @} appear in index entry text.  Also, more
4766   % complicated, when \tex is in effect and \{ is a \delimiter again.
4767   % We can't use \lbracecmd and \rbracecmd because texindex assumes
4768   % braces and backslashes are used only as delimiters.  Perhaps we
4769   % should use @lbracechar and @rbracechar?
4770   \def\{{{\tt\char123}}%
4771   \def\}{{\tt\char125}}%
4772   %
4773   % Do the redefinitions.
4774   \commondummies
4775 }
4776
4777 % For the aux and toc files, @ is the escape character.  So we want to
4778 % redefine everything using @ as the escape character (instead of
4779 % \realbackslash, still used for index files).  When everything uses @,
4780 % this will be simpler.
4781 %
4782 \def\atdummies{%
4783   \def\@{@@}%
4784   \def\ {@ }%
4785   \let\{ = \lbraceatcmd
4786   \let\} = \rbraceatcmd
4787   %
4788   % Do the redefinitions.
4789   \commondummies
4790   \otherbackslash
4791 }
4792
4793 % Called from \indexdummies and \atdummies.
4794 %
4795 \def\commondummies{%
4796   % \definedummyword defines \#1 as \string\#1\space, thus effectively
4797   % preventing its expansion.  This is used only for control words,
4798   % not control letters, because the \space would be incorrect for
4799   % control characters, but is needed to separate the control word
4800   % from whatever follows.
4801   %
4802   % For control letters, we have \definedummyletter, which omits the
4803   % space.
4804   %
4805   % These can be used both for control words that take an argument and
4806   % those that do not.  If it is followed by {arg} in the input, then
4807   % that will dutifully get written to the index (or wherever).
4808   %
4809   \def\definedummyword  ##1{\def##1{\string##1\space}}%
4810   \def\definedummyletter##1{\def##1{\string##1}}%
4811   \let\definedummyaccent\definedummyletter
4812   %
4813   \commondummiesnofonts
4814   %
4815   \definedummyletter\_%
4816   \definedummyletter\-%
4817   %
4818   % Non-English letters.
4819   \definedummyword\AA
4820   \definedummyword\AE
4821   \definedummyword\DH
4822   \definedummyword\L
4823   \definedummyword\O
4824   \definedummyword\OE
4825   \definedummyword\TH
4826   \definedummyword\aa
4827   \definedummyword\ae
4828   \definedummyword\dh
4829   \definedummyword\exclamdown
4830   \definedummyword\l
4831   \definedummyword\o
4832   \definedummyword\oe
4833   \definedummyword\ordf
4834   \definedummyword\ordm
4835   \definedummyword\questiondown
4836   \definedummyword\ss
4837   \definedummyword\th
4838   %
4839   % Although these internal commands shouldn't show up, sometimes they do.
4840   \definedummyword\bf
4841   \definedummyword\gtr
4842   \definedummyword\hat
4843   \definedummyword\less
4844   \definedummyword\sf
4845   \definedummyword\sl
4846   \definedummyword\tclose
4847   \definedummyword\tt
4848   %
4849   \definedummyword\LaTeX
4850   \definedummyword\TeX
4851   %
4852   % Assorted special characters.
4853   \definedummyword\arrow
4854   \definedummyword\bullet
4855   \definedummyword\comma
4856   \definedummyword\copyright
4857   \definedummyword\registeredsymbol
4858   \definedummyword\dots
4859   \definedummyword\enddots
4860   \definedummyword\entrybreak
4861   \definedummyword\equiv
4862   \definedummyword\error
4863   \definedummyword\euro
4864   \definedummyword\expansion
4865   \definedummyword\geq
4866   \definedummyword\guillemetleft
4867   \definedummyword\guillemetright
4868   \definedummyword\guilsinglleft
4869   \definedummyword\guilsinglright
4870   \definedummyword\lbracechar
4871   \definedummyword\leq
4872   \definedummyword\mathopsup
4873   \definedummyword\minus
4874   \definedummyword\ogonek
4875   \definedummyword\pounds
4876   \definedummyword\point
4877   \definedummyword\print
4878   \definedummyword\quotedblbase
4879   \definedummyword\quotedblleft
4880   \definedummyword\quotedblright
4881   \definedummyword\quoteleft
4882   \definedummyword\quoteright
4883   \definedummyword\quotesinglbase
4884   \definedummyword\rbracechar
4885   \definedummyword\result
4886   \definedummyword\sub
4887   \definedummyword\sup
4888   \definedummyword\textdegree
4889   %
4890   % We want to disable all macros so that they are not expanded by \write.
4891   \macrolist
4892   %
4893   \normalturnoffactive
4894   %
4895   % Handle some cases of @value -- where it does not contain any
4896   % (non-fully-expandable) commands.
4897   \makevalueexpandable
4898 }
4899
4900 % \commondummiesnofonts: common to \commondummies and \indexnofonts.
4901 % Define \definedumyletter, \definedummyaccent and \definedummyword before
4902 % using.
4903 %
4904 \def\commondummiesnofonts{%
4905   % Control letters and accents.
4906   \definedummyletter\!%
4907   \definedummyaccent\"%
4908   \definedummyaccent\'%
4909   \definedummyletter\*%
4910   \definedummyaccent\,%
4911   \definedummyletter\.%
4912   \definedummyletter\/%
4913   \definedummyletter\:%
4914   \definedummyaccent\=%
4915   \definedummyletter\?%
4916   \definedummyaccent\^%
4917   \definedummyaccent\`%
4918   \definedummyaccent\~%
4919   \definedummyword\u
4920   \definedummyword\v
4921   \definedummyword\H
4922   \definedummyword\dotaccent
4923   \definedummyword\ogonek
4924   \definedummyword\ringaccent
4925   \definedummyword\tieaccent
4926   \definedummyword\ubaraccent
4927   \definedummyword\udotaccent
4928   \definedummyword\dotless
4929   %
4930   % Texinfo font commands.
4931   \definedummyword\b
4932   \definedummyword\i
4933   \definedummyword\r
4934   \definedummyword\sansserif
4935   \definedummyword\sc
4936   \definedummyword\slanted
4937   \definedummyword\t
4938   %
4939   % Commands that take arguments.
4940   \definedummyword\abbr
4941   \definedummyword\acronym
4942   \definedummyword\anchor
4943   \definedummyword\cite
4944   \definedummyword\code
4945   \definedummyword\command
4946   \definedummyword\dfn
4947   \definedummyword\dmn
4948   \definedummyword\email
4949   \definedummyword\emph
4950   \definedummyword\env
4951   \definedummyword\file
4952   \definedummyword\image
4953   \definedummyword\indicateurl
4954   \definedummyword\inforef
4955   \definedummyword\kbd
4956   \definedummyword\key
4957   \definedummyword\math
4958   \definedummyword\option
4959   \definedummyword\pxref
4960   \definedummyword\ref
4961   \definedummyword\samp
4962   \definedummyword\strong
4963   \definedummyword\tie
4964   \definedummyword\U
4965   \definedummyword\uref
4966   \definedummyword\url
4967   \definedummyword\var
4968   \definedummyword\verb
4969   \definedummyword\w
4970   \definedummyword\xref
4971 }
4972
4973 % For testing: output @{ and @} in index sort strings as \{ and \}.
4974 \newif\ifusebracesinindexes
4975
4976 \let\indexlbrace\relax
4977 \let\indexrbrace\relax
4978
4979 {\catcode`\@=0
4980 \catcode`\\=13
4981   @gdef@backslashdisappear{@def\{}}
4982 }
4983
4984 {
4985 \catcode`\<=13
4986 \catcode`\-=13
4987 \catcode`\`=13
4988   \gdef\indexnonalnumdisappear{%
4989     \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
4990       % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
4991       % (Introduced for FSFS 2nd ed.)
4992       \let`=\empty
4993     \fi
4994     %
4995     \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
4996       \backslashdisappear
4997     \fi
4998     %
4999     \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
5000       \def-{}%
5001     \fi
5002     \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
5003       \def<{}%
5004     \fi
5005     \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
5006       \def\@{}%
5007     \fi
5008   }
5009
5010   \gdef\indexnonalnumreappear{%
5011     \useindexbackslash
5012     \let-\normaldash
5013     \let<\normalless
5014     \def\@{@}%
5015   }
5016 }
5017
5018
5019 % \indexnofonts is used when outputting the strings to sort the index
5020 % by, and when constructing control sequence names.  It eliminates all
5021 % control sequences and just writes whatever the best ASCII sort string
5022 % would be for a given command (usually its argument).
5023 %
5024 \def\indexnofonts{%
5025   % Accent commands should become @asis.
5026   \def\definedummyaccent##1{\let##1\asis}%
5027   % We can just ignore other control letters.
5028   \def\definedummyletter##1{\let##1\empty}%
5029   % All control words become @asis by default; overrides below.
5030   \let\definedummyword\definedummyaccent
5031   \commondummiesnofonts
5032   %
5033   % Don't no-op \tt, since it isn't a user-level command
5034   % and is used in the definitions of the active chars like <, >, |, etc.
5035   % Likewise with the other plain tex font commands.
5036   %\let\tt=\asis
5037   %
5038   \def\ { }%
5039   \def\@{@}%
5040   \def\_{\normalunderscore}%
5041   \def\-{}% @- shouldn't affect sorting
5042   %
5043   \uccode`\1=`\{ \uppercase{\def\{{1}}%
5044   \uccode`\1=`\} \uppercase{\def\}{1}}%
5045   \let\lbracechar\{%
5046   \let\rbracechar\}%
5047   %
5048   % Non-English letters.
5049   \def\AA{AA}%
5050   \def\AE{AE}%
5051   \def\DH{DZZ}%
5052   \def\L{L}%
5053   \def\OE{OE}%
5054   \def\O{O}%
5055   \def\TH{TH}%
5056   \def\aa{aa}%
5057   \def\ae{ae}%
5058   \def\dh{dzz}%
5059   \def\exclamdown{!}%
5060   \def\l{l}%
5061   \def\oe{oe}%
5062   \def\ordf{a}%
5063   \def\ordm{o}%
5064   \def\o{o}%
5065   \def\questiondown{?}%
5066   \def\ss{ss}%
5067   \def\th{th}%
5068   %
5069   \def\LaTeX{LaTeX}%
5070   \def\TeX{TeX}%
5071   %
5072   % Assorted special characters.
5073   % (The following {} will end up in the sort string, but that's ok.)
5074   \def\arrow{->}%
5075   \def\bullet{bullet}%
5076   \def\comma{,}%
5077   \def\copyright{copyright}%
5078   \def\dots{...}%
5079   \def\enddots{...}%
5080   \def\equiv{==}%
5081   \def\error{error}%
5082   \def\euro{euro}%
5083   \def\expansion{==>}%
5084   \def\geq{>=}%
5085   \def\guillemetleft{<<}%
5086   \def\guillemetright{>>}%
5087   \def\guilsinglleft{<}%
5088   \def\guilsinglright{>}%
5089   \def\leq{<=}%
5090   \def\minus{-}%
5091   \def\point{.}%
5092   \def\pounds{pounds}%
5093   \def\print{-|}%
5094   \def\quotedblbase{"}%
5095   \def\quotedblleft{"}%
5096   \def\quotedblright{"}%
5097   \def\quoteleft{`}%
5098   \def\quoteright{'}%
5099   \def\quotesinglbase{,}%
5100   \def\registeredsymbol{R}%
5101   \def\result{=>}%
5102   \def\textdegree{o}%
5103   %
5104   % We need to get rid of all macros, leaving only the arguments (if present).
5105   % Of course this is not nearly correct, but it is the best we can do for now.
5106   % makeinfo does not expand macros in the argument to @deffn, which ends up
5107   % writing an index entry, and texindex isn't prepared for an index sort entry
5108   % that starts with \.
5109   %
5110   % Since macro invocations are followed by braces, we can just redefine them
5111   % to take a single TeX argument.  The case of a macro invocation that
5112   % goes to end-of-line is not handled.
5113   %
5114   \macrolist
5115 }
5116
5117
5118 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
5119
5120 % Most index entries go through here, but \dosubind is the general case.
5121 % #1 is the index name, #2 is the entry text.
5122 \def\doind#1#2{\dosubind{#1}{#2}{}}
5123
5124 % There is also \dosubind {index}{topic}{subtopic}
5125 % which makes an entry in a two-level index such as the operation index.
5126 % TODO: Two-level index?  Operation index?
5127
5128 % Workhorse for all indexes.
5129 % #1 is name of index, #2 is stuff to put there, #3 is subentry --
5130 % empty if called from \doind, as we usually are (the main exception
5131 % is with most defuns, which call us directly).
5132 %
5133 \def\dosubind#1#2#3{%
5134   \iflinks
5135   {%
5136     \requireopenindexfile{#1}%
5137     % Store the main index entry text (including the third arg).
5138     \toks0 = {#2}%
5139     % If third arg is present, precede it with a space.
5140     \def\thirdarg{#3}%
5141     \ifx\thirdarg\empty \else
5142       \toks0 = \expandafter{\the\toks0 \space #3}%
5143     \fi
5144     %
5145     \edef\writeto{\csname#1indfile\endcsname}%
5146     %
5147     \safewhatsit\dosubindwrite
5148   }%
5149   \fi
5150 }
5151
5152 % Check if an index file has been opened, and if not, open it.
5153 \def\requireopenindexfile#1{%
5154 \ifnum\csname #1indfile\endcsname=0
5155   \expandafter\newwrite \csname#1indfile\endcsname
5156   \edef\suffix{#1}%
5157   % A .fls suffix would conflict with the file extension for the output
5158   % of -recorder, so use .f1s instead.
5159   \ifx\suffix\indexisfl\def\suffix{f1}\fi
5160   % Open the file
5161   \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
5162   % Using \immediate here prevents an object entering into the current box,
5163   % which could confound checks such as those in \safewhatsit for preceding
5164   % skips.
5165 \fi}
5166 \def\indexisfl{fl}
5167
5168 % Output \ as {\indexbackslash}, because \ is an escape character in
5169 % the index files.
5170 \let\indexbackslash=\relax
5171 {\catcode`\@=0 \catcode`\\=\active
5172   @gdef@useindexbackslash{@def\{{@indexbackslash}}}
5173 }
5174
5175 % Definition for writing index entry text.
5176 \def\sortas#1{\ignorespaces}%
5177
5178 % Definition for writing index entry sort key.  Should occur at the at
5179 % the beginning of the index entry, like
5180 %     @cindex @sortas{september} \september
5181 % The \ignorespaces takes care of following space, but there's no way
5182 % to remove space before it.
5183 {
5184 \catcode`\-=13
5185 \gdef\indexwritesortas{%
5186   \begingroup
5187   \indexnonalnumreappear
5188   \indexwritesortasxxx}
5189 \gdef\indexwritesortasxxx#1{%
5190   \xdef\indexsortkey{#1}\endgroup}
5191 }
5192
5193
5194 % Write the entry in \toks0 to the index file.
5195 %
5196 \def\dosubindwrite{%
5197   % Put the index entry in the margin if desired.
5198   \ifx\SETmarginindex\relax\else
5199     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
5200   \fi
5201   %
5202   % Remember, we are within a group.
5203   \indexdummies % Must do this here, since \bf, etc expand at this stage
5204   \useindexbackslash % \indexbackslash isn't defined now so it will be output 
5205                      % as is; and it will print as backslash.
5206   % The braces around \indexbrace are recognized by texindex.
5207   %
5208   % Get the string to sort by, by processing the index entry with all
5209   % font commands turned off.
5210   {\indexnofonts
5211    \def\lbracechar{{\indexlbrace}}%
5212    \def\rbracechar{{\indexrbrace}}%
5213    \let\{=\lbracechar
5214    \let\}=\rbracechar
5215    \indexnonalnumdisappear
5216    \xdef\indexsortkey{}%
5217    \let\sortas=\indexwritesortas
5218    \edef\temp{\the\toks0}%
5219    \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas
5220    \ifx\indexsortkey\empty
5221      \xdef\indexsortkey{\temp}%
5222      \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
5223    \fi
5224   }%
5225   %
5226   % Set up the complete index entry, with both the sort key and
5227   % the original text, including any font commands.  We write
5228   % three arguments to \entry to the .?? file (four in the
5229   % subentry case), texindex reduces to two when writing the .??s
5230   % sorted result.
5231   \edef\temp{%
5232     \write\writeto{%
5233       \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}%
5234   }%
5235   \temp
5236 }
5237 \newbox\dummybox % used above
5238
5239 % Take care of unwanted page breaks/skips around a whatsit:
5240 %
5241 % If a skip is the last thing on the list now, preserve it
5242 % by backing up by \lastskip, doing the \write, then inserting
5243 % the skip again.  Otherwise, the whatsit generated by the
5244 % \write or \pdfdest will make \lastskip zero.  The result is that
5245 % sequences like this:
5246 % @end defun
5247 % @tindex whatever
5248 % @defun ...
5249 % will have extra space inserted, because the \medbreak in the
5250 % start of the @defun won't see the skip inserted by the @end of
5251 % the previous defun.
5252 %
5253 % But don't do any of this if we're not in vertical mode.  We
5254 % don't want to do a \vskip and prematurely end a paragraph.
5255 %
5256 % Avoid page breaks due to these extra skips, too.
5257 %
5258 % But wait, there is a catch there:
5259 % We'll have to check whether \lastskip is zero skip.  \ifdim is not
5260 % sufficient for this purpose, as it ignores stretch and shrink parts
5261 % of the skip.  The only way seems to be to check the textual
5262 % representation of the skip.
5263 %
5264 % The following is almost like \def\zeroskipmacro{0.0pt} except that
5265 % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
5266 %
5267 \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
5268 %
5269 \newskip\whatsitskip
5270 \newcount\whatsitpenalty
5271 %
5272 % ..., ready, GO:
5273 %
5274 \def\safewhatsit#1{\ifhmode
5275   #1%
5276  \else
5277   % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
5278   \whatsitskip = \lastskip
5279   \edef\lastskipmacro{\the\lastskip}%
5280   \whatsitpenalty = \lastpenalty
5281   %
5282   % If \lastskip is nonzero, that means the last item was a
5283   % skip.  And since a skip is discardable, that means this
5284   % -\whatsitskip glue we're inserting is preceded by a
5285   % non-discardable item, therefore it is not a potential
5286   % breakpoint, therefore no \nobreak needed.
5287   \ifx\lastskipmacro\zeroskipmacro
5288   \else
5289     \vskip-\whatsitskip
5290   \fi
5291   %
5292   #1%
5293   %
5294   \ifx\lastskipmacro\zeroskipmacro
5295     % If \lastskip was zero, perhaps the last item was a penalty, and
5296     % perhaps it was >=10000, e.g., a \nobreak.  In that case, we want
5297     % to re-insert the same penalty (values >10000 are used for various
5298     % signals); since we just inserted a non-discardable item, any
5299     % following glue (such as a \parskip) would be a breakpoint.  For example:
5300     %   @deffn deffn-whatever
5301     %   @vindex index-whatever
5302     %   Description.
5303     % would allow a break between the index-whatever whatsit
5304     % and the "Description." paragraph.
5305     \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
5306   \else
5307     % On the other hand, if we had a nonzero \lastskip,
5308     % this make-up glue would be preceded by a non-discardable item
5309     % (the whatsit from the \write), so we must insert a \nobreak.
5310     \nobreak\vskip\whatsitskip
5311   \fi
5312 \fi}
5313
5314 % The index entry written in the file actually looks like
5315 %  \entry {sortstring}{page}{topic}
5316 % or
5317 %  \entry {sortstring}{page}{topic}{subtopic}
5318 % The texindex program reads in these files and writes files
5319 % containing these kinds of lines:
5320 %  \initial {c}
5321 %     before the first topic whose initial is c
5322 %  \entry {topic}{pagelist}
5323 %     for a topic that is used without subtopics
5324 %  \primary {topic}
5325 %     for the beginning of a topic that is used with subtopics
5326 %  \secondary {subtopic}{pagelist}
5327 %     for each subtopic.
5328
5329 % Define the user-accessible indexing commands
5330 % @findex, @vindex, @kindex, @cindex.
5331
5332 \def\findex {\fnindex}
5333 \def\kindex {\kyindex}
5334 \def\cindex {\cpindex}
5335 \def\vindex {\vrindex}
5336 \def\tindex {\tpindex}
5337 \def\pindex {\pgindex}
5338
5339 \def\cindexsub {\begingroup\obeylines\cindexsub}
5340 {\obeylines %
5341 \gdef\cindexsub "#1" #2^^M{\endgroup %
5342 \dosubind{cp}{#2}{#1}}}
5343
5344 % Define the macros used in formatting output of the sorted index material.
5345
5346 % @printindex causes a particular index (the ??s file) to get printed.
5347 % It does not print any chapter heading (usually an @unnumbered).
5348 %
5349 \parseargdef\printindex{\begingroup
5350   \dobreak \chapheadingskip{10000}%
5351   %
5352   \smallfonts \rm
5353   \tolerance = 9500
5354   \plainfrenchspacing
5355   \everypar = {}% don't want the \kern\-parindent from indentation suppression.
5356   %
5357   % See if the index file exists and is nonempty.
5358   % Change catcode of @ here so that if the index file contains
5359   % \initial {@}
5360   % as its first line, TeX doesn't complain about mismatched braces
5361   % (because it thinks @} is a control sequence).
5362   \catcode`\@ = 11
5363   % See comment in \requireopenindexfile.
5364   \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
5365   \openin 1 \jobname.\indexname s
5366   \ifeof 1
5367     % \enddoublecolumns gets confused if there is no text in the index,
5368     % and it loses the chapter title and the aux file entries for the
5369     % index.  The easiest way to prevent this problem is to make sure
5370     % there is some text.
5371     \putwordIndexNonexistent
5372   \else
5373     \catcode`\\ = 0
5374     %
5375     % If the index file exists but is empty, then \openin leaves \ifeof
5376     % false.  We have to make TeX try to read something from the file, so
5377     % it can discover if there is anything in it.
5378     \read 1 to \thisline
5379     \ifeof 1
5380       \putwordIndexIsEmpty
5381     \else
5382       % Index files are almost Texinfo source, but we use \ as the escape
5383       % character.  It would be better to use @, but that's too big a change
5384       % to make right now.
5385       \def\indexbackslash{\ttbackslash}%
5386       \let\indexlbrace\{   % Likewise, set these sequences for braces
5387       \let\indexrbrace\}   % used in the sort key.
5388       \begindoublecolumns
5389       \let\entryorphanpenalty=\indexorphanpenalty
5390       %
5391       % Read input from the index file line by line.
5392       \loopdo
5393         \ifeof1
5394           \let\firsttoken\relax
5395         \else
5396           \read 1 to \nextline
5397           \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}%
5398           \act
5399         \fi
5400         \thisline
5401         %
5402         \ifeof1\else
5403         \let\thisline\nextline
5404       \repeat
5405       %%
5406       \enddoublecolumns
5407     \fi
5408   \fi
5409   \closein 1
5410 \endgroup}
5411
5412 \def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken}
5413 \long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1}
5414
5415 \def\loopdo#1\repeat{\def\body{#1}\loopdoxxx}
5416 \def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next}
5417
5418 % These macros are used by the sorted index file itself.
5419 % Change them to control the appearance of the index.
5420
5421 {\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
5422 \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
5423 \catcode`\$=3
5424 \gdef\initialglyphs{%
5425   % Some changes for non-alphabetic characters.  Using the glyphs from the
5426   % math fonts looks more consistent than the typewriter font used elsewhere
5427   % for these characters.
5428   \def\indexbackslash{\math{\backslash}}%
5429   \let\\=\indexbackslash
5430   %
5431   % Can't get bold backslash so don't use bold forward slash
5432   \catcode`\/=13
5433   \def/{{\secrmnotbold \normalslash}}%
5434   \def-{{\normaldash\normaldash}}% en dash `--'
5435   \def^{{\chapbf \normalcaret}}%
5436   \def~{{\chapbf \normaltilde}}%
5437   \def\_{%
5438      \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
5439   \def|{$\vert$}%
5440   \def<{$\less$}%
5441   \def>{$\gtr$}%
5442   \def+{$\normalplus$}%
5443 }}
5444
5445 \def\initial{%
5446   \bgroup
5447   \initialglyphs
5448   \initialx
5449 }
5450
5451 \def\initialx#1{%
5452   % Remove any glue we may have, we'll be inserting our own.
5453   \removelastskip
5454   %
5455   % We like breaks before the index initials, so insert a bonus.
5456   % The glue before the bonus allows a little bit of space at the
5457   % bottom of a column to reduce an increase in inter-line spacing.
5458   \nobreak
5459   \vskip 0pt plus 5\baselineskip
5460   \penalty -300 
5461   \vskip 0pt plus -5\baselineskip
5462   %
5463   % Typeset the initial.  Making this add up to a whole number of
5464   % baselineskips increases the chance of the dots lining up from column
5465   % to column.  It still won't often be perfect, because of the stretch
5466   % we need before each entry, but it's better.
5467   %
5468   % No shrink because it confuses \balancecolumns.
5469   \vskip 1.67\baselineskip plus 1\baselineskip
5470   \leftline{\secfonts \kern-0.05em \secbf #1}%
5471   % \secfonts is inside the argument of \leftline so that the change of
5472   % \baselineskip will not affect any glue inserted before the vbox that
5473   % \leftline creates.
5474   % Do our best not to break after the initial.
5475   \nobreak
5476   \vskip .33\baselineskip plus .1\baselineskip
5477   \egroup % \initialglyphs
5478 }
5479
5480 \newdimen\entryrightmargin
5481 \entryrightmargin=0pt
5482
5483 % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
5484 % then page number (#2) flushed to the right margin.  It is used for index
5485 % and table of contents entries.  The paragraph is indented by \leftskip.
5486 %
5487 \def\entry{%
5488   \begingroup
5489     %
5490     % Start a new paragraph if necessary, so our assignments below can't
5491     % affect previous text.
5492     \par
5493     %
5494     % No extra space above this paragraph.
5495     \parskip = 0in
5496     %
5497     % When reading the text of entry, convert explicit line breaks
5498     % from @* into spaces.  The user might give these in long section
5499     % titles, for instance.
5500     \def\*{\unskip\space\ignorespaces}%
5501     \def\entrybreak{\hfil\break}% An undocumented command
5502     %
5503     % A bit of stretch before each entry for the benefit of balancing
5504     % columns.
5505     \vskip 0pt plus0.5pt
5506     %
5507     % Swallow the left brace of the text (first parameter):
5508     \afterassignment\doentry
5509     \let\temp =
5510 }
5511 \def\entrybreak{\unskip\space\ignorespaces}%
5512 \def\doentry{%
5513     % Save the text of the entry
5514     \global\setbox\boxA=\hbox\bgroup
5515     \bgroup % Instead of the swallowed brace.
5516       \noindent
5517       \aftergroup\finishentry
5518       % And now comes the text of the entry.
5519       % Not absorbing as a macro argument reduces the chance of problems
5520       % with catcodes occurring.
5521 }
5522 {\catcode`\@=11
5523 \gdef\finishentry#1{%
5524     \egroup % end box A
5525     \dimen@ = \wd\boxA % Length of text of entry
5526     \global\setbox\boxA=\hbox\bgroup\unhbox\boxA
5527     % #1 is the page number.
5528     %
5529     % Get the width of the page numbers, and only use
5530     % leaders if they are present.
5531     \global\setbox\boxB = \hbox{#1}%
5532     \ifdim\wd\boxB = 0pt
5533       \null\nobreak\hfill\ %
5534     \else
5535       %
5536       \null\nobreak\indexdotfill % Have leaders before the page number.
5537       %
5538       \ifpdf
5539         \pdfgettoks#1.%
5540         \bgroup\let\domark\relax
5541           \hskip\skip\thinshrinkable\the\toksA
5542         \egroup
5543         % The redefinion of \domark stops marks being added in \pdflink to 
5544         % preserve coloured links across page boundaries.  Otherwise the marks
5545         % would get in the way of \lastbox in \insertindexentrybox.
5546       \else
5547         \ifx\XeTeXrevision\thisisundefined
5548           \hskip\skip\thinshrinkable #1%
5549         \else
5550           \pdfgettoks#1.%
5551           \bgroup\let\domark\relax
5552             \hskip\skip\thinshrinkable\the\toksA
5553           \egroup
5554         \fi
5555       \fi
5556     \fi
5557     \egroup % end \boxA
5558     \ifdim\wd\boxB = 0pt
5559       \global\setbox\entryindexbox=\vbox{\unhbox\boxA}%
5560     \else
5561     \global\setbox\entryindexbox=\vbox\bgroup
5562       \prevdepth=\entrylinedepth
5563       \noindent
5564       % We want the text of the entries to be aligned to the left, and the
5565       % page numbers to be aligned to the right.
5566       %
5567       \advance\leftskip by 0pt plus 1fil
5568       \advance\leftskip by 0pt plus -1fill
5569       \rightskip = 0pt plus -1fil
5570       \advance\rightskip by 0pt plus 1fill
5571       % Cause last line, which could consist of page numbers on their own
5572       % if the list of page numbers is long, to be aligned to the right.
5573       \parfillskip=0pt plus -1fill
5574       %
5575       \hangindent=1em
5576       %
5577       \advance\rightskip by \entryrightmargin
5578       % Determine how far we can stretch into the margin.
5579       % This allows, e.g., "Appendix H  GNU Free Documentation License" to
5580       % fit on one line in @letterpaper format.
5581       \ifdim\entryrightmargin>2.1em
5582         \dimen@i=2.1em
5583       \else
5584         \dimen@i=0em
5585       \fi
5586       \advance \parfillskip by 0pt minus 1\dimen@i
5587       %
5588       \dimen@ii = \hsize
5589       \advance\dimen@ii by -1\leftskip
5590       \advance\dimen@ii by -1\entryrightmargin
5591       \advance\dimen@ii by 1\dimen@i
5592       \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
5593       \ifdim\dimen@ > 0.8\dimen@ii   % due to long index text
5594         \dimen@ = 0.7\dimen@ % Try to split the text roughly evenly
5595         \dimen@ii = \hsize
5596         \advance \dimen@ii by -1em
5597         \ifnum\dimen@>\dimen@ii
5598           % If the entry is too long, use the whole line
5599           \dimen@ = \dimen@ii
5600         \fi
5601         \advance\leftskip by 0pt plus 1fill % ragged right
5602         \advance \dimen@ by 1\rightskip
5603         \parshape = 2 0pt \dimen@ 1em \dimen@ii
5604         % Ideally we'd add a finite glue at the end of the first line only, but
5605         % TeX doesn't seem to provide a way to do such a thing.
5606       \fi\fi
5607       \unhbox\boxA
5608       %
5609       % Do not prefer a separate line ending with a hyphen to fewer lines.
5610       \finalhyphendemerits = 0
5611       %
5612       % Word spacing - no stretch
5613       \spaceskip=\fontdimen2\font minus \fontdimen4\font
5614       %
5615       \linepenalty=1000  % Discourage line breaks.
5616       \hyphenpenalty=5000  % Discourage hyphenation.
5617       %
5618       \par % format the paragraph
5619     \egroup % The \vbox
5620     \fi
5621   \endgroup
5622   % delay text of entry until after penalty
5623   \bgroup\aftergroup\insertindexentrybox
5624   \entryorphanpenalty
5625 }}
5626
5627 \newskip\thinshrinkable
5628 \skip\thinshrinkable=.15em minus .15em
5629
5630 \newbox\entryindexbox
5631 \def\insertindexentrybox{%
5632   \copy\entryindexbox
5633   % The following gets the depth of the last box.  This is for even
5634   % line spacing when entries span several lines.
5635   \setbox\dummybox\vbox{%
5636     \unvbox\entryindexbox
5637     \nointerlineskip
5638     \lastbox
5639     \global\entrylinedepth=\prevdepth
5640   }%
5641   % Note that we couldn't simply \unvbox\entryindexbox followed by 
5642   % \nointerlineskip\lastbox to remove the last box and then reinstate it, 
5643   % because this resets how far the box has been \moveleft'ed to 0.  \unvbox
5644   % doesn't affect \prevdepth either.
5645 }
5646 \newdimen\entrylinedepth
5647
5648 % Default is no penalty
5649 \let\entryorphanpenalty\egroup
5650
5651 % Used from \printindex.  \firsttoken should be the first token
5652 % after the \entry.  If it's not another \entry, we are at the last
5653 % line of a group of index entries, so insert a penalty to discourage
5654 % orphaned index entries.
5655 \long\def\indexorphanpenalty{%
5656   \def\isentry{\entry}%
5657   \ifx\firsttoken\isentry
5658   \else
5659     \unskip\penalty 9000
5660     % The \unskip here stops breaking before the glue.  It relies on the
5661     % \vskip above being there, otherwise there is an error
5662     % "You can't use `\unskip' in vertical mode".  There has to be glue
5663     % in the current vertical list that hasn't been added to the
5664     % "current page".  See Chapter 24 of the TeXbook.  This contradicts
5665     % Section 8.3.7 in "TeX by Topic," though.
5666   \fi
5667   \egroup % now comes the box added with \aftergroup
5668 }
5669
5670 % Like plain.tex's \dotfill, except uses up at least 1 em.
5671 % The filll stretch here overpowers both the fil and fill stretch to push
5672 % the page number to the right.
5673 \def\indexdotfill{\cleaders
5674   \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
5675
5676
5677 \def\primary #1{\line{#1\hfil}}
5678
5679 \newskip\secondaryindent \secondaryindent=0.5cm
5680 \def\secondary#1#2{{%
5681   \parfillskip=0in
5682   \parskip=0in
5683   \hangindent=1in
5684   \hangafter=1
5685   \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
5686   \ifpdf
5687     \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5688   \else
5689     \ifx\XeTeXrevision\thisisundefined
5690       #2
5691     \else
5692       \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5693     \fi
5694   \fi
5695   \par
5696 }}
5697
5698 % Define two-column mode, which we use to typeset indexes.
5699 % Adapted from the TeXbook, page 416, which is to say,
5700 % the manmac.tex format used to print the TeXbook itself.
5701 \catcode`\@=11  % private names
5702
5703 \newbox\partialpage
5704 \newdimen\doublecolumnhsize
5705 \newdimen\doublecolumntopgap
5706 \doublecolumntopgap = 0pt
5707
5708 % Use inside an output routine to save \topmark and \firstmark
5709 \def\savemarks{%
5710   \global\savedtopmark=\expandafter{\topmark }%
5711   \global\savedfirstmark=\expandafter{\firstmark }%
5712 }
5713 \newtoks\savedtopmark
5714 \newtoks\savedfirstmark
5715
5716 % Set \topmark and \firstmark for next time \output runs.
5717 % Can't be run from withinside \output (because any material
5718 % added while an output routine is active, including 
5719 % penalties, is saved for after it finishes).  The page so far
5720 % should be empty, otherwise what's on it will be thrown away.
5721 \def\restoremarks{%
5722   \mark{\the\savedtopmark}%
5723   \bgroup\output = {%
5724     \setbox\dummybox=\box\PAGE
5725   }abc\eject\egroup
5726   % "abc" because output routine doesn't fire for a completely empty page.
5727   \mark{\the\savedfirstmark}%
5728 }
5729
5730 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
5731   % If not much space left on page, start a new page.
5732   \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
5733   %
5734   % Grab any single-column material above us.
5735   \output = {%
5736     %
5737     % Here is a possibility not foreseen in manmac: if we accumulate a
5738     % whole lot of material, we might end up calling this \output
5739     % routine twice in a row (see the doublecol-lose test, which is
5740     % essentially a couple of indexes with @setchapternewpage off).  In
5741     % that case we just ship out what is in \partialpage with the normal
5742     % output routine.  Generally, \partialpage will be empty when this
5743     % runs and this will be a no-op.  See the indexspread.tex test case.
5744     \ifvoid\partialpage \else
5745       \onepageout{\pagecontents\partialpage}%
5746     \fi
5747     %
5748     \global\setbox\partialpage = \vbox{%
5749       % Unvbox the main output page.
5750       \unvbox\PAGE
5751       \kern-\topskip \kern\baselineskip
5752     }%
5753     \savemarks
5754   }%
5755   \eject % run that output routine to set \partialpage
5756   \restoremarks
5757   %
5758   % We recover the two marks that the last output routine saved in order
5759   % to propagate the information in marks added around a chapter heading,
5760   % which could be otherwise be lost by the time the final page is output.
5761   %
5762   %
5763   % Use the double-column output routine for subsequent pages.
5764   \output = {\doublecolumnout}%
5765   %
5766   % Change the page size parameters.  We could do this once outside this
5767   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5768   % format, but then we repeat the same computation.  Repeating a couple
5769   % of assignments once per index is clearly meaningless for the
5770   % execution time, so we may as well do it in one place.
5771   %
5772   % First we halve the line length, less a little for the gutter between
5773   % the columns.  We compute the gutter based on the line length, so it
5774   % changes automatically with the paper format.  The magic constant
5775   % below is chosen so that the gutter has the same value (well, +-<1pt)
5776   % as it did when we hard-coded it.
5777   %
5778   % We put the result in a separate register, \doublecolumhsize, so we
5779   % can restore it in \pagesofar, after \hsize itself has (potentially)
5780   % been clobbered.
5781   %
5782   \doublecolumnhsize = \hsize
5783     \advance\doublecolumnhsize by -.04154\hsize
5784     \divide\doublecolumnhsize by 2
5785   \hsize = \doublecolumnhsize
5786   %
5787   % Double the \vsize as well.  (We don't need a separate register here,
5788   % since nobody clobbers \vsize.)
5789   \global\doublecolumntopgap = \topskip
5790   \global\advance\doublecolumntopgap by -1\baselineskip
5791   \advance\vsize by -1\doublecolumntopgap
5792   \vsize = 2\vsize
5793   \topskip=0pt
5794   \global\entrylinedepth=0pt\relax
5795 }
5796
5797 % The double-column output routine for all double-column pages except
5798 % the last, which is done by \balancecolumns.
5799 %
5800 \def\doublecolumnout{%
5801   %
5802   \splittopskip=\topskip \splitmaxdepth=\maxdepth
5803   % Get the available space for the double columns -- the normal
5804   % (undoubled) page height minus any material left over from the
5805   % previous page.
5806   \dimen@ = \vsize
5807   \divide\dimen@ by 2
5808   \advance\dimen@ by -\ht\partialpage
5809   %
5810   % box0 will be the left-hand column, box2 the right.
5811   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
5812   \onepageout\pagesofar
5813   \unvbox255
5814   \penalty\outputpenalty
5815 }
5816 %
5817 % Re-output the contents of the output page -- any previous material,
5818 % followed by the two boxes we just split, in box0 and box2.
5819 \def\pagesofar{%
5820   \unvbox\partialpage
5821   %
5822   \hsize = \doublecolumnhsize
5823   \wd0=\hsize \wd2=\hsize
5824   \vbox{%
5825     \vskip\doublecolumntopgap
5826     \hbox to\txipagewidth{\box0\hfil\box2}}%
5827 }
5828
5829
5830 % Finished with with double columns.
5831 \def\enddoublecolumns{%
5832   % The following penalty ensures that the page builder is exercised
5833   % _before_ we change the output routine.  This is necessary in the
5834   % following situation:
5835   %
5836   % The last section of the index consists only of a single entry.
5837   % Before this section, \pagetotal is less than \pagegoal, so no
5838   % break occurs before the last section starts.  However, the last
5839   % section, consisting of \initial and the single \entry, does not
5840   % fit on the page and has to be broken off.  Without the following
5841   % penalty the page builder will not be exercised until \eject
5842   % below, and by that time we'll already have changed the output
5843   % routine to the \balancecolumns version, so the next-to-last
5844   % double-column page will be processed with \balancecolumns, which
5845   % is wrong:  The two columns will go to the main vertical list, with
5846   % the broken-off section in the recent contributions.  As soon as
5847   % the output routine finishes, TeX starts reconsidering the page
5848   % break.  The two columns and the broken-off section both fit on the
5849   % page, because the two columns now take up only half of the page
5850   % goal.  When TeX sees \eject from below which follows the final
5851   % section, it invokes the new output routine that we've set after
5852   % \balancecolumns below; \onepageout will try to fit the two columns
5853   % and the final section into the vbox of \txipageheight (see
5854   % \pagebody), causing an overfull box.
5855   %
5856   % Note that glue won't work here, because glue does not exercise the
5857   % page builder, unlike penalties (see The TeXbook, pp. 280-281).
5858   \penalty0
5859   %
5860   \output = {%
5861     % Split the last of the double-column material.
5862     \savemarks
5863     \balancecolumns
5864     %
5865     % Having called \balancecolumns once, we do not
5866     % want to call it again.  Therefore, reset \output to its normal
5867     % definition right away.
5868     \global\output = {\onepageout{\pagecontents\PAGE}}%
5869   }%
5870   \eject
5871   \endgroup % started in \begindoublecolumns
5872   \restoremarks
5873   % Leave the double-column material on the current page, no automatic
5874   % page break.
5875   \box\balancedcolumns
5876   %
5877   % \pagegoal was set to the doubled \vsize above, since we restarted
5878   % the current page.  We're now back to normal single-column
5879   % typesetting, so reset \pagegoal to the normal \vsize (after the
5880   % \endgroup where \vsize got restored).
5881   \pagegoal = \vsize
5882 }
5883 \newbox\balancedcolumns
5884 \setbox\balancedcolumns=\vbox{shouldnt see this}%
5885 %
5886 % Only called for the last of the double column material.  \doublecolumnout 
5887 % does the others.
5888 \def\balancecolumns{%
5889   \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
5890   \dimen@ = \ht0
5891   \advance\dimen@ by \topskip
5892   \advance\dimen@ by-\baselineskip
5893   \ifdim\dimen@<14\baselineskip
5894     % Don't split a short final column in two.
5895     \setbox2=\vbox{}%
5896   \else
5897     \divide\dimen@ by 2 % target to split to
5898     \dimen@ii = \dimen@
5899     \splittopskip = \topskip
5900     % Loop until the second column is no higher than the first
5901     {%
5902       \vbadness = 10000
5903       \loop
5904         \global\setbox3 = \copy0
5905         \global\setbox1 = \vsplit3 to \dimen@
5906         % Remove glue from bottom of first column to
5907         % make sure it is higher than the second.
5908         \global\setbox1 = \vbox{\unvbox1\unpenalty\unskip}%
5909       \ifdim\ht3>\ht1
5910         \global\advance\dimen@ by 1pt
5911       \repeat
5912     }%
5913     \multiply\dimen@ii by 4
5914     \divide\dimen@ii by 5
5915     \ifdim\ht3<\dimen@ii
5916       % Column heights are too different, so don't make their bottoms
5917       % flush with each other.  The glue at the end of the second column
5918       % allows a second column to stretch, reducing the difference in
5919       % height between the two.
5920       \setbox0=\vbox to\dimen@{\unvbox1\vfill}%
5921       \setbox2=\vbox to\dimen@{\unvbox3\vskip 0pt plus 0.3\ht0}%
5922     \else
5923       \setbox0=\vbox to\dimen@{\unvbox1}%
5924       \setbox2=\vbox to\dimen@{\unvbox3}%
5925     \fi
5926   \fi
5927   %
5928   \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5929 }
5930 \catcode`\@ = \other
5931
5932
5933 \message{sectioning,}
5934 % Chapters, sections, etc.
5935
5936 % Let's start with @part.
5937 \outer\parseargdef\part{\partzzz{#1}}
5938 \def\partzzz#1{%
5939   \chapoddpage
5940   \null
5941   \vskip.3\vsize  % move it down on the page a bit
5942   \begingroup
5943     \noindent \titlefonts\rmisbold #1\par % the text
5944     \let\lastnode=\empty      % no node to associate with
5945     \writetocentry{part}{#1}{}% but put it in the toc
5946     \headingsoff              % no headline or footline on the part page
5947     % This outputs a mark at the end of the page that clears \thischapter
5948     % and \thissection, as is done in \startcontents.
5949     \let\pchapsepmacro\relax
5950     \chapmacro{}{Yomitfromtoc}{}%
5951     \chapoddpage
5952   \endgroup
5953 }
5954
5955 % \unnumberedno is an oxymoron.  But we count the unnumbered
5956 % sections so that we can refer to them unambiguously in the pdf
5957 % outlines by their "section number".  We avoid collisions with chapter
5958 % numbers by starting them at 10000.  (If a document ever has 10000
5959 % chapters, we're in trouble anyway, I'm sure.)
5960 \newcount\unnumberedno \unnumberedno = 10000
5961 \newcount\chapno
5962 \newcount\secno        \secno=0
5963 \newcount\subsecno     \subsecno=0
5964 \newcount\subsubsecno  \subsubsecno=0
5965
5966 % This counter is funny since it counts through charcodes of letters A, B, ...
5967 \newcount\appendixno  \appendixno = `\@
5968 %
5969 % \def\appendixletter{\char\the\appendixno}
5970 % We do the following ugly conditional instead of the above simple
5971 % construct for the sake of pdftex, which needs the actual
5972 % letter in the expansion, not just typeset.
5973 %
5974 \def\appendixletter{%
5975   \ifnum\appendixno=`A A%
5976   \else\ifnum\appendixno=`B B%
5977   \else\ifnum\appendixno=`C C%
5978   \else\ifnum\appendixno=`D D%
5979   \else\ifnum\appendixno=`E E%
5980   \else\ifnum\appendixno=`F F%
5981   \else\ifnum\appendixno=`G G%
5982   \else\ifnum\appendixno=`H H%
5983   \else\ifnum\appendixno=`I I%
5984   \else\ifnum\appendixno=`J J%
5985   \else\ifnum\appendixno=`K K%
5986   \else\ifnum\appendixno=`L L%
5987   \else\ifnum\appendixno=`M M%
5988   \else\ifnum\appendixno=`N N%
5989   \else\ifnum\appendixno=`O O%
5990   \else\ifnum\appendixno=`P P%
5991   \else\ifnum\appendixno=`Q Q%
5992   \else\ifnum\appendixno=`R R%
5993   \else\ifnum\appendixno=`S S%
5994   \else\ifnum\appendixno=`T T%
5995   \else\ifnum\appendixno=`U U%
5996   \else\ifnum\appendixno=`V V%
5997   \else\ifnum\appendixno=`W W%
5998   \else\ifnum\appendixno=`X X%
5999   \else\ifnum\appendixno=`Y Y%
6000   \else\ifnum\appendixno=`Z Z%
6001   % The \the is necessary, despite appearances, because \appendixletter is
6002   % expanded while writing the .toc file.  \char\appendixno is not
6003   % expandable, thus it is written literally, thus all appendixes come out
6004   % with the same letter (or @) in the toc without it.
6005   \else\char\the\appendixno
6006   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
6007   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
6008
6009 % Each @chapter defines these (using marks) as the number+name, number
6010 % and name of the chapter.  Page headings and footings can use
6011 % these.  @section does likewise.
6012 \def\thischapter{}
6013 \def\thischapternum{}
6014 \def\thischaptername{}
6015 \def\thissection{}
6016 \def\thissectionnum{}
6017 \def\thissectionname{}
6018
6019 \newcount\absseclevel % used to calculate proper heading level
6020 \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
6021
6022 % @raisesections: treat @section as chapter, @subsection as section, etc.
6023 \def\raisesections{\global\advance\secbase by -1}
6024 \let\up=\raisesections % original BFox name
6025
6026 % @lowersections: treat @chapter as section, @section as subsection, etc.
6027 \def\lowersections{\global\advance\secbase by 1}
6028 \let\down=\lowersections % original BFox name
6029
6030 % we only have subsub.
6031 \chardef\maxseclevel = 3
6032 %
6033 % A numbered section within an unnumbered changes to unnumbered too.
6034 % To achieve this, remember the "biggest" unnum. sec. we are currently in:
6035 \chardef\unnlevel = \maxseclevel
6036 %
6037 % Trace whether the current chapter is an appendix or not:
6038 % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
6039 \def\chapheadtype{N}
6040
6041 % Choose a heading macro
6042 % #1 is heading type
6043 % #2 is heading level
6044 % #3 is text for heading
6045 \def\genhead#1#2#3{%
6046   % Compute the abs. sec. level:
6047   \absseclevel=#2
6048   \advance\absseclevel by \secbase
6049   % Make sure \absseclevel doesn't fall outside the range:
6050   \ifnum \absseclevel < 0
6051     \absseclevel = 0
6052   \else
6053     \ifnum \absseclevel > 3
6054       \absseclevel = 3
6055     \fi
6056   \fi
6057   % The heading type:
6058   \def\headtype{#1}%
6059   \if \headtype U%
6060     \ifnum \absseclevel < \unnlevel
6061       \chardef\unnlevel = \absseclevel
6062     \fi
6063   \else
6064     % Check for appendix sections:
6065     \ifnum \absseclevel = 0
6066       \edef\chapheadtype{\headtype}%
6067     \else
6068       \if \headtype A\if \chapheadtype N%
6069         \errmessage{@appendix... within a non-appendix chapter}%
6070       \fi\fi
6071     \fi
6072     % Check for numbered within unnumbered:
6073     \ifnum \absseclevel > \unnlevel
6074       \def\headtype{U}%
6075     \else
6076       \chardef\unnlevel = 3
6077     \fi
6078   \fi
6079   % Now print the heading:
6080   \if \headtype U%
6081     \ifcase\absseclevel
6082         \unnumberedzzz{#3}%
6083     \or \unnumberedseczzz{#3}%
6084     \or \unnumberedsubseczzz{#3}%
6085     \or \unnumberedsubsubseczzz{#3}%
6086     \fi
6087   \else
6088     \if \headtype A%
6089       \ifcase\absseclevel
6090           \appendixzzz{#3}%
6091       \or \appendixsectionzzz{#3}%
6092       \or \appendixsubseczzz{#3}%
6093       \or \appendixsubsubseczzz{#3}%
6094       \fi
6095     \else
6096       \ifcase\absseclevel
6097           \chapterzzz{#3}%
6098       \or \seczzz{#3}%
6099       \or \numberedsubseczzz{#3}%
6100       \or \numberedsubsubseczzz{#3}%
6101       \fi
6102     \fi
6103   \fi
6104   \suppressfirstparagraphindent
6105 }
6106
6107 % an interface:
6108 \def\numhead{\genhead N}
6109 \def\apphead{\genhead A}
6110 \def\unnmhead{\genhead U}
6111
6112 % @chapter, @appendix, @unnumbered.  Increment top-level counter, reset
6113 % all lower-level sectioning counters to zero.
6114 %
6115 % Also set \chaplevelprefix, which we prepend to @float sequence numbers
6116 % (e.g., figures), q.v.  By default (before any chapter), that is empty.
6117 \let\chaplevelprefix = \empty
6118 %
6119 \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
6120 \def\chapterzzz#1{%
6121   % section resetting is \global in case the chapter is in a group, such
6122   % as an @include file.
6123   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6124     \global\advance\chapno by 1
6125   %
6126   % Used for \float.
6127   \gdef\chaplevelprefix{\the\chapno.}%
6128   \resetallfloatnos
6129   %
6130   % \putwordChapter can contain complex things in translations.
6131   \toks0=\expandafter{\putwordChapter}%
6132   \message{\the\toks0 \space \the\chapno}%
6133   %
6134   % Write the actual heading.
6135   \chapmacro{#1}{Ynumbered}{\the\chapno}%
6136   %
6137   % So @section and the like are numbered underneath this chapter.
6138   \global\let\section = \numberedsec
6139   \global\let\subsection = \numberedsubsec
6140   \global\let\subsubsection = \numberedsubsubsec
6141 }
6142
6143 \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
6144 %
6145 \def\appendixzzz#1{%
6146   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6147     \global\advance\appendixno by 1
6148   \gdef\chaplevelprefix{\appendixletter.}%
6149   \resetallfloatnos
6150   %
6151   % \putwordAppendix can contain complex things in translations.
6152   \toks0=\expandafter{\putwordAppendix}%
6153   \message{\the\toks0 \space \appendixletter}%
6154   %
6155   \chapmacro{#1}{Yappendix}{\appendixletter}%
6156   %
6157   \global\let\section = \appendixsec
6158   \global\let\subsection = \appendixsubsec
6159   \global\let\subsubsection = \appendixsubsubsec
6160 }
6161
6162 % normally unnmhead0 calls unnumberedzzz:
6163 \outer\parseargdef\unnumbered{\unnmhead0{#1}}
6164 \def\unnumberedzzz#1{%
6165   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6166     \global\advance\unnumberedno by 1
6167   %
6168   % Since an unnumbered has no number, no prefix for figures.
6169   \global\let\chaplevelprefix = \empty
6170   \resetallfloatnos
6171   %
6172   % This used to be simply \message{#1}, but TeX fully expands the
6173   % argument to \message.  Therefore, if #1 contained @-commands, TeX
6174   % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
6175   % expanded @cite (which turns out to cause errors because \cite is meant
6176   % to be executed, not expanded).
6177   %
6178   % Anyway, we don't want the fully-expanded definition of @cite to appear
6179   % as a result of the \message, we just want `@cite' itself.  We use
6180   % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6181   % simply yielding the contents of <toks register>.  (We also do this for
6182   % the toc entries.)
6183   \toks0 = {#1}%
6184   \message{(\the\toks0)}%
6185   %
6186   \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
6187   %
6188   \global\let\section = \unnumberedsec
6189   \global\let\subsection = \unnumberedsubsec
6190   \global\let\subsubsection = \unnumberedsubsubsec
6191 }
6192
6193 % @centerchap is like @unnumbered, but the heading is centered.
6194 \outer\parseargdef\centerchap{%
6195   \let\centerparametersmaybe = \centerparameters
6196   \unnmhead0{#1}%
6197   \let\centerparametersmaybe = \relax
6198 }
6199
6200 % @top is like @unnumbered.
6201 \let\top\unnumbered
6202
6203 % Sections.
6204
6205 \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6206 \def\seczzz#1{%
6207   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6208   \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
6209 }
6210
6211 % normally calls appendixsectionzzz:
6212 \outer\parseargdef\appendixsection{\apphead1{#1}}
6213 \def\appendixsectionzzz#1{%
6214   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6215   \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
6216 }
6217 \let\appendixsec\appendixsection
6218
6219 % normally calls unnumberedseczzz:
6220 \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
6221 \def\unnumberedseczzz#1{%
6222   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6223   \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
6224 }
6225
6226 % Subsections.
6227
6228 % normally calls numberedsubseczzz:
6229 \outer\parseargdef\numberedsubsec{\numhead2{#1}}
6230 \def\numberedsubseczzz#1{%
6231   \global\subsubsecno=0  \global\advance\subsecno by 1
6232   \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
6233 }
6234
6235 % normally calls appendixsubseczzz:
6236 \outer\parseargdef\appendixsubsec{\apphead2{#1}}
6237 \def\appendixsubseczzz#1{%
6238   \global\subsubsecno=0  \global\advance\subsecno by 1
6239   \sectionheading{#1}{subsec}{Yappendix}%
6240                  {\appendixletter.\the\secno.\the\subsecno}%
6241 }
6242
6243 % normally calls unnumberedsubseczzz:
6244 \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
6245 \def\unnumberedsubseczzz#1{%
6246   \global\subsubsecno=0  \global\advance\subsecno by 1
6247   \sectionheading{#1}{subsec}{Ynothing}%
6248                  {\the\unnumberedno.\the\secno.\the\subsecno}%
6249 }
6250
6251 % Subsubsections.
6252
6253 % normally numberedsubsubseczzz:
6254 \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
6255 \def\numberedsubsubseczzz#1{%
6256   \global\advance\subsubsecno by 1
6257   \sectionheading{#1}{subsubsec}{Ynumbered}%
6258                  {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
6259 }
6260
6261 % normally appendixsubsubseczzz:
6262 \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
6263 \def\appendixsubsubseczzz#1{%
6264   \global\advance\subsubsecno by 1
6265   \sectionheading{#1}{subsubsec}{Yappendix}%
6266                  {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
6267 }
6268
6269 % normally unnumberedsubsubseczzz:
6270 \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
6271 \def\unnumberedsubsubseczzz#1{%
6272   \global\advance\subsubsecno by 1
6273   \sectionheading{#1}{subsubsec}{Ynothing}%
6274                  {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
6275 }
6276
6277 % These macros control what the section commands do, according
6278 % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6279 % Define them by default for a numbered chapter.
6280 \let\section = \numberedsec
6281 \let\subsection = \numberedsubsec
6282 \let\subsubsection = \numberedsubsubsec
6283
6284 % Define @majorheading, @heading and @subheading
6285
6286 \def\majorheading{%
6287   {\advance\chapheadingskip by 10pt \chapbreak }%
6288   \parsearg\chapheadingzzz
6289 }
6290
6291 \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6292 \def\chapheadingzzz#1{%
6293   \vbox{\chapfonts \raggedtitlesettings #1\par}%
6294   \nobreak\bigskip \nobreak
6295   \suppressfirstparagraphindent
6296 }
6297
6298 % @heading, @subheading, @subsubheading.
6299 \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6300   \suppressfirstparagraphindent}
6301 \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6302   \suppressfirstparagraphindent}
6303 \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6304   \suppressfirstparagraphindent}
6305
6306 % These macros generate a chapter, section, etc. heading only
6307 % (including whitespace, linebreaking, etc. around it),
6308 % given all the information in convenient, parsed form.
6309
6310 % Args are the skip and penalty (usually negative)
6311 \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6312
6313 % Parameter controlling skip before chapter headings (if needed)
6314 \newskip\chapheadingskip
6315
6316 % Define plain chapter starts, and page on/off switching for it.
6317 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
6318
6319 % Start a new page
6320 \def\chappager{\par\vfill\supereject}
6321
6322 % \chapoddpage - start on an odd page for a new chapter
6323 % Because \domark is called before \chapoddpage, the filler page will
6324 % get the headings for the next chapter, which is wrong.  But we don't
6325 % care -- we just disable all headings on the filler page.
6326 \def\chapoddpage{%
6327   \chappager
6328   \ifodd\pageno \else
6329     \begingroup
6330       \headingsoff
6331       \null
6332       \chappager
6333     \endgroup
6334   \fi
6335 }
6336
6337 \parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
6338
6339 \def\CHAPPAGoff{%
6340 \global\let\contentsalignmacro = \chappager
6341 \global\let\pchapsepmacro=\chapbreak
6342 \global\let\pagealignmacro=\chappager}
6343
6344 \def\CHAPPAGon{%
6345 \global\let\contentsalignmacro = \chappager
6346 \global\let\pchapsepmacro=\chappager
6347 \global\let\pagealignmacro=\chappager
6348 \global\def\HEADINGSon{\HEADINGSsingle}}
6349
6350 \def\CHAPPAGodd{%
6351 \global\let\contentsalignmacro = \chapoddpage
6352 \global\let\pchapsepmacro=\chapoddpage
6353 \global\let\pagealignmacro=\chapoddpage
6354 \global\def\HEADINGSon{\HEADINGSdouble}}
6355
6356 \CHAPPAGon
6357
6358 % \chapmacro - Chapter opening.
6359 %
6360 % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6361 % Yappendix, Yomitfromtoc), #3 the chapter number.
6362 % Not used for @heading series.
6363 %
6364 % To test against our argument.
6365 \def\Ynothingkeyword{Ynothing}
6366 \def\Yappendixkeyword{Yappendix}
6367 \def\Yomitfromtockeyword{Yomitfromtoc}
6368 %
6369 \def\chapmacro#1#2#3{%
6370   \expandafter\ifx\thisenv\titlepage\else
6371     \checkenv{}% chapters, etc., should not start inside an environment.
6372   \fi
6373   % FIXME: \chapmacro is currently called from inside \titlepage when
6374   % \setcontentsaftertitlepage to print the "Table of Contents" heading, but
6375   % this should probably be done by \sectionheading with an option to print
6376   % in chapter size.
6377   %
6378   % Insert the first mark before the heading break (see notes for \domark).
6379   \let\prevchapterdefs=\lastchapterdefs
6380   \let\prevsectiondefs=\lastsectiondefs
6381   \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6382                         \gdef\thissection{}}%
6383   %
6384   \def\temptype{#2}%
6385   \ifx\temptype\Ynothingkeyword
6386     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6387                           \gdef\thischapter{\thischaptername}}%
6388   \else\ifx\temptype\Yomitfromtockeyword
6389     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6390                           \gdef\thischapter{}}%
6391   \else\ifx\temptype\Yappendixkeyword
6392     \toks0={#1}%
6393     \xdef\lastchapterdefs{%
6394       \gdef\noexpand\thischaptername{\the\toks0}%
6395       \gdef\noexpand\thischapternum{\appendixletter}%
6396       % \noexpand\putwordAppendix avoids expanding indigestible
6397       % commands in some of the translations.
6398       \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
6399                                  \noexpand\thischapternum:
6400                                  \noexpand\thischaptername}%
6401     }%
6402   \else
6403     \toks0={#1}%
6404     \xdef\lastchapterdefs{%
6405       \gdef\noexpand\thischaptername{\the\toks0}%
6406       \gdef\noexpand\thischapternum{\the\chapno}%
6407       % \noexpand\putwordChapter avoids expanding indigestible
6408       % commands in some of the translations.
6409       \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
6410                                  \noexpand\thischapternum:
6411                                  \noexpand\thischaptername}%
6412     }%
6413   \fi\fi\fi
6414   %
6415   % Output the mark.  Pass it through \safewhatsit, to take care of
6416   % the preceding space.
6417   \safewhatsit\domark
6418   %
6419   % Insert the chapter heading break.
6420   \pchapsepmacro
6421   %
6422   % Now the second mark, after the heading break.  No break points
6423   % between here and the heading.
6424   \let\prevchapterdefs=\lastchapterdefs
6425   \let\prevsectiondefs=\lastsectiondefs
6426   \domark
6427   %
6428   {%
6429     \chapfonts \rmisbold
6430     \let\footnote=\errfootnoteheading % give better error message
6431     %
6432     % Have to define \lastsection before calling \donoderef, because the
6433     % xref code eventually uses it.  On the other hand, it has to be called
6434     % after \pchapsepmacro, or the headline will change too soon.
6435     \gdef\lastsection{#1}%
6436     %
6437     % Only insert the separating space if we have a chapter/appendix
6438     % number, and don't print the unnumbered ``number''.
6439     \ifx\temptype\Ynothingkeyword
6440       \setbox0 = \hbox{}%
6441       \def\toctype{unnchap}%
6442     \else\ifx\temptype\Yomitfromtockeyword
6443       \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6444       \def\toctype{omit}%
6445     \else\ifx\temptype\Yappendixkeyword
6446       \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6447       \def\toctype{app}%
6448     \else
6449       \setbox0 = \hbox{#3\enspace}%
6450       \def\toctype{numchap}%
6451     \fi\fi\fi
6452     %
6453     % Write the toc entry for this chapter.  Must come before the
6454     % \donoderef, because we include the current node name in the toc
6455     % entry, and \donoderef resets it to empty.
6456     \writetocentry{\toctype}{#1}{#3}%
6457     %
6458     % For pdftex, we have to write out the node definition (aka, make
6459     % the pdfdest) after any page break, but before the actual text has
6460     % been typeset.  If the destination for the pdf outline is after the
6461     % text, then jumping from the outline may wind up with the text not
6462     % being visible, for instance under high magnification.
6463     \donoderef{#2}%
6464     %
6465     % Typeset the actual heading.
6466     \nobreak % Avoid page breaks at the interline glue.
6467     \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
6468           \unhbox0 #1\par}%
6469   }%
6470   \nobreak\bigskip % no page break after a chapter title
6471   \nobreak
6472 }
6473
6474 % @centerchap -- centered and unnumbered.
6475 \let\centerparametersmaybe = \relax
6476 \def\centerparameters{%
6477   \advance\rightskip by 3\rightskip
6478   \leftskip = \rightskip
6479   \parfillskip = 0pt
6480 }
6481
6482
6483 % Section titles.  These macros combine the section number parts and
6484 % call the generic \sectionheading to do the printing.
6485 %
6486 \newskip\secheadingskip
6487 \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
6488
6489 % Subsection titles.
6490 \newskip\subsecheadingskip
6491 \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
6492
6493 % Subsubsection titles.
6494 \def\subsubsecheadingskip{\subsecheadingskip}
6495 \def\subsubsecheadingbreak{\subsecheadingbreak}
6496
6497
6498 % Print any size, any type, section title.
6499 %
6500 % #1 is the text of the title,
6501 % #2 is the section level (sec/subsec/subsubsec),
6502 % #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6503 % #4 is the section number.
6504 %
6505 \def\seckeyword{sec}
6506 %
6507 \def\sectionheading#1#2#3#4{%
6508   {%
6509     \def\sectionlevel{#2}%
6510     \def\temptype{#3}%
6511     %
6512     % It is ok for the @heading series commands to appear inside an
6513     % environment (it's been historically allowed, though the logic is
6514     % dubious), but not the others.
6515     \ifx\temptype\Yomitfromtockeyword\else
6516       \checkenv{}% non-@*heading should not be in an environment.
6517     \fi
6518     \let\footnote=\errfootnoteheading
6519     %
6520     % Switch to the right set of fonts.
6521     \csname #2fonts\endcsname \rmisbold
6522     %
6523     % Insert first mark before the heading break (see notes for \domark).
6524     \let\prevsectiondefs=\lastsectiondefs
6525     \ifx\temptype\Ynothingkeyword
6526       \ifx\sectionlevel\seckeyword
6527         \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6528                               \gdef\thissection{\thissectionname}}%
6529       \fi
6530     \else\ifx\temptype\Yomitfromtockeyword
6531       % Don't redefine \thissection.
6532     \else\ifx\temptype\Yappendixkeyword
6533       \ifx\sectionlevel\seckeyword
6534         \toks0={#1}%
6535         \xdef\lastsectiondefs{%
6536           \gdef\noexpand\thissectionname{\the\toks0}%
6537           \gdef\noexpand\thissectionnum{#4}%
6538           % \noexpand\putwordSection avoids expanding indigestible
6539           % commands in some of the translations.
6540           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6541                                      \noexpand\thissectionnum:
6542                                      \noexpand\thissectionname}%
6543         }%
6544       \fi
6545     \else
6546       \ifx\sectionlevel\seckeyword
6547         \toks0={#1}%
6548         \xdef\lastsectiondefs{%
6549           \gdef\noexpand\thissectionname{\the\toks0}%
6550           \gdef\noexpand\thissectionnum{#4}%
6551           % \noexpand\putwordSection avoids expanding indigestible
6552           % commands in some of the translations.
6553           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6554                                      \noexpand\thissectionnum:
6555                                      \noexpand\thissectionname}%
6556         }%
6557       \fi
6558     \fi\fi\fi
6559     %
6560     % Go into vertical mode.  Usually we'll already be there, but we
6561     % don't want the following whatsit to end up in a preceding paragraph
6562     % if the document didn't happen to have a blank line.
6563     \par
6564     %
6565     % Output the mark.  Pass it through \safewhatsit, to take care of
6566     % the preceding space.
6567     \safewhatsit\domark
6568     %
6569     % Insert space above the heading.
6570     \csname #2headingbreak\endcsname
6571     %
6572     % Now the second mark, after the heading break.  No break points
6573     % between here and the heading.
6574     \global\let\prevsectiondefs=\lastsectiondefs
6575     \domark
6576     %
6577     % Only insert the space after the number if we have a section number.
6578     \ifx\temptype\Ynothingkeyword
6579       \setbox0 = \hbox{}%
6580       \def\toctype{unn}%
6581       \gdef\lastsection{#1}%
6582     \else\ifx\temptype\Yomitfromtockeyword
6583       % for @headings -- no section number, don't include in toc,
6584       % and don't redefine \lastsection.
6585       \setbox0 = \hbox{}%
6586       \def\toctype{omit}%
6587       \let\sectionlevel=\empty
6588     \else\ifx\temptype\Yappendixkeyword
6589       \setbox0 = \hbox{#4\enspace}%
6590       \def\toctype{app}%
6591       \gdef\lastsection{#1}%
6592     \else
6593       \setbox0 = \hbox{#4\enspace}%
6594       \def\toctype{num}%
6595       \gdef\lastsection{#1}%
6596     \fi\fi\fi
6597     %
6598     % Write the toc entry (before \donoderef).  See comments in \chapmacro.
6599     \writetocentry{\toctype\sectionlevel}{#1}{#4}%
6600     %
6601     % Write the node reference (= pdf destination for pdftex).
6602     % Again, see comments in \chapmacro.
6603     \donoderef{#3}%
6604     %
6605     % Interline glue will be inserted when the vbox is completed.
6606     % That glue will be a valid breakpoint for the page, since it'll be
6607     % preceded by a whatsit (usually from the \donoderef, or from the
6608     % \writetocentry if there was no node).  We don't want to allow that
6609     % break, since then the whatsits could end up on page n while the
6610     % section is on page n+1, thus toc/etc. are wrong.  Debian bug 276000.
6611     \nobreak
6612     %
6613     % Output the actual section heading.
6614     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
6615           \hangindent=\wd0  % zero if no section number
6616           \unhbox0 #1}%
6617   }%
6618   % Add extra space after the heading -- half of whatever came above it.
6619   % Don't allow stretch, though.
6620   \kern .5 \csname #2headingskip\endcsname
6621   %
6622   % Do not let the kern be a potential breakpoint, as it would be if it
6623   % was followed by glue.
6624   \nobreak
6625   %
6626   % We'll almost certainly start a paragraph next, so don't let that
6627   % glue accumulate.  (Not a breakpoint because it's preceded by a
6628   % discardable item.)  However, when a paragraph is not started next
6629   % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6630   % or the negative glue will cause weirdly wrong output, typically
6631   % obscuring the section heading with something else.
6632   \vskip-\parskip
6633   %
6634   % This is so the last item on the main vertical list is a known
6635   % \penalty > 10000, so \startdefun, etc., can recognize the situation
6636   % and do the needful.
6637   \penalty 10001
6638 }
6639
6640
6641 \message{toc,}
6642 % Table of contents.
6643 \newwrite\tocfile
6644
6645 % Write an entry to the toc file, opening it if necessary.
6646 % Called from @chapter, etc.
6647 %
6648 % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6649 % We append the current node name (if any) and page number as additional
6650 % arguments for the \{chap,sec,...}entry macros which will eventually
6651 % read this.  The node name is used in the pdf outlines as the
6652 % destination to jump to.
6653 %
6654 % We open the .toc file for writing here instead of at @setfilename (or
6655 % any other fixed time) so that @contents can be anywhere in the document.
6656 % But if #1 is `omit', then we don't do anything.  This is used for the
6657 % table of contents chapter openings themselves.
6658 %
6659 \newif\iftocfileopened
6660 \def\omitkeyword{omit}%
6661 %
6662 \def\writetocentry#1#2#3{%
6663   \edef\writetoctype{#1}%
6664   \ifx\writetoctype\omitkeyword \else
6665     \iftocfileopened\else
6666       \immediate\openout\tocfile = \jobname.toc
6667       \global\tocfileopenedtrue
6668     \fi
6669     %
6670     \iflinks
6671       {\atdummies
6672        \edef\temp{%
6673          \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6674        \temp
6675       }%
6676     \fi
6677   \fi
6678   %
6679   % Tell \shipout to create a pdf destination on each page, if we're
6680   % writing pdf.  These are used in the table of contents.  We can't
6681   % just write one on every page because the title pages are numbered
6682   % 1 and 2 (the page numbers aren't printed), and so are the first
6683   % two pages of the document.  Thus, we'd have two destinations named
6684   % `1', and two named `2'.
6685   \ifpdf \global\pdfmakepagedesttrue \fi
6686 }
6687
6688
6689 % These characters do not print properly in the Computer Modern roman
6690 % fonts, so we must take special care.  This is more or less redundant
6691 % with the Texinfo input format setup at the end of this file.
6692 %
6693 \def\activecatcodes{%
6694   \catcode`\"=\active
6695   \catcode`\$=\active
6696   \catcode`\<=\active
6697   \catcode`\>=\active
6698   \catcode`\\=\active
6699   \catcode`\^=\active
6700   \catcode`\_=\active
6701   \catcode`\|=\active
6702   \catcode`\~=\active
6703 }
6704
6705
6706 % Read the toc file, which is essentially Texinfo input.
6707 \def\readtocfile{%
6708   \setupdatafile
6709   \activecatcodes
6710   \input \tocreadfilename
6711 }
6712
6713 \newskip\contentsrightmargin \contentsrightmargin=1in
6714 \newcount\savepageno
6715 \newcount\lastnegativepageno \lastnegativepageno = -1
6716
6717 % Prepare to read what we've written to \tocfile.
6718 %
6719 \def\startcontents#1{%
6720   % If @setchapternewpage on, and @headings double, the contents should
6721   % start on an odd page, unlike chapters.  Thus, we maintain
6722   % \contentsalignmacro in parallel with \pagealignmacro.
6723   % From: Torbjorn Granlund <tege@matematik.su.se>
6724   \contentsalignmacro
6725   \immediate\closeout\tocfile
6726   %
6727   % Don't need to put `Contents' or `Short Contents' in the headline.
6728   % It is abundantly clear what they are.
6729   \chapmacro{#1}{Yomitfromtoc}{}%
6730   %
6731   \savepageno = \pageno
6732   \begingroup                  % Set up to handle contents files properly.
6733     \raggedbottom              % Worry more about breakpoints than the bottom.
6734     \entryrightmargin=\contentsrightmargin % Don't use the full line length.
6735     %
6736     % Roman numerals for page numbers.
6737     \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
6738 }
6739
6740 % redefined for the two-volume lispref.  We always output on
6741 % \jobname.toc even if this is redefined.
6742 %
6743 \def\tocreadfilename{\jobname.toc}
6744
6745 % Normal (long) toc.
6746 %
6747 \def\contents{%
6748   \startcontents{\putwordTOC}%
6749     \openin 1 \tocreadfilename\space
6750     \ifeof 1 \else
6751       \readtocfile
6752     \fi
6753     \vfill \eject
6754     \contentsalignmacro % in case @setchapternewpage odd is in effect
6755     \ifeof 1 \else
6756       \pdfmakeoutlines
6757     \fi
6758     \closein 1
6759   \endgroup
6760   \lastnegativepageno = \pageno
6761   \global\pageno = \savepageno
6762 }
6763
6764 % And just the chapters.
6765 \def\summarycontents{%
6766   \startcontents{\putwordShortTOC}%
6767     %
6768     \let\partentry = \shortpartentry
6769     \let\numchapentry = \shortchapentry
6770     \let\appentry = \shortchapentry
6771     \let\unnchapentry = \shortunnchapentry
6772     % We want a true roman here for the page numbers.
6773     \secfonts
6774     \let\rm=\shortcontrm \let\bf=\shortcontbf
6775     \let\sl=\shortcontsl \let\tt=\shortconttt
6776     \rm
6777     \hyphenpenalty = 10000
6778     \advance\baselineskip by 1pt % Open it up a little.
6779     \def\numsecentry##1##2##3##4{}
6780     \let\appsecentry = \numsecentry
6781     \let\unnsecentry = \numsecentry
6782     \let\numsubsecentry = \numsecentry
6783     \let\appsubsecentry = \numsecentry
6784     \let\unnsubsecentry = \numsecentry
6785     \let\numsubsubsecentry = \numsecentry
6786     \let\appsubsubsecentry = \numsecentry
6787     \let\unnsubsubsecentry = \numsecentry
6788     \openin 1 \tocreadfilename\space
6789     \ifeof 1 \else
6790       \readtocfile
6791     \fi
6792     \closein 1
6793     \vfill \eject
6794     \contentsalignmacro % in case @setchapternewpage odd is in effect
6795   \endgroup
6796   \lastnegativepageno = \pageno
6797   \global\pageno = \savepageno
6798 }
6799 \let\shortcontents = \summarycontents
6800
6801 % Typeset the label for a chapter or appendix for the short contents.
6802 % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6803 %
6804 \def\shortchaplabel#1{%
6805   % This space should be enough, since a single number is .5em, and the
6806   % widest letter (M) is 1em, at least in the Computer Modern fonts.
6807   % But use \hss just in case.
6808   % (This space doesn't include the extra space that gets added after
6809   % the label; that gets put in by \shortchapentry above.)
6810   %
6811   % We'd like to right-justify chapter numbers, but that looks strange
6812   % with appendix letters.  And right-justifying numbers and
6813   % left-justifying letters looks strange when there is less than 10
6814   % chapters.  Have to read the whole toc once to know how many chapters
6815   % there are before deciding ...
6816   \hbox to 1em{#1\hss}%
6817 }
6818
6819 % These macros generate individual entries in the table of contents.
6820 % The first argument is the chapter or section name.
6821 % The last argument is the page number.
6822 % The arguments in between are the chapter number, section number, ...
6823
6824 % Parts, in the main contents.  Replace the part number, which doesn't
6825 % exist, with an empty box.  Let's hope all the numbers have the same width.
6826 % Also ignore the page number, which is conventionally not printed.
6827 \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6828 \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}}
6829 %
6830 % Parts, in the short toc.
6831 \def\shortpartentry#1#2#3#4{%
6832   \penalty-300
6833   \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
6834   \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
6835 }
6836
6837 % Chapters, in the main contents.
6838 \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
6839
6840 % Chapters, in the short toc.
6841 % See comments in \dochapentry re vbox and related settings.
6842 \def\shortchapentry#1#2#3#4{%
6843   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
6844 }
6845
6846 % Appendices, in the main contents.
6847 % Need the word Appendix, and a fixed-size box.
6848 %
6849 \def\appendixbox#1{%
6850   % We use M since it's probably the widest letter.
6851   \setbox0 = \hbox{\putwordAppendix{} M}%
6852   \hbox to \wd0{\putwordAppendix{} #1\hss}}
6853 %
6854 \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
6855
6856 % Unnumbered chapters.
6857 \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
6858 \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
6859
6860 % Sections.
6861 \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
6862 \let\appsecentry=\numsecentry
6863 \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
6864
6865 % Subsections.
6866 \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
6867 \let\appsubsecentry=\numsubsecentry
6868 \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
6869
6870 % And subsubsections.
6871 \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
6872 \let\appsubsubsecentry=\numsubsubsecentry
6873 \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
6874
6875 % This parameter controls the indentation of the various levels.
6876 % Same as \defaultparindent.
6877 \newdimen\tocindent \tocindent = 15pt
6878
6879 % Now for the actual typesetting. In all these, #1 is the text and #2 is the
6880 % page number.
6881 %
6882 % If the toc has to be broken over pages, we want it to be at chapters
6883 % if at all possible; hence the \penalty.
6884 \def\dochapentry#1#2{%
6885    \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
6886    \begingroup
6887      % Move the page numbers slightly to the right
6888      \advance\entryrightmargin by -0.05em
6889      \chapentryfonts
6890      \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6891    \endgroup
6892    \nobreak\vskip .25\baselineskip plus.1\baselineskip
6893 }
6894
6895 \def\dosecentry#1#2{\begingroup
6896   \secentryfonts \leftskip=\tocindent
6897   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6898 \endgroup}
6899
6900 \def\dosubsecentry#1#2{\begingroup
6901   \subsecentryfonts \leftskip=2\tocindent
6902   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6903 \endgroup}
6904
6905 \def\dosubsubsecentry#1#2{\begingroup
6906   \subsubsecentryfonts \leftskip=3\tocindent
6907   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6908 \endgroup}
6909
6910 % We use the same \entry macro as for the index entries.
6911 \let\tocentry = \entry
6912
6913 % Space between chapter (or whatever) number and the title.
6914 \def\labelspace{\hskip1em \relax}
6915
6916 \def\dopageno#1{{\rm #1}}
6917 \def\doshortpageno#1{{\rm #1}}
6918
6919 \def\chapentryfonts{\secfonts \rm}
6920 \def\secentryfonts{\textfonts}
6921 \def\subsecentryfonts{\textfonts}
6922 \def\subsubsecentryfonts{\textfonts}
6923
6924
6925 \message{environments,}
6926 % @foo ... @end foo.
6927
6928 % @tex ... @end tex    escapes into raw TeX temporarily.
6929 % One exception: @ is still an escape character, so that @end tex works.
6930 % But \@ or @@ will get a plain @ character.
6931
6932 \envdef\tex{%
6933   \setupmarkupstyle{tex}%
6934   \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
6935   \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
6936   \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
6937   \catcode `\%=14
6938   \catcode `\+=\other
6939   \catcode `\"=\other
6940   \catcode `\|=\other
6941   \catcode `\<=\other
6942   \catcode `\>=\other
6943   \catcode `\`=\other
6944   \catcode `\'=\other
6945   %
6946   % ' is active in math mode (mathcode"8000).  So reset it, and all our
6947   % other math active characters (just in case), to plain's definitions.
6948   \mathactive
6949   %
6950   % Inverse of the list at the beginning of the file.
6951   \let\b=\ptexb
6952   \let\bullet=\ptexbullet
6953   \let\c=\ptexc
6954   \let\,=\ptexcomma
6955   \let\.=\ptexdot
6956   \let\dots=\ptexdots
6957   \let\equiv=\ptexequiv
6958   \let\!=\ptexexclam
6959   \let\i=\ptexi
6960   \let\indent=\ptexindent
6961   \let\noindent=\ptexnoindent
6962   \let\{=\ptexlbrace
6963   \let\+=\tabalign
6964   \let\}=\ptexrbrace
6965   \let\/=\ptexslash
6966   \let\sp=\ptexsp
6967   \let\*=\ptexstar
6968   %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
6969   \let\t=\ptext
6970   \expandafter \let\csname top\endcsname=\ptextop  % we've made it outer
6971   \let\frenchspacing=\plainfrenchspacing
6972   %
6973   \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
6974   \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
6975   \def\@{@}%
6976 }
6977 % There is no need to define \Etex.
6978
6979 % Define @lisp ... @end lisp.
6980 % @lisp environment forms a group so it can rebind things,
6981 % including the definition of @end lisp (which normally is erroneous).
6982
6983 % Amount to narrow the margins by for @lisp.
6984 \newskip\lispnarrowing \lispnarrowing=0.4in
6985
6986 % This is the definition that ^^M gets inside @lisp, @example, and other
6987 % such environments.  \null is better than a space, since it doesn't
6988 % have any width.
6989 \def\lisppar{\null\endgraf}
6990
6991 % This space is always present above and below environments.
6992 \newskip\envskipamount \envskipamount = 0pt
6993
6994 % Make spacing and below environment symmetrical.  We use \parskip here
6995 % to help in doing that, since in @example-like environments \parskip
6996 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
6997 % start of the next paragraph will insert \parskip.
6998 %
6999 \def\aboveenvbreak{{%
7000   % =10000 instead of <10000 because of a special case in \itemzzz and
7001   % \sectionheading, q.v.
7002   \ifnum \lastpenalty=10000 \else
7003     \advance\envskipamount by \parskip
7004     \endgraf
7005     \ifdim\lastskip<\envskipamount
7006       \removelastskip
7007       \ifnum\lastpenalty<10000
7008         % Penalize breaking before the environment, because preceding text
7009         % often leads into it.
7010         \penalty100
7011       \fi
7012       \vskip\envskipamount
7013     \fi
7014   \fi
7015 }}
7016
7017 \def\afterenvbreak{{%
7018   % =10000 instead of <10000 because of a special case in \itemzzz and
7019   % \sectionheading, q.v.
7020   \ifnum \lastpenalty=10000 \else
7021     \advance\envskipamount by \parskip
7022     \endgraf
7023     \ifdim\lastskip<\envskipamount
7024       \removelastskip
7025       % it's not a good place to break if the last penalty was \nobreak
7026       % or better ...
7027       \ifnum\lastpenalty<10000 \penalty-50 \fi
7028       \vskip\envskipamount
7029     \fi
7030   \fi
7031 }}
7032
7033 % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins; it will
7034 % also clear it, so that its embedded environments do the narrowing again.
7035 \let\nonarrowing=\relax
7036
7037 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
7038 % environment contents.
7039 \font\circle=lcircle10
7040 \newdimen\circthick
7041 \newdimen\cartouter\newdimen\cartinner
7042 \newskip\normbskip\newskip\normpskip\newskip\normlskip
7043 \circthick=\fontdimen8\circle
7044 %
7045 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
7046 \def\ctr{{\hskip 6pt\circle\char'010}}
7047 \def\cbl{{\circle\char'012\hskip -6pt}}
7048 \def\cbr{{\hskip 6pt\circle\char'011}}
7049 \def\carttop{\hbox to \cartouter{\hskip\lskip
7050         \ctl\leaders\hrule height\circthick\hfil\ctr
7051         \hskip\rskip}}
7052 \def\cartbot{\hbox to \cartouter{\hskip\lskip
7053         \cbl\leaders\hrule height\circthick\hfil\cbr
7054         \hskip\rskip}}
7055 %
7056 \newskip\lskip\newskip\rskip
7057
7058 \envdef\cartouche{%
7059   \ifhmode\par\fi  % can't be in the midst of a paragraph.
7060   \startsavinginserts
7061   \lskip=\leftskip \rskip=\rightskip
7062   \leftskip=0pt\rightskip=0pt % we want these *outside*.
7063   \cartinner=\hsize \advance\cartinner by-\lskip
7064   \advance\cartinner by-\rskip
7065   \cartouter=\hsize
7066   \advance\cartouter by 18.4pt  % allow for 3pt kerns on either
7067                                 % side, and for 6pt waste from
7068                                 % each corner char, and rule thickness
7069   \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
7070   %
7071   % If this cartouche directly follows a sectioning command, we need the
7072   % \parskip glue (backspaced over by default) or the cartouche can
7073   % collide with the section heading.
7074   \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
7075   %
7076   \setbox\groupbox=\vbox\bgroup
7077       \baselineskip=0pt\parskip=0pt\lineskip=0pt
7078       \carttop
7079       \hbox\bgroup
7080           \hskip\lskip
7081           \vrule\kern3pt
7082           \vbox\bgroup
7083               \kern3pt
7084               \hsize=\cartinner
7085               \baselineskip=\normbskip
7086               \lineskip=\normlskip
7087               \parskip=\normpskip
7088               \vskip -\parskip
7089               \comment % For explanation, see the end of def\group.
7090 }
7091 \def\Ecartouche{%
7092               \ifhmode\par\fi
7093               \kern3pt
7094           \egroup
7095           \kern3pt\vrule
7096           \hskip\rskip
7097       \egroup
7098       \cartbot
7099   \egroup
7100   \addgroupbox
7101   \checkinserts
7102 }
7103
7104
7105 % This macro is called at the beginning of all the @example variants,
7106 % inside a group.
7107 \newdimen\nonfillparindent
7108 \def\nonfillstart{%
7109   \aboveenvbreak
7110   \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
7111   \sepspaces % Make spaces be word-separators rather than space tokens.
7112   \let\par = \lisppar % don't ignore blank lines
7113   \obeylines % each line of input is a line of output
7114   \parskip = 0pt
7115   % Turn off paragraph indentation but redefine \indent to emulate
7116   % the normal \indent.
7117   \nonfillparindent=\parindent
7118   \parindent = 0pt
7119   \let\indent\nonfillindent
7120   %
7121   \emergencystretch = 0pt % don't try to avoid overfull boxes
7122   \ifx\nonarrowing\relax
7123     \advance \leftskip by \lispnarrowing
7124     \exdentamount=\lispnarrowing
7125   \else
7126     \let\nonarrowing = \relax
7127   \fi
7128   \let\exdent=\nofillexdent
7129 }
7130
7131 \begingroup
7132 \obeyspaces
7133 % We want to swallow spaces (but not other tokens) after the fake
7134 % @indent in our nonfill-environments, where spaces are normally
7135 % active and set to @tie, resulting in them not being ignored after
7136 % @indent.
7137 \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
7138 \gdef\nonfillindentcheck{%
7139 \ifx\temp %
7140 \expandafter\nonfillindentgobble%
7141 \else%
7142 \leavevmode\nonfillindentbox%
7143 \fi%
7144 }%
7145 \endgroup
7146 \def\nonfillindentgobble#1{\nonfillindent}
7147 \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7148
7149 % If you want all examples etc. small: @set dispenvsize small.
7150 % If you want even small examples the full size: @set dispenvsize nosmall.
7151 % This affects the following displayed environments:
7152 %    @example, @display, @format, @lisp
7153 %
7154 \def\smallword{small}
7155 \def\nosmallword{nosmall}
7156 \let\SETdispenvsize\relax
7157 \def\setnormaldispenv{%
7158   \ifx\SETdispenvsize\smallword
7159     % end paragraph for sake of leading, in case document has no blank
7160     % line.  This is redundant with what happens in \aboveenvbreak, but
7161     % we need to do it before changing the fonts, and it's inconvenient
7162     % to change the fonts afterward.
7163     \ifnum \lastpenalty=10000 \else \endgraf \fi
7164     \smallexamplefonts \rm
7165   \fi
7166 }
7167 \def\setsmalldispenv{%
7168   \ifx\SETdispenvsize\nosmallword
7169   \else
7170     \ifnum \lastpenalty=10000 \else \endgraf \fi
7171     \smallexamplefonts \rm
7172   \fi
7173 }
7174
7175 % We often define two environments, @foo and @smallfoo.
7176 % Let's do it in one command.  #1 is the env name, #2 the definition.
7177 \def\makedispenvdef#1#2{%
7178   \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7179   \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
7180   \expandafter\let\csname E#1\endcsname \afterenvbreak
7181   \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
7182 }
7183
7184 % Define two environment synonyms (#1 and #2) for an environment.
7185 \def\maketwodispenvdef#1#2#3{%
7186   \makedispenvdef{#1}{#3}%
7187   \makedispenvdef{#2}{#3}%
7188 }
7189 %
7190 % @lisp: indented, narrowed, typewriter font;
7191 % @example: same as @lisp.
7192 %
7193 % @smallexample and @smalllisp: use smaller fonts.
7194 % Originally contributed by Pavel@xerox.
7195 %
7196 \maketwodispenvdef{lisp}{example}{%
7197   \nonfillstart
7198   \tt\setupmarkupstyle{example}%
7199   \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
7200   \gobble % eat return
7201 }
7202 % @display/@smalldisplay: same as @lisp except keep current font.
7203 %
7204 \makedispenvdef{display}{%
7205   \nonfillstart
7206   \gobble
7207 }
7208
7209 % @format/@smallformat: same as @display except don't narrow margins.
7210 %
7211 \makedispenvdef{format}{%
7212   \let\nonarrowing = t%
7213   \nonfillstart
7214   \gobble
7215 }
7216
7217 % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7218 \envdef\flushleft{%
7219   \let\nonarrowing = t%
7220   \nonfillstart
7221   \gobble
7222 }
7223 \let\Eflushleft = \afterenvbreak
7224
7225 % @flushright.
7226 %
7227 \envdef\flushright{%
7228   \let\nonarrowing = t%
7229   \nonfillstart
7230   \advance\leftskip by 0pt plus 1fill\relax
7231   \gobble
7232 }
7233 \let\Eflushright = \afterenvbreak
7234
7235
7236 % @raggedright does more-or-less normal line breaking but no right
7237 % justification.  From plain.tex.  Don't stretch around special
7238 % characters in urls in this environment, since the stretch at the right
7239 % should be enough.
7240 \envdef\raggedright{%
7241   \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7242   \def\urefprestretchamount{0pt}%
7243   \def\urefpoststretchamount{0pt}%
7244 }
7245 \let\Eraggedright\par
7246
7247 \envdef\raggedleft{%
7248   \parindent=0pt \leftskip0pt plus2em
7249   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7250   \hbadness=10000 % Last line will usually be underfull, so turn off
7251                   % badness reporting.
7252 }
7253 \let\Eraggedleft\par
7254
7255 \envdef\raggedcenter{%
7256   \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
7257   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7258   \hbadness=10000 % Last line will usually be underfull, so turn off
7259                   % badness reporting.
7260 }
7261 \let\Eraggedcenter\par
7262
7263
7264 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
7265 % and narrows the margins.  We keep \parskip nonzero in general, since
7266 % we're doing normal filling.  So, when using \aboveenvbreak and
7267 % \afterenvbreak, temporarily make \parskip 0.
7268 %
7269 \makedispenvdef{quotation}{\quotationstart}
7270 %
7271 \def\quotationstart{%
7272   \indentedblockstart % same as \indentedblock, but increase right margin too.
7273   \ifx\nonarrowing\relax
7274     \advance\rightskip by \lispnarrowing
7275   \fi
7276   \parsearg\quotationlabel
7277 }
7278
7279 % We have retained a nonzero parskip for the environment, since we're
7280 % doing normal filling.
7281 %
7282 \def\Equotation{%
7283   \par
7284   \ifx\quotationauthor\thisisundefined\else
7285     % indent a bit.
7286     \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7287   \fi
7288   {\parskip=0pt \afterenvbreak}%
7289 }
7290 \def\Esmallquotation{\Equotation}
7291
7292 % If we're given an argument, typeset it in bold with a colon after.
7293 \def\quotationlabel#1{%
7294   \def\temp{#1}%
7295   \ifx\temp\empty \else
7296     {\bf #1: }%
7297   \fi
7298 }
7299
7300 % @indentedblock is like @quotation, but indents only on the left and
7301 % has no optional argument.
7302
7303 \makedispenvdef{indentedblock}{\indentedblockstart}
7304 %
7305 \def\indentedblockstart{%
7306   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7307   \parindent=0pt
7308   %
7309   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7310   \ifx\nonarrowing\relax
7311     \advance\leftskip by \lispnarrowing
7312     \exdentamount = \lispnarrowing
7313   \else
7314     \let\nonarrowing = \relax
7315   \fi
7316 }
7317
7318 % Keep a nonzero parskip for the environment, since we're doing normal filling.
7319 %
7320 \def\Eindentedblock{%
7321   \par
7322   {\parskip=0pt \afterenvbreak}%
7323 }
7324 \def\Esmallindentedblock{\Eindentedblock}
7325
7326
7327 % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7328 % If we want to allow any <char> as delimiter,
7329 % we need the curly braces so that makeinfo sees the @verb command, eg:
7330 % `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
7331 %
7332 % [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
7333 %
7334 % [Knuth] p.344; only we need to do the other characters Texinfo sets
7335 % active too.  Otherwise, they get lost as the first character on a
7336 % verbatim line.
7337 \def\dospecials{%
7338   \do\ \do\\\do\{\do\}\do\$\do\&%
7339   \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7340   \do\<\do\>\do\|\do\@\do+\do\"%
7341   % Don't do the quotes -- if we do, @set txicodequoteundirected and
7342   % @set txicodequotebacktick will not have effect on @verb and
7343   % @verbatim, and ?` and !` ligatures won't get disabled.
7344   %\do\`\do\'%
7345 }
7346 %
7347 % [Knuth] p. 380
7348 \def\uncatcodespecials{%
7349   \def\do##1{\catcode`##1=\other}\dospecials}
7350 %
7351 % Setup for the @verb command.
7352 %
7353 % Eight spaces for a tab
7354 \begingroup
7355   \catcode`\^^I=\active
7356   \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7357 \endgroup
7358 %
7359 \def\setupverb{%
7360   \tt  % easiest (and conventionally used) font for verbatim
7361   \def\par{\leavevmode\endgraf}%
7362   \setupmarkupstyle{verb}%
7363   \tabeightspaces
7364   % Respect line breaks,
7365   % print special symbols as themselves, and
7366   % make each space count
7367   % must do in this order:
7368   \obeylines \uncatcodespecials \sepspaces
7369 }
7370
7371 % Setup for the @verbatim environment
7372 %
7373 % Real tab expansion.
7374 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7375 %
7376 % We typeset each line of the verbatim in an \hbox, so we can handle
7377 % tabs.  The \global is in case the verbatim line starts with an accent,
7378 % or some other command that starts with a begin-group.  Otherwise, the
7379 % entire \verbbox would disappear at the corresponding end-group, before
7380 % it is typeset.  Meanwhile, we can't have nested verbatim commands
7381 % (can we?), so the \global won't be overwriting itself.
7382 \newbox\verbbox
7383 \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
7384 %
7385 \begingroup
7386   \catcode`\^^I=\active
7387   \gdef\tabexpand{%
7388     \catcode`\^^I=\active
7389     \def^^I{\leavevmode\egroup
7390       \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7391       \divide\dimen\verbbox by\tabw
7392       \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7393       \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
7394       \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
7395     }%
7396   }
7397 \endgroup
7398
7399 % start the verbatim environment.
7400 \def\setupverbatim{%
7401   \let\nonarrowing = t%
7402   \nonfillstart
7403   \tt % easiest (and conventionally used) font for verbatim
7404   % The \leavevmode here is for blank lines.  Otherwise, we would
7405   % never \starttabox and the \egroup would end verbatim mode.
7406   \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
7407   \tabexpand
7408   \setupmarkupstyle{verbatim}%
7409   % Respect line breaks,
7410   % print special symbols as themselves, and
7411   % make each space count.
7412   % Must do in this order:
7413   \obeylines \uncatcodespecials \sepspaces
7414   \everypar{\starttabbox}%
7415 }
7416
7417 % Do the @verb magic: verbatim text is quoted by unique
7418 % delimiter characters.  Before first delimiter expect a
7419 % right brace, after last delimiter expect closing brace:
7420 %
7421 %    \def\doverb'{'<char>#1<char>'}'{#1}
7422 %
7423 % [Knuth] p. 382; only eat outer {}
7424 \begingroup
7425   \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
7426   \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7427 \endgroup
7428 %
7429 \def\verb{\begingroup\setupverb\doverb}
7430 %
7431 %
7432 % Do the @verbatim magic: define the macro \doverbatim so that
7433 % the (first) argument ends when '@end verbatim' is reached, ie:
7434 %
7435 %     \def\doverbatim#1@end verbatim{#1}
7436 %
7437 % For Texinfo it's a lot easier than for LaTeX,
7438 % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
7439 % we need not redefine '\', '{' and '}'.
7440 %
7441 % Inspired by LaTeX's verbatim command set [latex.ltx]
7442 %
7443 \begingroup
7444   \catcode`\ =\active
7445   \obeylines %
7446   % ignore everything up to the first ^^M, that's the newline at the end
7447   % of the @verbatim input line itself.  Otherwise we get an extra blank
7448   % line in the output.
7449   \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
7450   % We really want {...\end verbatim} in the body of the macro, but
7451   % without the active space; thus we have to use \xdef and \gobble.
7452 \endgroup
7453 %
7454 \envdef\verbatim{%
7455     \setupverbatim\doverbatim
7456 }
7457 \let\Everbatim = \afterenvbreak
7458
7459
7460 % @verbatiminclude FILE - insert text of file in verbatim environment.
7461 %
7462 \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
7463 %
7464 \def\doverbatiminclude#1{%
7465   {%
7466     \makevalueexpandable
7467     \setupverbatim
7468     \indexnofonts       % Allow `@@' and other weird things in file names.
7469     \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
7470     \input #1
7471     \afterenvbreak
7472   }%
7473 }
7474
7475 % @copying ... @end copying.
7476 % Save the text away for @insertcopying later.
7477 %
7478 % We save the uninterpreted tokens, rather than creating a box.
7479 % Saving the text in a box would be much easier, but then all the
7480 % typesetting commands (@smallbook, font changes, etc.) have to be done
7481 % beforehand -- and a) we want @copying to be done first in the source
7482 % file; b) letting users define the frontmatter in as flexible order as
7483 % possible is desirable.
7484 %
7485 \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
7486 \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
7487 %
7488 \def\insertcopying{%
7489   \begingroup
7490     \parindent = 0pt  % paragraph indentation looks wrong on title page
7491     \scanexp\copyingtext
7492   \endgroup
7493 }
7494
7495
7496 \message{defuns,}
7497 % @defun etc.
7498
7499 \newskip\defbodyindent \defbodyindent=.4in
7500 \newskip\defargsindent \defargsindent=50pt
7501 \newskip\deflastargmargin \deflastargmargin=18pt
7502 \newcount\defunpenalty
7503
7504 % Start the processing of @deffn:
7505 \def\startdefun{%
7506   \ifnum\lastpenalty<10000
7507     \medbreak
7508     \defunpenalty=10003 % Will keep this @deffn together with the
7509                         % following @def command, see below.
7510   \else
7511     % If there are two @def commands in a row, we'll have a \nobreak,
7512     % which is there to keep the function description together with its
7513     % header.  But if there's nothing but headers, we need to allow a
7514     % break somewhere.  Check specifically for penalty 10002, inserted
7515     % by \printdefunline, instead of 10000, since the sectioning
7516     % commands also insert a nobreak penalty, and we don't want to allow
7517     % a break between a section heading and a defun.
7518     %
7519     % As a further refinement, we avoid "club" headers by signalling
7520     % with penalty of 10003 after the very first @deffn in the
7521     % sequence (see above), and penalty of 10002 after any following
7522     % @def command.
7523     \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
7524     %
7525     % Similarly, after a section heading, do not allow a break.
7526     % But do insert the glue.
7527     \medskip  % preceded by discardable penalty, so not a breakpoint
7528   \fi
7529   %
7530   \parindent=0in
7531   \advance\leftskip by \defbodyindent
7532   \exdentamount=\defbodyindent
7533 }
7534
7535 \def\dodefunx#1{%
7536   % First, check whether we are in the right environment:
7537   \checkenv#1%
7538   %
7539   % As above, allow line break if we have multiple x headers in a row.
7540   % It's not a great place, though.
7541   \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
7542   %
7543   % And now, it's time to reuse the body of the original defun:
7544   \expandafter\gobbledefun#1%
7545 }
7546 \def\gobbledefun#1\startdefun{}
7547
7548 % \printdefunline \deffnheader{text}
7549 %
7550 \def\printdefunline#1#2{%
7551   \begingroup
7552     % call \deffnheader:
7553     #1#2 \endheader
7554     % common ending:
7555     \interlinepenalty = 10000
7556     \advance\rightskip by 0pt plus 1fil\relax
7557     \endgraf
7558     \nobreak\vskip -\parskip
7559     \penalty\defunpenalty  % signal to \startdefun and \dodefunx
7560     % Some of the @defun-type tags do not enable magic parentheses,
7561     % rendering the following check redundant.  But we don't optimize.
7562     \checkparencounts
7563   \endgroup
7564 }
7565
7566 \def\Edefun{\endgraf\medbreak}
7567
7568 % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
7569 % the only thing remaining is to define \deffnheader.
7570 %
7571 \def\makedefun#1{%
7572   \expandafter\let\csname E#1\endcsname = \Edefun
7573   \edef\temp{\noexpand\domakedefun
7574     \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7575   \temp
7576 }
7577
7578 % \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
7579 %
7580 % Define \deffn and \deffnx, without parameters.
7581 % \deffnheader has to be defined explicitly.
7582 %
7583 \def\domakedefun#1#2#3{%
7584   \envdef#1{%
7585     \startdefun
7586     \doingtypefnfalse    % distinguish typed functions from all else
7587     \parseargusing\activeparens{\printdefunline#3}%
7588   }%
7589   \def#2{\dodefunx#1}%
7590   \def#3%
7591 }
7592
7593 \newif\ifdoingtypefn       % doing typed function?
7594 \newif\ifrettypeownline    % typeset return type on its own line?
7595
7596 % @deftypefnnewline on|off says whether the return type of typed functions
7597 % are printed on their own line.  This affects @deftypefn, @deftypefun,
7598 % @deftypeop, and @deftypemethod.
7599
7600 \parseargdef\deftypefnnewline{%
7601   \def\temp{#1}%
7602   \ifx\temp\onword
7603     \expandafter\let\csname SETtxideftypefnnl\endcsname
7604       = \empty
7605   \else\ifx\temp\offword
7606     \expandafter\let\csname SETtxideftypefnnl\endcsname
7607       = \relax
7608   \else
7609     \errhelp = \EMsimple
7610     \errmessage{Unknown @txideftypefnnl value `\temp',
7611                 must be on|off}%
7612   \fi\fi
7613 }
7614
7615 % Untyped functions:
7616
7617 % @deffn category name args
7618 \makedefun{deffn}{\deffngeneral{}}
7619
7620 % @deffn category class name args
7621 \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
7622
7623 % \defopon {category on}class name args
7624 \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7625
7626 % \deffngeneral {subind}category name args
7627 %
7628 \def\deffngeneral#1#2 #3 #4\endheader{%
7629   % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
7630   \dosubind{fn}{\code{#3}}{#1}%
7631   \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
7632 }
7633
7634 % Typed functions:
7635
7636 % @deftypefn category type name args
7637 \makedefun{deftypefn}{\deftypefngeneral{}}
7638
7639 % @deftypeop category class type name args
7640 \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
7641
7642 % \deftypeopon {category on}class type name args
7643 \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7644
7645 % \deftypefngeneral {subind}category type name args
7646 %
7647 \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
7648   \dosubind{fn}{\code{#4}}{#1}%
7649   \doingtypefntrue
7650   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7651 }
7652
7653 % Typed variables:
7654
7655 % @deftypevr category type var args
7656 \makedefun{deftypevr}{\deftypecvgeneral{}}
7657
7658 % @deftypecv category class type var args
7659 \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
7660
7661 % \deftypecvof {category of}class type var args
7662 \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
7663
7664 % \deftypecvgeneral {subind}category type var args
7665 %
7666 \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
7667   \dosubind{vr}{\code{#4}}{#1}%
7668   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7669 }
7670
7671 % Untyped variables:
7672
7673 % @defvr category var args
7674 \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
7675
7676 % @defcv category class var args
7677 \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
7678
7679 % \defcvof {category of}class var args
7680 \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
7681
7682 % Types:
7683
7684 % @deftp category name args
7685 \makedefun{deftp}#1 #2 #3\endheader{%
7686   \doind{tp}{\code{#2}}%
7687   \defname{#1}{}{#2}\defunargs{#3\unskip}%
7688 }
7689
7690 % Remaining @defun-like shortcuts:
7691 \makedefun{defun}{\deffnheader{\putwordDeffunc} }
7692 \makedefun{defmac}{\deffnheader{\putwordDefmac} }
7693 \makedefun{defspec}{\deffnheader{\putwordDefspec} }
7694 \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7695 \makedefun{defvar}{\defvrheader{\putwordDefvar} }
7696 \makedefun{defopt}{\defvrheader{\putwordDefopt} }
7697 \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
7698 \makedefun{defmethod}{\defopon\putwordMethodon}
7699 \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
7700 \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
7701 \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
7702
7703 % \defname, which formats the name of the @def (not the args).
7704 % #1 is the category, such as "Function".
7705 % #2 is the return type, if any.
7706 % #3 is the function name.
7707 %
7708 % We are followed by (but not passed) the arguments, if any.
7709 %
7710 \def\defname#1#2#3{%
7711   \par
7712   % Get the values of \leftskip and \rightskip as they were outside the @def...
7713   \advance\leftskip by -\defbodyindent
7714   %
7715   % Determine if we are typesetting the return type of a typed function
7716   % on a line by itself.
7717   \rettypeownlinefalse
7718   \ifdoingtypefn  % doing a typed function specifically?
7719     % then check user option for putting return type on its own line:
7720     \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
7721       \rettypeownlinetrue
7722     \fi
7723   \fi
7724   %
7725   % How we'll format the category name.  Putting it in brackets helps
7726   % distinguish it from the body text that may end up on the next line
7727   % just below it.
7728   \def\temp{#1}%
7729   \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7730   %
7731   % Figure out line sizes for the paragraph shape.  We'll always have at
7732   % least two.
7733   \tempnum = 2
7734   %
7735   % The first line needs space for \box0; but if \rightskip is nonzero,
7736   % we need only space for the part of \box0 which exceeds it:
7737   \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
7738   %
7739   % If doing a return type on its own line, we'll have another line.
7740   \ifrettypeownline
7741     \advance\tempnum by 1
7742     \def\maybeshapeline{0in \hsize}%
7743   \else
7744     \def\maybeshapeline{}%
7745   \fi
7746   %
7747   % The continuations:
7748   \dimen2=\hsize  \advance\dimen2 by -\defargsindent
7749   %
7750   % The final paragraph shape:
7751   \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
7752   %
7753   % Put the category name at the right margin.
7754   \noindent
7755   \hbox to 0pt{%
7756     \hfil\box0 \kern-\hsize
7757     % \hsize has to be shortened this way:
7758     \kern\leftskip
7759     % Intentionally do not respect \rightskip, since we need the space.
7760   }%
7761   %
7762   % Allow all lines to be underfull without complaint:
7763   \tolerance=10000 \hbadness=10000
7764   \exdentamount=\defbodyindent
7765   {%
7766     % defun fonts. We use typewriter by default (used to be bold) because:
7767     % . we're printing identifiers, they should be in tt in principle.
7768     % . in languages with many accents, such as Czech or French, it's
7769     %   common to leave accents off identifiers.  The result looks ok in
7770     %   tt, but exceedingly strange in rm.
7771     % . we don't want -- and --- to be treated as ligatures.
7772     % . this still does not fix the ?` and !` ligatures, but so far no
7773     %   one has made identifiers using them :).
7774     \df \tt
7775     \def\temp{#2}% text of the return type
7776     \ifx\temp\empty\else
7777       \tclose{\temp}% typeset the return type
7778       \ifrettypeownline
7779         % put return type on its own line; prohibit line break following:
7780         \hfil\vadjust{\nobreak}\break  
7781       \else
7782         \space  % type on same line, so just followed by a space
7783       \fi
7784     \fi           % no return type
7785     #3% output function name
7786   }%
7787   {\rm\enskip}% hskip 0.5 em of \tenrm
7788   %
7789   \boldbrax
7790   % arguments will be output next, if any.
7791 }
7792
7793 % Print arguments in slanted roman (not ttsl), inconsistently with using
7794 % tt for the name.  This is because literal text is sometimes needed in
7795 % the argument list (groff manual), and ttsl and tt are not very
7796 % distinguishable.  Prevent hyphenation at `-' chars.
7797 %
7798 \def\defunargs#1{%
7799   % use sl by default (not ttsl),
7800   % tt for the names.
7801   \df \sl \hyphenchar\font=0
7802   %
7803   % On the other hand, if an argument has two dashes (for instance), we
7804   % want a way to get ttsl.  We used to recommend @var for that, so
7805   % leave the code in, but it's strange for @var to lead to typewriter.
7806   % Nowadays we recommend @code, since the difference between a ttsl hyphen
7807   % and a tt hyphen is pretty tiny.  @code also disables ?` !`.
7808   \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
7809   #1%
7810   \sl\hyphenchar\font=45
7811 }
7812
7813 % We want ()&[] to print specially on the defun line.
7814 %
7815 \def\activeparens{%
7816   \catcode`\(=\active \catcode`\)=\active
7817   \catcode`\[=\active \catcode`\]=\active
7818   \catcode`\&=\active
7819 }
7820
7821 % Make control sequences which act like normal parenthesis chars.
7822 \let\lparen = ( \let\rparen = )
7823
7824 % Be sure that we always have a definition for `(', etc.  For example,
7825 % if the fn name has parens in it, \boldbrax will not be in effect yet,
7826 % so TeX would otherwise complain about undefined control sequence.
7827 {
7828   \activeparens
7829   \global\let(=\lparen \global\let)=\rparen
7830   \global\let[=\lbrack \global\let]=\rbrack
7831   \global\let& = \&
7832
7833   \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
7834   \gdef\magicamp{\let&=\amprm}
7835 }
7836
7837 \newcount\parencount
7838
7839 % If we encounter &foo, then turn on ()-hacking afterwards
7840 \newif\ifampseen
7841 \def\amprm#1 {\ampseentrue{\bf\&#1 }}
7842
7843 \def\parenfont{%
7844   \ifampseen
7845     % At the first level, print parens in roman,
7846     % otherwise use the default font.
7847     \ifnum \parencount=1 \rm \fi
7848   \else
7849     % The \sf parens (in \boldbrax) actually are a little bolder than
7850     % the contained text.  This is especially needed for [ and ] .
7851     \sf
7852   \fi
7853 }
7854 \def\infirstlevel#1{%
7855   \ifampseen
7856     \ifnum\parencount=1
7857       #1%
7858     \fi
7859   \fi
7860 }
7861 \def\bfafterword#1 {#1 \bf}
7862
7863 \def\opnr{%
7864   \global\advance\parencount by 1
7865   {\parenfont(}%
7866   \infirstlevel \bfafterword
7867 }
7868 \def\clnr{%
7869   {\parenfont)}%
7870   \infirstlevel \sl
7871   \global\advance\parencount by -1
7872 }
7873
7874 \newcount\brackcount
7875 \def\lbrb{%
7876   \global\advance\brackcount by 1
7877   {\bf[}%
7878 }
7879 \def\rbrb{%
7880   {\bf]}%
7881   \global\advance\brackcount by -1
7882 }
7883
7884 \def\checkparencounts{%
7885   \ifnum\parencount=0 \else \badparencount \fi
7886   \ifnum\brackcount=0 \else \badbrackcount \fi
7887 }
7888 % these should not use \errmessage; the glibc manual, at least, actually
7889 % has such constructs (when documenting function pointers).
7890 \def\badparencount{%
7891   \message{Warning: unbalanced parentheses in @def...}%
7892   \global\parencount=0
7893 }
7894 \def\badbrackcount{%
7895   \message{Warning: unbalanced square brackets in @def...}%
7896   \global\brackcount=0
7897 }
7898
7899
7900 \message{macros,}
7901 % @macro.
7902
7903 % To do this right we need a feature of e-TeX, \scantokens,
7904 % which we arrange to emulate with a temporary file in ordinary TeX.
7905 \ifx\eTeXversion\thisisundefined
7906   \newwrite\macscribble
7907   \def\scantokens#1{%
7908     \toks0={#1}%
7909     \immediate\openout\macscribble=\jobname.tmp
7910     \immediate\write\macscribble{\the\toks0}%
7911     \immediate\closeout\macscribble
7912     \input \jobname.tmp
7913   }
7914 \fi
7915
7916 \let\aftermacroxxx\relax
7917 \def\aftermacro{\aftermacroxxx}
7918
7919 % alias because \c means cedilla in @tex or @math
7920 \let\texinfoc=\c
7921
7922 \newcount\savedcatcodeone
7923 \newcount\savedcatcodetwo
7924
7925 % Used at the time of macro expansion.
7926 % Argument is macro body with arguments substituted
7927 \def\scanmacro#1{%
7928   \newlinechar`\^^M
7929   \def\xeatspaces{\eatspaces}%
7930   %
7931   % Temporarily undo catcode changes of \printindex.  Set catcode of @ to
7932   % 0 so that @-commands in macro expansions aren't printed literally when 
7933   % formatting an index file, where \ is used as the escape character.
7934   \savedcatcodeone=\catcode`\@
7935   \savedcatcodetwo=\catcode`\\
7936   \catcode`\@=0
7937   \catcode`\\=\active
7938   %
7939   % Process the macro body under the current catcode regime.
7940   \scantokens{#1@texinfoc}\aftermacro%
7941   %
7942   \catcode`\@=\savedcatcodeone
7943   \catcode`\\=\savedcatcodetwo
7944   %
7945   % The \texinfoc is to remove the \newlinechar added by \scantokens, and
7946   % can be noticed by \parsearg.
7947   %   The \aftermacro allows a \comment at the end of the macro definition
7948   % to duplicate itself past the final \newlinechar added by \scantokens:
7949   % this is used in the definition of \group to comment out a newline.  We
7950   % don't do the same for \c to support Texinfo files with macros that ended
7951   % with a @c, which should no longer be necessary.
7952   %   We avoid surrounding the call to \scantokens with \bgroup and \egroup
7953   % to allow macros to open or close groups themselves.
7954 }
7955
7956 % Used for copying and captions
7957 \def\scanexp#1{%
7958   \expandafter\scanmacro\expandafter{#1}%
7959 }
7960
7961 \newcount\paramno   % Count of parameters
7962 \newtoks\macname    % Macro name
7963 \newif\ifrecursive  % Is it recursive?
7964
7965 % List of all defined macros in the form
7966 %    \definedummyword\macro1\definedummyword\macro2...
7967 % Currently is also contains all @aliases; the list can be split
7968 % if there is a need.
7969 \def\macrolist{}
7970
7971 % Add the macro to \macrolist
7972 \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
7973 \def\addtomacrolistxxx#1{%
7974      \toks0 = \expandafter{\macrolist\definedummyword#1}%
7975      \xdef\macrolist{\the\toks0}%
7976 }
7977
7978 % Utility routines.
7979 % This does \let #1 = #2, with \csnames; that is,
7980 %   \let \csname#1\endcsname = \csname#2\endcsname
7981 % (except of course we have to play expansion games).
7982 %
7983 \def\cslet#1#2{%
7984   \expandafter\let
7985   \csname#1\expandafter\endcsname
7986   \csname#2\endcsname
7987 }
7988
7989 % Trim leading and trailing spaces off a string.
7990 % Concepts from aro-bend problem 15 (see CTAN).
7991 {\catcode`\@=11
7992 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
7993 \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
7994 \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
7995 \def\unbrace#1{#1}
7996 \unbrace{\gdef\trim@@@ #1 } #2@{#1}
7997 }
7998
7999 % Trim a single trailing ^^M off a string.
8000 {\catcode`\^^M=\other \catcode`\Q=3%
8001 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
8002 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
8003 \gdef\eatcrb#1Q#2Q{#1}%
8004 }
8005
8006 % Macro bodies are absorbed as an argument in a context where
8007 % all characters are catcode 10, 11 or 12, except \ which is active
8008 % (as in normal texinfo). It is necessary to change the definition of \
8009 % to recognize macro arguments; this is the job of \mbodybackslash.
8010 %
8011 % Non-ASCII encodings make 8-bit characters active, so un-activate
8012 % them to avoid their expansion.  Must do this non-globally, to
8013 % confine the change to the current group.
8014 %
8015 % It's necessary to have hard CRs when the macro is executed. This is
8016 % done by making ^^M (\endlinechar) catcode 12 when reading the macro
8017 % body, and then making it the \newlinechar in \scanmacro.
8018 %
8019 \def\scanctxt{% used as subroutine
8020   \catcode`\"=\other
8021   \catcode`\+=\other
8022   \catcode`\<=\other
8023   \catcode`\>=\other
8024   \catcode`\^=\other
8025   \catcode`\_=\other
8026   \catcode`\|=\other
8027   \catcode`\~=\other
8028   \passthroughcharstrue
8029 }
8030
8031 \def\scanargctxt{% used for copying and captions, not macros.
8032   \scanctxt
8033   \catcode`\@=\other
8034   \catcode`\\=\other
8035   \catcode`\^^M=\other
8036 }
8037
8038 \def\macrobodyctxt{% used for @macro definitions
8039   \scanctxt
8040   \catcode`\ =\other
8041   \catcode`\@=\other
8042   \catcode`\{=\other
8043   \catcode`\}=\other
8044   \catcode`\^^M=\other
8045   \usembodybackslash
8046 }
8047
8048 % Used when scanning braced macro arguments.  Note, however, that catcode
8049 % changes here are ineffectual if the macro invocation was nested inside
8050 % an argument to another Texinfo command.
8051 \def\macroargctxt{%
8052   \scanctxt
8053   \catcode`\ =\active
8054   \catcode`\^^M=\other
8055   \catcode`\\=\active
8056 }
8057
8058 \def\macrolineargctxt{% used for whole-line arguments without braces
8059   \scanctxt
8060   \catcode`\{=\other
8061   \catcode`\}=\other
8062 }
8063
8064 % \mbodybackslash is the definition of \ in @macro bodies.
8065 % It maps \foo\ => \csname macarg.foo\endcsname => #N
8066 % where N is the macro parameter number.
8067 % We define \csname macarg.\endcsname to be \realbackslash, so
8068 % \\ in macro replacement text gets you a backslash.
8069 %
8070 {\catcode`@=0 @catcode`@\=@active
8071  @gdef@usembodybackslash{@let\=@mbodybackslash}
8072  @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
8073 }
8074 \expandafter\def\csname macarg.\endcsname{\realbackslash}
8075
8076 \def\margbackslash#1{\char`\#1 }
8077
8078 \def\macro{\recursivefalse\parsearg\macroxxx}
8079 \def\rmacro{\recursivetrue\parsearg\macroxxx}
8080
8081 \def\macroxxx#1{%
8082   \getargs{#1}% now \macname is the macname and \argl the arglist
8083   \ifx\argl\empty       % no arguments
8084      \paramno=0\relax
8085   \else
8086      \expandafter\parsemargdef \argl;%
8087      \if\paramno>256\relax
8088        \ifx\eTeXversion\thisisundefined
8089          \errhelp = \EMsimple
8090          \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
8091        \fi
8092      \fi
8093   \fi
8094   \if1\csname ismacro.\the\macname\endcsname
8095      \message{Warning: redefining \the\macname}%
8096   \else
8097      \expandafter\ifx\csname \the\macname\endcsname \relax
8098      \else \errmessage{Macro name \the\macname\space already defined}\fi
8099      \global\cslet{macsave.\the\macname}{\the\macname}%
8100      \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
8101      \addtomacrolist{\the\macname}%
8102   \fi
8103   \begingroup \macrobodyctxt
8104   \ifrecursive \expandafter\parsermacbody
8105   \else \expandafter\parsemacbody
8106   \fi}
8107
8108 \parseargdef\unmacro{%
8109   \if1\csname ismacro.#1\endcsname
8110     \global\cslet{#1}{macsave.#1}%
8111     \global\expandafter\let \csname ismacro.#1\endcsname=0%
8112     % Remove the macro name from \macrolist:
8113     \begingroup
8114       \expandafter\let\csname#1\endcsname \relax
8115       \let\definedummyword\unmacrodo
8116       \xdef\macrolist{\macrolist}%
8117     \endgroup
8118   \else
8119     \errmessage{Macro #1 not defined}%
8120   \fi
8121 }
8122
8123 % Called by \do from \dounmacro on each macro.  The idea is to omit any
8124 % macro definitions that have been changed to \relax.
8125 %
8126 \def\unmacrodo#1{%
8127   \ifx #1\relax
8128     % remove this
8129   \else
8130     \noexpand\definedummyword \noexpand#1%
8131   \fi
8132 }
8133
8134 % \getargs -- Parse the arguments to a @macro line.  Set \macname to
8135 % the name of the macro, and \argl to the braced argument list.
8136 \def\getargs#1{\getargsxxx#1{}}
8137 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
8138 \def\getmacname#1 #2\relax{\macname={#1}}
8139 \def\getmacargs#1{\def\argl{#1}}
8140 % This made use of the feature that if the last token of a
8141 % <parameter list> is #, then the preceding argument is delimited by
8142 % an opening brace, and that opening brace is not consumed.
8143
8144 % Parse the optional {params} list to @macro or @rmacro.
8145 % Set \paramno to the number of arguments,
8146 % and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
8147 % three-param macro.)  Define \macarg.BLAH for each BLAH in the params
8148 % list to some hook where the argument is to be expanded.  If there are
8149 % less than 10 arguments that hook is to be replaced by ##N where N
8150 % is the position in that list, that is to say the macro arguments are to be
8151 % defined `a la TeX in the macro body.  
8152 %
8153 % That gets used by \mbodybackslash (above).
8154 %
8155 % If there are 10 or more arguments, a different technique is used: see
8156 % \parsemmanyargdef.
8157 %
8158 \def\parsemargdef#1;{%
8159   \paramno=0\def\paramlist{}%
8160   \let\hash\relax
8161   % \hash is redefined to `#' later to get it into definitions
8162   \let\xeatspaces\relax
8163   \parsemargdefxxx#1,;,%
8164   \ifnum\paramno<10\relax\else
8165     \paramno0\relax
8166     \parsemmanyargdef@@#1,;,% 10 or more arguments
8167   \fi
8168 }
8169 \def\parsemargdefxxx#1,{%
8170   \if#1;\let\next=\relax
8171   \else \let\next=\parsemargdefxxx
8172     \advance\paramno by 1
8173     \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
8174         {\xeatspaces{\hash\the\paramno}}%
8175     \edef\paramlist{\paramlist\hash\the\paramno,}%
8176   \fi\next}
8177
8178 % \parsemacbody, \parsermacbody
8179 %
8180 % Read recursive and nonrecursive macro bodies. (They're different since
8181 % rec and nonrec macros end differently.)
8182
8183 % We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro 
8184 % body to be transformed.
8185 % Set \macrobody to the body of the macro, and call \defmacro.
8186 %
8187 {\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{%
8188 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8189 {\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
8190 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8191
8192 % Make @ a letter, so that we can make private-to-Texinfo macro names.
8193 \edef\texiatcatcode{\the\catcode`\@}
8194 \catcode `@=11\relax
8195
8196 %%%%%%%%%%%%%% Code for > 10 arguments only   %%%%%%%%%%%%%%%%%%
8197
8198 % If there are 10 or more arguments, a different technique is used, where the
8199 % hook remains in the body, and when macro is to be expanded the body is
8200 % processed again to replace the arguments.
8201 %
8202 % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
8203 % argument N value and then \edef the body (nothing else will expand because of
8204 % the catcode regime under which the body was input).
8205 %
8206 % If you compile with TeX (not eTeX), and you have macros with 10 or more
8207 % arguments, no macro can have more than 256 arguments (else error).
8208 %
8209 % In case that there are 10 or more arguments we parse again the arguments
8210 % list to set new definitions for the \macarg.BLAH macros corresponding to
8211 % each BLAH argument. It was anyhow needed to parse already once this list
8212 % in order to count the arguments, and as macros with at most 9 arguments
8213 % are by far more frequent than macro with 10 or more arguments, defining
8214 % twice the \macarg.BLAH macros does not cost too much processing power.
8215 \def\parsemmanyargdef@@#1,{%
8216   \if#1;\let\next=\relax
8217   \else 
8218     \let\next=\parsemmanyargdef@@
8219     \edef\tempb{\eatspaces{#1}}%
8220     \expandafter\def\expandafter\tempa
8221        \expandafter{\csname macarg.\tempb\endcsname}%
8222     % Note that we need some extra \noexpand\noexpand, this is because we
8223     % don't want \the  to be expanded in the \parsermacbody  as it uses an
8224     % \xdef .
8225     \expandafter\edef\tempa
8226       {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
8227     \advance\paramno by 1\relax
8228   \fi\next}
8229
8230
8231 \let\endargs@\relax
8232 \let\nil@\relax
8233 \def\nilm@{\nil@}%
8234 \long\def\nillm@{\nil@}%
8235
8236 % This macro is expanded during the Texinfo macro expansion, not during its
8237 % definition.  It gets all the arguments' values and assigns them to macros
8238 % macarg.ARGNAME
8239 %
8240 % #1 is the macro name
8241 % #2 is the list of argument names
8242 % #3 is the list of argument values
8243 \def\getargvals@#1#2#3{%
8244   \def\macargdeflist@{}%
8245   \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
8246   \def\paramlist{#2,\nil@}%
8247   \def\macroname{#1}%
8248   \begingroup
8249   \macroargctxt
8250   \def\argvaluelist{#3,\nil@}%
8251   \def\@tempa{#3}%
8252   \ifx\@tempa\empty
8253     \setemptyargvalues@
8254   \else
8255     \getargvals@@
8256   \fi
8257 }
8258 \def\getargvals@@{%
8259   \ifx\paramlist\nilm@
8260       % Some sanity check needed here that \argvaluelist is also empty.
8261       \ifx\argvaluelist\nillm@
8262       \else
8263         \errhelp = \EMsimple
8264         \errmessage{Too many arguments in macro `\macroname'!}%
8265       \fi
8266       \let\next\macargexpandinbody@
8267   \else
8268     \ifx\argvaluelist\nillm@
8269        % No more arguments values passed to macro.  Set remaining named-arg
8270        % macros to empty.
8271        \let\next\setemptyargvalues@
8272     \else
8273       % pop current arg name into \@tempb
8274       \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
8275       \expandafter\@tempa\expandafter{\paramlist}%
8276        % pop current argument value into \@tempc
8277       \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
8278       \expandafter\@tempa\expandafter{\argvaluelist}%
8279        % Here \@tempb is the current arg name and \@tempc is the current arg value.
8280        % First place the new argument macro definition into \@tempd
8281        \expandafter\macname\expandafter{\@tempc}%
8282        \expandafter\let\csname macarg.\@tempb\endcsname\relax
8283        \expandafter\def\expandafter\@tempe\expandafter{%
8284          \csname macarg.\@tempb\endcsname}%
8285        \edef\@tempd{\long\def\@tempe{\the\macname}}%
8286        \push@\@tempd\macargdeflist@
8287        \let\next\getargvals@@
8288     \fi
8289   \fi
8290   \next
8291 }
8292
8293 \def\push@#1#2{%
8294   \expandafter\expandafter\expandafter\def
8295   \expandafter\expandafter\expandafter#2%
8296   \expandafter\expandafter\expandafter{%
8297   \expandafter#1#2}%
8298 }
8299
8300 % Replace arguments by their values in the macro body, and place the result
8301 % in macro \@tempa.
8302
8303 \def\macvalstoargs@{%
8304   %  To do this we use the property that token registers that are \the'ed
8305   % within an \edef  expand only once. So we are going to place all argument
8306   % values into respective token registers.
8307   %
8308   % First we save the token context, and initialize argument numbering.
8309   \begingroup
8310     \paramno0\relax
8311     % Then, for each argument number #N, we place the corresponding argument
8312     % value into a new token list register \toks#N
8313     \expandafter\putargsintokens@\saveparamlist@,;,%
8314     % Then, we expand the body so that argument are replaced by their
8315     % values. The trick for values not to be expanded themselves is that they
8316     % are within tokens and that tokens expand only once in an \edef .
8317     \edef\@tempc{\csname mac.\macroname .body\endcsname}%
8318     % Now we restore the token stack pointer to free the token list registers
8319     % which we have used, but we make sure that expanded body is saved after
8320     % group.
8321     \expandafter
8322   \endgroup
8323   \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
8324   }
8325
8326 % Define the named-macro outside of this group and then close this group. 
8327
8328 \def\macargexpandinbody@{% 
8329   \expandafter
8330   \endgroup
8331   \macargdeflist@
8332   % First the replace in body the macro arguments by their values, the result
8333   % is in \@tempa .
8334   \macvalstoargs@
8335   % Then we point at the \norecurse or \gobble (for recursive) macro value
8336   % with \@tempb .
8337   \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
8338   % Depending on whether it is recursive or not, we need some tailing
8339   % \egroup .
8340   \ifx\@tempb\gobble
8341      \let\@tempc\relax
8342   \else
8343      \let\@tempc\egroup
8344   \fi
8345   % And now we do the real job:
8346   \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
8347   \@tempd
8348 }
8349
8350 \def\putargsintokens@#1,{%
8351   \if#1;\let\next\relax
8352   \else
8353     \let\next\putargsintokens@
8354     % First we allocate the new token list register, and give it a temporary
8355     % alias \@tempb .
8356     \toksdef\@tempb\the\paramno
8357     % Then we place the argument value into that token list register.
8358     \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
8359     \expandafter\@tempb\expandafter{\@tempa}%
8360     \advance\paramno by 1\relax
8361   \fi
8362   \next
8363 }
8364
8365 % Trailing missing arguments are set to empty.
8366
8367 \def\setemptyargvalues@{%
8368   \ifx\paramlist\nilm@
8369     \let\next\macargexpandinbody@
8370   \else
8371     \expandafter\setemptyargvaluesparser@\paramlist\endargs@
8372     \let\next\setemptyargvalues@
8373   \fi
8374   \next
8375 }
8376
8377 \def\setemptyargvaluesparser@#1,#2\endargs@{%
8378   \expandafter\def\expandafter\@tempa\expandafter{%
8379     \expandafter\def\csname macarg.#1\endcsname{}}%
8380   \push@\@tempa\macargdeflist@
8381   \def\paramlist{#2}%
8382 }
8383
8384 % #1 is the element target macro
8385 % #2 is the list macro
8386 % #3,#4\endargs@ is the list value
8387 \def\pop@#1#2#3,#4\endargs@{%
8388    \def#1{#3}%
8389    \def#2{#4}%
8390 }
8391 \long\def\longpop@#1#2#3,#4\endargs@{%
8392    \long\def#1{#3}%
8393    \long\def#2{#4}%
8394 }
8395
8396
8397 %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
8398
8399
8400 % This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
8401 %    \macrobody has the body of the macro in it, with placeholders for
8402 % its parameters, looking like "\xeatspaces{\hash 1}".
8403 %    \paramno is the number of parameters
8404 %    \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
8405 % There are eight cases: recursive and nonrecursive macros of zero, one,
8406 % up to nine, and many arguments.
8407 % \xdef is used so that macro definitions will survive the file
8408 % they're defined in: @include reads the file inside a group.
8409 %
8410 \def\defmacro{%
8411   \let\hash=##% convert placeholders to macro parameter chars
8412   \ifnum\paramno=1
8413     \def\xeatspaces##1{##1}%
8414     % This removes the pair of braces around the argument.  We don't
8415     % use \eatspaces, because this can cause ends of lines to be lost
8416     % when the argument to \eatspaces is read, leading to line-based
8417     % commands like "@itemize" not being read correctly.
8418   \else
8419     \let\xeatspaces\relax % suppress expansion
8420   \fi
8421   \ifrecursive   %%%%%%%%%%%%%% Recursive %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8422     \ifcase\paramno
8423     % 0
8424       \expandafter\xdef\csname\the\macname\endcsname{%
8425         \noexpand\scanmacro{\macrobody}}%
8426     \or % 1
8427       \expandafter\xdef\csname\the\macname\endcsname{%
8428          \bgroup
8429          \noexpand\braceorline
8430          \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8431       \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8432         \egroup
8433         \noexpand\scanmacro{\macrobody}%
8434         }%
8435     \else
8436       \ifnum\paramno<10\relax % at most 9
8437         % See non-recursive section below for comments
8438         \expandafter\xdef\csname\the\macname\endcsname{%
8439           \bgroup
8440           \noexpand\expandafter
8441           \noexpand\macroargctxt
8442           \noexpand\expandafter
8443           \expandafter\noexpand\csname\the\macname @@\endcsname}%
8444         \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8445             \noexpand\passargtomacro
8446             \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8447         \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8448             \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8449         \expandafter\expandafter
8450         \expandafter\xdef
8451         \expandafter\expandafter
8452           \csname\the\macname @@@@\endcsname\paramlist{%
8453             \egroup\noexpand\scanmacro{\macrobody}}%
8454       \else % 10 or more
8455         \expandafter\xdef\csname\the\macname\endcsname{%
8456           \noexpand\getargvals@{\the\macname}{\argl}%
8457         }%    
8458         \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8459         \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
8460       \fi
8461     \fi
8462   \else  %%%%%%%%%%%%%%%%%%%%%% Non-recursive %%%%%%%%%%%%%%%%%%%%%%%%%%
8463     \ifcase\paramno
8464     % 0
8465       \expandafter\xdef\csname\the\macname\endcsname{%
8466         \noexpand\scanmacro{\macrobody}}%
8467     \or % 1
8468       \expandafter\xdef\csname\the\macname\endcsname{%
8469          \bgroup
8470          \noexpand\braceorline
8471          \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8472       \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8473         \egroup
8474         \noexpand\scanmacro{\macrobody}%
8475         }%
8476     \else % at most 9
8477       \ifnum\paramno<10\relax
8478         % @MACNAME sets the context for reading the macro argument
8479         % @MACNAME@@ gets the argument, processes backslashes and appends a 
8480         % comma.
8481         % @MACNAME@@@ removes braces surrounding the argument list.
8482         % @MACNAME@@@@ scans the macro body with arguments substituted.
8483         \expandafter\xdef\csname\the\macname\endcsname{%
8484           \bgroup
8485           \noexpand\expandafter  % This \expandafter skip any spaces after the
8486           \noexpand\macroargctxt % macro before we change the catcode of space.
8487           \noexpand\expandafter
8488           \expandafter\noexpand\csname\the\macname @@\endcsname}%
8489         \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8490             \noexpand\passargtomacro
8491             \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8492         \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8493             \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8494         \expandafter\expandafter
8495         \expandafter\xdef
8496         \expandafter\expandafter
8497           \csname\the\macname @@@@\endcsname\paramlist{%
8498             \egroup\noexpand\scanmacro{\macrobody}}%
8499       \else % 10 or more:
8500         \expandafter\xdef\csname\the\macname\endcsname{%
8501           \noexpand\getargvals@{\the\macname}{\argl}%
8502         }%
8503         \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8504         \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse
8505       \fi
8506     \fi
8507   \fi}
8508
8509 \catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
8510
8511 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
8512
8513
8514 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8515 %
8516 {\catcode`\@=0 \catcode`\\=13  % We need to manipulate \ so use @ as escape
8517 @catcode`@_=11  % private names
8518 @catcode`@!=11  % used as argument separator
8519
8520 % \passargtomacro#1#2 -
8521 % Call #1 with a list of tokens #2, with any doubled backslashes in #2
8522 % compressed to one.
8523 %
8524 % This implementation works by expansion, and not execution (so we cannot use 
8525 % \def or similar).  This reduces the risk of this failing in contexts where 
8526 % complete expansion is done with no execution (for example, in writing out to 
8527 % an auxiliary file for an index entry).
8528
8529 % State is kept in the input stream: the argument passed to
8530 % @look_ahead, @gobble_and_check_finish and @add_segment is
8531 %
8532 % THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN  (... rest of input)
8533 %
8534 % where:
8535 % THE_MACRO - name of the macro we want to call
8536 % ARG_RESULT - argument list we build to pass to that macro
8537 % PENDING_BS - either a backslash or nothing
8538 % NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
8539
8540 @gdef@passargtomacro#1#2{%
8541   @add_segment #1!{}@relax#2\@_finish\%
8542 }
8543 @gdef@_finish{@_finishx} @global@let@_finishx@relax
8544
8545 % #1 - THE_MACRO ARG_RESULT
8546 % #2 - PENDING_BS
8547 % #3 - NEXT_TOKEN
8548 % #4 used to look ahead
8549 %
8550 % If the next token is not a backslash, process the rest of the argument; 
8551 % otherwise, remove the next token.
8552 @gdef@look_ahead#1!#2#3#4{%
8553   @ifx#4\%
8554    @expandafter@gobble_and_check_finish 
8555   @else
8556    @expandafter@add_segment
8557   @fi#1!{#2}#4#4%
8558 }
8559
8560 % #1 - THE_MACRO ARG_RESULT
8561 % #2 - PENDING_BS
8562 % #3 - NEXT_TOKEN
8563 % #4 should be a backslash, which is gobbled.
8564 % #5 looks ahead
8565 %
8566 % Double backslash found.  Add a single backslash, and look ahead.
8567 @gdef@gobble_and_check_finish#1!#2#3#4#5{%
8568   @add_segment#1\!{}#5#5%
8569 }
8570
8571 @gdef@is_fi{@fi}
8572
8573 % #1 - THE_MACRO ARG_RESULT
8574 % #2 - PENDING_BS
8575 % #3 - NEXT_TOKEN
8576 % #4 is input stream until next backslash
8577 %
8578 % Input stream is either at the start of the argument, or just after a 
8579 % backslash sequence, either a lone backslash, or a doubled backslash.  
8580 % NEXT_TOKEN contains the first token in the input stream: if it is \finish, 
8581 % finish; otherwise, append to ARG_RESULT the segment of the argument up until
8582 % the next backslash.  PENDING_BACKSLASH contains a backslash to represent
8583 % a backslash just before the start of the input stream that has not been
8584 % added to ARG_RESULT.
8585 @gdef@add_segment#1!#2#3#4\{%
8586 @ifx#3@_finish
8587   @call_the_macro#1!%
8588 @else
8589   % append the pending backslash to the result, followed by the next segment
8590   @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
8591   % this @fi is discarded by @look_ahead.
8592   % we can't get rid of it with \expandafter because we don't know how 
8593   % long #4 is.
8594 }
8595
8596 % #1 - THE_MACRO
8597 % #2 - ARG_RESULT
8598 % #3 discards the res of the conditional in @add_segment, and @is_fi ends the 
8599 % conditional.
8600 @gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
8601
8602 }
8603 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8604
8605 % \braceorline MAC is used for a one-argument macro MAC.  It checks
8606 % whether the next non-whitespace character is a {.  It sets the context
8607 % for reading the argument (slightly different in the two cases).  Then,
8608 % to read the argument, in the whole-line case, it then calls the regular
8609 % \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
8610
8611 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
8612 \def\braceorlinexxx{%
8613   \ifx\nchar\bgroup
8614     \macroargctxt
8615     \expandafter\passargtomacro
8616   \else
8617     \macrolineargctxt\expandafter\parsearg
8618   \fi \macnamexxx}
8619
8620
8621 % @alias.
8622 % We need some trickery to remove the optional spaces around the equal
8623 % sign.  Make them active and then expand them all to nothing.
8624 %
8625 \def\alias{\parseargusing\obeyspaces\aliasxxx}
8626 \def\aliasxxx #1{\aliasyyy#1\relax}
8627 \def\aliasyyy #1=#2\relax{%
8628   {%
8629     \expandafter\let\obeyedspace=\empty
8630     \addtomacrolist{#1}%
8631     \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
8632   }%
8633   \next
8634 }
8635
8636
8637 \message{cross references,}
8638
8639 \newwrite\auxfile
8640 \newif\ifhavexrefs    % True if xref values are known.
8641 \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
8642
8643 % @inforef is relatively simple.
8644 \def\inforef #1{\inforefzzz #1,,,,**}
8645 \def\inforefzzz #1,#2,#3,#4**{%
8646   \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
8647   node \samp{\ignorespaces#1{}}}
8648
8649 % @node's only job in TeX is to define \lastnode, which is used in
8650 % cross-references.  The @node line might or might not have commas, and
8651 % might or might not have spaces before the first comma, like:
8652 % @node foo , bar , ...
8653 % We don't want such trailing spaces in the node name.
8654 %
8655 \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
8656 %
8657 % also remove a trailing comma, in case of something like this:
8658 % @node Help-Cross,  ,  , Cross-refs
8659 \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
8660 \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
8661
8662 \let\nwnode=\node
8663 \let\lastnode=\empty
8664
8665 % Write a cross-reference definition for the current node.  #1 is the
8666 % type (Ynumbered, Yappendix, Ynothing).
8667 %
8668 \def\donoderef#1{%
8669   \ifx\lastnode\empty\else
8670     \setref{\lastnode}{#1}%
8671     \global\let\lastnode=\empty
8672   \fi
8673 }
8674
8675 % @anchor{NAME} -- define xref target at arbitrary point.
8676 %
8677 \newcount\savesfregister
8678 %
8679 \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
8680 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
8681 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
8682
8683 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
8684 % anchor), which consists of three parts:
8685 % 1) NAME-title - the current sectioning name taken from \lastsection,
8686 %                 or the anchor name.
8687 % 2) NAME-snt   - section number and type, passed as the SNT arg, or
8688 %                 empty for anchors.
8689 % 3) NAME-pg    - the page number.
8690 %
8691 % This is called from \donoderef, \anchor, and \dofloat.  In the case of
8692 % floats, there is an additional part, which is not written here:
8693 % 4) NAME-lof   - the text as it should appear in a @listoffloats.
8694 %
8695 \def\setref#1#2{%
8696   \pdfmkdest{#1}%
8697   \iflinks
8698     {%
8699       \requireauxfile
8700       \atdummies  % preserve commands, but don't expand them
8701       \edef\writexrdef##1##2{%
8702         \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
8703           ##1}{##2}}% these are parameters of \writexrdef
8704       }%
8705       \toks0 = \expandafter{\lastsection}%
8706       \immediate \writexrdef{title}{\the\toks0 }%
8707       \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
8708       \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
8709     }%
8710   \fi
8711 }
8712
8713 % @xrefautosectiontitle on|off says whether @section(ing) names are used
8714 % automatically in xrefs, if the third arg is not explicitly specified.
8715 % This was provided as a "secret" @set xref-automatic-section-title
8716 % variable, now it's official.
8717
8718 \parseargdef\xrefautomaticsectiontitle{%
8719   \def\temp{#1}%
8720   \ifx\temp\onword
8721     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8722       = \empty
8723   \else\ifx\temp\offword
8724     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8725       = \relax
8726   \else
8727     \errhelp = \EMsimple
8728     \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
8729                 must be on|off}%
8730   \fi\fi
8731 }
8732
8733\f
8734 % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
8735 % the node name, #2 the name of the Info cross-reference, #3 the printed
8736 % node name, #4 the name of the Info file, #5 the name of the printed
8737 % manual.  All but the node name can be omitted.
8738 %
8739 \def\pxref{\putwordsee{} \xrefXX}
8740 \def\xref{\putwordSee{} \xrefXX}
8741 \def\ref{\xrefXX}
8742
8743 \def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
8744 \def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
8745 %
8746 \newbox\toprefbox
8747 \newbox\printedrefnamebox
8748 \newbox\infofilenamebox
8749 \newbox\printedmanualbox
8750 %
8751 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
8752   \unsepspaces
8753   %
8754   % Get args without leading/trailing spaces.
8755   \def\printedrefname{\ignorespaces #3}%
8756   \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
8757   %
8758   \def\infofilename{\ignorespaces #4}%
8759   \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
8760   %
8761   \def\printedmanual{\ignorespaces #5}%
8762   \setbox\printedmanualbox  = \hbox{\printedmanual\unskip}%
8763   %
8764   % If the printed reference name (arg #3) was not explicitly given in
8765   % the @xref, figure out what we want to use.
8766   \ifdim \wd\printedrefnamebox = 0pt
8767     % No printed node name was explicitly given.
8768     \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
8769       % Not auto section-title: use node name inside the square brackets.
8770       \def\printedrefname{\ignorespaces #1}%
8771     \else
8772       % Auto section-title: use chapter/section title inside
8773       % the square brackets if we have it.
8774       \ifdim \wd\printedmanualbox > 0pt
8775         % It is in another manual, so we don't have it; use node name.
8776         \def\printedrefname{\ignorespaces #1}%
8777       \else
8778         \ifhavexrefs
8779           % We (should) know the real title if we have the xref values.
8780           \def\printedrefname{\refx{#1-title}{}}%
8781         \else
8782           % Otherwise just copy the Info node name.
8783           \def\printedrefname{\ignorespaces #1}%
8784         \fi%
8785       \fi
8786     \fi
8787   \fi
8788   %
8789   % Make link in pdf output.
8790   \ifpdf
8791     % For pdfTeX and LuaTeX
8792     {\indexnofonts
8793      \turnoffactive
8794      \makevalueexpandable
8795      % This expands tokens, so do it after making catcode changes, so _
8796      % etc. don't get their TeX definitions.  This ignores all spaces in
8797      % #4, including (wrongly) those in the middle of the filename.
8798      \getfilename{#4}%
8799      %
8800      % This (wrongly) does not take account of leading or trailing
8801      % spaces in #1, which should be ignored.
8802      \edef\pdfxrefdest{#1}%
8803      \ifx\pdfxrefdest\empty
8804        \def\pdfxrefdest{Top}% no empty targets
8805      \else
8806        \txiescapepdf\pdfxrefdest  % escape PDF special chars
8807      \fi
8808      %
8809      \leavevmode
8810      \startlink attr{/Border [0 0 0]}%
8811      \ifnum\filenamelength>0
8812        goto file{\the\filename.pdf} name{\pdfxrefdest}%
8813      \else
8814        goto name{\pdfmkpgn{\pdfxrefdest}}%
8815      \fi
8816     }%
8817     \setcolor{\linkcolor}%
8818   \else
8819     \ifx\XeTeXrevision\thisisundefined
8820     \else
8821       % For XeTeX
8822       {\indexnofonts
8823        \turnoffactive
8824        \makevalueexpandable
8825        % This expands tokens, so do it after making catcode changes, so _
8826        % etc. don't get their TeX definitions.  This ignores all spaces in
8827        % #4, including (wrongly) those in the middle of the filename.
8828        \getfilename{#4}%
8829        %
8830        % This (wrongly) does not take account of leading or trailing
8831        % spaces in #1, which should be ignored.
8832        \iftxiuseunicodedestname
8833          \def\pdfxrefdest{#1}% Pass through Unicode characters.
8834        \else
8835          \edef\pdfxrefdest{#1}% Replace Unicode characters to ASCII.
8836        \fi
8837        \ifx\pdfxrefdest\empty
8838          \def\pdfxrefdest{Top}% no empty targets
8839        \else
8840          \txiescapepdf\pdfxrefdest  % escape PDF special chars
8841        \fi
8842        %
8843        \leavevmode
8844        \ifnum\filenamelength>0
8845          % By the default settings,
8846          % XeTeX (xdvipdfmx) replaces link destination names with integers.
8847          % In this case, the replaced destination names of
8848          % remote PDF cannot be known. In order to avoid replacement,
8849          % you can use commandline option `-C 0x0010' for xdvipdfmx.
8850          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8851            << /S /GoToR /F (\the\filename.pdf) /D (name\pdfxrefdest) >> >>}%
8852        \else
8853          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8854            << /S /GoTo /D (name\pdfxrefdest) >> >>}%
8855        \fi
8856       }%
8857       \setcolor{\linkcolor}%
8858     \fi
8859   \fi
8860   {%
8861     % Have to otherify everything special to allow the \csname to
8862     % include an _ in the xref name, etc.
8863     \indexnofonts
8864     \turnoffactive
8865     \expandafter\global\expandafter\let\expandafter\Xthisreftitle
8866       \csname XR#1-title\endcsname
8867   }%
8868   %
8869   % Float references are printed completely differently: "Figure 1.2"
8870   % instead of "[somenode], p.3".  \iffloat distinguishes them by
8871   % \Xthisreftitle being set to a magic string.
8872   \iffloat\Xthisreftitle
8873     % If the user specified the print name (third arg) to the ref,
8874     % print it instead of our usual "Figure 1.2".
8875     \ifdim\wd\printedrefnamebox = 0pt
8876       \refx{#1-snt}{}%
8877     \else
8878       \printedrefname
8879     \fi
8880     %
8881     % If the user also gave the printed manual name (fifth arg), append
8882     % "in MANUALNAME".
8883     \ifdim \wd\printedmanualbox > 0pt
8884       \space \putwordin{} \cite{\printedmanual}%
8885     \fi
8886   \else
8887     % node/anchor (non-float) references.
8888     % 
8889     % If we use \unhbox to print the node names, TeX does not insert
8890     % empty discretionaries after hyphens, which means that it will not
8891     % find a line break at a hyphen in a node names.  Since some manuals
8892     % are best written with fairly long node names, containing hyphens,
8893     % this is a loss.  Therefore, we give the text of the node name
8894     % again, so it is as if TeX is seeing it for the first time.
8895     % 
8896     \ifdim \wd\printedmanualbox > 0pt
8897       % Cross-manual reference with a printed manual name.
8898       % 
8899       \crossmanualxref{\cite{\printedmanual\unskip}}%
8900     %
8901     \else\ifdim \wd\infofilenamebox > 0pt
8902       % Cross-manual reference with only an info filename (arg 4), no
8903       % printed manual name (arg 5).  This is essentially the same as
8904       % the case above; we output the filename, since we have nothing else.
8905       % 
8906       \crossmanualxref{\code{\infofilename\unskip}}%
8907     %
8908     \else
8909       % Reference within this manual.
8910       %
8911       % _ (for example) has to be the character _ for the purposes of the
8912       % control sequence corresponding to the node, but it has to expand
8913       % into the usual \leavevmode...\vrule stuff for purposes of
8914       % printing. So we \turnoffactive for the \refx-snt, back on for the
8915       % printing, back off for the \refx-pg.
8916       {\turnoffactive
8917        % Only output a following space if the -snt ref is nonempty; for
8918        % @unnumbered and @anchor, it won't be.
8919        \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
8920        \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
8921       }%
8922       % output the `[mynode]' via the macro below so it can be overridden.
8923       \xrefprintnodename\printedrefname
8924       %
8925       % But we always want a comma and a space:
8926       ,\space
8927       %
8928       % output the `page 3'.
8929       \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
8930       % Add a , if xref followed by a space
8931       \if\space\noexpand\tokenafterxref ,%
8932       \else\ifx\        \tokenafterxref ,% @TAB
8933       \else\ifx\*\tokenafterxref ,%   @*
8934       \else\ifx\ \tokenafterxref ,%   @SPACE
8935       \else\ifx\
8936                 \tokenafterxref ,%    @NL
8937       \else\ifx\tie\tokenafterxref ,% @tie
8938       \fi\fi\fi\fi\fi\fi
8939     \fi\fi
8940   \fi
8941   \endlink
8942 \endgroup}
8943
8944 % Output a cross-manual xref to #1.  Used just above (twice).
8945
8946 % Only include the text "Section ``foo'' in" if the foo is neither
8947 % missing or Top.  Thus, @xref{,,,foo,The Foo Manual} outputs simply
8948 % "see The Foo Manual", the idea being to refer to the whole manual.
8949
8950 % But, this being TeX, we can't easily compare our node name against the
8951 % string "Top" while ignoring the possible spaces before and after in
8952 % the input.  By adding the arbitrary 7sp below, we make it much less
8953 % likely that a real node name would have the same width as "Top" (e.g.,
8954 % in a monospaced font).  Hopefully it will never happen in practice.
8955
8956 % For the same basic reason, we retypeset the "Top" at every
8957 % reference, since the current font is indeterminate.
8958
8959 \def\crossmanualxref#1{%
8960   \setbox\toprefbox = \hbox{Top\kern7sp}%
8961   \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
8962   \ifdim \wd2 > 7sp  % nonempty?
8963     \ifdim \wd2 = \wd\toprefbox \else  % same as Top?
8964       \putwordSection{} ``\printedrefname'' \putwordin{}\space
8965     \fi
8966   \fi
8967   #1%
8968 }
8969
8970 % This macro is called from \xrefX for the `[nodename]' part of xref
8971 % output.  It's a separate macro only so it can be changed more easily,
8972 % since square brackets don't work well in some documents.  Particularly
8973 % one that Bob is working on :).
8974 %
8975 \def\xrefprintnodename#1{[#1]}
8976
8977 % Things referred to by \setref.
8978 %
8979 \def\Ynothing{}
8980 \def\Yomitfromtoc{}
8981 \def\Ynumbered{%
8982   \ifnum\secno=0
8983     \putwordChapter@tie \the\chapno
8984   \else \ifnum\subsecno=0
8985     \putwordSection@tie \the\chapno.\the\secno
8986   \else \ifnum\subsubsecno=0
8987     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
8988   \else
8989     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
8990   \fi\fi\fi
8991 }
8992 \def\Yappendix{%
8993   \ifnum\secno=0
8994      \putwordAppendix@tie @char\the\appendixno{}%
8995   \else \ifnum\subsecno=0
8996      \putwordSection@tie @char\the\appendixno.\the\secno
8997   \else \ifnum\subsubsecno=0
8998     \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
8999   \else
9000     \putwordSection@tie
9001       @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
9002   \fi\fi\fi
9003 }
9004
9005 % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
9006 % If its value is nonempty, SUFFIX is output afterward.
9007 %
9008 \def\refx#1#2{%
9009   \requireauxfile
9010   {%
9011     \indexnofonts
9012     \otherbackslash
9013     \expandafter\global\expandafter\let\expandafter\thisrefX
9014       \csname XR#1\endcsname
9015   }%
9016   \ifx\thisrefX\relax
9017     % If not defined, say something at least.
9018     \angleleft un\-de\-fined\angleright
9019     \iflinks
9020       \ifhavexrefs
9021         {\toks0 = {#1}% avoid expansion of possibly-complex value
9022          \message{\linenumber Undefined cross reference `\the\toks0'.}}%
9023       \else
9024         \ifwarnedxrefs\else
9025           \global\warnedxrefstrue
9026           \message{Cross reference values unknown; you must run TeX again.}%
9027         \fi
9028       \fi
9029     \fi
9030   \else
9031     % It's defined, so just use it.
9032     \thisrefX
9033   \fi
9034   #2% Output the suffix in any case.
9035 }
9036
9037 % This is the macro invoked by entries in the aux file.  Usually it's
9038 % just a \def (we prepend XR to the control sequence name to avoid
9039 % collisions).  But if this is a float type, we have more work to do.
9040 %
9041 \def\xrdef#1#2{%
9042   {% The node name might contain 8-bit characters, which in our current
9043    % implementation are changed to commands like @'e.  Don't let these
9044    % mess up the control sequence name.
9045     \indexnofonts
9046     \turnoffactive
9047     \xdef\safexrefname{#1}%
9048   }%
9049   %
9050   \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref
9051   %
9052   % Was that xref control sequence that we just defined for a float?
9053   \expandafter\iffloat\csname XR\safexrefname\endcsname
9054     % it was a float, and we have the (safe) float type in \iffloattype.
9055     \expandafter\let\expandafter\floatlist
9056       \csname floatlist\iffloattype\endcsname
9057     %
9058     % Is this the first time we've seen this float type?
9059     \expandafter\ifx\floatlist\relax
9060       \toks0 = {\do}% yes, so just \do
9061     \else
9062       % had it before, so preserve previous elements in list.
9063       \toks0 = \expandafter{\floatlist\do}%
9064     \fi
9065     %
9066     % Remember this xref in the control sequence \floatlistFLOATTYPE,
9067     % for later use in \listoffloats.
9068     \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
9069       {\safexrefname}}%
9070   \fi
9071 }
9072
9073 % If working on a large document in chapters, it is convenient to
9074 % be able to disable indexing, cross-referencing, and contents, for test runs.
9075 % This is done with @novalidate at the beginning of the file.
9076 %
9077 \newif\iflinks \linkstrue % by default we want the aux files.
9078 \let\novalidate = \linksfalse
9079
9080 % Used when writing to the aux file, or when using data from it.
9081 \def\requireauxfile{%
9082   \iflinks
9083     \tryauxfile
9084     % Open the new aux file.  TeX will close it automatically at exit.
9085     \immediate\openout\auxfile=\jobname.aux
9086   \fi
9087   \global\let\requireauxfile=\relax   % Only do this once.
9088 }
9089
9090 % Read the last existing aux file, if any.  No error if none exists.
9091 %
9092 \def\tryauxfile{%
9093   \openin 1 \jobname.aux
9094   \ifeof 1 \else
9095     \readdatafile{aux}%
9096     \global\havexrefstrue
9097   \fi
9098   \closein 1
9099 }
9100
9101 \def\setupdatafile{%
9102   \catcode`\^^@=\other
9103   \catcode`\^^A=\other
9104   \catcode`\^^B=\other
9105   \catcode`\^^C=\other
9106   \catcode`\^^D=\other
9107   \catcode`\^^E=\other
9108   \catcode`\^^F=\other
9109   \catcode`\^^G=\other
9110   \catcode`\^^H=\other
9111   \catcode`\^^K=\other
9112   \catcode`\^^L=\other
9113   \catcode`\^^N=\other
9114   \catcode`\^^P=\other
9115   \catcode`\^^Q=\other
9116   \catcode`\^^R=\other
9117   \catcode`\^^S=\other
9118   \catcode`\^^T=\other
9119   \catcode`\^^U=\other
9120   \catcode`\^^V=\other
9121   \catcode`\^^W=\other
9122   \catcode`\^^X=\other
9123   \catcode`\^^Z=\other
9124   \catcode`\^^[=\other
9125   \catcode`\^^\=\other
9126   \catcode`\^^]=\other
9127   \catcode`\^^^=\other
9128   \catcode`\^^_=\other
9129   % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
9130   % in xref tags, i.e., node names.  But since ^^e4 notation isn't
9131   % supported in the main text, it doesn't seem desirable.  Furthermore,
9132   % that is not enough: for node names that actually contain a ^
9133   % character, we would end up writing a line like this: 'xrdef {'hat
9134   % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
9135   % argument, and \hat is not an expandable control sequence.  It could
9136   % all be worked out, but why?  Either we support ^^ or we don't.
9137   %
9138   % The other change necessary for this was to define \auxhat:
9139   % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
9140   % and then to call \auxhat in \setq.
9141   %
9142   \catcode`\^=\other
9143   %
9144   % Special characters.  Should be turned off anyway, but...
9145   \catcode`\~=\other
9146   \catcode`\[=\other
9147   \catcode`\]=\other
9148   \catcode`\"=\other
9149   \catcode`\_=\other
9150   \catcode`\|=\other
9151   \catcode`\<=\other
9152   \catcode`\>=\other
9153   \catcode`\$=\other
9154   \catcode`\#=\other
9155   \catcode`\&=\other
9156   \catcode`\%=\other
9157   \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
9158   %
9159   % This is to support \ in node names and titles, since the \
9160   % characters end up in a \csname.  It's easier than
9161   % leaving it active and making its active definition an actual \
9162   % character.  What I don't understand is why it works in the *value*
9163   % of the xrdef.  Seems like it should be a catcode12 \, and that
9164   % should not typeset properly.  But it works, so I'm moving on for
9165   % now.  --karl, 15jan04.
9166   \catcode`\\=\other
9167   %
9168   % @ is our escape character in .aux files, and we need braces.
9169   \catcode`\{=1
9170   \catcode`\}=2
9171   \catcode`\@=0
9172 }
9173
9174 \def\readdatafile#1{%
9175 \begingroup
9176   \setupdatafile
9177   \input\jobname.#1
9178 \endgroup}
9179
9180
9181 \message{insertions,}
9182 % including footnotes.
9183
9184 \newcount \footnoteno
9185
9186 % The trailing space in the following definition for supereject is
9187 % vital for proper filling; pages come out unaligned when you do a
9188 % pagealignmacro call if that space before the closing brace is
9189 % removed. (Generally, numeric constants should always be followed by a
9190 % space to prevent strange expansion errors.)
9191 \def\supereject{\par\penalty -20000\footnoteno =0 }
9192
9193 % @footnotestyle is meaningful for Info output only.
9194 \let\footnotestyle=\comment
9195
9196 {\catcode `\@=11
9197 %
9198 % Auto-number footnotes.  Otherwise like plain.
9199 \gdef\footnote{%
9200   \global\advance\footnoteno by \@ne
9201   \edef\thisfootno{$^{\the\footnoteno}$}%
9202   %
9203   % In case the footnote comes at the end of a sentence, preserve the
9204   % extra spacing after we do the footnote number.
9205   \let\@sf\empty
9206   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9207   %
9208   % Remove inadvertent blank space before typesetting the footnote number.
9209   \unskip
9210   \thisfootno\@sf
9211   \dofootnote
9212 }%
9213
9214 % Don't bother with the trickery in plain.tex to not require the
9215 % footnote text as a parameter.  Our footnotes don't need to be so general.
9216 %
9217 % Oh yes, they do; otherwise, @ifset (and anything else that uses
9218 % \parseargline) fails inside footnotes because the tokens are fixed when
9219 % the footnote is read.  --karl, 16nov96.
9220 %
9221 \gdef\dofootnote{%
9222   \insert\footins\bgroup
9223   %
9224   % Nested footnotes are not supported in TeX, that would take a lot
9225   % more work.  (\startsavinginserts does not suffice.)
9226   \let\footnote=\errfootnotenest
9227   %
9228   % We want to typeset this text as a normal paragraph, even if the
9229   % footnote reference occurs in (for example) a display environment.
9230   % So reset some parameters.
9231   \hsize=\txipagewidth
9232   \interlinepenalty\interfootnotelinepenalty
9233   \splittopskip\ht\strutbox % top baseline for broken footnotes
9234   \splitmaxdepth\dp\strutbox
9235   \floatingpenalty\@MM
9236   \leftskip\z@skip
9237   \rightskip\z@skip
9238   \spaceskip\z@skip
9239   \xspaceskip\z@skip
9240   \parindent\defaultparindent
9241   %
9242   \smallfonts \rm
9243   %
9244   % Because we use hanging indentation in footnotes, a @noindent appears
9245   % to exdent this text, so make it be a no-op.  makeinfo does not use
9246   % hanging indentation so @noindent can still be needed within footnote
9247   % text after an @example or the like (not that this is good style).
9248   \let\noindent = \relax
9249   %
9250   % Hang the footnote text off the number.  Use \everypar in case the
9251   % footnote extends for more than one paragraph.
9252   \everypar = {\hang}%
9253   \textindent{\thisfootno}%
9254   %
9255   % Don't crash into the line above the footnote text.  Since this
9256   % expands into a box, it must come within the paragraph, lest it
9257   % provide a place where TeX can split the footnote.
9258   \footstrut
9259   %
9260   % Invoke rest of plain TeX footnote routine.
9261   \futurelet\next\fo@t
9262 }
9263 }%end \catcode `\@=11
9264
9265 \def\errfootnotenest{%
9266   \errhelp=\EMsimple
9267   \errmessage{Nested footnotes not supported in texinfo.tex,
9268     even though they work in makeinfo; sorry}
9269 }
9270
9271 \def\errfootnoteheading{%
9272   \errhelp=\EMsimple
9273   \errmessage{Footnotes in chapters, sections, etc., are not supported}
9274 }
9275
9276 % In case a @footnote appears in a vbox, save the footnote text and create
9277 % the real \insert just after the vbox finished.  Otherwise, the insertion
9278 % would be lost.
9279 % Similarly, if a @footnote appears inside an alignment, save the footnote
9280 % text to a box and make the \insert when a row of the table is finished.
9281 % And the same can be done for other insert classes.  --kasal, 16nov03.
9282 %
9283 % Replace the \insert primitive by a cheating macro.
9284 % Deeper inside, just make sure that the saved insertions are not spilled
9285 % out prematurely.
9286 %
9287 \def\startsavinginserts{%
9288   \ifx \insert\ptexinsert
9289     \let\insert\saveinsert
9290   \else
9291     \let\checkinserts\relax
9292   \fi
9293 }
9294
9295 % This \insert replacement works for both \insert\footins{foo} and
9296 % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9297 %
9298 \def\saveinsert#1{%
9299   \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9300   \afterassignment\next
9301   % swallow the left brace
9302   \let\temp =
9303 }
9304 \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9305 \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9306
9307 \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9308
9309 \def\placesaveins#1{%
9310   \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9311     {\box#1}%
9312 }
9313
9314 % eat @SAVE -- beware, all of them have catcode \other:
9315 {
9316   \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials  %  ;-)
9317   \gdef\gobblesave @SAVE{}
9318 }
9319
9320 % initialization:
9321 \def\newsaveins #1{%
9322   \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9323   \next
9324 }
9325 \def\newsaveinsX #1{%
9326   \csname newbox\endcsname #1%
9327   \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9328     \checksaveins #1}%
9329 }
9330
9331 % initialize:
9332 \let\checkinserts\empty
9333 \newsaveins\footins
9334 \newsaveins\margin
9335
9336
9337 % @image.  We use the macros from epsf.tex to support this.
9338 % If epsf.tex is not installed and @image is used, we complain.
9339 %
9340 % Check for and read epsf.tex up front.  If we read it only at @image
9341 % time, we might be inside a group, and then its definitions would get
9342 % undone and the next image would fail.
9343 \openin 1 = epsf.tex
9344 \ifeof 1 \else
9345   % Do not bother showing banner with epsf.tex v2.7k (available in
9346   % doc/epsf.tex and on ctan).
9347   \def\epsfannounce{\toks0 = }%
9348   \input epsf.tex
9349 \fi
9350 \closein 1
9351 %
9352 % We will only complain once about lack of epsf.tex.
9353 \newif\ifwarnednoepsf
9354 \newhelp\noepsfhelp{epsf.tex must be installed for images to
9355   work.  It is also included in the Texinfo distribution, or you can get
9356   it from ftp://tug.org/tex/epsf.tex.}
9357 %
9358 \def\image#1{%
9359   \ifx\epsfbox\thisisundefined
9360     \ifwarnednoepsf \else
9361       \errhelp = \noepsfhelp
9362       \errmessage{epsf.tex not found, images will be ignored}%
9363       \global\warnednoepsftrue
9364     \fi
9365   \else
9366     \imagexxx #1,,,,,\finish
9367   \fi
9368 }
9369 %
9370 % Arguments to @image:
9371 % #1 is (mandatory) image filename; we tack on .eps extension.
9372 % #2 is (optional) width, #3 is (optional) height.
9373 % #4 is (ignored optional) html alt text.
9374 % #5 is (ignored optional) extension.
9375 % #6 is just the usual extra ignored arg for parsing stuff.
9376 \newif\ifimagevmode
9377 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
9378   \catcode`\^^M = 5     % in case we're inside an example
9379   \normalturnoffactive  % allow _ et al. in names
9380   \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
9381   % If the image is by itself, center it.
9382   \ifvmode
9383     \imagevmodetrue
9384   \else \ifx\centersub\centerV
9385     % for @center @image, we need a vbox so we can have our vertical space
9386     \imagevmodetrue
9387     \vbox\bgroup % vbox has better behavior than vtop herev
9388   \fi\fi
9389   %
9390   \ifimagevmode
9391     \nobreak\medskip
9392     % Usually we'll have text after the image which will insert
9393     % \parskip glue, so insert it here too to equalize the space
9394     % above and below.
9395     \nobreak\vskip\parskip
9396     \nobreak
9397   \fi
9398   %
9399   % Leave vertical mode so that indentation from an enclosing
9400   %  environment such as @quotation is respected.
9401   % However, if we're at the top level, we don't want the
9402   %  normal paragraph indentation.
9403   % On the other hand, if we are in the case of @center @image, we don't
9404   %  want to start a paragraph, which will create a hsize-width box and
9405   %  eradicate the centering.
9406   \ifx\centersub\centerV\else \noindent \fi
9407   %
9408   % Output the image.
9409   \ifpdf
9410     % For pdfTeX and LuaTeX <= 0.80
9411     \dopdfimage{#1}{#2}{#3}%
9412   \else
9413     \ifx\XeTeXrevision\thisisundefined
9414       % For epsf.tex
9415       % \epsfbox itself resets \epsf?size at each figure.
9416       \setbox0 = \hbox{\ignorespaces #2}%
9417         \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9418       \setbox0 = \hbox{\ignorespaces #3}%
9419         \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9420       \epsfbox{#1.eps}%
9421     \else
9422       % For XeTeX
9423       \doxeteximage{#1}{#2}{#3}%
9424     \fi
9425   \fi
9426   %
9427   \ifimagevmode
9428     \medskip  % space after a standalone image
9429   \fi  
9430   \ifx\centersub\centerV \egroup \fi
9431 \endgroup}
9432
9433
9434 % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9435 % etc.  We don't actually implement floating yet, we always include the
9436 % float "here".  But it seemed the best name for the future.
9437 %
9438 \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9439
9440 % There may be a space before second and/or third parameter; delete it.
9441 \def\eatcommaspace#1, {#1,}
9442
9443 % #1 is the optional FLOATTYPE, the text label for this float, typically
9444 % "Figure", "Table", "Example", etc.  Can't contain commas.  If omitted,
9445 % this float will not be numbered and cannot be referred to.
9446 %
9447 % #2 is the optional xref label.  Also must be present for the float to
9448 % be referable.
9449 %
9450 % #3 is the optional positioning argument; for now, it is ignored.  It
9451 % will somehow specify the positions allowed to float to (here, top, bottom).
9452 %
9453 % We keep a separate counter for each FLOATTYPE, which we reset at each
9454 % chapter-level command.
9455 \let\resetallfloatnos=\empty
9456 %
9457 \def\dofloat#1,#2,#3,#4\finish{%
9458   \let\thiscaption=\empty
9459   \let\thisshortcaption=\empty
9460   %
9461   % don't lose footnotes inside @float.
9462   %
9463   % BEWARE: when the floats start float, we have to issue warning whenever an
9464   % insert appears inside a float which could possibly float. --kasal, 26may04
9465   %
9466   \startsavinginserts
9467   %
9468   % We can't be used inside a paragraph.
9469   \par
9470   %
9471   \vtop\bgroup
9472     \def\floattype{#1}%
9473     \def\floatlabel{#2}%
9474     \def\floatloc{#3}% we do nothing with this yet.
9475     %
9476     \ifx\floattype\empty
9477       \let\safefloattype=\empty
9478     \else
9479       {%
9480         % the floattype might have accents or other special characters,
9481         % but we need to use it in a control sequence name.
9482         \indexnofonts
9483         \turnoffactive
9484         \xdef\safefloattype{\floattype}%
9485       }%
9486     \fi
9487     %
9488     % If label is given but no type, we handle that as the empty type.
9489     \ifx\floatlabel\empty \else
9490       % We want each FLOATTYPE to be numbered separately (Figure 1,
9491       % Table 1, Figure 2, ...).  (And if no label, no number.)
9492       %
9493       \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9494       \global\advance\floatno by 1
9495       %
9496       {%
9497         % This magic value for \lastsection is output by \setref as the
9498         % XREFLABEL-title value.  \xrefX uses it to distinguish float
9499         % labels (which have a completely different output format) from
9500         % node and anchor labels.  And \xrdef uses it to construct the
9501         % lists of floats.
9502         %
9503         \edef\lastsection{\floatmagic=\safefloattype}%
9504         \setref{\floatlabel}{Yfloat}%
9505       }%
9506     \fi
9507     %
9508     % start with \parskip glue, I guess.
9509     \vskip\parskip
9510     %
9511     % Don't suppress indentation if a float happens to start a section.
9512     \restorefirstparagraphindent
9513 }
9514
9515 % we have these possibilities:
9516 % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9517 % @float Foo,lbl & no caption:    Foo 1.1
9518 % @float Foo & @caption{Cap}:     Foo: Cap
9519 % @float Foo & no caption:        Foo
9520 % @float ,lbl & Caption{Cap}:     1.1: Cap
9521 % @float ,lbl & no caption:       1.1
9522 % @float & @caption{Cap}:         Cap
9523 % @float & no caption:
9524 %
9525 \def\Efloat{%
9526     \let\floatident = \empty
9527     %
9528     % In all cases, if we have a float type, it comes first.
9529     \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9530     %
9531     % If we have an xref label, the number comes next.
9532     \ifx\floatlabel\empty \else
9533       \ifx\floattype\empty \else % if also had float type, need tie first.
9534         \appendtomacro\floatident{\tie}%
9535       \fi
9536       % the number.
9537       \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9538     \fi
9539     %
9540     % Start the printed caption with what we've constructed in
9541     % \floatident, but keep it separate; we need \floatident again.
9542     \let\captionline = \floatident
9543     %
9544     \ifx\thiscaption\empty \else
9545       \ifx\floatident\empty \else
9546         \appendtomacro\captionline{: }% had ident, so need a colon between
9547       \fi
9548       %
9549       % caption text.
9550       \appendtomacro\captionline{\scanexp\thiscaption}%
9551     \fi
9552     %
9553     % If we have anything to print, print it, with space before.
9554     % Eventually this needs to become an \insert.
9555     \ifx\captionline\empty \else
9556       \vskip.5\parskip
9557       \captionline
9558       %
9559       % Space below caption.
9560       \vskip\parskip
9561     \fi
9562     %
9563     % If have an xref label, write the list of floats info.  Do this
9564     % after the caption, to avoid chance of it being a breakpoint.
9565     \ifx\floatlabel\empty \else
9566       % Write the text that goes in the lof to the aux file as
9567       % \floatlabel-lof.  Besides \floatident, we include the short
9568       % caption if specified, else the full caption if specified, else nothing.
9569       {%
9570         \requireauxfile
9571         \atdummies
9572         %
9573         \ifx\thisshortcaption\empty
9574           \def\gtemp{\thiscaption}%
9575         \else
9576           \def\gtemp{\thisshortcaption}%
9577         \fi
9578         \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
9579           \ifx\gtemp\empty \else : \gtemp \fi}}%
9580       }%
9581     \fi
9582   \egroup  % end of \vtop
9583   %
9584   \checkinserts
9585 }
9586
9587 % Append the tokens #2 to the definition of macro #1, not expanding either.
9588 %
9589 \def\appendtomacro#1#2{%
9590   \expandafter\def\expandafter#1\expandafter{#1#2}%
9591 }
9592
9593 % @caption, @shortcaption
9594 %
9595 \def\caption{\docaption\thiscaption}
9596 \def\shortcaption{\docaption\thisshortcaption}
9597 \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
9598 \def\defcaption#1#2{\egroup \def#1{#2}}
9599
9600 % The parameter is the control sequence identifying the counter we are
9601 % going to use.  Create it if it doesn't exist and assign it to \floatno.
9602 \def\getfloatno#1{%
9603   \ifx#1\relax
9604       % Haven't seen this figure type before.
9605       \csname newcount\endcsname #1%
9606       %
9607       % Remember to reset this floatno at the next chap.
9608       \expandafter\gdef\expandafter\resetallfloatnos
9609         \expandafter{\resetallfloatnos #1=0 }%
9610   \fi
9611   \let\floatno#1%
9612 }
9613
9614 % \setref calls this to get the XREFLABEL-snt value.  We want an @xref
9615 % to the FLOATLABEL to expand to "Figure 3.1".  We call \setref when we
9616 % first read the @float command.
9617 %
9618 \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9619
9620 % Magic string used for the XREFLABEL-title value, so \xrefX can
9621 % distinguish floats from other xref types.
9622 \def\floatmagic{!!float!!}
9623
9624 % #1 is the control sequence we are passed; we expand into a conditional
9625 % which is true if #1 represents a float ref.  That is, the magic
9626 % \lastsection value which we \setref above.
9627 %
9628 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
9629 %
9630 % #1 is (maybe) the \floatmagic string.  If so, #2 will be the
9631 % (safe) float type for this float.  We set \iffloattype to #2.
9632 %
9633 \def\doiffloat#1=#2=#3\finish{%
9634   \def\temp{#1}%
9635   \def\iffloattype{#2}%
9636   \ifx\temp\floatmagic
9637 }
9638
9639 % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9640 %
9641 \parseargdef\listoffloats{%
9642   \def\floattype{#1}% floattype
9643   {%
9644     % the floattype might have accents or other special characters,
9645     % but we need to use it in a control sequence name.
9646     \indexnofonts
9647     \turnoffactive
9648     \xdef\safefloattype{\floattype}%
9649   }%
9650   %
9651   % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9652   \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9653     \ifhavexrefs
9654       % if the user said @listoffloats foo but never @float foo.
9655       \message{\linenumber No `\safefloattype' floats to list.}%
9656     \fi
9657   \else
9658     \begingroup
9659       \leftskip=\tocindent  % indent these entries like a toc
9660       \let\do=\listoffloatsdo
9661       \csname floatlist\safefloattype\endcsname
9662     \endgroup
9663   \fi
9664 }
9665
9666 % This is called on each entry in a list of floats.  We're passed the
9667 % xref label, in the form LABEL-title, which is how we save it in the
9668 % aux file.  We strip off the -title and look up \XRLABEL-lof, which
9669 % has the text we're supposed to typeset here.
9670 %
9671 % Figures without xref labels will not be included in the list (since
9672 % they won't appear in the aux file).
9673 %
9674 \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9675 \def\listoffloatsdoentry#1-title\finish{{%
9676   % Can't fully expand XR#1-lof because it can contain anything.  Just
9677   % pass the control sequence.  On the other hand, XR#1-pg is just the
9678   % page number, and we want to fully expand that so we can get a link
9679   % in pdf output.
9680   \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9681   %
9682   % use the same \entry macro we use to generate the TOC and index.
9683   \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9684   \writeentry
9685 }}
9686
9687
9688 \message{localization,}
9689
9690 % For single-language documents, @documentlanguage is usually given very
9691 % early, just after @documentencoding.  Single argument is the language
9692 % (de) or locale (de_DE) abbreviation.
9693 %
9694 {
9695   \catcode`\_ = \active
9696   \globaldefs=1
9697 \parseargdef\documentlanguage{%
9698   \tex % read txi-??.tex file in plain TeX.
9699     % Read the file by the name they passed if it exists.
9700     \let_ = \normalunderscore  % normal _ character for filename test
9701     \openin 1 txi-#1.tex
9702     \ifeof 1
9703       \documentlanguagetrywithoutunderscore #1_\finish
9704     \else
9705       \globaldefs = 1  % everything in the txi-LL files needs to persist
9706       \input txi-#1.tex
9707     \fi
9708     \closein 1
9709   \endgroup % end raw TeX
9710 }
9711 %
9712 % If they passed de_DE, and txi-de_DE.tex doesn't exist,
9713 % try txi-de.tex.
9714 %
9715 \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
9716   \openin 1 txi-#1.tex
9717   \ifeof 1
9718     \errhelp = \nolanghelp
9719     \errmessage{Cannot read language file txi-#1.tex}%
9720   \else
9721     \globaldefs = 1  % everything in the txi-LL files needs to persist
9722     \input txi-#1.tex
9723   \fi
9724   \closein 1
9725 }
9726 }% end of special _ catcode
9727 %
9728 \newhelp\nolanghelp{The given language definition file cannot be found or
9729 is empty.  Maybe you need to install it?  Putting it in the current
9730 directory should work if nowhere else does.}
9731
9732 % This macro is called from txi-??.tex files; the first argument is the
9733 % \language name to set (without the "\lang@" prefix), the second and
9734 % third args are \{left,right}hyphenmin.
9735 %
9736 % The language names to pass are determined when the format is built.
9737 % See the etex.log file created at that time, e.g.,
9738 % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9739 %
9740 % With TeX Live 2008, etex now includes hyphenation patterns for all
9741 % available languages.  This means we can support hyphenation in
9742 % Texinfo, at least to some extent.  (This still doesn't solve the
9743 % accented characters problem.)
9744 %
9745 \catcode`@=11
9746 \def\txisetlanguage#1#2#3{%
9747   % do not set the language if the name is undefined in the current TeX.
9748   \expandafter\ifx\csname lang@#1\endcsname \relax
9749     \message{no patterns for #1}%
9750   \else
9751     \global\language = \csname lang@#1\endcsname
9752   \fi
9753   % but there is no harm in adjusting the hyphenmin values regardless.
9754   \global\lefthyphenmin = #2\relax
9755   \global\righthyphenmin = #3\relax
9756 }
9757
9758 % XeTeX and LuaTeX can handle native Unicode.
9759 % Their default I/O is UTF-8 sequence instead of byte-wise.
9760 % Other TeX engine (pdfTeX etc.) I/O is byte-wise.
9761 %
9762 \newif\iftxinativeunicodecapable
9763 \newif\iftxiusebytewiseio
9764
9765 \ifx\XeTeXrevision\thisisundefined
9766   \ifx\luatexversion\thisisundefined
9767     \txinativeunicodecapablefalse
9768     \txiusebytewiseiotrue
9769   \else
9770     \txinativeunicodecapabletrue
9771     \txiusebytewiseiofalse
9772   \fi
9773 \else
9774   \txinativeunicodecapabletrue
9775   \txiusebytewiseiofalse
9776 \fi
9777
9778 % Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9779 % for non-UTF-8 (byte-wise) encodings.
9780 %
9781 \def\setbytewiseio{%
9782   \ifx\XeTeXrevision\thisisundefined
9783   \else
9784     \XeTeXdefaultencoding "bytes"  % For subsequent files to be read
9785     \XeTeXinputencoding "bytes"  % For document root file
9786     % Unfortunately, there seems to be no corresponding XeTeX command for
9787     % output encoding.  This is a problem for auxiliary index and TOC files.
9788     % The only solution would be perhaps to write out @U{...} sequences in
9789     % place of non-ASCII characters.
9790   \fi
9791
9792   \ifx\luatexversion\thisisundefined
9793   \else
9794     \directlua{
9795     local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9796     local function convert_char (char)
9797       return utf8_char(byte(char))
9798     end
9799
9800     local function convert_line (line)
9801       return gsub(line, ".", convert_char)
9802     end
9803
9804     callback.register("process_input_buffer", convert_line)
9805
9806     local function convert_line_out (line)
9807       local line_out = ""
9808       for c in string.utfvalues(line) do
9809          line_out = line_out .. string.char(c)
9810       end
9811       return line_out
9812     end
9813
9814     callback.register("process_output_buffer", convert_line_out)
9815     }
9816   \fi
9817
9818   \txiusebytewiseiotrue
9819 }
9820
9821
9822 % Helpers for encodings.
9823 % Set the catcode of characters 128 through 255 to the specified number.
9824 %
9825 \def\setnonasciicharscatcode#1{%
9826    \count255=128
9827    \loop\ifnum\count255<256
9828       \global\catcode\count255=#1\relax
9829       \advance\count255 by 1
9830    \repeat
9831 }
9832
9833 \def\setnonasciicharscatcodenonglobal#1{%
9834    \count255=128
9835    \loop\ifnum\count255<256
9836       \catcode\count255=#1\relax
9837       \advance\count255 by 1
9838    \repeat
9839 }
9840
9841 % @documentencoding sets the definition of non-ASCII characters
9842 % according to the specified encoding.
9843 %
9844 \def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9845 \def\documentencodingzzz#1{%
9846   %
9847   % Encoding being declared for the document.
9848   \def\declaredencoding{\csname #1.enc\endcsname}%
9849   %
9850   % Supported encodings: names converted to tokens in order to be able
9851   % to compare them with \ifx.
9852   \def\ascii{\csname US-ASCII.enc\endcsname}%
9853   \def\latnine{\csname ISO-8859-15.enc\endcsname}%
9854   \def\latone{\csname ISO-8859-1.enc\endcsname}%
9855   \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
9856   \def\utfeight{\csname UTF-8.enc\endcsname}%
9857   %
9858   \ifx \declaredencoding \ascii
9859      \asciichardefs
9860   %
9861   \else \ifx \declaredencoding \lattwo
9862      \iftxinativeunicodecapable
9863        \setbytewiseio
9864      \fi
9865      \setnonasciicharscatcode\active
9866      \lattwochardefs
9867   %
9868   \else \ifx \declaredencoding \latone
9869      \iftxinativeunicodecapable
9870        \setbytewiseio
9871      \fi
9872      \setnonasciicharscatcode\active
9873      \latonechardefs
9874   %
9875   \else \ifx \declaredencoding \latnine
9876      \iftxinativeunicodecapable
9877        \setbytewiseio
9878      \fi
9879      \setnonasciicharscatcode\active
9880      \latninechardefs
9881   %
9882   \else \ifx \declaredencoding \utfeight
9883      \iftxinativeunicodecapable
9884        % For native Unicode (XeTeX and LuaTeX)
9885        \nativeunicodechardefs
9886      \else
9887        % For UTF-8 byte sequence (TeX, eTeX and pdfTeX)
9888        \setnonasciicharscatcode\active
9889        % since we already invoked \utfeightchardefs at the top level
9890        % (below), do not re-invoke it, then our check for duplicated
9891        % definitions triggers.  Making non-ascii chars active is enough.
9892      \fi
9893   %
9894   \else
9895     \message{Ignoring unknown document encoding: #1.}%
9896   %
9897   \fi % utfeight
9898   \fi % latnine
9899   \fi % latone
9900   \fi % lattwo
9901   \fi % ascii
9902 }
9903
9904 % emacs-page
9905 % A message to be logged when using a character that isn't available
9906 % the default font encoding (OT1).
9907 %
9908 \def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
9909
9910 % Take account of \c (plain) vs. \, (Texinfo) difference.
9911 \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
9912
9913 % First, make active non-ASCII characters in order for them to be
9914 % correctly categorized when TeX reads the replacement text of
9915 % macros containing the character definitions.
9916 \setnonasciicharscatcode\active
9917 %
9918
9919 \def\gdefchar#1#2{%
9920 \gdef#1{%
9921    \ifpassthroughchars
9922      \string#1%
9923    \else
9924      #2%
9925    \fi
9926 }}
9927
9928 % Latin1 (ISO-8859-1) character definitions.
9929 \def\latonechardefs{%
9930   \gdefchar^^a0{\tie}
9931   \gdefchar^^a1{\exclamdown}
9932   \gdefchar^^a2{{\tcfont \char162}} % cent
9933   \gdefchar^^a3{\pounds}
9934   \gdefchar^^a4{{\tcfont \char164}} % currency
9935   \gdefchar^^a5{{\tcfont \char165}} % yen
9936   \gdefchar^^a6{{\tcfont \char166}} % broken bar
9937   \gdefchar^^a7{\S}
9938   \gdefchar^^a8{\"{}}
9939   \gdefchar^^a9{\copyright}
9940   \gdefchar^^aa{\ordf}
9941   \gdefchar^^ab{\guillemetleft}
9942   \gdefchar^^ac{\ensuremath\lnot}
9943   \gdefchar^^ad{\-}
9944   \gdefchar^^ae{\registeredsymbol}
9945   \gdefchar^^af{\={}}
9946   %
9947   \gdefchar^^b0{\textdegree}
9948   \gdefchar^^b1{$\pm$}
9949   \gdefchar^^b2{$^2$}
9950   \gdefchar^^b3{$^3$}
9951   \gdefchar^^b4{\'{}}
9952   \gdefchar^^b5{$\mu$}
9953   \gdefchar^^b6{\P}
9954   \gdefchar^^b7{\ensuremath\cdot}
9955   \gdefchar^^b8{\cedilla\ }
9956   \gdefchar^^b9{$^1$}
9957   \gdefchar^^ba{\ordm}
9958   \gdefchar^^bb{\guillemetright}
9959   \gdefchar^^bc{$1\over4$}
9960   \gdefchar^^bd{$1\over2$}
9961   \gdefchar^^be{$3\over4$}
9962   \gdefchar^^bf{\questiondown}
9963   %
9964   \gdefchar^^c0{\`A}
9965   \gdefchar^^c1{\'A}
9966   \gdefchar^^c2{\^A}
9967   \gdefchar^^c3{\~A}
9968   \gdefchar^^c4{\"A}
9969   \gdefchar^^c5{\ringaccent A}
9970   \gdefchar^^c6{\AE}
9971   \gdefchar^^c7{\cedilla C}
9972   \gdefchar^^c8{\`E}
9973   \gdefchar^^c9{\'E}
9974   \gdefchar^^ca{\^E}
9975   \gdefchar^^cb{\"E}
9976   \gdefchar^^cc{\`I}
9977   \gdefchar^^cd{\'I}
9978   \gdefchar^^ce{\^I}
9979   \gdefchar^^cf{\"I}
9980   %
9981   \gdefchar^^d0{\DH}
9982   \gdefchar^^d1{\~N}
9983   \gdefchar^^d2{\`O}
9984   \gdefchar^^d3{\'O}
9985   \gdefchar^^d4{\^O}
9986   \gdefchar^^d5{\~O}
9987   \gdefchar^^d6{\"O}
9988   \gdefchar^^d7{$\times$}
9989   \gdefchar^^d8{\O}
9990   \gdefchar^^d9{\`U}
9991   \gdefchar^^da{\'U}
9992   \gdefchar^^db{\^U}
9993   \gdefchar^^dc{\"U}
9994   \gdefchar^^dd{\'Y}
9995   \gdefchar^^de{\TH}
9996   \gdefchar^^df{\ss}
9997   %
9998   \gdefchar^^e0{\`a}
9999   \gdefchar^^e1{\'a}
10000   \gdefchar^^e2{\^a}
10001   \gdefchar^^e3{\~a}
10002   \gdefchar^^e4{\"a}
10003   \gdefchar^^e5{\ringaccent a}
10004   \gdefchar^^e6{\ae}
10005   \gdefchar^^e7{\cedilla c}
10006   \gdefchar^^e8{\`e}
10007   \gdefchar^^e9{\'e}
10008   \gdefchar^^ea{\^e}
10009   \gdefchar^^eb{\"e}
10010   \gdefchar^^ec{\`{\dotless i}}
10011   \gdefchar^^ed{\'{\dotless i}}
10012   \gdefchar^^ee{\^{\dotless i}}
10013   \gdefchar^^ef{\"{\dotless i}}
10014   %
10015   \gdefchar^^f0{\dh}
10016   \gdefchar^^f1{\~n}
10017   \gdefchar^^f2{\`o}
10018   \gdefchar^^f3{\'o}
10019   \gdefchar^^f4{\^o}
10020   \gdefchar^^f5{\~o}
10021   \gdefchar^^f6{\"o}
10022   \gdefchar^^f7{$\div$}
10023   \gdefchar^^f8{\o}
10024   \gdefchar^^f9{\`u}
10025   \gdefchar^^fa{\'u}
10026   \gdefchar^^fb{\^u}
10027   \gdefchar^^fc{\"u}
10028   \gdefchar^^fd{\'y}
10029   \gdefchar^^fe{\th}
10030   \gdefchar^^ff{\"y}
10031 }
10032
10033 % Latin9 (ISO-8859-15) encoding character definitions.
10034 \def\latninechardefs{%
10035   % Encoding is almost identical to Latin1.
10036   \latonechardefs
10037   %
10038   \gdefchar^^a4{\euro}
10039   \gdefchar^^a6{\v S}
10040   \gdefchar^^a8{\v s}
10041   \gdefchar^^b4{\v Z}
10042   \gdefchar^^b8{\v z}
10043   \gdefchar^^bc{\OE}
10044   \gdefchar^^bd{\oe}
10045   \gdefchar^^be{\"Y}
10046 }
10047
10048 % Latin2 (ISO-8859-2) character definitions.
10049 \def\lattwochardefs{%
10050   \gdefchar^^a0{\tie}
10051   \gdefchar^^a1{\ogonek{A}}
10052   \gdefchar^^a2{\u{}}
10053   \gdefchar^^a3{\L}
10054   \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
10055   \gdefchar^^a5{\v L}
10056   \gdefchar^^a6{\'S}
10057   \gdefchar^^a7{\S}
10058   \gdefchar^^a8{\"{}}
10059   \gdefchar^^a9{\v S}
10060   \gdefchar^^aa{\cedilla S}
10061   \gdefchar^^ab{\v T}
10062   \gdefchar^^ac{\'Z}
10063   \gdefchar^^ad{\-}
10064   \gdefchar^^ae{\v Z}
10065   \gdefchar^^af{\dotaccent Z}
10066   %
10067   \gdefchar^^b0{\textdegree}
10068   \gdefchar^^b1{\ogonek{a}}
10069   \gdefchar^^b2{\ogonek{ }}
10070   \gdefchar^^b3{\l}
10071   \gdefchar^^b4{\'{}}
10072   \gdefchar^^b5{\v l}
10073   \gdefchar^^b6{\'s}
10074   \gdefchar^^b7{\v{}}
10075   \gdefchar^^b8{\cedilla\ }
10076   \gdefchar^^b9{\v s}
10077   \gdefchar^^ba{\cedilla s}
10078   \gdefchar^^bb{\v t}
10079   \gdefchar^^bc{\'z}
10080   \gdefchar^^bd{\H{}}
10081   \gdefchar^^be{\v z}
10082   \gdefchar^^bf{\dotaccent z}
10083   %
10084   \gdefchar^^c0{\'R}
10085   \gdefchar^^c1{\'A}
10086   \gdefchar^^c2{\^A}
10087   \gdefchar^^c3{\u A}
10088   \gdefchar^^c4{\"A}
10089   \gdefchar^^c5{\'L}
10090   \gdefchar^^c6{\'C}
10091   \gdefchar^^c7{\cedilla C}
10092   \gdefchar^^c8{\v C}
10093   \gdefchar^^c9{\'E}
10094   \gdefchar^^ca{\ogonek{E}}
10095   \gdefchar^^cb{\"E}
10096   \gdefchar^^cc{\v E}
10097   \gdefchar^^cd{\'I}
10098   \gdefchar^^ce{\^I}
10099   \gdefchar^^cf{\v D}
10100   %
10101   \gdefchar^^d0{\DH}
10102   \gdefchar^^d1{\'N}
10103   \gdefchar^^d2{\v N}
10104   \gdefchar^^d3{\'O}
10105   \gdefchar^^d4{\^O}
10106   \gdefchar^^d5{\H O}
10107   \gdefchar^^d6{\"O}
10108   \gdefchar^^d7{$\times$}
10109   \gdefchar^^d8{\v R}
10110   \gdefchar^^d9{\ringaccent U}
10111   \gdefchar^^da{\'U}
10112   \gdefchar^^db{\H U}
10113   \gdefchar^^dc{\"U}
10114   \gdefchar^^dd{\'Y}
10115   \gdefchar^^de{\cedilla T}
10116   \gdefchar^^df{\ss}
10117   %
10118   \gdefchar^^e0{\'r}
10119   \gdefchar^^e1{\'a}
10120   \gdefchar^^e2{\^a}
10121   \gdefchar^^e3{\u a}
10122   \gdefchar^^e4{\"a}
10123   \gdefchar^^e5{\'l}
10124   \gdefchar^^e6{\'c}
10125   \gdefchar^^e7{\cedilla c}
10126   \gdefchar^^e8{\v c}
10127   \gdefchar^^e9{\'e}
10128   \gdefchar^^ea{\ogonek{e}}
10129   \gdefchar^^eb{\"e}
10130   \gdefchar^^ec{\v e}
10131   \gdefchar^^ed{\'{\dotless{i}}}
10132   \gdefchar^^ee{\^{\dotless{i}}}
10133   \gdefchar^^ef{\v d}
10134   %
10135   \gdefchar^^f0{\dh}
10136   \gdefchar^^f1{\'n}
10137   \gdefchar^^f2{\v n}
10138   \gdefchar^^f3{\'o}
10139   \gdefchar^^f4{\^o}
10140   \gdefchar^^f5{\H o}
10141   \gdefchar^^f6{\"o}
10142   \gdefchar^^f7{$\div$}
10143   \gdefchar^^f8{\v r}
10144   \gdefchar^^f9{\ringaccent u}
10145   \gdefchar^^fa{\'u}
10146   \gdefchar^^fb{\H u}
10147   \gdefchar^^fc{\"u}
10148   \gdefchar^^fd{\'y}
10149   \gdefchar^^fe{\cedilla t}
10150   \gdefchar^^ff{\dotaccent{}}
10151 }
10152
10153 % UTF-8 character definitions.
10154 %
10155 % This code to support UTF-8 is based on LaTeX's utf8.def, with some
10156 % changes for Texinfo conventions.  It is included here under the GPL by
10157 % permission from Frank Mittelbach and the LaTeX team.
10158 %
10159 \newcount\countUTFx
10160 \newcount\countUTFy
10161 \newcount\countUTFz
10162
10163 \gdef\UTFviiiTwoOctets#1#2{\expandafter
10164    \UTFviiiDefined\csname u8:#1\string #2\endcsname}
10165 %
10166 \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
10167    \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
10168 %
10169 \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
10170    \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
10171
10172 \gdef\UTFviiiDefined#1{%
10173   \ifx #1\relax
10174     \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10175   \else
10176     \expandafter #1%
10177   \fi
10178 }
10179
10180 % Give non-ASCII bytes the active definitions for processing UTF-8 sequences
10181 \begingroup
10182   \catcode`\~13
10183   \catcode`\$12
10184   \catcode`\"12
10185
10186   % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
10187   % substituting ~ and $ with a character token of that value.
10188   \def\UTFviiiLoop{%
10189     \global\catcode\countUTFx\active
10190     \uccode`\~\countUTFx
10191     \uccode`\$\countUTFx
10192     \uppercase\expandafter{\UTFviiiTmp}%
10193     \advance\countUTFx by 1
10194     \ifnum\countUTFx < \countUTFy
10195       \expandafter\UTFviiiLoop
10196     \fi}
10197
10198   % For bytes other than the first in a UTF-8 sequence.  Not expected to
10199   % be expanded except when writing to auxiliary files.
10200   \countUTFx = "80
10201   \countUTFy = "C2
10202   \def\UTFviiiTmp{%
10203     \gdef~{
10204         \ifpassthroughchars $\fi}}%
10205   \UTFviiiLoop
10206
10207   \countUTFx = "C2
10208   \countUTFy = "E0
10209   \def\UTFviiiTmp{%
10210     \gdef~{%
10211         \ifpassthroughchars $%
10212         \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
10213   \UTFviiiLoop
10214
10215   \countUTFx = "E0
10216   \countUTFy = "F0
10217   \def\UTFviiiTmp{%
10218     \gdef~{%
10219         \ifpassthroughchars $%
10220         \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
10221   \UTFviiiLoop
10222
10223   \countUTFx = "F0
10224   \countUTFy = "F4
10225   \def\UTFviiiTmp{%
10226     \gdef~{%
10227         \ifpassthroughchars $%
10228         \else\expandafter\UTFviiiFourOctets\expandafter$\fi
10229         }}%
10230   \UTFviiiLoop
10231 \endgroup
10232
10233 \def\globallet{\global\let} % save some \expandafter's below
10234
10235 % @U{xxxx} to produce U+xxxx, if we support it.
10236 \def\U#1{%
10237   \expandafter\ifx\csname uni:#1\endcsname \relax
10238     \iftxinativeunicodecapable
10239       % Any Unicode characters can be used by native Unicode.
10240       % However, if the font does not have the glyph, the letter will miss.
10241       \begingroup
10242         \uccode`\.="#1\relax
10243         \uppercase{.}
10244       \endgroup
10245     \else
10246       \errhelp = \EMsimple      
10247       \errmessage{Unicode character U+#1 not supported, sorry}%
10248     \fi
10249   \else
10250     \csname uni:#1\endcsname
10251   \fi
10252 }
10253
10254 % For UTF-8 byte sequence (TeX, e-TeX and pdfTeX)
10255 % Definition macro to replace the Unicode character
10256 % Definition macro that is used by @U command
10257 %
10258 \begingroup
10259   \catcode`\"=12
10260   \catcode`\<=12
10261   \catcode`\.=12
10262   \catcode`\,=12
10263   \catcode`\;=12
10264   \catcode`\!=12
10265   \catcode`\~=13
10266   \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
10267     \countUTFz = "#1\relax
10268     \begingroup
10269       \parseXMLCharref
10270       %
10271       % Access definitions of characters given UTF-8 sequences
10272       \def\UTFviiiTwoOctets##1##2{%
10273         \csname u8:##1\string ##2\endcsname}%
10274       \def\UTFviiiThreeOctets##1##2##3{%
10275         \csname u8:##1\string ##2\string ##3\endcsname}%
10276       \def\UTFviiiFourOctets##1##2##3##4{%
10277         \csname u8:##1\string ##2\string ##3\string ##4\endcsname}%
10278       \expandafter\expandafter\expandafter\expandafter
10279        \expandafter\expandafter\expandafter
10280        \gdef\UTFviiiTmp{#2}%
10281       % 
10282       \expandafter\ifx\csname uni:#1\endcsname \relax \else
10283        \message{Internal error, already defined: #1}%
10284       \fi
10285       %
10286       % define an additional control sequence for this code point.
10287       \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
10288     \endgroup}
10289   %
10290   % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp.
10291   \gdef\parseXMLCharref{%
10292     \ifnum\countUTFz < "A0\relax
10293       \errhelp = \EMsimple
10294       \errmessage{Cannot define Unicode char value < 00A0}%
10295     \else\ifnum\countUTFz < "800\relax
10296       \parseUTFviiiA,%
10297       \parseUTFviiiB C\UTFviiiTwoOctets.,%
10298     \else\ifnum\countUTFz < "10000\relax
10299       \parseUTFviiiA;%
10300       \parseUTFviiiA,%
10301       \parseUTFviiiB E\UTFviiiThreeOctets.{,;}%
10302     \else
10303       \parseUTFviiiA;%
10304       \parseUTFviiiA,%
10305       \parseUTFviiiA!%
10306       \parseUTFviiiB F\UTFviiiFourOctets.{!,;}%
10307     \fi\fi\fi
10308   }
10309
10310   \gdef\parseUTFviiiA#1{%
10311     \countUTFx = \countUTFz
10312     \divide\countUTFz by 64
10313     \countUTFy = \countUTFz
10314     \multiply\countUTFz by 64
10315     \advance\countUTFx by -\countUTFz
10316     \advance\countUTFx by 128
10317     \uccode `#1\countUTFx
10318     \countUTFz = \countUTFy}
10319
10320   % Used to set \UTFviiiTmp to a UTF-8 byte sequence
10321   \gdef\parseUTFviiiB#1#2#3#4{%
10322     \advance\countUTFz by "#10\relax
10323     \uccode `#3\countUTFz
10324     \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10325 \endgroup
10326
10327 % For native Unicode (XeTeX and LuaTeX)
10328 % Definition macro that is set catcode other non global
10329 %
10330 \def\DeclareUnicodeCharacterNativeOther#1#2{%
10331   \catcode"#1=\other
10332 }
10333
10334 % https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10335 % U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10336 % U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10337 % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10338 % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10339
10340 % Many of our renditions are less than wonderful, and all the missing
10341 % characters are available somewhere.  Loading the necessary fonts
10342 % awaits user request.  We can't truly support Unicode without
10343 % reimplementing everything that's been done in LaTeX for many years,
10344 % plus probably using luatex or xetex, and who knows what else.
10345 % We won't be doing that here in this simple file.  But we can try to at
10346 % least make most of the characters not bomb out.
10347 %
10348 \def\unicodechardefs{%
10349   \DeclareUnicodeCharacter{00A0}{\tie}%
10350   \DeclareUnicodeCharacter{00A1}{\exclamdown}%
10351   \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
10352   \DeclareUnicodeCharacter{00A3}{\pounds}%
10353   \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10354   \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10355   \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
10356   \DeclareUnicodeCharacter{00A7}{\S}%
10357   \DeclareUnicodeCharacter{00A8}{\"{ }}%
10358   \DeclareUnicodeCharacter{00A9}{\copyright}%
10359   \DeclareUnicodeCharacter{00AA}{\ordf}%
10360   \DeclareUnicodeCharacter{00AB}{\guillemetleft}%
10361   \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10362   \DeclareUnicodeCharacter{00AD}{\-}%
10363   \DeclareUnicodeCharacter{00AE}{\registeredsymbol}%
10364   \DeclareUnicodeCharacter{00AF}{\={ }}%
10365   %
10366   \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
10367   \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10368   \DeclareUnicodeCharacter{00B2}{$^2$}%
10369   \DeclareUnicodeCharacter{00B3}{$^3$}%
10370   \DeclareUnicodeCharacter{00B4}{\'{ }}%
10371   \DeclareUnicodeCharacter{00B5}{$\mu$}%
10372   \DeclareUnicodeCharacter{00B6}{\P}%
10373   \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10374   \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10375   \DeclareUnicodeCharacter{00B9}{$^1$}%
10376   \DeclareUnicodeCharacter{00BA}{\ordm}%
10377   \DeclareUnicodeCharacter{00BB}{\guillemetright}%
10378   \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10379   \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10380   \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10381   \DeclareUnicodeCharacter{00BF}{\questiondown}%
10382   %
10383   \DeclareUnicodeCharacter{00C0}{\`A}%
10384   \DeclareUnicodeCharacter{00C1}{\'A}%
10385   \DeclareUnicodeCharacter{00C2}{\^A}%
10386   \DeclareUnicodeCharacter{00C3}{\~A}%
10387   \DeclareUnicodeCharacter{00C4}{\"A}%
10388   \DeclareUnicodeCharacter{00C5}{\AA}%
10389   \DeclareUnicodeCharacter{00C6}{\AE}%
10390   \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10391   \DeclareUnicodeCharacter{00C8}{\`E}%
10392   \DeclareUnicodeCharacter{00C9}{\'E}%
10393   \DeclareUnicodeCharacter{00CA}{\^E}%
10394   \DeclareUnicodeCharacter{00CB}{\"E}%
10395   \DeclareUnicodeCharacter{00CC}{\`I}%
10396   \DeclareUnicodeCharacter{00CD}{\'I}%
10397   \DeclareUnicodeCharacter{00CE}{\^I}%
10398   \DeclareUnicodeCharacter{00CF}{\"I}%
10399   %
10400   \DeclareUnicodeCharacter{00D0}{\DH}%
10401   \DeclareUnicodeCharacter{00D1}{\~N}%
10402   \DeclareUnicodeCharacter{00D2}{\`O}%
10403   \DeclareUnicodeCharacter{00D3}{\'O}%
10404   \DeclareUnicodeCharacter{00D4}{\^O}%
10405   \DeclareUnicodeCharacter{00D5}{\~O}%
10406   \DeclareUnicodeCharacter{00D6}{\"O}%
10407   \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10408   \DeclareUnicodeCharacter{00D8}{\O}%
10409   \DeclareUnicodeCharacter{00D9}{\`U}%
10410   \DeclareUnicodeCharacter{00DA}{\'U}%
10411   \DeclareUnicodeCharacter{00DB}{\^U}%
10412   \DeclareUnicodeCharacter{00DC}{\"U}%
10413   \DeclareUnicodeCharacter{00DD}{\'Y}%
10414   \DeclareUnicodeCharacter{00DE}{\TH}%
10415   \DeclareUnicodeCharacter{00DF}{\ss}%
10416   %
10417   \DeclareUnicodeCharacter{00E0}{\`a}%
10418   \DeclareUnicodeCharacter{00E1}{\'a}%
10419   \DeclareUnicodeCharacter{00E2}{\^a}%
10420   \DeclareUnicodeCharacter{00E3}{\~a}%
10421   \DeclareUnicodeCharacter{00E4}{\"a}%
10422   \DeclareUnicodeCharacter{00E5}{\aa}%
10423   \DeclareUnicodeCharacter{00E6}{\ae}%
10424   \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10425   \DeclareUnicodeCharacter{00E8}{\`e}%
10426   \DeclareUnicodeCharacter{00E9}{\'e}%
10427   \DeclareUnicodeCharacter{00EA}{\^e}%
10428   \DeclareUnicodeCharacter{00EB}{\"e}%
10429   \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10430   \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10431   \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10432   \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10433   %
10434   \DeclareUnicodeCharacter{00F0}{\dh}%
10435   \DeclareUnicodeCharacter{00F1}{\~n}%
10436   \DeclareUnicodeCharacter{00F2}{\`o}%
10437   \DeclareUnicodeCharacter{00F3}{\'o}%
10438   \DeclareUnicodeCharacter{00F4}{\^o}%
10439   \DeclareUnicodeCharacter{00F5}{\~o}%
10440   \DeclareUnicodeCharacter{00F6}{\"o}%
10441   \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10442   \DeclareUnicodeCharacter{00F8}{\o}%
10443   \DeclareUnicodeCharacter{00F9}{\`u}%
10444   \DeclareUnicodeCharacter{00FA}{\'u}%
10445   \DeclareUnicodeCharacter{00FB}{\^u}%
10446   \DeclareUnicodeCharacter{00FC}{\"u}%
10447   \DeclareUnicodeCharacter{00FD}{\'y}%
10448   \DeclareUnicodeCharacter{00FE}{\th}%
10449   \DeclareUnicodeCharacter{00FF}{\"y}%
10450   %
10451   \DeclareUnicodeCharacter{0100}{\=A}%
10452   \DeclareUnicodeCharacter{0101}{\=a}%
10453   \DeclareUnicodeCharacter{0102}{\u{A}}%
10454   \DeclareUnicodeCharacter{0103}{\u{a}}%
10455   \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10456   \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10457   \DeclareUnicodeCharacter{0106}{\'C}%
10458   \DeclareUnicodeCharacter{0107}{\'c}%
10459   \DeclareUnicodeCharacter{0108}{\^C}%
10460   \DeclareUnicodeCharacter{0109}{\^c}%
10461   \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10462   \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10463   \DeclareUnicodeCharacter{010C}{\v{C}}%
10464   \DeclareUnicodeCharacter{010D}{\v{c}}%
10465   \DeclareUnicodeCharacter{010E}{\v{D}}%
10466   \DeclareUnicodeCharacter{010F}{d'}%
10467   %
10468   \DeclareUnicodeCharacter{0110}{\DH}%
10469   \DeclareUnicodeCharacter{0111}{\dh}%
10470   \DeclareUnicodeCharacter{0112}{\=E}%
10471   \DeclareUnicodeCharacter{0113}{\=e}%
10472   \DeclareUnicodeCharacter{0114}{\u{E}}%
10473   \DeclareUnicodeCharacter{0115}{\u{e}}%
10474   \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10475   \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10476   \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10477   \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10478   \DeclareUnicodeCharacter{011A}{\v{E}}%
10479   \DeclareUnicodeCharacter{011B}{\v{e}}%
10480   \DeclareUnicodeCharacter{011C}{\^G}%
10481   \DeclareUnicodeCharacter{011D}{\^g}%
10482   \DeclareUnicodeCharacter{011E}{\u{G}}%
10483   \DeclareUnicodeCharacter{011F}{\u{g}}%
10484   %
10485   \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10486   \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10487   \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10488   \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10489   \DeclareUnicodeCharacter{0124}{\^H}%
10490   \DeclareUnicodeCharacter{0125}{\^h}%
10491   \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10492   \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10493   \DeclareUnicodeCharacter{0128}{\~I}%
10494   \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10495   \DeclareUnicodeCharacter{012A}{\=I}%
10496   \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10497   \DeclareUnicodeCharacter{012C}{\u{I}}%
10498   \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10499   \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10500   \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10501   %
10502   \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10503   \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10504   \DeclareUnicodeCharacter{0132}{IJ}%
10505   \DeclareUnicodeCharacter{0133}{ij}%
10506   \DeclareUnicodeCharacter{0134}{\^J}%
10507   \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10508   \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10509   \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10510   \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10511   \DeclareUnicodeCharacter{0139}{\'L}%
10512   \DeclareUnicodeCharacter{013A}{\'l}%
10513   \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10514   \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
10515   \DeclareUnicodeCharacter{013D}{L'}% should kern
10516   \DeclareUnicodeCharacter{013E}{l'}% should kern
10517   \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10518   %
10519   \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10520   \DeclareUnicodeCharacter{0141}{\L}%
10521   \DeclareUnicodeCharacter{0142}{\l}%
10522   \DeclareUnicodeCharacter{0143}{\'N}%
10523   \DeclareUnicodeCharacter{0144}{\'n}%
10524   \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10525   \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10526   \DeclareUnicodeCharacter{0147}{\v{N}}%
10527   \DeclareUnicodeCharacter{0148}{\v{n}}%
10528   \DeclareUnicodeCharacter{0149}{'n}%
10529   \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10530   \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10531   \DeclareUnicodeCharacter{014C}{\=O}%
10532   \DeclareUnicodeCharacter{014D}{\=o}%
10533   \DeclareUnicodeCharacter{014E}{\u{O}}%
10534   \DeclareUnicodeCharacter{014F}{\u{o}}%
10535   %
10536   \DeclareUnicodeCharacter{0150}{\H{O}}%
10537   \DeclareUnicodeCharacter{0151}{\H{o}}%
10538   \DeclareUnicodeCharacter{0152}{\OE}%
10539   \DeclareUnicodeCharacter{0153}{\oe}%
10540   \DeclareUnicodeCharacter{0154}{\'R}%
10541   \DeclareUnicodeCharacter{0155}{\'r}%
10542   \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10543   \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10544   \DeclareUnicodeCharacter{0158}{\v{R}}%
10545   \DeclareUnicodeCharacter{0159}{\v{r}}%
10546   \DeclareUnicodeCharacter{015A}{\'S}%
10547   \DeclareUnicodeCharacter{015B}{\'s}%
10548   \DeclareUnicodeCharacter{015C}{\^S}%
10549   \DeclareUnicodeCharacter{015D}{\^s}%
10550   \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10551   \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10552   %
10553   \DeclareUnicodeCharacter{0160}{\v{S}}%
10554   \DeclareUnicodeCharacter{0161}{\v{s}}%
10555   \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10556   \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10557   \DeclareUnicodeCharacter{0164}{\v{T}}%
10558   \DeclareUnicodeCharacter{0165}{\v{t}}%
10559   \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10560   \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10561   \DeclareUnicodeCharacter{0168}{\~U}%
10562   \DeclareUnicodeCharacter{0169}{\~u}%
10563   \DeclareUnicodeCharacter{016A}{\=U}%
10564   \DeclareUnicodeCharacter{016B}{\=u}%
10565   \DeclareUnicodeCharacter{016C}{\u{U}}%
10566   \DeclareUnicodeCharacter{016D}{\u{u}}%
10567   \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10568   \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10569   %
10570   \DeclareUnicodeCharacter{0170}{\H{U}}%
10571   \DeclareUnicodeCharacter{0171}{\H{u}}%
10572   \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10573   \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10574   \DeclareUnicodeCharacter{0174}{\^W}%
10575   \DeclareUnicodeCharacter{0175}{\^w}%
10576   \DeclareUnicodeCharacter{0176}{\^Y}%
10577   \DeclareUnicodeCharacter{0177}{\^y}%
10578   \DeclareUnicodeCharacter{0178}{\"Y}%
10579   \DeclareUnicodeCharacter{0179}{\'Z}%
10580   \DeclareUnicodeCharacter{017A}{\'z}%
10581   \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10582   \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10583   \DeclareUnicodeCharacter{017D}{\v{Z}}%
10584   \DeclareUnicodeCharacter{017E}{\v{z}}%
10585   \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10586   %
10587   \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10588   \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10589   \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10590   \DeclareUnicodeCharacter{01C7}{LJ}%
10591   \DeclareUnicodeCharacter{01C8}{Lj}%
10592   \DeclareUnicodeCharacter{01C9}{lj}%
10593   \DeclareUnicodeCharacter{01CA}{NJ}%
10594   \DeclareUnicodeCharacter{01CB}{Nj}%
10595   \DeclareUnicodeCharacter{01CC}{nj}%
10596   \DeclareUnicodeCharacter{01CD}{\v{A}}%
10597   \DeclareUnicodeCharacter{01CE}{\v{a}}%
10598   \DeclareUnicodeCharacter{01CF}{\v{I}}%
10599   %
10600   \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10601   \DeclareUnicodeCharacter{01D1}{\v{O}}%
10602   \DeclareUnicodeCharacter{01D2}{\v{o}}%
10603   \DeclareUnicodeCharacter{01D3}{\v{U}}%
10604   \DeclareUnicodeCharacter{01D4}{\v{u}}%
10605   %
10606   \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10607   \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10608   \DeclareUnicodeCharacter{01E6}{\v{G}}%
10609   \DeclareUnicodeCharacter{01E7}{\v{g}}%
10610   \DeclareUnicodeCharacter{01E8}{\v{K}}%
10611   \DeclareUnicodeCharacter{01E9}{\v{k}}%
10612   %
10613   \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10614   \DeclareUnicodeCharacter{01F1}{DZ}%
10615   \DeclareUnicodeCharacter{01F2}{Dz}%
10616   \DeclareUnicodeCharacter{01F3}{dz}%
10617   \DeclareUnicodeCharacter{01F4}{\'G}%
10618   \DeclareUnicodeCharacter{01F5}{\'g}%
10619   \DeclareUnicodeCharacter{01F8}{\`N}%
10620   \DeclareUnicodeCharacter{01F9}{\`n}%
10621   \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10622   \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10623   \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10624   \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10625   %
10626   \DeclareUnicodeCharacter{021E}{\v{H}}%
10627   \DeclareUnicodeCharacter{021F}{\v{h}}%
10628   %
10629   \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10630   \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10631   \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10632   \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10633   \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10634   \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10635   %
10636   \DeclareUnicodeCharacter{0232}{\=Y}%
10637   \DeclareUnicodeCharacter{0233}{\=y}%
10638   \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10639   %
10640   \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10641   %
10642   % Greek letters upper case
10643   \DeclareUnicodeCharacter{0391}{{\it A}}%
10644   \DeclareUnicodeCharacter{0392}{{\it B}}%
10645   \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10646   \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10647   \DeclareUnicodeCharacter{0395}{{\it E}}%
10648   \DeclareUnicodeCharacter{0396}{{\it Z}}%
10649   \DeclareUnicodeCharacter{0397}{{\it H}}%
10650   \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10651   \DeclareUnicodeCharacter{0399}{{\it I}}%
10652   \DeclareUnicodeCharacter{039A}{{\it K}}%
10653   \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10654   \DeclareUnicodeCharacter{039C}{{\it M}}%
10655   \DeclareUnicodeCharacter{039D}{{\it N}}%
10656   \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10657   \DeclareUnicodeCharacter{039F}{{\it O}}%
10658   \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10659   \DeclareUnicodeCharacter{03A1}{{\it P}}%
10660   %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
10661   \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10662   \DeclareUnicodeCharacter{03A4}{{\it T}}%
10663   \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10664   \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10665   \DeclareUnicodeCharacter{03A7}{{\it X}}%
10666   \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10667   \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10668   %
10669   % Vowels with accents
10670   \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10671   \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10672   \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10673   \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10674   \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10675   \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10676   %
10677   % Standalone accent
10678   \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10679   %
10680   % Greek letters lower case
10681   \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10682   \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10683   \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10684   \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10685   \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10686   \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10687   \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10688   \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10689   \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10690   \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10691   \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10692   \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10693   \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10694   \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10695   \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10696   \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10697   \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10698   \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10699   \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10700   \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10701   \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10702   \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10703   \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10704   \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10705   \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10706   %
10707   % More Greek vowels with accents
10708   \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10709   \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10710   \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10711   \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10712   \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10713   %
10714   % Variant Greek letters
10715   \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10716   \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10717   \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10718   %
10719   \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10720   \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10721   \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10722   \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10723   \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10724   \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10725   \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10726   \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10727   \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10728   \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10729   \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10730   \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10731   %
10732   \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10733   \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10734   %
10735   \DeclareUnicodeCharacter{1E20}{\=G}%
10736   \DeclareUnicodeCharacter{1E21}{\=g}%
10737   \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10738   \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10739   \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10740   \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10741   \DeclareUnicodeCharacter{1E26}{\"H}%
10742   \DeclareUnicodeCharacter{1E27}{\"h}%
10743   %
10744   \DeclareUnicodeCharacter{1E30}{\'K}%
10745   \DeclareUnicodeCharacter{1E31}{\'k}%
10746   \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10747   \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10748   \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10749   \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10750   \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10751   \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10752   \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10753   \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10754   \DeclareUnicodeCharacter{1E3E}{\'M}%
10755   \DeclareUnicodeCharacter{1E3F}{\'m}%
10756   %
10757   \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10758   \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10759   \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10760   \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10761   \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10762   \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10763   \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10764   \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10765   \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10766   \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10767   %
10768   \DeclareUnicodeCharacter{1E54}{\'P}%
10769   \DeclareUnicodeCharacter{1E55}{\'p}%
10770   \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10771   \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10772   \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10773   \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10774   \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10775   \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10776   \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10777   \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10778   %
10779   \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10780   \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10781   \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10782   \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10783   \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10784   \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10785   \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10786   \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10787   \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10788   \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10789   %
10790   \DeclareUnicodeCharacter{1E7C}{\~V}%
10791   \DeclareUnicodeCharacter{1E7D}{\~v}%
10792   \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10793   \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10794   %
10795   \DeclareUnicodeCharacter{1E80}{\`W}%
10796   \DeclareUnicodeCharacter{1E81}{\`w}%
10797   \DeclareUnicodeCharacter{1E82}{\'W}%
10798   \DeclareUnicodeCharacter{1E83}{\'w}%
10799   \DeclareUnicodeCharacter{1E84}{\"W}%
10800   \DeclareUnicodeCharacter{1E85}{\"w}%
10801   \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10802   \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10803   \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10804   \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10805   \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10806   \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10807   \DeclareUnicodeCharacter{1E8C}{\"X}%
10808   \DeclareUnicodeCharacter{1E8D}{\"x}%
10809   \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10810   \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10811   %
10812   \DeclareUnicodeCharacter{1E90}{\^Z}%
10813   \DeclareUnicodeCharacter{1E91}{\^z}%
10814   \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
10815   \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
10816   \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
10817   \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
10818   \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
10819   \DeclareUnicodeCharacter{1E97}{\"t}%
10820   \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
10821   \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
10822   %
10823   \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
10824   \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
10825   %
10826   \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
10827   \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
10828   \DeclareUnicodeCharacter{1EBC}{\~E}%
10829   \DeclareUnicodeCharacter{1EBD}{\~e}%
10830   %
10831   \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
10832   \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
10833   \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
10834   \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
10835   %
10836   \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
10837   \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
10838   %
10839   \DeclareUnicodeCharacter{1EF2}{\`Y}%
10840   \DeclareUnicodeCharacter{1EF3}{\`y}%
10841   \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
10842   %
10843   \DeclareUnicodeCharacter{1EF8}{\~Y}%
10844   \DeclareUnicodeCharacter{1EF9}{\~y}%
10845   %
10846   % Punctuation
10847   \DeclareUnicodeCharacter{2013}{--}%
10848   \DeclareUnicodeCharacter{2014}{---}%
10849   \DeclareUnicodeCharacter{2018}{\quoteleft}%
10850   \DeclareUnicodeCharacter{2019}{\quoteright}%
10851   \DeclareUnicodeCharacter{201A}{\quotesinglbase}%
10852   \DeclareUnicodeCharacter{201C}{\quotedblleft}%
10853   \DeclareUnicodeCharacter{201D}{\quotedblright}%
10854   \DeclareUnicodeCharacter{201E}{\quotedblbase}%
10855   \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}%
10856   \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}%
10857   \DeclareUnicodeCharacter{2022}{\bullet}%
10858   \DeclareUnicodeCharacter{202F}{\thinspace}%
10859   \DeclareUnicodeCharacter{2026}{\dots}%
10860   \DeclareUnicodeCharacter{2039}{\guilsinglleft}%
10861   \DeclareUnicodeCharacter{203A}{\guilsinglright}%
10862   %
10863   \DeclareUnicodeCharacter{20AC}{\euro}%
10864   %
10865   \DeclareUnicodeCharacter{2192}{\expansion}%
10866   \DeclareUnicodeCharacter{21D2}{\result}%
10867   %
10868   % Mathematical symbols
10869   \DeclareUnicodeCharacter{2200}{\ensuremath\forall}%
10870   \DeclareUnicodeCharacter{2203}{\ensuremath\exists}%
10871   \DeclareUnicodeCharacter{2208}{\ensuremath\in}%
10872   \DeclareUnicodeCharacter{2212}{\minus}%
10873   \DeclareUnicodeCharacter{2217}{\ast}%
10874   \DeclareUnicodeCharacter{221E}{\ensuremath\infty}%
10875   \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}%
10876   \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}%
10877   \DeclareUnicodeCharacter{2229}{\ensuremath\cap}%
10878   \DeclareUnicodeCharacter{2261}{\equiv}%
10879   \DeclareUnicodeCharacter{2264}{\ensuremath\leq}%
10880   \DeclareUnicodeCharacter{2265}{\ensuremath\geq}%
10881   \DeclareUnicodeCharacter{2282}{\ensuremath\subset}%
10882   \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}%
10883   %
10884   \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}%
10885   \DeclareUnicodeCharacter{2032}{\ensuremath\prime}%
10886   \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}%
10887   \DeclareUnicodeCharacter{2111}{\ensuremath\Im}%
10888   \DeclareUnicodeCharacter{2113}{\ensuremath\ell}%
10889   \DeclareUnicodeCharacter{2118}{\ensuremath\wp}%
10890   \DeclareUnicodeCharacter{211C}{\ensuremath\Re}%
10891   \DeclareUnicodeCharacter{2127}{\ensuremath\mho}%
10892   \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}%
10893   \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}%
10894   \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}%
10895   \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}%
10896   \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}%
10897   \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}%
10898   \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}%
10899   \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}%
10900   \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}%
10901   \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}%
10902   \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}%
10903   \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}%
10904   \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}%
10905   \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}%
10906   \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}%
10907   \DeclareUnicodeCharacter{21BE}{\ensuremath\upharpoonright}%
10908   \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}%
10909   \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}%
10910   \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}%
10911   \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}%
10912   \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}%
10913   \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}%
10914   \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}%
10915   \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}%
10916   \DeclareUnicodeCharacter{21DD}{\ensuremath\leadsto}%
10917   \DeclareUnicodeCharacter{2201}{\ensuremath\complement}%
10918   \DeclareUnicodeCharacter{2202}{\ensuremath\partial}%
10919   \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}%
10920   \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}%
10921   \DeclareUnicodeCharacter{2209}{\ensuremath\notin}%
10922   \DeclareUnicodeCharacter{220B}{\ensuremath\owns}%
10923   \DeclareUnicodeCharacter{220F}{\ensuremath\prod}%
10924   \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}%
10925   \DeclareUnicodeCharacter{2211}{\ensuremath\sum}%
10926   \DeclareUnicodeCharacter{2213}{\ensuremath\mp}%
10927   \DeclareUnicodeCharacter{2218}{\ensuremath\circ}%
10928   \DeclareUnicodeCharacter{221A}{\ensuremath\surd}%
10929   \DeclareUnicodeCharacter{221D}{\ensuremath\propto}%
10930   \DeclareUnicodeCharacter{2220}{\ensuremath\angle}%
10931   \DeclareUnicodeCharacter{2223}{\ensuremath\mid}%
10932   \DeclareUnicodeCharacter{2228}{\ensuremath\vee}%
10933   \DeclareUnicodeCharacter{222A}{\ensuremath\cup}%
10934   \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}%
10935   \DeclareUnicodeCharacter{222E}{\ensuremath\oint}%
10936   \DeclareUnicodeCharacter{223C}{\ensuremath\sim}%
10937   \DeclareUnicodeCharacter{2240}{\ensuremath\wr}%
10938   \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}%
10939   \DeclareUnicodeCharacter{2245}{\ensuremath\cong}%
10940   \DeclareUnicodeCharacter{2248}{\ensuremath\approx}%
10941   \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}%
10942   \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}%
10943   \DeclareUnicodeCharacter{2260}{\ensuremath\neq}%
10944   \DeclareUnicodeCharacter{226A}{\ensuremath\ll}%
10945   \DeclareUnicodeCharacter{226B}{\ensuremath\gg}%
10946   \DeclareUnicodeCharacter{227A}{\ensuremath\prec}%
10947   \DeclareUnicodeCharacter{227B}{\ensuremath\succ}%
10948   \DeclareUnicodeCharacter{2283}{\ensuremath\supset}%
10949   \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}%
10950   \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}%
10951   \DeclareUnicodeCharacter{228F}{\ensuremath\sqsubset}%
10952   \DeclareUnicodeCharacter{2290}{\ensuremath\sqsupset}%
10953   \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}%
10954   \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}%
10955   \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}%
10956   \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}%
10957   \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}%
10958   \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}%
10959   \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}%
10960   \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}%
10961   \DeclareUnicodeCharacter{2299}{\ensuremath\odot}%
10962   \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}%
10963   \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}%
10964   \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}%
10965   \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}%
10966   \DeclareUnicodeCharacter{22A8}{\ensuremath\models}%
10967   \DeclareUnicodeCharacter{22B4}{\ensuremath\unlhd}%
10968   \DeclareUnicodeCharacter{22B5}{\ensuremath\unrhd}%
10969   \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}%
10970   \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}%
10971   \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}%
10972   \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}%
10973   \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}%
10974   \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}%
10975   \DeclareUnicodeCharacter{22C6}{\ensuremath\star}%
10976   \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}%
10977   \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}%
10978   \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}%
10979   \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}%
10980   \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}%
10981   \DeclareUnicodeCharacter{2322}{\ensuremath\frown}%
10982   \DeclareUnicodeCharacter{2323}{\ensuremath\smile}%
10983   %
10984   \DeclareUnicodeCharacter{25A1}{\ensuremath\Box}%
10985   \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
10986   \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
10987   \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
10988   \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
10989   \DeclareUnicodeCharacter{25C7}{\ensuremath\Diamond}%
10990   \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}%
10991   \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}%
10992   \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}%
10993   \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}%
10994   \DeclareUnicodeCharacter{266D}{\ensuremath\flat}%
10995   \DeclareUnicodeCharacter{266E}{\ensuremath\natural}%
10996   \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}%
10997   \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}%
10998   \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}%
10999   \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}%
11000   \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}%
11001   \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}%
11002   \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}%
11003   \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}%
11004   \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}%
11005   \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}%
11006   \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}%
11007   \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}%
11008   \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}%
11009   \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}%
11010   \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}%
11011   \DeclareUnicodeCharacter{2A1D}{\ensuremath\Join}%
11012   \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}%
11013   \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}%
11014   \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}%
11015   %
11016   \global\mathchardef\checkmark="1370% actually the square root sign
11017   \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}%
11018 }% end of \unicodechardefs
11019
11020 % UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
11021 % It makes the setting that replace UTF-8 byte sequence.
11022 \def\utfeightchardefs{%
11023   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
11024   \unicodechardefs
11025 }
11026
11027 % Whether the active definitions of non-ASCII characters expand to
11028 % non-active tokens with the same character code.  This is used to
11029 % write characters literally, instead of using active definitions for
11030 % printing the correct glyphs.
11031 \newif\ifpassthroughchars
11032 \passthroughcharsfalse
11033
11034 % For native Unicode (XeTeX and LuaTeX)
11035 % Definition macro to replace / pass-through the Unicode character
11036 %
11037 \def\DeclareUnicodeCharacterNative#1#2{%
11038   \catcode"#1=\active
11039   \def\dodeclareunicodecharacternative##1##2##3{%
11040     \begingroup
11041       \uccode`\~="##2\relax
11042       \uppercase{\gdef~}{%
11043         \ifpassthroughchars
11044           ##1%
11045         \else
11046           ##3%
11047         \fi
11048       }
11049     \endgroup
11050   }
11051   \begingroup
11052     \uccode`\.="#1\relax
11053     \uppercase{\def\UTFNativeTmp{.}}%
11054     \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
11055   \endgroup
11056 }
11057
11058 % Native Unicode (XeTeX and LuaTeX) character replacing definitions
11059 % It makes the setting that replace the Unicode characters.
11060 \def\nativeunicodechardefs{%
11061   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
11062   \unicodechardefs
11063 }
11064
11065 % For native Unicode (XeTeX and LuaTeX).  Make the character token expand
11066 % to the sequences given in \unicodechardefs for printing.
11067 \def\DeclareUnicodeCharacterNativeAtU#1#2{%
11068   \def\UTFAtUTmp{#2}
11069   \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
11070 }
11071
11072 % Native Unicode (XeTeX and LuaTeX) @U command definitions
11073 \def\nativeunicodechardefsatu{%
11074   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
11075   \unicodechardefs
11076 }
11077
11078 % US-ASCII character definitions.
11079 \def\asciichardefs{% nothing need be done
11080    \relax
11081 }
11082
11083 % define all the unicode characters we know about, for the sake of @U.
11084 \iftxinativeunicodecapable
11085   \nativeunicodechardefsatu
11086 \else
11087   \utfeightchardefs
11088 \fi
11089
11090
11091 % Make non-ASCII characters printable again for compatibility with
11092 % existing Texinfo documents that may use them, even without declaring a
11093 % document encoding.
11094 %
11095 \setnonasciicharscatcode \other
11096
11097
11098 \message{formatting,}
11099
11100 \newdimen\defaultparindent \defaultparindent = 15pt
11101
11102 \chapheadingskip = 15pt plus 4pt minus 2pt
11103 \secheadingskip = 12pt plus 3pt minus 2pt
11104 \subsecheadingskip = 9pt plus 2pt minus 2pt
11105
11106 % Prevent underfull vbox error messages.
11107 \vbadness = 10000
11108
11109 % Don't be very finicky about underfull hboxes, either.
11110 \hbadness = 6666
11111
11112 % Following George Bush, get rid of widows and orphans.
11113 \widowpenalty=10000
11114 \clubpenalty=10000
11115
11116 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
11117 % using an old version of TeX, don't do anything.  We want the amount of
11118 % stretch added to depend on the line length, hence the dependence on
11119 % \hsize.  We call this whenever the paper size is set.
11120 %
11121 \def\setemergencystretch{%
11122   \ifx\emergencystretch\thisisundefined
11123     % Allow us to assign to \emergencystretch anyway.
11124     \def\emergencystretch{\dimen0}%
11125   \else
11126     \emergencystretch = .15\hsize
11127   \fi
11128 }
11129
11130 % Parameters in order: 1) textheight; 2) textwidth;
11131 % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11132 % 7) physical page height; 8) physical page width.
11133 %
11134 % We also call \setleading{\textleading}, so the caller should define
11135 % \textleading.  The caller should also set \parskip.
11136 %
11137 \def\internalpagesizes#1#2#3#4#5#6#7#8{%
11138   \voffset = #3\relax
11139   \topskip = #6\relax
11140   \splittopskip = \topskip
11141   %
11142   \vsize = #1\relax
11143   \advance\vsize by \topskip
11144   \outervsize = \vsize
11145   \advance\outervsize by 2\topandbottommargin
11146   \txipageheight = \vsize
11147   %
11148   \hsize = #2\relax
11149   \outerhsize = \hsize
11150   \advance\outerhsize by 0.5in
11151   \txipagewidth = \hsize
11152   %
11153   \normaloffset = #4\relax
11154   \bindingoffset = #5\relax
11155   %
11156   \ifpdf
11157     \pdfpageheight #7\relax
11158     \pdfpagewidth #8\relax
11159     % if we don't reset these, they will remain at "1 true in" of
11160     % whatever layout pdftex was dumped with.
11161     \pdfhorigin = 1 true in
11162     \pdfvorigin = 1 true in
11163   \else
11164     \ifx\XeTeXrevision\thisisundefined
11165     \else
11166       \pdfpageheight #7\relax
11167       \pdfpagewidth #8\relax
11168       % XeTeX does not have \pdfhorigin and \pdfvorigin.
11169     \fi
11170   \fi
11171   %
11172   \setleading{\textleading}
11173   %
11174   \parindent = \defaultparindent
11175   \setemergencystretch
11176 }
11177
11178 % @letterpaper (the default).
11179 \def\letterpaper{{\globaldefs = 1
11180   \parskip = 3pt plus 2pt minus 1pt
11181   \textleading = 13.2pt
11182   %
11183   % If page is nothing but text, make it come out even.
11184   \internalpagesizes{607.2pt}{6in}% that's 46 lines
11185                     {\voffset}{.25in}%
11186                     {\bindingoffset}{36pt}%
11187                     {11in}{8.5in}%
11188 }}
11189
11190 % Use @smallbook to reset parameters for 7x9.25 trim size.
11191 \def\smallbook{{\globaldefs = 1
11192   \parskip = 2pt plus 1pt
11193   \textleading = 12pt
11194   %
11195   \internalpagesizes{7.5in}{5in}%
11196                     {-.2in}{0in}%
11197                     {\bindingoffset}{16pt}%
11198                     {9.25in}{7in}%
11199   %
11200   \lispnarrowing = 0.3in
11201   \tolerance = 700
11202   \hfuzz = 1pt
11203   \contentsrightmargin = 0pt
11204   \defbodyindent = .5cm
11205 }}
11206
11207 % Use @smallerbook to reset parameters for 6x9 trim size.
11208 % (Just testing, parameters still in flux.)
11209 \def\smallerbook{{\globaldefs = 1
11210   \parskip = 1.5pt plus 1pt
11211   \textleading = 12pt
11212   %
11213   \internalpagesizes{7.4in}{4.8in}%
11214                     {-.2in}{-.4in}%
11215                     {0pt}{14pt}%
11216                     {9in}{6in}%
11217   %
11218   \lispnarrowing = 0.25in
11219   \tolerance = 700
11220   \hfuzz = 1pt
11221   \contentsrightmargin = 0pt
11222   \defbodyindent = .4cm
11223 }}
11224
11225 % Use @afourpaper to print on European A4 paper.
11226 \def\afourpaper{{\globaldefs = 1
11227   \parskip = 3pt plus 2pt minus 1pt
11228   \textleading = 13.2pt
11229   %
11230   % Double-side printing via postscript on Laserjet 4050
11231   % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11232   % To change the settings for a different printer or situation, adjust
11233   % \normaloffset until the front-side and back-side texts align.  Then
11234   % do the same for \bindingoffset.  You can set these for testing in
11235   % your texinfo source file like this:
11236   % @tex
11237   % \global\normaloffset = -6mm
11238   % \global\bindingoffset = 10mm
11239   % @end tex
11240   \internalpagesizes{673.2pt}{160mm}% that's 51 lines
11241                     {\voffset}{\hoffset}%
11242                     {\bindingoffset}{44pt}%
11243                     {297mm}{210mm}%
11244   %
11245   \tolerance = 700
11246   \hfuzz = 1pt
11247   \contentsrightmargin = 0pt
11248   \defbodyindent = 5mm
11249 }}
11250
11251 % Use @afivepaper to print on European A5 paper.
11252 % From romildo@urano.iceb.ufop.br, 2 July 2000.
11253 % He also recommends making @example and @lisp be small.
11254 \def\afivepaper{{\globaldefs = 1
11255   \parskip = 2pt plus 1pt minus 0.1pt
11256   \textleading = 12.5pt
11257   %
11258   \internalpagesizes{160mm}{120mm}%
11259                     {\voffset}{\hoffset}%
11260                     {\bindingoffset}{8pt}%
11261                     {210mm}{148mm}%
11262   %
11263   \lispnarrowing = 0.2in
11264   \tolerance = 800
11265   \hfuzz = 1.2pt
11266   \contentsrightmargin = 0pt
11267   \defbodyindent = 2mm
11268   \tableindent = 12mm
11269 }}
11270
11271 % A specific text layout, 24x15cm overall, intended for A4 paper.
11272 \def\afourlatex{{\globaldefs = 1
11273   \afourpaper
11274   \internalpagesizes{237mm}{150mm}%
11275                     {\voffset}{4.6mm}%
11276                     {\bindingoffset}{7mm}%
11277                     {297mm}{210mm}%
11278   %
11279   % Must explicitly reset to 0 because we call \afourpaper.
11280   \globaldefs = 0
11281 }}
11282
11283 % Use @afourwide to print on A4 paper in landscape format.
11284 \def\afourwide{{\globaldefs = 1
11285   \afourpaper
11286   \internalpagesizes{241mm}{165mm}%
11287                     {\voffset}{-2.95mm}%
11288                     {\bindingoffset}{7mm}%
11289                     {297mm}{210mm}%
11290   \globaldefs = 0
11291 }}
11292
11293 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11294 % Perhaps we should allow setting the margins, \topskip, \parskip,
11295 % and/or leading, also. Or perhaps we should compute them somehow.
11296 %
11297 \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
11298 \def\pagesizesyyy#1,#2,#3\finish{{%
11299   \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11300   \globaldefs = 1
11301   %
11302   \parskip = 3pt plus 2pt minus 1pt
11303   \setleading{\textleading}%
11304   %
11305   \dimen0 = #1\relax
11306   \advance\dimen0 by \voffset
11307   %
11308   \dimen2 = \hsize
11309   \advance\dimen2 by \normaloffset
11310   %
11311   \internalpagesizes{#1}{\hsize}%
11312                     {\voffset}{\normaloffset}%
11313                     {\bindingoffset}{44pt}%
11314                     {\dimen0}{\dimen2}%
11315 }}
11316
11317 % Set default to letter.
11318 %
11319 \letterpaper
11320
11321
11322 \message{and turning on texinfo input format.}
11323
11324 \def^^L{\par} % remove \outer, so ^L can appear in an @comment
11325
11326 % DEL is a comment character, in case @c does not suffice.
11327 \catcode`\^^? = 14
11328
11329 % Define macros to output various characters with catcode for normal text.
11330 \catcode`\"=\other \def\normaldoublequote{"}
11331 \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11332 \catcode`\+=\other \def\normalplus{+}
11333 \catcode`\<=\other \def\normalless{<}
11334 \catcode`\>=\other \def\normalgreater{>}
11335 \catcode`\^=\other \def\normalcaret{^}
11336 \catcode`\_=\other \def\normalunderscore{_}
11337 \catcode`\|=\other \def\normalverticalbar{|}
11338 \catcode`\~=\other \def\normaltilde{~}
11339
11340 % This macro is used to make a character print one way in \tt
11341 % (where it can probably be output as-is), and another way in other fonts,
11342 % where something hairier probably needs to be done.
11343 %
11344 % #1 is what to print if we are indeed using \tt; #2 is what to print
11345 % otherwise.  Since all the Computer Modern typewriter fonts have zero
11346 % interword stretch (and shrink), and it is reasonable to expect all
11347 % typewriter fonts to have this, we can check that font parameter.
11348 %
11349 \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
11350
11351 % Same as above, but check for italic font.  Actually this also catches
11352 % non-italic slanted fonts since it is impossible to distinguish them from
11353 % italic fonts.  But since this is only used by $ and it uses \sl anyway
11354 % this is not a problem.
11355 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
11356
11357 % Set catcodes for Texinfo file
11358
11359 % Active characters for printing the wanted glyph.
11360 % Most of these we simply print from the \tt font, but for some, we can
11361 % use math or other variants that look better in normal text.
11362 %
11363 \catcode`\"=\active
11364 \def\activedoublequote{{\tt\char34}}
11365 \let"=\activedoublequote
11366 \catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
11367 \chardef\hatchar=`\^
11368 \catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
11369
11370 \catcode`\_=\active
11371 \def_{\ifusingtt\normalunderscore\_}
11372 \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
11373 \let\realunder=_
11374
11375 \catcode`\|=\active \def|{{\tt\char124}}
11376
11377 \chardef \less=`\<
11378 \catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
11379 \chardef \gtr=`\>
11380 \catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11381 \catcode`\+=\active \def+{{\tt \char 43}}
11382 \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
11383 \catcode`\-=\active \let-=\normaldash
11384
11385
11386 % used for headline/footline in the output routine, in case the page
11387 % breaks in the middle of an @tex block.
11388 \def\texinfochars{%
11389   \let< = \activeless
11390   \let> = \activegtr
11391   \let~ = \activetilde 
11392   \let^ = \activehat
11393   \markupsetuplqdefault \markupsetuprqdefault 
11394   \let\b = \strong
11395   \let\i = \smartitalic
11396   % in principle, all other definitions in \tex have to be undone too.
11397 }
11398
11399 % Used sometimes to turn off (effectively) the active characters even after
11400 % parsing them.
11401 \def\turnoffactive{%
11402   \normalturnoffactive
11403   \otherbackslash
11404 }
11405
11406 \catcode`\@=0
11407
11408 % \backslashcurfont outputs one backslash character in current font,
11409 % as in \char`\\.
11410 \global\chardef\backslashcurfont=`\\
11411 \global\let\rawbackslashxx=\backslashcurfont  % let existing .??s files work
11412
11413 % \realbackslash is an actual character `\' with catcode other, and
11414 % \doublebackslash is two of them (for the pdf outlines).
11415 {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
11416
11417 % In Texinfo, backslash is an active character; it prints the backslash
11418 % in fixed width font.
11419 \catcode`\\=\active  % @ for escape char from now on.
11420
11421 % Print a typewriter backslash.  For math mode, we can't simply use
11422 % \backslashcurfont: the story here is that in math mode, the \char
11423 % of \backslashcurfont ends up printing the roman \ from the math symbol
11424 % font (because \char in math mode uses the \mathcode, and plain.tex
11425 % sets \mathcode`\\="026E).  Hence we use an explicit \mathchar,
11426 % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11427 % ignored family value; char position "5C).  We can't use " for the
11428 % usual hex value because it has already been made active.
11429
11430 @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
11431 @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
11432
11433 % \rawbackslash defines an active \ to do \backslashcurfont.
11434 % \otherbackslash defines an active \ to be a literal `\' character with
11435 % catcode other.  We switch back and forth between these.
11436 @gdef@rawbackslash{@let\=@backslashcurfont}
11437 @gdef@otherbackslash{@let\=@realbackslash}
11438
11439 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
11440 % the literal character `\'.
11441 %
11442 {@catcode`- = @active
11443  @gdef@normalturnoffactive{%
11444    @passthroughcharstrue
11445    @let-=@normaldash
11446    @let"=@normaldoublequote
11447    @let$=@normaldollar %$ font-lock fix
11448    @let+=@normalplus
11449    @let<=@normalless
11450    @let>=@normalgreater
11451    @let^=@normalcaret
11452    @let_=@normalunderscore
11453    @let|=@normalverticalbar
11454    @let~=@normaltilde
11455    @let\=@ttbackslash
11456    @markupsetuplqdefault
11457    @markupsetuprqdefault
11458    @unsepspaces
11459  }
11460 }
11461
11462 % If a .fmt file is being used, characters that might appear in a file
11463 % name cannot be active until we have parsed the command line.
11464 % So turn them off again, and have @fixbackslash turn them back on.
11465 @catcode`+=@other @catcode`@_=@other
11466
11467 % \enablebackslashhack - allow file to begin `\input texinfo'
11468 %
11469 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
11470 % That is what \eatinput is for; after that, the `\' should revert to printing
11471 % a backslash.
11472 % If the file did not have a `\input texinfo', then it is turned off after
11473 % the first line; otherwise the first `\' in the file would cause an error.
11474 % This is used on the very last line of this file, texinfo.tex.
11475 % We also use @c to call @fixbackslash, in case ends of lines are hidden.
11476 {
11477 @catcode`@^=7
11478 @catcode`@^^M=13@gdef@enablebackslashhack{%
11479   @global@let\ = @eatinput%
11480   @catcode`@^^M=13%
11481   @def@c{@fixbackslash@c}%
11482   % Definition for the newline at the end of this file.
11483   @def ^^M{@let^^M@secondlinenl}%
11484   % Definition for a newline in the main Texinfo file.
11485   @gdef @secondlinenl{@fixbackslash}%
11486 }}
11487
11488 {@catcode`@^=7 @catcode`@^^M=13%
11489 @gdef@eatinput input texinfo#1^^M{@fixbackslash}}
11490
11491 % Emergency active definition of newline, in case an active newline token
11492 % appears by mistake.
11493 {@catcode`@^=7 @catcode13=13%
11494 @gdef@enableemergencynewline{%
11495   @gdef^^M{%
11496     @par%
11497     %<warning: active newline>@par%
11498 }}}
11499
11500
11501 @gdef@fixbackslash{%
11502   @ifx\@eatinput @let\ = @ttbackslash @fi
11503   @catcode13=5 % regular end of line
11504   @enableemergencynewline
11505   @let@c=@texinfoc
11506   % Also turn back on active characters that might appear in the input
11507   % file name, in case not using a pre-dumped format.
11508   @catcode`+=@active
11509   @catcode`@_=@active
11510   %
11511   % If texinfo.cnf is present on the system, read it.
11512   % Useful for site-wide @afourpaper, etc.  This macro, @fixbackslash, gets
11513   % called at the beginning of every Texinfo file.  Not opening texinfo.cnf
11514   % directly in this file, texinfo.tex, makes it possible to make a format
11515   % file for Texinfo.
11516   %
11517   @openin 1 texinfo.cnf
11518   @ifeof 1 @else @input texinfo.cnf @fi
11519   @closein 1
11520 }
11521
11522
11523 % Say @foo, not \foo, in error messages.
11524 @escapechar = `@@
11525
11526 % These (along with & and #) are made active for url-breaking, so need
11527 % active definitions as the normal characters.
11528 @def@normaldot{.}
11529 @def@normalquest{?}
11530 @def@normalslash{/}
11531
11532 % These look ok in all fonts, so just make them not special.
11533 % @hashchar{} gets its own user-level command, because of #line.
11534 @catcode`@& = @other @def@normalamp{&}
11535 @catcode`@# = @other @def@normalhash{#}
11536 @catcode`@% = @other @def@normalpercent{%}
11537
11538 @let @hashchar = @normalhash
11539
11540 @c Finally, make ` and ' active, so that txicodequoteundirected and
11541 @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
11542 @c don't make ` and ' active, @code will not get them as active chars.
11543 @c Do this last of all since we use ` in the previous @catcode assignments.
11544 @catcode`@'=@active
11545 @catcode`@`=@active
11546 @markupsetuplqdefault
11547 @markupsetuprqdefault
11548
11549 @c Local variables:
11550 @c eval: (add-hook 'write-file-hooks 'time-stamp)
11551 @c page-delimiter: "^\\\\message\\|emacs-page"
11552 @c time-stamp-start: "def\\\\texinfoversion{"
11553 @c time-stamp-format: "%:y-%02m-%02d.%02H"
11554 @c time-stamp-end: "}"
11555 @c End:
11556
11557 @c vim:sw=2:
11558
11559 @ignore
11560    arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
11561 @end ignore
11562 @enablebackslashhack