work on docs
[pspp] / build-aux / texinfo.tex
1 % texinfo.tex -- TeX macros to handle Texinfo files.
2 %
3 % Load plain if necessary, i.e., if running under initex.
4 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5 %
6 \def\texinfoversion{2020-06-25.17}
7 %
8 % Copyright 1985, 1986, 1988, 1990-2020 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 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
245 \newdimen\topandbottommargin \topandbottommargin=.75in
246
247 % Output a mark which sets \thischapter, \thissection and \thiscolor.
248 % We dump everything together because we only have one kind of mark.
249 % This works because we only use \botmark / \topmark, not \firstmark.
250 %
251 % A mark contains a subexpression of the \ifcase ... \fi construct.
252 % \get*marks macros below extract the needed part using \ifcase.
253 %
254 % Another complication is to let the user choose whether \thischapter
255 % (\thissection) refers to the chapter (section) in effect at the top
256 % of a page, or that at the bottom of a page.
257
258 % \domark is called twice inside \chapmacro, to add one
259 % mark before the section break, and one after.
260 %   In the second call \prevchapterdefs is the same as \currentchapterdefs,
261 % and \prevsectiondefs is the same as \currentsectiondefs.
262 %   Then if the page is not broken at the mark, some of the previous
263 % section appears on the page, and we can get the name of this section
264 % from \firstmark for @everyheadingmarks top.
265 %   @everyheadingmarks bottom uses \botmark.
266 %
267 % See page 260 of The TeXbook.
268 \def\domark{%
269   \toks0=\expandafter{\currentchapterdefs}%
270   \toks2=\expandafter{\currentsectiondefs}%
271   \toks4=\expandafter{\prevchapterdefs}%
272   \toks6=\expandafter{\prevsectiondefs}%
273   \toks8=\expandafter{\currentcolordefs}%
274   \mark{%
275                    \the\toks0 \the\toks2  % 0: marks for @everyheadingmarks top
276       \noexpand\or \the\toks4 \the\toks6  % 1: for @everyheadingmarks bottom
277     \noexpand\else \the\toks8             % 2: color marks
278   }%
279 }
280
281 % \gettopheadingmarks, \getbottomheadingmarks,
282 % \getcolormarks - extract needed part of mark.
283 %
284 % \topmark doesn't work for the very first chapter (after the title
285 % page or the contents), so we use \firstmark there -- this gets us
286 % the mark with the chapter defs, unless the user sneaks in, e.g.,
287 % @setcolor (or @url, or @link, etc.) between @contents and the very
288 % first @chapter.
289 \def\gettopheadingmarks{%
290   \ifcase0\the\savedtopmark\fi
291   \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
292 }
293 \def\getbottomheadingmarks{\ifcase1\botmark\fi}
294 \def\getcolormarks{\ifcase2\the\savedtopmark\fi}
295
296 % Avoid "undefined control sequence" errors.
297 \def\currentchapterdefs{}
298 \def\currentsectiondefs{}
299 \def\currentsection{}
300 \def\prevchapterdefs{}
301 \def\prevsectiondefs{}
302 \def\currentcolordefs{}
303
304 % Margin to add to right of even pages, to left of odd pages.
305 \newdimen\bindingoffset
306 \newdimen\normaloffset
307 \newdimen\txipagewidth \newdimen\txipageheight
308
309 % Main output routine.
310 %
311 \chardef\PAGE = 255
312 \newtoks\defaultoutput
313 \defaultoutput = {\savetopmark\onepageout{\pagecontents\PAGE}}
314 \output=\expandafter{\the\defaultoutput}
315
316 \newbox\headlinebox
317 \newbox\footlinebox
318
319 % When outputting the double column layout for indices, an output routine
320 % is run several times, which hides the original value of \topmark.  This
321 % can lead to a page heading being output and duplicating the chapter heading
322 % of the index.  Hence, save the contents of \topmark at the beginning of
323 % the output routine.  The saved contents are valid until we actually
324 % \shipout a page.
325 %
326 % (We used to run a short output routine to actually set \topmark and
327 % \firstmark to the right values, but if this was called with an empty page
328 % containing whatsits for writing index entries, the whatsits would be thrown
329 % away and the index auxiliary file would remain empty.)
330 %
331 \newtoks\savedtopmark
332 \newif\iftopmarksaved
333 \topmarksavedtrue
334 \def\savetopmark{%
335   \iftopmarksaved\else
336     \global\savedtopmark=\expandafter{\topmark}%
337     \global\topmarksavedtrue
338   \fi
339 }
340
341 % \onepageout takes a vbox as an argument.
342 % \shipout a vbox for a single page, adding an optional header, footer
343 % and footnote.  This also causes index entries for this page to be written
344 % to the auxiliary files.
345 %
346 \def\onepageout#1{%
347   \hoffset=\normaloffset
348   %
349   \ifodd\pageno  \advance\hoffset by \bindingoffset
350   \else \advance\hoffset by -\bindingoffset\fi
351   %
352   \checkchapterpage
353   %
354   % Retrieve the information for the headings from the marks in the page,
355   % and call Plain TeX's \makeheadline and \makefootline, which use the
356   % values in \headline and \footline.
357   %
358   % Common context changes for both heading and footing.
359   % Do this outside of the \shipout so @code etc. will be expanded in
360   % the headline as they should be, not taken literally (outputting ''code).
361   \def\commonheadfootline{\let\hsize=\txipagewidth \texinfochars}
362   %
363   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
364   \global\setbox\headlinebox = \vbox{\commonheadfootline \makeheadline}%
365   \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
366   \global\setbox\footlinebox = \vbox{\commonheadfootline \makefootline}%
367   %
368   {%
369     % Set context for writing to auxiliary files like index files.
370     % Have to do this stuff outside the \shipout because we want it to
371     % take effect in \write's, yet the group defined by the \vbox ends
372     % before the \shipout runs.
373     %
374     \atdummies         % don't expand commands in the output.
375     \turnoffactive
376     \shipout\vbox{%
377       % Do this early so pdf references go to the beginning of the page.
378       \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
379       %
380       \unvbox\headlinebox
381       \pagebody{#1}%
382       \ifdim\ht\footlinebox > 0pt
383         % Only leave this space if the footline is nonempty.
384         % (We lessened \vsize for it in \oddfootingyyy.)
385         % The \baselineskip=24pt in plain's \makefootline has no effect.
386         \vskip 24pt
387         \unvbox\footlinebox
388       \fi
389       %
390     }%
391   }%
392   \global\topmarksavedfalse
393   \advancepageno
394   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
395 }
396
397 \newinsert\margin \dimen\margin=\maxdimen
398
399 % Main part of page, including any footnotes
400 \def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
401 {\catcode`\@ =11
402 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
403 % marginal hacks, juha@viisa.uucp (Juha Takala)
404 \ifvoid\margin\else % marginal info is present
405   \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
406 \dimen@=\dp#1\relax \unvbox#1\relax
407 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
408 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
409 }
410
411 % Check if we are on the first page of a chapter.  Used for printing headings.
412 \newif\ifchapterpage
413 \def\checkchapterpage{%
414   % Get the chapter that was current at the end of the last page
415   \ifcase1\the\savedtopmark\fi
416   \let\prevchaptername\thischaptername
417   %
418   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
419   \let\curchaptername\thischaptername
420   %
421   \ifx\curchaptername\prevchaptername
422     \chapterpagefalse
423   \else
424     \chapterpagetrue
425   \fi
426 }
427
428 % Argument parsing
429
430 % Parse an argument, then pass it to #1.  The argument is the rest of
431 % the input line (except we remove a trailing comment).  #1 should be a
432 % macro which expects an ordinary undelimited TeX argument.
433 % For example, \def\foo{\parsearg\fooxxx}.
434 %
435 \def\parsearg{\parseargusing{}}
436 \def\parseargusing#1#2{%
437   \def\argtorun{#2}%
438   \begingroup
439     \obeylines
440     \spaceisspace
441     #1%
442     \parseargline\empty% Insert the \empty token, see \finishparsearg below.
443 }
444
445 {\obeylines %
446   \gdef\parseargline#1^^M{%
447     \endgroup % End of the group started in \parsearg.
448     \argremovecomment #1\comment\ArgTerm%
449   }%
450 }
451
452 % First remove any @comment, then any @c comment.  Pass the result on to
453 % \argcheckspaces.
454 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
455 \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
456
457 % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
458 %
459 % \argremovec might leave us with trailing space, e.g.,
460 %    @end itemize  @c foo
461 % This space token undergoes the same procedure and is eventually removed
462 % by \finishparsearg.
463 %
464 \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
465 \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
466 \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
467   \def\temp{#3}%
468   \ifx\temp\empty
469     % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
470     \let\temp\finishparsearg
471   \else
472     \let\temp\argcheckspaces
473   \fi
474   % Put the space token in:
475   \temp#1 #3\ArgTerm
476 }
477
478 % If a _delimited_ argument is enclosed in braces, they get stripped; so
479 % to get _exactly_ the rest of the line, we had to prevent such situation.
480 % We prepended an \empty token at the very beginning and we expand it now,
481 % just before passing the control to \argtorun.
482 % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
483 % either the null string, or it ends with \^^M---thus there is no danger
484 % that a pair of braces would be stripped.
485 %
486 % But first, we have to remove the trailing space token.
487 %
488 \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
489
490
491 % \parseargdef - define a command taking an argument on the line
492 %
493 % \parseargdef\foo{...}
494 %       is roughly equivalent to
495 % \def\foo{\parsearg\Xfoo}
496 % \def\Xfoo#1{...}
497 \def\parseargdef#1{%
498   \expandafter \doparseargdef \csname\string#1\endcsname #1%
499 }
500 \def\doparseargdef#1#2{%
501   \def#2{\parsearg#1}%
502   \def#1##1%
503 }
504
505 % Several utility definitions with active space:
506 {
507   \obeyspaces
508   \gdef\obeyedspace{ }
509
510   % Make each space character in the input produce a normal interword
511   % space in the output.  Don't allow a line break at this space, as this
512   % is used only in environments like @example, where each line of input
513   % should produce a line of output anyway.
514   %
515   \gdef\sepspaces{\obeyspaces\let =\tie}
516
517   % If an index command is used in an @example environment, any spaces
518   % therein should become regular spaces in the raw index file, not the
519   % expansion of \tie (\leavevmode \penalty \@M \ ).
520   \gdef\unsepspaces{\let =\space}
521 }
522
523
524 \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
525
526 % Define the framework for environments in texinfo.tex.  It's used like this:
527 %
528 %   \envdef\foo{...}
529 %   \def\Efoo{...}
530 %
531 % It's the responsibility of \envdef to insert \begingroup before the
532 % actual body; @end closes the group after calling \Efoo.  \envdef also
533 % defines \thisenv, so the current environment is known; @end checks
534 % whether the environment name matches.  The \checkenv macro can also be
535 % used to check whether the current environment is the one expected.
536 %
537 % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
538 % are not treated as environments; they don't open a group.  (The
539 % implementation of @end takes care not to call \endgroup in this
540 % special case.)
541
542
543 % At run-time, environments start with this:
544 \def\startenvironment#1{\begingroup\def\thisenv{#1}}
545 % initialize
546 \let\thisenv\empty
547
548 % ... but they get defined via ``\envdef\foo{...}'':
549 \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
550 \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
551
552 % Check whether we're in the right environment:
553 \def\checkenv#1{%
554   \def\temp{#1}%
555   \ifx\thisenv\temp
556   \else
557     \badenverr
558   \fi
559 }
560
561 % Environment mismatch, #1 expected:
562 \def\badenverr{%
563   \errhelp = \EMsimple
564   \errmessage{This command can appear only \inenvironment\temp,
565     not \inenvironment\thisenv}%
566 }
567 \def\inenvironment#1{%
568   \ifx#1\empty
569     outside of any environment%
570   \else
571     in environment \expandafter\string#1%
572   \fi
573 }
574
575 % @end foo executes the definition of \Efoo.
576 % But first, it executes a specialized version of \checkenv
577 %
578 \parseargdef\end{%
579   \if 1\csname iscond.#1\endcsname
580   \else
581     % The general wording of \badenverr may not be ideal.
582     \expandafter\checkenv\csname#1\endcsname
583     \csname E#1\endcsname
584     \endgroup
585   \fi
586 }
587
588 \newhelp\EMsimple{Press RETURN to continue.}
589
590
591 % Be sure we're in horizontal mode when doing a tie, since we make space
592 % equivalent to this in @example-like environments. Otherwise, a space
593 % at the beginning of a line will start with \penalty -- and
594 % since \penalty is valid in vertical mode, we'd end up putting the
595 % penalty on the vertical list instead of in the new paragraph.
596 {\catcode`@ = 11
597  % Avoid using \@M directly, because that causes trouble
598  % if the definition is written into an index file.
599  \global\let\tiepenalty = \@M
600  \gdef\tie{\leavevmode\penalty\tiepenalty\ }
601 }
602
603 % @: forces normal size whitespace following.
604 \def\:{\spacefactor=1000 }
605
606 % @* forces a line break.
607 \def\*{\unskip\hfil\break\hbox{}\ignorespaces}
608
609 % @/ allows a line break.
610 \let\/=\allowbreak
611
612 % @. is an end-of-sentence period.
613 \def\.{.\spacefactor=\endofsentencespacefactor\space}
614
615 % @! is an end-of-sentence bang.
616 \def\!{!\spacefactor=\endofsentencespacefactor\space}
617
618 % @? is an end-of-sentence query.
619 \def\?{?\spacefactor=\endofsentencespacefactor\space}
620
621 % @frenchspacing on|off  says whether to put extra space after punctuation.
622 %
623 \def\onword{on}
624 \def\offword{off}
625 %
626 \parseargdef\frenchspacing{%
627   \def\temp{#1}%
628   \ifx\temp\onword \plainfrenchspacing
629   \else\ifx\temp\offword \plainnonfrenchspacing
630   \else
631     \errhelp = \EMsimple
632     \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
633   \fi\fi
634 }
635
636 % @w prevents a word break.  Without the \leavevmode, @w at the
637 % beginning of a paragraph, when TeX is still in vertical mode, would
638 % produce a whole line of output instead of starting the paragraph.
639 \def\w#1{\leavevmode\hbox{#1}}
640
641 % @group ... @end group forces ... to be all on one page, by enclosing
642 % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
643 % to keep its height that of a normal line.  According to the rules for
644 % \topskip (p.114 of the TeXbook), the glue inserted is
645 % max (\topskip - \ht (first item), 0).  If that height is large,
646 % therefore, no glue is inserted, and the space between the headline and
647 % the text is small, which looks bad.
648 %
649 % Another complication is that the group might be very large.  This can
650 % cause the glue on the previous page to be unduly stretched, because it
651 % does not have much material.  In this case, it's better to add an
652 % explicit \vfill so that the extra space is at the bottom.  The
653 % threshold for doing this is if the group is more than \vfilllimit
654 % percent of a page (\vfilllimit can be changed inside of @tex).
655 %
656 \newbox\groupbox
657 \def\vfilllimit{0.7}
658 %
659 \envdef\group{%
660   \ifnum\catcode`\^^M=\active \else
661     \errhelp = \groupinvalidhelp
662     \errmessage{@group invalid in context where filling is enabled}%
663   \fi
664   \startsavinginserts
665   %
666   \setbox\groupbox = \vtop\bgroup
667     % Do @comment since we are called inside an environment such as
668     % @example, where each end-of-line in the input causes an
669     % end-of-line in the output.  We don't want the end-of-line after
670     % the `@group' to put extra space in the output.  Since @group
671     % should appear on a line by itself (according to the Texinfo
672     % manual), we don't worry about eating any user text.
673     \comment
674 }
675 %
676 % The \vtop produces a box with normal height and large depth; thus, TeX puts
677 % \baselineskip glue before it, and (when the next line of text is done)
678 % \lineskip glue after it.  Thus, space below is not quite equal to space
679 % above.  But it's pretty close.
680 \def\Egroup{%
681     % To get correct interline space between the last line of the group
682     % and the first line afterwards, we have to propagate \prevdepth.
683     \endgraf % Not \par, as it may have been set to \lisppar.
684     \global\dimen1 = \prevdepth
685   \egroup           % End the \vtop.
686   \addgroupbox
687   \prevdepth = \dimen1
688   \checkinserts
689 }
690
691 \def\addgroupbox{
692   % \dimen0 is the vertical size of the group's box.
693   \dimen0 = \ht\groupbox  \advance\dimen0 by \dp\groupbox
694   % \dimen2 is how much space is left on the page (more or less).
695   \dimen2 = \txipageheight   \advance\dimen2 by -\pagetotal
696   % if the group doesn't fit on the current page, and it's a big big
697   % group, force a page break.
698   \ifdim \dimen0 > \dimen2
699     \ifdim \pagetotal < \vfilllimit\txipageheight
700       \page
701     \fi
702   \fi
703   \box\groupbox
704 }
705
706 %
707 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
708 % message, so this ends up printing `@group can only ...'.
709 %
710 \newhelp\groupinvalidhelp{%
711 group can only be used in environments such as @example,^^J%
712 where each line of input produces a line of output.}
713
714 % @need space-in-mils
715 % forces a page break if there is not space-in-mils remaining.
716
717 \newdimen\mil  \mil=0.001in
718
719 \parseargdef\need{%
720   % Ensure vertical mode, so we don't make a big box in the middle of a
721   % paragraph.
722   \par
723   %
724   % If the @need value is less than one line space, it's useless.
725   \dimen0 = #1\mil
726   \dimen2 = \ht\strutbox
727   \advance\dimen2 by \dp\strutbox
728   \ifdim\dimen0 > \dimen2
729     %
730     % Do a \strut just to make the height of this box be normal, so the
731     % normal leading is inserted relative to the preceding line.
732     % And a page break here is fine.
733     \vtop to #1\mil{\strut\vfil}%
734     %
735     % TeX does not even consider page breaks if a penalty added to the
736     % main vertical list is 10000 or more.  But in order to see if the
737     % empty box we just added fits on the page, we must make it consider
738     % page breaks.  On the other hand, we don't want to actually break the
739     % page after the empty box.  So we use a penalty of 9999.
740     %
741     % There is an extremely small chance that TeX will actually break the
742     % page at this \penalty, if there are no other feasible breakpoints in
743     % sight.  (If the user is using lots of big @group commands, which
744     % almost-but-not-quite fill up a page, TeX will have a hard time doing
745     % good page breaking, for example.)  However, I could not construct an
746     % example where a page broke at this \penalty; if it happens in a real
747     % document, then we can reconsider our strategy.
748     \penalty9999
749     %
750     % Back up by the size of the box, whether we did a page break or not.
751     \kern -#1\mil
752     %
753     % Do not allow a page break right after this kern.
754     \nobreak
755   \fi
756 }
757
758 % @br   forces paragraph break (and is undocumented).
759
760 \let\br = \par
761
762 % @page forces the start of a new page.
763 %
764 \def\page{\par\vfill\supereject}
765
766 % @exdent text....
767 % outputs text on separate line in roman font, starting at standard page margin
768
769 % This records the amount of indent in the innermost environment.
770 % That's how much \exdent should take out.
771 \newskip\exdentamount
772
773 % This defn is used inside fill environments such as @defun.
774 \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
775
776 % This defn is used inside nofill environments such as @example.
777 \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
778   \leftline{\hskip\leftskip{\rm#1}}}}
779
780 % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
781 % paragraph.  For more general purposes, use the \margin insertion
782 % class.  WHICH is `l' or `r'.  Not documented, written for gawk manual.
783 %
784 \newskip\inmarginspacing \inmarginspacing=1cm
785 \def\strutdepth{\dp\strutbox}
786 %
787 \def\doinmargin#1#2{\strut\vadjust{%
788   \nobreak
789   \kern-\strutdepth
790   \vtop to \strutdepth{%
791     \baselineskip=\strutdepth
792     \vss
793     % if you have multiple lines of stuff to put here, you'll need to
794     % make the vbox yourself of the appropriate size.
795     \ifx#1l%
796       \llap{\ignorespaces #2\hskip\inmarginspacing}%
797     \else
798       \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
799     \fi
800     \null
801   }%
802 }}
803 \def\inleftmargin{\doinmargin l}
804 \def\inrightmargin{\doinmargin r}
805 %
806 % @inmargin{TEXT [, RIGHT-TEXT]}
807 % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
808 % else use TEXT for both).
809 %
810 \def\inmargin#1{\parseinmargin #1,,\finish}
811 \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
812   \setbox0 = \hbox{\ignorespaces #2}%
813   \ifdim\wd0 > 0pt
814     \def\lefttext{#1}%  have both texts
815     \def\righttext{#2}%
816   \else
817     \def\lefttext{#1}%  have only one text
818     \def\righttext{#1}%
819   \fi
820   %
821   \ifodd\pageno
822     \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
823   \else
824     \def\temp{\inleftmargin\lefttext}%
825   \fi
826   \temp
827 }
828
829 % @include FILE -- \input text of FILE.
830 %
831 \def\include{\parseargusing\filenamecatcodes\includezzz}
832 \def\includezzz#1{%
833   \pushthisfilestack
834   \def\thisfile{#1}%
835   {%
836     \makevalueexpandable  % we want to expand any @value in FILE.
837     \turnoffactive        % and allow special characters in the expansion
838     \indexnofonts         % Allow `@@' and other weird things in file names.
839     \wlog{texinfo.tex: doing @include of #1^^J}%
840     \edef\temp{\noexpand\input #1 }%
841     %
842     % This trickery is to read FILE outside of a group, in case it makes
843     % definitions, etc.
844     \expandafter
845   }\temp
846   \popthisfilestack
847 }
848 \def\filenamecatcodes{%
849   \catcode`\\=\other
850   \catcode`~=\other
851   \catcode`^=\other
852   \catcode`_=\other
853   \catcode`|=\other
854   \catcode`<=\other
855   \catcode`>=\other
856   \catcode`+=\other
857   \catcode`-=\other
858   \catcode`\`=\other
859   \catcode`\'=\other
860 }
861
862 \def\pushthisfilestack{%
863   \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
864 }
865 \def\pushthisfilestackX{%
866   \expandafter\pushthisfilestackY\thisfile\StackTerm
867 }
868 \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
869   \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
870 }
871
872 \def\popthisfilestack{\errthisfilestackempty}
873 \def\errthisfilestackempty{\errmessage{Internal error:
874   the stack of filenames is empty.}}
875 %
876 \def\thisfile{}
877
878 % @center line
879 % outputs that line, centered.
880 %
881 \parseargdef\center{%
882   \ifhmode
883     \let\centersub\centerH
884   \else
885     \let\centersub\centerV
886   \fi
887   \centersub{\hfil \ignorespaces#1\unskip \hfil}%
888   \let\centersub\relax % don't let the definition persist, just in case
889 }
890 \def\centerH#1{{%
891   \hfil\break
892   \advance\hsize by -\leftskip
893   \advance\hsize by -\rightskip
894   \line{#1}%
895   \break
896 }}
897 %
898 \newcount\centerpenalty
899 \def\centerV#1{%
900   % The idea here is the same as in \startdefun, \cartouche, etc.: if
901   % @center is the first thing after a section heading, we need to wipe
902   % out the negative parskip inserted by \sectionheading, but still
903   % prevent a page break here.
904   \centerpenalty = \lastpenalty
905   \ifnum\centerpenalty>10000 \vskip\parskip \fi
906   \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
907   \line{\kern\leftskip #1\kern\rightskip}%
908 }
909
910 % @sp n   outputs n lines of vertical space
911 %
912 \parseargdef\sp{\vskip #1\baselineskip}
913
914 % @comment ...line which is ignored...
915 % @c is the same as @comment
916 % @ignore ... @end ignore  is another way to write a comment
917
918
919 \def\c{\begingroup \catcode`\^^M=\active%
920 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
921 \cxxx}
922 {\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
923 %
924 \let\comment\c
925
926 % @paragraphindent NCHARS
927 % We'll use ems for NCHARS, close enough.
928 % NCHARS can also be the word `asis' or `none'.
929 % We cannot feasibly implement @paragraphindent asis, though.
930 %
931 \def\asisword{asis} % no translation, these are keywords
932 \def\noneword{none}
933 %
934 \parseargdef\paragraphindent{%
935   \def\temp{#1}%
936   \ifx\temp\asisword
937   \else
938     \ifx\temp\noneword
939       \defaultparindent = 0pt
940     \else
941       \defaultparindent = #1em
942     \fi
943   \fi
944   \parindent = \defaultparindent
945 }
946
947 % @exampleindent NCHARS
948 % We'll use ems for NCHARS like @paragraphindent.
949 % It seems @exampleindent asis isn't necessary, but
950 % I preserve it to make it similar to @paragraphindent.
951 \parseargdef\exampleindent{%
952   \def\temp{#1}%
953   \ifx\temp\asisword
954   \else
955     \ifx\temp\noneword
956       \lispnarrowing = 0pt
957     \else
958       \lispnarrowing = #1em
959     \fi
960   \fi
961 }
962
963 % @firstparagraphindent WORD
964 % If WORD is `none', then suppress indentation of the first paragraph
965 % after a section heading.  If WORD is `insert', then do indent at such
966 % paragraphs.
967 %
968 % The paragraph indentation is suppressed or not by calling
969 % \suppressfirstparagraphindent, which the sectioning commands do.
970 % We switch the definition of this back and forth according to WORD.
971 % By default, we suppress indentation.
972 %
973 \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
974 \def\insertword{insert}
975 %
976 \parseargdef\firstparagraphindent{%
977   \def\temp{#1}%
978   \ifx\temp\noneword
979     \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
980   \else\ifx\temp\insertword
981     \let\suppressfirstparagraphindent = \relax
982   \else
983     \errhelp = \EMsimple
984     \errmessage{Unknown @firstparagraphindent option `\temp'}%
985   \fi\fi
986 }
987
988 % Here is how we actually suppress indentation.  Redefine \everypar to
989 % \kern backwards by \parindent, and then reset itself to empty.
990 %
991 % We also make \indent itself not actually do anything until the next
992 % paragraph.
993 %
994 \gdef\dosuppressfirstparagraphindent{%
995   \gdef\indent  {\restorefirstparagraphindent \indent}%
996   \gdef\noindent{\restorefirstparagraphindent \noindent}%
997   \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
998 }
999 %
1000 \gdef\restorefirstparagraphindent{%
1001   \global\let\indent = \ptexindent
1002   \global\let\noindent = \ptexnoindent
1003   \global\everypar = {}%
1004 }
1005
1006
1007 % @refill is a no-op.
1008 \let\refill=\relax
1009
1010 % @setfilename INFO-FILENAME - ignored
1011 \let\setfilename=\comment
1012
1013 % @bye.
1014 \outer\def\bye{\chappager\pagelabels\tracingstats=1\ptexend}
1015
1016
1017 \message{pdf,}
1018 % adobe `portable' document format
1019 \newcount\tempnum
1020 \newcount\lnkcount
1021 \newtoks\filename
1022 \newcount\filenamelength
1023 \newcount\pgn
1024 \newtoks\toksA
1025 \newtoks\toksB
1026 \newtoks\toksC
1027 \newtoks\toksD
1028 \newbox\boxA
1029 \newbox\boxB
1030 \newcount\countA
1031 \newif\ifpdf
1032 \newif\ifpdfmakepagedest
1033
1034 %
1035 % For LuaTeX
1036 %
1037
1038 \newif\iftxiuseunicodedestname
1039 \txiuseunicodedestnamefalse % For pdfTeX etc.
1040
1041 \ifx\luatexversion\thisisundefined
1042 \else
1043   % Use Unicode destination names
1044   \txiuseunicodedestnametrue
1045   % Escape PDF strings with converting UTF-16 from UTF-8
1046   \begingroup
1047     \catcode`\%=12
1048     \directlua{
1049       function UTF16oct(str)
1050         tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
1051         for c in string.utfvalues(str) do
1052           if c < 0x10000 then
1053             tex.sprint(
1054               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1055                             string.char(0x5c) .. string.char(0x25) .. '03o',
1056                             math.floor(c / 256), math.floor(c % 256)))
1057           else
1058             c = c - 0x10000
1059             local c_hi = c / 1024 + 0xd800
1060             local c_lo = c % 1024 + 0xdc00
1061             tex.sprint(
1062               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1063                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
1064                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
1065                             string.char(0x5c) .. string.char(0x25) .. '03o',
1066                             math.floor(c_hi / 256), math.floor(c_hi % 256),
1067                             math.floor(c_lo / 256), math.floor(c_lo % 256)))
1068           end
1069         end
1070       end
1071     }
1072   \endgroup
1073   \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
1074   % Escape PDF strings without converting
1075   \begingroup
1076     \directlua{
1077       function PDFescstr(str)
1078         for c in string.bytes(str) do
1079           if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
1080             tex.sprint(-2,
1081               string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
1082                             c))
1083           else
1084             tex.sprint(-2, string.char(c))
1085           end
1086         end
1087       end
1088     }
1089     % The -2 in the arguments here gives all the input to TeX catcode 12
1090     % (other) or 10 (space), preventing undefined control sequence errors. See
1091     % https://lists.gnu.org/archive/html/bug-texinfo/2019-08/msg00031.html
1092     %
1093   \endgroup
1094   \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
1095   \ifnum\luatexversion>84
1096     % For LuaTeX >= 0.85
1097     \def\pdfdest{\pdfextension dest}
1098     \let\pdfoutput\outputmode
1099     \def\pdfliteral{\pdfextension literal}
1100     \def\pdfcatalog{\pdfextension catalog}
1101     \def\pdftexversion{\numexpr\pdffeedback version\relax}
1102     \let\pdfximage\saveimageresource
1103     \let\pdfrefximage\useimageresource
1104     \let\pdflastximage\lastsavedimageresourceindex
1105     \def\pdfendlink{\pdfextension endlink\relax}
1106     \def\pdfoutline{\pdfextension outline}
1107     \def\pdfstartlink{\pdfextension startlink}
1108     \def\pdffontattr{\pdfextension fontattr}
1109     \def\pdfobj{\pdfextension obj}
1110     \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
1111     \let\pdfpagewidth\pagewidth
1112     \let\pdfpageheight\pageheight
1113     \edef\pdfhorigin{\pdfvariable horigin}
1114     \edef\pdfvorigin{\pdfvariable vorigin}
1115   \fi
1116 \fi
1117
1118 % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1119 % can be set).  So we test for \relax and 0 as well as being undefined.
1120 \ifx\pdfoutput\thisisundefined
1121 \else
1122   \ifx\pdfoutput\relax
1123   \else
1124     \ifcase\pdfoutput
1125     \else
1126       \pdftrue
1127     \fi
1128   \fi
1129 \fi
1130
1131 \newif\ifpdforxetex
1132 \pdforxetexfalse
1133 \ifpdf
1134   \pdforxetextrue
1135 \fi
1136 \ifx\XeTeXrevision\thisisundefined\else
1137   \pdforxetextrue
1138 \fi
1139
1140
1141 % Output page labels information.
1142 % See PDF reference v.1.7 p.594, section 8.3.1.
1143 \ifpdf
1144 \def\pagelabels{%
1145   \def\title{0 << /P (T-) /S /D >>}%
1146   \edef\roman{\the\romancount << /S /r >>}%
1147   \edef\arabic{\the\arabiccount << /S /D >>}%
1148   %
1149   % Page label ranges must be increasing.  Remove any duplicates.
1150   % (There is a slight chance of this being wrong if e.g. there is
1151   % a @contents but no @titlepage, etc.)
1152   %
1153   \ifnum\romancount=0 \def\roman{}\fi
1154   \ifnum\arabiccount=0 \def\title{}%
1155   \else
1156     \ifnum\romancount=\arabiccount \def\roman{}\fi
1157   \fi
1158   %
1159   \ifnum\romancount<\arabiccount
1160     \pdfcatalog{/PageLabels << /Nums [\title \roman \arabic ] >> }\relax
1161   \else
1162     \pdfcatalog{/PageLabels << /Nums [\title \arabic \roman ] >> }\relax
1163   \fi
1164 }
1165 \else
1166   \let\pagelabels\relax
1167 \fi
1168
1169 \newcount\pagecount \pagecount=0
1170 \newcount\romancount \romancount=0
1171 \newcount\arabiccount \arabiccount=0
1172 \ifpdf
1173   \let\ptxadvancepageno\advancepageno
1174   \def\advancepageno{%
1175     \ptxadvancepageno\global\advance\pagecount by 1
1176   }
1177 \fi
1178
1179
1180 % PDF uses PostScript string constants for the names of xref targets,
1181 % for display in the outlines, and in other places.  Thus, we have to
1182 % double any backslashes.  Otherwise, a name like "\node" will be
1183 % interpreted as a newline (\n), followed by o, d, e.  Not good.
1184 %
1185 % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
1186 % related messages.  The final outcome is that it is up to the TeX user
1187 % to double the backslashes and otherwise make the string valid, so
1188 % that's what we do.  pdftex 1.30.0 (ca.2005) introduced a primitive to
1189 % do this reliably, so we use it.
1190
1191 % #1 is a control sequence in which to do the replacements,
1192 % which we \xdef.
1193 \def\txiescapepdf#1{%
1194   \ifx\pdfescapestring\thisisundefined
1195     % No primitive available; should we give a warning or log?
1196     % Many times it won't matter.
1197     \xdef#1{#1}%
1198   \else
1199     % The expandable \pdfescapestring primitive escapes parentheses,
1200     % backslashes, and other special chars.
1201     \xdef#1{\pdfescapestring{#1}}%
1202   \fi
1203 }
1204 \def\txiescapepdfutfsixteen#1{%
1205   \ifx\pdfescapestrutfsixteen\thisisundefined
1206     % No UTF-16 converting macro available.
1207     \txiescapepdf{#1}%
1208   \else
1209     \xdef#1{\pdfescapestrutfsixteen{#1}}%
1210   \fi
1211 }
1212
1213 \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1214 with PDF output, and none of those formats could be found.  (.eps cannot
1215 be supported due to the design of the PDF format; use regular TeX (DVI
1216 output) for that.)}
1217
1218 \ifpdf
1219   %
1220   % Color manipulation macros using ideas from pdfcolor.tex,
1221   % except using rgb instead of cmyk; the latter is said to render as a
1222   % very dark gray on-screen and a very dark halftone in print, instead
1223   % of actual black. The dark red here is dark enough to print on paper as
1224   % nearly black, but still distinguishable for online viewing.  We use
1225   % black by default, though.
1226   \def\rgbDarkRed{0.50 0.09 0.12}
1227   \def\rgbBlack{0 0 0}
1228   %
1229   % rg sets the color for filling (usual text, etc.);
1230   % RG sets the color for stroking (thin rules, e.g., normal _'s).
1231   \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
1232   %
1233   % Set color, and create a mark which defines \thiscolor accordingly,
1234   % so that \makeheadline knows which color to restore.
1235   \def\setcolor#1{%
1236     \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
1237     \domark
1238     \pdfsetcolor{#1}%
1239   }
1240   %
1241   \def\maincolor{\rgbBlack}
1242   \pdfsetcolor{\maincolor}
1243   \edef\thiscolor{\maincolor}
1244   \def\currentcolordefs{}
1245   %
1246   \def\makefootline{%
1247     \baselineskip24pt
1248     \line{\pdfsetcolor{\maincolor}\the\footline}%
1249   }
1250   %
1251   \def\makeheadline{%
1252     \vbox to 0pt{%
1253       \vskip-22.5pt
1254       \line{%
1255         \vbox to8.5pt{}%
1256         % Extract \thiscolor definition from the marks.
1257         \getcolormarks
1258         % Typeset the headline with \maincolor, then restore the color.
1259         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1260       }%
1261       \vss
1262     }%
1263     \nointerlineskip
1264   }
1265   %
1266   %
1267   \pdfcatalog{/PageMode /UseOutlines}
1268   %
1269   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1270   \def\dopdfimage#1#2#3{%
1271     \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1272     \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1273     %
1274     % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1275     % others).  Let's try in that order, PDF first since if
1276     % someone has a scalable image, presumably better to use that than a
1277     % bitmap.
1278     \let\pdfimgext=\empty
1279     \begingroup
1280       \openin 1 #1.pdf \ifeof 1
1281         \openin 1 #1.PDF \ifeof 1
1282           \openin 1 #1.png \ifeof 1
1283             \openin 1 #1.jpg \ifeof 1
1284               \openin 1 #1.jpeg \ifeof 1
1285                 \openin 1 #1.JPG \ifeof 1
1286                   \errhelp = \nopdfimagehelp
1287                   \errmessage{Could not find image file #1 for pdf}%
1288                 \else \gdef\pdfimgext{JPG}%
1289                 \fi
1290               \else \gdef\pdfimgext{jpeg}%
1291               \fi
1292             \else \gdef\pdfimgext{jpg}%
1293             \fi
1294           \else \gdef\pdfimgext{png}%
1295           \fi
1296         \else \gdef\pdfimgext{PDF}%
1297         \fi
1298       \else \gdef\pdfimgext{pdf}%
1299       \fi
1300       \closein 1
1301     \endgroup
1302     %
1303     % without \immediate, ancient pdftex seg faults when the same image is
1304     % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
1305     \ifnum\pdftexversion < 14
1306       \immediate\pdfimage
1307     \else
1308       \immediate\pdfximage
1309     \fi
1310       \ifdim \wd0 >0pt width \pdfimagewidth \fi
1311       \ifdim \wd2 >0pt height \pdfimageheight \fi
1312       \ifnum\pdftexversion<13
1313          #1.\pdfimgext
1314        \else
1315          {#1.\pdfimgext}%
1316        \fi
1317     \ifnum\pdftexversion < 14 \else
1318       \pdfrefximage \pdflastximage
1319     \fi}
1320   %
1321   \def\setpdfdestname#1{{%
1322     % We have to set dummies so commands such as @code, and characters
1323     % such as \, aren't expanded when present in a section title.
1324     \indexnofonts
1325     \makevalueexpandable
1326     \turnoffactive
1327     \iftxiuseunicodedestname
1328       \ifx \declaredencoding \latone
1329         % Pass through Latin-1 characters.
1330         % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode.
1331       \else
1332         \ifx \declaredencoding \utfeight
1333           % Pass through Unicode characters.
1334         \else
1335           % Use ASCII approximations in destination names.
1336           \passthroughcharsfalse
1337         \fi
1338       \fi
1339     \else
1340       % Use ASCII approximations in destination names.
1341       \passthroughcharsfalse
1342     \fi
1343     \def\pdfdestname{#1}%
1344     \txiescapepdf\pdfdestname
1345   }}
1346   %
1347   \def\setpdfoutlinetext#1{{%
1348     \indexnofonts
1349     \makevalueexpandable
1350     \turnoffactive
1351     \ifx \declaredencoding \latone
1352       % The PDF format can use an extended form of Latin-1 in bookmark
1353       % strings.  See Appendix D of the PDF Reference, Sixth Edition, for
1354       % the "PDFDocEncoding".
1355       \passthroughcharstrue
1356       % Pass through Latin-1 characters.
1357       %   LuaTeX: Convert to Unicode
1358       %   pdfTeX: Use Latin-1 as PDFDocEncoding
1359       \def\pdfoutlinetext{#1}%
1360     \else
1361       \ifx \declaredencoding \utfeight
1362         \ifx\luatexversion\thisisundefined
1363           % For pdfTeX  with UTF-8.
1364           % TODO: the PDF format can use UTF-16 in bookmark strings,
1365           % but the code for this isn't done yet.
1366           % Use ASCII approximations.
1367           \passthroughcharsfalse
1368           \def\pdfoutlinetext{#1}%
1369         \else
1370           % For LuaTeX with UTF-8.
1371           % Pass through Unicode characters for title texts.
1372           \passthroughcharstrue
1373           \def\pdfoutlinetext{#1}%
1374         \fi
1375       \else
1376         % For non-Latin-1 or non-UTF-8 encodings.
1377         % Use ASCII approximations.
1378         \passthroughcharsfalse
1379         \def\pdfoutlinetext{#1}%
1380       \fi
1381     \fi
1382     % LuaTeX: Convert to UTF-16
1383     % pdfTeX: Use Latin-1 as PDFDocEncoding
1384     \txiescapepdfutfsixteen\pdfoutlinetext
1385   }}
1386   %
1387   \def\pdfmkdest#1{%
1388     \setpdfdestname{#1}%
1389     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1390   }
1391   %
1392   % used to mark target names; must be expandable.
1393   \def\pdfmkpgn#1{#1}
1394   %
1395   % by default, use black for everything.
1396   \def\urlcolor{\rgbBlack}
1397   \def\linkcolor{\rgbBlack}
1398   \def\endlink{\setcolor{\maincolor}\pdfendlink}
1399   %
1400   % Adding outlines to PDF; macros for calculating structure of outlines
1401   % come from Petr Olsak
1402   \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1403     \else \csname#1\endcsname \fi}
1404   \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1405     \advance\tempnum by 1
1406     \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1407   %
1408   % #1 is the section text, which is what will be displayed in the
1409   % outline by the pdf viewer.  #2 is the pdf expression for the number
1410   % of subentries (or empty, for subsubsections).  #3 is the node text,
1411   % which might be empty if this toc entry had no corresponding node.
1412   % #4 is the page number
1413   %
1414   \def\dopdfoutline#1#2#3#4{%
1415     % Generate a link to the node text if that exists; else, use the
1416     % page number.  We could generate a destination for the section
1417     % text in the case where a section has no node, but it doesn't
1418     % seem worth the trouble, since most documents are normally structured.
1419     \setpdfoutlinetext{#1}
1420     \setpdfdestname{#3}
1421     \ifx\pdfdestname\empty
1422       \def\pdfdestname{#4}%
1423     \fi
1424     %
1425     \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}%
1426   }
1427   %
1428   \def\pdfmakeoutlines{%
1429     \begingroup
1430       % Read toc silently, to get counts of subentries for \pdfoutline.
1431       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1432       \def\numchapentry##1##2##3##4{%
1433         \def\thischapnum{##2}%
1434         \def\thissecnum{0}%
1435         \def\thissubsecnum{0}%
1436       }%
1437       \def\numsecentry##1##2##3##4{%
1438         \advancenumber{chap\thischapnum}%
1439         \def\thissecnum{##2}%
1440         \def\thissubsecnum{0}%
1441       }%
1442       \def\numsubsecentry##1##2##3##4{%
1443         \advancenumber{sec\thissecnum}%
1444         \def\thissubsecnum{##2}%
1445       }%
1446       \def\numsubsubsecentry##1##2##3##4{%
1447         \advancenumber{subsec\thissubsecnum}%
1448       }%
1449       \def\thischapnum{0}%
1450       \def\thissecnum{0}%
1451       \def\thissubsecnum{0}%
1452       %
1453       % use \def rather than \let here because we redefine \chapentry et
1454       % al. a second time, below.
1455       \def\appentry{\numchapentry}%
1456       \def\appsecentry{\numsecentry}%
1457       \def\appsubsecentry{\numsubsecentry}%
1458       \def\appsubsubsecentry{\numsubsubsecentry}%
1459       \def\unnchapentry{\numchapentry}%
1460       \def\unnsecentry{\numsecentry}%
1461       \def\unnsubsecentry{\numsubsecentry}%
1462       \def\unnsubsubsecentry{\numsubsubsecentry}%
1463       \readdatafile{toc}%
1464       %
1465       % Read toc second time, this time actually producing the outlines.
1466       % The `-' means take the \expnumber as the absolute number of
1467       % subentries, which we calculated on our first read of the .toc above.
1468       %
1469       % We use the node names as the destinations.
1470       %
1471       % Currently we prefix the section name with the section number
1472       % for chapter and appendix headings only in order to avoid too much
1473       % horizontal space being required in the PDF viewer.
1474       \def\numchapentry##1##2##3##4{%
1475         \dopdfoutline{##2 ##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1476       \def\unnchapentry##1##2##3##4{%
1477         \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1478       \def\numsecentry##1##2##3##4{%
1479         \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1480       \def\numsubsecentry##1##2##3##4{%
1481         \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1482       \def\numsubsubsecentry##1##2##3##4{% count is always zero
1483         \dopdfoutline{##1}{}{##3}{##4}}%
1484       %
1485       % PDF outlines are displayed using system fonts, instead of
1486       % document fonts.  Therefore we cannot use special characters,
1487       % since the encoding is unknown.  For example, the eogonek from
1488       % Latin 2 (0xea) gets translated to a | character.  Info from
1489       % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1490       %
1491       % TODO this right, we have to translate 8-bit characters to
1492       % their "best" equivalent, based on the @documentencoding.  Too
1493       % much work for too little return.  Just use the ASCII equivalents
1494       % we use for the index sort strings.
1495       %
1496       \indexnofonts
1497       \setupdatafile
1498       % We can have normal brace characters in the PDF outlines, unlike
1499       % Texinfo index files.  So set that up.
1500       \def\{{\lbracecharliteral}%
1501       \def\}{\rbracecharliteral}%
1502       \catcode`\\=\active \otherbackslash
1503       \input \tocreadfilename
1504     \endgroup
1505   }
1506   {\catcode`[=1 \catcode`]=2
1507    \catcode`{=\other \catcode`}=\other
1508    \gdef\lbracecharliteral[{]%
1509    \gdef\rbracecharliteral[}]%
1510   ]
1511   %
1512   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1513     \ifx\PP\D\let\nextsp\relax
1514     \else\let\nextsp\skipspaces
1515       \addtokens{\filename}{\PP}%
1516       \advance\filenamelength by 1
1517     \fi
1518     \nextsp}
1519   \def\getfilename#1{%
1520     \filenamelength=0
1521     % If we don't expand the argument now, \skipspaces will get
1522     % snagged on things like "@value{foo}".
1523     \edef\temp{#1}%
1524     \expandafter\skipspaces\temp|\relax
1525   }
1526   \ifnum\pdftexversion < 14
1527     \let \startlink \pdfannotlink
1528   \else
1529     \let \startlink \pdfstartlink
1530   \fi
1531   % make a live url in pdf output.
1532   \def\pdfurl#1{%
1533     \begingroup
1534       % it seems we really need yet another set of dummies; have not
1535       % tried to figure out what each command should do in the context
1536       % of @url.  for now, just make @/ a no-op, that's the only one
1537       % people have actually reported a problem with.
1538       %
1539       \normalturnoffactive
1540       \def\@{@}%
1541       \let\/=\empty
1542       \makevalueexpandable
1543       % do we want to go so far as to use \indexnofonts instead of just
1544       % special-casing \var here?
1545       \def\var##1{##1}%
1546       %
1547       \leavevmode\setcolor{\urlcolor}%
1548       \startlink attr{/Border [0 0 0]}%
1549         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1550     \endgroup}
1551   % \pdfgettoks - Surround page numbers in #1 with @pdflink.  #1 may
1552   % be a simple number, or a list of numbers in the case of an index
1553   % entry.
1554   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1555   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1556   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1557   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1558   \def\maketoks{%
1559     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1560     \ifx\first0\adn0
1561     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1562     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1563     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1564     \else
1565       \ifnum0=\countA\else\makelink\fi
1566       \ifx\first.\let\next=\done\else
1567         \let\next=\maketoks
1568         \addtokens{\toksB}{\the\toksD}
1569         \ifx\first,\addtokens{\toksB}{\space}\fi
1570       \fi
1571     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1572     \next}
1573   \def\makelink{\addtokens{\toksB}%
1574     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1575   \def\pdflink#1{%
1576     \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1577     \setcolor{\linkcolor}#1\endlink}
1578   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1579 \else
1580   % non-pdf mode
1581   \let\pdfmkdest = \gobble
1582   \let\pdfurl = \gobble
1583   \let\endlink = \relax
1584   \let\setcolor = \gobble
1585   \let\pdfsetcolor = \gobble
1586   \let\pdfmakeoutlines = \relax
1587 \fi  % \ifx\pdfoutput
1588
1589 %
1590 % For XeTeX
1591 %
1592 \ifx\XeTeXrevision\thisisundefined
1593 \else
1594   %
1595   % XeTeX version check
1596   %
1597   \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1
1598     % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307.
1599     % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941).
1600     % For avoiding PDF destination name replacement, we use this special
1601     % instead of xdvipdfmx's command line option `-C 0x0010'.
1602     \special{dvipdfmx:config C 0x0010}
1603     % XeTeX 0.99995+ comes with xdvipdfmx 20160307+.
1604     % It can handle Unicode destination names for PDF.
1605     \txiuseunicodedestnametrue
1606   \else
1607     % XeTeX < 0.99996 (TeX Live < 2016) cannot use the
1608     % `dvipdfmx:config' special.
1609     % So for avoiding PDF destination name replacement,
1610     % xdvipdfmx's command line option `-C 0x0010' is necessary.
1611     %
1612     % XeTeX < 0.99995 can not handle Unicode destination names for PDF
1613     % because xdvipdfmx 20150315 has a UTF-16 conversion issue.
1614     % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1615     \txiuseunicodedestnamefalse
1616   \fi
1617   %
1618   % Color support
1619   %
1620   \def\rgbDarkRed{0.50 0.09 0.12}
1621   \def\rgbBlack{0 0 0}
1622   %
1623   \def\pdfsetcolor#1{\special{pdf:scolor [#1]}}
1624   %
1625   % Set color, and create a mark which defines \thiscolor accordingly,
1626   % so that \makeheadline knows which color to restore.
1627   \def\setcolor#1{%
1628     \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
1629     \domark
1630     \pdfsetcolor{#1}%
1631   }
1632   %
1633   \def\maincolor{\rgbBlack}
1634   \pdfsetcolor{\maincolor}
1635   \edef\thiscolor{\maincolor}
1636   \def\currentcolordefs{}
1637   %
1638   \def\makefootline{%
1639     \baselineskip24pt
1640     \line{\pdfsetcolor{\maincolor}\the\footline}%
1641   }
1642   %
1643   \def\makeheadline{%
1644     \vbox to 0pt{%
1645       \vskip-22.5pt
1646       \line{%
1647         \vbox to8.5pt{}%
1648         % Extract \thiscolor definition from the marks.
1649         \getcolormarks
1650         % Typeset the headline with \maincolor, then restore the color.
1651         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1652       }%
1653       \vss
1654     }%
1655     \nointerlineskip
1656   }
1657   %
1658   % PDF outline support
1659   %
1660   % Emulate pdfTeX primitive
1661   \def\pdfdest name#1 xyz{%
1662     \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}%
1663   }
1664   %
1665   \def\setpdfdestname#1{{%
1666     % We have to set dummies so commands such as @code, and characters
1667     % such as \, aren't expanded when present in a section title.
1668     \indexnofonts
1669     \makevalueexpandable
1670     \turnoffactive
1671     \iftxiuseunicodedestname
1672       % Pass through Unicode characters.
1673     \else
1674       % Use ASCII approximations in destination names.
1675       \passthroughcharsfalse
1676     \fi
1677     \def\pdfdestname{#1}%
1678     \txiescapepdf\pdfdestname
1679   }}
1680   %
1681   \def\setpdfoutlinetext#1{{%
1682     \turnoffactive
1683     % Always use Unicode characters in title texts.
1684     \def\pdfoutlinetext{#1}%
1685     % For XeTeX, xdvipdfmx converts to UTF-16.
1686     % So we do not convert.
1687     \txiescapepdf\pdfoutlinetext
1688   }}
1689   %
1690   \def\pdfmkdest#1{%
1691     \setpdfdestname{#1}%
1692     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1693   }
1694   %
1695   % by default, use black for everything.
1696   \def\urlcolor{\rgbBlack}
1697   \def\linkcolor{\rgbBlack}
1698   \def\endlink{\setcolor{\maincolor}\pdfendlink}
1699   %
1700   \def\dopdfoutline#1#2#3#4{%
1701     \setpdfoutlinetext{#1}
1702     \setpdfdestname{#3}
1703     \ifx\pdfdestname\empty
1704       \def\pdfdestname{#4}%
1705     \fi
1706     %
1707     \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
1708       << /S /GoTo /D (\pdfdestname) >> >> }%
1709   }
1710   %
1711   \def\pdfmakeoutlines{%
1712     \begingroup
1713       %
1714       % For XeTeX, counts of subentries are not necessary.
1715       % Therefore, we read toc only once.
1716       %
1717       % We use node names as destinations.
1718       %
1719       % Currently we prefix the section name with the section number
1720       % for chapter and appendix headings only in order to avoid too much
1721       % horizontal space being required in the PDF viewer.
1722       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1723       \def\numchapentry##1##2##3##4{%
1724         \dopdfoutline{##2 ##1}{1}{##3}{##4}}%
1725       \def\numsecentry##1##2##3##4{%
1726         \dopdfoutline{##1}{2}{##3}{##4}}%
1727       \def\numsubsecentry##1##2##3##4{%
1728         \dopdfoutline{##1}{3}{##3}{##4}}%
1729       \def\numsubsubsecentry##1##2##3##4{%
1730         \dopdfoutline{##1}{4}{##3}{##4}}%
1731       %
1732       \let\appentry\numchapentry%
1733       \let\appsecentry\numsecentry%
1734       \let\appsubsecentry\numsubsecentry%
1735       \let\appsubsubsecentry\numsubsubsecentry%
1736       \def\unnchapentry##1##2##3##4{%
1737         \dopdfoutline{##1}{1}{##3}{##4}}%
1738       \let\unnsecentry\numsecentry%
1739       \let\unnsubsecentry\numsubsecentry%
1740       \let\unnsubsubsecentry\numsubsubsecentry%
1741       %
1742       % For XeTeX, xdvipdfmx converts strings to UTF-16.
1743       % Therefore, the encoding and the language may not be considered.
1744       %
1745       \indexnofonts
1746       \setupdatafile
1747       % We can have normal brace characters in the PDF outlines, unlike
1748       % Texinfo index files.  So set that up.
1749       \def\{{\lbracecharliteral}%
1750       \def\}{\rbracecharliteral}%
1751       \catcode`\\=\active \otherbackslash
1752       \input \tocreadfilename
1753     \endgroup
1754   }
1755   {\catcode`[=1 \catcode`]=2
1756    \catcode`{=\other \catcode`}=\other
1757    \gdef\lbracecharliteral[{]%
1758    \gdef\rbracecharliteral[}]%
1759   ]
1760
1761   \special{pdf:docview << /PageMode /UseOutlines >> }
1762   % ``\special{pdf:tounicode ...}'' is not necessary
1763   % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
1764   % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315,
1765   % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings.
1766   % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1767 %
1768   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1769     \ifx\PP\D\let\nextsp\relax
1770     \else\let\nextsp\skipspaces
1771       \addtokens{\filename}{\PP}%
1772       \advance\filenamelength by 1
1773     \fi
1774     \nextsp}
1775   \def\getfilename#1{%
1776     \filenamelength=0
1777     % If we don't expand the argument now, \skipspaces will get
1778     % snagged on things like "@value{foo}".
1779     \edef\temp{#1}%
1780     \expandafter\skipspaces\temp|\relax
1781   }
1782   % make a live url in pdf output.
1783   \def\pdfurl#1{%
1784     \begingroup
1785       % it seems we really need yet another set of dummies; have not
1786       % tried to figure out what each command should do in the context
1787       % of @url.  for now, just make @/ a no-op, that's the only one
1788       % people have actually reported a problem with.
1789       %
1790       \normalturnoffactive
1791       \def\@{@}%
1792       \let\/=\empty
1793       \makevalueexpandable
1794       % do we want to go so far as to use \indexnofonts instead of just
1795       % special-casing \var here?
1796       \def\var##1{##1}%
1797       %
1798       \leavevmode\setcolor{\urlcolor}%
1799       \special{pdf:bann << /Border [0 0 0]
1800         /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
1801     \endgroup}
1802   \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
1803   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1804   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1805   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1806   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1807   \def\maketoks{%
1808     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1809     \ifx\first0\adn0
1810     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1811     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1812     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1813     \else
1814       \ifnum0=\countA\else\makelink\fi
1815       \ifx\first.\let\next=\done\else
1816         \let\next=\maketoks
1817         \addtokens{\toksB}{\the\toksD}
1818         \ifx\first,\addtokens{\toksB}{\space}\fi
1819       \fi
1820     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1821     \next}
1822   \def\makelink{\addtokens{\toksB}%
1823     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1824   \def\pdflink#1{%
1825     \special{pdf:bann << /Border [0 0 0]
1826       /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}%
1827     \setcolor{\linkcolor}#1\endlink}
1828   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1829 %
1830   %
1831   % @image support
1832   %
1833   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1834   \def\doxeteximage#1#2#3{%
1835     \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1836     \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1837     %
1838     % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among
1839     % others).  Let's try in that order, PDF first since if
1840     % someone has a scalable image, presumably better to use that than a
1841     % bitmap.
1842     \let\xeteximgext=\empty
1843     \begingroup
1844       \openin 1 #1.pdf \ifeof 1
1845         \openin 1 #1.PDF \ifeof 1
1846           \openin 1 #1.png \ifeof 1
1847             \openin 1 #1.jpg \ifeof 1
1848               \openin 1 #1.jpeg \ifeof 1
1849                 \openin 1 #1.JPG \ifeof 1
1850                   \errmessage{Could not find image file #1 for XeTeX}%
1851                 \else \gdef\xeteximgext{JPG}%
1852                 \fi
1853               \else \gdef\xeteximgext{jpeg}%
1854               \fi
1855             \else \gdef\xeteximgext{jpg}%
1856             \fi
1857           \else \gdef\xeteximgext{png}%
1858           \fi
1859         \else \gdef\xeteximgext{PDF}%
1860         \fi
1861       \else \gdef\xeteximgext{pdf}%
1862       \fi
1863       \closein 1
1864     \endgroup
1865     %
1866     \def\xetexpdfext{pdf}%
1867     \ifx\xeteximgext\xetexpdfext
1868       \XeTeXpdffile "#1".\xeteximgext ""
1869     \else
1870       \def\xetexpdfext{PDF}%
1871       \ifx\xeteximgext\xetexpdfext
1872         \XeTeXpdffile "#1".\xeteximgext ""
1873       \else
1874         \XeTeXpicfile "#1".\xeteximgext ""
1875       \fi
1876     \fi
1877     \ifdim \wd0 >0pt width \xeteximagewidth \fi
1878     \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1879   }
1880 \fi
1881
1882
1883 %
1884 \message{fonts,}
1885
1886 % Set the baselineskip to #1, and the lineskip and strut size
1887 % correspondingly.  There is no deep meaning behind these magic numbers
1888 % used as factors; they just match (closely enough) what Knuth defined.
1889 %
1890 \def\lineskipfactor{.08333}
1891 \def\strutheightpercent{.70833}
1892 \def\strutdepthpercent {.29167}
1893 %
1894 % can get a sort of poor man's double spacing by redefining this.
1895 \def\baselinefactor{1}
1896 %
1897 \newdimen\textleading
1898 \def\setleading#1{%
1899   \dimen0 = #1\relax
1900   \normalbaselineskip = \baselinefactor\dimen0
1901   \normallineskip = \lineskipfactor\normalbaselineskip
1902   \normalbaselines
1903   \setbox\strutbox =\hbox{%
1904     \vrule width0pt height\strutheightpercent\baselineskip
1905                     depth \strutdepthpercent \baselineskip
1906   }%
1907 }
1908
1909 % PDF CMaps.  See also LaTeX's t1.cmap.
1910 %
1911 % do nothing with this by default.
1912 \expandafter\let\csname cmapOT1\endcsname\gobble
1913 \expandafter\let\csname cmapOT1IT\endcsname\gobble
1914 \expandafter\let\csname cmapOT1TT\endcsname\gobble
1915
1916 % if we are producing pdf, and we have \pdffontattr, then define cmaps.
1917 % (\pdffontattr was introduced many years ago, but people still run
1918 % older pdftex's; it's easy to conditionalize, so we do.)
1919 \ifpdf \ifx\pdffontattr\thisisundefined \else
1920   \begingroup
1921     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1922     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1923 %%DocumentNeededResources: ProcSet (CIDInit)
1924 %%IncludeResource: ProcSet (CIDInit)
1925 %%BeginResource: CMap (TeX-OT1-0)
1926 %%Title: (TeX-OT1-0 TeX OT1 0)
1927 %%Version: 1.000
1928 %%EndComments
1929 /CIDInit /ProcSet findresource begin
1930 12 dict begin
1931 begincmap
1932 /CIDSystemInfo
1933 << /Registry (TeX)
1934 /Ordering (OT1)
1935 /Supplement 0
1936 >> def
1937 /CMapName /TeX-OT1-0 def
1938 /CMapType 2 def
1939 1 begincodespacerange
1940 <00> <7F>
1941 endcodespacerange
1942 8 beginbfrange
1943 <00> <01> <0393>
1944 <09> <0A> <03A8>
1945 <23> <26> <0023>
1946 <28> <3B> <0028>
1947 <3F> <5B> <003F>
1948 <5D> <5E> <005D>
1949 <61> <7A> <0061>
1950 <7B> <7C> <2013>
1951 endbfrange
1952 40 beginbfchar
1953 <02> <0398>
1954 <03> <039B>
1955 <04> <039E>
1956 <05> <03A0>
1957 <06> <03A3>
1958 <07> <03D2>
1959 <08> <03A6>
1960 <0B> <00660066>
1961 <0C> <00660069>
1962 <0D> <0066006C>
1963 <0E> <006600660069>
1964 <0F> <00660066006C>
1965 <10> <0131>
1966 <11> <0237>
1967 <12> <0060>
1968 <13> <00B4>
1969 <14> <02C7>
1970 <15> <02D8>
1971 <16> <00AF>
1972 <17> <02DA>
1973 <18> <00B8>
1974 <19> <00DF>
1975 <1A> <00E6>
1976 <1B> <0153>
1977 <1C> <00F8>
1978 <1D> <00C6>
1979 <1E> <0152>
1980 <1F> <00D8>
1981 <21> <0021>
1982 <22> <201D>
1983 <27> <2019>
1984 <3C> <00A1>
1985 <3D> <003D>
1986 <3E> <00BF>
1987 <5C> <201C>
1988 <5F> <02D9>
1989 <60> <2018>
1990 <7D> <02DD>
1991 <7E> <007E>
1992 <7F> <00A8>
1993 endbfchar
1994 endcmap
1995 CMapName currentdict /CMap defineresource pop
1996 end
1997 end
1998 %%EndResource
1999 %%EOF
2000     }\endgroup
2001   \expandafter\edef\csname cmapOT1\endcsname#1{%
2002     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2003   }%
2004 %
2005 % \cmapOT1IT
2006   \begingroup
2007     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2008     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2009 %%DocumentNeededResources: ProcSet (CIDInit)
2010 %%IncludeResource: ProcSet (CIDInit)
2011 %%BeginResource: CMap (TeX-OT1IT-0)
2012 %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
2013 %%Version: 1.000
2014 %%EndComments
2015 /CIDInit /ProcSet findresource begin
2016 12 dict begin
2017 begincmap
2018 /CIDSystemInfo
2019 << /Registry (TeX)
2020 /Ordering (OT1IT)
2021 /Supplement 0
2022 >> def
2023 /CMapName /TeX-OT1IT-0 def
2024 /CMapType 2 def
2025 1 begincodespacerange
2026 <00> <7F>
2027 endcodespacerange
2028 8 beginbfrange
2029 <00> <01> <0393>
2030 <09> <0A> <03A8>
2031 <25> <26> <0025>
2032 <28> <3B> <0028>
2033 <3F> <5B> <003F>
2034 <5D> <5E> <005D>
2035 <61> <7A> <0061>
2036 <7B> <7C> <2013>
2037 endbfrange
2038 42 beginbfchar
2039 <02> <0398>
2040 <03> <039B>
2041 <04> <039E>
2042 <05> <03A0>
2043 <06> <03A3>
2044 <07> <03D2>
2045 <08> <03A6>
2046 <0B> <00660066>
2047 <0C> <00660069>
2048 <0D> <0066006C>
2049 <0E> <006600660069>
2050 <0F> <00660066006C>
2051 <10> <0131>
2052 <11> <0237>
2053 <12> <0060>
2054 <13> <00B4>
2055 <14> <02C7>
2056 <15> <02D8>
2057 <16> <00AF>
2058 <17> <02DA>
2059 <18> <00B8>
2060 <19> <00DF>
2061 <1A> <00E6>
2062 <1B> <0153>
2063 <1C> <00F8>
2064 <1D> <00C6>
2065 <1E> <0152>
2066 <1F> <00D8>
2067 <21> <0021>
2068 <22> <201D>
2069 <23> <0023>
2070 <24> <00A3>
2071 <27> <2019>
2072 <3C> <00A1>
2073 <3D> <003D>
2074 <3E> <00BF>
2075 <5C> <201C>
2076 <5F> <02D9>
2077 <60> <2018>
2078 <7D> <02DD>
2079 <7E> <007E>
2080 <7F> <00A8>
2081 endbfchar
2082 endcmap
2083 CMapName currentdict /CMap defineresource pop
2084 end
2085 end
2086 %%EndResource
2087 %%EOF
2088     }\endgroup
2089   \expandafter\edef\csname cmapOT1IT\endcsname#1{%
2090     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2091   }%
2092 %
2093 % \cmapOT1TT
2094   \begingroup
2095     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2096     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2097 %%DocumentNeededResources: ProcSet (CIDInit)
2098 %%IncludeResource: ProcSet (CIDInit)
2099 %%BeginResource: CMap (TeX-OT1TT-0)
2100 %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
2101 %%Version: 1.000
2102 %%EndComments
2103 /CIDInit /ProcSet findresource begin
2104 12 dict begin
2105 begincmap
2106 /CIDSystemInfo
2107 << /Registry (TeX)
2108 /Ordering (OT1TT)
2109 /Supplement 0
2110 >> def
2111 /CMapName /TeX-OT1TT-0 def
2112 /CMapType 2 def
2113 1 begincodespacerange
2114 <00> <7F>
2115 endcodespacerange
2116 5 beginbfrange
2117 <00> <01> <0393>
2118 <09> <0A> <03A8>
2119 <21> <26> <0021>
2120 <28> <5F> <0028>
2121 <61> <7E> <0061>
2122 endbfrange
2123 32 beginbfchar
2124 <02> <0398>
2125 <03> <039B>
2126 <04> <039E>
2127 <05> <03A0>
2128 <06> <03A3>
2129 <07> <03D2>
2130 <08> <03A6>
2131 <0B> <2191>
2132 <0C> <2193>
2133 <0D> <0027>
2134 <0E> <00A1>
2135 <0F> <00BF>
2136 <10> <0131>
2137 <11> <0237>
2138 <12> <0060>
2139 <13> <00B4>
2140 <14> <02C7>
2141 <15> <02D8>
2142 <16> <00AF>
2143 <17> <02DA>
2144 <18> <00B8>
2145 <19> <00DF>
2146 <1A> <00E6>
2147 <1B> <0153>
2148 <1C> <00F8>
2149 <1D> <00C6>
2150 <1E> <0152>
2151 <1F> <00D8>
2152 <20> <2423>
2153 <27> <2019>
2154 <60> <2018>
2155 <7F> <00A8>
2156 endbfchar
2157 endcmap
2158 CMapName currentdict /CMap defineresource pop
2159 end
2160 end
2161 %%EndResource
2162 %%EOF
2163     }\endgroup
2164   \expandafter\edef\csname cmapOT1TT\endcsname#1{%
2165     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2166   }%
2167 \fi\fi
2168
2169
2170 % Set the font macro #1 to the font named \fontprefix#2.
2171 % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
2172 % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
2173 % Example:
2174 % #1 = \textrm
2175 % #2 = \rmshape
2176 % #3 = 10
2177 % #4 = \mainmagstep
2178 % #5 = OT1
2179 %
2180 \def\setfont#1#2#3#4#5{%
2181   \font#1=\fontprefix#2#3 scaled #4
2182   \csname cmap#5\endcsname#1%
2183 }
2184 % This is what gets called when #5 of \setfont is empty.
2185 \let\cmap\gobble
2186 %
2187 % (end of cmaps)
2188
2189 % Use cm as the default font prefix.
2190 % To specify the font prefix, you must define \fontprefix
2191 % before you read in texinfo.tex.
2192 \ifx\fontprefix\thisisundefined
2193 \def\fontprefix{cm}
2194 \fi
2195 % Support font families that don't use the same naming scheme as CM.
2196 \def\rmshape{r}
2197 \def\rmbshape{bx}               % where the normal face is bold
2198 \def\bfshape{b}
2199 \def\bxshape{bx}
2200 \def\ttshape{tt}
2201 \def\ttbshape{tt}
2202 \def\ttslshape{sltt}
2203 \def\itshape{ti}
2204 \def\itbshape{bxti}
2205 \def\slshape{sl}
2206 \def\slbshape{bxsl}
2207 \def\sfshape{ss}
2208 \def\sfbshape{ss}
2209 \def\scshape{csc}
2210 \def\scbshape{csc}
2211
2212 % Definitions for a main text size of 11pt.  (The default in Texinfo.)
2213 %
2214 \def\definetextfontsizexi{%
2215 % Text fonts (11.2pt, magstep1).
2216 \def\textnominalsize{11pt}
2217 \edef\mainmagstep{\magstephalf}
2218 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2219 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2220 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2221 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2222 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2223 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2224 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2225 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2226 \font\texti=cmmi10 scaled \mainmagstep
2227 \font\textsy=cmsy10 scaled \mainmagstep
2228 \def\textecsize{1095}
2229
2230 % A few fonts for @defun names and args.
2231 \setfont\defbf\bfshape{10}{\magstep1}{OT1}
2232 \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
2233 \setfont\defsl\slshape{10}{\magstep1}{OT1}
2234 \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
2235 \def\df{\let\ttfont=\deftt \let\bffont = \defbf
2236 \let\ttslfont=\defttsl \let\slfont=\defsl \bf}
2237
2238 % Fonts for indices, footnotes, small examples (9pt).
2239 \def\smallnominalsize{9pt}
2240 \setfont\smallrm\rmshape{9}{1000}{OT1}
2241 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2242 \setfont\smallbf\bfshape{10}{900}{OT1}
2243 \setfont\smallit\itshape{9}{1000}{OT1IT}
2244 \setfont\smallsl\slshape{9}{1000}{OT1}
2245 \setfont\smallsf\sfshape{9}{1000}{OT1}
2246 \setfont\smallsc\scshape{10}{900}{OT1}
2247 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2248 \font\smalli=cmmi9
2249 \font\smallsy=cmsy9
2250 \def\smallecsize{0900}
2251
2252 % Fonts for small examples (8pt).
2253 \def\smallernominalsize{8pt}
2254 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2255 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2256 \setfont\smallerbf\bfshape{10}{800}{OT1}
2257 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2258 \setfont\smallersl\slshape{8}{1000}{OT1}
2259 \setfont\smallersf\sfshape{8}{1000}{OT1}
2260 \setfont\smallersc\scshape{10}{800}{OT1}
2261 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2262 \font\smalleri=cmmi8
2263 \font\smallersy=cmsy8
2264 \def\smallerecsize{0800}
2265
2266 % Fonts for math mode superscripts (7pt).
2267 \def\sevennominalsize{7pt}
2268 \setfont\sevenrm\rmshape{7}{1000}{OT1}
2269 \setfont\seventt\ttshape{10}{700}{OT1TT}
2270 \setfont\sevenbf\bfshape{10}{700}{OT1}
2271 \setfont\sevenit\itshape{7}{1000}{OT1IT}
2272 \setfont\sevensl\slshape{10}{700}{OT1}
2273 \setfont\sevensf\sfshape{10}{700}{OT1}
2274 \setfont\sevensc\scshape{10}{700}{OT1}
2275 \setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2276 \font\seveni=cmmi7
2277 \font\sevensy=cmsy7
2278 \def\sevenecsize{0700}
2279
2280 % Fonts for title page (20.4pt):
2281 \def\titlenominalsize{20pt}
2282 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2283 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2284 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2285 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2286 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2287 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2288 \let\titlebf=\titlerm
2289 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2290 \font\titlei=cmmi12 scaled \magstep3
2291 \font\titlesy=cmsy10 scaled \magstep4
2292 \def\titleecsize{2074}
2293
2294 % Chapter (and unnumbered) fonts (17.28pt).
2295 \def\chapnominalsize{17pt}
2296 \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2297 \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2298 \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2299 \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2300 \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2301 \setfont\chapsf\sfbshape{17}{1000}{OT1}
2302 \let\chapbf=\chaprm
2303 \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
2304 \font\chapi=cmmi12 scaled \magstep2
2305 \font\chapsy=cmsy10 scaled \magstep3
2306 \def\chapecsize{1728}
2307
2308 % Section fonts (14.4pt).
2309 \def\secnominalsize{14pt}
2310 \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
2311 \setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
2312 \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2313 \setfont\secsl\slbshape{10}{\magstep2}{OT1}
2314 \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2315 \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2316 \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
2317 \let\secbf\secrm
2318 \setfont\secsc\scbshape{10}{\magstep2}{OT1}
2319 \font\seci=cmmi12 scaled \magstep1
2320 \font\secsy=cmsy10 scaled \magstep2
2321 \def\sececsize{1440}
2322
2323 % Subsection fonts (13.15pt).
2324 \def\ssecnominalsize{13pt}
2325 \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2326 \setfont\ssecit\itbshape{10}{1315}{OT1IT}
2327 \setfont\ssecsl\slbshape{10}{1315}{OT1}
2328 \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2329 \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2330 \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
2331 \let\ssecbf\ssecrm
2332 \setfont\ssecsc\scbshape{10}{1315}{OT1}
2333 \font\sseci=cmmi12 scaled \magstephalf
2334 \font\ssecsy=cmsy10 scaled 1315
2335 \def\ssececsize{1200}
2336
2337 % Reduced fonts for @acronym in text (10pt).
2338 \def\reducednominalsize{10pt}
2339 \setfont\reducedrm\rmshape{10}{1000}{OT1}
2340 \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2341 \setfont\reducedbf\bfshape{10}{1000}{OT1}
2342 \setfont\reducedit\itshape{10}{1000}{OT1IT}
2343 \setfont\reducedsl\slshape{10}{1000}{OT1}
2344 \setfont\reducedsf\sfshape{10}{1000}{OT1}
2345 \setfont\reducedsc\scshape{10}{1000}{OT1}
2346 \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
2347 \font\reducedi=cmmi10
2348 \font\reducedsy=cmsy10
2349 \def\reducedecsize{1000}
2350
2351 \textleading = 13.2pt % line spacing for 11pt CM
2352 \textfonts            % reset the current fonts
2353 \rm
2354 } % end of 11pt text font size definitions, \definetextfontsizexi
2355
2356
2357 % Definitions to make the main text be 10pt Computer Modern, with
2358 % section, chapter, etc., sizes following suit.  This is for the GNU
2359 % Press printing of the Emacs 22 manual.  Maybe other manuals in the
2360 % future.  Used with @smallbook, which sets the leading to 12pt.
2361 %
2362 \def\definetextfontsizex{%
2363 % Text fonts (10pt).
2364 \def\textnominalsize{10pt}
2365 \edef\mainmagstep{1000}
2366 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2367 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2368 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2369 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2370 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2371 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2372 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2373 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2374 \font\texti=cmmi10 scaled \mainmagstep
2375 \font\textsy=cmsy10 scaled \mainmagstep
2376 \def\textecsize{1000}
2377
2378 % A few fonts for @defun names and args.
2379 \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2380 \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
2381 \setfont\defsl\slshape{10}{\magstephalf}{OT1}
2382 \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
2383 \def\df{\let\ttfont=\deftt \let\bffont = \defbf
2384 \let\slfont=\defsl \let\ttslfont=\defttsl \bf}
2385
2386 % Fonts for indices, footnotes, small examples (9pt).
2387 \def\smallnominalsize{9pt}
2388 \setfont\smallrm\rmshape{9}{1000}{OT1}
2389 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2390 \setfont\smallbf\bfshape{10}{900}{OT1}
2391 \setfont\smallit\itshape{9}{1000}{OT1IT}
2392 \setfont\smallsl\slshape{9}{1000}{OT1}
2393 \setfont\smallsf\sfshape{9}{1000}{OT1}
2394 \setfont\smallsc\scshape{10}{900}{OT1}
2395 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2396 \font\smalli=cmmi9
2397 \font\smallsy=cmsy9
2398 \def\smallecsize{0900}
2399
2400 % Fonts for small examples (8pt).
2401 \def\smallernominalsize{8pt}
2402 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2403 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2404 \setfont\smallerbf\bfshape{10}{800}{OT1}
2405 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2406 \setfont\smallersl\slshape{8}{1000}{OT1}
2407 \setfont\smallersf\sfshape{8}{1000}{OT1}
2408 \setfont\smallersc\scshape{10}{800}{OT1}
2409 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2410 \font\smalleri=cmmi8
2411 \font\smallersy=cmsy8
2412 \def\smallerecsize{0800}
2413
2414 % Fonts for math mode superscripts (7pt).
2415 \def\sevennominalsize{7pt}
2416 \setfont\sevenrm\rmshape{7}{1000}{OT1}
2417 \setfont\seventt\ttshape{10}{700}{OT1TT}
2418 \setfont\sevenbf\bfshape{10}{700}{OT1}
2419 \setfont\sevenit\itshape{7}{1000}{OT1IT}
2420 \setfont\sevensl\slshape{10}{700}{OT1}
2421 \setfont\sevensf\sfshape{10}{700}{OT1}
2422 \setfont\sevensc\scshape{10}{700}{OT1}
2423 \setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2424 \font\seveni=cmmi7
2425 \font\sevensy=cmsy7
2426 \def\sevenecsize{0700}
2427
2428 % Fonts for title page (20.4pt):
2429 \def\titlenominalsize{20pt}
2430 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2431 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2432 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2433 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2434 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2435 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2436 \let\titlebf=\titlerm
2437 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2438 \font\titlei=cmmi12 scaled \magstep3
2439 \font\titlesy=cmsy10 scaled \magstep4
2440 \def\titleecsize{2074}
2441
2442 % Chapter fonts (14.4pt).
2443 \def\chapnominalsize{14pt}
2444 \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2445 \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2446 \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2447 \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2448 \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2449 \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2450 \let\chapbf\chaprm
2451 \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2452 \font\chapi=cmmi12 scaled \magstep1
2453 \font\chapsy=cmsy10 scaled \magstep2
2454 \def\chapecsize{1440}
2455
2456 % Section fonts (12pt).
2457 \def\secnominalsize{12pt}
2458 \setfont\secrm\rmbshape{12}{1000}{OT1}
2459 \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2460 \setfont\secsl\slbshape{10}{\magstep1}{OT1}
2461 \setfont\sectt\ttbshape{12}{1000}{OT1TT}
2462 \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2463 \setfont\secsf\sfbshape{12}{1000}{OT1}
2464 \let\secbf\secrm
2465 \setfont\secsc\scbshape{10}{\magstep1}{OT1}
2466 \font\seci=cmmi12
2467 \font\secsy=cmsy10 scaled \magstep1
2468 \def\sececsize{1200}
2469
2470 % Subsection fonts (10pt).
2471 \def\ssecnominalsize{10pt}
2472 \setfont\ssecrm\rmbshape{10}{1000}{OT1}
2473 \setfont\ssecit\itbshape{10}{1000}{OT1IT}
2474 \setfont\ssecsl\slbshape{10}{1000}{OT1}
2475 \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2476 \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2477 \setfont\ssecsf\sfbshape{10}{1000}{OT1}
2478 \let\ssecbf\ssecrm
2479 \setfont\ssecsc\scbshape{10}{1000}{OT1}
2480 \font\sseci=cmmi10
2481 \font\ssecsy=cmsy10
2482 \def\ssececsize{1000}
2483
2484 % Reduced fonts for @acronym in text (9pt).
2485 \def\reducednominalsize{9pt}
2486 \setfont\reducedrm\rmshape{9}{1000}{OT1}
2487 \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2488 \setfont\reducedbf\bfshape{10}{900}{OT1}
2489 \setfont\reducedit\itshape{9}{1000}{OT1IT}
2490 \setfont\reducedsl\slshape{9}{1000}{OT1}
2491 \setfont\reducedsf\sfshape{9}{1000}{OT1}
2492 \setfont\reducedsc\scshape{10}{900}{OT1}
2493 \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2494 \font\reducedi=cmmi9
2495 \font\reducedsy=cmsy9
2496 \def\reducedecsize{0900}
2497
2498 \divide\parskip by 2  % reduce space between paragraphs
2499 \textleading = 12pt   % line spacing for 10pt CM
2500 \textfonts            % reset the current fonts
2501 \rm
2502 } % end of 10pt text font size definitions, \definetextfontsizex
2503
2504 % Fonts for short table of contents.
2505 \setfont\shortcontrm\rmshape{12}{1000}{OT1}
2506 \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
2507 \setfont\shortcontsl\slshape{12}{1000}{OT1}
2508 \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2509
2510
2511 % We provide the user-level command
2512 %   @fonttextsize 10
2513 % (or 11) to redefine the text font size.  pt is assumed.
2514 %
2515 \def\xiword{11}
2516 \def\xword{10}
2517 \def\xwordpt{10pt}
2518 %
2519 \parseargdef\fonttextsize{%
2520   \def\textsizearg{#1}%
2521   %\wlog{doing @fonttextsize \textsizearg}%
2522   %
2523   % Set \globaldefs so that documents can use this inside @tex, since
2524   % makeinfo 4.8 does not support it, but we need it nonetheless.
2525   %
2526  \begingroup \globaldefs=1
2527   \ifx\textsizearg\xword \definetextfontsizex
2528   \else \ifx\textsizearg\xiword \definetextfontsizexi
2529   \else
2530     \errhelp=\EMsimple
2531     \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2532   \fi\fi
2533  \endgroup
2534 }
2535
2536 %
2537 % Change the current font style to #1, remembering it in \curfontstyle.
2538 % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
2539 % italics, not bold italics.
2540 %
2541 \def\setfontstyle#1{%
2542   \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
2543   \csname #1font\endcsname  % change the current font
2544 }
2545
2546 \def\rm{\fam=0 \setfontstyle{rm}}
2547 \def\it{\fam=\itfam \setfontstyle{it}}
2548 \def\sl{\fam=\slfam \setfontstyle{sl}}
2549 \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
2550 \def\tt{\fam=\ttfam \setfontstyle{tt}}\def\ttstylename{tt}
2551
2552 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
2553 % So we set up a \sf.
2554 \newfam\sffam
2555 \def\sf{\fam=\sffam \setfontstyle{sf}}
2556
2557 % We don't need math for this font style.
2558 \def\ttsl{\setfontstyle{ttsl}}
2559
2560
2561 % In order for the font changes to affect most math symbols and letters,
2562 % we have to define the \textfont of the standard families.
2563 % We don't bother to reset \scriptscriptfont; awaiting user need.
2564 %
2565 \def\resetmathfonts{%
2566   \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont
2567   \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont
2568   \textfont\ttfam=\ttfont \textfont\sffam=\sffont
2569   %
2570   % Fonts for superscript.  Note that the 7pt fonts are used regardless
2571   % of the current font size.
2572   \scriptfont0=\sevenrm \scriptfont1=\seveni \scriptfont2=\sevensy
2573   \scriptfont\itfam=\sevenit \scriptfont\slfam=\sevensl
2574   \scriptfont\bffam=\sevenbf \scriptfont\ttfam=\seventt
2575   \scriptfont\sffam=\sevensf
2576 }
2577
2578 %
2579
2580 % The font-changing commands (all called \...fonts) redefine the meanings
2581 % of \STYLEfont, instead of just \STYLE.  We do this because \STYLE needs
2582 % to also set the current \fam for math mode.  Our \STYLE (e.g., \rm)
2583 % commands hardwire \STYLEfont to set the current font.
2584 %
2585 % The fonts used for \ifont are for "math italics"  (\itfont is for italics
2586 % in regular text).  \syfont is also used in math mode only.
2587 %
2588 % Each font-changing command also sets the names \lsize (one size lower)
2589 % and \lllsize (three sizes lower).  These relative commands are used
2590 % in, e.g., the LaTeX logo and acronyms.
2591 %
2592 % This all needs generalizing, badly.
2593 %
2594
2595 \def\assignfonts#1{%
2596   \expandafter\let\expandafter\rmfont\csname #1rm\endcsname
2597   \expandafter\let\expandafter\itfont\csname #1it\endcsname
2598   \expandafter\let\expandafter\slfont\csname #1sl\endcsname
2599   \expandafter\let\expandafter\bffont\csname #1bf\endcsname
2600   \expandafter\let\expandafter\ttfont\csname #1tt\endcsname
2601   \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname
2602   \expandafter\let\expandafter\sffont  \csname #1sf\endcsname
2603   \expandafter\let\expandafter\ifont   \csname #1i\endcsname
2604   \expandafter\let\expandafter\syfont  \csname #1sy\endcsname
2605   \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname
2606 }
2607
2608 \newif\ifrmisbold
2609
2610 % Select smaller font size with the current style.  Used to change font size
2611 % in, e.g., the LaTeX logo and acronyms.  If we are using bold fonts for
2612 % normal roman text, also use bold fonts for roman text in the smaller size.
2613 \def\switchtolllsize{%
2614    \expandafter\assignfonts\expandafter{\lllsize}%
2615    \ifrmisbold
2616      \let\rmfont\bffont
2617    \fi
2618    \csname\curfontstyle\endcsname
2619 }%
2620
2621 \def\switchtolsize{%
2622    \expandafter\assignfonts\expandafter{\lsize}%
2623    \ifrmisbold
2624      \let\rmfont\bffont
2625    \fi
2626    \csname\curfontstyle\endcsname
2627 }%
2628
2629 \def\definefontsetatsize#1#2#3#4#5{%
2630 \expandafter\def\csname #1fonts\endcsname{%
2631   \def\curfontsize{#1}%
2632   \def\lsize{#2}\def\lllsize{#3}%
2633   \csname rmisbold#5\endcsname
2634   \assignfonts{#1}%
2635   \resetmathfonts
2636   \setleading{#4}%
2637 }}
2638
2639 \definefontsetatsize{text}   {reduced}{smaller}{\textleading}{false}
2640 \definefontsetatsize{title}  {chap}   {subsec} {27pt}  {true}
2641 \definefontsetatsize{chap}   {sec}    {text}   {19pt}  {true}
2642 \definefontsetatsize{sec}    {subsec} {reduced}{17pt}  {true}
2643 \definefontsetatsize{ssec}   {text}   {small}  {15pt}  {true}
2644 \definefontsetatsize{reduced}{small}  {smaller}{10.5pt}{false}
2645 \definefontsetatsize{small}  {smaller}{smaller}{10.5pt}{false}
2646 \definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false}
2647
2648 \def\titlefont#1{{\titlefonts\rm #1}}
2649 \let\subsecfonts = \ssecfonts
2650 \let\subsubsecfonts = \ssecfonts
2651
2652 % Define these just so they can be easily changed for other fonts.
2653 \def\angleleft{$\langle$}
2654 \def\angleright{$\rangle$}
2655
2656 % Set the fonts to use with the @small... environments.
2657 \let\smallexamplefonts = \smallfonts
2658
2659 % About \smallexamplefonts.  If we use \smallfonts (9pt), @smallexample
2660 % can fit this many characters:
2661 %   8.5x11=86   smallbook=72  a4=90  a5=69
2662 % If we use \scriptfonts (8pt), then we can fit this many characters:
2663 %   8.5x11=90+  smallbook=80  a4=90+  a5=77
2664 % For me, subjectively, the few extra characters that fit aren't worth
2665 % the additional smallness of 8pt.  So I'm making the default 9pt.
2666 %
2667 % By the way, for comparison, here's what fits with @example (10pt):
2668 %   8.5x11=71  smallbook=60  a4=75  a5=58
2669 % --karl, 24jan03.
2670
2671 % Set up the default fonts, so we can use them for creating boxes.
2672 %
2673 \definetextfontsizexi
2674
2675
2676 \message{markup,}
2677
2678 % Check if we are currently using a typewriter font.  Since all the
2679 % Computer Modern typewriter fonts have zero interword stretch (and
2680 % shrink), and it is reasonable to expect all typewriter fonts to have
2681 % this property, we can check that font parameter.
2682 %
2683 \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
2684
2685 % Markup style infrastructure.  \defmarkupstylesetup\INITMACRO will
2686 % define and register \INITMACRO to be called on markup style changes.
2687 % \INITMACRO can check \currentmarkupstyle for the innermost
2688 % style.
2689
2690 \let\currentmarkupstyle\empty
2691
2692 \def\setupmarkupstyle#1{%
2693   \def\currentmarkupstyle{#1}%
2694   \markupstylesetup
2695 }
2696
2697 \let\markupstylesetup\empty
2698
2699 \def\defmarkupstylesetup#1{%
2700   \expandafter\def\expandafter\markupstylesetup
2701     \expandafter{\markupstylesetup #1}%
2702   \def#1%
2703 }
2704
2705 % Markup style setup for left and right quotes.
2706 \defmarkupstylesetup\markupsetuplq{%
2707   \expandafter\let\expandafter \temp
2708     \csname markupsetuplq\currentmarkupstyle\endcsname
2709   \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
2710 }
2711
2712 \defmarkupstylesetup\markupsetuprq{%
2713   \expandafter\let\expandafter \temp
2714     \csname markupsetuprq\currentmarkupstyle\endcsname
2715   \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
2716 }
2717
2718 {
2719 \catcode`\'=\active
2720 \catcode`\`=\active
2721
2722 \gdef\markupsetuplqdefault{\let`\lq}
2723 \gdef\markupsetuprqdefault{\let'\rq}
2724
2725 \gdef\markupsetcodequoteleft{\let`\codequoteleft}
2726 \gdef\markupsetcodequoteright{\let'\codequoteright}
2727 }
2728
2729 \let\markupsetuplqcode \markupsetcodequoteleft
2730 \let\markupsetuprqcode \markupsetcodequoteright
2731 %
2732 \let\markupsetuplqexample \markupsetcodequoteleft
2733 \let\markupsetuprqexample \markupsetcodequoteright
2734 %
2735 \let\markupsetuplqkbd     \markupsetcodequoteleft
2736 \let\markupsetuprqkbd     \markupsetcodequoteright
2737 %
2738 \let\markupsetuplqsamp \markupsetcodequoteleft
2739 \let\markupsetuprqsamp \markupsetcodequoteright
2740 %
2741 \let\markupsetuplqverb \markupsetcodequoteleft
2742 \let\markupsetuprqverb \markupsetcodequoteright
2743 %
2744 \let\markupsetuplqverbatim \markupsetcodequoteleft
2745 \let\markupsetuprqverbatim \markupsetcodequoteright
2746
2747 % Allow an option to not use regular directed right quote/apostrophe
2748 % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2749 % The undirected quote is ugly, so don't make it the default, but it
2750 % works for pasting with more pdf viewers (at least evince), the
2751 % lilypond developers report.  xpdf does work with the regular 0x27.
2752 %
2753 \def\codequoteright{%
2754   \ifmonospace
2755     \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
2756       \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
2757         '%
2758       \else \char'15 \fi
2759     \else \char'15 \fi
2760    \else
2761      '%
2762    \fi
2763 }
2764 %
2765 % and a similar option for the left quote char vs. a grave accent.
2766 % Modern fonts display ASCII 0x60 as a grave accent, so some people like
2767 % the code environments to do likewise.
2768 %
2769 \def\codequoteleft{%
2770   \ifmonospace
2771     \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
2772       \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
2773         % [Knuth] pp. 380,381,391
2774         % \relax disables Spanish ligatures ?` and !` of \tt font.
2775         \relax`%
2776       \else \char'22 \fi
2777     \else \char'22 \fi
2778    \else
2779      \relax`%
2780    \fi
2781 }
2782
2783 % Commands to set the quote options.
2784 %
2785 \parseargdef\codequoteundirected{%
2786   \def\temp{#1}%
2787   \ifx\temp\onword
2788     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2789       = t%
2790   \else\ifx\temp\offword
2791     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2792       = \relax
2793   \else
2794     \errhelp = \EMsimple
2795     \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2796   \fi\fi
2797 }
2798 %
2799 \parseargdef\codequotebacktick{%
2800   \def\temp{#1}%
2801   \ifx\temp\onword
2802     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2803       = t%
2804   \else\ifx\temp\offword
2805     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2806       = \relax
2807   \else
2808     \errhelp = \EMsimple
2809     \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2810   \fi\fi
2811 }
2812
2813 % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2814 \def\noligaturesquoteleft{\relax\lq}
2815
2816 % Count depth in font-changes, for error checks
2817 \newcount\fontdepth \fontdepth=0
2818
2819 % Font commands.
2820
2821 % #1 is the font command (\sl or \it), #2 is the text to slant.
2822 % If we are in a monospaced environment, however, 1) always use \ttsl,
2823 % and 2) do not add an italic correction.
2824 \def\dosmartslant#1#2{%
2825   \ifusingtt
2826     {{\ttsl #2}\let\next=\relax}%
2827     {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
2828   \next
2829 }
2830 \def\smartslanted{\dosmartslant\sl}
2831 \def\smartitalic{\dosmartslant\it}
2832
2833 % Output an italic correction unless \next (presumed to be the following
2834 % character) is such as not to need one.
2835 \def\smartitaliccorrection{%
2836   \ifx\next,%
2837   \else\ifx\next-%
2838   \else\ifx\next.%
2839   \else\ifx\next\.%
2840   \else\ifx\next\comma%
2841   \else\ptexslash
2842   \fi\fi\fi\fi\fi
2843   \aftersmartic
2844 }
2845
2846 % Unconditional use \ttsl, and no ic.  @var is set to this for defuns.
2847 \def\ttslanted#1{{\ttsl #1}}
2848
2849 % @cite is like \smartslanted except unconditionally use \sl.  We never want
2850 % ttsl for book titles, do we?
2851 \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
2852
2853 \def\aftersmartic{}
2854 \def\var#1{%
2855   \let\saveaftersmartic = \aftersmartic
2856   \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
2857   \smartslanted{#1}%
2858 }
2859
2860 \let\i=\smartitalic
2861 \let\slanted=\smartslanted
2862 \let\dfn=\smartslanted
2863 \let\emph=\smartitalic
2864
2865 % Explicit font changes: @r, @sc, undocumented @ii.
2866 \def\r#1{{\rm #1}}              % roman font
2867 \def\sc#1{{\smallcaps#1}}       % smallcaps font
2868 \def\ii#1{{\it #1}}             % italic font
2869
2870 % @b, explicit bold.  Also @strong.
2871 \def\b#1{{\bf #1}}
2872 \let\strong=\b
2873
2874 % @sansserif, explicit sans.
2875 \def\sansserif#1{{\sf #1}}
2876
2877 % We can't just use \exhyphenpenalty, because that only has effect at
2878 % the end of a paragraph.  Restore normal hyphenation at the end of the
2879 % group within which \nohyphenation is presumably called.
2880 %
2881 \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
2882 \def\restorehyphenation{\hyphenchar\font = `- }
2883
2884 % Set sfcode to normal for the chars that usually have another value.
2885 % Can't use plain's \frenchspacing because it uses the `\x notation, and
2886 % sometimes \x has an active definition that messes things up.
2887 %
2888 \catcode`@=11
2889   \def\plainfrenchspacing{%
2890     \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
2891     \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
2892     \def\endofsentencespacefactor{1000}% for @. and friends
2893   }
2894   \def\plainnonfrenchspacing{%
2895     \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2896     \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2897     \def\endofsentencespacefactor{3000}% for @. and friends
2898   }
2899 \catcode`@=\other
2900 \def\endofsentencespacefactor{3000}% default
2901
2902 % @t, explicit typewriter.
2903 \def\t#1{%
2904   {\tt \plainfrenchspacing #1}%
2905   \null
2906 }
2907
2908 % @samp.
2909 \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
2910
2911 % @indicateurl is \samp, that is, with quotes.
2912 \let\indicateurl=\samp
2913
2914 % @code (and similar) prints in typewriter, but with spaces the same
2915 % size as normal in the surrounding text, without hyphenation, etc.
2916 % This is a subroutine for that.
2917 \def\tclose#1{%
2918   {%
2919     % Change normal interword space to be same as for the current font.
2920     \spaceskip = \fontdimen2\font
2921     %
2922     % Switch to typewriter.
2923     \tt
2924     %
2925     % But `\ ' produces the large typewriter interword space.
2926     \def\ {{\spaceskip = 0pt{} }}%
2927     %
2928     % Turn off hyphenation.
2929     \nohyphenation
2930     %
2931     \plainfrenchspacing
2932     #1%
2933   }%
2934   \null % reset spacefactor to 1000
2935 }
2936
2937 % We *must* turn on hyphenation at `-' and `_' in @code.
2938 % (But see \codedashfinish below.)
2939 % Otherwise, it is too hard to avoid overfull hboxes
2940 % in the Emacs manual, the Library manual, etc.
2941 %
2942 % Unfortunately, TeX uses one parameter (\hyphenchar) to control
2943 % both hyphenation at - and hyphenation within words.
2944 % We must therefore turn them both off (\tclose does that)
2945 % and arrange explicitly to hyphenate at a dash. -- rms.
2946 {
2947   \catcode`\-=\active \catcode`\_=\active
2948   \catcode`\'=\active \catcode`\`=\active
2949   \global\let'=\rq \global\let`=\lq  % default definitions
2950   %
2951   \global\def\code{\begingroup
2952     \setupmarkupstyle{code}%
2953     % The following should really be moved into \setupmarkupstyle handlers.
2954     \catcode\dashChar=\active  \catcode\underChar=\active
2955     \ifallowcodebreaks
2956      \let-\codedash
2957      \let_\codeunder
2958     \else
2959      \let-\normaldash
2960      \let_\realunder
2961     \fi
2962     % Given -foo (with a single dash), we do not want to allow a break
2963     % after the hyphen.
2964     \global\let\codedashprev=\codedash
2965     %
2966     \codex
2967   }
2968   %
2969   \gdef\codedash{\futurelet\next\codedashfinish}
2970   \gdef\codedashfinish{%
2971     \normaldash % always output the dash character itself.
2972     %
2973     % Now, output a discretionary to allow a line break, unless
2974     % (a) the next character is a -, or
2975     % (b) the preceding character is a -.
2976     % E.g., given --posix, we do not want to allow a break after either -.
2977     % Given --foo-bar, we do want to allow a break between the - and the b.
2978     \ifx\next\codedash \else
2979       \ifx\codedashprev\codedash
2980       \else \discretionary{}{}{}\fi
2981     \fi
2982     % we need the space after the = for the case when \next itself is a
2983     % space token; it would get swallowed otherwise.  As in @code{- a}.
2984     \global\let\codedashprev= \next
2985   }
2986 }
2987 \def\normaldash{-}
2988 %
2989 \def\codex #1{\tclose{#1}\endgroup}
2990
2991 \def\codeunder{%
2992   % this is all so @math{@code{var_name}+1} can work.  In math mode, _
2993   % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2994   % will therefore expand the active definition of _, which is us
2995   % (inside @code that is), therefore an endless loop.
2996   \ifusingtt{\ifmmode
2997                \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2998              \else\normalunderscore \fi
2999              \discretionary{}{}{}}%
3000             {\_}%
3001 }
3002
3003 % An additional complication: the above will allow breaks after, e.g.,
3004 % each of the four underscores in __typeof__.  This is bad.
3005 % @allowcodebreaks provides a document-level way to turn breaking at -
3006 % and _ on and off.
3007 %
3008 \newif\ifallowcodebreaks  \allowcodebreakstrue
3009
3010 \def\keywordtrue{true}
3011 \def\keywordfalse{false}
3012
3013 \parseargdef\allowcodebreaks{%
3014   \def\txiarg{#1}%
3015   \ifx\txiarg\keywordtrue
3016     \allowcodebreakstrue
3017   \else\ifx\txiarg\keywordfalse
3018     \allowcodebreaksfalse
3019   \else
3020     \errhelp = \EMsimple
3021     \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
3022   \fi\fi
3023 }
3024
3025 % For @command, @env, @file, @option quotes seem unnecessary,
3026 % so use \code rather than \samp.
3027 \let\command=\code
3028 \let\env=\code
3029 \let\file=\code
3030 \let\option=\code
3031
3032 % @uref (abbreviation for `urlref') aka @url takes an optional
3033 % (comma-separated) second argument specifying the text to display and
3034 % an optional third arg as text to display instead of (rather than in
3035 % addition to) the url itself.  First (mandatory) arg is the url.
3036
3037 % TeX-only option to allow changing PDF output to show only the second
3038 % arg (if given), and not the url (which is then just the link target).
3039 \newif\ifurefurlonlylink
3040
3041 % The main macro is \urefbreak, which allows breaking at expected
3042 % places within the url.  (There used to be another version, which
3043 % didn't support automatic breaking.)
3044 \def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
3045 \let\uref=\urefbreak
3046 %
3047 \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
3048 \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
3049   \unsepspaces
3050   \pdfurl{#1}%
3051   \setbox0 = \hbox{\ignorespaces #3}%
3052   \ifdim\wd0 > 0pt
3053     \unhbox0 % third arg given, show only that
3054   \else
3055     \setbox0 = \hbox{\ignorespaces #2}% look for second arg
3056     \ifdim\wd0 > 0pt
3057       \ifpdf
3058         % For pdfTeX and LuaTeX
3059         \ifurefurlonlylink
3060           % PDF plus option to not display url, show just arg
3061           \unhbox0
3062         \else
3063           % PDF, normally display both arg and url for consistency,
3064           % visibility, if the pdf is eventually used to print, etc.
3065           \unhbox0\ (\urefcode{#1})%
3066         \fi
3067       \else
3068         \ifx\XeTeXrevision\thisisundefined
3069           \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
3070         \else
3071           % For XeTeX
3072           \ifurefurlonlylink
3073             % PDF plus option to not display url, show just arg
3074             \unhbox0
3075           \else
3076             % PDF, normally display both arg and url for consistency,
3077             % visibility, if the pdf is eventually used to print, etc.
3078             \unhbox0\ (\urefcode{#1})%
3079           \fi
3080         \fi
3081       \fi
3082     \else
3083       \urefcode{#1}% only url given, so show it
3084     \fi
3085   \fi
3086   \endlink
3087 \endgroup}
3088
3089 % Allow line breaks around only a few characters (only).
3090 \def\urefcatcodes{%
3091   \catcode`\&=\active \catcode`\.=\active
3092   \catcode`\#=\active \catcode`\?=\active
3093   \catcode`\/=\active
3094 }
3095 {
3096   \urefcatcodes
3097   %
3098   \global\def\urefcode{\begingroup
3099     \setupmarkupstyle{code}%
3100     \urefcatcodes
3101     \let&\urefcodeamp
3102     \let.\urefcodedot
3103     \let#\urefcodehash
3104     \let?\urefcodequest
3105     \let/\urefcodeslash
3106     \codex
3107   }
3108   %
3109   % By default, they are just regular characters.
3110   \global\def&{\normalamp}
3111   \global\def.{\normaldot}
3112   \global\def#{\normalhash}
3113   \global\def?{\normalquest}
3114   \global\def/{\normalslash}
3115 }
3116
3117 \def\urefcodeamp{\urefprebreak \&\urefpostbreak}
3118 \def\urefcodedot{\urefprebreak .\urefpostbreak}
3119 \def\urefcodehash{\urefprebreak \#\urefpostbreak}
3120 \def\urefcodequest{\urefprebreak ?\urefpostbreak}
3121 \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
3122 {
3123   \catcode`\/=\active
3124   \global\def\urefcodeslashfinish{%
3125     \urefprebreak \slashChar
3126     % Allow line break only after the final / in a sequence of
3127     % slashes, to avoid line break between the slashes in http://.
3128     \ifx\next/\else \urefpostbreak \fi
3129   }
3130 }
3131
3132 % By default we'll break after the special characters, but some people like to
3133 % break before the special chars, so allow that.  Also allow no breaking at
3134 % all, for manual control.
3135 %
3136 \parseargdef\urefbreakstyle{%
3137   \def\txiarg{#1}%
3138   \ifx\txiarg\wordnone
3139     \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
3140   \else\ifx\txiarg\wordbefore
3141     \def\urefprebreak{\urefallowbreak}\def\urefpostbreak{\nobreak}
3142   \else\ifx\txiarg\wordafter
3143     \def\urefprebreak{\nobreak}\def\urefpostbreak{\urefallowbreak}
3144   \else
3145     \errhelp = \EMsimple
3146     \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
3147   \fi\fi\fi
3148 }
3149 \def\wordafter{after}
3150 \def\wordbefore{before}
3151 \def\wordnone{none}
3152
3153 % Allow a ragged right output to aid breaking long URL's.  There can
3154 % be a break at the \allowbreak with no extra glue (if the existing stretch in
3155 % the line is sufficient), a break at the \penalty100 with extra glue added
3156 % at the end of the line, or no break at all here.
3157 %   Changing the value of the penalty and/or the amount of stretch affects how
3158 % preferable one choice is over the other.
3159 \def\urefallowbreak{%
3160   \allowbreak
3161   \hskip 0pt plus 2 em\relax
3162   \penalty300
3163   \hskip 0pt plus -2 em\relax
3164 }
3165
3166 \urefbreakstyle after
3167
3168 % @url synonym for @uref, since that's how everyone uses it.
3169 %
3170 \let\url=\uref
3171
3172 % rms does not like angle brackets --karl, 17may97.
3173 % So now @email is just like @uref, unless we are pdf.
3174 %
3175 %\def\email#1{\angleleft{\tt #1}\angleright}
3176 \ifpdforxetex
3177   \def\email#1{\doemail#1,,\finish}
3178   \def\doemail#1,#2,#3\finish{\begingroup
3179     \unsepspaces
3180     \pdfurl{mailto:#1}%
3181     \setbox0 = \hbox{\ignorespaces #2}%
3182     \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3183     \endlink
3184   \endgroup}
3185 \else
3186   \let\email=\uref
3187 \fi
3188
3189 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
3190 %   `example' (@kbd uses ttsl only inside of @example and friends),
3191 %   or `code' (@kbd uses normal tty font always).
3192 \parseargdef\kbdinputstyle{%
3193   \def\txiarg{#1}%
3194   \ifx\txiarg\worddistinct
3195     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
3196   \else\ifx\txiarg\wordexample
3197     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
3198   \else\ifx\txiarg\wordcode
3199     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
3200   \else
3201     \errhelp = \EMsimple
3202     \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
3203   \fi\fi\fi
3204 }
3205 \def\worddistinct{distinct}
3206 \def\wordexample{example}
3207 \def\wordcode{code}
3208
3209 % Default is `distinct'.
3210 \kbdinputstyle distinct
3211
3212 % @kbd is like @code, except that if the argument is just one @key command,
3213 % then @kbd has no effect.
3214 \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
3215
3216 \def\xkey{\key}
3217 \def\kbdsub#1#2#3\par{%
3218   \def\one{#1}\def\three{#3}\def\threex{??}%
3219   \ifx\one\xkey\ifx\threex\three \key{#2}%
3220   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3221   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3222 }
3223
3224 % definition of @key that produces a lozenge.  Doesn't adjust to text size.
3225 %\setfont\keyrm\rmshape{8}{1000}{OT1}
3226 %\font\keysy=cmsy9
3227 %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
3228 %  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
3229 %    \vbox{\hrule\kern-0.4pt
3230 %     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
3231 %    \kern-0.4pt\hrule}%
3232 %  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
3233
3234 % definition of @key with no lozenge.  If the current font is already
3235 % monospace, don't change it; that way, we respect @kbdinputstyle.  But
3236 % if it isn't monospace, then use \tt.
3237 %
3238 \def\key#1{{\setupmarkupstyle{key}%
3239   \nohyphenation
3240   \ifmonospace\else\tt\fi
3241   #1}\null}
3242
3243 % @clicksequence{File @click{} Open ...}
3244 \def\clicksequence#1{\begingroup #1\endgroup}
3245
3246 % @clickstyle @arrow   (by default)
3247 \parseargdef\clickstyle{\def\click{#1}}
3248 \def\click{\arrow}
3249
3250 % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
3251 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
3252 %
3253 \def\dmn#1{\thinspace #1}
3254
3255 % @acronym for "FBI", "NATO", and the like.
3256 % We print this one point size smaller, since it's intended for
3257 % all-uppercase.
3258 %
3259 \def\acronym#1{\doacronym #1,,\finish}
3260 \def\doacronym#1,#2,#3\finish{%
3261   {\switchtolsize #1}%
3262   \def\temp{#2}%
3263   \ifx\temp\empty \else
3264     \space ({\unsepspaces \ignorespaces \temp \unskip})%
3265   \fi
3266   \null % reset \spacefactor=1000
3267 }
3268
3269 % @abbr for "Comput. J." and the like.
3270 % No font change, but don't do end-of-sentence spacing.
3271 %
3272 \def\abbr#1{\doabbr #1,,\finish}
3273 \def\doabbr#1,#2,#3\finish{%
3274   {\plainfrenchspacing #1}%
3275   \def\temp{#2}%
3276   \ifx\temp\empty \else
3277     \space ({\unsepspaces \ignorespaces \temp \unskip})%
3278   \fi
3279   \null % reset \spacefactor=1000
3280 }
3281
3282 % @asis just yields its argument.  Used with @table, for example.
3283 %
3284 \def\asis#1{#1}
3285
3286 % @math outputs its argument in math mode.
3287 %
3288 % One complication: _ usually means subscripts, but it could also mean
3289 % an actual _ character, as in @math{@var{some_variable} + 1}.  So make
3290 % _ active, and distinguish by seeing if the current family is \slfam,
3291 % which is what @var uses.
3292 {
3293   \catcode`\_ = \active
3294   \gdef\mathunderscore{%
3295     \catcode`\_=\active
3296     \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
3297   }
3298 }
3299 % Another complication: we want \\ (and @\) to output a math (or tt) \.
3300 % FYI, plain.tex uses \\ as a temporary control sequence (for no
3301 % particular reason), but this is not advertised and we don't care.
3302 %
3303 % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
3304 \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
3305 %
3306 \def\math{%
3307   \ifmmode\else % only go into math if not in math mode already
3308     \tex
3309     \mathunderscore
3310     \let\\ = \mathbackslash
3311     \mathactive
3312     % make the texinfo accent commands work in math mode
3313     \let\"=\ddot
3314     \let\'=\acute
3315     \let\==\bar
3316     \let\^=\hat
3317     \let\`=\grave
3318     \let\u=\breve
3319     \let\v=\check
3320     \let\~=\tilde
3321     \let\dotaccent=\dot
3322     % have to provide another name for sup operator
3323     \let\mathopsup=\sup
3324   $\expandafter\finishmath\fi
3325 }
3326 \def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
3327
3328 % Some active characters (such as <) are spaced differently in math.
3329 % We have to reset their definitions in case the @math was an argument
3330 % to a command which sets the catcodes (such as @item or @section).
3331 %
3332 {
3333   \catcode`^ = \active
3334   \catcode`< = \active
3335   \catcode`> = \active
3336   \catcode`+ = \active
3337   \catcode`' = \active
3338   \gdef\mathactive{%
3339     \let^ = \ptexhat
3340     \let< = \ptexless
3341     \let> = \ptexgtr
3342     \let+ = \ptexplus
3343     \let' = \ptexquoteright
3344   }
3345 }
3346
3347 % for @sub and @sup, if in math mode, just do a normal sub/superscript.
3348 % If in text, use math to place as sub/superscript, but switch
3349 % into text mode, with smaller fonts.  This is a different font than the
3350 % one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3351 % fix it (significant additions to font machinery) until someone notices.
3352 %
3353 \def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
3354 \def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}%
3355 %
3356 \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
3357 \def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}%
3358
3359 % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3360 % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3361 % except specified as a normal braced arg, so no newlines to worry about.
3362 %
3363 \def\outfmtnametex{tex}
3364 %
3365 \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3366 \long\def\doinlinefmt#1,#2,\finish{%
3367   \def\inlinefmtname{#1}%
3368   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3369 }
3370 %
3371 % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3372 % FMTNAME is tex, else ELSE-TEXT.
3373 \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3374 \long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3375   \def\inlinefmtname{#1}%
3376   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3377 }
3378 %
3379 % For raw, must switch into @tex before parsing the argument, to avoid
3380 % setting catcodes prematurely.  Doing it this way means that, for
3381 % example, @inlineraw{html, foo{bar} gets a parse error instead of being
3382 % ignored.  But this isn't important because if people want a literal
3383 % *right* brace they would have to use a command anyway, so they may as
3384 % well use a command to get a left brace too.  We could re-use the
3385 % delimiter character idea from \verb, but it seems like overkill.
3386 %
3387 \long\def\inlineraw{\tex \doinlineraw}
3388 \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3389 \def\doinlinerawtwo#1,#2,\finish{%
3390   \def\inlinerawname{#1}%
3391   \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3392   \endgroup % close group opened by \tex.
3393 }
3394
3395 % @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3396 %
3397 \long\def\inlineifset#1{\doinlineifset #1,\finish}
3398 \long\def\doinlineifset#1,#2,\finish{%
3399   \def\inlinevarname{#1}%
3400   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3401   \else\ignorespaces#2\fi
3402 }
3403
3404 % @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3405 %
3406 \long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3407 \long\def\doinlineifclear#1,#2,\finish{%
3408   \def\inlinevarname{#1}%
3409   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3410 }
3411
3412
3413 \message{glyphs,}
3414 % and logos.
3415
3416 % @@ prints an @, as does @atchar{}.
3417 \def\@{\char64 }
3418 \let\atchar=\@
3419
3420 % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
3421 \def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}}
3422 \def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}}
3423 \let\{=\lbracechar
3424 \let\}=\rbracechar
3425
3426 % @comma{} to avoid , parsing problems.
3427 \let\comma = ,
3428
3429 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3430 % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3431 \let\, = \ptexc
3432 \let\dotaccent = \ptexdot
3433 \def\ringaccent#1{{\accent23 #1}}
3434 \let\tieaccent = \ptext
3435 \let\ubaraccent = \ptexb
3436 \let\udotaccent = \d
3437
3438 % Other special characters: @questiondown @exclamdown @ordf @ordm
3439 % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3440 \def\questiondown{?`}
3441 \def\exclamdown{!`}
3442 \def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}}
3443 \def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}}
3444
3445 % Dotless i and dotless j, used for accents.
3446 \def\imacro{i}
3447 \def\jmacro{j}
3448 \def\dotless#1{%
3449   \def\temp{#1}%
3450   \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3451   \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3452   \else \errmessage{@dotless can be used only with i or j}%
3453   \fi\fi
3454 }
3455
3456 % The \TeX{} logo, as in plain, but resetting the spacing so that a
3457 % period following counts as ending a sentence.  (Idea found in latex.)
3458 %
3459 \edef\TeX{\TeX \spacefactor=1000 }
3460
3461 % @LaTeX{} logo.  Not quite the same results as the definition in
3462 % latex.ltx, since we use a different font for the raised A; it's most
3463 % convenient for us to use an explicitly smaller font, rather than using
3464 % the \scriptstyle font (since we don't reset \scriptstyle and
3465 % \scriptscriptstyle).
3466 %
3467 \def\LaTeX{%
3468   L\kern-.36em
3469   {\setbox0=\hbox{T}%
3470    \vbox to \ht0{\hbox{%
3471      \ifx\textnominalsize\xwordpt
3472        % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX.
3473        % Revert to plain's \scriptsize, which is 7pt.
3474        \count255=\the\fam $\fam\count255 \scriptstyle A$%
3475      \else
3476        % For 11pt, we can use our lllsize.
3477        \switchtolllsize A%
3478      \fi
3479      }%
3480      \vss
3481   }}%
3482   \kern-.15em
3483   \TeX
3484 }
3485
3486 % Some math mode symbols.  Define \ensuremath to switch into math mode
3487 % unless we are already there.  Expansion tricks may not be needed here,
3488 % but safer, and can't hurt.
3489 \def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3490 \def\ensuredmath#1{$\relax#1$}
3491 %
3492 \def\bullet{\ensuremath\ptexbullet}
3493 \def\geq{\ensuremath\ge}
3494 \def\leq{\ensuremath\le}
3495 \def\minus{\ensuremath-}
3496
3497 % @dots{} outputs an ellipsis using the current font.
3498 % We do .5em per period so that it has the same spacing in the cm
3499 % typewriter fonts as three actual period characters; on the other hand,
3500 % in other typewriter fonts three periods are wider than 1.5em.  So do
3501 % whichever is larger.
3502 %
3503 \def\dots{%
3504   \leavevmode
3505   \setbox0=\hbox{...}% get width of three periods
3506   \ifdim\wd0 > 1.5em
3507     \dimen0 = \wd0
3508   \else
3509     \dimen0 = 1.5em
3510   \fi
3511   \hbox to \dimen0{%
3512     \hskip 0pt plus.25fil
3513     .\hskip 0pt plus1fil
3514     .\hskip 0pt plus1fil
3515     .\hskip 0pt plus.5fil
3516   }%
3517 }
3518
3519 % @enddots{} is an end-of-sentence ellipsis.
3520 %
3521 \def\enddots{%
3522   \dots
3523   \spacefactor=\endofsentencespacefactor
3524 }
3525
3526 % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3527 %
3528 % Since these characters are used in examples, they should be an even number of
3529 % \tt widths. Each \tt character is 1en, so two makes it 1em.
3530 %
3531 \def\point{$\star$}
3532 \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3533 \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3534 \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3535 \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3536 \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3537
3538 % The @error{} command.
3539 % Adapted from the TeXbook's \boxit.
3540 %
3541 \newbox\errorbox
3542 %
3543 {\ttfont \global\dimen0 = 3em}% Width of the box.
3544 \dimen2 = .55pt % Thickness of rules
3545 % The text. (`r' is open on the right, `e' somewhat less so on the left.)
3546 \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3547 %
3548 \setbox\errorbox=\hbox to \dimen0{\hfil
3549    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3550    \advance\hsize by -2\dimen2 % Rules.
3551    \vbox{%
3552       \hrule height\dimen2
3553       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
3554          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3555          \kern3pt\vrule width\dimen2}% Space to right.
3556       \hrule height\dimen2}
3557     \hfil}
3558 %
3559 \def\error{\leavevmode\lower.7ex\copy\errorbox}
3560
3561 % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3562 %
3563 \def\pounds{\ifmonospace{\ecfont\char"BF}\else{\it\$}\fi}
3564
3565 % @euro{} comes from a separate font, depending on the current style.
3566 % We use the free feym* fonts from the eurosym package by Henrik
3567 % Theiling, which support regular, slanted, bold and bold slanted (and
3568 % "outlined" (blackboard board, sort of) versions, which we don't need).
3569 % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3570 %
3571 % Although only regular is the truly official Euro symbol, we ignore
3572 % that.  The Euro is designed to be slightly taller than the regular
3573 % font height.
3574 %
3575 % feymr - regular
3576 % feymo - slanted
3577 % feybr - bold
3578 % feybo - bold slanted
3579 %
3580 % There is no good (free) typewriter version, to my knowledge.
3581 % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3582 % Hmm.
3583 %
3584 % Also doesn't work in math.  Do we need to do math with euro symbols?
3585 % Hope not.
3586 %
3587 %
3588 \def\euro{{\eurofont e}}
3589 \def\eurofont{%
3590   % We set the font at each command, rather than predefining it in
3591   % \textfonts and the other font-switching commands, so that
3592   % installations which never need the symbol don't have to have the
3593   % font installed.
3594   %
3595   % There is only one designed size (nominal 10pt), so we always scale
3596   % that to the current nominal size.
3597   %
3598   % By the way, simply using "at 1em" works for cmr10 and the like, but
3599   % does not work for cmbx10 and other extended/shrunken fonts.
3600   %
3601   \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3602   %
3603   \ifx\curfontstyle\bfstylename
3604     % bold:
3605     \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3606   \else
3607     % regular:
3608     \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3609   \fi
3610   \thiseurofont
3611 }
3612
3613 % Glyphs from the EC fonts.  We don't use \let for the aliases, because
3614 % sometimes we redefine the original macro, and the alias should reflect
3615 % the redefinition.
3616 %
3617 % Use LaTeX names for the Icelandic letters.
3618 \def\DH{{\ecfont \char"D0}} % Eth
3619 \def\dh{{\ecfont \char"F0}} % eth
3620 \def\TH{{\ecfont \char"DE}} % Thorn
3621 \def\th{{\ecfont \char"FE}} % thorn
3622 %
3623 \def\guillemetleft{{\ecfont \char"13}}
3624 \def\guillemotleft{\guillemetleft}
3625 \def\guillemetright{{\ecfont \char"14}}
3626 \def\guillemotright{\guillemetright}
3627 \def\guilsinglleft{{\ecfont \char"0E}}
3628 \def\guilsinglright{{\ecfont \char"0F}}
3629 \def\quotedblbase{{\ecfont \char"12}}
3630 \def\quotesinglbase{{\ecfont \char"0D}}
3631 %
3632 % This positioning is not perfect (see the ogonek LaTeX package), but
3633 % we have the precomposed glyphs for the most common cases.  We put the
3634 % tests to use those glyphs in the single \ogonek macro so we have fewer
3635 % dummy definitions to worry about for index entries, etc.
3636 %
3637 % ogonek is also used with other letters in Lithuanian (IOU), but using
3638 % the precomposed glyphs for those is not so easy since they aren't in
3639 % the same EC font.
3640 \def\ogonek#1{{%
3641   \def\temp{#1}%
3642   \ifx\temp\macrocharA\Aogonek
3643   \else\ifx\temp\macrochara\aogonek
3644   \else\ifx\temp\macrocharE\Eogonek
3645   \else\ifx\temp\macrochare\eogonek
3646   \else
3647     \ecfont \setbox0=\hbox{#1}%
3648     \ifdim\ht0=1ex\accent"0C #1%
3649     \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3650     \fi
3651   \fi\fi\fi\fi
3652   }%
3653 }
3654 \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3655 \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3656 \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3657 \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3658 %
3659 % Use the European Computer Modern fonts (cm-super in outline format)
3660 % for non-CM glyphs.  That is ec* for regular text and tc* for the text
3661 % companion symbols (LaTeX TS1 encoding).  Both are part of the ec
3662 % package and follow the same conventions.
3663 %
3664 \def\ecfont{\etcfont{e}}
3665 \def\tcfont{\etcfont{t}}
3666 %
3667 \def\etcfont#1{%
3668   % We can't distinguish serif/sans and italic/slanted, but this
3669   % is used for crude hacks anyway (like adding French and German
3670   % quotes to documents typeset with CM, where we lose kerning), so
3671   % hopefully nobody will notice/care.
3672   \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3673   \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
3674   \ifmonospace
3675     % typewriter:
3676     \font\thisecfont = #1ctt\ecsize \space at \nominalsize
3677   \else
3678     \ifx\curfontstyle\bfstylename
3679       % bold:
3680       \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
3681     \else
3682       % regular:
3683       \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
3684     \fi
3685   \fi
3686   \thisecfont
3687 }
3688
3689 % @registeredsymbol - R in a circle.  The font for the R should really
3690 % be smaller yet, but lllsize is the best we can do for now.
3691 % Adapted from the plain.tex definition of \copyright.
3692 %
3693 \def\registeredsymbol{%
3694   $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}%
3695                \hfil\crcr\Orb}}%
3696     }$%
3697 }
3698
3699 % @textdegree - the normal degrees sign.
3700 %
3701 \def\textdegree{$^\circ$}
3702
3703 % Laurent Siebenmann reports \Orb undefined with:
3704 %  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
3705 % so we'll define it if necessary.
3706 %
3707 \ifx\Orb\thisisundefined
3708 \def\Orb{\mathhexbox20D}
3709 \fi
3710
3711 % Quotes.
3712 \chardef\quoteleft=`\`
3713 \chardef\quoteright=`\'
3714
3715 % only change font for tt for correct kerning and to avoid using
3716 % \ecfont unless necessary.
3717 \def\quotedblleft{%
3718   \ifmonospace{\ecfont\char"10}\else{\char"5C}\fi
3719 }
3720
3721 \def\quotedblright{%
3722   \ifmonospace{\ecfont\char"11}\else{\char`\"}\fi
3723 }
3724
3725
3726 \message{page headings,}
3727
3728 \newskip\titlepagetopglue \titlepagetopglue = 1.5in
3729 \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3730
3731 % First the title page.  Must do @settitle before @titlepage.
3732 \newif\ifseenauthor
3733 \newif\iffinishedtitlepage
3734
3735 % @setcontentsaftertitlepage used to do an implicit @contents or
3736 % @shortcontents after @end titlepage, but it is now obsolete.
3737 \def\setcontentsaftertitlepage{%
3738   \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
3739               command; move your @contents command if you want the contents
3740               after the title page.}}%
3741 \def\setshortcontentsaftertitlepage{%
3742   \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
3743               command; move your @shortcontents and @contents commands if you
3744               want the contents after the title page.}}%
3745
3746 \parseargdef\shorttitlepage{%
3747   \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3748   \endgroup\page\hbox{}\page}
3749
3750 \envdef\titlepage{%
3751   % Open one extra group, as we want to close it in the middle of \Etitlepage.
3752   \begingroup
3753     \parindent=0pt \textfonts
3754     % Leave some space at the very top of the page.
3755     \vglue\titlepagetopglue
3756     % No rule at page bottom unless we print one at the top with @title.
3757     \finishedtitlepagetrue
3758     %
3759     % Most title ``pages'' are actually two pages long, with space
3760     % at the top of the second.  We don't want the ragged left on the second.
3761     \let\oldpage = \page
3762     \def\page{%
3763       \iffinishedtitlepage\else
3764          \finishtitlepage
3765       \fi
3766       \let\page = \oldpage
3767       \page
3768       \null
3769     }%
3770 }
3771
3772 \def\Etitlepage{%
3773     \iffinishedtitlepage\else
3774         \finishtitlepage
3775     \fi
3776     % It is important to do the page break before ending the group,
3777     % because the headline and footline are only empty inside the group.
3778     % If we use the new definition of \page, we always get a blank page
3779     % after the title page, which we certainly don't want.
3780     \oldpage
3781   \endgroup
3782   %
3783   % Need this before the \...aftertitlepage checks so that if they are
3784   % in effect the toc pages will come out with page numbers.
3785   \HEADINGSon
3786 }
3787
3788 \def\finishtitlepage{%
3789   \vskip4pt \hrule height 2pt width \hsize
3790   \vskip\titlepagebottomglue
3791   \finishedtitlepagetrue
3792 }
3793
3794 % Settings used for typesetting titles: no hyphenation, no indentation,
3795 % don't worry much about spacing, ragged right.  This should be used
3796 % inside a \vbox, and fonts need to be set appropriately first. \par should
3797 % be specified before the end of the \vbox, since a vbox is a group.
3798 %
3799 \def\raggedtitlesettings{%
3800   \rm
3801   \hyphenpenalty=10000
3802   \parindent=0pt
3803   \tolerance=5000
3804   \ptexraggedright
3805 }
3806
3807 % Macros to be used within @titlepage:
3808
3809 \let\subtitlerm=\rmfont
3810 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3811
3812 \parseargdef\title{%
3813   \checkenv\titlepage
3814   \vbox{\titlefonts \raggedtitlesettings #1\par}%
3815   % print a rule at the page bottom also.
3816   \finishedtitlepagefalse
3817   \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3818 }
3819
3820 \parseargdef\subtitle{%
3821   \checkenv\titlepage
3822   {\subtitlefont \rightline{#1}}%
3823 }
3824
3825 % @author should come last, but may come many times.
3826 % It can also be used inside @quotation.
3827 %
3828 \parseargdef\author{%
3829   \def\temp{\quotation}%
3830   \ifx\thisenv\temp
3831     \def\quotationauthor{#1}% printed in \Equotation.
3832   \else
3833     \checkenv\titlepage
3834     \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3835     {\secfonts\rm \leftline{#1}}%
3836   \fi
3837 }
3838
3839
3840 % Set up page headings and footings.
3841
3842 \let\thispage=\folio
3843
3844 \newtoks\evenheadline    % headline on even pages
3845 \newtoks\oddheadline     % headline on odd pages
3846 \newtoks\evenchapheadline% headline on even pages with a new chapter
3847 \newtoks\oddchapheadline % headline on odd pages with a new chapter
3848 \newtoks\evenfootline    % footline on even pages
3849 \newtoks\oddfootline     % footline on odd pages
3850
3851 % Now make \makeheadline and \makefootline in Plain TeX use those variables
3852 \headline={{\textfonts\rm
3853             \ifchapterpage
3854               \ifodd\pageno\the\oddchapheadline\else\the\evenchapheadline\fi
3855             \else
3856               \ifodd\pageno\the\oddheadline\else\the\evenheadline\fi
3857             \fi}}
3858
3859 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
3860                             \else \the\evenfootline \fi}\HEADINGShook}
3861 \let\HEADINGShook=\relax
3862
3863 % Commands to set those variables.
3864 % For example, this is what  @headings on  does
3865 % @evenheading @thistitle|@thispage|@thischapter
3866 % @oddheading @thischapter|@thispage|@thistitle
3867 % @evenfooting @thisfile||
3868 % @oddfooting ||@thisfile
3869
3870
3871 \def\evenheading{\parsearg\evenheadingxxx}
3872 \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3873 \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
3874   \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
3875   \global\evenchapheadline=\evenheadline}
3876
3877 \def\oddheading{\parsearg\oddheadingxxx}
3878 \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3879 \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
3880   \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3881   \global\oddchapheadline=\oddheadline}
3882
3883 \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3884
3885 \def\evenfooting{\parsearg\evenfootingxxx}
3886 \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3887 \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3888 \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3889
3890 \def\oddfooting{\parsearg\oddfootingxxx}
3891 \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3892 \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3893   \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3894   %
3895   % Leave some space for the footline.  Hopefully ok to assume
3896   % @evenfooting will not be used by itself.
3897   \global\advance\txipageheight by -12pt
3898   \global\advance\vsize by -12pt
3899 }
3900
3901 \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3902
3903 % @evenheadingmarks top     \thischapter <- chapter at the top of a page
3904 % @evenheadingmarks bottom  \thischapter <- chapter at the bottom of a page
3905 %
3906 % The same set of arguments for:
3907 %
3908 % @oddheadingmarks
3909 % @evenfootingmarks
3910 % @oddfootingmarks
3911 % @everyheadingmarks
3912 % @everyfootingmarks
3913
3914 % These define \getoddheadingmarks, \getevenheadingmarks,
3915 % \getoddfootingmarks, and \getevenfootingmarks, each to one of
3916 % \gettopheadingmarks, \getbottomheadingmarks.
3917 %
3918 \def\evenheadingmarks{\headingmarks{even}{heading}}
3919 \def\oddheadingmarks{\headingmarks{odd}{heading}}
3920 \def\evenfootingmarks{\headingmarks{even}{footing}}
3921 \def\oddfootingmarks{\headingmarks{odd}{footing}}
3922 \parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
3923                           \headingmarks{odd}{heading}{#1} }
3924 \parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
3925                           \headingmarks{odd}{footing}{#1} }
3926 % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3927 \def\headingmarks#1#2#3 {%
3928   \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3929   \global\expandafter\let\csname get#1#2marks\endcsname \temp
3930 }
3931
3932 \everyheadingmarks bottom
3933 \everyfootingmarks bottom
3934
3935 % @headings double      turns headings on for double-sided printing.
3936 % @headings single      turns headings on for single-sided printing.
3937 % @headings off         turns them off.
3938 % @headings on          same as @headings double, retained for compatibility.
3939 % @headings after       turns on double-sided headings after this page.
3940 % @headings doubleafter turns on double-sided headings after this page.
3941 % @headings singleafter turns on single-sided headings after this page.
3942 % By default, they are off at the start of a document,
3943 % and turned `on' after @end titlepage.
3944
3945 \parseargdef\headings{\csname HEADINGS#1\endcsname}
3946
3947 \def\headingsoff{% non-global headings elimination
3948   \evenheadline={\hfil}\evenfootline={\hfil}\evenchapheadline={\hfil}%
3949    \oddheadline={\hfil}\oddfootline={\hfil}\oddchapheadline={\hfil}%
3950 }
3951
3952 \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3953 \HEADINGSoff  % it's the default
3954
3955 % When we turn headings on, set the page number to 1.
3956 \def\pageone{
3957   \global\pageno=1
3958   \global\arabiccount = \pagecount
3959 }
3960
3961 % For double-sided printing, put current file name in lower left corner,
3962 % chapter name on inside top of right hand pages, document
3963 % title on inside top of left hand pages, and page numbers on outside top
3964 % edge of all pages.
3965 \def\HEADINGSdouble{%
3966 \pageone
3967 \HEADINGSdoublex
3968 }
3969 \let\contentsalignmacro = \chappager
3970
3971 % For single-sided printing, chapter title goes across top left of page,
3972 % page number on top right.
3973 \def\HEADINGSsingle{%
3974 \pageone
3975 \HEADINGSsinglex
3976 }
3977 \def\HEADINGSon{\HEADINGSdouble}
3978
3979 \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
3980 \let\HEADINGSdoubleafter=\HEADINGSafter
3981 \def\HEADINGSdoublex{%
3982 \global\evenfootline={\hfil}
3983 \global\oddfootline={\hfil}
3984 \global\evenheadline={\line{\folio\hfil\thistitle}}
3985 \global\oddheadline={\line{\thischapter\hfil\folio}}
3986 \global\evenchapheadline={\line{\folio\hfil}}
3987 \global\oddchapheadline={\line{\hfil\folio}}
3988 \global\let\contentsalignmacro = \chapoddpage
3989 }
3990
3991 \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
3992 \def\HEADINGSsinglex{%
3993 \global\evenfootline={\hfil}
3994 \global\oddfootline={\hfil}
3995 \global\evenheadline={\line{\thischapter\hfil\folio}}
3996 \global\oddheadline={\line{\thischapter\hfil\folio}}
3997 \global\evenchapheadline={\line{\hfil\folio}}
3998 \global\oddchapheadline={\line{\hfil\folio}}
3999 \global\let\contentsalignmacro = \chappager
4000 }
4001
4002 % for @setchapternewpage off
4003 \def\HEADINGSsinglechapoff{%
4004 \pageone
4005 \global\evenfootline={\hfil}
4006 \global\oddfootline={\hfil}
4007 \global\evenheadline={\line{\thischapter\hfil\folio}}
4008 \global\oddheadline={\line{\thischapter\hfil\folio}}
4009 \global\evenchapheadline=\evenheadline
4010 \global\oddchapheadline=\oddheadline
4011 \global\let\contentsalignmacro = \chappager
4012 }
4013
4014 % Subroutines used in generating headings
4015 % This produces Day Month Year style of output.
4016 % Only define if not already defined, in case a txi-??.tex file has set
4017 % up a different format (e.g., txi-cs.tex does this).
4018 \ifx\today\thisisundefined
4019 \def\today{%
4020   \number\day\space
4021   \ifcase\month
4022   \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
4023   \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
4024   \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
4025   \fi
4026   \space\number\year}
4027 \fi
4028
4029 % @settitle line...  specifies the title of the document, for headings.
4030 % It generates no output of its own.
4031 \def\thistitle{\putwordNoTitle}
4032 \def\settitle{\parsearg{\gdef\thistitle}}
4033
4034
4035 \message{tables,}
4036 % Tables -- @table, @ftable, @vtable, @item(x).
4037
4038 % default indentation of table text
4039 \newdimen\tableindent \tableindent=.8in
4040 % default indentation of @itemize and @enumerate text
4041 \newdimen\itemindent  \itemindent=.3in
4042 % margin between end of table item and start of table text.
4043 \newdimen\itemmargin  \itemmargin=.1in
4044
4045 % used internally for \itemindent minus \itemmargin
4046 \newdimen\itemmax
4047
4048 % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
4049 % these defs.
4050 % They also define \itemindex
4051 % to index the item name in whatever manner is desired (perhaps none).
4052
4053 \newif\ifitemxneedsnegativevskip
4054
4055 \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
4056
4057 \def\internalBitem{\smallbreak \parsearg\itemzzz}
4058 \def\internalBitemx{\itemxpar \parsearg\itemzzz}
4059
4060 \def\itemzzz #1{\begingroup %
4061   \advance\hsize by -\rightskip
4062   \advance\hsize by -\tableindent
4063   \setbox0=\hbox{\itemindicate{#1}}%
4064   \itemindex{#1}%
4065   \nobreak % This prevents a break before @itemx.
4066   %
4067   % If the item text does not fit in the space we have, put it on a line
4068   % by itself, and do not allow a page break either before or after that
4069   % line.  We do not start a paragraph here because then if the next
4070   % command is, e.g., @kindex, the whatsit would get put into the
4071   % horizontal list on a line by itself, resulting in extra blank space.
4072   \ifdim \wd0>\itemmax
4073     %
4074     % Make this a paragraph so we get the \parskip glue and wrapping,
4075     % but leave it ragged-right.
4076     \begingroup
4077       \advance\leftskip by-\tableindent
4078       \advance\hsize by\tableindent
4079       \advance\rightskip by0pt plus1fil\relax
4080       \leavevmode\unhbox0\par
4081     \endgroup
4082     %
4083     % We're going to be starting a paragraph, but we don't want the
4084     % \parskip glue -- logically it's part of the @item we just started.
4085     \nobreak \vskip-\parskip
4086     %
4087     % Stop a page break at the \parskip glue coming up.  However, if
4088     % what follows is an environment such as @example, there will be no
4089     % \parskip glue; then the negative vskip we just inserted would
4090     % cause the example and the item to crash together.  So we use this
4091     % bizarre value of 10001 as a signal to \aboveenvbreak to insert
4092     % \parskip glue after all.  Section titles are handled this way also.
4093     %
4094     \penalty 10001
4095     \endgroup
4096     \itemxneedsnegativevskipfalse
4097   \else
4098     % The item text fits into the space.  Start a paragraph, so that the
4099     % following text (if any) will end up on the same line.
4100     \noindent
4101     % Do this with kerns and \unhbox so that if there is a footnote in
4102     % the item text, it can migrate to the main vertical list and
4103     % eventually be printed.
4104     \nobreak\kern-\tableindent
4105     \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
4106     \unhbox0
4107     \nobreak\kern\dimen0
4108     \endgroup
4109     \itemxneedsnegativevskiptrue
4110   \fi
4111 }
4112
4113 \def\item{\errmessage{@item while not in a list environment}}
4114 \def\itemx{\errmessage{@itemx while not in a list environment}}
4115
4116 % @table, @ftable, @vtable.
4117 \envdef\table{%
4118   \let\itemindex\gobble
4119   \tablecheck{table}%
4120 }
4121 \envdef\ftable{%
4122   \def\itemindex ##1{\doind {fn}{\code{##1}}}%
4123   \tablecheck{ftable}%
4124 }
4125 \envdef\vtable{%
4126   \def\itemindex ##1{\doind {vr}{\code{##1}}}%
4127   \tablecheck{vtable}%
4128 }
4129 \def\tablecheck#1{%
4130   \ifnum \the\catcode`\^^M=\active
4131     \endgroup
4132     \errmessage{This command won't work in this context; perhaps the problem is
4133       that we are \inenvironment\thisenv}%
4134     \def\next{\doignore{#1}}%
4135   \else
4136     \let\next\tablex
4137   \fi
4138   \next
4139 }
4140 \def\tablex#1{%
4141   \def\itemindicate{#1}%
4142   \parsearg\tabley
4143 }
4144 \def\tabley#1{%
4145   {%
4146     \makevalueexpandable
4147     \edef\temp{\noexpand\tablez #1\space\space\space}%
4148     \expandafter
4149   }\temp \endtablez
4150 }
4151 \def\tablez #1 #2 #3 #4\endtablez{%
4152   \aboveenvbreak
4153   \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
4154   \ifnum 0#2>0 \tableindent=#2\mil \fi
4155   \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
4156   \itemmax=\tableindent
4157   \advance \itemmax by -\itemmargin
4158   \advance \leftskip by \tableindent
4159   \exdentamount=\tableindent
4160   \parindent = 0pt
4161   \parskip = \smallskipamount
4162   \ifdim \parskip=0pt \parskip=2pt \fi
4163   \let\item = \internalBitem
4164   \let\itemx = \internalBitemx
4165 }
4166 \def\Etable{\endgraf\afterenvbreak}
4167 \let\Eftable\Etable
4168 \let\Evtable\Etable
4169 \let\Eitemize\Etable
4170 \let\Eenumerate\Etable
4171
4172 % This is the counter used by @enumerate, which is really @itemize
4173
4174 \newcount \itemno
4175
4176 \envdef\itemize{\parsearg\doitemize}
4177
4178 \def\doitemize#1{%
4179   \aboveenvbreak
4180   \itemmax=\itemindent
4181   \advance\itemmax by -\itemmargin
4182   \advance\leftskip by \itemindent
4183   \exdentamount=\itemindent
4184   \parindent=0pt
4185   \parskip=\smallskipamount
4186   \ifdim\parskip=0pt \parskip=2pt \fi
4187   %
4188   % Try typesetting the item mark so that if the document erroneously says
4189   % something like @itemize @samp (intending @table), there's an error
4190   % right away at the @itemize.  It's not the best error message in the
4191   % world, but it's better than leaving it to the @item.  This means if
4192   % the user wants an empty mark, they have to say @w{} not just @w.
4193   \def\itemcontents{#1}%
4194   \setbox0 = \hbox{\itemcontents}%
4195   %
4196   % @itemize with no arg is equivalent to @itemize @bullet.
4197   \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
4198   %
4199   \let\item=\itemizeitem
4200 }
4201
4202 % Definition of @item while inside @itemize and @enumerate.
4203 %
4204 \def\itemizeitem{%
4205   \advance\itemno by 1  % for enumerations
4206   {\let\par=\endgraf \smallbreak}% reasonable place to break
4207   {%
4208    % If the document has an @itemize directly after a section title, a
4209    % \nobreak will be last on the list, and \sectionheading will have
4210    % done a \vskip-\parskip.  In that case, we don't want to zero
4211    % parskip, or the item text will crash with the heading.  On the
4212    % other hand, when there is normal text preceding the item (as there
4213    % usually is), we do want to zero parskip, or there would be too much
4214    % space.  In that case, we won't have a \nobreak before.  At least
4215    % that's the theory.
4216    \ifnum\lastpenalty<10000 \parskip=0in \fi
4217    \noindent
4218    \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
4219    %
4220    \ifinner\else
4221      \vadjust{\penalty 1200}% not good to break after first line of item.
4222    \fi
4223    % We can be in inner vertical mode in a footnote, although an
4224    % @itemize looks awful there.
4225   }%
4226   \flushcr
4227 }
4228
4229 % \splitoff TOKENS\endmark defines \first to be the first token in
4230 % TOKENS, and \rest to be the remainder.
4231 %
4232 \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
4233
4234 % Allow an optional argument of an uppercase letter, lowercase letter,
4235 % or number, to specify the first label in the enumerated list.  No
4236 % argument is the same as `1'.
4237 %
4238 \envparseargdef\enumerate{\enumeratey #1  \endenumeratey}
4239 \def\enumeratey #1 #2\endenumeratey{%
4240   % If we were given no argument, pretend we were given `1'.
4241   \def\thearg{#1}%
4242   \ifx\thearg\empty \def\thearg{1}\fi
4243   %
4244   % Detect if the argument is a single token.  If so, it might be a
4245   % letter.  Otherwise, the only valid thing it can be is a number.
4246   % (We will always have one token, because of the test we just made.
4247   % This is a good thing, since \splitoff doesn't work given nothing at
4248   % all -- the first parameter is undelimited.)
4249   \expandafter\splitoff\thearg\endmark
4250   \ifx\rest\empty
4251     % Only one token in the argument.  It could still be anything.
4252     % A ``lowercase letter'' is one whose \lccode is nonzero.
4253     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
4254     %   not equal to itself.
4255     % Otherwise, we assume it's a number.
4256     %
4257     % We need the \relax at the end of the \ifnum lines to stop TeX from
4258     % continuing to look for a <number>.
4259     %
4260     \ifnum\lccode\expandafter`\thearg=0\relax
4261       \numericenumerate % a number (we hope)
4262     \else
4263       % It's a letter.
4264       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
4265         \lowercaseenumerate % lowercase letter
4266       \else
4267         \uppercaseenumerate % uppercase letter
4268       \fi
4269     \fi
4270   \else
4271     % Multiple tokens in the argument.  We hope it's a number.
4272     \numericenumerate
4273   \fi
4274 }
4275
4276 % An @enumerate whose labels are integers.  The starting integer is
4277 % given in \thearg.
4278 %
4279 \def\numericenumerate{%
4280   \itemno = \thearg
4281   \startenumeration{\the\itemno}%
4282 }
4283
4284 % The starting (lowercase) letter is in \thearg.
4285 \def\lowercaseenumerate{%
4286   \itemno = \expandafter`\thearg
4287   \startenumeration{%
4288     % Be sure we're not beyond the end of the alphabet.
4289     \ifnum\itemno=0
4290       \errmessage{No more lowercase letters in @enumerate; get a bigger
4291                   alphabet}%
4292     \fi
4293     \char\lccode\itemno
4294   }%
4295 }
4296
4297 % The starting (uppercase) letter is in \thearg.
4298 \def\uppercaseenumerate{%
4299   \itemno = \expandafter`\thearg
4300   \startenumeration{%
4301     % Be sure we're not beyond the end of the alphabet.
4302     \ifnum\itemno=0
4303       \errmessage{No more uppercase letters in @enumerate; get a bigger
4304                   alphabet}
4305     \fi
4306     \char\uccode\itemno
4307   }%
4308 }
4309
4310 % Call \doitemize, adding a period to the first argument and supplying the
4311 % common last two arguments.  Also subtract one from the initial value in
4312 % \itemno, since @item increments \itemno.
4313 %
4314 \def\startenumeration#1{%
4315   \advance\itemno by -1
4316   \doitemize{#1.}\flushcr
4317 }
4318
4319 % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
4320 % to @enumerate.
4321 %
4322 \def\alphaenumerate{\enumerate{a}}
4323 \def\capsenumerate{\enumerate{A}}
4324 \def\Ealphaenumerate{\Eenumerate}
4325 \def\Ecapsenumerate{\Eenumerate}
4326
4327
4328 % @multitable macros
4329 % Amy Hendrickson, 8/18/94, 3/6/96
4330 %
4331 % @multitable ... @end multitable will make as many columns as desired.
4332 % Contents of each column will wrap at width given in preamble.  Width
4333 % can be specified either with sample text given in a template line,
4334 % or in percent of \hsize, the current width of text on page.
4335
4336 % Table can continue over pages but will only break between lines.
4337
4338 % To make preamble:
4339 %
4340 % Either define widths of columns in terms of percent of \hsize:
4341 %   @multitable @columnfractions .25 .3 .45
4342 %   @item ...
4343 %
4344 %   Numbers following @columnfractions are the percent of the total
4345 %   current hsize to be used for each column. You may use as many
4346 %   columns as desired.
4347
4348
4349 % Or use a template:
4350 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4351 %   @item ...
4352 %   using the widest term desired in each column.
4353
4354 % Each new table line starts with @item, each subsequent new column
4355 % starts with @tab. Empty columns may be produced by supplying @tab's
4356 % with nothing between them for as many times as empty columns are needed,
4357 % ie, @tab@tab@tab will produce two empty columns.
4358
4359 % @item, @tab do not need to be on their own lines, but it will not hurt
4360 % if they are.
4361
4362 % Sample multitable:
4363
4364 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4365 %   @item first col stuff @tab second col stuff @tab third col
4366 %   @item
4367 %   first col stuff
4368 %   @tab
4369 %   second col stuff
4370 %   @tab
4371 %   third col
4372 %   @item first col stuff @tab second col stuff
4373 %   @tab Many paragraphs of text may be used in any column.
4374 %
4375 %         They will wrap at the width determined by the template.
4376 %   @item@tab@tab This will be in third column.
4377 %   @end multitable
4378
4379 % Default dimensions may be reset by user.
4380 % @multitableparskip is vertical space between paragraphs in table.
4381 % @multitableparindent is paragraph indent in table.
4382 % @multitablecolmargin is horizontal space to be left between columns.
4383 % @multitablelinespace is space to leave between table items, baseline
4384 %                                                            to baseline.
4385 %   0pt means it depends on current normal line spacing.
4386 %
4387 \newskip\multitableparskip
4388 \newskip\multitableparindent
4389 \newdimen\multitablecolspace
4390 \newskip\multitablelinespace
4391 \multitableparskip=0pt
4392 \multitableparindent=6pt
4393 \multitablecolspace=12pt
4394 \multitablelinespace=0pt
4395
4396 % Macros used to set up halign preamble:
4397 %
4398 \let\endsetuptable\relax
4399 \def\xendsetuptable{\endsetuptable}
4400 \let\columnfractions\relax
4401 \def\xcolumnfractions{\columnfractions}
4402 \newif\ifsetpercent
4403
4404 % #1 is the @columnfraction, usually a decimal number like .5, but might
4405 % be just 1.  We just use it, whatever it is.
4406 %
4407 \def\pickupwholefraction#1 {%
4408   \global\advance\colcount by 1
4409   \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
4410   \setuptable
4411 }
4412
4413 \newcount\colcount
4414 \def\setuptable#1{%
4415   \def\firstarg{#1}%
4416   \ifx\firstarg\xendsetuptable
4417     \let\go = \relax
4418   \else
4419     \ifx\firstarg\xcolumnfractions
4420       \global\setpercenttrue
4421     \else
4422       \ifsetpercent
4423          \let\go\pickupwholefraction
4424       \else
4425          \global\advance\colcount by 1
4426          \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
4427                    % separator; typically that is always in the input, anyway.
4428          \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
4429       \fi
4430     \fi
4431     \ifx\go\pickupwholefraction
4432       % Put the argument back for the \pickupwholefraction call, so
4433       % we'll always have a period there to be parsed.
4434       \def\go{\pickupwholefraction#1}%
4435     \else
4436       \let\go = \setuptable
4437     \fi%
4438   \fi
4439   \go
4440 }
4441
4442 % multitable-only commands.
4443 %
4444 % @headitem starts a heading row, which we typeset in bold.  Assignments
4445 % have to be global since we are inside the implicit group of an
4446 % alignment entry.  \everycr below resets \everytab so we don't have to
4447 % undo it ourselves.
4448 \def\headitemfont{\b}% for people to use in the template row; not changeable
4449 \def\headitem{%
4450   \checkenv\multitable
4451   \crcr
4452   \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
4453   \global\everytab={\bf}% can't use \headitemfont since the parsing differs
4454   \the\everytab % for the first item
4455 }%
4456 %
4457 % default for tables with no headings.
4458 \let\headitemcrhook=\relax
4459 %
4460 % A \tab used to include \hskip1sp.  But then the space in a template
4461 % line is not enough.  That is bad.  So let's go back to just `&' until
4462 % we again encounter the problem the 1sp was intended to solve.
4463 %                                       --karl, nathan@acm.org, 20apr99.
4464 \def\tab{\checkenv\multitable &\the\everytab}%
4465
4466 % @multitable ... @end multitable definitions:
4467 %
4468 \newtoks\everytab  % insert after every tab.
4469 %
4470 \envdef\multitable{%
4471   \vskip\parskip
4472   \startsavinginserts
4473   %
4474   % @item within a multitable starts a normal row.
4475   % We use \def instead of \let so that if one of the multitable entries
4476   % contains an @itemize, we don't choke on the \item (seen as \crcr aka
4477   % \endtemplate) expanding \doitemize.
4478   \def\item{\crcr}%
4479   %
4480   \tolerance=9500
4481   \hbadness=9500
4482   \setmultitablespacing
4483   \parskip=\multitableparskip
4484   \parindent=\multitableparindent
4485   \overfullrule=0pt
4486   \global\colcount=0
4487   %
4488   \everycr = {%
4489     \noalign{%
4490       \global\everytab={}% Reset from possible headitem.
4491       \global\colcount=0 % Reset the column counter.
4492       %
4493       % Check for saved footnotes, etc.:
4494       \checkinserts
4495       %
4496       % Perhaps a \nobreak, then reset:
4497       \headitemcrhook
4498       \global\let\headitemcrhook=\relax
4499     }%
4500   }%
4501   %
4502   \parsearg\domultitable
4503 }
4504 \def\domultitable#1{%
4505   % To parse everything between @multitable and @item:
4506   \setuptable#1 \endsetuptable
4507   %
4508   % This preamble sets up a generic column definition, which will
4509   % be used as many times as user calls for columns.
4510   % \vtop will set a single line and will also let text wrap and
4511   % continue for many paragraphs if desired.
4512   \halign\bgroup &%
4513     \global\advance\colcount by 1
4514     \multistrut
4515     \vtop{%
4516       % Use the current \colcount to find the correct column width:
4517       \hsize=\expandafter\csname col\the\colcount\endcsname
4518       %
4519       % In order to keep entries from bumping into each other
4520       % we will add a \leftskip of \multitablecolspace to all columns after
4521       % the first one.
4522       %
4523       % If a template has been used, we will add \multitablecolspace
4524       % to the width of each template entry.
4525       %
4526       % If the user has set preamble in terms of percent of \hsize we will
4527       % use that dimension as the width of the column, and the \leftskip
4528       % will keep entries from bumping into each other.  Table will start at
4529       % left margin and final column will justify at right margin.
4530       %
4531       % Make sure we don't inherit \rightskip from the outer environment.
4532       \rightskip=0pt
4533       \ifnum\colcount=1
4534         % The first column will be indented with the surrounding text.
4535         \advance\hsize by\leftskip
4536       \else
4537         \ifsetpercent \else
4538           % If user has not set preamble in terms of percent of \hsize
4539           % we will advance \hsize by \multitablecolspace.
4540           \advance\hsize by \multitablecolspace
4541         \fi
4542        % In either case we will make \leftskip=\multitablecolspace:
4543       \leftskip=\multitablecolspace
4544       \fi
4545       % Ignoring space at the beginning and end avoids an occasional spurious
4546       % blank line, when TeX decides to break the line at the space before the
4547       % box from the multistrut, so the strut ends up on a line by itself.
4548       % For example:
4549       % @multitable @columnfractions .11 .89
4550       % @item @code{#}
4551       % @tab Legal holiday which is valid in major parts of the whole country.
4552       % Is automatically provided with highlighting sequences respectively
4553       % marking characters.
4554       \noindent\ignorespaces##\unskip\multistrut
4555     }\cr
4556 }
4557 \def\Emultitable{%
4558   \crcr
4559   \egroup % end the \halign
4560   \global\setpercentfalse
4561 }
4562
4563 \def\setmultitablespacing{%
4564   \def\multistrut{\strut}% just use the standard line spacing
4565   %
4566   % Compute \multitablelinespace (if not defined by user) for use in
4567   % \multitableparskip calculation.  We used define \multistrut based on
4568   % this, but (ironically) that caused the spacing to be off.
4569   % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
4570 \ifdim\multitablelinespace=0pt
4571 \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
4572 \global\advance\multitablelinespace by-\ht0
4573 \fi
4574 % Test to see if parskip is larger than space between lines of
4575 % table. If not, do nothing.
4576 %        If so, set to same dimension as multitablelinespace.
4577 \ifdim\multitableparskip>\multitablelinespace
4578 \global\multitableparskip=\multitablelinespace
4579 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4580                                       % than skip between lines in the table.
4581 \fi%
4582 \ifdim\multitableparskip=0pt
4583 \global\multitableparskip=\multitablelinespace
4584 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4585                                       % than skip between lines in the table.
4586 \fi}
4587
4588
4589 \message{conditionals,}
4590
4591 % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
4592 % @ifnotxml always succeed.  They currently do nothing; we don't
4593 % attempt to check whether the conditionals are properly nested.  But we
4594 % have to remember that they are conditionals, so that @end doesn't
4595 % attempt to close an environment group.
4596 %
4597 \def\makecond#1{%
4598   \expandafter\let\csname #1\endcsname = \relax
4599   \expandafter\let\csname iscond.#1\endcsname = 1
4600 }
4601 \makecond{iftex}
4602 \makecond{ifnotdocbook}
4603 \makecond{ifnothtml}
4604 \makecond{ifnotinfo}
4605 \makecond{ifnotplaintext}
4606 \makecond{ifnotxml}
4607
4608 % Ignore @ignore, @ifhtml, @ifinfo, and the like.
4609 %
4610 \def\direntry{\doignore{direntry}}
4611 \def\documentdescription{\doignore{documentdescription}}
4612 \def\docbook{\doignore{docbook}}
4613 \def\html{\doignore{html}}
4614 \def\ifdocbook{\doignore{ifdocbook}}
4615 \def\ifhtml{\doignore{ifhtml}}
4616 \def\ifinfo{\doignore{ifinfo}}
4617 \def\ifnottex{\doignore{ifnottex}}
4618 \def\ifplaintext{\doignore{ifplaintext}}
4619 \def\ifxml{\doignore{ifxml}}
4620 \def\ignore{\doignore{ignore}}
4621 \def\menu{\doignore{menu}}
4622 \def\xml{\doignore{xml}}
4623
4624 % Ignore text until a line `@end #1', keeping track of nested conditionals.
4625 %
4626 % A count to remember the depth of nesting.
4627 \newcount\doignorecount
4628
4629 \def\doignore#1{\begingroup
4630   % Scan in ``verbatim'' mode:
4631   \obeylines
4632   \catcode`\@ = \other
4633   \catcode`\{ = \other
4634   \catcode`\} = \other
4635   %
4636   % Make sure that spaces turn into tokens that match what \doignoretext wants.
4637   \spaceisspace
4638   %
4639   % Count number of #1's that we've seen.
4640   \doignorecount = 0
4641   %
4642   % Swallow text until we reach the matching `@end #1'.
4643   \dodoignore{#1}%
4644 }
4645
4646 { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4647   \obeylines %
4648   %
4649   \gdef\dodoignore#1{%
4650     % #1 contains the command name as a string, e.g., `ifinfo'.
4651     %
4652     % Define a command to find the next `@end #1'.
4653     \long\def\doignoretext##1^^M@end #1{%
4654       \doignoretextyyy##1^^M@#1\_STOP_}%
4655     %
4656     % And this command to find another #1 command, at the beginning of a
4657     % line.  (Otherwise, we would consider a line `@c @ifset', for
4658     % example, to count as an @ifset for nesting.)
4659     \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
4660     %
4661     % And now expand that command.
4662     \doignoretext ^^M%
4663   }%
4664 }
4665
4666 \def\doignoreyyy#1{%
4667   \def\temp{#1}%
4668   \ifx\temp\empty                       % Nothing found.
4669     \let\next\doignoretextzzz
4670   \else                                 % Found a nested condition, ...
4671     \advance\doignorecount by 1
4672     \let\next\doignoretextyyy           % ..., look for another.
4673     % If we're here, #1 ends with ^^M\ifinfo (for example).
4674   \fi
4675   \next #1% the token \_STOP_ is present just after this macro.
4676 }
4677
4678 % We have to swallow the remaining "\_STOP_".
4679 %
4680 \def\doignoretextzzz#1{%
4681   \ifnum\doignorecount = 0      % We have just found the outermost @end.
4682     \let\next\enddoignore
4683   \else                         % Still inside a nested condition.
4684     \advance\doignorecount by -1
4685     \let\next\doignoretext      % Look for the next @end.
4686   \fi
4687   \next
4688 }
4689
4690 % Finish off ignored text.
4691 { \obeylines%
4692   % Ignore anything after the last `@end #1'; this matters in verbatim
4693   % environments, where otherwise the newline after an ignored conditional
4694   % would result in a blank line in the output.
4695   \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4696 }
4697
4698
4699 % @set VAR sets the variable VAR to an empty value.
4700 % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4701 %
4702 % Since we want to separate VAR from REST-OF-LINE (which might be
4703 % empty), we can't just use \parsearg; we have to insert a space of our
4704 % own to delimit the rest of the line, and then take it out again if we
4705 % didn't need it.
4706 % We rely on the fact that \parsearg sets \catcode`\ =10.
4707 %
4708 \parseargdef\set{\setyyy#1 \endsetyyy}
4709 \def\setyyy#1 #2\endsetyyy{%
4710   {%
4711     \makevalueexpandable
4712     \def\temp{#2}%
4713     \edef\next{\gdef\makecsname{SET#1}}%
4714     \ifx\temp\empty
4715       \next{}%
4716     \else
4717       \setzzz#2\endsetzzz
4718     \fi
4719   }%
4720 }
4721 % Remove the trailing space \setxxx inserted.
4722 \def\setzzz#1 \endsetzzz{\next{#1}}
4723
4724 % @clear VAR clears (i.e., unsets) the variable VAR.
4725 %
4726 \parseargdef\clear{%
4727   {%
4728     \makevalueexpandable
4729     \global\expandafter\let\csname SET#1\endcsname=\relax
4730   }%
4731 }
4732
4733 % @value{foo} gets the text saved in variable foo.
4734 \def\value{\begingroup\makevalueexpandable\valuexxx}
4735 \def\valuexxx#1{\expandablevalue{#1}\endgroup}
4736 {
4737   \catcode`\-=\active \catcode`\_=\active
4738   %
4739   \gdef\makevalueexpandable{%
4740     \let\value = \expandablevalue
4741     % We don't want these characters active, ...
4742     \catcode`\-=\other \catcode`\_=\other
4743     % ..., but we might end up with active ones in the argument if
4744     % we're called from @code, as @code{@value{foo-bar_}}, though.
4745     % So \let them to their normal equivalents.
4746     \let-\normaldash \let_\normalunderscore
4747   }
4748 }
4749
4750 \def\expandablevalue#1{%
4751   \expandafter\ifx\csname SET#1\endcsname\relax
4752     {[No value for ``#1'']}%
4753     \message{Variable `#1', used in @value, is not set.}%
4754   \else
4755     \csname SET#1\endcsname
4756   \fi
4757 }
4758
4759 % Like \expandablevalue, but completely expandable (the \message in the
4760 % definition above operates at the execution level of TeX).  Used when
4761 % writing to auxiliary files, due to the expansion that \write does.
4762 % If flag is undefined, pass through an unexpanded @value command: maybe it
4763 % will be set by the time it is read back in.
4764 %
4765 % NB flag names containing - or _ may not work here.
4766 \def\dummyvalue#1{%
4767   \expandafter\ifx\csname SET#1\endcsname\relax
4768     \string\value{#1}%
4769   \else
4770     \csname SET#1\endcsname
4771   \fi
4772 }
4773
4774 % Used for @value's in index entries to form the sort key: expand the @value
4775 % if possible, otherwise sort late.
4776 \def\indexnofontsvalue#1{%
4777   \expandafter\ifx\csname SET#1\endcsname\relax
4778     ZZZZZZZ%
4779   \else
4780     \csname SET#1\endcsname
4781   \fi
4782 }
4783
4784 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4785 % with @set.
4786 %
4787 % To get the special treatment we need for `@end ifset,' we call
4788 % \makecond and then redefine.
4789 %
4790 \makecond{ifset}
4791 \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4792 \def\doifset#1#2{%
4793   {%
4794     \makevalueexpandable
4795     \let\next=\empty
4796     \expandafter\ifx\csname SET#2\endcsname\relax
4797       #1% If not set, redefine \next.
4798     \fi
4799     \expandafter
4800   }\next
4801 }
4802 \def\ifsetfail{\doignore{ifset}}
4803
4804 % @ifclear VAR ... @end executes the `...' iff VAR has never been
4805 % defined with @set, or has been undefined with @clear.
4806 %
4807 % The `\else' inside the `\doifset' parameter is a trick to reuse the
4808 % above code: if the variable is not set, do nothing, if it is set,
4809 % then redefine \next to \ifclearfail.
4810 %
4811 \makecond{ifclear}
4812 \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4813 \def\ifclearfail{\doignore{ifclear}}
4814
4815 % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
4816 % without the @) is in fact defined.  We can only feasibly check at the
4817 % TeX level, so something like `mathcode' is going to considered
4818 % defined even though it is not a Texinfo command.
4819 %
4820 \makecond{ifcommanddefined}
4821 \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
4822 %
4823 \def\doifcmddefined#1#2{{%
4824     \makevalueexpandable
4825     \let\next=\empty
4826     \expandafter\ifx\csname #2\endcsname\relax
4827       #1% If not defined, \let\next as above.
4828     \fi
4829     \expandafter
4830   }\next
4831 }
4832 \def\ifcmddefinedfail{\doignore{ifcommanddefined}}
4833
4834 % @ifcommandnotdefined CMD ... handled similar to @ifclear above.
4835 \makecond{ifcommandnotdefined}
4836 \def\ifcommandnotdefined{%
4837   \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
4838 \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
4839
4840 % Set the `txicommandconditionals' variable, so documents have a way to
4841 % test if the @ifcommand...defined conditionals are available.
4842 \set txicommandconditionals
4843
4844 % @dircategory CATEGORY  -- specify a category of the dir file
4845 % which this file should belong to.  Ignore this in TeX.
4846 \let\dircategory=\comment
4847
4848 % @defininfoenclose.
4849 \let\definfoenclose=\comment
4850
4851
4852 \message{indexing,}
4853 % Index generation facilities
4854
4855 % Define \newwrite to be identical to plain tex's \newwrite
4856 % except not \outer, so it can be used within macros and \if's.
4857 \edef\newwrite{\makecsname{ptexnewwrite}}
4858
4859 % \newindex {foo} defines an index named IX.
4860 % It automatically defines \IXindex such that
4861 % \IXindex ...rest of line... puts an entry in the index IX.
4862 % It also defines \IXindfile to be the number of the output channel for
4863 % the file that accumulates this index.  The file's extension is IX.
4864 % The name of an index should be no more than 2 characters long
4865 % for the sake of vms.
4866 %
4867 \def\newindex#1{%
4868   \expandafter\chardef\csname#1indfile\endcsname=0
4869   \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
4870     \noexpand\doindex{#1}}
4871 }
4872
4873 % @defindex foo  ==  \newindex{foo}
4874 %
4875 \def\defindex{\parsearg\newindex}
4876
4877 % Define @defcodeindex, like @defindex except put all entries in @code.
4878 %
4879 \def\defcodeindex{\parsearg\newcodeindex}
4880 %
4881 \def\newcodeindex#1{%
4882   \expandafter\chardef\csname#1indfile\endcsname=0
4883   \expandafter\xdef\csname#1index\endcsname{%
4884     \noexpand\docodeindex{#1}}%
4885 }
4886
4887 % The default indices:
4888 \newindex{cp}%      concepts,
4889 \newcodeindex{fn}%  functions,
4890 \newcodeindex{vr}%  variables,
4891 \newcodeindex{tp}%  types,
4892 \newcodeindex{ky}%  keys
4893 \newcodeindex{pg}%  and programs.
4894
4895
4896 % @synindex foo bar    makes index foo feed into index bar.
4897 % Do this instead of @defindex foo if you don't want it as a separate index.
4898 %
4899 % @syncodeindex foo bar   similar, but put all entries made for index foo
4900 % inside @code.
4901 %
4902 \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4903 \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4904
4905 % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4906 % #3 the target index (bar).
4907 \def\dosynindex#1#2#3{%
4908   \requireopenindexfile{#3}%
4909   % redefine \fooindfile:
4910   \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4911   \expandafter\let\csname#2indfile\endcsname=\temp
4912   % redefine \fooindex:
4913   \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
4914 }
4915
4916 % Define \doindex, the driver for all index macros.
4917 % Argument #1 is generated by the calling \fooindex macro,
4918 % and it is the two-letter name of the index.
4919
4920 \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
4921 \def\doindexxxx #1{\doind{\indexname}{#1}}
4922
4923 % like the previous two, but they put @code around the argument.
4924 \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
4925 \def\docodeindexxxx #1{\docind{\indexname}{#1}}
4926
4927
4928 % Used for the aux, toc and index files to prevent expansion of Texinfo
4929 % commands.
4930 %
4931 \def\atdummies{%
4932   \definedummyletter\@%
4933   \definedummyletter\ %
4934   \definedummyletter\{%
4935   \definedummyletter\}%
4936   \definedummyletter\&%
4937   %
4938   % Do the redefinitions.
4939   \definedummies
4940   \otherbackslash
4941 }
4942
4943 % \definedummyword defines \#1 as \string\#1\space, thus effectively
4944 % preventing its expansion.  This is used only for control words,
4945 % not control letters, because the \space would be incorrect for
4946 % control characters, but is needed to separate the control word
4947 % from whatever follows.
4948 %
4949 % These can be used both for control words that take an argument and
4950 % those that do not.  If it is followed by {arg} in the input, then
4951 % that will dutifully get written to the index (or wherever).
4952 %
4953 % For control letters, we have \definedummyletter, which omits the
4954 % space.
4955 %
4956 \def\definedummyword  #1{\def#1{\string#1\space}}%
4957 \def\definedummyletter#1{\def#1{\string#1}}%
4958 \let\definedummyaccent\definedummyletter
4959
4960 % Called from \atdummies to prevent the expansion of commands.
4961 %
4962 \def\definedummies{%
4963   %
4964   \let\commondummyword\definedummyword
4965   \let\commondummyletter\definedummyletter
4966   \let\commondummyaccent\definedummyaccent
4967   \commondummiesnofonts
4968   %
4969   \definedummyletter\_%
4970   \definedummyletter\-%
4971   %
4972   % Non-English letters.
4973   \definedummyword\AA
4974   \definedummyword\AE
4975   \definedummyword\DH
4976   \definedummyword\L
4977   \definedummyword\O
4978   \definedummyword\OE
4979   \definedummyword\TH
4980   \definedummyword\aa
4981   \definedummyword\ae
4982   \definedummyword\dh
4983   \definedummyword\exclamdown
4984   \definedummyword\l
4985   \definedummyword\o
4986   \definedummyword\oe
4987   \definedummyword\ordf
4988   \definedummyword\ordm
4989   \definedummyword\questiondown
4990   \definedummyword\ss
4991   \definedummyword\th
4992   %
4993   % Although these internal commands shouldn't show up, sometimes they do.
4994   \definedummyword\bf
4995   \definedummyword\gtr
4996   \definedummyword\hat
4997   \definedummyword\less
4998   \definedummyword\sf
4999   \definedummyword\sl
5000   \definedummyword\tclose
5001   \definedummyword\tt
5002   %
5003   \definedummyword\LaTeX
5004   \definedummyword\TeX
5005   %
5006   % Assorted special characters.
5007   \definedummyword\ampchar
5008   \definedummyword\atchar
5009   \definedummyword\arrow
5010   \definedummyword\backslashchar
5011   \definedummyword\bullet
5012   \definedummyword\comma
5013   \definedummyword\copyright
5014   \definedummyword\registeredsymbol
5015   \definedummyword\dots
5016   \definedummyword\enddots
5017   \definedummyword\entrybreak
5018   \definedummyword\equiv
5019   \definedummyword\error
5020   \definedummyword\euro
5021   \definedummyword\expansion
5022   \definedummyword\geq
5023   \definedummyword\guillemetleft
5024   \definedummyword\guillemetright
5025   \definedummyword\guilsinglleft
5026   \definedummyword\guilsinglright
5027   \definedummyword\lbracechar
5028   \definedummyword\leq
5029   \definedummyword\mathopsup
5030   \definedummyword\minus
5031   \definedummyword\ogonek
5032   \definedummyword\pounds
5033   \definedummyword\point
5034   \definedummyword\print
5035   \definedummyword\quotedblbase
5036   \definedummyword\quotedblleft
5037   \definedummyword\quotedblright
5038   \definedummyword\quoteleft
5039   \definedummyword\quoteright
5040   \definedummyword\quotesinglbase
5041   \definedummyword\rbracechar
5042   \definedummyword\result
5043   \definedummyword\sub
5044   \definedummyword\sup
5045   \definedummyword\textdegree
5046   %
5047   \definedummyword\subentry
5048   %
5049   % We want to disable all macros so that they are not expanded by \write.
5050   \macrolist
5051   \let\value\dummyvalue
5052   %
5053   \normalturnoffactive
5054 }
5055
5056 % \commondummiesnofonts: common to \definedummies and \indexnofonts.
5057 % Define \commondummyletter, \commondummyaccent and \commondummyword before
5058 % using.  Used for accents, font commands, and various control letters.
5059 %
5060 \def\commondummiesnofonts{%
5061   % Control letters and accents.
5062   \commondummyletter\!%
5063   \commondummyaccent\"%
5064   \commondummyaccent\'%
5065   \commondummyletter\*%
5066   \commondummyaccent\,%
5067   \commondummyletter\.%
5068   \commondummyletter\/%
5069   \commondummyletter\:%
5070   \commondummyaccent\=%
5071   \commondummyletter\?%
5072   \commondummyaccent\^%
5073   \commondummyaccent\`%
5074   \commondummyaccent\~%
5075   \commondummyword\u
5076   \commondummyword\v
5077   \commondummyword\H
5078   \commondummyword\dotaccent
5079   \commondummyword\ogonek
5080   \commondummyword\ringaccent
5081   \commondummyword\tieaccent
5082   \commondummyword\ubaraccent
5083   \commondummyword\udotaccent
5084   \commondummyword\dotless
5085   %
5086   % Texinfo font commands.
5087   \commondummyword\b
5088   \commondummyword\i
5089   \commondummyword\r
5090   \commondummyword\sansserif
5091   \commondummyword\sc
5092   \commondummyword\slanted
5093   \commondummyword\t
5094   %
5095   % Commands that take arguments.
5096   \commondummyword\abbr
5097   \commondummyword\acronym
5098   \commondummyword\anchor
5099   \commondummyword\cite
5100   \commondummyword\code
5101   \commondummyword\command
5102   \commondummyword\dfn
5103   \commondummyword\dmn
5104   \commondummyword\email
5105   \commondummyword\emph
5106   \commondummyword\env
5107   \commondummyword\file
5108   \commondummyword\image
5109   \commondummyword\indicateurl
5110   \commondummyword\inforef
5111   \commondummyword\kbd
5112   \commondummyword\key
5113   \commondummyword\math
5114   \commondummyword\option
5115   \commondummyword\pxref
5116   \commondummyword\ref
5117   \commondummyword\samp
5118   \commondummyword\strong
5119   \commondummyword\tie
5120   \commondummyword\U
5121   \commondummyword\uref
5122   \commondummyword\url
5123   \commondummyword\var
5124   \commondummyword\verb
5125   \commondummyword\w
5126   \commondummyword\xref
5127 }
5128
5129 \let\indexlbrace\relax
5130 \let\indexrbrace\relax
5131 \let\indexatchar\relax
5132 \let\indexbackslash\relax
5133
5134 {\catcode`\@=0
5135 \catcode`\\=13
5136   @gdef@backslashdisappear{@def\{}}
5137 }
5138
5139 {
5140 \catcode`\<=13
5141 \catcode`\-=13
5142 \catcode`\`=13
5143   \gdef\indexnonalnumdisappear{%
5144     \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
5145       % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
5146       % (Introduced for FSFS 2nd ed.)
5147       \let`=\empty
5148     \fi
5149     %
5150     \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
5151       \backslashdisappear
5152     \fi
5153     %
5154     \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
5155       \def-{}%
5156     \fi
5157     \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
5158       \def<{}%
5159     \fi
5160     \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
5161       \def\@{}%
5162     \fi
5163   }
5164
5165   \gdef\indexnonalnumreappear{%
5166     \let-\normaldash
5167     \let<\normalless
5168   }
5169 }
5170
5171
5172 % \indexnofonts is used when outputting the strings to sort the index
5173 % by, and when constructing control sequence names.  It eliminates all
5174 % control sequences and just writes whatever the best ASCII sort string
5175 % would be for a given command (usually its argument).
5176 %
5177 \def\indexnofonts{%
5178   % Accent commands should become @asis.
5179   \def\commondummyaccent##1{\let##1\asis}%
5180   % We can just ignore other control letters.
5181   \def\commondummyletter##1{\let##1\empty}%
5182   % All control words become @asis by default; overrides below.
5183   \let\commondummyword\commondummyaccent
5184   \commondummiesnofonts
5185   %
5186   % Don't no-op \tt, since it isn't a user-level command
5187   % and is used in the definitions of the active chars like <, >, |, etc.
5188   % Likewise with the other plain tex font commands.
5189   %\let\tt=\asis
5190   %
5191   \def\ { }%
5192   \def\@{@}%
5193   \def\_{\normalunderscore}%
5194   \def\-{}% @- shouldn't affect sorting
5195   %
5196   \uccode`\1=`\{ \uppercase{\def\{{1}}%
5197   \uccode`\1=`\} \uppercase{\def\}{1}}%
5198   \let\lbracechar\{%
5199   \let\rbracechar\}%
5200   %
5201   %
5202   \let\do\indexnofontsdef
5203   %
5204   % Non-English letters.
5205   \do\AA{AA}%
5206   \do\AE{AE}%
5207   \do\DH{DZZ}%
5208   \do\L{L}%
5209   \do\OE{OE}%
5210   \do\O{O}%
5211   \do\TH{TH}%
5212   \do\aa{aa}%
5213   \do\ae{ae}%
5214   \do\dh{dzz}%
5215   \do\exclamdown{!}%
5216   \do\l{l}%
5217   \do\oe{oe}%
5218   \do\ordf{a}%
5219   \do\ordm{o}%
5220   \do\o{o}%
5221   \do\questiondown{?}%
5222   \do\ss{ss}%
5223   \do\th{th}%
5224   %
5225   \do\LaTeX{LaTeX}%
5226   \do\TeX{TeX}%
5227   %
5228   % Assorted special characters.
5229   \do\atchar{@}%
5230   \do\arrow{->}%
5231   \do\bullet{bullet}%
5232   \do\comma{,}%
5233   \do\copyright{copyright}%
5234   \do\dots{...}%
5235   \do\enddots{...}%
5236   \do\equiv{==}%
5237   \do\error{error}%
5238   \do\euro{euro}%
5239   \do\expansion{==>}%
5240   \do\geq{>=}%
5241   \do\guillemetleft{<<}%
5242   \do\guillemetright{>>}%
5243   \do\guilsinglleft{<}%
5244   \do\guilsinglright{>}%
5245   \do\leq{<=}%
5246   \do\lbracechar{\{}%
5247   \do\minus{-}%
5248   \do\point{.}%
5249   \do\pounds{pounds}%
5250   \do\print{-|}%
5251   \do\quotedblbase{"}%
5252   \do\quotedblleft{"}%
5253   \do\quotedblright{"}%
5254   \do\quoteleft{`}%
5255   \do\quoteright{'}%
5256   \do\quotesinglbase{,}%
5257   \do\rbracechar{\}}%
5258   \do\registeredsymbol{R}%
5259   \do\result{=>}%
5260   \do\textdegree{o}%
5261   %
5262   % We need to get rid of all macros, leaving only the arguments (if present).
5263   % Of course this is not nearly correct, but it is the best we can do for now.
5264   % makeinfo does not expand macros in the argument to @deffn, which ends up
5265   % writing an index entry, and texindex isn't prepared for an index sort entry
5266   % that starts with \.
5267   %
5268   % Since macro invocations are followed by braces, we can just redefine them
5269   % to take a single TeX argument.  The case of a macro invocation that
5270   % goes to end-of-line is not handled.
5271   %
5272   \macrolist
5273   \let\value\indexnofontsvalue
5274 }
5275
5276 % Give the control sequence a definition that removes the {} that follows
5277 % its use, e.g. @AA{} -> AA
5278 \def\indexnofontsdef#1#2{\def#1##1{#2}}%
5279
5280
5281
5282
5283 % #1 is the index name, #2 is the entry text.
5284 \def\doind#1#2{%
5285   \iflinks
5286   {%
5287     %
5288     \requireopenindexfile{#1}%
5289     \edef\writeto{\csname#1indfile\endcsname}%
5290     %
5291     \def\indextext{#2}%
5292     \safewhatsit\doindwrite
5293   }%
5294   \fi
5295 }
5296
5297 % Same as \doind, but for code indices
5298 \def\docind#1#2{%
5299   \iflinks
5300   {%
5301     %
5302     \requireopenindexfile{#1}%
5303     \edef\writeto{\csname#1indfile\endcsname}%
5304     %
5305     \def\indextext{#2}%
5306     \safewhatsit\docindwrite
5307   }%
5308   \fi
5309 }
5310
5311 % Check if an index file has been opened, and if not, open it.
5312 \def\requireopenindexfile#1{%
5313 \ifnum\csname #1indfile\endcsname=0
5314   \expandafter\newwrite \csname#1indfile\endcsname
5315   \edef\suffix{#1}%
5316   % A .fls suffix would conflict with the file extension for the output
5317   % of -recorder, so use .f1s instead.
5318   \ifx\suffix\indexisfl\def\suffix{f1}\fi
5319   % Open the file
5320   \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
5321   % Using \immediate above here prevents an object entering into the current
5322   % box, which could confound checks such as those in \safewhatsit for
5323   % preceding skips.
5324   \typeout{Writing index file \jobname.\suffix}%
5325 \fi}
5326 \def\indexisfl{fl}
5327
5328 % Definition for writing index entry sort key.
5329 {
5330 \catcode`\-=13
5331 \gdef\indexwritesortas{%
5332   \begingroup
5333   \indexnonalnumreappear
5334   \indexwritesortasxxx}
5335 \gdef\indexwritesortasxxx#1{%
5336   \xdef\indexsortkey{#1}\endgroup}
5337 }
5338
5339 \def\indexwriteseealso#1{
5340   \gdef\pagenumbertext{\string\seealso{#1}}%
5341 }
5342 \def\indexwriteseeentry#1{
5343   \gdef\pagenumbertext{\string\seeentry{#1}}%
5344 }
5345
5346 % The default definitions
5347 \def\sortas#1{}%
5348 \def\seealso#1{\i{\putwordSeeAlso}\ #1}% for sorted index file only
5349 \def\putwordSeeAlso{See also}
5350 \def\seeentry#1{\i{\putwordSee}\ #1}% for sorted index file only
5351
5352
5353 % Given index entry text like "aaa @subentry bbb @sortas{ZZZ}":
5354 %   * Set \bracedtext to "{aaa}{bbb}"
5355 %   * Set \fullindexsortkey to "aaa @subentry ZZZ"
5356 %   * If @seealso occurs, set \pagenumbertext
5357 %
5358 \def\splitindexentry#1{%
5359   \gdef\fullindexsortkey{}%
5360   \xdef\bracedtext{}%
5361   \def\sep{}%
5362   \def\seealso##1{}%
5363   \def\seeentry##1{}%
5364   \expandafter\doindexsegment#1\subentry\finish\subentry
5365 }
5366
5367 % append the results from the next segment
5368 \def\doindexsegment#1\subentry{%
5369   \def\segment{#1}%
5370   \ifx\segment\isfinish
5371   \else
5372     %
5373     % Fully expand the segment, throwing away any @sortas directives, and
5374     % trim spaces.
5375     \edef\trimmed{\segment}%
5376     \edef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
5377     \ifincodeindex
5378       \edef\trimmed{\noexpand\code{\trimmed}}%
5379     \fi
5380     %
5381     \xdef\bracedtext{\bracedtext{\trimmed}}%
5382     %
5383     % Get the string to sort by.  Process the segment with all
5384     % font commands turned off.
5385     \bgroup
5386       \let\sortas\indexwritesortas
5387       \let\seealso\indexwriteseealso
5388       \let\seeentry\indexwriteseeentry
5389       \indexnofonts
5390       % The braces around the commands are recognized by texindex.
5391       \def\lbracechar{{\string\indexlbrace}}%
5392       \def\rbracechar{{\string\indexrbrace}}%
5393       \let\{=\lbracechar
5394       \let\}=\rbracechar
5395       \def\@{{\string\indexatchar}}%
5396       \def\atchar##1{\@}%
5397       \def\backslashchar{{\string\indexbackslash}}%
5398       \uccode`\~=`\\ \uppercase{\let~\backslashchar}%
5399       %
5400       \let\indexsortkey\empty
5401       \global\let\pagenumbertext\empty
5402       % Execute the segment and throw away the typeset output.  This executes
5403       % any @sortas or @seealso commands in this segment.
5404       \setbox\dummybox = \hbox{\segment}%
5405       \ifx\indexsortkey\empty{%
5406         \indexnonalnumdisappear
5407         \xdef\trimmed{\segment}%
5408         \xdef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
5409         \xdef\indexsortkey{\trimmed}%
5410         \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
5411       }\fi
5412       %
5413       % Append to \fullindexsortkey.
5414       \edef\tmp{\gdef\noexpand\fullindexsortkey{%
5415                   \fullindexsortkey\sep\indexsortkey}}%
5416       \tmp
5417     \egroup
5418     \def\sep{\subentry}%
5419     %
5420     \expandafter\doindexsegment
5421   \fi
5422 }
5423 \def\isfinish{\finish}%
5424 \newbox\dummybox % used above
5425
5426 \let\subentry\relax
5427
5428 % Use \ instead of @ in index files.  To support old texi2dvi and texindex.
5429 % This works without changing the escape character used in the toc or aux
5430 % files because the index entries are fully expanded here, and \string uses
5431 % the current value of \escapechar.
5432 \def\escapeisbackslash{\escapechar=`\\}
5433
5434 % Use \ in index files by default.  texi2dvi didn't support @ as the escape
5435 % character (as it checked for "\entry" in the files, and not "@entry").  When
5436 % the new version of texi2dvi has had a chance to become more prevalent, then
5437 % the escape character can change back to @ again.  This should be an easy
5438 % change to make now because both @ and \ are only used as escape characters in
5439 % index files, never standing for themselves.
5440 %
5441 \set txiindexescapeisbackslash
5442
5443 % Write the entry in \indextext to the index file.
5444 %
5445
5446 \newif\ifincodeindex
5447 \def\doindwrite{\incodeindexfalse\doindwritex}
5448 \def\docindwrite{\incodeindextrue\doindwritex}
5449
5450 \def\doindwritex{%
5451   \maybemarginindex
5452   %
5453   \atdummies
5454   %
5455   \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax\else
5456     \escapeisbackslash
5457   \fi
5458   %
5459   % For texindex which always views { and } as separators.
5460   \def\{{\lbracechar{}}%
5461   \def\}{\rbracechar{}}%
5462   \uccode`\~=`\\ \uppercase{\def~{\backslashchar{}}}%
5463   %
5464   % Split the entry into primary entry and any subentries, and get the index
5465   % sort key.
5466   \splitindexentry\indextext
5467   %
5468   % Set up the complete index entry, with both the sort key and
5469   % the original text, including any font commands.  We write
5470   % three arguments to \entry to the .?? file (four in the
5471   % subentry case), texindex reduces to two when writing the .??s
5472   % sorted result.
5473   %
5474   \edef\temp{%
5475     \write\writeto{%
5476       \string\entry{\fullindexsortkey}%
5477         {\ifx\pagenumbertext\empty\noexpand\folio\else\pagenumbertext\fi}%
5478         \bracedtext}%
5479   }%
5480   \temp
5481 }
5482
5483 % Put the index entry in the margin if desired (undocumented).
5484 \def\maybemarginindex{%
5485   \ifx\SETmarginindex\relax\else
5486     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \relax\indextext}}%
5487   \fi
5488 }
5489 \let\SETmarginindex=\relax
5490
5491
5492 % Take care of unwanted page breaks/skips around a whatsit:
5493 %
5494 % If a skip is the last thing on the list now, preserve it
5495 % by backing up by \lastskip, doing the \write, then inserting
5496 % the skip again.  Otherwise, the whatsit generated by the
5497 % \write or \pdfdest will make \lastskip zero.  The result is that
5498 % sequences like this:
5499 % @end defun
5500 % @tindex whatever
5501 % @defun ...
5502 % will have extra space inserted, because the \medbreak in the
5503 % start of the @defun won't see the skip inserted by the @end of
5504 % the previous defun.
5505 %
5506 % But don't do any of this if we're not in vertical mode.  We
5507 % don't want to do a \vskip and prematurely end a paragraph.
5508 %
5509 % Avoid page breaks due to these extra skips, too.
5510 %
5511 % But wait, there is a catch there:
5512 % We'll have to check whether \lastskip is zero skip.  \ifdim is not
5513 % sufficient for this purpose, as it ignores stretch and shrink parts
5514 % of the skip.  The only way seems to be to check the textual
5515 % representation of the skip.
5516 %
5517 % The following is almost like \def\zeroskipmacro{0.0pt} except that
5518 % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
5519 %
5520 \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
5521 %
5522 \newskip\whatsitskip
5523 \newcount\whatsitpenalty
5524 %
5525 % ..., ready, GO:
5526 %
5527 \def\safewhatsit#1{\ifhmode
5528   #1%
5529  \else
5530   % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
5531   \whatsitskip = \lastskip
5532   \edef\lastskipmacro{\the\lastskip}%
5533   \whatsitpenalty = \lastpenalty
5534   %
5535   % If \lastskip is nonzero, that means the last item was a
5536   % skip.  And since a skip is discardable, that means this
5537   % -\whatsitskip glue we're inserting is preceded by a
5538   % non-discardable item, therefore it is not a potential
5539   % breakpoint, therefore no \nobreak needed.
5540   \ifx\lastskipmacro\zeroskipmacro
5541   \else
5542     \vskip-\whatsitskip
5543   \fi
5544   %
5545   #1%
5546   %
5547   \ifx\lastskipmacro\zeroskipmacro
5548     % If \lastskip was zero, perhaps the last item was a penalty, and
5549     % perhaps it was >=10000, e.g., a \nobreak.  In that case, we want
5550     % to re-insert the same penalty (values >10000 are used for various
5551     % signals); since we just inserted a non-discardable item, any
5552     % following glue (such as a \parskip) would be a breakpoint.  For example:
5553     %   @deffn deffn-whatever
5554     %   @vindex index-whatever
5555     %   Description.
5556     % would allow a break between the index-whatever whatsit
5557     % and the "Description." paragraph.
5558     \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
5559   \else
5560     % On the other hand, if we had a nonzero \lastskip,
5561     % this make-up glue would be preceded by a non-discardable item
5562     % (the whatsit from the \write), so we must insert a \nobreak.
5563     \nobreak\vskip\whatsitskip
5564   \fi
5565 \fi}
5566
5567 % The index entry written in the file actually looks like
5568 %  \entry {sortstring}{page}{topic}
5569 % or
5570 %  \entry {sortstring}{page}{topic}{subtopic}
5571 % The texindex program reads in these files and writes files
5572 % containing these kinds of lines:
5573 %  \initial {c}
5574 %     before the first topic whose initial is c
5575 %  \entry {topic}{pagelist}
5576 %     for a topic that is used without subtopics
5577 %  \primary {topic}
5578 %  \entry {topic}{}
5579 %     for the beginning of a topic that is used with subtopics
5580 %  \secondary {subtopic}{pagelist}
5581 %     for each subtopic.
5582 %  \secondary {subtopic}{}
5583 %     for a subtopic with sub-subtopics
5584 %  \tertiary {subtopic}{subsubtopic}{pagelist}
5585 %     for each sub-subtopic.
5586
5587 % Define the user-accessible indexing commands
5588 % @findex, @vindex, @kindex, @cindex.
5589
5590 \def\findex {\fnindex}
5591 \def\kindex {\kyindex}
5592 \def\cindex {\cpindex}
5593 \def\vindex {\vrindex}
5594 \def\tindex {\tpindex}
5595 \def\pindex {\pgindex}
5596
5597 % Define the macros used in formatting output of the sorted index material.
5598
5599 % @printindex causes a particular index (the ??s file) to get printed.
5600 % It does not print any chapter heading (usually an @unnumbered).
5601 %
5602 \parseargdef\printindex{\begingroup
5603   \dobreak \chapheadingskip{10000}%
5604   %
5605   \smallfonts \rm
5606   \tolerance = 9500
5607   \plainfrenchspacing
5608   \everypar = {}% don't want the \kern\-parindent from indentation suppression.
5609   %
5610   % See comment in \requireopenindexfile.
5611   \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
5612   %
5613   % See if the index file exists and is nonempty.
5614   \openin 1 \jobname.\indexname s
5615   \ifeof 1
5616     % \enddoublecolumns gets confused if there is no text in the index,
5617     % and it loses the chapter title and the aux file entries for the
5618     % index.  The easiest way to prevent this problem is to make sure
5619     % there is some text.
5620     \putwordIndexNonexistent
5621     \typeout{No file \jobname.\indexname s.}%
5622   \else
5623     % If the index file exists but is empty, then \openin leaves \ifeof
5624     % false.  We have to make TeX try to read something from the file, so
5625     % it can discover if there is anything in it.
5626     \read 1 to \thisline
5627     \ifeof 1
5628       \putwordIndexIsEmpty
5629     \else
5630       \expandafter\printindexzz\thisline\relax\relax\finish%
5631     \fi
5632   \fi
5633   \closein 1
5634 \endgroup}
5635
5636 % If the index file starts with a backslash, forgo reading the index
5637 % file altogether.  If somebody upgrades texinfo.tex they may still have
5638 % old index files using \ as the escape character.  Reading this would
5639 % at best lead to typesetting garbage, at worst a TeX syntax error.
5640 \def\printindexzz#1#2\finish{%
5641   \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax
5642     \uccode`\~=`\\ \uppercase{\if\noexpand~}\noexpand#1
5643       \expandafter\ifx\csname SETtxiskipindexfileswithbackslash\endcsname\relax
5644 \errmessage{%
5645 ERROR: A sorted index file in an obsolete format was skipped.
5646 To fix this problem, please upgrade your version of 'texi2dvi'
5647 or 'texi2pdf' to that at <https://ftp.gnu.org/gnu/texinfo>.
5648 If you are using an old version of 'texindex' (part of the Texinfo
5649 distribution), you may also need to upgrade to a newer version (at least 6.0).
5650 You may be able to typeset the index if you run
5651 'texindex \jobname.\indexname' yourself.
5652 You could also try setting the 'txiindexescapeisbackslash' flag by
5653 running a command like
5654 'texi2dvi -t "@set txiindexescapeisbackslash" \jobname.texi'.  If you do
5655 this, Texinfo will try to use index files in the old format.
5656 If you continue to have problems, deleting the index files and starting again
5657 might help (with 'rm \jobname.?? \jobname.??s')%
5658 }%
5659       \else
5660         (Skipped sorted index file in obsolete format)
5661       \fi
5662     \else
5663       \begindoublecolumns
5664       \input \jobname.\indexname s
5665       \enddoublecolumns
5666     \fi
5667   \else
5668     \begindoublecolumns
5669     \catcode`\\=0\relax
5670     %
5671     % Make @ an escape character to give macros a chance to work.  This
5672     % should work because we (hopefully) don't otherwise use @ in index files.
5673     %\catcode`\@=12\relax
5674     \catcode`\@=0\relax
5675     \input \jobname.\indexname s
5676     \enddoublecolumns
5677   \fi
5678 }
5679
5680 % These macros are used by the sorted index file itself.
5681 % Change them to control the appearance of the index.
5682
5683 {\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
5684 \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
5685 \catcode`\$=3
5686 \gdef\initialglyphs{%
5687   % special control sequences used in the index sort key
5688   \let\indexlbrace\{%
5689   \let\indexrbrace\}%
5690   \let\indexatchar\@%
5691   \def\indexbackslash{\math{\backslash}}%
5692   %
5693   % Some changes for non-alphabetic characters.  Using the glyphs from the
5694   % math fonts looks more consistent than the typewriter font used elsewhere
5695   % for these characters.
5696   \uccode`\~=`\\ \uppercase{\def~{\math{\backslash}}}
5697   %
5698   % In case @\ is used for backslash
5699   \uppercase{\let\\=~}
5700   % Can't get bold backslash so don't use bold forward slash
5701   \catcode`\/=13
5702   \def/{{\secrmnotbold \normalslash}}%
5703   \def-{{\normaldash\normaldash}}% en dash `--'
5704   \def^{{\chapbf \normalcaret}}%
5705   \def~{{\chapbf \normaltilde}}%
5706   \def\_{%
5707      \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
5708   \def|{$\vert$}%
5709   \def<{$\less$}%
5710   \def>{$\gtr$}%
5711   \def+{$\normalplus$}%
5712 }}
5713
5714 \def\initial{%
5715   \bgroup
5716   \initialglyphs
5717   \initialx
5718 }
5719
5720 \def\initialx#1{%
5721   % Remove any glue we may have, we'll be inserting our own.
5722   \removelastskip
5723   %
5724   % We like breaks before the index initials, so insert a bonus.
5725   % The glue before the bonus allows a little bit of space at the
5726   % bottom of a column to reduce an increase in inter-line spacing.
5727   \nobreak
5728   \vskip 0pt plus 5\baselineskip
5729   \penalty -300
5730   \vskip 0pt plus -5\baselineskip
5731   %
5732   % Typeset the initial.  Making this add up to a whole number of
5733   % baselineskips increases the chance of the dots lining up from column
5734   % to column.  It still won't often be perfect, because of the stretch
5735   % we need before each entry, but it's better.
5736   %
5737   % No shrink because it confuses \balancecolumns.
5738   \vskip 1.67\baselineskip plus 1\baselineskip
5739   \leftline{\secfonts \kern-0.05em \secbf #1}%
5740   % \secfonts is inside the argument of \leftline so that the change of
5741   % \baselineskip will not affect any glue inserted before the vbox that
5742   % \leftline creates.
5743   % Do our best not to break after the initial.
5744   \nobreak
5745   \vskip .33\baselineskip plus .1\baselineskip
5746   \egroup % \initialglyphs
5747 }
5748
5749 \newdimen\entryrightmargin
5750 \entryrightmargin=0pt
5751
5752 % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
5753 % then page number (#2) flushed to the right margin.  It is used for index
5754 % and table of contents entries.  The paragraph is indented by \leftskip.
5755 %
5756 \def\entry{%
5757   \begingroup
5758     %
5759     % Start a new paragraph if necessary, so our assignments below can't
5760     % affect previous text.
5761     \par
5762     %
5763     % No extra space above this paragraph.
5764     \parskip = 0in
5765     %
5766     % When reading the text of entry, convert explicit line breaks
5767     % from @* into spaces.  The user might give these in long section
5768     % titles, for instance.
5769     \def\*{\unskip\space\ignorespaces}%
5770     \def\entrybreak{\hfil\break}% An undocumented command
5771     %
5772     % Swallow the left brace of the text (first parameter):
5773     \afterassignment\doentry
5774     \let\temp =
5775 }
5776 \def\entrybreak{\unskip\space\ignorespaces}%
5777 \def\doentry{%
5778     % Save the text of the entry
5779     \global\setbox\boxA=\hbox\bgroup
5780     \bgroup % Instead of the swallowed brace.
5781       \noindent
5782       \aftergroup\finishentry
5783       % And now comes the text of the entry.
5784       % Not absorbing as a macro argument reduces the chance of problems
5785       % with catcodes occurring.
5786 }
5787 {\catcode`\@=11
5788 \gdef\finishentry#1{%
5789     \egroup % end box A
5790     \dimen@ = \wd\boxA % Length of text of entry
5791     \global\setbox\boxA=\hbox\bgroup
5792       \unhbox\boxA
5793       % #1 is the page number.
5794       %
5795       % Get the width of the page numbers, and only use
5796       % leaders if they are present.
5797       \global\setbox\boxB = \hbox{#1}%
5798       \ifdim\wd\boxB = 0pt
5799         \null\nobreak\hfill\ %
5800       \else
5801         %
5802         \null\nobreak\indexdotfill % Have leaders before the page number.
5803         %
5804         \ifpdforxetex
5805           \pdfgettoks#1.%
5806           \hskip\skip\thinshrinkable\the\toksA
5807         \else
5808           \hskip\skip\thinshrinkable #1%
5809         \fi
5810       \fi
5811     \egroup % end \boxA
5812     \ifdim\wd\boxB = 0pt
5813       \noindent\unhbox\boxA\par
5814       \nobreak
5815     \else\bgroup
5816       % We want the text of the entries to be aligned to the left, and the
5817       % page numbers to be aligned to the right.
5818       %
5819       \parindent = 0pt
5820       \advance\leftskip by 0pt plus 1fil
5821       \advance\leftskip by 0pt plus -1fill
5822       \rightskip = 0pt plus -1fil
5823       \advance\rightskip by 0pt plus 1fill
5824       % Cause last line, which could consist of page numbers on their own
5825       % if the list of page numbers is long, to be aligned to the right.
5826       \parfillskip=0pt plus -1fill
5827       %
5828       \advance\rightskip by \entryrightmargin
5829       % Determine how far we can stretch into the margin.
5830       % This allows, e.g., "Appendix H  GNU Free Documentation License" to
5831       % fit on one line in @letterpaper format.
5832       \ifdim\entryrightmargin>2.1em
5833         \dimen@i=2.1em
5834       \else
5835         \dimen@i=0em
5836       \fi
5837       \advance \parfillskip by 0pt minus 1\dimen@i
5838       %
5839       \dimen@ii = \hsize
5840       \advance\dimen@ii by -1\leftskip
5841       \advance\dimen@ii by -1\entryrightmargin
5842       \advance\dimen@ii by 1\dimen@i
5843       \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
5844       \ifdim\dimen@ > 0.8\dimen@ii   % due to long index text
5845         % Try to split the text roughly evenly.  \dimen@ will be the length of
5846         % the first line.
5847         \dimen@ = 0.7\dimen@
5848         \dimen@ii = \hsize
5849         \ifnum\dimen@>\dimen@ii
5850           % If the entry is too long (for example, if it needs more than
5851           % two lines), use all the space in the first line.
5852           \dimen@ = \dimen@ii
5853         \fi
5854         \advance\leftskip by 0pt plus 1fill % ragged right
5855         \advance \dimen@ by 1\rightskip
5856         \parshape = 2 0pt \dimen@ 0em \dimen@ii
5857         % Ideally we'd add a finite glue at the end of the first line only,
5858         % instead of using \parshape with explicit line lengths, but TeX
5859         % doesn't seem to provide a way to do such a thing.
5860         %
5861         % Indent all lines but the first one.
5862         \advance\leftskip by 1em
5863         \advance\parindent by -1em
5864       \fi\fi
5865       \indent % start paragraph
5866       \unhbox\boxA
5867       %
5868       % Do not prefer a separate line ending with a hyphen to fewer lines.
5869       \finalhyphendemerits = 0
5870       %
5871       % Word spacing - no stretch
5872       \spaceskip=\fontdimen2\font minus \fontdimen4\font
5873       %
5874       \linepenalty=1000  % Discourage line breaks.
5875       \hyphenpenalty=5000  % Discourage hyphenation.
5876       %
5877       \par % format the paragraph
5878     \egroup % The \vbox
5879     \fi
5880   \endgroup
5881 }}
5882
5883 \newskip\thinshrinkable
5884 \skip\thinshrinkable=.15em minus .15em
5885
5886 % Like plain.tex's \dotfill, except uses up at least 1 em.
5887 % The filll stretch here overpowers both the fil and fill stretch to push
5888 % the page number to the right.
5889 \def\indexdotfill{\cleaders
5890   \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
5891
5892
5893 \def\primary #1{\line{#1\hfil}}
5894
5895 \def\secondary{\indententry{0.5cm}}
5896 \def\tertiary{\indententry{1cm}}
5897
5898 \def\indententry#1#2#3{%
5899   \bgroup
5900   \leftskip=#1
5901   \entry{#2}{#3}%
5902   \egroup
5903 }
5904
5905 % Define two-column mode, which we use to typeset indexes.
5906 % Adapted from the TeXbook, page 416, which is to say,
5907 % the manmac.tex format used to print the TeXbook itself.
5908 \catcode`\@=11  % private names
5909
5910 \newbox\partialpage
5911 \newdimen\doublecolumnhsize
5912
5913 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
5914   % If not much space left on page, start a new page.
5915   \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
5916   %
5917   % Grab any single-column material above us.
5918   \output = {%
5919     \savetopmark
5920     %
5921     \global\setbox\partialpage = \vbox{%
5922       % Unvbox the main output page.
5923       \unvbox\PAGE
5924       \kern-\topskip \kern\baselineskip
5925     }%
5926   }%
5927   \eject % run that output routine to set \partialpage
5928   %
5929   % Use the double-column output routine for subsequent pages.
5930   \output = {\doublecolumnout}%
5931   %
5932   % Change the page size parameters.  We could do this once outside this
5933   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5934   % format, but then we repeat the same computation.  Repeating a couple
5935   % of assignments once per index is clearly meaningless for the
5936   % execution time, so we may as well do it in one place.
5937   %
5938   % First we halve the line length, less a little for the gutter between
5939   % the columns.  We compute the gutter based on the line length, so it
5940   % changes automatically with the paper format.  The magic constant
5941   % below is chosen so that the gutter has the same value (well, +-<1pt)
5942   % as it did when we hard-coded it.
5943   %
5944   % We put the result in a separate register, \doublecolumhsize, so we
5945   % can restore it in \pagesofar, after \hsize itself has (potentially)
5946   % been clobbered.
5947   %
5948   \doublecolumnhsize = \hsize
5949     \advance\doublecolumnhsize by -.04154\hsize
5950     \divide\doublecolumnhsize by 2
5951   \hsize = \doublecolumnhsize
5952   %
5953   % Get the available space for the double columns -- the normal
5954   % (undoubled) page height minus any material left over from the
5955   % previous page.
5956   \advance\vsize by -\ht\partialpage
5957   \vsize = 2\vsize
5958   %
5959   % For the benefit of balancing columns
5960   \advance\baselineskip by 0pt plus 0.5pt
5961 }
5962
5963 % The double-column output routine for all double-column pages except
5964 % the last, which is done by \balancecolumns.
5965 %
5966 \def\doublecolumnout{%
5967   %
5968   \savetopmark
5969   \splittopskip=\topskip \splitmaxdepth=\maxdepth
5970   \dimen@ = \vsize
5971   \divide\dimen@ by 2
5972   %
5973   % box0 will be the left-hand column, box2 the right.
5974   \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@
5975   \global\advance\vsize by 2\ht\partialpage
5976   \onepageout\pagesofar % empty except for the first time we are called
5977   \unvbox\PAGE
5978   \penalty\outputpenalty
5979 }
5980 %
5981 % Re-output the contents of the output page -- any previous material,
5982 % followed by the two boxes we just split, in box0 and box2.
5983 \def\pagesofar{%
5984   \unvbox\partialpage
5985   %
5986   \hsize = \doublecolumnhsize
5987   \wd0=\hsize \wd2=\hsize
5988   \hbox to\txipagewidth{\box0\hfil\box2}%
5989 }
5990
5991
5992 % Finished with double columns.
5993 \def\enddoublecolumns{%
5994   % The following penalty ensures that the page builder is exercised
5995   % _before_ we change the output routine.  This is necessary in the
5996   % following situation:
5997   %
5998   % The last section of the index consists only of a single entry.
5999   % Before this section, \pagetotal is less than \pagegoal, so no
6000   % break occurs before the last section starts.  However, the last
6001   % section, consisting of \initial and the single \entry, does not
6002   % fit on the page and has to be broken off.  Without the following
6003   % penalty the page builder will not be exercised until \eject
6004   % below, and by that time we'll already have changed the output
6005   % routine to the \balancecolumns version, so the next-to-last
6006   % double-column page will be processed with \balancecolumns, which
6007   % is wrong:  The two columns will go to the main vertical list, with
6008   % the broken-off section in the recent contributions.  As soon as
6009   % the output routine finishes, TeX starts reconsidering the page
6010   % break.  The two columns and the broken-off section both fit on the
6011   % page, because the two columns now take up only half of the page
6012   % goal.  When TeX sees \eject from below which follows the final
6013   % section, it invokes the new output routine that we've set after
6014   % \balancecolumns below; \onepageout will try to fit the two columns
6015   % and the final section into the vbox of \txipageheight (see
6016   % \pagebody), causing an overfull box.
6017   %
6018   % Note that glue won't work here, because glue does not exercise the
6019   % page builder, unlike penalties (see The TeXbook, pp. 280-281).
6020   \penalty0
6021   %
6022   \output = {%
6023     % Split the last of the double-column material.
6024     \savetopmark
6025     \balancecolumns
6026   }%
6027   \eject % call the \output just set
6028   \ifdim\pagetotal=0pt
6029     % Having called \balancecolumns once, we do not
6030     % want to call it again.  Therefore, reset \output to its normal
6031     % definition right away.
6032     \global\output=\expandafter{\the\defaultoutput}
6033     %
6034     \endgroup % started in \begindoublecolumns
6035     % Leave the double-column material on the current page, no automatic
6036     % page break.
6037     \box\balancedcolumns
6038     %
6039     % \pagegoal was set to the doubled \vsize above, since we restarted
6040     % the current page.  We're now back to normal single-column
6041     % typesetting, so reset \pagegoal to the normal \vsize.
6042     \global\vsize = \txipageheight %
6043     \pagegoal = \txipageheight %
6044   \else
6045     % We had some left-over material.  This might happen when \doublecolumnout
6046     % is called in \balancecolumns.  Try again.
6047     \expandafter\enddoublecolumns
6048   \fi
6049 }
6050 \newbox\balancedcolumns
6051 \setbox\balancedcolumns=\vbox{shouldnt see this}%
6052 %
6053 % Only called for the last of the double column material.  \doublecolumnout
6054 % does the others.
6055 \def\balancecolumns{%
6056   \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120.
6057   \dimen@ = \ht0
6058   \ifdim\dimen@<7\baselineskip
6059     % Don't split a short final column in two.
6060     \setbox2=\vbox{}%
6061     \global\setbox\balancedcolumns=\vbox{\pagesofar}%
6062   \else
6063     % double the leading vertical space
6064     \advance\dimen@ by \topskip
6065     \advance\dimen@ by-\baselineskip
6066     \divide\dimen@ by 2 % target to split to
6067     \dimen@ii = \dimen@
6068     \splittopskip = \topskip
6069     % Loop until left column is at least as high as the right column.
6070     {%
6071       \vbadness = 10000
6072       \loop
6073         \global\setbox3 = \copy0
6074         \global\setbox1 = \vsplit3 to \dimen@
6075       \ifdim\ht1<\ht3
6076         \global\advance\dimen@ by 1pt
6077       \repeat
6078     }%
6079     % Now the left column is in box 1, and the right column in box 3.
6080     %
6081     % Check whether the left column has come out higher than the page itself.
6082     % (Note that we have doubled \vsize for the double columns, so
6083     % the actual height of the page is 0.5\vsize).
6084     \ifdim2\ht1>\vsize
6085       % It appears that we have been called upon to balance too much material.
6086       % Output some of it with \doublecolumnout, leaving the rest on the page.
6087       \setbox\PAGE=\box0
6088       \doublecolumnout
6089     \else
6090       % Compare the heights of the two columns.
6091       \ifdim4\ht1>5\ht3
6092         % Column heights are too different, so don't make their bottoms
6093         % flush with each other.
6094         \setbox2=\vbox to \ht1 {\unvbox3\vfill}%
6095         \setbox0=\vbox to \ht1 {\unvbox1\vfill}%
6096       \else
6097         % Make column bottoms flush with each other.
6098         \setbox2=\vbox to\ht1{\unvbox3\unskip}%
6099         \setbox0=\vbox to\ht1{\unvbox1\unskip}%
6100       \fi
6101       \global\setbox\balancedcolumns=\vbox{\pagesofar}%
6102     \fi
6103   \fi
6104   %
6105 }
6106 \catcode`\@ = \other
6107
6108
6109 \message{sectioning,}
6110 % Chapters, sections, etc.
6111
6112 % Let's start with @part.
6113 \outer\parseargdef\part{\partzzz{#1}}
6114 \def\partzzz#1{%
6115   \chapoddpage
6116   \null
6117   \vskip.3\vsize  % move it down on the page a bit
6118   \begingroup
6119     \noindent \titlefonts\rm #1\par % the text
6120     \let\lastnode=\empty      % no node to associate with
6121     \writetocentry{part}{#1}{}% but put it in the toc
6122     \headingsoff              % no headline or footline on the part page
6123     % This outputs a mark at the end of the page that clears \thischapter
6124     % and \thissection, as is done in \startcontents.
6125     \let\pchapsepmacro\relax
6126     \chapmacro{}{Yomitfromtoc}{}%
6127     \chapoddpage
6128   \endgroup
6129 }
6130
6131 % \unnumberedno is an oxymoron.  But we count the unnumbered
6132 % sections so that we can refer to them unambiguously in the pdf
6133 % outlines by their "section number".  We avoid collisions with chapter
6134 % numbers by starting them at 10000.  (If a document ever has 10000
6135 % chapters, we're in trouble anyway, I'm sure.)
6136 \newcount\unnumberedno \unnumberedno = 10000
6137 \newcount\chapno
6138 \newcount\secno        \secno=0
6139 \newcount\subsecno     \subsecno=0
6140 \newcount\subsubsecno  \subsubsecno=0
6141
6142 % This counter is funny since it counts through charcodes of letters A, B, ...
6143 \newcount\appendixno  \appendixno = `\@
6144 %
6145 % \def\appendixletter{\char\the\appendixno}
6146 % We do the following ugly conditional instead of the above simple
6147 % construct for the sake of pdftex, which needs the actual
6148 % letter in the expansion, not just typeset.
6149 %
6150 \def\appendixletter{%
6151   \ifnum\appendixno=`A A%
6152   \else\ifnum\appendixno=`B B%
6153   \else\ifnum\appendixno=`C C%
6154   \else\ifnum\appendixno=`D D%
6155   \else\ifnum\appendixno=`E E%
6156   \else\ifnum\appendixno=`F F%
6157   \else\ifnum\appendixno=`G G%
6158   \else\ifnum\appendixno=`H H%
6159   \else\ifnum\appendixno=`I I%
6160   \else\ifnum\appendixno=`J J%
6161   \else\ifnum\appendixno=`K K%
6162   \else\ifnum\appendixno=`L L%
6163   \else\ifnum\appendixno=`M M%
6164   \else\ifnum\appendixno=`N N%
6165   \else\ifnum\appendixno=`O O%
6166   \else\ifnum\appendixno=`P P%
6167   \else\ifnum\appendixno=`Q Q%
6168   \else\ifnum\appendixno=`R R%
6169   \else\ifnum\appendixno=`S S%
6170   \else\ifnum\appendixno=`T T%
6171   \else\ifnum\appendixno=`U U%
6172   \else\ifnum\appendixno=`V V%
6173   \else\ifnum\appendixno=`W W%
6174   \else\ifnum\appendixno=`X X%
6175   \else\ifnum\appendixno=`Y Y%
6176   \else\ifnum\appendixno=`Z Z%
6177   % The \the is necessary, despite appearances, because \appendixletter is
6178   % expanded while writing the .toc file.  \char\appendixno is not
6179   % expandable, thus it is written literally, thus all appendixes come out
6180   % with the same letter (or @) in the toc without it.
6181   \else\char\the\appendixno
6182   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
6183   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
6184
6185 % Each @chapter defines these (using marks) as the number+name, number
6186 % and name of the chapter.  Page headings and footings can use
6187 % these.  @section does likewise.
6188 \def\thischapter{}
6189 \def\thischapternum{}
6190 \def\thischaptername{}
6191 \def\thissection{}
6192 \def\thissectionnum{}
6193 \def\thissectionname{}
6194
6195 \newcount\absseclevel % used to calculate proper heading level
6196 \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
6197
6198 % @raisesections: treat @section as chapter, @subsection as section, etc.
6199 \def\raisesections{\global\advance\secbase by -1}
6200
6201 % @lowersections: treat @chapter as section, @section as subsection, etc.
6202 \def\lowersections{\global\advance\secbase by 1}
6203
6204 % we only have subsub.
6205 \chardef\maxseclevel = 3
6206 %
6207 % A numbered section within an unnumbered changes to unnumbered too.
6208 % To achieve this, remember the "biggest" unnum. sec. we are currently in:
6209 \chardef\unnlevel = \maxseclevel
6210 %
6211 % Trace whether the current chapter is an appendix or not:
6212 % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
6213 \def\chapheadtype{N}
6214
6215 % Choose a heading macro
6216 % #1 is heading type
6217 % #2 is heading level
6218 % #3 is text for heading
6219 \def\genhead#1#2#3{%
6220   % Compute the abs. sec. level:
6221   \absseclevel=#2
6222   \advance\absseclevel by \secbase
6223   % Make sure \absseclevel doesn't fall outside the range:
6224   \ifnum \absseclevel < 0
6225     \absseclevel = 0
6226   \else
6227     \ifnum \absseclevel > 3
6228       \absseclevel = 3
6229     \fi
6230   \fi
6231   % The heading type:
6232   \def\headtype{#1}%
6233   \if \headtype U%
6234     \ifnum \absseclevel < \unnlevel
6235       \chardef\unnlevel = \absseclevel
6236     \fi
6237   \else
6238     % Check for appendix sections:
6239     \ifnum \absseclevel = 0
6240       \edef\chapheadtype{\headtype}%
6241     \else
6242       \if \headtype A\if \chapheadtype N%
6243         \errmessage{@appendix... within a non-appendix chapter}%
6244       \fi\fi
6245     \fi
6246     % Check for numbered within unnumbered:
6247     \ifnum \absseclevel > \unnlevel
6248       \def\headtype{U}%
6249     \else
6250       \chardef\unnlevel = 3
6251     \fi
6252   \fi
6253   % Now print the heading:
6254   \if \headtype U%
6255     \ifcase\absseclevel
6256         \unnumberedzzz{#3}%
6257     \or \unnumberedseczzz{#3}%
6258     \or \unnumberedsubseczzz{#3}%
6259     \or \unnumberedsubsubseczzz{#3}%
6260     \fi
6261   \else
6262     \if \headtype A%
6263       \ifcase\absseclevel
6264           \appendixzzz{#3}%
6265       \or \appendixsectionzzz{#3}%
6266       \or \appendixsubseczzz{#3}%
6267       \or \appendixsubsubseczzz{#3}%
6268       \fi
6269     \else
6270       \ifcase\absseclevel
6271           \chapterzzz{#3}%
6272       \or \seczzz{#3}%
6273       \or \numberedsubseczzz{#3}%
6274       \or \numberedsubsubseczzz{#3}%
6275       \fi
6276     \fi
6277   \fi
6278   \suppressfirstparagraphindent
6279 }
6280
6281 % an interface:
6282 \def\numhead{\genhead N}
6283 \def\apphead{\genhead A}
6284 \def\unnmhead{\genhead U}
6285
6286 % @chapter, @appendix, @unnumbered.  Increment top-level counter, reset
6287 % all lower-level sectioning counters to zero.
6288 %
6289 % Also set \chaplevelprefix, which we prepend to @float sequence numbers
6290 % (e.g., figures), q.v.  By default (before any chapter), that is empty.
6291 \let\chaplevelprefix = \empty
6292 %
6293 \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
6294 \def\chapterzzz#1{%
6295   % section resetting is \global in case the chapter is in a group, such
6296   % as an @include file.
6297   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6298     \global\advance\chapno by 1
6299   %
6300   % Used for \float.
6301   \gdef\chaplevelprefix{\the\chapno.}%
6302   \resetallfloatnos
6303   %
6304   % \putwordChapter can contain complex things in translations.
6305   \toks0=\expandafter{\putwordChapter}%
6306   \message{\the\toks0 \space \the\chapno}%
6307   %
6308   % Write the actual heading.
6309   \chapmacro{#1}{Ynumbered}{\the\chapno}%
6310   %
6311   % So @section and the like are numbered underneath this chapter.
6312   \global\let\section = \numberedsec
6313   \global\let\subsection = \numberedsubsec
6314   \global\let\subsubsection = \numberedsubsubsec
6315 }
6316
6317 \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
6318 %
6319 \def\appendixzzz#1{%
6320   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6321     \global\advance\appendixno by 1
6322   \gdef\chaplevelprefix{\appendixletter.}%
6323   \resetallfloatnos
6324   %
6325   % \putwordAppendix can contain complex things in translations.
6326   \toks0=\expandafter{\putwordAppendix}%
6327   \message{\the\toks0 \space \appendixletter}%
6328   %
6329   \chapmacro{#1}{Yappendix}{\appendixletter}%
6330   %
6331   \global\let\section = \appendixsec
6332   \global\let\subsection = \appendixsubsec
6333   \global\let\subsubsection = \appendixsubsubsec
6334 }
6335
6336 % normally unnmhead0 calls unnumberedzzz:
6337 \outer\parseargdef\unnumbered{\unnmhead0{#1}}
6338 \def\unnumberedzzz#1{%
6339   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6340     \global\advance\unnumberedno by 1
6341   %
6342   % Since an unnumbered has no number, no prefix for figures.
6343   \global\let\chaplevelprefix = \empty
6344   \resetallfloatnos
6345   %
6346   % This used to be simply \message{#1}, but TeX fully expands the
6347   % argument to \message.  Therefore, if #1 contained @-commands, TeX
6348   % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
6349   % expanded @cite (which turns out to cause errors because \cite is meant
6350   % to be executed, not expanded).
6351   %
6352   % Anyway, we don't want the fully-expanded definition of @cite to appear
6353   % as a result of the \message, we just want `@cite' itself.  We use
6354   % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6355   % simply yielding the contents of <toks register>.  (We also do this for
6356   % the toc entries.)
6357   \toks0 = {#1}%
6358   \message{(\the\toks0)}%
6359   %
6360   \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
6361   %
6362   \global\let\section = \unnumberedsec
6363   \global\let\subsection = \unnumberedsubsec
6364   \global\let\subsubsection = \unnumberedsubsubsec
6365 }
6366
6367 % @centerchap is like @unnumbered, but the heading is centered.
6368 \outer\parseargdef\centerchap{%
6369   \let\centerparametersmaybe = \centerparameters
6370   \unnmhead0{#1}%
6371   \let\centerparametersmaybe = \relax
6372 }
6373
6374 % @top is like @unnumbered.
6375 \let\top\unnumbered
6376
6377 % Sections.
6378 %
6379 \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6380 \def\seczzz#1{%
6381   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6382   \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
6383 }
6384
6385 % normally calls appendixsectionzzz:
6386 \outer\parseargdef\appendixsection{\apphead1{#1}}
6387 \def\appendixsectionzzz#1{%
6388   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6389   \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
6390 }
6391 \let\appendixsec\appendixsection
6392
6393 % normally calls unnumberedseczzz:
6394 \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
6395 \def\unnumberedseczzz#1{%
6396   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6397   \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
6398 }
6399
6400 % Subsections.
6401 %
6402 % normally calls numberedsubseczzz:
6403 \outer\parseargdef\numberedsubsec{\numhead2{#1}}
6404 \def\numberedsubseczzz#1{%
6405   \global\subsubsecno=0  \global\advance\subsecno by 1
6406   \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
6407 }
6408
6409 % normally calls appendixsubseczzz:
6410 \outer\parseargdef\appendixsubsec{\apphead2{#1}}
6411 \def\appendixsubseczzz#1{%
6412   \global\subsubsecno=0  \global\advance\subsecno by 1
6413   \sectionheading{#1}{subsec}{Yappendix}%
6414                  {\appendixletter.\the\secno.\the\subsecno}%
6415 }
6416
6417 % normally calls unnumberedsubseczzz:
6418 \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
6419 \def\unnumberedsubseczzz#1{%
6420   \global\subsubsecno=0  \global\advance\subsecno by 1
6421   \sectionheading{#1}{subsec}{Ynothing}%
6422                  {\the\unnumberedno.\the\secno.\the\subsecno}%
6423 }
6424
6425 % Subsubsections.
6426 %
6427 % normally numberedsubsubseczzz:
6428 \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
6429 \def\numberedsubsubseczzz#1{%
6430   \global\advance\subsubsecno by 1
6431   \sectionheading{#1}{subsubsec}{Ynumbered}%
6432                  {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
6433 }
6434
6435 % normally appendixsubsubseczzz:
6436 \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
6437 \def\appendixsubsubseczzz#1{%
6438   \global\advance\subsubsecno by 1
6439   \sectionheading{#1}{subsubsec}{Yappendix}%
6440                  {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
6441 }
6442
6443 % normally unnumberedsubsubseczzz:
6444 \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
6445 \def\unnumberedsubsubseczzz#1{%
6446   \global\advance\subsubsecno by 1
6447   \sectionheading{#1}{subsubsec}{Ynothing}%
6448                  {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
6449 }
6450
6451 % These macros control what the section commands do, according
6452 % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6453 % Define them by default for a numbered chapter.
6454 \let\section = \numberedsec
6455 \let\subsection = \numberedsubsec
6456 \let\subsubsection = \numberedsubsubsec
6457
6458 % Define @majorheading, @heading and @subheading
6459
6460 \def\majorheading{%
6461   {\advance\chapheadingskip by 10pt \chapbreak }%
6462   \parsearg\chapheadingzzz
6463 }
6464
6465 \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6466 \def\chapheadingzzz#1{%
6467   \vbox{\chapfonts \raggedtitlesettings #1\par}%
6468   \nobreak\bigskip \nobreak
6469   \suppressfirstparagraphindent
6470 }
6471
6472 % @heading, @subheading, @subsubheading.
6473 \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6474   \suppressfirstparagraphindent}
6475 \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6476   \suppressfirstparagraphindent}
6477 \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6478   \suppressfirstparagraphindent}
6479
6480 % These macros generate a chapter, section, etc. heading only
6481 % (including whitespace, linebreaking, etc. around it),
6482 % given all the information in convenient, parsed form.
6483
6484 % Args are the skip and penalty (usually negative)
6485 \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6486
6487 % Parameter controlling skip before chapter headings (if needed)
6488 \newskip\chapheadingskip
6489
6490 % Define plain chapter starts, and page on/off switching for it.
6491 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
6492
6493 % Start a new page
6494 \def\chappager{\par\vfill\supereject}
6495
6496 % \chapoddpage - start on an odd page for a new chapter
6497 % Because \domark is called before \chapoddpage, the filler page will
6498 % get the headings for the next chapter, which is wrong.  But we don't
6499 % care -- we just disable all headings on the filler page.
6500 \def\chapoddpage{%
6501   \chappager
6502   \ifodd\pageno \else
6503     \begingroup
6504       \headingsoff
6505       \null
6506       \chappager
6507     \endgroup
6508   \fi
6509 }
6510
6511 \parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
6512
6513 \def\CHAPPAGoff{%
6514 \global\let\contentsalignmacro = \chappager
6515 \global\let\pchapsepmacro=\chapbreak
6516 \global\def\HEADINGSon{\HEADINGSsinglechapoff}}
6517
6518 \def\CHAPPAGon{%
6519 \global\let\contentsalignmacro = \chappager
6520 \global\let\pchapsepmacro=\chappager
6521 \global\def\HEADINGSon{\HEADINGSsingle}}
6522
6523 \def\CHAPPAGodd{%
6524 \global\let\contentsalignmacro = \chapoddpage
6525 \global\let\pchapsepmacro=\chapoddpage
6526 \global\def\HEADINGSon{\HEADINGSdouble}}
6527
6528 \CHAPPAGon
6529
6530 % \chapmacro - Chapter opening.
6531 %
6532 % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6533 % Yappendix, Yomitfromtoc), #3 the chapter number.
6534 % Not used for @heading series.
6535 %
6536 % To test against our argument.
6537 \def\Ynothingkeyword{Ynothing}
6538 \def\Yappendixkeyword{Yappendix}
6539 \def\Yomitfromtockeyword{Yomitfromtoc}
6540 %
6541 \def\chapmacro#1#2#3{%
6542   \expandafter\ifx\thisenv\titlepage\else
6543     \checkenv{}% chapters, etc., should not start inside an environment.
6544   \fi
6545   % Insert the first mark before the heading break (see notes for \domark).
6546   \let\prevchapterdefs=\currentchapterdefs
6547   \let\prevsectiondefs=\currentsectiondefs
6548   \gdef\currentsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6549                         \gdef\thissection{}}%
6550   %
6551   \def\temptype{#2}%
6552   \ifx\temptype\Ynothingkeyword
6553     \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6554                           \gdef\thischapter{\thischaptername}}%
6555   \else\ifx\temptype\Yomitfromtockeyword
6556     \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6557                           \gdef\thischapter{}}%
6558   \else\ifx\temptype\Yappendixkeyword
6559     \toks0={#1}%
6560     \xdef\currentchapterdefs{%
6561       \gdef\noexpand\thischaptername{\the\toks0}%
6562       \gdef\noexpand\thischapternum{\appendixletter}%
6563       % \noexpand\putwordAppendix avoids expanding indigestible
6564       % commands in some of the translations.
6565       \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
6566                                  \noexpand\thischapternum:
6567                                  \noexpand\thischaptername}%
6568     }%
6569   \else
6570     \toks0={#1}%
6571     \xdef\currentchapterdefs{%
6572       \gdef\noexpand\thischaptername{\the\toks0}%
6573       \gdef\noexpand\thischapternum{\the\chapno}%
6574       % \noexpand\putwordChapter avoids expanding indigestible
6575       % commands in some of the translations.
6576       \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
6577                                  \noexpand\thischapternum:
6578                                  \noexpand\thischaptername}%
6579     }%
6580   \fi\fi\fi
6581   %
6582   % Output the mark.  Pass it through \safewhatsit, to take care of
6583   % the preceding space.
6584   \safewhatsit\domark
6585   %
6586   % Insert the chapter heading break.
6587   \pchapsepmacro
6588   %
6589   % Now the second mark, after the heading break.  No break points
6590   % between here and the heading.
6591   \let\prevchapterdefs=\currentchapterdefs
6592   \let\prevsectiondefs=\currentsectiondefs
6593   \domark
6594   %
6595   {%
6596     \chapfonts \rm
6597     \let\footnote=\errfootnoteheading % give better error message
6598     %
6599     % Have to define \currentsection before calling \donoderef, because the
6600     % xref code eventually uses it.  On the other hand, it has to be called
6601     % after \pchapsepmacro, or the headline will change too soon.
6602     \gdef\currentsection{#1}%
6603     %
6604     % Only insert the separating space if we have a chapter/appendix
6605     % number, and don't print the unnumbered ``number''.
6606     \ifx\temptype\Ynothingkeyword
6607       \setbox0 = \hbox{}%
6608       \def\toctype{unnchap}%
6609     \else\ifx\temptype\Yomitfromtockeyword
6610       \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6611       \def\toctype{omit}%
6612     \else\ifx\temptype\Yappendixkeyword
6613       \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6614       \def\toctype{app}%
6615     \else
6616       \setbox0 = \hbox{#3\enspace}%
6617       \def\toctype{numchap}%
6618     \fi\fi\fi
6619     %
6620     % Write the toc entry for this chapter.  Must come before the
6621     % \donoderef, because we include the current node name in the toc
6622     % entry, and \donoderef resets it to empty.
6623     \writetocentry{\toctype}{#1}{#3}%
6624     %
6625     % For pdftex, we have to write out the node definition (aka, make
6626     % the pdfdest) after any page break, but before the actual text has
6627     % been typeset.  If the destination for the pdf outline is after the
6628     % text, then jumping from the outline may wind up with the text not
6629     % being visible, for instance under high magnification.
6630     \donoderef{#2}%
6631     %
6632     % Typeset the actual heading.
6633     \nobreak % Avoid page breaks at the interline glue.
6634     \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
6635           \unhbox0 #1\par}%
6636   }%
6637   \nobreak\bigskip % no page break after a chapter title
6638   \nobreak
6639 }
6640
6641 % @centerchap -- centered and unnumbered.
6642 \let\centerparametersmaybe = \relax
6643 \def\centerparameters{%
6644   \advance\rightskip by 3\rightskip
6645   \leftskip = \rightskip
6646   \parfillskip = 0pt
6647 }
6648
6649
6650 % Section titles.  These macros combine the section number parts and
6651 % call the generic \sectionheading to do the printing.
6652 %
6653 \newskip\secheadingskip
6654 \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
6655
6656 % Subsection titles.
6657 \newskip\subsecheadingskip
6658 \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
6659
6660 % Subsubsection titles.
6661 \def\subsubsecheadingskip{\subsecheadingskip}
6662 \def\subsubsecheadingbreak{\subsecheadingbreak}
6663
6664
6665 % Print any size, any type, section title.
6666 %
6667 % #1 is the text of the title,
6668 % #2 is the section level (sec/subsec/subsubsec),
6669 % #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6670 % #4 is the section number.
6671 %
6672 \def\seckeyword{sec}
6673 %
6674 \def\sectionheading#1#2#3#4{%
6675   {%
6676     \def\sectionlevel{#2}%
6677     \def\temptype{#3}%
6678     %
6679     % It is ok for the @heading series commands to appear inside an
6680     % environment (it's been historically allowed, though the logic is
6681     % dubious), but not the others.
6682     \ifx\temptype\Yomitfromtockeyword\else
6683       \checkenv{}% non-@*heading should not be in an environment.
6684     \fi
6685     \let\footnote=\errfootnoteheading
6686     %
6687     % Switch to the right set of fonts.
6688     \csname #2fonts\endcsname \rm
6689     %
6690     % Insert first mark before the heading break (see notes for \domark).
6691     \let\prevsectiondefs=\currentsectiondefs
6692     \ifx\temptype\Ynothingkeyword
6693       \ifx\sectionlevel\seckeyword
6694         \gdef\currentsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6695                               \gdef\thissection{\thissectionname}}%
6696       \fi
6697     \else\ifx\temptype\Yomitfromtockeyword
6698       % Don't redefine \thissection.
6699     \else\ifx\temptype\Yappendixkeyword
6700       \ifx\sectionlevel\seckeyword
6701         \toks0={#1}%
6702         \xdef\currentsectiondefs{%
6703           \gdef\noexpand\thissectionname{\the\toks0}%
6704           \gdef\noexpand\thissectionnum{#4}%
6705           % \noexpand\putwordSection avoids expanding indigestible
6706           % commands in some of the translations.
6707           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6708                                      \noexpand\thissectionnum:
6709                                      \noexpand\thissectionname}%
6710         }%
6711       \fi
6712     \else
6713       \ifx\sectionlevel\seckeyword
6714         \toks0={#1}%
6715         \xdef\currentsectiondefs{%
6716           \gdef\noexpand\thissectionname{\the\toks0}%
6717           \gdef\noexpand\thissectionnum{#4}%
6718           % \noexpand\putwordSection avoids expanding indigestible
6719           % commands in some of the translations.
6720           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6721                                      \noexpand\thissectionnum:
6722                                      \noexpand\thissectionname}%
6723         }%
6724       \fi
6725     \fi\fi\fi
6726     %
6727     % Go into vertical mode.  Usually we'll already be there, but we
6728     % don't want the following whatsit to end up in a preceding paragraph
6729     % if the document didn't happen to have a blank line.
6730     \par
6731     %
6732     % Output the mark.  Pass it through \safewhatsit, to take care of
6733     % the preceding space.
6734     \safewhatsit\domark
6735     %
6736     % Insert space above the heading.
6737     \csname #2headingbreak\endcsname
6738     %
6739     % Now the second mark, after the heading break.  No break points
6740     % between here and the heading.
6741     \global\let\prevsectiondefs=\currentsectiondefs
6742     \domark
6743     %
6744     % Only insert the space after the number if we have a section number.
6745     \ifx\temptype\Ynothingkeyword
6746       \setbox0 = \hbox{}%
6747       \def\toctype{unn}%
6748       \gdef\currentsection{#1}%
6749     \else\ifx\temptype\Yomitfromtockeyword
6750       % for @headings -- no section number, don't include in toc,
6751       % and don't redefine \currentsection.
6752       \setbox0 = \hbox{}%
6753       \def\toctype{omit}%
6754       \let\sectionlevel=\empty
6755     \else\ifx\temptype\Yappendixkeyword
6756       \setbox0 = \hbox{#4\enspace}%
6757       \def\toctype{app}%
6758       \gdef\currentsection{#1}%
6759     \else
6760       \setbox0 = \hbox{#4\enspace}%
6761       \def\toctype{num}%
6762       \gdef\currentsection{#1}%
6763     \fi\fi\fi
6764     %
6765     % Write the toc entry (before \donoderef).  See comments in \chapmacro.
6766     \writetocentry{\toctype\sectionlevel}{#1}{#4}%
6767     %
6768     % Write the node reference (= pdf destination for pdftex).
6769     % Again, see comments in \chapmacro.
6770     \donoderef{#3}%
6771     %
6772     % Interline glue will be inserted when the vbox is completed.
6773     % That glue will be a valid breakpoint for the page, since it'll be
6774     % preceded by a whatsit (usually from the \donoderef, or from the
6775     % \writetocentry if there was no node).  We don't want to allow that
6776     % break, since then the whatsits could end up on page n while the
6777     % section is on page n+1, thus toc/etc. are wrong.  Debian bug 276000.
6778     \nobreak
6779     %
6780     % Output the actual section heading.
6781     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
6782           \hangindent=\wd0  % zero if no section number
6783           \unhbox0 #1}%
6784   }%
6785   % Add extra space after the heading -- half of whatever came above it.
6786   % Don't allow stretch, though.
6787   \kern .5 \csname #2headingskip\endcsname
6788   %
6789   % Do not let the kern be a potential breakpoint, as it would be if it
6790   % was followed by glue.
6791   \nobreak
6792   %
6793   % We'll almost certainly start a paragraph next, so don't let that
6794   % glue accumulate.  (Not a breakpoint because it's preceded by a
6795   % discardable item.)  However, when a paragraph is not started next
6796   % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6797   % or the negative glue will cause weirdly wrong output, typically
6798   % obscuring the section heading with something else.
6799   \vskip-\parskip
6800   %
6801   % This is so the last item on the main vertical list is a known
6802   % \penalty > 10000, so \startdefun, etc., can recognize the situation
6803   % and do the needful.
6804   \penalty 10001
6805 }
6806
6807
6808 \message{toc,}
6809 % Table of contents.
6810 \newwrite\tocfile
6811
6812 % Write an entry to the toc file, opening it if necessary.
6813 % Called from @chapter, etc.
6814 %
6815 % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6816 % We append the current node name (if any) and page number as additional
6817 % arguments for the \{chap,sec,...}entry macros which will eventually
6818 % read this.  The node name is used in the pdf outlines as the
6819 % destination to jump to.
6820 %
6821 % We open the .toc file for writing here instead of at @setfilename (or
6822 % any other fixed time) so that @contents can be anywhere in the document.
6823 % But if #1 is `omit', then we don't do anything.  This is used for the
6824 % table of contents chapter openings themselves.
6825 %
6826 \newif\iftocfileopened
6827 \def\omitkeyword{omit}%
6828 %
6829 \def\writetocentry#1#2#3{%
6830   \edef\writetoctype{#1}%
6831   \ifx\writetoctype\omitkeyword \else
6832     \iftocfileopened\else
6833       \immediate\openout\tocfile = \jobname.toc
6834       \global\tocfileopenedtrue
6835     \fi
6836     %
6837     \iflinks
6838       {\atdummies
6839        \edef\temp{%
6840          \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6841        \temp
6842       }%
6843     \fi
6844   \fi
6845   %
6846   % Tell \shipout to create a pdf destination on each page, if we're
6847   % writing pdf.  These are used in the table of contents.  We can't
6848   % just write one on every page because the title pages are numbered
6849   % 1 and 2 (the page numbers aren't printed), and so are the first
6850   % two pages of the document.  Thus, we'd have two destinations named
6851   % `1', and two named `2'.
6852   \ifpdforxetex
6853     \global\pdfmakepagedesttrue
6854   \fi
6855 }
6856
6857
6858 % These characters do not print properly in the Computer Modern roman
6859 % fonts, so we must take special care.  This is more or less redundant
6860 % with the Texinfo input format setup at the end of this file.
6861 %
6862 \def\activecatcodes{%
6863   \catcode`\"=\active
6864   \catcode`\$=\active
6865   \catcode`\<=\active
6866   \catcode`\>=\active
6867   \catcode`\\=\active
6868   \catcode`\^=\active
6869   \catcode`\_=\active
6870   \catcode`\|=\active
6871   \catcode`\~=\active
6872 }
6873
6874
6875 % Read the toc file, which is essentially Texinfo input.
6876 \def\readtocfile{%
6877   \setupdatafile
6878   \activecatcodes
6879   \input \tocreadfilename
6880 }
6881
6882 \newskip\contentsrightmargin \contentsrightmargin=1in
6883 \newcount\savepageno
6884 \newcount\lastnegativepageno \lastnegativepageno = -1
6885
6886 % Prepare to read what we've written to \tocfile.
6887 %
6888 \def\startcontents#1{%
6889   % If @setchapternewpage on, and @headings double, the contents should
6890   % start on an odd page, unlike chapters.
6891   \contentsalignmacro
6892   \immediate\closeout\tocfile
6893   %
6894   % Don't need to put `Contents' or `Short Contents' in the headline.
6895   % It is abundantly clear what they are.
6896   \chapmacro{#1}{Yomitfromtoc}{}%
6897   %
6898   \savepageno = \pageno
6899   \begingroup                  % Set up to handle contents files properly.
6900     \raggedbottom              % Worry more about breakpoints than the bottom.
6901     \entryrightmargin=\contentsrightmargin % Don't use the full line length.
6902     %
6903     % Roman numerals for page numbers.
6904     \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
6905     \def\thistitle{}% no title in double-sided headings
6906     % Record where the Roman numerals started.
6907     \ifnum\romancount=0 \global\romancount=\pagecount \fi
6908 }
6909
6910 % redefined for the two-volume lispref.  We always output on
6911 % \jobname.toc even if this is redefined.
6912 %
6913 \def\tocreadfilename{\jobname.toc}
6914
6915 % Normal (long) toc.
6916 %
6917 \def\contents{%
6918   \startcontents{\putwordTOC}%
6919     \openin 1 \tocreadfilename\space
6920     \ifeof 1 \else
6921       \readtocfile
6922     \fi
6923     \vfill \eject
6924     \contentsalignmacro % in case @setchapternewpage odd is in effect
6925     \ifeof 1 \else
6926       \pdfmakeoutlines
6927     \fi
6928     \closein 1
6929   \endgroup
6930   \contentsendroman
6931 }
6932
6933 % And just the chapters.
6934 \def\summarycontents{%
6935   \startcontents{\putwordShortTOC}%
6936     %
6937     \let\partentry = \shortpartentry
6938     \let\numchapentry = \shortchapentry
6939     \let\appentry = \shortchapentry
6940     \let\unnchapentry = \shortunnchapentry
6941     % We want a true roman here for the page numbers.
6942     \secfonts
6943     \let\rm=\shortcontrm \let\bf=\shortcontbf
6944     \let\sl=\shortcontsl \let\tt=\shortconttt
6945     \rm
6946     \hyphenpenalty = 10000
6947     \advance\baselineskip by 1pt % Open it up a little.
6948     \def\numsecentry##1##2##3##4{}
6949     \let\appsecentry = \numsecentry
6950     \let\unnsecentry = \numsecentry
6951     \let\numsubsecentry = \numsecentry
6952     \let\appsubsecentry = \numsecentry
6953     \let\unnsubsecentry = \numsecentry
6954     \let\numsubsubsecentry = \numsecentry
6955     \let\appsubsubsecentry = \numsecentry
6956     \let\unnsubsubsecentry = \numsecentry
6957     \openin 1 \tocreadfilename\space
6958     \ifeof 1 \else
6959       \readtocfile
6960     \fi
6961     \closein 1
6962     \vfill \eject
6963     \contentsalignmacro % in case @setchapternewpage odd is in effect
6964   \endgroup
6965   \contentsendroman
6966 }
6967 \let\shortcontents = \summarycontents
6968
6969 % Get ready to use Arabic numerals again
6970 \def\contentsendroman{%
6971   \lastnegativepageno = \pageno
6972   \global\pageno = \savepageno
6973   %
6974   % If \romancount > \arabiccount, the contents are at the end of the
6975   % document.  Otherwise, advance where the Arabic numerals start for
6976   % the page numbers.
6977   \ifnum\romancount>\arabiccount\else\global\arabiccount=\pagecount\fi
6978 }
6979
6980 % Typeset the label for a chapter or appendix for the short contents.
6981 % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6982 %
6983 \def\shortchaplabel#1{%
6984   % This space should be enough, since a single number is .5em, and the
6985   % widest letter (M) is 1em, at least in the Computer Modern fonts.
6986   % But use \hss just in case.
6987   % (This space doesn't include the extra space that gets added after
6988   % the label; that gets put in by \shortchapentry above.)
6989   %
6990   % We'd like to right-justify chapter numbers, but that looks strange
6991   % with appendix letters.  And right-justifying numbers and
6992   % left-justifying letters looks strange when there is less than 10
6993   % chapters.  Have to read the whole toc once to know how many chapters
6994   % there are before deciding ...
6995   \hbox to 1em{#1\hss}%
6996 }
6997
6998 % These macros generate individual entries in the table of contents.
6999 % The first argument is the chapter or section name.
7000 % The last argument is the page number.
7001 % The arguments in between are the chapter number, section number, ...
7002
7003 % Parts, in the main contents.  Replace the part number, which doesn't
7004 % exist, with an empty box.  Let's hope all the numbers have the same width.
7005 % Also ignore the page number, which is conventionally not printed.
7006 \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
7007 \def\partentry#1#2#3#4{%
7008   % Add stretch and a bonus for breaking the page before the part heading.
7009   % This reduces the chance of the page being broken immediately after the
7010   % part heading, before a following chapter heading.
7011   \vskip 0pt plus 5\baselineskip
7012   \penalty-300
7013   \vskip 0pt plus -5\baselineskip
7014   \dochapentry{\numeralbox\labelspace#1}{}%
7015 }
7016 %
7017 % Parts, in the short toc.
7018 \def\shortpartentry#1#2#3#4{%
7019   \penalty-300
7020   \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
7021   \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
7022 }
7023
7024 % Chapters, in the main contents.
7025 \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
7026
7027 % Chapters, in the short toc.
7028 % See comments in \dochapentry re vbox and related settings.
7029 \def\shortchapentry#1#2#3#4{%
7030   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
7031 }
7032
7033 % Appendices, in the main contents.
7034 % Need the word Appendix, and a fixed-size box.
7035 %
7036 \def\appendixbox#1{%
7037   % We use M since it's probably the widest letter.
7038   \setbox0 = \hbox{\putwordAppendix{} M}%
7039   \hbox to \wd0{\putwordAppendix{} #1\hss}}
7040 %
7041 \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
7042
7043 % Unnumbered chapters.
7044 \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
7045 \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
7046
7047 % Sections.
7048 \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
7049 \let\appsecentry=\numsecentry
7050 \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
7051
7052 % Subsections.
7053 \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
7054 \let\appsubsecentry=\numsubsecentry
7055 \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
7056
7057 % And subsubsections.
7058 \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
7059 \let\appsubsubsecentry=\numsubsubsecentry
7060 \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
7061
7062 % This parameter controls the indentation of the various levels.
7063 % Same as \defaultparindent.
7064 \newdimen\tocindent \tocindent = 15pt
7065
7066 % Now for the actual typesetting. In all these, #1 is the text and #2 is the
7067 % page number.
7068 %
7069 % If the toc has to be broken over pages, we want it to be at chapters
7070 % if at all possible; hence the \penalty.
7071 \def\dochapentry#1#2{%
7072    \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
7073    \begingroup
7074      % Move the page numbers slightly to the right
7075      \advance\entryrightmargin by -0.05em
7076      \chapentryfonts
7077      \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7078    \endgroup
7079    \nobreak\vskip .25\baselineskip plus.1\baselineskip
7080 }
7081
7082 \def\dosecentry#1#2{\begingroup
7083   \secentryfonts \leftskip=\tocindent
7084   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7085 \endgroup}
7086
7087 \def\dosubsecentry#1#2{\begingroup
7088   \subsecentryfonts \leftskip=2\tocindent
7089   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7090 \endgroup}
7091
7092 \def\dosubsubsecentry#1#2{\begingroup
7093   \subsubsecentryfonts \leftskip=3\tocindent
7094   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7095 \endgroup}
7096
7097 % We use the same \entry macro as for the index entries.
7098 \let\tocentry = \entry
7099
7100 % Space between chapter (or whatever) number and the title.
7101 \def\labelspace{\hskip1em \relax}
7102
7103 \def\dopageno#1{{\rm #1}}
7104 \def\doshortpageno#1{{\rm #1}}
7105
7106 \def\chapentryfonts{\secfonts \rm}
7107 \def\secentryfonts{\textfonts}
7108 \def\subsecentryfonts{\textfonts}
7109 \def\subsubsecentryfonts{\textfonts}
7110
7111
7112 \message{environments,}
7113 % @foo ... @end foo.
7114
7115 % @tex ... @end tex    escapes into raw TeX temporarily.
7116 % One exception: @ is still an escape character, so that @end tex works.
7117 % But \@ or @@ will get a plain @ character.
7118
7119 \envdef\tex{%
7120   \setupmarkupstyle{tex}%
7121   \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
7122   \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
7123   \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
7124   \catcode `\%=14
7125   \catcode `\+=\other
7126   \catcode `\"=\other
7127   \catcode `\|=\other
7128   \catcode `\<=\other
7129   \catcode `\>=\other
7130   \catcode `\`=\other
7131   \catcode `\'=\other
7132   %
7133   % ' is active in math mode (mathcode"8000).  So reset it, and all our
7134   % other math active characters (just in case), to plain's definitions.
7135   \mathactive
7136   %
7137   % Inverse of the list at the beginning of the file.
7138   \let\b=\ptexb
7139   \let\bullet=\ptexbullet
7140   \let\c=\ptexc
7141   \let\,=\ptexcomma
7142   \let\.=\ptexdot
7143   \let\dots=\ptexdots
7144   \let\equiv=\ptexequiv
7145   \let\!=\ptexexclam
7146   \let\i=\ptexi
7147   \let\indent=\ptexindent
7148   \let\noindent=\ptexnoindent
7149   \let\{=\ptexlbrace
7150   \let\+=\tabalign
7151   \let\}=\ptexrbrace
7152   \let\/=\ptexslash
7153   \let\sp=\ptexsp
7154   \let\*=\ptexstar
7155   %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
7156   \let\t=\ptext
7157   \expandafter \let\csname top\endcsname=\ptextop  % we've made it outer
7158   \let\frenchspacing=\plainfrenchspacing
7159   %
7160   \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
7161   \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
7162   \def\@{@}%
7163 }
7164 % There is no need to define \Etex.
7165
7166 % Define @lisp ... @end lisp.
7167 % @lisp environment forms a group so it can rebind things,
7168 % including the definition of @end lisp (which normally is erroneous).
7169
7170 % Amount to narrow the margins by for @lisp.
7171 \newskip\lispnarrowing \lispnarrowing=0.4in
7172
7173 % This is the definition that ^^M gets inside @lisp, @example, and other
7174 % such environments.  \null is better than a space, since it doesn't
7175 % have any width.
7176 \def\lisppar{\null\endgraf}
7177
7178 % This space is always present above and below environments.
7179 \newskip\envskipamount \envskipamount = 0pt
7180
7181 % Make spacing and below environment symmetrical.  We use \parskip here
7182 % to help in doing that, since in @example-like environments \parskip
7183 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
7184 % start of the next paragraph will insert \parskip.
7185 %
7186 \def\aboveenvbreak{{%
7187   % =10000 instead of <10000 because of a special case in \itemzzz and
7188   % \sectionheading, q.v.
7189   \ifnum \lastpenalty=10000 \else
7190     \advance\envskipamount by \parskip
7191     \endgraf
7192     \ifdim\lastskip<\envskipamount
7193       \removelastskip
7194       \ifnum\lastpenalty<10000
7195         % Penalize breaking before the environment, because preceding text
7196         % often leads into it.
7197         \penalty100
7198       \fi
7199       \vskip\envskipamount
7200     \fi
7201   \fi
7202 }}
7203
7204 \def\afterenvbreak{{%
7205   % =10000 instead of <10000 because of a special case in \itemzzz and
7206   % \sectionheading, q.v.
7207   \ifnum \lastpenalty=10000 \else
7208     \advance\envskipamount by \parskip
7209     \endgraf
7210     \ifdim\lastskip<\envskipamount
7211       \removelastskip
7212       % it's not a good place to break if the last penalty was \nobreak
7213       % or better ...
7214       \ifnum\lastpenalty<10000 \penalty-50 \fi
7215       \vskip\envskipamount
7216     \fi
7217   \fi
7218 }}
7219
7220 % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins; it will
7221 % also clear it, so that its embedded environments do the narrowing again.
7222 \let\nonarrowing=\relax
7223
7224 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
7225 % environment contents.
7226
7227 %
7228 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
7229 \def\ctr{{\hskip 6pt\circle\char'010}}
7230 \def\cbl{{\circle\char'012\hskip -6pt}}
7231 \def\cbr{{\hskip 6pt\circle\char'011}}
7232 \def\carttop{\hbox to \cartouter{\hskip\lskip
7233         \ctl\leaders\hrule height\circthick\hfil\ctr
7234         \hskip\rskip}}
7235 \def\cartbot{\hbox to \cartouter{\hskip\lskip
7236         \cbl\leaders\hrule height\circthick\hfil\cbr
7237         \hskip\rskip}}
7238 %
7239 \newskip\lskip\newskip\rskip
7240
7241 % only require the font if @cartouche is actually used
7242 \def\cartouchefontdefs{%
7243   \font\circle=lcircle10\relax
7244   \circthick=\fontdimen8\circle
7245 }
7246 \newdimen\circthick
7247 \newdimen\cartouter\newdimen\cartinner
7248 \newskip\normbskip\newskip\normpskip\newskip\normlskip
7249
7250
7251 \envdef\cartouche{%
7252   \cartouchefontdefs
7253   \ifhmode\par\fi  % can't be in the midst of a paragraph.
7254   \startsavinginserts
7255   \lskip=\leftskip \rskip=\rightskip
7256   \leftskip=0pt\rightskip=0pt % we want these *outside*.
7257   \cartinner=\hsize \advance\cartinner by-\lskip
7258   \advance\cartinner by-\rskip
7259   \cartouter=\hsize
7260   \advance\cartouter by 18.4pt  % allow for 3pt kerns on either
7261                                 % side, and for 6pt waste from
7262                                 % each corner char, and rule thickness
7263   \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
7264   %
7265   % If this cartouche directly follows a sectioning command, we need the
7266   % \parskip glue (backspaced over by default) or the cartouche can
7267   % collide with the section heading.
7268   \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
7269   %
7270   \setbox\groupbox=\vbox\bgroup
7271       \baselineskip=0pt\parskip=0pt\lineskip=0pt
7272       \carttop
7273       \hbox\bgroup
7274           \hskip\lskip
7275           \vrule\kern3pt
7276           \vbox\bgroup
7277               \kern3pt
7278               \hsize=\cartinner
7279               \baselineskip=\normbskip
7280               \lineskip=\normlskip
7281               \parskip=\normpskip
7282               \vskip -\parskip
7283               \comment % For explanation, see the end of def\group.
7284 }
7285 \def\Ecartouche{%
7286               \ifhmode\par\fi
7287               \kern3pt
7288           \egroup
7289           \kern3pt\vrule
7290           \hskip\rskip
7291       \egroup
7292       \cartbot
7293   \egroup
7294   \addgroupbox
7295   \checkinserts
7296 }
7297
7298
7299 % This macro is called at the beginning of all the @example variants,
7300 % inside a group.
7301 \newdimen\nonfillparindent
7302 \def\nonfillstart{%
7303   \aboveenvbreak
7304   \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
7305   \sepspaces % Make spaces be word-separators rather than space tokens.
7306   \let\par = \lisppar % don't ignore blank lines
7307   \obeylines % each line of input is a line of output
7308   \parskip = 0pt
7309   % Turn off paragraph indentation but redefine \indent to emulate
7310   % the normal \indent.
7311   \nonfillparindent=\parindent
7312   \parindent = 0pt
7313   \let\indent\nonfillindent
7314   %
7315   \emergencystretch = 0pt % don't try to avoid overfull boxes
7316   \ifx\nonarrowing\relax
7317     \advance \leftskip by \lispnarrowing
7318     \exdentamount=\lispnarrowing
7319   \else
7320     \let\nonarrowing = \relax
7321   \fi
7322   \let\exdent=\nofillexdent
7323 }
7324
7325 \begingroup
7326 \obeyspaces
7327 % We want to swallow spaces (but not other tokens) after the fake
7328 % @indent in our nonfill-environments, where spaces are normally
7329 % active and set to @tie, resulting in them not being ignored after
7330 % @indent.
7331 \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
7332 \gdef\nonfillindentcheck{%
7333 \ifx\temp %
7334 \expandafter\nonfillindentgobble%
7335 \else%
7336 \leavevmode\nonfillindentbox%
7337 \fi%
7338 }%
7339 \endgroup
7340 \def\nonfillindentgobble#1{\nonfillindent}
7341 \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7342
7343 % If you want all examples etc. small: @set dispenvsize small.
7344 % If you want even small examples the full size: @set dispenvsize nosmall.
7345 % This affects the following displayed environments:
7346 %    @example, @display, @format, @lisp
7347 %
7348 \def\smallword{small}
7349 \def\nosmallword{nosmall}
7350 \let\SETdispenvsize\relax
7351 \def\setnormaldispenv{%
7352   \ifx\SETdispenvsize\smallword
7353     % end paragraph for sake of leading, in case document has no blank
7354     % line.  This is redundant with what happens in \aboveenvbreak, but
7355     % we need to do it before changing the fonts, and it's inconvenient
7356     % to change the fonts afterward.
7357     \ifnum \lastpenalty=10000 \else \endgraf \fi
7358     \smallexamplefonts \rm
7359   \fi
7360 }
7361 \def\setsmalldispenv{%
7362   \ifx\SETdispenvsize\nosmallword
7363   \else
7364     \ifnum \lastpenalty=10000 \else \endgraf \fi
7365     \smallexamplefonts \rm
7366   \fi
7367 }
7368
7369 % We often define two environments, @foo and @smallfoo.
7370 % Let's do it in one command.  #1 is the env name, #2 the definition.
7371 \def\makedispenvdef#1#2{%
7372   \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7373   \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
7374   \expandafter\let\csname E#1\endcsname \afterenvbreak
7375   \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
7376 }
7377
7378 % Define two environment synonyms (#1 and #2) for an environment.
7379 \def\maketwodispenvdef#1#2#3{%
7380   \makedispenvdef{#1}{#3}%
7381   \makedispenvdef{#2}{#3}%
7382 }
7383 %
7384 % @lisp: indented, narrowed, typewriter font;
7385 % @example: same as @lisp.
7386 %
7387 % @smallexample and @smalllisp: use smaller fonts.
7388 % Originally contributed by Pavel@xerox.
7389 %
7390 \maketwodispenvdef{lisp}{example}{%
7391   \nonfillstart
7392   \tt\setupmarkupstyle{example}%
7393   \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
7394   \gobble % eat return
7395 }
7396 % @display/@smalldisplay: same as @lisp except keep current font.
7397 %
7398 \makedispenvdef{display}{%
7399   \nonfillstart
7400   \gobble
7401 }
7402
7403 % @format/@smallformat: same as @display except don't narrow margins.
7404 %
7405 \makedispenvdef{format}{%
7406   \let\nonarrowing = t%
7407   \nonfillstart
7408   \gobble
7409 }
7410
7411 % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7412 \envdef\flushleft{%
7413   \let\nonarrowing = t%
7414   \nonfillstart
7415   \gobble
7416 }
7417 \let\Eflushleft = \afterenvbreak
7418
7419 % @flushright.
7420 %
7421 \envdef\flushright{%
7422   \let\nonarrowing = t%
7423   \nonfillstart
7424   \advance\leftskip by 0pt plus 1fill\relax
7425   \gobble
7426 }
7427 \let\Eflushright = \afterenvbreak
7428
7429
7430 % @raggedright does more-or-less normal line breaking but no right
7431 % justification.  From plain.tex.
7432 \envdef\raggedright{%
7433   \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7434 }
7435 \let\Eraggedright\par
7436
7437 \envdef\raggedleft{%
7438   \parindent=0pt \leftskip0pt plus2em
7439   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7440   \hbadness=10000 % Last line will usually be underfull, so turn off
7441                   % badness reporting.
7442 }
7443 \let\Eraggedleft\par
7444
7445 \envdef\raggedcenter{%
7446   \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
7447   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7448   \hbadness=10000 % Last line will usually be underfull, so turn off
7449                   % badness reporting.
7450 }
7451 \let\Eraggedcenter\par
7452
7453
7454 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
7455 % and narrows the margins.  We keep \parskip nonzero in general, since
7456 % we're doing normal filling.  So, when using \aboveenvbreak and
7457 % \afterenvbreak, temporarily make \parskip 0.
7458 %
7459 \makedispenvdef{quotation}{\quotationstart}
7460 %
7461 \def\quotationstart{%
7462   \indentedblockstart % same as \indentedblock, but increase right margin too.
7463   \ifx\nonarrowing\relax
7464     \advance\rightskip by \lispnarrowing
7465   \fi
7466   \parsearg\quotationlabel
7467 }
7468
7469 % We have retained a nonzero parskip for the environment, since we're
7470 % doing normal filling.
7471 %
7472 \def\Equotation{%
7473   \par
7474   \ifx\quotationauthor\thisisundefined\else
7475     % indent a bit.
7476     \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7477   \fi
7478   {\parskip=0pt \afterenvbreak}%
7479 }
7480 \def\Esmallquotation{\Equotation}
7481
7482 % If we're given an argument, typeset it in bold with a colon after.
7483 \def\quotationlabel#1{%
7484   \def\temp{#1}%
7485   \ifx\temp\empty \else
7486     {\bf #1: }%
7487   \fi
7488 }
7489
7490 % @indentedblock is like @quotation, but indents only on the left and
7491 % has no optional argument.
7492 %
7493 \makedispenvdef{indentedblock}{\indentedblockstart}
7494 %
7495 \def\indentedblockstart{%
7496   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7497   \parindent=0pt
7498   %
7499   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7500   \ifx\nonarrowing\relax
7501     \advance\leftskip by \lispnarrowing
7502     \exdentamount = \lispnarrowing
7503   \else
7504     \let\nonarrowing = \relax
7505   \fi
7506 }
7507
7508 % Keep a nonzero parskip for the environment, since we're doing normal filling.
7509 %
7510 \def\Eindentedblock{%
7511   \par
7512   {\parskip=0pt \afterenvbreak}%
7513 }
7514 \def\Esmallindentedblock{\Eindentedblock}
7515
7516
7517 % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7518 % If we want to allow any <char> as delimiter,
7519 % we need the curly braces so that makeinfo sees the @verb command, eg:
7520 % `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
7521 %
7522 % [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
7523 %
7524 % [Knuth] p.344; only we need to do the other characters Texinfo sets
7525 % active too.  Otherwise, they get lost as the first character on a
7526 % verbatim line.
7527 \def\dospecials{%
7528   \do\ \do\\\do\{\do\}\do\$\do\&%
7529   \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7530   \do\<\do\>\do\|\do\@\do+\do\"%
7531   % Don't do the quotes -- if we do, @set txicodequoteundirected and
7532   % @set txicodequotebacktick will not have effect on @verb and
7533   % @verbatim, and ?` and !` ligatures won't get disabled.
7534   %\do\`\do\'%
7535 }
7536 %
7537 % [Knuth] p. 380
7538 \def\uncatcodespecials{%
7539   \def\do##1{\catcode`##1=\other}\dospecials}
7540 %
7541 % Setup for the @verb command.
7542 %
7543 % Eight spaces for a tab
7544 \begingroup
7545   \catcode`\^^I=\active
7546   \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7547 \endgroup
7548 %
7549 \def\setupverb{%
7550   \tt  % easiest (and conventionally used) font for verbatim
7551   \def\par{\leavevmode\endgraf}%
7552   \setupmarkupstyle{verb}%
7553   \tabeightspaces
7554   % Respect line breaks,
7555   % print special symbols as themselves, and
7556   % make each space count
7557   % must do in this order:
7558   \obeylines \uncatcodespecials \sepspaces
7559 }
7560
7561 % Setup for the @verbatim environment
7562 %
7563 % Real tab expansion.
7564 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7565 %
7566 % We typeset each line of the verbatim in an \hbox, so we can handle
7567 % tabs.
7568 \newbox\verbbox
7569 \def\starttabbox{\setbox\verbbox=\hbox\bgroup}
7570 %
7571 \begingroup
7572   \catcode`\^^I=\active
7573   \gdef\tabexpand{%
7574     \catcode`\^^I=\active
7575     \def^^I{\leavevmode\egroup
7576       \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7577       \divide\dimen\verbbox by\tabw
7578       \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7579       \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
7580       \wd\verbbox=\dimen\verbbox
7581       \leavevmode\box\verbbox \starttabbox
7582     }%
7583   }
7584 \endgroup
7585
7586 % start the verbatim environment.
7587 \def\setupverbatim{%
7588   \let\nonarrowing = t%
7589   \nonfillstart
7590   \tt % easiest (and conventionally used) font for verbatim
7591   \def\par{\egroup\leavevmode\box\verbbox\endgraf\starttabbox}%
7592   \tabexpand
7593   \setupmarkupstyle{verbatim}%
7594   % Respect line breaks,
7595   % print special symbols as themselves, and
7596   % make each space count.
7597   % Must do in this order:
7598   \obeylines \uncatcodespecials \sepspaces
7599 }
7600
7601 % Do the @verb magic: verbatim text is quoted by unique
7602 % delimiter characters.  Before first delimiter expect a
7603 % right brace, after last delimiter expect closing brace:
7604 %
7605 %    \def\doverb'{'<char>#1<char>'}'{#1}
7606 %
7607 % [Knuth] p. 382; only eat outer {}
7608 \begingroup
7609   \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
7610   \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7611 \endgroup
7612 %
7613 \def\verb{\begingroup\setupverb\doverb}
7614 %
7615 %
7616 % Do the @verbatim magic: define the macro \doverbatim so that
7617 % the (first) argument ends when '@end verbatim' is reached, ie:
7618 %
7619 %     \def\doverbatim#1@end verbatim{#1}
7620 %
7621 % For Texinfo it's a lot easier than for LaTeX,
7622 % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
7623 % we need not redefine '\', '{' and '}'.
7624 %
7625 % Inspired by LaTeX's verbatim command set [latex.ltx]
7626 %
7627 \begingroup
7628   \catcode`\ =\active
7629   \obeylines %
7630   % ignore everything up to the first ^^M, that's the newline at the end
7631   % of the @verbatim input line itself.  Otherwise we get an extra blank
7632   % line in the output.
7633   \xdef\doverbatim#1^^M#2@end verbatim{%
7634     \starttabbox#2\egroup\noexpand\end\gobble verbatim}%
7635   % We really want {...\end verbatim} in the body of the macro, but
7636   % without the active space; thus we have to use \xdef and \gobble.
7637   % The \egroup ends the \verbbox started at the end of the last line in
7638   % the block.
7639 \endgroup
7640 %
7641 \envdef\verbatim{%
7642     \setupverbatim\doverbatim
7643 }
7644 \let\Everbatim = \afterenvbreak
7645
7646
7647 % @verbatiminclude FILE - insert text of file in verbatim environment.
7648 %
7649 \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
7650 %
7651 \def\doverbatiminclude#1{%
7652   {%
7653     \makevalueexpandable
7654     \setupverbatim
7655     {%
7656       \indexnofonts       % Allow `@@' and other weird things in file names.
7657       \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
7658       \edef\tmp{\noexpand\input #1 }
7659       \expandafter
7660     }\expandafter\starttabbox\tmp\egroup
7661     \afterenvbreak
7662   }%
7663 }
7664
7665 % @copying ... @end copying.
7666 % Save the text away for @insertcopying later.
7667 %
7668 % We save the uninterpreted tokens, rather than creating a box.
7669 % Saving the text in a box would be much easier, but then all the
7670 % typesetting commands (@smallbook, font changes, etc.) have to be done
7671 % beforehand -- and a) we want @copying to be done first in the source
7672 % file; b) letting users define the frontmatter in as flexible order as
7673 % possible is desirable.
7674 %
7675 \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
7676 \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
7677 %
7678 \def\insertcopying{%
7679   \begingroup
7680     \parindent = 0pt  % paragraph indentation looks wrong on title page
7681     \scanexp\copyingtext
7682   \endgroup
7683 }
7684
7685
7686 \message{defuns,}
7687 % @defun etc.
7688
7689 \newskip\defbodyindent \defbodyindent=.4in
7690 \newskip\defargsindent \defargsindent=50pt
7691 \newskip\deflastargmargin \deflastargmargin=18pt
7692 \newcount\defunpenalty
7693
7694 % Start the processing of @deffn:
7695 \def\startdefun{%
7696   \ifnum\lastpenalty<10000
7697     \medbreak
7698     \defunpenalty=10003 % Will keep this @deffn together with the
7699                         % following @def command, see below.
7700   \else
7701     % If there are two @def commands in a row, we'll have a \nobreak,
7702     % which is there to keep the function description together with its
7703     % header.  But if there's nothing but headers, we need to allow a
7704     % break somewhere.  Check specifically for penalty 10002, inserted
7705     % by \printdefunline, instead of 10000, since the sectioning
7706     % commands also insert a nobreak penalty, and we don't want to allow
7707     % a break between a section heading and a defun.
7708     %
7709     % As a further refinement, we avoid "club" headers by signalling
7710     % with penalty of 10003 after the very first @deffn in the
7711     % sequence (see above), and penalty of 10002 after any following
7712     % @def command.
7713     \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
7714     %
7715     % Similarly, after a section heading, do not allow a break.
7716     % But do insert the glue.
7717     \medskip  % preceded by discardable penalty, so not a breakpoint
7718   \fi
7719   %
7720   \parindent=0in
7721   \advance\leftskip by \defbodyindent
7722   \exdentamount=\defbodyindent
7723 }
7724
7725 \def\dodefunx#1{%
7726   % First, check whether we are in the right environment:
7727   \checkenv#1%
7728   %
7729   % As above, allow line break if we have multiple x headers in a row.
7730   % It's not a great place, though.
7731   \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
7732   %
7733   % And now, it's time to reuse the body of the original defun:
7734   \expandafter\gobbledefun#1%
7735 }
7736 \def\gobbledefun#1\startdefun{}
7737
7738 % \printdefunline \deffnheader{text}
7739 %
7740 \def\printdefunline#1#2{%
7741   \begingroup
7742     % call \deffnheader:
7743     #1#2 \endheader
7744     % common ending:
7745     \interlinepenalty = 10000
7746     \advance\rightskip by 0pt plus 1fil\relax
7747     \endgraf
7748     \nobreak\vskip -\parskip
7749     \penalty\defunpenalty  % signal to \startdefun and \dodefunx
7750     % Some of the @defun-type tags do not enable magic parentheses,
7751     % rendering the following check redundant.  But we don't optimize.
7752     \checkparencounts
7753   \endgroup
7754 }
7755
7756 \def\Edefun{\endgraf\medbreak}
7757
7758 % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
7759 % the only thing remaining is to define \deffnheader.
7760 %
7761 \def\makedefun#1{%
7762   \expandafter\let\csname E#1\endcsname = \Edefun
7763   \edef\temp{\noexpand\domakedefun
7764     \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7765   \temp
7766 }
7767
7768 % \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
7769 %
7770 % Define \deffn and \deffnx, without parameters.
7771 % \deffnheader has to be defined explicitly.
7772 %
7773 \def\domakedefun#1#2#3{%
7774   \envdef#1{%
7775     \startdefun
7776     \doingtypefnfalse    % distinguish typed functions from all else
7777     \parseargusing\activeparens{\printdefunline#3}%
7778   }%
7779   \def#2{\dodefunx#1}%
7780   \def#3%
7781 }
7782
7783 \newif\ifdoingtypefn       % doing typed function?
7784 \newif\ifrettypeownline    % typeset return type on its own line?
7785
7786 % @deftypefnnewline on|off says whether the return type of typed functions
7787 % are printed on their own line.  This affects @deftypefn, @deftypefun,
7788 % @deftypeop, and @deftypemethod.
7789 %
7790 \parseargdef\deftypefnnewline{%
7791   \def\temp{#1}%
7792   \ifx\temp\onword
7793     \expandafter\let\csname SETtxideftypefnnl\endcsname
7794       = \empty
7795   \else\ifx\temp\offword
7796     \expandafter\let\csname SETtxideftypefnnl\endcsname
7797       = \relax
7798   \else
7799     \errhelp = \EMsimple
7800     \errmessage{Unknown @txideftypefnnl value `\temp',
7801                 must be on|off}%
7802   \fi\fi
7803 }
7804
7805 % \dosubind {index}{topic}{subtopic}
7806 %
7807 % If SUBTOPIC is present, precede it with a space, and call \doind.
7808 % (At some time during the 20th century, this made a two-level entry in an
7809 % index such as the operation index.  Nobody seemed to notice the change in
7810 % behaviour though.)
7811 \def\dosubind#1#2#3{%
7812   \def\thirdarg{#3}%
7813   \ifx\thirdarg\empty
7814     \doind{#1}{#2}%
7815   \else
7816     \doind{#1}{#2\space#3}%
7817   \fi
7818 }
7819
7820 % Untyped functions:
7821
7822 % @deffn category name args
7823 \makedefun{deffn}{\deffngeneral{}}
7824
7825 % @deffn category class name args
7826 \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
7827
7828 % \defopon {category on}class name args
7829 \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7830
7831 % \deffngeneral {subind}category name args
7832 %
7833 \def\deffngeneral#1#2 #3 #4\endheader{%
7834   \dosubind{fn}{\code{#3}}{#1}%
7835   \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
7836 }
7837
7838 % Typed functions:
7839
7840 % @deftypefn category type name args
7841 \makedefun{deftypefn}{\deftypefngeneral{}}
7842
7843 % @deftypeop category class type name args
7844 \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
7845
7846 % \deftypeopon {category on}class type name args
7847 \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7848
7849 % \deftypefngeneral {subind}category type name args
7850 %
7851 \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
7852   \dosubind{fn}{\code{#4}}{#1}%
7853   \doingtypefntrue
7854   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7855 }
7856
7857 % Typed variables:
7858
7859 % @deftypevr category type var args
7860 \makedefun{deftypevr}{\deftypecvgeneral{}}
7861
7862 % @deftypecv category class type var args
7863 \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
7864
7865 % \deftypecvof {category of}class type var args
7866 \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
7867
7868 % \deftypecvgeneral {subind}category type var args
7869 %
7870 \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
7871   \dosubind{vr}{\code{#4}}{#1}%
7872   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7873 }
7874
7875 % Untyped variables:
7876
7877 % @defvr category var args
7878 \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
7879
7880 % @defcv category class var args
7881 \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
7882
7883 % \defcvof {category of}class var args
7884 \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
7885
7886 % Types:
7887
7888 % @deftp category name args
7889 \makedefun{deftp}#1 #2 #3\endheader{%
7890   \doind{tp}{\code{#2}}%
7891   \defname{#1}{}{#2}\defunargs{#3\unskip}%
7892 }
7893
7894 % Remaining @defun-like shortcuts:
7895 \makedefun{defun}{\deffnheader{\putwordDeffunc} }
7896 \makedefun{defmac}{\deffnheader{\putwordDefmac} }
7897 \makedefun{defspec}{\deffnheader{\putwordDefspec} }
7898 \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7899 \makedefun{defvar}{\defvrheader{\putwordDefvar} }
7900 \makedefun{defopt}{\defvrheader{\putwordDefopt} }
7901 \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
7902 \makedefun{defmethod}{\defopon\putwordMethodon}
7903 \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
7904 \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
7905 \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
7906
7907 % \defname, which formats the name of the @def (not the args).
7908 % #1 is the category, such as "Function".
7909 % #2 is the return type, if any.
7910 % #3 is the function name.
7911 %
7912 % We are followed by (but not passed) the arguments, if any.
7913 %
7914 \def\defname#1#2#3{%
7915   \par
7916   % Get the values of \leftskip and \rightskip as they were outside the @def...
7917   \advance\leftskip by -\defbodyindent
7918   %
7919   % Determine if we are typesetting the return type of a typed function
7920   % on a line by itself.
7921   \rettypeownlinefalse
7922   \ifdoingtypefn  % doing a typed function specifically?
7923     % then check user option for putting return type on its own line:
7924     \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
7925       \rettypeownlinetrue
7926     \fi
7927   \fi
7928   %
7929   % How we'll format the category name.  Putting it in brackets helps
7930   % distinguish it from the body text that may end up on the next line
7931   % just below it.
7932   \def\temp{#1}%
7933   \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7934   %
7935   % Figure out line sizes for the paragraph shape.  We'll always have at
7936   % least two.
7937   \tempnum = 2
7938   %
7939   % The first line needs space for \box0; but if \rightskip is nonzero,
7940   % we need only space for the part of \box0 which exceeds it:
7941   \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
7942   %
7943   % If doing a return type on its own line, we'll have another line.
7944   \ifrettypeownline
7945     \advance\tempnum by 1
7946     \def\maybeshapeline{0in \hsize}%
7947   \else
7948     \def\maybeshapeline{}%
7949   \fi
7950   %
7951   % The continuations:
7952   \dimen2=\hsize  \advance\dimen2 by -\defargsindent
7953   %
7954   % The final paragraph shape:
7955   \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
7956   %
7957   % Put the category name at the right margin.
7958   \noindent
7959   \hbox to 0pt{%
7960     \hfil\box0 \kern-\hsize
7961     % \hsize has to be shortened this way:
7962     \kern\leftskip
7963     % Intentionally do not respect \rightskip, since we need the space.
7964   }%
7965   %
7966   % Allow all lines to be underfull without complaint:
7967   \tolerance=10000 \hbadness=10000
7968   \exdentamount=\defbodyindent
7969   {%
7970     % defun fonts. We use typewriter by default (used to be bold) because:
7971     % . we're printing identifiers, they should be in tt in principle.
7972     % . in languages with many accents, such as Czech or French, it's
7973     %   common to leave accents off identifiers.  The result looks ok in
7974     %   tt, but exceedingly strange in rm.
7975     % . we don't want -- and --- to be treated as ligatures.
7976     % . this still does not fix the ?` and !` ligatures, but so far no
7977     %   one has made identifiers using them :).
7978     \df \tt
7979     \def\temp{#2}% text of the return type
7980     \ifx\temp\empty\else
7981       \tclose{\temp}% typeset the return type
7982       \ifrettypeownline
7983         % put return type on its own line; prohibit line break following:
7984         \hfil\vadjust{\nobreak}\break
7985       \else
7986         \space  % type on same line, so just followed by a space
7987       \fi
7988     \fi           % no return type
7989     #3% output function name
7990   }%
7991   {\rm\enskip}% hskip 0.5 em of \rmfont
7992   %
7993   \boldbrax
7994   % arguments will be output next, if any.
7995 }
7996
7997 % Print arguments in slanted roman (not ttsl), inconsistently with using
7998 % tt for the name.  This is because literal text is sometimes needed in
7999 % the argument list (groff manual), and ttsl and tt are not very
8000 % distinguishable.  Prevent hyphenation at `-' chars.
8001 %
8002 \def\defunargs#1{%
8003   % use sl by default (not ttsl),
8004   % tt for the names.
8005   \df \sl \hyphenchar\font=0
8006   %
8007   % On the other hand, if an argument has two dashes (for instance), we
8008   % want a way to get ttsl.  We used to recommend @var for that, so
8009   % leave the code in, but it's strange for @var to lead to typewriter.
8010   % Nowadays we recommend @code, since the difference between a ttsl hyphen
8011   % and a tt hyphen is pretty tiny.  @code also disables ?` !`.
8012   \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
8013   #1%
8014   \sl\hyphenchar\font=45
8015 }
8016
8017 % We want ()&[] to print specially on the defun line.
8018 %
8019 \def\activeparens{%
8020   \catcode`\(=\active \catcode`\)=\active
8021   \catcode`\[=\active \catcode`\]=\active
8022   \catcode`\&=\active
8023 }
8024
8025 % Make control sequences which act like normal parenthesis chars.
8026 \let\lparen = ( \let\rparen = )
8027
8028 % Be sure that we always have a definition for `(', etc.  For example,
8029 % if the fn name has parens in it, \boldbrax will not be in effect yet,
8030 % so TeX would otherwise complain about undefined control sequence.
8031 {
8032   \activeparens
8033   \global\let(=\lparen \global\let)=\rparen
8034   \global\let[=\lbrack \global\let]=\rbrack
8035   \global\let& = \&
8036
8037   \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
8038   \gdef\magicamp{\let&=\amprm}
8039 }
8040 \let\ampchar\&
8041
8042 \newcount\parencount
8043
8044 % If we encounter &foo, then turn on ()-hacking afterwards
8045 \newif\ifampseen
8046 \def\amprm#1 {\ampseentrue{\bf\&#1 }}
8047
8048 \def\parenfont{%
8049   \ifampseen
8050     % At the first level, print parens in roman,
8051     % otherwise use the default font.
8052     \ifnum \parencount=1 \rm \fi
8053   \else
8054     % The \sf parens (in \boldbrax) actually are a little bolder than
8055     % the contained text.  This is especially needed for [ and ] .
8056     \sf
8057   \fi
8058 }
8059 \def\infirstlevel#1{%
8060   \ifampseen
8061     \ifnum\parencount=1
8062       #1%
8063     \fi
8064   \fi
8065 }
8066 \def\bfafterword#1 {#1 \bf}
8067
8068 \def\opnr{%
8069   \global\advance\parencount by 1
8070   {\parenfont(}%
8071   \infirstlevel \bfafterword
8072 }
8073 \def\clnr{%
8074   {\parenfont)}%
8075   \infirstlevel \sl
8076   \global\advance\parencount by -1
8077 }
8078
8079 \newcount\brackcount
8080 \def\lbrb{%
8081   \global\advance\brackcount by 1
8082   {\bf[}%
8083 }
8084 \def\rbrb{%
8085   {\bf]}%
8086   \global\advance\brackcount by -1
8087 }
8088
8089 \def\checkparencounts{%
8090   \ifnum\parencount=0 \else \badparencount \fi
8091   \ifnum\brackcount=0 \else \badbrackcount \fi
8092 }
8093 % these should not use \errmessage; the glibc manual, at least, actually
8094 % has such constructs (when documenting function pointers).
8095 \def\badparencount{%
8096   \message{Warning: unbalanced parentheses in @def...}%
8097   \global\parencount=0
8098 }
8099 \def\badbrackcount{%
8100   \message{Warning: unbalanced square brackets in @def...}%
8101   \global\brackcount=0
8102 }
8103
8104
8105 \message{macros,}
8106 % @macro.
8107
8108 % To do this right we need a feature of e-TeX, \scantokens,
8109 % which we arrange to emulate with a temporary file in ordinary TeX.
8110 \ifx\eTeXversion\thisisundefined
8111   \newwrite\macscribble
8112   \def\scantokens#1{%
8113     \toks0={#1}%
8114     \immediate\openout\macscribble=\jobname.tmp
8115     \immediate\write\macscribble{\the\toks0}%
8116     \immediate\closeout\macscribble
8117     \input \jobname.tmp
8118   }
8119 \fi
8120
8121 % Used at the time of macro expansion.
8122 % Argument is macro body with arguments substituted
8123 \def\scanmacro#1{%
8124   \newlinechar`\^^M
8125   \def\xeatspaces{\eatspaces}%
8126   %
8127   % Process the macro body under the current catcode regime.
8128   \scantokens{#1@comment}%
8129   %
8130   % The \comment is to remove the \newlinechar added by \scantokens, and
8131   % can be noticed by \parsearg.  Note \c isn't used because this means cedilla
8132   % in math mode.
8133 }
8134
8135 % Used for copying and captions
8136 \def\scanexp#1{%
8137   \expandafter\scanmacro\expandafter{#1}%
8138 }
8139
8140 \newcount\paramno   % Count of parameters
8141 \newtoks\macname    % Macro name
8142 \newif\ifrecursive  % Is it recursive?
8143
8144 % List of all defined macros in the form
8145 %    \commondummyword\macro1\commondummyword\macro2...
8146 % Currently is also contains all @aliases; the list can be split
8147 % if there is a need.
8148 \def\macrolist{}
8149
8150 % Add the macro to \macrolist
8151 \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
8152 \def\addtomacrolistxxx#1{%
8153      \toks0 = \expandafter{\macrolist\commondummyword#1}%
8154      \xdef\macrolist{\the\toks0}%
8155 }
8156
8157 % Utility routines.
8158 % This does \let #1 = #2, with \csnames; that is,
8159 %   \let \csname#1\endcsname = \csname#2\endcsname
8160 % (except of course we have to play expansion games).
8161 %
8162 \def\cslet#1#2{%
8163   \expandafter\let
8164   \csname#1\expandafter\endcsname
8165   \csname#2\endcsname
8166 }
8167
8168 % Trim leading and trailing spaces off a string.
8169 % Concepts from aro-bend problem 15 (see CTAN).
8170 {\catcode`\@=11
8171 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
8172 \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
8173 \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
8174 \def\unbrace#1{#1}
8175 \unbrace{\gdef\trim@@@ #1 } #2@{#1}
8176 }
8177
8178 % Trim a single trailing ^^M off a string.
8179 {\catcode`\^^M=\other \catcode`\Q=3%
8180 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
8181 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
8182 \gdef\eatcrb#1Q#2Q{#1}%
8183 }
8184
8185 % Macro bodies are absorbed as an argument in a context where
8186 % all characters are catcode 10, 11 or 12, except \ which is active
8187 % (as in normal texinfo). It is necessary to change the definition of \
8188 % to recognize macro arguments; this is the job of \mbodybackslash.
8189 %
8190 % Non-ASCII encodings make 8-bit characters active, so un-activate
8191 % them to avoid their expansion.  Must do this non-globally, to
8192 % confine the change to the current group.
8193 %
8194 % It's necessary to have hard CRs when the macro is executed. This is
8195 % done by making ^^M (\endlinechar) catcode 12 when reading the macro
8196 % body, and then making it the \newlinechar in \scanmacro.
8197 %
8198 \def\scanctxt{% used as subroutine
8199   \catcode`\"=\other
8200   \catcode`\+=\other
8201   \catcode`\<=\other
8202   \catcode`\>=\other
8203   \catcode`\^=\other
8204   \catcode`\_=\other
8205   \catcode`\|=\other
8206   \catcode`\~=\other
8207   \passthroughcharstrue
8208 }
8209
8210 \def\scanargctxt{% used for copying and captions, not macros.
8211   \scanctxt
8212   \catcode`\@=\other
8213   \catcode`\\=\other
8214   \catcode`\^^M=\other
8215 }
8216
8217 \def\macrobodyctxt{% used for @macro definitions
8218   \scanctxt
8219   \catcode`\ =\other
8220   \catcode`\@=\other
8221   \catcode`\{=\other
8222   \catcode`\}=\other
8223   \catcode`\^^M=\other
8224   \usembodybackslash
8225 }
8226
8227 % Used when scanning braced macro arguments.  Note, however, that catcode
8228 % changes here are ineffectual if the macro invocation was nested inside
8229 % an argument to another Texinfo command.
8230 \def\macroargctxt{%
8231   \scanctxt
8232   \catcode`\ =\active
8233   \catcode`\@=\other
8234   \catcode`\^^M=\other
8235   \catcode`\\=\active
8236 }
8237
8238 \def\macrolineargctxt{% used for whole-line arguments without braces
8239   \scanctxt
8240   \catcode`\@=\other
8241   \catcode`\{=\other
8242   \catcode`\}=\other
8243 }
8244
8245 % \mbodybackslash is the definition of \ in @macro bodies.
8246 % It maps \foo\ => \csname macarg.foo\endcsname => #N
8247 % where N is the macro parameter number.
8248 % We define \csname macarg.\endcsname to be \realbackslash, so
8249 % \\ in macro replacement text gets you a backslash.
8250 %
8251 {\catcode`@=0 @catcode`@\=@active
8252  @gdef@usembodybackslash{@let\=@mbodybackslash}
8253  @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
8254 }
8255 \expandafter\def\csname macarg.\endcsname{\realbackslash}
8256
8257 \def\margbackslash#1{\char`\#1 }
8258
8259 \def\macro{\recursivefalse\parsearg\macroxxx}
8260 \def\rmacro{\recursivetrue\parsearg\macroxxx}
8261
8262 \def\macroxxx#1{%
8263   \getargs{#1}% now \macname is the macname and \argl the arglist
8264   \ifx\argl\empty       % no arguments
8265      \paramno=0\relax
8266   \else
8267      \expandafter\parsemargdef \argl;%
8268      \if\paramno>256\relax
8269        \ifx\eTeXversion\thisisundefined
8270          \errhelp = \EMsimple
8271          \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
8272        \fi
8273      \fi
8274   \fi
8275   \if1\csname ismacro.\the\macname\endcsname
8276      \message{Warning: redefining \the\macname}%
8277   \else
8278      \expandafter\ifx\csname \the\macname\endcsname \relax
8279      \else \errmessage{Macro name \the\macname\space already defined}\fi
8280      \global\cslet{macsave.\the\macname}{\the\macname}%
8281      \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
8282      \addtomacrolist{\the\macname}%
8283   \fi
8284   \begingroup \macrobodyctxt
8285   \ifrecursive \expandafter\parsermacbody
8286   \else \expandafter\parsemacbody
8287   \fi}
8288
8289 \parseargdef\unmacro{%
8290   \if1\csname ismacro.#1\endcsname
8291     \global\cslet{#1}{macsave.#1}%
8292     \global\expandafter\let \csname ismacro.#1\endcsname=0%
8293     % Remove the macro name from \macrolist:
8294     \begingroup
8295       \expandafter\let\csname#1\endcsname \relax
8296       \let\commondummyword\unmacrodo
8297       \xdef\macrolist{\macrolist}%
8298     \endgroup
8299   \else
8300     \errmessage{Macro #1 not defined}%
8301   \fi
8302 }
8303
8304 % Called by \do from \dounmacro on each macro.  The idea is to omit any
8305 % macro definitions that have been changed to \relax.
8306 %
8307 \def\unmacrodo#1{%
8308   \ifx #1\relax
8309     % remove this
8310   \else
8311     \noexpand\commondummyword \noexpand#1%
8312   \fi
8313 }
8314
8315 % \getargs -- Parse the arguments to a @macro line.  Set \macname to
8316 % the name of the macro, and \argl to the braced argument list.
8317 \def\getargs#1{\getargsxxx#1{}}
8318 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
8319 \def\getmacname#1 #2\relax{\macname={#1}}
8320 \def\getmacargs#1{\def\argl{#1}}
8321 % This made use of the feature that if the last token of a
8322 % <parameter list> is #, then the preceding argument is delimited by
8323 % an opening brace, and that opening brace is not consumed.
8324
8325 % Parse the optional {params} list to @macro or @rmacro.
8326 % Set \paramno to the number of arguments,
8327 % and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
8328 % three-param macro.)  Define \macarg.BLAH for each BLAH in the params
8329 % list to some hook where the argument is to be expanded.  If there are
8330 % less than 10 arguments that hook is to be replaced by ##N where N
8331 % is the position in that list, that is to say the macro arguments are to be
8332 % defined `a la TeX in the macro body.
8333 %
8334 % That gets used by \mbodybackslash (above).
8335 %
8336 % If there are 10 or more arguments, a different technique is used: see
8337 % \parsemmanyargdef.
8338 %
8339 \def\parsemargdef#1;{%
8340   \paramno=0\def\paramlist{}%
8341   \let\hash\relax
8342   % \hash is redefined to `#' later to get it into definitions
8343   \let\xeatspaces\relax
8344   \parsemargdefxxx#1,;,%
8345   \ifnum\paramno<10\relax\else
8346     \paramno0\relax
8347     \parsemmanyargdef@@#1,;,% 10 or more arguments
8348   \fi
8349 }
8350 \def\parsemargdefxxx#1,{%
8351   \if#1;\let\next=\relax
8352   \else \let\next=\parsemargdefxxx
8353     \advance\paramno by 1
8354     \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
8355         {\xeatspaces{\hash\the\paramno}}%
8356     \edef\paramlist{\paramlist\hash\the\paramno,}%
8357   \fi\next}
8358
8359 % \parsemacbody, \parsermacbody
8360 %
8361 % Read recursive and nonrecursive macro bodies. (They're different since
8362 % rec and nonrec macros end differently.)
8363 %
8364 % We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro
8365 % body to be transformed.
8366 % Set \macrobody to the body of the macro, and call \defmacro.
8367 %
8368 {\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{%
8369 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8370 {\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
8371 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8372
8373 % Make @ a letter, so that we can make private-to-Texinfo macro names.
8374 \edef\texiatcatcode{\the\catcode`\@}
8375 \catcode `@=11\relax
8376
8377 %%%%%%%%%%%%%% Code for > 10 arguments only   %%%%%%%%%%%%%%%%%%
8378
8379 % If there are 10 or more arguments, a different technique is used, where the
8380 % hook remains in the body, and when macro is to be expanded the body is
8381 % processed again to replace the arguments.
8382 %
8383 % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
8384 % argument N value and then \edef the body (nothing else will expand because of
8385 % the catcode regime under which the body was input).
8386 %
8387 % If you compile with TeX (not eTeX), and you have macros with 10 or more
8388 % arguments, no macro can have more than 256 arguments (else error).
8389 %
8390 % In case that there are 10 or more arguments we parse again the arguments
8391 % list to set new definitions for the \macarg.BLAH macros corresponding to
8392 % each BLAH argument. It was anyhow needed to parse already once this list
8393 % in order to count the arguments, and as macros with at most 9 arguments
8394 % are by far more frequent than macro with 10 or more arguments, defining
8395 % twice the \macarg.BLAH macros does not cost too much processing power.
8396 \def\parsemmanyargdef@@#1,{%
8397   \if#1;\let\next=\relax
8398   \else
8399     \let\next=\parsemmanyargdef@@
8400     \edef\tempb{\eatspaces{#1}}%
8401     \expandafter\def\expandafter\tempa
8402        \expandafter{\csname macarg.\tempb\endcsname}%
8403     % Note that we need some extra \noexpand\noexpand, this is because we
8404     % don't want \the  to be expanded in the \parsermacbody  as it uses an
8405     % \xdef .
8406     \expandafter\edef\tempa
8407       {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
8408     \advance\paramno by 1\relax
8409   \fi\next}
8410
8411
8412 \let\endargs@\relax
8413 \let\nil@\relax
8414 \def\nilm@{\nil@}%
8415 \long\def\nillm@{\nil@}%
8416
8417 % This macro is expanded during the Texinfo macro expansion, not during its
8418 % definition.  It gets all the arguments' values and assigns them to macros
8419 % macarg.ARGNAME
8420 %
8421 % #1 is the macro name
8422 % #2 is the list of argument names
8423 % #3 is the list of argument values
8424 \def\getargvals@#1#2#3{%
8425   \def\macargdeflist@{}%
8426   \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
8427   \def\paramlist{#2,\nil@}%
8428   \def\macroname{#1}%
8429   \begingroup
8430   \macroargctxt
8431   \def\argvaluelist{#3,\nil@}%
8432   \def\@tempa{#3}%
8433   \ifx\@tempa\empty
8434     \setemptyargvalues@
8435   \else
8436     \getargvals@@
8437   \fi
8438 }
8439 \def\getargvals@@{%
8440   \ifx\paramlist\nilm@
8441       % Some sanity check needed here that \argvaluelist is also empty.
8442       \ifx\argvaluelist\nillm@
8443       \else
8444         \errhelp = \EMsimple
8445         \errmessage{Too many arguments in macro `\macroname'!}%
8446       \fi
8447       \let\next\macargexpandinbody@
8448   \else
8449     \ifx\argvaluelist\nillm@
8450        % No more arguments values passed to macro.  Set remaining named-arg
8451        % macros to empty.
8452        \let\next\setemptyargvalues@
8453     \else
8454       % pop current arg name into \@tempb
8455       \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
8456       \expandafter\@tempa\expandafter{\paramlist}%
8457        % pop current argument value into \@tempc
8458       \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
8459       \expandafter\@tempa\expandafter{\argvaluelist}%
8460        % Here \@tempb is the current arg name and \@tempc is the current arg value.
8461        % First place the new argument macro definition into \@tempd
8462        \expandafter\macname\expandafter{\@tempc}%
8463        \expandafter\let\csname macarg.\@tempb\endcsname\relax
8464        \expandafter\def\expandafter\@tempe\expandafter{%
8465          \csname macarg.\@tempb\endcsname}%
8466        \edef\@tempd{\long\def\@tempe{\the\macname}}%
8467        \push@\@tempd\macargdeflist@
8468        \let\next\getargvals@@
8469     \fi
8470   \fi
8471   \next
8472 }
8473
8474 \def\push@#1#2{%
8475   \expandafter\expandafter\expandafter\def
8476   \expandafter\expandafter\expandafter#2%
8477   \expandafter\expandafter\expandafter{%
8478   \expandafter#1#2}%
8479 }
8480
8481 % Replace arguments by their values in the macro body, and place the result
8482 % in macro \@tempa.
8483 %
8484 \def\macvalstoargs@{%
8485   %  To do this we use the property that token registers that are \the'ed
8486   % within an \edef  expand only once. So we are going to place all argument
8487   % values into respective token registers.
8488   %
8489   % First we save the token context, and initialize argument numbering.
8490   \begingroup
8491     \paramno0\relax
8492     % Then, for each argument number #N, we place the corresponding argument
8493     % value into a new token list register \toks#N
8494     \expandafter\putargsintokens@\saveparamlist@,;,%
8495     % Then, we expand the body so that argument are replaced by their
8496     % values. The trick for values not to be expanded themselves is that they
8497     % are within tokens and that tokens expand only once in an \edef .
8498     \edef\@tempc{\csname mac.\macroname .body\endcsname}%
8499     % Now we restore the token stack pointer to free the token list registers
8500     % which we have used, but we make sure that expanded body is saved after
8501     % group.
8502     \expandafter
8503   \endgroup
8504   \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
8505   }
8506
8507 % Define the named-macro outside of this group and then close this group.
8508 %
8509 \def\macargexpandinbody@{%
8510   \expandafter
8511   \endgroup
8512   \macargdeflist@
8513   % First the replace in body the macro arguments by their values, the result
8514   % is in \@tempa .
8515   \macvalstoargs@
8516   % Then we point at the \norecurse or \gobble (for recursive) macro value
8517   % with \@tempb .
8518   \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
8519   % Depending on whether it is recursive or not, we need some tailing
8520   % \egroup .
8521   \ifx\@tempb\gobble
8522      \let\@tempc\relax
8523   \else
8524      \let\@tempc\egroup
8525   \fi
8526   % And now we do the real job:
8527   \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
8528   \@tempd
8529 }
8530
8531 \def\putargsintokens@#1,{%
8532   \if#1;\let\next\relax
8533   \else
8534     \let\next\putargsintokens@
8535     % First we allocate the new token list register, and give it a temporary
8536     % alias \@tempb .
8537     \toksdef\@tempb\the\paramno
8538     % Then we place the argument value into that token list register.
8539     \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
8540     \expandafter\@tempb\expandafter{\@tempa}%
8541     \advance\paramno by 1\relax
8542   \fi
8543   \next
8544 }
8545
8546 % Trailing missing arguments are set to empty.
8547 %
8548 \def\setemptyargvalues@{%
8549   \ifx\paramlist\nilm@
8550     \let\next\macargexpandinbody@
8551   \else
8552     \expandafter\setemptyargvaluesparser@\paramlist\endargs@
8553     \let\next\setemptyargvalues@
8554   \fi
8555   \next
8556 }
8557
8558 \def\setemptyargvaluesparser@#1,#2\endargs@{%
8559   \expandafter\def\expandafter\@tempa\expandafter{%
8560     \expandafter\def\csname macarg.#1\endcsname{}}%
8561   \push@\@tempa\macargdeflist@
8562   \def\paramlist{#2}%
8563 }
8564
8565 % #1 is the element target macro
8566 % #2 is the list macro
8567 % #3,#4\endargs@ is the list value
8568 \def\pop@#1#2#3,#4\endargs@{%
8569    \def#1{#3}%
8570    \def#2{#4}%
8571 }
8572 \long\def\longpop@#1#2#3,#4\endargs@{%
8573    \long\def#1{#3}%
8574    \long\def#2{#4}%
8575 }
8576
8577
8578 %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
8579
8580
8581 % This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
8582 %    \macrobody has the body of the macro in it, with placeholders for
8583 % its parameters, looking like "\xeatspaces{\hash 1}".
8584 %    \paramno is the number of parameters
8585 %    \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
8586 % There are four cases: macros of zero, one, up to nine, and many arguments.
8587 % \xdef is used so that macro definitions will survive the file
8588 % they're defined in: @include reads the file inside a group.
8589 %
8590 \def\defmacro{%
8591   \let\hash=##% convert placeholders to macro parameter chars
8592   \ifnum\paramno=1
8593     \def\xeatspaces##1{##1}%
8594     % This removes the pair of braces around the argument.  We don't
8595     % use \eatspaces, because this can cause ends of lines to be lost
8596     % when the argument to \eatspaces is read, leading to line-based
8597     % commands like "@itemize" not being read correctly.
8598   \else
8599     \let\xeatspaces\relax % suppress expansion
8600   \fi
8601   \ifcase\paramno
8602   % 0
8603     \expandafter\xdef\csname\the\macname\endcsname{%
8604       \bgroup
8605         \noexpand\spaceisspace
8606         \noexpand\endlineisspace
8607         \noexpand\expandafter % skip any whitespace after the macro name.
8608         \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8609     \expandafter\xdef\csname\the\macname @@@\endcsname{%
8610       \egroup
8611       \noexpand\scanmacro{\macrobody}}%
8612   \or % 1
8613     \expandafter\xdef\csname\the\macname\endcsname{%
8614        \bgroup
8615        \noexpand\braceorline
8616        \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8617     \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8618       \egroup
8619       \noexpand\scanmacro{\macrobody}%
8620       }%
8621   \else % at most 9
8622     \ifnum\paramno<10\relax
8623       % @MACNAME sets the context for reading the macro argument
8624       % @MACNAME@@ gets the argument, processes backslashes and appends a
8625       % comma.
8626       % @MACNAME@@@ removes braces surrounding the argument list.
8627       % @MACNAME@@@@ scans the macro body with arguments substituted.
8628       \expandafter\xdef\csname\the\macname\endcsname{%
8629         \bgroup
8630         \noexpand\expandafter  % This \expandafter skip any spaces after the
8631         \noexpand\macroargctxt % macro before we change the catcode of space.
8632         \noexpand\expandafter
8633         \expandafter\noexpand\csname\the\macname @@\endcsname}%
8634       \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8635           \noexpand\passargtomacro
8636           \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8637       \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8638           \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8639       \expandafter\expandafter
8640       \expandafter\xdef
8641       \expandafter\expandafter
8642         \csname\the\macname @@@@\endcsname\paramlist{%
8643           \egroup\noexpand\scanmacro{\macrobody}}%
8644     \else % 10 or more:
8645       \expandafter\xdef\csname\the\macname\endcsname{%
8646         \noexpand\getargvals@{\the\macname}{\argl}%
8647       }%
8648       \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8649       \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
8650     \fi
8651   \fi}
8652
8653 \catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
8654
8655 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
8656
8657
8658 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8659 %
8660 {\catcode`\@=0 \catcode`\\=13  % We need to manipulate \ so use @ as escape
8661 @catcode`@_=11  % private names
8662 @catcode`@!=11  % used as argument separator
8663
8664 % \passargtomacro#1#2 -
8665 % Call #1 with a list of tokens #2, with any doubled backslashes in #2
8666 % compressed to one.
8667 %
8668 % This implementation works by expansion, and not execution (so we cannot use
8669 % \def or similar).  This reduces the risk of this failing in contexts where
8670 % complete expansion is done with no execution (for example, in writing out to
8671 % an auxiliary file for an index entry).
8672 %
8673 % State is kept in the input stream: the argument passed to
8674 % @look_ahead, @gobble_and_check_finish and @add_segment is
8675 %
8676 % THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN  (... rest of input)
8677 %
8678 % where:
8679 % THE_MACRO - name of the macro we want to call
8680 % ARG_RESULT - argument list we build to pass to that macro
8681 % PENDING_BS - either a backslash or nothing
8682 % NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
8683
8684 @gdef@passargtomacro#1#2{%
8685   @add_segment #1!{}@relax#2\@_finish\%
8686 }
8687 @gdef@_finish{@_finishx} @global@let@_finishx@relax
8688
8689 % #1 - THE_MACRO ARG_RESULT
8690 % #2 - PENDING_BS
8691 % #3 - NEXT_TOKEN
8692 % #4 used to look ahead
8693 %
8694 % If the next token is not a backslash, process the rest of the argument;
8695 % otherwise, remove the next token.
8696 @gdef@look_ahead#1!#2#3#4{%
8697   @ifx#4\%
8698    @expandafter@gobble_and_check_finish
8699   @else
8700    @expandafter@add_segment
8701   @fi#1!{#2}#4#4%
8702 }
8703
8704 % #1 - THE_MACRO ARG_RESULT
8705 % #2 - PENDING_BS
8706 % #3 - NEXT_TOKEN
8707 % #4 should be a backslash, which is gobbled.
8708 % #5 looks ahead
8709 %
8710 % Double backslash found.  Add a single backslash, and look ahead.
8711 @gdef@gobble_and_check_finish#1!#2#3#4#5{%
8712   @add_segment#1\!{}#5#5%
8713 }
8714
8715 @gdef@is_fi{@fi}
8716
8717 % #1 - THE_MACRO ARG_RESULT
8718 % #2 - PENDING_BS
8719 % #3 - NEXT_TOKEN
8720 % #4 is input stream until next backslash
8721 %
8722 % Input stream is either at the start of the argument, or just after a
8723 % backslash sequence, either a lone backslash, or a doubled backslash.
8724 % NEXT_TOKEN contains the first token in the input stream: if it is \finish,
8725 % finish; otherwise, append to ARG_RESULT the segment of the argument up until
8726 % the next backslash.  PENDING_BACKSLASH contains a backslash to represent
8727 % a backslash just before the start of the input stream that has not been
8728 % added to ARG_RESULT.
8729 @gdef@add_segment#1!#2#3#4\{%
8730 @ifx#3@_finish
8731   @call_the_macro#1!%
8732 @else
8733   % append the pending backslash to the result, followed by the next segment
8734   @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
8735   % this @fi is discarded by @look_ahead.
8736   % we can't get rid of it with \expandafter because we don't know how
8737   % long #4 is.
8738 }
8739
8740 % #1 - THE_MACRO
8741 % #2 - ARG_RESULT
8742 % #3 discards the res of the conditional in @add_segment, and @is_fi ends the
8743 % conditional.
8744 @gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
8745
8746 }
8747 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8748
8749 % \braceorline MAC is used for a one-argument macro MAC.  It checks
8750 % whether the next non-whitespace character is a {.  It sets the context
8751 % for reading the argument (slightly different in the two cases).  Then,
8752 % to read the argument, in the whole-line case, it then calls the regular
8753 % \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
8754 %
8755 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
8756 \def\braceorlinexxx{%
8757   \ifx\nchar\bgroup
8758     \macroargctxt
8759     \expandafter\passargtomacro
8760   \else
8761     \macrolineargctxt\expandafter\parsearg
8762   \fi \macnamexxx}
8763
8764
8765 % @alias.
8766 % We need some trickery to remove the optional spaces around the equal
8767 % sign.  Make them active and then expand them all to nothing.
8768 %
8769 \def\alias{\parseargusing\obeyspaces\aliasxxx}
8770 \def\aliasxxx #1{\aliasyyy#1\relax}
8771 \def\aliasyyy #1=#2\relax{%
8772   {%
8773     \expandafter\let\obeyedspace=\empty
8774     \addtomacrolist{#1}%
8775     \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
8776   }%
8777   \next
8778 }
8779
8780
8781 \message{cross references,}
8782
8783 \newwrite\auxfile
8784 \newif\ifhavexrefs    % True if xref values are known.
8785 \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
8786
8787 % @inforef is relatively simple.
8788 \def\inforef #1{\inforefzzz #1,,,,**}
8789 \def\inforefzzz #1,#2,#3,#4**{%
8790   \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
8791   node \samp{\ignorespaces#1{}}}
8792
8793 % @node's only job in TeX is to define \lastnode, which is used in
8794 % cross-references.  The @node line might or might not have commas, and
8795 % might or might not have spaces before the first comma, like:
8796 % @node foo , bar , ...
8797 % We don't want such trailing spaces in the node name.
8798 %
8799 \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
8800 %
8801 % also remove a trailing comma, in case of something like this:
8802 % @node Help-Cross,  ,  , Cross-refs
8803 \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
8804 \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}\omittopnode}
8805
8806 % Used so that the @top node doesn't have to be wrapped in an @ifnottex
8807 % conditional.
8808 % \doignore goes to more effort to skip nested conditionals but we don't need
8809 % that here.
8810 \def\omittopnode{%
8811    \ifx\lastnode\wordTop
8812    \expandafter\ignorenode\fi
8813 }
8814 \def\wordTop{Top}
8815
8816 % Until the next @node or @bye command, divert output to a box that is not
8817 % output.
8818 \def\ignorenode{\setbox\dummybox\vbox\bgroup\def\node{\egroup\node}%
8819 \ignorenodebye
8820 }
8821
8822 {\let\bye\relax
8823 \gdef\ignorenodebye{\let\bye\ignorenodebyedef}
8824 \gdef\ignorenodebyedef{\egroup(`Top' node ignored)\bye}}
8825 % The redefinition of \bye here is because it is declared \outer
8826
8827 \let\lastnode=\empty
8828
8829 % Write a cross-reference definition for the current node.  #1 is the
8830 % type (Ynumbered, Yappendix, Ynothing).
8831 %
8832 \def\donoderef#1{%
8833   \ifx\lastnode\empty\else
8834     \setref{\lastnode}{#1}%
8835     \global\let\lastnode=\empty
8836   \fi
8837 }
8838
8839 % @anchor{NAME} -- define xref target at arbitrary point.
8840 %
8841 \newcount\savesfregister
8842 %
8843 \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
8844 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
8845 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
8846
8847 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
8848 % anchor), which consists of three parts:
8849 % 1) NAME-title - the current sectioning name taken from \currentsection,
8850 %                 or the anchor name.
8851 % 2) NAME-snt   - section number and type, passed as the SNT arg, or
8852 %                 empty for anchors.
8853 % 3) NAME-pg    - the page number.
8854 %
8855 % This is called from \donoderef, \anchor, and \dofloat.  In the case of
8856 % floats, there is an additional part, which is not written here:
8857 % 4) NAME-lof   - the text as it should appear in a @listoffloats.
8858 %
8859 \def\setref#1#2{%
8860   \pdfmkdest{#1}%
8861   \iflinks
8862     {%
8863       \requireauxfile
8864       \atdummies  % preserve commands, but don't expand them
8865       % match definition in \xrdef, \refx, \xrefX.
8866       \def\value##1{##1}%
8867       \edef\writexrdef##1##2{%
8868         \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
8869           ##1}{##2}}% these are parameters of \writexrdef
8870       }%
8871       \toks0 = \expandafter{\currentsection}%
8872       \immediate \writexrdef{title}{\the\toks0 }%
8873       \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
8874       \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
8875     }%
8876   \fi
8877 }
8878
8879 % @xrefautosectiontitle on|off says whether @section(ing) names are used
8880 % automatically in xrefs, if the third arg is not explicitly specified.
8881 % This was provided as a "secret" @set xref-automatic-section-title
8882 % variable, now it's official.
8883 %
8884 \parseargdef\xrefautomaticsectiontitle{%
8885   \def\temp{#1}%
8886   \ifx\temp\onword
8887     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8888       = \empty
8889   \else\ifx\temp\offword
8890     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8891       = \relax
8892   \else
8893     \errhelp = \EMsimple
8894     \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
8895                 must be on|off}%
8896   \fi\fi
8897 }
8898
8899 %
8900 % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
8901 % the node name, #2 the name of the Info cross-reference, #3 the printed
8902 % node name, #4 the name of the Info file, #5 the name of the printed
8903 % manual.  All but the node name can be omitted.
8904 %
8905 \def\pxref{\putwordsee{} \xrefXX}
8906 \def\xref{\putwordSee{} \xrefXX}
8907 \def\ref{\xrefXX}
8908
8909 \def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
8910 \def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
8911 %
8912 \newbox\toprefbox
8913 \newbox\printedrefnamebox
8914 \newbox\infofilenamebox
8915 \newbox\printedmanualbox
8916 %
8917 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
8918   \unsepspaces
8919   %
8920   % Get args without leading/trailing spaces.
8921   \def\printedrefname{\ignorespaces #3}%
8922   \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
8923   %
8924   \def\infofilename{\ignorespaces #4}%
8925   \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
8926   %
8927   \def\printedmanual{\ignorespaces #5}%
8928   \setbox\printedmanualbox  = \hbox{\printedmanual\unskip}%
8929   %
8930   % If the printed reference name (arg #3) was not explicitly given in
8931   % the @xref, figure out what we want to use.
8932   \ifdim \wd\printedrefnamebox = 0pt
8933     % No printed node name was explicitly given.
8934     \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
8935       % Not auto section-title: use node name inside the square brackets.
8936       \def\printedrefname{\ignorespaces #1}%
8937     \else
8938       % Auto section-title: use chapter/section title inside
8939       % the square brackets if we have it.
8940       \ifdim \wd\printedmanualbox > 0pt
8941         % It is in another manual, so we don't have it; use node name.
8942         \def\printedrefname{\ignorespaces #1}%
8943       \else
8944         \ifhavexrefs
8945           % We (should) know the real title if we have the xref values.
8946           \def\printedrefname{\refx{#1-title}{}}%
8947         \else
8948           % Otherwise just copy the Info node name.
8949           \def\printedrefname{\ignorespaces #1}%
8950         \fi%
8951       \fi
8952     \fi
8953   \fi
8954   %
8955   % Make link in pdf output.
8956   \ifpdf
8957     % For pdfTeX and LuaTeX
8958     {\indexnofonts
8959      \makevalueexpandable
8960      \turnoffactive
8961      % This expands tokens, so do it after making catcode changes, so _
8962      % etc. don't get their TeX definitions.  This ignores all spaces in
8963      % #4, including (wrongly) those in the middle of the filename.
8964      \getfilename{#4}%
8965      %
8966      % This (wrongly) does not take account of leading or trailing
8967      % spaces in #1, which should be ignored.
8968      \setpdfdestname{#1}%
8969      %
8970      \ifx\pdfdestname\empty
8971        \def\pdfdestname{Top}% no empty targets
8972      \fi
8973      %
8974      \leavevmode
8975      \startlink attr{/Border [0 0 0]}%
8976      \ifnum\filenamelength>0
8977        goto file{\the\filename.pdf} name{\pdfdestname}%
8978      \else
8979        goto name{\pdfmkpgn{\pdfdestname}}%
8980      \fi
8981     }%
8982     \setcolor{\linkcolor}%
8983   \else
8984     \ifx\XeTeXrevision\thisisundefined
8985     \else
8986       % For XeTeX
8987       {\indexnofonts
8988        \makevalueexpandable
8989        \turnoffactive
8990        % This expands tokens, so do it after making catcode changes, so _
8991        % etc. don't get their TeX definitions.  This ignores all spaces in
8992        % #4, including (wrongly) those in the middle of the filename.
8993        \getfilename{#4}%
8994        %
8995        % This (wrongly) does not take account of leading or trailing
8996        % spaces in #1, which should be ignored.
8997        \setpdfdestname{#1}%
8998        %
8999        \ifx\pdfdestname\empty
9000          \def\pdfdestname{Top}% no empty targets
9001        \fi
9002        %
9003        \leavevmode
9004        \ifnum\filenamelength>0
9005          % With default settings,
9006          % XeTeX (xdvipdfmx) replaces link destination names with integers.
9007          % In this case, the replaced destination names of
9008          % remote PDFs are no longer known.  In order to avoid a replacement,
9009          % you can use xdvipdfmx's command line option `-C 0x0010'.
9010          % If you use XeTeX 0.99996+ (TeX Live 2016+),
9011          % this command line option is no longer necessary
9012          % because we can use the `dvipdfmx:config' special.
9013          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
9014            << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}%
9015        \else
9016          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
9017            << /S /GoTo /D (\pdfdestname) >> >>}%
9018        \fi
9019       }%
9020       \setcolor{\linkcolor}%
9021     \fi
9022   \fi
9023   {%
9024     % Have to otherify everything special to allow the \csname to
9025     % include an _ in the xref name, etc.
9026     \indexnofonts
9027     \turnoffactive
9028     \def\value##1{##1}%
9029     \expandafter\global\expandafter\let\expandafter\Xthisreftitle
9030       \csname XR#1-title\endcsname
9031   }%
9032   %
9033   % Float references are printed completely differently: "Figure 1.2"
9034   % instead of "[somenode], p.3".  \iffloat distinguishes them by
9035   % \Xthisreftitle being set to a magic string.
9036   \iffloat\Xthisreftitle
9037     % If the user specified the print name (third arg) to the ref,
9038     % print it instead of our usual "Figure 1.2".
9039     \ifdim\wd\printedrefnamebox = 0pt
9040       \refx{#1-snt}{}%
9041     \else
9042       \printedrefname
9043     \fi
9044     %
9045     % If the user also gave the printed manual name (fifth arg), append
9046     % "in MANUALNAME".
9047     \ifdim \wd\printedmanualbox > 0pt
9048       \space \putwordin{} \cite{\printedmanual}%
9049     \fi
9050   \else
9051     % node/anchor (non-float) references.
9052     %
9053     % If we use \unhbox to print the node names, TeX does not insert
9054     % empty discretionaries after hyphens, which means that it will not
9055     % find a line break at a hyphen in a node names.  Since some manuals
9056     % are best written with fairly long node names, containing hyphens,
9057     % this is a loss.  Therefore, we give the text of the node name
9058     % again, so it is as if TeX is seeing it for the first time.
9059     %
9060     \ifdim \wd\printedmanualbox > 0pt
9061       % Cross-manual reference with a printed manual name.
9062       %
9063       \crossmanualxref{\cite{\printedmanual\unskip}}%
9064     %
9065     \else\ifdim \wd\infofilenamebox > 0pt
9066       % Cross-manual reference with only an info filename (arg 4), no
9067       % printed manual name (arg 5).  This is essentially the same as
9068       % the case above; we output the filename, since we have nothing else.
9069       %
9070       \crossmanualxref{\code{\infofilename\unskip}}%
9071     %
9072     \else
9073       % Reference within this manual.
9074       %
9075       % Only output a following space if the -snt ref is nonempty; for
9076       % @unnumbered and @anchor, it won't be.
9077       \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
9078       \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
9079       %
9080       % output the `[mynode]' via the macro below so it can be overridden.
9081       \xrefprintnodename\printedrefname
9082       %
9083       % But we always want a comma and a space:
9084       ,\space
9085       %
9086       % output the `page 3'.
9087       \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
9088       % Add a , if xref followed by a space
9089       \if\space\noexpand\tokenafterxref ,%
9090       \else\ifx\        \tokenafterxref ,% @TAB
9091       \else\ifx\*\tokenafterxref ,%   @*
9092       \else\ifx\ \tokenafterxref ,%   @SPACE
9093       \else\ifx\
9094                 \tokenafterxref ,%    @NL
9095       \else\ifx\tie\tokenafterxref ,% @tie
9096       \fi\fi\fi\fi\fi\fi
9097     \fi\fi
9098   \fi
9099   \endlink
9100 \endgroup}
9101
9102 % Output a cross-manual xref to #1.  Used just above (twice).
9103 %
9104 % Only include the text "Section ``foo'' in" if the foo is neither
9105 % missing or Top.  Thus, @xref{,,,foo,The Foo Manual} outputs simply
9106 % "see The Foo Manual", the idea being to refer to the whole manual.
9107 %
9108 % But, this being TeX, we can't easily compare our node name against the
9109 % string "Top" while ignoring the possible spaces before and after in
9110 % the input.  By adding the arbitrary 7sp below, we make it much less
9111 % likely that a real node name would have the same width as "Top" (e.g.,
9112 % in a monospaced font).  Hopefully it will never happen in practice.
9113 %
9114 % For the same basic reason, we retypeset the "Top" at every
9115 % reference, since the current font is indeterminate.
9116 %
9117 \def\crossmanualxref#1{%
9118   \setbox\toprefbox = \hbox{Top\kern7sp}%
9119   \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
9120   \ifdim \wd2 > 7sp  % nonempty?
9121     \ifdim \wd2 = \wd\toprefbox \else  % same as Top?
9122       \putwordSection{} ``\printedrefname'' \putwordin{}\space
9123     \fi
9124   \fi
9125   #1%
9126 }
9127
9128 % This macro is called from \xrefX for the `[nodename]' part of xref
9129 % output.  It's a separate macro only so it can be changed more easily,
9130 % since square brackets don't work well in some documents.  Particularly
9131 % one that Bob is working on :).
9132 %
9133 \def\xrefprintnodename#1{[#1]}
9134
9135 % Things referred to by \setref.
9136 %
9137 \def\Ynothing{}
9138 \def\Yomitfromtoc{}
9139 \def\Ynumbered{%
9140   \ifnum\secno=0
9141     \putwordChapter@tie \the\chapno
9142   \else \ifnum\subsecno=0
9143     \putwordSection@tie \the\chapno.\the\secno
9144   \else \ifnum\subsubsecno=0
9145     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
9146   \else
9147     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
9148   \fi\fi\fi
9149 }
9150 \def\Yappendix{%
9151   \ifnum\secno=0
9152      \putwordAppendix@tie @char\the\appendixno{}%
9153   \else \ifnum\subsecno=0
9154      \putwordSection@tie @char\the\appendixno.\the\secno
9155   \else \ifnum\subsubsecno=0
9156     \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
9157   \else
9158     \putwordSection@tie
9159       @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
9160   \fi\fi\fi
9161 }
9162
9163 % \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME.  SUFFIX
9164 % is output afterwards if non-empty.
9165 \def\refx#1#2{%
9166   \requireauxfile
9167   {%
9168     \indexnofonts
9169     \turnoffactive
9170     \def\value##1{##1}%
9171     \expandafter\global\expandafter\let\expandafter\thisrefX
9172       \csname XR#1\endcsname
9173   }%
9174   \ifx\thisrefX\relax
9175     % If not defined, say something at least.
9176     \angleleft un\-de\-fined\angleright
9177     \iflinks
9178       \ifhavexrefs
9179         {\toks0 = {#1}% avoid expansion of possibly-complex value
9180          \message{\linenumber Undefined cross reference `\the\toks0'.}}%
9181       \else
9182         \ifwarnedxrefs\else
9183           \global\warnedxrefstrue
9184           \message{Cross reference values unknown; you must run TeX again.}%
9185         \fi
9186       \fi
9187     \fi
9188   \else
9189     % It's defined, so just use it.
9190     \thisrefX
9191   \fi
9192   #2% Output the suffix in any case.
9193 }
9194
9195 % This is the macro invoked by entries in the aux file.  Define a control
9196 % sequence for a cross-reference target (we prepend XR to the control sequence
9197 % name to avoid collisions).  The value is the page number.  If this is a float
9198 % type, we have more work to do.
9199 %
9200 \def\xrdef#1#2{%
9201   {% Expand the node or anchor name to remove control sequences.
9202    % \turnoffactive stops 8-bit characters being changed to commands
9203    % like @'e.  \refx does the same to retrieve the value in the definition.
9204     \indexnofonts
9205     \turnoffactive
9206     \def\value##1{##1}%
9207     \xdef\safexrefname{#1}%
9208   }%
9209   %
9210   \bgroup
9211     \expandafter\gdef\csname XR\safexrefname\endcsname{#2}%
9212   \egroup
9213   % We put the \gdef inside a group to avoid the definitions building up on
9214   % TeX's save stack, which can cause it to run out of space for aux files with
9215   % thousands of lines.  \gdef doesn't use the save stack, but \csname does
9216   % when it defines an unknown control sequence as \relax.
9217   %
9218   % Was that xref control sequence that we just defined for a float?
9219   \expandafter\iffloat\csname XR\safexrefname\endcsname
9220     % it was a float, and we have the (safe) float type in \iffloattype.
9221     \expandafter\let\expandafter\floatlist
9222       \csname floatlist\iffloattype\endcsname
9223     %
9224     % Is this the first time we've seen this float type?
9225     \expandafter\ifx\floatlist\relax
9226       \toks0 = {\do}% yes, so just \do
9227     \else
9228       % had it before, so preserve previous elements in list.
9229       \toks0 = \expandafter{\floatlist\do}%
9230     \fi
9231     %
9232     % Remember this xref in the control sequence \floatlistFLOATTYPE,
9233     % for later use in \listoffloats.
9234     \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
9235       {\safexrefname}}%
9236   \fi
9237 }
9238
9239 % If working on a large document in chapters, it is convenient to
9240 % be able to disable indexing, cross-referencing, and contents, for test runs.
9241 % This is done with @novalidate at the beginning of the file.
9242 %
9243 \newif\iflinks \linkstrue % by default we want the aux files.
9244 \let\novalidate = \linksfalse
9245
9246 % Used when writing to the aux file, or when using data from it.
9247 \def\requireauxfile{%
9248   \iflinks
9249     \tryauxfile
9250     % Open the new aux file.  TeX will close it automatically at exit.
9251     \immediate\openout\auxfile=\jobname.aux
9252   \fi
9253   \global\let\requireauxfile=\relax   % Only do this once.
9254 }
9255
9256 % Read the last existing aux file, if any.  No error if none exists.
9257 %
9258 \def\tryauxfile{%
9259   \openin 1 \jobname.aux
9260   \ifeof 1 \else
9261     \readdatafile{aux}%
9262     \global\havexrefstrue
9263   \fi
9264   \closein 1
9265 }
9266
9267 \def\setupdatafile{%
9268   \catcode`\^^@=\other
9269   \catcode`\^^A=\other
9270   \catcode`\^^B=\other
9271   \catcode`\^^C=\other
9272   \catcode`\^^D=\other
9273   \catcode`\^^E=\other
9274   \catcode`\^^F=\other
9275   \catcode`\^^G=\other
9276   \catcode`\^^H=\other
9277   \catcode`\^^K=\other
9278   \catcode`\^^L=\other
9279   \catcode`\^^N=\other
9280   \catcode`\^^P=\other
9281   \catcode`\^^Q=\other
9282   \catcode`\^^R=\other
9283   \catcode`\^^S=\other
9284   \catcode`\^^T=\other
9285   \catcode`\^^U=\other
9286   \catcode`\^^V=\other
9287   \catcode`\^^W=\other
9288   \catcode`\^^X=\other
9289   \catcode`\^^Z=\other
9290   \catcode`\^^[=\other
9291   \catcode`\^^\=\other
9292   \catcode`\^^]=\other
9293   \catcode`\^^^=\other
9294   \catcode`\^^_=\other
9295   \catcode`\^=\other
9296   %
9297   % Special characters.  Should be turned off anyway, but...
9298   \catcode`\~=\other
9299   \catcode`\[=\other
9300   \catcode`\]=\other
9301   \catcode`\"=\other
9302   \catcode`\_=\other
9303   \catcode`\|=\other
9304   \catcode`\<=\other
9305   \catcode`\>=\other
9306   \catcode`\$=\other
9307   \catcode`\#=\other
9308   \catcode`\&=\other
9309   \catcode`\%=\other
9310   \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
9311   %
9312   \catcode`\\=\active
9313   %
9314   % @ is our escape character in .aux files, and we need braces.
9315   \catcode`\{=1
9316   \catcode`\}=2
9317   \catcode`\@=0
9318 }
9319
9320 \def\readdatafile#1{%
9321 \begingroup
9322   \setupdatafile
9323   \input\jobname.#1
9324 \endgroup}
9325
9326
9327 \message{insertions,}
9328 % including footnotes.
9329
9330 \newcount \footnoteno
9331
9332 % The trailing space in the following definition for supereject is
9333 % vital for proper filling; pages come out unaligned when you do a
9334 % pagealignmacro call if that space before the closing brace is
9335 % removed. (Generally, numeric constants should always be followed by a
9336 % space to prevent strange expansion errors.)
9337 \def\supereject{\par\penalty -20000\footnoteno =0 }
9338
9339 % @footnotestyle is meaningful for Info output only.
9340 \let\footnotestyle=\comment
9341
9342 {\catcode `\@=11
9343 %
9344 % Auto-number footnotes.  Otherwise like plain.
9345 \gdef\footnote{%
9346   \global\advance\footnoteno by \@ne
9347   \edef\thisfootno{$^{\the\footnoteno}$}%
9348   %
9349   % In case the footnote comes at the end of a sentence, preserve the
9350   % extra spacing after we do the footnote number.
9351   \let\@sf\empty
9352   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9353   %
9354   % Remove inadvertent blank space before typesetting the footnote number.
9355   \unskip
9356   \thisfootno\@sf
9357   \dofootnote
9358 }%
9359
9360 % Don't bother with the trickery in plain.tex to not require the
9361 % footnote text as a parameter.  Our footnotes don't need to be so general.
9362 %
9363 % Oh yes, they do; otherwise, @ifset (and anything else that uses
9364 % \parseargline) fails inside footnotes because the tokens are fixed when
9365 % the footnote is read.  --karl, 16nov96.
9366 %
9367 \gdef\dofootnote{%
9368   \insert\footins\bgroup
9369   %
9370   % Nested footnotes are not supported in TeX, that would take a lot
9371   % more work.  (\startsavinginserts does not suffice.)
9372   \let\footnote=\errfootnotenest
9373   %
9374   % We want to typeset this text as a normal paragraph, even if the
9375   % footnote reference occurs in (for example) a display environment.
9376   % So reset some parameters.
9377   \hsize=\txipagewidth
9378   \interlinepenalty\interfootnotelinepenalty
9379   \splittopskip\ht\strutbox % top baseline for broken footnotes
9380   \splitmaxdepth\dp\strutbox
9381   \floatingpenalty\@MM
9382   \leftskip\z@skip
9383   \rightskip\z@skip
9384   \spaceskip\z@skip
9385   \xspaceskip\z@skip
9386   \parindent\defaultparindent
9387   %
9388   \smallfonts \rm
9389   %
9390   % Because we use hanging indentation in footnotes, a @noindent appears
9391   % to exdent this text, so make it be a no-op.  makeinfo does not use
9392   % hanging indentation so @noindent can still be needed within footnote
9393   % text after an @example or the like (not that this is good style).
9394   \let\noindent = \relax
9395   %
9396   % Hang the footnote text off the number.  Use \everypar in case the
9397   % footnote extends for more than one paragraph.
9398   \everypar = {\hang}%
9399   \textindent{\thisfootno}%
9400   %
9401   % Don't crash into the line above the footnote text.  Since this
9402   % expands into a box, it must come within the paragraph, lest it
9403   % provide a place where TeX can split the footnote.
9404   \footstrut
9405   %
9406   % Invoke rest of plain TeX footnote routine.
9407   \futurelet\next\fo@t
9408 }
9409 }%end \catcode `\@=11
9410
9411 \def\errfootnotenest{%
9412   \errhelp=\EMsimple
9413   \errmessage{Nested footnotes not supported in texinfo.tex,
9414     even though they work in makeinfo; sorry}
9415 }
9416
9417 \def\errfootnoteheading{%
9418   \errhelp=\EMsimple
9419   \errmessage{Footnotes in chapters, sections, etc., are not supported}
9420 }
9421
9422 % In case a @footnote appears in a vbox, save the footnote text and create
9423 % the real \insert just after the vbox finished.  Otherwise, the insertion
9424 % would be lost.
9425 % Similarly, if a @footnote appears inside an alignment, save the footnote
9426 % text to a box and make the \insert when a row of the table is finished.
9427 % And the same can be done for other insert classes.  --kasal, 16nov03.
9428 %
9429 % Replace the \insert primitive by a cheating macro.
9430 % Deeper inside, just make sure that the saved insertions are not spilled
9431 % out prematurely.
9432 %
9433 \def\startsavinginserts{%
9434   \ifx \insert\ptexinsert
9435     \let\insert\saveinsert
9436   \else
9437     \let\checkinserts\relax
9438   \fi
9439 }
9440
9441 % This \insert replacement works for both \insert\footins{foo} and
9442 % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9443 %
9444 \def\saveinsert#1{%
9445   \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9446   \afterassignment\next
9447   % swallow the left brace
9448   \let\temp =
9449 }
9450 \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9451 \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9452
9453 \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9454
9455 \def\placesaveins#1{%
9456   \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9457     {\box#1}%
9458 }
9459
9460 % eat @SAVE -- beware, all of them have catcode \other:
9461 {
9462   \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials  %  ;-)
9463   \gdef\gobblesave @SAVE{}
9464 }
9465
9466 % initialization:
9467 \def\newsaveins #1{%
9468   \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9469   \next
9470 }
9471 \def\newsaveinsX #1{%
9472   \csname newbox\endcsname #1%
9473   \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9474     \checksaveins #1}%
9475 }
9476
9477 % initialize:
9478 \let\checkinserts\empty
9479 \newsaveins\footins
9480 \newsaveins\margin
9481
9482
9483 % @image.  We use the macros from epsf.tex to support this.
9484 % If epsf.tex is not installed and @image is used, we complain.
9485 %
9486 % Check for and read epsf.tex up front.  If we read it only at @image
9487 % time, we might be inside a group, and then its definitions would get
9488 % undone and the next image would fail.
9489 \openin 1 = epsf.tex
9490 \ifeof 1 \else
9491   % Do not bother showing banner with epsf.tex v2.7k (available in
9492   % doc/epsf.tex and on ctan).
9493   \def\epsfannounce{\toks0 = }%
9494   \input epsf.tex
9495 \fi
9496 \closein 1
9497 %
9498 % We will only complain once about lack of epsf.tex.
9499 \newif\ifwarnednoepsf
9500 \newhelp\noepsfhelp{epsf.tex must be installed for images to
9501   work.  It is also included in the Texinfo distribution, or you can get
9502   it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.}
9503 %
9504 \def\image#1{%
9505   \ifx\epsfbox\thisisundefined
9506     \ifwarnednoepsf \else
9507       \errhelp = \noepsfhelp
9508       \errmessage{epsf.tex not found, images will be ignored}%
9509       \global\warnednoepsftrue
9510     \fi
9511   \else
9512     \imagexxx #1,,,,,\finish
9513   \fi
9514 }
9515 %
9516 % Arguments to @image:
9517 % #1 is (mandatory) image filename; we tack on .eps extension.
9518 % #2 is (optional) width, #3 is (optional) height.
9519 % #4 is (ignored optional) html alt text.
9520 % #5 is (ignored optional) extension.
9521 % #6 is just the usual extra ignored arg for parsing stuff.
9522 \newif\ifimagevmode
9523 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
9524   \catcode`\^^M = 5     % in case we're inside an example
9525   \normalturnoffactive  % allow _ et al. in names
9526   \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
9527   % If the image is by itself, center it.
9528   \ifvmode
9529     \imagevmodetrue
9530   \else \ifx\centersub\centerV
9531     % for @center @image, we need a vbox so we can have our vertical space
9532     \imagevmodetrue
9533     \vbox\bgroup % vbox has better behavior than vtop herev
9534   \fi\fi
9535   %
9536   \ifimagevmode
9537     \nobreak\medskip
9538     % Usually we'll have text after the image which will insert
9539     % \parskip glue, so insert it here too to equalize the space
9540     % above and below.
9541     \nobreak\vskip\parskip
9542     \nobreak
9543   \fi
9544   %
9545   % Leave vertical mode so that indentation from an enclosing
9546   %  environment such as @quotation is respected.
9547   % However, if we're at the top level, we don't want the
9548   %  normal paragraph indentation.
9549   % On the other hand, if we are in the case of @center @image, we don't
9550   %  want to start a paragraph, which will create a hsize-width box and
9551   %  eradicate the centering.
9552   \ifx\centersub\centerV\else \noindent \fi
9553   %
9554   % Output the image.
9555   \ifpdf
9556     % For pdfTeX and LuaTeX <= 0.80
9557     \dopdfimage{#1}{#2}{#3}%
9558   \else
9559     \ifx\XeTeXrevision\thisisundefined
9560       % For epsf.tex
9561       % \epsfbox itself resets \epsf?size at each figure.
9562       \setbox0 = \hbox{\ignorespaces #2}%
9563         \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9564       \setbox0 = \hbox{\ignorespaces #3}%
9565         \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9566       \epsfbox{#1.eps}%
9567     \else
9568       % For XeTeX
9569       \doxeteximage{#1}{#2}{#3}%
9570     \fi
9571   \fi
9572   %
9573   \ifimagevmode
9574     \medskip  % space after a standalone image
9575   \fi
9576   \ifx\centersub\centerV \egroup \fi
9577 \endgroup}
9578
9579
9580 % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9581 % etc.  We don't actually implement floating yet, we always include the
9582 % float "here".  But it seemed the best name for the future.
9583 %
9584 \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9585
9586 % There may be a space before second and/or third parameter; delete it.
9587 \def\eatcommaspace#1, {#1,}
9588
9589 % #1 is the optional FLOATTYPE, the text label for this float, typically
9590 % "Figure", "Table", "Example", etc.  Can't contain commas.  If omitted,
9591 % this float will not be numbered and cannot be referred to.
9592 %
9593 % #2 is the optional xref label.  Also must be present for the float to
9594 % be referable.
9595 %
9596 % #3 is the optional positioning argument; for now, it is ignored.  It
9597 % will somehow specify the positions allowed to float to (here, top, bottom).
9598 %
9599 % We keep a separate counter for each FLOATTYPE, which we reset at each
9600 % chapter-level command.
9601 \let\resetallfloatnos=\empty
9602 %
9603 \def\dofloat#1,#2,#3,#4\finish{%
9604   \let\thiscaption=\empty
9605   \let\thisshortcaption=\empty
9606   %
9607   % don't lose footnotes inside @float.
9608   %
9609   % BEWARE: when the floats start float, we have to issue warning whenever an
9610   % insert appears inside a float which could possibly float. --kasal, 26may04
9611   %
9612   \startsavinginserts
9613   %
9614   % We can't be used inside a paragraph.
9615   \par
9616   %
9617   \vtop\bgroup
9618     \def\floattype{#1}%
9619     \def\floatlabel{#2}%
9620     \def\floatloc{#3}% we do nothing with this yet.
9621     %
9622     \ifx\floattype\empty
9623       \let\safefloattype=\empty
9624     \else
9625       {%
9626         % the floattype might have accents or other special characters,
9627         % but we need to use it in a control sequence name.
9628         \indexnofonts
9629         \turnoffactive
9630         \xdef\safefloattype{\floattype}%
9631       }%
9632     \fi
9633     %
9634     % If label is given but no type, we handle that as the empty type.
9635     \ifx\floatlabel\empty \else
9636       % We want each FLOATTYPE to be numbered separately (Figure 1,
9637       % Table 1, Figure 2, ...).  (And if no label, no number.)
9638       %
9639       \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9640       \global\advance\floatno by 1
9641       %
9642       {%
9643         % This magic value for \currentsection is output by \setref as the
9644         % XREFLABEL-title value.  \xrefX uses it to distinguish float
9645         % labels (which have a completely different output format) from
9646         % node and anchor labels.  And \xrdef uses it to construct the
9647         % lists of floats.
9648         %
9649         \edef\currentsection{\floatmagic=\safefloattype}%
9650         \setref{\floatlabel}{Yfloat}%
9651       }%
9652     \fi
9653     %
9654     % start with \parskip glue, I guess.
9655     \vskip\parskip
9656     %
9657     % Don't suppress indentation if a float happens to start a section.
9658     \restorefirstparagraphindent
9659 }
9660
9661 % we have these possibilities:
9662 % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9663 % @float Foo,lbl & no caption:    Foo 1.1
9664 % @float Foo & @caption{Cap}:     Foo: Cap
9665 % @float Foo & no caption:        Foo
9666 % @float ,lbl & Caption{Cap}:     1.1: Cap
9667 % @float ,lbl & no caption:       1.1
9668 % @float & @caption{Cap}:         Cap
9669 % @float & no caption:
9670 %
9671 \def\Efloat{%
9672     \let\floatident = \empty
9673     %
9674     % In all cases, if we have a float type, it comes first.
9675     \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9676     %
9677     % If we have an xref label, the number comes next.
9678     \ifx\floatlabel\empty \else
9679       \ifx\floattype\empty \else % if also had float type, need tie first.
9680         \appendtomacro\floatident{\tie}%
9681       \fi
9682       % the number.
9683       \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9684     \fi
9685     %
9686     % Start the printed caption with what we've constructed in
9687     % \floatident, but keep it separate; we need \floatident again.
9688     \let\captionline = \floatident
9689     %
9690     \ifx\thiscaption\empty \else
9691       \ifx\floatident\empty \else
9692         \appendtomacro\captionline{: }% had ident, so need a colon between
9693       \fi
9694       %
9695       % caption text.
9696       \appendtomacro\captionline{\scanexp\thiscaption}%
9697     \fi
9698     %
9699     % If we have anything to print, print it, with space before.
9700     % Eventually this needs to become an \insert.
9701     \ifx\captionline\empty \else
9702       \vskip.5\parskip
9703       \captionline
9704       %
9705       % Space below caption.
9706       \vskip\parskip
9707     \fi
9708     %
9709     % If have an xref label, write the list of floats info.  Do this
9710     % after the caption, to avoid chance of it being a breakpoint.
9711     \ifx\floatlabel\empty \else
9712       % Write the text that goes in the lof to the aux file as
9713       % \floatlabel-lof.  Besides \floatident, we include the short
9714       % caption if specified, else the full caption if specified, else nothing.
9715       {%
9716         \requireauxfile
9717         \atdummies
9718         %
9719         \ifx\thisshortcaption\empty
9720           \def\gtemp{\thiscaption}%
9721         \else
9722           \def\gtemp{\thisshortcaption}%
9723         \fi
9724         \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
9725           \ifx\gtemp\empty \else : \gtemp \fi}}%
9726       }%
9727     \fi
9728   \egroup  % end of \vtop
9729   %
9730   \checkinserts
9731 }
9732
9733 % Append the tokens #2 to the definition of macro #1, not expanding either.
9734 %
9735 \def\appendtomacro#1#2{%
9736   \expandafter\def\expandafter#1\expandafter{#1#2}%
9737 }
9738
9739 % @caption, @shortcaption
9740 %
9741 \def\caption{\docaption\thiscaption}
9742 \def\shortcaption{\docaption\thisshortcaption}
9743 \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
9744 \def\defcaption#1#2{\egroup \def#1{#2}}
9745
9746 % The parameter is the control sequence identifying the counter we are
9747 % going to use.  Create it if it doesn't exist and assign it to \floatno.
9748 \def\getfloatno#1{%
9749   \ifx#1\relax
9750       % Haven't seen this figure type before.
9751       \csname newcount\endcsname #1%
9752       %
9753       % Remember to reset this floatno at the next chap.
9754       \expandafter\gdef\expandafter\resetallfloatnos
9755         \expandafter{\resetallfloatnos #1=0 }%
9756   \fi
9757   \let\floatno#1%
9758 }
9759
9760 % \setref calls this to get the XREFLABEL-snt value.  We want an @xref
9761 % to the FLOATLABEL to expand to "Figure 3.1".  We call \setref when we
9762 % first read the @float command.
9763 %
9764 \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9765
9766 % Magic string used for the XREFLABEL-title value, so \xrefX can
9767 % distinguish floats from other xref types.
9768 \def\floatmagic{!!float!!}
9769
9770 % #1 is the control sequence we are passed; we expand into a conditional
9771 % which is true if #1 represents a float ref.  That is, the magic
9772 % \currentsection value which we \setref above.
9773 %
9774 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
9775 %
9776 % #1 is (maybe) the \floatmagic string.  If so, #2 will be the
9777 % (safe) float type for this float.  We set \iffloattype to #2.
9778 %
9779 \def\doiffloat#1=#2=#3\finish{%
9780   \def\temp{#1}%
9781   \def\iffloattype{#2}%
9782   \ifx\temp\floatmagic
9783 }
9784
9785 % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9786 %
9787 \parseargdef\listoffloats{%
9788   \def\floattype{#1}% floattype
9789   {%
9790     % the floattype might have accents or other special characters,
9791     % but we need to use it in a control sequence name.
9792     \indexnofonts
9793     \turnoffactive
9794     \xdef\safefloattype{\floattype}%
9795   }%
9796   %
9797   % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9798   \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9799     \ifhavexrefs
9800       % if the user said @listoffloats foo but never @float foo.
9801       \message{\linenumber No `\safefloattype' floats to list.}%
9802     \fi
9803   \else
9804     \begingroup
9805       \leftskip=\tocindent  % indent these entries like a toc
9806       \let\do=\listoffloatsdo
9807       \csname floatlist\safefloattype\endcsname
9808     \endgroup
9809   \fi
9810 }
9811
9812 % This is called on each entry in a list of floats.  We're passed the
9813 % xref label, in the form LABEL-title, which is how we save it in the
9814 % aux file.  We strip off the -title and look up \XRLABEL-lof, which
9815 % has the text we're supposed to typeset here.
9816 %
9817 % Figures without xref labels will not be included in the list (since
9818 % they won't appear in the aux file).
9819 %
9820 \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9821 \def\listoffloatsdoentry#1-title\finish{{%
9822   % Can't fully expand XR#1-lof because it can contain anything.  Just
9823   % pass the control sequence.  On the other hand, XR#1-pg is just the
9824   % page number, and we want to fully expand that so we can get a link
9825   % in pdf output.
9826   \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9827   %
9828   % use the same \entry macro we use to generate the TOC and index.
9829   \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9830   \writeentry
9831 }}
9832
9833
9834 \message{localization,}
9835
9836 % For single-language documents, @documentlanguage is usually given very
9837 % early, just after @documentencoding.  Single argument is the language
9838 % (de) or locale (de_DE) abbreviation.
9839 %
9840 {
9841   \catcode`\_ = \active
9842   \globaldefs=1
9843 \parseargdef\documentlanguage{%
9844   \tex % read txi-??.tex file in plain TeX.
9845     % Read the file by the name they passed if it exists.
9846     \let_ = \normalunderscore  % normal _ character for filename test
9847     \openin 1 txi-#1.tex
9848     \ifeof 1
9849       \documentlanguagetrywithoutunderscore #1_\finish
9850     \else
9851       \globaldefs = 1  % everything in the txi-LL files needs to persist
9852       \input txi-#1.tex
9853     \fi
9854     \closein 1
9855   \endgroup % end raw TeX
9856 }
9857 %
9858 % If they passed de_DE, and txi-de_DE.tex doesn't exist,
9859 % try txi-de.tex.
9860 %
9861 \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
9862   \openin 1 txi-#1.tex
9863   \ifeof 1
9864     \errhelp = \nolanghelp
9865     \errmessage{Cannot read language file txi-#1.tex}%
9866   \else
9867     \globaldefs = 1  % everything in the txi-LL files needs to persist
9868     \input txi-#1.tex
9869   \fi
9870   \closein 1
9871 }
9872 }% end of special _ catcode
9873 %
9874 \newhelp\nolanghelp{The given language definition file cannot be found or
9875 is empty.  Maybe you need to install it?  Putting it in the current
9876 directory should work if nowhere else does.}
9877
9878 % This macro is called from txi-??.tex files; the first argument is the
9879 % \language name to set (without the "\lang@" prefix), the second and
9880 % third args are \{left,right}hyphenmin.
9881 %
9882 % The language names to pass are determined when the format is built.
9883 % See the etex.log file created at that time, e.g.,
9884 % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9885 %
9886 % With TeX Live 2008, etex now includes hyphenation patterns for all
9887 % available languages.  This means we can support hyphenation in
9888 % Texinfo, at least to some extent.  (This still doesn't solve the
9889 % accented characters problem.)
9890 %
9891 \catcode`@=11
9892 \def\txisetlanguage#1#2#3{%
9893   % do not set the language if the name is undefined in the current TeX.
9894   \expandafter\ifx\csname lang@#1\endcsname \relax
9895     \message{no patterns for #1}%
9896   \else
9897     \global\language = \csname lang@#1\endcsname
9898   \fi
9899   % but there is no harm in adjusting the hyphenmin values regardless.
9900   \global\lefthyphenmin = #2\relax
9901   \global\righthyphenmin = #3\relax
9902 }
9903
9904 % XeTeX and LuaTeX can handle Unicode natively.
9905 % Their default I/O uses UTF-8 sequences instead of a byte-wise operation.
9906 % Other TeX engines' I/O (pdfTeX, etc.) is byte-wise.
9907 %
9908 \newif\iftxinativeunicodecapable
9909 \newif\iftxiusebytewiseio
9910
9911 \ifx\XeTeXrevision\thisisundefined
9912   \ifx\luatexversion\thisisundefined
9913     \txinativeunicodecapablefalse
9914     \txiusebytewiseiotrue
9915   \else
9916     \txinativeunicodecapabletrue
9917     \txiusebytewiseiofalse
9918   \fi
9919 \else
9920   \txinativeunicodecapabletrue
9921   \txiusebytewiseiofalse
9922 \fi
9923
9924 % Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9925 % for non-UTF-8 (byte-wise) encodings.
9926 %
9927 \def\setbytewiseio{%
9928   \ifx\XeTeXrevision\thisisundefined
9929   \else
9930     \XeTeXdefaultencoding "bytes"  % For subsequent files to be read
9931     \XeTeXinputencoding "bytes"  % For document root file
9932     % Unfortunately, there seems to be no corresponding XeTeX command for
9933     % output encoding.  This is a problem for auxiliary index and TOC files.
9934     % The only solution would be perhaps to write out @U{...} sequences in
9935     % place of non-ASCII characters.
9936   \fi
9937
9938   \ifx\luatexversion\thisisundefined
9939   \else
9940     \directlua{
9941     local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9942     local function convert_char (char)
9943       return utf8_char(byte(char))
9944     end
9945
9946     local function convert_line (line)
9947       return gsub(line, ".", convert_char)
9948     end
9949
9950     callback.register("process_input_buffer", convert_line)
9951
9952     local function convert_line_out (line)
9953       local line_out = ""
9954       for c in string.utfvalues(line) do
9955          line_out = line_out .. string.char(c)
9956       end
9957       return line_out
9958     end
9959
9960     callback.register("process_output_buffer", convert_line_out)
9961     }
9962   \fi
9963
9964   \txiusebytewiseiotrue
9965 }
9966
9967
9968 % Helpers for encodings.
9969 % Set the catcode of characters 128 through 255 to the specified number.
9970 %
9971 \def\setnonasciicharscatcode#1{%
9972    \count255=128
9973    \loop\ifnum\count255<256
9974       \global\catcode\count255=#1\relax
9975       \advance\count255 by 1
9976    \repeat
9977 }
9978
9979 \def\setnonasciicharscatcodenonglobal#1{%
9980    \count255=128
9981    \loop\ifnum\count255<256
9982       \catcode\count255=#1\relax
9983       \advance\count255 by 1
9984    \repeat
9985 }
9986
9987 % @documentencoding sets the definition of non-ASCII characters
9988 % according to the specified encoding.
9989 %
9990 \def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9991 \def\documentencodingzzz#1{%
9992   %
9993   % Encoding being declared for the document.
9994   \def\declaredencoding{\csname #1.enc\endcsname}%
9995   %
9996   % Supported encodings: names converted to tokens in order to be able
9997   % to compare them with \ifx.
9998   \def\ascii{\csname US-ASCII.enc\endcsname}%
9999   \def\latnine{\csname ISO-8859-15.enc\endcsname}%
10000   \def\latone{\csname ISO-8859-1.enc\endcsname}%
10001   \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
10002   \def\utfeight{\csname UTF-8.enc\endcsname}%
10003   %
10004   \ifx \declaredencoding \ascii
10005      \asciichardefs
10006   %
10007   \else \ifx \declaredencoding \lattwo
10008      \iftxinativeunicodecapable
10009        \setbytewiseio
10010      \fi
10011      \setnonasciicharscatcode\active
10012      \lattwochardefs
10013   %
10014   \else \ifx \declaredencoding \latone
10015      \iftxinativeunicodecapable
10016        \setbytewiseio
10017      \fi
10018      \setnonasciicharscatcode\active
10019      \latonechardefs
10020   %
10021   \else \ifx \declaredencoding \latnine
10022      \iftxinativeunicodecapable
10023        \setbytewiseio
10024      \fi
10025      \setnonasciicharscatcode\active
10026      \latninechardefs
10027   %
10028   \else \ifx \declaredencoding \utfeight
10029      \iftxinativeunicodecapable
10030        % For native Unicode handling (XeTeX and LuaTeX)
10031        \nativeunicodechardefs
10032      \else
10033        % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX)
10034        \setnonasciicharscatcode\active
10035        % since we already invoked \utfeightchardefs at the top level
10036        % (below), do not re-invoke it, otherwise our check for duplicated
10037        % definitions gets triggered.  Making non-ascii chars active is
10038        % sufficient.
10039      \fi
10040   %
10041   \else
10042     \message{Ignoring unknown document encoding: #1.}%
10043   %
10044   \fi % utfeight
10045   \fi % latnine
10046   \fi % latone
10047   \fi % lattwo
10048   \fi % ascii
10049   %
10050   \ifx\XeTeXrevision\thisisundefined
10051   \else
10052     \ifx \declaredencoding \utfeight
10053     \else
10054       \ifx \declaredencoding \ascii
10055       \else
10056         \message{Warning: XeTeX with non-UTF-8 encodings cannot handle %
10057         non-ASCII characters in auxiliary files.}%
10058       \fi
10059     \fi
10060   \fi
10061 }
10062
10063 % emacs-page
10064 % A message to be logged when using a character that isn't available
10065 % the default font encoding (OT1).
10066 %
10067 \def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
10068
10069 % Take account of \c (plain) vs. \, (Texinfo) difference.
10070 \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
10071
10072 % First, make active non-ASCII characters in order for them to be
10073 % correctly categorized when TeX reads the replacement text of
10074 % macros containing the character definitions.
10075 \setnonasciicharscatcode\active
10076 %
10077
10078 \def\gdefchar#1#2{%
10079 \gdef#1{%
10080    \ifpassthroughchars
10081      \string#1%
10082    \else
10083      #2%
10084    \fi
10085 }}
10086
10087 % Latin1 (ISO-8859-1) character definitions.
10088 \def\latonechardefs{%
10089   \gdefchar^^a0{\tie}
10090   \gdefchar^^a1{\exclamdown}
10091   \gdefchar^^a2{{\tcfont \char162}} % cent
10092   \gdefchar^^a3{\pounds{}}
10093   \gdefchar^^a4{{\tcfont \char164}} % currency
10094   \gdefchar^^a5{{\tcfont \char165}} % yen
10095   \gdefchar^^a6{{\tcfont \char166}} % broken bar
10096   \gdefchar^^a7{\S}
10097   \gdefchar^^a8{\"{}}
10098   \gdefchar^^a9{\copyright{}}
10099   \gdefchar^^aa{\ordf}
10100   \gdefchar^^ab{\guillemetleft{}}
10101   \gdefchar^^ac{\ensuremath\lnot}
10102   \gdefchar^^ad{\-}
10103   \gdefchar^^ae{\registeredsymbol{}}
10104   \gdefchar^^af{\={}}
10105   %
10106   \gdefchar^^b0{\textdegree}
10107   \gdefchar^^b1{$\pm$}
10108   \gdefchar^^b2{$^2$}
10109   \gdefchar^^b3{$^3$}
10110   \gdefchar^^b4{\'{}}
10111   \gdefchar^^b5{$\mu$}
10112   \gdefchar^^b6{\P}
10113   \gdefchar^^b7{\ensuremath\cdot}
10114   \gdefchar^^b8{\cedilla\ }
10115   \gdefchar^^b9{$^1$}
10116   \gdefchar^^ba{\ordm}
10117   \gdefchar^^bb{\guillemetright{}}
10118   \gdefchar^^bc{$1\over4$}
10119   \gdefchar^^bd{$1\over2$}
10120   \gdefchar^^be{$3\over4$}
10121   \gdefchar^^bf{\questiondown}
10122   %
10123   \gdefchar^^c0{\`A}
10124   \gdefchar^^c1{\'A}
10125   \gdefchar^^c2{\^A}
10126   \gdefchar^^c3{\~A}
10127   \gdefchar^^c4{\"A}
10128   \gdefchar^^c5{\ringaccent A}
10129   \gdefchar^^c6{\AE}
10130   \gdefchar^^c7{\cedilla C}
10131   \gdefchar^^c8{\`E}
10132   \gdefchar^^c9{\'E}
10133   \gdefchar^^ca{\^E}
10134   \gdefchar^^cb{\"E}
10135   \gdefchar^^cc{\`I}
10136   \gdefchar^^cd{\'I}
10137   \gdefchar^^ce{\^I}
10138   \gdefchar^^cf{\"I}
10139   %
10140   \gdefchar^^d0{\DH}
10141   \gdefchar^^d1{\~N}
10142   \gdefchar^^d2{\`O}
10143   \gdefchar^^d3{\'O}
10144   \gdefchar^^d4{\^O}
10145   \gdefchar^^d5{\~O}
10146   \gdefchar^^d6{\"O}
10147   \gdefchar^^d7{$\times$}
10148   \gdefchar^^d8{\O}
10149   \gdefchar^^d9{\`U}
10150   \gdefchar^^da{\'U}
10151   \gdefchar^^db{\^U}
10152   \gdefchar^^dc{\"U}
10153   \gdefchar^^dd{\'Y}
10154   \gdefchar^^de{\TH}
10155   \gdefchar^^df{\ss}
10156   %
10157   \gdefchar^^e0{\`a}
10158   \gdefchar^^e1{\'a}
10159   \gdefchar^^e2{\^a}
10160   \gdefchar^^e3{\~a}
10161   \gdefchar^^e4{\"a}
10162   \gdefchar^^e5{\ringaccent a}
10163   \gdefchar^^e6{\ae}
10164   \gdefchar^^e7{\cedilla c}
10165   \gdefchar^^e8{\`e}
10166   \gdefchar^^e9{\'e}
10167   \gdefchar^^ea{\^e}
10168   \gdefchar^^eb{\"e}
10169   \gdefchar^^ec{\`{\dotless i}}
10170   \gdefchar^^ed{\'{\dotless i}}
10171   \gdefchar^^ee{\^{\dotless i}}
10172   \gdefchar^^ef{\"{\dotless i}}
10173   %
10174   \gdefchar^^f0{\dh}
10175   \gdefchar^^f1{\~n}
10176   \gdefchar^^f2{\`o}
10177   \gdefchar^^f3{\'o}
10178   \gdefchar^^f4{\^o}
10179   \gdefchar^^f5{\~o}
10180   \gdefchar^^f6{\"o}
10181   \gdefchar^^f7{$\div$}
10182   \gdefchar^^f8{\o}
10183   \gdefchar^^f9{\`u}
10184   \gdefchar^^fa{\'u}
10185   \gdefchar^^fb{\^u}
10186   \gdefchar^^fc{\"u}
10187   \gdefchar^^fd{\'y}
10188   \gdefchar^^fe{\th}
10189   \gdefchar^^ff{\"y}
10190 }
10191
10192 % Latin9 (ISO-8859-15) encoding character definitions.
10193 \def\latninechardefs{%
10194   % Encoding is almost identical to Latin1.
10195   \latonechardefs
10196   %
10197   \gdefchar^^a4{\euro{}}
10198   \gdefchar^^a6{\v S}
10199   \gdefchar^^a8{\v s}
10200   \gdefchar^^b4{\v Z}
10201   \gdefchar^^b8{\v z}
10202   \gdefchar^^bc{\OE}
10203   \gdefchar^^bd{\oe}
10204   \gdefchar^^be{\"Y}
10205 }
10206
10207 % Latin2 (ISO-8859-2) character definitions.
10208 \def\lattwochardefs{%
10209   \gdefchar^^a0{\tie}
10210   \gdefchar^^a1{\ogonek{A}}
10211   \gdefchar^^a2{\u{}}
10212   \gdefchar^^a3{\L}
10213   \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
10214   \gdefchar^^a5{\v L}
10215   \gdefchar^^a6{\'S}
10216   \gdefchar^^a7{\S}
10217   \gdefchar^^a8{\"{}}
10218   \gdefchar^^a9{\v S}
10219   \gdefchar^^aa{\cedilla S}
10220   \gdefchar^^ab{\v T}
10221   \gdefchar^^ac{\'Z}
10222   \gdefchar^^ad{\-}
10223   \gdefchar^^ae{\v Z}
10224   \gdefchar^^af{\dotaccent Z}
10225   %
10226   \gdefchar^^b0{\textdegree{}}
10227   \gdefchar^^b1{\ogonek{a}}
10228   \gdefchar^^b2{\ogonek{ }}
10229   \gdefchar^^b3{\l}
10230   \gdefchar^^b4{\'{}}
10231   \gdefchar^^b5{\v l}
10232   \gdefchar^^b6{\'s}
10233   \gdefchar^^b7{\v{}}
10234   \gdefchar^^b8{\cedilla\ }
10235   \gdefchar^^b9{\v s}
10236   \gdefchar^^ba{\cedilla s}
10237   \gdefchar^^bb{\v t}
10238   \gdefchar^^bc{\'z}
10239   \gdefchar^^bd{\H{}}
10240   \gdefchar^^be{\v z}
10241   \gdefchar^^bf{\dotaccent z}
10242   %
10243   \gdefchar^^c0{\'R}
10244   \gdefchar^^c1{\'A}
10245   \gdefchar^^c2{\^A}
10246   \gdefchar^^c3{\u A}
10247   \gdefchar^^c4{\"A}
10248   \gdefchar^^c5{\'L}
10249   \gdefchar^^c6{\'C}
10250   \gdefchar^^c7{\cedilla C}
10251   \gdefchar^^c8{\v C}
10252   \gdefchar^^c9{\'E}
10253   \gdefchar^^ca{\ogonek{E}}
10254   \gdefchar^^cb{\"E}
10255   \gdefchar^^cc{\v E}
10256   \gdefchar^^cd{\'I}
10257   \gdefchar^^ce{\^I}
10258   \gdefchar^^cf{\v D}
10259   %
10260   \gdefchar^^d0{\DH}
10261   \gdefchar^^d1{\'N}
10262   \gdefchar^^d2{\v N}
10263   \gdefchar^^d3{\'O}
10264   \gdefchar^^d4{\^O}
10265   \gdefchar^^d5{\H O}
10266   \gdefchar^^d6{\"O}
10267   \gdefchar^^d7{$\times$}
10268   \gdefchar^^d8{\v R}
10269   \gdefchar^^d9{\ringaccent U}
10270   \gdefchar^^da{\'U}
10271   \gdefchar^^db{\H U}
10272   \gdefchar^^dc{\"U}
10273   \gdefchar^^dd{\'Y}
10274   \gdefchar^^de{\cedilla T}
10275   \gdefchar^^df{\ss}
10276   %
10277   \gdefchar^^e0{\'r}
10278   \gdefchar^^e1{\'a}
10279   \gdefchar^^e2{\^a}
10280   \gdefchar^^e3{\u a}
10281   \gdefchar^^e4{\"a}
10282   \gdefchar^^e5{\'l}
10283   \gdefchar^^e6{\'c}
10284   \gdefchar^^e7{\cedilla c}
10285   \gdefchar^^e8{\v c}
10286   \gdefchar^^e9{\'e}
10287   \gdefchar^^ea{\ogonek{e}}
10288   \gdefchar^^eb{\"e}
10289   \gdefchar^^ec{\v e}
10290   \gdefchar^^ed{\'{\dotless{i}}}
10291   \gdefchar^^ee{\^{\dotless{i}}}
10292   \gdefchar^^ef{\v d}
10293   %
10294   \gdefchar^^f0{\dh}
10295   \gdefchar^^f1{\'n}
10296   \gdefchar^^f2{\v n}
10297   \gdefchar^^f3{\'o}
10298   \gdefchar^^f4{\^o}
10299   \gdefchar^^f5{\H o}
10300   \gdefchar^^f6{\"o}
10301   \gdefchar^^f7{$\div$}
10302   \gdefchar^^f8{\v r}
10303   \gdefchar^^f9{\ringaccent u}
10304   \gdefchar^^fa{\'u}
10305   \gdefchar^^fb{\H u}
10306   \gdefchar^^fc{\"u}
10307   \gdefchar^^fd{\'y}
10308   \gdefchar^^fe{\cedilla t}
10309   \gdefchar^^ff{\dotaccent{}}
10310 }
10311
10312 % UTF-8 character definitions.
10313 %
10314 % This code to support UTF-8 is based on LaTeX's utf8.def, with some
10315 % changes for Texinfo conventions.  It is included here under the GPL by
10316 % permission from Frank Mittelbach and the LaTeX team.
10317 %
10318 \newcount\countUTFx
10319 \newcount\countUTFy
10320 \newcount\countUTFz
10321
10322 \gdef\UTFviiiTwoOctets#1#2{\expandafter
10323    \UTFviiiDefined\csname u8:#1\string #2\endcsname}
10324 %
10325 \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
10326    \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
10327 %
10328 \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
10329    \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
10330
10331 \gdef\UTFviiiDefined#1{%
10332   \ifx #1\relax
10333     \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10334   \else
10335     \expandafter #1%
10336   \fi
10337 }
10338
10339 % Give non-ASCII bytes the active definitions for processing UTF-8 sequences
10340 \begingroup
10341   \catcode`\~13
10342   \catcode`\$12
10343   \catcode`\"12
10344
10345   % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
10346   % substituting ~ and $ with a character token of that value.
10347   \def\UTFviiiLoop{%
10348     \global\catcode\countUTFx\active
10349     \uccode`\~\countUTFx
10350     \uccode`\$\countUTFx
10351     \uppercase\expandafter{\UTFviiiTmp}%
10352     \advance\countUTFx by 1
10353     \ifnum\countUTFx < \countUTFy
10354       \expandafter\UTFviiiLoop
10355     \fi}
10356
10357   % For bytes other than the first in a UTF-8 sequence.  Not expected to
10358   % be expanded except when writing to auxiliary files.
10359   \countUTFx = "80
10360   \countUTFy = "C2
10361   \def\UTFviiiTmp{%
10362     \gdef~{%
10363         \ifpassthroughchars $\fi}}%
10364   \UTFviiiLoop
10365
10366   \countUTFx = "C2
10367   \countUTFy = "E0
10368   \def\UTFviiiTmp{%
10369     \gdef~{%
10370         \ifpassthroughchars $%
10371         \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
10372   \UTFviiiLoop
10373
10374   \countUTFx = "E0
10375   \countUTFy = "F0
10376   \def\UTFviiiTmp{%
10377     \gdef~{%
10378         \ifpassthroughchars $%
10379         \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
10380   \UTFviiiLoop
10381
10382   \countUTFx = "F0
10383   \countUTFy = "F4
10384   \def\UTFviiiTmp{%
10385     \gdef~{%
10386         \ifpassthroughchars $%
10387         \else\expandafter\UTFviiiFourOctets\expandafter$\fi
10388         }}%
10389   \UTFviiiLoop
10390 \endgroup
10391
10392 \def\globallet{\global\let} % save some \expandafter's below
10393
10394 % @U{xxxx} to produce U+xxxx, if we support it.
10395 \def\U#1{%
10396   \expandafter\ifx\csname uni:#1\endcsname \relax
10397     \iftxinativeunicodecapable
10398       % All Unicode characters can be used if native Unicode handling is
10399       % active.  However, if the font does not have the glyph,
10400       % letters are missing.
10401       \begingroup
10402         \uccode`\.="#1\relax
10403         \uppercase{.}
10404       \endgroup
10405     \else
10406       \errhelp = \EMsimple
10407       \errmessage{Unicode character U+#1 not supported, sorry}%
10408     \fi
10409   \else
10410     \csname uni:#1\endcsname
10411   \fi
10412 }
10413
10414 % These macros are used here to construct the name of a control
10415 % sequence to be defined.
10416 \def\UTFviiiTwoOctetsName#1#2{%
10417   \csname u8:#1\string #2\endcsname}%
10418 \def\UTFviiiThreeOctetsName#1#2#3{%
10419   \csname u8:#1\string #2\string #3\endcsname}%
10420 \def\UTFviiiFourOctetsName#1#2#3#4{%
10421   \csname u8:#1\string #2\string #3\string #4\endcsname}%
10422
10423 % For UTF-8 byte sequences (TeX, e-TeX and pdfTeX),
10424 % provide a definition macro to replace a Unicode character;
10425 % this gets used by the @U command
10426 %
10427 \begingroup
10428   \catcode`\"=12
10429   \catcode`\<=12
10430   \catcode`\.=12
10431   \catcode`\,=12
10432   \catcode`\;=12
10433   \catcode`\!=12
10434   \catcode`\~=13
10435   \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
10436     \countUTFz = "#1\relax
10437     \begingroup
10438       \parseXMLCharref
10439
10440       % Give \u8:... its definition.  The sequence of seven \expandafter's
10441       % expands after the \gdef three times, e.g.
10442       %
10443       % 1.  \UTFviiTwoOctetsName B1 B2
10444       % 2.  \csname u8:B1 \string B2 \endcsname
10445       % 3.  \u8: B1 B2  (a single control sequence token)
10446       %
10447       \expandafter\expandafter
10448       \expandafter\expandafter
10449       \expandafter\expandafter
10450       \expandafter\gdef       \UTFviiiTmp{#2}%
10451       %
10452       \expandafter\ifx\csname uni:#1\endcsname \relax \else
10453        \message{Internal error, already defined: #1}%
10454       \fi
10455       %
10456       % define an additional control sequence for this code point.
10457       \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
10458     \endgroup}
10459   %
10460   % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp
10461   % to the corresponding UTF-8 sequence.
10462   \gdef\parseXMLCharref{%
10463     \ifnum\countUTFz < "A0\relax
10464       \errhelp = \EMsimple
10465       \errmessage{Cannot define Unicode char value < 00A0}%
10466     \else\ifnum\countUTFz < "800\relax
10467       \parseUTFviiiA,%
10468       \parseUTFviiiB C\UTFviiiTwoOctetsName.,%
10469     \else\ifnum\countUTFz < "10000\relax
10470       \parseUTFviiiA;%
10471       \parseUTFviiiA,%
10472       \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}%
10473     \else
10474       \parseUTFviiiA;%
10475       \parseUTFviiiA,%
10476       \parseUTFviiiA!%
10477       \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}%
10478     \fi\fi\fi
10479   }
10480
10481   % Extract a byte from the end of the UTF-8 representation of \countUTFx.
10482   % It must be a non-initial byte in the sequence.
10483   % Change \uccode of #1 for it to be used in \parseUTFviiiB as one
10484   % of the bytes.
10485   \gdef\parseUTFviiiA#1{%
10486     \countUTFx = \countUTFz
10487     \divide\countUTFz by 64
10488     \countUTFy = \countUTFz  % Save to be the future value of \countUTFz.
10489     \multiply\countUTFz by 64
10490
10491     % \countUTFz is now \countUTFx with the last 5 bits cleared.  Subtract
10492     % in order to get the last five bits.
10493     \advance\countUTFx by -\countUTFz
10494
10495     % Convert this to the byte in the UTF-8 sequence.
10496     \advance\countUTFx by 128
10497     \uccode `#1\countUTFx
10498     \countUTFz = \countUTFy}
10499
10500   % Used to put a UTF-8 byte sequence into \UTFviiiTmp
10501   % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8
10502   %    sequence.
10503   % #2 is one of the \UTFviii*OctetsName macros.
10504   % #3 is always a full stop (.)
10505   % #4 is a template for the other bytes in the sequence.  The values for these
10506   %    bytes is substituted in here with \uppercase using the \uccode's.
10507   \gdef\parseUTFviiiB#1#2#3#4{%
10508     \advance\countUTFz by "#10\relax
10509     \uccode `#3\countUTFz
10510     \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10511 \endgroup
10512
10513 % For native Unicode handling (XeTeX and LuaTeX),
10514 % provide a definition macro that sets a catcode to `other' non-globally
10515 %
10516 \def\DeclareUnicodeCharacterNativeOther#1#2{%
10517   \catcode"#1=\other
10518 }
10519
10520 % https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10521 % U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10522 % U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10523 % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10524 % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10525 %
10526 % Many of our renditions are less than wonderful, and all the missing
10527 % characters are available somewhere.  Loading the necessary fonts
10528 % awaits user request.  We can't truly support Unicode without
10529 % reimplementing everything that's been done in LaTeX for many years,
10530 % plus probably using luatex or xetex, and who knows what else.
10531 % We won't be doing that here in this simple file.  But we can try to at
10532 % least make most of the characters not bomb out.
10533 %
10534 \def\unicodechardefs{%
10535   \DeclareUnicodeCharacter{00A0}{\tie}%
10536   \DeclareUnicodeCharacter{00A1}{\exclamdown}%
10537   \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
10538   \DeclareUnicodeCharacter{00A3}{\pounds{}}%
10539   \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10540   \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10541   \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
10542   \DeclareUnicodeCharacter{00A7}{\S}%
10543   \DeclareUnicodeCharacter{00A8}{\"{ }}%
10544   \DeclareUnicodeCharacter{00A9}{\copyright{}}%
10545   \DeclareUnicodeCharacter{00AA}{\ordf}%
10546   \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}%
10547   \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10548   \DeclareUnicodeCharacter{00AD}{\-}%
10549   \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}%
10550   \DeclareUnicodeCharacter{00AF}{\={ }}%
10551   %
10552   \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
10553   \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10554   \DeclareUnicodeCharacter{00B2}{$^2$}%
10555   \DeclareUnicodeCharacter{00B3}{$^3$}%
10556   \DeclareUnicodeCharacter{00B4}{\'{ }}%
10557   \DeclareUnicodeCharacter{00B5}{$\mu$}%
10558   \DeclareUnicodeCharacter{00B6}{\P}%
10559   \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10560   \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10561   \DeclareUnicodeCharacter{00B9}{$^1$}%
10562   \DeclareUnicodeCharacter{00BA}{\ordm}%
10563   \DeclareUnicodeCharacter{00BB}{\guillemetright{}}%
10564   \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10565   \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10566   \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10567   \DeclareUnicodeCharacter{00BF}{\questiondown}%
10568   %
10569   \DeclareUnicodeCharacter{00C0}{\`A}%
10570   \DeclareUnicodeCharacter{00C1}{\'A}%
10571   \DeclareUnicodeCharacter{00C2}{\^A}%
10572   \DeclareUnicodeCharacter{00C3}{\~A}%
10573   \DeclareUnicodeCharacter{00C4}{\"A}%
10574   \DeclareUnicodeCharacter{00C5}{\AA}%
10575   \DeclareUnicodeCharacter{00C6}{\AE}%
10576   \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10577   \DeclareUnicodeCharacter{00C8}{\`E}%
10578   \DeclareUnicodeCharacter{00C9}{\'E}%
10579   \DeclareUnicodeCharacter{00CA}{\^E}%
10580   \DeclareUnicodeCharacter{00CB}{\"E}%
10581   \DeclareUnicodeCharacter{00CC}{\`I}%
10582   \DeclareUnicodeCharacter{00CD}{\'I}%
10583   \DeclareUnicodeCharacter{00CE}{\^I}%
10584   \DeclareUnicodeCharacter{00CF}{\"I}%
10585   %
10586   \DeclareUnicodeCharacter{00D0}{\DH}%
10587   \DeclareUnicodeCharacter{00D1}{\~N}%
10588   \DeclareUnicodeCharacter{00D2}{\`O}%
10589   \DeclareUnicodeCharacter{00D3}{\'O}%
10590   \DeclareUnicodeCharacter{00D4}{\^O}%
10591   \DeclareUnicodeCharacter{00D5}{\~O}%
10592   \DeclareUnicodeCharacter{00D6}{\"O}%
10593   \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10594   \DeclareUnicodeCharacter{00D8}{\O}%
10595   \DeclareUnicodeCharacter{00D9}{\`U}%
10596   \DeclareUnicodeCharacter{00DA}{\'U}%
10597   \DeclareUnicodeCharacter{00DB}{\^U}%
10598   \DeclareUnicodeCharacter{00DC}{\"U}%
10599   \DeclareUnicodeCharacter{00DD}{\'Y}%
10600   \DeclareUnicodeCharacter{00DE}{\TH}%
10601   \DeclareUnicodeCharacter{00DF}{\ss}%
10602   %
10603   \DeclareUnicodeCharacter{00E0}{\`a}%
10604   \DeclareUnicodeCharacter{00E1}{\'a}%
10605   \DeclareUnicodeCharacter{00E2}{\^a}%
10606   \DeclareUnicodeCharacter{00E3}{\~a}%
10607   \DeclareUnicodeCharacter{00E4}{\"a}%
10608   \DeclareUnicodeCharacter{00E5}{\aa}%
10609   \DeclareUnicodeCharacter{00E6}{\ae}%
10610   \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10611   \DeclareUnicodeCharacter{00E8}{\`e}%
10612   \DeclareUnicodeCharacter{00E9}{\'e}%
10613   \DeclareUnicodeCharacter{00EA}{\^e}%
10614   \DeclareUnicodeCharacter{00EB}{\"e}%
10615   \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10616   \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10617   \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10618   \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10619   %
10620   \DeclareUnicodeCharacter{00F0}{\dh}%
10621   \DeclareUnicodeCharacter{00F1}{\~n}%
10622   \DeclareUnicodeCharacter{00F2}{\`o}%
10623   \DeclareUnicodeCharacter{00F3}{\'o}%
10624   \DeclareUnicodeCharacter{00F4}{\^o}%
10625   \DeclareUnicodeCharacter{00F5}{\~o}%
10626   \DeclareUnicodeCharacter{00F6}{\"o}%
10627   \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10628   \DeclareUnicodeCharacter{00F8}{\o}%
10629   \DeclareUnicodeCharacter{00F9}{\`u}%
10630   \DeclareUnicodeCharacter{00FA}{\'u}%
10631   \DeclareUnicodeCharacter{00FB}{\^u}%
10632   \DeclareUnicodeCharacter{00FC}{\"u}%
10633   \DeclareUnicodeCharacter{00FD}{\'y}%
10634   \DeclareUnicodeCharacter{00FE}{\th}%
10635   \DeclareUnicodeCharacter{00FF}{\"y}%
10636   %
10637   \DeclareUnicodeCharacter{0100}{\=A}%
10638   \DeclareUnicodeCharacter{0101}{\=a}%
10639   \DeclareUnicodeCharacter{0102}{\u{A}}%
10640   \DeclareUnicodeCharacter{0103}{\u{a}}%
10641   \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10642   \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10643   \DeclareUnicodeCharacter{0106}{\'C}%
10644   \DeclareUnicodeCharacter{0107}{\'c}%
10645   \DeclareUnicodeCharacter{0108}{\^C}%
10646   \DeclareUnicodeCharacter{0109}{\^c}%
10647   \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10648   \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10649   \DeclareUnicodeCharacter{010C}{\v{C}}%
10650   \DeclareUnicodeCharacter{010D}{\v{c}}%
10651   \DeclareUnicodeCharacter{010E}{\v{D}}%
10652   \DeclareUnicodeCharacter{010F}{d'}%
10653   %
10654   \DeclareUnicodeCharacter{0110}{\DH}%
10655   \DeclareUnicodeCharacter{0111}{\dh}%
10656   \DeclareUnicodeCharacter{0112}{\=E}%
10657   \DeclareUnicodeCharacter{0113}{\=e}%
10658   \DeclareUnicodeCharacter{0114}{\u{E}}%
10659   \DeclareUnicodeCharacter{0115}{\u{e}}%
10660   \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10661   \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10662   \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10663   \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10664   \DeclareUnicodeCharacter{011A}{\v{E}}%
10665   \DeclareUnicodeCharacter{011B}{\v{e}}%
10666   \DeclareUnicodeCharacter{011C}{\^G}%
10667   \DeclareUnicodeCharacter{011D}{\^g}%
10668   \DeclareUnicodeCharacter{011E}{\u{G}}%
10669   \DeclareUnicodeCharacter{011F}{\u{g}}%
10670   %
10671   \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10672   \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10673   \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10674   \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10675   \DeclareUnicodeCharacter{0124}{\^H}%
10676   \DeclareUnicodeCharacter{0125}{\^h}%
10677   \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10678   \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10679   \DeclareUnicodeCharacter{0128}{\~I}%
10680   \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10681   \DeclareUnicodeCharacter{012A}{\=I}%
10682   \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10683   \DeclareUnicodeCharacter{012C}{\u{I}}%
10684   \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10685   \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10686   \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10687   %
10688   \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10689   \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10690   \DeclareUnicodeCharacter{0132}{IJ}%
10691   \DeclareUnicodeCharacter{0133}{ij}%
10692   \DeclareUnicodeCharacter{0134}{\^J}%
10693   \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10694   \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10695   \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10696   \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10697   \DeclareUnicodeCharacter{0139}{\'L}%
10698   \DeclareUnicodeCharacter{013A}{\'l}%
10699   \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10700   \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
10701   \DeclareUnicodeCharacter{013D}{L'}% should kern
10702   \DeclareUnicodeCharacter{013E}{l'}% should kern
10703   \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10704   %
10705   \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10706   \DeclareUnicodeCharacter{0141}{\L}%
10707   \DeclareUnicodeCharacter{0142}{\l}%
10708   \DeclareUnicodeCharacter{0143}{\'N}%
10709   \DeclareUnicodeCharacter{0144}{\'n}%
10710   \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10711   \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10712   \DeclareUnicodeCharacter{0147}{\v{N}}%
10713   \DeclareUnicodeCharacter{0148}{\v{n}}%
10714   \DeclareUnicodeCharacter{0149}{'n}%
10715   \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10716   \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10717   \DeclareUnicodeCharacter{014C}{\=O}%
10718   \DeclareUnicodeCharacter{014D}{\=o}%
10719   \DeclareUnicodeCharacter{014E}{\u{O}}%
10720   \DeclareUnicodeCharacter{014F}{\u{o}}%
10721   %
10722   \DeclareUnicodeCharacter{0150}{\H{O}}%
10723   \DeclareUnicodeCharacter{0151}{\H{o}}%
10724   \DeclareUnicodeCharacter{0152}{\OE}%
10725   \DeclareUnicodeCharacter{0153}{\oe}%
10726   \DeclareUnicodeCharacter{0154}{\'R}%
10727   \DeclareUnicodeCharacter{0155}{\'r}%
10728   \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10729   \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10730   \DeclareUnicodeCharacter{0158}{\v{R}}%
10731   \DeclareUnicodeCharacter{0159}{\v{r}}%
10732   \DeclareUnicodeCharacter{015A}{\'S}%
10733   \DeclareUnicodeCharacter{015B}{\'s}%
10734   \DeclareUnicodeCharacter{015C}{\^S}%
10735   \DeclareUnicodeCharacter{015D}{\^s}%
10736   \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10737   \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10738   %
10739   \DeclareUnicodeCharacter{0160}{\v{S}}%
10740   \DeclareUnicodeCharacter{0161}{\v{s}}%
10741   \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10742   \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10743   \DeclareUnicodeCharacter{0164}{\v{T}}%
10744   \DeclareUnicodeCharacter{0165}{\v{t}}%
10745   \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10746   \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10747   \DeclareUnicodeCharacter{0168}{\~U}%
10748   \DeclareUnicodeCharacter{0169}{\~u}%
10749   \DeclareUnicodeCharacter{016A}{\=U}%
10750   \DeclareUnicodeCharacter{016B}{\=u}%
10751   \DeclareUnicodeCharacter{016C}{\u{U}}%
10752   \DeclareUnicodeCharacter{016D}{\u{u}}%
10753   \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10754   \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10755   %
10756   \DeclareUnicodeCharacter{0170}{\H{U}}%
10757   \DeclareUnicodeCharacter{0171}{\H{u}}%
10758   \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10759   \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10760   \DeclareUnicodeCharacter{0174}{\^W}%
10761   \DeclareUnicodeCharacter{0175}{\^w}%
10762   \DeclareUnicodeCharacter{0176}{\^Y}%
10763   \DeclareUnicodeCharacter{0177}{\^y}%
10764   \DeclareUnicodeCharacter{0178}{\"Y}%
10765   \DeclareUnicodeCharacter{0179}{\'Z}%
10766   \DeclareUnicodeCharacter{017A}{\'z}%
10767   \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10768   \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10769   \DeclareUnicodeCharacter{017D}{\v{Z}}%
10770   \DeclareUnicodeCharacter{017E}{\v{z}}%
10771   \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10772   %
10773   \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10774   \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10775   \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10776   \DeclareUnicodeCharacter{01C7}{LJ}%
10777   \DeclareUnicodeCharacter{01C8}{Lj}%
10778   \DeclareUnicodeCharacter{01C9}{lj}%
10779   \DeclareUnicodeCharacter{01CA}{NJ}%
10780   \DeclareUnicodeCharacter{01CB}{Nj}%
10781   \DeclareUnicodeCharacter{01CC}{nj}%
10782   \DeclareUnicodeCharacter{01CD}{\v{A}}%
10783   \DeclareUnicodeCharacter{01CE}{\v{a}}%
10784   \DeclareUnicodeCharacter{01CF}{\v{I}}%
10785   %
10786   \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10787   \DeclareUnicodeCharacter{01D1}{\v{O}}%
10788   \DeclareUnicodeCharacter{01D2}{\v{o}}%
10789   \DeclareUnicodeCharacter{01D3}{\v{U}}%
10790   \DeclareUnicodeCharacter{01D4}{\v{u}}%
10791   %
10792   \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10793   \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10794   \DeclareUnicodeCharacter{01E6}{\v{G}}%
10795   \DeclareUnicodeCharacter{01E7}{\v{g}}%
10796   \DeclareUnicodeCharacter{01E8}{\v{K}}%
10797   \DeclareUnicodeCharacter{01E9}{\v{k}}%
10798   %
10799   \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10800   \DeclareUnicodeCharacter{01F1}{DZ}%
10801   \DeclareUnicodeCharacter{01F2}{Dz}%
10802   \DeclareUnicodeCharacter{01F3}{dz}%
10803   \DeclareUnicodeCharacter{01F4}{\'G}%
10804   \DeclareUnicodeCharacter{01F5}{\'g}%
10805   \DeclareUnicodeCharacter{01F8}{\`N}%
10806   \DeclareUnicodeCharacter{01F9}{\`n}%
10807   \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10808   \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10809   \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10810   \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10811   %
10812   \DeclareUnicodeCharacter{021E}{\v{H}}%
10813   \DeclareUnicodeCharacter{021F}{\v{h}}%
10814   %
10815   \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10816   \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10817   \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10818   \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10819   \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10820   \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10821   %
10822   \DeclareUnicodeCharacter{0232}{\=Y}%
10823   \DeclareUnicodeCharacter{0233}{\=y}%
10824   \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10825   %
10826   \DeclareUnicodeCharacter{02BC}{'}%
10827   %
10828   \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10829   %
10830   % Greek letters upper case
10831   \DeclareUnicodeCharacter{0391}{{\it A}}%
10832   \DeclareUnicodeCharacter{0392}{{\it B}}%
10833   \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10834   \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10835   \DeclareUnicodeCharacter{0395}{{\it E}}%
10836   \DeclareUnicodeCharacter{0396}{{\it Z}}%
10837   \DeclareUnicodeCharacter{0397}{{\it H}}%
10838   \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10839   \DeclareUnicodeCharacter{0399}{{\it I}}%
10840   \DeclareUnicodeCharacter{039A}{{\it K}}%
10841   \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10842   \DeclareUnicodeCharacter{039C}{{\it M}}%
10843   \DeclareUnicodeCharacter{039D}{{\it N}}%
10844   \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10845   \DeclareUnicodeCharacter{039F}{{\it O}}%
10846   \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10847   \DeclareUnicodeCharacter{03A1}{{\it P}}%
10848   %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
10849   \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10850   \DeclareUnicodeCharacter{03A4}{{\it T}}%
10851   \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10852   \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10853   \DeclareUnicodeCharacter{03A7}{{\it X}}%
10854   \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10855   \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10856   %
10857   % Vowels with accents
10858   \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10859   \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10860   \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10861   \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10862   \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10863   \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10864   %
10865   % Standalone accent
10866   \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10867   %
10868   % Greek letters lower case
10869   \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10870   \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10871   \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10872   \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10873   \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10874   \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10875   \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10876   \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10877   \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10878   \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10879   \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10880   \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10881   \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10882   \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10883   \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10884   \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10885   \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10886   \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10887   \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10888   \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10889   \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10890   \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10891   \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10892   \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10893   \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10894   %
10895   % More Greek vowels with accents
10896   \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10897   \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10898   \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10899   \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10900   \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10901   %
10902   % Variant Greek letters
10903   \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10904   \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10905   \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10906   %
10907   \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10908   \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10909   \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10910   \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10911   \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10912   \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10913   \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10914   \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10915   \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10916   \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10917   \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10918   \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10919   %
10920   \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10921   \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10922   %
10923   \DeclareUnicodeCharacter{1E20}{\=G}%
10924   \DeclareUnicodeCharacter{1E21}{\=g}%
10925   \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10926   \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10927   \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10928   \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10929   \DeclareUnicodeCharacter{1E26}{\"H}%
10930   \DeclareUnicodeCharacter{1E27}{\"h}%
10931   %
10932   \DeclareUnicodeCharacter{1E30}{\'K}%
10933   \DeclareUnicodeCharacter{1E31}{\'k}%
10934   \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10935   \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10936   \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10937   \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10938   \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10939   \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10940   \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10941   \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10942   \DeclareUnicodeCharacter{1E3E}{\'M}%
10943   \DeclareUnicodeCharacter{1E3F}{\'m}%
10944   %
10945   \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10946   \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10947   \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10948   \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10949   \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10950   \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10951   \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10952   \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10953   \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10954   \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10955   %
10956   \DeclareUnicodeCharacter{1E54}{\'P}%
10957   \DeclareUnicodeCharacter{1E55}{\'p}%
10958   \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10959   \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10960   \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10961   \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10962   \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10963   \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10964   \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10965   \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10966   %
10967   \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10968   \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10969   \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10970   \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10971   \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10972   \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10973   \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10974   \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10975   \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10976   \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10977   %
10978   \DeclareUnicodeCharacter{1E7C}{\~V}%
10979   \DeclareUnicodeCharacter{1E7D}{\~v}%
10980   \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10981   \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10982   %
10983   \DeclareUnicodeCharacter{1E80}{\`W}%
10984   \DeclareUnicodeCharacter{1E81}{\`w}%
10985   \DeclareUnicodeCharacter{1E82}{\'W}%
10986   \DeclareUnicodeCharacter{1E83}{\'w}%
10987   \DeclareUnicodeCharacter{1E84}{\"W}%
10988   \DeclareUnicodeCharacter{1E85}{\"w}%
10989   \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10990   \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10991   \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10992   \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10993   \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10994   \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10995   \DeclareUnicodeCharacter{1E8C}{\"X}%
10996   \DeclareUnicodeCharacter{1E8D}{\"x}%
10997   \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10998   \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10999   %
11000   \DeclareUnicodeCharacter{1E90}{\^Z}%
11001   \DeclareUnicodeCharacter{1E91}{\^z}%
11002   \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
11003   \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
11004   \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
11005   \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
11006   \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
11007   \DeclareUnicodeCharacter{1E97}{\"t}%
11008   \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
11009   \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
11010   %
11011   \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
11012   \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
11013   %
11014   \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
11015   \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
11016   \DeclareUnicodeCharacter{1EBC}{\~E}%
11017   \DeclareUnicodeCharacter{1EBD}{\~e}%
11018   %
11019   \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
11020   \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
11021   \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
11022   \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
11023   %
11024   \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
11025   \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
11026   %
11027   \DeclareUnicodeCharacter{1EF2}{\`Y}%
11028   \DeclareUnicodeCharacter{1EF3}{\`y}%
11029   \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
11030   %
11031   \DeclareUnicodeCharacter{1EF8}{\~Y}%
11032   \DeclareUnicodeCharacter{1EF9}{\~y}%
11033   %
11034   % Punctuation
11035   \DeclareUnicodeCharacter{2013}{--}%
11036   \DeclareUnicodeCharacter{2014}{---}%
11037   \DeclareUnicodeCharacter{2018}{\quoteleft{}}%
11038   \DeclareUnicodeCharacter{2019}{\quoteright{}}%
11039   \DeclareUnicodeCharacter{201A}{\quotesinglbase{}}%
11040   \DeclareUnicodeCharacter{201C}{\quotedblleft{}}%
11041   \DeclareUnicodeCharacter{201D}{\quotedblright{}}%
11042   \DeclareUnicodeCharacter{201E}{\quotedblbase{}}%
11043   \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}%
11044   \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}%
11045   \DeclareUnicodeCharacter{2022}{\bullet{}}%
11046   \DeclareUnicodeCharacter{202F}{\thinspace}%
11047   \DeclareUnicodeCharacter{2026}{\dots{}}%
11048   \DeclareUnicodeCharacter{2039}{\guilsinglleft{}}%
11049   \DeclareUnicodeCharacter{203A}{\guilsinglright{}}%
11050   %
11051   \DeclareUnicodeCharacter{20AC}{\euro{}}%
11052   %
11053   \DeclareUnicodeCharacter{2192}{\expansion{}}%
11054   \DeclareUnicodeCharacter{21D2}{\result{}}%
11055   %
11056   % Mathematical symbols
11057   \DeclareUnicodeCharacter{2200}{\ensuremath\forall}%
11058   \DeclareUnicodeCharacter{2203}{\ensuremath\exists}%
11059   \DeclareUnicodeCharacter{2208}{\ensuremath\in}%
11060   \DeclareUnicodeCharacter{2212}{\minus{}}%
11061   \DeclareUnicodeCharacter{2217}{\ast}%
11062   \DeclareUnicodeCharacter{221E}{\ensuremath\infty}%
11063   \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}%
11064   \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}%
11065   \DeclareUnicodeCharacter{2229}{\ensuremath\cap}%
11066   \DeclareUnicodeCharacter{2261}{\equiv{}}%
11067   \DeclareUnicodeCharacter{2264}{\ensuremath\leq}%
11068   \DeclareUnicodeCharacter{2265}{\ensuremath\geq}%
11069   \DeclareUnicodeCharacter{2282}{\ensuremath\subset}%
11070   \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}%
11071   %
11072   \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}%
11073   \DeclareUnicodeCharacter{2032}{\ensuremath\prime}%
11074   \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}%
11075   \DeclareUnicodeCharacter{2111}{\ensuremath\Im}%
11076   \DeclareUnicodeCharacter{2113}{\ensuremath\ell}%
11077   \DeclareUnicodeCharacter{2118}{\ensuremath\wp}%
11078   \DeclareUnicodeCharacter{211C}{\ensuremath\Re}%
11079   \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}%
11080   \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}%
11081   \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}%
11082   \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}%
11083   \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}%
11084   \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}%
11085   \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}%
11086   \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}%
11087   \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}%
11088   \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}%
11089   \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}%
11090   \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}%
11091   \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}%
11092   \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}%
11093   \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}%
11094   \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}%
11095   \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}%
11096   \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}%
11097   \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}%
11098   \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}%
11099   \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}%
11100   \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}%
11101   \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}%
11102   \DeclareUnicodeCharacter{2202}{\ensuremath\partial}%
11103   \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}%
11104   \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}%
11105   \DeclareUnicodeCharacter{2209}{\ensuremath\notin}%
11106   \DeclareUnicodeCharacter{220B}{\ensuremath\owns}%
11107   \DeclareUnicodeCharacter{220F}{\ensuremath\prod}%
11108   \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}%
11109   \DeclareUnicodeCharacter{2211}{\ensuremath\sum}%
11110   \DeclareUnicodeCharacter{2213}{\ensuremath\mp}%
11111   \DeclareUnicodeCharacter{2218}{\ensuremath\circ}%
11112   \DeclareUnicodeCharacter{221A}{\ensuremath\surd}%
11113   \DeclareUnicodeCharacter{221D}{\ensuremath\propto}%
11114   \DeclareUnicodeCharacter{2220}{\ensuremath\angle}%
11115   \DeclareUnicodeCharacter{2223}{\ensuremath\mid}%
11116   \DeclareUnicodeCharacter{2228}{\ensuremath\vee}%
11117   \DeclareUnicodeCharacter{222A}{\ensuremath\cup}%
11118   \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}%
11119   \DeclareUnicodeCharacter{222E}{\ensuremath\oint}%
11120   \DeclareUnicodeCharacter{223C}{\ensuremath\sim}%
11121   \DeclareUnicodeCharacter{2240}{\ensuremath\wr}%
11122   \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}%
11123   \DeclareUnicodeCharacter{2245}{\ensuremath\cong}%
11124   \DeclareUnicodeCharacter{2248}{\ensuremath\approx}%
11125   \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}%
11126   \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}%
11127   \DeclareUnicodeCharacter{2260}{\ensuremath\neq}%
11128   \DeclareUnicodeCharacter{226A}{\ensuremath\ll}%
11129   \DeclareUnicodeCharacter{226B}{\ensuremath\gg}%
11130   \DeclareUnicodeCharacter{227A}{\ensuremath\prec}%
11131   \DeclareUnicodeCharacter{227B}{\ensuremath\succ}%
11132   \DeclareUnicodeCharacter{2283}{\ensuremath\supset}%
11133   \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}%
11134   \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}%
11135   \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}%
11136   \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}%
11137   \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}%
11138   \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}%
11139   \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}%
11140   \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}%
11141   \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}%
11142   \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}%
11143   \DeclareUnicodeCharacter{2299}{\ensuremath\odot}%
11144   \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}%
11145   \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}%
11146   \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}%
11147   \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}%
11148   \DeclareUnicodeCharacter{22A8}{\ensuremath\models}%
11149   \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}%
11150   \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}%
11151   \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}%
11152   \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}%
11153   \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}%
11154   \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}%
11155   \DeclareUnicodeCharacter{22C6}{\ensuremath\star}%
11156   \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}%
11157   \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}%
11158   \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}%
11159   \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}%
11160   \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}%
11161   \DeclareUnicodeCharacter{2322}{\ensuremath\frown}%
11162   \DeclareUnicodeCharacter{2323}{\ensuremath\smile}%
11163   %
11164   \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
11165   \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
11166   \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
11167   \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
11168   \DeclareUnicodeCharacter{25C7}{\ensuremath\diamond}%
11169   \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}%
11170   \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}%
11171   \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}%
11172   \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}%
11173   \DeclareUnicodeCharacter{266D}{\ensuremath\flat}%
11174   \DeclareUnicodeCharacter{266E}{\ensuremath\natural}%
11175   \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}%
11176   \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}%
11177   \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}%
11178   \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}%
11179   \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}%
11180   \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}%
11181   \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}%
11182   \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}%
11183   \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}%
11184   \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}%
11185   \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}%
11186   \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}%
11187   \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}%
11188   \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}%
11189   \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}%
11190   \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}%
11191   \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}%
11192   \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}%
11193   %
11194   \global\mathchardef\checkmark="1370% actually the square root sign
11195   \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}%
11196 }% end of \unicodechardefs
11197
11198 % UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
11199 % It makes the setting that replace UTF-8 byte sequence.
11200 \def\utfeightchardefs{%
11201   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
11202   \unicodechardefs
11203 }
11204
11205 % Whether the active definitions of non-ASCII characters expand to
11206 % non-active tokens with the same character code.  This is used to
11207 % write characters literally, instead of using active definitions for
11208 % printing the correct glyphs.
11209 \newif\ifpassthroughchars
11210 \passthroughcharsfalse
11211
11212 % For native Unicode handling (XeTeX and LuaTeX),
11213 % provide a definition macro to replace/pass-through a Unicode character
11214 %
11215 \def\DeclareUnicodeCharacterNative#1#2{%
11216   \catcode"#1=\active
11217   \def\dodeclareunicodecharacternative##1##2##3{%
11218     \begingroup
11219       \uccode`\~="##2\relax
11220       \uppercase{\gdef~}{%
11221         \ifpassthroughchars
11222           ##1%
11223         \else
11224           ##3%
11225         \fi
11226       }
11227     \endgroup
11228   }
11229   \begingroup
11230     \uccode`\.="#1\relax
11231     \uppercase{\def\UTFNativeTmp{.}}%
11232     \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
11233   \endgroup
11234 }
11235
11236 % Native Unicode handling (XeTeX and LuaTeX) character replacing definition.
11237 % It activates the setting that replaces Unicode characters.
11238 \def\nativeunicodechardefs{%
11239   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
11240   \unicodechardefs
11241 }
11242
11243 % For native Unicode handling (XeTeX and LuaTeX),
11244 % make the character token expand
11245 % to the sequences given in \unicodechardefs for printing.
11246 \def\DeclareUnicodeCharacterNativeAtU#1#2{%
11247   \def\UTFAtUTmp{#2}
11248   \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
11249 }
11250
11251 % @U command definitions for native Unicode handling (XeTeX and LuaTeX).
11252 \def\nativeunicodechardefsatu{%
11253   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
11254   \unicodechardefs
11255 }
11256
11257 % US-ASCII character definitions.
11258 \def\asciichardefs{% nothing need be done
11259    \relax
11260 }
11261
11262 % Define all Unicode characters we know about.  This makes UTF-8 the default
11263 % input encoding and allows @U to work.
11264 \iftxinativeunicodecapable
11265   \nativeunicodechardefsatu
11266 \else
11267   \utfeightchardefs
11268 \fi
11269
11270 \message{formatting,}
11271
11272 \newdimen\defaultparindent \defaultparindent = 15pt
11273
11274 \chapheadingskip = 15pt plus 4pt minus 2pt
11275 \secheadingskip = 12pt plus 3pt minus 2pt
11276 \subsecheadingskip = 9pt plus 2pt minus 2pt
11277
11278 % Prevent underfull vbox error messages.
11279 \vbadness = 10000
11280
11281 % Don't be very finicky about underfull hboxes, either.
11282 \hbadness = 6666
11283
11284 % Following George Bush, get rid of widows and orphans.
11285 \widowpenalty=10000
11286 \clubpenalty=10000
11287
11288 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
11289 % using an old version of TeX, don't do anything.  We want the amount of
11290 % stretch added to depend on the line length, hence the dependence on
11291 % \hsize.  We call this whenever the paper size is set.
11292 %
11293 \def\setemergencystretch{%
11294   \ifx\emergencystretch\thisisundefined
11295     % Allow us to assign to \emergencystretch anyway.
11296     \def\emergencystretch{\dimen0}%
11297   \else
11298     \emergencystretch = .15\hsize
11299   \fi
11300 }
11301
11302 % Parameters in order: 1) textheight; 2) textwidth;
11303 % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11304 % 7) physical page height; 8) physical page width.
11305 %
11306 % We also call \setleading{\textleading}, so the caller should define
11307 % \textleading.  The caller should also set \parskip.
11308 %
11309 \def\internalpagesizes#1#2#3#4#5#6#7#8{%
11310   \voffset = #3\relax
11311   \topskip = #6\relax
11312   \splittopskip = \topskip
11313   %
11314   \vsize = #1\relax
11315   \advance\vsize by \topskip
11316   \outervsize = \vsize
11317   \advance\outervsize by 2\topandbottommargin
11318   \txipageheight = \vsize
11319   %
11320   \hsize = #2\relax
11321   \outerhsize = \hsize
11322   \advance\outerhsize by 0.5in
11323   \txipagewidth = \hsize
11324   %
11325   \normaloffset = #4\relax
11326   \bindingoffset = #5\relax
11327   %
11328   \ifpdf
11329     \pdfpageheight #7\relax
11330     \pdfpagewidth #8\relax
11331     % if we don't reset these, they will remain at "1 true in" of
11332     % whatever layout pdftex was dumped with.
11333     \pdfhorigin = 1 true in
11334     \pdfvorigin = 1 true in
11335   \else
11336     \ifx\XeTeXrevision\thisisundefined
11337       \special{papersize=#8,#7}%
11338     \else
11339       \pdfpageheight #7\relax
11340       \pdfpagewidth #8\relax
11341       % XeTeX does not have \pdfhorigin and \pdfvorigin.
11342     \fi
11343   \fi
11344   %
11345   \setleading{\textleading}
11346   %
11347   \parindent = \defaultparindent
11348   \setemergencystretch
11349 }
11350
11351 % @letterpaper (the default).
11352 \def\letterpaper{{\globaldefs = 1
11353   \parskip = 3pt plus 2pt minus 1pt
11354   \textleading = 13.2pt
11355   %
11356   % If page is nothing but text, make it come out even.
11357   \internalpagesizes{607.2pt}{6in}% that's 46 lines
11358                     {\voffset}{.25in}%
11359                     {\bindingoffset}{36pt}%
11360                     {11in}{8.5in}%
11361 }}
11362
11363 % Use @smallbook to reset parameters for 7x9.25 trim size.
11364 \def\smallbook{{\globaldefs = 1
11365   \parskip = 2pt plus 1pt
11366   \textleading = 12pt
11367   %
11368   \internalpagesizes{7.5in}{5in}%
11369                     {-.2in}{0in}%
11370                     {\bindingoffset}{16pt}%
11371                     {9.25in}{7in}%
11372   %
11373   \lispnarrowing = 0.3in
11374   \tolerance = 700
11375   \contentsrightmargin = 0pt
11376   \defbodyindent = .5cm
11377 }}
11378
11379 % Use @smallerbook to reset parameters for 6x9 trim size.
11380 % (Just testing, parameters still in flux.)
11381 \def\smallerbook{{\globaldefs = 1
11382   \parskip = 1.5pt plus 1pt
11383   \textleading = 12pt
11384   %
11385   \internalpagesizes{7.4in}{4.8in}%
11386                     {-.2in}{-.4in}%
11387                     {0pt}{14pt}%
11388                     {9in}{6in}%
11389   %
11390   \lispnarrowing = 0.25in
11391   \tolerance = 700
11392   \contentsrightmargin = 0pt
11393   \defbodyindent = .4cm
11394 }}
11395
11396 % Use @afourpaper to print on European A4 paper.
11397 \def\afourpaper{{\globaldefs = 1
11398   \parskip = 3pt plus 2pt minus 1pt
11399   \textleading = 13.2pt
11400   %
11401   % Double-side printing via postscript on Laserjet 4050
11402   % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11403   % To change the settings for a different printer or situation, adjust
11404   % \normaloffset until the front-side and back-side texts align.  Then
11405   % do the same for \bindingoffset.  You can set these for testing in
11406   % your texinfo source file like this:
11407   % @tex
11408   % \global\normaloffset = -6mm
11409   % \global\bindingoffset = 10mm
11410   % @end tex
11411   \internalpagesizes{673.2pt}{160mm}% that's 51 lines
11412                     {\voffset}{\hoffset}%
11413                     {\bindingoffset}{44pt}%
11414                     {297mm}{210mm}%
11415   %
11416   \tolerance = 700
11417   \contentsrightmargin = 0pt
11418   \defbodyindent = 5mm
11419 }}
11420
11421 % Use @afivepaper to print on European A5 paper.
11422 % From romildo@urano.iceb.ufop.br, 2 July 2000.
11423 % He also recommends making @example and @lisp be small.
11424 \def\afivepaper{{\globaldefs = 1
11425   \parskip = 2pt plus 1pt minus 0.1pt
11426   \textleading = 12.5pt
11427   %
11428   \internalpagesizes{160mm}{120mm}%
11429                     {\voffset}{\hoffset}%
11430                     {\bindingoffset}{8pt}%
11431                     {210mm}{148mm}%
11432   %
11433   \lispnarrowing = 0.2in
11434   \tolerance = 800
11435   \contentsrightmargin = 0pt
11436   \defbodyindent = 2mm
11437   \tableindent = 12mm
11438 }}
11439
11440 % A specific text layout, 24x15cm overall, intended for A4 paper.
11441 \def\afourlatex{{\globaldefs = 1
11442   \afourpaper
11443   \internalpagesizes{237mm}{150mm}%
11444                     {\voffset}{4.6mm}%
11445                     {\bindingoffset}{7mm}%
11446                     {297mm}{210mm}%
11447   %
11448   % Must explicitly reset to 0 because we call \afourpaper.
11449   \globaldefs = 0
11450 }}
11451
11452 % Use @afourwide to print on A4 paper in landscape format.
11453 \def\afourwide{{\globaldefs = 1
11454   \afourpaper
11455   \internalpagesizes{241mm}{165mm}%
11456                     {\voffset}{-2.95mm}%
11457                     {\bindingoffset}{7mm}%
11458                     {297mm}{210mm}%
11459   \globaldefs = 0
11460 }}
11461
11462 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11463 % Perhaps we should allow setting the margins, \topskip, \parskip,
11464 % and/or leading, also. Or perhaps we should compute them somehow.
11465 %
11466 \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
11467 \def\pagesizesyyy#1,#2,#3\finish{{%
11468   \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11469   \globaldefs = 1
11470   %
11471   \parskip = 3pt plus 2pt minus 1pt
11472   \setleading{\textleading}%
11473   %
11474   \dimen0 = #1\relax
11475   \advance\dimen0 by \voffset
11476   \advance\dimen0 by 1in % reference point for DVI is 1 inch from top of page
11477   %
11478   \dimen2 = \hsize
11479   \advance\dimen2 by \normaloffset
11480   \advance\dimen2 by 1in % reference point is 1 inch from left edge of page
11481   %
11482   \internalpagesizes{#1}{\hsize}%
11483                     {\voffset}{\normaloffset}%
11484                     {\bindingoffset}{44pt}%
11485                     {\dimen0}{\dimen2}%
11486 }}
11487
11488 % Set default to letter.
11489 %
11490 \letterpaper
11491
11492 % Default value of \hfuzz, for suppressing warnings about overfull hboxes.
11493 \hfuzz = 1pt
11494
11495
11496 \message{and turning on texinfo input format.}
11497
11498 \def^^L{\par} % remove \outer, so ^L can appear in an @comment
11499
11500 % DEL is a comment character, in case @c does not suffice.
11501 \catcode`\^^? = 14
11502
11503 % Define macros to output various characters with catcode for normal text.
11504 \catcode`\"=\other \def\normaldoublequote{"}
11505 \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11506 \catcode`\+=\other \def\normalplus{+}
11507 \catcode`\<=\other \def\normalless{<}
11508 \catcode`\>=\other \def\normalgreater{>}
11509 \catcode`\^=\other \def\normalcaret{^}
11510 \catcode`\_=\other \def\normalunderscore{_}
11511 \catcode`\|=\other \def\normalverticalbar{|}
11512 \catcode`\~=\other \def\normaltilde{~}
11513
11514 % This macro is used to make a character print one way in \tt
11515 % (where it can probably be output as-is), and another way in other fonts,
11516 % where something hairier probably needs to be done.
11517 %
11518 % #1 is what to print if we are indeed using \tt; #2 is what to print
11519 % otherwise.  Since all the Computer Modern typewriter fonts have zero
11520 % interword stretch (and shrink), and it is reasonable to expect all
11521 % typewriter fonts to have this, we can check that font parameter.
11522 %
11523 \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
11524
11525 % Same as above, but check for italic font.  Actually this also catches
11526 % non-italic slanted fonts since it is impossible to distinguish them from
11527 % italic fonts.  But since this is only used by $ and it uses \sl anyway
11528 % this is not a problem.
11529 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
11530
11531 % Set catcodes for Texinfo file
11532
11533 % Active characters for printing the wanted glyph.
11534 % Most of these we simply print from the \tt font, but for some, we can
11535 % use math or other variants that look better in normal text.
11536 %
11537 \catcode`\"=\active
11538 \def\activedoublequote{{\tt\char34}}
11539 \let"=\activedoublequote
11540 \catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
11541 \chardef\hatchar=`\^
11542 \catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
11543
11544 \catcode`\_=\active
11545 \def_{\ifusingtt\normalunderscore\_}
11546 \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
11547 \let\realunder=_
11548
11549 \catcode`\|=\active \def|{{\tt\char124}}
11550
11551 \chardef \less=`\<
11552 \catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
11553 \chardef \gtr=`\>
11554 \catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11555 \catcode`\+=\active \def+{{\tt \char 43}}
11556 \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
11557 \catcode`\-=\active \let-=\normaldash
11558
11559
11560 % used for headline/footline in the output routine, in case the page
11561 % breaks in the middle of an @tex block.
11562 \def\texinfochars{%
11563   \let< = \activeless
11564   \let> = \activegtr
11565   \let~ = \activetilde
11566   \let^ = \activehat
11567   \markupsetuplqdefault \markupsetuprqdefault
11568   \let\b = \strong
11569   \let\i = \smartitalic
11570   % in principle, all other definitions in \tex have to be undone too.
11571 }
11572
11573 % Used sometimes to turn off (effectively) the active characters even after
11574 % parsing them.
11575 \def\turnoffactive{%
11576   \normalturnoffactive
11577   \otherbackslash
11578 }
11579
11580 \catcode`\@=0
11581
11582 % \backslashcurfont outputs one backslash character in current font,
11583 % as in \char`\\.
11584 \global\chardef\backslashcurfont=`\\
11585
11586 % \realbackslash is an actual character `\' with catcode other.
11587 {\catcode`\\=\other @gdef@realbackslash{\}}
11588
11589 % In Texinfo, backslash is an active character; it prints the backslash
11590 % in fixed width font.
11591 \catcode`\\=\active  % @ for escape char from now on.
11592
11593 % Print a typewriter backslash.  For math mode, we can't simply use
11594 % \backslashcurfont: the story here is that in math mode, the \char
11595 % of \backslashcurfont ends up printing the roman \ from the math symbol
11596 % font (because \char in math mode uses the \mathcode, and plain.tex
11597 % sets \mathcode`\\="026E).  Hence we use an explicit \mathchar,
11598 % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11599 % ignored family value; char position "5C).  We can't use " for the
11600 % usual hex value because it has already been made active.
11601
11602 @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
11603 @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
11604
11605 % \otherbackslash defines an active \ to be a literal `\' character with
11606 % catcode other.
11607 @gdef@otherbackslash{@let\=@realbackslash}
11608
11609 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
11610 % the literal character `\'.
11611 %
11612 {@catcode`- = @active
11613  @gdef@normalturnoffactive{%
11614    @passthroughcharstrue
11615    @let-=@normaldash
11616    @let"=@normaldoublequote
11617    @let$=@normaldollar %$ font-lock fix
11618    @let+=@normalplus
11619    @let<=@normalless
11620    @let>=@normalgreater
11621    @let^=@normalcaret
11622    @let_=@normalunderscore
11623    @let|=@normalverticalbar
11624    @let~=@normaltilde
11625    @let\=@ttbackslash
11626    @markupsetuplqdefault
11627    @markupsetuprqdefault
11628    @unsepspaces
11629  }
11630 }
11631
11632 % If a .fmt file is being used, characters that might appear in a file
11633 % name cannot be active until we have parsed the command line.
11634 % So turn them off again, and have @fixbackslash turn them back on.
11635 @catcode`+=@other @catcode`@_=@other
11636
11637 % \enablebackslashhack - allow file to begin `\input texinfo'
11638 %
11639 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
11640 % That is what \eatinput is for; after that, the `\' should revert to printing
11641 % a backslash.
11642 % If the file did not have a `\input texinfo', then it is turned off after
11643 % the first line; otherwise the first `\' in the file would cause an error.
11644 % This is used on the very last line of this file, texinfo.tex.
11645 % We also use @c to call @fixbackslash, in case ends of lines are hidden.
11646 {
11647 @catcode`@^=7
11648 @catcode`@^^M=13@gdef@enablebackslashhack{%
11649   @global@let\ = @eatinput%
11650   @catcode`@^^M=13%
11651   @def@c{@fixbackslash@c}%
11652   % Definition for the newline at the end of this file.
11653   @def ^^M{@let^^M@secondlinenl}%
11654   % Definition for a newline in the main Texinfo file.
11655   @gdef @secondlinenl{@fixbackslash}%
11656   % In case the first line has a whole-line command on it
11657   @let@originalparsearg@parsearg
11658   @def@parsearg{@fixbackslash@originalparsearg}
11659 }}
11660
11661 {@catcode`@^=7 @catcode`@^^M=13%
11662 @gdef@eatinput input texinfo#1^^M{@fixbackslash}}
11663
11664 % Emergency active definition of newline, in case an active newline token
11665 % appears by mistake.
11666 {@catcode`@^=7 @catcode13=13%
11667 @gdef@enableemergencynewline{%
11668   @gdef^^M{%
11669     @par%
11670     %<warning: active newline>@par%
11671 }}}
11672
11673
11674 @gdef@fixbackslash{%
11675   @ifx\@eatinput @let\ = @ttbackslash @fi
11676   @catcode13=5 % regular end of line
11677   @enableemergencynewline
11678   @let@c=@comment
11679   @let@parsearg@originalparsearg
11680   % Also turn back on active characters that might appear in the input
11681   % file name, in case not using a pre-dumped format.
11682   @catcode`+=@active
11683   @catcode`@_=@active
11684   %
11685   % If texinfo.cnf is present on the system, read it.
11686   % Useful for site-wide @afourpaper, etc.  This macro, @fixbackslash, gets
11687   % called at the beginning of every Texinfo file.  Not opening texinfo.cnf
11688   % directly in this file, texinfo.tex, makes it possible to make a format
11689   % file for Texinfo.
11690   %
11691   @openin 1 texinfo.cnf
11692   @ifeof 1 @else @input texinfo.cnf @fi
11693   @closein 1
11694 }
11695
11696
11697 % Say @foo, not \foo, in error messages.
11698 @escapechar = `@@
11699
11700 % These (along with & and #) are made active for url-breaking, so need
11701 % active definitions as the normal characters.
11702 @def@normaldot{.}
11703 @def@normalquest{?}
11704 @def@normalslash{/}
11705
11706 % These look ok in all fonts, so just make them not special.
11707 % @hashchar{} gets its own user-level command, because of #line.
11708 @catcode`@& = @other @def@normalamp{&}
11709 @catcode`@# = @other @def@normalhash{#}
11710 @catcode`@% = @other @def@normalpercent{%}
11711
11712 @let @hashchar = @normalhash
11713
11714 @c Finally, make ` and ' active, so that txicodequoteundirected and
11715 @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
11716 @c don't make ` and ' active, @code will not get them as active chars.
11717 @c Do this last of all since we use ` in the previous @catcode assignments.
11718 @catcode`@'=@active
11719 @catcode`@`=@active
11720 @markupsetuplqdefault
11721 @markupsetuprqdefault
11722
11723 @c Local variables:
11724 @c eval: (add-hook 'before-save-hook 'time-stamp)
11725 @c page-delimiter: "^\\\\message\\|emacs-page"
11726 @c time-stamp-start: "def\\\\texinfoversion{"
11727 @c time-stamp-format: "%:y-%02m-%02d.%02H"
11728 @c time-stamp-end: "}"
11729 @c End:
11730
11731 @c vim:sw=2:
11732
11733 @enablebackslashhack