Imported Upstream version 4.0.41
[platform/upstream/mtools.git] / 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{2022-09-15.17}
7 %
8 % Copyright 1985, 1986, 1988, 1990-2022 Free Software Foundation, Inc.
9 %
10 % This texinfo.tex file is free software: you can redistribute it and/or
11 % modify it under the terms of the GNU General Public License as
12 % published by the Free Software Foundation, either version 3 of the
13 % License, or (at your option) any later version.
14 %
15 % This texinfo.tex file is distributed in the hope that it will be
16 % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17 % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 % General Public License for more details.
19 %
20 % You should have received a copy of the GNU General Public License
21 % along with this program.  If not, see <https://www.gnu.org/licenses/>.
22 %
23 % As a special exception, when this file is read by TeX when processing
24 % a Texinfo source document, you may use the result without
25 % restriction. This Exception is an additional permission under section 7
26 % of the GNU General Public License, version 3 ("GPLv3").
27 %
28 % Please try the latest version of texinfo.tex before submitting bug
29 % reports; you can get the latest version from:
30 %   https://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
31 %   https://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
32 %   https://www.gnu.org/software/texinfo/ (the Texinfo home page)
33 % The texinfo.tex in any given distribution could well be out
34 % of date, so if that's what you're using, please check.
35 %
36 % Send bug reports to bug-texinfo@gnu.org.  Please include a
37 % complete document in each bug report with which we can reproduce the
38 % problem.  Patches are, of course, greatly appreciated.
39 %
40 % To process a Texinfo manual with TeX, it's most reliable to use the
41 % texi2dvi shell script that comes with the distribution.  For a simple
42 % manual foo.texi, however, you can get away with this:
43 %   tex foo.texi
44 %   texindex foo.??
45 %   tex foo.texi
46 %   tex foo.texi
47 %   dvips foo.dvi -o  # or whatever; this makes foo.ps.
48 % The extra TeX runs get the cross-reference information correct.
49 % Sometimes one run after texindex suffices, and sometimes you need more
50 % than two; texi2dvi does it as many times as necessary.
51 %
52 % It is possible to adapt texinfo.tex for other languages, to some
53 % extent.  You can get the existing language-specific files from the
54 % full Texinfo distribution.
55 %
56 % The GNU Texinfo home page is https://www.gnu.org/software/texinfo.
57
58
59 \message{Loading texinfo [version \texinfoversion]:}
60
61 % If in a .fmt file, print the version number
62 % and turn on active characters that we couldn't do earlier because
63 % they might have appeared in the input file name.
64 \everyjob{\message{[Texinfo version \texinfoversion]}%
65   \catcode`+=\active \catcode`\_=\active}
66
67 % LaTeX's \typeout.  This ensures that the messages it is used for
68 % are identical in format to the corresponding ones from latex/pdflatex.
69 \def\typeout{\immediate\write17}%
70
71 \chardef\other=12
72
73 % We never want plain's \outer definition of \+ in Texinfo.
74 % For @tex, we can use \tabalign.
75 \let\+ = \relax
76
77 % Save some plain tex macros whose names we will redefine.
78 \let\ptexb=\b
79 \let\ptexbullet=\bullet
80 \let\ptexc=\c
81 \let\ptexcomma=\,
82 \let\ptexdot=\.
83 \let\ptexdots=\dots
84 \let\ptexend=\end
85 \let\ptexequiv=\equiv
86 \let\ptexexclam=\!
87 \let\ptexfootnote=\footnote
88 \let\ptexgtr=>
89 \let\ptexhat=^
90 \let\ptexi=\i
91 \let\ptexindent=\indent
92 \let\ptexinsert=\insert
93 \let\ptexlbrace=\{
94 \let\ptexless=<
95 \let\ptexnewwrite\newwrite
96 \let\ptexnoindent=\noindent
97 \let\ptexplus=+
98 \let\ptexraggedright=\raggedright
99 \let\ptexrbrace=\}
100 \let\ptexslash=\/
101 \let\ptexsp=\sp
102 \let\ptexstar=\*
103 \let\ptexsup=\sup
104 \let\ptext=\t
105 \let\ptextop=\top
106 {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
107
108 % If this character appears in an error message or help string, it
109 % starts a new line in the output.
110 \newlinechar = `^^J
111
112 % Use TeX 3.0's \inputlineno to get the line number, for better error
113 % messages, but if we're using an old version of TeX, don't do anything.
114 %
115 \ifx\inputlineno\thisisundefined
116   \let\linenumber = \empty % Pre-3.0.
117 \else
118   \def\linenumber{l.\the\inputlineno:\space}
119 \fi
120
121 % Set up fixed words for English if not already set.
122 \ifx\putwordAppendix\undefined  \gdef\putwordAppendix{Appendix}\fi
123 \ifx\putwordChapter\undefined   \gdef\putwordChapter{Chapter}\fi
124 \ifx\putworderror\undefined     \gdef\putworderror{error}\fi
125 \ifx\putwordfile\undefined      \gdef\putwordfile{file}\fi
126 \ifx\putwordin\undefined        \gdef\putwordin{in}\fi
127 \ifx\putwordIndexIsEmpty\undefined       \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
128 \ifx\putwordIndexNonexistent\undefined   \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
129 \ifx\putwordInfo\undefined      \gdef\putwordInfo{Info}\fi
130 \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
131 \ifx\putwordMethodon\undefined  \gdef\putwordMethodon{Method on}\fi
132 \ifx\putwordNoTitle\undefined   \gdef\putwordNoTitle{No Title}\fi
133 \ifx\putwordof\undefined        \gdef\putwordof{of}\fi
134 \ifx\putwordon\undefined        \gdef\putwordon{on}\fi
135 \ifx\putwordpage\undefined      \gdef\putwordpage{page}\fi
136 \ifx\putwordsection\undefined   \gdef\putwordsection{section}\fi
137 \ifx\putwordSection\undefined   \gdef\putwordSection{Section}\fi
138 \ifx\putwordsee\undefined       \gdef\putwordsee{see}\fi
139 \ifx\putwordSee\undefined       \gdef\putwordSee{See}\fi
140 \ifx\putwordShortTOC\undefined  \gdef\putwordShortTOC{Short Contents}\fi
141 \ifx\putwordTOC\undefined       \gdef\putwordTOC{Table of Contents}\fi
142 %
143 \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
144 \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
145 \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
146 \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
147 \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
148 \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
149 \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
150 \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
151 \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
152 \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
153 \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
154 \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
155 %
156 \ifx\putwordDefmac\undefined    \gdef\putwordDefmac{Macro}\fi
157 \ifx\putwordDefspec\undefined   \gdef\putwordDefspec{Special Form}\fi
158 \ifx\putwordDefvar\undefined    \gdef\putwordDefvar{Variable}\fi
159 \ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
160 \ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
161
162 % Give the space character the catcode for a space.
163 \def\spaceisspace{\catcode`\ =10\relax}
164
165 % Likewise for ^^M, the end of line character.
166 \def\endlineisspace{\catcode13=10\relax}
167
168 \chardef\dashChar  = `\-
169 \chardef\slashChar = `\/
170 \chardef\underChar = `\_
171
172 % Ignore a token.
173 %
174 \def\gobble#1{}
175
176 % The following is used inside several \edef's.
177 \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
178
179 % Hyphenation fixes.
180 \hyphenation{
181   Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
182   ap-pen-dix bit-map bit-maps
183   data-base data-bases eshell fall-ing half-way long-est man-u-script
184   man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
185   par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
186   spell-ing spell-ings
187   stand-alone strong-est time-stamp time-stamps which-ever white-space
188   wide-spread wrap-around
189 }
190
191 % Sometimes it is convenient to have everything in the transcript file
192 % and nothing on the terminal.  We don't just call \tracingall here,
193 % since that produces some useless output on the terminal.  We also make
194 % some effort to order the tracing commands to reduce output in the log
195 % file; cf. trace.sty in LaTeX.
196 %
197 \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
198 \def\loggingall{%
199   \tracingstats2
200   \tracingpages1
201   \tracinglostchars2  % 2 gives us more in etex
202   \tracingparagraphs1
203   \tracingoutput1
204   \tracingmacros2
205   \tracingrestores1
206   \showboxbreadth\maxdimen \showboxdepth\maxdimen
207   \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
208     \tracingscantokens1
209     \tracingifs1
210     \tracinggroups1
211     \tracingnesting2
212     \tracingassigns1
213   \fi
214   \tracingcommands3  % 3 gives us more in etex
215   \errorcontextlines16
216 }%
217
218 % @errormsg{MSG}.  Do the index-like expansions on MSG, but if things
219 % aren't perfect, it's not the end of the world, being an error message,
220 % after all.
221 %
222 \def\errormsg{\begingroup \indexnofonts \doerrormsg}
223 \def\doerrormsg#1{\errmessage{#1}}
224
225 % add check for \lastpenalty to plain's definitions.  If the last thing
226 % we did was a \nobreak, we don't want to insert more space.
227 %
228 \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
229   \removelastskip\penalty-50\smallskip\fi\fi}
230 \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
231   \removelastskip\penalty-100\medskip\fi\fi}
232 \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
233   \removelastskip\penalty-200\bigskip\fi\fi}
234
235 %\f Output routine
236 %
237
238 % For a final copy, take out the rectangles
239 % that mark overfull boxes (in case you have decided
240 % that the text looks ok even though it passes the margin).
241 %
242 \def\finalout{\overfullrule=0pt }
243
244 % Output a mark which sets \thischapter, \thissection and \thiscolor.
245 % We dump everything together because we only have one kind of mark.
246 % This works because we only use \botmark / \topmark, not \firstmark.
247 %
248 % A mark contains a subexpression of the \ifcase ... \fi construct.
249 % \get*marks macros below extract the needed part using \ifcase.
250 %
251 % Another complication is to let the user choose whether \thischapter
252 % (\thissection) refers to the chapter (section) in effect at the top
253 % of a page, or that at the bottom of a page.
254
255 % \domark is called twice inside \chapmacro, to add one
256 % mark before the section break, and one after.
257 %   In the second call \prevchapterdefs is the same as \currentchapterdefs,
258 % and \prevsectiondefs is the same as \currentsectiondefs.
259 %   Then if the page is not broken at the mark, some of the previous
260 % section appears on the page, and we can get the name of this section
261 % from \firstmark for @everyheadingmarks top.
262 %   @everyheadingmarks bottom uses \botmark.
263 %
264 % See page 260 of The TeXbook.
265 \def\domark{%
266   \toks0=\expandafter{\currentchapterdefs}%
267   \toks2=\expandafter{\currentsectiondefs}%
268   \toks4=\expandafter{\prevchapterdefs}%
269   \toks6=\expandafter{\prevsectiondefs}%
270   \toks8=\expandafter{\currentcolordefs}%
271   \mark{%
272                    \the\toks0 \the\toks2  % 0: marks for @everyheadingmarks top
273       \noexpand\or \the\toks4 \the\toks6  % 1: for @everyheadingmarks bottom
274     \noexpand\else \the\toks8             % 2: color marks
275   }%
276 }
277
278 % \gettopheadingmarks, \getbottomheadingmarks,
279 % \getcolormarks - extract needed part of mark.
280 %
281 % \topmark doesn't work for the very first chapter (after the title
282 % page or the contents), so we use \firstmark there -- this gets us
283 % the mark with the chapter defs, unless the user sneaks in, e.g.,
284 % @setcolor (or @url, or @link, etc.) between @contents and the very
285 % first @chapter.
286 \def\gettopheadingmarks{%
287   \ifcase0\the\savedtopmark\fi
288   \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
289 }
290 \def\getbottomheadingmarks{\ifcase1\botmark\fi}
291 \def\getcolormarks{\ifcase2\the\savedtopmark\fi}
292
293 % Avoid "undefined control sequence" errors.
294 \def\currentchapterdefs{}
295 \def\currentsectiondefs{}
296 \def\currentsection{}
297 \def\prevchapterdefs{}
298 \def\prevsectiondefs{}
299 \def\currentcolordefs{}
300
301 % Margin to add to right of even pages, to left of odd pages.
302 \newdimen\bindingoffset
303 \newdimen\normaloffset
304 \newdimen\txipagewidth \newdimen\txipageheight
305
306 % Main output routine.
307 %
308 \chardef\PAGE = 255
309 \newtoks\defaultoutput
310 \defaultoutput = {\savetopmark\onepageout{\pagecontents\PAGE}}
311 \output=\expandafter{\the\defaultoutput}
312
313 \newbox\headlinebox
314 \newbox\footlinebox
315
316 % When outputting the double column layout for indices, an output routine
317 % is run several times, which hides the original value of \topmark.  This
318 % can lead to a page heading being output and duplicating the chapter heading
319 % of the index.  Hence, save the contents of \topmark at the beginning of
320 % the output routine.  The saved contents are valid until we actually
321 % \shipout a page.
322 %
323 % (We used to run a short output routine to actually set \topmark and
324 % \firstmark to the right values, but if this was called with an empty page
325 % containing whatsits for writing index entries, the whatsits would be thrown
326 % away and the index auxiliary file would remain empty.)
327 %
328 \newtoks\savedtopmark
329 \newif\iftopmarksaved
330 \topmarksavedtrue
331 \def\savetopmark{%
332   \iftopmarksaved\else
333     \global\savedtopmark=\expandafter{\topmark}%
334     \global\topmarksavedtrue
335   \fi
336 }
337
338 % \onepageout takes a vbox as an argument.
339 % \shipout a vbox for a single page, adding an optional header, footer
340 % and footnote.  This also causes index entries for this page to be written
341 % to the auxiliary files.
342 %
343 \def\onepageout#1{%
344   \hoffset=\normaloffset
345   %
346   \ifodd\pageno  \advance\hoffset by \bindingoffset
347   \else \advance\hoffset by -\bindingoffset\fi
348   %
349   \checkchapterpage
350   %
351   % Retrieve the information for the headings from the marks in the page,
352   % and call Plain TeX's \makeheadline and \makefootline, which use the
353   % values in \headline and \footline.
354   %
355   % Common context changes for both heading and footing.
356   % Do this outside of the \shipout so @code etc. will be expanded in
357   % the headline as they should be, not taken literally (outputting ''code).
358   \def\commonheadfootline{\let\hsize=\txipagewidth \texinfochars}
359   %
360   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
361   \global\setbox\headlinebox = \vbox{\commonheadfootline \makeheadline}%
362   \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
363   \global\setbox\footlinebox = \vbox{\commonheadfootline \makefootline}%
364   %
365   {%
366     % Set context for writing to auxiliary files like index files.
367     % Have to do this stuff outside the \shipout because we want it to
368     % take effect in \write's, yet the group defined by the \vbox ends
369     % before the \shipout runs.
370     %
371     \atdummies         % don't expand commands in the output.
372     \turnoffactive
373     \shipout\vbox{%
374       % Do this early so pdf references go to the beginning of the page.
375       \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
376       %
377       \unvbox\headlinebox
378       \pagebody{#1}%
379       \ifdim\ht\footlinebox > 0pt
380         % Only leave this space if the footline is nonempty.
381         % (We lessened \vsize for it in \oddfootingyyy.)
382         % The \baselineskip=24pt in plain's \makefootline has no effect.
383         \vskip 24pt
384         \unvbox\footlinebox
385       \fi
386       %
387     }%
388   }%
389   \global\topmarksavedfalse
390   \advancepageno
391   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
392 }
393
394 \newinsert\margin \dimen\margin=\maxdimen
395
396 % Main part of page, including any footnotes
397 \def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
398 {\catcode`\@ =11
399 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
400 % marginal hacks, juha@viisa.uucp (Juha Takala)
401 \ifvoid\margin\else % marginal info is present
402   \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
403 \dimen@=\dp#1\relax \unvbox#1\relax
404 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
405 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
406 }
407
408 % Check if we are on the first page of a chapter.  Used for printing headings.
409 \newif\ifchapterpage
410 \def\checkchapterpage{%
411   % Get the chapter that was current at the end of the last page
412   \ifcase1\the\savedtopmark\fi
413   \let\prevchaptername\thischaptername
414   %
415   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
416   \let\curchaptername\thischaptername
417   %
418   \ifx\curchaptername\prevchaptername
419     \chapterpagefalse
420   \else
421     \chapterpagetrue
422   \fi
423 }
424
425 % Argument parsing
426
427 % Parse an argument, then pass it to #1.  The argument is the rest of
428 % the input line (except we remove a trailing comment).  #1 should be a
429 % macro which expects an ordinary undelimited TeX argument.
430 % For example, \def\foo{\parsearg\fooxxx}.
431 %
432 \def\parsearg{\parseargusing{}}
433 \def\parseargusing#1#2{%
434   \def\argtorun{#2}%
435   \begingroup
436     \obeylines
437     \spaceisspace
438     #1%
439     \parseargline\empty% Insert the \empty token, see \finishparsearg below.
440 }
441
442 {\obeylines %
443   \gdef\parseargline#1^^M{%
444     \endgroup % End of the group started in \parsearg.
445     \argremovecomment #1\comment\ArgTerm%
446   }%
447 }
448
449 % First remove any @comment, then any @c comment.  Pass the result on to
450 % \argcheckspaces.
451 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
452 \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
453
454 % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
455 %
456 % \argremovec might leave us with trailing space, e.g.,
457 %    @end itemize  @c foo
458 % This space token undergoes the same procedure and is eventually removed
459 % by \finishparsearg.
460 %
461 \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
462 \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
463 \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
464   \def\temp{#3}%
465   \ifx\temp\empty
466     % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
467     \let\temp\finishparsearg
468   \else
469     \let\temp\argcheckspaces
470   \fi
471   % Put the space token in:
472   \temp#1 #3\ArgTerm
473 }
474
475 % If a _delimited_ argument is enclosed in braces, they get stripped; so
476 % to get _exactly_ the rest of the line, we had to prevent such situation.
477 % We prepended an \empty token at the very beginning and we expand it now,
478 % just before passing the control to \argtorun.
479 % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
480 % either the null string, or it ends with \^^M---thus there is no danger
481 % that a pair of braces would be stripped.
482 %
483 % But first, we have to remove the trailing space token.
484 %
485 \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
486
487
488 % \parseargdef - define a command taking an argument on the line
489 %
490 % \parseargdef\foo{...}
491 %       is roughly equivalent to
492 % \def\foo{\parsearg\Xfoo}
493 % \def\Xfoo#1{...}
494 \def\parseargdef#1{%
495   \expandafter \doparseargdef \csname\string#1\endcsname #1%
496 }
497 \def\doparseargdef#1#2{%
498   \def#2{\parsearg#1}%
499   \def#1##1%
500 }
501
502 % Several utility definitions with active space:
503 {
504   \obeyspaces
505   \gdef\obeyedspace{ }
506
507   % Make each space character in the input produce a normal interword
508   % space in the output.  Don't allow a line break at this space, as this
509   % is used only in environments like @example, where each line of input
510   % should produce a line of output anyway.
511   %
512   \gdef\sepspaces{\obeyspaces\let =\tie}
513
514   % If an index command is used in an @example environment, any spaces
515   % therein should become regular spaces in the raw index file, not the
516   % expansion of \tie (\leavevmode \penalty \@M \ ).
517   \gdef\unsepspaces{\let =\space}
518 }
519
520
521 \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
522
523 % Define the framework for environments in texinfo.tex.  It's used like this:
524 %
525 %   \envdef\foo{...}
526 %   \def\Efoo{...}
527 %
528 % It's the responsibility of \envdef to insert \begingroup before the
529 % actual body; @end closes the group after calling \Efoo.  \envdef also
530 % defines \thisenv, so the current environment is known; @end checks
531 % whether the environment name matches.  The \checkenv macro can also be
532 % used to check whether the current environment is the one expected.
533 %
534 % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
535 % are not treated as environments; they don't open a group.  (The
536 % implementation of @end takes care not to call \endgroup in this
537 % special case.)
538
539
540 % At run-time, environments start with this:
541 \def\startenvironment#1{\begingroup\def\thisenv{#1}}
542 % initialize
543 \let\thisenv\empty
544
545 % ... but they get defined via ``\envdef\foo{...}'':
546 \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
547 \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
548
549 % Check whether we're in the right environment:
550 \def\checkenv#1{%
551   \def\temp{#1}%
552   \ifx\thisenv\temp
553   \else
554     \badenverr
555   \fi
556 }
557
558 % Environment mismatch, #1 expected:
559 \def\badenverr{%
560   \errhelp = \EMsimple
561   \errmessage{This command can appear only \inenvironment\temp,
562     not \inenvironment\thisenv}%
563 }
564 \def\inenvironment#1{%
565   \ifx#1\empty
566     outside of any environment%
567   \else
568     in environment \expandafter\string#1%
569   \fi
570 }
571
572
573 % @end foo calls \checkenv and executes the definition of \Efoo.
574 \parseargdef\end{%
575   \if 1\csname iscond.#1\endcsname
576   \else
577     % The general wording of \badenverr may not be ideal.
578     \expandafter\checkenv\csname#1\endcsname
579     \csname E#1\endcsname
580     \endgroup
581   \fi
582 }
583
584 \newhelp\EMsimple{Press RETURN to continue.}
585
586
587 % Be sure we're in horizontal mode when doing a tie, since we make space
588 % equivalent to this in @example-like environments. Otherwise, a space
589 % at the beginning of a line will start with \penalty -- and
590 % since \penalty is valid in vertical mode, we'd end up putting the
591 % penalty on the vertical list instead of in the new paragraph.
592 {\catcode`@ = 11
593  % Avoid using \@M directly, because that causes trouble
594  % if the definition is written into an index file.
595  \global\let\tiepenalty = \@M
596  \gdef\tie{\leavevmode\penalty\tiepenalty\ }
597 }
598
599 % @: forces normal size whitespace following.
600 \def\:{\spacefactor=1000 }
601
602 % @* forces a line break.
603 \def\*{\unskip\hfil\break\hbox{}\ignorespaces}
604
605 % @/ allows a line break.
606 \let\/=\allowbreak
607
608 % @. is an end-of-sentence period.
609 \def\.{.\spacefactor=\endofsentencespacefactor\space}
610
611 % @! is an end-of-sentence bang.
612 \def\!{!\spacefactor=\endofsentencespacefactor\space}
613
614 % @? is an end-of-sentence query.
615 \def\?{?\spacefactor=\endofsentencespacefactor\space}
616
617 % @frenchspacing on|off  says whether to put extra space after punctuation.
618 %
619 \def\onword{on}
620 \def\offword{off}
621 %
622 \parseargdef\frenchspacing{%
623   \def\temp{#1}%
624   \ifx\temp\onword \plainfrenchspacing
625   \else\ifx\temp\offword \plainnonfrenchspacing
626   \else
627     \errhelp = \EMsimple
628     \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
629   \fi\fi
630 }
631
632 % @w prevents a word break.  Without the \leavevmode, @w at the
633 % beginning of a paragraph, when TeX is still in vertical mode, would
634 % produce a whole line of output instead of starting the paragraph.
635 \def\w#1{\leavevmode\hbox{#1}}
636
637 % @group ... @end group forces ... to be all on one page, by enclosing
638 % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
639 % to keep its height that of a normal line.  According to the rules for
640 % \topskip (p.114 of the TeXbook), the glue inserted is
641 % max (\topskip - \ht (first item), 0).  If that height is large,
642 % therefore, no glue is inserted, and the space between the headline and
643 % the text is small, which looks bad.
644 %
645 % Another complication is that the group might be very large.  This can
646 % cause the glue on the previous page to be unduly stretched, because it
647 % does not have much material.  In this case, it's better to add an
648 % explicit \vfill so that the extra space is at the bottom.  The
649 % threshold for doing this is if the group is more than \vfilllimit
650 % percent of a page (\vfilllimit can be changed inside of @tex).
651 %
652 \newbox\groupbox
653 \def\vfilllimit{0.7}
654 %
655 \envdef\group{%
656   \ifnum\catcode`\^^M=\active \else
657     \errhelp = \groupinvalidhelp
658     \errmessage{@group invalid in context where filling is enabled}%
659   \fi
660   \startsavinginserts
661   %
662   \setbox\groupbox = \vtop\bgroup
663     % Do @comment since we are called inside an environment such as
664     % @example, where each end-of-line in the input causes an
665     % end-of-line in the output.  We don't want the end-of-line after
666     % the `@group' to put extra space in the output.  Since @group
667     % should appear on a line by itself (according to the Texinfo
668     % manual), we don't worry about eating any user text.
669     \comment
670 }
671 %
672 % The \vtop produces a box with normal height and large depth; thus, TeX puts
673 % \baselineskip glue before it, and (when the next line of text is done)
674 % \lineskip glue after it.  Thus, space below is not quite equal to space
675 % above.  But it's pretty close.
676 \def\Egroup{%
677     % To get correct interline space between the last line of the group
678     % and the first line afterwards, we have to propagate \prevdepth.
679     \endgraf % Not \par, as it may have been set to \lisppar.
680     \global\dimen1 = \prevdepth
681   \egroup           % End the \vtop.
682   \addgroupbox
683   \prevdepth = \dimen1
684   \checkinserts
685 }
686
687 \def\addgroupbox{
688   % \dimen0 is the vertical size of the group's box.
689   \dimen0 = \ht\groupbox  \advance\dimen0 by \dp\groupbox
690   % \dimen2 is how much space is left on the page (more or less).
691   \dimen2 = \txipageheight   \advance\dimen2 by -\pagetotal
692   % if the group doesn't fit on the current page, and it's a big big
693   % group, force a page break.
694   \ifdim \dimen0 > \dimen2
695     \ifdim \pagetotal < \vfilllimit\txipageheight
696       \page
697     \fi
698   \fi
699   \box\groupbox
700 }
701
702 %
703 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
704 % message, so this ends up printing `@group can only ...'.
705 %
706 \newhelp\groupinvalidhelp{%
707 group can only be used in environments such as @example,^^J%
708 where each line of input produces a line of output.}
709
710 % @need space-in-mils
711 % forces a page break if there is not space-in-mils remaining.
712
713 \newdimen\mil  \mil=0.001in
714
715 \parseargdef\need{%
716   % Ensure vertical mode, so we don't make a big box in the middle of a
717   % paragraph.
718   \par
719   %
720   % If the @need value is less than one line space, it's useless.
721   \dimen0 = #1\mil
722   \dimen2 = \ht\strutbox
723   \advance\dimen2 by \dp\strutbox
724   \ifdim\dimen0 > \dimen2
725     % This is similar to the 'needspace' module in LaTeX.
726     % The first penalty allows a break if the end of the page is
727     % not too far away.  Following penalties and skips are discarded.
728     % Otherwise, require at least \dimen0 of vertical space.
729     %
730     % (We used to use a \vtop to reserve space, but this had spacing issues
731     % when followed by a section heading, as it was not a "discardable item".
732     % This also has the benefit of providing glue before the page break if
733     % there isn't enough space.)
734     \vskip0pt plus \dimen0
735     \penalty-100
736     \vskip0pt plus -\dimen0
737     \vskip \dimen0
738     \penalty9999
739     \vskip -\dimen0
740     \penalty0\relax % this hides the above glue from \safewhatsit and \dobreak
741   \fi
742 }
743
744 % @br   forces paragraph break (and is undocumented).
745
746 \let\br = \par
747
748 % @page forces the start of a new page.
749 %
750 \def\page{\par\vfill\supereject}
751
752 % @exdent text....
753 % outputs text on separate line in roman font, starting at standard page margin
754
755 % This records the amount of indent in the innermost environment.
756 % That's how much \exdent should take out.
757 \newskip\exdentamount
758
759 % This defn is used inside fill environments such as @defun.
760 \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
761
762 % This defn is used inside nofill environments such as @example.
763 \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
764   \leftline{\hskip\leftskip{\rm#1}}}}
765
766 % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
767 % paragraph.  For more general purposes, use the \margin insertion
768 % class.  WHICH is `l' or `r'.  Not documented, written for gawk manual.
769 %
770 \newskip\inmarginspacing \inmarginspacing=1cm
771 \def\strutdepth{\dp\strutbox}
772 %
773 \def\doinmargin#1#2{\strut\vadjust{%
774   \nobreak
775   \kern-\strutdepth
776   \vtop to \strutdepth{%
777     \baselineskip=\strutdepth
778     \vss
779     % if you have multiple lines of stuff to put here, you'll need to
780     % make the vbox yourself of the appropriate size.
781     \ifx#1l%
782       \llap{\ignorespaces #2\hskip\inmarginspacing}%
783     \else
784       \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
785     \fi
786     \null
787   }%
788 }}
789 \def\inleftmargin{\doinmargin l}
790 \def\inrightmargin{\doinmargin r}
791 %
792 % @inmargin{TEXT [, RIGHT-TEXT]}
793 % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
794 % else use TEXT for both).
795 %
796 \def\inmargin#1{\parseinmargin #1,,\finish}
797 \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
798   \setbox0 = \hbox{\ignorespaces #2}%
799   \ifdim\wd0 > 0pt
800     \def\lefttext{#1}%  have both texts
801     \def\righttext{#2}%
802   \else
803     \def\lefttext{#1}%  have only one text
804     \def\righttext{#1}%
805   \fi
806   %
807   \ifodd\pageno
808     \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
809   \else
810     \def\temp{\inleftmargin\lefttext}%
811   \fi
812   \temp
813 }
814
815 % @include FILE -- \input text of FILE.
816 %
817 \def\include{\parseargusing\filenamecatcodes\includezzz}
818 \def\includezzz#1{%
819   \pushthisfilestack
820   \def\thisfile{#1}%
821   {%
822     \makevalueexpandable  % we want to expand any @value in FILE.
823     \turnoffactive        % and allow special characters in the expansion
824     \indexnofonts         % Allow `@@' and other weird things in file names.
825     \wlog{texinfo.tex: doing @include of #1^^J}%
826     \edef\temp{\noexpand\input #1 }%
827     %
828     % This trickery is to read FILE outside of a group, in case it makes
829     % definitions, etc.
830     \expandafter
831   }\temp
832   \popthisfilestack
833 }
834 \def\filenamecatcodes{%
835   \catcode`\\=\other
836   \catcode`~=\other
837   \catcode`^=\other
838   \catcode`_=\other
839   \catcode`|=\other
840   \catcode`<=\other
841   \catcode`>=\other
842   \catcode`+=\other
843   \catcode`-=\other
844   \catcode`\`=\other
845   \catcode`\'=\other
846 }
847
848 \def\pushthisfilestack{%
849   \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
850 }
851 \def\pushthisfilestackX{%
852   \expandafter\pushthisfilestackY\thisfile\StackTerm
853 }
854 \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
855   \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
856 }
857
858 \def\popthisfilestack{\errthisfilestackempty}
859 \def\errthisfilestackempty{\errmessage{Internal error:
860   the stack of filenames is empty.}}
861 %
862 \def\thisfile{}
863
864 % @center line
865 % outputs that line, centered.
866 %
867 \parseargdef\center{%
868   \ifhmode
869     \let\centersub\centerH
870   \else
871     \let\centersub\centerV
872   \fi
873   \centersub{\hfil \ignorespaces#1\unskip \hfil}%
874   \let\centersub\relax % don't let the definition persist, just in case
875 }
876 \def\centerH#1{{%
877   \hfil\break
878   \advance\hsize by -\leftskip
879   \advance\hsize by -\rightskip
880   \line{#1}%
881   \break
882 }}
883 %
884 \newcount\centerpenalty
885 \def\centerV#1{%
886   % The idea here is the same as in \startdefun, \cartouche, etc.: if
887   % @center is the first thing after a section heading, we need to wipe
888   % out the negative parskip inserted by \sectionheading, but still
889   % prevent a page break here.
890   \centerpenalty = \lastpenalty
891   \ifnum\centerpenalty>10000 \vskip\parskip \fi
892   \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
893   \line{\kern\leftskip #1\kern\rightskip}%
894 }
895
896 % @sp n   outputs n lines of vertical space
897 %
898 \parseargdef\sp{\vskip #1\baselineskip}
899
900 % @comment ...line which is ignored...
901 % @c is the same as @comment
902 % @ignore ... @end ignore  is another way to write a comment
903
904
905 \def\c{\begingroup \catcode`\^^M=\active%
906 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
907 \cxxx}
908 {\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
909 %
910 \let\comment\c
911
912 % @paragraphindent NCHARS
913 % We'll use ems for NCHARS, close enough.
914 % NCHARS can also be the word `asis' or `none'.
915 % We cannot feasibly implement @paragraphindent asis, though.
916 %
917 \def\asisword{asis} % no translation, these are keywords
918 \def\noneword{none}
919 %
920 \parseargdef\paragraphindent{%
921   \def\temp{#1}%
922   \ifx\temp\asisword
923   \else
924     \ifx\temp\noneword
925       \defaultparindent = 0pt
926     \else
927       \defaultparindent = #1em
928     \fi
929   \fi
930   \parindent = \defaultparindent
931 }
932
933 % @exampleindent NCHARS
934 % We'll use ems for NCHARS like @paragraphindent.
935 % It seems @exampleindent asis isn't necessary, but
936 % I preserve it to make it similar to @paragraphindent.
937 \parseargdef\exampleindent{%
938   \def\temp{#1}%
939   \ifx\temp\asisword
940   \else
941     \ifx\temp\noneword
942       \lispnarrowing = 0pt
943     \else
944       \lispnarrowing = #1em
945     \fi
946   \fi
947 }
948
949 % @firstparagraphindent WORD
950 % If WORD is `none', then suppress indentation of the first paragraph
951 % after a section heading.  If WORD is `insert', then do indent at such
952 % paragraphs.
953 %
954 % The paragraph indentation is suppressed or not by calling
955 % \suppressfirstparagraphindent, which the sectioning commands do.
956 % We switch the definition of this back and forth according to WORD.
957 % By default, we suppress indentation.
958 %
959 \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
960 \def\insertword{insert}
961 %
962 \parseargdef\firstparagraphindent{%
963   \def\temp{#1}%
964   \ifx\temp\noneword
965     \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
966   \else\ifx\temp\insertword
967     \let\suppressfirstparagraphindent = \relax
968   \else
969     \errhelp = \EMsimple
970     \errmessage{Unknown @firstparagraphindent option `\temp'}%
971   \fi\fi
972 }
973
974 % Here is how we actually suppress indentation.  Redefine \everypar to
975 % \kern backwards by \parindent, and then reset itself to empty.
976 %
977 % We also make \indent itself not actually do anything until the next
978 % paragraph.
979 %
980 \gdef\dosuppressfirstparagraphindent{%
981   \gdef\indent  {\restorefirstparagraphindent \indent}%
982   \gdef\noindent{\restorefirstparagraphindent \noindent}%
983   \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
984 }
985 %
986 \gdef\restorefirstparagraphindent{%
987   \global\let\indent = \ptexindent
988   \global\let\noindent = \ptexnoindent
989   \global\everypar = {}%
990 }
991
992 % leave vertical mode without cancelling any first paragraph indent
993 \gdef\imageindent{%
994   \toks0=\everypar
995   \everypar={}%
996   \ptexnoindent
997   \global\everypar=\toks0
998 }
999
1000
1001 % @refill is a no-op.
1002 \let\refill=\relax
1003
1004 % @setfilename INFO-FILENAME - ignored
1005 \let\setfilename=\comment
1006
1007 % @bye.
1008 \outer\def\bye{\chappager\pagelabels\tracingstats=1\ptexend}
1009
1010
1011 \message{pdf,}
1012 % adobe `portable' document format
1013 \newcount\tempnum
1014 \newcount\lnkcount
1015 \newtoks\filename
1016 \newcount\filenamelength
1017 \newcount\pgn
1018 \newtoks\toksA
1019 \newtoks\toksB
1020 \newtoks\toksC
1021 \newtoks\toksD
1022 \newbox\boxA
1023 \newbox\boxB
1024 \newcount\countA
1025 \newif\ifpdf
1026 \newif\ifpdfmakepagedest
1027
1028 %
1029 % For LuaTeX
1030 %
1031
1032 \newif\iftxiuseunicodedestname
1033 \txiuseunicodedestnamefalse % For pdfTeX etc.
1034
1035 \ifx\luatexversion\thisisundefined
1036 \else
1037   % Use Unicode destination names
1038   \txiuseunicodedestnametrue
1039   % Escape PDF strings with converting UTF-16 from UTF-8
1040   \begingroup
1041     \catcode`\%=12
1042     \directlua{
1043       function UTF16oct(str)
1044         tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
1045         for c in string.utfvalues(str) do
1046           if c < 0x10000 then
1047             tex.sprint(
1048               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1049                             string.char(0x5c) .. string.char(0x25) .. '03o',
1050                             math.floor(c / 256), math.floor(c % 256)))
1051           else
1052             c = c - 0x10000
1053             local c_hi = c / 1024 + 0xd800
1054             local c_lo = c % 1024 + 0xdc00
1055             tex.sprint(
1056               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1057                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
1058                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
1059                             string.char(0x5c) .. string.char(0x25) .. '03o',
1060                             math.floor(c_hi / 256), math.floor(c_hi % 256),
1061                             math.floor(c_lo / 256), math.floor(c_lo % 256)))
1062           end
1063         end
1064       end
1065     }
1066   \endgroup
1067   \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
1068   % Escape PDF strings without converting
1069   \begingroup
1070     \directlua{
1071       function PDFescstr(str)
1072         for c in string.bytes(str) do
1073           if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
1074             tex.sprint(-2,
1075               string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
1076                             c))
1077           else
1078             tex.sprint(-2, string.char(c))
1079           end
1080         end
1081       end
1082     }
1083     % The -2 in the arguments here gives all the input to TeX catcode 12
1084     % (other) or 10 (space), preventing undefined control sequence errors. See
1085     % https://lists.gnu.org/archive/html/bug-texinfo/2019-08/msg00031.html
1086     %
1087   \endgroup
1088   \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
1089   \ifnum\luatexversion>84
1090     % For LuaTeX >= 0.85
1091     \def\pdfdest{\pdfextension dest}
1092     \let\pdfoutput\outputmode
1093     \def\pdfliteral{\pdfextension literal}
1094     \def\pdfcatalog{\pdfextension catalog}
1095     \def\pdftexversion{\numexpr\pdffeedback version\relax}
1096     \let\pdfximage\saveimageresource
1097     \let\pdfrefximage\useimageresource
1098     \let\pdflastximage\lastsavedimageresourceindex
1099     \def\pdfendlink{\pdfextension endlink\relax}
1100     \def\pdfoutline{\pdfextension outline}
1101     \def\pdfstartlink{\pdfextension startlink}
1102     \def\pdffontattr{\pdfextension fontattr}
1103     \def\pdfobj{\pdfextension obj}
1104     \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
1105     \let\pdfpagewidth\pagewidth
1106     \let\pdfpageheight\pageheight
1107     \edef\pdfhorigin{\pdfvariable horigin}
1108     \edef\pdfvorigin{\pdfvariable vorigin}
1109   \fi
1110 \fi
1111
1112 % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1113 % can be set).  So we test for \relax and 0 as well as being undefined.
1114 \ifx\pdfoutput\thisisundefined
1115 \else
1116   \ifx\pdfoutput\relax
1117   \else
1118     \ifcase\pdfoutput
1119     \else
1120       \pdftrue
1121     \fi
1122   \fi
1123 \fi
1124
1125 \newif\ifpdforxetex
1126 \pdforxetexfalse
1127 \ifpdf
1128   \pdforxetextrue
1129 \fi
1130 \ifx\XeTeXrevision\thisisundefined\else
1131   \pdforxetextrue
1132 \fi
1133
1134
1135 % Output page labels information.
1136 % See PDF reference v.1.7 p.594, section 8.3.1.
1137 \ifpdf
1138 \def\pagelabels{%
1139   \def\title{0 << /P (T-) /S /D >>}%
1140   \edef\roman{\the\romancount << /S /r >>}%
1141   \edef\arabic{\the\arabiccount << /S /D >>}%
1142   %
1143   % Page label ranges must be increasing.  Remove any duplicates.
1144   % (There is a slight chance of this being wrong if e.g. there is
1145   % a @contents but no @titlepage, etc.)
1146   %
1147   \ifnum\romancount=0 \def\roman{}\fi
1148   \ifnum\arabiccount=0 \def\title{}%
1149   \else
1150     \ifnum\romancount=\arabiccount \def\roman{}\fi
1151   \fi
1152   %
1153   \ifnum\romancount<\arabiccount
1154     \pdfcatalog{/PageLabels << /Nums [\title \roman \arabic ] >> }\relax
1155   \else
1156     \pdfcatalog{/PageLabels << /Nums [\title \arabic \roman ] >> }\relax
1157   \fi
1158 }
1159 \else
1160   \let\pagelabels\relax
1161 \fi
1162
1163 \newcount\pagecount \pagecount=0
1164 \newcount\romancount \romancount=0
1165 \newcount\arabiccount \arabiccount=0
1166 \ifpdf
1167   \let\ptxadvancepageno\advancepageno
1168   \def\advancepageno{%
1169     \ptxadvancepageno\global\advance\pagecount by 1
1170   }
1171 \fi
1172
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     \xdef#1{#1}%
1192   \else
1193     % The expandable \pdfescapestring primitive escapes parentheses,
1194     % backslashes, and other special chars.
1195     \xdef#1{\pdfescapestring{#1}}%
1196   \fi
1197 }
1198 \def\txiescapepdfutfsixteen#1{%
1199   \ifx\pdfescapestrutfsixteen\thisisundefined
1200     % No UTF-16 converting macro available.
1201     \txiescapepdf{#1}%
1202   \else
1203     \xdef#1{\pdfescapestrutfsixteen{#1}}%
1204   \fi
1205 }
1206
1207 \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1208 with PDF output, and none of those formats could be found.  (.eps cannot
1209 be supported due to the design of the PDF format; use regular TeX (DVI
1210 output) for that.)}
1211
1212 \ifpdf
1213   %
1214   % Color manipulation macros using ideas from pdfcolor.tex,
1215   % except using rgb instead of cmyk; the latter is said to render as a
1216   % very dark gray on-screen and a very dark halftone in print, instead
1217   % of actual black. The dark red here is dark enough to print on paper as
1218   % nearly black, but still distinguishable for online viewing.  We use
1219   % black by default, though.
1220   \def\rgbDarkRed{0.50 0.09 0.12}
1221   \def\rgbBlack{0 0 0}
1222   %
1223   % rg sets the color for filling (usual text, etc.);
1224   % RG sets the color for stroking (thin rules, e.g., normal _'s).
1225   \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
1226   %
1227   % Set color, and create a mark which defines \thiscolor accordingly,
1228   % so that \makeheadline knows which color to restore.
1229   \def\setcolor#1{%
1230     \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
1231     \domark
1232     \pdfsetcolor{#1}%
1233   }
1234   %
1235   \def\maincolor{\rgbBlack}
1236   \pdfsetcolor{\maincolor}
1237   \edef\thiscolor{\maincolor}
1238   \def\currentcolordefs{}
1239   %
1240   \def\makefootline{%
1241     \baselineskip24pt
1242     \line{\pdfsetcolor{\maincolor}\the\footline}%
1243   }
1244   %
1245   \def\makeheadline{%
1246     \vbox to 0pt{%
1247       \vskip-22.5pt
1248       \line{%
1249         \vbox to8.5pt{}%
1250         % Extract \thiscolor definition from the marks.
1251         \getcolormarks
1252         % Typeset the headline with \maincolor, then restore the color.
1253         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1254       }%
1255       \vss
1256     }%
1257     \nointerlineskip
1258   }
1259   %
1260   %
1261   \pdfcatalog{/PageMode /UseOutlines}
1262   %
1263   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1264   \def\dopdfimage#1#2#3{%
1265     \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1266     \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1267     %
1268     % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1269     % others).  Let's try in that order, PDF first since if
1270     % someone has a scalable image, presumably better to use that than a
1271     % bitmap.
1272     \let\pdfimgext=\empty
1273     \begingroup
1274       \openin 1 #1.pdf \ifeof 1
1275         \openin 1 #1.PDF \ifeof 1
1276           \openin 1 #1.png \ifeof 1
1277             \openin 1 #1.jpg \ifeof 1
1278               \openin 1 #1.jpeg \ifeof 1
1279                 \openin 1 #1.JPG \ifeof 1
1280                   \errhelp = \nopdfimagehelp
1281                   \errmessage{Could not find image file #1 for pdf}%
1282                 \else \gdef\pdfimgext{JPG}%
1283                 \fi
1284               \else \gdef\pdfimgext{jpeg}%
1285               \fi
1286             \else \gdef\pdfimgext{jpg}%
1287             \fi
1288           \else \gdef\pdfimgext{png}%
1289           \fi
1290         \else \gdef\pdfimgext{PDF}%
1291         \fi
1292       \else \gdef\pdfimgext{pdf}%
1293       \fi
1294       \closein 1
1295     \endgroup
1296     %
1297     % without \immediate, ancient pdftex seg faults when the same image is
1298     % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
1299     \ifnum\pdftexversion < 14
1300       \immediate\pdfimage
1301     \else
1302       \immediate\pdfximage
1303     \fi
1304       \ifdim \wd0 >0pt width \pdfimagewidth \fi
1305       \ifdim \wd2 >0pt height \pdfimageheight \fi
1306       \ifnum\pdftexversion<13
1307          #1.\pdfimgext
1308        \else
1309          {#1.\pdfimgext}%
1310        \fi
1311     \ifnum\pdftexversion < 14 \else
1312       \pdfrefximage \pdflastximage
1313     \fi}
1314   %
1315   \def\setpdfdestname#1{{%
1316     % We have to set dummies so commands such as @code, and characters
1317     % such as \, aren't expanded when present in a section title.
1318     \indexnofonts
1319     \makevalueexpandable
1320     \turnoffactive
1321     \iftxiuseunicodedestname
1322       \ifx \declaredencoding \latone
1323         % Pass through Latin-1 characters.
1324         % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode.
1325       \else
1326         \ifx \declaredencoding \utfeight
1327           % Pass through Unicode characters.
1328         \else
1329           % Use ASCII approximations in destination names.
1330           \passthroughcharsfalse
1331         \fi
1332       \fi
1333     \else
1334       % Use ASCII approximations in destination names.
1335       \passthroughcharsfalse
1336     \fi
1337     \def\pdfdestname{#1}%
1338     \txiescapepdf\pdfdestname
1339   }}
1340   %
1341   \def\setpdfoutlinetext#1{{%
1342     \indexnofonts
1343     \makevalueexpandable
1344     \turnoffactive
1345     \ifx \declaredencoding \latone
1346       % The PDF format can use an extended form of Latin-1 in bookmark
1347       % strings.  See Appendix D of the PDF Reference, Sixth Edition, for
1348       % the "PDFDocEncoding".
1349       \passthroughcharstrue
1350       % Pass through Latin-1 characters.
1351       %   LuaTeX: Convert to Unicode
1352       %   pdfTeX: Use Latin-1 as PDFDocEncoding
1353       \def\pdfoutlinetext{#1}%
1354     \else
1355       \ifx \declaredencoding \utfeight
1356         \ifx\luatexversion\thisisundefined
1357           % For pdfTeX  with UTF-8.
1358           % TODO: the PDF format can use UTF-16 in bookmark strings,
1359           % but the code for this isn't done yet.
1360           % Use ASCII approximations.
1361           \passthroughcharsfalse
1362           \def\pdfoutlinetext{#1}%
1363         \else
1364           % For LuaTeX with UTF-8.
1365           % Pass through Unicode characters for title texts.
1366           \passthroughcharstrue
1367           \def\pdfoutlinetext{#1}%
1368         \fi
1369       \else
1370         % For non-Latin-1 or non-UTF-8 encodings.
1371         % Use ASCII approximations.
1372         \passthroughcharsfalse
1373         \def\pdfoutlinetext{#1}%
1374       \fi
1375     \fi
1376     % LuaTeX: Convert to UTF-16
1377     % pdfTeX: Use Latin-1 as PDFDocEncoding
1378     \txiescapepdfutfsixteen\pdfoutlinetext
1379   }}
1380   %
1381   \def\pdfmkdest#1{%
1382     \setpdfdestname{#1}%
1383     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1384   }
1385   %
1386   % used to mark target names; must be expandable.
1387   \def\pdfmkpgn#1{#1}
1388   %
1389   % by default, use black for everything.
1390   \def\urlcolor{\rgbBlack}
1391   \def\linkcolor{\rgbBlack}
1392   \def\endlink{\setcolor{\maincolor}\pdfendlink}
1393   %
1394   % Adding outlines to PDF; macros for calculating structure of outlines
1395   % come from Petr Olsak
1396   \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1397     \else \csname#1\endcsname \fi}
1398   \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1399     \advance\tempnum by 1
1400     \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1401   %
1402   % #1 is the section text, which is what will be displayed in the
1403   % outline by the pdf viewer.  #2 is the pdf expression for the number
1404   % of subentries (or empty, for subsubsections).  #3 is the node text,
1405   % which might be empty if this toc entry had no corresponding node.
1406   % #4 is the page number
1407   %
1408   \def\dopdfoutline#1#2#3#4{%
1409     % Generate a link to the node text if that exists; else, use the
1410     % page number.  We could generate a destination for the section
1411     % text in the case where a section has no node, but it doesn't
1412     % seem worth the trouble, since most documents are normally structured.
1413     \setpdfoutlinetext{#1}
1414     \setpdfdestname{#3}
1415     \ifx\pdfdestname\empty
1416       \def\pdfdestname{#4}%
1417     \fi
1418     %
1419     \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}%
1420   }
1421   %
1422   \def\pdfmakeoutlines{%
1423     \begingroup
1424       % Read toc silently, to get counts of subentries for \pdfoutline.
1425       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1426       \def\numchapentry##1##2##3##4{%
1427         \def\thischapnum{##2}%
1428         \def\thissecnum{0}%
1429         \def\thissubsecnum{0}%
1430       }%
1431       \def\numsecentry##1##2##3##4{%
1432         \advancenumber{chap\thischapnum}%
1433         \def\thissecnum{##2}%
1434         \def\thissubsecnum{0}%
1435       }%
1436       \def\numsubsecentry##1##2##3##4{%
1437         \advancenumber{sec\thissecnum}%
1438         \def\thissubsecnum{##2}%
1439       }%
1440       \def\numsubsubsecentry##1##2##3##4{%
1441         \advancenumber{subsec\thissubsecnum}%
1442       }%
1443       \def\thischapnum{0}%
1444       \def\thissecnum{0}%
1445       \def\thissubsecnum{0}%
1446       %
1447       % use \def rather than \let here because we redefine \chapentry et
1448       % al. a second time, below.
1449       \def\appentry{\numchapentry}%
1450       \def\appsecentry{\numsecentry}%
1451       \def\appsubsecentry{\numsubsecentry}%
1452       \def\appsubsubsecentry{\numsubsubsecentry}%
1453       \def\unnchapentry{\numchapentry}%
1454       \def\unnsecentry{\numsecentry}%
1455       \def\unnsubsecentry{\numsubsecentry}%
1456       \def\unnsubsubsecentry{\numsubsubsecentry}%
1457       \readdatafile{toc}%
1458       %
1459       % Read toc second time, this time actually producing the outlines.
1460       % The `-' means take the \expnumber as the absolute number of
1461       % subentries, which we calculated on our first read of the .toc above.
1462       %
1463       % We use the node names as the destinations.
1464       %
1465       % Currently we prefix the section name with the section number
1466       % for chapter and appendix headings only in order to avoid too much
1467       % horizontal space being required in the PDF viewer.
1468       \def\numchapentry##1##2##3##4{%
1469         \dopdfoutline{##2 ##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1470       \def\unnchapentry##1##2##3##4{%
1471         \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1472       \def\numsecentry##1##2##3##4{%
1473         \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1474       \def\numsubsecentry##1##2##3##4{%
1475         \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1476       \def\numsubsubsecentry##1##2##3##4{% count is always zero
1477         \dopdfoutline{##1}{}{##3}{##4}}%
1478       %
1479       % PDF outlines are displayed using system fonts, instead of
1480       % document fonts.  Therefore we cannot use special characters,
1481       % since the encoding is unknown.  For example, the eogonek from
1482       % Latin 2 (0xea) gets translated to a | character.  Info from
1483       % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1484       %
1485       % TODO this right, we have to translate 8-bit characters to
1486       % their "best" equivalent, based on the @documentencoding.  Too
1487       % much work for too little return.  Just use the ASCII equivalents
1488       % we use for the index sort strings.
1489       %
1490       \indexnofonts
1491       \setupdatafile
1492       % We can have normal brace characters in the PDF outlines, unlike
1493       % Texinfo index files.  So set that up.
1494       \def\{{\lbracecharliteral}%
1495       \def\}{\rbracecharliteral}%
1496       \catcode`\\=\active \otherbackslash
1497       \input \tocreadfilename
1498     \endgroup
1499   }
1500   {\catcode`[=1 \catcode`]=2
1501    \catcode`{=\other \catcode`}=\other
1502    \gdef\lbracecharliteral[{]%
1503    \gdef\rbracecharliteral[}]%
1504   ]
1505   %
1506   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1507     \ifx\PP\D\let\nextsp\relax
1508     \else\let\nextsp\skipspaces
1509       \addtokens{\filename}{\PP}%
1510       \advance\filenamelength by 1
1511     \fi
1512     \nextsp}
1513   \def\getfilename#1{%
1514     \filenamelength=0
1515     % If we don't expand the argument now, \skipspaces will get
1516     % snagged on things like "@value{foo}".
1517     \edef\temp{#1}%
1518     \expandafter\skipspaces\temp|\relax
1519   }
1520   \ifnum\pdftexversion < 14
1521     \let \startlink \pdfannotlink
1522   \else
1523     \let \startlink \pdfstartlink
1524   \fi
1525   % make a live url in pdf output.
1526   \def\pdfurl#1{%
1527     \begingroup
1528       % it seems we really need yet another set of dummies; have not
1529       % tried to figure out what each command should do in the context
1530       % of @url.  for now, just make @/ a no-op, that's the only one
1531       % people have actually reported a problem with.
1532       %
1533       \normalturnoffactive
1534       \def\@{@}%
1535       \let\/=\empty
1536       \makevalueexpandable
1537       % do we want to go so far as to use \indexnofonts instead of just
1538       % special-casing \var here?
1539       \def\var##1{##1}%
1540       %
1541       \leavevmode\setcolor{\urlcolor}%
1542       \startlink attr{/Border [0 0 0]}%
1543         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1544     \endgroup}
1545   % \pdfgettoks - Surround page numbers in #1 with @pdflink.  #1 may
1546   % be a simple number, or a list of numbers in the case of an index
1547   % entry.
1548   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1549   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1550   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1551   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1552   \def\maketoks{%
1553     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1554     \ifx\first0\adn0
1555     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1556     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1557     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1558     \else
1559       \ifnum0=\countA\else\makelink\fi
1560       \ifx\first.\let\next=\done\else
1561         \let\next=\maketoks
1562         \addtokens{\toksB}{\the\toksD}
1563         \ifx\first,\addtokens{\toksB}{\space}\fi
1564       \fi
1565     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1566     \next}
1567   \def\makelink{\addtokens{\toksB}%
1568     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1569   \def\pdflink#1{%
1570     \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1571     \setcolor{\linkcolor}#1\endlink}
1572   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1573 \else
1574   % non-pdf mode
1575   \let\pdfmkdest = \gobble
1576   \let\pdfurl = \gobble
1577   \let\endlink = \relax
1578   \let\setcolor = \gobble
1579   \let\pdfsetcolor = \gobble
1580   \let\pdfmakeoutlines = \relax
1581 \fi  % \ifx\pdfoutput
1582
1583 %
1584 % For XeTeX
1585 %
1586 \ifx\XeTeXrevision\thisisundefined
1587 \else
1588   %
1589   % XeTeX version check
1590   %
1591   \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1
1592     % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307.
1593     % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941).
1594     % For avoiding PDF destination name replacement, we use this special
1595     % instead of xdvipdfmx's command line option `-C 0x0010'.
1596     \special{dvipdfmx:config C 0x0010}
1597     % XeTeX 0.99995+ comes with xdvipdfmx 20160307+.
1598     % It can handle Unicode destination names for PDF.
1599     \txiuseunicodedestnametrue
1600   \else
1601     % XeTeX < 0.99996 (TeX Live < 2016) cannot use the
1602     % `dvipdfmx:config' special.
1603     % So for avoiding PDF destination name replacement,
1604     % xdvipdfmx's command line option `-C 0x0010' is necessary.
1605     %
1606     % XeTeX < 0.99995 can not handle Unicode destination names for PDF
1607     % because xdvipdfmx 20150315 has a UTF-16 conversion issue.
1608     % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1609     \txiuseunicodedestnamefalse
1610   \fi
1611   %
1612   % Color support
1613   %
1614   \def\rgbDarkRed{0.50 0.09 0.12}
1615   \def\rgbBlack{0 0 0}
1616   %
1617   \def\pdfsetcolor#1{\special{pdf:scolor [#1]}}
1618   %
1619   % Set color, and create a mark which defines \thiscolor accordingly,
1620   % so that \makeheadline knows which color to restore.
1621   \def\setcolor#1{%
1622     \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
1623     \domark
1624     \pdfsetcolor{#1}%
1625   }
1626   %
1627   \def\maincolor{\rgbBlack}
1628   \pdfsetcolor{\maincolor}
1629   \edef\thiscolor{\maincolor}
1630   \def\currentcolordefs{}
1631   %
1632   \def\makefootline{%
1633     \baselineskip24pt
1634     \line{\pdfsetcolor{\maincolor}\the\footline}%
1635   }
1636   %
1637   \def\makeheadline{%
1638     \vbox to 0pt{%
1639       \vskip-22.5pt
1640       \line{%
1641         \vbox to8.5pt{}%
1642         % Extract \thiscolor definition from the marks.
1643         \getcolormarks
1644         % Typeset the headline with \maincolor, then restore the color.
1645         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1646       }%
1647       \vss
1648     }%
1649     \nointerlineskip
1650   }
1651   %
1652   % PDF outline support
1653   %
1654   % Emulate pdfTeX primitive
1655   \def\pdfdest name#1 xyz{%
1656     \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}%
1657   }
1658   %
1659   \def\setpdfdestname#1{{%
1660     % We have to set dummies so commands such as @code, and characters
1661     % such as \, aren't expanded when present in a section title.
1662     \indexnofonts
1663     \makevalueexpandable
1664     \turnoffactive
1665     \iftxiuseunicodedestname
1666       % Pass through Unicode characters.
1667     \else
1668       % Use ASCII approximations in destination names.
1669       \passthroughcharsfalse
1670     \fi
1671     \def\pdfdestname{#1}%
1672     \txiescapepdf\pdfdestname
1673   }}
1674   %
1675   \def\setpdfoutlinetext#1{{%
1676     \turnoffactive
1677     % Always use Unicode characters in title texts.
1678     \def\pdfoutlinetext{#1}%
1679     % For XeTeX, xdvipdfmx converts to UTF-16.
1680     % So we do not convert.
1681     \txiescapepdf\pdfoutlinetext
1682   }}
1683   %
1684   \def\pdfmkdest#1{%
1685     \setpdfdestname{#1}%
1686     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1687   }
1688   %
1689   % by default, use black for everything.
1690   \def\urlcolor{\rgbBlack}
1691   \def\linkcolor{\rgbBlack}
1692   \def\endlink{\setcolor{\maincolor}\pdfendlink}
1693   %
1694   \def\dopdfoutline#1#2#3#4{%
1695     \setpdfoutlinetext{#1}
1696     \setpdfdestname{#3}
1697     \ifx\pdfdestname\empty
1698       \def\pdfdestname{#4}%
1699     \fi
1700     %
1701     \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
1702       << /S /GoTo /D (\pdfdestname) >> >> }%
1703   }
1704   %
1705   \def\pdfmakeoutlines{%
1706     \begingroup
1707       %
1708       % For XeTeX, counts of subentries are not necessary.
1709       % Therefore, we read toc only once.
1710       %
1711       % We use node names as destinations.
1712       %
1713       % Currently we prefix the section name with the section number
1714       % for chapter and appendix headings only in order to avoid too much
1715       % horizontal space being required in the PDF viewer.
1716       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1717       \def\numchapentry##1##2##3##4{%
1718         \dopdfoutline{##2 ##1}{1}{##3}{##4}}%
1719       \def\numsecentry##1##2##3##4{%
1720         \dopdfoutline{##1}{2}{##3}{##4}}%
1721       \def\numsubsecentry##1##2##3##4{%
1722         \dopdfoutline{##1}{3}{##3}{##4}}%
1723       \def\numsubsubsecentry##1##2##3##4{%
1724         \dopdfoutline{##1}{4}{##3}{##4}}%
1725       %
1726       \let\appentry\numchapentry%
1727       \let\appsecentry\numsecentry%
1728       \let\appsubsecentry\numsubsecentry%
1729       \let\appsubsubsecentry\numsubsubsecentry%
1730       \def\unnchapentry##1##2##3##4{%
1731         \dopdfoutline{##1}{1}{##3}{##4}}%
1732       \let\unnsecentry\numsecentry%
1733       \let\unnsubsecentry\numsubsecentry%
1734       \let\unnsubsubsecentry\numsubsubsecentry%
1735       %
1736       % For XeTeX, xdvipdfmx converts strings to UTF-16.
1737       % Therefore, the encoding and the language may not be considered.
1738       %
1739       \indexnofonts
1740       \setupdatafile
1741       % We can have normal brace characters in the PDF outlines, unlike
1742       % Texinfo index files.  So set that up.
1743       \def\{{\lbracecharliteral}%
1744       \def\}{\rbracecharliteral}%
1745       \catcode`\\=\active \otherbackslash
1746       \input \tocreadfilename
1747     \endgroup
1748   }
1749   {\catcode`[=1 \catcode`]=2
1750    \catcode`{=\other \catcode`}=\other
1751    \gdef\lbracecharliteral[{]%
1752    \gdef\rbracecharliteral[}]%
1753   ]
1754
1755   \special{pdf:docview << /PageMode /UseOutlines >> }
1756   % ``\special{pdf:tounicode ...}'' is not necessary
1757   % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
1758   % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315,
1759   % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings.
1760   % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1761 %
1762   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1763     \ifx\PP\D\let\nextsp\relax
1764     \else\let\nextsp\skipspaces
1765       \addtokens{\filename}{\PP}%
1766       \advance\filenamelength by 1
1767     \fi
1768     \nextsp}
1769   \def\getfilename#1{%
1770     \filenamelength=0
1771     % If we don't expand the argument now, \skipspaces will get
1772     % snagged on things like "@value{foo}".
1773     \edef\temp{#1}%
1774     \expandafter\skipspaces\temp|\relax
1775   }
1776   % make a live url in pdf output.
1777   \def\pdfurl#1{%
1778     \begingroup
1779       % it seems we really need yet another set of dummies; have not
1780       % tried to figure out what each command should do in the context
1781       % of @url.  for now, just make @/ a no-op, that's the only one
1782       % people have actually reported a problem with.
1783       %
1784       \normalturnoffactive
1785       \def\@{@}%
1786       \let\/=\empty
1787       \makevalueexpandable
1788       % do we want to go so far as to use \indexnofonts instead of just
1789       % special-casing \var here?
1790       \def\var##1{##1}%
1791       %
1792       \leavevmode\setcolor{\urlcolor}%
1793       \special{pdf:bann << /Border [0 0 0]
1794         /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
1795     \endgroup}
1796   \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
1797   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1798   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1799   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1800   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1801   \def\maketoks{%
1802     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1803     \ifx\first0\adn0
1804     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1805     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1806     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1807     \else
1808       \ifnum0=\countA\else\makelink\fi
1809       \ifx\first.\let\next=\done\else
1810         \let\next=\maketoks
1811         \addtokens{\toksB}{\the\toksD}
1812         \ifx\first,\addtokens{\toksB}{\space}\fi
1813       \fi
1814     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1815     \next}
1816   \def\makelink{\addtokens{\toksB}%
1817     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1818   \def\pdflink#1{%
1819     \special{pdf:bann << /Border [0 0 0]
1820       /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}%
1821     \setcolor{\linkcolor}#1\endlink}
1822   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1823 %
1824   %
1825   % @image support
1826   %
1827   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1828   \def\doxeteximage#1#2#3{%
1829     \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1830     \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1831     %
1832     % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among
1833     % others).  Let's try in that order, PDF first since if
1834     % someone has a scalable image, presumably better to use that than a
1835     % bitmap.
1836     \let\xeteximgext=\empty
1837     \begingroup
1838       \openin 1 #1.pdf \ifeof 1
1839         \openin 1 #1.PDF \ifeof 1
1840           \openin 1 #1.png \ifeof 1
1841             \openin 1 #1.jpg \ifeof 1
1842               \openin 1 #1.jpeg \ifeof 1
1843                 \openin 1 #1.JPG \ifeof 1
1844                   \errmessage{Could not find image file #1 for XeTeX}%
1845                 \else \gdef\xeteximgext{JPG}%
1846                 \fi
1847               \else \gdef\xeteximgext{jpeg}%
1848               \fi
1849             \else \gdef\xeteximgext{jpg}%
1850             \fi
1851           \else \gdef\xeteximgext{png}%
1852           \fi
1853         \else \gdef\xeteximgext{PDF}%
1854         \fi
1855       \else \gdef\xeteximgext{pdf}%
1856       \fi
1857       \closein 1
1858     \endgroup
1859     %
1860     % Putting an \hbox around the image can prevent an over-long line
1861     % after the image.
1862     \hbox\bgroup
1863       \def\xetexpdfext{pdf}%
1864       \ifx\xeteximgext\xetexpdfext
1865         \XeTeXpdffile "#1".\xeteximgext ""
1866       \else
1867         \def\xetexpdfext{PDF}%
1868         \ifx\xeteximgext\xetexpdfext
1869           \XeTeXpdffile "#1".\xeteximgext ""
1870         \else
1871           \XeTeXpicfile "#1".\xeteximgext ""
1872         \fi
1873       \fi
1874       \ifdim \wd0 >0pt width \xeteximagewidth \fi
1875       \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1876     \egroup
1877   }
1878 \fi
1879
1880
1881 %
1882 \message{fonts,}
1883
1884 % Set the baselineskip to #1, and the lineskip and strut size
1885 % correspondingly.  There is no deep meaning behind these magic numbers
1886 % used as factors; they just match (closely enough) what Knuth defined.
1887 %
1888 \def\lineskipfactor{.08333}
1889 \def\strutheightpercent{.70833}
1890 \def\strutdepthpercent {.29167}
1891 %
1892 % can get a sort of poor man's double spacing by redefining this.
1893 \def\baselinefactor{1}
1894 %
1895 \newdimen\textleading
1896 \def\setleading#1{%
1897   \dimen0 = #1\relax
1898   \normalbaselineskip = \baselinefactor\dimen0
1899   \normallineskip = \lineskipfactor\normalbaselineskip
1900   \normalbaselines
1901   \setbox\strutbox =\hbox{%
1902     \vrule width0pt height\strutheightpercent\baselineskip
1903                     depth \strutdepthpercent \baselineskip
1904   }%
1905 }
1906
1907 % PDF CMaps.  See also LaTeX's t1.cmap.
1908 %
1909 % do nothing with this by default.
1910 \expandafter\let\csname cmapOT1\endcsname\gobble
1911 \expandafter\let\csname cmapOT1IT\endcsname\gobble
1912 \expandafter\let\csname cmapOT1TT\endcsname\gobble
1913
1914 % if we are producing pdf, and we have \pdffontattr, then define cmaps.
1915 % (\pdffontattr was introduced many years ago, but people still run
1916 % older pdftex's; it's easy to conditionalize, so we do.)
1917 \ifpdf \ifx\pdffontattr\thisisundefined \else
1918   \begingroup
1919     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1920     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1921 %%DocumentNeededResources: ProcSet (CIDInit)
1922 %%IncludeResource: ProcSet (CIDInit)
1923 %%BeginResource: CMap (TeX-OT1-0)
1924 %%Title: (TeX-OT1-0 TeX OT1 0)
1925 %%Version: 1.000
1926 %%EndComments
1927 /CIDInit /ProcSet findresource begin
1928 12 dict begin
1929 begincmap
1930 /CIDSystemInfo
1931 << /Registry (TeX)
1932 /Ordering (OT1)
1933 /Supplement 0
1934 >> def
1935 /CMapName /TeX-OT1-0 def
1936 /CMapType 2 def
1937 1 begincodespacerange
1938 <00> <7F>
1939 endcodespacerange
1940 8 beginbfrange
1941 <00> <01> <0393>
1942 <09> <0A> <03A8>
1943 <23> <26> <0023>
1944 <28> <3B> <0028>
1945 <3F> <5B> <003F>
1946 <5D> <5E> <005D>
1947 <61> <7A> <0061>
1948 <7B> <7C> <2013>
1949 endbfrange
1950 40 beginbfchar
1951 <02> <0398>
1952 <03> <039B>
1953 <04> <039E>
1954 <05> <03A0>
1955 <06> <03A3>
1956 <07> <03D2>
1957 <08> <03A6>
1958 <0B> <00660066>
1959 <0C> <00660069>
1960 <0D> <0066006C>
1961 <0E> <006600660069>
1962 <0F> <00660066006C>
1963 <10> <0131>
1964 <11> <0237>
1965 <12> <0060>
1966 <13> <00B4>
1967 <14> <02C7>
1968 <15> <02D8>
1969 <16> <00AF>
1970 <17> <02DA>
1971 <18> <00B8>
1972 <19> <00DF>
1973 <1A> <00E6>
1974 <1B> <0153>
1975 <1C> <00F8>
1976 <1D> <00C6>
1977 <1E> <0152>
1978 <1F> <00D8>
1979 <21> <0021>
1980 <22> <201D>
1981 <27> <2019>
1982 <3C> <00A1>
1983 <3D> <003D>
1984 <3E> <00BF>
1985 <5C> <201C>
1986 <5F> <02D9>
1987 <60> <2018>
1988 <7D> <02DD>
1989 <7E> <007E>
1990 <7F> <00A8>
1991 endbfchar
1992 endcmap
1993 CMapName currentdict /CMap defineresource pop
1994 end
1995 end
1996 %%EndResource
1997 %%EOF
1998     }\endgroup
1999   \expandafter\edef\csname cmapOT1\endcsname#1{%
2000     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2001   }%
2002 %
2003 % \cmapOT1IT
2004   \begingroup
2005     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2006     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2007 %%DocumentNeededResources: ProcSet (CIDInit)
2008 %%IncludeResource: ProcSet (CIDInit)
2009 %%BeginResource: CMap (TeX-OT1IT-0)
2010 %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
2011 %%Version: 1.000
2012 %%EndComments
2013 /CIDInit /ProcSet findresource begin
2014 12 dict begin
2015 begincmap
2016 /CIDSystemInfo
2017 << /Registry (TeX)
2018 /Ordering (OT1IT)
2019 /Supplement 0
2020 >> def
2021 /CMapName /TeX-OT1IT-0 def
2022 /CMapType 2 def
2023 1 begincodespacerange
2024 <00> <7F>
2025 endcodespacerange
2026 8 beginbfrange
2027 <00> <01> <0393>
2028 <09> <0A> <03A8>
2029 <25> <26> <0025>
2030 <28> <3B> <0028>
2031 <3F> <5B> <003F>
2032 <5D> <5E> <005D>
2033 <61> <7A> <0061>
2034 <7B> <7C> <2013>
2035 endbfrange
2036 42 beginbfchar
2037 <02> <0398>
2038 <03> <039B>
2039 <04> <039E>
2040 <05> <03A0>
2041 <06> <03A3>
2042 <07> <03D2>
2043 <08> <03A6>
2044 <0B> <00660066>
2045 <0C> <00660069>
2046 <0D> <0066006C>
2047 <0E> <006600660069>
2048 <0F> <00660066006C>
2049 <10> <0131>
2050 <11> <0237>
2051 <12> <0060>
2052 <13> <00B4>
2053 <14> <02C7>
2054 <15> <02D8>
2055 <16> <00AF>
2056 <17> <02DA>
2057 <18> <00B8>
2058 <19> <00DF>
2059 <1A> <00E6>
2060 <1B> <0153>
2061 <1C> <00F8>
2062 <1D> <00C6>
2063 <1E> <0152>
2064 <1F> <00D8>
2065 <21> <0021>
2066 <22> <201D>
2067 <23> <0023>
2068 <24> <00A3>
2069 <27> <2019>
2070 <3C> <00A1>
2071 <3D> <003D>
2072 <3E> <00BF>
2073 <5C> <201C>
2074 <5F> <02D9>
2075 <60> <2018>
2076 <7D> <02DD>
2077 <7E> <007E>
2078 <7F> <00A8>
2079 endbfchar
2080 endcmap
2081 CMapName currentdict /CMap defineresource pop
2082 end
2083 end
2084 %%EndResource
2085 %%EOF
2086     }\endgroup
2087   \expandafter\edef\csname cmapOT1IT\endcsname#1{%
2088     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2089   }%
2090 %
2091 % \cmapOT1TT
2092   \begingroup
2093     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2094     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2095 %%DocumentNeededResources: ProcSet (CIDInit)
2096 %%IncludeResource: ProcSet (CIDInit)
2097 %%BeginResource: CMap (TeX-OT1TT-0)
2098 %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
2099 %%Version: 1.000
2100 %%EndComments
2101 /CIDInit /ProcSet findresource begin
2102 12 dict begin
2103 begincmap
2104 /CIDSystemInfo
2105 << /Registry (TeX)
2106 /Ordering (OT1TT)
2107 /Supplement 0
2108 >> def
2109 /CMapName /TeX-OT1TT-0 def
2110 /CMapType 2 def
2111 1 begincodespacerange
2112 <00> <7F>
2113 endcodespacerange
2114 5 beginbfrange
2115 <00> <01> <0393>
2116 <09> <0A> <03A8>
2117 <21> <26> <0021>
2118 <28> <5F> <0028>
2119 <61> <7E> <0061>
2120 endbfrange
2121 32 beginbfchar
2122 <02> <0398>
2123 <03> <039B>
2124 <04> <039E>
2125 <05> <03A0>
2126 <06> <03A3>
2127 <07> <03D2>
2128 <08> <03A6>
2129 <0B> <2191>
2130 <0C> <2193>
2131 <0D> <0027>
2132 <0E> <00A1>
2133 <0F> <00BF>
2134 <10> <0131>
2135 <11> <0237>
2136 <12> <0060>
2137 <13> <00B4>
2138 <14> <02C7>
2139 <15> <02D8>
2140 <16> <00AF>
2141 <17> <02DA>
2142 <18> <00B8>
2143 <19> <00DF>
2144 <1A> <00E6>
2145 <1B> <0153>
2146 <1C> <00F8>
2147 <1D> <00C6>
2148 <1E> <0152>
2149 <1F> <00D8>
2150 <20> <2423>
2151 <27> <2019>
2152 <60> <2018>
2153 <7F> <00A8>
2154 endbfchar
2155 endcmap
2156 CMapName currentdict /CMap defineresource pop
2157 end
2158 end
2159 %%EndResource
2160 %%EOF
2161     }\endgroup
2162   \expandafter\edef\csname cmapOT1TT\endcsname#1{%
2163     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2164   }%
2165 \fi\fi
2166
2167
2168 % Set the font macro #1 to the font named \fontprefix#2.
2169 % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
2170 % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
2171 % Example:
2172 % #1 = \textrm
2173 % #2 = \rmshape
2174 % #3 = 10
2175 % #4 = \mainmagstep
2176 % #5 = OT1
2177 %
2178 \def\setfont#1#2#3#4#5{%
2179   \font#1=\fontprefix#2#3 scaled #4
2180   \csname cmap#5\endcsname#1%
2181 }
2182 % This is what gets called when #5 of \setfont is empty.
2183 \let\cmap\gobble
2184 %
2185 % (end of cmaps)
2186
2187 % Use cm as the default font prefix.
2188 % To specify the font prefix, you must define \fontprefix
2189 % before you read in texinfo.tex.
2190 \ifx\fontprefix\thisisundefined
2191 \def\fontprefix{cm}
2192 \fi
2193 % Support font families that don't use the same naming scheme as CM.
2194 \def\rmshape{r}
2195 \def\rmbshape{bx}               % where the normal face is bold
2196 \def\bfshape{b}
2197 \def\bxshape{bx}
2198 \def\ttshape{tt}
2199 \def\ttbshape{tt}
2200 \def\ttslshape{sltt}
2201 \def\itshape{ti}
2202 \def\itbshape{bxti}
2203 \def\slshape{sl}
2204 \def\slbshape{bxsl}
2205 \def\sfshape{ss}
2206 \def\sfbshape{ss}
2207 \def\scshape{csc}
2208 \def\scbshape{csc}
2209
2210 % Definitions for a main text size of 11pt.  (The default in Texinfo.)
2211 %
2212 \def\definetextfontsizexi{%
2213 % Text fonts (11.2pt, magstep1).
2214 \def\textnominalsize{11pt}
2215 \edef\mainmagstep{\magstephalf}
2216 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2217 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2218 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2219 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2220 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2221 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2222 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2223 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2224 \font\texti=cmmi10 scaled \mainmagstep
2225 \font\textsy=cmsy10 scaled \mainmagstep
2226 \def\textecsize{1095}
2227
2228 % A few fonts for @defun names and args.
2229 \setfont\defbf\bfshape{10}{\magstep1}{OT1}
2230 \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
2231 \setfont\defsl\slshape{10}{\magstep1}{OT1}
2232 \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
2233 \def\df{\let\ttfont=\deftt \let\bffont = \defbf
2234 \let\ttslfont=\defttsl \let\slfont=\defsl \bf}
2235
2236 % Fonts for indices, footnotes, small examples (9pt).
2237 \def\smallnominalsize{9pt}
2238 \setfont\smallrm\rmshape{9}{1000}{OT1}
2239 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2240 \setfont\smallbf\bfshape{10}{900}{OT1}
2241 \setfont\smallit\itshape{9}{1000}{OT1IT}
2242 \setfont\smallsl\slshape{9}{1000}{OT1}
2243 \setfont\smallsf\sfshape{9}{1000}{OT1}
2244 \setfont\smallsc\scshape{10}{900}{OT1}
2245 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2246 \font\smalli=cmmi9
2247 \font\smallsy=cmsy9
2248 \def\smallecsize{0900}
2249
2250 % Fonts for small examples (8pt).
2251 \def\smallernominalsize{8pt}
2252 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2253 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2254 \setfont\smallerbf\bfshape{10}{800}{OT1}
2255 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2256 \setfont\smallersl\slshape{8}{1000}{OT1}
2257 \setfont\smallersf\sfshape{8}{1000}{OT1}
2258 \setfont\smallersc\scshape{10}{800}{OT1}
2259 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2260 \font\smalleri=cmmi8
2261 \font\smallersy=cmsy8
2262 \def\smallerecsize{0800}
2263
2264 % Fonts for math mode superscripts (7pt).
2265 \def\sevennominalsize{7pt}
2266 \setfont\sevenrm\rmshape{7}{1000}{OT1}
2267 \setfont\seventt\ttshape{10}{700}{OT1TT}
2268 \setfont\sevenbf\bfshape{10}{700}{OT1}
2269 \setfont\sevenit\itshape{7}{1000}{OT1IT}
2270 \setfont\sevensl\slshape{10}{700}{OT1}
2271 \setfont\sevensf\sfshape{10}{700}{OT1}
2272 \setfont\sevensc\scshape{10}{700}{OT1}
2273 \setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2274 \font\seveni=cmmi7
2275 \font\sevensy=cmsy7
2276 \def\sevenecsize{0700}
2277
2278 % Fonts for title page (20.4pt):
2279 \def\titlenominalsize{20pt}
2280 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2281 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2282 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2283 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2284 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2285 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2286 \let\titlebf=\titlerm
2287 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2288 \font\titlei=cmmi12 scaled \magstep3
2289 \font\titlesy=cmsy10 scaled \magstep4
2290 \def\titleecsize{2074}
2291
2292 % Chapter (and unnumbered) fonts (17.28pt).
2293 \def\chapnominalsize{17pt}
2294 \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2295 \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2296 \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2297 \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2298 \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2299 \setfont\chapsf\sfbshape{17}{1000}{OT1}
2300 \let\chapbf=\chaprm
2301 \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
2302 \font\chapi=cmmi12 scaled \magstep2
2303 \font\chapsy=cmsy10 scaled \magstep3
2304 \def\chapecsize{1728}
2305
2306 % Section fonts (14.4pt).
2307 \def\secnominalsize{14pt}
2308 \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
2309 \setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
2310 \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2311 \setfont\secsl\slbshape{10}{\magstep2}{OT1}
2312 \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2313 \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2314 \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
2315 \let\secbf\secrm
2316 \setfont\secsc\scbshape{10}{\magstep2}{OT1}
2317 \font\seci=cmmi12 scaled \magstep1
2318 \font\secsy=cmsy10 scaled \magstep2
2319 \def\sececsize{1440}
2320
2321 % Subsection fonts (13.15pt).
2322 \def\ssecnominalsize{13pt}
2323 \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2324 \setfont\ssecit\itbshape{10}{1315}{OT1IT}
2325 \setfont\ssecsl\slbshape{10}{1315}{OT1}
2326 \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2327 \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2328 \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
2329 \let\ssecbf\ssecrm
2330 \setfont\ssecsc\scbshape{10}{1315}{OT1}
2331 \font\sseci=cmmi12 scaled \magstephalf
2332 \font\ssecsy=cmsy10 scaled 1315
2333 \def\ssececsize{1200}
2334
2335 % Reduced fonts for @acronym in text (10pt).
2336 \def\reducednominalsize{10pt}
2337 \setfont\reducedrm\rmshape{10}{1000}{OT1}
2338 \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2339 \setfont\reducedbf\bfshape{10}{1000}{OT1}
2340 \setfont\reducedit\itshape{10}{1000}{OT1IT}
2341 \setfont\reducedsl\slshape{10}{1000}{OT1}
2342 \setfont\reducedsf\sfshape{10}{1000}{OT1}
2343 \setfont\reducedsc\scshape{10}{1000}{OT1}
2344 \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
2345 \font\reducedi=cmmi10
2346 \font\reducedsy=cmsy10
2347 \def\reducedecsize{1000}
2348
2349 \textleading = 13.2pt % line spacing for 11pt CM
2350 \textfonts            % reset the current fonts
2351 \rm
2352 } % end of 11pt text font size definitions, \definetextfontsizexi
2353
2354
2355 % Definitions to make the main text be 10pt Computer Modern, with
2356 % section, chapter, etc., sizes following suit.  This is for the GNU
2357 % Press printing of the Emacs 22 manual.  Maybe other manuals in the
2358 % future.  Used with @smallbook, which sets the leading to 12pt.
2359 %
2360 \def\definetextfontsizex{%
2361 % Text fonts (10pt).
2362 \def\textnominalsize{10pt}
2363 \edef\mainmagstep{1000}
2364 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2365 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2366 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2367 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2368 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2369 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2370 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2371 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2372 \font\texti=cmmi10 scaled \mainmagstep
2373 \font\textsy=cmsy10 scaled \mainmagstep
2374 \def\textecsize{1000}
2375
2376 % A few fonts for @defun names and args.
2377 \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2378 \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
2379 \setfont\defsl\slshape{10}{\magstephalf}{OT1}
2380 \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
2381 \def\df{\let\ttfont=\deftt \let\bffont = \defbf
2382 \let\slfont=\defsl \let\ttslfont=\defttsl \bf}
2383
2384 % Fonts for indices, footnotes, small examples (9pt).
2385 \def\smallnominalsize{9pt}
2386 \setfont\smallrm\rmshape{9}{1000}{OT1}
2387 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2388 \setfont\smallbf\bfshape{10}{900}{OT1}
2389 \setfont\smallit\itshape{9}{1000}{OT1IT}
2390 \setfont\smallsl\slshape{9}{1000}{OT1}
2391 \setfont\smallsf\sfshape{9}{1000}{OT1}
2392 \setfont\smallsc\scshape{10}{900}{OT1}
2393 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2394 \font\smalli=cmmi9
2395 \font\smallsy=cmsy9
2396 \def\smallecsize{0900}
2397
2398 % Fonts for small examples (8pt).
2399 \def\smallernominalsize{8pt}
2400 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2401 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2402 \setfont\smallerbf\bfshape{10}{800}{OT1}
2403 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2404 \setfont\smallersl\slshape{8}{1000}{OT1}
2405 \setfont\smallersf\sfshape{8}{1000}{OT1}
2406 \setfont\smallersc\scshape{10}{800}{OT1}
2407 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2408 \font\smalleri=cmmi8
2409 \font\smallersy=cmsy8
2410 \def\smallerecsize{0800}
2411
2412 % Fonts for math mode superscripts (7pt).
2413 \def\sevennominalsize{7pt}
2414 \setfont\sevenrm\rmshape{7}{1000}{OT1}
2415 \setfont\seventt\ttshape{10}{700}{OT1TT}
2416 \setfont\sevenbf\bfshape{10}{700}{OT1}
2417 \setfont\sevenit\itshape{7}{1000}{OT1IT}
2418 \setfont\sevensl\slshape{10}{700}{OT1}
2419 \setfont\sevensf\sfshape{10}{700}{OT1}
2420 \setfont\sevensc\scshape{10}{700}{OT1}
2421 \setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2422 \font\seveni=cmmi7
2423 \font\sevensy=cmsy7
2424 \def\sevenecsize{0700}
2425
2426 % Fonts for title page (20.4pt):
2427 \def\titlenominalsize{20pt}
2428 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2429 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2430 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2431 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2432 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2433 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2434 \let\titlebf=\titlerm
2435 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2436 \font\titlei=cmmi12 scaled \magstep3
2437 \font\titlesy=cmsy10 scaled \magstep4
2438 \def\titleecsize{2074}
2439
2440 % Chapter fonts (14.4pt).
2441 \def\chapnominalsize{14pt}
2442 \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2443 \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2444 \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2445 \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2446 \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2447 \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2448 \let\chapbf\chaprm
2449 \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2450 \font\chapi=cmmi12 scaled \magstep1
2451 \font\chapsy=cmsy10 scaled \magstep2
2452 \def\chapecsize{1440}
2453
2454 % Section fonts (12pt).
2455 \def\secnominalsize{12pt}
2456 \setfont\secrm\rmbshape{12}{1000}{OT1}
2457 \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2458 \setfont\secsl\slbshape{10}{\magstep1}{OT1}
2459 \setfont\sectt\ttbshape{12}{1000}{OT1TT}
2460 \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2461 \setfont\secsf\sfbshape{12}{1000}{OT1}
2462 \let\secbf\secrm
2463 \setfont\secsc\scbshape{10}{\magstep1}{OT1}
2464 \font\seci=cmmi12
2465 \font\secsy=cmsy10 scaled \magstep1
2466 \def\sececsize{1200}
2467
2468 % Subsection fonts (10pt).
2469 \def\ssecnominalsize{10pt}
2470 \setfont\ssecrm\rmbshape{10}{1000}{OT1}
2471 \setfont\ssecit\itbshape{10}{1000}{OT1IT}
2472 \setfont\ssecsl\slbshape{10}{1000}{OT1}
2473 \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2474 \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2475 \setfont\ssecsf\sfbshape{10}{1000}{OT1}
2476 \let\ssecbf\ssecrm
2477 \setfont\ssecsc\scbshape{10}{1000}{OT1}
2478 \font\sseci=cmmi10
2479 \font\ssecsy=cmsy10
2480 \def\ssececsize{1000}
2481
2482 % Reduced fonts for @acronym in text (9pt).
2483 \def\reducednominalsize{9pt}
2484 \setfont\reducedrm\rmshape{9}{1000}{OT1}
2485 \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2486 \setfont\reducedbf\bfshape{10}{900}{OT1}
2487 \setfont\reducedit\itshape{9}{1000}{OT1IT}
2488 \setfont\reducedsl\slshape{9}{1000}{OT1}
2489 \setfont\reducedsf\sfshape{9}{1000}{OT1}
2490 \setfont\reducedsc\scshape{10}{900}{OT1}
2491 \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2492 \font\reducedi=cmmi9
2493 \font\reducedsy=cmsy9
2494 \def\reducedecsize{0900}
2495
2496 \divide\parskip by 2  % reduce space between paragraphs
2497 \textleading = 12pt   % line spacing for 10pt CM
2498 \textfonts            % reset the current fonts
2499 \rm
2500 } % end of 10pt text font size definitions, \definetextfontsizex
2501
2502 % Fonts for short table of contents.
2503 \setfont\shortcontrm\rmshape{12}{1000}{OT1}
2504 \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
2505 \setfont\shortcontsl\slshape{12}{1000}{OT1}
2506 \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2507
2508
2509 % We provide the user-level command
2510 %   @fonttextsize 10
2511 % (or 11) to redefine the text font size.  pt is assumed.
2512 %
2513 \def\xiword{11}
2514 \def\xword{10}
2515 \def\xwordpt{10pt}
2516 %
2517 \parseargdef\fonttextsize{%
2518   \def\textsizearg{#1}%
2519   %\wlog{doing @fonttextsize \textsizearg}%
2520   %
2521   % Set \globaldefs so that documents can use this inside @tex, since
2522   % makeinfo 4.8 does not support it, but we need it nonetheless.
2523   %
2524  \begingroup \globaldefs=1
2525   \ifx\textsizearg\xword \definetextfontsizex
2526   \else \ifx\textsizearg\xiword \definetextfontsizexi
2527   \else
2528     \errhelp=\EMsimple
2529     \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2530   \fi\fi
2531  \endgroup
2532 }
2533
2534 %
2535 % Change the current font style to #1, remembering it in \curfontstyle.
2536 % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
2537 % italics, not bold italics.
2538 %
2539 \def\setfontstyle#1{%
2540   \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
2541   \csname #1font\endcsname  % change the current font
2542 }
2543
2544 \def\rm{\fam=0 \setfontstyle{rm}}
2545 \def\it{\fam=\itfam \setfontstyle{it}}
2546 \def\sl{\fam=\slfam \setfontstyle{sl}}
2547 \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
2548 \def\tt{\fam=\ttfam \setfontstyle{tt}}
2549
2550 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
2551 % So we set up a \sf.
2552 \newfam\sffam
2553 \def\sf{\fam=\sffam \setfontstyle{sf}}
2554
2555 % We don't need math for this font style.
2556 \def\ttsl{\setfontstyle{ttsl}}
2557
2558
2559 % In order for the font changes to affect most math symbols and letters,
2560 % we have to define the \textfont of the standard families.
2561 % We don't bother to reset \scriptscriptfont; awaiting user need.
2562 %
2563 \def\resetmathfonts{%
2564   \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont
2565   \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont
2566   \textfont\ttfam=\ttfont \textfont\sffam=\sffont
2567   %
2568   % Fonts for superscript.  Note that the 7pt fonts are used regardless
2569   % of the current font size.
2570   \scriptfont0=\sevenrm \scriptfont1=\seveni \scriptfont2=\sevensy
2571   \scriptfont\itfam=\sevenit \scriptfont\slfam=\sevensl
2572   \scriptfont\bffam=\sevenbf \scriptfont\ttfam=\seventt
2573   \scriptfont\sffam=\sevensf
2574 }
2575
2576 %
2577
2578 % The font-changing commands (all called \...fonts) redefine the meanings
2579 % of \STYLEfont, instead of just \STYLE.  We do this because \STYLE needs
2580 % to also set the current \fam for math mode.  Our \STYLE (e.g., \rm)
2581 % commands hardwire \STYLEfont to set the current font.
2582 %
2583 % The fonts used for \ifont are for "math italics"  (\itfont is for italics
2584 % in regular text).  \syfont is also used in math mode only.
2585 %
2586 % Each font-changing command also sets the names \lsize (one size lower)
2587 % and \lllsize (three sizes lower).  These relative commands are used
2588 % in, e.g., the LaTeX logo and acronyms.
2589 %
2590 % This all needs generalizing, badly.
2591 %
2592
2593 \def\assignfonts#1{%
2594   \expandafter\let\expandafter\rmfont\csname #1rm\endcsname
2595   \expandafter\let\expandafter\itfont\csname #1it\endcsname
2596   \expandafter\let\expandafter\slfont\csname #1sl\endcsname
2597   \expandafter\let\expandafter\bffont\csname #1bf\endcsname
2598   \expandafter\let\expandafter\ttfont\csname #1tt\endcsname
2599   \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname
2600   \expandafter\let\expandafter\sffont  \csname #1sf\endcsname
2601   \expandafter\let\expandafter\ifont   \csname #1i\endcsname
2602   \expandafter\let\expandafter\syfont  \csname #1sy\endcsname
2603   \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname
2604 }
2605
2606 \newif\ifrmisbold
2607
2608 % Select smaller font size with the current style.  Used to change font size
2609 % in, e.g., the LaTeX logo and acronyms.  If we are using bold fonts for
2610 % normal roman text, also use bold fonts for roman text in the smaller size.
2611 \def\switchtolllsize{%
2612    \expandafter\assignfonts\expandafter{\lllsize}%
2613    \ifrmisbold
2614      \let\rmfont\bffont
2615    \fi
2616    \csname\curfontstyle\endcsname
2617 }%
2618
2619 \def\switchtolsize{%
2620    \expandafter\assignfonts\expandafter{\lsize}%
2621    \ifrmisbold
2622      \let\rmfont\bffont
2623    \fi
2624    \csname\curfontstyle\endcsname
2625 }%
2626
2627 \def\definefontsetatsize#1#2#3#4#5{%
2628 \expandafter\def\csname #1fonts\endcsname{%
2629   \def\curfontsize{#1}%
2630   \def\lsize{#2}\def\lllsize{#3}%
2631   \csname rmisbold#5\endcsname
2632   \assignfonts{#1}%
2633   \resetmathfonts
2634   \setleading{#4}%
2635 }}
2636
2637 \definefontsetatsize{text}   {reduced}{smaller}{\textleading}{false}
2638 \definefontsetatsize{title}  {chap}   {subsec} {27pt}  {true}
2639 \definefontsetatsize{chap}   {sec}    {text}   {19pt}  {true}
2640 \definefontsetatsize{sec}    {subsec} {reduced}{17pt}  {true}
2641 \definefontsetatsize{ssec}   {text}   {small}  {15pt}  {true}
2642 \definefontsetatsize{reduced}{small}  {smaller}{10.5pt}{false}
2643 \definefontsetatsize{small}  {smaller}{smaller}{10.5pt}{false}
2644 \definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false}
2645
2646 \def\titlefont#1{{\titlefonts\rm #1}}
2647 \let\subsecfonts = \ssecfonts
2648 \let\subsubsecfonts = \ssecfonts
2649
2650 % Define these just so they can be easily changed for other fonts.
2651 \def\angleleft{$\langle$}
2652 \def\angleright{$\rangle$}
2653
2654 % Set the fonts to use with the @small... environments.
2655 \let\smallexamplefonts = \smallfonts
2656
2657 % About \smallexamplefonts.  If we use \smallfonts (9pt), @smallexample
2658 % can fit this many characters:
2659 %   8.5x11=86   smallbook=72  a4=90  a5=69
2660 % If we use \scriptfonts (8pt), then we can fit this many characters:
2661 %   8.5x11=90+  smallbook=80  a4=90+  a5=77
2662 % For me, subjectively, the few extra characters that fit aren't worth
2663 % the additional smallness of 8pt.  So I'm making the default 9pt.
2664 %
2665 % By the way, for comparison, here's what fits with @example (10pt):
2666 %   8.5x11=71  smallbook=60  a4=75  a5=58
2667 % --karl, 24jan03.
2668
2669 % Set up the default fonts, so we can use them for creating boxes.
2670 %
2671 \definetextfontsizexi
2672
2673
2674 % Check if we are currently using a typewriter font.  Since all the
2675 % Computer Modern typewriter fonts have zero interword stretch (and
2676 % shrink), and it is reasonable to expect all typewriter fonts to have
2677 % this property, we can check that font parameter.
2678 %
2679 \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
2680
2681 % Check if internal flag is clear, i.e. has not been @set.
2682 \def\ifflagclear#1#2#3{%
2683   \expandafter\ifx\csname SET#1\endcsname\relax
2684   #2\else#3\fi
2685 }
2686
2687
2688
2689 {
2690 \catcode`\'=\active
2691 \catcode`\`=\active
2692
2693 \gdef\setcodequotes{\let`\codequoteleft \let'\codequoteright}
2694 \gdef\setregularquotes{\let`\lq \let'\rq}
2695 }
2696
2697 % Allow an option to not use regular directed right quote/apostrophe
2698 % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2699 % The undirected quote is ugly, so don't make it the default, but it
2700 % works for pasting with more pdf viewers (at least evince), the
2701 % lilypond developers report.  xpdf does work with the regular 0x27.
2702 %
2703 \def\codequoteright{%
2704   \ifmonospace
2705     \ifflagclear{txicodequoteundirected}{%
2706       \ifflagclear{codequoteundirected}{%
2707         '%
2708       }{\char'15 }%
2709     }{\char'15 }%
2710   \else
2711     '%
2712   \fi
2713 }
2714 %
2715 % and a similar option for the left quote char vs. a grave accent.
2716 % Modern fonts display ASCII 0x60 as a grave accent, so some people like
2717 % the code environments to do likewise.
2718 %
2719 \def\codequoteleft{%
2720   \ifmonospace
2721     \ifflagclear{txicodequotebacktick}{%
2722       \ifflagclear{codequotebacktick}{%
2723         % [Knuth] pp. 380,381,391
2724         % \relax disables Spanish ligatures ?` and !` of \tt font.
2725         \relax`%
2726       }{\char'22 }%
2727     }{\char'22 }%
2728   \else
2729     \relax`%
2730   \fi
2731 }
2732
2733 % Commands to set the quote options.
2734 %
2735 \parseargdef\codequoteundirected{%
2736   \def\temp{#1}%
2737   \ifx\temp\onword
2738     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2739       = t%
2740   \else\ifx\temp\offword
2741     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2742       = \relax
2743   \else
2744     \errhelp = \EMsimple
2745     \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2746   \fi\fi
2747 }
2748 %
2749 \parseargdef\codequotebacktick{%
2750   \def\temp{#1}%
2751   \ifx\temp\onword
2752     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2753       = t%
2754   \else\ifx\temp\offword
2755     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2756       = \relax
2757   \else
2758     \errhelp = \EMsimple
2759     \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2760   \fi\fi
2761 }
2762
2763 % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2764 \def\noligaturesquoteleft{\relax\lq}
2765
2766 % Count depth in font-changes, for error checks
2767 \newcount\fontdepth \fontdepth=0
2768
2769 % Font commands.
2770
2771 % #1 is the font command (\sl or \it), #2 is the text to slant.
2772 % If we are in a monospaced environment, however, 1) always use \ttsl,
2773 % and 2) do not add an italic correction.
2774 \def\dosmartslant#1#2{%
2775   \ifusingtt
2776     {{\ttsl #2}\let\next=\relax}%
2777     {\def\next{{#1#2}\smartitaliccorrection}}%
2778   \next
2779 }
2780 \def\smartslanted{\dosmartslant\sl}
2781 \def\smartitalic{\dosmartslant\it}
2782
2783 % Output an italic correction unless the following character is such as
2784 % not to need one.
2785 \def\smartitaliccorrection{\futurelet\next\smartitaliccorrectionx}
2786 \def\smartitaliccorrectionx{%
2787   \ifx\next,%
2788   \else\ifx\next-%
2789   \else\ifx\next.%
2790   \else\ifx\next\.%
2791   \else\ifx\next\comma%
2792   \else\ptexslash
2793   \fi\fi\fi\fi\fi
2794   \aftersmartic
2795 }
2796
2797 % @cite unconditionally uses \sl with \smartitaliccorrection.
2798 \def\cite#1{{\sl #1}\smartitaliccorrection}
2799
2800 % @var unconditionally uses \sl.  This gives consistency for
2801 % parameter names whether they are in @def, @table @code or a
2802 % regular paragraph.
2803 %  To get ttsl font for @var when used in code context, @set txicodevaristt.
2804 % The \null is to reset \spacefactor.
2805 \def\aftersmartic{}
2806 \def\var#1{%
2807   \let\saveaftersmartic = \aftersmartic
2808   \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
2809   %
2810   \ifflagclear{txicodevaristt}%
2811     {\def\varnext{{{\sl #1}}\smartitaliccorrection}}%
2812     {\def\varnext{\smartslanted{#1}}}%
2813   \varnext
2814 }
2815
2816 % To be removed after next release
2817 \def\SETtxicodevaristt{}% @set txicodevaristt
2818
2819 \let\i=\smartitalic
2820 \let\slanted=\smartslanted
2821 \let\dfn=\smartslanted
2822 \let\emph=\smartitalic
2823
2824 % @r for roman font, used for code comment
2825 \def\r#1{{%
2826   \usenormaldash % get --, --- ligatures even if in @code
2827   \defcharsdefault  % in case on def line
2828   \rm #1}}
2829 {\catcode`-=\active \gdef\usenormaldash{\let-\normaldash}}
2830
2831 % @sc, undocumented @ii.
2832 \def\sc#1{{\smallcaps#1}}       % smallcaps font
2833 \def\ii#1{{\it #1}}             % italic font
2834
2835 % @b, explicit bold.  Also @strong.
2836 \def\b#1{{\bf #1}}
2837 \let\strong=\b
2838
2839 % @sansserif, explicit sans.
2840 \def\sansserif#1{{\sf #1}}
2841
2842 % We can't just use \exhyphenpenalty, because that only has effect at
2843 % the end of a paragraph.  Restore normal hyphenation at the end of the
2844 % group within which \nohyphenation is presumably called.
2845 %
2846 \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
2847 \def\restorehyphenation{\hyphenchar\font = `- }
2848
2849 % Set sfcode to normal for the chars that usually have another value.
2850 % Can't use plain's \frenchspacing because it uses the `\x notation, and
2851 % sometimes \x has an active definition that messes things up.
2852 %
2853 \catcode`@=11
2854   \def\plainfrenchspacing{%
2855     \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
2856     \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
2857     \def\endofsentencespacefactor{1000}% for @. and friends
2858   }
2859   \def\plainnonfrenchspacing{%
2860     \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2861     \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2862     \def\endofsentencespacefactor{3000}% for @. and friends
2863   }
2864 \catcode`@=\other
2865 \def\endofsentencespacefactor{3000}% default
2866
2867 % @t, explicit typewriter.
2868 \def\t#1{%
2869   {\tt \defcharsdefault \plainfrenchspacing #1}%
2870   \null
2871 }
2872
2873 % @samp.
2874 \def\samp#1{{\setcodequotes\lq\tclose{#1}\rq\null}}
2875
2876 % @indicateurl is \samp, that is, with quotes.
2877 \let\indicateurl=\samp
2878
2879 % @code (and similar) prints in typewriter, but with spaces the same
2880 % size as normal in the surrounding text, without hyphenation, etc.
2881 % This is a subroutine for that.
2882 \def\tclose#1{%
2883   {%
2884     % Change normal interword space to be same as for the current font.
2885     \spaceskip = \fontdimen2\font
2886     %
2887     % Switch to typewriter.
2888     \tt
2889     %
2890     % But `\ ' produces the large typewriter interword space.
2891     \def\ {{\spaceskip = 0pt{} }}%
2892     %
2893     % Turn off hyphenation.
2894     \nohyphenation
2895     %
2896     \plainfrenchspacing
2897     #1%
2898   }%
2899   \null % reset spacefactor to 1000
2900 }
2901
2902 % We *must* turn on hyphenation at `-' and `_' in @code.
2903 % (But see \codedashfinish below.)
2904 % Otherwise, it is too hard to avoid overfull hboxes
2905 % in the Emacs manual, the Library manual, etc.
2906 %
2907 % Unfortunately, TeX uses one parameter (\hyphenchar) to control
2908 % both hyphenation at - and hyphenation within words.
2909 % We must therefore turn them both off (\tclose does that)
2910 % and arrange explicitly to hyphenate at a dash. -- rms.
2911 {
2912   \catcode`\-=\active \catcode`\_=\active
2913   \catcode`\'=\active \catcode`\`=\active
2914   \global\let'=\rq \global\let`=\lq  % default definitions
2915   %
2916   \global\def\code{\begingroup
2917     \setcodequotes
2918     \catcode\dashChar=\active  \catcode\underChar=\active
2919     \ifallowcodebreaks
2920      \let-\codedash
2921      \let_\codeunder
2922     \else
2923      \let-\normaldash
2924      \let_\realunder
2925     \fi
2926     % Given -foo (with a single dash), we do not want to allow a break
2927     % after the hyphen.
2928     \global\let\codedashprev=\codedash
2929     %
2930     \codex
2931   }
2932   %
2933   \gdef\codedash{\futurelet\next\codedashfinish}
2934   \gdef\codedashfinish{%
2935     \normaldash % always output the dash character itself.
2936     %
2937     % Now, output a discretionary to allow a line break, unless
2938     % (a) the next character is a -, or
2939     % (b) the preceding character is a -.
2940     % E.g., given --posix, we do not want to allow a break after either -.
2941     % Given --foo-bar, we do want to allow a break between the - and the b.
2942     \ifx\next\codedash \else
2943       \ifx\codedashprev\codedash
2944       \else \discretionary{}{}{}\fi
2945     \fi
2946     % we need the space after the = for the case when \next itself is a
2947     % space token; it would get swallowed otherwise.  As in @code{- a}.
2948     \global\let\codedashprev= \next
2949   }
2950 }
2951 \def\normaldash{-}
2952 %
2953 \def\codex #1{\tclose{#1}\endgroup}
2954
2955 \def\codeunder{%
2956   % this is all so @math{@code{var_name}+1} can work.  In math mode, _
2957   % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2958   % will therefore expand the active definition of _, which is us
2959   % (inside @code that is), therefore an endless loop.
2960   \ifusingtt{\ifmmode
2961                \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2962              \else\normalunderscore \fi
2963              \discretionary{}{}{}}%
2964             {\_}%
2965 }
2966
2967 % An additional complication: the above will allow breaks after, e.g.,
2968 % each of the four underscores in __typeof__.  This is bad.
2969 % @allowcodebreaks provides a document-level way to turn breaking at -
2970 % and _ on and off.
2971 %
2972 \newif\ifallowcodebreaks  \allowcodebreakstrue
2973
2974 \def\keywordtrue{true}
2975 \def\keywordfalse{false}
2976
2977 \parseargdef\allowcodebreaks{%
2978   \def\txiarg{#1}%
2979   \ifx\txiarg\keywordtrue
2980     \allowcodebreakstrue
2981   \else\ifx\txiarg\keywordfalse
2982     \allowcodebreaksfalse
2983   \else
2984     \errhelp = \EMsimple
2985     \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
2986   \fi\fi
2987 }
2988
2989 % For @command, @env, @file, @option quotes seem unnecessary,
2990 % so use \code rather than \samp.
2991 \let\command=\code
2992 \let\env=\code
2993 \let\file=\code
2994 \let\option=\code
2995
2996 % @uref (abbreviation for `urlref') aka @url takes an optional
2997 % (comma-separated) second argument specifying the text to display and
2998 % an optional third arg as text to display instead of (rather than in
2999 % addition to) the url itself.  First (mandatory) arg is the url.
3000
3001 % TeX-only option to allow changing PDF output to show only the second
3002 % arg (if given), and not the url (which is then just the link target).
3003 \newif\ifurefurlonlylink
3004
3005 % The default \pretolerance setting stops the penalty inserted in
3006 % \urefallowbreak being a discouragement to line breaking.  Set it to
3007 % a negative value for this paragraph only.  Hopefully this does not
3008 % conflict with redefinitions of \par done elsewhere.
3009 \def\nopretolerance{%
3010 \pretolerance=-1
3011 \def\par{\endgraf\pretolerance=100 \let\par\endgraf}%
3012 }
3013
3014 % The main macro is \urefbreak, which allows breaking at expected
3015 % places within the url.
3016 \def\urefbreak{\nopretolerance \begingroup \urefcatcodes \dourefbreak}
3017 \let\uref=\urefbreak
3018 %
3019 \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
3020 \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
3021   \unsepspaces
3022   \pdfurl{#1}%
3023   \setbox0 = \hbox{\ignorespaces #3}%
3024   \ifdim\wd0 > 0pt
3025     \unhbox0 % third arg given, show only that
3026   \else
3027     \setbox0 = \hbox{\ignorespaces #2}% look for second arg
3028     \ifdim\wd0 > 0pt
3029       \ifpdf
3030         % For pdfTeX and LuaTeX
3031         \ifurefurlonlylink
3032           % PDF plus option to not display url, show just arg
3033           \unhbox0
3034         \else
3035           % PDF, normally display both arg and url for consistency,
3036           % visibility, if the pdf is eventually used to print, etc.
3037           \unhbox0\ (\urefcode{#1})%
3038         \fi
3039       \else
3040         \ifx\XeTeXrevision\thisisundefined
3041           \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
3042         \else
3043           % For XeTeX
3044           \ifurefurlonlylink
3045             % PDF plus option to not display url, show just arg
3046             \unhbox0
3047           \else
3048             % PDF, normally display both arg and url for consistency,
3049             % visibility, if the pdf is eventually used to print, etc.
3050             \unhbox0\ (\urefcode{#1})%
3051           \fi
3052         \fi
3053       \fi
3054     \else
3055       \urefcode{#1}% only url given, so show it
3056     \fi
3057   \fi
3058   \endlink
3059 \endgroup}
3060
3061 % Allow line breaks around only a few characters (only).
3062 \def\urefcatcodes{%
3063   \catcode`\&=\active \catcode`\.=\active
3064   \catcode`\#=\active \catcode`\?=\active
3065   \catcode`\/=\active
3066 }
3067 {
3068   \urefcatcodes
3069   %
3070   \global\def\urefcode{\begingroup
3071     \setcodequotes
3072     \urefcatcodes
3073     \let&\urefcodeamp
3074     \let.\urefcodedot
3075     \let#\urefcodehash
3076     \let?\urefcodequest
3077     \let/\urefcodeslash
3078     \codex
3079   }
3080   %
3081   % By default, they are just regular characters.
3082   \global\def&{\normalamp}
3083   \global\def.{\normaldot}
3084   \global\def#{\normalhash}
3085   \global\def?{\normalquest}
3086   \global\def/{\normalslash}
3087 }
3088
3089 \def\urefcodeamp{\urefprebreak \&\urefpostbreak}
3090 \def\urefcodedot{\urefprebreak .\urefpostbreak}
3091 \def\urefcodehash{\urefprebreak \#\urefpostbreak}
3092 \def\urefcodequest{\urefprebreak ?\urefpostbreak}
3093 \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
3094 {
3095   \catcode`\/=\active
3096   \global\def\urefcodeslashfinish{%
3097     \urefprebreak \slashChar
3098     % Allow line break only after the final / in a sequence of
3099     % slashes, to avoid line break between the slashes in http://.
3100     \ifx\next/\else \urefpostbreak \fi
3101   }
3102 }
3103
3104 % By default we'll break after the special characters, but some people like to
3105 % break before the special chars, so allow that.  Also allow no breaking at
3106 % all, for manual control.
3107 %
3108 \parseargdef\urefbreakstyle{%
3109   \def\txiarg{#1}%
3110   \ifx\txiarg\wordnone
3111     \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
3112   \else\ifx\txiarg\wordbefore
3113     \def\urefprebreak{\urefallowbreak}\def\urefpostbreak{\nobreak}
3114   \else\ifx\txiarg\wordafter
3115     \def\urefprebreak{\nobreak}\def\urefpostbreak{\urefallowbreak}
3116   \else
3117     \errhelp = \EMsimple
3118     \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
3119   \fi\fi\fi
3120 }
3121 \def\wordafter{after}
3122 \def\wordbefore{before}
3123 \def\wordnone{none}
3124
3125 % Allow a ragged right output to aid breaking long URL's.  There can
3126 % be a break at the \allowbreak with no extra glue (if the existing stretch in
3127 % the line is sufficient), a break at the \penalty with extra glue added
3128 % at the end of the line, or no break at all here.
3129 %   Changing the value of the penalty and/or the amount of stretch affects how
3130 % preferable one choice is over the other.
3131 \def\urefallowbreak{%
3132   \penalty0\relax
3133   \hskip 0pt plus 2 em\relax
3134   \penalty1000\relax
3135   \hskip 0pt plus -2 em\relax
3136 }
3137
3138 \urefbreakstyle after
3139
3140 % @url synonym for @uref, since that's how everyone uses it.
3141 %
3142 \let\url=\uref
3143
3144 % rms does not like angle brackets --karl, 17may97.
3145 % So now @email is just like @uref, unless we are pdf.
3146 %
3147 %\def\email#1{\angleleft{\tt #1}\angleright}
3148 \ifpdforxetex
3149   \def\email#1{\doemail#1,,\finish}
3150   \def\doemail#1,#2,#3\finish{\begingroup
3151     \unsepspaces
3152     \pdfurl{mailto:#1}%
3153     \setbox0 = \hbox{\ignorespaces #2}%
3154     \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3155     \endlink
3156   \endgroup}
3157 \else
3158   \let\email=\uref
3159 \fi
3160
3161 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
3162 %   `example' (@kbd uses ttsl only inside of @example and friends),
3163 %   or `code' (@kbd uses normal tty font always).
3164 \parseargdef\kbdinputstyle{%
3165   \def\txiarg{#1}%
3166   \ifx\txiarg\worddistinct
3167     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
3168   \else\ifx\txiarg\wordexample
3169     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
3170   \else\ifx\txiarg\wordcode
3171     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
3172   \else
3173     \errhelp = \EMsimple
3174     \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
3175   \fi\fi\fi
3176 }
3177 \def\worddistinct{distinct}
3178 \def\wordexample{example}
3179 \def\wordcode{code}
3180
3181 % Default is `distinct'.
3182 \kbdinputstyle distinct
3183
3184 \def\kbd#1{%
3185   \tclose{\kbdfont\setcodequotes#1}%
3186 }
3187
3188 % definition of @key that produces a lozenge.  Doesn't adjust to text size.
3189 %\setfont\keyrm\rmshape{8}{1000}{OT1}
3190 %\font\keysy=cmsy9
3191 %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
3192 %  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
3193 %    \vbox{\hrule\kern-0.4pt
3194 %     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
3195 %    \kern-0.4pt\hrule}%
3196 %  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
3197
3198 % definition of @key with no lozenge.
3199 %
3200 \def\key#1{{\setregularquotes \nohyphenation \tt #1}\null}
3201
3202 % @clicksequence{File @click{} Open ...}
3203 \def\clicksequence#1{\begingroup #1\endgroup}
3204
3205 % @clickstyle @arrow   (by default)
3206 \parseargdef\clickstyle{\def\click{#1}}
3207 \def\click{\arrow}
3208
3209 % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
3210 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
3211 %
3212 \def\dmn#1{\thinspace #1}
3213
3214 % @acronym for "FBI", "NATO", and the like.
3215 % We print this one point size smaller, since it's intended for
3216 % all-uppercase.
3217 %
3218 \def\acronym#1{\doacronym #1,,\finish}
3219 \def\doacronym#1,#2,#3\finish{%
3220   {\switchtolsize #1}%
3221   \def\temp{#2}%
3222   \ifx\temp\empty \else
3223     \space ({\unsepspaces \ignorespaces \temp \unskip})%
3224   \fi
3225   \null % reset \spacefactor=1000
3226 }
3227
3228 % @abbr for "Comput. J." and the like.
3229 % No font change, but don't do end-of-sentence spacing.
3230 %
3231 \def\abbr#1{\doabbr #1,,\finish}
3232 \def\doabbr#1,#2,#3\finish{%
3233   {\plainfrenchspacing #1}%
3234   \def\temp{#2}%
3235   \ifx\temp\empty \else
3236     \space ({\unsepspaces \ignorespaces \temp \unskip})%
3237   \fi
3238   \null % reset \spacefactor=1000
3239 }
3240
3241 % @asis just yields its argument.  Used with @table, for example.
3242 %
3243 \def\asis#1{#1}
3244
3245 % @math outputs its argument in math mode.
3246 %
3247 % One complication: _ usually means subscripts, but it could also mean
3248 % an actual _ character, as in @math{@var{some_variable} + 1}.  So make
3249 % _ active, and distinguish by seeing if the current family is \slfam,
3250 % which is what @var uses.
3251 {
3252   \catcode`\_ = \active
3253   \gdef\mathunderscore{%
3254     \catcode`\_=\active
3255     \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
3256   }
3257 }
3258 % Another complication: we want \\ (and @\) to output a math (or tt) \.
3259 % FYI, plain.tex uses \\ as a temporary control sequence (for no
3260 % particular reason), but this is not advertised and we don't care.
3261 %
3262 % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
3263 \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
3264 %
3265 \def\math{%
3266   \ifmmode\else % only go into math if not in math mode already
3267     \tex
3268     \mathunderscore
3269     \let\\ = \mathbackslash
3270     \mathactive
3271     % make the texinfo accent commands work in math mode
3272     \let\"=\ddot
3273     \let\'=\acute
3274     \let\==\bar
3275     \let\^=\hat
3276     \let\`=\grave
3277     \let\u=\breve
3278     \let\v=\check
3279     \let\~=\tilde
3280     \let\dotaccent=\dot
3281     % have to provide another name for sup operator
3282     \let\mathopsup=\sup
3283   $\expandafter\finishmath\fi
3284 }
3285 \def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
3286
3287 % Some active characters (such as <) are spaced differently in math.
3288 % We have to reset their definitions in case the @math was an argument
3289 % to a command which sets the catcodes (such as @item or @section).
3290 %
3291 {
3292   \catcode`^ = \active
3293   \catcode`< = \active
3294   \catcode`> = \active
3295   \catcode`+ = \active
3296   \catcode`' = \active
3297   \gdef\mathactive{%
3298     \let^ = \ptexhat
3299     \let< = \ptexless
3300     \let> = \ptexgtr
3301     \let+ = \ptexplus
3302     \let' = \ptexquoteright
3303   }
3304 }
3305
3306 % for @sub and @sup, if in math mode, just do a normal sub/superscript.
3307 % If in text, use math to place as sub/superscript, but switch
3308 % into text mode, with smaller fonts.  This is a different font than the
3309 % one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3310 % fix it (significant additions to font machinery) until someone notices.
3311 %
3312 \def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
3313 \def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}%
3314 %
3315 \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
3316 \def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}%
3317
3318 % provide this command from LaTeX as it is very common
3319 \def\frac#1#2{{{#1}\over{#2}}}
3320
3321 % @displaymath.
3322 % \globaldefs is needed to recognize the end lines in \tex and
3323 % \end tex.  Set \thisenv as @end displaymath is seen before @end tex.
3324 {\obeylines
3325 \globaldefs=1
3326 \envdef\displaymath{%
3327 \tex%
3328 \def\thisenv{\displaymath}%
3329 \begingroup\let\end\displaymathend%
3330 $$%
3331 }
3332
3333 \def\displaymathend{$$\endgroup\end}%
3334
3335 \def\Edisplaymath{%
3336 \def\thisenv{\tex}%
3337 \end tex
3338 }}
3339
3340
3341 % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3342 % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3343 % except specified as a normal braced arg, so no newlines to worry about.
3344 %
3345 \def\outfmtnametex{tex}
3346 %
3347 \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3348 \long\def\doinlinefmt#1,#2,\finish{%
3349   \def\inlinefmtname{#1}%
3350   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3351 }
3352 %
3353 % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3354 % FMTNAME is tex, else ELSE-TEXT.
3355 \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3356 \long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3357   \def\inlinefmtname{#1}%
3358   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3359 }
3360 %
3361 % For raw, must switch into @tex before parsing the argument, to avoid
3362 % setting catcodes prematurely.  Doing it this way means that, for
3363 % example, @inlineraw{html, foo{bar} gets a parse error instead of being
3364 % ignored.  But this isn't important because if people want a literal
3365 % *right* brace they would have to use a command anyway, so they may as
3366 % well use a command to get a left brace too.  We could re-use the
3367 % delimiter character idea from \verb, but it seems like overkill.
3368 %
3369 \long\def\inlineraw{\tex \doinlineraw}
3370 \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3371 \def\doinlinerawtwo#1,#2,\finish{%
3372   \def\inlinerawname{#1}%
3373   \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3374   \endgroup % close group opened by \tex.
3375 }
3376
3377 % @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3378 %
3379 \long\def\inlineifset#1{\doinlineifset #1,\finish}
3380 \long\def\doinlineifset#1,#2,\finish{%
3381   \def\inlinevarname{#1}%
3382   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3383   \else\ignorespaces#2\fi
3384 }
3385
3386 % @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3387 %
3388 \long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3389 \long\def\doinlineifclear#1,#2,\finish{%
3390   \def\inlinevarname{#1}%
3391   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3392 }
3393
3394
3395 \message{glyphs,}
3396 % and logos.
3397
3398 % @@ prints an @, as does @atchar{}.
3399 \def\@{\char64 }
3400 \let\atchar=\@
3401
3402 % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
3403 \def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}}
3404 \def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}}
3405 \let\{=\lbracechar
3406 \let\}=\rbracechar
3407
3408 % @comma{} to avoid , parsing problems.
3409 \let\comma = ,
3410
3411 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3412 % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3413 \let\, = \ptexc
3414 \let\dotaccent = \ptexdot
3415 \def\ringaccent#1{{\accent23 #1}}
3416 \let\tieaccent = \ptext
3417 \let\ubaraccent = \ptexb
3418 \let\udotaccent = \d
3419
3420 % Other special characters: @questiondown @exclamdown @ordf @ordm
3421 % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3422 \def\questiondown{?`}
3423 \def\exclamdown{!`}
3424 \def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}}
3425 \def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}}
3426
3427 % Dotless i and dotless j, used for accents.
3428 \def\imacro{i}
3429 \def\jmacro{j}
3430 \def\dotless#1{%
3431   \def\temp{#1}%
3432   \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3433   \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3434   \else \errmessage{@dotless can be used only with i or j}%
3435   \fi\fi
3436 }
3437
3438 % The \TeX{} logo, as in plain, but resetting the spacing so that a
3439 % period following counts as ending a sentence.  (Idea found in latex.)
3440 %
3441 \edef\TeX{\TeX \spacefactor=1000 }
3442
3443 % @LaTeX{} logo.  Not quite the same results as the definition in
3444 % latex.ltx, since we use a different font for the raised A; it's most
3445 % convenient for us to use an explicitly smaller font, rather than using
3446 % the \scriptstyle font (since we don't reset \scriptstyle and
3447 % \scriptscriptstyle).
3448 %
3449 \def\LaTeX{%
3450   L\kern-.36em
3451   {\setbox0=\hbox{T}%
3452    \vbox to \ht0{\hbox{%
3453      \ifx\textnominalsize\xwordpt
3454        % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX.
3455        % Revert to plain's \scriptsize, which is 7pt.
3456        \count255=\the\fam $\fam\count255 \scriptstyle A$%
3457      \else
3458        \ifx\curfontsize\smallword
3459          % For footnotes and indices
3460          \count255=\the\fam $\fam\count255 \scriptstyle A$%
3461        \else
3462          % For 11pt, we can use our lllsize.
3463          \switchtolllsize A%
3464        \fi
3465      \fi
3466      }%
3467      \vss
3468   }}%
3469   \kern-.15em
3470   \TeX
3471 }
3472 \def\smallword{small}
3473
3474 % Some math mode symbols.  Define \ensuremath to switch into math mode
3475 % unless we are already there.  Expansion tricks may not be needed here,
3476 % but safer, and can't hurt.
3477 \def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3478 \def\ensuredmath#1{$\relax#1$}
3479 %
3480 \def\bullet{\ensuremath\ptexbullet}
3481 \def\geq{\ensuremath\ge}
3482 \def\leq{\ensuremath\le}
3483 \def\minus{\ensuremath-}
3484
3485 % @dots{} outputs an ellipsis using the current font.
3486 % We do .5em per period so that it has the same spacing in the cm
3487 % typewriter fonts as three actual period characters; on the other hand,
3488 % in other typewriter fonts three periods are wider than 1.5em.  So do
3489 % whichever is larger.
3490 %
3491 \def\dots{%
3492   \leavevmode
3493   \setbox0=\hbox{...}% get width of three periods
3494   \ifdim\wd0 > 1.5em
3495     \dimen0 = \wd0
3496   \else
3497     \dimen0 = 1.5em
3498   \fi
3499   \hbox to \dimen0{%
3500     \hskip 0pt plus.25fil
3501     .\hskip 0pt plus1fil
3502     .\hskip 0pt plus1fil
3503     .\hskip 0pt plus.5fil
3504   }%
3505 }
3506
3507 % @enddots{} is an end-of-sentence ellipsis.
3508 %
3509 \def\enddots{%
3510   \dots
3511   \spacefactor=\endofsentencespacefactor
3512 }
3513
3514 % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3515 %
3516 % Since these characters are used in examples, they should be an even number of
3517 % \tt widths. Each \tt character is 1en, so two makes it 1em.
3518 %
3519 \def\point{$\star$}
3520 \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3521 \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3522 \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3523 \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3524 \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3525
3526 % The @error{} command.
3527 % Adapted from the TeXbook's \boxit.
3528 %
3529 \newbox\errorbox
3530 %
3531 {\ttfont \global\dimen0 = 3em}% Width of the box.
3532 \dimen2 = .55pt % Thickness of rules
3533 % The text. (`r' is open on the right, `e' somewhat less so on the left.)
3534 \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3535 %
3536 \setbox\errorbox=\hbox to \dimen0{\hfil
3537    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3538    \advance\hsize by -2\dimen2 % Rules.
3539    \vbox{%
3540       \hrule height\dimen2
3541       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
3542          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3543          \kern3pt\vrule width\dimen2}% Space to right.
3544       \hrule height\dimen2}
3545     \hfil}
3546 %
3547 \def\error{\leavevmode\lower.7ex\copy\errorbox}
3548
3549 % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3550 %
3551 \def\pounds{\ifmonospace{\ecfont\char"BF}\else{\it\$}\fi}
3552
3553 % @euro{} comes from a separate font, depending on the current style.
3554 % We use the free feym* fonts from the eurosym package by Henrik
3555 % Theiling, which support regular, slanted, bold and bold slanted (and
3556 % "outlined" (blackboard board, sort of) versions, which we don't need).
3557 % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3558 %
3559 % Although only regular is the truly official Euro symbol, we ignore
3560 % that.  The Euro is designed to be slightly taller than the regular
3561 % font height.
3562 %
3563 % feymr - regular
3564 % feymo - slanted
3565 % feybr - bold
3566 % feybo - bold slanted
3567 %
3568 % There is no good (free) typewriter version, to my knowledge.
3569 % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3570 % Hmm.
3571 %
3572 % Also doesn't work in math.  Do we need to do math with euro symbols?
3573 % Hope not.
3574 %
3575 %
3576 \def\euro{{\eurofont e}}
3577 \def\eurofont{%
3578   % We set the font at each command, rather than predefining it in
3579   % \textfonts and the other font-switching commands, so that
3580   % installations which never need the symbol don't have to have the
3581   % font installed.
3582   %
3583   % There is only one designed size (nominal 10pt), so we always scale
3584   % that to the current nominal size.
3585   %
3586   % By the way, simply using "at 1em" works for cmr10 and the like, but
3587   % does not work for cmbx10 and other extended/shrunken fonts.
3588   %
3589   \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3590   %
3591   \ifx\curfontstyle\bfstylename
3592     % bold:
3593     \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3594   \else
3595     % regular:
3596     \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3597   \fi
3598   \thiseurofont
3599 }
3600
3601 % Glyphs from the EC fonts.  We don't use \let for the aliases, because
3602 % sometimes we redefine the original macro, and the alias should reflect
3603 % the redefinition.
3604 %
3605 % Use LaTeX names for the Icelandic letters.
3606 \def\DH{{\ecfont \char"D0}} % Eth
3607 \def\dh{{\ecfont \char"F0}} % eth
3608 \def\TH{{\ecfont \char"DE}} % Thorn
3609 \def\th{{\ecfont \char"FE}} % thorn
3610 %
3611 \def\guillemetleft{{\ecfont \char"13}}
3612 \def\guillemotleft{\guillemetleft}
3613 \def\guillemetright{{\ecfont \char"14}}
3614 \def\guillemotright{\guillemetright}
3615 \def\guilsinglleft{{\ecfont \char"0E}}
3616 \def\guilsinglright{{\ecfont \char"0F}}
3617 \def\quotedblbase{{\ecfont \char"12}}
3618 \def\quotesinglbase{{\ecfont \char"0D}}
3619 %
3620 \def\L{{\ecfont \char"8A}} % L with stroke
3621 \def\l{{\ecfont \char"AA}} % l with stroke
3622 %
3623 % This positioning is not perfect (see the ogonek LaTeX package), but
3624 % we have the precomposed glyphs for the most common cases.  We put the
3625 % tests to use those glyphs in the single \ogonek macro so we have fewer
3626 % dummy definitions to worry about for index entries, etc.
3627 %
3628 % ogonek is also used with other letters in Lithuanian (IOU), but using
3629 % the precomposed glyphs for those is not so easy since they aren't in
3630 % the same EC font.
3631 \def\ogonek#1{{%
3632   \def\temp{#1}%
3633   \ifx\temp\macrocharA\Aogonek
3634   \else\ifx\temp\macrochara\aogonek
3635   \else\ifx\temp\macrocharE\Eogonek
3636   \else\ifx\temp\macrochare\eogonek
3637   \else
3638     \ecfont \setbox0=\hbox{#1}%
3639     \ifdim\ht0=1ex\accent"0C #1%
3640     \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3641     \fi
3642   \fi\fi\fi\fi
3643   }%
3644 }
3645 \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3646 \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3647 \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3648 \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3649 %
3650 % Use the European Computer Modern fonts (cm-super in outline format)
3651 % for non-CM glyphs.  That is ec* for regular text and tc* for the text
3652 % companion symbols (LaTeX TS1 encoding).  Both are part of the ec
3653 % package and follow the same conventions.
3654 %
3655 \def\ecfont{\etcfont{e}}
3656 \def\tcfont{\etcfont{t}}
3657 %
3658 \def\etcfont#1{%
3659   % We can't distinguish serif/sans and italic/slanted, but this
3660   % is used for crude hacks anyway (like adding French and German
3661   % quotes to documents typeset with CM, where we lose kerning), so
3662   % hopefully nobody will notice/care.
3663   \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3664   \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
3665   \ifmonospace
3666     % typewriter:
3667     \font\thisecfont = #1ctt\ecsize \space at \nominalsize
3668   \else
3669     \ifx\curfontstyle\bfstylename
3670       % bold:
3671       \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
3672     \else
3673       % regular:
3674       \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
3675     \fi
3676   \fi
3677   \thisecfont
3678 }
3679
3680 % @registeredsymbol - R in a circle.  The font for the R should really
3681 % be smaller yet, but lllsize is the best we can do for now.
3682 % Adapted from the plain.tex definition of \copyright.
3683 %
3684 \def\registeredsymbol{%
3685   $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}%
3686                \hfil\crcr\Orb}}%
3687     }$%
3688 }
3689
3690 % @textdegree - the normal degrees sign.
3691 %
3692 \def\textdegree{$^\circ$}
3693
3694 % Laurent Siebenmann reports \Orb undefined with:
3695 %  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
3696 % so we'll define it if necessary.
3697 %
3698 \ifx\Orb\thisisundefined
3699 \def\Orb{\mathhexbox20D}
3700 \fi
3701
3702 % Quotes.
3703 \chardef\quoteleft=`\`
3704 \chardef\quoteright=`\'
3705
3706 % only change font for tt for correct kerning and to avoid using
3707 % \ecfont unless necessary.
3708 \def\quotedblleft{%
3709   \ifmonospace{\ecfont\char"10}\else{\char"5C}\fi
3710 }
3711
3712 \def\quotedblright{%
3713   \ifmonospace{\ecfont\char"11}\else{\char`\"}\fi
3714 }
3715
3716
3717 \message{page headings,}
3718
3719 \newskip\titlepagetopglue \titlepagetopglue = 1.5in
3720 \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3721
3722 % First the title page.  Must do @settitle before @titlepage.
3723 \newif\ifseenauthor
3724 \newif\iffinishedtitlepage
3725
3726 % @setcontentsaftertitlepage used to do an implicit @contents or
3727 % @shortcontents after @end titlepage, but it is now obsolete.
3728 \def\setcontentsaftertitlepage{%
3729   \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
3730               command; move your @contents command if you want the contents
3731               after the title page.}}%
3732 \def\setshortcontentsaftertitlepage{%
3733   \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
3734               command; move your @shortcontents and @contents commands if you
3735               want the contents after the title page.}}%
3736
3737 \parseargdef\shorttitlepage{%
3738   \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3739   \endgroup\page\hbox{}\page}
3740
3741 \envdef\titlepage{%
3742   % Open one extra group, as we want to close it in the middle of \Etitlepage.
3743   \begingroup
3744     \parindent=0pt \textfonts
3745     % Leave some space at the very top of the page.
3746     \vglue\titlepagetopglue
3747     % No rule at page bottom unless we print one at the top with @title.
3748     \finishedtitlepagetrue
3749     %
3750     % Most title ``pages'' are actually two pages long, with space
3751     % at the top of the second.  We don't want the ragged left on the second.
3752     \let\oldpage = \page
3753     \def\page{%
3754       \iffinishedtitlepage\else
3755          \finishtitlepage
3756       \fi
3757       \let\page = \oldpage
3758       \page
3759       \null
3760     }%
3761 }
3762
3763 \def\Etitlepage{%
3764     \iffinishedtitlepage\else
3765         \finishtitlepage
3766     \fi
3767     % It is important to do the page break before ending the group,
3768     % because the headline and footline are only empty inside the group.
3769     % If we use the new definition of \page, we always get a blank page
3770     % after the title page, which we certainly don't want.
3771     \oldpage
3772   \endgroup
3773   %
3774   % Need this before the \...aftertitlepage checks so that if they are
3775   % in effect the toc pages will come out with page numbers.
3776   \HEADINGSon
3777 }
3778
3779 \def\finishtitlepage{%
3780   \vskip4pt \hrule height 2pt width \hsize
3781   \vskip\titlepagebottomglue
3782   \finishedtitlepagetrue
3783 }
3784
3785 % Settings used for typesetting titles: no hyphenation, no indentation,
3786 % don't worry much about spacing, ragged right.  This should be used
3787 % inside a \vbox, and fonts need to be set appropriately first. \par should
3788 % be specified before the end of the \vbox, since a vbox is a group.
3789 %
3790 \def\raggedtitlesettings{%
3791   \rm
3792   \hyphenpenalty=10000
3793   \parindent=0pt
3794   \tolerance=5000
3795   \ptexraggedright
3796 }
3797
3798 % Macros to be used within @titlepage:
3799
3800 \let\subtitlerm=\rmfont
3801 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3802
3803 \parseargdef\title{%
3804   \checkenv\titlepage
3805   \vbox{\titlefonts \raggedtitlesettings #1\par}%
3806   % print a rule at the page bottom also.
3807   \finishedtitlepagefalse
3808   \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3809 }
3810
3811 \parseargdef\subtitle{%
3812   \checkenv\titlepage
3813   {\subtitlefont \rightline{#1}}%
3814 }
3815
3816 % @author should come last, but may come many times.
3817 % It can also be used inside @quotation.
3818 %
3819 \parseargdef\author{%
3820   \def\temp{\quotation}%
3821   \ifx\thisenv\temp
3822     \def\quotationauthor{#1}% printed in \Equotation.
3823   \else
3824     \checkenv\titlepage
3825     \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3826     {\secfonts\rm \leftline{#1}}%
3827   \fi
3828 }
3829
3830
3831 % Set up page headings and footings.
3832
3833 \let\thispage=\folio
3834
3835 \newtoks\evenheadline    % headline on even pages
3836 \newtoks\oddheadline     % headline on odd pages
3837 \newtoks\evenchapheadline% headline on even pages with a new chapter
3838 \newtoks\oddchapheadline % headline on odd pages with a new chapter
3839 \newtoks\evenfootline    % footline on even pages
3840 \newtoks\oddfootline     % footline on odd pages
3841
3842 % Now make \makeheadline and \makefootline in Plain TeX use those variables
3843 \headline={{\textfonts\rm
3844             \ifchapterpage
3845               \ifodd\pageno\the\oddchapheadline\else\the\evenchapheadline\fi
3846             \else
3847               \ifodd\pageno\the\oddheadline\else\the\evenheadline\fi
3848             \fi}}
3849
3850 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
3851                             \else \the\evenfootline \fi}\HEADINGShook}
3852 \let\HEADINGShook=\relax
3853
3854 % Commands to set those variables.
3855 % For example, this is what  @headings on  does
3856 % @evenheading @thistitle|@thispage|@thischapter
3857 % @oddheading @thischapter|@thispage|@thistitle
3858 % @evenfooting @thisfile||
3859 % @oddfooting ||@thisfile
3860
3861
3862 \def\evenheading{\parsearg\evenheadingxxx}
3863 \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3864 \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
3865   \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
3866   \global\evenchapheadline=\evenheadline}
3867
3868 \def\oddheading{\parsearg\oddheadingxxx}
3869 \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3870 \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
3871   \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3872   \global\oddchapheadline=\oddheadline}
3873
3874 \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3875
3876 \def\evenfooting{\parsearg\evenfootingxxx}
3877 \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3878 \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3879 \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3880
3881 \def\oddfooting{\parsearg\oddfootingxxx}
3882 \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3883 \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3884   \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3885   %
3886   % Leave some space for the footline.  Hopefully ok to assume
3887   % @evenfooting will not be used by itself.
3888   \global\advance\txipageheight by -12pt
3889   \global\advance\vsize by -12pt
3890 }
3891
3892 \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3893
3894 % @evenheadingmarks top     \thischapter <- chapter at the top of a page
3895 % @evenheadingmarks bottom  \thischapter <- chapter at the bottom of a page
3896 %
3897 % The same set of arguments for:
3898 %
3899 % @oddheadingmarks
3900 % @evenfootingmarks
3901 % @oddfootingmarks
3902 % @everyheadingmarks
3903 % @everyfootingmarks
3904
3905 % These define \getoddheadingmarks, \getevenheadingmarks,
3906 % \getoddfootingmarks, and \getevenfootingmarks, each to one of
3907 % \gettopheadingmarks, \getbottomheadingmarks.
3908 %
3909 \def\evenheadingmarks{\headingmarks{even}{heading}}
3910 \def\oddheadingmarks{\headingmarks{odd}{heading}}
3911 \def\evenfootingmarks{\headingmarks{even}{footing}}
3912 \def\oddfootingmarks{\headingmarks{odd}{footing}}
3913 \parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
3914                           \headingmarks{odd}{heading}{#1} }
3915 \parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
3916                           \headingmarks{odd}{footing}{#1} }
3917 % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3918 \def\headingmarks#1#2#3 {%
3919   \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3920   \global\expandafter\let\csname get#1#2marks\endcsname \temp
3921 }
3922
3923 \everyheadingmarks bottom
3924 \everyfootingmarks bottom
3925
3926 % @headings double      turns headings on for double-sided printing.
3927 % @headings single      turns headings on for single-sided printing.
3928 % @headings off         turns them off.
3929 % @headings on          same as @headings double, retained for compatibility.
3930 % @headings after       turns on double-sided headings after this page.
3931 % @headings doubleafter turns on double-sided headings after this page.
3932 % @headings singleafter turns on single-sided headings after this page.
3933 % By default, they are off at the start of a document,
3934 % and turned `on' after @end titlepage.
3935
3936 \parseargdef\headings{\csname HEADINGS#1\endcsname}
3937
3938 \def\headingsoff{% non-global headings elimination
3939   \evenheadline={\hfil}\evenfootline={\hfil}\evenchapheadline={\hfil}%
3940    \oddheadline={\hfil}\oddfootline={\hfil}\oddchapheadline={\hfil}%
3941 }
3942
3943 \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3944 \HEADINGSoff  % it's the default
3945
3946 % When we turn headings on, set the page number to 1.
3947 \def\pageone{
3948   \global\pageno=1
3949   \global\arabiccount = \pagecount
3950 }
3951
3952 % For double-sided printing, put current file name in lower left corner,
3953 % chapter name on inside top of right hand pages, document
3954 % title on inside top of left hand pages, and page numbers on outside top
3955 % edge of all pages.
3956 \def\HEADINGSdouble{%
3957 \pageone
3958 \HEADINGSdoublex
3959 }
3960 \let\contentsalignmacro = \chappager
3961
3962 % For single-sided printing, chapter title goes across top left of page,
3963 % page number on top right.
3964 \def\HEADINGSsingle{%
3965 \pageone
3966 \HEADINGSsinglex
3967 }
3968 \def\HEADINGSon{\HEADINGSdouble}
3969
3970 \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
3971 \let\HEADINGSdoubleafter=\HEADINGSafter
3972 \def\HEADINGSdoublex{%
3973 \global\evenfootline={\hfil}
3974 \global\oddfootline={\hfil}
3975 \global\evenheadline={\line{\folio\hfil\thistitle}}
3976 \global\oddheadline={\line{\thischapter\hfil\folio}}
3977 \global\evenchapheadline={\line{\folio\hfil\thistitle}}
3978 \global\oddchapheadline={\line{\hfil\folio}}
3979 \global\let\contentsalignmacro = \chapoddpage
3980 }
3981
3982 \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
3983 \def\HEADINGSsinglex{%
3984 \global\evenfootline={\hfil}
3985 \global\oddfootline={\hfil}
3986 \global\evenheadline={\line{\thischapter\hfil\folio}}
3987 \global\oddheadline={\line{\thischapter\hfil\folio}}
3988 \global\evenchapheadline={\line{\hfil\folio}}
3989 \global\oddchapheadline={\line{\hfil\folio}}
3990 \global\let\contentsalignmacro = \chappager
3991 }
3992
3993 % for @setchapternewpage off
3994 \def\HEADINGSsinglechapoff{%
3995 \pageone
3996 \global\evenfootline={\hfil}
3997 \global\oddfootline={\hfil}
3998 \global\evenheadline={\line{\thischapter\hfil\folio}}
3999 \global\oddheadline={\line{\thischapter\hfil\folio}}
4000 \global\evenchapheadline=\evenheadline
4001 \global\oddchapheadline=\oddheadline
4002 \global\let\contentsalignmacro = \chappager
4003 }
4004
4005 % Subroutines used in generating headings
4006 % This produces Day Month Year style of output.
4007 % Only define if not already defined, in case a txi-??.tex file has set
4008 % up a different format (e.g., txi-cs.tex does this).
4009 \ifx\today\thisisundefined
4010 \def\today{%
4011   \number\day\space
4012   \ifcase\month
4013   \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
4014   \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
4015   \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
4016   \fi
4017   \space\number\year}
4018 \fi
4019
4020 % @settitle line...  specifies the title of the document, for headings.
4021 % It generates no output of its own.
4022 \def\thistitle{\putwordNoTitle}
4023 \def\settitle{\parsearg{\gdef\thistitle}}
4024
4025
4026 \message{tables,}
4027 % Tables -- @table, @ftable, @vtable, @item(x).
4028
4029 % default indentation of table text
4030 \newdimen\tableindent \tableindent=.8in
4031 % default indentation of @itemize and @enumerate text
4032 \newdimen\itemindent  \itemindent=.3in
4033 % margin between end of table item and start of table text.
4034 \newdimen\itemmargin  \itemmargin=.1in
4035
4036 % used internally for \itemindent minus \itemmargin
4037 \newdimen\itemmax
4038
4039 % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
4040 % these defs.
4041 % They also define \itemindex
4042 % to index the item name in whatever manner is desired (perhaps none).
4043
4044 \newif\ifitemxneedsnegativevskip
4045
4046 \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
4047
4048 \def\internalBitem{\smallbreak \parsearg\itemzzz}
4049 \def\internalBitemx{\itemxpar \parsearg\itemzzz}
4050
4051 \def\itemzzz #1{\begingroup %
4052   \advance\hsize by -\rightskip
4053   \advance\hsize by -\tableindent
4054   \setbox0=\hbox{\itemindicate{#1}}%
4055   \itemindex{#1}%
4056   \nobreak % This prevents a break before @itemx.
4057   %
4058   % If the item text does not fit in the space we have, put it on a line
4059   % by itself, and do not allow a page break either before or after that
4060   % line.  We do not start a paragraph here because then if the next
4061   % command is, e.g., @kindex, the whatsit would get put into the
4062   % horizontal list on a line by itself, resulting in extra blank space.
4063   \ifdim \wd0>\itemmax
4064     %
4065     % Make this a paragraph so we get the \parskip glue and wrapping,
4066     % but leave it ragged-right.
4067     \begingroup
4068       \advance\leftskip by-\tableindent
4069       \advance\hsize by\tableindent
4070       \advance\rightskip by0pt plus1fil\relax
4071       \leavevmode\unhbox0\par
4072     \endgroup
4073     %
4074     % We're going to be starting a paragraph, but we don't want the
4075     % \parskip glue -- logically it's part of the @item we just started.
4076     \nobreak \vskip-\parskip
4077     %
4078     % Stop a page break at the \parskip glue coming up.  However, if
4079     % what follows is an environment such as @example, there will be no
4080     % \parskip glue; then the negative vskip we just inserted would
4081     % cause the example and the item to crash together.  So we use this
4082     % bizarre value of 10001 as a signal to \aboveenvbreak to insert
4083     % \parskip glue after all.  Section titles are handled this way also.
4084     %
4085     \penalty 10001
4086     \endgroup
4087     \itemxneedsnegativevskipfalse
4088   \else
4089     % The item text fits into the space.  Start a paragraph, so that the
4090     % following text (if any) will end up on the same line.
4091     \noindent
4092     % Do this with kerns and \unhbox so that if there is a footnote in
4093     % the item text, it can migrate to the main vertical list and
4094     % eventually be printed.
4095     \nobreak\kern-\tableindent
4096     \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
4097     \unhbox0
4098     \nobreak\kern\dimen0
4099     \endgroup
4100     \itemxneedsnegativevskiptrue
4101   \fi
4102 }
4103
4104 \def\item{\errmessage{@item while not in a list environment}}
4105 \def\itemx{\errmessage{@itemx while not in a list environment}}
4106
4107 % @table, @ftable, @vtable.
4108 \envdef\table{%
4109   \let\itemindex\gobble
4110   \tablecheck{table}%
4111 }
4112 \envdef\ftable{%
4113   \def\itemindex ##1{\doind {fn}{\code{##1}}}%
4114   \tablecheck{ftable}%
4115 }
4116 \envdef\vtable{%
4117   \def\itemindex ##1{\doind {vr}{\code{##1}}}%
4118   \tablecheck{vtable}%
4119 }
4120 \def\tablecheck#1{%
4121   \ifnum \the\catcode`\^^M=\active
4122     \endgroup
4123     \errmessage{This command won't work in this context; perhaps the problem is
4124       that we are \inenvironment\thisenv}%
4125     \def\next{\doignore{#1}}%
4126   \else
4127     \let\next\tablex
4128   \fi
4129   \next
4130 }
4131 \def\tablex#1{%
4132   \def\itemindicate{#1}%
4133   \parsearg\tabley
4134 }
4135 \def\tabley#1{%
4136   {%
4137     \makevalueexpandable
4138     \edef\temp{\noexpand\tablez #1\space\space\space}%
4139     \expandafter
4140   }\temp \endtablez
4141 }
4142 \def\tablez #1 #2 #3 #4\endtablez{%
4143   \aboveenvbreak
4144   \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
4145   \ifnum 0#2>0 \tableindent=#2\mil \fi
4146   \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
4147   \itemmax=\tableindent
4148   \advance \itemmax by -\itemmargin
4149   \advance \leftskip by \tableindent
4150   \exdentamount=\tableindent
4151   \parindent = 0pt
4152   \parskip = \smallskipamount
4153   \ifdim \parskip=0pt \parskip=2pt \fi
4154   \let\item = \internalBitem
4155   \let\itemx = \internalBitemx
4156 }
4157 \def\Etable{\endgraf\afterenvbreak}
4158 \let\Eftable\Etable
4159 \let\Evtable\Etable
4160 \let\Eitemize\Etable
4161 \let\Eenumerate\Etable
4162
4163 % This is the counter used by @enumerate, which is really @itemize
4164
4165 \newcount \itemno
4166
4167 \envdef\itemize{\parsearg\doitemize}
4168
4169 \def\doitemize#1{%
4170   \aboveenvbreak
4171   \itemmax=\itemindent
4172   \advance\itemmax by -\itemmargin
4173   \advance\leftskip by \itemindent
4174   \exdentamount=\itemindent
4175   \parindent=0pt
4176   \parskip=\smallskipamount
4177   \ifdim\parskip=0pt \parskip=2pt \fi
4178   %
4179   % Try typesetting the item mark so that if the document erroneously says
4180   % something like @itemize @samp (intending @table), there's an error
4181   % right away at the @itemize.  It's not the best error message in the
4182   % world, but it's better than leaving it to the @item.  This means if
4183   % the user wants an empty mark, they have to say @w{} not just @w.
4184   \def\itemcontents{#1}%
4185   \setbox0 = \hbox{\itemcontents}%
4186   %
4187   % @itemize with no arg is equivalent to @itemize @bullet.
4188   \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
4189   %
4190   \let\item=\itemizeitem
4191 }
4192
4193 % Definition of @item while inside @itemize and @enumerate.
4194 %
4195 \def\itemizeitem{%
4196   \advance\itemno by 1  % for enumerations
4197   {\let\par=\endgraf \smallbreak}% reasonable place to break
4198   {%
4199    % If the document has an @itemize directly after a section title, a
4200    % \nobreak will be last on the list, and \sectionheading will have
4201    % done a \vskip-\parskip.  In that case, we don't want to zero
4202    % parskip, or the item text will crash with the heading.  On the
4203    % other hand, when there is normal text preceding the item (as there
4204    % usually is), we do want to zero parskip, or there would be too much
4205    % space.  In that case, we won't have a \nobreak before.  At least
4206    % that's the theory.
4207    \ifnum\lastpenalty<10000 \parskip=0in \fi
4208    \noindent
4209    \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
4210    %
4211    \ifinner\else
4212      \vadjust{\penalty 1200}% not good to break after first line of item.
4213    \fi
4214    % We can be in inner vertical mode in a footnote, although an
4215    % @itemize looks awful there.
4216   }%
4217   \flushcr
4218 }
4219
4220 % \splitoff TOKENS\endmark defines \first to be the first token in
4221 % TOKENS, and \rest to be the remainder.
4222 %
4223 \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
4224
4225 % Allow an optional argument of an uppercase letter, lowercase letter,
4226 % or number, to specify the first label in the enumerated list.  No
4227 % argument is the same as `1'.
4228 %
4229 \envparseargdef\enumerate{\enumeratey #1  \endenumeratey}
4230 \def\enumeratey #1 #2\endenumeratey{%
4231   % If we were given no argument, pretend we were given `1'.
4232   \def\thearg{#1}%
4233   \ifx\thearg\empty \def\thearg{1}\fi
4234   %
4235   % Detect if the argument is a single token.  If so, it might be a
4236   % letter.  Otherwise, the only valid thing it can be is a number.
4237   % (We will always have one token, because of the test we just made.
4238   % This is a good thing, since \splitoff doesn't work given nothing at
4239   % all -- the first parameter is undelimited.)
4240   \expandafter\splitoff\thearg\endmark
4241   \ifx\rest\empty
4242     % Only one token in the argument.  It could still be anything.
4243     % A ``lowercase letter'' is one whose \lccode is nonzero.
4244     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
4245     %   not equal to itself.
4246     % Otherwise, we assume it's a number.
4247     %
4248     % We need the \relax at the end of the \ifnum lines to stop TeX from
4249     % continuing to look for a <number>.
4250     %
4251     \ifnum\lccode\expandafter`\thearg=0\relax
4252       \numericenumerate % a number (we hope)
4253     \else
4254       % It's a letter.
4255       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
4256         \lowercaseenumerate % lowercase letter
4257       \else
4258         \uppercaseenumerate % uppercase letter
4259       \fi
4260     \fi
4261   \else
4262     % Multiple tokens in the argument.  We hope it's a number.
4263     \numericenumerate
4264   \fi
4265 }
4266
4267 % An @enumerate whose labels are integers.  The starting integer is
4268 % given in \thearg.
4269 %
4270 \def\numericenumerate{%
4271   \itemno = \thearg
4272   \startenumeration{\the\itemno}%
4273 }
4274
4275 % The starting (lowercase) letter is in \thearg.
4276 \def\lowercaseenumerate{%
4277   \itemno = \expandafter`\thearg
4278   \startenumeration{%
4279     % Be sure we're not beyond the end of the alphabet.
4280     \ifnum\itemno=0
4281       \errmessage{No more lowercase letters in @enumerate; get a bigger
4282                   alphabet}%
4283     \fi
4284     \char\lccode\itemno
4285   }%
4286 }
4287
4288 % The starting (uppercase) letter is in \thearg.
4289 \def\uppercaseenumerate{%
4290   \itemno = \expandafter`\thearg
4291   \startenumeration{%
4292     % Be sure we're not beyond the end of the alphabet.
4293     \ifnum\itemno=0
4294       \errmessage{No more uppercase letters in @enumerate; get a bigger
4295                   alphabet}
4296     \fi
4297     \char\uccode\itemno
4298   }%
4299 }
4300
4301 % Call \doitemize, adding a period to the first argument and supplying the
4302 % common last two arguments.  Also subtract one from the initial value in
4303 % \itemno, since @item increments \itemno.
4304 %
4305 \def\startenumeration#1{%
4306   \advance\itemno by -1
4307   \doitemize{#1.}\flushcr
4308 }
4309
4310
4311 % @multitable macros
4312
4313 % Macros used to set up halign preamble:
4314 %
4315 \let\endsetuptable\relax
4316 \def\xendsetuptable{\endsetuptable}
4317 \let\columnfractions\relax
4318 \def\xcolumnfractions{\columnfractions}
4319 \newif\ifsetpercent
4320
4321 % #1 is the @columnfraction, usually a decimal number like .5, but might
4322 % be just 1.  We just use it, whatever it is.
4323 %
4324 \def\pickupwholefraction#1 {%
4325   \global\advance\colcount by 1
4326   \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
4327   \setuptable
4328 }
4329
4330 \newcount\colcount
4331 \def\setuptable#1{%
4332   \def\firstarg{#1}%
4333   \ifx\firstarg\xendsetuptable
4334     \let\go = \relax
4335   \else
4336     \ifx\firstarg\xcolumnfractions
4337       \global\setpercenttrue
4338     \else
4339       \ifsetpercent
4340          \let\go\pickupwholefraction
4341       \else
4342          \global\advance\colcount by 1
4343          \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
4344                    % separator; typically that is always in the input, anyway.
4345          \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
4346       \fi
4347     \fi
4348     \ifx\go\pickupwholefraction
4349       % Put the argument back for the \pickupwholefraction call, so
4350       % we'll always have a period there to be parsed.
4351       \def\go{\pickupwholefraction#1}%
4352     \else
4353       \let\go = \setuptable
4354     \fi%
4355   \fi
4356   \go
4357 }
4358
4359 % @headitem starts a heading row, which we typeset in bold.  Assignments
4360 % have to be global since we are inside the implicit group of an
4361 % alignment entry.  \everycr below resets \everytab so we don't have to
4362 % undo it ourselves.
4363 \def\headitemfont{\b}% for people to use in the template row; not changeable
4364 \def\headitem{%
4365   \crcr % must appear first
4366   \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
4367   \global\everytab={\bf}% can't use \headitemfont since the parsing differs
4368   \the\everytab % for the first item
4369 }%
4370 %
4371 % default for tables with no headings.
4372 \let\headitemcrhook=\relax
4373 %
4374 \def\tab{\checkenv\multitable &\the\everytab}%
4375
4376 \newtoks\everytab  % insert after every tab.
4377 %
4378 \envdef\multitable{%
4379   \vskip\parskip
4380   \startsavinginserts
4381   %
4382   % @item within a multitable starts a normal row.
4383   % We use \def instead of \let so that if one of the multitable entries
4384   % contains an @itemize, we don't choke on the \item (seen as \crcr aka
4385   % \endtemplate) expanding \doitemize.
4386   \def\item{\crcr}%
4387   %
4388   \tolerance=9500
4389   \hbadness=9500
4390   \parskip=0pt
4391   \parindent=6pt
4392   \overfullrule=0pt
4393   \global\colcount=0
4394   %
4395   \everycr = {%
4396     \noalign{%
4397       \global\everytab={}% Reset from possible headitem.
4398       \global\colcount=0 % Reset the column counter.
4399       %
4400       % Check for saved footnotes, etc.:
4401       \checkinserts
4402       %
4403       % Perhaps a \nobreak, then reset:
4404       \headitemcrhook
4405       \global\let\headitemcrhook=\relax
4406     }%
4407   }%
4408   %
4409   \parsearg\domultitable
4410 }
4411 \def\domultitable#1{%
4412   % To parse everything between @multitable and @item:
4413   \setuptable#1 \endsetuptable
4414   %
4415   % This preamble sets up a generic column definition, which will
4416   % be used as many times as user calls for columns.
4417   % \vtop will set a single line and will also let text wrap and
4418   % continue for many paragraphs if desired.
4419   \halign\bgroup &%
4420     \global\advance\colcount by 1
4421     \strut
4422     \vtop{%
4423       \advance\hsize by -1\leftskip
4424       % Find the correct column width
4425       \hsize=\expandafter\csname col\the\colcount\endcsname
4426       %
4427       \advance\rightskip by -1\rightskip % Zero leaving only any stretch
4428       \ifnum\colcount=1
4429         \advance\hsize by\leftskip % Add indent of surrounding text
4430       \else
4431         % In order to keep entries from bumping into each other.
4432         \leftskip=12pt
4433         \ifsetpercent \else
4434           % If a template has been used
4435           \advance\hsize by \leftskip
4436         \fi
4437       \fi
4438       \noindent\ignorespaces##\unskip\strut
4439     }\cr
4440 }
4441 \def\Emultitable{%
4442   \crcr
4443   \egroup % end the \halign
4444   \global\setpercentfalse
4445 }
4446
4447
4448 \message{conditionals,}
4449
4450 % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotlatex, @ifnotplaintext,
4451 % @ifnotxml always succeed.  They currently do nothing; we don't
4452 % attempt to check whether the conditionals are properly nested.  But we
4453 % have to remember that they are conditionals, so that @end doesn't
4454 % attempt to close an environment group.
4455 %
4456 \def\makecond#1{%
4457   \expandafter\let\csname #1\endcsname = \relax
4458   \expandafter\let\csname iscond.#1\endcsname = 1
4459 }
4460 \makecond{iftex}
4461 \makecond{ifnotdocbook}
4462 \makecond{ifnothtml}
4463 \makecond{ifnotinfo}
4464 \makecond{ifnotlatex}
4465 \makecond{ifnotplaintext}
4466 \makecond{ifnotxml}
4467
4468 % Ignore @ignore, @ifhtml, @ifinfo, and the like.
4469 %
4470 \def\direntry{\doignore{direntry}}
4471 \def\documentdescription{\doignore{documentdescription}}
4472 \def\docbook{\doignore{docbook}}
4473 \def\html{\doignore{html}}
4474 \def\ifdocbook{\doignore{ifdocbook}}
4475 \def\ifhtml{\doignore{ifhtml}}
4476 \def\ifinfo{\doignore{ifinfo}}
4477 \def\iflatex{\doignore{iflatex}}
4478 \def\ifnottex{\doignore{ifnottex}}
4479 \def\ifplaintext{\doignore{ifplaintext}}
4480 \def\ifxml{\doignore{ifxml}}
4481 \def\ignore{\doignore{ignore}}
4482 \def\latex{\doignore{latex}}
4483 \def\menu{\doignore{menu}}
4484 \def\xml{\doignore{xml}}
4485
4486 % Ignore text until a line `@end #1', keeping track of nested conditionals.
4487 %
4488 % A count to remember the depth of nesting.
4489 \newcount\doignorecount
4490
4491 \def\doignore#1{\begingroup
4492   % Scan in ``verbatim'' mode:
4493   \obeylines
4494   \catcode`\@ = \other
4495   \catcode`\{ = \other
4496   \catcode`\} = \other
4497   %
4498   % Make sure that spaces turn into tokens that match what \doignoretext wants.
4499   \spaceisspace
4500   %
4501   % Count number of #1's that we've seen.
4502   \doignorecount = 0
4503   %
4504   % Swallow text until we reach the matching `@end #1'.
4505   \dodoignore{#1}%
4506 }
4507
4508 { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4509   \obeylines %
4510   %
4511   \gdef\dodoignore#1{%
4512     % #1 contains the command name as a string, e.g., `ifinfo'.
4513     %
4514     % Define a command to find the next `@end #1'.
4515     \long\def\doignoretext##1^^M@end #1{%
4516       \doignoretextyyy##1^^M@#1\_STOP_}%
4517     %
4518     % And this command to find another #1 command, at the beginning of a
4519     % line.  (Otherwise, we would consider a line `@c @ifset', for
4520     % example, to count as an @ifset for nesting.)
4521     \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
4522     %
4523     % And now expand that command.
4524     \doignoretext ^^M%
4525   }%
4526 }
4527
4528 \def\doignoreyyy#1{%
4529   \def\temp{#1}%
4530   \ifx\temp\empty                       % Nothing found.
4531     \let\next\doignoretextzzz
4532   \else                                 % Found a nested condition, ...
4533     \advance\doignorecount by 1
4534     \let\next\doignoretextyyy           % ..., look for another.
4535     % If we're here, #1 ends with ^^M\ifinfo (for example).
4536   \fi
4537   \next #1% the token \_STOP_ is present just after this macro.
4538 }
4539
4540 % We have to swallow the remaining "\_STOP_".
4541 %
4542 \def\doignoretextzzz#1{%
4543   \ifnum\doignorecount = 0      % We have just found the outermost @end.
4544     \let\next\enddoignore
4545   \else                         % Still inside a nested condition.
4546     \advance\doignorecount by -1
4547     \let\next\doignoretext      % Look for the next @end.
4548   \fi
4549   \next
4550 }
4551
4552 % Finish off ignored text.
4553 { \obeylines%
4554   % Ignore anything after the last `@end #1'; this matters in verbatim
4555   % environments, where otherwise the newline after an ignored conditional
4556   % would result in a blank line in the output.
4557   \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4558 }
4559
4560
4561 % @set VAR sets the variable VAR to an empty value.
4562 % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4563 %
4564 % Since we want to separate VAR from REST-OF-LINE (which might be
4565 % empty), we can't just use \parsearg; we have to insert a space of our
4566 % own to delimit the rest of the line, and then take it out again if we
4567 % didn't need it.
4568 % We rely on the fact that \parsearg sets \catcode`\ =10.
4569 %
4570 \parseargdef\set{\setyyy#1 \endsetyyy}
4571 \def\setyyy#1 #2\endsetyyy{%
4572   {%
4573     \makevalueexpandable
4574     \def\temp{#2}%
4575     \edef\next{\gdef\makecsname{SET#1}}%
4576     \ifx\temp\empty
4577       \next{}%
4578     \else
4579       \setzzz#2\endsetzzz
4580     \fi
4581   }%
4582 }
4583 % Remove the trailing space \setxxx inserted.
4584 \def\setzzz#1 \endsetzzz{\next{#1}}
4585
4586 % @clear VAR clears (i.e., unsets) the variable VAR.
4587 %
4588 \parseargdef\clear{%
4589   {%
4590     \makevalueexpandable
4591     \global\expandafter\let\csname SET#1\endcsname=\relax
4592   }%
4593 }
4594
4595 % @value{foo} gets the text saved in variable foo.
4596 \def\value{\begingroup\makevalueexpandable\valuexxx}
4597 \def\valuexxx#1{\expandablevalue{#1}\endgroup}
4598 {
4599   \catcode`\-=\active \catcode`\_=\active
4600   %
4601   \gdef\makevalueexpandable{%
4602     \let\value = \expandablevalue
4603     % We don't want these characters active, ...
4604     \catcode`\-=\other \catcode`\_=\other
4605     % ..., but we might end up with active ones in the argument if
4606     % we're called from @code, as @code{@value{foo-bar_}}, though.
4607     % So \let them to their normal equivalents.
4608     \let-\normaldash \let_\normalunderscore
4609   }
4610 }
4611
4612 \def\expandablevalue#1{%
4613   \expandafter\ifx\csname SET#1\endcsname\relax
4614     {[No value for ``#1'']}%
4615     \message{Variable `#1', used in @value, is not set.}%
4616   \else
4617     \csname SET#1\endcsname
4618   \fi
4619 }
4620
4621 % Like \expandablevalue, but completely expandable (the \message in the
4622 % definition above operates at the execution level of TeX).  Used when
4623 % writing to auxiliary files, due to the expansion that \write does.
4624 % If flag is undefined, pass through an unexpanded @value command: maybe it
4625 % will be set by the time it is read back in.
4626 %
4627 % NB flag names containing - or _ may not work here.
4628 \def\dummyvalue#1{%
4629   \expandafter\ifx\csname SET#1\endcsname\relax
4630     \string\value{#1}%
4631   \else
4632     \csname SET#1\endcsname
4633   \fi
4634 }
4635
4636 % Used for @value's in index entries to form the sort key: expand the @value
4637 % if possible, otherwise sort late.
4638 \def\indexnofontsvalue#1{%
4639   \expandafter\ifx\csname SET#1\endcsname\relax
4640     ZZZZZZZ%
4641   \else
4642     \csname SET#1\endcsname
4643   \fi
4644 }
4645
4646 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4647 % with @set.
4648 %
4649 % To get the special treatment we need for `@end ifset,' we call
4650 % \makecond and then redefine.
4651 %
4652 \makecond{ifset}
4653 \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4654 \def\doifset#1#2{%
4655   {%
4656     \makevalueexpandable
4657     \let\next=\empty
4658     \expandafter\ifx\csname SET#2\endcsname\relax
4659       #1% If not set, redefine \next.
4660     \fi
4661     \expandafter
4662   }\next
4663 }
4664 \def\ifsetfail{\doignore{ifset}}
4665
4666 % @ifclear VAR ... @end executes the `...' iff VAR has never been
4667 % defined with @set, or has been undefined with @clear.
4668 %
4669 % The `\else' inside the `\doifset' parameter is a trick to reuse the
4670 % above code: if the variable is not set, do nothing, if it is set,
4671 % then redefine \next to \ifclearfail.
4672 %
4673 \makecond{ifclear}
4674 \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4675 \def\ifclearfail{\doignore{ifclear}}
4676
4677 % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
4678 % without the @) is in fact defined.  We can only feasibly check at the
4679 % TeX level, so something like `mathcode' is going to considered
4680 % defined even though it is not a Texinfo command.
4681 %
4682 \makecond{ifcommanddefined}
4683 \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
4684 %
4685 \def\doifcmddefined#1#2{{%
4686     \makevalueexpandable
4687     \let\next=\empty
4688     \expandafter\ifx\csname #2\endcsname\relax
4689       #1% If not defined, \let\next as above.
4690     \fi
4691     \expandafter
4692   }\next
4693 }
4694 \def\ifcmddefinedfail{\doignore{ifcommanddefined}}
4695
4696 % @ifcommandnotdefined CMD ... handled similar to @ifclear above.
4697 \makecond{ifcommandnotdefined}
4698 \def\ifcommandnotdefined{%
4699   \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
4700 \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
4701
4702 % Set the `txicommandconditionals' variable, so documents have a way to
4703 % test if the @ifcommand...defined conditionals are available.
4704 \set txicommandconditionals
4705
4706 % @dircategory CATEGORY  -- specify a category of the dir file
4707 % which this file should belong to.  Ignore this in TeX.
4708 \let\dircategory=\comment
4709
4710 % @defininfoenclose.
4711 \let\definfoenclose=\comment
4712
4713
4714 \message{indexing,}
4715 % Index generation facilities
4716
4717 % Define \newwrite to be identical to plain tex's \newwrite
4718 % except not \outer, so it can be used within macros and \if's.
4719 \edef\newwrite{\makecsname{ptexnewwrite}}
4720
4721 % \newindex {foo} defines an index named IX.
4722 % It automatically defines \IXindex such that
4723 % \IXindex ...rest of line... puts an entry in the index IX.
4724 % It also defines \IXindfile to be the number of the output channel for
4725 % the file that accumulates this index.  The file's extension is IX.
4726 % The name of an index should be no more than 2 characters long
4727 % for the sake of vms.
4728 %
4729 \def\newindex#1{%
4730   \expandafter\chardef\csname#1indfile\endcsname=0
4731   \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
4732     \noexpand\doindex{#1}}
4733 }
4734
4735 % @defindex foo  ==  \newindex{foo}
4736 %
4737 \def\defindex{\parsearg\newindex}
4738
4739 % Define @defcodeindex, like @defindex except put all entries in @code.
4740 %
4741 \def\defcodeindex{\parsearg\newcodeindex}
4742 %
4743 \def\newcodeindex#1{%
4744   \expandafter\chardef\csname#1indfile\endcsname=0
4745   \expandafter\xdef\csname#1index\endcsname{%
4746     \noexpand\docodeindex{#1}}%
4747 }
4748
4749 % The default indices:
4750 \newindex{cp}%      concepts,
4751 \newcodeindex{fn}%  functions,
4752 \newcodeindex{vr}%  variables,
4753 \newcodeindex{tp}%  types,
4754 \newcodeindex{ky}%  keys
4755 \newcodeindex{pg}%  and programs.
4756
4757
4758 % @synindex foo bar    makes index foo feed into index bar.
4759 % Do this instead of @defindex foo if you don't want it as a separate index.
4760 %
4761 % @syncodeindex foo bar   similar, but put all entries made for index foo
4762 % inside @code.
4763 %
4764 \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4765 \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4766
4767 % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4768 % #3 the target index (bar).
4769 \def\dosynindex#1#2#3{%
4770   \requireopenindexfile{#3}%
4771   % redefine \fooindfile:
4772   \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4773   \expandafter\let\csname#2indfile\endcsname=\temp
4774   % redefine \fooindex:
4775   \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
4776 }
4777
4778 % Define \doindex, the driver for all index macros.
4779 % Argument #1 is generated by the calling \fooindex macro,
4780 % and it is the two-letter name of the index.
4781
4782 \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
4783 \def\doindexxxx #1{\doind{\indexname}{#1}}
4784
4785 % like the previous two, but they put @code around the argument.
4786 \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
4787 \def\docodeindexxxx #1{\docind{\indexname}{#1}}
4788
4789
4790 % Used for the aux, toc and index files to prevent expansion of Texinfo
4791 % commands.
4792 %
4793 \def\atdummies{%
4794   \definedummyletter\@%
4795   \definedummyletter\ %
4796   \definedummyletter\{%
4797   \definedummyletter\}%
4798   \definedummyletter\&%
4799   %
4800   % Do the redefinitions.
4801   \definedummies
4802   \otherbackslash
4803 }
4804
4805 % \definedummyword defines \#1 as \string\#1\space, thus effectively
4806 % preventing its expansion.  This is used only for control words,
4807 % not control letters, because the \space would be incorrect for
4808 % control characters, but is needed to separate the control word
4809 % from whatever follows.
4810 %
4811 % These can be used both for control words that take an argument and
4812 % those that do not.  If it is followed by {arg} in the input, then
4813 % that will dutifully get written to the index (or wherever).
4814 %
4815 % For control letters, we have \definedummyletter, which omits the
4816 % space.
4817 %
4818 \def\definedummyword  #1{\def#1{\string#1\space}}%
4819 \def\definedummyletter#1{\def#1{\string#1}}%
4820 \let\definedummyaccent\definedummyletter
4821
4822 % Called from \atdummies to prevent the expansion of commands.
4823 %
4824 \def\definedummies{%
4825   %
4826   \let\commondummyword\definedummyword
4827   \let\commondummyletter\definedummyletter
4828   \let\commondummyaccent\definedummyaccent
4829   \commondummiesnofonts
4830   %
4831   \definedummyletter\_%
4832   \definedummyletter\-%
4833   %
4834   % Non-English letters.
4835   \definedummyword\AA
4836   \definedummyword\AE
4837   \definedummyword\DH
4838   \definedummyword\L
4839   \definedummyword\O
4840   \definedummyword\OE
4841   \definedummyword\TH
4842   \definedummyword\aa
4843   \definedummyword\ae
4844   \definedummyword\dh
4845   \definedummyword\exclamdown
4846   \definedummyword\l
4847   \definedummyword\o
4848   \definedummyword\oe
4849   \definedummyword\ordf
4850   \definedummyword\ordm
4851   \definedummyword\questiondown
4852   \definedummyword\ss
4853   \definedummyword\th
4854   %
4855   % Although these internal commands shouldn't show up, sometimes they do.
4856   \definedummyword\bf
4857   \definedummyword\gtr
4858   \definedummyword\hat
4859   \definedummyword\less
4860   \definedummyword\sf
4861   \definedummyword\sl
4862   \definedummyword\tclose
4863   \definedummyword\tt
4864   %
4865   \definedummyword\LaTeX
4866   \definedummyword\TeX
4867   %
4868   % Assorted special characters.
4869   \definedummyword\ampchar
4870   \definedummyword\atchar
4871   \definedummyword\arrow
4872   \definedummyword\backslashchar
4873   \definedummyword\bullet
4874   \definedummyword\comma
4875   \definedummyword\copyright
4876   \definedummyword\registeredsymbol
4877   \definedummyword\dots
4878   \definedummyword\enddots
4879   \definedummyword\entrybreak
4880   \definedummyword\equiv
4881   \definedummyword\error
4882   \definedummyword\euro
4883   \definedummyword\expansion
4884   \definedummyword\geq
4885   \definedummyword\guillemetleft
4886   \definedummyword\guillemetright
4887   \definedummyword\guilsinglleft
4888   \definedummyword\guilsinglright
4889   \definedummyword\lbracechar
4890   \definedummyword\leq
4891   \definedummyword\mathopsup
4892   \definedummyword\minus
4893   \definedummyword\ogonek
4894   \definedummyword\pounds
4895   \definedummyword\point
4896   \definedummyword\print
4897   \definedummyword\quotedblbase
4898   \definedummyword\quotedblleft
4899   \definedummyword\quotedblright
4900   \definedummyword\quoteleft
4901   \definedummyword\quoteright
4902   \definedummyword\quotesinglbase
4903   \definedummyword\rbracechar
4904   \definedummyword\result
4905   \definedummyword\sub
4906   \definedummyword\sup
4907   \definedummyword\textdegree
4908   %
4909   \definedummyword\subentry
4910   %
4911   % We want to disable all macros so that they are not expanded by \write.
4912   \macrolist
4913   \let\value\dummyvalue
4914   %
4915   \normalturnoffactive
4916 }
4917
4918 % \commondummiesnofonts: common to \definedummies and \indexnofonts.
4919 % Define \commondummyletter, \commondummyaccent and \commondummyword before
4920 % using.  Used for accents, font commands, and various control letters.
4921 %
4922 \def\commondummiesnofonts{%
4923   % Control letters and accents.
4924   \commondummyletter\!%
4925   \commondummyaccent\"%
4926   \commondummyaccent\'%
4927   \commondummyletter\*%
4928   \commondummyaccent\,%
4929   \commondummyletter\.%
4930   \commondummyletter\/%
4931   \commondummyletter\:%
4932   \commondummyaccent\=%
4933   \commondummyletter\?%
4934   \commondummyaccent\^%
4935   \commondummyaccent\`%
4936   \commondummyaccent\~%
4937   \commondummyword\u
4938   \commondummyword\v
4939   \commondummyword\H
4940   \commondummyword\dotaccent
4941   \commondummyword\ogonek
4942   \commondummyword\ringaccent
4943   \commondummyword\tieaccent
4944   \commondummyword\ubaraccent
4945   \commondummyword\udotaccent
4946   \commondummyword\dotless
4947   %
4948   % Texinfo font commands.
4949   \commondummyword\b
4950   \commondummyword\i
4951   \commondummyword\r
4952   \commondummyword\sansserif
4953   \commondummyword\sc
4954   \commondummyword\slanted
4955   \commondummyword\t
4956   %
4957   % Commands that take arguments.
4958   \commondummyword\abbr
4959   \commondummyword\acronym
4960   \commondummyword\anchor
4961   \commondummyword\cite
4962   \commondummyword\code
4963   \commondummyword\command
4964   \commondummyword\dfn
4965   \commondummyword\dmn
4966   \commondummyword\email
4967   \commondummyword\emph
4968   \commondummyword\env
4969   \commondummyword\file
4970   \commondummyword\image
4971   \commondummyword\indicateurl
4972   \commondummyword\inforef
4973   \commondummyword\kbd
4974   \commondummyword\key
4975   \commondummyword\math
4976   \commondummyword\option
4977   \commondummyword\pxref
4978   \commondummyword\ref
4979   \commondummyword\samp
4980   \commondummyword\strong
4981   \commondummyword\tie
4982   \commondummyword\U
4983   \commondummyword\uref
4984   \commondummyword\url
4985   \commondummyword\var
4986   \commondummyword\verb
4987   \commondummyword\w
4988   \commondummyword\xref
4989 }
4990
4991 \let\indexlbrace\relax
4992 \let\indexrbrace\relax
4993 \let\indexatchar\relax
4994 \let\indexbackslash\relax
4995
4996 {\catcode`\@=0
4997 \catcode`\\=13
4998   @gdef@backslashdisappear{@def\{}}
4999 }
5000
5001 {
5002 \catcode`\<=13
5003 \catcode`\-=13
5004 \catcode`\`=13
5005   \gdef\indexnonalnumdisappear{%
5006     \ifflagclear{txiindexlquoteignore}{}{%
5007       % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
5008       % (Introduced for FSFS 2nd ed.)
5009       \let`=\empty
5010     }%
5011     %
5012     \ifflagclear{txiindexbackslashignore}{}{%
5013       \backslashdisappear
5014     }%
5015     \ifflagclear{txiindexhyphenignore}{}{%
5016       \def-{}%
5017     }%
5018     \ifflagclear{txiindexlessthanignore}{}{%
5019       \def<{}%
5020     }%
5021     \ifflagclear{txiindexatsignignore}{}{%
5022       \def\@{}%
5023     }%
5024   }
5025
5026   \gdef\indexnonalnumreappear{%
5027     \let-\normaldash
5028     \let<\normalless
5029   }
5030 }
5031
5032
5033 % \indexnofonts is used when outputting the strings to sort the index
5034 % by, and when constructing control sequence names.  It eliminates all
5035 % control sequences and just writes whatever the best ASCII sort string
5036 % would be for a given command (usually its argument).
5037 %
5038 \def\indexnofonts{%
5039   % Accent commands should become @asis.
5040   \def\commondummyaccent##1{\let##1\asis}%
5041   % We can just ignore other control letters.
5042   \def\commondummyletter##1{\let##1\empty}%
5043   % All control words become @asis by default; overrides below.
5044   \let\commondummyword\commondummyaccent
5045   \commondummiesnofonts
5046   %
5047   % Don't no-op \tt, since it isn't a user-level command
5048   % and is used in the definitions of the active chars like <, >, |, etc.
5049   % Likewise with the other plain tex font commands.
5050   %\let\tt=\asis
5051   %
5052   \def\ { }%
5053   \def\@{@}%
5054   \def\_{\normalunderscore}%
5055   \def\-{}% @- shouldn't affect sorting
5056   %
5057   \uccode`\1=`\{ \uppercase{\def\{{1}}%
5058   \uccode`\1=`\} \uppercase{\def\}{1}}%
5059   \let\lbracechar\{%
5060   \let\rbracechar\}%
5061   %
5062   % Non-English letters.
5063   \def\AA{AA}%
5064   \def\AE{AE}%
5065   \def\DH{DZZ}%
5066   \def\L{L}%
5067   \def\OE{OE}%
5068   \def\O{O}%
5069   \def\TH{TH}%
5070   \def\aa{aa}%
5071   \def\ae{ae}%
5072   \def\dh{dzz}%
5073   \def\exclamdown{!}%
5074   \def\l{l}%
5075   \def\oe{oe}%
5076   \def\ordf{a}%
5077   \def\ordm{o}%
5078   \def\o{o}%
5079   \def\questiondown{?}%
5080   \def\ss{ss}%
5081   \def\th{th}%
5082   %
5083   \let\do\indexnofontsdef
5084   %
5085   \do\LaTeX{LaTeX}%
5086   \do\TeX{TeX}%
5087   %
5088   % Assorted special characters.
5089   \do\atchar{@}%
5090   \do\arrow{->}%
5091   \do\bullet{bullet}%
5092   \do\comma{,}%
5093   \do\copyright{copyright}%
5094   \do\dots{...}%
5095   \do\enddots{...}%
5096   \do\equiv{==}%
5097   \do\error{error}%
5098   \do\euro{euro}%
5099   \do\expansion{==>}%
5100   \do\geq{>=}%
5101   \do\guillemetleft{<<}%
5102   \do\guillemetright{>>}%
5103   \do\guilsinglleft{<}%
5104   \do\guilsinglright{>}%
5105   \do\leq{<=}%
5106   \do\lbracechar{\{}%
5107   \do\minus{-}%
5108   \do\point{.}%
5109   \do\pounds{pounds}%
5110   \do\print{-|}%
5111   \do\quotedblbase{"}%
5112   \do\quotedblleft{"}%
5113   \do\quotedblright{"}%
5114   \do\quoteleft{`}%
5115   \do\quoteright{'}%
5116   \do\quotesinglbase{,}%
5117   \do\rbracechar{\}}%
5118   \do\registeredsymbol{R}%
5119   \do\result{=>}%
5120   \do\textdegree{o}%
5121   %
5122   % We need to get rid of all macros, leaving only the arguments (if present).
5123   % Of course this is not nearly correct, but it is the best we can do for now.
5124   % makeinfo does not expand macros in the argument to @deffn, which ends up
5125   % writing an index entry, and texindex isn't prepared for an index sort entry
5126   % that starts with \.
5127   %
5128   % Since macro invocations are followed by braces, we can just redefine them
5129   % to take a single TeX argument.  The case of a macro invocation that
5130   % goes to end-of-line is not handled.
5131   %
5132   \macrolist
5133   \let\value\indexnofontsvalue
5134 }
5135
5136 % Give the control sequence a definition that removes the {} that follows
5137 % its use, e.g. @AA{} -> AA
5138 \def\indexnofontsdef#1#2{\def#1##1{#2}}%
5139
5140
5141
5142
5143 % #1 is the index name, #2 is the entry text.
5144 \def\doind#1#2{%
5145   \iflinks
5146   {%
5147     %
5148     \requireopenindexfile{#1}%
5149     \edef\writeto{\csname#1indfile\endcsname}%
5150     %
5151     \def\indextext{#2}%
5152     \safewhatsit\doindwrite
5153   }%
5154   \fi
5155 }
5156
5157 % Same as \doind, but for code indices
5158 \def\docind#1#2{%
5159   \iflinks
5160   {%
5161     %
5162     \requireopenindexfile{#1}%
5163     \edef\writeto{\csname#1indfile\endcsname}%
5164     %
5165     \def\indextext{#2}%
5166     \safewhatsit\docindwrite
5167   }%
5168   \fi
5169 }
5170
5171 % Check if an index file has been opened, and if not, open it.
5172 \def\requireopenindexfile#1{%
5173 \ifnum\csname #1indfile\endcsname=0
5174   \expandafter\newwrite \csname#1indfile\endcsname
5175   \edef\suffix{#1}%
5176   % A .fls suffix would conflict with the file extension for the output
5177   % of -recorder, so use .f1s instead.
5178   \ifx\suffix\indexisfl\def\suffix{f1}\fi
5179   % Open the file
5180   \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
5181   % Using \immediate above here prevents an object entering into the current
5182   % box, which could confound checks such as those in \safewhatsit for
5183   % preceding skips.
5184   \typeout{Writing index file \jobname.\suffix}%
5185 \fi}
5186 \def\indexisfl{fl}
5187
5188 % Definition for writing index entry sort key.
5189 {
5190 \catcode`\-=13
5191 \gdef\indexwritesortas{%
5192   \begingroup
5193   \indexnonalnumreappear
5194   \indexwritesortasxxx}
5195 \gdef\indexwritesortasxxx#1{%
5196   \xdef\indexsortkey{#1}\endgroup}
5197 }
5198
5199 \def\indexwriteseealso#1{
5200   \gdef\pagenumbertext{\string\seealso{#1}}%
5201 }
5202 \def\indexwriteseeentry#1{
5203   \gdef\pagenumbertext{\string\seeentry{#1}}%
5204 }
5205
5206 % The default definitions
5207 \def\sortas#1{}%
5208 \def\seealso#1{\i{\putwordSeeAlso}\ #1}% for sorted index file only
5209 \def\putwordSeeAlso{See also}
5210 \def\seeentry#1{\i{\putwordSee}\ #1}% for sorted index file only
5211
5212
5213 % Given index entry text like "aaa @subentry bbb @sortas{ZZZ}":
5214 %   * Set \bracedtext to "{aaa}{bbb}"
5215 %   * Set \fullindexsortkey to "aaa @subentry ZZZ"
5216 %   * If @seealso occurs, set \pagenumbertext
5217 %
5218 \def\splitindexentry#1{%
5219   \gdef\fullindexsortkey{}%
5220   \xdef\bracedtext{}%
5221   \def\sep{}%
5222   \def\seealso##1{}%
5223   \def\seeentry##1{}%
5224   \expandafter\doindexsegment#1\subentry\finish\subentry
5225 }
5226
5227 % append the results from the next segment
5228 \def\doindexsegment#1\subentry{%
5229   \def\segment{#1}%
5230   \ifx\segment\isfinish
5231   \else
5232     %
5233     % Fully expand the segment, throwing away any @sortas directives, and
5234     % trim spaces.
5235     \edef\trimmed{\segment}%
5236     \edef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
5237     \ifincodeindex
5238       \edef\trimmed{\noexpand\code{\trimmed}}%
5239     \fi
5240     %
5241     \xdef\bracedtext{\bracedtext{\trimmed}}%
5242     %
5243     % Get the string to sort by.  Process the segment with all
5244     % font commands turned off.
5245     \bgroup
5246       \let\sortas\indexwritesortas
5247       \let\seealso\indexwriteseealso
5248       \let\seeentry\indexwriteseeentry
5249       \indexnofonts
5250       % The braces around the commands are recognized by texindex.
5251       \def\lbracechar{{\string\indexlbrace}}%
5252       \def\rbracechar{{\string\indexrbrace}}%
5253       \let\{=\lbracechar
5254       \let\}=\rbracechar
5255       \def\@{{\string\indexatchar}}%
5256       \def\atchar##1{\@}%
5257       \def\backslashchar{{\string\indexbackslash}}%
5258       \uccode`\~=`\\ \uppercase{\let~\backslashchar}%
5259       %
5260       \let\indexsortkey\empty
5261       \global\let\pagenumbertext\empty
5262       % Execute the segment and throw away the typeset output.  This executes
5263       % any @sortas or @seealso commands in this segment.
5264       \setbox\dummybox = \hbox{\segment}%
5265       \ifx\indexsortkey\empty{%
5266         \indexnonalnumdisappear
5267         \xdef\trimmed{\segment}%
5268         \xdef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
5269         \xdef\indexsortkey{\trimmed}%
5270         \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
5271       }\fi
5272       %
5273       % Append to \fullindexsortkey.
5274       \edef\tmp{\gdef\noexpand\fullindexsortkey{%
5275                   \fullindexsortkey\sep\indexsortkey}}%
5276       \tmp
5277     \egroup
5278     \def\sep{\subentry}%
5279     %
5280     \expandafter\doindexsegment
5281   \fi
5282 }
5283 \def\isfinish{\finish}%
5284 \newbox\dummybox % used above
5285
5286 \let\subentry\relax
5287
5288 % Use \ instead of @ in index files.  To support old texi2dvi and texindex.
5289 % This works without changing the escape character used in the toc or aux
5290 % files because the index entries are fully expanded here, and \string uses
5291 % the current value of \escapechar.
5292 \def\escapeisbackslash{\escapechar=`\\}
5293
5294 % Use \ in index files by default.  texi2dvi didn't support @ as the escape
5295 % character (as it checked for "\entry" in the files, and not "@entry").  When
5296 % the new version of texi2dvi has had a chance to become more prevalent, then
5297 % the escape character can change back to @ again.  This should be an easy
5298 % change to make now because both @ and \ are only used as escape characters in
5299 % index files, never standing for themselves.
5300 %
5301 \set txiindexescapeisbackslash
5302
5303 % Write the entry in \indextext to the index file.
5304 %
5305
5306 \newif\ifincodeindex
5307 \def\doindwrite{\incodeindexfalse\doindwritex}
5308 \def\docindwrite{\incodeindextrue\doindwritex}
5309
5310 \def\doindwritex{%
5311   \maybemarginindex
5312   %
5313   \atdummies
5314   %
5315   \ifflagclear{txiindexescapeisbackslash}{}{\escapeisbackslash}%
5316   %
5317   % For texindex which always views { and } as separators.
5318   \def\{{\lbracechar{}}%
5319   \def\}{\rbracechar{}}%
5320   \uccode`\~=`\\ \uppercase{\def~{\backslashchar{}}}%
5321   %
5322   % Split the entry into primary entry and any subentries, and get the index
5323   % sort key.
5324   \splitindexentry\indextext
5325   %
5326   % Set up the complete index entry, with both the sort key and
5327   % the original text, including any font commands.  We write
5328   % three arguments to \entry to the .?? file (four in the
5329   % subentry case), texindex reduces to two when writing the .??s
5330   % sorted result.
5331   %
5332   \edef\temp{%
5333     \write\writeto{%
5334       \string\entry{\fullindexsortkey}%
5335         {\ifx\pagenumbertext\empty\noexpand\folio\else\pagenumbertext\fi}%
5336         \bracedtext}%
5337   }%
5338   \temp
5339 }
5340
5341 % Put the index entry in the margin if desired (undocumented).
5342 \def\maybemarginindex{%
5343   \ifx\SETmarginindex\relax\else
5344     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \relax\indextext}}%
5345   \fi
5346 }
5347 \let\SETmarginindex=\relax
5348
5349
5350 % Take care of unwanted page breaks/skips around a whatsit:
5351 %
5352 % If a skip is the last thing on the list now, preserve it
5353 % by backing up by \lastskip, doing the \write, then inserting
5354 % the skip again.  Otherwise, the whatsit generated by the
5355 % \write or \pdfdest will make \lastskip zero.  The result is that
5356 % sequences like this:
5357 % @end defun
5358 % @tindex whatever
5359 % @defun ...
5360 % will have extra space inserted, because the \medbreak in the
5361 % start of the @defun won't see the skip inserted by the @end of
5362 % the previous defun.
5363 %
5364 % But don't do any of this if we're not in vertical mode.  We
5365 % don't want to do a \vskip and prematurely end a paragraph.
5366 %
5367 % Avoid page breaks due to these extra skips, too.
5368 %
5369 % But wait, there is a catch there:
5370 % We'll have to check whether \lastskip is zero skip.  \ifdim is not
5371 % sufficient for this purpose, as it ignores stretch and shrink parts
5372 % of the skip.  The only way seems to be to check the textual
5373 % representation of the skip.
5374 %
5375 % The following is almost like \def\zeroskipmacro{0.0pt} except that
5376 % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
5377 %
5378 \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
5379 %
5380 \newskip\whatsitskip
5381 \newcount\whatsitpenalty
5382 %
5383 % ..., ready, GO:
5384 %
5385 \def\safewhatsit#1{\ifhmode
5386   #1%
5387  \else
5388   % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
5389   \whatsitskip = \lastskip
5390   \edef\lastskipmacro{\the\lastskip}%
5391   \whatsitpenalty = \lastpenalty
5392   %
5393   % If \lastskip is nonzero, that means the last item was a
5394   % skip.  And since a skip is discardable, that means this
5395   % -\whatsitskip glue we're inserting is preceded by a
5396   % non-discardable item, therefore it is not a potential
5397   % breakpoint, therefore no \nobreak needed.
5398   \ifx\lastskipmacro\zeroskipmacro
5399   \else
5400     \vskip-\whatsitskip
5401   \fi
5402   %
5403   #1%
5404   %
5405   \ifx\lastskipmacro\zeroskipmacro
5406     % If \lastskip was zero, perhaps the last item was a penalty, and
5407     % perhaps it was >=10000, e.g., a \nobreak.  In that case, we want
5408     % to re-insert the same penalty (values >10000 are used for various
5409     % signals); since we just inserted a non-discardable item, any
5410     % following glue (such as a \parskip) would be a breakpoint.  For example:
5411     %   @deffn deffn-whatever
5412     %   @vindex index-whatever
5413     %   Description.
5414     % would allow a break between the index-whatever whatsit
5415     % and the "Description." paragraph.
5416     \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
5417   \else
5418     % On the other hand, if we had a nonzero \lastskip,
5419     % this make-up glue would be preceded by a non-discardable item
5420     % (the whatsit from the \write), so we must insert a \nobreak.
5421     \nobreak\vskip\whatsitskip
5422   \fi
5423 \fi}
5424
5425 % The index entry written in the file actually looks like
5426 %  \entry {sortstring}{page}{topic}
5427 % or
5428 %  \entry {sortstring}{page}{topic}{subtopic}
5429 % The texindex program reads in these files and writes files
5430 % containing these kinds of lines:
5431 %  \initial {c}
5432 %     before the first topic whose initial is c
5433 %  \entry {topic}{pagelist}
5434 %     for a topic that is used without subtopics
5435 %  \primary {topic}
5436 %  \entry {topic}{}
5437 %     for the beginning of a topic that is used with subtopics
5438 %  \secondary {subtopic}{pagelist}
5439 %     for each subtopic.
5440 %  \secondary {subtopic}{}
5441 %     for a subtopic with sub-subtopics
5442 %  \tertiary {subtopic}{subsubtopic}{pagelist}
5443 %     for each sub-subtopic.
5444
5445 % Define the user-accessible indexing commands
5446 % @findex, @vindex, @kindex, @cindex.
5447
5448 \def\findex {\fnindex}
5449 \def\kindex {\kyindex}
5450 \def\cindex {\cpindex}
5451 \def\vindex {\vrindex}
5452 \def\tindex {\tpindex}
5453 \def\pindex {\pgindex}
5454
5455 % Define the macros used in formatting output of the sorted index material.
5456
5457 % @printindex causes a particular index (the ??s file) to get printed.
5458 % It does not print any chapter heading (usually an @unnumbered).
5459 %
5460 \parseargdef\printindex{\begingroup
5461   \dobreak \chapheadingskip{10000}%
5462   %
5463   \smallfonts \rm
5464   \tolerance = 9500
5465   \plainfrenchspacing
5466   \everypar = {}% don't want the \kern\-parindent from indentation suppression.
5467   %
5468   % See comment in \requireopenindexfile.
5469   \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
5470   %
5471   % See if the index file exists and is nonempty.
5472   \openin 1 \jobname.\indexname s
5473   \ifeof 1
5474     % \enddoublecolumns gets confused if there is no text in the index,
5475     % and it loses the chapter title and the aux file entries for the
5476     % index.  The easiest way to prevent this problem is to make sure
5477     % there is some text.
5478     \putwordIndexNonexistent
5479     \typeout{No file \jobname.\indexname s.}%
5480   \else
5481     % If the index file exists but is empty, then \openin leaves \ifeof
5482     % false.  We have to make TeX try to read something from the file, so
5483     % it can discover if there is anything in it.
5484     \read 1 to \thisline
5485     \ifeof 1
5486       \putwordIndexIsEmpty
5487     \else
5488       \expandafter\printindexzz\thisline\relax\relax\finish%
5489     \fi
5490   \fi
5491   \closein 1
5492 \endgroup}
5493
5494 % If the index file starts with a backslash, forgo reading the index
5495 % file altogether.  If somebody upgrades texinfo.tex they may still have
5496 % old index files using \ as the escape character.  Reading this would
5497 % at best lead to typesetting garbage, at worst a TeX syntax error.
5498 \def\printindexzz#1#2\finish{%
5499   \ifflagclear{txiindexescapeisbackslash}{%
5500     \uccode`\~=`\\ \uppercase{\if\noexpand~}\noexpand#1
5501       \ifflagclear{txiskipindexfileswithbackslash}{%
5502 \errmessage{%
5503 ERROR: A sorted index file in an obsolete format was skipped.
5504 To fix this problem, please upgrade your version of 'texi2dvi'
5505 or 'texi2pdf' to that at <https://ftp.gnu.org/gnu/texinfo>.
5506 If you are using an old version of 'texindex' (part of the Texinfo
5507 distribution), you may also need to upgrade to a newer version (at least 6.0).
5508 You may be able to typeset the index if you run
5509 'texindex \jobname.\indexname' yourself.
5510 You could also try setting the 'txiindexescapeisbackslash' flag by
5511 running a command like
5512 'texi2dvi -t "@set txiindexescapeisbackslash" \jobname.texi'.  If you do
5513 this, Texinfo will try to use index files in the old format.
5514 If you continue to have problems, deleting the index files and starting again
5515 might help (with 'rm \jobname.?? \jobname.??s')%
5516 }%
5517       }{%
5518         (Skipped sorted index file in obsolete format)
5519       }%
5520     \else
5521       \begindoublecolumns
5522       \input \jobname.\indexname s
5523       \enddoublecolumns
5524     \fi
5525   }{%
5526     \begindoublecolumns
5527     \catcode`\\=0\relax
5528     %
5529     % Make @ an escape character to give macros a chance to work.  This
5530     % should work because we (hopefully) don't otherwise use @ in index files.
5531     %\catcode`\@=12\relax
5532     \catcode`\@=0\relax
5533     \input \jobname.\indexname s
5534     \enddoublecolumns
5535   }%
5536 }
5537
5538 % These macros are used by the sorted index file itself.
5539 % Change them to control the appearance of the index.
5540
5541 {\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
5542 \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
5543 \catcode`\$=3
5544 \gdef\initialglyphs{%
5545   % special control sequences used in the index sort key
5546   \let\indexlbrace\{%
5547   \let\indexrbrace\}%
5548   \let\indexatchar\@%
5549   \def\indexbackslash{\math{\backslash}}%
5550   %
5551   % Some changes for non-alphabetic characters.  Using the glyphs from the
5552   % math fonts looks more consistent than the typewriter font used elsewhere
5553   % for these characters.
5554   \uccode`\~=`\\ \uppercase{\def~{\math{\backslash}}}
5555   %
5556   % In case @\ is used for backslash
5557   \uppercase{\let\\=~}
5558   % Can't get bold backslash so don't use bold forward slash
5559   \catcode`\/=13
5560   \def/{{\secrmnotbold \normalslash}}%
5561   \def-{{\normaldash\normaldash}}% en dash `--'
5562   \def^{{\chapbf \normalcaret}}%
5563   \def~{{\chapbf \normaltilde}}%
5564   \def\_{%
5565      \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
5566   \def|{$\vert$}%
5567   \def<{$\less$}%
5568   \def>{$\gtr$}%
5569   \def+{$\normalplus$}%
5570 }}
5571
5572 \def\initial{%
5573   \bgroup
5574   \initialglyphs
5575   \initialx
5576 }
5577
5578 \def\initialx#1{%
5579   % Remove any glue we may have, we'll be inserting our own.
5580   \removelastskip
5581   %
5582   % We like breaks before the index initials, so insert a bonus.
5583   % The glue before the bonus allows a little bit of space at the
5584   % bottom of a column to reduce an increase in inter-line spacing.
5585   \nobreak
5586   \vskip 0pt plus 5\baselineskip
5587   \penalty -300
5588   \vskip 0pt plus -5\baselineskip
5589   %
5590   % Typeset the initial.  Making this add up to a whole number of
5591   % baselineskips increases the chance of the dots lining up from column
5592   % to column.  It still won't often be perfect, because of the stretch
5593   % we need before each entry, but it's better.
5594   %
5595   % No shrink because it confuses \balancecolumns.
5596   \vskip 1.67\baselineskip plus 1\baselineskip
5597   \leftline{\secfonts \kern-0.05em \secbf #1}%
5598   % \secfonts is inside the argument of \leftline so that the change of
5599   % \baselineskip will not affect any glue inserted before the vbox that
5600   % \leftline creates.
5601   % Do our best not to break after the initial.
5602   \nobreak
5603   \vskip .33\baselineskip plus .1\baselineskip
5604   \egroup % \initialglyphs
5605 }
5606
5607 \newdimen\entryrightmargin
5608 \entryrightmargin=0pt
5609
5610 % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
5611 % then page number (#2) flushed to the right margin.  It is used for index
5612 % and table of contents entries.  The paragraph is indented by \leftskip.
5613 %
5614 \def\entry{%
5615   \begingroup
5616     %
5617     % Start a new paragraph if necessary, so our assignments below can't
5618     % affect previous text.
5619     \par
5620     %
5621     % No extra space above this paragraph.
5622     \parskip = 0in
5623     %
5624     % When reading the text of entry, convert explicit line breaks
5625     % from @* into spaces.  The user might give these in long section
5626     % titles, for instance.
5627     \def\*{\unskip\space\ignorespaces}%
5628     \def\entrybreak{\hfil\break}% An undocumented command
5629     %
5630     % Swallow the left brace of the text (first parameter):
5631     \afterassignment\doentry
5632     \let\temp =
5633 }
5634 \def\entrybreak{\unskip\space\ignorespaces}%
5635 \def\doentry{%
5636     % Save the text of the entry
5637     \global\setbox\boxA=\hbox\bgroup
5638     \bgroup % Instead of the swallowed brace.
5639       \noindent
5640       \aftergroup\finishentry
5641       % And now comes the text of the entry.
5642       % Not absorbing as a macro argument reduces the chance of problems
5643       % with catcodes occurring.
5644 }
5645 {\catcode`\@=11
5646 \gdef\finishentry#1{%
5647     \egroup % end box A
5648     \dimen@ = \wd\boxA % Length of text of entry
5649     \global\setbox\boxA=\hbox\bgroup
5650       \unhbox\boxA
5651       % #1 is the page number.
5652       %
5653       % Get the width of the page numbers, and only use
5654       % leaders if they are present.
5655       \global\setbox\boxB = \hbox{#1}%
5656       \ifdim\wd\boxB = 0pt
5657         \null\nobreak\hfill\ %
5658       \else
5659         %
5660         \null\nobreak\indexdotfill % Have leaders before the page number.
5661         %
5662         \ifpdforxetex
5663           \pdfgettoks#1.%
5664           \hskip\skip\thinshrinkable\the\toksA
5665         \else
5666           \hskip\skip\thinshrinkable #1%
5667         \fi
5668       \fi
5669     \egroup % end \boxA
5670     \ifdim\wd\boxB = 0pt
5671       \noindent\unhbox\boxA\par
5672       \nobreak
5673     \else\bgroup
5674       % We want the text of the entries to be aligned to the left, and the
5675       % page numbers to be aligned to the right.
5676       %
5677       \parindent = 0pt
5678       \advance\leftskip by 0pt plus 1fil
5679       \advance\leftskip by 0pt plus -1fill
5680       \rightskip = 0pt plus -1fil
5681       \advance\rightskip by 0pt plus 1fill
5682       % Cause last line, which could consist of page numbers on their own
5683       % if the list of page numbers is long, to be aligned to the right.
5684       \parfillskip=0pt plus -1fill
5685       %
5686       \advance\rightskip by \entryrightmargin
5687       % Determine how far we can stretch into the margin.
5688       % This allows, e.g., "Appendix H  GNU Free Documentation License" to
5689       % fit on one line in @letterpaper format.
5690       \ifdim\entryrightmargin>2.1em
5691         \dimen@i=2.1em
5692       \else
5693         \dimen@i=0em
5694       \fi
5695       \advance \parfillskip by 0pt minus 1\dimen@i
5696       %
5697       \dimen@ii = \hsize
5698       \advance\dimen@ii by -1\leftskip
5699       \advance\dimen@ii by -1\entryrightmargin
5700       \advance\dimen@ii by 1\dimen@i
5701       \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
5702       \ifdim\dimen@ > 0.8\dimen@ii   % due to long index text
5703         % Try to split the text roughly evenly.  \dimen@ will be the length of
5704         % the first line.
5705         \dimen@ = 0.7\dimen@
5706         \dimen@ii = \hsize
5707         \ifnum\dimen@>\dimen@ii
5708           % If the entry is too long (for example, if it needs more than
5709           % two lines), use all the space in the first line.
5710           \dimen@ = \dimen@ii
5711         \fi
5712         \advance\leftskip by 0pt plus 1fill % ragged right
5713         \advance \dimen@ by 1\rightskip
5714         \parshape = 2 0pt \dimen@ 0em \dimen@ii
5715         % Ideally we'd add a finite glue at the end of the first line only,
5716         % instead of using \parshape with explicit line lengths, but TeX
5717         % doesn't seem to provide a way to do such a thing.
5718         %
5719         % Indent all lines but the first one.
5720         \advance\leftskip by 1em
5721         \advance\parindent by -1em
5722       \fi\fi
5723       \indent % start paragraph
5724       \unhbox\boxA
5725       %
5726       % Do not prefer a separate line ending with a hyphen to fewer lines.
5727       \finalhyphendemerits = 0
5728       %
5729       % Word spacing - no stretch
5730       \spaceskip=\fontdimen2\font minus \fontdimen4\font
5731       %
5732       \linepenalty=1000  % Discourage line breaks.
5733       \hyphenpenalty=5000  % Discourage hyphenation.
5734       %
5735       \par % format the paragraph
5736     \egroup % The \vbox
5737     \fi
5738   \endgroup
5739 }}
5740
5741 \newskip\thinshrinkable
5742 \skip\thinshrinkable=.15em minus .15em
5743
5744 % Like plain.tex's \dotfill, except uses up at least 1 em.
5745 % The filll stretch here overpowers both the fil and fill stretch to push
5746 % the page number to the right.
5747 \def\indexdotfill{\cleaders
5748   \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
5749
5750
5751 \def\primary #1{\line{#1\hfil}}
5752
5753 \def\secondary{\indententry{0.5cm}}
5754 \def\tertiary{\indententry{1cm}}
5755
5756 \def\indententry#1#2#3{%
5757   \bgroup
5758   \leftskip=#1
5759   \entry{#2}{#3}%
5760   \egroup
5761 }
5762
5763 % Define two-column mode, which we use to typeset indexes.
5764 % Adapted from the TeXbook, page 416, which is to say,
5765 % the manmac.tex format used to print the TeXbook itself.
5766 \catcode`\@=11  % private names
5767
5768 \newbox\partialpage
5769 \newdimen\doublecolumnhsize
5770
5771 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
5772   % If not much space left on page, start a new page.
5773   \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
5774   %
5775   % Grab any single-column material above us.
5776   \output = {%
5777     \savetopmark
5778     %
5779     \global\setbox\partialpage = \vbox{%
5780       % Unvbox the main output page.
5781       \unvbox\PAGE
5782       \kern-\topskip \kern\baselineskip
5783     }%
5784   }%
5785   \eject % run that output routine to set \partialpage
5786   %
5787   % Use the double-column output routine for subsequent pages.
5788   \output = {\doublecolumnout}%
5789   %
5790   % Change the page size parameters.  We could do this once outside this
5791   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5792   % format, but then we repeat the same computation.  Repeating a couple
5793   % of assignments once per index is clearly meaningless for the
5794   % execution time, so we may as well do it in one place.
5795   %
5796   % First we halve the line length, less a little for the gutter between
5797   % the columns.  We compute the gutter based on the line length, so it
5798   % changes automatically with the paper format.  The magic constant
5799   % below is chosen so that the gutter has the same value (well, +-<1pt)
5800   % as it did when we hard-coded it.
5801   %
5802   % We put the result in a separate register, \doublecolumhsize, so we
5803   % can restore it in \pagesofar, after \hsize itself has (potentially)
5804   % been clobbered.
5805   %
5806   \doublecolumnhsize = \hsize
5807     \advance\doublecolumnhsize by -.04154\hsize
5808     \divide\doublecolumnhsize by 2
5809   \hsize = \doublecolumnhsize
5810   %
5811   % Get the available space for the double columns -- the normal
5812   % (undoubled) page height minus any material left over from the
5813   % previous page.
5814   \advance\vsize by -\ht\partialpage
5815   \vsize = 2\vsize
5816   %
5817   % For the benefit of balancing columns
5818   \advance\baselineskip by 0pt plus 0.5pt
5819 }
5820
5821 % The double-column output routine for all double-column pages except
5822 % the last, which is done by \balancecolumns.
5823 %
5824 \def\doublecolumnout{%
5825   %
5826   \savetopmark
5827   \splittopskip=\topskip \splitmaxdepth=\maxdepth
5828   \dimen@ = \vsize
5829   \divide\dimen@ by 2
5830   %
5831   % box0 will be the left-hand column, box2 the right.
5832   \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@
5833   \global\advance\vsize by 2\ht\partialpage
5834   \onepageout\pagesofar % empty except for the first time we are called
5835   \unvbox\PAGE
5836   \penalty\outputpenalty
5837 }
5838 %
5839 % Re-output the contents of the output page -- any previous material,
5840 % followed by the two boxes we just split, in box0 and box2.
5841 \def\pagesofar{%
5842   \unvbox\partialpage
5843   %
5844   \hsize = \doublecolumnhsize
5845   \wd0=\hsize \wd2=\hsize
5846   \hbox to\txipagewidth{\box0\hfil\box2}%
5847 }
5848
5849
5850 % Finished with double columns.
5851 \def\enddoublecolumns{%
5852   % The following penalty ensures that the page builder is exercised
5853   % _before_ we change the output routine.  This is necessary in the
5854   % following situation:
5855   %
5856   % The last section of the index consists only of a single entry.
5857   % Before this section, \pagetotal is less than \pagegoal, so no
5858   % break occurs before the last section starts.  However, the last
5859   % section, consisting of \initial and the single \entry, does not
5860   % fit on the page and has to be broken off.  Without the following
5861   % penalty the page builder will not be exercised until \eject
5862   % below, and by that time we'll already have changed the output
5863   % routine to the \balancecolumns version, so the next-to-last
5864   % double-column page will be processed with \balancecolumns, which
5865   % is wrong:  The two columns will go to the main vertical list, with
5866   % the broken-off section in the recent contributions.  As soon as
5867   % the output routine finishes, TeX starts reconsidering the page
5868   % break.  The two columns and the broken-off section both fit on the
5869   % page, because the two columns now take up only half of the page
5870   % goal.  When TeX sees \eject from below which follows the final
5871   % section, it invokes the new output routine that we've set after
5872   % \balancecolumns below; \onepageout will try to fit the two columns
5873   % and the final section into the vbox of \txipageheight (see
5874   % \pagebody), causing an overfull box.
5875   %
5876   % Note that glue won't work here, because glue does not exercise the
5877   % page builder, unlike penalties (see The TeXbook, pp. 280-281).
5878   \penalty0
5879   %
5880   \output = {%
5881     % Split the last of the double-column material.
5882     \savetopmark
5883     \balancecolumns
5884   }%
5885   \eject % call the \output just set
5886   \ifdim\pagetotal=0pt
5887     % Having called \balancecolumns once, we do not
5888     % want to call it again.  Therefore, reset \output to its normal
5889     % definition right away.
5890     \global\output=\expandafter{\the\defaultoutput}
5891     %
5892     \endgroup % started in \begindoublecolumns
5893     % Leave the double-column material on the current page, no automatic
5894     % page break.
5895     \box\balancedcolumns
5896     %
5897     % \pagegoal was set to the doubled \vsize above, since we restarted
5898     % the current page.  We're now back to normal single-column
5899     % typesetting, so reset \pagegoal to the normal \vsize.
5900     \global\vsize = \txipageheight %
5901     \pagegoal = \txipageheight %
5902   \else
5903     % We had some left-over material.  This might happen when \doublecolumnout
5904     % is called in \balancecolumns.  Try again.
5905     \expandafter\enddoublecolumns
5906   \fi
5907 }
5908 \newbox\balancedcolumns
5909 \setbox\balancedcolumns=\vbox{shouldnt see this}%
5910 %
5911 % Only called for the last of the double column material.  \doublecolumnout
5912 % does the others.
5913 \def\balancecolumns{%
5914   \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120.
5915   \dimen@ = \ht0
5916   \ifdim\dimen@<7\baselineskip
5917     % Don't split a short final column in two.
5918     \setbox2=\vbox{}%
5919     \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5920   \else
5921     % double the leading vertical space
5922     \advance\dimen@ by \topskip
5923     \advance\dimen@ by-\baselineskip
5924     \divide\dimen@ by 2 % target to split to
5925     \dimen@ii = \dimen@
5926     \splittopskip = \topskip
5927     % Loop until left column is at least as high as the right column.
5928     {%
5929       \vbadness = 10000
5930       \loop
5931         \global\setbox3 = \copy0
5932         \global\setbox1 = \vsplit3 to \dimen@
5933       \ifdim\ht1<\ht3
5934         \global\advance\dimen@ by 1pt
5935       \repeat
5936     }%
5937     % Now the left column is in box 1, and the right column in box 3.
5938     %
5939     % Check whether the left column has come out higher than the page itself.
5940     % (Note that we have doubled \vsize for the double columns, so
5941     % the actual height of the page is 0.5\vsize).
5942     \ifdim2\ht1>\vsize
5943       % It appears that we have been called upon to balance too much material.
5944       % Output some of it with \doublecolumnout, leaving the rest on the page.
5945       \setbox\PAGE=\box0
5946       \doublecolumnout
5947     \else
5948       % Compare the heights of the two columns.
5949       \ifdim4\ht1>5\ht3
5950         % Column heights are too different, so don't make their bottoms
5951         % flush with each other.
5952         \setbox2=\vbox to \ht1 {\unvbox3\vfill}%
5953         \setbox0=\vbox to \ht1 {\unvbox1\vfill}%
5954       \else
5955         % Make column bottoms flush with each other.
5956         \setbox2=\vbox to\ht1{\unvbox3\unskip}%
5957         \setbox0=\vbox to\ht1{\unvbox1\unskip}%
5958       \fi
5959       \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5960     \fi
5961   \fi
5962   %
5963 }
5964 \catcode`\@ = \other
5965
5966
5967 \message{sectioning,}
5968 % Chapters, sections, etc.
5969
5970 % Let's start with @part.
5971 \parseargdef\part{\partzzz{#1}}
5972 \def\partzzz#1{%
5973   \chapoddpage
5974   \null
5975   \vskip.3\vsize  % move it down on the page a bit
5976   \begingroup
5977     \noindent \titlefonts\rm #1\par % the text
5978     \let\lastnode=\empty      % no node to associate with
5979     \writetocentry{part}{#1}{}% but put it in the toc
5980     \headingsoff              % no headline or footline on the part page
5981     % This outputs a mark at the end of the page that clears \thischapter
5982     % and \thissection, as is done in \startcontents.
5983     \let\pchapsepmacro\relax
5984     \chapmacro{}{Yomitfromtoc}{}%
5985     \chapoddpage
5986   \endgroup
5987 }
5988
5989 % \unnumberedno is an oxymoron.  But we count the unnumbered
5990 % sections so that we can refer to them unambiguously in the pdf
5991 % outlines by their "section number".  We avoid collisions with chapter
5992 % numbers by starting them at 10000.  (If a document ever has 10000
5993 % chapters, we're in trouble anyway, I'm sure.)
5994 \newcount\unnumberedno \unnumberedno = 10000
5995 \newcount\chapno
5996 \newcount\secno        \secno=0
5997 \newcount\subsecno     \subsecno=0
5998 \newcount\subsubsecno  \subsubsecno=0
5999
6000 % This counter is funny since it counts through charcodes of letters A, B, ...
6001 \newcount\appendixno  \appendixno = `\@
6002 %
6003 % \def\appendixletter{\char\the\appendixno}
6004 % We do the following ugly conditional instead of the above simple
6005 % construct for the sake of pdftex, which needs the actual
6006 % letter in the expansion, not just typeset.
6007 %
6008 \def\appendixletter{%
6009   \ifnum\appendixno=`A A%
6010   \else\ifnum\appendixno=`B B%
6011   \else\ifnum\appendixno=`C C%
6012   \else\ifnum\appendixno=`D D%
6013   \else\ifnum\appendixno=`E E%
6014   \else\ifnum\appendixno=`F F%
6015   \else\ifnum\appendixno=`G G%
6016   \else\ifnum\appendixno=`H H%
6017   \else\ifnum\appendixno=`I I%
6018   \else\ifnum\appendixno=`J J%
6019   \else\ifnum\appendixno=`K K%
6020   \else\ifnum\appendixno=`L L%
6021   \else\ifnum\appendixno=`M M%
6022   \else\ifnum\appendixno=`N N%
6023   \else\ifnum\appendixno=`O O%
6024   \else\ifnum\appendixno=`P P%
6025   \else\ifnum\appendixno=`Q Q%
6026   \else\ifnum\appendixno=`R R%
6027   \else\ifnum\appendixno=`S S%
6028   \else\ifnum\appendixno=`T T%
6029   \else\ifnum\appendixno=`U U%
6030   \else\ifnum\appendixno=`V V%
6031   \else\ifnum\appendixno=`W W%
6032   \else\ifnum\appendixno=`X X%
6033   \else\ifnum\appendixno=`Y Y%
6034   \else\ifnum\appendixno=`Z Z%
6035   % The \the is necessary, despite appearances, because \appendixletter is
6036   % expanded while writing the .toc file.  \char\appendixno is not
6037   % expandable, thus it is written literally, thus all appendixes come out
6038   % with the same letter (or @) in the toc without it.
6039   \else\char\the\appendixno
6040   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
6041   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
6042
6043 % Each @chapter defines these (using marks) as the number+name, number
6044 % and name of the chapter.  Page headings and footings can use
6045 % these.  @section does likewise.
6046 \def\thischapter{}
6047 \def\thischapternum{}
6048 \def\thischaptername{}
6049 \def\thissection{}
6050 \def\thissectionnum{}
6051 \def\thissectionname{}
6052
6053 \newcount\absseclevel % used to calculate proper heading level
6054 \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
6055
6056 % @raisesections: treat @section as chapter, @subsection as section, etc.
6057 \def\raisesections{\global\advance\secbase by -1}
6058
6059 % @lowersections: treat @chapter as section, @section as subsection, etc.
6060 \def\lowersections{\global\advance\secbase by 1}
6061
6062 % we only have subsub.
6063 \chardef\maxseclevel = 3
6064 %
6065 % A numbered section within an unnumbered changes to unnumbered too.
6066 % To achieve this, remember the "biggest" unnum. sec. we are currently in:
6067 \chardef\unnlevel = \maxseclevel
6068 %
6069 % Trace whether the current chapter is an appendix or not:
6070 % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
6071 \def\chapheadtype{N}
6072
6073 % Choose a heading macro
6074 % #1 is heading type
6075 % #2 is heading level
6076 % #3 is text for heading
6077 \def\genhead#1#2#3{%
6078   % Compute the abs. sec. level:
6079   \absseclevel=#2
6080   \advance\absseclevel by \secbase
6081   % Make sure \absseclevel doesn't fall outside the range:
6082   \ifnum \absseclevel < 0
6083     \absseclevel = 0
6084   \else
6085     \ifnum \absseclevel > 3
6086       \absseclevel = 3
6087     \fi
6088   \fi
6089   % The heading type:
6090   \def\headtype{#1}%
6091   \if \headtype U%
6092     \ifnum \absseclevel < \unnlevel
6093       \chardef\unnlevel = \absseclevel
6094     \fi
6095   \else
6096     % Check for appendix sections:
6097     \ifnum \absseclevel = 0
6098       \edef\chapheadtype{\headtype}%
6099     \else
6100       \if \headtype A\if \chapheadtype N%
6101         \errmessage{@appendix... within a non-appendix chapter}%
6102       \fi\fi
6103     \fi
6104     % Check for numbered within unnumbered:
6105     \ifnum \absseclevel > \unnlevel
6106       \def\headtype{U}%
6107     \else
6108       \chardef\unnlevel = 3
6109     \fi
6110   \fi
6111   % Now print the heading:
6112   \if \headtype U%
6113     \ifcase\absseclevel
6114         \unnumberedzzz{#3}%
6115     \or \unnumberedseczzz{#3}%
6116     \or \unnumberedsubseczzz{#3}%
6117     \or \unnumberedsubsubseczzz{#3}%
6118     \fi
6119   \else
6120     \if \headtype A%
6121       \ifcase\absseclevel
6122           \appendixzzz{#3}%
6123       \or \appendixsectionzzz{#3}%
6124       \or \appendixsubseczzz{#3}%
6125       \or \appendixsubsubseczzz{#3}%
6126       \fi
6127     \else
6128       \ifcase\absseclevel
6129           \chapterzzz{#3}%
6130       \or \seczzz{#3}%
6131       \or \numberedsubseczzz{#3}%
6132       \or \numberedsubsubseczzz{#3}%
6133       \fi
6134     \fi
6135   \fi
6136   \suppressfirstparagraphindent
6137 }
6138
6139 % an interface:
6140 \def\numhead{\genhead N}
6141 \def\apphead{\genhead A}
6142 \def\unnmhead{\genhead U}
6143
6144 % @chapter, @appendix, @unnumbered.  Increment top-level counter, reset
6145 % all lower-level sectioning counters to zero.
6146 %
6147 % Also set \chaplevelprefix, which we prepend to @float sequence numbers
6148 % (e.g., figures), q.v.  By default (before any chapter), that is empty.
6149 \let\chaplevelprefix = \empty
6150 %
6151 \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
6152 \def\chapterzzz#1{%
6153   % section resetting is \global in case the chapter is in a group, such
6154   % as an @include file.
6155   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6156     \global\advance\chapno by 1
6157   %
6158   % Used for \float.
6159   \gdef\chaplevelprefix{\the\chapno.}%
6160   \resetallfloatnos
6161   %
6162   % \putwordChapter can contain complex things in translations.
6163   \toks0=\expandafter{\putwordChapter}%
6164   \message{\the\toks0 \space \the\chapno}%
6165   %
6166   % Write the actual heading.
6167   \chapmacro{#1}{Ynumbered}{\the\chapno}%
6168   %
6169   % So @section and the like are numbered underneath this chapter.
6170   \global\let\section = \numberedsec
6171   \global\let\subsection = \numberedsubsec
6172   \global\let\subsubsection = \numberedsubsubsec
6173 }
6174
6175 \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
6176 %
6177 \def\appendixzzz#1{%
6178   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6179     \global\advance\appendixno by 1
6180   \gdef\chaplevelprefix{\appendixletter.}%
6181   \resetallfloatnos
6182   %
6183   % \putwordAppendix can contain complex things in translations.
6184   \toks0=\expandafter{\putwordAppendix}%
6185   \message{\the\toks0 \space \appendixletter}%
6186   %
6187   \chapmacro{#1}{Yappendix}{\appendixletter}%
6188   %
6189   \global\let\section = \appendixsec
6190   \global\let\subsection = \appendixsubsec
6191   \global\let\subsubsection = \appendixsubsubsec
6192 }
6193
6194 % normally unnmhead0 calls unnumberedzzz:
6195 \outer\parseargdef\unnumbered{\unnmhead0{#1}}
6196 \def\unnumberedzzz#1{%
6197   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6198     \global\advance\unnumberedno by 1
6199   %
6200   % Since an unnumbered has no number, no prefix for figures.
6201   \global\let\chaplevelprefix = \empty
6202   \resetallfloatnos
6203   %
6204   % This used to be simply \message{#1}, but TeX fully expands the
6205   % argument to \message.  Therefore, if #1 contained @-commands, TeX
6206   % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
6207   % expanded @cite (which turns out to cause errors because \cite is meant
6208   % to be executed, not expanded).
6209   %
6210   % Anyway, we don't want the fully-expanded definition of @cite to appear
6211   % as a result of the \message, we just want `@cite' itself.  We use
6212   % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6213   % simply yielding the contents of <toks register>.  (We also do this for
6214   % the toc entries.)
6215   \toks0 = {#1}%
6216   \message{(\the\toks0)}%
6217   %
6218   \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
6219   %
6220   \global\let\section = \unnumberedsec
6221   \global\let\subsection = \unnumberedsubsec
6222   \global\let\subsubsection = \unnumberedsubsubsec
6223 }
6224
6225 % @centerchap is like @unnumbered, but the heading is centered.
6226 \outer\parseargdef\centerchap{%
6227   \let\centerparametersmaybe = \centerparameters
6228   \unnmhead0{#1}%
6229   \let\centerparametersmaybe = \relax
6230 }
6231
6232 % @top is like @unnumbered.
6233 \let\top\unnumbered
6234
6235 % Sections.
6236 %
6237 \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6238 \def\seczzz#1{%
6239   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6240   \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
6241 }
6242
6243 % normally calls appendixsectionzzz:
6244 \outer\parseargdef\appendixsection{\apphead1{#1}}
6245 \def\appendixsectionzzz#1{%
6246   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6247   \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
6248 }
6249 \let\appendixsec\appendixsection
6250
6251 % normally calls unnumberedseczzz:
6252 \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
6253 \def\unnumberedseczzz#1{%
6254   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6255   \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
6256 }
6257
6258 % Subsections.
6259 %
6260 % normally calls numberedsubseczzz:
6261 \outer\parseargdef\numberedsubsec{\numhead2{#1}}
6262 \def\numberedsubseczzz#1{%
6263   \global\subsubsecno=0  \global\advance\subsecno by 1
6264   \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
6265 }
6266
6267 % normally calls appendixsubseczzz:
6268 \outer\parseargdef\appendixsubsec{\apphead2{#1}}
6269 \def\appendixsubseczzz#1{%
6270   \global\subsubsecno=0  \global\advance\subsecno by 1
6271   \sectionheading{#1}{subsec}{Yappendix}%
6272                  {\appendixletter.\the\secno.\the\subsecno}%
6273 }
6274
6275 % normally calls unnumberedsubseczzz:
6276 \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
6277 \def\unnumberedsubseczzz#1{%
6278   \global\subsubsecno=0  \global\advance\subsecno by 1
6279   \sectionheading{#1}{subsec}{Ynothing}%
6280                  {\the\unnumberedno.\the\secno.\the\subsecno}%
6281 }
6282
6283 % Subsubsections.
6284 %
6285 % normally numberedsubsubseczzz:
6286 \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
6287 \def\numberedsubsubseczzz#1{%
6288   \global\advance\subsubsecno by 1
6289   \sectionheading{#1}{subsubsec}{Ynumbered}%
6290                  {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
6291 }
6292
6293 % normally appendixsubsubseczzz:
6294 \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
6295 \def\appendixsubsubseczzz#1{%
6296   \global\advance\subsubsecno by 1
6297   \sectionheading{#1}{subsubsec}{Yappendix}%
6298                  {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
6299 }
6300
6301 % normally unnumberedsubsubseczzz:
6302 \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
6303 \def\unnumberedsubsubseczzz#1{%
6304   \global\advance\subsubsecno by 1
6305   \sectionheading{#1}{subsubsec}{Ynothing}%
6306                  {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
6307 }
6308
6309 % These macros control what the section commands do, according
6310 % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6311 % Define them by default for a numbered chapter.
6312 \let\section = \numberedsec
6313 \let\subsection = \numberedsubsec
6314 \let\subsubsection = \numberedsubsubsec
6315
6316 % Define @majorheading, @heading and @subheading
6317
6318 \def\majorheading{%
6319   {\advance\chapheadingskip by 10pt \chapbreak }%
6320   \parsearg\chapheadingzzz
6321 }
6322
6323 \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6324 \def\chapheadingzzz#1{%
6325   \vbox{\chapfonts \raggedtitlesettings #1\par}%
6326   \nobreak\bigskip \nobreak
6327   \suppressfirstparagraphindent
6328 }
6329
6330 % @heading, @subheading, @subsubheading.
6331 \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6332   \suppressfirstparagraphindent}
6333 \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6334   \suppressfirstparagraphindent}
6335 \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6336   \suppressfirstparagraphindent}
6337
6338 % These macros generate a chapter, section, etc. heading only
6339 % (including whitespace, linebreaking, etc. around it),
6340 % given all the information in convenient, parsed form.
6341
6342 % Args are the skip and penalty (usually negative)
6343 \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6344
6345 % Parameter controlling skip before chapter headings (if needed)
6346 \newskip\chapheadingskip
6347
6348 % Define plain chapter starts, and page on/off switching for it.
6349 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
6350
6351 % Start a new page
6352 \def\chappager{\par\vfill\supereject}
6353
6354 % \chapoddpage - start on an odd page for a new chapter
6355 % Because \domark is called before \chapoddpage, the filler page will
6356 % get the headings for the next chapter, which is wrong.  But we don't
6357 % care -- we just disable all headings on the filler page.
6358 \def\chapoddpage{%
6359   \chappager
6360   \ifodd\pageno \else
6361     \begingroup
6362       \headingsoff
6363       \null
6364       \chappager
6365     \endgroup
6366   \fi
6367 }
6368
6369 \parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
6370
6371 \def\CHAPPAGoff{%
6372 \global\let\contentsalignmacro = \chappager
6373 \global\let\pchapsepmacro=\chapbreak
6374 \global\def\HEADINGSon{\HEADINGSsinglechapoff}}
6375
6376 \def\CHAPPAGon{%
6377 \global\let\contentsalignmacro = \chappager
6378 \global\let\pchapsepmacro=\chappager
6379 \global\def\HEADINGSon{\HEADINGSsingle}}
6380
6381 \def\CHAPPAGodd{%
6382 \global\let\contentsalignmacro = \chapoddpage
6383 \global\let\pchapsepmacro=\chapoddpage
6384 \global\def\HEADINGSon{\HEADINGSdouble}}
6385
6386 \CHAPPAGon
6387
6388 % \chapmacro - Chapter opening.
6389 %
6390 % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6391 % Yappendix, Yomitfromtoc), #3 the chapter number.
6392 % Not used for @heading series.
6393 %
6394 % To test against our argument.
6395 \def\Ynothingkeyword{Ynothing}
6396 \def\Yappendixkeyword{Yappendix}
6397 \def\Yomitfromtockeyword{Yomitfromtoc}
6398 %
6399 \def\chapmacro#1#2#3{%
6400   \expandafter\ifx\thisenv\titlepage\else
6401     \checkenv{}% chapters, etc., should not start inside an environment.
6402   \fi
6403   % Insert the first mark before the heading break (see notes for \domark).
6404   \let\prevchapterdefs=\currentchapterdefs
6405   \let\prevsectiondefs=\currentsectiondefs
6406   \gdef\currentsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6407                         \gdef\thissection{}}%
6408   %
6409   \def\temptype{#2}%
6410   \ifx\temptype\Ynothingkeyword
6411     \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6412                           \gdef\thischapter{\thischaptername}}%
6413   \else\ifx\temptype\Yomitfromtockeyword
6414     \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6415                           \gdef\thischapter{}}%
6416   \else\ifx\temptype\Yappendixkeyword
6417     \toks0={#1}%
6418     \xdef\currentchapterdefs{%
6419       \gdef\noexpand\thischaptername{\the\toks0}%
6420       \gdef\noexpand\thischapternum{\appendixletter}%
6421       % \noexpand\putwordAppendix avoids expanding indigestible
6422       % commands in some of the translations.
6423       \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
6424                                  \noexpand\thischapternum:
6425                                  \noexpand\thischaptername}%
6426     }%
6427   \else
6428     \toks0={#1}%
6429     \xdef\currentchapterdefs{%
6430       \gdef\noexpand\thischaptername{\the\toks0}%
6431       \gdef\noexpand\thischapternum{\the\chapno}%
6432       % \noexpand\putwordChapter avoids expanding indigestible
6433       % commands in some of the translations.
6434       \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
6435                                  \noexpand\thischapternum:
6436                                  \noexpand\thischaptername}%
6437     }%
6438   \fi\fi\fi
6439   %
6440   % Output the mark.  Pass it through \safewhatsit, to take care of
6441   % the preceding space.
6442   \safewhatsit\domark
6443   %
6444   % Insert the chapter heading break.
6445   \pchapsepmacro
6446   %
6447   % Now the second mark, after the heading break.  No break points
6448   % between here and the heading.
6449   \let\prevchapterdefs=\currentchapterdefs
6450   \let\prevsectiondefs=\currentsectiondefs
6451   \domark
6452   %
6453   {%
6454     \chapfonts \rm
6455     \let\footnote=\errfootnoteheading % give better error message
6456     %
6457     % Have to define \currentsection before calling \donoderef, because the
6458     % xref code eventually uses it.  On the other hand, it has to be called
6459     % after \pchapsepmacro, or the headline will change too soon.
6460     \gdef\currentsection{#1}%
6461     %
6462     % Only insert the separating space if we have a chapter/appendix
6463     % number, and don't print the unnumbered ``number''.
6464     \ifx\temptype\Ynothingkeyword
6465       \setbox0 = \hbox{}%
6466       \def\toctype{unnchap}%
6467     \else\ifx\temptype\Yomitfromtockeyword
6468       \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6469       \def\toctype{omit}%
6470     \else\ifx\temptype\Yappendixkeyword
6471       \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6472       \def\toctype{app}%
6473     \else
6474       \setbox0 = \hbox{#3\enspace}%
6475       \def\toctype{numchap}%
6476     \fi\fi\fi
6477     %
6478     % Write the toc entry for this chapter.  Must come before the
6479     % \donoderef, because we include the current node name in the toc
6480     % entry, and \donoderef resets it to empty.
6481     \writetocentry{\toctype}{#1}{#3}%
6482     %
6483     % For pdftex, we have to write out the node definition (aka, make
6484     % the pdfdest) after any page break, but before the actual text has
6485     % been typeset.  If the destination for the pdf outline is after the
6486     % text, then jumping from the outline may wind up with the text not
6487     % being visible, for instance under high magnification.
6488     \donoderef{#2}%
6489     %
6490     % Typeset the actual heading.
6491     \nobreak % Avoid page breaks at the interline glue.
6492     \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
6493           \unhbox0 #1\par}%
6494   }%
6495   \nobreak\bigskip % no page break after a chapter title
6496   \nobreak
6497 }
6498
6499 % @centerchap -- centered and unnumbered.
6500 \let\centerparametersmaybe = \relax
6501 \def\centerparameters{%
6502   \advance\rightskip by 3\rightskip
6503   \leftskip = \rightskip
6504   \parfillskip = 0pt
6505 }
6506
6507
6508 % Section titles.  These macros combine the section number parts and
6509 % call the generic \sectionheading to do the printing.
6510 %
6511 \newskip\secheadingskip
6512 \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
6513
6514 % Subsection titles.
6515 \newskip\subsecheadingskip
6516 \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
6517
6518 % Subsubsection titles.
6519 \def\subsubsecheadingskip{\subsecheadingskip}
6520 \def\subsubsecheadingbreak{\subsecheadingbreak}
6521
6522
6523 % Print any size, any type, section title.
6524 %
6525 % #1 is the text of the title,
6526 % #2 is the section level (sec/subsec/subsubsec),
6527 % #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6528 % #4 is the section number.
6529 %
6530 \def\seckeyword{sec}
6531 %
6532 \def\sectionheading#1#2#3#4{%
6533   {%
6534     \def\sectionlevel{#2}%
6535     \def\temptype{#3}%
6536     %
6537     % It is ok for the @heading series commands to appear inside an
6538     % environment (it's been historically allowed, though the logic is
6539     % dubious), but not the others.
6540     \ifx\temptype\Yomitfromtockeyword\else
6541       \checkenv{}% non-@*heading should not be in an environment.
6542     \fi
6543     \let\footnote=\errfootnoteheading
6544     %
6545     % Switch to the right set of fonts.
6546     \csname #2fonts\endcsname \rm
6547     %
6548     % Insert first mark before the heading break (see notes for \domark).
6549     \let\prevsectiondefs=\currentsectiondefs
6550     \ifx\temptype\Ynothingkeyword
6551       \ifx\sectionlevel\seckeyword
6552         \gdef\currentsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6553                               \gdef\thissection{\thissectionname}}%
6554       \fi
6555     \else\ifx\temptype\Yomitfromtockeyword
6556       % Don't redefine \thissection.
6557     \else\ifx\temptype\Yappendixkeyword
6558       \ifx\sectionlevel\seckeyword
6559         \toks0={#1}%
6560         \xdef\currentsectiondefs{%
6561           \gdef\noexpand\thissectionname{\the\toks0}%
6562           \gdef\noexpand\thissectionnum{#4}%
6563           % \noexpand\putwordSection avoids expanding indigestible
6564           % commands in some of the translations.
6565           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6566                                      \noexpand\thissectionnum:
6567                                      \noexpand\thissectionname}%
6568         }%
6569       \fi
6570     \else
6571       \ifx\sectionlevel\seckeyword
6572         \toks0={#1}%
6573         \xdef\currentsectiondefs{%
6574           \gdef\noexpand\thissectionname{\the\toks0}%
6575           \gdef\noexpand\thissectionnum{#4}%
6576           % \noexpand\putwordSection avoids expanding indigestible
6577           % commands in some of the translations.
6578           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6579                                      \noexpand\thissectionnum:
6580                                      \noexpand\thissectionname}%
6581         }%
6582       \fi
6583     \fi\fi\fi
6584     %
6585     % Go into vertical mode.  Usually we'll already be there, but we
6586     % don't want the following whatsit to end up in a preceding paragraph
6587     % if the document didn't happen to have a blank line.
6588     \par
6589     %
6590     % Output the mark.  Pass it through \safewhatsit, to take care of
6591     % the preceding space.
6592     \safewhatsit\domark
6593     %
6594     % Insert space above the heading.
6595     \csname #2headingbreak\endcsname
6596     %
6597     % Now the second mark, after the heading break.  No break points
6598     % between here and the heading.
6599     \global\let\prevsectiondefs=\currentsectiondefs
6600     \domark
6601     %
6602     % Only insert the space after the number if we have a section number.
6603     \ifx\temptype\Ynothingkeyword
6604       \setbox0 = \hbox{}%
6605       \def\toctype{unn}%
6606       \gdef\currentsection{#1}%
6607     \else\ifx\temptype\Yomitfromtockeyword
6608       % for @headings -- no section number, don't include in toc,
6609       % and don't redefine \currentsection.
6610       \setbox0 = \hbox{}%
6611       \def\toctype{omit}%
6612       \let\sectionlevel=\empty
6613     \else\ifx\temptype\Yappendixkeyword
6614       \setbox0 = \hbox{#4\enspace}%
6615       \def\toctype{app}%
6616       \gdef\currentsection{#1}%
6617     \else
6618       \setbox0 = \hbox{#4\enspace}%
6619       \def\toctype{num}%
6620       \gdef\currentsection{#1}%
6621     \fi\fi\fi
6622     %
6623     % Write the toc entry (before \donoderef).  See comments in \chapmacro.
6624     \writetocentry{\toctype\sectionlevel}{#1}{#4}%
6625     %
6626     % Write the node reference (= pdf destination for pdftex).
6627     % Again, see comments in \chapmacro.
6628     \donoderef{#3}%
6629     %
6630     % Interline glue will be inserted when the vbox is completed.
6631     % That glue will be a valid breakpoint for the page, since it'll be
6632     % preceded by a whatsit (usually from the \donoderef, or from the
6633     % \writetocentry if there was no node).  We don't want to allow that
6634     % break, since then the whatsits could end up on page n while the
6635     % section is on page n+1, thus toc/etc. are wrong.  Debian bug 276000.
6636     \nobreak
6637     %
6638     % Output the actual section heading.
6639     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
6640           \hangindent=\wd0  % zero if no section number
6641           \unhbox0 #1}%
6642   }%
6643   % Add extra space after the heading -- half of whatever came above it.
6644   % Don't allow stretch, though.
6645   \kern .5 \csname #2headingskip\endcsname
6646   %
6647   % Do not let the kern be a potential breakpoint, as it would be if it
6648   % was followed by glue.
6649   \nobreak
6650   %
6651   % We'll almost certainly start a paragraph next, so don't let that
6652   % glue accumulate.  (Not a breakpoint because it's preceded by a
6653   % discardable item.)  However, when a paragraph is not started next
6654   % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6655   % or the negative glue will cause weirdly wrong output, typically
6656   % obscuring the section heading with something else.
6657   \vskip-\parskip
6658   %
6659   % This is so the last item on the main vertical list is a known
6660   % \penalty > 10000, so \startdefun, etc., can recognize the situation
6661   % and do the needful.
6662   \penalty 10001
6663 }
6664
6665
6666 \message{toc,}
6667 % Table of contents.
6668 \newwrite\tocfile
6669
6670 % Write an entry to the toc file, opening it if necessary.
6671 % Called from @chapter, etc.
6672 %
6673 % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6674 % We append the current node name (if any) and page number as additional
6675 % arguments for the \{chap,sec,...}entry macros which will eventually
6676 % read this.  The node name is used in the pdf outlines as the
6677 % destination to jump to.
6678 %
6679 % We open the .toc file for writing here instead of at @setfilename (or
6680 % any other fixed time) so that @contents can be anywhere in the document.
6681 % But if #1 is `omit', then we don't do anything.  This is used for the
6682 % table of contents chapter openings themselves.
6683 %
6684 \newif\iftocfileopened
6685 \def\omitkeyword{omit}%
6686 %
6687 \def\writetocentry#1#2#3{%
6688   \edef\writetoctype{#1}%
6689   \ifx\writetoctype\omitkeyword \else
6690     \iftocfileopened\else
6691       \immediate\openout\tocfile = \jobname.toc
6692       \global\tocfileopenedtrue
6693     \fi
6694     %
6695     \iflinks
6696       {\atdummies
6697        \edef\temp{%
6698          \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6699        \temp
6700       }%
6701     \fi
6702   \fi
6703   %
6704   % Tell \shipout to create a pdf destination on each page, if we're
6705   % writing pdf.  These are used in the table of contents.  We can't
6706   % just write one on every page because the title pages are numbered
6707   % 1 and 2 (the page numbers aren't printed), and so are the first
6708   % two pages of the document.  Thus, we'd have two destinations named
6709   % `1', and two named `2'.
6710   \ifpdforxetex
6711     \global\pdfmakepagedesttrue
6712   \fi
6713 }
6714
6715
6716 % These characters do not print properly in the Computer Modern roman
6717 % fonts, so we must take special care.  This is more or less redundant
6718 % with the Texinfo input format setup at the end of this file.
6719 %
6720 \def\activecatcodes{%
6721   \catcode`\"=\active
6722   \catcode`\$=\active
6723   \catcode`\<=\active
6724   \catcode`\>=\active
6725   \catcode`\\=\active
6726   \catcode`\^=\active
6727   \catcode`\_=\active
6728   \catcode`\|=\active
6729   \catcode`\~=\active
6730 }
6731
6732
6733 % Read the toc file, which is essentially Texinfo input.
6734 \def\readtocfile{%
6735   \setupdatafile
6736   \activecatcodes
6737   \input \tocreadfilename
6738 }
6739
6740 \newskip\contentsrightmargin \contentsrightmargin=1in
6741 \newcount\savepageno
6742 \newcount\lastnegativepageno \lastnegativepageno = -1
6743
6744 % Prepare to read what we've written to \tocfile.
6745 %
6746 \def\startcontents#1{%
6747   % If @setchapternewpage on, and @headings double, the contents should
6748   % start on an odd page, unlike chapters.
6749   \contentsalignmacro
6750   \immediate\closeout\tocfile
6751   %
6752   % Don't need to put `Contents' or `Short Contents' in the headline.
6753   % It is abundantly clear what they are.
6754   \chapmacro{#1}{Yomitfromtoc}{}%
6755   %
6756   \savepageno = \pageno
6757   \begingroup                  % Set up to handle contents files properly.
6758     \raggedbottom              % Worry more about breakpoints than the bottom.
6759     \entryrightmargin=\contentsrightmargin % Don't use the full line length.
6760     %
6761     % Roman numerals for page numbers.
6762     \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
6763     \def\thistitle{}% no title in double-sided headings
6764     % Record where the Roman numerals started.
6765     \ifnum\romancount=0 \global\romancount=\pagecount \fi
6766 }
6767
6768 % \raggedbottom in plain.tex hardcodes \topskip so override it
6769 \catcode`\@=11
6770 \def\raggedbottom{\advance\topskip by 0pt plus60pt \r@ggedbottomtrue}
6771 \catcode`\@=\other
6772
6773 % redefined for the two-volume lispref.  We always output on
6774 % \jobname.toc even if this is redefined.
6775 %
6776 \def\tocreadfilename{\jobname.toc}
6777
6778 % Normal (long) toc.
6779 %
6780 \def\contents{%
6781   \startcontents{\putwordTOC}%
6782     \openin 1 \tocreadfilename\space
6783     \ifeof 1 \else
6784       \readtocfile
6785     \fi
6786     \vfill \eject
6787     \contentsalignmacro % in case @setchapternewpage odd is in effect
6788     \ifeof 1 \else
6789       \pdfmakeoutlines
6790     \fi
6791     \closein 1
6792   \endgroup
6793   \contentsendroman
6794 }
6795
6796 % And just the chapters.
6797 \def\summarycontents{%
6798   \startcontents{\putwordShortTOC}%
6799     %
6800     \let\partentry = \shortpartentry
6801     \let\numchapentry = \shortchapentry
6802     \let\appentry = \shortchapentry
6803     \let\unnchapentry = \shortunnchapentry
6804     % We want a true roman here for the page numbers.
6805     \secfonts
6806     \let\rm=\shortcontrm \let\bf=\shortcontbf
6807     \let\sl=\shortcontsl \let\tt=\shortconttt
6808     \rm
6809     \hyphenpenalty = 10000
6810     \advance\baselineskip by 1pt % Open it up a little.
6811     \def\numsecentry##1##2##3##4{}
6812     \let\appsecentry = \numsecentry
6813     \let\unnsecentry = \numsecentry
6814     \let\numsubsecentry = \numsecentry
6815     \let\appsubsecentry = \numsecentry
6816     \let\unnsubsecentry = \numsecentry
6817     \let\numsubsubsecentry = \numsecentry
6818     \let\appsubsubsecentry = \numsecentry
6819     \let\unnsubsubsecentry = \numsecentry
6820     \openin 1 \tocreadfilename\space
6821     \ifeof 1 \else
6822       \readtocfile
6823     \fi
6824     \closein 1
6825     \vfill \eject
6826     \contentsalignmacro % in case @setchapternewpage odd is in effect
6827   \endgroup
6828   \contentsendroman
6829 }
6830 \let\shortcontents = \summarycontents
6831
6832 % Get ready to use Arabic numerals again
6833 \def\contentsendroman{%
6834   \lastnegativepageno = \pageno
6835   \global\pageno = \savepageno
6836   %
6837   % If \romancount > \arabiccount, the contents are at the end of the
6838   % document.  Otherwise, advance where the Arabic numerals start for
6839   % the page numbers.
6840   \ifnum\romancount>\arabiccount\else\global\arabiccount=\pagecount\fi
6841 }
6842
6843 % Typeset the label for a chapter or appendix for the short contents.
6844 % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6845 %
6846 \def\shortchaplabel#1{%
6847   % This space should be enough, since a single number is .5em, and the
6848   % widest letter (M) is 1em, at least in the Computer Modern fonts.
6849   % But use \hss just in case.
6850   % (This space doesn't include the extra space that gets added after
6851   % the label; that gets put in by \shortchapentry above.)
6852   %
6853   % We'd like to right-justify chapter numbers, but that looks strange
6854   % with appendix letters.  And right-justifying numbers and
6855   % left-justifying letters looks strange when there is less than 10
6856   % chapters.  Have to read the whole toc once to know how many chapters
6857   % there are before deciding ...
6858   \hbox to 1em{#1\hss}%
6859 }
6860
6861 % These macros generate individual entries in the table of contents.
6862 % The first argument is the chapter or section name.
6863 % The last argument is the page number.
6864 % The arguments in between are the chapter number, section number, ...
6865
6866 % Parts, in the main contents.  Replace the part number, which doesn't
6867 % exist, with an empty box.  Let's hope all the numbers have the same width.
6868 % Also ignore the page number, which is conventionally not printed.
6869 \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6870 \def\partentry#1#2#3#4{%
6871   % Add stretch and a bonus for breaking the page before the part heading.
6872   % This reduces the chance of the page being broken immediately after the
6873   % part heading, before a following chapter heading.
6874   \vskip 0pt plus 5\baselineskip
6875   \penalty-300
6876   \vskip 0pt plus -5\baselineskip
6877   \dochapentry{\numeralbox\labelspace#1}{}%
6878 }
6879 %
6880 % Parts, in the short toc.
6881 \def\shortpartentry#1#2#3#4{%
6882   \penalty-300
6883   \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
6884   \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
6885 }
6886
6887 % Chapters, in the main contents.
6888 \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
6889
6890 % Chapters, in the short toc.
6891 % See comments in \dochapentry re vbox and related settings.
6892 \def\shortchapentry#1#2#3#4{%
6893   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
6894 }
6895
6896 % Appendices, in the main contents.
6897 % Need the word Appendix, and a fixed-size box.
6898 %
6899 \def\appendixbox#1{%
6900   % We use M since it's probably the widest letter.
6901   \setbox0 = \hbox{\putwordAppendix{} M}%
6902   \hbox to \wd0{\putwordAppendix{} #1\hss}}
6903 %
6904 \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
6905
6906 % Unnumbered chapters.
6907 \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
6908 \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
6909
6910 % Sections.
6911 \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
6912 \let\appsecentry=\numsecentry
6913 \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
6914
6915 % Subsections.
6916 \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
6917 \let\appsubsecentry=\numsubsecentry
6918 \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
6919
6920 % And subsubsections.
6921 \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
6922 \let\appsubsubsecentry=\numsubsubsecentry
6923 \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
6924
6925 % This parameter controls the indentation of the various levels.
6926 % Same as \defaultparindent.
6927 \newdimen\tocindent \tocindent = 15pt
6928
6929 % Now for the actual typesetting. In all these, #1 is the text and #2 is the
6930 % page number.
6931 %
6932 % If the toc has to be broken over pages, we want it to be at chapters
6933 % if at all possible; hence the \penalty.
6934 \def\dochapentry#1#2{%
6935    \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
6936    \begingroup
6937      % Move the page numbers slightly to the right
6938      \advance\entryrightmargin by -0.05em
6939      \chapentryfonts
6940      \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6941    \endgroup
6942    \nobreak\vskip .25\baselineskip plus.1\baselineskip
6943 }
6944
6945 \def\dosecentry#1#2{\begingroup
6946   \secentryfonts \leftskip=\tocindent
6947   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6948 \endgroup}
6949
6950 \def\dosubsecentry#1#2{\begingroup
6951   \subsecentryfonts \leftskip=2\tocindent
6952   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6953 \endgroup}
6954
6955 \def\dosubsubsecentry#1#2{\begingroup
6956   \subsubsecentryfonts \leftskip=3\tocindent
6957   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6958 \endgroup}
6959
6960 % We use the same \entry macro as for the index entries.
6961 \let\tocentry = \entry
6962
6963 % Space between chapter (or whatever) number and the title.
6964 \def\labelspace{\hskip1em \relax}
6965
6966 \def\dopageno#1{{\rm #1}}
6967 \def\doshortpageno#1{{\rm #1}}
6968
6969 \def\chapentryfonts{\secfonts \rm}
6970 \def\secentryfonts{\textfonts}
6971 \def\subsecentryfonts{\textfonts}
6972 \def\subsubsecentryfonts{\textfonts}
6973
6974
6975 \message{environments,}
6976 % @foo ... @end foo.
6977
6978 % @tex ... @end tex    escapes into raw TeX temporarily.
6979 % One exception: @ is still an escape character, so that @end tex works.
6980 % But \@ or @@ will get a plain @ character.
6981
6982 \envdef\tex{%
6983   \setregularquotes
6984   \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
6985   \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
6986   \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
6987   \catcode `\%=14
6988   \catcode `\+=\other
6989   \catcode `\"=\other
6990   \catcode `\|=\other
6991   \catcode `\<=\other
6992   \catcode `\>=\other
6993   \catcode `\`=\other
6994   \catcode `\'=\other
6995   %
6996   % ' is active in math mode (mathcode"8000).  So reset it, and all our
6997   % other math active characters (just in case), to plain's definitions.
6998   \mathactive
6999   %
7000   % Inverse of the list at the beginning of the file.
7001   \let\b=\ptexb
7002   \let\bullet=\ptexbullet
7003   \let\c=\ptexc
7004   \let\,=\ptexcomma
7005   \let\.=\ptexdot
7006   \let\dots=\ptexdots
7007   \let\equiv=\ptexequiv
7008   \let\!=\ptexexclam
7009   \let\i=\ptexi
7010   \let\indent=\ptexindent
7011   \let\noindent=\ptexnoindent
7012   \let\{=\ptexlbrace
7013   \let\+=\tabalign
7014   \let\}=\ptexrbrace
7015   \let\/=\ptexslash
7016   \let\sp=\ptexsp
7017   \let\*=\ptexstar
7018   %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
7019   \let\t=\ptext
7020   \expandafter \let\csname top\endcsname=\ptextop  % we've made it outer
7021   \let\frenchspacing=\plainfrenchspacing
7022   %
7023   \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
7024   \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
7025   \def\@{@}%
7026 }
7027 % There is no need to define \Etex.
7028
7029 % Define @lisp ... @end lisp.
7030 % @lisp environment forms a group so it can rebind things,
7031 % including the definition of @end lisp (which normally is erroneous).
7032
7033 % Amount to narrow the margins by for @lisp.
7034 \newskip\lispnarrowing \lispnarrowing=0.4in
7035
7036 % This is the definition that ^^M gets inside @lisp, @example, and other
7037 % such environments.  \null is better than a space, since it doesn't
7038 % have any width.
7039 \def\lisppar{\null\endgraf}
7040
7041 % This space is always present above and below environments.
7042 \newskip\envskipamount \envskipamount = 0pt
7043
7044 % Make spacing and below environment symmetrical.  We use \parskip here
7045 % to help in doing that, since in @example-like environments \parskip
7046 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
7047 % start of the next paragraph will insert \parskip.
7048 %
7049 \def\aboveenvbreak{{%
7050   % =10000 instead of <10000 because of a special case in \itemzzz and
7051   % \sectionheading, q.v.
7052   \ifnum \lastpenalty=10000 \else
7053     \advance\envskipamount by \parskip
7054     \endgraf
7055     \ifdim\lastskip<\envskipamount
7056       \removelastskip
7057       \ifnum\lastpenalty<10000
7058         % Penalize breaking before the environment, because preceding text
7059         % often leads into it.
7060         \penalty100
7061       \fi
7062       \vskip\envskipamount
7063     \fi
7064   \fi
7065 }}
7066
7067 \def\afterenvbreak{{%
7068   % =10000 instead of <10000 because of a special case in \itemzzz and
7069   % \sectionheading, q.v.
7070   \ifnum \lastpenalty=10000 \else
7071     \advance\envskipamount by \parskip
7072     \endgraf
7073     \ifdim\lastskip<\envskipamount
7074       \removelastskip
7075       % it's not a good place to break if the last penalty was \nobreak
7076       % or better ...
7077       \ifnum\lastpenalty<10000 \penalty-50 \fi
7078       \vskip\envskipamount
7079     \fi
7080   \fi
7081 }}
7082
7083 % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins; it will
7084 % also clear it, so that its embedded environments do the narrowing again.
7085 \let\nonarrowing=\relax
7086
7087 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
7088 % environment contents.
7089
7090 %
7091 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
7092 \def\ctr{{\hskip 6pt\circle\char'010}}
7093 \def\cbl{{\circle\char'012\hskip -6pt}}
7094 \def\cbr{{\hskip 6pt\circle\char'011}}
7095 \def\carttop{\hbox to \cartouter{\hskip\lskip
7096         \ctl\leaders\hrule height\circthick\hfil\ctr
7097         \hskip\rskip}}
7098 \def\cartbot{\hbox to \cartouter{\hskip\lskip
7099         \cbl\leaders\hrule height\circthick\hfil\cbr
7100         \hskip\rskip}}
7101 %
7102 \newskip\lskip\newskip\rskip
7103
7104 % only require the font if @cartouche is actually used
7105 \def\cartouchefontdefs{%
7106   \font\circle=lcircle10\relax
7107   \circthick=\fontdimen8\circle
7108 }
7109 \newdimen\circthick
7110 \newdimen\cartouter\newdimen\cartinner
7111 \newskip\normbskip\newskip\normpskip\newskip\normlskip
7112
7113
7114 \envdef\cartouche{%
7115   \cartouchefontdefs
7116   \ifhmode\par\fi  % can't be in the midst of a paragraph.
7117   \startsavinginserts
7118   \lskip=\leftskip \rskip=\rightskip
7119   \leftskip=0pt\rightskip=0pt % we want these *outside*.
7120   \cartinner=\hsize \advance\cartinner by-\lskip
7121   \advance\cartinner by-\rskip
7122   \cartouter=\hsize
7123   \advance\cartouter by 18.4pt  % allow for 3pt kerns on either
7124                                 % side, and for 6pt waste from
7125                                 % each corner char, and rule thickness
7126   \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
7127   %
7128   % If this cartouche directly follows a sectioning command, we need the
7129   % \parskip glue (backspaced over by default) or the cartouche can
7130   % collide with the section heading.
7131   \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
7132   %
7133   \setbox\groupbox=\vtop\bgroup
7134       \baselineskip=0pt\parskip=0pt\lineskip=0pt
7135       \carttop
7136       \hbox\bgroup
7137           \hskip\lskip
7138           \vrule\kern3pt
7139           \vbox\bgroup
7140               \kern3pt
7141               \hsize=\cartinner
7142               \baselineskip=\normbskip
7143               \lineskip=\normlskip
7144               \parskip=\normpskip
7145               \vskip -\parskip
7146               \comment % For explanation, see the end of def\group.
7147 }
7148 \def\Ecartouche{%
7149               \ifhmode\par\fi
7150               \kern3pt
7151           \egroup
7152           \kern3pt\vrule
7153           \hskip\rskip
7154       \egroup
7155       \cartbot
7156   \egroup
7157   \addgroupbox
7158   \checkinserts
7159 }
7160
7161
7162 % This macro is called at the beginning of all the @example variants,
7163 % inside a group.
7164 \newdimen\nonfillparindent
7165 \def\nonfillstart{%
7166   \aboveenvbreak
7167   \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
7168   \sepspaces % Make spaces be word-separators rather than space tokens.
7169   \let\par = \lisppar % don't ignore blank lines
7170   \obeylines % each line of input is a line of output
7171   \parskip = 0pt
7172   % Turn off paragraph indentation but redefine \indent to emulate
7173   % the normal \indent.
7174   \nonfillparindent=\parindent
7175   \parindent = 0pt
7176   \let\indent\nonfillindent
7177   %
7178   \emergencystretch = 0pt % don't try to avoid overfull boxes
7179   \ifx\nonarrowing\relax
7180     \advance \leftskip by \lispnarrowing
7181     \exdentamount=\lispnarrowing
7182   \else
7183     \let\nonarrowing = \relax
7184   \fi
7185   \let\exdent=\nofillexdent
7186 }
7187
7188 \begingroup
7189 \obeyspaces
7190 % We want to swallow spaces (but not other tokens) after the fake
7191 % @indent in our nonfill-environments, where spaces are normally
7192 % active and set to @tie, resulting in them not being ignored after
7193 % @indent.
7194 \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
7195 \gdef\nonfillindentcheck{%
7196 \ifx\temp %
7197 \expandafter\nonfillindentgobble%
7198 \else%
7199 \leavevmode\nonfillindentbox%
7200 \fi%
7201 }%
7202 \endgroup
7203 \def\nonfillindentgobble#1{\nonfillindent}
7204 \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7205
7206 % If you want all examples etc. small: @set dispenvsize small.
7207 % If you want even small examples the full size: @set dispenvsize nosmall.
7208 % This affects the following displayed environments:
7209 %    @example, @display, @format, @lisp, @verbatim
7210 %
7211 \def\smallword{small}
7212 \def\nosmallword{nosmall}
7213 \let\SETdispenvsize\relax
7214 \def\setnormaldispenv{%
7215   \ifx\SETdispenvsize\smallword
7216     % end paragraph for sake of leading, in case document has no blank
7217     % line.  This is redundant with what happens in \aboveenvbreak, but
7218     % we need to do it before changing the fonts, and it's inconvenient
7219     % to change the fonts afterward.
7220     \ifnum \lastpenalty=10000 \else \endgraf \fi
7221     \smallexamplefonts \rm
7222   \fi
7223 }
7224 \def\setsmalldispenv{%
7225   \ifx\SETdispenvsize\nosmallword
7226   \else
7227     \ifnum \lastpenalty=10000 \else \endgraf \fi
7228     \smallexamplefonts \rm
7229   \fi
7230 }
7231
7232 % We often define two environments, @foo and @smallfoo.
7233 % Let's do it in one command.  #1 is the env name, #2 the definition.
7234 \def\makedispenvdef#1#2{%
7235   \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7236   \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
7237   \expandafter\let\csname E#1\endcsname \afterenvbreak
7238   \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
7239 }
7240
7241 % Define two environment synonyms (#1 and #2) for an environment.
7242 \def\maketwodispenvdef#1#2#3{%
7243   \makedispenvdef{#1}{#3}%
7244   \makedispenvdef{#2}{#3}%
7245 }
7246 %
7247 % @lisp: indented, narrowed, typewriter font;
7248 % @example: same as @lisp.
7249 %
7250 % @smallexample and @smalllisp: use smaller fonts.
7251 % Originally contributed by Pavel@xerox.
7252 %
7253 \maketwodispenvdef{lisp}{example}{%
7254   \nonfillstart
7255   \tt\setcodequotes
7256   \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
7257   \parsearg\gobble
7258 }
7259 % @display/@smalldisplay: same as @lisp except keep current font.
7260 %
7261 \makedispenvdef{display}{%
7262   \nonfillstart
7263   \gobble
7264 }
7265
7266 % @format/@smallformat: same as @display except don't narrow margins.
7267 %
7268 \makedispenvdef{format}{%
7269   \let\nonarrowing = t%
7270   \nonfillstart
7271   \gobble
7272 }
7273
7274 % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7275 \envdef\flushleft{%
7276   \let\nonarrowing = t%
7277   \nonfillstart
7278   \gobble
7279 }
7280 \let\Eflushleft = \afterenvbreak
7281
7282 % @flushright.
7283 %
7284 \envdef\flushright{%
7285   \let\nonarrowing = t%
7286   \nonfillstart
7287   \advance\leftskip by 0pt plus 1fill\relax
7288   \gobble
7289 }
7290 \let\Eflushright = \afterenvbreak
7291
7292
7293 % @raggedright does more-or-less normal line breaking but no right
7294 % justification.  From plain.tex.
7295 \envdef\raggedright{%
7296   \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7297 }
7298 \let\Eraggedright\par
7299
7300
7301 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
7302 % and narrows the margins.  We keep \parskip nonzero in general, since
7303 % we're doing normal filling.  So, when using \aboveenvbreak and
7304 % \afterenvbreak, temporarily make \parskip 0.
7305 %
7306 \makedispenvdef{quotation}{\quotationstart}
7307 %
7308 \def\quotationstart{%
7309   \indentedblockstart % same as \indentedblock, but increase right margin too.
7310   \ifx\nonarrowing\relax
7311     \advance\rightskip by \lispnarrowing
7312   \fi
7313   \parsearg\quotationlabel
7314 }
7315
7316 % We have retained a nonzero parskip for the environment, since we're
7317 % doing normal filling.
7318 %
7319 \def\Equotation{%
7320   \par
7321   \ifx\quotationauthor\thisisundefined\else
7322     % indent a bit.
7323     \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7324   \fi
7325   {\parskip=0pt \afterenvbreak}%
7326 }
7327 \def\Esmallquotation{\Equotation}
7328
7329 % If we're given an argument, typeset it in bold with a colon after.
7330 \def\quotationlabel#1{%
7331   \def\temp{#1}%
7332   \ifx\temp\empty \else
7333     {\bf #1: }%
7334   \fi
7335 }
7336
7337 % @indentedblock is like @quotation, but indents only on the left and
7338 % has no optional argument.
7339 %
7340 \makedispenvdef{indentedblock}{\indentedblockstart}
7341 %
7342 \def\indentedblockstart{%
7343   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7344   \parindent=0pt
7345   %
7346   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7347   \ifx\nonarrowing\relax
7348     \advance\leftskip by \lispnarrowing
7349     \exdentamount = \lispnarrowing
7350   \else
7351     \let\nonarrowing = \relax
7352   \fi
7353 }
7354
7355 % Keep a nonzero parskip for the environment, since we're doing normal filling.
7356 %
7357 \def\Eindentedblock{%
7358   \par
7359   {\parskip=0pt \afterenvbreak}%
7360 }
7361 \def\Esmallindentedblock{\Eindentedblock}
7362
7363
7364 % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7365 % If we want to allow any <char> as delimiter,
7366 % we need the curly braces so that makeinfo sees the @verb command, eg:
7367 % `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
7368 %
7369 % [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
7370 %
7371 % [Knuth] p.344; only we need to do the other characters Texinfo sets
7372 % active too.  Otherwise, they get lost as the first character on a
7373 % verbatim line.
7374 \def\dospecials{%
7375   \do\ \do\\\do\{\do\}\do\$\do\&%
7376   \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7377   \do\<\do\>\do\|\do\@\do+\do\"%
7378   % Don't do the quotes -- if we do, @set txicodequoteundirected and
7379   % @set txicodequotebacktick will not have effect on @verb and
7380   % @verbatim, and ?` and !` ligatures won't get disabled.
7381   %\do\`\do\'%
7382 }
7383 %
7384 % [Knuth] p. 380
7385 \def\uncatcodespecials{%
7386   \def\do##1{\catcode`##1=\other}\dospecials}
7387 %
7388 % Setup for the @verb command.
7389 %
7390 % Eight spaces for a tab
7391 \begingroup
7392   \catcode`\^^I=\active
7393   \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7394 \endgroup
7395 %
7396 \def\setupverb{%
7397   \tt  % easiest (and conventionally used) font for verbatim
7398   \def\par{\leavevmode\endgraf}%
7399   \setcodequotes
7400   \tabeightspaces
7401   % Respect line breaks,
7402   % print special symbols as themselves, and
7403   % make each space count
7404   % must do in this order:
7405   \obeylines \uncatcodespecials \sepspaces
7406 }
7407
7408 % Setup for the @verbatim environment
7409 %
7410 % Real tab expansion.
7411 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7412 %
7413 % We typeset each line of the verbatim in an \hbox, so we can handle
7414 % tabs.
7415 \newbox\verbbox
7416 \def\starttabbox{\setbox\verbbox=\hbox\bgroup}
7417 %
7418 \begingroup
7419   \catcode`\^^I=\active
7420   \gdef\tabexpand{%
7421     \catcode`\^^I=\active
7422     \def^^I{\leavevmode\egroup
7423       \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7424       \divide\dimen\verbbox by\tabw
7425       \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7426       \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
7427       \wd\verbbox=\dimen\verbbox
7428       \leavevmode\box\verbbox \starttabbox
7429     }%
7430   }
7431 \endgroup
7432
7433 % start the verbatim environment.
7434 \def\setupverbatim{%
7435   \let\nonarrowing = t%
7436   \nonfillstart
7437   \tt % easiest (and conventionally used) font for verbatim
7438   \def\par{\egroup\leavevmode\box\verbbox\endgraf\starttabbox}%
7439   \tabexpand
7440   \setcodequotes
7441   % Respect line breaks,
7442   % print special symbols as themselves, and
7443   % make each space count.
7444   % Must do in this order:
7445   \obeylines \uncatcodespecials \sepspaces
7446 }
7447
7448 % Do the @verb magic: verbatim text is quoted by unique
7449 % delimiter characters.  Before first delimiter expect a
7450 % right brace, after last delimiter expect closing brace:
7451 %
7452 %    \def\doverb'{'<char>#1<char>'}'{#1}
7453 %
7454 % [Knuth] p. 382; only eat outer {}
7455 \begingroup
7456   \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
7457   \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7458 \endgroup
7459 %
7460 \def\verb{\begingroup\setupverb\doverb}
7461 %
7462 %
7463 % Do the @verbatim magic: define the macro \doverbatim so that
7464 % the (first) argument ends when '@end verbatim' is reached, ie:
7465 %
7466 %     \def\doverbatim#1@end verbatim{#1}
7467 %
7468 % For Texinfo it's a lot easier than for LaTeX,
7469 % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
7470 % we need not redefine '\', '{' and '}'.
7471 %
7472 % Inspired by LaTeX's verbatim command set [latex.ltx]
7473 %
7474 \begingroup
7475   \catcode`\ =\active
7476   \obeylines %
7477   % ignore everything up to the first ^^M, that's the newline at the end
7478   % of the @verbatim input line itself.  Otherwise we get an extra blank
7479   % line in the output.
7480   \xdef\doverbatim#1^^M#2@end verbatim{%
7481     \starttabbox#2\egroup\noexpand\end\gobble verbatim}%
7482   % We really want {...\end verbatim} in the body of the macro, but
7483   % without the active space; thus we have to use \xdef and \gobble.
7484   % The \egroup ends the \verbbox started at the end of the last line in
7485   % the block.
7486 \endgroup
7487 %
7488 \envdef\verbatim{%
7489     \setnormaldispenv\setupverbatim\doverbatim
7490 }
7491 \let\Everbatim = \afterenvbreak
7492
7493
7494 % @verbatiminclude FILE - insert text of file in verbatim environment.
7495 %
7496 \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
7497 %
7498 \def\doverbatiminclude#1{%
7499   {%
7500     \makevalueexpandable
7501     \setupverbatim
7502     {%
7503       \indexnofonts       % Allow `@@' and other weird things in file names.
7504       \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
7505       \edef\tmp{\noexpand\input #1 }
7506       \expandafter
7507     }\expandafter\starttabbox\tmp\egroup
7508     \afterenvbreak
7509   }%
7510 }
7511
7512 % @copying ... @end copying.
7513 % Save the text away for @insertcopying later.
7514 %
7515 % We save the uninterpreted tokens, rather than creating a box.
7516 % Saving the text in a box would be much easier, but then all the
7517 % typesetting commands (@smallbook, font changes, etc.) have to be done
7518 % beforehand -- and a) we want @copying to be done first in the source
7519 % file; b) letting users define the frontmatter in as flexible order as
7520 % possible is desirable.
7521 %
7522 \def\copying{\checkenv{}\begingroup\macrobodyctxt\docopying}
7523 {\catcode`\ =\other
7524 \gdef\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
7525 }
7526
7527 \def\insertcopying{%
7528   \begingroup
7529     \parindent = 0pt  % paragraph indentation looks wrong on title page
7530     \scanexp\copyingtext
7531   \endgroup
7532 }
7533
7534
7535 \message{defuns,}
7536 % @defun etc.
7537
7538 \newskip\defbodyindent \defbodyindent=.4in
7539 \newskip\defargsindent \defargsindent=50pt
7540 \newskip\deflastargmargin \deflastargmargin=18pt
7541 \newcount\defunpenalty
7542
7543 % Start the processing of @deffn:
7544 \def\startdefun{%
7545   \ifnum\lastpenalty<10000
7546     \medbreak
7547     \defunpenalty=10003 % Will keep this @deffn together with the
7548                         % following @def command, see below.
7549   \else
7550     % If there are two @def commands in a row, we'll have a \nobreak,
7551     % which is there to keep the function description together with its
7552     % header.  But if there's nothing but headers, we need to allow a
7553     % break somewhere.  Check specifically for penalty 10002, inserted
7554     % by \printdefunline, instead of 10000, since the sectioning
7555     % commands also insert a nobreak penalty, and we don't want to allow
7556     % a break between a section heading and a defun.
7557     %
7558     % As a further refinement, we avoid "club" headers by signalling
7559     % with penalty of 10003 after the very first @deffn in the
7560     % sequence (see above), and penalty of 10002 after any following
7561     % @def command.
7562     \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
7563     %
7564     % Similarly, after a section heading, do not allow a break.
7565     % But do insert the glue.
7566     \medskip  % preceded by discardable penalty, so not a breakpoint
7567   \fi
7568   %
7569   \parindent=0in
7570   \advance\leftskip by \defbodyindent
7571   \exdentamount=\defbodyindent
7572 }
7573
7574 \def\dodefunx#1{%
7575   % First, check whether we are in the right environment:
7576   \checkenv#1%
7577   %
7578   % As above, allow line break if we have multiple x headers in a row.
7579   % It's not a great place, though.
7580   \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
7581   %
7582   % And now, it's time to reuse the body of the original defun:
7583   \expandafter\gobbledefun#1%
7584 }
7585 \def\gobbledefun#1\startdefun{}
7586
7587 % \printdefunline \deffnheader{text}
7588 %
7589 \def\printdefunline#1#2{%
7590   \begingroup
7591     \plainfrenchspacing
7592     % call \deffnheader:
7593     #1#2 \endheader
7594     % common ending:
7595     \interlinepenalty = 10000
7596     \advance\rightskip by 0pt plus 1fil\relax
7597     \endgraf
7598     \nobreak\vskip -\parskip
7599     \penalty\defunpenalty  % signal to \startdefun and \dodefunx
7600     % Some of the @defun-type tags do not enable magic parentheses,
7601     % rendering the following check redundant.  But we don't optimize.
7602     \checkparencounts
7603   \endgroup
7604 }
7605
7606 \def\Edefun{\endgraf\medbreak}
7607
7608 % \makedefun{deffoo}{ (definition of \deffooheader) }
7609 %
7610 % Define \deffoo, \deffoox  \Edeffoo and \deffooheader.
7611 \def\makedefun#1{%
7612   \expandafter\let\csname E#1\endcsname = \Edefun
7613   \edef\temp{\noexpand\domakedefun
7614     \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7615   \temp
7616 }
7617 \def\domakedefun#1#2#3{%
7618   \envdef#1{%
7619     \startdefun
7620     \doingtypefnfalse    % distinguish typed functions from all else
7621     \parseargusing\activeparens{\printdefunline#3}%
7622   }%
7623   \def#2{\dodefunx#1}%
7624   \def#3%
7625 }
7626
7627 \newif\ifdoingtypefn       % doing typed function?
7628 \newif\ifrettypeownline    % typeset return type on its own line?
7629
7630 % @deftypefnnewline on|off says whether the return type of typed functions
7631 % are printed on their own line.  This affects @deftypefn, @deftypefun,
7632 % @deftypeop, and @deftypemethod.
7633 %
7634 \parseargdef\deftypefnnewline{%
7635   \def\temp{#1}%
7636   \ifx\temp\onword
7637     \expandafter\let\csname SETtxideftypefnnl\endcsname
7638       = \empty
7639   \else\ifx\temp\offword
7640     \expandafter\let\csname SETtxideftypefnnl\endcsname
7641       = \relax
7642   \else
7643     \errhelp = \EMsimple
7644     \errmessage{Unknown @txideftypefnnl value `\temp',
7645                 must be on|off}%
7646   \fi\fi
7647 }
7648
7649 % Untyped functions:
7650
7651 % @deffn category name args
7652 \makedefun{deffn}#1 #2 #3\endheader{%
7653   \doind{fn}{\code{#2}}%
7654   \defname{#1}{}{#2}\magicamp\defunargs{#3\unskip}%
7655 }
7656
7657 % @defop category class name args
7658 \makedefun{defop}#1 {\defopheaderx{#1\ \putwordon}}
7659 \def\defopheaderx#1#2 #3 #4\endheader{%
7660   \doind{fn}{\code{#3}\space\putwordon\ \code{#2}}%
7661   \defname{#1\ \code{#2}}{}{#3}\magicamp\defunargs{#4\unskip}%
7662 }
7663
7664 % Typed functions:
7665
7666 % @deftypefn category type name args
7667 \makedefun{deftypefn}#1 #2 #3 #4\endheader{%
7668   \doind{fn}{\code{#3}}%
7669   \doingtypefntrue
7670   \defname{#1}{#2}{#3}\defunargs{#4\unskip}%
7671 }
7672
7673 % @deftypeop category class type name args
7674 \makedefun{deftypeop}#1 {\deftypeopheaderx{#1\ \putwordon}}
7675 \def\deftypeopheaderx#1#2 #3 #4 #5\endheader{%
7676   \doind{fn}{\code{#4}\space\putwordon\ \code{#1\ \code{#2}}}%
7677   \doingtypefntrue
7678   \defname{#1\ \code{#2}}{#3}{#4}\defunargs{#5\unskip}%
7679 }
7680
7681 % Typed variables:
7682
7683 % @deftypevr category type var args
7684 \makedefun{deftypevr}#1 #2 #3 #4\endheader{%
7685   \doind{vr}{\code{#3}}%
7686   \defname{#1}{#2}{#3}\defunargs{#4\unskip}%
7687 }
7688
7689 % @deftypecv category class type var args
7690 \makedefun{deftypecv}#1 {\deftypecvheaderx{#1\ \putwordof}}
7691 \def\deftypecvheaderx#1#2 #3 #4 #5\endheader{%
7692   \doind{vr}{\code{#4}\space\putwordof\ \code{#2}}%
7693   \defname{#1\ \code{#2}}{#3}{#4}\defunargs{#5\unskip}%
7694 }
7695
7696 % Untyped variables:
7697
7698 % @defvr category var args
7699 \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
7700
7701 % @defcv category class var args
7702 \makedefun{defcv}#1 {\defcvheaderx{#1\ \putwordof}}
7703 \def\defcvheaderx#1#2 {\deftypecvheaderx{#1}#2 {} }
7704
7705 % Types:
7706
7707 % @deftp category name args
7708 \makedefun{deftp}#1 #2 #3\endheader{%
7709   \doind{tp}{\code{#2}}%
7710   \defname{#1}{}{#2}\defunargs{#3\unskip}%
7711 }
7712
7713 % Remaining @defun-like shortcuts:
7714 \makedefun{defun}{\deffnheader{\putwordDeffunc} }
7715 \makedefun{defmac}{\deffnheader{\putwordDefmac} }
7716 \makedefun{defspec}{\deffnheader{\putwordDefspec} }
7717 \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7718 \makedefun{defvar}{\defvrheader{\putwordDefvar} }
7719 \makedefun{defopt}{\defvrheader{\putwordDefopt} }
7720 \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
7721 \makedefun{defmethod}{\defopheaderx\putwordMethodon}
7722 \makedefun{deftypemethod}{\deftypeopheaderx\putwordMethodon}
7723 \makedefun{defivar}{\defcvheaderx\putwordInstanceVariableof}
7724 \makedefun{deftypeivar}{\deftypecvheaderx\putwordInstanceVariableof}
7725
7726 % \defname, which formats the name of the @def (not the args).
7727 % #1 is the category, such as "Function".
7728 % #2 is the return type, if any.
7729 % #3 is the function name.
7730 %
7731 % We are followed by (but not passed) the arguments, if any.
7732 %
7733 \def\defname#1#2#3{%
7734   \par
7735   % Get the values of \leftskip and \rightskip as they were outside the @def...
7736   \advance\leftskip by -\defbodyindent
7737   %
7738   % Determine if we are typesetting the return type of a typed function
7739   % on a line by itself.
7740   \rettypeownlinefalse
7741   \ifdoingtypefn  % doing a typed function specifically?
7742     % then check user option for putting return type on its own line:
7743     \ifflagclear{txideftypefnnl}{}{\rettypeownlinetrue}%
7744   \fi
7745   %
7746   % How we'll format the category name.  Putting it in brackets helps
7747   % distinguish it from the body text that may end up on the next line
7748   % just below it.
7749   \def\temp{#1}%
7750   \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7751   %
7752   % Figure out line sizes for the paragraph shape.  We'll always have at
7753   % least two.
7754   \tempnum = 2
7755   %
7756   % The first line needs space for \box0; but if \rightskip is nonzero,
7757   % we need only space for the part of \box0 which exceeds it:
7758   \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
7759   %
7760   % If doing a return type on its own line, we'll have another line.
7761   \ifrettypeownline
7762     \advance\tempnum by 1
7763     \def\maybeshapeline{0in \hsize}%
7764   \else
7765     \def\maybeshapeline{}%
7766   \fi
7767   %
7768   % The continuations:
7769   \dimen2=\hsize  \advance\dimen2 by -\defargsindent
7770   %
7771   % The final paragraph shape:
7772   \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
7773   %
7774   % Put the category name at the right margin.
7775   \noindent
7776   \hbox to 0pt{%
7777     \hfil\box0 \kern-\hsize
7778     % \hsize has to be shortened this way:
7779     \kern\leftskip
7780     % Intentionally do not respect \rightskip, since we need the space.
7781   }%
7782   %
7783   % Allow all lines to be underfull without complaint:
7784   \tolerance=10000 \hbadness=10000
7785   \exdentamount=\defbodyindent
7786   {%
7787     % defun fonts. We use typewriter by default (used to be bold) because:
7788     % . we're printing identifiers, they should be in tt in principle.
7789     % . in languages with many accents, such as Czech or French, it's
7790     %   common to leave accents off identifiers.  The result looks ok in
7791     %   tt, but exceedingly strange in rm.
7792     % . we don't want -- and --- to be treated as ligatures.
7793     % . this still does not fix the ?` and !` ligatures, but so far no
7794     %   one has made identifiers using them :).
7795     \df \tt
7796     \def\temp{#2}% text of the return type
7797     \ifx\temp\empty\else
7798       \tclose{\temp}% typeset the return type
7799       \ifrettypeownline
7800         % put return type on its own line; prohibit line break following:
7801         \hfil\vadjust{\nobreak}\break
7802       \else
7803         \space  % type on same line, so just followed by a space
7804       \fi
7805     \fi           % no return type
7806     #3% output function name
7807   }%
7808   \ifflagclear{txidefnamenospace}{%
7809     {\rm\enskip}% hskip 0.5 em of \rmfont
7810   }{}%
7811   %
7812   \boldbrax
7813   % arguments will be output next, if any.
7814 }
7815
7816 % Print arguments.  Use slanted for @def*, typewriter for @deftype*.
7817 \def\defunargs#1{%
7818   \df \ifdoingtypefn \tt \else \sl \fi
7819   \ifflagclear{txicodevaristt}{}%
7820     {\def\var##1{{\setregularquotes \ttsl ##1}}}%
7821   #1%
7822 }
7823
7824 % We want ()&[] to print specially on the defun line.
7825 %
7826 \def\activeparens{%
7827   \catcode`\(=\active \catcode`\)=\active
7828   \catcode`\[=\active \catcode`\]=\active
7829   \catcode`\&=\active
7830 }
7831
7832 % Make control sequences which act like normal parenthesis chars.
7833 \let\lparen = ( \let\rparen = )
7834
7835 % Be sure that we always have a definition for `(', etc.  For example,
7836 % if the fn name has parens in it, \boldbrax will not be in effect yet,
7837 % so TeX would otherwise complain about undefined control sequence.
7838 {
7839   \activeparens
7840   \gdef\defcharsdefault{%
7841     \let(=\lparen \let)=\rparen
7842     \let[=\lbrack \let]=\rbrack
7843     \let& = \&%
7844   }
7845   \globaldefs=1 \defcharsdefault
7846
7847   \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
7848   \gdef\magicamp{\let&=\amprm}
7849 }
7850 \let\ampchar\&
7851
7852 \newcount\parencount
7853
7854 % If we encounter &foo, then turn on ()-hacking afterwards
7855 \newif\ifampseen
7856 \def\amprm#1 {\ampseentrue{\bf\&#1 }}
7857
7858 \def\parenfont{%
7859   \ifampseen
7860     % At the first level, print parens in roman,
7861     % otherwise use the default font.
7862     \ifnum \parencount=1 \rm \fi
7863   \else
7864     % The \sf parens (in \boldbrax) actually are a little bolder than
7865     % the contained text.  This is especially needed for [ and ] .
7866     \sf
7867   \fi
7868 }
7869 \def\infirstlevel#1{%
7870   \ifampseen
7871     \ifnum\parencount=1
7872       #1%
7873     \fi
7874   \fi
7875 }
7876 \def\bfafterword#1 {#1 \bf}
7877
7878 \def\opnr{%
7879   \global\advance\parencount by 1
7880   {\parenfont(}%
7881   \infirstlevel \bfafterword
7882 }
7883 \def\clnr{%
7884   {\parenfont)}%
7885   \infirstlevel \sl
7886   \global\advance\parencount by -1
7887 }
7888
7889 \newcount\brackcount
7890 \def\lbrb{%
7891   \global\advance\brackcount by 1
7892   {\bf[}%
7893 }
7894 \def\rbrb{%
7895   {\bf]}%
7896   \global\advance\brackcount by -1
7897 }
7898
7899 \def\checkparencounts{%
7900   \ifnum\parencount=0 \else \badparencount \fi
7901   \ifnum\brackcount=0 \else \badbrackcount \fi
7902 }
7903 % these should not use \errmessage; the glibc manual, at least, actually
7904 % has such constructs (when documenting function pointers).
7905 \def\badparencount{%
7906   \message{Warning: unbalanced parentheses in @def...}%
7907   \global\parencount=0
7908 }
7909 \def\badbrackcount{%
7910   \message{Warning: unbalanced square brackets in @def...}%
7911   \global\brackcount=0
7912 }
7913
7914
7915 \message{macros,}
7916 % @macro.
7917
7918 % To do this right we need a feature of e-TeX, \scantokens,
7919 % which we arrange to emulate with a temporary file in ordinary TeX.
7920 \ifx\eTeXversion\thisisundefined
7921   \newwrite\macscribble
7922   \def\scantokens#1{%
7923     \toks0={#1}%
7924     \immediate\openout\macscribble=\jobname.tmp
7925     \immediate\write\macscribble{\the\toks0}%
7926     \immediate\closeout\macscribble
7927     \input \jobname.tmp
7928   }
7929 \fi
7930
7931 \let\E=\expandafter
7932
7933 % Used at the time of macro expansion.
7934 % Argument is macro body with arguments substituted
7935 \def\scanmacro#1{%
7936   \newlinechar`\^^M
7937   % expand the expansion of \eatleadingcr twice to maybe remove a leading
7938   % newline (and \else and \fi tokens), then call \eatspaces on the result.
7939   \def\xeatspaces##1{%
7940     \E\E\E\E\E\E\E\eatspaces\E\E\E\E\E\E\E{\eatleadingcr##1%
7941   }}%
7942   \def\xempty##1{}%
7943   %
7944   % Process the macro body under the current catcode regime.
7945   \scantokens{#1@comment}%
7946   %
7947   % The \comment is to remove the \newlinechar added by \scantokens, and
7948   % can be noticed by \parsearg.  Note \c isn't used because this means cedilla
7949   % in math mode.
7950 }
7951
7952 % Used for copying and captions
7953 \def\scanexp#1{%
7954   \expandafter\scanmacro\expandafter{#1}%
7955 }
7956
7957 \newcount\paramno   % Count of parameters
7958 \newtoks\macname    % Macro name
7959 \newif\ifrecursive  % Is it recursive?
7960
7961 % List of all defined macros in the form
7962 %    \commondummyword\macro1\commondummyword\macro2...
7963 % Currently is also contains all @aliases; the list can be split
7964 % if there is a need.
7965 \def\macrolist{}
7966
7967 % Add the macro to \macrolist
7968 \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
7969 \def\addtomacrolistxxx#1{%
7970      \toks0 = \expandafter{\macrolist\commondummyword#1}%
7971      \xdef\macrolist{\the\toks0}%
7972 }
7973
7974 % Utility routines.
7975 % This does \let #1 = #2, with \csnames; that is,
7976 %   \let \csname#1\endcsname = \csname#2\endcsname
7977 % (except of course we have to play expansion games).
7978 %
7979 \def\cslet#1#2{%
7980   \expandafter\let
7981   \csname#1\expandafter\endcsname
7982   \csname#2\endcsname
7983 }
7984
7985 % Trim leading and trailing spaces off a string.
7986 % Concepts from aro-bend problem 15 (see CTAN).
7987 {\catcode`\@=11
7988 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
7989 \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
7990 \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
7991 \def\unbrace#1{#1}
7992 \unbrace{\gdef\trim@@@ #1 } #2@{#1}
7993 }
7994
7995 {\catcode`\^^M=\other%
7996 \gdef\eatleadingcr#1{\if\noexpand#1\noexpand^^M\else\E#1\fi}}%
7997 % Warning: this won't work for a delimited argument
7998 % or for an empty argument
7999
8000 % Trim a single trailing ^^M off a string.
8001 {\catcode`\^^M=\other \catcode`\Q=3%
8002 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
8003 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
8004 \gdef\eatcrb#1Q#2Q{#1}%
8005 }
8006
8007 % Macro bodies are absorbed as an argument in a context where
8008 % all characters are catcode 10, 11 or 12, except \ which is active
8009 % (as in normal texinfo). It is necessary to change the definition of \
8010 % to recognize macro arguments; this is the job of \mbodybackslash.
8011 %
8012 % Non-ASCII encodings make 8-bit characters active, so un-activate
8013 % them to avoid their expansion.  Must do this non-globally, to
8014 % confine the change to the current group.
8015 %
8016 % It's necessary to have hard CRs when the macro is executed. This is
8017 % done by making ^^M (\endlinechar) catcode 12 when reading the macro
8018 % body, and then making it the \newlinechar in \scanmacro.
8019 %
8020 \def\scanctxt{% used as subroutine
8021   \catcode`\"=\other
8022   \catcode`\+=\other
8023   \catcode`\<=\other
8024   \catcode`\>=\other
8025   \catcode`\^=\other
8026   \catcode`\_=\other
8027   \catcode`\|=\other
8028   \catcode`\~=\other
8029   \catcode`\@=\other
8030   \catcode`\^^M=\other
8031   \catcode`\\=\active
8032   \passthroughcharstrue
8033 }
8034
8035 \def\macrobodyctxt{% used for @macro definitions and @copying
8036   \scanctxt
8037   \catcode`\ =\other
8038   \catcode`\{=\other
8039   \catcode`\}=\other
8040 }
8041
8042 % Used when scanning braced macro arguments.  Note, however, that catcode
8043 % changes here are ineffectual if the macro invocation was nested inside
8044 % an argument to another Texinfo command.
8045 \def\macroargctxt{%
8046   \scanctxt
8047   \catcode`\ =\active
8048 }
8049
8050 \def\macrolineargctxt{% used for whole-line arguments without braces
8051   \scanctxt
8052   \catcode`\{=\other
8053   \catcode`\}=\other
8054 }
8055
8056 % \mbodybackslash is the definition of \ in @macro bodies.
8057 % It maps \foo\ => \csname macarg.foo\endcsname => #N
8058 % where N is the macro parameter number.
8059 % We define \csname macarg.\endcsname to be \realbackslash, so
8060 % \\ in macro replacement text gets you a backslash.
8061 %
8062 {\catcode`@=0 @catcode`@\=@active
8063  @gdef@usembodybackslash{@let\=@mbodybackslash}
8064  @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
8065 }
8066 \expandafter\def\csname macarg.\endcsname{\realbackslash}
8067
8068 \def\margbackslash#1{\char`\#1 }
8069
8070 \def\macro{\recursivefalse\parsearg\macroxxx}
8071 \def\rmacro{\recursivetrue\parsearg\macroxxx}
8072
8073 \def\macroxxx#1{%
8074   \getargs{#1}% now \macname is the macname and \argl the arglist
8075   \ifx\argl\empty       % no arguments
8076      \paramno=0\relax
8077   \else
8078      \expandafter\parsemargdef \argl;%
8079      \if\paramno>256\relax
8080        \ifx\eTeXversion\thisisundefined
8081          \errhelp = \EMsimple
8082          \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
8083        \fi
8084      \fi
8085   \fi
8086   \if1\csname ismacro.\the\macname\endcsname
8087      \message{Warning: redefining \the\macname}%
8088   \else
8089      \expandafter\ifx\csname \the\macname\endcsname \relax
8090      \else \errmessage{Macro name \the\macname\space already defined}\fi
8091      \global\cslet{macsave.\the\macname}{\the\macname}%
8092      \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
8093      \addtomacrolist{\the\macname}%
8094   \fi
8095   \begingroup \macrobodyctxt \usembodybackslash
8096   \ifrecursive \expandafter\parsermacbody
8097   \else \expandafter\parsemacbody
8098   \fi}
8099
8100 \parseargdef\unmacro{%
8101   \if1\csname ismacro.#1\endcsname
8102     \global\cslet{#1}{macsave.#1}%
8103     \global\expandafter\let \csname ismacro.#1\endcsname=0%
8104     % Remove the macro name from \macrolist:
8105     \begingroup
8106       \expandafter\let\csname#1\endcsname \relax
8107       \let\commondummyword\unmacrodo
8108       \xdef\macrolist{\macrolist}%
8109     \endgroup
8110   \else
8111     \errmessage{Macro #1 not defined}%
8112   \fi
8113 }
8114
8115 % Called by \do from \dounmacro on each macro.  The idea is to omit any
8116 % macro definitions that have been changed to \relax.
8117 %
8118 \def\unmacrodo#1{%
8119   \ifx #1\relax
8120     % remove this
8121   \else
8122     \noexpand\commondummyword \noexpand#1%
8123   \fi
8124 }
8125
8126 % \getargs -- Parse the arguments to a @macro line.  Set \macname to
8127 % the name of the macro, and \argl to the braced argument list.
8128 \def\getargs#1{\getargsxxx#1{}}
8129 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
8130 \def\getmacname#1 #2\relax{\macname={#1}}
8131 \def\getmacargs#1{\def\argl{#1}}
8132 % This made use of the feature that if the last token of a
8133 % <parameter list> is #, then the preceding argument is delimited by
8134 % an opening brace, and that opening brace is not consumed.
8135
8136 % Parse the optional {params} list to @macro or @rmacro.
8137 % Set \paramno to the number of arguments,
8138 % and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
8139 % three-param macro.)  Define \macarg.BLAH for each BLAH in the params
8140 % list to some hook where the argument is to be expanded.  If there are
8141 % less than 10 arguments that hook is to be replaced by ##N where N
8142 % is the position in that list, that is to say the macro arguments are to be
8143 % defined `a la TeX in the macro body.
8144 %
8145 % That gets used by \mbodybackslash (above).
8146 %
8147 % If there are 10 or more arguments, a different technique is used: see
8148 % \parsemmanyargdef.
8149 %
8150 \def\parsemargdef#1;{%
8151   \paramno=0\def\paramlist{}%
8152   \let\hash\relax
8153   % \hash is redefined to `#' later to get it into definitions
8154   \let\xeatspaces\relax
8155   \let\xempty\relax
8156   \parsemargdefxxx#1,;,%
8157   \ifnum\paramno<10\relax\else
8158     \paramno0\relax
8159     \parsemmanyargdef@@#1,;,% 10 or more arguments
8160   \fi
8161 }
8162 \def\parsemargdefxxx#1,{%
8163   \if#1;\let\next=\relax
8164   \else \let\next=\parsemargdefxxx
8165     \advance\paramno by 1
8166     \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
8167         {\xeatspaces{\hash\the\paramno\noexpand\xempty{}}}%
8168     \edef\paramlist{\paramlist\hash\the\paramno,}%
8169   \fi\next}
8170 % the \xempty{} is to give \eatleadingcr an argument in the case of an
8171 % empty macro argument.
8172
8173 % \parsemacbody, \parsermacbody
8174 %
8175 % Read recursive and nonrecursive macro bodies. (They're different since
8176 % rec and nonrec macros end differently.)
8177 %
8178 % We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro
8179 % body to be transformed.
8180 % Set \macrobody to the body of the macro, and call \defmacro.
8181 %
8182 {\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{%
8183 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8184 {\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
8185 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8186
8187 % Make @ a letter, so that we can make private-to-Texinfo macro names.
8188 \edef\texiatcatcode{\the\catcode`\@}
8189 \catcode `@=11\relax
8190
8191 %%%%%%%%%%%%%% Code for > 10 arguments only   %%%%%%%%%%%%%%%%%%
8192
8193 % If there are 10 or more arguments, a different technique is used, where the
8194 % hook remains in the body, and when macro is to be expanded the body is
8195 % processed again to replace the arguments.
8196 %
8197 % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
8198 % argument N value and then \edef the body (nothing else will expand because of
8199 % the catcode regime under which the body was input).
8200 %
8201 % If you compile with TeX (not eTeX), and you have macros with 10 or more
8202 % arguments, no macro can have more than 256 arguments (else error).
8203 %
8204 % In case that there are 10 or more arguments we parse again the arguments
8205 % list to set new definitions for the \macarg.BLAH macros corresponding to
8206 % each BLAH argument. It was anyhow needed to parse already once this list
8207 % in order to count the arguments, and as macros with at most 9 arguments
8208 % are by far more frequent than macro with 10 or more arguments, defining
8209 % twice the \macarg.BLAH macros does not cost too much processing power.
8210 \def\parsemmanyargdef@@#1,{%
8211   \if#1;\let\next=\relax
8212   \else
8213     \let\next=\parsemmanyargdef@@
8214     \edef\tempb{\eatspaces{#1}}%
8215     \expandafter\def\expandafter\tempa
8216        \expandafter{\csname macarg.\tempb\endcsname}%
8217     % Note that we need some extra \noexpand\noexpand, this is because we
8218     % don't want \the  to be expanded in the \parsermacbody  as it uses an
8219     % \xdef .
8220     \expandafter\edef\tempa
8221       {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
8222     \advance\paramno by 1\relax
8223   \fi\next}
8224
8225
8226 \let\endargs@\relax
8227 \let\nil@\relax
8228 \def\nilm@{\nil@}%
8229 \long\def\nillm@{\nil@}%
8230
8231 % This macro is expanded during the Texinfo macro expansion, not during its
8232 % definition.  It gets all the arguments' values and assigns them to macros
8233 % macarg.ARGNAME
8234 %
8235 % #1 is the macro name
8236 % #2 is the list of argument names
8237 % #3 is the list of argument values
8238 \def\getargvals@#1#2#3{%
8239   \def\macargdeflist@{}%
8240   \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
8241   \def\paramlist{#2,\nil@}%
8242   \def\macroname{#1}%
8243   \begingroup
8244   \macroargctxt
8245   \def\argvaluelist{#3,\nil@}%
8246   \def\@tempa{#3}%
8247   \ifx\@tempa\empty
8248     \setemptyargvalues@
8249   \else
8250     \getargvals@@
8251   \fi
8252 }
8253 \def\getargvals@@{%
8254   \ifx\paramlist\nilm@
8255       % Some sanity check needed here that \argvaluelist is also empty.
8256       \ifx\argvaluelist\nillm@
8257       \else
8258         \errhelp = \EMsimple
8259         \errmessage{Too many arguments in macro `\macroname'!}%
8260       \fi
8261       \let\next\macargexpandinbody@
8262   \else
8263     \ifx\argvaluelist\nillm@
8264        % No more arguments values passed to macro.  Set remaining named-arg
8265        % macros to empty.
8266        \let\next\setemptyargvalues@
8267     \else
8268       % pop current arg name into \@tempb
8269       \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
8270       \expandafter\@tempa\expandafter{\paramlist}%
8271        % pop current argument value into \@tempc
8272       \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
8273       \expandafter\@tempa\expandafter{\argvaluelist}%
8274        % Here \@tempb is the current arg name and \@tempc is the current arg value.
8275        % First place the new argument macro definition into \@tempd
8276        \expandafter\macname\expandafter{\@tempc}%
8277        \expandafter\let\csname macarg.\@tempb\endcsname\relax
8278        \expandafter\def\expandafter\@tempe\expandafter{%
8279          \csname macarg.\@tempb\endcsname}%
8280        \edef\@tempd{\long\def\@tempe{\the\macname}}%
8281        \push@\@tempd\macargdeflist@
8282        \let\next\getargvals@@
8283     \fi
8284   \fi
8285   \next
8286 }
8287
8288 \def\push@#1#2{%
8289   \expandafter\expandafter\expandafter\def
8290   \expandafter\expandafter\expandafter#2%
8291   \expandafter\expandafter\expandafter{%
8292   \expandafter#1#2}%
8293 }
8294
8295 % Replace arguments by their values in the macro body, and place the result
8296 % in macro \@tempa.
8297 %
8298 \def\macvalstoargs@{%
8299   %  To do this we use the property that token registers that are \the'ed
8300   % within an \edef  expand only once. So we are going to place all argument
8301   % values into respective token registers.
8302   %
8303   % First we save the token context, and initialize argument numbering.
8304   \begingroup
8305     \paramno0\relax
8306     % Then, for each argument number #N, we place the corresponding argument
8307     % value into a new token list register \toks#N
8308     \expandafter\putargsintokens@\saveparamlist@,;,%
8309     % Then, we expand the body so that argument are replaced by their
8310     % values. The trick for values not to be expanded themselves is that they
8311     % are within tokens and that tokens expand only once in an \edef .
8312     \edef\@tempc{\csname mac.\macroname .body\endcsname}%
8313     % Now we restore the token stack pointer to free the token list registers
8314     % which we have used, but we make sure that expanded body is saved after
8315     % group.
8316     \expandafter
8317   \endgroup
8318   \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
8319   }
8320
8321 % Define the named-macro outside of this group and then close this group.
8322 %
8323 \def\macargexpandinbody@{%
8324   \expandafter
8325   \endgroup
8326   \macargdeflist@
8327   % First the replace in body the macro arguments by their values, the result
8328   % is in \@tempa .
8329   \macvalstoargs@
8330   % Then we point at the \norecurse or \gobble (for recursive) macro value
8331   % with \@tempb .
8332   \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
8333   % Depending on whether it is recursive or not, we need some tailing
8334   % \egroup .
8335   \ifx\@tempb\gobble
8336      \let\@tempc\relax
8337   \else
8338      \let\@tempc\egroup
8339   \fi
8340   % And now we do the real job:
8341   \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
8342   \@tempd
8343 }
8344
8345 \def\putargsintokens@#1,{%
8346   \if#1;\let\next\relax
8347   \else
8348     \let\next\putargsintokens@
8349     % First we allocate the new token list register, and give it a temporary
8350     % alias \@tempb .
8351     \toksdef\@tempb\the\paramno
8352     % Then we place the argument value into that token list register.
8353     \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
8354     \expandafter\@tempb\expandafter{\@tempa}%
8355     \advance\paramno by 1\relax
8356   \fi
8357   \next
8358 }
8359
8360 % Trailing missing arguments are set to empty.
8361 %
8362 \def\setemptyargvalues@{%
8363   \ifx\paramlist\nilm@
8364     \let\next\macargexpandinbody@
8365   \else
8366     \expandafter\setemptyargvaluesparser@\paramlist\endargs@
8367     \let\next\setemptyargvalues@
8368   \fi
8369   \next
8370 }
8371
8372 \def\setemptyargvaluesparser@#1,#2\endargs@{%
8373   \expandafter\def\expandafter\@tempa\expandafter{%
8374     \expandafter\def\csname macarg.#1\endcsname{}}%
8375   \push@\@tempa\macargdeflist@
8376   \def\paramlist{#2}%
8377 }
8378
8379 % #1 is the element target macro
8380 % #2 is the list macro
8381 % #3,#4\endargs@ is the list value
8382 \def\pop@#1#2#3,#4\endargs@{%
8383    \def#1{#3}%
8384    \def#2{#4}%
8385 }
8386 \long\def\longpop@#1#2#3,#4\endargs@{%
8387    \long\def#1{#3}%
8388    \long\def#2{#4}%
8389 }
8390
8391
8392 %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
8393
8394
8395 % This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
8396 %    \macrobody has the body of the macro in it, with placeholders for
8397 % its parameters, looking like "\xeatspaces{\hash 1}".
8398 %    \paramno is the number of parameters
8399 %    \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
8400 % There are four cases: macros of zero, one, up to nine, and many arguments.
8401 % \xdef is used so that macro definitions will survive the file
8402 % they're defined in: @include reads the file inside a group.
8403 %
8404 \def\defmacro{%
8405   \let\hash=##% convert placeholders to macro parameter chars
8406   \ifnum\paramno=1
8407     \def\xeatspaces##1{##1}%
8408     % This removes the pair of braces around the argument.  We don't
8409     % use \eatspaces, because this can cause ends of lines to be lost
8410     % when the argument to \eatspaces is read, leading to line-based
8411     % commands like "@itemize" not being read correctly.
8412   \else
8413     \let\xeatspaces\relax % suppress expansion
8414   \fi
8415   \ifcase\paramno
8416   % 0
8417     \expandafter\xdef\csname\the\macname\endcsname{%
8418       \bgroup
8419         \noexpand\spaceisspace
8420         \noexpand\endlineisspace
8421         \noexpand\expandafter % skip any whitespace after the macro name.
8422         \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8423     \expandafter\xdef\csname\the\macname @@@\endcsname{%
8424       \egroup
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 % at most 9
8436     \ifnum\paramno<10\relax
8437       % @MACNAME sets the context for reading the macro argument
8438       % @MACNAME@@ gets the argument, processes backslashes and appends a
8439       % comma.
8440       % @MACNAME@@@ removes braces surrounding the argument list.
8441       % @MACNAME@@@@ scans the macro body with arguments substituted.
8442       \expandafter\xdef\csname\the\macname\endcsname{%
8443         \bgroup
8444         \noexpand\expandafter  % This \expandafter skip any spaces after the
8445         \noexpand\macroargctxt % macro before we change the catcode of space.
8446         \noexpand\expandafter
8447         \expandafter\noexpand\csname\the\macname @@\endcsname}%
8448       \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8449           \noexpand\passargtomacro
8450           \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8451       \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8452           \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8453       \expandafter\expandafter
8454       \expandafter\xdef
8455       \expandafter\expandafter
8456         \csname\the\macname @@@@\endcsname\paramlist{%
8457           \egroup\noexpand\scanmacro{\macrobody}}%
8458     \else % 10 or more:
8459       \expandafter\xdef\csname\the\macname\endcsname{%
8460         \noexpand\getargvals@{\the\macname}{\argl}%
8461       }%
8462       \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8463       \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
8464     \fi
8465   \fi}
8466
8467 \catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
8468
8469 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
8470
8471
8472 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8473 %
8474 {\catcode`\@=0 \catcode`\\=13  % We need to manipulate \ so use @ as escape
8475 @catcode`@_=11  % private names
8476 @catcode`@!=11  % used as argument separator
8477
8478 % \passargtomacro#1#2 -
8479 % Call #1 with a list of tokens #2, with any doubled backslashes in #2
8480 % compressed to one.
8481 %
8482 % This implementation works by expansion, and not execution (so we cannot use
8483 % \def or similar).  This reduces the risk of this failing in contexts where
8484 % complete expansion is done with no execution (for example, in writing out to
8485 % an auxiliary file for an index entry).
8486 %
8487 % State is kept in the input stream: the argument passed to
8488 % @look_ahead, @gobble_and_check_finish and @add_segment is
8489 %
8490 % THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN  (... rest of input)
8491 %
8492 % where:
8493 % THE_MACRO - name of the macro we want to call
8494 % ARG_RESULT - argument list we build to pass to that macro
8495 % PENDING_BS - either a backslash or nothing
8496 % NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
8497
8498 @gdef@passargtomacro#1#2{%
8499   @add_segment #1!{}@relax#2\@_finish\%
8500 }
8501 @gdef@_finish{@_finishx} @global@let@_finishx@relax
8502
8503 % #1 - THE_MACRO ARG_RESULT
8504 % #2 - PENDING_BS
8505 % #3 - NEXT_TOKEN
8506 % #4 used to look ahead
8507 %
8508 % If the next token is not a backslash, process the rest of the argument;
8509 % otherwise, remove the next token.
8510 @gdef@look_ahead#1!#2#3#4{%
8511   @ifx#4\%
8512    @expandafter@gobble_and_check_finish
8513   @else
8514    @expandafter@add_segment
8515   @fi#1!{#2}#4#4%
8516 }
8517
8518 % #1 - THE_MACRO ARG_RESULT
8519 % #2 - PENDING_BS
8520 % #3 - NEXT_TOKEN
8521 % #4 should be a backslash, which is gobbled.
8522 % #5 looks ahead
8523 %
8524 % Double backslash found.  Add a single backslash, and look ahead.
8525 @gdef@gobble_and_check_finish#1!#2#3#4#5{%
8526   @add_segment#1\!{}#5#5%
8527 }
8528
8529 @gdef@is_fi{@fi}
8530
8531 % #1 - THE_MACRO ARG_RESULT
8532 % #2 - PENDING_BS
8533 % #3 - NEXT_TOKEN
8534 % #4 is input stream until next backslash
8535 %
8536 % Input stream is either at the start of the argument, or just after a
8537 % backslash sequence, either a lone backslash, or a doubled backslash.
8538 % NEXT_TOKEN contains the first token in the input stream: if it is \finish,
8539 % finish; otherwise, append to ARG_RESULT the segment of the argument up until
8540 % the next backslash.  PENDING_BACKSLASH contains a backslash to represent
8541 % a backslash just before the start of the input stream that has not been
8542 % added to ARG_RESULT.
8543 @gdef@add_segment#1!#2#3#4\{%
8544 @ifx#3@_finish
8545   @call_the_macro#1!%
8546 @else
8547   % append the pending backslash to the result, followed by the next segment
8548   @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
8549   % this @fi is discarded by @look_ahead.
8550   % we can't get rid of it with \expandafter because we don't know how
8551   % long #4 is.
8552 }
8553
8554 % #1 - THE_MACRO
8555 % #2 - ARG_RESULT
8556 % #3 discards the res of the conditional in @add_segment, and @is_fi ends the
8557 % conditional.
8558 @gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
8559
8560 }
8561 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8562
8563 % \braceorline MAC is used for a one-argument macro MAC.  It checks
8564 % whether the next non-whitespace character is a {.  It sets the context
8565 % for reading the argument (slightly different in the two cases).  Then,
8566 % to read the argument, in the whole-line case, it then calls the regular
8567 % \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
8568 %
8569 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
8570 \def\braceorlinexxx{%
8571   \ifx\nchar\bgroup
8572     \macroargctxt
8573     \expandafter\passargtomacro
8574   \else
8575     \macrolineargctxt\expandafter\parsearg
8576   \fi \macnamexxx}
8577
8578
8579 % @alias.
8580 % We need some trickery to remove the optional spaces around the equal
8581 % sign.  Make them active and then expand them all to nothing.
8582 %
8583 \def\alias{\parseargusing\obeyspaces\aliasxxx}
8584 \def\aliasxxx #1{\aliasyyy#1\relax}
8585 \def\aliasyyy #1=#2\relax{%
8586   {%
8587     \expandafter\let\obeyedspace=\empty
8588     \addtomacrolist{#1}%
8589     \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
8590   }%
8591   \next
8592 }
8593
8594
8595 \message{cross references,}
8596
8597 \newwrite\auxfile
8598 \newif\ifhavexrefs    % True if xref values are known.
8599 \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
8600
8601 % @inforef is relatively simple.
8602 \def\inforef #1{\inforefzzz #1,,,,**}
8603 \def\inforefzzz #1,#2,#3,#4**{%
8604   \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
8605   node \samp{\ignorespaces#1{}}}
8606
8607 % @node's only job in TeX is to define \lastnode, which is used in
8608 % cross-references.  The @node line might or might not have commas, and
8609 % might or might not have spaces before the first comma, like:
8610 % @node foo , bar , ...
8611 % We don't want such trailing spaces in the node name.
8612 %
8613 \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
8614 %
8615 % also remove a trailing comma, in case of something like this:
8616 % @node Help-Cross,  ,  , Cross-refs
8617 \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
8618 \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}\omittopnode}
8619
8620 % Used so that the @top node doesn't have to be wrapped in an @ifnottex
8621 % conditional.
8622 % \doignore goes to more effort to skip nested conditionals but we don't need
8623 % that here.
8624 \def\omittopnode{%
8625    \ifx\lastnode\wordTop
8626    \expandafter\ignorenode\fi
8627 }
8628 \def\wordTop{Top}
8629
8630 % Until the next @node, @part or @bye command, divert output to a box that
8631 % is not output.
8632 \def\ignorenode{\setbox\dummybox\vbox\bgroup
8633 \def\part{\egroup\part}%
8634 \def\node{\egroup\node}%
8635 \ignorenodebye
8636 }
8637
8638 {\let\bye\relax
8639 \gdef\ignorenodebye{\let\bye\ignorenodebyedef}
8640 \gdef\ignorenodebyedef{\egroup(`Top' node ignored)\bye}}
8641 % The redefinition of \bye here is because it is declared \outer
8642
8643 \let\lastnode=\empty
8644
8645 % Write a cross-reference definition for the current node.  #1 is the
8646 % type (Ynumbered, Yappendix, Ynothing).
8647 %
8648 \def\donoderef#1{%
8649   \ifx\lastnode\empty\else
8650     \setref{\lastnode}{#1}%
8651     \global\let\lastnode=\empty
8652   \fi
8653 }
8654
8655 % @anchor{NAME} -- define xref target at arbitrary point.
8656 %
8657 \newcount\savesfregister
8658 %
8659 \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
8660 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
8661 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
8662
8663 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
8664 % anchor), which consists of three parts:
8665 % 1) NAME-title - the current sectioning name taken from \currentsection,
8666 %                 or the anchor name.
8667 % 2) NAME-snt   - section number and type, passed as the SNT arg, or
8668 %                 empty for anchors.
8669 % 3) NAME-pg    - the page number.
8670 %
8671 % This is called from \donoderef, \anchor, and \dofloat.  In the case of
8672 % floats, there is an additional part, which is not written here:
8673 % 4) NAME-lof   - the text as it should appear in a @listoffloats.
8674 %
8675 \def\setref#1#2{%
8676   \pdfmkdest{#1}%
8677   \iflinks
8678     {%
8679       \requireauxfile
8680       \atdummies  % preserve commands, but don't expand them
8681       % match definition in \xrdef, \refx, \xrefX.
8682       \def\value##1{##1}%
8683       \edef\writexrdef##1##2{%
8684         \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
8685           ##1}{##2}}% these are parameters of \writexrdef
8686       }%
8687       \toks0 = \expandafter{\currentsection}%
8688       \immediate \writexrdef{title}{\the\toks0 }%
8689       \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
8690       \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
8691     }%
8692   \fi
8693 }
8694
8695 % @xrefautosectiontitle on|off says whether @section(ing) names are used
8696 % automatically in xrefs, if the third arg is not explicitly specified.
8697 % This was provided as a "secret" @set xref-automatic-section-title
8698 % variable, now it's official.
8699 %
8700 \parseargdef\xrefautomaticsectiontitle{%
8701   \def\temp{#1}%
8702   \ifx\temp\onword
8703     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8704       = \empty
8705   \else\ifx\temp\offword
8706     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8707       = \relax
8708   \else
8709     \errhelp = \EMsimple
8710     \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
8711                 must be on|off}%
8712   \fi\fi
8713 }
8714
8715 %
8716 % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
8717 % the node name, #2 the name of the Info cross-reference, #3 the printed
8718 % node name, #4 the name of the Info file, #5 the name of the printed
8719 % manual.  All but the node name can be omitted.
8720 %
8721 \def\pxref{\putwordsee{} \xrefXX}
8722 \def\xref{\putwordSee{} \xrefXX}
8723 \def\ref{\xrefXX}
8724
8725 \def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
8726 \def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
8727 %
8728 \newbox\toprefbox
8729 \newbox\printedrefnamebox
8730 \newbox\infofilenamebox
8731 \newbox\printedmanualbox
8732 %
8733 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
8734   \unsepspaces
8735   %
8736   % Get args without leading/trailing spaces.
8737   \def\printedrefname{\ignorespaces #3}%
8738   \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
8739   %
8740   \def\infofilename{\ignorespaces #4}%
8741   \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
8742   %
8743   \def\printedmanual{\ignorespaces #5}%
8744   \setbox\printedmanualbox  = \hbox{\printedmanual\unskip}%
8745   %
8746   % If the printed reference name (arg #3) was not explicitly given in
8747   % the @xref, figure out what we want to use.
8748   \ifdim \wd\printedrefnamebox = 0pt
8749     % No printed node name was explicitly given.
8750     \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
8751       % Not auto section-title: use node name inside the square brackets.
8752       \def\printedrefname{\ignorespaces #1}%
8753     \else
8754       % Auto section-title: use chapter/section title inside
8755       % the square brackets if we have it.
8756       \ifdim \wd\printedmanualbox > 0pt
8757         % It is in another manual, so we don't have it; use node name.
8758         \def\printedrefname{\ignorespaces #1}%
8759       \else
8760         \ifhavexrefs
8761           % We (should) know the real title if we have the xref values.
8762           \def\printedrefname{\refx{#1-title}}%
8763         \else
8764           % Otherwise just copy the Info node name.
8765           \def\printedrefname{\ignorespaces #1}%
8766         \fi%
8767       \fi
8768     \fi
8769   \fi
8770   %
8771   % Make link in pdf output.
8772   \ifpdf
8773     % For pdfTeX and LuaTeX
8774     {\indexnofonts
8775      \makevalueexpandable
8776      \turnoffactive
8777      % This expands tokens, so do it after making catcode changes, so _
8778      % etc. don't get their TeX definitions.  This ignores all spaces in
8779      % #4, including (wrongly) those in the middle of the filename.
8780      \getfilename{#4}%
8781      %
8782      % This (wrongly) does not take account of leading or trailing
8783      % spaces in #1, which should be ignored.
8784      \setpdfdestname{#1}%
8785      %
8786      \ifx\pdfdestname\empty
8787        \def\pdfdestname{Top}% no empty targets
8788      \fi
8789      %
8790      \leavevmode
8791      \startlink attr{/Border [0 0 0]}%
8792      \ifnum\filenamelength>0
8793        goto file{\the\filename.pdf} name{\pdfdestname}%
8794      \else
8795        goto name{\pdfmkpgn{\pdfdestname}}%
8796      \fi
8797     }%
8798     \setcolor{\linkcolor}%
8799   \else
8800     \ifx\XeTeXrevision\thisisundefined
8801     \else
8802       % For XeTeX
8803       {\indexnofonts
8804        \makevalueexpandable
8805        \turnoffactive
8806        % This expands tokens, so do it after making catcode changes, so _
8807        % etc. don't get their TeX definitions.  This ignores all spaces in
8808        % #4, including (wrongly) those in the middle of the filename.
8809        \getfilename{#4}%
8810        %
8811        % This (wrongly) does not take account of leading or trailing
8812        % spaces in #1, which should be ignored.
8813        \setpdfdestname{#1}%
8814        %
8815        \ifx\pdfdestname\empty
8816          \def\pdfdestname{Top}% no empty targets
8817        \fi
8818        %
8819        \leavevmode
8820        \ifnum\filenamelength>0
8821          % With default settings,
8822          % XeTeX (xdvipdfmx) replaces link destination names with integers.
8823          % In this case, the replaced destination names of
8824          % remote PDFs are no longer known.  In order to avoid a replacement,
8825          % you can use xdvipdfmx's command line option `-C 0x0010'.
8826          % If you use XeTeX 0.99996+ (TeX Live 2016+),
8827          % this command line option is no longer necessary
8828          % because we can use the `dvipdfmx:config' special.
8829          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8830            << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}%
8831        \else
8832          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8833            << /S /GoTo /D (\pdfdestname) >> >>}%
8834        \fi
8835       }%
8836       \setcolor{\linkcolor}%
8837     \fi
8838   \fi
8839   {%
8840     % Have to otherify everything special to allow the \csname to
8841     % include an _ in the xref name, etc.
8842     \indexnofonts
8843     \turnoffactive
8844     \def\value##1{##1}%
8845     \expandafter\global\expandafter\let\expandafter\Xthisreftitle
8846       \csname XR#1-title\endcsname
8847   }%
8848   %
8849   % Float references are printed completely differently: "Figure 1.2"
8850   % instead of "[somenode], p.3".  \iffloat distinguishes them by
8851   % \Xthisreftitle being set to a magic string.
8852   \iffloat\Xthisreftitle
8853     % If the user specified the print name (third arg) to the ref,
8854     % print it instead of our usual "Figure 1.2".
8855     \ifdim\wd\printedrefnamebox = 0pt
8856       \refx{#1-snt}%
8857     \else
8858       \printedrefname
8859     \fi
8860     %
8861     % If the user also gave the printed manual name (fifth arg), append
8862     % "in MANUALNAME".
8863     \ifdim \wd\printedmanualbox > 0pt
8864       \space \putwordin{} \cite{\printedmanual}%
8865     \fi
8866   \else
8867     % node/anchor (non-float) references.
8868     %
8869     % If we use \unhbox to print the node names, TeX does not insert
8870     % empty discretionaries after hyphens, which means that it will not
8871     % find a line break at a hyphen in a node names.  Since some manuals
8872     % are best written with fairly long node names, containing hyphens,
8873     % this is a loss.  Therefore, we give the text of the node name
8874     % again, so it is as if TeX is seeing it for the first time.
8875     %
8876     \ifdim \wd\printedmanualbox > 0pt
8877       % Cross-manual reference with a printed manual name.
8878       %
8879       \crossmanualxref{\cite{\printedmanual\unskip}}%
8880     %
8881     \else\ifdim \wd\infofilenamebox > 0pt
8882       % Cross-manual reference with only an info filename (arg 4), no
8883       % printed manual name (arg 5).  This is essentially the same as
8884       % the case above; we output the filename, since we have nothing else.
8885       %
8886       \crossmanualxref{\code{\infofilename\unskip}}%
8887     %
8888     \else
8889       % Reference within this manual.
8890       %
8891       % Only output a following space if the -snt ref is nonempty, as the ref
8892       % will be empty for @unnumbered and @anchor.
8893       \setbox2 = \hbox{\ignorespaces \refx{#1-snt}}%
8894       \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
8895       %
8896       % output the `[mynode]' via the macro below so it can be overridden.
8897       \xrefprintnodename\printedrefname
8898       %
8899       \ifflagclear{txiomitxrefpg}{%
8900         % But we always want a comma and a space:
8901         ,\space
8902         %
8903         % output the `page 3'.
8904         \turnoffactive \putwordpage\tie\refx{#1-pg}%
8905         % Add a , if xref followed by a space
8906         \if\space\noexpand\tokenafterxref ,%
8907         \else\ifx\      \tokenafterxref ,% @TAB
8908         \else\ifx\*\tokenafterxref ,%   @*
8909         \else\ifx\ \tokenafterxref ,%   @SPACE
8910         \else\ifx\
8911                   \tokenafterxref ,%    @NL
8912         \else\ifx\tie\tokenafterxref ,% @tie
8913         \fi\fi\fi\fi\fi\fi
8914       }{}%
8915     \fi\fi
8916   \fi
8917   \endlink
8918 \endgroup}
8919
8920 % Output a cross-manual xref to #1.  Used just above (twice).
8921 %
8922 % Only include the text "Section ``foo'' in" if the foo is neither
8923 % missing or Top.  Thus, @xref{,,,foo,The Foo Manual} outputs simply
8924 % "see The Foo Manual", the idea being to refer to the whole manual.
8925 %
8926 % But, this being TeX, we can't easily compare our node name against the
8927 % string "Top" while ignoring the possible spaces before and after in
8928 % the input.  By adding the arbitrary 7sp below, we make it much less
8929 % likely that a real node name would have the same width as "Top" (e.g.,
8930 % in a monospaced font).  Hopefully it will never happen in practice.
8931 %
8932 % For the same basic reason, we retypeset the "Top" at every
8933 % reference, since the current font is indeterminate.
8934 %
8935 \def\crossmanualxref#1{%
8936   \setbox\toprefbox = \hbox{Top\kern7sp}%
8937   \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
8938   \ifdim \wd2 > 7sp  % nonempty?
8939     \ifdim \wd2 = \wd\toprefbox \else  % same as Top?
8940       \putwordSection{} ``\printedrefname'' \putwordin{}\space
8941     \fi
8942   \fi
8943   #1%
8944 }
8945
8946 % This macro is called from \xrefX for the `[nodename]' part of xref
8947 % output.  It's a separate macro only so it can be changed more easily,
8948 % since square brackets don't work well in some documents.  Particularly
8949 % one that Bob is working on :).
8950 %
8951 \def\xrefprintnodename#1{[#1]}
8952
8953 % Things referred to by \setref.
8954 %
8955 \def\Ynothing{}
8956 \def\Yomitfromtoc{}
8957 \def\Ynumbered{%
8958   \ifnum\secno=0
8959     \putwordChapter@tie \the\chapno
8960   \else \ifnum\subsecno=0
8961     \putwordSection@tie \the\chapno.\the\secno
8962   \else \ifnum\subsubsecno=0
8963     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
8964   \else
8965     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
8966   \fi\fi\fi
8967 }
8968 \def\Yappendix{%
8969   \ifnum\secno=0
8970      \putwordAppendix@tie @char\the\appendixno{}%
8971   \else \ifnum\subsecno=0
8972      \putwordSection@tie @char\the\appendixno.\the\secno
8973   \else \ifnum\subsubsecno=0
8974     \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
8975   \else
8976     \putwordSection@tie
8977       @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
8978   \fi\fi\fi
8979 }
8980
8981 % \refx{NAME} - reference a cross-reference string named NAME.
8982 \def\refx#1{%
8983   \requireauxfile
8984   {%
8985     \indexnofonts
8986     \turnoffactive
8987     \def\value##1{##1}%
8988     \expandafter\global\expandafter\let\expandafter\thisrefX
8989       \csname XR#1\endcsname
8990   }%
8991   \ifx\thisrefX\relax
8992     % If not defined, say something at least.
8993     \angleleft un\-de\-fined\angleright
8994     \iflinks
8995       \ifhavexrefs
8996         {\toks0 = {#1}% avoid expansion of possibly-complex value
8997          \message{\linenumber Undefined cross reference `\the\toks0'.}}%
8998       \else
8999         \ifwarnedxrefs\else
9000           \global\warnedxrefstrue
9001           \message{Cross reference values unknown; you must run TeX again.}%
9002         \fi
9003       \fi
9004     \fi
9005   \else
9006     % It's defined, so just use it.
9007     \thisrefX
9008   \fi
9009 }
9010
9011 % This is the macro invoked by entries in the aux file.  Define a control
9012 % sequence for a cross-reference target (we prepend XR to the control sequence
9013 % name to avoid collisions).  The value is the page number.  If this is a float
9014 % type, we have more work to do.
9015 %
9016 \def\xrdef#1#2{%
9017   {% Expand the node or anchor name to remove control sequences.
9018    % \turnoffactive stops 8-bit characters being changed to commands
9019    % like @'e.  \refx does the same to retrieve the value in the definition.
9020     \indexnofonts
9021     \turnoffactive
9022     \def\value##1{##1}%
9023     \xdef\safexrefname{#1}%
9024   }%
9025   %
9026   \bgroup
9027     \expandafter\gdef\csname XR\safexrefname\endcsname{#2}%
9028   \egroup
9029   % We put the \gdef inside a group to avoid the definitions building up on
9030   % TeX's save stack, which can cause it to run out of space for aux files with
9031   % thousands of lines.  \gdef doesn't use the save stack, but \csname does
9032   % when it defines an unknown control sequence as \relax.
9033   %
9034   % Was that xref control sequence that we just defined for a float?
9035   \expandafter\iffloat\csname XR\safexrefname\endcsname
9036     % it was a float, and we have the (safe) float type in \iffloattype.
9037     \expandafter\let\expandafter\floatlist
9038       \csname floatlist\iffloattype\endcsname
9039     %
9040     % Is this the first time we've seen this float type?
9041     \expandafter\ifx\floatlist\relax
9042       \toks0 = {\do}% yes, so just \do
9043     \else
9044       % had it before, so preserve previous elements in list.
9045       \toks0 = \expandafter{\floatlist\do}%
9046     \fi
9047     %
9048     % Remember this xref in the control sequence \floatlistFLOATTYPE,
9049     % for later use in \listoffloats.
9050     \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
9051       {\safexrefname}}%
9052   \fi
9053 }
9054
9055 % If working on a large document in chapters, it is convenient to
9056 % be able to disable indexing, cross-referencing, and contents, for test runs.
9057 % This is done with @novalidate at the beginning of the file.
9058 %
9059 \newif\iflinks \linkstrue % by default we want the aux files.
9060 \let\novalidate = \linksfalse
9061
9062 % Used when writing to the aux file, or when using data from it.
9063 \def\requireauxfile{%
9064   \iflinks
9065     \tryauxfile
9066     % Open the new aux file.  TeX will close it automatically at exit.
9067     \immediate\openout\auxfile=\jobname.aux
9068   \fi
9069   \global\let\requireauxfile=\relax   % Only do this once.
9070 }
9071
9072 % Read the last existing aux file, if any.  No error if none exists.
9073 %
9074 \def\tryauxfile{%
9075   \openin 1 \jobname.aux
9076   \ifeof 1 \else
9077     \readdatafile{aux}%
9078     \global\havexrefstrue
9079   \fi
9080   \closein 1
9081 }
9082
9083 \def\setupdatafile{%
9084   \catcode`\^^@=\other
9085   \catcode`\^^A=\other
9086   \catcode`\^^B=\other
9087   \catcode`\^^C=\other
9088   \catcode`\^^D=\other
9089   \catcode`\^^E=\other
9090   \catcode`\^^F=\other
9091   \catcode`\^^G=\other
9092   \catcode`\^^H=\other
9093   \catcode`\^^K=\other
9094   \catcode`\^^L=\other
9095   \catcode`\^^N=\other
9096   \catcode`\^^P=\other
9097   \catcode`\^^Q=\other
9098   \catcode`\^^R=\other
9099   \catcode`\^^S=\other
9100   \catcode`\^^T=\other
9101   \catcode`\^^U=\other
9102   \catcode`\^^V=\other
9103   \catcode`\^^W=\other
9104   \catcode`\^^X=\other
9105   \catcode`\^^Z=\other
9106   \catcode`\^^[=\other
9107   \catcode`\^^\=\other
9108   \catcode`\^^]=\other
9109   \catcode`\^^^=\other
9110   \catcode`\^^_=\other
9111   \catcode`\^=\other
9112   %
9113   % Special characters.  Should be turned off anyway, but...
9114   \catcode`\~=\other
9115   \catcode`\[=\other
9116   \catcode`\]=\other
9117   \catcode`\"=\other
9118   \catcode`\_=\active
9119   \catcode`\|=\active
9120   \catcode`\<=\active
9121   \catcode`\>=\active
9122   \catcode`\$=\other
9123   \catcode`\#=\other
9124   \catcode`\&=\other
9125   \catcode`\%=\other
9126   \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
9127   %
9128   \catcode`\\=\active
9129   %
9130   % @ is our escape character in .aux files, and we need braces.
9131   \catcode`\{=1
9132   \catcode`\}=2
9133   \catcode`\@=0
9134 }
9135
9136 \def\readdatafile#1{%
9137 \begingroup
9138   \setupdatafile
9139   \input\jobname.#1
9140 \endgroup}
9141
9142
9143 \message{insertions,}
9144 % including footnotes.
9145
9146 \newcount \footnoteno
9147
9148 % The trailing space in the following definition for supereject is
9149 % vital for proper filling; pages come out unaligned when you do a
9150 % pagealignmacro call if that space before the closing brace is
9151 % removed. (Generally, numeric constants should always be followed by a
9152 % space to prevent strange expansion errors.)
9153 \def\supereject{\par\penalty -20000\footnoteno =0 }
9154
9155 % @footnotestyle is meaningful for Info output only.
9156 \let\footnotestyle=\comment
9157
9158 {\catcode `\@=11
9159 %
9160 % Auto-number footnotes.  Otherwise like plain.
9161 \gdef\footnote{%
9162   \global\advance\footnoteno by \@ne
9163   \edef\thisfootno{$^{\the\footnoteno}$}%
9164   %
9165   % In case the footnote comes at the end of a sentence, preserve the
9166   % extra spacing after we do the footnote number.
9167   \let\@sf\empty
9168   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9169   %
9170   % Remove inadvertent blank space before typesetting the footnote number.
9171   \unskip
9172   \thisfootno\@sf
9173   \dofootnote
9174 }%
9175
9176 % Don't bother with the trickery in plain.tex to not require the
9177 % footnote text as a parameter.  Our footnotes don't need to be so general.
9178 %
9179 % Oh yes, they do; otherwise, @ifset (and anything else that uses
9180 % \parseargline) fails inside footnotes because the tokens are fixed when
9181 % the footnote is read.  --karl, 16nov96.
9182 %
9183 \gdef\dofootnote{%
9184   \insert\footins\bgroup
9185   %
9186   % Nested footnotes are not supported in TeX, that would take a lot
9187   % more work.  (\startsavinginserts does not suffice.)
9188   \let\footnote=\errfootnotenest
9189   %
9190   % We want to typeset this text as a normal paragraph, even if the
9191   % footnote reference occurs in (for example) a display environment.
9192   % So reset some parameters.
9193   \hsize=\txipagewidth
9194   \interlinepenalty\interfootnotelinepenalty
9195   \splittopskip\ht\strutbox % top baseline for broken footnotes
9196   \splitmaxdepth\dp\strutbox
9197   \floatingpenalty\@MM
9198   \leftskip\z@skip
9199   \rightskip\z@skip
9200   \spaceskip\z@skip
9201   \xspaceskip\z@skip
9202   \parindent\defaultparindent
9203   %
9204   \smallfonts \rm
9205   %
9206   % Because we use hanging indentation in footnotes, a @noindent appears
9207   % to exdent this text, so make it be a no-op.  makeinfo does not use
9208   % hanging indentation so @noindent can still be needed within footnote
9209   % text after an @example or the like (not that this is good style).
9210   \let\noindent = \relax
9211   %
9212   % Hang the footnote text off the number.  Use \everypar in case the
9213   % footnote extends for more than one paragraph.
9214   \everypar = {\hang}%
9215   \textindent{\thisfootno}%
9216   %
9217   % Don't crash into the line above the footnote text.  Since this
9218   % expands into a box, it must come within the paragraph, lest it
9219   % provide a place where TeX can split the footnote.
9220   \footstrut
9221   %
9222   % Invoke rest of plain TeX footnote routine.
9223   \futurelet\next\fo@t
9224 }
9225 }%end \catcode `\@=11
9226
9227 \def\errfootnotenest{%
9228   \errhelp=\EMsimple
9229   \errmessage{Nested footnotes not supported in texinfo.tex,
9230     even though they work in makeinfo; sorry}
9231 }
9232
9233 \def\errfootnoteheading{%
9234   \errhelp=\EMsimple
9235   \errmessage{Footnotes in chapters, sections, etc., are not supported}
9236 }
9237
9238 % In case a @footnote appears in a vbox, save the footnote text and create
9239 % the real \insert just after the vbox finished.  Otherwise, the insertion
9240 % would be lost.
9241 % Similarly, if a @footnote appears inside an alignment, save the footnote
9242 % text to a box and make the \insert when a row of the table is finished.
9243 % And the same can be done for other insert classes.  --kasal, 16nov03.
9244 %
9245 % Replace the \insert primitive by a cheating macro.
9246 % Deeper inside, just make sure that the saved insertions are not spilled
9247 % out prematurely.
9248 %
9249 \def\startsavinginserts{%
9250   \ifx \insert\ptexinsert
9251     \let\insert\saveinsert
9252   \else
9253     \let\checkinserts\relax
9254   \fi
9255 }
9256
9257 % This \insert replacement works for both \insert\footins{foo} and
9258 % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9259 %
9260 \def\saveinsert#1{%
9261   \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9262   \afterassignment\next
9263   % swallow the left brace
9264   \let\temp =
9265 }
9266 \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9267 \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9268
9269 \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9270
9271 \def\placesaveins#1{%
9272   \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9273     {\box#1}%
9274 }
9275
9276 % eat @SAVE -- beware, all of them have catcode \other:
9277 {
9278   \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials  %  ;-)
9279   \gdef\gobblesave @SAVE{}
9280 }
9281
9282 % initialization:
9283 \def\newsaveins #1{%
9284   \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9285   \next
9286 }
9287 \def\newsaveinsX #1{%
9288   \csname newbox\endcsname #1%
9289   \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9290     \checksaveins #1}%
9291 }
9292
9293 % initialize:
9294 \let\checkinserts\empty
9295 \newsaveins\footins
9296 \newsaveins\margin
9297
9298
9299 % @image.  We use the macros from epsf.tex to support this.
9300 % If epsf.tex is not installed and @image is used, we complain.
9301 %
9302 % Check for and read epsf.tex up front.  If we read it only at @image
9303 % time, we might be inside a group, and then its definitions would get
9304 % undone and the next image would fail.
9305 \openin 1 = epsf.tex
9306 \ifeof 1 \else
9307   % Do not bother showing banner with epsf.tex v2.7k (available in
9308   % doc/epsf.tex and on ctan).
9309   \def\epsfannounce{\toks0 = }%
9310   \input epsf.tex
9311 \fi
9312 \closein 1
9313 %
9314 % We will only complain once about lack of epsf.tex.
9315 \newif\ifwarnednoepsf
9316 \newhelp\noepsfhelp{epsf.tex must be installed for images to
9317   work.  It is also included in the Texinfo distribution, or you can get
9318   it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.}
9319 %
9320 \def\image#1{%
9321   \ifx\epsfbox\thisisundefined
9322     \ifwarnednoepsf \else
9323       \errhelp = \noepsfhelp
9324       \errmessage{epsf.tex not found, images will be ignored}%
9325       \global\warnednoepsftrue
9326     \fi
9327   \else
9328     \imagexxx #1,,,,,\finish
9329   \fi
9330 }
9331 %
9332 % Arguments to @image:
9333 % #1 is (mandatory) image filename; we tack on .eps extension.
9334 % #2 is (optional) width, #3 is (optional) height.
9335 % #4 is (ignored optional) html alt text.
9336 % #5 is (ignored optional) extension.
9337 % #6 is just the usual extra ignored arg for parsing stuff.
9338 \newif\ifimagevmode
9339 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
9340   \catcode`\^^M = 5     % in case we're inside an example
9341   \normalturnoffactive  % allow _ et al. in names
9342   \makevalueexpandable
9343   \ifvmode
9344     \imagevmodetrue
9345   \else \ifx\centersub\centerV
9346     % for @center @image, we need a vbox so we can have our vertical space
9347     \imagevmodetrue
9348     \vbox\bgroup % vbox has better behavior than vtop here
9349   \fi\fi
9350   %
9351   \ifimagevmode
9352     \medskip
9353     % Usually we'll have text after the image which will insert
9354     % \parskip glue, so insert it here too to equalize the space
9355     % above and below.
9356     \vskip\parskip
9357     %
9358     % Place image in a \vtop for a top page margin that is (close to) correct,
9359     % as \topskip glue is relative to the first baseline.
9360     \vtop\bgroup\hrule height 0pt\vskip-\parskip
9361   \fi
9362   %
9363   % Enter horizontal mode so that indentation from an enclosing
9364   %  environment such as @quotation is respected.
9365   % However, if we're at the top level, we don't want the
9366   %  normal paragraph indentation.
9367   % On the other hand, if we are in the case of @center @image, we don't
9368   %  want to start a paragraph, which will create a hsize-width box and
9369   %  eradicate the centering.
9370   \ifx\centersub\centerV \else \imageindent \fi
9371   %
9372   % Output the image.
9373   \ifpdf
9374     % For pdfTeX and LuaTeX <= 0.80
9375     \dopdfimage{#1}{#2}{#3}%
9376   \else
9377     \ifx\XeTeXrevision\thisisundefined
9378       % For epsf.tex
9379       % \epsfbox itself resets \epsf?size at each figure.
9380       \setbox0 = \hbox{\ignorespaces #2}%
9381         \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9382       \setbox0 = \hbox{\ignorespaces #3}%
9383         \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9384       \epsfbox{#1.eps}%
9385     \else
9386       % For XeTeX
9387       \doxeteximage{#1}{#2}{#3}%
9388     \fi
9389   \fi
9390   %
9391   \ifimagevmode
9392     \egroup
9393     \medskip  % space after a standalone image
9394   \fi
9395   \ifx\centersub\centerV \egroup \fi
9396 \endgroup}
9397
9398
9399 % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9400 % etc.  We don't actually implement floating yet, we always include the
9401 % float "here".  But it seemed the best name for the future.
9402 %
9403 \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9404
9405 % There may be a space before second and/or third parameter; delete it.
9406 \def\eatcommaspace#1, {#1,}
9407
9408 % #1 is the optional FLOATTYPE, the text label for this float, typically
9409 % "Figure", "Table", "Example", etc.  Can't contain commas.  If omitted,
9410 % this float will not be numbered and cannot be referred to.
9411 %
9412 % #2 is the optional xref label.  Also must be present for the float to
9413 % be referable.
9414 %
9415 % #3 is the optional positioning argument; for now, it is ignored.  It
9416 % will somehow specify the positions allowed to float to (here, top, bottom).
9417 %
9418 % We keep a separate counter for each FLOATTYPE, which we reset at each
9419 % chapter-level command.
9420 \let\resetallfloatnos=\empty
9421 %
9422 \def\dofloat#1,#2,#3,#4\finish{%
9423   \let\thiscaption=\empty
9424   \let\thisshortcaption=\empty
9425   %
9426   % don't lose footnotes inside @float.
9427   %
9428   % BEWARE: when the floats start float, we have to issue warning whenever an
9429   % insert appears inside a float which could possibly float. --kasal, 26may04
9430   %
9431   \startsavinginserts
9432   %
9433   % We can't be used inside a paragraph.
9434   \par
9435   %
9436   \vtop\bgroup
9437     \def\floattype{#1}%
9438     \def\floatlabel{#2}%
9439     \def\floatloc{#3}% we do nothing with this yet.
9440     %
9441     \ifx\floattype\empty
9442       \let\safefloattype=\empty
9443     \else
9444       {%
9445         % the floattype might have accents or other special characters,
9446         % but we need to use it in a control sequence name.
9447         \indexnofonts
9448         \turnoffactive
9449         \xdef\safefloattype{\floattype}%
9450       }%
9451     \fi
9452     %
9453     % If label is given but no type, we handle that as the empty type.
9454     \ifx\floatlabel\empty \else
9455       % We want each FLOATTYPE to be numbered separately (Figure 1,
9456       % Table 1, Figure 2, ...).  (And if no label, no number.)
9457       %
9458       \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9459       \global\advance\floatno by 1
9460       %
9461       {%
9462         % This magic value for \currentsection is output by \setref as the
9463         % XREFLABEL-title value.  \xrefX uses it to distinguish float
9464         % labels (which have a completely different output format) from
9465         % node and anchor labels.  And \xrdef uses it to construct the
9466         % lists of floats.
9467         %
9468         \edef\currentsection{\floatmagic=\safefloattype}%
9469         \setref{\floatlabel}{Yfloat}%
9470       }%
9471     \fi
9472     %
9473     % start with \parskip glue, I guess.
9474     \vskip\parskip
9475     %
9476     % Don't suppress indentation if a float happens to start a section.
9477     \restorefirstparagraphindent
9478 }
9479
9480 % we have these possibilities:
9481 % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9482 % @float Foo,lbl & no caption:    Foo 1.1
9483 % @float Foo & @caption{Cap}:     Foo: Cap
9484 % @float Foo & no caption:        Foo
9485 % @float ,lbl & Caption{Cap}:     1.1: Cap
9486 % @float ,lbl & no caption:       1.1
9487 % @float & @caption{Cap}:         Cap
9488 % @float & no caption:
9489 %
9490 \def\Efloat{%
9491     \let\floatident = \empty
9492     %
9493     % In all cases, if we have a float type, it comes first.
9494     \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9495     %
9496     % If we have an xref label, the number comes next.
9497     \ifx\floatlabel\empty \else
9498       \ifx\floattype\empty \else % if also had float type, need tie first.
9499         \appendtomacro\floatident{\tie}%
9500       \fi
9501       % the number.
9502       \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9503     \fi
9504     %
9505     % Start the printed caption with what we've constructed in
9506     % \floatident, but keep it separate; we need \floatident again.
9507     \let\captionline = \floatident
9508     %
9509     \ifx\thiscaption\empty \else
9510       \ifx\floatident\empty \else
9511         \appendtomacro\captionline{: }% had ident, so need a colon between
9512       \fi
9513       %
9514       % caption text.
9515       \appendtomacro\captionline{\scanexp\thiscaption}%
9516     \fi
9517     %
9518     % If we have anything to print, print it, with space before.
9519     % Eventually this needs to become an \insert.
9520     \ifx\captionline\empty \else
9521       \vskip.5\parskip
9522       \captionline
9523       %
9524       % Space below caption.
9525       \vskip\parskip
9526     \fi
9527     %
9528     % If have an xref label, write the list of floats info.  Do this
9529     % after the caption, to avoid chance of it being a breakpoint.
9530     \ifx\floatlabel\empty \else
9531       % Write the text that goes in the lof to the aux file as
9532       % \floatlabel-lof.  Besides \floatident, we include the short
9533       % caption if specified, else the full caption if specified, else nothing.
9534       {%
9535         \requireauxfile
9536         \atdummies
9537         %
9538         \ifx\thisshortcaption\empty
9539           \def\gtemp{\thiscaption}%
9540         \else
9541           \def\gtemp{\thisshortcaption}%
9542         \fi
9543         \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
9544           \ifx\gtemp\empty \else : \gtemp \fi}}%
9545       }%
9546     \fi
9547   \egroup  % end of \vtop
9548   %
9549   \checkinserts
9550 }
9551
9552 % Append the tokens #2 to the definition of macro #1, not expanding either.
9553 %
9554 \def\appendtomacro#1#2{%
9555   \expandafter\def\expandafter#1\expandafter{#1#2}%
9556 }
9557
9558 % @caption, @shortcaption
9559 %
9560 \def\caption{\docaption\thiscaption}
9561 \def\shortcaption{\docaption\thisshortcaption}
9562 \def\docaption{\checkenv\float \bgroup\scanctxt\defcaption}
9563 \def\defcaption#1#2{\egroup \def#1{#2}}
9564
9565 % The parameter is the control sequence identifying the counter we are
9566 % going to use.  Create it if it doesn't exist and assign it to \floatno.
9567 \def\getfloatno#1{%
9568   \ifx#1\relax
9569       % Haven't seen this figure type before.
9570       \csname newcount\endcsname #1%
9571       %
9572       % Remember to reset this floatno at the next chap.
9573       \expandafter\gdef\expandafter\resetallfloatnos
9574         \expandafter{\resetallfloatnos #1=0 }%
9575   \fi
9576   \let\floatno#1%
9577 }
9578
9579 % \setref calls this to get the XREFLABEL-snt value.  We want an @xref
9580 % to the FLOATLABEL to expand to "Figure 3.1".  We call \setref when we
9581 % first read the @float command.
9582 %
9583 \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9584
9585 % Magic string used for the XREFLABEL-title value, so \xrefX can
9586 % distinguish floats from other xref types.
9587 \def\floatmagic{!!float!!}
9588
9589 % #1 is the control sequence we are passed; we expand into a conditional
9590 % which is true if #1 represents a float ref.  That is, the magic
9591 % \currentsection value which we \setref above.
9592 %
9593 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
9594 %
9595 % #1 is (maybe) the \floatmagic string.  If so, #2 will be the
9596 % (safe) float type for this float.  We set \iffloattype to #2.
9597 %
9598 \def\doiffloat#1=#2=#3\finish{%
9599   \def\temp{#1}%
9600   \def\iffloattype{#2}%
9601   \ifx\temp\floatmagic
9602 }
9603
9604 % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9605 %
9606 \parseargdef\listoffloats{%
9607   \def\floattype{#1}% floattype
9608   {%
9609     % the floattype might have accents or other special characters,
9610     % but we need to use it in a control sequence name.
9611     \indexnofonts
9612     \turnoffactive
9613     \xdef\safefloattype{\floattype}%
9614   }%
9615   %
9616   % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9617   \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9618     \ifhavexrefs
9619       % if the user said @listoffloats foo but never @float foo.
9620       \message{\linenumber No `\safefloattype' floats to list.}%
9621     \fi
9622   \else
9623     \begingroup
9624       \leftskip=\tocindent  % indent these entries like a toc
9625       \let\do=\listoffloatsdo
9626       \csname floatlist\safefloattype\endcsname
9627     \endgroup
9628   \fi
9629 }
9630
9631 % This is called on each entry in a list of floats.  We're passed the
9632 % xref label, in the form LABEL-title, which is how we save it in the
9633 % aux file.  We strip off the -title and look up \XRLABEL-lof, which
9634 % has the text we're supposed to typeset here.
9635 %
9636 % Figures without xref labels will not be included in the list (since
9637 % they won't appear in the aux file).
9638 %
9639 \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9640 \def\listoffloatsdoentry#1-title\finish{{%
9641   % Can't fully expand XR#1-lof because it can contain anything.  Just
9642   % pass the control sequence.  On the other hand, XR#1-pg is just the
9643   % page number, and we want to fully expand that so we can get a link
9644   % in pdf output.
9645   \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9646   %
9647   % use the same \entry macro we use to generate the TOC and index.
9648   \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9649   \writeentry
9650 }}
9651
9652
9653 \message{localization,}
9654
9655 % For single-language documents, @documentlanguage is usually given very
9656 % early, just after @documentencoding.  Single argument is the language
9657 % (de) or locale (de_DE) abbreviation.
9658 %
9659 {
9660   \catcode`\_ = \active
9661   \globaldefs=1
9662 \parseargdef\documentlanguage{%
9663   \tex % read txi-??.tex file in plain TeX.
9664     % Read the file by the name they passed if it exists.
9665     \let_ = \normalunderscore  % normal _ character for filename test
9666     \openin 1 txi-#1.tex
9667     \ifeof 1
9668       \documentlanguagetrywithoutunderscore #1_\finish
9669     \else
9670       \globaldefs = 1  % everything in the txi-LL files needs to persist
9671       \input txi-#1.tex
9672     \fi
9673     \closein 1
9674   \endgroup % end raw TeX
9675 }
9676 %
9677 % If they passed de_DE, and txi-de_DE.tex doesn't exist,
9678 % try txi-de.tex.
9679 %
9680 \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
9681   \openin 1 txi-#1.tex
9682   \ifeof 1
9683     \errhelp = \nolanghelp
9684     \errmessage{Cannot read language file txi-#1.tex}%
9685   \else
9686     \globaldefs = 1  % everything in the txi-LL files needs to persist
9687     \input txi-#1.tex
9688   \fi
9689   \closein 1
9690 }
9691 }% end of special _ catcode
9692 %
9693 \newhelp\nolanghelp{The given language definition file cannot be found or
9694 is empty.  Maybe you need to install it?  Putting it in the current
9695 directory should work if nowhere else does.}
9696
9697 % This macro is called from txi-??.tex files; the first argument is the
9698 % \language name to set (without the "\lang@" prefix), the second and
9699 % third args are \{left,right}hyphenmin.
9700 %
9701 % The language names to pass are determined when the format is built.
9702 % See the etex.log file created at that time, e.g.,
9703 % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9704 %
9705 % With TeX Live 2008, etex now includes hyphenation patterns for all
9706 % available languages.  This means we can support hyphenation in
9707 % Texinfo, at least to some extent.  (This still doesn't solve the
9708 % accented characters problem.)
9709 %
9710 \catcode`@=11
9711 \def\txisetlanguage#1#2#3{%
9712   % do not set the language if the name is undefined in the current TeX.
9713   \expandafter\ifx\csname lang@#1\endcsname \relax
9714     \message{no patterns for #1}%
9715   \else
9716     \global\language = \csname lang@#1\endcsname
9717   \fi
9718   % but there is no harm in adjusting the hyphenmin values regardless.
9719   \global\lefthyphenmin = #2\relax
9720   \global\righthyphenmin = #3\relax
9721 }
9722
9723 % XeTeX and LuaTeX can handle Unicode natively.
9724 % Their default I/O uses UTF-8 sequences instead of a byte-wise operation.
9725 % Other TeX engines' I/O (pdfTeX, etc.) is byte-wise.
9726 %
9727 \newif\iftxinativeunicodecapable
9728 \newif\iftxiusebytewiseio
9729
9730 \ifx\XeTeXrevision\thisisundefined
9731   \ifx\luatexversion\thisisundefined
9732     \txinativeunicodecapablefalse
9733     \txiusebytewiseiotrue
9734   \else
9735     \txinativeunicodecapabletrue
9736     \txiusebytewiseiofalse
9737   \fi
9738 \else
9739   \txinativeunicodecapabletrue
9740   \txiusebytewiseiofalse
9741 \fi
9742
9743 % Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9744 % for non-UTF-8 (byte-wise) encodings.
9745 %
9746 \def\setbytewiseio{%
9747   \ifx\XeTeXrevision\thisisundefined
9748   \else
9749     \XeTeXdefaultencoding "bytes"  % For subsequent files to be read
9750     \XeTeXinputencoding "bytes"  % For document root file
9751     % Unfortunately, there seems to be no corresponding XeTeX command for
9752     % output encoding.  This is a problem for auxiliary index and TOC files.
9753     % The only solution would be perhaps to write out @U{...} sequences in
9754     % place of non-ASCII characters.
9755   \fi
9756
9757   \ifx\luatexversion\thisisundefined
9758   \else
9759     \directlua{
9760     local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9761     local function convert_char (char)
9762       return utf8_char(byte(char))
9763     end
9764
9765     local function convert_line (line)
9766       return gsub(line, ".", convert_char)
9767     end
9768
9769     callback.register("process_input_buffer", convert_line)
9770
9771     local function convert_line_out (line)
9772       local line_out = ""
9773       for c in string.utfvalues(line) do
9774          line_out = line_out .. string.char(c)
9775       end
9776       return line_out
9777     end
9778
9779     callback.register("process_output_buffer", convert_line_out)
9780     }
9781   \fi
9782
9783   \txiusebytewiseiotrue
9784 }
9785
9786
9787 % Helpers for encodings.
9788 % Set the catcode of characters 128 through 255 to the specified number.
9789 %
9790 \def\setnonasciicharscatcode#1{%
9791    \count255=128
9792    \loop\ifnum\count255<256
9793       \global\catcode\count255=#1\relax
9794       \advance\count255 by 1
9795    \repeat
9796 }
9797
9798 \def\setnonasciicharscatcodenonglobal#1{%
9799    \count255=128
9800    \loop\ifnum\count255<256
9801       \catcode\count255=#1\relax
9802       \advance\count255 by 1
9803    \repeat
9804 }
9805
9806 % @documentencoding sets the definition of non-ASCII characters
9807 % according to the specified encoding.
9808 %
9809 \def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9810 \def\documentencodingzzz#1{%
9811   %
9812   % Encoding being declared for the document.
9813   \def\declaredencoding{\csname #1.enc\endcsname}%
9814   %
9815   % Supported encodings: names converted to tokens in order to be able
9816   % to compare them with \ifx.
9817   \def\ascii{\csname US-ASCII.enc\endcsname}%
9818   \def\latnine{\csname ISO-8859-15.enc\endcsname}%
9819   \def\latone{\csname ISO-8859-1.enc\endcsname}%
9820   \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
9821   \def\utfeight{\csname UTF-8.enc\endcsname}%
9822   %
9823   \ifx \declaredencoding \ascii
9824      \asciichardefs
9825   %
9826   \else \ifx \declaredencoding \lattwo
9827      \iftxinativeunicodecapable
9828        \setbytewiseio
9829      \fi
9830      \setnonasciicharscatcode\active
9831      \lattwochardefs
9832   %
9833   \else \ifx \declaredencoding \latone
9834      \iftxinativeunicodecapable
9835        \setbytewiseio
9836      \fi
9837      \setnonasciicharscatcode\active
9838      \latonechardefs
9839   %
9840   \else \ifx \declaredencoding \latnine
9841      \iftxinativeunicodecapable
9842        \setbytewiseio
9843      \fi
9844      \setnonasciicharscatcode\active
9845      \latninechardefs
9846   %
9847   \else \ifx \declaredencoding \utfeight
9848      \iftxinativeunicodecapable
9849        % For native Unicode handling (XeTeX and LuaTeX)
9850        \nativeunicodechardefs
9851      \else
9852        % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX)
9853        \setnonasciicharscatcode\active
9854        % since we already invoked \utfeightchardefs at the top level
9855        % (below), do not re-invoke it, otherwise our check for duplicated
9856        % definitions gets triggered.  Making non-ascii chars active is
9857        % sufficient.
9858      \fi
9859   %
9860   \else
9861     \message{Ignoring unknown document encoding: #1.}%
9862   %
9863   \fi % utfeight
9864   \fi % latnine
9865   \fi % latone
9866   \fi % lattwo
9867   \fi % ascii
9868   %
9869   \ifx\XeTeXrevision\thisisundefined
9870   \else
9871     \ifx \declaredencoding \utfeight
9872     \else
9873       \ifx \declaredencoding \ascii
9874       \else
9875         \message{Warning: XeTeX with non-UTF-8 encodings cannot handle %
9876         non-ASCII characters in auxiliary files.}%
9877       \fi
9878     \fi
9879   \fi
9880 }
9881
9882 % emacs-page
9883 % A message to be logged when using a character that isn't available
9884 % the default font encoding (OT1).
9885 %
9886 \def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
9887
9888 % Take account of \c (plain) vs. \, (Texinfo) difference.
9889 \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
9890
9891 % First, make active non-ASCII characters in order for them to be
9892 % correctly categorized when TeX reads the replacement text of
9893 % macros containing the character definitions.
9894 \setnonasciicharscatcode\active
9895 %
9896
9897 \def\gdefchar#1#2{%
9898 \gdef#1{%
9899    \ifpassthroughchars
9900      \string#1%
9901    \else
9902      #2%
9903    \fi
9904 }}
9905
9906 % Latin1 (ISO-8859-1) character definitions.
9907 \def\latonechardefs{%
9908   \gdefchar^^a0{\tie}
9909   \gdefchar^^a1{\exclamdown}
9910   \gdefchar^^a2{{\tcfont \char162}} % cent
9911   \gdefchar^^a3{\pounds{}}
9912   \gdefchar^^a4{{\tcfont \char164}} % currency
9913   \gdefchar^^a5{{\tcfont \char165}} % yen
9914   \gdefchar^^a6{{\tcfont \char166}} % broken bar
9915   \gdefchar^^a7{\S}
9916   \gdefchar^^a8{\"{}}
9917   \gdefchar^^a9{\copyright{}}
9918   \gdefchar^^aa{\ordf}
9919   \gdefchar^^ab{\guillemetleft{}}
9920   \gdefchar^^ac{\ensuremath\lnot}
9921   \gdefchar^^ad{\-}
9922   \gdefchar^^ae{\registeredsymbol{}}
9923   \gdefchar^^af{\={}}
9924   %
9925   \gdefchar^^b0{\textdegree}
9926   \gdefchar^^b1{$\pm$}
9927   \gdefchar^^b2{$^2$}
9928   \gdefchar^^b3{$^3$}
9929   \gdefchar^^b4{\'{}}
9930   \gdefchar^^b5{$\mu$}
9931   \gdefchar^^b6{\P}
9932   \gdefchar^^b7{\ensuremath\cdot}
9933   \gdefchar^^b8{\cedilla\ }
9934   \gdefchar^^b9{$^1$}
9935   \gdefchar^^ba{\ordm}
9936   \gdefchar^^bb{\guillemetright{}}
9937   \gdefchar^^bc{$1\over4$}
9938   \gdefchar^^bd{$1\over2$}
9939   \gdefchar^^be{$3\over4$}
9940   \gdefchar^^bf{\questiondown}
9941   %
9942   \gdefchar^^c0{\`A}
9943   \gdefchar^^c1{\'A}
9944   \gdefchar^^c2{\^A}
9945   \gdefchar^^c3{\~A}
9946   \gdefchar^^c4{\"A}
9947   \gdefchar^^c5{\ringaccent A}
9948   \gdefchar^^c6{\AE}
9949   \gdefchar^^c7{\cedilla C}
9950   \gdefchar^^c8{\`E}
9951   \gdefchar^^c9{\'E}
9952   \gdefchar^^ca{\^E}
9953   \gdefchar^^cb{\"E}
9954   \gdefchar^^cc{\`I}
9955   \gdefchar^^cd{\'I}
9956   \gdefchar^^ce{\^I}
9957   \gdefchar^^cf{\"I}
9958   %
9959   \gdefchar^^d0{\DH}
9960   \gdefchar^^d1{\~N}
9961   \gdefchar^^d2{\`O}
9962   \gdefchar^^d3{\'O}
9963   \gdefchar^^d4{\^O}
9964   \gdefchar^^d5{\~O}
9965   \gdefchar^^d6{\"O}
9966   \gdefchar^^d7{$\times$}
9967   \gdefchar^^d8{\O}
9968   \gdefchar^^d9{\`U}
9969   \gdefchar^^da{\'U}
9970   \gdefchar^^db{\^U}
9971   \gdefchar^^dc{\"U}
9972   \gdefchar^^dd{\'Y}
9973   \gdefchar^^de{\TH}
9974   \gdefchar^^df{\ss}
9975   %
9976   \gdefchar^^e0{\`a}
9977   \gdefchar^^e1{\'a}
9978   \gdefchar^^e2{\^a}
9979   \gdefchar^^e3{\~a}
9980   \gdefchar^^e4{\"a}
9981   \gdefchar^^e5{\ringaccent a}
9982   \gdefchar^^e6{\ae}
9983   \gdefchar^^e7{\cedilla c}
9984   \gdefchar^^e8{\`e}
9985   \gdefchar^^e9{\'e}
9986   \gdefchar^^ea{\^e}
9987   \gdefchar^^eb{\"e}
9988   \gdefchar^^ec{\`{\dotless i}}
9989   \gdefchar^^ed{\'{\dotless i}}
9990   \gdefchar^^ee{\^{\dotless i}}
9991   \gdefchar^^ef{\"{\dotless i}}
9992   %
9993   \gdefchar^^f0{\dh}
9994   \gdefchar^^f1{\~n}
9995   \gdefchar^^f2{\`o}
9996   \gdefchar^^f3{\'o}
9997   \gdefchar^^f4{\^o}
9998   \gdefchar^^f5{\~o}
9999   \gdefchar^^f6{\"o}
10000   \gdefchar^^f7{$\div$}
10001   \gdefchar^^f8{\o}
10002   \gdefchar^^f9{\`u}
10003   \gdefchar^^fa{\'u}
10004   \gdefchar^^fb{\^u}
10005   \gdefchar^^fc{\"u}
10006   \gdefchar^^fd{\'y}
10007   \gdefchar^^fe{\th}
10008   \gdefchar^^ff{\"y}
10009 }
10010
10011 % Latin9 (ISO-8859-15) encoding character definitions.
10012 \def\latninechardefs{%
10013   % Encoding is almost identical to Latin1.
10014   \latonechardefs
10015   %
10016   \gdefchar^^a4{\euro{}}
10017   \gdefchar^^a6{\v S}
10018   \gdefchar^^a8{\v s}
10019   \gdefchar^^b4{\v Z}
10020   \gdefchar^^b8{\v z}
10021   \gdefchar^^bc{\OE}
10022   \gdefchar^^bd{\oe}
10023   \gdefchar^^be{\"Y}
10024 }
10025
10026 % Latin2 (ISO-8859-2) character definitions.
10027 \def\lattwochardefs{%
10028   \gdefchar^^a0{\tie}
10029   \gdefchar^^a1{\ogonek{A}}
10030   \gdefchar^^a2{\u{}}
10031   \gdefchar^^a3{\L}
10032   \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
10033   \gdefchar^^a5{\v L}
10034   \gdefchar^^a6{\'S}
10035   \gdefchar^^a7{\S}
10036   \gdefchar^^a8{\"{}}
10037   \gdefchar^^a9{\v S}
10038   \gdefchar^^aa{\cedilla S}
10039   \gdefchar^^ab{\v T}
10040   \gdefchar^^ac{\'Z}
10041   \gdefchar^^ad{\-}
10042   \gdefchar^^ae{\v Z}
10043   \gdefchar^^af{\dotaccent Z}
10044   %
10045   \gdefchar^^b0{\textdegree{}}
10046   \gdefchar^^b1{\ogonek{a}}
10047   \gdefchar^^b2{\ogonek{ }}
10048   \gdefchar^^b3{\l}
10049   \gdefchar^^b4{\'{}}
10050   \gdefchar^^b5{\v l}
10051   \gdefchar^^b6{\'s}
10052   \gdefchar^^b7{\v{}}
10053   \gdefchar^^b8{\cedilla\ }
10054   \gdefchar^^b9{\v s}
10055   \gdefchar^^ba{\cedilla s}
10056   \gdefchar^^bb{\v t}
10057   \gdefchar^^bc{\'z}
10058   \gdefchar^^bd{\H{}}
10059   \gdefchar^^be{\v z}
10060   \gdefchar^^bf{\dotaccent z}
10061   %
10062   \gdefchar^^c0{\'R}
10063   \gdefchar^^c1{\'A}
10064   \gdefchar^^c2{\^A}
10065   \gdefchar^^c3{\u A}
10066   \gdefchar^^c4{\"A}
10067   \gdefchar^^c5{\'L}
10068   \gdefchar^^c6{\'C}
10069   \gdefchar^^c7{\cedilla C}
10070   \gdefchar^^c8{\v C}
10071   \gdefchar^^c9{\'E}
10072   \gdefchar^^ca{\ogonek{E}}
10073   \gdefchar^^cb{\"E}
10074   \gdefchar^^cc{\v E}
10075   \gdefchar^^cd{\'I}
10076   \gdefchar^^ce{\^I}
10077   \gdefchar^^cf{\v D}
10078   %
10079   \gdefchar^^d0{\DH}
10080   \gdefchar^^d1{\'N}
10081   \gdefchar^^d2{\v N}
10082   \gdefchar^^d3{\'O}
10083   \gdefchar^^d4{\^O}
10084   \gdefchar^^d5{\H O}
10085   \gdefchar^^d6{\"O}
10086   \gdefchar^^d7{$\times$}
10087   \gdefchar^^d8{\v R}
10088   \gdefchar^^d9{\ringaccent U}
10089   \gdefchar^^da{\'U}
10090   \gdefchar^^db{\H U}
10091   \gdefchar^^dc{\"U}
10092   \gdefchar^^dd{\'Y}
10093   \gdefchar^^de{\cedilla T}
10094   \gdefchar^^df{\ss}
10095   %
10096   \gdefchar^^e0{\'r}
10097   \gdefchar^^e1{\'a}
10098   \gdefchar^^e2{\^a}
10099   \gdefchar^^e3{\u a}
10100   \gdefchar^^e4{\"a}
10101   \gdefchar^^e5{\'l}
10102   \gdefchar^^e6{\'c}
10103   \gdefchar^^e7{\cedilla c}
10104   \gdefchar^^e8{\v c}
10105   \gdefchar^^e9{\'e}
10106   \gdefchar^^ea{\ogonek{e}}
10107   \gdefchar^^eb{\"e}
10108   \gdefchar^^ec{\v e}
10109   \gdefchar^^ed{\'{\dotless{i}}}
10110   \gdefchar^^ee{\^{\dotless{i}}}
10111   \gdefchar^^ef{\v d}
10112   %
10113   \gdefchar^^f0{\dh}
10114   \gdefchar^^f1{\'n}
10115   \gdefchar^^f2{\v n}
10116   \gdefchar^^f3{\'o}
10117   \gdefchar^^f4{\^o}
10118   \gdefchar^^f5{\H o}
10119   \gdefchar^^f6{\"o}
10120   \gdefchar^^f7{$\div$}
10121   \gdefchar^^f8{\v r}
10122   \gdefchar^^f9{\ringaccent u}
10123   \gdefchar^^fa{\'u}
10124   \gdefchar^^fb{\H u}
10125   \gdefchar^^fc{\"u}
10126   \gdefchar^^fd{\'y}
10127   \gdefchar^^fe{\cedilla t}
10128   \gdefchar^^ff{\dotaccent{}}
10129 }
10130
10131 % UTF-8 character definitions.
10132 %
10133 % This code to support UTF-8 is based on LaTeX's utf8.def, with some
10134 % changes for Texinfo conventions.  It is included here under the GPL by
10135 % permission from Frank Mittelbach and the LaTeX team.
10136 %
10137 \newcount\countUTFx
10138 \newcount\countUTFy
10139 \newcount\countUTFz
10140
10141 \gdef\UTFviiiTwoOctets#1#2{\expandafter
10142    \UTFviiiDefined\csname u8:#1\string #2\endcsname}
10143 %
10144 \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
10145    \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
10146 %
10147 \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
10148    \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
10149
10150 \gdef\UTFviiiDefined#1{%
10151   \ifx #1\relax
10152     \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10153   \else
10154     \expandafter #1%
10155   \fi
10156 }
10157
10158 % Give non-ASCII bytes the active definitions for processing UTF-8 sequences
10159 \begingroup
10160   \catcode`\~13
10161   \catcode`\$12
10162   \catcode`\"12
10163
10164   % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
10165   % substituting ~ and $ with a character token of that value.
10166   \def\UTFviiiLoop{%
10167     \global\catcode\countUTFx\active
10168     \uccode`\~\countUTFx
10169     \uccode`\$\countUTFx
10170     \uppercase\expandafter{\UTFviiiTmp}%
10171     \advance\countUTFx by 1
10172     \ifnum\countUTFx < \countUTFy
10173       \expandafter\UTFviiiLoop
10174     \fi}
10175
10176   % For bytes other than the first in a UTF-8 sequence.  Not expected to
10177   % be expanded except when writing to auxiliary files.
10178   \countUTFx = "80
10179   \countUTFy = "C2
10180   \def\UTFviiiTmp{%
10181     \gdef~{%
10182         \ifpassthroughchars $\fi}}%
10183   \UTFviiiLoop
10184
10185   \countUTFx = "C2
10186   \countUTFy = "E0
10187   \def\UTFviiiTmp{%
10188     \gdef~{%
10189         \ifpassthroughchars $%
10190         \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
10191   \UTFviiiLoop
10192
10193   \countUTFx = "E0
10194   \countUTFy = "F0
10195   \def\UTFviiiTmp{%
10196     \gdef~{%
10197         \ifpassthroughchars $%
10198         \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
10199   \UTFviiiLoop
10200
10201   \countUTFx = "F0
10202   \countUTFy = "F4
10203   \def\UTFviiiTmp{%
10204     \gdef~{%
10205         \ifpassthroughchars $%
10206         \else\expandafter\UTFviiiFourOctets\expandafter$\fi
10207         }}%
10208   \UTFviiiLoop
10209 \endgroup
10210
10211 \def\globallet{\global\let} % save some \expandafter's below
10212
10213 % @U{xxxx} to produce U+xxxx, if we support it.
10214 \def\U#1{%
10215   \expandafter\ifx\csname uni:#1\endcsname \relax
10216     \iftxinativeunicodecapable
10217       % All Unicode characters can be used if native Unicode handling is
10218       % active.  However, if the font does not have the glyph,
10219       % letters are missing.
10220       \begingroup
10221         \uccode`\.="#1\relax
10222         \uppercase{.}
10223       \endgroup
10224     \else
10225       \errhelp = \EMsimple
10226       \errmessage{Unicode character U+#1 not supported, sorry}%
10227     \fi
10228   \else
10229     \csname uni:#1\endcsname
10230   \fi
10231 }
10232
10233 % These macros are used here to construct the name of a control
10234 % sequence to be defined.
10235 \def\UTFviiiTwoOctetsName#1#2{%
10236   \csname u8:#1\string #2\endcsname}%
10237 \def\UTFviiiThreeOctetsName#1#2#3{%
10238   \csname u8:#1\string #2\string #3\endcsname}%
10239 \def\UTFviiiFourOctetsName#1#2#3#4{%
10240   \csname u8:#1\string #2\string #3\string #4\endcsname}%
10241
10242 % For UTF-8 byte sequences (TeX, e-TeX and pdfTeX),
10243 % provide a definition macro to replace a Unicode character;
10244 % this gets used by the @U command
10245 %
10246 \begingroup
10247   \catcode`\"=12
10248   \catcode`\<=12
10249   \catcode`\.=12
10250   \catcode`\,=12
10251   \catcode`\;=12
10252   \catcode`\!=12
10253   \catcode`\~=13
10254   \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
10255     \countUTFz = "#1\relax
10256     \begingroup
10257       \parseXMLCharref
10258
10259       % Give \u8:... its definition.  The sequence of seven \expandafter's
10260       % expands after the \gdef three times, e.g.
10261       %
10262       % 1.  \UTFviiTwoOctetsName B1 B2
10263       % 2.  \csname u8:B1 \string B2 \endcsname
10264       % 3.  \u8: B1 B2  (a single control sequence token)
10265       %
10266       \expandafter\expandafter
10267       \expandafter\expandafter
10268       \expandafter\expandafter
10269       \expandafter\gdef       \UTFviiiTmp{#2}%
10270       %
10271       \expandafter\ifx\csname uni:#1\endcsname \relax \else
10272        \message{Internal error, already defined: #1}%
10273       \fi
10274       %
10275       % define an additional control sequence for this code point.
10276       \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
10277     \endgroup}
10278   %
10279   % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp
10280   % to the corresponding UTF-8 sequence.
10281   \gdef\parseXMLCharref{%
10282     \ifnum\countUTFz < "20\relax
10283       \errhelp = \EMsimple
10284       \errmessage{Cannot define Unicode char value < 0020}%
10285     \else\ifnum\countUTFz < "800\relax
10286       \parseUTFviiiA,%
10287       \parseUTFviiiB C\UTFviiiTwoOctetsName.,%
10288     \else\ifnum\countUTFz < "10000\relax
10289       \parseUTFviiiA;%
10290       \parseUTFviiiA,%
10291       \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}%
10292     \else
10293       \parseUTFviiiA;%
10294       \parseUTFviiiA,%
10295       \parseUTFviiiA!%
10296       \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}%
10297     \fi\fi\fi
10298   }
10299
10300   % Extract a byte from the end of the UTF-8 representation of \countUTFx.
10301   % It must be a non-initial byte in the sequence.
10302   % Change \uccode of #1 for it to be used in \parseUTFviiiB as one
10303   % of the bytes.
10304   \gdef\parseUTFviiiA#1{%
10305     \countUTFx = \countUTFz
10306     \divide\countUTFz by 64
10307     \countUTFy = \countUTFz  % Save to be the future value of \countUTFz.
10308     \multiply\countUTFz by 64
10309
10310     % \countUTFz is now \countUTFx with the last 5 bits cleared.  Subtract
10311     % in order to get the last five bits.
10312     \advance\countUTFx by -\countUTFz
10313
10314     % Convert this to the byte in the UTF-8 sequence.
10315     \advance\countUTFx by 128
10316     \uccode `#1\countUTFx
10317     \countUTFz = \countUTFy}
10318
10319   % Used to put a UTF-8 byte sequence into \UTFviiiTmp
10320   % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8
10321   %    sequence.
10322   % #2 is one of the \UTFviii*OctetsName macros.
10323   % #3 is always a full stop (.)
10324   % #4 is a template for the other bytes in the sequence.  The values for these
10325   %    bytes is substituted in here with \uppercase using the \uccode's.
10326   \gdef\parseUTFviiiB#1#2#3#4{%
10327     \advance\countUTFz by "#10\relax
10328     \uccode `#3\countUTFz
10329     \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10330 \endgroup
10331
10332 % For native Unicode handling (XeTeX and LuaTeX),
10333 % provide a definition macro that sets a catcode to `other' non-globally
10334 %
10335 \def\DeclareUnicodeCharacterNativeOther#1#2{%
10336   \catcode"#1=\other
10337 }
10338
10339 % https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10340 % U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10341 % U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10342 % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10343 % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10344 %
10345 % Many of our renditions are less than wonderful, and all the missing
10346 % characters are available somewhere.  Loading the necessary fonts
10347 % awaits user request.  We can't truly support Unicode without
10348 % reimplementing everything that's been done in LaTeX for many years,
10349 % plus probably using luatex or xetex, and who knows what else.
10350 % We won't be doing that here in this simple file.  But we can try to at
10351 % least make most of the characters not bomb out.
10352 %
10353 \def\unicodechardefs{%
10354   \DeclareUnicodeCharacter{0020}{ } % space
10355   \DeclareUnicodeCharacter{0021}{\char"21 }% % space to terminate number
10356   \DeclareUnicodeCharacter{0022}{\char"22 }%
10357   \DeclareUnicodeCharacter{0023}{\char"23 }%
10358   \DeclareUnicodeCharacter{0024}{\char"24 }%
10359   \DeclareUnicodeCharacter{0025}{\char"25 }%
10360   \DeclareUnicodeCharacter{0026}{\char"26 }%
10361   \DeclareUnicodeCharacter{0027}{\char"27 }%
10362   \DeclareUnicodeCharacter{0028}{\char"28 }%
10363   \DeclareUnicodeCharacter{0029}{\char"29 }%
10364   \DeclareUnicodeCharacter{002A}{\char"2A }%
10365   \DeclareUnicodeCharacter{002B}{\char"2B }%
10366   \DeclareUnicodeCharacter{002C}{\char"2C }%
10367   \DeclareUnicodeCharacter{002D}{\char"2D }%
10368   \DeclareUnicodeCharacter{002E}{\char"2E }%
10369   \DeclareUnicodeCharacter{002F}{\char"2F }%
10370   \DeclareUnicodeCharacter{0030}{0}%
10371   \DeclareUnicodeCharacter{0031}{1}%
10372   \DeclareUnicodeCharacter{0032}{2}%
10373   \DeclareUnicodeCharacter{0033}{3}%
10374   \DeclareUnicodeCharacter{0034}{4}%
10375   \DeclareUnicodeCharacter{0035}{5}%
10376   \DeclareUnicodeCharacter{0036}{6}%
10377   \DeclareUnicodeCharacter{0037}{7}%
10378   \DeclareUnicodeCharacter{0038}{8}%
10379   \DeclareUnicodeCharacter{0039}{9}%
10380   \DeclareUnicodeCharacter{003A}{\char"3A }%
10381   \DeclareUnicodeCharacter{003B}{\char"3B }%
10382   \DeclareUnicodeCharacter{003C}{\char"3C }%
10383   \DeclareUnicodeCharacter{003D}{\char"3D }%
10384   \DeclareUnicodeCharacter{003E}{\char"3E }%
10385   \DeclareUnicodeCharacter{003F}{\char"3F }%
10386   \DeclareUnicodeCharacter{0040}{\char"40 }%
10387   \DeclareUnicodeCharacter{0041}{A}%
10388   \DeclareUnicodeCharacter{0042}{B}%
10389   \DeclareUnicodeCharacter{0043}{C}%
10390   \DeclareUnicodeCharacter{0044}{D}%
10391   \DeclareUnicodeCharacter{0045}{E}%
10392   \DeclareUnicodeCharacter{0046}{F}%
10393   \DeclareUnicodeCharacter{0047}{G}%
10394   \DeclareUnicodeCharacter{0048}{H}%
10395   \DeclareUnicodeCharacter{0049}{I}%
10396   \DeclareUnicodeCharacter{004A}{J}%
10397   \DeclareUnicodeCharacter{004B}{K}%
10398   \DeclareUnicodeCharacter{004C}{L}%
10399   \DeclareUnicodeCharacter{004D}{M}%
10400   \DeclareUnicodeCharacter{004E}{N}%
10401   \DeclareUnicodeCharacter{004F}{O}%
10402   \DeclareUnicodeCharacter{0050}{P}%
10403   \DeclareUnicodeCharacter{0051}{Q}%
10404   \DeclareUnicodeCharacter{0052}{R}%
10405   \DeclareUnicodeCharacter{0053}{S}%
10406   \DeclareUnicodeCharacter{0054}{T}%
10407   \DeclareUnicodeCharacter{0055}{U}%
10408   \DeclareUnicodeCharacter{0056}{V}%
10409   \DeclareUnicodeCharacter{0057}{W}%
10410   \DeclareUnicodeCharacter{0058}{X}%
10411   \DeclareUnicodeCharacter{0059}{Y}%
10412   \DeclareUnicodeCharacter{005A}{Z}%
10413   \DeclareUnicodeCharacter{005B}{\char"5B }%
10414   \DeclareUnicodeCharacter{005C}{\char"5C }%
10415   \DeclareUnicodeCharacter{005D}{\char"5D }%
10416   \DeclareUnicodeCharacter{005E}{\char"5E }%
10417   \DeclareUnicodeCharacter{005F}{\char"5F }%
10418   \DeclareUnicodeCharacter{0060}{\char"60 }%
10419   \DeclareUnicodeCharacter{0061}{a}%
10420   \DeclareUnicodeCharacter{0062}{b}%
10421   \DeclareUnicodeCharacter{0063}{c}%
10422   \DeclareUnicodeCharacter{0064}{d}%
10423   \DeclareUnicodeCharacter{0065}{e}%
10424   \DeclareUnicodeCharacter{0066}{f}%
10425   \DeclareUnicodeCharacter{0067}{g}%
10426   \DeclareUnicodeCharacter{0068}{h}%
10427   \DeclareUnicodeCharacter{0069}{i}%
10428   \DeclareUnicodeCharacter{006A}{j}%
10429   \DeclareUnicodeCharacter{006B}{k}%
10430   \DeclareUnicodeCharacter{006C}{l}%
10431   \DeclareUnicodeCharacter{006D}{m}%
10432   \DeclareUnicodeCharacter{006E}{n}%
10433   \DeclareUnicodeCharacter{006F}{o}%
10434   \DeclareUnicodeCharacter{0070}{p}%
10435   \DeclareUnicodeCharacter{0071}{q}%
10436   \DeclareUnicodeCharacter{0072}{r}%
10437   \DeclareUnicodeCharacter{0073}{s}%
10438   \DeclareUnicodeCharacter{0074}{t}%
10439   \DeclareUnicodeCharacter{0075}{u}%
10440   \DeclareUnicodeCharacter{0076}{v}%
10441   \DeclareUnicodeCharacter{0077}{w}%
10442   \DeclareUnicodeCharacter{0078}{x}%
10443   \DeclareUnicodeCharacter{0079}{y}%
10444   \DeclareUnicodeCharacter{007A}{z}%
10445   \DeclareUnicodeCharacter{007B}{\char"7B }%
10446   \DeclareUnicodeCharacter{007C}{\char"7C }%
10447   \DeclareUnicodeCharacter{007D}{\char"7D }%
10448   \DeclareUnicodeCharacter{007E}{\char"7E }%
10449   % \DeclareUnicodeCharacter{007F}{} % DEL
10450   %
10451   \DeclareUnicodeCharacter{00A0}{\tie}%
10452   \DeclareUnicodeCharacter{00A1}{\exclamdown}%
10453   \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
10454   \DeclareUnicodeCharacter{00A3}{\pounds{}}%
10455   \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10456   \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10457   \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
10458   \DeclareUnicodeCharacter{00A7}{\S}%
10459   \DeclareUnicodeCharacter{00A8}{\"{ }}%
10460   \DeclareUnicodeCharacter{00A9}{\copyright{}}%
10461   \DeclareUnicodeCharacter{00AA}{\ordf}%
10462   \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}%
10463   \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10464   \DeclareUnicodeCharacter{00AD}{\-}%
10465   \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}%
10466   \DeclareUnicodeCharacter{00AF}{\={ }}%
10467   %
10468   \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
10469   \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10470   \DeclareUnicodeCharacter{00B2}{$^2$}%
10471   \DeclareUnicodeCharacter{00B3}{$^3$}%
10472   \DeclareUnicodeCharacter{00B4}{\'{ }}%
10473   \DeclareUnicodeCharacter{00B5}{$\mu$}%
10474   \DeclareUnicodeCharacter{00B6}{\P}%
10475   \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10476   \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10477   \DeclareUnicodeCharacter{00B9}{$^1$}%
10478   \DeclareUnicodeCharacter{00BA}{\ordm}%
10479   \DeclareUnicodeCharacter{00BB}{\guillemetright{}}%
10480   \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10481   \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10482   \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10483   \DeclareUnicodeCharacter{00BF}{\questiondown}%
10484   %
10485   \DeclareUnicodeCharacter{00C0}{\`A}%
10486   \DeclareUnicodeCharacter{00C1}{\'A}%
10487   \DeclareUnicodeCharacter{00C2}{\^A}%
10488   \DeclareUnicodeCharacter{00C3}{\~A}%
10489   \DeclareUnicodeCharacter{00C4}{\"A}%
10490   \DeclareUnicodeCharacter{00C5}{\AA}%
10491   \DeclareUnicodeCharacter{00C6}{\AE}%
10492   \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10493   \DeclareUnicodeCharacter{00C8}{\`E}%
10494   \DeclareUnicodeCharacter{00C9}{\'E}%
10495   \DeclareUnicodeCharacter{00CA}{\^E}%
10496   \DeclareUnicodeCharacter{00CB}{\"E}%
10497   \DeclareUnicodeCharacter{00CC}{\`I}%
10498   \DeclareUnicodeCharacter{00CD}{\'I}%
10499   \DeclareUnicodeCharacter{00CE}{\^I}%
10500   \DeclareUnicodeCharacter{00CF}{\"I}%
10501   %
10502   \DeclareUnicodeCharacter{00D0}{\DH}%
10503   \DeclareUnicodeCharacter{00D1}{\~N}%
10504   \DeclareUnicodeCharacter{00D2}{\`O}%
10505   \DeclareUnicodeCharacter{00D3}{\'O}%
10506   \DeclareUnicodeCharacter{00D4}{\^O}%
10507   \DeclareUnicodeCharacter{00D5}{\~O}%
10508   \DeclareUnicodeCharacter{00D6}{\"O}%
10509   \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10510   \DeclareUnicodeCharacter{00D8}{\O}%
10511   \DeclareUnicodeCharacter{00D9}{\`U}%
10512   \DeclareUnicodeCharacter{00DA}{\'U}%
10513   \DeclareUnicodeCharacter{00DB}{\^U}%
10514   \DeclareUnicodeCharacter{00DC}{\"U}%
10515   \DeclareUnicodeCharacter{00DD}{\'Y}%
10516   \DeclareUnicodeCharacter{00DE}{\TH}%
10517   \DeclareUnicodeCharacter{00DF}{\ss}%
10518   %
10519   \DeclareUnicodeCharacter{00E0}{\`a}%
10520   \DeclareUnicodeCharacter{00E1}{\'a}%
10521   \DeclareUnicodeCharacter{00E2}{\^a}%
10522   \DeclareUnicodeCharacter{00E3}{\~a}%
10523   \DeclareUnicodeCharacter{00E4}{\"a}%
10524   \DeclareUnicodeCharacter{00E5}{\aa}%
10525   \DeclareUnicodeCharacter{00E6}{\ae}%
10526   \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10527   \DeclareUnicodeCharacter{00E8}{\`e}%
10528   \DeclareUnicodeCharacter{00E9}{\'e}%
10529   \DeclareUnicodeCharacter{00EA}{\^e}%
10530   \DeclareUnicodeCharacter{00EB}{\"e}%
10531   \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10532   \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10533   \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10534   \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10535   %
10536   \DeclareUnicodeCharacter{00F0}{\dh}%
10537   \DeclareUnicodeCharacter{00F1}{\~n}%
10538   \DeclareUnicodeCharacter{00F2}{\`o}%
10539   \DeclareUnicodeCharacter{00F3}{\'o}%
10540   \DeclareUnicodeCharacter{00F4}{\^o}%
10541   \DeclareUnicodeCharacter{00F5}{\~o}%
10542   \DeclareUnicodeCharacter{00F6}{\"o}%
10543   \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10544   \DeclareUnicodeCharacter{00F8}{\o}%
10545   \DeclareUnicodeCharacter{00F9}{\`u}%
10546   \DeclareUnicodeCharacter{00FA}{\'u}%
10547   \DeclareUnicodeCharacter{00FB}{\^u}%
10548   \DeclareUnicodeCharacter{00FC}{\"u}%
10549   \DeclareUnicodeCharacter{00FD}{\'y}%
10550   \DeclareUnicodeCharacter{00FE}{\th}%
10551   \DeclareUnicodeCharacter{00FF}{\"y}%
10552   %
10553   \DeclareUnicodeCharacter{0100}{\=A}%
10554   \DeclareUnicodeCharacter{0101}{\=a}%
10555   \DeclareUnicodeCharacter{0102}{\u{A}}%
10556   \DeclareUnicodeCharacter{0103}{\u{a}}%
10557   \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10558   \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10559   \DeclareUnicodeCharacter{0106}{\'C}%
10560   \DeclareUnicodeCharacter{0107}{\'c}%
10561   \DeclareUnicodeCharacter{0108}{\^C}%
10562   \DeclareUnicodeCharacter{0109}{\^c}%
10563   \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10564   \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10565   \DeclareUnicodeCharacter{010C}{\v{C}}%
10566   \DeclareUnicodeCharacter{010D}{\v{c}}%
10567   \DeclareUnicodeCharacter{010E}{\v{D}}%
10568   \DeclareUnicodeCharacter{010F}{d'}%
10569   %
10570   \DeclareUnicodeCharacter{0110}{\DH}%
10571   \DeclareUnicodeCharacter{0111}{\dh}%
10572   \DeclareUnicodeCharacter{0112}{\=E}%
10573   \DeclareUnicodeCharacter{0113}{\=e}%
10574   \DeclareUnicodeCharacter{0114}{\u{E}}%
10575   \DeclareUnicodeCharacter{0115}{\u{e}}%
10576   \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10577   \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10578   \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10579   \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10580   \DeclareUnicodeCharacter{011A}{\v{E}}%
10581   \DeclareUnicodeCharacter{011B}{\v{e}}%
10582   \DeclareUnicodeCharacter{011C}{\^G}%
10583   \DeclareUnicodeCharacter{011D}{\^g}%
10584   \DeclareUnicodeCharacter{011E}{\u{G}}%
10585   \DeclareUnicodeCharacter{011F}{\u{g}}%
10586   %
10587   \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10588   \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10589   \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10590   \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10591   \DeclareUnicodeCharacter{0124}{\^H}%
10592   \DeclareUnicodeCharacter{0125}{\^h}%
10593   \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10594   \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10595   \DeclareUnicodeCharacter{0128}{\~I}%
10596   \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10597   \DeclareUnicodeCharacter{012A}{\=I}%
10598   \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10599   \DeclareUnicodeCharacter{012C}{\u{I}}%
10600   \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10601   \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10602   \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10603   %
10604   \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10605   \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10606   \DeclareUnicodeCharacter{0132}{IJ}%
10607   \DeclareUnicodeCharacter{0133}{ij}%
10608   \DeclareUnicodeCharacter{0134}{\^J}%
10609   \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10610   \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10611   \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10612   \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10613   \DeclareUnicodeCharacter{0139}{\'L}%
10614   \DeclareUnicodeCharacter{013A}{\'l}%
10615   \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10616   \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
10617   \DeclareUnicodeCharacter{013D}{L'}% should kern
10618   \DeclareUnicodeCharacter{013E}{l'}% should kern
10619   \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10620   %
10621   \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10622   \DeclareUnicodeCharacter{0141}{\L}%
10623   \DeclareUnicodeCharacter{0142}{\l}%
10624   \DeclareUnicodeCharacter{0143}{\'N}%
10625   \DeclareUnicodeCharacter{0144}{\'n}%
10626   \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10627   \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10628   \DeclareUnicodeCharacter{0147}{\v{N}}%
10629   \DeclareUnicodeCharacter{0148}{\v{n}}%
10630   \DeclareUnicodeCharacter{0149}{'n}%
10631   \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10632   \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10633   \DeclareUnicodeCharacter{014C}{\=O}%
10634   \DeclareUnicodeCharacter{014D}{\=o}%
10635   \DeclareUnicodeCharacter{014E}{\u{O}}%
10636   \DeclareUnicodeCharacter{014F}{\u{o}}%
10637   %
10638   \DeclareUnicodeCharacter{0150}{\H{O}}%
10639   \DeclareUnicodeCharacter{0151}{\H{o}}%
10640   \DeclareUnicodeCharacter{0152}{\OE}%
10641   \DeclareUnicodeCharacter{0153}{\oe}%
10642   \DeclareUnicodeCharacter{0154}{\'R}%
10643   \DeclareUnicodeCharacter{0155}{\'r}%
10644   \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10645   \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10646   \DeclareUnicodeCharacter{0158}{\v{R}}%
10647   \DeclareUnicodeCharacter{0159}{\v{r}}%
10648   \DeclareUnicodeCharacter{015A}{\'S}%
10649   \DeclareUnicodeCharacter{015B}{\'s}%
10650   \DeclareUnicodeCharacter{015C}{\^S}%
10651   \DeclareUnicodeCharacter{015D}{\^s}%
10652   \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10653   \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10654   %
10655   \DeclareUnicodeCharacter{0160}{\v{S}}%
10656   \DeclareUnicodeCharacter{0161}{\v{s}}%
10657   \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10658   \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10659   \DeclareUnicodeCharacter{0164}{\v{T}}%
10660   \DeclareUnicodeCharacter{0165}{\v{t}}%
10661   \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10662   \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10663   \DeclareUnicodeCharacter{0168}{\~U}%
10664   \DeclareUnicodeCharacter{0169}{\~u}%
10665   \DeclareUnicodeCharacter{016A}{\=U}%
10666   \DeclareUnicodeCharacter{016B}{\=u}%
10667   \DeclareUnicodeCharacter{016C}{\u{U}}%
10668   \DeclareUnicodeCharacter{016D}{\u{u}}%
10669   \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10670   \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10671   %
10672   \DeclareUnicodeCharacter{0170}{\H{U}}%
10673   \DeclareUnicodeCharacter{0171}{\H{u}}%
10674   \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10675   \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10676   \DeclareUnicodeCharacter{0174}{\^W}%
10677   \DeclareUnicodeCharacter{0175}{\^w}%
10678   \DeclareUnicodeCharacter{0176}{\^Y}%
10679   \DeclareUnicodeCharacter{0177}{\^y}%
10680   \DeclareUnicodeCharacter{0178}{\"Y}%
10681   \DeclareUnicodeCharacter{0179}{\'Z}%
10682   \DeclareUnicodeCharacter{017A}{\'z}%
10683   \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10684   \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10685   \DeclareUnicodeCharacter{017D}{\v{Z}}%
10686   \DeclareUnicodeCharacter{017E}{\v{z}}%
10687   \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10688   %
10689   \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10690   \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10691   \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10692   \DeclareUnicodeCharacter{01C7}{LJ}%
10693   \DeclareUnicodeCharacter{01C8}{Lj}%
10694   \DeclareUnicodeCharacter{01C9}{lj}%
10695   \DeclareUnicodeCharacter{01CA}{NJ}%
10696   \DeclareUnicodeCharacter{01CB}{Nj}%
10697   \DeclareUnicodeCharacter{01CC}{nj}%
10698   \DeclareUnicodeCharacter{01CD}{\v{A}}%
10699   \DeclareUnicodeCharacter{01CE}{\v{a}}%
10700   \DeclareUnicodeCharacter{01CF}{\v{I}}%
10701   %
10702   \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10703   \DeclareUnicodeCharacter{01D1}{\v{O}}%
10704   \DeclareUnicodeCharacter{01D2}{\v{o}}%
10705   \DeclareUnicodeCharacter{01D3}{\v{U}}%
10706   \DeclareUnicodeCharacter{01D4}{\v{u}}%
10707   %
10708   \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10709   \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10710   \DeclareUnicodeCharacter{01E6}{\v{G}}%
10711   \DeclareUnicodeCharacter{01E7}{\v{g}}%
10712   \DeclareUnicodeCharacter{01E8}{\v{K}}%
10713   \DeclareUnicodeCharacter{01E9}{\v{k}}%
10714   %
10715   \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10716   \DeclareUnicodeCharacter{01F1}{DZ}%
10717   \DeclareUnicodeCharacter{01F2}{Dz}%
10718   \DeclareUnicodeCharacter{01F3}{dz}%
10719   \DeclareUnicodeCharacter{01F4}{\'G}%
10720   \DeclareUnicodeCharacter{01F5}{\'g}%
10721   \DeclareUnicodeCharacter{01F8}{\`N}%
10722   \DeclareUnicodeCharacter{01F9}{\`n}%
10723   \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10724   \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10725   \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10726   \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10727   %
10728   \DeclareUnicodeCharacter{021E}{\v{H}}%
10729   \DeclareUnicodeCharacter{021F}{\v{h}}%
10730   %
10731   \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10732   \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10733   \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10734   \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10735   \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10736   \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10737   %
10738   \DeclareUnicodeCharacter{0232}{\=Y}%
10739   \DeclareUnicodeCharacter{0233}{\=y}%
10740   \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10741   %
10742   \DeclareUnicodeCharacter{02BC}{'}%
10743   %
10744   \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10745   %
10746   % Greek letters upper case
10747   \DeclareUnicodeCharacter{0391}{{\it A}}%
10748   \DeclareUnicodeCharacter{0392}{{\it B}}%
10749   \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10750   \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10751   \DeclareUnicodeCharacter{0395}{{\it E}}%
10752   \DeclareUnicodeCharacter{0396}{{\it Z}}%
10753   \DeclareUnicodeCharacter{0397}{{\it H}}%
10754   \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10755   \DeclareUnicodeCharacter{0399}{{\it I}}%
10756   \DeclareUnicodeCharacter{039A}{{\it K}}%
10757   \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10758   \DeclareUnicodeCharacter{039C}{{\it M}}%
10759   \DeclareUnicodeCharacter{039D}{{\it N}}%
10760   \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10761   \DeclareUnicodeCharacter{039F}{{\it O}}%
10762   \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10763   \DeclareUnicodeCharacter{03A1}{{\it P}}%
10764   %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
10765   \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10766   \DeclareUnicodeCharacter{03A4}{{\it T}}%
10767   \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10768   \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10769   \DeclareUnicodeCharacter{03A7}{{\it X}}%
10770   \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10771   \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10772   %
10773   % Vowels with accents
10774   \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10775   \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10776   \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10777   \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10778   \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10779   \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10780   %
10781   % Standalone accent
10782   \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10783   %
10784   % Greek letters lower case
10785   \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10786   \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10787   \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10788   \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10789   \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10790   \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10791   \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10792   \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10793   \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10794   \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10795   \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10796   \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10797   \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10798   \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10799   \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10800   \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10801   \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10802   \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10803   \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10804   \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10805   \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10806   \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10807   \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10808   \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10809   \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10810   %
10811   % More Greek vowels with accents
10812   \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10813   \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10814   \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10815   \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10816   \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10817   %
10818   % Variant Greek letters
10819   \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10820   \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10821   \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10822   %
10823   \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10824   \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10825   \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10826   \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10827   \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10828   \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10829   \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10830   \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10831   \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10832   \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10833   \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10834   \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10835   %
10836   \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10837   \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10838   %
10839   \DeclareUnicodeCharacter{1E20}{\=G}%
10840   \DeclareUnicodeCharacter{1E21}{\=g}%
10841   \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10842   \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10843   \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10844   \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10845   \DeclareUnicodeCharacter{1E26}{\"H}%
10846   \DeclareUnicodeCharacter{1E27}{\"h}%
10847   %
10848   \DeclareUnicodeCharacter{1E30}{\'K}%
10849   \DeclareUnicodeCharacter{1E31}{\'k}%
10850   \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10851   \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10852   \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10853   \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10854   \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10855   \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10856   \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10857   \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10858   \DeclareUnicodeCharacter{1E3E}{\'M}%
10859   \DeclareUnicodeCharacter{1E3F}{\'m}%
10860   %
10861   \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10862   \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10863   \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10864   \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10865   \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10866   \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10867   \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10868   \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10869   \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10870   \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10871   %
10872   \DeclareUnicodeCharacter{1E54}{\'P}%
10873   \DeclareUnicodeCharacter{1E55}{\'p}%
10874   \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10875   \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10876   \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10877   \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10878   \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10879   \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10880   \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10881   \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10882   %
10883   \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10884   \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10885   \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10886   \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10887   \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10888   \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10889   \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10890   \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10891   \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10892   \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10893   %
10894   \DeclareUnicodeCharacter{1E7C}{\~V}%
10895   \DeclareUnicodeCharacter{1E7D}{\~v}%
10896   \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10897   \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10898   %
10899   \DeclareUnicodeCharacter{1E80}{\`W}%
10900   \DeclareUnicodeCharacter{1E81}{\`w}%
10901   \DeclareUnicodeCharacter{1E82}{\'W}%
10902   \DeclareUnicodeCharacter{1E83}{\'w}%
10903   \DeclareUnicodeCharacter{1E84}{\"W}%
10904   \DeclareUnicodeCharacter{1E85}{\"w}%
10905   \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10906   \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10907   \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10908   \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10909   \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10910   \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10911   \DeclareUnicodeCharacter{1E8C}{\"X}%
10912   \DeclareUnicodeCharacter{1E8D}{\"x}%
10913   \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10914   \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10915   %
10916   \DeclareUnicodeCharacter{1E90}{\^Z}%
10917   \DeclareUnicodeCharacter{1E91}{\^z}%
10918   \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
10919   \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
10920   \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
10921   \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
10922   \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
10923   \DeclareUnicodeCharacter{1E97}{\"t}%
10924   \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
10925   \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
10926   %
10927   \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
10928   \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
10929   %
10930   \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
10931   \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
10932   \DeclareUnicodeCharacter{1EBC}{\~E}%
10933   \DeclareUnicodeCharacter{1EBD}{\~e}%
10934   %
10935   \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
10936   \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
10937   \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
10938   \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
10939   %
10940   \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
10941   \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
10942   %
10943   \DeclareUnicodeCharacter{1EF2}{\`Y}%
10944   \DeclareUnicodeCharacter{1EF3}{\`y}%
10945   \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
10946   %
10947   \DeclareUnicodeCharacter{1EF8}{\~Y}%
10948   \DeclareUnicodeCharacter{1EF9}{\~y}%
10949   %
10950   % Exotic spaces
10951   \DeclareUnicodeCharacter{2007}{\hphantom{0}}%
10952   %
10953   % Punctuation
10954   \DeclareUnicodeCharacter{2013}{--}%
10955   \DeclareUnicodeCharacter{2014}{---}%
10956   \DeclareUnicodeCharacter{2018}{\quoteleft{}}%
10957   \DeclareUnicodeCharacter{2019}{\quoteright{}}%
10958   \DeclareUnicodeCharacter{201A}{\quotesinglbase{}}%
10959   \DeclareUnicodeCharacter{201C}{\quotedblleft{}}%
10960   \DeclareUnicodeCharacter{201D}{\quotedblright{}}%
10961   \DeclareUnicodeCharacter{201E}{\quotedblbase{}}%
10962   \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}%
10963   \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}%
10964   \DeclareUnicodeCharacter{2022}{\bullet{}}%
10965   \DeclareUnicodeCharacter{202F}{\thinspace}%
10966   \DeclareUnicodeCharacter{2026}{\dots{}}%
10967   \DeclareUnicodeCharacter{2039}{\guilsinglleft{}}%
10968   \DeclareUnicodeCharacter{203A}{\guilsinglright{}}%
10969   %
10970   \DeclareUnicodeCharacter{20AC}{\euro{}}%
10971   %
10972   \DeclareUnicodeCharacter{2192}{\expansion{}}%
10973   \DeclareUnicodeCharacter{21D2}{\result{}}%
10974   %
10975   % Mathematical symbols
10976   \DeclareUnicodeCharacter{2200}{\ensuremath\forall}%
10977   \DeclareUnicodeCharacter{2203}{\ensuremath\exists}%
10978   \DeclareUnicodeCharacter{2208}{\ensuremath\in}%
10979   \DeclareUnicodeCharacter{2212}{\minus{}}%
10980   \DeclareUnicodeCharacter{2217}{\ast}%
10981   \DeclareUnicodeCharacter{221E}{\ensuremath\infty}%
10982   \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}%
10983   \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}%
10984   \DeclareUnicodeCharacter{2229}{\ensuremath\cap}%
10985   \DeclareUnicodeCharacter{2261}{\equiv{}}%
10986   \DeclareUnicodeCharacter{2264}{\ensuremath\leq}%
10987   \DeclareUnicodeCharacter{2265}{\ensuremath\geq}%
10988   \DeclareUnicodeCharacter{2282}{\ensuremath\subset}%
10989   \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}%
10990   %
10991   \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}%
10992   \DeclareUnicodeCharacter{2032}{\ensuremath\prime}%
10993   \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}%
10994   \DeclareUnicodeCharacter{2111}{\ensuremath\Im}%
10995   \DeclareUnicodeCharacter{2113}{\ensuremath\ell}%
10996   \DeclareUnicodeCharacter{2118}{\ensuremath\wp}%
10997   \DeclareUnicodeCharacter{211C}{\ensuremath\Re}%
10998   \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}%
10999   \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}%
11000   \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}%
11001   \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}%
11002   \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}%
11003   \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}%
11004   \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}%
11005   \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}%
11006   \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}%
11007   \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}%
11008   \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}%
11009   \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}%
11010   \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}%
11011   \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}%
11012   \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}%
11013   \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}%
11014   \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}%
11015   \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}%
11016   \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}%
11017   \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}%
11018   \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}%
11019   \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}%
11020   \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}%
11021   \DeclareUnicodeCharacter{2202}{\ensuremath\partial}%
11022   \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}%
11023   \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}%
11024   \DeclareUnicodeCharacter{2209}{\ensuremath\notin}%
11025   \DeclareUnicodeCharacter{220B}{\ensuremath\owns}%
11026   \DeclareUnicodeCharacter{220F}{\ensuremath\prod}%
11027   \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}%
11028   \DeclareUnicodeCharacter{2211}{\ensuremath\sum}%
11029   \DeclareUnicodeCharacter{2213}{\ensuremath\mp}%
11030   \DeclareUnicodeCharacter{2218}{\ensuremath\circ}%
11031   \DeclareUnicodeCharacter{221A}{\ensuremath\surd}%
11032   \DeclareUnicodeCharacter{221D}{\ensuremath\propto}%
11033   \DeclareUnicodeCharacter{2220}{\ensuremath\angle}%
11034   \DeclareUnicodeCharacter{2223}{\ensuremath\mid}%
11035   \DeclareUnicodeCharacter{2228}{\ensuremath\vee}%
11036   \DeclareUnicodeCharacter{222A}{\ensuremath\cup}%
11037   \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}%
11038   \DeclareUnicodeCharacter{222E}{\ensuremath\oint}%
11039   \DeclareUnicodeCharacter{223C}{\ensuremath\sim}%
11040   \DeclareUnicodeCharacter{2240}{\ensuremath\wr}%
11041   \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}%
11042   \DeclareUnicodeCharacter{2245}{\ensuremath\cong}%
11043   \DeclareUnicodeCharacter{2248}{\ensuremath\approx}%
11044   \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}%
11045   \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}%
11046   \DeclareUnicodeCharacter{2260}{\ensuremath\neq}%
11047   \DeclareUnicodeCharacter{226A}{\ensuremath\ll}%
11048   \DeclareUnicodeCharacter{226B}{\ensuremath\gg}%
11049   \DeclareUnicodeCharacter{227A}{\ensuremath\prec}%
11050   \DeclareUnicodeCharacter{227B}{\ensuremath\succ}%
11051   \DeclareUnicodeCharacter{2283}{\ensuremath\supset}%
11052   \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}%
11053   \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}%
11054   \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}%
11055   \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}%
11056   \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}%
11057   \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}%
11058   \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}%
11059   \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}%
11060   \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}%
11061   \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}%
11062   \DeclareUnicodeCharacter{2299}{\ensuremath\odot}%
11063   \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}%
11064   \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}%
11065   \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}%
11066   \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}%
11067   \DeclareUnicodeCharacter{22A8}{\ensuremath\models}%
11068   \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}%
11069   \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}%
11070   \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}%
11071   \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}%
11072   \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}%
11073   \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}%
11074   \DeclareUnicodeCharacter{22C6}{\ensuremath\star}%
11075   \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}%
11076   \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}%
11077   \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}%
11078   \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}%
11079   \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}%
11080   \DeclareUnicodeCharacter{2322}{\ensuremath\frown}%
11081   \DeclareUnicodeCharacter{2323}{\ensuremath\smile}%
11082   %
11083   \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
11084   \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
11085   \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
11086   \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
11087   \DeclareUnicodeCharacter{25C7}{\ensuremath\diamond}%
11088   \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}%
11089   \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}%
11090   \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}%
11091   \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}%
11092   \DeclareUnicodeCharacter{266D}{\ensuremath\flat}%
11093   \DeclareUnicodeCharacter{266E}{\ensuremath\natural}%
11094   \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}%
11095   \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}%
11096   \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}%
11097   \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}%
11098   \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}%
11099   \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}%
11100   \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}%
11101   \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}%
11102   \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}%
11103   \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}%
11104   \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}%
11105   \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}%
11106   \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}%
11107   \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}%
11108   \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}%
11109   \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}%
11110   \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}%
11111   \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}%
11112   %
11113   \global\mathchardef\checkmark="1370% actually the square root sign
11114   \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}%
11115 }% end of \unicodechardefs
11116
11117 % UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
11118 % It makes the setting that replace UTF-8 byte sequence.
11119 \def\utfeightchardefs{%
11120   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
11121   \unicodechardefs
11122 }
11123
11124 % Whether the active definitions of non-ASCII characters expand to
11125 % non-active tokens with the same character code.  This is used to
11126 % write characters literally, instead of using active definitions for
11127 % printing the correct glyphs.
11128 \newif\ifpassthroughchars
11129 \passthroughcharsfalse
11130
11131 % For native Unicode handling (XeTeX and LuaTeX),
11132 % provide a definition macro to replace/pass-through a Unicode character
11133 %
11134 \def\DeclareUnicodeCharacterNative#1#2{%
11135   \ifnum"#1>"7F % only make non-ASCII chars active
11136     \catcode"#1=\active
11137     \def\dodeclareunicodecharacternative##1##2##3{%
11138       \begingroup
11139         \uccode`\~="##2\relax
11140         \uppercase{\gdef~}{%
11141           \ifpassthroughchars
11142             ##1%
11143           \else
11144             ##3%
11145           \fi
11146         }
11147       \endgroup
11148     }
11149     \begingroup
11150       \uccode`\.="#1\relax
11151       \uppercase{\def\UTFNativeTmp{.}}%
11152       \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
11153     \endgroup
11154   \fi
11155 }
11156
11157 % Native Unicode handling (XeTeX and LuaTeX) character replacing definition.
11158 % It activates the setting that replaces Unicode characters.
11159 \def\nativeunicodechardefs{%
11160   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
11161   \unicodechardefs
11162 }
11163
11164 % For native Unicode handling (XeTeX and LuaTeX),
11165 % make the character token expand
11166 % to the sequences given in \unicodechardefs for printing.
11167 \def\DeclareUnicodeCharacterNativeAtU#1#2{%
11168   \def\UTFAtUTmp{#2}
11169   \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
11170 }
11171
11172 % @U command definitions for native Unicode handling (XeTeX and LuaTeX).
11173 \def\nativeunicodechardefsatu{%
11174   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
11175   \unicodechardefs
11176 }
11177
11178 % US-ASCII character definitions.
11179 \def\asciichardefs{% nothing need be done
11180    \relax
11181 }
11182
11183 % Define all Unicode characters we know about.  This makes UTF-8 the default
11184 % input encoding and allows @U to work.
11185 \iftxinativeunicodecapable
11186   \nativeunicodechardefsatu
11187 \else
11188   \utfeightchardefs
11189 \fi
11190
11191 \message{formatting,}
11192
11193 \newdimen\defaultparindent \defaultparindent = 15pt
11194
11195 \chapheadingskip = 15pt plus 4pt minus 2pt
11196 \secheadingskip = 12pt plus 3pt minus 2pt
11197 \subsecheadingskip = 9pt plus 2pt minus 2pt
11198
11199 % Prevent underfull vbox error messages.
11200 \vbadness = 10000
11201
11202 % Don't be very finicky about underfull hboxes, either.
11203 \hbadness = 6666
11204
11205 % Following George Bush, get rid of widows and orphans.
11206 \widowpenalty=10000
11207 \clubpenalty=10000
11208
11209 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
11210 % using an old version of TeX, don't do anything.  We want the amount of
11211 % stretch added to depend on the line length, hence the dependence on
11212 % \hsize.  We call this whenever the paper size is set.
11213 %
11214 \def\setemergencystretch{%
11215   \ifx\emergencystretch\thisisundefined
11216     % Allow us to assign to \emergencystretch anyway.
11217     \def\emergencystretch{\dimen0}%
11218   \else
11219     \emergencystretch = .15\hsize
11220   \fi
11221 }
11222
11223 % Parameters in order: 1) textheight; 2) textwidth;
11224 % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11225 % 7) physical page height; 8) physical page width.
11226 %
11227 % We also call \setleading{\textleading}, so the caller should define
11228 % \textleading.  The caller should also set \parskip.
11229 %
11230 \def\internalpagesizes#1#2#3#4#5#6#7#8{%
11231   \voffset = #3\relax
11232   \topskip = #6\relax
11233   \splittopskip = \topskip
11234   %
11235   \vsize = #1\relax
11236   \advance\vsize by \topskip
11237   \txipageheight = \vsize
11238   %
11239   \hsize = #2\relax
11240   \txipagewidth = \hsize
11241   %
11242   \normaloffset = #4\relax
11243   \bindingoffset = #5\relax
11244   %
11245   \ifpdf
11246     \pdfpageheight #7\relax
11247     \pdfpagewidth #8\relax
11248     % if we don't reset these, they will remain at "1 true in" of
11249     % whatever layout pdftex was dumped with.
11250     \pdfhorigin = 1 true in
11251     \pdfvorigin = 1 true in
11252   \else
11253     \ifx\XeTeXrevision\thisisundefined
11254       \special{papersize=#8,#7}%
11255     \else
11256       \pdfpageheight #7\relax
11257       \pdfpagewidth #8\relax
11258       % XeTeX does not have \pdfhorigin and \pdfvorigin.
11259     \fi
11260   \fi
11261   %
11262   \setleading{\textleading}
11263   %
11264   \parindent = \defaultparindent
11265   \setemergencystretch
11266 }
11267
11268 % @letterpaper (the default).
11269 \def\letterpaper{{\globaldefs = 1
11270   \parskip = 3pt plus 2pt minus 1pt
11271   \textleading = 13.2pt
11272   %
11273   % If page is nothing but text, make it come out even.
11274   \internalpagesizes{607.2pt}{6in}% that's 46 lines
11275                     {\voffset}{.25in}%
11276                     {\bindingoffset}{36pt}%
11277                     {11in}{8.5in}%
11278 }}
11279
11280 % Use @smallbook to reset parameters for 7x9.25 trim size.
11281 \def\smallbook{{\globaldefs = 1
11282   \parskip = 2pt plus 1pt
11283   \textleading = 12pt
11284   %
11285   \internalpagesizes{7.5in}{5in}%
11286                     {-.2in}{0in}%
11287                     {\bindingoffset}{16pt}%
11288                     {9.25in}{7in}%
11289   %
11290   \lispnarrowing = 0.3in
11291   \tolerance = 700
11292   \contentsrightmargin = 0pt
11293   \defbodyindent = .5cm
11294 }}
11295
11296 % Use @afourpaper to print on European A4 paper.
11297 \def\afourpaper{{\globaldefs = 1
11298   \parskip = 3pt plus 2pt minus 1pt
11299   \textleading = 13.2pt
11300   %
11301   % Double-side printing via postscript on Laserjet 4050
11302   % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11303   % To change the settings for a different printer or situation, adjust
11304   % \normaloffset until the front-side and back-side texts align.  Then
11305   % do the same for \bindingoffset.  You can set these for testing in
11306   % your texinfo source file like this:
11307   % @tex
11308   % \global\normaloffset = -6mm
11309   % \global\bindingoffset = 10mm
11310   % @end tex
11311   \internalpagesizes{673.2pt}{160mm}% that's 51 lines
11312                     {\voffset}{\hoffset}%
11313                     {\bindingoffset}{44pt}%
11314                     {297mm}{210mm}%
11315   %
11316   \tolerance = 700
11317   \contentsrightmargin = 0pt
11318   \defbodyindent = 5mm
11319 }}
11320
11321 % Use @afivepaper to print on European A5 paper.
11322 % From romildo@urano.iceb.ufop.br, 2 July 2000.
11323 % He also recommends making @example and @lisp be small.
11324 \def\afivepaper{{\globaldefs = 1
11325   \parskip = 2pt plus 1pt minus 0.1pt
11326   \textleading = 12.5pt
11327   %
11328   \internalpagesizes{160mm}{120mm}%
11329                     {\voffset}{-11.4mm}%
11330                     {\bindingoffset}{8pt}%
11331                     {210mm}{148mm}%
11332   %
11333   \lispnarrowing = 0.2in
11334   \tolerance = 800
11335   \contentsrightmargin = 0pt
11336   \defbodyindent = 2mm
11337   \tableindent = 12mm
11338 }}
11339
11340 % A specific text layout, 24x15cm overall, intended for A4 paper.
11341 \def\afourlatex{{\globaldefs = 1
11342   \afourpaper
11343   \internalpagesizes{237mm}{150mm}%
11344                     {\voffset}{4.6mm}%
11345                     {\bindingoffset}{7mm}%
11346                     {297mm}{210mm}%
11347   %
11348   % Must explicitly reset to 0 because we call \afourpaper.
11349   \globaldefs = 0
11350 }}
11351
11352 % Use @afourwide to print on A4 paper in landscape format.
11353 \def\afourwide{{\globaldefs = 1
11354   \afourpaper
11355   \internalpagesizes{241mm}{165mm}%
11356                     {\voffset}{-2.95mm}%
11357                     {\bindingoffset}{7mm}%
11358                     {297mm}{210mm}%
11359   \globaldefs = 0
11360 }}
11361
11362 \def\bsixpaper{{\globaldefs = 1
11363   \afourpaper
11364   \internalpagesizes{140mm}{100mm}%
11365                     {-6.35mm}{-12.7mm}%
11366                     {\bindingoffset}{14pt}%
11367                     {176mm}{125mm}%
11368   \let\SETdispenvsize=\smallword
11369   \lispnarrowing = 0.2in
11370   \globaldefs = 0
11371 }}
11372
11373
11374 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11375 % Perhaps we should allow setting the margins, \topskip, \parskip,
11376 % and/or leading, also. Or perhaps we should compute them somehow.
11377 %
11378 \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
11379 \def\pagesizesyyy#1,#2,#3\finish{{%
11380   \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11381   \globaldefs = 1
11382   %
11383   \parskip = 3pt plus 2pt minus 1pt
11384   \setleading{\textleading}%
11385   %
11386   \dimen0 = #1\relax
11387   \advance\dimen0 by 2.5in % default 1in margin above heading line
11388                            % and 1.5in to include heading, footing and
11389                            % bottom margin
11390   %
11391   \dimen2 = \hsize
11392   \advance\dimen2 by 2in % default to 1 inch margin on each side
11393   %
11394   \internalpagesizes{#1}{\hsize}%
11395                     {\voffset}{\normaloffset}%
11396                     {\bindingoffset}{44pt}%
11397                     {\dimen0}{\dimen2}%
11398 }}
11399
11400 % Set default to letter.
11401 %
11402 \letterpaper
11403
11404 % Default value of \hfuzz, for suppressing warnings about overfull hboxes.
11405 \hfuzz = 1pt
11406
11407 \ifx\eTeXversion\thisisundefined\else \lastlinefit=500 \fi
11408
11409
11410 \message{and turning on texinfo input format.}
11411
11412 \def^^L{\par} % remove \outer, so ^L can appear in an @comment
11413 \catcode`\^^K = 10 % treat vertical tab as whitespace
11414
11415 % DEL is a comment character, in case @c does not suffice.
11416 \catcode`\^^? = 14
11417
11418 % Define macros to output various characters with catcode for normal text.
11419 \catcode`\"=\other \def\normaldoublequote{"}
11420 \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11421 \catcode`\+=\other \def\normalplus{+}
11422 \catcode`\<=\other \def\normalless{<}
11423 \catcode`\>=\other \def\normalgreater{>}
11424 \catcode`\^=\other \def\normalcaret{^}
11425 \catcode`\_=\other \def\normalunderscore{_}
11426 \catcode`\|=\other \def\normalverticalbar{|}
11427 \catcode`\~=\other \def\normaltilde{~}
11428
11429 % This macro is used to make a character print one way in \tt
11430 % (where it can probably be output as-is), and another way in other fonts,
11431 % where something hairier probably needs to be done.
11432 %
11433 % #1 is what to print if we are indeed using \tt; #2 is what to print
11434 % otherwise.  Since all the Computer Modern typewriter fonts have zero
11435 % interword stretch (and shrink), and it is reasonable to expect all
11436 % typewriter fonts to have this, we can check that font parameter.
11437 %
11438 \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
11439
11440 % Same as above, but check for italic font.  Actually this also catches
11441 % non-italic slanted fonts since it is impossible to distinguish them from
11442 % italic fonts.  But since this is only used by $ and it uses \sl anyway
11443 % this is not a problem.
11444 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
11445
11446 % Set catcodes for Texinfo file
11447
11448 % Active characters for printing the wanted glyph.
11449 % Most of these we simply print from the \tt font, but for some, we can
11450 % use math or other variants that look better in normal text.
11451 %
11452 \catcode`\"=\active
11453 \def\activedoublequote{{\tt\char34}}
11454 \let"=\activedoublequote
11455 \catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
11456 \chardef\hatchar=`\^
11457 \catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
11458
11459 \catcode`\_=\active
11460 \def_{\ifusingtt\normalunderscore\_}
11461 \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
11462 \let\realunder=_
11463
11464 \catcode`\|=\active \def|{{\tt\char124}}
11465
11466 \chardef \less=`\<
11467 \catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
11468 \chardef \gtr=`\>
11469 \catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11470 \catcode`\+=\active \def+{{\tt \char 43}}
11471 \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
11472 \catcode`\-=\active \let-=\normaldash
11473
11474
11475 % used for headline/footline in the output routine, in case the page
11476 % breaks in the middle of an @tex block.
11477 \def\texinfochars{%
11478   \let< = \activeless
11479   \let> = \activegtr
11480   \let~ = \activetilde
11481   \let^ = \activehat
11482   \setregularquotes
11483   \let\b = \strong
11484   \let\i = \smartitalic
11485   % in principle, all other definitions in \tex have to be undone too.
11486 }
11487
11488 % Used sometimes to turn off (effectively) the active characters even after
11489 % parsing them.
11490 \def\turnoffactive{%
11491   \normalturnoffactive
11492   \otherbackslash
11493 }
11494
11495 \catcode`\@=0
11496
11497 % \backslashcurfont outputs one backslash character in current font,
11498 % as in \char`\\.
11499 \global\chardef\backslashcurfont=`\\
11500
11501 % \realbackslash is an actual character `\' with catcode other.
11502 {\catcode`\\=\other @gdef@realbackslash{\}}
11503
11504 % In Texinfo, backslash is an active character; it prints the backslash
11505 % in fixed width font.
11506 \catcode`\\=\active  % @ for escape char from now on.
11507
11508 % Print a typewriter backslash.  For math mode, we can't simply use
11509 % \backslashcurfont: the story here is that in math mode, the \char
11510 % of \backslashcurfont ends up printing the roman \ from the math symbol
11511 % font (because \char in math mode uses the \mathcode, and plain.tex
11512 % sets \mathcode`\\="026E).  Hence we use an explicit \mathchar,
11513 % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11514 % ignored family value; char position "5C).  We can't use " for the
11515 % usual hex value because it has already been made active.
11516
11517 @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
11518 @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
11519
11520 % \otherbackslash defines an active \ to be a literal `\' character with
11521 % catcode other.
11522 @gdef@otherbackslash{@let\=@realbackslash}
11523
11524 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
11525 % the literal character `\'.
11526 %
11527 {@catcode`- = @active
11528  @gdef@normalturnoffactive{%
11529    @passthroughcharstrue
11530    @let-=@normaldash
11531    @let"=@normaldoublequote
11532    @let$=@normaldollar %$ font-lock fix
11533    @let+=@normalplus
11534    @let<=@normalless
11535    @let>=@normalgreater
11536    @let^=@normalcaret
11537    @let_=@normalunderscore
11538    @let|=@normalverticalbar
11539    @let~=@normaltilde
11540    @let\=@ttbackslash
11541    @setregularquotes
11542    @unsepspaces
11543  }
11544 }
11545
11546 % If a .fmt file is being used, characters that might appear in a file
11547 % name cannot be active until we have parsed the command line.
11548 % So turn them off again, and have @fixbackslash turn them back on.
11549 @catcode`+=@other @catcode`@_=@other
11550
11551 % \enablebackslashhack - allow file to begin `\input texinfo'
11552 %
11553 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
11554 % That is what \eatinput is for; after that, the `\' should revert to printing
11555 % a backslash.
11556 % If the file did not have a `\input texinfo', then it is turned off after
11557 % the first line; otherwise the first `\' in the file would cause an error.
11558 % This is used on the very last line of this file, texinfo.tex.
11559 % We also use @c to call @fixbackslash, in case ends of lines are hidden.
11560 {
11561 @catcode`@^=7
11562 @catcode`@^^M=13@gdef@enablebackslashhack{%
11563   @global@let\ = @eatinput%
11564   @catcode`@^^M=13%
11565   @def@c{@fixbackslash@c}%
11566   % Definition for the newline at the end of this file.
11567   @def ^^M{@let^^M@secondlinenl}%
11568   % Definition for a newline in the main Texinfo file.
11569   @gdef @secondlinenl{@fixbackslash}%
11570   % In case the first line has a whole-line command on it
11571   @let@originalparsearg@parsearg
11572   @def@parsearg{@fixbackslash@originalparsearg}
11573 }}
11574
11575 {@catcode`@^=7 @catcode`@^^M=13%
11576 @gdef@eatinput input texinfo#1^^M{@fixbackslash}}
11577
11578 % Emergency active definition of newline, in case an active newline token
11579 % appears by mistake.
11580 {@catcode`@^=7 @catcode13=13%
11581 @gdef@enableemergencynewline{%
11582   @gdef^^M{%
11583     @par%
11584     %<warning: active newline>@par%
11585 }}}
11586
11587
11588 @gdef@fixbackslash{%
11589   @ifx\@eatinput @let\ = @ttbackslash @fi
11590   @catcode13=5 % regular end of line
11591   @enableemergencynewline
11592   @let@c=@comment
11593   @let@parsearg@originalparsearg
11594   % Also turn back on active characters that might appear in the input
11595   % file name, in case not using a pre-dumped format.
11596   @catcode`+=@active
11597   @catcode`@_=@active
11598   %
11599   % If texinfo.cnf is present on the system, read it.
11600   % Useful for site-wide @afourpaper, etc.  This macro, @fixbackslash, gets
11601   % called at the beginning of every Texinfo file.  Not opening texinfo.cnf
11602   % directly in this file, texinfo.tex, makes it possible to make a format
11603   % file for Texinfo.
11604   %
11605   @openin 1 texinfo.cnf
11606   @ifeof 1 @else @input texinfo.cnf @fi
11607   @closein 1
11608 }
11609
11610
11611 % Say @foo, not \foo, in error messages.
11612 @escapechar = `@@
11613
11614 % These (along with & and #) are made active for url-breaking, so need
11615 % active definitions as the normal characters.
11616 @def@normaldot{.}
11617 @def@normalquest{?}
11618 @def@normalslash{/}
11619
11620 % These look ok in all fonts, so just make them not special.
11621 % @hashchar{} gets its own user-level command, because of #line.
11622 @catcode`@& = @other @def@normalamp{&}
11623 @catcode`@# = @other @def@normalhash{#}
11624 @catcode`@% = @other @def@normalpercent{%}
11625
11626 @let @hashchar = @normalhash
11627
11628 @c Finally, make ` and ' active, so that txicodequoteundirected and
11629 @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
11630 @c don't make ` and ' active, @code will not get them as active chars.
11631 @c Do this last of all since we use ` in the previous @catcode assignments.
11632 @catcode`@'=@active
11633 @catcode`@`=@active
11634 @setregularquotes
11635
11636 @c Local variables:
11637 @c eval: (add-hook 'before-save-hook 'time-stamp nil t)
11638 @c time-stamp-pattern: "texinfoversion{%Y-%02m-%02d.%02H}"
11639 @c page-delimiter: "^\\\\message\\|emacs-page"
11640 @c End:
11641
11642 @c vim:sw=2:
11643
11644 @enablebackslashhack
11645