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{2021-11-01.16}
7%
8% Copyright 1985, 1986, 1988, 1990-2021 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% 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
576% @end foo calls \checkenv and executes the definition of \Efoo.
577\parseargdef\end{%
578  \if 1\csname iscond.#1\endcsname
579  \else
580    % The general wording of \badenverr may not be ideal.
581    \expandafter\checkenv\csname#1\endcsname
582    \csname E#1\endcsname
583    \endgroup
584  \fi
585}
586
587\newhelp\EMsimple{Press RETURN to continue.}
588
589
590% Be sure we're in horizontal mode when doing a tie, since we make space
591% equivalent to this in @example-like environments. Otherwise, a space
592% at the beginning of a line will start with \penalty -- and
593% since \penalty is valid in vertical mode, we'd end up putting the
594% penalty on the vertical list instead of in the new paragraph.
595{\catcode`@ = 11
596 % Avoid using \@M directly, because that causes trouble
597 % if the definition is written into an index file.
598 \global\let\tiepenalty = \@M
599 \gdef\tie{\leavevmode\penalty\tiepenalty\ }
600}
601
602% @: forces normal size whitespace following.
603\def\:{\spacefactor=1000 }
604
605% @* forces a line break.
606\def\*{\unskip\hfil\break\hbox{}\ignorespaces}
607
608% @/ allows a line break.
609\let\/=\allowbreak
610
611% @. is an end-of-sentence period.
612\def\.{.\spacefactor=\endofsentencespacefactor\space}
613
614% @! is an end-of-sentence bang.
615\def\!{!\spacefactor=\endofsentencespacefactor\space}
616
617% @? is an end-of-sentence query.
618\def\?{?\spacefactor=\endofsentencespacefactor\space}
619
620% @frenchspacing on|off  says whether to put extra space after punctuation.
621%
622\def\onword{on}
623\def\offword{off}
624%
625\parseargdef\frenchspacing{%
626  \def\temp{#1}%
627  \ifx\temp\onword \plainfrenchspacing
628  \else\ifx\temp\offword \plainnonfrenchspacing
629  \else
630    \errhelp = \EMsimple
631    \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
632  \fi\fi
633}
634
635% @w prevents a word break.  Without the \leavevmode, @w at the
636% beginning of a paragraph, when TeX is still in vertical mode, would
637% produce a whole line of output instead of starting the paragraph.
638\def\w#1{\leavevmode\hbox{#1}}
639
640% @group ... @end group forces ... to be all on one page, by enclosing
641% it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
642% to keep its height that of a normal line.  According to the rules for
643% \topskip (p.114 of the TeXbook), the glue inserted is
644% max (\topskip - \ht (first item), 0).  If that height is large,
645% therefore, no glue is inserted, and the space between the headline and
646% the text is small, which looks bad.
647%
648% Another complication is that the group might be very large.  This can
649% cause the glue on the previous page to be unduly stretched, because it
650% does not have much material.  In this case, it's better to add an
651% explicit \vfill so that the extra space is at the bottom.  The
652% threshold for doing this is if the group is more than \vfilllimit
653% percent of a page (\vfilllimit can be changed inside of @tex).
654%
655\newbox\groupbox
656\def\vfilllimit{0.7}
657%
658\envdef\group{%
659  \ifnum\catcode`\^^M=\active \else
660    \errhelp = \groupinvalidhelp
661    \errmessage{@group invalid in context where filling is enabled}%
662  \fi
663  \startsavinginserts
664  %
665  \setbox\groupbox = \vtop\bgroup
666    % Do @comment since we are called inside an environment such as
667    % @example, where each end-of-line in the input causes an
668    % end-of-line in the output.  We don't want the end-of-line after
669    % the `@group' to put extra space in the output.  Since @group
670    % should appear on a line by itself (according to the Texinfo
671    % manual), we don't worry about eating any user text.
672    \comment
673}
674%
675% The \vtop produces a box with normal height and large depth; thus, TeX puts
676% \baselineskip glue before it, and (when the next line of text is done)
677% \lineskip glue after it.  Thus, space below is not quite equal to space
678% above.  But it's pretty close.
679\def\Egroup{%
680    % To get correct interline space between the last line of the group
681    % and the first line afterwards, we have to propagate \prevdepth.
682    \endgraf % Not \par, as it may have been set to \lisppar.
683    \global\dimen1 = \prevdepth
684  \egroup           % End the \vtop.
685  \addgroupbox
686  \prevdepth = \dimen1
687  \checkinserts
688}
689
690\def\addgroupbox{
691  % \dimen0 is the vertical size of the group's box.
692  \dimen0 = \ht\groupbox  \advance\dimen0 by \dp\groupbox
693  % \dimen2 is how much space is left on the page (more or less).
694  \dimen2 = \txipageheight   \advance\dimen2 by -\pagetotal
695  % if the group doesn't fit on the current page, and it's a big big
696  % group, force a page break.
697  \ifdim \dimen0 > \dimen2
698    \ifdim \pagetotal < \vfilllimit\txipageheight
699      \page
700    \fi
701  \fi
702  \box\groupbox
703}
704
705%
706% TeX puts in an \escapechar (i.e., `@') at the beginning of the help
707% message, so this ends up printing `@group can only ...'.
708%
709\newhelp\groupinvalidhelp{%
710group can only be used in environments such as @example,^^J%
711where each line of input produces a line of output.}
712
713% @need space-in-mils
714% forces a page break if there is not space-in-mils remaining.
715
716\newdimen\mil  \mil=0.001in
717
718\parseargdef\need{%
719  % Ensure vertical mode, so we don't make a big box in the middle of a
720  % paragraph.
721  \par
722  %
723  % If the @need value is less than one line space, it's useless.
724  \dimen0 = #1\mil
725  \dimen2 = \ht\strutbox
726  \advance\dimen2 by \dp\strutbox
727  \ifdim\dimen0 > \dimen2
728    %
729    % Do a \strut just to make the height of this box be normal, so the
730    % normal leading is inserted relative to the preceding line.
731    % And a page break here is fine.
732    \vtop to #1\mil{\strut\vfil}%
733    %
734    % TeX does not even consider page breaks if a penalty added to the
735    % main vertical list is 10000 or more.  But in order to see if the
736    % empty box we just added fits on the page, we must make it consider
737    % page breaks.  On the other hand, we don't want to actually break the
738    % page after the empty box.  So we use a penalty of 9999.
739    %
740    % There is an extremely small chance that TeX will actually break the
741    % page at this \penalty, if there are no other feasible breakpoints in
742    % sight.  (If the user is using lots of big @group commands, which
743    % almost-but-not-quite fill up a page, TeX will have a hard time doing
744    % good page breaking, for example.)  However, I could not construct an
745    % example where a page broke at this \penalty; if it happens in a real
746    % document, then we can reconsider our strategy.
747    \penalty9999
748    %
749    % Back up by the size of the box, whether we did a page break or not.
750    \kern -#1\mil
751    %
752    % Do not allow a page break right after this kern.
753    \nobreak
754  \fi
755}
756
757% @br   forces paragraph break (and is undocumented).
758
759\let\br = \par
760
761% @page forces the start of a new page.
762%
763\def\page{\par\vfill\supereject}
764
765% @exdent text....
766% outputs text on separate line in roman font, starting at standard page margin
767
768% This records the amount of indent in the innermost environment.
769% That's how much \exdent should take out.
770\newskip\exdentamount
771
772% This defn is used inside fill environments such as @defun.
773\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
774
775% This defn is used inside nofill environments such as @example.
776\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
777  \leftline{\hskip\leftskip{\rm#1}}}}
778
779% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
780% paragraph.  For more general purposes, use the \margin insertion
781% class.  WHICH is `l' or `r'.  Not documented, written for gawk manual.
782%
783\newskip\inmarginspacing \inmarginspacing=1cm
784\def\strutdepth{\dp\strutbox}
785%
786\def\doinmargin#1#2{\strut\vadjust{%
787  \nobreak
788  \kern-\strutdepth
789  \vtop to \strutdepth{%
790    \baselineskip=\strutdepth
791    \vss
792    % if you have multiple lines of stuff to put here, you'll need to
793    % make the vbox yourself of the appropriate size.
794    \ifx#1l%
795      \llap{\ignorespaces #2\hskip\inmarginspacing}%
796    \else
797      \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
798    \fi
799    \null
800  }%
801}}
802\def\inleftmargin{\doinmargin l}
803\def\inrightmargin{\doinmargin r}
804%
805% @inmargin{TEXT [, RIGHT-TEXT]}
806% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
807% else use TEXT for both).
808%
809\def\inmargin#1{\parseinmargin #1,,\finish}
810\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
811  \setbox0 = \hbox{\ignorespaces #2}%
812  \ifdim\wd0 > 0pt
813    \def\lefttext{#1}%  have both texts
814    \def\righttext{#2}%
815  \else
816    \def\lefttext{#1}%  have only one text
817    \def\righttext{#1}%
818  \fi
819  %
820  \ifodd\pageno
821    \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
822  \else
823    \def\temp{\inleftmargin\lefttext}%
824  \fi
825  \temp
826}
827
828% @include FILE -- \input text of FILE.
829%
830\def\include{\parseargusing\filenamecatcodes\includezzz}
831\def\includezzz#1{%
832  \pushthisfilestack
833  \def\thisfile{#1}%
834  {%
835    \makevalueexpandable  % we want to expand any @value in FILE.
836    \turnoffactive        % and allow special characters in the expansion
837    \indexnofonts         % Allow `@@' and other weird things in file names.
838    \wlog{texinfo.tex: doing @include of #1^^J}%
839    \edef\temp{\noexpand\input #1 }%
840    %
841    % This trickery is to read FILE outside of a group, in case it makes
842    % definitions, etc.
843    \expandafter
844  }\temp
845  \popthisfilestack
846}
847\def\filenamecatcodes{%
848  \catcode`\\=\other
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}
860
861\def\pushthisfilestack{%
862  \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
863}
864\def\pushthisfilestackX{%
865  \expandafter\pushthisfilestackY\thisfile\StackTerm
866}
867\def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
868  \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
869}
870
871\def\popthisfilestack{\errthisfilestackempty}
872\def\errthisfilestackempty{\errmessage{Internal error:
873  the stack of filenames is empty.}}
874%
875\def\thisfile{}
876
877% @center line
878% outputs that line, centered.
879%
880\parseargdef\center{%
881  \ifhmode
882    \let\centersub\centerH
883  \else
884    \let\centersub\centerV
885  \fi
886  \centersub{\hfil \ignorespaces#1\unskip \hfil}%
887  \let\centersub\relax % don't let the definition persist, just in case
888}
889\def\centerH#1{{%
890  \hfil\break
891  \advance\hsize by -\leftskip
892  \advance\hsize by -\rightskip
893  \line{#1}%
894  \break
895}}
896%
897\newcount\centerpenalty
898\def\centerV#1{%
899  % The idea here is the same as in \startdefun, \cartouche, etc.: if
900  % @center is the first thing after a section heading, we need to wipe
901  % out the negative parskip inserted by \sectionheading, but still
902  % prevent a page break here.
903  \centerpenalty = \lastpenalty
904  \ifnum\centerpenalty>10000 \vskip\parskip \fi
905  \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
906  \line{\kern\leftskip #1\kern\rightskip}%
907}
908
909% @sp n   outputs n lines of vertical space
910%
911\parseargdef\sp{\vskip #1\baselineskip}
912
913% @comment ...line which is ignored...
914% @c is the same as @comment
915% @ignore ... @end ignore  is another way to write a comment
916
917
918\def\c{\begingroup \catcode`\^^M=\active%
919\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
920\cxxx}
921{\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
922%
923\let\comment\c
924
925% @paragraphindent NCHARS
926% We'll use ems for NCHARS, close enough.
927% NCHARS can also be the word `asis' or `none'.
928% We cannot feasibly implement @paragraphindent asis, though.
929%
930\def\asisword{asis} % no translation, these are keywords
931\def\noneword{none}
932%
933\parseargdef\paragraphindent{%
934  \def\temp{#1}%
935  \ifx\temp\asisword
936  \else
937    \ifx\temp\noneword
938      \defaultparindent = 0pt
939    \else
940      \defaultparindent = #1em
941    \fi
942  \fi
943  \parindent = \defaultparindent
944}
945
946% @exampleindent NCHARS
947% We'll use ems for NCHARS like @paragraphindent.
948% It seems @exampleindent asis isn't necessary, but
949% I preserve it to make it similar to @paragraphindent.
950\parseargdef\exampleindent{%
951  \def\temp{#1}%
952  \ifx\temp\asisword
953  \else
954    \ifx\temp\noneword
955      \lispnarrowing = 0pt
956    \else
957      \lispnarrowing = #1em
958    \fi
959  \fi
960}
961
962% @firstparagraphindent WORD
963% If WORD is `none', then suppress indentation of the first paragraph
964% after a section heading.  If WORD is `insert', then do indent at such
965% paragraphs.
966%
967% The paragraph indentation is suppressed or not by calling
968% \suppressfirstparagraphindent, which the sectioning commands do.
969% We switch the definition of this back and forth according to WORD.
970% By default, we suppress indentation.
971%
972\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
973\def\insertword{insert}
974%
975\parseargdef\firstparagraphindent{%
976  \def\temp{#1}%
977  \ifx\temp\noneword
978    \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
979  \else\ifx\temp\insertword
980    \let\suppressfirstparagraphindent = \relax
981  \else
982    \errhelp = \EMsimple
983    \errmessage{Unknown @firstparagraphindent option `\temp'}%
984  \fi\fi
985}
986
987% Here is how we actually suppress indentation.  Redefine \everypar to
988% \kern backwards by \parindent, and then reset itself to empty.
989%
990% We also make \indent itself not actually do anything until the next
991% paragraph.
992%
993\gdef\dosuppressfirstparagraphindent{%
994  \gdef\indent  {\restorefirstparagraphindent \indent}%
995  \gdef\noindent{\restorefirstparagraphindent \noindent}%
996  \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
997}
998%
999\gdef\restorefirstparagraphindent{%
1000  \global\let\indent = \ptexindent
1001  \global\let\noindent = \ptexnoindent
1002  \global\everypar = {}%
1003}
1004
1005% leave vertical mode without cancelling any first paragraph indent
1006\gdef\imageindent{%
1007  \toks0=\everypar
1008  \everypar={}%
1009  \ptexnoindent
1010  \global\everypar=\toks0
1011}
1012
1013
1014% @refill is a no-op.
1015\let\refill=\relax
1016
1017% @setfilename INFO-FILENAME - ignored
1018\let\setfilename=\comment
1019
1020% @bye.
1021\outer\def\bye{\chappager\pagelabels\tracingstats=1\ptexend}
1022
1023
1024\message{pdf,}
1025% adobe `portable' document format
1026\newcount\tempnum
1027\newcount\lnkcount
1028\newtoks\filename
1029\newcount\filenamelength
1030\newcount\pgn
1031\newtoks\toksA
1032\newtoks\toksB
1033\newtoks\toksC
1034\newtoks\toksD
1035\newbox\boxA
1036\newbox\boxB
1037\newcount\countA
1038\newif\ifpdf
1039\newif\ifpdfmakepagedest
1040
1041%
1042% For LuaTeX
1043%
1044
1045\newif\iftxiuseunicodedestname
1046\txiuseunicodedestnamefalse % For pdfTeX etc.
1047
1048\ifx\luatexversion\thisisundefined
1049\else
1050  % Use Unicode destination names
1051  \txiuseunicodedestnametrue
1052  % Escape PDF strings with converting UTF-16 from UTF-8
1053  \begingroup
1054    \catcode`\%=12
1055    \directlua{
1056      function UTF16oct(str)
1057        tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
1058        for c in string.utfvalues(str) do
1059          if c < 0x10000 then
1060            tex.sprint(
1061              string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1062                            string.char(0x5c) .. string.char(0x25) .. '03o',
1063                            math.floor(c / 256), math.floor(c % 256)))
1064          else
1065            c = c - 0x10000
1066            local c_hi = c / 1024 + 0xd800
1067            local c_lo = c % 1024 + 0xdc00
1068            tex.sprint(
1069              string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1070                            string.char(0x5c) .. string.char(0x25) .. '03o' ..
1071                            string.char(0x5c) .. string.char(0x25) .. '03o' ..
1072                            string.char(0x5c) .. string.char(0x25) .. '03o',
1073                            math.floor(c_hi / 256), math.floor(c_hi % 256),
1074                            math.floor(c_lo / 256), math.floor(c_lo % 256)))
1075          end
1076        end
1077      end
1078    }
1079  \endgroup
1080  \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
1081  % Escape PDF strings without converting
1082  \begingroup
1083    \directlua{
1084      function PDFescstr(str)
1085        for c in string.bytes(str) do
1086          if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
1087            tex.sprint(-2,
1088              string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
1089                            c))
1090          else
1091            tex.sprint(-2, string.char(c))
1092          end
1093        end
1094      end
1095    }
1096    % The -2 in the arguments here gives all the input to TeX catcode 12
1097    % (other) or 10 (space), preventing undefined control sequence errors. See
1098    % https://lists.gnu.org/archive/html/bug-texinfo/2019-08/msg00031.html
1099    %
1100  \endgroup
1101  \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
1102  \ifnum\luatexversion>84
1103    % For LuaTeX >= 0.85
1104    \def\pdfdest{\pdfextension dest}
1105    \let\pdfoutput\outputmode
1106    \def\pdfliteral{\pdfextension literal}
1107    \def\pdfcatalog{\pdfextension catalog}
1108    \def\pdftexversion{\numexpr\pdffeedback version\relax}
1109    \let\pdfximage\saveimageresource
1110    \let\pdfrefximage\useimageresource
1111    \let\pdflastximage\lastsavedimageresourceindex
1112    \def\pdfendlink{\pdfextension endlink\relax}
1113    \def\pdfoutline{\pdfextension outline}
1114    \def\pdfstartlink{\pdfextension startlink}
1115    \def\pdffontattr{\pdfextension fontattr}
1116    \def\pdfobj{\pdfextension obj}
1117    \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
1118    \let\pdfpagewidth\pagewidth
1119    \let\pdfpageheight\pageheight
1120    \edef\pdfhorigin{\pdfvariable horigin}
1121    \edef\pdfvorigin{\pdfvariable vorigin}
1122  \fi
1123\fi
1124
1125% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1126% can be set).  So we test for \relax and 0 as well as being undefined.
1127\ifx\pdfoutput\thisisundefined
1128\else
1129  \ifx\pdfoutput\relax
1130  \else
1131    \ifcase\pdfoutput
1132    \else
1133      \pdftrue
1134    \fi
1135  \fi
1136\fi
1137
1138\newif\ifpdforxetex
1139\pdforxetexfalse
1140\ifpdf
1141  \pdforxetextrue
1142\fi
1143\ifx\XeTeXrevision\thisisundefined\else
1144  \pdforxetextrue
1145\fi
1146
1147
1148% Output page labels information.
1149% See PDF reference v.1.7 p.594, section 8.3.1.
1150\ifpdf
1151\def\pagelabels{%
1152  \def\title{0 << /P (T-) /S /D >>}%
1153  \edef\roman{\the\romancount << /S /r >>}%
1154  \edef\arabic{\the\arabiccount << /S /D >>}%
1155  %
1156  % Page label ranges must be increasing.  Remove any duplicates.
1157  % (There is a slight chance of this being wrong if e.g. there is
1158  % a @contents but no @titlepage, etc.)
1159  %
1160  \ifnum\romancount=0 \def\roman{}\fi
1161  \ifnum\arabiccount=0 \def\title{}%
1162  \else
1163    \ifnum\romancount=\arabiccount \def\roman{}\fi
1164  \fi
1165  %
1166  \ifnum\romancount<\arabiccount
1167    \pdfcatalog{/PageLabels << /Nums [\title \roman \arabic ] >> }\relax
1168  \else
1169    \pdfcatalog{/PageLabels << /Nums [\title \arabic \roman ] >> }\relax
1170  \fi
1171}
1172\else
1173  \let\pagelabels\relax
1174\fi
1175
1176\newcount\pagecount \pagecount=0
1177\newcount\romancount \romancount=0
1178\newcount\arabiccount \arabiccount=0
1179\ifpdf
1180  \let\ptxadvancepageno\advancepageno
1181  \def\advancepageno{%
1182    \ptxadvancepageno\global\advance\pagecount by 1
1183  }
1184\fi
1185
1186
1187% PDF uses PostScript string constants for the names of xref targets,
1188% for display in the outlines, and in other places.  Thus, we have to
1189% double any backslashes.  Otherwise, a name like "\node" will be
1190% interpreted as a newline (\n), followed by o, d, e.  Not good.
1191%
1192% See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
1193% related messages.  The final outcome is that it is up to the TeX user
1194% to double the backslashes and otherwise make the string valid, so
1195% that's what we do.  pdftex 1.30.0 (ca.2005) introduced a primitive to
1196% do this reliably, so we use it.
1197
1198% #1 is a control sequence in which to do the replacements,
1199% which we \xdef.
1200\def\txiescapepdf#1{%
1201  \ifx\pdfescapestring\thisisundefined
1202    % No primitive available; should we give a warning or log?
1203    % Many times it won't matter.
1204    \xdef#1{#1}%
1205  \else
1206    % The expandable \pdfescapestring primitive escapes parentheses,
1207    % backslashes, and other special chars.
1208    \xdef#1{\pdfescapestring{#1}}%
1209  \fi
1210}
1211\def\txiescapepdfutfsixteen#1{%
1212  \ifx\pdfescapestrutfsixteen\thisisundefined
1213    % No UTF-16 converting macro available.
1214    \txiescapepdf{#1}%
1215  \else
1216    \xdef#1{\pdfescapestrutfsixteen{#1}}%
1217  \fi
1218}
1219
1220\newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1221with PDF output, and none of those formats could be found.  (.eps cannot
1222be supported due to the design of the PDF format; use regular TeX (DVI
1223output) for that.)}
1224
1225\ifpdf
1226  %
1227  % Color manipulation macros using ideas from pdfcolor.tex,
1228  % except using rgb instead of cmyk; the latter is said to render as a
1229  % very dark gray on-screen and a very dark halftone in print, instead
1230  % of actual black. The dark red here is dark enough to print on paper as
1231  % nearly black, but still distinguishable for online viewing.  We use
1232  % black by default, though.
1233  \def\rgbDarkRed{0.50 0.09 0.12}
1234  \def\rgbBlack{0 0 0}
1235  %
1236  % rg sets the color for filling (usual text, etc.);
1237  % RG sets the color for stroking (thin rules, e.g., normal _'s).
1238  \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
1239  %
1240  % Set color, and create a mark which defines \thiscolor accordingly,
1241  % so that \makeheadline knows which color to restore.
1242  \def\setcolor#1{%
1243    \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
1244    \domark
1245    \pdfsetcolor{#1}%
1246  }
1247  %
1248  \def\maincolor{\rgbBlack}
1249  \pdfsetcolor{\maincolor}
1250  \edef\thiscolor{\maincolor}
1251  \def\currentcolordefs{}
1252  %
1253  \def\makefootline{%
1254    \baselineskip24pt
1255    \line{\pdfsetcolor{\maincolor}\the\footline}%
1256  }
1257  %
1258  \def\makeheadline{%
1259    \vbox to 0pt{%
1260      \vskip-22.5pt
1261      \line{%
1262        \vbox to8.5pt{}%
1263        % Extract \thiscolor definition from the marks.
1264        \getcolormarks
1265        % Typeset the headline with \maincolor, then restore the color.
1266        \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1267      }%
1268      \vss
1269    }%
1270    \nointerlineskip
1271  }
1272  %
1273  %
1274  \pdfcatalog{/PageMode /UseOutlines}
1275  %
1276  % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1277  \def\dopdfimage#1#2#3{%
1278    \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1279    \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1280    %
1281    % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1282    % others).  Let's try in that order, PDF first since if
1283    % someone has a scalable image, presumably better to use that than a
1284    % bitmap.
1285    \let\pdfimgext=\empty
1286    \begingroup
1287      \openin 1 #1.pdf \ifeof 1
1288        \openin 1 #1.PDF \ifeof 1
1289          \openin 1 #1.png \ifeof 1
1290            \openin 1 #1.jpg \ifeof 1
1291              \openin 1 #1.jpeg \ifeof 1
1292                \openin 1 #1.JPG \ifeof 1
1293                  \errhelp = \nopdfimagehelp
1294                  \errmessage{Could not find image file #1 for pdf}%
1295                \else \gdef\pdfimgext{JPG}%
1296                \fi
1297              \else \gdef\pdfimgext{jpeg}%
1298              \fi
1299            \else \gdef\pdfimgext{jpg}%
1300            \fi
1301          \else \gdef\pdfimgext{png}%
1302          \fi
1303        \else \gdef\pdfimgext{PDF}%
1304        \fi
1305      \else \gdef\pdfimgext{pdf}%
1306      \fi
1307      \closein 1
1308    \endgroup
1309    %
1310    % without \immediate, ancient pdftex seg faults when the same image is
1311    % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
1312    \ifnum\pdftexversion < 14
1313      \immediate\pdfimage
1314    \else
1315      \immediate\pdfximage
1316    \fi
1317      \ifdim \wd0 >0pt width \pdfimagewidth \fi
1318      \ifdim \wd2 >0pt height \pdfimageheight \fi
1319      \ifnum\pdftexversion<13
1320         #1.\pdfimgext
1321       \else
1322         {#1.\pdfimgext}%
1323       \fi
1324    \ifnum\pdftexversion < 14 \else
1325      \pdfrefximage \pdflastximage
1326    \fi}
1327  %
1328  \def\setpdfdestname#1{{%
1329    % We have to set dummies so commands such as @code, and characters
1330    % such as \, aren't expanded when present in a section title.
1331    \indexnofonts
1332    \makevalueexpandable
1333    \turnoffactive
1334    \iftxiuseunicodedestname
1335      \ifx \declaredencoding \latone
1336        % Pass through Latin-1 characters.
1337        % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode.
1338      \else
1339        \ifx \declaredencoding \utfeight
1340          % Pass through Unicode characters.
1341        \else
1342          % Use ASCII approximations in destination names.
1343          \passthroughcharsfalse
1344        \fi
1345      \fi
1346    \else
1347      % Use ASCII approximations in destination names.
1348      \passthroughcharsfalse
1349    \fi
1350    \def\pdfdestname{#1}%
1351    \txiescapepdf\pdfdestname
1352  }}
1353  %
1354  \def\setpdfoutlinetext#1{{%
1355    \indexnofonts
1356    \makevalueexpandable
1357    \turnoffactive
1358    \ifx \declaredencoding \latone
1359      % The PDF format can use an extended form of Latin-1 in bookmark
1360      % strings.  See Appendix D of the PDF Reference, Sixth Edition, for
1361      % the "PDFDocEncoding".
1362      \passthroughcharstrue
1363      % Pass through Latin-1 characters.
1364      %   LuaTeX: Convert to Unicode
1365      %   pdfTeX: Use Latin-1 as PDFDocEncoding
1366      \def\pdfoutlinetext{#1}%
1367    \else
1368      \ifx \declaredencoding \utfeight
1369        \ifx\luatexversion\thisisundefined
1370          % For pdfTeX  with UTF-8.
1371          % TODO: the PDF format can use UTF-16 in bookmark strings,
1372          % but the code for this isn't done yet.
1373          % Use ASCII approximations.
1374          \passthroughcharsfalse
1375          \def\pdfoutlinetext{#1}%
1376        \else
1377          % For LuaTeX with UTF-8.
1378          % Pass through Unicode characters for title texts.
1379          \passthroughcharstrue
1380          \def\pdfoutlinetext{#1}%
1381        \fi
1382      \else
1383        % For non-Latin-1 or non-UTF-8 encodings.
1384        % Use ASCII approximations.
1385        \passthroughcharsfalse
1386        \def\pdfoutlinetext{#1}%
1387      \fi
1388    \fi
1389    % LuaTeX: Convert to UTF-16
1390    % pdfTeX: Use Latin-1 as PDFDocEncoding
1391    \txiescapepdfutfsixteen\pdfoutlinetext
1392  }}
1393  %
1394  \def\pdfmkdest#1{%
1395    \setpdfdestname{#1}%
1396    \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1397  }
1398  %
1399  % used to mark target names; must be expandable.
1400  \def\pdfmkpgn#1{#1}
1401  %
1402  % by default, use black for everything.
1403  \def\urlcolor{\rgbBlack}
1404  \def\linkcolor{\rgbBlack}
1405  \def\endlink{\setcolor{\maincolor}\pdfendlink}
1406  %
1407  % Adding outlines to PDF; macros for calculating structure of outlines
1408  % come from Petr Olsak
1409  \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1410    \else \csname#1\endcsname \fi}
1411  \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1412    \advance\tempnum by 1
1413    \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1414  %
1415  % #1 is the section text, which is what will be displayed in the
1416  % outline by the pdf viewer.  #2 is the pdf expression for the number
1417  % of subentries (or empty, for subsubsections).  #3 is the node text,
1418  % which might be empty if this toc entry had no corresponding node.
1419  % #4 is the page number
1420  %
1421  \def\dopdfoutline#1#2#3#4{%
1422    % Generate a link to the node text if that exists; else, use the
1423    % page number.  We could generate a destination for the section
1424    % text in the case where a section has no node, but it doesn't
1425    % seem worth the trouble, since most documents are normally structured.
1426    \setpdfoutlinetext{#1}
1427    \setpdfdestname{#3}
1428    \ifx\pdfdestname\empty
1429      \def\pdfdestname{#4}%
1430    \fi
1431    %
1432    \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}%
1433  }
1434  %
1435  \def\pdfmakeoutlines{%
1436    \begingroup
1437      % Read toc silently, to get counts of subentries for \pdfoutline.
1438      \def\partentry##1##2##3##4{}% ignore parts in the outlines
1439      \def\numchapentry##1##2##3##4{%
1440	\def\thischapnum{##2}%
1441	\def\thissecnum{0}%
1442	\def\thissubsecnum{0}%
1443      }%
1444      \def\numsecentry##1##2##3##4{%
1445	\advancenumber{chap\thischapnum}%
1446	\def\thissecnum{##2}%
1447	\def\thissubsecnum{0}%
1448      }%
1449      \def\numsubsecentry##1##2##3##4{%
1450	\advancenumber{sec\thissecnum}%
1451	\def\thissubsecnum{##2}%
1452      }%
1453      \def\numsubsubsecentry##1##2##3##4{%
1454	\advancenumber{subsec\thissubsecnum}%
1455      }%
1456      \def\thischapnum{0}%
1457      \def\thissecnum{0}%
1458      \def\thissubsecnum{0}%
1459      %
1460      % use \def rather than \let here because we redefine \chapentry et
1461      % al. a second time, below.
1462      \def\appentry{\numchapentry}%
1463      \def\appsecentry{\numsecentry}%
1464      \def\appsubsecentry{\numsubsecentry}%
1465      \def\appsubsubsecentry{\numsubsubsecentry}%
1466      \def\unnchapentry{\numchapentry}%
1467      \def\unnsecentry{\numsecentry}%
1468      \def\unnsubsecentry{\numsubsecentry}%
1469      \def\unnsubsubsecentry{\numsubsubsecentry}%
1470      \readdatafile{toc}%
1471      %
1472      % Read toc second time, this time actually producing the outlines.
1473      % The `-' means take the \expnumber as the absolute number of
1474      % subentries, which we calculated on our first read of the .toc above.
1475      %
1476      % We use the node names as the destinations.
1477      %
1478      % Currently we prefix the section name with the section number
1479      % for chapter and appendix headings only in order to avoid too much
1480      % horizontal space being required in the PDF viewer.
1481      \def\numchapentry##1##2##3##4{%
1482        \dopdfoutline{##2 ##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1483      \def\unnchapentry##1##2##3##4{%
1484        \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1485      \def\numsecentry##1##2##3##4{%
1486        \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1487      \def\numsubsecentry##1##2##3##4{%
1488        \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1489      \def\numsubsubsecentry##1##2##3##4{% count is always zero
1490        \dopdfoutline{##1}{}{##3}{##4}}%
1491      %
1492      % PDF outlines are displayed using system fonts, instead of
1493      % document fonts.  Therefore we cannot use special characters,
1494      % since the encoding is unknown.  For example, the eogonek from
1495      % Latin 2 (0xea) gets translated to a | character.  Info from
1496      % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1497      %
1498      % TODO this right, we have to translate 8-bit characters to
1499      % their "best" equivalent, based on the @documentencoding.  Too
1500      % much work for too little return.  Just use the ASCII equivalents
1501      % we use for the index sort strings.
1502      %
1503      \indexnofonts
1504      \setupdatafile
1505      % We can have normal brace characters in the PDF outlines, unlike
1506      % Texinfo index files.  So set that up.
1507      \def\{{\lbracecharliteral}%
1508      \def\}{\rbracecharliteral}%
1509      \catcode`\\=\active \otherbackslash
1510      \input \tocreadfilename
1511    \endgroup
1512  }
1513  {\catcode`[=1 \catcode`]=2
1514   \catcode`{=\other \catcode`}=\other
1515   \gdef\lbracecharliteral[{]%
1516   \gdef\rbracecharliteral[}]%
1517  ]
1518  %
1519  \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1520    \ifx\PP\D\let\nextsp\relax
1521    \else\let\nextsp\skipspaces
1522      \addtokens{\filename}{\PP}%
1523      \advance\filenamelength by 1
1524    \fi
1525    \nextsp}
1526  \def\getfilename#1{%
1527    \filenamelength=0
1528    % If we don't expand the argument now, \skipspaces will get
1529    % snagged on things like "@value{foo}".
1530    \edef\temp{#1}%
1531    \expandafter\skipspaces\temp|\relax
1532  }
1533  \ifnum\pdftexversion < 14
1534    \let \startlink \pdfannotlink
1535  \else
1536    \let \startlink \pdfstartlink
1537  \fi
1538  % make a live url in pdf output.
1539  \def\pdfurl#1{%
1540    \begingroup
1541      % it seems we really need yet another set of dummies; have not
1542      % tried to figure out what each command should do in the context
1543      % of @url.  for now, just make @/ a no-op, that's the only one
1544      % people have actually reported a problem with.
1545      %
1546      \normalturnoffactive
1547      \def\@{@}%
1548      \let\/=\empty
1549      \makevalueexpandable
1550      % do we want to go so far as to use \indexnofonts instead of just
1551      % special-casing \var here?
1552      \def\var##1{##1}%
1553      %
1554      \leavevmode\setcolor{\urlcolor}%
1555      \startlink attr{/Border [0 0 0]}%
1556        user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1557    \endgroup}
1558  % \pdfgettoks - Surround page numbers in #1 with @pdflink.  #1 may
1559  % be a simple number, or a list of numbers in the case of an index
1560  % entry.
1561  \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1562  \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1563  \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1564  \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1565  \def\maketoks{%
1566    \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1567    \ifx\first0\adn0
1568    \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1569    \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1570    \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1571    \else
1572      \ifnum0=\countA\else\makelink\fi
1573      \ifx\first.\let\next=\done\else
1574        \let\next=\maketoks
1575        \addtokens{\toksB}{\the\toksD}
1576        \ifx\first,\addtokens{\toksB}{\space}\fi
1577      \fi
1578    \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1579    \next}
1580  \def\makelink{\addtokens{\toksB}%
1581    {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1582  \def\pdflink#1{%
1583    \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1584    \setcolor{\linkcolor}#1\endlink}
1585  \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1586\else
1587  % non-pdf mode
1588  \let\pdfmkdest = \gobble
1589  \let\pdfurl = \gobble
1590  \let\endlink = \relax
1591  \let\setcolor = \gobble
1592  \let\pdfsetcolor = \gobble
1593  \let\pdfmakeoutlines = \relax
1594\fi  % \ifx\pdfoutput
1595
1596%
1597% For XeTeX
1598%
1599\ifx\XeTeXrevision\thisisundefined
1600\else
1601  %
1602  % XeTeX version check
1603  %
1604  \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1
1605    % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307.
1606    % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941).
1607    % For avoiding PDF destination name replacement, we use this special
1608    % instead of xdvipdfmx's command line option `-C 0x0010'.
1609    \special{dvipdfmx:config C 0x0010}
1610    % XeTeX 0.99995+ comes with xdvipdfmx 20160307+.
1611    % It can handle Unicode destination names for PDF.
1612    \txiuseunicodedestnametrue
1613  \else
1614    % XeTeX < 0.99996 (TeX Live < 2016) cannot use the
1615    % `dvipdfmx:config' special.
1616    % So for avoiding PDF destination name replacement,
1617    % xdvipdfmx's command line option `-C 0x0010' is necessary.
1618    %
1619    % XeTeX < 0.99995 can not handle Unicode destination names for PDF
1620    % because xdvipdfmx 20150315 has a UTF-16 conversion issue.
1621    % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1622    \txiuseunicodedestnamefalse
1623  \fi
1624  %
1625  % Color support
1626  %
1627  \def\rgbDarkRed{0.50 0.09 0.12}
1628  \def\rgbBlack{0 0 0}
1629  %
1630  \def\pdfsetcolor#1{\special{pdf:scolor [#1]}}
1631  %
1632  % Set color, and create a mark which defines \thiscolor accordingly,
1633  % so that \makeheadline knows which color to restore.
1634  \def\setcolor#1{%
1635    \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
1636    \domark
1637    \pdfsetcolor{#1}%
1638  }
1639  %
1640  \def\maincolor{\rgbBlack}
1641  \pdfsetcolor{\maincolor}
1642  \edef\thiscolor{\maincolor}
1643  \def\currentcolordefs{}
1644  %
1645  \def\makefootline{%
1646    \baselineskip24pt
1647    \line{\pdfsetcolor{\maincolor}\the\footline}%
1648  }
1649  %
1650  \def\makeheadline{%
1651    \vbox to 0pt{%
1652      \vskip-22.5pt
1653      \line{%
1654        \vbox to8.5pt{}%
1655        % Extract \thiscolor definition from the marks.
1656        \getcolormarks
1657        % Typeset the headline with \maincolor, then restore the color.
1658        \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1659      }%
1660      \vss
1661    }%
1662    \nointerlineskip
1663  }
1664  %
1665  % PDF outline support
1666  %
1667  % Emulate pdfTeX primitive
1668  \def\pdfdest name#1 xyz{%
1669    \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}%
1670  }
1671  %
1672  \def\setpdfdestname#1{{%
1673    % We have to set dummies so commands such as @code, and characters
1674    % such as \, aren't expanded when present in a section title.
1675    \indexnofonts
1676    \makevalueexpandable
1677    \turnoffactive
1678    \iftxiuseunicodedestname
1679      % Pass through Unicode characters.
1680    \else
1681      % Use ASCII approximations in destination names.
1682      \passthroughcharsfalse
1683    \fi
1684    \def\pdfdestname{#1}%
1685    \txiescapepdf\pdfdestname
1686  }}
1687  %
1688  \def\setpdfoutlinetext#1{{%
1689    \turnoffactive
1690    % Always use Unicode characters in title texts.
1691    \def\pdfoutlinetext{#1}%
1692    % For XeTeX, xdvipdfmx converts to UTF-16.
1693    % So we do not convert.
1694    \txiescapepdf\pdfoutlinetext
1695  }}
1696  %
1697  \def\pdfmkdest#1{%
1698    \setpdfdestname{#1}%
1699    \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1700  }
1701  %
1702  % by default, use black for everything.
1703  \def\urlcolor{\rgbBlack}
1704  \def\linkcolor{\rgbBlack}
1705  \def\endlink{\setcolor{\maincolor}\pdfendlink}
1706  %
1707  \def\dopdfoutline#1#2#3#4{%
1708    \setpdfoutlinetext{#1}
1709    \setpdfdestname{#3}
1710    \ifx\pdfdestname\empty
1711      \def\pdfdestname{#4}%
1712    \fi
1713    %
1714    \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
1715      << /S /GoTo /D (\pdfdestname) >> >> }%
1716  }
1717  %
1718  \def\pdfmakeoutlines{%
1719    \begingroup
1720      %
1721      % For XeTeX, counts of subentries are not necessary.
1722      % Therefore, we read toc only once.
1723      %
1724      % We use node names as destinations.
1725      %
1726      % Currently we prefix the section name with the section number
1727      % for chapter and appendix headings only in order to avoid too much
1728      % horizontal space being required in the PDF viewer.
1729      \def\partentry##1##2##3##4{}% ignore parts in the outlines
1730      \def\numchapentry##1##2##3##4{%
1731        \dopdfoutline{##2 ##1}{1}{##3}{##4}}%
1732      \def\numsecentry##1##2##3##4{%
1733        \dopdfoutline{##1}{2}{##3}{##4}}%
1734      \def\numsubsecentry##1##2##3##4{%
1735        \dopdfoutline{##1}{3}{##3}{##4}}%
1736      \def\numsubsubsecentry##1##2##3##4{%
1737        \dopdfoutline{##1}{4}{##3}{##4}}%
1738      %
1739      \let\appentry\numchapentry%
1740      \let\appsecentry\numsecentry%
1741      \let\appsubsecentry\numsubsecentry%
1742      \let\appsubsubsecentry\numsubsubsecentry%
1743      \def\unnchapentry##1##2##3##4{%
1744        \dopdfoutline{##1}{1}{##3}{##4}}%
1745      \let\unnsecentry\numsecentry%
1746      \let\unnsubsecentry\numsubsecentry%
1747      \let\unnsubsubsecentry\numsubsubsecentry%
1748      %
1749      % For XeTeX, xdvipdfmx converts strings to UTF-16.
1750      % Therefore, the encoding and the language may not be considered.
1751      %
1752      \indexnofonts
1753      \setupdatafile
1754      % We can have normal brace characters in the PDF outlines, unlike
1755      % Texinfo index files.  So set that up.
1756      \def\{{\lbracecharliteral}%
1757      \def\}{\rbracecharliteral}%
1758      \catcode`\\=\active \otherbackslash
1759      \input \tocreadfilename
1760    \endgroup
1761  }
1762  {\catcode`[=1 \catcode`]=2
1763   \catcode`{=\other \catcode`}=\other
1764   \gdef\lbracecharliteral[{]%
1765   \gdef\rbracecharliteral[}]%
1766  ]
1767
1768  \special{pdf:docview << /PageMode /UseOutlines >> }
1769  % ``\special{pdf:tounicode ...}'' is not necessary
1770  % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
1771  % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315,
1772  % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings.
1773  % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1774%
1775  \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1776    \ifx\PP\D\let\nextsp\relax
1777    \else\let\nextsp\skipspaces
1778      \addtokens{\filename}{\PP}%
1779      \advance\filenamelength by 1
1780    \fi
1781    \nextsp}
1782  \def\getfilename#1{%
1783    \filenamelength=0
1784    % If we don't expand the argument now, \skipspaces will get
1785    % snagged on things like "@value{foo}".
1786    \edef\temp{#1}%
1787    \expandafter\skipspaces\temp|\relax
1788  }
1789  % make a live url in pdf output.
1790  \def\pdfurl#1{%
1791    \begingroup
1792      % it seems we really need yet another set of dummies; have not
1793      % tried to figure out what each command should do in the context
1794      % of @url.  for now, just make @/ a no-op, that's the only one
1795      % people have actually reported a problem with.
1796      %
1797      \normalturnoffactive
1798      \def\@{@}%
1799      \let\/=\empty
1800      \makevalueexpandable
1801      % do we want to go so far as to use \indexnofonts instead of just
1802      % special-casing \var here?
1803      \def\var##1{##1}%
1804      %
1805      \leavevmode\setcolor{\urlcolor}%
1806      \special{pdf:bann << /Border [0 0 0]
1807        /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
1808    \endgroup}
1809  \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
1810  \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1811  \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1812  \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1813  \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1814  \def\maketoks{%
1815    \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1816    \ifx\first0\adn0
1817    \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1818    \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1819    \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1820    \else
1821      \ifnum0=\countA\else\makelink\fi
1822      \ifx\first.\let\next=\done\else
1823        \let\next=\maketoks
1824        \addtokens{\toksB}{\the\toksD}
1825        \ifx\first,\addtokens{\toksB}{\space}\fi
1826      \fi
1827    \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1828    \next}
1829  \def\makelink{\addtokens{\toksB}%
1830    {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1831  \def\pdflink#1{%
1832    \special{pdf:bann << /Border [0 0 0]
1833      /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}%
1834    \setcolor{\linkcolor}#1\endlink}
1835  \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1836%
1837  %
1838  % @image support
1839  %
1840  % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1841  \def\doxeteximage#1#2#3{%
1842    \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1843    \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1844    %
1845    % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among
1846    % others).  Let's try in that order, PDF first since if
1847    % someone has a scalable image, presumably better to use that than a
1848    % bitmap.
1849    \let\xeteximgext=\empty
1850    \begingroup
1851      \openin 1 #1.pdf \ifeof 1
1852        \openin 1 #1.PDF \ifeof 1
1853          \openin 1 #1.png \ifeof 1
1854            \openin 1 #1.jpg \ifeof 1
1855              \openin 1 #1.jpeg \ifeof 1
1856                \openin 1 #1.JPG \ifeof 1
1857                  \errmessage{Could not find image file #1 for XeTeX}%
1858                \else \gdef\xeteximgext{JPG}%
1859                \fi
1860              \else \gdef\xeteximgext{jpeg}%
1861              \fi
1862            \else \gdef\xeteximgext{jpg}%
1863            \fi
1864          \else \gdef\xeteximgext{png}%
1865          \fi
1866        \else \gdef\xeteximgext{PDF}%
1867        \fi
1868      \else \gdef\xeteximgext{pdf}%
1869      \fi
1870      \closein 1
1871    \endgroup
1872    %
1873    % Putting an \hbox around the image can prevent an over-long line
1874    % after the image.
1875    \hbox\bgroup
1876      \def\xetexpdfext{pdf}%
1877      \ifx\xeteximgext\xetexpdfext
1878        \XeTeXpdffile "#1".\xeteximgext ""
1879      \else
1880        \def\xetexpdfext{PDF}%
1881        \ifx\xeteximgext\xetexpdfext
1882          \XeTeXpdffile "#1".\xeteximgext ""
1883        \else
1884          \XeTeXpicfile "#1".\xeteximgext ""
1885        \fi
1886      \fi
1887      \ifdim \wd0 >0pt width \xeteximagewidth \fi
1888      \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1889    \egroup
1890  }
1891\fi
1892
1893
1894%
1895\message{fonts,}
1896
1897% Set the baselineskip to #1, and the lineskip and strut size
1898% correspondingly.  There is no deep meaning behind these magic numbers
1899% used as factors; they just match (closely enough) what Knuth defined.
1900%
1901\def\lineskipfactor{.08333}
1902\def\strutheightpercent{.70833}
1903\def\strutdepthpercent {.29167}
1904%
1905% can get a sort of poor man's double spacing by redefining this.
1906\def\baselinefactor{1}
1907%
1908\newdimen\textleading
1909\def\setleading#1{%
1910  \dimen0 = #1\relax
1911  \normalbaselineskip = \baselinefactor\dimen0
1912  \normallineskip = \lineskipfactor\normalbaselineskip
1913  \normalbaselines
1914  \setbox\strutbox =\hbox{%
1915    \vrule width0pt height\strutheightpercent\baselineskip
1916                    depth \strutdepthpercent \baselineskip
1917  }%
1918}
1919
1920% PDF CMaps.  See also LaTeX's t1.cmap.
1921%
1922% do nothing with this by default.
1923\expandafter\let\csname cmapOT1\endcsname\gobble
1924\expandafter\let\csname cmapOT1IT\endcsname\gobble
1925\expandafter\let\csname cmapOT1TT\endcsname\gobble
1926
1927% if we are producing pdf, and we have \pdffontattr, then define cmaps.
1928% (\pdffontattr was introduced many years ago, but people still run
1929% older pdftex's; it's easy to conditionalize, so we do.)
1930\ifpdf \ifx\pdffontattr\thisisundefined \else
1931  \begingroup
1932    \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1933    \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1934%%DocumentNeededResources: ProcSet (CIDInit)
1935%%IncludeResource: ProcSet (CIDInit)
1936%%BeginResource: CMap (TeX-OT1-0)
1937%%Title: (TeX-OT1-0 TeX OT1 0)
1938%%Version: 1.000
1939%%EndComments
1940/CIDInit /ProcSet findresource begin
194112 dict begin
1942begincmap
1943/CIDSystemInfo
1944<< /Registry (TeX)
1945/Ordering (OT1)
1946/Supplement 0
1947>> def
1948/CMapName /TeX-OT1-0 def
1949/CMapType 2 def
19501 begincodespacerange
1951<00> <7F>
1952endcodespacerange
19538 beginbfrange
1954<00> <01> <0393>
1955<09> <0A> <03A8>
1956<23> <26> <0023>
1957<28> <3B> <0028>
1958<3F> <5B> <003F>
1959<5D> <5E> <005D>
1960<61> <7A> <0061>
1961<7B> <7C> <2013>
1962endbfrange
196340 beginbfchar
1964<02> <0398>
1965<03> <039B>
1966<04> <039E>
1967<05> <03A0>
1968<06> <03A3>
1969<07> <03D2>
1970<08> <03A6>
1971<0B> <00660066>
1972<0C> <00660069>
1973<0D> <0066006C>
1974<0E> <006600660069>
1975<0F> <00660066006C>
1976<10> <0131>
1977<11> <0237>
1978<12> <0060>
1979<13> <00B4>
1980<14> <02C7>
1981<15> <02D8>
1982<16> <00AF>
1983<17> <02DA>
1984<18> <00B8>
1985<19> <00DF>
1986<1A> <00E6>
1987<1B> <0153>
1988<1C> <00F8>
1989<1D> <00C6>
1990<1E> <0152>
1991<1F> <00D8>
1992<21> <0021>
1993<22> <201D>
1994<27> <2019>
1995<3C> <00A1>
1996<3D> <003D>
1997<3E> <00BF>
1998<5C> <201C>
1999<5F> <02D9>
2000<60> <2018>
2001<7D> <02DD>
2002<7E> <007E>
2003<7F> <00A8>
2004endbfchar
2005endcmap
2006CMapName currentdict /CMap defineresource pop
2007end
2008end
2009%%EndResource
2010%%EOF
2011    }\endgroup
2012  \expandafter\edef\csname cmapOT1\endcsname#1{%
2013    \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2014  }%
2015%
2016% \cmapOT1IT
2017  \begingroup
2018    \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2019    \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2020%%DocumentNeededResources: ProcSet (CIDInit)
2021%%IncludeResource: ProcSet (CIDInit)
2022%%BeginResource: CMap (TeX-OT1IT-0)
2023%%Title: (TeX-OT1IT-0 TeX OT1IT 0)
2024%%Version: 1.000
2025%%EndComments
2026/CIDInit /ProcSet findresource begin
202712 dict begin
2028begincmap
2029/CIDSystemInfo
2030<< /Registry (TeX)
2031/Ordering (OT1IT)
2032/Supplement 0
2033>> def
2034/CMapName /TeX-OT1IT-0 def
2035/CMapType 2 def
20361 begincodespacerange
2037<00> <7F>
2038endcodespacerange
20398 beginbfrange
2040<00> <01> <0393>
2041<09> <0A> <03A8>
2042<25> <26> <0025>
2043<28> <3B> <0028>
2044<3F> <5B> <003F>
2045<5D> <5E> <005D>
2046<61> <7A> <0061>
2047<7B> <7C> <2013>
2048endbfrange
204942 beginbfchar
2050<02> <0398>
2051<03> <039B>
2052<04> <039E>
2053<05> <03A0>
2054<06> <03A3>
2055<07> <03D2>
2056<08> <03A6>
2057<0B> <00660066>
2058<0C> <00660069>
2059<0D> <0066006C>
2060<0E> <006600660069>
2061<0F> <00660066006C>
2062<10> <0131>
2063<11> <0237>
2064<12> <0060>
2065<13> <00B4>
2066<14> <02C7>
2067<15> <02D8>
2068<16> <00AF>
2069<17> <02DA>
2070<18> <00B8>
2071<19> <00DF>
2072<1A> <00E6>
2073<1B> <0153>
2074<1C> <00F8>
2075<1D> <00C6>
2076<1E> <0152>
2077<1F> <00D8>
2078<21> <0021>
2079<22> <201D>
2080<23> <0023>
2081<24> <00A3>
2082<27> <2019>
2083<3C> <00A1>
2084<3D> <003D>
2085<3E> <00BF>
2086<5C> <201C>
2087<5F> <02D9>
2088<60> <2018>
2089<7D> <02DD>
2090<7E> <007E>
2091<7F> <00A8>
2092endbfchar
2093endcmap
2094CMapName currentdict /CMap defineresource pop
2095end
2096end
2097%%EndResource
2098%%EOF
2099    }\endgroup
2100  \expandafter\edef\csname cmapOT1IT\endcsname#1{%
2101    \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2102  }%
2103%
2104% \cmapOT1TT
2105  \begingroup
2106    \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2107    \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2108%%DocumentNeededResources: ProcSet (CIDInit)
2109%%IncludeResource: ProcSet (CIDInit)
2110%%BeginResource: CMap (TeX-OT1TT-0)
2111%%Title: (TeX-OT1TT-0 TeX OT1TT 0)
2112%%Version: 1.000
2113%%EndComments
2114/CIDInit /ProcSet findresource begin
211512 dict begin
2116begincmap
2117/CIDSystemInfo
2118<< /Registry (TeX)
2119/Ordering (OT1TT)
2120/Supplement 0
2121>> def
2122/CMapName /TeX-OT1TT-0 def
2123/CMapType 2 def
21241 begincodespacerange
2125<00> <7F>
2126endcodespacerange
21275 beginbfrange
2128<00> <01> <0393>
2129<09> <0A> <03A8>
2130<21> <26> <0021>
2131<28> <5F> <0028>
2132<61> <7E> <0061>
2133endbfrange
213432 beginbfchar
2135<02> <0398>
2136<03> <039B>
2137<04> <039E>
2138<05> <03A0>
2139<06> <03A3>
2140<07> <03D2>
2141<08> <03A6>
2142<0B> <2191>
2143<0C> <2193>
2144<0D> <0027>
2145<0E> <00A1>
2146<0F> <00BF>
2147<10> <0131>
2148<11> <0237>
2149<12> <0060>
2150<13> <00B4>
2151<14> <02C7>
2152<15> <02D8>
2153<16> <00AF>
2154<17> <02DA>
2155<18> <00B8>
2156<19> <00DF>
2157<1A> <00E6>
2158<1B> <0153>
2159<1C> <00F8>
2160<1D> <00C6>
2161<1E> <0152>
2162<1F> <00D8>
2163<20> <2423>
2164<27> <2019>
2165<60> <2018>
2166<7F> <00A8>
2167endbfchar
2168endcmap
2169CMapName currentdict /CMap defineresource pop
2170end
2171end
2172%%EndResource
2173%%EOF
2174    }\endgroup
2175  \expandafter\edef\csname cmapOT1TT\endcsname#1{%
2176    \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2177  }%
2178\fi\fi
2179
2180
2181% Set the font macro #1 to the font named \fontprefix#2.
2182% #3 is the font's design size, #4 is a scale factor, #5 is the CMap
2183% encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
2184% Example:
2185% #1 = \textrm
2186% #2 = \rmshape
2187% #3 = 10
2188% #4 = \mainmagstep
2189% #5 = OT1
2190%
2191\def\setfont#1#2#3#4#5{%
2192  \font#1=\fontprefix#2#3 scaled #4
2193  \csname cmap#5\endcsname#1%
2194}
2195% This is what gets called when #5 of \setfont is empty.
2196\let\cmap\gobble
2197%
2198% (end of cmaps)
2199
2200% Use cm as the default font prefix.
2201% To specify the font prefix, you must define \fontprefix
2202% before you read in texinfo.tex.
2203\ifx\fontprefix\thisisundefined
2204\def\fontprefix{cm}
2205\fi
2206% Support font families that don't use the same naming scheme as CM.
2207\def\rmshape{r}
2208\def\rmbshape{bx}               % where the normal face is bold
2209\def\bfshape{b}
2210\def\bxshape{bx}
2211\def\ttshape{tt}
2212\def\ttbshape{tt}
2213\def\ttslshape{sltt}
2214\def\itshape{ti}
2215\def\itbshape{bxti}
2216\def\slshape{sl}
2217\def\slbshape{bxsl}
2218\def\sfshape{ss}
2219\def\sfbshape{ss}
2220\def\scshape{csc}
2221\def\scbshape{csc}
2222
2223% Definitions for a main text size of 11pt.  (The default in Texinfo.)
2224%
2225\def\definetextfontsizexi{%
2226% Text fonts (11.2pt, magstep1).
2227\def\textnominalsize{11pt}
2228\edef\mainmagstep{\magstephalf}
2229\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2230\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2231\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2232\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2233\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2234\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2235\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2236\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2237\font\texti=cmmi10 scaled \mainmagstep
2238\font\textsy=cmsy10 scaled \mainmagstep
2239\def\textecsize{1095}
2240
2241% A few fonts for @defun names and args.
2242\setfont\defbf\bfshape{10}{\magstep1}{OT1}
2243\setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
2244\setfont\defsl\slshape{10}{\magstep1}{OT1}
2245\setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
2246\def\df{\let\ttfont=\deftt \let\bffont = \defbf
2247\let\ttslfont=\defttsl \let\slfont=\defsl \bf}
2248
2249% Fonts for indices, footnotes, small examples (9pt).
2250\def\smallnominalsize{9pt}
2251\setfont\smallrm\rmshape{9}{1000}{OT1}
2252\setfont\smalltt\ttshape{9}{1000}{OT1TT}
2253\setfont\smallbf\bfshape{10}{900}{OT1}
2254\setfont\smallit\itshape{9}{1000}{OT1IT}
2255\setfont\smallsl\slshape{9}{1000}{OT1}
2256\setfont\smallsf\sfshape{9}{1000}{OT1}
2257\setfont\smallsc\scshape{10}{900}{OT1}
2258\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2259\font\smalli=cmmi9
2260\font\smallsy=cmsy9
2261\def\smallecsize{0900}
2262
2263% Fonts for small examples (8pt).
2264\def\smallernominalsize{8pt}
2265\setfont\smallerrm\rmshape{8}{1000}{OT1}
2266\setfont\smallertt\ttshape{8}{1000}{OT1TT}
2267\setfont\smallerbf\bfshape{10}{800}{OT1}
2268\setfont\smallerit\itshape{8}{1000}{OT1IT}
2269\setfont\smallersl\slshape{8}{1000}{OT1}
2270\setfont\smallersf\sfshape{8}{1000}{OT1}
2271\setfont\smallersc\scshape{10}{800}{OT1}
2272\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2273\font\smalleri=cmmi8
2274\font\smallersy=cmsy8
2275\def\smallerecsize{0800}
2276
2277% Fonts for math mode superscripts (7pt).
2278\def\sevennominalsize{7pt}
2279\setfont\sevenrm\rmshape{7}{1000}{OT1}
2280\setfont\seventt\ttshape{10}{700}{OT1TT}
2281\setfont\sevenbf\bfshape{10}{700}{OT1}
2282\setfont\sevenit\itshape{7}{1000}{OT1IT}
2283\setfont\sevensl\slshape{10}{700}{OT1}
2284\setfont\sevensf\sfshape{10}{700}{OT1}
2285\setfont\sevensc\scshape{10}{700}{OT1}
2286\setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2287\font\seveni=cmmi7
2288\font\sevensy=cmsy7
2289\def\sevenecsize{0700}
2290
2291% Fonts for title page (20.4pt):
2292\def\titlenominalsize{20pt}
2293\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2294\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2295\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2296\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2297\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2298\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2299\let\titlebf=\titlerm
2300\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2301\font\titlei=cmmi12 scaled \magstep3
2302\font\titlesy=cmsy10 scaled \magstep4
2303\def\titleecsize{2074}
2304
2305% Chapter (and unnumbered) fonts (17.28pt).
2306\def\chapnominalsize{17pt}
2307\setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2308\setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2309\setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2310\setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2311\setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2312\setfont\chapsf\sfbshape{17}{1000}{OT1}
2313\let\chapbf=\chaprm
2314\setfont\chapsc\scbshape{10}{\magstep3}{OT1}
2315\font\chapi=cmmi12 scaled \magstep2
2316\font\chapsy=cmsy10 scaled \magstep3
2317\def\chapecsize{1728}
2318
2319% Section fonts (14.4pt).
2320\def\secnominalsize{14pt}
2321\setfont\secrm\rmbshape{12}{\magstep1}{OT1}
2322\setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
2323\setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2324\setfont\secsl\slbshape{10}{\magstep2}{OT1}
2325\setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2326\setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2327\setfont\secsf\sfbshape{12}{\magstep1}{OT1}
2328\let\secbf\secrm
2329\setfont\secsc\scbshape{10}{\magstep2}{OT1}
2330\font\seci=cmmi12 scaled \magstep1
2331\font\secsy=cmsy10 scaled \magstep2
2332\def\sececsize{1440}
2333
2334% Subsection fonts (13.15pt).
2335\def\ssecnominalsize{13pt}
2336\setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2337\setfont\ssecit\itbshape{10}{1315}{OT1IT}
2338\setfont\ssecsl\slbshape{10}{1315}{OT1}
2339\setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2340\setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2341\setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
2342\let\ssecbf\ssecrm
2343\setfont\ssecsc\scbshape{10}{1315}{OT1}
2344\font\sseci=cmmi12 scaled \magstephalf
2345\font\ssecsy=cmsy10 scaled 1315
2346\def\ssececsize{1200}
2347
2348% Reduced fonts for @acronym in text (10pt).
2349\def\reducednominalsize{10pt}
2350\setfont\reducedrm\rmshape{10}{1000}{OT1}
2351\setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2352\setfont\reducedbf\bfshape{10}{1000}{OT1}
2353\setfont\reducedit\itshape{10}{1000}{OT1IT}
2354\setfont\reducedsl\slshape{10}{1000}{OT1}
2355\setfont\reducedsf\sfshape{10}{1000}{OT1}
2356\setfont\reducedsc\scshape{10}{1000}{OT1}
2357\setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
2358\font\reducedi=cmmi10
2359\font\reducedsy=cmsy10
2360\def\reducedecsize{1000}
2361
2362\textleading = 13.2pt % line spacing for 11pt CM
2363\textfonts            % reset the current fonts
2364\rm
2365} % end of 11pt text font size definitions, \definetextfontsizexi
2366
2367
2368% Definitions to make the main text be 10pt Computer Modern, with
2369% section, chapter, etc., sizes following suit.  This is for the GNU
2370% Press printing of the Emacs 22 manual.  Maybe other manuals in the
2371% future.  Used with @smallbook, which sets the leading to 12pt.
2372%
2373\def\definetextfontsizex{%
2374% Text fonts (10pt).
2375\def\textnominalsize{10pt}
2376\edef\mainmagstep{1000}
2377\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2378\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2379\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2380\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2381\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2382\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2383\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2384\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2385\font\texti=cmmi10 scaled \mainmagstep
2386\font\textsy=cmsy10 scaled \mainmagstep
2387\def\textecsize{1000}
2388
2389% A few fonts for @defun names and args.
2390\setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2391\setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
2392\setfont\defsl\slshape{10}{\magstephalf}{OT1}
2393\setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
2394\def\df{\let\ttfont=\deftt \let\bffont = \defbf
2395\let\slfont=\defsl \let\ttslfont=\defttsl \bf}
2396
2397% Fonts for indices, footnotes, small examples (9pt).
2398\def\smallnominalsize{9pt}
2399\setfont\smallrm\rmshape{9}{1000}{OT1}
2400\setfont\smalltt\ttshape{9}{1000}{OT1TT}
2401\setfont\smallbf\bfshape{10}{900}{OT1}
2402\setfont\smallit\itshape{9}{1000}{OT1IT}
2403\setfont\smallsl\slshape{9}{1000}{OT1}
2404\setfont\smallsf\sfshape{9}{1000}{OT1}
2405\setfont\smallsc\scshape{10}{900}{OT1}
2406\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2407\font\smalli=cmmi9
2408\font\smallsy=cmsy9
2409\def\smallecsize{0900}
2410
2411% Fonts for small examples (8pt).
2412\def\smallernominalsize{8pt}
2413\setfont\smallerrm\rmshape{8}{1000}{OT1}
2414\setfont\smallertt\ttshape{8}{1000}{OT1TT}
2415\setfont\smallerbf\bfshape{10}{800}{OT1}
2416\setfont\smallerit\itshape{8}{1000}{OT1IT}
2417\setfont\smallersl\slshape{8}{1000}{OT1}
2418\setfont\smallersf\sfshape{8}{1000}{OT1}
2419\setfont\smallersc\scshape{10}{800}{OT1}
2420\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2421\font\smalleri=cmmi8
2422\font\smallersy=cmsy8
2423\def\smallerecsize{0800}
2424
2425% Fonts for math mode superscripts (7pt).
2426\def\sevennominalsize{7pt}
2427\setfont\sevenrm\rmshape{7}{1000}{OT1}
2428\setfont\seventt\ttshape{10}{700}{OT1TT}
2429\setfont\sevenbf\bfshape{10}{700}{OT1}
2430\setfont\sevenit\itshape{7}{1000}{OT1IT}
2431\setfont\sevensl\slshape{10}{700}{OT1}
2432\setfont\sevensf\sfshape{10}{700}{OT1}
2433\setfont\sevensc\scshape{10}{700}{OT1}
2434\setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2435\font\seveni=cmmi7
2436\font\sevensy=cmsy7
2437\def\sevenecsize{0700}
2438
2439% Fonts for title page (20.4pt):
2440\def\titlenominalsize{20pt}
2441\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2442\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2443\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2444\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2445\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2446\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2447\let\titlebf=\titlerm
2448\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2449\font\titlei=cmmi12 scaled \magstep3
2450\font\titlesy=cmsy10 scaled \magstep4
2451\def\titleecsize{2074}
2452
2453% Chapter fonts (14.4pt).
2454\def\chapnominalsize{14pt}
2455\setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2456\setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2457\setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2458\setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2459\setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2460\setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2461\let\chapbf\chaprm
2462\setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2463\font\chapi=cmmi12 scaled \magstep1
2464\font\chapsy=cmsy10 scaled \magstep2
2465\def\chapecsize{1440}
2466
2467% Section fonts (12pt).
2468\def\secnominalsize{12pt}
2469\setfont\secrm\rmbshape{12}{1000}{OT1}
2470\setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2471\setfont\secsl\slbshape{10}{\magstep1}{OT1}
2472\setfont\sectt\ttbshape{12}{1000}{OT1TT}
2473\setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2474\setfont\secsf\sfbshape{12}{1000}{OT1}
2475\let\secbf\secrm
2476\setfont\secsc\scbshape{10}{\magstep1}{OT1}
2477\font\seci=cmmi12
2478\font\secsy=cmsy10 scaled \magstep1
2479\def\sececsize{1200}
2480
2481% Subsection fonts (10pt).
2482\def\ssecnominalsize{10pt}
2483\setfont\ssecrm\rmbshape{10}{1000}{OT1}
2484\setfont\ssecit\itbshape{10}{1000}{OT1IT}
2485\setfont\ssecsl\slbshape{10}{1000}{OT1}
2486\setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2487\setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2488\setfont\ssecsf\sfbshape{10}{1000}{OT1}
2489\let\ssecbf\ssecrm
2490\setfont\ssecsc\scbshape{10}{1000}{OT1}
2491\font\sseci=cmmi10
2492\font\ssecsy=cmsy10
2493\def\ssececsize{1000}
2494
2495% Reduced fonts for @acronym in text (9pt).
2496\def\reducednominalsize{9pt}
2497\setfont\reducedrm\rmshape{9}{1000}{OT1}
2498\setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2499\setfont\reducedbf\bfshape{10}{900}{OT1}
2500\setfont\reducedit\itshape{9}{1000}{OT1IT}
2501\setfont\reducedsl\slshape{9}{1000}{OT1}
2502\setfont\reducedsf\sfshape{9}{1000}{OT1}
2503\setfont\reducedsc\scshape{10}{900}{OT1}
2504\setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2505\font\reducedi=cmmi9
2506\font\reducedsy=cmsy9
2507\def\reducedecsize{0900}
2508
2509\divide\parskip by 2  % reduce space between paragraphs
2510\textleading = 12pt   % line spacing for 10pt CM
2511\textfonts            % reset the current fonts
2512\rm
2513} % end of 10pt text font size definitions, \definetextfontsizex
2514
2515% Fonts for short table of contents.
2516\setfont\shortcontrm\rmshape{12}{1000}{OT1}
2517\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
2518\setfont\shortcontsl\slshape{12}{1000}{OT1}
2519\setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2520
2521
2522% We provide the user-level command
2523%   @fonttextsize 10
2524% (or 11) to redefine the text font size.  pt is assumed.
2525%
2526\def\xiword{11}
2527\def\xword{10}
2528\def\xwordpt{10pt}
2529%
2530\parseargdef\fonttextsize{%
2531  \def\textsizearg{#1}%
2532  %\wlog{doing @fonttextsize \textsizearg}%
2533  %
2534  % Set \globaldefs so that documents can use this inside @tex, since
2535  % makeinfo 4.8 does not support it, but we need it nonetheless.
2536  %
2537 \begingroup \globaldefs=1
2538  \ifx\textsizearg\xword \definetextfontsizex
2539  \else \ifx\textsizearg\xiword \definetextfontsizexi
2540  \else
2541    \errhelp=\EMsimple
2542    \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2543  \fi\fi
2544 \endgroup
2545}
2546
2547%
2548% Change the current font style to #1, remembering it in \curfontstyle.
2549% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
2550% italics, not bold italics.
2551%
2552\def\setfontstyle#1{%
2553  \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
2554  \csname #1font\endcsname  % change the current font
2555}
2556
2557\def\rm{\fam=0 \setfontstyle{rm}}
2558\def\it{\fam=\itfam \setfontstyle{it}}
2559\def\sl{\fam=\slfam \setfontstyle{sl}}
2560\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
2561\def\tt{\fam=\ttfam \setfontstyle{tt}}\def\ttstylename{tt}
2562
2563% Texinfo sort of supports the sans serif font style, which plain TeX does not.
2564% So we set up a \sf.
2565\newfam\sffam
2566\def\sf{\fam=\sffam \setfontstyle{sf}}
2567
2568% We don't need math for this font style.
2569\def\ttsl{\setfontstyle{ttsl}}
2570
2571
2572% In order for the font changes to affect most math symbols and letters,
2573% we have to define the \textfont of the standard families.
2574% We don't bother to reset \scriptscriptfont; awaiting user need.
2575%
2576\def\resetmathfonts{%
2577  \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont
2578  \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont
2579  \textfont\ttfam=\ttfont \textfont\sffam=\sffont
2580  %
2581  % Fonts for superscript.  Note that the 7pt fonts are used regardless
2582  % of the current font size.
2583  \scriptfont0=\sevenrm \scriptfont1=\seveni \scriptfont2=\sevensy
2584  \scriptfont\itfam=\sevenit \scriptfont\slfam=\sevensl
2585  \scriptfont\bffam=\sevenbf \scriptfont\ttfam=\seventt
2586  \scriptfont\sffam=\sevensf
2587}
2588
2589%
2590
2591% The font-changing commands (all called \...fonts) redefine the meanings
2592% of \STYLEfont, instead of just \STYLE.  We do this because \STYLE needs
2593% to also set the current \fam for math mode.  Our \STYLE (e.g., \rm)
2594% commands hardwire \STYLEfont to set the current font.
2595%
2596% The fonts used for \ifont are for "math italics"  (\itfont is for italics
2597% in regular text).  \syfont is also used in math mode only.
2598%
2599% Each font-changing command also sets the names \lsize (one size lower)
2600% and \lllsize (three sizes lower).  These relative commands are used
2601% in, e.g., the LaTeX logo and acronyms.
2602%
2603% This all needs generalizing, badly.
2604%
2605
2606\def\assignfonts#1{%
2607  \expandafter\let\expandafter\rmfont\csname #1rm\endcsname
2608  \expandafter\let\expandafter\itfont\csname #1it\endcsname
2609  \expandafter\let\expandafter\slfont\csname #1sl\endcsname
2610  \expandafter\let\expandafter\bffont\csname #1bf\endcsname
2611  \expandafter\let\expandafter\ttfont\csname #1tt\endcsname
2612  \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname
2613  \expandafter\let\expandafter\sffont  \csname #1sf\endcsname
2614  \expandafter\let\expandafter\ifont   \csname #1i\endcsname
2615  \expandafter\let\expandafter\syfont  \csname #1sy\endcsname
2616  \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname
2617}
2618
2619\newif\ifrmisbold
2620
2621% Select smaller font size with the current style.  Used to change font size
2622% in, e.g., the LaTeX logo and acronyms.  If we are using bold fonts for
2623% normal roman text, also use bold fonts for roman text in the smaller size.
2624\def\switchtolllsize{%
2625   \expandafter\assignfonts\expandafter{\lllsize}%
2626   \ifrmisbold
2627     \let\rmfont\bffont
2628   \fi
2629   \csname\curfontstyle\endcsname
2630}%
2631
2632\def\switchtolsize{%
2633   \expandafter\assignfonts\expandafter{\lsize}%
2634   \ifrmisbold
2635     \let\rmfont\bffont
2636   \fi
2637   \csname\curfontstyle\endcsname
2638}%
2639
2640\def\definefontsetatsize#1#2#3#4#5{%
2641\expandafter\def\csname #1fonts\endcsname{%
2642  \def\curfontsize{#1}%
2643  \def\lsize{#2}\def\lllsize{#3}%
2644  \csname rmisbold#5\endcsname
2645  \assignfonts{#1}%
2646  \resetmathfonts
2647  \setleading{#4}%
2648}}
2649
2650\definefontsetatsize{text}   {reduced}{smaller}{\textleading}{false}
2651\definefontsetatsize{title}  {chap}   {subsec} {27pt}  {true}
2652\definefontsetatsize{chap}   {sec}    {text}   {19pt}  {true}
2653\definefontsetatsize{sec}    {subsec} {reduced}{17pt}  {true}
2654\definefontsetatsize{ssec}   {text}   {small}  {15pt}  {true}
2655\definefontsetatsize{reduced}{small}  {smaller}{10.5pt}{false}
2656\definefontsetatsize{small}  {smaller}{smaller}{10.5pt}{false}
2657\definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false}
2658
2659\def\titlefont#1{{\titlefonts\rm #1}}
2660\let\subsecfonts = \ssecfonts
2661\let\subsubsecfonts = \ssecfonts
2662
2663% Define these just so they can be easily changed for other fonts.
2664\def\angleleft{$\langle$}
2665\def\angleright{$\rangle$}
2666
2667% Set the fonts to use with the @small... environments.
2668\let\smallexamplefonts = \smallfonts
2669
2670% About \smallexamplefonts.  If we use \smallfonts (9pt), @smallexample
2671% can fit this many characters:
2672%   8.5x11=86   smallbook=72  a4=90  a5=69
2673% If we use \scriptfonts (8pt), then we can fit this many characters:
2674%   8.5x11=90+  smallbook=80  a4=90+  a5=77
2675% For me, subjectively, the few extra characters that fit aren't worth
2676% the additional smallness of 8pt.  So I'm making the default 9pt.
2677%
2678% By the way, for comparison, here's what fits with @example (10pt):
2679%   8.5x11=71  smallbook=60  a4=75  a5=58
2680% --karl, 24jan03.
2681
2682% Set up the default fonts, so we can use them for creating boxes.
2683%
2684\definetextfontsizexi
2685
2686
2687% Check if we are currently using a typewriter font.  Since all the
2688% Computer Modern typewriter fonts have zero interword stretch (and
2689% shrink), and it is reasonable to expect all typewriter fonts to have
2690% this property, we can check that font parameter.
2691%
2692\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
2693
2694{
2695\catcode`\'=\active
2696\catcode`\`=\active
2697
2698\gdef\setcodequotes{\let`\codequoteleft \let'\codequoteright}
2699\gdef\setregularquotes{\let`\lq \let'\rq}
2700}
2701
2702% Allow an option to not use regular directed right quote/apostrophe
2703% (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2704% The undirected quote is ugly, so don't make it the default, but it
2705% works for pasting with more pdf viewers (at least evince), the
2706% lilypond developers report.  xpdf does work with the regular 0x27.
2707%
2708\def\codequoteright{%
2709  \ifmonospace
2710    \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
2711      \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
2712        '%
2713      \else \char'15 \fi
2714    \else \char'15 \fi
2715   \else
2716     '%
2717   \fi
2718}
2719%
2720% and a similar option for the left quote char vs. a grave accent.
2721% Modern fonts display ASCII 0x60 as a grave accent, so some people like
2722% the code environments to do likewise.
2723%
2724\def\codequoteleft{%
2725  \ifmonospace
2726    \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
2727      \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
2728        % [Knuth] pp. 380,381,391
2729        % \relax disables Spanish ligatures ?` and !` of \tt font.
2730        \relax`%
2731      \else \char'22 \fi
2732    \else \char'22 \fi
2733   \else
2734     \relax`%
2735   \fi
2736}
2737
2738% Commands to set the quote options.
2739%
2740\parseargdef\codequoteundirected{%
2741  \def\temp{#1}%
2742  \ifx\temp\onword
2743    \expandafter\let\csname SETtxicodequoteundirected\endcsname
2744      = t%
2745  \else\ifx\temp\offword
2746    \expandafter\let\csname SETtxicodequoteundirected\endcsname
2747      = \relax
2748  \else
2749    \errhelp = \EMsimple
2750    \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2751  \fi\fi
2752}
2753%
2754\parseargdef\codequotebacktick{%
2755  \def\temp{#1}%
2756  \ifx\temp\onword
2757    \expandafter\let\csname SETtxicodequotebacktick\endcsname
2758      = t%
2759  \else\ifx\temp\offword
2760    \expandafter\let\csname SETtxicodequotebacktick\endcsname
2761      = \relax
2762  \else
2763    \errhelp = \EMsimple
2764    \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2765  \fi\fi
2766}
2767
2768% [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2769\def\noligaturesquoteleft{\relax\lq}
2770
2771% Count depth in font-changes, for error checks
2772\newcount\fontdepth \fontdepth=0
2773
2774% Font commands.
2775
2776% #1 is the font command (\sl or \it), #2 is the text to slant.
2777% If we are in a monospaced environment, however, 1) always use \ttsl,
2778% and 2) do not add an italic correction.
2779\def\dosmartslant#1#2{%
2780  \ifusingtt
2781    {{\ttsl #2}\let\next=\relax}%
2782    {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
2783  \next
2784}
2785\def\smartslanted{\dosmartslant\sl}
2786\def\smartitalic{\dosmartslant\it}
2787
2788% Output an italic correction unless \next (presumed to be the following
2789% character) is such as not to need one.
2790\def\smartitaliccorrection{%
2791  \ifx\next,%
2792  \else\ifx\next-%
2793  \else\ifx\next.%
2794  \else\ifx\next\.%
2795  \else\ifx\next\comma%
2796  \else\ptexslash
2797  \fi\fi\fi\fi\fi
2798  \aftersmartic
2799}
2800
2801% Unconditional use \ttsl, and no ic.  @var is set to this for defuns.
2802\def\ttslanted#1{{\ttsl #1}}
2803
2804% @cite is like \smartslanted except unconditionally use \sl.  We never want
2805% ttsl for book titles, do we?
2806\def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
2807
2808\def\aftersmartic{}
2809\def\var#1{%
2810  \let\saveaftersmartic = \aftersmartic
2811  \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
2812  \smartslanted{#1}%
2813}
2814
2815\let\i=\smartitalic
2816\let\slanted=\smartslanted
2817\let\dfn=\smartslanted
2818\let\emph=\smartitalic
2819
2820% Explicit font changes: @r, @sc, undocumented @ii.
2821\def\r#1{{\rm #1}}              % roman font
2822\def\sc#1{{\smallcaps#1}}       % smallcaps font
2823\def\ii#1{{\it #1}}             % italic font
2824
2825% @b, explicit bold.  Also @strong.
2826\def\b#1{{\bf #1}}
2827\let\strong=\b
2828
2829% @sansserif, explicit sans.
2830\def\sansserif#1{{\sf #1}}
2831
2832% We can't just use \exhyphenpenalty, because that only has effect at
2833% the end of a paragraph.  Restore normal hyphenation at the end of the
2834% group within which \nohyphenation is presumably called.
2835%
2836\def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
2837\def\restorehyphenation{\hyphenchar\font = `- }
2838
2839% Set sfcode to normal for the chars that usually have another value.
2840% Can't use plain's \frenchspacing because it uses the `\x notation, and
2841% sometimes \x has an active definition that messes things up.
2842%
2843\catcode`@=11
2844  \def\plainfrenchspacing{%
2845    \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
2846    \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
2847    \def\endofsentencespacefactor{1000}% for @. and friends
2848  }
2849  \def\plainnonfrenchspacing{%
2850    \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2851    \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2852    \def\endofsentencespacefactor{3000}% for @. and friends
2853  }
2854\catcode`@=\other
2855\def\endofsentencespacefactor{3000}% default
2856
2857% @t, explicit typewriter.
2858\def\t#1{%
2859  {\tt \plainfrenchspacing #1}%
2860  \null
2861}
2862
2863% @samp.
2864\def\samp#1{{\setcodequotes\lq\tclose{#1}\rq\null}}
2865
2866% @indicateurl is \samp, that is, with quotes.
2867\let\indicateurl=\samp
2868
2869% @code (and similar) prints in typewriter, but with spaces the same
2870% size as normal in the surrounding text, without hyphenation, etc.
2871% This is a subroutine for that.
2872\def\tclose#1{%
2873  {%
2874    % Change normal interword space to be same as for the current font.
2875    \spaceskip = \fontdimen2\font
2876    %
2877    % Switch to typewriter.
2878    \tt
2879    %
2880    % But `\ ' produces the large typewriter interword space.
2881    \def\ {{\spaceskip = 0pt{} }}%
2882    %
2883    % Turn off hyphenation.
2884    \nohyphenation
2885    %
2886    \plainfrenchspacing
2887    #1%
2888  }%
2889  \null % reset spacefactor to 1000
2890}
2891
2892% We *must* turn on hyphenation at `-' and `_' in @code.
2893% (But see \codedashfinish below.)
2894% Otherwise, it is too hard to avoid overfull hboxes
2895% in the Emacs manual, the Library manual, etc.
2896%
2897% Unfortunately, TeX uses one parameter (\hyphenchar) to control
2898% both hyphenation at - and hyphenation within words.
2899% We must therefore turn them both off (\tclose does that)
2900% and arrange explicitly to hyphenate at a dash. -- rms.
2901{
2902  \catcode`\-=\active \catcode`\_=\active
2903  \catcode`\'=\active \catcode`\`=\active
2904  \global\let'=\rq \global\let`=\lq  % default definitions
2905  %
2906  \global\def\code{\begingroup
2907    \setcodequotes
2908    \catcode\dashChar=\active  \catcode\underChar=\active
2909    \ifallowcodebreaks
2910     \let-\codedash
2911     \let_\codeunder
2912    \else
2913     \let-\normaldash
2914     \let_\realunder
2915    \fi
2916    % Given -foo (with a single dash), we do not want to allow a break
2917    % after the hyphen.
2918    \global\let\codedashprev=\codedash
2919    %
2920    \codex
2921  }
2922  %
2923  \gdef\codedash{\futurelet\next\codedashfinish}
2924  \gdef\codedashfinish{%
2925    \normaldash % always output the dash character itself.
2926    %
2927    % Now, output a discretionary to allow a line break, unless
2928    % (a) the next character is a -, or
2929    % (b) the preceding character is a -.
2930    % E.g., given --posix, we do not want to allow a break after either -.
2931    % Given --foo-bar, we do want to allow a break between the - and the b.
2932    \ifx\next\codedash \else
2933      \ifx\codedashprev\codedash
2934      \else \discretionary{}{}{}\fi
2935    \fi
2936    % we need the space after the = for the case when \next itself is a
2937    % space token; it would get swallowed otherwise.  As in @code{- a}.
2938    \global\let\codedashprev= \next
2939  }
2940}
2941\def\normaldash{-}
2942%
2943\def\codex #1{\tclose{#1}\endgroup}
2944
2945\def\codeunder{%
2946  % this is all so @math{@code{var_name}+1} can work.  In math mode, _
2947  % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2948  % will therefore expand the active definition of _, which is us
2949  % (inside @code that is), therefore an endless loop.
2950  \ifusingtt{\ifmmode
2951               \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2952             \else\normalunderscore \fi
2953             \discretionary{}{}{}}%
2954            {\_}%
2955}
2956
2957% An additional complication: the above will allow breaks after, e.g.,
2958% each of the four underscores in __typeof__.  This is bad.
2959% @allowcodebreaks provides a document-level way to turn breaking at -
2960% and _ on and off.
2961%
2962\newif\ifallowcodebreaks  \allowcodebreakstrue
2963
2964\def\keywordtrue{true}
2965\def\keywordfalse{false}
2966
2967\parseargdef\allowcodebreaks{%
2968  \def\txiarg{#1}%
2969  \ifx\txiarg\keywordtrue
2970    \allowcodebreakstrue
2971  \else\ifx\txiarg\keywordfalse
2972    \allowcodebreaksfalse
2973  \else
2974    \errhelp = \EMsimple
2975    \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
2976  \fi\fi
2977}
2978
2979% For @command, @env, @file, @option quotes seem unnecessary,
2980% so use \code rather than \samp.
2981\let\command=\code
2982\let\env=\code
2983\let\file=\code
2984\let\option=\code
2985
2986% @uref (abbreviation for `urlref') aka @url takes an optional
2987% (comma-separated) second argument specifying the text to display and
2988% an optional third arg as text to display instead of (rather than in
2989% addition to) the url itself.  First (mandatory) arg is the url.
2990
2991% TeX-only option to allow changing PDF output to show only the second
2992% arg (if given), and not the url (which is then just the link target).
2993\newif\ifurefurlonlylink
2994
2995% The default \pretolerance setting stops the penalty inserted in
2996% \urefallowbreak being a discouragement to line breaking.  Set it to
2997% a negative value for this paragraph only.  Hopefully this does not
2998% conflict with redefinitions of \par done elsewhere.
2999\def\nopretolerance{%
3000\pretolerance=-1
3001\def\par{\endgraf\pretolerance=100 \let\par\endgraf}%
3002}
3003
3004% The main macro is \urefbreak, which allows breaking at expected
3005% places within the url.
3006\def\urefbreak{\nopretolerance \begingroup \urefcatcodes \dourefbreak}
3007\let\uref=\urefbreak
3008%
3009\def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
3010\def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
3011  \unsepspaces
3012  \pdfurl{#1}%
3013  \setbox0 = \hbox{\ignorespaces #3}%
3014  \ifdim\wd0 > 0pt
3015    \unhbox0 % third arg given, show only that
3016  \else
3017    \setbox0 = \hbox{\ignorespaces #2}% look for second arg
3018    \ifdim\wd0 > 0pt
3019      \ifpdf
3020        % For pdfTeX and LuaTeX
3021        \ifurefurlonlylink
3022          % PDF plus option to not display url, show just arg
3023          \unhbox0
3024        \else
3025          % PDF, normally display both arg and url for consistency,
3026          % visibility, if the pdf is eventually used to print, etc.
3027          \unhbox0\ (\urefcode{#1})%
3028        \fi
3029      \else
3030        \ifx\XeTeXrevision\thisisundefined
3031          \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
3032        \else
3033          % For XeTeX
3034          \ifurefurlonlylink
3035            % PDF plus option to not display url, show just arg
3036            \unhbox0
3037          \else
3038            % PDF, normally display both arg and url for consistency,
3039            % visibility, if the pdf is eventually used to print, etc.
3040            \unhbox0\ (\urefcode{#1})%
3041          \fi
3042        \fi
3043      \fi
3044    \else
3045      \urefcode{#1}% only url given, so show it
3046    \fi
3047  \fi
3048  \endlink
3049\endgroup}
3050
3051% Allow line breaks around only a few characters (only).
3052\def\urefcatcodes{%
3053  \catcode`\&=\active \catcode`\.=\active
3054  \catcode`\#=\active \catcode`\?=\active
3055  \catcode`\/=\active
3056}
3057{
3058  \urefcatcodes
3059  %
3060  \global\def\urefcode{\begingroup
3061    \setcodequotes
3062    \urefcatcodes
3063    \let&\urefcodeamp
3064    \let.\urefcodedot
3065    \let#\urefcodehash
3066    \let?\urefcodequest
3067    \let/\urefcodeslash
3068    \codex
3069  }
3070  %
3071  % By default, they are just regular characters.
3072  \global\def&{\normalamp}
3073  \global\def.{\normaldot}
3074  \global\def#{\normalhash}
3075  \global\def?{\normalquest}
3076  \global\def/{\normalslash}
3077}
3078
3079\def\urefcodeamp{\urefprebreak \&\urefpostbreak}
3080\def\urefcodedot{\urefprebreak .\urefpostbreak}
3081\def\urefcodehash{\urefprebreak \#\urefpostbreak}
3082\def\urefcodequest{\urefprebreak ?\urefpostbreak}
3083\def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
3084{
3085  \catcode`\/=\active
3086  \global\def\urefcodeslashfinish{%
3087    \urefprebreak \slashChar
3088    % Allow line break only after the final / in a sequence of
3089    % slashes, to avoid line break between the slashes in http://.
3090    \ifx\next/\else \urefpostbreak \fi
3091  }
3092}
3093
3094% By default we'll break after the special characters, but some people like to
3095% break before the special chars, so allow that.  Also allow no breaking at
3096% all, for manual control.
3097%
3098\parseargdef\urefbreakstyle{%
3099  \def\txiarg{#1}%
3100  \ifx\txiarg\wordnone
3101    \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
3102  \else\ifx\txiarg\wordbefore
3103    \def\urefprebreak{\urefallowbreak}\def\urefpostbreak{\nobreak}
3104  \else\ifx\txiarg\wordafter
3105    \def\urefprebreak{\nobreak}\def\urefpostbreak{\urefallowbreak}
3106  \else
3107    \errhelp = \EMsimple
3108    \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
3109  \fi\fi\fi
3110}
3111\def\wordafter{after}
3112\def\wordbefore{before}
3113\def\wordnone{none}
3114
3115% Allow a ragged right output to aid breaking long URL's.  There can
3116% be a break at the \allowbreak with no extra glue (if the existing stretch in
3117% the line is sufficient), a break at the \penalty with extra glue added
3118% at the end of the line, or no break at all here.
3119%   Changing the value of the penalty and/or the amount of stretch affects how
3120% preferable one choice is over the other.
3121\def\urefallowbreak{%
3122  \penalty0\relax
3123  \hskip 0pt plus 2 em\relax
3124  \penalty1000\relax
3125  \hskip 0pt plus -2 em\relax
3126}
3127
3128\urefbreakstyle after
3129
3130% @url synonym for @uref, since that's how everyone uses it.
3131%
3132\let\url=\uref
3133
3134% rms does not like angle brackets --karl, 17may97.
3135% So now @email is just like @uref, unless we are pdf.
3136%
3137%\def\email#1{\angleleft{\tt #1}\angleright}
3138\ifpdforxetex
3139  \def\email#1{\doemail#1,,\finish}
3140  \def\doemail#1,#2,#3\finish{\begingroup
3141    \unsepspaces
3142    \pdfurl{mailto:#1}%
3143    \setbox0 = \hbox{\ignorespaces #2}%
3144    \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3145    \endlink
3146  \endgroup}
3147\else
3148  \let\email=\uref
3149\fi
3150
3151% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
3152%   `example' (@kbd uses ttsl only inside of @example and friends),
3153%   or `code' (@kbd uses normal tty font always).
3154\parseargdef\kbdinputstyle{%
3155  \def\txiarg{#1}%
3156  \ifx\txiarg\worddistinct
3157    \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
3158  \else\ifx\txiarg\wordexample
3159    \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
3160  \else\ifx\txiarg\wordcode
3161    \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
3162  \else
3163    \errhelp = \EMsimple
3164    \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
3165  \fi\fi\fi
3166}
3167\def\worddistinct{distinct}
3168\def\wordexample{example}
3169\def\wordcode{code}
3170
3171% Default is `distinct'.
3172\kbdinputstyle distinct
3173
3174% @kbd is like @code, except that if the argument is just one @key command,
3175% then @kbd has no effect.
3176\def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
3177
3178\def\xkey{\key}
3179\def\kbdsub#1#2#3\par{%
3180  \def\one{#1}\def\three{#3}\def\threex{??}%
3181  \ifx\one\xkey\ifx\threex\three \key{#2}%
3182  \else{\tclose{\kbdfont\setcodequotes\look}}\fi
3183  \else{\tclose{\kbdfont\setcodequotes\look}}\fi
3184}
3185
3186% definition of @key that produces a lozenge.  Doesn't adjust to text size.
3187%\setfont\keyrm\rmshape{8}{1000}{OT1}
3188%\font\keysy=cmsy9
3189%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
3190%  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
3191%    \vbox{\hrule\kern-0.4pt
3192%     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
3193%    \kern-0.4pt\hrule}%
3194%  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
3195
3196% definition of @key with no lozenge.  If the current font is already
3197% monospace, don't change it; that way, we respect @kbdinputstyle.  But
3198% if it isn't monospace, then use \tt.
3199%
3200\def\key#1{{\setregularquotes
3201  \nohyphenation
3202  \ifmonospace\else\tt\fi
3203  #1}\null}
3204
3205% @clicksequence{File @click{} Open ...}
3206\def\clicksequence#1{\begingroup #1\endgroup}
3207
3208% @clickstyle @arrow   (by default)
3209\parseargdef\clickstyle{\def\click{#1}}
3210\def\click{\arrow}
3211
3212% Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
3213% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
3214%
3215\def\dmn#1{\thinspace #1}
3216
3217% @acronym for "FBI", "NATO", and the like.
3218% We print this one point size smaller, since it's intended for
3219% all-uppercase.
3220%
3221\def\acronym#1{\doacronym #1,,\finish}
3222\def\doacronym#1,#2,#3\finish{%
3223  {\switchtolsize #1}%
3224  \def\temp{#2}%
3225  \ifx\temp\empty \else
3226    \space ({\unsepspaces \ignorespaces \temp \unskip})%
3227  \fi
3228  \null % reset \spacefactor=1000
3229}
3230
3231% @abbr for "Comput. J." and the like.
3232% No font change, but don't do end-of-sentence spacing.
3233%
3234\def\abbr#1{\doabbr #1,,\finish}
3235\def\doabbr#1,#2,#3\finish{%
3236  {\plainfrenchspacing #1}%
3237  \def\temp{#2}%
3238  \ifx\temp\empty \else
3239    \space ({\unsepspaces \ignorespaces \temp \unskip})%
3240  \fi
3241  \null % reset \spacefactor=1000
3242}
3243
3244% @asis just yields its argument.  Used with @table, for example.
3245%
3246\def\asis#1{#1}
3247
3248% @math outputs its argument in math mode.
3249%
3250% One complication: _ usually means subscripts, but it could also mean
3251% an actual _ character, as in @math{@var{some_variable} + 1}.  So make
3252% _ active, and distinguish by seeing if the current family is \slfam,
3253% which is what @var uses.
3254{
3255  \catcode`\_ = \active
3256  \gdef\mathunderscore{%
3257    \catcode`\_=\active
3258    \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
3259  }
3260}
3261% Another complication: we want \\ (and @\) to output a math (or tt) \.
3262% FYI, plain.tex uses \\ as a temporary control sequence (for no
3263% particular reason), but this is not advertised and we don't care.
3264%
3265% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
3266\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
3267%
3268\def\math{%
3269  \ifmmode\else % only go into math if not in math mode already
3270    \tex
3271    \mathunderscore
3272    \let\\ = \mathbackslash
3273    \mathactive
3274    % make the texinfo accent commands work in math mode
3275    \let\"=\ddot
3276    \let\'=\acute
3277    \let\==\bar
3278    \let\^=\hat
3279    \let\`=\grave
3280    \let\u=\breve
3281    \let\v=\check
3282    \let\~=\tilde
3283    \let\dotaccent=\dot
3284    % have to provide another name for sup operator
3285    \let\mathopsup=\sup
3286  $\expandafter\finishmath\fi
3287}
3288\def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
3289
3290% Some active characters (such as <) are spaced differently in math.
3291% We have to reset their definitions in case the @math was an argument
3292% to a command which sets the catcodes (such as @item or @section).
3293%
3294{
3295  \catcode`^ = \active
3296  \catcode`< = \active
3297  \catcode`> = \active
3298  \catcode`+ = \active
3299  \catcode`' = \active
3300  \gdef\mathactive{%
3301    \let^ = \ptexhat
3302    \let< = \ptexless
3303    \let> = \ptexgtr
3304    \let+ = \ptexplus
3305    \let' = \ptexquoteright
3306  }
3307}
3308
3309% for @sub and @sup, if in math mode, just do a normal sub/superscript.
3310% If in text, use math to place as sub/superscript, but switch
3311% into text mode, with smaller fonts.  This is a different font than the
3312% one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3313% fix it (significant additions to font machinery) until someone notices.
3314%
3315\def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
3316\def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}%
3317%
3318\def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
3319\def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}%
3320
3321% provide this command from LaTeX as it is very common
3322\def\frac#1#2{{{#1}\over{#2}}}
3323
3324% @displaymath.
3325% \globaldefs is needed to recognize the end lines in \tex and
3326% \end tex.  Set \thisenv as @end displaymath is seen before @end tex.
3327{\obeylines
3328\globaldefs=1
3329\envdef\displaymath{%
3330\tex%
3331\def\thisenv{\displaymath}%
3332\begingroup\let\end\displaymathend%
3333$$%
3334}
3335
3336\def\displaymathend{$$\endgroup\end}%
3337
3338\def\Edisplaymath{%
3339\def\thisenv{\tex}%
3340\end tex
3341}}
3342
3343
3344% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3345% Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3346% except specified as a normal braced arg, so no newlines to worry about.
3347%
3348\def\outfmtnametex{tex}
3349%
3350\long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3351\long\def\doinlinefmt#1,#2,\finish{%
3352  \def\inlinefmtname{#1}%
3353  \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3354}
3355%
3356% @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3357% FMTNAME is tex, else ELSE-TEXT.
3358\long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3359\long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3360  \def\inlinefmtname{#1}%
3361  \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3362}
3363%
3364% For raw, must switch into @tex before parsing the argument, to avoid
3365% setting catcodes prematurely.  Doing it this way means that, for
3366% example, @inlineraw{html, foo{bar} gets a parse error instead of being
3367% ignored.  But this isn't important because if people want a literal
3368% *right* brace they would have to use a command anyway, so they may as
3369% well use a command to get a left brace too.  We could re-use the
3370% delimiter character idea from \verb, but it seems like overkill.
3371%
3372\long\def\inlineraw{\tex \doinlineraw}
3373\long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3374\def\doinlinerawtwo#1,#2,\finish{%
3375  \def\inlinerawname{#1}%
3376  \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3377  \endgroup % close group opened by \tex.
3378}
3379
3380% @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3381%
3382\long\def\inlineifset#1{\doinlineifset #1,\finish}
3383\long\def\doinlineifset#1,#2,\finish{%
3384  \def\inlinevarname{#1}%
3385  \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3386  \else\ignorespaces#2\fi
3387}
3388
3389% @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3390%
3391\long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3392\long\def\doinlineifclear#1,#2,\finish{%
3393  \def\inlinevarname{#1}%
3394  \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3395}
3396
3397
3398\message{glyphs,}
3399% and logos.
3400
3401% @@ prints an @, as does @atchar{}.
3402\def\@{\char64 }
3403\let\atchar=\@
3404
3405% @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
3406\def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}}
3407\def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}}
3408\let\{=\lbracechar
3409\let\}=\rbracechar
3410
3411% @comma{} to avoid , parsing problems.
3412\let\comma = ,
3413
3414% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3415% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3416\let\, = \ptexc
3417\let\dotaccent = \ptexdot
3418\def\ringaccent#1{{\accent23 #1}}
3419\let\tieaccent = \ptext
3420\let\ubaraccent = \ptexb
3421\let\udotaccent = \d
3422
3423% Other special characters: @questiondown @exclamdown @ordf @ordm
3424% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3425\def\questiondown{?`}
3426\def\exclamdown{!`}
3427\def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}}
3428\def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}}
3429
3430% Dotless i and dotless j, used for accents.
3431\def\imacro{i}
3432\def\jmacro{j}
3433\def\dotless#1{%
3434  \def\temp{#1}%
3435  \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3436  \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3437  \else \errmessage{@dotless can be used only with i or j}%
3438  \fi\fi
3439}
3440
3441% The \TeX{} logo, as in plain, but resetting the spacing so that a
3442% period following counts as ending a sentence.  (Idea found in latex.)
3443%
3444\edef\TeX{\TeX \spacefactor=1000 }
3445
3446% @LaTeX{} logo.  Not quite the same results as the definition in
3447% latex.ltx, since we use a different font for the raised A; it's most
3448% convenient for us to use an explicitly smaller font, rather than using
3449% the \scriptstyle font (since we don't reset \scriptstyle and
3450% \scriptscriptstyle).
3451%
3452\def\LaTeX{%
3453  L\kern-.36em
3454  {\setbox0=\hbox{T}%
3455   \vbox to \ht0{\hbox{%
3456     \ifx\textnominalsize\xwordpt
3457       % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX.
3458       % Revert to plain's \scriptsize, which is 7pt.
3459       \count255=\the\fam $\fam\count255 \scriptstyle A$%
3460     \else
3461       % For 11pt, we can use our lllsize.
3462       \switchtolllsize A%
3463     \fi
3464     }%
3465     \vss
3466  }}%
3467  \kern-.15em
3468  \TeX
3469}
3470
3471% Some math mode symbols.  Define \ensuremath to switch into math mode
3472% unless we are already there.  Expansion tricks may not be needed here,
3473% but safer, and can't hurt.
3474\def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3475\def\ensuredmath#1{$\relax#1$}
3476%
3477\def\bullet{\ensuremath\ptexbullet}
3478\def\geq{\ensuremath\ge}
3479\def\leq{\ensuremath\le}
3480\def\minus{\ensuremath-}
3481
3482% @dots{} outputs an ellipsis using the current font.
3483% We do .5em per period so that it has the same spacing in the cm
3484% typewriter fonts as three actual period characters; on the other hand,
3485% in other typewriter fonts three periods are wider than 1.5em.  So do
3486% whichever is larger.
3487%
3488\def\dots{%
3489  \leavevmode
3490  \setbox0=\hbox{...}% get width of three periods
3491  \ifdim\wd0 > 1.5em
3492    \dimen0 = \wd0
3493  \else
3494    \dimen0 = 1.5em
3495  \fi
3496  \hbox to \dimen0{%
3497    \hskip 0pt plus.25fil
3498    .\hskip 0pt plus1fil
3499    .\hskip 0pt plus1fil
3500    .\hskip 0pt plus.5fil
3501  }%
3502}
3503
3504% @enddots{} is an end-of-sentence ellipsis.
3505%
3506\def\enddots{%
3507  \dots
3508  \spacefactor=\endofsentencespacefactor
3509}
3510
3511% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3512%
3513% Since these characters are used in examples, they should be an even number of
3514% \tt widths. Each \tt character is 1en, so two makes it 1em.
3515%
3516\def\point{$\star$}
3517\def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3518\def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3519\def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3520\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3521\def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3522
3523% The @error{} command.
3524% Adapted from the TeXbook's \boxit.
3525%
3526\newbox\errorbox
3527%
3528{\ttfont \global\dimen0 = 3em}% Width of the box.
3529\dimen2 = .55pt % Thickness of rules
3530% The text. (`r' is open on the right, `e' somewhat less so on the left.)
3531\setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3532%
3533\setbox\errorbox=\hbox to \dimen0{\hfil
3534   \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3535   \advance\hsize by -2\dimen2 % Rules.
3536   \vbox{%
3537      \hrule height\dimen2
3538      \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
3539         \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3540         \kern3pt\vrule width\dimen2}% Space to right.
3541      \hrule height\dimen2}
3542    \hfil}
3543%
3544\def\error{\leavevmode\lower.7ex\copy\errorbox}
3545
3546% @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3547%
3548\def\pounds{\ifmonospace{\ecfont\char"BF}\else{\it\$}\fi}
3549
3550% @euro{} comes from a separate font, depending on the current style.
3551% We use the free feym* fonts from the eurosym package by Henrik
3552% Theiling, which support regular, slanted, bold and bold slanted (and
3553% "outlined" (blackboard board, sort of) versions, which we don't need).
3554% It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3555%
3556% Although only regular is the truly official Euro symbol, we ignore
3557% that.  The Euro is designed to be slightly taller than the regular
3558% font height.
3559%
3560% feymr - regular
3561% feymo - slanted
3562% feybr - bold
3563% feybo - bold slanted
3564%
3565% There is no good (free) typewriter version, to my knowledge.
3566% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3567% Hmm.
3568%
3569% Also doesn't work in math.  Do we need to do math with euro symbols?
3570% Hope not.
3571%
3572%
3573\def\euro{{\eurofont e}}
3574\def\eurofont{%
3575  % We set the font at each command, rather than predefining it in
3576  % \textfonts and the other font-switching commands, so that
3577  % installations which never need the symbol don't have to have the
3578  % font installed.
3579  %
3580  % There is only one designed size (nominal 10pt), so we always scale
3581  % that to the current nominal size.
3582  %
3583  % By the way, simply using "at 1em" works for cmr10 and the like, but
3584  % does not work for cmbx10 and other extended/shrunken fonts.
3585  %
3586  \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3587  %
3588  \ifx\curfontstyle\bfstylename
3589    % bold:
3590    \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3591  \else
3592    % regular:
3593    \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3594  \fi
3595  \thiseurofont
3596}
3597
3598% Glyphs from the EC fonts.  We don't use \let for the aliases, because
3599% sometimes we redefine the original macro, and the alias should reflect
3600% the redefinition.
3601%
3602% Use LaTeX names for the Icelandic letters.
3603\def\DH{{\ecfont \char"D0}} % Eth
3604\def\dh{{\ecfont \char"F0}} % eth
3605\def\TH{{\ecfont \char"DE}} % Thorn
3606\def\th{{\ecfont \char"FE}} % thorn
3607%
3608\def\guillemetleft{{\ecfont \char"13}}
3609\def\guillemotleft{\guillemetleft}
3610\def\guillemetright{{\ecfont \char"14}}
3611\def\guillemotright{\guillemetright}
3612\def\guilsinglleft{{\ecfont \char"0E}}
3613\def\guilsinglright{{\ecfont \char"0F}}
3614\def\quotedblbase{{\ecfont \char"12}}
3615\def\quotesinglbase{{\ecfont \char"0D}}
3616%
3617\def\L{{\ecfont \char"8A}} % L with stroke
3618\def\l{{\ecfont \char"AA}} % l with stroke
3619%
3620% This positioning is not perfect (see the ogonek LaTeX package), but
3621% we have the precomposed glyphs for the most common cases.  We put the
3622% tests to use those glyphs in the single \ogonek macro so we have fewer
3623% dummy definitions to worry about for index entries, etc.
3624%
3625% ogonek is also used with other letters in Lithuanian (IOU), but using
3626% the precomposed glyphs for those is not so easy since they aren't in
3627% the same EC font.
3628\def\ogonek#1{{%
3629  \def\temp{#1}%
3630  \ifx\temp\macrocharA\Aogonek
3631  \else\ifx\temp\macrochara\aogonek
3632  \else\ifx\temp\macrocharE\Eogonek
3633  \else\ifx\temp\macrochare\eogonek
3634  \else
3635    \ecfont \setbox0=\hbox{#1}%
3636    \ifdim\ht0=1ex\accent"0C #1%
3637    \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3638    \fi
3639  \fi\fi\fi\fi
3640  }%
3641}
3642\def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3643\def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3644\def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3645\def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3646%
3647% Use the European Computer Modern fonts (cm-super in outline format)
3648% for non-CM glyphs.  That is ec* for regular text and tc* for the text
3649% companion symbols (LaTeX TS1 encoding).  Both are part of the ec
3650% package and follow the same conventions.
3651%
3652\def\ecfont{\etcfont{e}}
3653\def\tcfont{\etcfont{t}}
3654%
3655\def\etcfont#1{%
3656  % We can't distinguish serif/sans and italic/slanted, but this
3657  % is used for crude hacks anyway (like adding French and German
3658  % quotes to documents typeset with CM, where we lose kerning), so
3659  % hopefully nobody will notice/care.
3660  \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3661  \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
3662  \ifmonospace
3663    % typewriter:
3664    \font\thisecfont = #1ctt\ecsize \space at \nominalsize
3665  \else
3666    \ifx\curfontstyle\bfstylename
3667      % bold:
3668      \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
3669    \else
3670      % regular:
3671      \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
3672    \fi
3673  \fi
3674  \thisecfont
3675}
3676
3677% @registeredsymbol - R in a circle.  The font for the R should really
3678% be smaller yet, but lllsize is the best we can do for now.
3679% Adapted from the plain.tex definition of \copyright.
3680%
3681\def\registeredsymbol{%
3682  $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}%
3683               \hfil\crcr\Orb}}%
3684    }$%
3685}
3686
3687% @textdegree - the normal degrees sign.
3688%
3689\def\textdegree{$^\circ$}
3690
3691% Laurent Siebenmann reports \Orb undefined with:
3692%  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
3693% so we'll define it if necessary.
3694%
3695\ifx\Orb\thisisundefined
3696\def\Orb{\mathhexbox20D}
3697\fi
3698
3699% Quotes.
3700\chardef\quoteleft=`\`
3701\chardef\quoteright=`\'
3702
3703% only change font for tt for correct kerning and to avoid using
3704% \ecfont unless necessary.
3705\def\quotedblleft{%
3706  \ifmonospace{\ecfont\char"10}\else{\char"5C}\fi
3707}
3708
3709\def\quotedblright{%
3710  \ifmonospace{\ecfont\char"11}\else{\char`\"}\fi
3711}
3712
3713
3714\message{page headings,}
3715
3716\newskip\titlepagetopglue \titlepagetopglue = 1.5in
3717\newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3718
3719% First the title page.  Must do @settitle before @titlepage.
3720\newif\ifseenauthor
3721\newif\iffinishedtitlepage
3722
3723% @setcontentsaftertitlepage used to do an implicit @contents or
3724% @shortcontents after @end titlepage, but it is now obsolete.
3725\def\setcontentsaftertitlepage{%
3726  \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
3727              command; move your @contents command if you want the contents
3728              after the title page.}}%
3729\def\setshortcontentsaftertitlepage{%
3730  \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
3731              command; move your @shortcontents and @contents commands if you
3732              want the contents after the title page.}}%
3733
3734\parseargdef\shorttitlepage{%
3735  \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3736  \endgroup\page\hbox{}\page}
3737
3738\envdef\titlepage{%
3739  % Open one extra group, as we want to close it in the middle of \Etitlepage.
3740  \begingroup
3741    \parindent=0pt \textfonts
3742    % Leave some space at the very top of the page.
3743    \vglue\titlepagetopglue
3744    % No rule at page bottom unless we print one at the top with @title.
3745    \finishedtitlepagetrue
3746    %
3747    % Most title ``pages'' are actually two pages long, with space
3748    % at the top of the second.  We don't want the ragged left on the second.
3749    \let\oldpage = \page
3750    \def\page{%
3751      \iffinishedtitlepage\else
3752	 \finishtitlepage
3753      \fi
3754      \let\page = \oldpage
3755      \page
3756      \null
3757    }%
3758}
3759
3760\def\Etitlepage{%
3761    \iffinishedtitlepage\else
3762	\finishtitlepage
3763    \fi
3764    % It is important to do the page break before ending the group,
3765    % because the headline and footline are only empty inside the group.
3766    % If we use the new definition of \page, we always get a blank page
3767    % after the title page, which we certainly don't want.
3768    \oldpage
3769  \endgroup
3770  %
3771  % Need this before the \...aftertitlepage checks so that if they are
3772  % in effect the toc pages will come out with page numbers.
3773  \HEADINGSon
3774}
3775
3776\def\finishtitlepage{%
3777  \vskip4pt \hrule height 2pt width \hsize
3778  \vskip\titlepagebottomglue
3779  \finishedtitlepagetrue
3780}
3781
3782% Settings used for typesetting titles: no hyphenation, no indentation,
3783% don't worry much about spacing, ragged right.  This should be used
3784% inside a \vbox, and fonts need to be set appropriately first. \par should
3785% be specified before the end of the \vbox, since a vbox is a group.
3786%
3787\def\raggedtitlesettings{%
3788  \rm
3789  \hyphenpenalty=10000
3790  \parindent=0pt
3791  \tolerance=5000
3792  \ptexraggedright
3793}
3794
3795% Macros to be used within @titlepage:
3796
3797\let\subtitlerm=\rmfont
3798\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3799
3800\parseargdef\title{%
3801  \checkenv\titlepage
3802  \vbox{\titlefonts \raggedtitlesettings #1\par}%
3803  % print a rule at the page bottom also.
3804  \finishedtitlepagefalse
3805  \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3806}
3807
3808\parseargdef\subtitle{%
3809  \checkenv\titlepage
3810  {\subtitlefont \rightline{#1}}%
3811}
3812
3813% @author should come last, but may come many times.
3814% It can also be used inside @quotation.
3815%
3816\parseargdef\author{%
3817  \def\temp{\quotation}%
3818  \ifx\thisenv\temp
3819    \def\quotationauthor{#1}% printed in \Equotation.
3820  \else
3821    \checkenv\titlepage
3822    \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3823    {\secfonts\rm \leftline{#1}}%
3824  \fi
3825}
3826
3827
3828% Set up page headings and footings.
3829
3830\let\thispage=\folio
3831
3832\newtoks\evenheadline    % headline on even pages
3833\newtoks\oddheadline     % headline on odd pages
3834\newtoks\evenchapheadline% headline on even pages with a new chapter
3835\newtoks\oddchapheadline % headline on odd pages with a new chapter
3836\newtoks\evenfootline    % footline on even pages
3837\newtoks\oddfootline     % footline on odd pages
3838
3839% Now make \makeheadline and \makefootline in Plain TeX use those variables
3840\headline={{\textfonts\rm
3841            \ifchapterpage
3842              \ifodd\pageno\the\oddchapheadline\else\the\evenchapheadline\fi
3843            \else
3844              \ifodd\pageno\the\oddheadline\else\the\evenheadline\fi
3845            \fi}}
3846
3847\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
3848                            \else \the\evenfootline \fi}\HEADINGShook}
3849\let\HEADINGShook=\relax
3850
3851% Commands to set those variables.
3852% For example, this is what  @headings on  does
3853% @evenheading @thistitle|@thispage|@thischapter
3854% @oddheading @thischapter|@thispage|@thistitle
3855% @evenfooting @thisfile||
3856% @oddfooting ||@thisfile
3857
3858
3859\def\evenheading{\parsearg\evenheadingxxx}
3860\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3861\def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
3862  \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
3863  \global\evenchapheadline=\evenheadline}
3864
3865\def\oddheading{\parsearg\oddheadingxxx}
3866\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3867\def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
3868  \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3869  \global\oddchapheadline=\oddheadline}
3870
3871\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3872
3873\def\evenfooting{\parsearg\evenfootingxxx}
3874\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3875\def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3876\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3877
3878\def\oddfooting{\parsearg\oddfootingxxx}
3879\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3880\def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3881  \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3882  %
3883  % Leave some space for the footline.  Hopefully ok to assume
3884  % @evenfooting will not be used by itself.
3885  \global\advance\txipageheight by -12pt
3886  \global\advance\vsize by -12pt
3887}
3888
3889\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3890
3891% @evenheadingmarks top     \thischapter <- chapter at the top of a page
3892% @evenheadingmarks bottom  \thischapter <- chapter at the bottom of a page
3893%
3894% The same set of arguments for:
3895%
3896% @oddheadingmarks
3897% @evenfootingmarks
3898% @oddfootingmarks
3899% @everyheadingmarks
3900% @everyfootingmarks
3901
3902% These define \getoddheadingmarks, \getevenheadingmarks,
3903% \getoddfootingmarks, and \getevenfootingmarks, each to one of
3904% \gettopheadingmarks, \getbottomheadingmarks.
3905%
3906\def\evenheadingmarks{\headingmarks{even}{heading}}
3907\def\oddheadingmarks{\headingmarks{odd}{heading}}
3908\def\evenfootingmarks{\headingmarks{even}{footing}}
3909\def\oddfootingmarks{\headingmarks{odd}{footing}}
3910\parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
3911                          \headingmarks{odd}{heading}{#1} }
3912\parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
3913                          \headingmarks{odd}{footing}{#1} }
3914% #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3915\def\headingmarks#1#2#3 {%
3916  \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3917  \global\expandafter\let\csname get#1#2marks\endcsname \temp
3918}
3919
3920\everyheadingmarks bottom
3921\everyfootingmarks bottom
3922
3923% @headings double      turns headings on for double-sided printing.
3924% @headings single      turns headings on for single-sided printing.
3925% @headings off         turns them off.
3926% @headings on          same as @headings double, retained for compatibility.
3927% @headings after       turns on double-sided headings after this page.
3928% @headings doubleafter turns on double-sided headings after this page.
3929% @headings singleafter turns on single-sided headings after this page.
3930% By default, they are off at the start of a document,
3931% and turned `on' after @end titlepage.
3932
3933\parseargdef\headings{\csname HEADINGS#1\endcsname}
3934
3935\def\headingsoff{% non-global headings elimination
3936  \evenheadline={\hfil}\evenfootline={\hfil}\evenchapheadline={\hfil}%
3937   \oddheadline={\hfil}\oddfootline={\hfil}\oddchapheadline={\hfil}%
3938}
3939
3940\def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3941\HEADINGSoff  % it's the default
3942
3943% When we turn headings on, set the page number to 1.
3944\def\pageone{
3945  \global\pageno=1
3946  \global\arabiccount = \pagecount
3947}
3948
3949% For double-sided printing, put current file name in lower left corner,
3950% chapter name on inside top of right hand pages, document
3951% title on inside top of left hand pages, and page numbers on outside top
3952% edge of all pages.
3953\def\HEADINGSdouble{%
3954\pageone
3955\HEADINGSdoublex
3956}
3957\let\contentsalignmacro = \chappager
3958
3959% For single-sided printing, chapter title goes across top left of page,
3960% page number on top right.
3961\def\HEADINGSsingle{%
3962\pageone
3963\HEADINGSsinglex
3964}
3965\def\HEADINGSon{\HEADINGSdouble}
3966
3967\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
3968\let\HEADINGSdoubleafter=\HEADINGSafter
3969\def\HEADINGSdoublex{%
3970\global\evenfootline={\hfil}
3971\global\oddfootline={\hfil}
3972\global\evenheadline={\line{\folio\hfil\thistitle}}
3973\global\oddheadline={\line{\thischapter\hfil\folio}}
3974\global\evenchapheadline={\line{\folio\hfil}}
3975\global\oddchapheadline={\line{\hfil\folio}}
3976\global\let\contentsalignmacro = \chapoddpage
3977}
3978
3979\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
3980\def\HEADINGSsinglex{%
3981\global\evenfootline={\hfil}
3982\global\oddfootline={\hfil}
3983\global\evenheadline={\line{\thischapter\hfil\folio}}
3984\global\oddheadline={\line{\thischapter\hfil\folio}}
3985\global\evenchapheadline={\line{\hfil\folio}}
3986\global\oddchapheadline={\line{\hfil\folio}}
3987\global\let\contentsalignmacro = \chappager
3988}
3989
3990% for @setchapternewpage off
3991\def\HEADINGSsinglechapoff{%
3992\pageone
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=\evenheadline
3998\global\oddchapheadline=\oddheadline
3999\global\let\contentsalignmacro = \chappager
4000}
4001
4002% Subroutines used in generating headings
4003% This produces Day Month Year style of output.
4004% Only define if not already defined, in case a txi-??.tex file has set
4005% up a different format (e.g., txi-cs.tex does this).
4006\ifx\today\thisisundefined
4007\def\today{%
4008  \number\day\space
4009  \ifcase\month
4010  \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
4011  \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
4012  \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
4013  \fi
4014  \space\number\year}
4015\fi
4016
4017% @settitle line...  specifies the title of the document, for headings.
4018% It generates no output of its own.
4019\def\thistitle{\putwordNoTitle}
4020\def\settitle{\parsearg{\gdef\thistitle}}
4021
4022
4023\message{tables,}
4024% Tables -- @table, @ftable, @vtable, @item(x).
4025
4026% default indentation of table text
4027\newdimen\tableindent \tableindent=.8in
4028% default indentation of @itemize and @enumerate text
4029\newdimen\itemindent  \itemindent=.3in
4030% margin between end of table item and start of table text.
4031\newdimen\itemmargin  \itemmargin=.1in
4032
4033% used internally for \itemindent minus \itemmargin
4034\newdimen\itemmax
4035
4036% Note @table, @ftable, and @vtable define @item, @itemx, etc., with
4037% these defs.
4038% They also define \itemindex
4039% to index the item name in whatever manner is desired (perhaps none).
4040
4041\newif\ifitemxneedsnegativevskip
4042
4043\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
4044
4045\def\internalBitem{\smallbreak \parsearg\itemzzz}
4046\def\internalBitemx{\itemxpar \parsearg\itemzzz}
4047
4048\def\itemzzz #1{\begingroup %
4049  \advance\hsize by -\rightskip
4050  \advance\hsize by -\tableindent
4051  \setbox0=\hbox{\itemindicate{#1}}%
4052  \itemindex{#1}%
4053  \nobreak % This prevents a break before @itemx.
4054  %
4055  % If the item text does not fit in the space we have, put it on a line
4056  % by itself, and do not allow a page break either before or after that
4057  % line.  We do not start a paragraph here because then if the next
4058  % command is, e.g., @kindex, the whatsit would get put into the
4059  % horizontal list on a line by itself, resulting in extra blank space.
4060  \ifdim \wd0>\itemmax
4061    %
4062    % Make this a paragraph so we get the \parskip glue and wrapping,
4063    % but leave it ragged-right.
4064    \begingroup
4065      \advance\leftskip by-\tableindent
4066      \advance\hsize by\tableindent
4067      \advance\rightskip by0pt plus1fil\relax
4068      \leavevmode\unhbox0\par
4069    \endgroup
4070    %
4071    % We're going to be starting a paragraph, but we don't want the
4072    % \parskip glue -- logically it's part of the @item we just started.
4073    \nobreak \vskip-\parskip
4074    %
4075    % Stop a page break at the \parskip glue coming up.  However, if
4076    % what follows is an environment such as @example, there will be no
4077    % \parskip glue; then the negative vskip we just inserted would
4078    % cause the example and the item to crash together.  So we use this
4079    % bizarre value of 10001 as a signal to \aboveenvbreak to insert
4080    % \parskip glue after all.  Section titles are handled this way also.
4081    %
4082    \penalty 10001
4083    \endgroup
4084    \itemxneedsnegativevskipfalse
4085  \else
4086    % The item text fits into the space.  Start a paragraph, so that the
4087    % following text (if any) will end up on the same line.
4088    \noindent
4089    % Do this with kerns and \unhbox so that if there is a footnote in
4090    % the item text, it can migrate to the main vertical list and
4091    % eventually be printed.
4092    \nobreak\kern-\tableindent
4093    \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
4094    \unhbox0
4095    \nobreak\kern\dimen0
4096    \endgroup
4097    \itemxneedsnegativevskiptrue
4098  \fi
4099}
4100
4101\def\item{\errmessage{@item while not in a list environment}}
4102\def\itemx{\errmessage{@itemx while not in a list environment}}
4103
4104% @table, @ftable, @vtable.
4105\envdef\table{%
4106  \let\itemindex\gobble
4107  \tablecheck{table}%
4108}
4109\envdef\ftable{%
4110  \def\itemindex ##1{\doind {fn}{\code{##1}}}%
4111  \tablecheck{ftable}%
4112}
4113\envdef\vtable{%
4114  \def\itemindex ##1{\doind {vr}{\code{##1}}}%
4115  \tablecheck{vtable}%
4116}
4117\def\tablecheck#1{%
4118  \ifnum \the\catcode`\^^M=\active
4119    \endgroup
4120    \errmessage{This command won't work in this context; perhaps the problem is
4121      that we are \inenvironment\thisenv}%
4122    \def\next{\doignore{#1}}%
4123  \else
4124    \let\next\tablex
4125  \fi
4126  \next
4127}
4128\def\tablex#1{%
4129  \def\itemindicate{#1}%
4130  \parsearg\tabley
4131}
4132\def\tabley#1{%
4133  {%
4134    \makevalueexpandable
4135    \edef\temp{\noexpand\tablez #1\space\space\space}%
4136    \expandafter
4137  }\temp \endtablez
4138}
4139\def\tablez #1 #2 #3 #4\endtablez{%
4140  \aboveenvbreak
4141  \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
4142  \ifnum 0#2>0 \tableindent=#2\mil \fi
4143  \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
4144  \itemmax=\tableindent
4145  \advance \itemmax by -\itemmargin
4146  \advance \leftskip by \tableindent
4147  \exdentamount=\tableindent
4148  \parindent = 0pt
4149  \parskip = \smallskipamount
4150  \ifdim \parskip=0pt \parskip=2pt \fi
4151  \let\item = \internalBitem
4152  \let\itemx = \internalBitemx
4153}
4154\def\Etable{\endgraf\afterenvbreak}
4155\let\Eftable\Etable
4156\let\Evtable\Etable
4157\let\Eitemize\Etable
4158\let\Eenumerate\Etable
4159
4160% This is the counter used by @enumerate, which is really @itemize
4161
4162\newcount \itemno
4163
4164\envdef\itemize{\parsearg\doitemize}
4165
4166\def\doitemize#1{%
4167  \aboveenvbreak
4168  \itemmax=\itemindent
4169  \advance\itemmax by -\itemmargin
4170  \advance\leftskip by \itemindent
4171  \exdentamount=\itemindent
4172  \parindent=0pt
4173  \parskip=\smallskipamount
4174  \ifdim\parskip=0pt \parskip=2pt \fi
4175  %
4176  % Try typesetting the item mark so that if the document erroneously says
4177  % something like @itemize @samp (intending @table), there's an error
4178  % right away at the @itemize.  It's not the best error message in the
4179  % world, but it's better than leaving it to the @item.  This means if
4180  % the user wants an empty mark, they have to say @w{} not just @w.
4181  \def\itemcontents{#1}%
4182  \setbox0 = \hbox{\itemcontents}%
4183  %
4184  % @itemize with no arg is equivalent to @itemize @bullet.
4185  \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
4186  %
4187  \let\item=\itemizeitem
4188}
4189
4190% Definition of @item while inside @itemize and @enumerate.
4191%
4192\def\itemizeitem{%
4193  \advance\itemno by 1  % for enumerations
4194  {\let\par=\endgraf \smallbreak}% reasonable place to break
4195  {%
4196   % If the document has an @itemize directly after a section title, a
4197   % \nobreak will be last on the list, and \sectionheading will have
4198   % done a \vskip-\parskip.  In that case, we don't want to zero
4199   % parskip, or the item text will crash with the heading.  On the
4200   % other hand, when there is normal text preceding the item (as there
4201   % usually is), we do want to zero parskip, or there would be too much
4202   % space.  In that case, we won't have a \nobreak before.  At least
4203   % that's the theory.
4204   \ifnum\lastpenalty<10000 \parskip=0in \fi
4205   \noindent
4206   \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
4207   %
4208   \ifinner\else
4209     \vadjust{\penalty 1200}% not good to break after first line of item.
4210   \fi
4211   % We can be in inner vertical mode in a footnote, although an
4212   % @itemize looks awful there.
4213  }%
4214  \flushcr
4215}
4216
4217% \splitoff TOKENS\endmark defines \first to be the first token in
4218% TOKENS, and \rest to be the remainder.
4219%
4220\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
4221
4222% Allow an optional argument of an uppercase letter, lowercase letter,
4223% or number, to specify the first label in the enumerated list.  No
4224% argument is the same as `1'.
4225%
4226\envparseargdef\enumerate{\enumeratey #1  \endenumeratey}
4227\def\enumeratey #1 #2\endenumeratey{%
4228  % If we were given no argument, pretend we were given `1'.
4229  \def\thearg{#1}%
4230  \ifx\thearg\empty \def\thearg{1}\fi
4231  %
4232  % Detect if the argument is a single token.  If so, it might be a
4233  % letter.  Otherwise, the only valid thing it can be is a number.
4234  % (We will always have one token, because of the test we just made.
4235  % This is a good thing, since \splitoff doesn't work given nothing at
4236  % all -- the first parameter is undelimited.)
4237  \expandafter\splitoff\thearg\endmark
4238  \ifx\rest\empty
4239    % Only one token in the argument.  It could still be anything.
4240    % A ``lowercase letter'' is one whose \lccode is nonzero.
4241    % An ``uppercase letter'' is one whose \lccode is both nonzero, and
4242    %   not equal to itself.
4243    % Otherwise, we assume it's a number.
4244    %
4245    % We need the \relax at the end of the \ifnum lines to stop TeX from
4246    % continuing to look for a <number>.
4247    %
4248    \ifnum\lccode\expandafter`\thearg=0\relax
4249      \numericenumerate % a number (we hope)
4250    \else
4251      % It's a letter.
4252      \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
4253        \lowercaseenumerate % lowercase letter
4254      \else
4255        \uppercaseenumerate % uppercase letter
4256      \fi
4257    \fi
4258  \else
4259    % Multiple tokens in the argument.  We hope it's a number.
4260    \numericenumerate
4261  \fi
4262}
4263
4264% An @enumerate whose labels are integers.  The starting integer is
4265% given in \thearg.
4266%
4267\def\numericenumerate{%
4268  \itemno = \thearg
4269  \startenumeration{\the\itemno}%
4270}
4271
4272% The starting (lowercase) letter is in \thearg.
4273\def\lowercaseenumerate{%
4274  \itemno = \expandafter`\thearg
4275  \startenumeration{%
4276    % Be sure we're not beyond the end of the alphabet.
4277    \ifnum\itemno=0
4278      \errmessage{No more lowercase letters in @enumerate; get a bigger
4279                  alphabet}%
4280    \fi
4281    \char\lccode\itemno
4282  }%
4283}
4284
4285% The starting (uppercase) letter is in \thearg.
4286\def\uppercaseenumerate{%
4287  \itemno = \expandafter`\thearg
4288  \startenumeration{%
4289    % Be sure we're not beyond the end of the alphabet.
4290    \ifnum\itemno=0
4291      \errmessage{No more uppercase letters in @enumerate; get a bigger
4292                  alphabet}
4293    \fi
4294    \char\uccode\itemno
4295  }%
4296}
4297
4298% Call \doitemize, adding a period to the first argument and supplying the
4299% common last two arguments.  Also subtract one from the initial value in
4300% \itemno, since @item increments \itemno.
4301%
4302\def\startenumeration#1{%
4303  \advance\itemno by -1
4304  \doitemize{#1.}\flushcr
4305}
4306
4307
4308% @multitable macros
4309
4310% Macros used to set up halign preamble:
4311%
4312\let\endsetuptable\relax
4313\def\xendsetuptable{\endsetuptable}
4314\let\columnfractions\relax
4315\def\xcolumnfractions{\columnfractions}
4316\newif\ifsetpercent
4317
4318% #1 is the @columnfraction, usually a decimal number like .5, but might
4319% be just 1.  We just use it, whatever it is.
4320%
4321\def\pickupwholefraction#1 {%
4322  \global\advance\colcount by 1
4323  \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
4324  \setuptable
4325}
4326
4327\newcount\colcount
4328\def\setuptable#1{%
4329  \def\firstarg{#1}%
4330  \ifx\firstarg\xendsetuptable
4331    \let\go = \relax
4332  \else
4333    \ifx\firstarg\xcolumnfractions
4334      \global\setpercenttrue
4335    \else
4336      \ifsetpercent
4337         \let\go\pickupwholefraction
4338      \else
4339         \global\advance\colcount by 1
4340         \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
4341                   % separator; typically that is always in the input, anyway.
4342         \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
4343      \fi
4344    \fi
4345    \ifx\go\pickupwholefraction
4346      % Put the argument back for the \pickupwholefraction call, so
4347      % we'll always have a period there to be parsed.
4348      \def\go{\pickupwholefraction#1}%
4349    \else
4350      \let\go = \setuptable
4351    \fi%
4352  \fi
4353  \go
4354}
4355
4356% @headitem starts a heading row, which we typeset in bold.  Assignments
4357% have to be global since we are inside the implicit group of an
4358% alignment entry.  \everycr below resets \everytab so we don't have to
4359% undo it ourselves.
4360\def\headitemfont{\b}% for people to use in the template row; not changeable
4361\def\headitem{%
4362  \checkenv\multitable
4363  \crcr
4364  \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
4365  \global\everytab={\bf}% can't use \headitemfont since the parsing differs
4366  \the\everytab % for the first item
4367}%
4368%
4369% default for tables with no headings.
4370\let\headitemcrhook=\relax
4371%
4372\def\tab{\checkenv\multitable &\the\everytab}%
4373
4374\newtoks\everytab  % insert after every tab.
4375%
4376\envdef\multitable{%
4377  \vskip\parskip
4378  \startsavinginserts
4379  %
4380  % @item within a multitable starts a normal row.
4381  % We use \def instead of \let so that if one of the multitable entries
4382  % contains an @itemize, we don't choke on the \item (seen as \crcr aka
4383  % \endtemplate) expanding \doitemize.
4384  \def\item{\crcr}%
4385  %
4386  \tolerance=9500
4387  \hbadness=9500
4388  \parskip=0pt
4389  \parindent=6pt
4390  \overfullrule=0pt
4391  \global\colcount=0
4392  %
4393  \everycr = {%
4394    \noalign{%
4395      \global\everytab={}% Reset from possible headitem.
4396      \global\colcount=0 % Reset the column counter.
4397      %
4398      % Check for saved footnotes, etc.:
4399      \checkinserts
4400      %
4401      % Perhaps a \nobreak, then reset:
4402      \headitemcrhook
4403      \global\let\headitemcrhook=\relax
4404    }%
4405  }%
4406  %
4407  \parsearg\domultitable
4408}
4409\def\domultitable#1{%
4410  % To parse everything between @multitable and @item:
4411  \setuptable#1 \endsetuptable
4412  %
4413  % This preamble sets up a generic column definition, which will
4414  % be used as many times as user calls for columns.
4415  % \vtop will set a single line and will also let text wrap and
4416  % continue for many paragraphs if desired.
4417  \halign\bgroup &%
4418    \global\advance\colcount by 1
4419    \strut
4420    \vtop{%
4421      \advance\hsize by -1\leftskip
4422      % Find the correct column width
4423      \hsize=\expandafter\csname col\the\colcount\endcsname
4424      %
4425      \rightskip=0pt
4426      \ifnum\colcount=1
4427        \advance\hsize by\leftskip % Add indent of surrounding text
4428      \else
4429        % In order to keep entries from bumping into each other.
4430        \leftskip=12pt
4431        \ifsetpercent \else
4432          % If a template has been used
4433          \advance\hsize by \leftskip
4434        \fi
4435      \fi
4436      \noindent\ignorespaces##\unskip\strut
4437    }\cr
4438}
4439\def\Emultitable{%
4440  \crcr
4441  \egroup % end the \halign
4442  \global\setpercentfalse
4443}
4444
4445
4446\message{conditionals,}
4447
4448% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
4449% @ifnotxml always succeed.  They currently do nothing; we don't
4450% attempt to check whether the conditionals are properly nested.  But we
4451% have to remember that they are conditionals, so that @end doesn't
4452% attempt to close an environment group.
4453%
4454\def\makecond#1{%
4455  \expandafter\let\csname #1\endcsname = \relax
4456  \expandafter\let\csname iscond.#1\endcsname = 1
4457}
4458\makecond{iftex}
4459\makecond{ifnotdocbook}
4460\makecond{ifnothtml}
4461\makecond{ifnotinfo}
4462\makecond{ifnotplaintext}
4463\makecond{ifnotxml}
4464
4465% Ignore @ignore, @ifhtml, @ifinfo, and the like.
4466%
4467\def\direntry{\doignore{direntry}}
4468\def\documentdescription{\doignore{documentdescription}}
4469\def\docbook{\doignore{docbook}}
4470\def\html{\doignore{html}}
4471\def\ifdocbook{\doignore{ifdocbook}}
4472\def\ifhtml{\doignore{ifhtml}}
4473\def\ifinfo{\doignore{ifinfo}}
4474\def\ifnottex{\doignore{ifnottex}}
4475\def\ifplaintext{\doignore{ifplaintext}}
4476\def\ifxml{\doignore{ifxml}}
4477\def\ignore{\doignore{ignore}}
4478\def\menu{\doignore{menu}}
4479\def\xml{\doignore{xml}}
4480
4481% Ignore text until a line `@end #1', keeping track of nested conditionals.
4482%
4483% A count to remember the depth of nesting.
4484\newcount\doignorecount
4485
4486\def\doignore#1{\begingroup
4487  % Scan in ``verbatim'' mode:
4488  \obeylines
4489  \catcode`\@ = \other
4490  \catcode`\{ = \other
4491  \catcode`\} = \other
4492  %
4493  % Make sure that spaces turn into tokens that match what \doignoretext wants.
4494  \spaceisspace
4495  %
4496  % Count number of #1's that we've seen.
4497  \doignorecount = 0
4498  %
4499  % Swallow text until we reach the matching `@end #1'.
4500  \dodoignore{#1}%
4501}
4502
4503{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4504  \obeylines %
4505  %
4506  \gdef\dodoignore#1{%
4507    % #1 contains the command name as a string, e.g., `ifinfo'.
4508    %
4509    % Define a command to find the next `@end #1'.
4510    \long\def\doignoretext##1^^M@end #1{%
4511      \doignoretextyyy##1^^M@#1\_STOP_}%
4512    %
4513    % And this command to find another #1 command, at the beginning of a
4514    % line.  (Otherwise, we would consider a line `@c @ifset', for
4515    % example, to count as an @ifset for nesting.)
4516    \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
4517    %
4518    % And now expand that command.
4519    \doignoretext ^^M%
4520  }%
4521}
4522
4523\def\doignoreyyy#1{%
4524  \def\temp{#1}%
4525  \ifx\temp\empty			% Nothing found.
4526    \let\next\doignoretextzzz
4527  \else					% Found a nested condition, ...
4528    \advance\doignorecount by 1
4529    \let\next\doignoretextyyy		% ..., look for another.
4530    % If we're here, #1 ends with ^^M\ifinfo (for example).
4531  \fi
4532  \next #1% the token \_STOP_ is present just after this macro.
4533}
4534
4535% We have to swallow the remaining "\_STOP_".
4536%
4537\def\doignoretextzzz#1{%
4538  \ifnum\doignorecount = 0	% We have just found the outermost @end.
4539    \let\next\enddoignore
4540  \else				% Still inside a nested condition.
4541    \advance\doignorecount by -1
4542    \let\next\doignoretext      % Look for the next @end.
4543  \fi
4544  \next
4545}
4546
4547% Finish off ignored text.
4548{ \obeylines%
4549  % Ignore anything after the last `@end #1'; this matters in verbatim
4550  % environments, where otherwise the newline after an ignored conditional
4551  % would result in a blank line in the output.
4552  \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4553}
4554
4555
4556% @set VAR sets the variable VAR to an empty value.
4557% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4558%
4559% Since we want to separate VAR from REST-OF-LINE (which might be
4560% empty), we can't just use \parsearg; we have to insert a space of our
4561% own to delimit the rest of the line, and then take it out again if we
4562% didn't need it.
4563% We rely on the fact that \parsearg sets \catcode`\ =10.
4564%
4565\parseargdef\set{\setyyy#1 \endsetyyy}
4566\def\setyyy#1 #2\endsetyyy{%
4567  {%
4568    \makevalueexpandable
4569    \def\temp{#2}%
4570    \edef\next{\gdef\makecsname{SET#1}}%
4571    \ifx\temp\empty
4572      \next{}%
4573    \else
4574      \setzzz#2\endsetzzz
4575    \fi
4576  }%
4577}
4578% Remove the trailing space \setxxx inserted.
4579\def\setzzz#1 \endsetzzz{\next{#1}}
4580
4581% @clear VAR clears (i.e., unsets) the variable VAR.
4582%
4583\parseargdef\clear{%
4584  {%
4585    \makevalueexpandable
4586    \global\expandafter\let\csname SET#1\endcsname=\relax
4587  }%
4588}
4589
4590% @value{foo} gets the text saved in variable foo.
4591\def\value{\begingroup\makevalueexpandable\valuexxx}
4592\def\valuexxx#1{\expandablevalue{#1}\endgroup}
4593{
4594  \catcode`\-=\active \catcode`\_=\active
4595  %
4596  \gdef\makevalueexpandable{%
4597    \let\value = \expandablevalue
4598    % We don't want these characters active, ...
4599    \catcode`\-=\other \catcode`\_=\other
4600    % ..., but we might end up with active ones in the argument if
4601    % we're called from @code, as @code{@value{foo-bar_}}, though.
4602    % So \let them to their normal equivalents.
4603    \let-\normaldash \let_\normalunderscore
4604  }
4605}
4606
4607\def\expandablevalue#1{%
4608  \expandafter\ifx\csname SET#1\endcsname\relax
4609    {[No value for ``#1'']}%
4610    \message{Variable `#1', used in @value, is not set.}%
4611  \else
4612    \csname SET#1\endcsname
4613  \fi
4614}
4615
4616% Like \expandablevalue, but completely expandable (the \message in the
4617% definition above operates at the execution level of TeX).  Used when
4618% writing to auxiliary files, due to the expansion that \write does.
4619% If flag is undefined, pass through an unexpanded @value command: maybe it
4620% will be set by the time it is read back in.
4621%
4622% NB flag names containing - or _ may not work here.
4623\def\dummyvalue#1{%
4624  \expandafter\ifx\csname SET#1\endcsname\relax
4625    \string\value{#1}%
4626  \else
4627    \csname SET#1\endcsname
4628  \fi
4629}
4630
4631% Used for @value's in index entries to form the sort key: expand the @value
4632% if possible, otherwise sort late.
4633\def\indexnofontsvalue#1{%
4634  \expandafter\ifx\csname SET#1\endcsname\relax
4635    ZZZZZZZ%
4636  \else
4637    \csname SET#1\endcsname
4638  \fi
4639}
4640
4641% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4642% with @set.
4643%
4644% To get the special treatment we need for `@end ifset,' we call
4645% \makecond and then redefine.
4646%
4647\makecond{ifset}
4648\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4649\def\doifset#1#2{%
4650  {%
4651    \makevalueexpandable
4652    \let\next=\empty
4653    \expandafter\ifx\csname SET#2\endcsname\relax
4654      #1% If not set, redefine \next.
4655    \fi
4656    \expandafter
4657  }\next
4658}
4659\def\ifsetfail{\doignore{ifset}}
4660
4661% @ifclear VAR ... @end executes the `...' iff VAR has never been
4662% defined with @set, or has been undefined with @clear.
4663%
4664% The `\else' inside the `\doifset' parameter is a trick to reuse the
4665% above code: if the variable is not set, do nothing, if it is set,
4666% then redefine \next to \ifclearfail.
4667%
4668\makecond{ifclear}
4669\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4670\def\ifclearfail{\doignore{ifclear}}
4671
4672% @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
4673% without the @) is in fact defined.  We can only feasibly check at the
4674% TeX level, so something like `mathcode' is going to considered
4675% defined even though it is not a Texinfo command.
4676%
4677\makecond{ifcommanddefined}
4678\def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
4679%
4680\def\doifcmddefined#1#2{{%
4681    \makevalueexpandable
4682    \let\next=\empty
4683    \expandafter\ifx\csname #2\endcsname\relax
4684      #1% If not defined, \let\next as above.
4685    \fi
4686    \expandafter
4687  }\next
4688}
4689\def\ifcmddefinedfail{\doignore{ifcommanddefined}}
4690
4691% @ifcommandnotdefined CMD ... handled similar to @ifclear above.
4692\makecond{ifcommandnotdefined}
4693\def\ifcommandnotdefined{%
4694  \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
4695\def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
4696
4697% Set the `txicommandconditionals' variable, so documents have a way to
4698% test if the @ifcommand...defined conditionals are available.
4699\set txicommandconditionals
4700
4701% @dircategory CATEGORY  -- specify a category of the dir file
4702% which this file should belong to.  Ignore this in TeX.
4703\let\dircategory=\comment
4704
4705% @defininfoenclose.
4706\let\definfoenclose=\comment
4707
4708
4709\message{indexing,}
4710% Index generation facilities
4711
4712% Define \newwrite to be identical to plain tex's \newwrite
4713% except not \outer, so it can be used within macros and \if's.
4714\edef\newwrite{\makecsname{ptexnewwrite}}
4715
4716% \newindex {foo} defines an index named IX.
4717% It automatically defines \IXindex such that
4718% \IXindex ...rest of line... puts an entry in the index IX.
4719% It also defines \IXindfile to be the number of the output channel for
4720% the file that accumulates this index.  The file's extension is IX.
4721% The name of an index should be no more than 2 characters long
4722% for the sake of vms.
4723%
4724\def\newindex#1{%
4725  \expandafter\chardef\csname#1indfile\endcsname=0
4726  \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
4727    \noexpand\doindex{#1}}
4728}
4729
4730% @defindex foo  ==  \newindex{foo}
4731%
4732\def\defindex{\parsearg\newindex}
4733
4734% Define @defcodeindex, like @defindex except put all entries in @code.
4735%
4736\def\defcodeindex{\parsearg\newcodeindex}
4737%
4738\def\newcodeindex#1{%
4739  \expandafter\chardef\csname#1indfile\endcsname=0
4740  \expandafter\xdef\csname#1index\endcsname{%
4741    \noexpand\docodeindex{#1}}%
4742}
4743
4744% The default indices:
4745\newindex{cp}%      concepts,
4746\newcodeindex{fn}%  functions,
4747\newcodeindex{vr}%  variables,
4748\newcodeindex{tp}%  types,
4749\newcodeindex{ky}%  keys
4750\newcodeindex{pg}%  and programs.
4751
4752
4753% @synindex foo bar    makes index foo feed into index bar.
4754% Do this instead of @defindex foo if you don't want it as a separate index.
4755%
4756% @syncodeindex foo bar   similar, but put all entries made for index foo
4757% inside @code.
4758%
4759\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4760\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4761
4762% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4763% #3 the target index (bar).
4764\def\dosynindex#1#2#3{%
4765  \requireopenindexfile{#3}%
4766  % redefine \fooindfile:
4767  \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4768  \expandafter\let\csname#2indfile\endcsname=\temp
4769  % redefine \fooindex:
4770  \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
4771}
4772
4773% Define \doindex, the driver for all index macros.
4774% Argument #1 is generated by the calling \fooindex macro,
4775% and it is the two-letter name of the index.
4776
4777\def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
4778\def\doindexxxx #1{\doind{\indexname}{#1}}
4779
4780% like the previous two, but they put @code around the argument.
4781\def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
4782\def\docodeindexxxx #1{\docind{\indexname}{#1}}
4783
4784
4785% Used for the aux, toc and index files to prevent expansion of Texinfo
4786% commands.
4787%
4788\def\atdummies{%
4789  \definedummyletter\@%
4790  \definedummyletter\ %
4791  \definedummyletter\{%
4792  \definedummyletter\}%
4793  \definedummyletter\&%
4794  %
4795  % Do the redefinitions.
4796  \definedummies
4797  \otherbackslash
4798}
4799
4800% \definedummyword defines \#1 as \string\#1\space, thus effectively
4801% preventing its expansion.  This is used only for control words,
4802% not control letters, because the \space would be incorrect for
4803% control characters, but is needed to separate the control word
4804% from whatever follows.
4805%
4806% These can be used both for control words that take an argument and
4807% those that do not.  If it is followed by {arg} in the input, then
4808% that will dutifully get written to the index (or wherever).
4809%
4810% For control letters, we have \definedummyletter, which omits the
4811% space.
4812%
4813\def\definedummyword  #1{\def#1{\string#1\space}}%
4814\def\definedummyletter#1{\def#1{\string#1}}%
4815\let\definedummyaccent\definedummyletter
4816
4817% Called from \atdummies to prevent the expansion of commands.
4818%
4819\def\definedummies{%
4820  %
4821  \let\commondummyword\definedummyword
4822  \let\commondummyletter\definedummyletter
4823  \let\commondummyaccent\definedummyaccent
4824  \commondummiesnofonts
4825  %
4826  \definedummyletter\_%
4827  \definedummyletter\-%
4828  %
4829  % Non-English letters.
4830  \definedummyword\AA
4831  \definedummyword\AE
4832  \definedummyword\DH
4833  \definedummyword\L
4834  \definedummyword\O
4835  \definedummyword\OE
4836  \definedummyword\TH
4837  \definedummyword\aa
4838  \definedummyword\ae
4839  \definedummyword\dh
4840  \definedummyword\exclamdown
4841  \definedummyword\l
4842  \definedummyword\o
4843  \definedummyword\oe
4844  \definedummyword\ordf
4845  \definedummyword\ordm
4846  \definedummyword\questiondown
4847  \definedummyword\ss
4848  \definedummyword\th
4849  %
4850  % Although these internal commands shouldn't show up, sometimes they do.
4851  \definedummyword\bf
4852  \definedummyword\gtr
4853  \definedummyword\hat
4854  \definedummyword\less
4855  \definedummyword\sf
4856  \definedummyword\sl
4857  \definedummyword\tclose
4858  \definedummyword\tt
4859  %
4860  \definedummyword\LaTeX
4861  \definedummyword\TeX
4862  %
4863  % Assorted special characters.
4864  \definedummyword\ampchar
4865  \definedummyword\atchar
4866  \definedummyword\arrow
4867  \definedummyword\backslashchar
4868  \definedummyword\bullet
4869  \definedummyword\comma
4870  \definedummyword\copyright
4871  \definedummyword\registeredsymbol
4872  \definedummyword\dots
4873  \definedummyword\enddots
4874  \definedummyword\entrybreak
4875  \definedummyword\equiv
4876  \definedummyword\error
4877  \definedummyword\euro
4878  \definedummyword\expansion
4879  \definedummyword\geq
4880  \definedummyword\guillemetleft
4881  \definedummyword\guillemetright
4882  \definedummyword\guilsinglleft
4883  \definedummyword\guilsinglright
4884  \definedummyword\lbracechar
4885  \definedummyword\leq
4886  \definedummyword\mathopsup
4887  \definedummyword\minus
4888  \definedummyword\ogonek
4889  \definedummyword\pounds
4890  \definedummyword\point
4891  \definedummyword\print
4892  \definedummyword\quotedblbase
4893  \definedummyword\quotedblleft
4894  \definedummyword\quotedblright
4895  \definedummyword\quoteleft
4896  \definedummyword\quoteright
4897  \definedummyword\quotesinglbase
4898  \definedummyword\rbracechar
4899  \definedummyword\result
4900  \definedummyword\sub
4901  \definedummyword\sup
4902  \definedummyword\textdegree
4903  %
4904  \definedummyword\subentry
4905  %
4906  % We want to disable all macros so that they are not expanded by \write.
4907  \macrolist
4908  \let\value\dummyvalue
4909  %
4910  \normalturnoffactive
4911}
4912
4913% \commondummiesnofonts: common to \definedummies and \indexnofonts.
4914% Define \commondummyletter, \commondummyaccent and \commondummyword before
4915% using.  Used for accents, font commands, and various control letters.
4916%
4917\def\commondummiesnofonts{%
4918  % Control letters and accents.
4919  \commondummyletter\!%
4920  \commondummyaccent\"%
4921  \commondummyaccent\'%
4922  \commondummyletter\*%
4923  \commondummyaccent\,%
4924  \commondummyletter\.%
4925  \commondummyletter\/%
4926  \commondummyletter\:%
4927  \commondummyaccent\=%
4928  \commondummyletter\?%
4929  \commondummyaccent\^%
4930  \commondummyaccent\`%
4931  \commondummyaccent\~%
4932  \commondummyword\u
4933  \commondummyword\v
4934  \commondummyword\H
4935  \commondummyword\dotaccent
4936  \commondummyword\ogonek
4937  \commondummyword\ringaccent
4938  \commondummyword\tieaccent
4939  \commondummyword\ubaraccent
4940  \commondummyword\udotaccent
4941  \commondummyword\dotless
4942  %
4943  % Texinfo font commands.
4944  \commondummyword\b
4945  \commondummyword\i
4946  \commondummyword\r
4947  \commondummyword\sansserif
4948  \commondummyword\sc
4949  \commondummyword\slanted
4950  \commondummyword\t
4951  %
4952  % Commands that take arguments.
4953  \commondummyword\abbr
4954  \commondummyword\acronym
4955  \commondummyword\anchor
4956  \commondummyword\cite
4957  \commondummyword\code
4958  \commondummyword\command
4959  \commondummyword\dfn
4960  \commondummyword\dmn
4961  \commondummyword\email
4962  \commondummyword\emph
4963  \commondummyword\env
4964  \commondummyword\file
4965  \commondummyword\image
4966  \commondummyword\indicateurl
4967  \commondummyword\inforef
4968  \commondummyword\kbd
4969  \commondummyword\key
4970  \commondummyword\math
4971  \commondummyword\option
4972  \commondummyword\pxref
4973  \commondummyword\ref
4974  \commondummyword\samp
4975  \commondummyword\strong
4976  \commondummyword\tie
4977  \commondummyword\U
4978  \commondummyword\uref
4979  \commondummyword\url
4980  \commondummyword\var
4981  \commondummyword\verb
4982  \commondummyword\w
4983  \commondummyword\xref
4984}
4985
4986\let\indexlbrace\relax
4987\let\indexrbrace\relax
4988\let\indexatchar\relax
4989\let\indexbackslash\relax
4990
4991{\catcode`\@=0
4992\catcode`\\=13
4993  @gdef@backslashdisappear{@def\{}}
4994}
4995
4996{
4997\catcode`\<=13
4998\catcode`\-=13
4999\catcode`\`=13
5000  \gdef\indexnonalnumdisappear{%
5001    \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
5002      % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
5003      % (Introduced for FSFS 2nd ed.)
5004      \let`=\empty
5005    \fi
5006    %
5007    \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
5008      \backslashdisappear
5009    \fi
5010    %
5011    \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
5012      \def-{}%
5013    \fi
5014    \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
5015      \def<{}%
5016    \fi
5017    \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
5018      \def\@{}%
5019    \fi
5020  }
5021
5022  \gdef\indexnonalnumreappear{%
5023    \let-\normaldash
5024    \let<\normalless
5025  }
5026}
5027
5028
5029% \indexnofonts is used when outputting the strings to sort the index
5030% by, and when constructing control sequence names.  It eliminates all
5031% control sequences and just writes whatever the best ASCII sort string
5032% would be for a given command (usually its argument).
5033%
5034\def\indexnofonts{%
5035  % Accent commands should become @asis.
5036  \def\commondummyaccent##1{\let##1\asis}%
5037  % We can just ignore other control letters.
5038  \def\commondummyletter##1{\let##1\empty}%
5039  % All control words become @asis by default; overrides below.
5040  \let\commondummyword\commondummyaccent
5041  \commondummiesnofonts
5042  %
5043  % Don't no-op \tt, since it isn't a user-level command
5044  % and is used in the definitions of the active chars like <, >, |, etc.
5045  % Likewise with the other plain tex font commands.
5046  %\let\tt=\asis
5047  %
5048  \def\ { }%
5049  \def\@{@}%
5050  \def\_{\normalunderscore}%
5051  \def\-{}% @- shouldn't affect sorting
5052  %
5053  \uccode`\1=`\{ \uppercase{\def\{{1}}%
5054  \uccode`\1=`\} \uppercase{\def\}{1}}%
5055  \let\lbracechar\{%
5056  \let\rbracechar\}%
5057  %
5058  % Non-English letters.
5059  \def\AA{AA}%
5060  \def\AE{AE}%
5061  \def\DH{DZZ}%
5062  \def\L{L}%
5063  \def\OE{OE}%
5064  \def\O{O}%
5065  \def\TH{TH}%
5066  \def\aa{aa}%
5067  \def\ae{ae}%
5068  \def\dh{dzz}%
5069  \def\exclamdown{!}%
5070  \def\l{l}%
5071  \def\oe{oe}%
5072  \def\ordf{a}%
5073  \def\ordm{o}%
5074  \def\o{o}%
5075  \def\questiondown{?}%
5076  \def\ss{ss}%
5077  \def\th{th}%
5078  %
5079  \let\do\indexnofontsdef
5080  %
5081  \do\LaTeX{LaTeX}%
5082  \do\TeX{TeX}%
5083  %
5084  % Assorted special characters.
5085  \do\atchar{@}%
5086  \do\arrow{->}%
5087  \do\bullet{bullet}%
5088  \do\comma{,}%
5089  \do\copyright{copyright}%
5090  \do\dots{...}%
5091  \do\enddots{...}%
5092  \do\equiv{==}%
5093  \do\error{error}%
5094  \do\euro{euro}%
5095  \do\expansion{==>}%
5096  \do\geq{>=}%
5097  \do\guillemetleft{<<}%
5098  \do\guillemetright{>>}%
5099  \do\guilsinglleft{<}%
5100  \do\guilsinglright{>}%
5101  \do\leq{<=}%
5102  \do\lbracechar{\{}%
5103  \do\minus{-}%
5104  \do\point{.}%
5105  \do\pounds{pounds}%
5106  \do\print{-|}%
5107  \do\quotedblbase{"}%
5108  \do\quotedblleft{"}%
5109  \do\quotedblright{"}%
5110  \do\quoteleft{`}%
5111  \do\quoteright{'}%
5112  \do\quotesinglbase{,}%
5113  \do\rbracechar{\}}%
5114  \do\registeredsymbol{R}%
5115  \do\result{=>}%
5116  \do\textdegree{o}%
5117  %
5118  % We need to get rid of all macros, leaving only the arguments (if present).
5119  % Of course this is not nearly correct, but it is the best we can do for now.
5120  % makeinfo does not expand macros in the argument to @deffn, which ends up
5121  % writing an index entry, and texindex isn't prepared for an index sort entry
5122  % that starts with \.
5123  %
5124  % Since macro invocations are followed by braces, we can just redefine them
5125  % to take a single TeX argument.  The case of a macro invocation that
5126  % goes to end-of-line is not handled.
5127  %
5128  \macrolist
5129  \let\value\indexnofontsvalue
5130}
5131
5132% Give the control sequence a definition that removes the {} that follows
5133% its use, e.g. @AA{} -> AA
5134\def\indexnofontsdef#1#2{\def#1##1{#2}}%
5135
5136
5137
5138
5139% #1 is the index name, #2 is the entry text.
5140\def\doind#1#2{%
5141  \iflinks
5142  {%
5143    %
5144    \requireopenindexfile{#1}%
5145    \edef\writeto{\csname#1indfile\endcsname}%
5146    %
5147    \def\indextext{#2}%
5148    \safewhatsit\doindwrite
5149  }%
5150  \fi
5151}
5152
5153% Same as \doind, but for code indices
5154\def\docind#1#2{%
5155  \iflinks
5156  {%
5157    %
5158    \requireopenindexfile{#1}%
5159    \edef\writeto{\csname#1indfile\endcsname}%
5160    %
5161    \def\indextext{#2}%
5162    \safewhatsit\docindwrite
5163  }%
5164  \fi
5165}
5166
5167% Check if an index file has been opened, and if not, open it.
5168\def\requireopenindexfile#1{%
5169\ifnum\csname #1indfile\endcsname=0
5170  \expandafter\newwrite \csname#1indfile\endcsname
5171  \edef\suffix{#1}%
5172  % A .fls suffix would conflict with the file extension for the output
5173  % of -recorder, so use .f1s instead.
5174  \ifx\suffix\indexisfl\def\suffix{f1}\fi
5175  % Open the file
5176  \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
5177  % Using \immediate above here prevents an object entering into the current
5178  % box, which could confound checks such as those in \safewhatsit for
5179  % preceding skips.
5180  \typeout{Writing index file \jobname.\suffix}%
5181\fi}
5182\def\indexisfl{fl}
5183
5184% Definition for writing index entry sort key.
5185{
5186\catcode`\-=13
5187\gdef\indexwritesortas{%
5188  \begingroup
5189  \indexnonalnumreappear
5190  \indexwritesortasxxx}
5191\gdef\indexwritesortasxxx#1{%
5192  \xdef\indexsortkey{#1}\endgroup}
5193}
5194
5195\def\indexwriteseealso#1{
5196  \gdef\pagenumbertext{\string\seealso{#1}}%
5197}
5198\def\indexwriteseeentry#1{
5199  \gdef\pagenumbertext{\string\seeentry{#1}}%
5200}
5201
5202% The default definitions
5203\def\sortas#1{}%
5204\def\seealso#1{\i{\putwordSeeAlso}\ #1}% for sorted index file only
5205\def\putwordSeeAlso{See also}
5206\def\seeentry#1{\i{\putwordSee}\ #1}% for sorted index file only
5207
5208
5209% Given index entry text like "aaa @subentry bbb @sortas{ZZZ}":
5210%   * Set \bracedtext to "{aaa}{bbb}"
5211%   * Set \fullindexsortkey to "aaa @subentry ZZZ"
5212%   * If @seealso occurs, set \pagenumbertext
5213%
5214\def\splitindexentry#1{%
5215  \gdef\fullindexsortkey{}%
5216  \xdef\bracedtext{}%
5217  \def\sep{}%
5218  \def\seealso##1{}%
5219  \def\seeentry##1{}%
5220  \expandafter\doindexsegment#1\subentry\finish\subentry
5221}
5222
5223% append the results from the next segment
5224\def\doindexsegment#1\subentry{%
5225  \def\segment{#1}%
5226  \ifx\segment\isfinish
5227  \else
5228    %
5229    % Fully expand the segment, throwing away any @sortas directives, and
5230    % trim spaces.
5231    \edef\trimmed{\segment}%
5232    \edef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
5233    \ifincodeindex
5234      \edef\trimmed{\noexpand\code{\trimmed}}%
5235    \fi
5236    %
5237    \xdef\bracedtext{\bracedtext{\trimmed}}%
5238    %
5239    % Get the string to sort by.  Process the segment with all
5240    % font commands turned off.
5241    \bgroup
5242      \let\sortas\indexwritesortas
5243      \let\seealso\indexwriteseealso
5244      \let\seeentry\indexwriteseeentry
5245      \indexnofonts
5246      % The braces around the commands are recognized by texindex.
5247      \def\lbracechar{{\string\indexlbrace}}%
5248      \def\rbracechar{{\string\indexrbrace}}%
5249      \let\{=\lbracechar
5250      \let\}=\rbracechar
5251      \def\@{{\string\indexatchar}}%
5252      \def\atchar##1{\@}%
5253      \def\backslashchar{{\string\indexbackslash}}%
5254      \uccode`\~=`\\ \uppercase{\let~\backslashchar}%
5255      %
5256      \let\indexsortkey\empty
5257      \global\let\pagenumbertext\empty
5258      % Execute the segment and throw away the typeset output.  This executes
5259      % any @sortas or @seealso commands in this segment.
5260      \setbox\dummybox = \hbox{\segment}%
5261      \ifx\indexsortkey\empty{%
5262        \indexnonalnumdisappear
5263        \xdef\trimmed{\segment}%
5264        \xdef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
5265        \xdef\indexsortkey{\trimmed}%
5266        \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
5267      }\fi
5268      %
5269      % Append to \fullindexsortkey.
5270      \edef\tmp{\gdef\noexpand\fullindexsortkey{%
5271                  \fullindexsortkey\sep\indexsortkey}}%
5272      \tmp
5273    \egroup
5274    \def\sep{\subentry}%
5275    %
5276    \expandafter\doindexsegment
5277  \fi
5278}
5279\def\isfinish{\finish}%
5280\newbox\dummybox % used above
5281
5282\let\subentry\relax
5283
5284% Use \ instead of @ in index files.  To support old texi2dvi and texindex.
5285% This works without changing the escape character used in the toc or aux
5286% files because the index entries are fully expanded here, and \string uses
5287% the current value of \escapechar.
5288\def\escapeisbackslash{\escapechar=`\\}
5289
5290% Use \ in index files by default.  texi2dvi didn't support @ as the escape
5291% character (as it checked for "\entry" in the files, and not "@entry").  When
5292% the new version of texi2dvi has had a chance to become more prevalent, then
5293% the escape character can change back to @ again.  This should be an easy
5294% change to make now because both @ and \ are only used as escape characters in
5295% index files, never standing for themselves.
5296%
5297\set txiindexescapeisbackslash
5298
5299% Write the entry in \indextext to the index file.
5300%
5301
5302\newif\ifincodeindex
5303\def\doindwrite{\incodeindexfalse\doindwritex}
5304\def\docindwrite{\incodeindextrue\doindwritex}
5305
5306\def\doindwritex{%
5307  \maybemarginindex
5308  %
5309  \atdummies
5310  %
5311  \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax\else
5312    \escapeisbackslash
5313  \fi
5314  %
5315  % For texindex which always views { and } as separators.
5316  \def\{{\lbracechar{}}%
5317  \def\}{\rbracechar{}}%
5318  \uccode`\~=`\\ \uppercase{\def~{\backslashchar{}}}%
5319  %
5320  % Split the entry into primary entry and any subentries, and get the index
5321  % sort key.
5322  \splitindexentry\indextext
5323  %
5324  % Set up the complete index entry, with both the sort key and
5325  % the original text, including any font commands.  We write
5326  % three arguments to \entry to the .?? file (four in the
5327  % subentry case), texindex reduces to two when writing the .??s
5328  % sorted result.
5329  %
5330  \edef\temp{%
5331    \write\writeto{%
5332      \string\entry{\fullindexsortkey}%
5333        {\ifx\pagenumbertext\empty\noexpand\folio\else\pagenumbertext\fi}%
5334        \bracedtext}%
5335  }%
5336  \temp
5337}
5338
5339% Put the index entry in the margin if desired (undocumented).
5340\def\maybemarginindex{%
5341  \ifx\SETmarginindex\relax\else
5342    \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \relax\indextext}}%
5343  \fi
5344}
5345\let\SETmarginindex=\relax
5346
5347
5348% Take care of unwanted page breaks/skips around a whatsit:
5349%
5350% If a skip is the last thing on the list now, preserve it
5351% by backing up by \lastskip, doing the \write, then inserting
5352% the skip again.  Otherwise, the whatsit generated by the
5353% \write or \pdfdest will make \lastskip zero.  The result is that
5354% sequences like this:
5355% @end defun
5356% @tindex whatever
5357% @defun ...
5358% will have extra space inserted, because the \medbreak in the
5359% start of the @defun won't see the skip inserted by the @end of
5360% the previous defun.
5361%
5362% But don't do any of this if we're not in vertical mode.  We
5363% don't want to do a \vskip and prematurely end a paragraph.
5364%
5365% Avoid page breaks due to these extra skips, too.
5366%
5367% But wait, there is a catch there:
5368% We'll have to check whether \lastskip is zero skip.  \ifdim is not
5369% sufficient for this purpose, as it ignores stretch and shrink parts
5370% of the skip.  The only way seems to be to check the textual
5371% representation of the skip.
5372%
5373% The following is almost like \def\zeroskipmacro{0.0pt} except that
5374% the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
5375%
5376\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
5377%
5378\newskip\whatsitskip
5379\newcount\whatsitpenalty
5380%
5381% ..., ready, GO:
5382%
5383\def\safewhatsit#1{\ifhmode
5384  #1%
5385 \else
5386  % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
5387  \whatsitskip = \lastskip
5388  \edef\lastskipmacro{\the\lastskip}%
5389  \whatsitpenalty = \lastpenalty
5390  %
5391  % If \lastskip is nonzero, that means the last item was a
5392  % skip.  And since a skip is discardable, that means this
5393  % -\whatsitskip glue we're inserting is preceded by a
5394  % non-discardable item, therefore it is not a potential
5395  % breakpoint, therefore no \nobreak needed.
5396  \ifx\lastskipmacro\zeroskipmacro
5397  \else
5398    \vskip-\whatsitskip
5399  \fi
5400  %
5401  #1%
5402  %
5403  \ifx\lastskipmacro\zeroskipmacro
5404    % If \lastskip was zero, perhaps the last item was a penalty, and
5405    % perhaps it was >=10000, e.g., a \nobreak.  In that case, we want
5406    % to re-insert the same penalty (values >10000 are used for various
5407    % signals); since we just inserted a non-discardable item, any
5408    % following glue (such as a \parskip) would be a breakpoint.  For example:
5409    %   @deffn deffn-whatever
5410    %   @vindex index-whatever
5411    %   Description.
5412    % would allow a break between the index-whatever whatsit
5413    % and the "Description." paragraph.
5414    \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
5415  \else
5416    % On the other hand, if we had a nonzero \lastskip,
5417    % this make-up glue would be preceded by a non-discardable item
5418    % (the whatsit from the \write), so we must insert a \nobreak.
5419    \nobreak\vskip\whatsitskip
5420  \fi
5421\fi}
5422
5423% The index entry written in the file actually looks like
5424%  \entry {sortstring}{page}{topic}
5425% or
5426%  \entry {sortstring}{page}{topic}{subtopic}
5427% The texindex program reads in these files and writes files
5428% containing these kinds of lines:
5429%  \initial {c}
5430%     before the first topic whose initial is c
5431%  \entry {topic}{pagelist}
5432%     for a topic that is used without subtopics
5433%  \primary {topic}
5434%  \entry {topic}{}
5435%     for the beginning of a topic that is used with subtopics
5436%  \secondary {subtopic}{pagelist}
5437%     for each subtopic.
5438%  \secondary {subtopic}{}
5439%     for a subtopic with sub-subtopics
5440%  \tertiary {subtopic}{subsubtopic}{pagelist}
5441%     for each sub-subtopic.
5442
5443% Define the user-accessible indexing commands
5444% @findex, @vindex, @kindex, @cindex.
5445
5446\def\findex {\fnindex}
5447\def\kindex {\kyindex}
5448\def\cindex {\cpindex}
5449\def\vindex {\vrindex}
5450\def\tindex {\tpindex}
5451\def\pindex {\pgindex}
5452
5453% Define the macros used in formatting output of the sorted index material.
5454
5455% @printindex causes a particular index (the ??s file) to get printed.
5456% It does not print any chapter heading (usually an @unnumbered).
5457%
5458\parseargdef\printindex{\begingroup
5459  \dobreak \chapheadingskip{10000}%
5460  %
5461  \smallfonts \rm
5462  \tolerance = 9500
5463  \plainfrenchspacing
5464  \everypar = {}% don't want the \kern\-parindent from indentation suppression.
5465  %
5466  % See comment in \requireopenindexfile.
5467  \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
5468  %
5469  % See if the index file exists and is nonempty.
5470  \openin 1 \jobname.\indexname s
5471  \ifeof 1
5472    % \enddoublecolumns gets confused if there is no text in the index,
5473    % and it loses the chapter title and the aux file entries for the
5474    % index.  The easiest way to prevent this problem is to make sure
5475    % there is some text.
5476    \putwordIndexNonexistent
5477    \typeout{No file \jobname.\indexname s.}%
5478  \else
5479    % If the index file exists but is empty, then \openin leaves \ifeof
5480    % false.  We have to make TeX try to read something from the file, so
5481    % it can discover if there is anything in it.
5482    \read 1 to \thisline
5483    \ifeof 1
5484      \putwordIndexIsEmpty
5485    \else
5486      \expandafter\printindexzz\thisline\relax\relax\finish%
5487    \fi
5488  \fi
5489  \closein 1
5490\endgroup}
5491
5492% If the index file starts with a backslash, forgo reading the index
5493% file altogether.  If somebody upgrades texinfo.tex they may still have
5494% old index files using \ as the escape character.  Reading this would
5495% at best lead to typesetting garbage, at worst a TeX syntax error.
5496\def\printindexzz#1#2\finish{%
5497  \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax
5498    \uccode`\~=`\\ \uppercase{\if\noexpand~}\noexpand#1
5499      \expandafter\ifx\csname SETtxiskipindexfileswithbackslash\endcsname\relax
5500\errmessage{%
5501ERROR: A sorted index file in an obsolete format was skipped.
5502To fix this problem, please upgrade your version of 'texi2dvi'
5503or 'texi2pdf' to that at <https://ftp.gnu.org/gnu/texinfo>.
5504If you are using an old version of 'texindex' (part of the Texinfo
5505distribution), you may also need to upgrade to a newer version (at least 6.0).
5506You may be able to typeset the index if you run
5507'texindex \jobname.\indexname' yourself.
5508You could also try setting the 'txiindexescapeisbackslash' flag by
5509running a command like
5510'texi2dvi -t "@set txiindexescapeisbackslash" \jobname.texi'.  If you do
5511this, Texinfo will try to use index files in the old format.
5512If you continue to have problems, deleting the index files and starting again
5513might help (with 'rm \jobname.?? \jobname.??s')%
5514}%
5515      \else
5516        (Skipped sorted index file in obsolete format)
5517      \fi
5518    \else
5519      \begindoublecolumns
5520      \input \jobname.\indexname s
5521      \enddoublecolumns
5522    \fi
5523  \else
5524    \begindoublecolumns
5525    \catcode`\\=0\relax
5526    %
5527    % Make @ an escape character to give macros a chance to work.  This
5528    % should work because we (hopefully) don't otherwise use @ in index files.
5529    %\catcode`\@=12\relax
5530    \catcode`\@=0\relax
5531    \input \jobname.\indexname s
5532    \enddoublecolumns
5533  \fi
5534}
5535
5536% These macros are used by the sorted index file itself.
5537% Change them to control the appearance of the index.
5538
5539{\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
5540\catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
5541\catcode`\$=3
5542\gdef\initialglyphs{%
5543  % special control sequences used in the index sort key
5544  \let\indexlbrace\{%
5545  \let\indexrbrace\}%
5546  \let\indexatchar\@%
5547  \def\indexbackslash{\math{\backslash}}%
5548  %
5549  % Some changes for non-alphabetic characters.  Using the glyphs from the
5550  % math fonts looks more consistent than the typewriter font used elsewhere
5551  % for these characters.
5552  \uccode`\~=`\\ \uppercase{\def~{\math{\backslash}}}
5553  %
5554  % In case @\ is used for backslash
5555  \uppercase{\let\\=~}
5556  % Can't get bold backslash so don't use bold forward slash
5557  \catcode`\/=13
5558  \def/{{\secrmnotbold \normalslash}}%
5559  \def-{{\normaldash\normaldash}}% en dash `--'
5560  \def^{{\chapbf \normalcaret}}%
5561  \def~{{\chapbf \normaltilde}}%
5562  \def\_{%
5563     \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
5564  \def|{$\vert$}%
5565  \def<{$\less$}%
5566  \def>{$\gtr$}%
5567  \def+{$\normalplus$}%
5568}}
5569
5570\def\initial{%
5571  \bgroup
5572  \initialglyphs
5573  \initialx
5574}
5575
5576\def\initialx#1{%
5577  % Remove any glue we may have, we'll be inserting our own.
5578  \removelastskip
5579  %
5580  % We like breaks before the index initials, so insert a bonus.
5581  % The glue before the bonus allows a little bit of space at the
5582  % bottom of a column to reduce an increase in inter-line spacing.
5583  \nobreak
5584  \vskip 0pt plus 5\baselineskip
5585  \penalty -300
5586  \vskip 0pt plus -5\baselineskip
5587  %
5588  % Typeset the initial.  Making this add up to a whole number of
5589  % baselineskips increases the chance of the dots lining up from column
5590  % to column.  It still won't often be perfect, because of the stretch
5591  % we need before each entry, but it's better.
5592  %
5593  % No shrink because it confuses \balancecolumns.
5594  \vskip 1.67\baselineskip plus 1\baselineskip
5595  \leftline{\secfonts \kern-0.05em \secbf #1}%
5596  % \secfonts is inside the argument of \leftline so that the change of
5597  % \baselineskip will not affect any glue inserted before the vbox that
5598  % \leftline creates.
5599  % Do our best not to break after the initial.
5600  \nobreak
5601  \vskip .33\baselineskip plus .1\baselineskip
5602  \egroup % \initialglyphs
5603}
5604
5605\newdimen\entryrightmargin
5606\entryrightmargin=0pt
5607
5608% \entry typesets a paragraph consisting of the text (#1), dot leaders, and
5609% then page number (#2) flushed to the right margin.  It is used for index
5610% and table of contents entries.  The paragraph is indented by \leftskip.
5611%
5612\def\entry{%
5613  \begingroup
5614    %
5615    % Start a new paragraph if necessary, so our assignments below can't
5616    % affect previous text.
5617    \par
5618    %
5619    % No extra space above this paragraph.
5620    \parskip = 0in
5621    %
5622    % When reading the text of entry, convert explicit line breaks
5623    % from @* into spaces.  The user might give these in long section
5624    % titles, for instance.
5625    \def\*{\unskip\space\ignorespaces}%
5626    \def\entrybreak{\hfil\break}% An undocumented command
5627    %
5628    % Swallow the left brace of the text (first parameter):
5629    \afterassignment\doentry
5630    \let\temp =
5631}
5632\def\entrybreak{\unskip\space\ignorespaces}%
5633\def\doentry{%
5634    % Save the text of the entry
5635    \global\setbox\boxA=\hbox\bgroup
5636    \bgroup % Instead of the swallowed brace.
5637      \noindent
5638      \aftergroup\finishentry
5639      % And now comes the text of the entry.
5640      % Not absorbing as a macro argument reduces the chance of problems
5641      % with catcodes occurring.
5642}
5643{\catcode`\@=11
5644\gdef\finishentry#1{%
5645    \egroup % end box A
5646    \dimen@ = \wd\boxA % Length of text of entry
5647    \global\setbox\boxA=\hbox\bgroup
5648      \unhbox\boxA
5649      % #1 is the page number.
5650      %
5651      % Get the width of the page numbers, and only use
5652      % leaders if they are present.
5653      \global\setbox\boxB = \hbox{#1}%
5654      \ifdim\wd\boxB = 0pt
5655        \null\nobreak\hfill\ %
5656      \else
5657        %
5658        \null\nobreak\indexdotfill % Have leaders before the page number.
5659        %
5660        \ifpdforxetex
5661          \pdfgettoks#1.%
5662          \hskip\skip\thinshrinkable\the\toksA
5663        \else
5664          \hskip\skip\thinshrinkable #1%
5665        \fi
5666      \fi
5667    \egroup % end \boxA
5668    \ifdim\wd\boxB = 0pt
5669      \noindent\unhbox\boxA\par
5670      \nobreak
5671    \else\bgroup
5672      % We want the text of the entries to be aligned to the left, and the
5673      % page numbers to be aligned to the right.
5674      %
5675      \parindent = 0pt
5676      \advance\leftskip by 0pt plus 1fil
5677      \advance\leftskip by 0pt plus -1fill
5678      \rightskip = 0pt plus -1fil
5679      \advance\rightskip by 0pt plus 1fill
5680      % Cause last line, which could consist of page numbers on their own
5681      % if the list of page numbers is long, to be aligned to the right.
5682      \parfillskip=0pt plus -1fill
5683      %
5684      \advance\rightskip by \entryrightmargin
5685      % Determine how far we can stretch into the margin.
5686      % This allows, e.g., "Appendix H  GNU Free Documentation License" to
5687      % fit on one line in @letterpaper format.
5688      \ifdim\entryrightmargin>2.1em
5689        \dimen@i=2.1em
5690      \else
5691        \dimen@i=0em
5692      \fi
5693      \advance \parfillskip by 0pt minus 1\dimen@i
5694      %
5695      \dimen@ii = \hsize
5696      \advance\dimen@ii by -1\leftskip
5697      \advance\dimen@ii by -1\entryrightmargin
5698      \advance\dimen@ii by 1\dimen@i
5699      \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
5700      \ifdim\dimen@ > 0.8\dimen@ii   % due to long index text
5701        % Try to split the text roughly evenly.  \dimen@ will be the length of
5702        % the first line.
5703        \dimen@ = 0.7\dimen@
5704        \dimen@ii = \hsize
5705        \ifnum\dimen@>\dimen@ii
5706          % If the entry is too long (for example, if it needs more than
5707          % two lines), use all the space in the first line.
5708          \dimen@ = \dimen@ii
5709        \fi
5710        \advance\leftskip by 0pt plus 1fill % ragged right
5711        \advance \dimen@ by 1\rightskip
5712        \parshape = 2 0pt \dimen@ 0em \dimen@ii
5713        % Ideally we'd add a finite glue at the end of the first line only,
5714        % instead of using \parshape with explicit line lengths, but TeX
5715        % doesn't seem to provide a way to do such a thing.
5716        %
5717        % Indent all lines but the first one.
5718        \advance\leftskip by 1em
5719        \advance\parindent by -1em
5720      \fi\fi
5721      \indent % start paragraph
5722      \unhbox\boxA
5723      %
5724      % Do not prefer a separate line ending with a hyphen to fewer lines.
5725      \finalhyphendemerits = 0
5726      %
5727      % Word spacing - no stretch
5728      \spaceskip=\fontdimen2\font minus \fontdimen4\font
5729      %
5730      \linepenalty=1000  % Discourage line breaks.
5731      \hyphenpenalty=5000  % Discourage hyphenation.
5732      %
5733      \par % format the paragraph
5734    \egroup % The \vbox
5735    \fi
5736  \endgroup
5737}}
5738
5739\newskip\thinshrinkable
5740\skip\thinshrinkable=.15em minus .15em
5741
5742% Like plain.tex's \dotfill, except uses up at least 1 em.
5743% The filll stretch here overpowers both the fil and fill stretch to push
5744% the page number to the right.
5745\def\indexdotfill{\cleaders
5746  \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
5747
5748
5749\def\primary #1{\line{#1\hfil}}
5750
5751\def\secondary{\indententry{0.5cm}}
5752\def\tertiary{\indententry{1cm}}
5753
5754\def\indententry#1#2#3{%
5755  \bgroup
5756  \leftskip=#1
5757  \entry{#2}{#3}%
5758  \egroup
5759}
5760
5761% Define two-column mode, which we use to typeset indexes.
5762% Adapted from the TeXbook, page 416, which is to say,
5763% the manmac.tex format used to print the TeXbook itself.
5764\catcode`\@=11  % private names
5765
5766\newbox\partialpage
5767\newdimen\doublecolumnhsize
5768
5769\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
5770  % If not much space left on page, start a new page.
5771  \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
5772  %
5773  % Grab any single-column material above us.
5774  \output = {%
5775    \savetopmark
5776    %
5777    \global\setbox\partialpage = \vbox{%
5778      % Unvbox the main output page.
5779      \unvbox\PAGE
5780      \kern-\topskip \kern\baselineskip
5781    }%
5782  }%
5783  \eject % run that output routine to set \partialpage
5784  %
5785  % Use the double-column output routine for subsequent pages.
5786  \output = {\doublecolumnout}%
5787  %
5788  % Change the page size parameters.  We could do this once outside this
5789  % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5790  % format, but then we repeat the same computation.  Repeating a couple
5791  % of assignments once per index is clearly meaningless for the
5792  % execution time, so we may as well do it in one place.
5793  %
5794  % First we halve the line length, less a little for the gutter between
5795  % the columns.  We compute the gutter based on the line length, so it
5796  % changes automatically with the paper format.  The magic constant
5797  % below is chosen so that the gutter has the same value (well, +-<1pt)
5798  % as it did when we hard-coded it.
5799  %
5800  % We put the result in a separate register, \doublecolumhsize, so we
5801  % can restore it in \pagesofar, after \hsize itself has (potentially)
5802  % been clobbered.
5803  %
5804  \doublecolumnhsize = \hsize
5805    \advance\doublecolumnhsize by -.04154\hsize
5806    \divide\doublecolumnhsize by 2
5807  \hsize = \doublecolumnhsize
5808  %
5809  % Get the available space for the double columns -- the normal
5810  % (undoubled) page height minus any material left over from the
5811  % previous page.
5812  \advance\vsize by -\ht\partialpage
5813  \vsize = 2\vsize
5814  %
5815  % For the benefit of balancing columns
5816  \advance\baselineskip by 0pt plus 0.5pt
5817}
5818
5819% The double-column output routine for all double-column pages except
5820% the last, which is done by \balancecolumns.
5821%
5822\def\doublecolumnout{%
5823  %
5824  \savetopmark
5825  \splittopskip=\topskip \splitmaxdepth=\maxdepth
5826  \dimen@ = \vsize
5827  \divide\dimen@ by 2
5828  %
5829  % box0 will be the left-hand column, box2 the right.
5830  \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@
5831  \global\advance\vsize by 2\ht\partialpage
5832  \onepageout\pagesofar % empty except for the first time we are called
5833  \unvbox\PAGE
5834  \penalty\outputpenalty
5835}
5836%
5837% Re-output the contents of the output page -- any previous material,
5838% followed by the two boxes we just split, in box0 and box2.
5839\def\pagesofar{%
5840  \unvbox\partialpage
5841  %
5842  \hsize = \doublecolumnhsize
5843  \wd0=\hsize \wd2=\hsize
5844  \hbox to\txipagewidth{\box0\hfil\box2}%
5845}
5846
5847
5848% Finished with double columns.
5849\def\enddoublecolumns{%
5850  % The following penalty ensures that the page builder is exercised
5851  % _before_ we change the output routine.  This is necessary in the
5852  % following situation:
5853  %
5854  % The last section of the index consists only of a single entry.
5855  % Before this section, \pagetotal is less than \pagegoal, so no
5856  % break occurs before the last section starts.  However, the last
5857  % section, consisting of \initial and the single \entry, does not
5858  % fit on the page and has to be broken off.  Without the following
5859  % penalty the page builder will not be exercised until \eject
5860  % below, and by that time we'll already have changed the output
5861  % routine to the \balancecolumns version, so the next-to-last
5862  % double-column page will be processed with \balancecolumns, which
5863  % is wrong:  The two columns will go to the main vertical list, with
5864  % the broken-off section in the recent contributions.  As soon as
5865  % the output routine finishes, TeX starts reconsidering the page
5866  % break.  The two columns and the broken-off section both fit on the
5867  % page, because the two columns now take up only half of the page
5868  % goal.  When TeX sees \eject from below which follows the final
5869  % section, it invokes the new output routine that we've set after
5870  % \balancecolumns below; \onepageout will try to fit the two columns
5871  % and the final section into the vbox of \txipageheight (see
5872  % \pagebody), causing an overfull box.
5873  %
5874  % Note that glue won't work here, because glue does not exercise the
5875  % page builder, unlike penalties (see The TeXbook, pp. 280-281).
5876  \penalty0
5877  %
5878  \output = {%
5879    % Split the last of the double-column material.
5880    \savetopmark
5881    \balancecolumns
5882  }%
5883  \eject % call the \output just set
5884  \ifdim\pagetotal=0pt
5885    % Having called \balancecolumns once, we do not
5886    % want to call it again.  Therefore, reset \output to its normal
5887    % definition right away.
5888    \global\output=\expandafter{\the\defaultoutput}
5889    %
5890    \endgroup % started in \begindoublecolumns
5891    % Leave the double-column material on the current page, no automatic
5892    % page break.
5893    \box\balancedcolumns
5894    %
5895    % \pagegoal was set to the doubled \vsize above, since we restarted
5896    % the current page.  We're now back to normal single-column
5897    % typesetting, so reset \pagegoal to the normal \vsize.
5898    \global\vsize = \txipageheight %
5899    \pagegoal = \txipageheight %
5900  \else
5901    % We had some left-over material.  This might happen when \doublecolumnout
5902    % is called in \balancecolumns.  Try again.
5903    \expandafter\enddoublecolumns
5904  \fi
5905}
5906\newbox\balancedcolumns
5907\setbox\balancedcolumns=\vbox{shouldnt see this}%
5908%
5909% Only called for the last of the double column material.  \doublecolumnout
5910% does the others.
5911\def\balancecolumns{%
5912  \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120.
5913  \dimen@ = \ht0
5914  \ifdim\dimen@<7\baselineskip
5915    % Don't split a short final column in two.
5916    \setbox2=\vbox{}%
5917    \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5918  \else
5919    % double the leading vertical space
5920    \advance\dimen@ by \topskip
5921    \advance\dimen@ by-\baselineskip
5922    \divide\dimen@ by 2 % target to split to
5923    \dimen@ii = \dimen@
5924    \splittopskip = \topskip
5925    % Loop until left column is at least as high as the right column.
5926    {%
5927      \vbadness = 10000
5928      \loop
5929        \global\setbox3 = \copy0
5930        \global\setbox1 = \vsplit3 to \dimen@
5931      \ifdim\ht1<\ht3
5932        \global\advance\dimen@ by 1pt
5933      \repeat
5934    }%
5935    % Now the left column is in box 1, and the right column in box 3.
5936    %
5937    % Check whether the left column has come out higher than the page itself.
5938    % (Note that we have doubled \vsize for the double columns, so
5939    % the actual height of the page is 0.5\vsize).
5940    \ifdim2\ht1>\vsize
5941      % It appears that we have been called upon to balance too much material.
5942      % Output some of it with \doublecolumnout, leaving the rest on the page.
5943      \setbox\PAGE=\box0
5944      \doublecolumnout
5945    \else
5946      % Compare the heights of the two columns.
5947      \ifdim4\ht1>5\ht3
5948        % Column heights are too different, so don't make their bottoms
5949        % flush with each other.
5950        \setbox2=\vbox to \ht1 {\unvbox3\vfill}%
5951        \setbox0=\vbox to \ht1 {\unvbox1\vfill}%
5952      \else
5953        % Make column bottoms flush with each other.
5954        \setbox2=\vbox to\ht1{\unvbox3\unskip}%
5955        \setbox0=\vbox to\ht1{\unvbox1\unskip}%
5956      \fi
5957      \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5958    \fi
5959  \fi
5960  %
5961}
5962\catcode`\@ = \other
5963
5964
5965\message{sectioning,}
5966% Chapters, sections, etc.
5967
5968% Let's start with @part.
5969\outer\parseargdef\part{\partzzz{#1}}
5970\def\partzzz#1{%
5971  \chapoddpage
5972  \null
5973  \vskip.3\vsize  % move it down on the page a bit
5974  \begingroup
5975    \noindent \titlefonts\rm #1\par % the text
5976    \let\lastnode=\empty      % no node to associate with
5977    \writetocentry{part}{#1}{}% but put it in the toc
5978    \headingsoff              % no headline or footline on the part page
5979    % This outputs a mark at the end of the page that clears \thischapter
5980    % and \thissection, as is done in \startcontents.
5981    \let\pchapsepmacro\relax
5982    \chapmacro{}{Yomitfromtoc}{}%
5983    \chapoddpage
5984  \endgroup
5985}
5986
5987% \unnumberedno is an oxymoron.  But we count the unnumbered
5988% sections so that we can refer to them unambiguously in the pdf
5989% outlines by their "section number".  We avoid collisions with chapter
5990% numbers by starting them at 10000.  (If a document ever has 10000
5991% chapters, we're in trouble anyway, I'm sure.)
5992\newcount\unnumberedno \unnumberedno = 10000
5993\newcount\chapno
5994\newcount\secno        \secno=0
5995\newcount\subsecno     \subsecno=0
5996\newcount\subsubsecno  \subsubsecno=0
5997
5998% This counter is funny since it counts through charcodes of letters A, B, ...
5999\newcount\appendixno  \appendixno = `\@
6000%
6001% \def\appendixletter{\char\the\appendixno}
6002% We do the following ugly conditional instead of the above simple
6003% construct for the sake of pdftex, which needs the actual
6004% letter in the expansion, not just typeset.
6005%
6006\def\appendixletter{%
6007  \ifnum\appendixno=`A A%
6008  \else\ifnum\appendixno=`B B%
6009  \else\ifnum\appendixno=`C C%
6010  \else\ifnum\appendixno=`D D%
6011  \else\ifnum\appendixno=`E E%
6012  \else\ifnum\appendixno=`F F%
6013  \else\ifnum\appendixno=`G G%
6014  \else\ifnum\appendixno=`H H%
6015  \else\ifnum\appendixno=`I I%
6016  \else\ifnum\appendixno=`J J%
6017  \else\ifnum\appendixno=`K K%
6018  \else\ifnum\appendixno=`L L%
6019  \else\ifnum\appendixno=`M M%
6020  \else\ifnum\appendixno=`N N%
6021  \else\ifnum\appendixno=`O O%
6022  \else\ifnum\appendixno=`P P%
6023  \else\ifnum\appendixno=`Q Q%
6024  \else\ifnum\appendixno=`R R%
6025  \else\ifnum\appendixno=`S S%
6026  \else\ifnum\appendixno=`T T%
6027  \else\ifnum\appendixno=`U U%
6028  \else\ifnum\appendixno=`V V%
6029  \else\ifnum\appendixno=`W W%
6030  \else\ifnum\appendixno=`X X%
6031  \else\ifnum\appendixno=`Y Y%
6032  \else\ifnum\appendixno=`Z Z%
6033  % The \the is necessary, despite appearances, because \appendixletter is
6034  % expanded while writing the .toc file.  \char\appendixno is not
6035  % expandable, thus it is written literally, thus all appendixes come out
6036  % with the same letter (or @) in the toc without it.
6037  \else\char\the\appendixno
6038  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
6039  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
6040
6041% Each @chapter defines these (using marks) as the number+name, number
6042% and name of the chapter.  Page headings and footings can use
6043% these.  @section does likewise.
6044\def\thischapter{}
6045\def\thischapternum{}
6046\def\thischaptername{}
6047\def\thissection{}
6048\def\thissectionnum{}
6049\def\thissectionname{}
6050
6051\newcount\absseclevel % used to calculate proper heading level
6052\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
6053
6054% @raisesections: treat @section as chapter, @subsection as section, etc.
6055\def\raisesections{\global\advance\secbase by -1}
6056
6057% @lowersections: treat @chapter as section, @section as subsection, etc.
6058\def\lowersections{\global\advance\secbase by 1}
6059
6060% we only have subsub.
6061\chardef\maxseclevel = 3
6062%
6063% A numbered section within an unnumbered changes to unnumbered too.
6064% To achieve this, remember the "biggest" unnum. sec. we are currently in:
6065\chardef\unnlevel = \maxseclevel
6066%
6067% Trace whether the current chapter is an appendix or not:
6068% \chapheadtype is "N" or "A", unnumbered chapters are ignored.
6069\def\chapheadtype{N}
6070
6071% Choose a heading macro
6072% #1 is heading type
6073% #2 is heading level
6074% #3 is text for heading
6075\def\genhead#1#2#3{%
6076  % Compute the abs. sec. level:
6077  \absseclevel=#2
6078  \advance\absseclevel by \secbase
6079  % Make sure \absseclevel doesn't fall outside the range:
6080  \ifnum \absseclevel < 0
6081    \absseclevel = 0
6082  \else
6083    \ifnum \absseclevel > 3
6084      \absseclevel = 3
6085    \fi
6086  \fi
6087  % The heading type:
6088  \def\headtype{#1}%
6089  \if \headtype U%
6090    \ifnum \absseclevel < \unnlevel
6091      \chardef\unnlevel = \absseclevel
6092    \fi
6093  \else
6094    % Check for appendix sections:
6095    \ifnum \absseclevel = 0
6096      \edef\chapheadtype{\headtype}%
6097    \else
6098      \if \headtype A\if \chapheadtype N%
6099	\errmessage{@appendix... within a non-appendix chapter}%
6100      \fi\fi
6101    \fi
6102    % Check for numbered within unnumbered:
6103    \ifnum \absseclevel > \unnlevel
6104      \def\headtype{U}%
6105    \else
6106      \chardef\unnlevel = 3
6107    \fi
6108  \fi
6109  % Now print the heading:
6110  \if \headtype U%
6111    \ifcase\absseclevel
6112	\unnumberedzzz{#3}%
6113    \or \unnumberedseczzz{#3}%
6114    \or \unnumberedsubseczzz{#3}%
6115    \or \unnumberedsubsubseczzz{#3}%
6116    \fi
6117  \else
6118    \if \headtype A%
6119      \ifcase\absseclevel
6120	  \appendixzzz{#3}%
6121      \or \appendixsectionzzz{#3}%
6122      \or \appendixsubseczzz{#3}%
6123      \or \appendixsubsubseczzz{#3}%
6124      \fi
6125    \else
6126      \ifcase\absseclevel
6127	  \chapterzzz{#3}%
6128      \or \seczzz{#3}%
6129      \or \numberedsubseczzz{#3}%
6130      \or \numberedsubsubseczzz{#3}%
6131      \fi
6132    \fi
6133  \fi
6134  \suppressfirstparagraphindent
6135}
6136
6137% an interface:
6138\def\numhead{\genhead N}
6139\def\apphead{\genhead A}
6140\def\unnmhead{\genhead U}
6141
6142% @chapter, @appendix, @unnumbered.  Increment top-level counter, reset
6143% all lower-level sectioning counters to zero.
6144%
6145% Also set \chaplevelprefix, which we prepend to @float sequence numbers
6146% (e.g., figures), q.v.  By default (before any chapter), that is empty.
6147\let\chaplevelprefix = \empty
6148%
6149\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
6150\def\chapterzzz#1{%
6151  % section resetting is \global in case the chapter is in a group, such
6152  % as an @include file.
6153  \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6154    \global\advance\chapno by 1
6155  %
6156  % Used for \float.
6157  \gdef\chaplevelprefix{\the\chapno.}%
6158  \resetallfloatnos
6159  %
6160  % \putwordChapter can contain complex things in translations.
6161  \toks0=\expandafter{\putwordChapter}%
6162  \message{\the\toks0 \space \the\chapno}%
6163  %
6164  % Write the actual heading.
6165  \chapmacro{#1}{Ynumbered}{\the\chapno}%
6166  %
6167  % So @section and the like are numbered underneath this chapter.
6168  \global\let\section = \numberedsec
6169  \global\let\subsection = \numberedsubsec
6170  \global\let\subsubsection = \numberedsubsubsec
6171}
6172
6173\outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
6174%
6175\def\appendixzzz#1{%
6176  \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6177    \global\advance\appendixno by 1
6178  \gdef\chaplevelprefix{\appendixletter.}%
6179  \resetallfloatnos
6180  %
6181  % \putwordAppendix can contain complex things in translations.
6182  \toks0=\expandafter{\putwordAppendix}%
6183  \message{\the\toks0 \space \appendixletter}%
6184  %
6185  \chapmacro{#1}{Yappendix}{\appendixletter}%
6186  %
6187  \global\let\section = \appendixsec
6188  \global\let\subsection = \appendixsubsec
6189  \global\let\subsubsection = \appendixsubsubsec
6190}
6191
6192% normally unnmhead0 calls unnumberedzzz:
6193\outer\parseargdef\unnumbered{\unnmhead0{#1}}
6194\def\unnumberedzzz#1{%
6195  \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6196    \global\advance\unnumberedno by 1
6197  %
6198  % Since an unnumbered has no number, no prefix for figures.
6199  \global\let\chaplevelprefix = \empty
6200  \resetallfloatnos
6201  %
6202  % This used to be simply \message{#1}, but TeX fully expands the
6203  % argument to \message.  Therefore, if #1 contained @-commands, TeX
6204  % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
6205  % expanded @cite (which turns out to cause errors because \cite is meant
6206  % to be executed, not expanded).
6207  %
6208  % Anyway, we don't want the fully-expanded definition of @cite to appear
6209  % as a result of the \message, we just want `@cite' itself.  We use
6210  % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6211  % simply yielding the contents of <toks register>.  (We also do this for
6212  % the toc entries.)
6213  \toks0 = {#1}%
6214  \message{(\the\toks0)}%
6215  %
6216  \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
6217  %
6218  \global\let\section = \unnumberedsec
6219  \global\let\subsection = \unnumberedsubsec
6220  \global\let\subsubsection = \unnumberedsubsubsec
6221}
6222
6223% @centerchap is like @unnumbered, but the heading is centered.
6224\outer\parseargdef\centerchap{%
6225  \let\centerparametersmaybe = \centerparameters
6226  \unnmhead0{#1}%
6227  \let\centerparametersmaybe = \relax
6228}
6229
6230% @top is like @unnumbered.
6231\let\top\unnumbered
6232
6233% Sections.
6234%
6235\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6236\def\seczzz#1{%
6237  \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6238  \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
6239}
6240
6241% normally calls appendixsectionzzz:
6242\outer\parseargdef\appendixsection{\apphead1{#1}}
6243\def\appendixsectionzzz#1{%
6244  \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6245  \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
6246}
6247\let\appendixsec\appendixsection
6248
6249% normally calls unnumberedseczzz:
6250\outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
6251\def\unnumberedseczzz#1{%
6252  \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6253  \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
6254}
6255
6256% Subsections.
6257%
6258% normally calls numberedsubseczzz:
6259\outer\parseargdef\numberedsubsec{\numhead2{#1}}
6260\def\numberedsubseczzz#1{%
6261  \global\subsubsecno=0  \global\advance\subsecno by 1
6262  \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
6263}
6264
6265% normally calls appendixsubseczzz:
6266\outer\parseargdef\appendixsubsec{\apphead2{#1}}
6267\def\appendixsubseczzz#1{%
6268  \global\subsubsecno=0  \global\advance\subsecno by 1
6269  \sectionheading{#1}{subsec}{Yappendix}%
6270                 {\appendixletter.\the\secno.\the\subsecno}%
6271}
6272
6273% normally calls unnumberedsubseczzz:
6274\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
6275\def\unnumberedsubseczzz#1{%
6276  \global\subsubsecno=0  \global\advance\subsecno by 1
6277  \sectionheading{#1}{subsec}{Ynothing}%
6278                 {\the\unnumberedno.\the\secno.\the\subsecno}%
6279}
6280
6281% Subsubsections.
6282%
6283% normally numberedsubsubseczzz:
6284\outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
6285\def\numberedsubsubseczzz#1{%
6286  \global\advance\subsubsecno by 1
6287  \sectionheading{#1}{subsubsec}{Ynumbered}%
6288                 {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
6289}
6290
6291% normally appendixsubsubseczzz:
6292\outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
6293\def\appendixsubsubseczzz#1{%
6294  \global\advance\subsubsecno by 1
6295  \sectionheading{#1}{subsubsec}{Yappendix}%
6296                 {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
6297}
6298
6299% normally unnumberedsubsubseczzz:
6300\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
6301\def\unnumberedsubsubseczzz#1{%
6302  \global\advance\subsubsecno by 1
6303  \sectionheading{#1}{subsubsec}{Ynothing}%
6304                 {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
6305}
6306
6307% These macros control what the section commands do, according
6308% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6309% Define them by default for a numbered chapter.
6310\let\section = \numberedsec
6311\let\subsection = \numberedsubsec
6312\let\subsubsection = \numberedsubsubsec
6313
6314% Define @majorheading, @heading and @subheading
6315
6316\def\majorheading{%
6317  {\advance\chapheadingskip by 10pt \chapbreak }%
6318  \parsearg\chapheadingzzz
6319}
6320
6321\def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6322\def\chapheadingzzz#1{%
6323  \vbox{\chapfonts \raggedtitlesettings #1\par}%
6324  \nobreak\bigskip \nobreak
6325  \suppressfirstparagraphindent
6326}
6327
6328% @heading, @subheading, @subsubheading.
6329\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6330  \suppressfirstparagraphindent}
6331\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6332  \suppressfirstparagraphindent}
6333\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6334  \suppressfirstparagraphindent}
6335
6336% These macros generate a chapter, section, etc. heading only
6337% (including whitespace, linebreaking, etc. around it),
6338% given all the information in convenient, parsed form.
6339
6340% Args are the skip and penalty (usually negative)
6341\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6342
6343% Parameter controlling skip before chapter headings (if needed)
6344\newskip\chapheadingskip
6345
6346% Define plain chapter starts, and page on/off switching for it.
6347\def\chapbreak{\dobreak \chapheadingskip {-4000}}
6348
6349% Start a new page
6350\def\chappager{\par\vfill\supereject}
6351
6352% \chapoddpage - start on an odd page for a new chapter
6353% Because \domark is called before \chapoddpage, the filler page will
6354% get the headings for the next chapter, which is wrong.  But we don't
6355% care -- we just disable all headings on the filler page.
6356\def\chapoddpage{%
6357  \chappager
6358  \ifodd\pageno \else
6359    \begingroup
6360      \headingsoff
6361      \null
6362      \chappager
6363    \endgroup
6364  \fi
6365}
6366
6367\parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
6368
6369\def\CHAPPAGoff{%
6370\global\let\contentsalignmacro = \chappager
6371\global\let\pchapsepmacro=\chapbreak
6372\global\def\HEADINGSon{\HEADINGSsinglechapoff}}
6373
6374\def\CHAPPAGon{%
6375\global\let\contentsalignmacro = \chappager
6376\global\let\pchapsepmacro=\chappager
6377\global\def\HEADINGSon{\HEADINGSsingle}}
6378
6379\def\CHAPPAGodd{%
6380\global\let\contentsalignmacro = \chapoddpage
6381\global\let\pchapsepmacro=\chapoddpage
6382\global\def\HEADINGSon{\HEADINGSdouble}}
6383
6384\CHAPPAGon
6385
6386% \chapmacro - Chapter opening.
6387%
6388% #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6389% Yappendix, Yomitfromtoc), #3 the chapter number.
6390% Not used for @heading series.
6391%
6392% To test against our argument.
6393\def\Ynothingkeyword{Ynothing}
6394\def\Yappendixkeyword{Yappendix}
6395\def\Yomitfromtockeyword{Yomitfromtoc}
6396%
6397\def\chapmacro#1#2#3{%
6398  \expandafter\ifx\thisenv\titlepage\else
6399    \checkenv{}% chapters, etc., should not start inside an environment.
6400  \fi
6401  % Insert the first mark before the heading break (see notes for \domark).
6402  \let\prevchapterdefs=\currentchapterdefs
6403  \let\prevsectiondefs=\currentsectiondefs
6404  \gdef\currentsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6405                        \gdef\thissection{}}%
6406  %
6407  \def\temptype{#2}%
6408  \ifx\temptype\Ynothingkeyword
6409    \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6410                          \gdef\thischapter{\thischaptername}}%
6411  \else\ifx\temptype\Yomitfromtockeyword
6412    \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6413                          \gdef\thischapter{}}%
6414  \else\ifx\temptype\Yappendixkeyword
6415    \toks0={#1}%
6416    \xdef\currentchapterdefs{%
6417      \gdef\noexpand\thischaptername{\the\toks0}%
6418      \gdef\noexpand\thischapternum{\appendixletter}%
6419      % \noexpand\putwordAppendix avoids expanding indigestible
6420      % commands in some of the translations.
6421      \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
6422                                 \noexpand\thischapternum:
6423                                 \noexpand\thischaptername}%
6424    }%
6425  \else
6426    \toks0={#1}%
6427    \xdef\currentchapterdefs{%
6428      \gdef\noexpand\thischaptername{\the\toks0}%
6429      \gdef\noexpand\thischapternum{\the\chapno}%
6430      % \noexpand\putwordChapter avoids expanding indigestible
6431      % commands in some of the translations.
6432      \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
6433                                 \noexpand\thischapternum:
6434                                 \noexpand\thischaptername}%
6435    }%
6436  \fi\fi\fi
6437  %
6438  % Output the mark.  Pass it through \safewhatsit, to take care of
6439  % the preceding space.
6440  \safewhatsit\domark
6441  %
6442  % Insert the chapter heading break.
6443  \pchapsepmacro
6444  %
6445  % Now the second mark, after the heading break.  No break points
6446  % between here and the heading.
6447  \let\prevchapterdefs=\currentchapterdefs
6448  \let\prevsectiondefs=\currentsectiondefs
6449  \domark
6450  %
6451  {%
6452    \chapfonts \rm
6453    \let\footnote=\errfootnoteheading % give better error message
6454    %
6455    % Have to define \currentsection before calling \donoderef, because the
6456    % xref code eventually uses it.  On the other hand, it has to be called
6457    % after \pchapsepmacro, or the headline will change too soon.
6458    \gdef\currentsection{#1}%
6459    %
6460    % Only insert the separating space if we have a chapter/appendix
6461    % number, and don't print the unnumbered ``number''.
6462    \ifx\temptype\Ynothingkeyword
6463      \setbox0 = \hbox{}%
6464      \def\toctype{unnchap}%
6465    \else\ifx\temptype\Yomitfromtockeyword
6466      \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6467      \def\toctype{omit}%
6468    \else\ifx\temptype\Yappendixkeyword
6469      \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6470      \def\toctype{app}%
6471    \else
6472      \setbox0 = \hbox{#3\enspace}%
6473      \def\toctype{numchap}%
6474    \fi\fi\fi
6475    %
6476    % Write the toc entry for this chapter.  Must come before the
6477    % \donoderef, because we include the current node name in the toc
6478    % entry, and \donoderef resets it to empty.
6479    \writetocentry{\toctype}{#1}{#3}%
6480    %
6481    % For pdftex, we have to write out the node definition (aka, make
6482    % the pdfdest) after any page break, but before the actual text has
6483    % been typeset.  If the destination for the pdf outline is after the
6484    % text, then jumping from the outline may wind up with the text not
6485    % being visible, for instance under high magnification.
6486    \donoderef{#2}%
6487    %
6488    % Typeset the actual heading.
6489    \nobreak % Avoid page breaks at the interline glue.
6490    \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
6491          \unhbox0 #1\par}%
6492  }%
6493  \nobreak\bigskip % no page break after a chapter title
6494  \nobreak
6495}
6496
6497% @centerchap -- centered and unnumbered.
6498\let\centerparametersmaybe = \relax
6499\def\centerparameters{%
6500  \advance\rightskip by 3\rightskip
6501  \leftskip = \rightskip
6502  \parfillskip = 0pt
6503}
6504
6505
6506% Section titles.  These macros combine the section number parts and
6507% call the generic \sectionheading to do the printing.
6508%
6509\newskip\secheadingskip
6510\def\secheadingbreak{\dobreak \secheadingskip{-1000}}
6511
6512% Subsection titles.
6513\newskip\subsecheadingskip
6514\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
6515
6516% Subsubsection titles.
6517\def\subsubsecheadingskip{\subsecheadingskip}
6518\def\subsubsecheadingbreak{\subsecheadingbreak}
6519
6520
6521% Print any size, any type, section title.
6522%
6523% #1 is the text of the title,
6524% #2 is the section level (sec/subsec/subsubsec),
6525% #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6526% #4 is the section number.
6527%
6528\def\seckeyword{sec}
6529%
6530\def\sectionheading#1#2#3#4{%
6531  {%
6532    \def\sectionlevel{#2}%
6533    \def\temptype{#3}%
6534    %
6535    % It is ok for the @heading series commands to appear inside an
6536    % environment (it's been historically allowed, though the logic is
6537    % dubious), but not the others.
6538    \ifx\temptype\Yomitfromtockeyword\else
6539      \checkenv{}% non-@*heading should not be in an environment.
6540    \fi
6541    \let\footnote=\errfootnoteheading
6542    %
6543    % Switch to the right set of fonts.
6544    \csname #2fonts\endcsname \rm
6545    %
6546    % Insert first mark before the heading break (see notes for \domark).
6547    \let\prevsectiondefs=\currentsectiondefs
6548    \ifx\temptype\Ynothingkeyword
6549      \ifx\sectionlevel\seckeyword
6550        \gdef\currentsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6551                              \gdef\thissection{\thissectionname}}%
6552      \fi
6553    \else\ifx\temptype\Yomitfromtockeyword
6554      % Don't redefine \thissection.
6555    \else\ifx\temptype\Yappendixkeyword
6556      \ifx\sectionlevel\seckeyword
6557        \toks0={#1}%
6558        \xdef\currentsectiondefs{%
6559          \gdef\noexpand\thissectionname{\the\toks0}%
6560          \gdef\noexpand\thissectionnum{#4}%
6561          % \noexpand\putwordSection avoids expanding indigestible
6562          % commands in some of the translations.
6563          \gdef\noexpand\thissection{\noexpand\putwordSection{}
6564                                     \noexpand\thissectionnum:
6565                                     \noexpand\thissectionname}%
6566        }%
6567      \fi
6568    \else
6569      \ifx\sectionlevel\seckeyword
6570        \toks0={#1}%
6571        \xdef\currentsectiondefs{%
6572          \gdef\noexpand\thissectionname{\the\toks0}%
6573          \gdef\noexpand\thissectionnum{#4}%
6574          % \noexpand\putwordSection avoids expanding indigestible
6575          % commands in some of the translations.
6576          \gdef\noexpand\thissection{\noexpand\putwordSection{}
6577                                     \noexpand\thissectionnum:
6578                                     \noexpand\thissectionname}%
6579        }%
6580      \fi
6581    \fi\fi\fi
6582    %
6583    % Go into vertical mode.  Usually we'll already be there, but we
6584    % don't want the following whatsit to end up in a preceding paragraph
6585    % if the document didn't happen to have a blank line.
6586    \par
6587    %
6588    % Output the mark.  Pass it through \safewhatsit, to take care of
6589    % the preceding space.
6590    \safewhatsit\domark
6591    %
6592    % Insert space above the heading.
6593    \csname #2headingbreak\endcsname
6594    %
6595    % Now the second mark, after the heading break.  No break points
6596    % between here and the heading.
6597    \global\let\prevsectiondefs=\currentsectiondefs
6598    \domark
6599    %
6600    % Only insert the space after the number if we have a section number.
6601    \ifx\temptype\Ynothingkeyword
6602      \setbox0 = \hbox{}%
6603      \def\toctype{unn}%
6604      \gdef\currentsection{#1}%
6605    \else\ifx\temptype\Yomitfromtockeyword
6606      % for @headings -- no section number, don't include in toc,
6607      % and don't redefine \currentsection.
6608      \setbox0 = \hbox{}%
6609      \def\toctype{omit}%
6610      \let\sectionlevel=\empty
6611    \else\ifx\temptype\Yappendixkeyword
6612      \setbox0 = \hbox{#4\enspace}%
6613      \def\toctype{app}%
6614      \gdef\currentsection{#1}%
6615    \else
6616      \setbox0 = \hbox{#4\enspace}%
6617      \def\toctype{num}%
6618      \gdef\currentsection{#1}%
6619    \fi\fi\fi
6620    %
6621    % Write the toc entry (before \donoderef).  See comments in \chapmacro.
6622    \writetocentry{\toctype\sectionlevel}{#1}{#4}%
6623    %
6624    % Write the node reference (= pdf destination for pdftex).
6625    % Again, see comments in \chapmacro.
6626    \donoderef{#3}%
6627    %
6628    % Interline glue will be inserted when the vbox is completed.
6629    % That glue will be a valid breakpoint for the page, since it'll be
6630    % preceded by a whatsit (usually from the \donoderef, or from the
6631    % \writetocentry if there was no node).  We don't want to allow that
6632    % break, since then the whatsits could end up on page n while the
6633    % section is on page n+1, thus toc/etc. are wrong.  Debian bug 276000.
6634    \nobreak
6635    %
6636    % Output the actual section heading.
6637    \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
6638          \hangindent=\wd0  % zero if no section number
6639          \unhbox0 #1}%
6640  }%
6641  % Add extra space after the heading -- half of whatever came above it.
6642  % Don't allow stretch, though.
6643  \kern .5 \csname #2headingskip\endcsname
6644  %
6645  % Do not let the kern be a potential breakpoint, as it would be if it
6646  % was followed by glue.
6647  \nobreak
6648  %
6649  % We'll almost certainly start a paragraph next, so don't let that
6650  % glue accumulate.  (Not a breakpoint because it's preceded by a
6651  % discardable item.)  However, when a paragraph is not started next
6652  % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6653  % or the negative glue will cause weirdly wrong output, typically
6654  % obscuring the section heading with something else.
6655  \vskip-\parskip
6656  %
6657  % This is so the last item on the main vertical list is a known
6658  % \penalty > 10000, so \startdefun, etc., can recognize the situation
6659  % and do the needful.
6660  \penalty 10001
6661}
6662
6663
6664\message{toc,}
6665% Table of contents.
6666\newwrite\tocfile
6667
6668% Write an entry to the toc file, opening it if necessary.
6669% Called from @chapter, etc.
6670%
6671% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6672% We append the current node name (if any) and page number as additional
6673% arguments for the \{chap,sec,...}entry macros which will eventually
6674% read this.  The node name is used in the pdf outlines as the
6675% destination to jump to.
6676%
6677% We open the .toc file for writing here instead of at @setfilename (or
6678% any other fixed time) so that @contents can be anywhere in the document.
6679% But if #1 is `omit', then we don't do anything.  This is used for the
6680% table of contents chapter openings themselves.
6681%
6682\newif\iftocfileopened
6683\def\omitkeyword{omit}%
6684%
6685\def\writetocentry#1#2#3{%
6686  \edef\writetoctype{#1}%
6687  \ifx\writetoctype\omitkeyword \else
6688    \iftocfileopened\else
6689      \immediate\openout\tocfile = \jobname.toc
6690      \global\tocfileopenedtrue
6691    \fi
6692    %
6693    \iflinks
6694      {\atdummies
6695       \edef\temp{%
6696         \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6697       \temp
6698      }%
6699    \fi
6700  \fi
6701  %
6702  % Tell \shipout to create a pdf destination on each page, if we're
6703  % writing pdf.  These are used in the table of contents.  We can't
6704  % just write one on every page because the title pages are numbered
6705  % 1 and 2 (the page numbers aren't printed), and so are the first
6706  % two pages of the document.  Thus, we'd have two destinations named
6707  % `1', and two named `2'.
6708  \ifpdforxetex
6709    \global\pdfmakepagedesttrue
6710  \fi
6711}
6712
6713
6714% These characters do not print properly in the Computer Modern roman
6715% fonts, so we must take special care.  This is more or less redundant
6716% with the Texinfo input format setup at the end of this file.
6717%
6718\def\activecatcodes{%
6719  \catcode`\"=\active
6720  \catcode`\$=\active
6721  \catcode`\<=\active
6722  \catcode`\>=\active
6723  \catcode`\\=\active
6724  \catcode`\^=\active
6725  \catcode`\_=\active
6726  \catcode`\|=\active
6727  \catcode`\~=\active
6728}
6729
6730
6731% Read the toc file, which is essentially Texinfo input.
6732\def\readtocfile{%
6733  \setupdatafile
6734  \activecatcodes
6735  \input \tocreadfilename
6736}
6737
6738\newskip\contentsrightmargin \contentsrightmargin=1in
6739\newcount\savepageno
6740\newcount\lastnegativepageno \lastnegativepageno = -1
6741
6742% Prepare to read what we've written to \tocfile.
6743%
6744\def\startcontents#1{%
6745  % If @setchapternewpage on, and @headings double, the contents should
6746  % start on an odd page, unlike chapters.
6747  \contentsalignmacro
6748  \immediate\closeout\tocfile
6749  %
6750  % Don't need to put `Contents' or `Short Contents' in the headline.
6751  % It is abundantly clear what they are.
6752  \chapmacro{#1}{Yomitfromtoc}{}%
6753  %
6754  \savepageno = \pageno
6755  \begingroup                  % Set up to handle contents files properly.
6756    \raggedbottom              % Worry more about breakpoints than the bottom.
6757    \entryrightmargin=\contentsrightmargin % Don't use the full line length.
6758    %
6759    % Roman numerals for page numbers.
6760    \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
6761    \def\thistitle{}% no title in double-sided headings
6762    % Record where the Roman numerals started.
6763    \ifnum\romancount=0 \global\romancount=\pagecount \fi
6764}
6765
6766% redefined for the two-volume lispref.  We always output on
6767% \jobname.toc even if this is redefined.
6768%
6769\def\tocreadfilename{\jobname.toc}
6770
6771% Normal (long) toc.
6772%
6773\def\contents{%
6774  \startcontents{\putwordTOC}%
6775    \openin 1 \tocreadfilename\space
6776    \ifeof 1 \else
6777      \readtocfile
6778    \fi
6779    \vfill \eject
6780    \contentsalignmacro % in case @setchapternewpage odd is in effect
6781    \ifeof 1 \else
6782      \pdfmakeoutlines
6783    \fi
6784    \closein 1
6785  \endgroup
6786  \contentsendroman
6787}
6788
6789% And just the chapters.
6790\def\summarycontents{%
6791  \startcontents{\putwordShortTOC}%
6792    %
6793    \let\partentry = \shortpartentry
6794    \let\numchapentry = \shortchapentry
6795    \let\appentry = \shortchapentry
6796    \let\unnchapentry = \shortunnchapentry
6797    % We want a true roman here for the page numbers.
6798    \secfonts
6799    \let\rm=\shortcontrm \let\bf=\shortcontbf
6800    \let\sl=\shortcontsl \let\tt=\shortconttt
6801    \rm
6802    \hyphenpenalty = 10000
6803    \advance\baselineskip by 1pt % Open it up a little.
6804    \def\numsecentry##1##2##3##4{}
6805    \let\appsecentry = \numsecentry
6806    \let\unnsecentry = \numsecentry
6807    \let\numsubsecentry = \numsecentry
6808    \let\appsubsecentry = \numsecentry
6809    \let\unnsubsecentry = \numsecentry
6810    \let\numsubsubsecentry = \numsecentry
6811    \let\appsubsubsecentry = \numsecentry
6812    \let\unnsubsubsecentry = \numsecentry
6813    \openin 1 \tocreadfilename\space
6814    \ifeof 1 \else
6815      \readtocfile
6816    \fi
6817    \closein 1
6818    \vfill \eject
6819    \contentsalignmacro % in case @setchapternewpage odd is in effect
6820  \endgroup
6821  \contentsendroman
6822}
6823\let\shortcontents = \summarycontents
6824
6825% Get ready to use Arabic numerals again
6826\def\contentsendroman{%
6827  \lastnegativepageno = \pageno
6828  \global\pageno = \savepageno
6829  %
6830  % If \romancount > \arabiccount, the contents are at the end of the
6831  % document.  Otherwise, advance where the Arabic numerals start for
6832  % the page numbers.
6833  \ifnum\romancount>\arabiccount\else\global\arabiccount=\pagecount\fi
6834}
6835
6836% Typeset the label for a chapter or appendix for the short contents.
6837% The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6838%
6839\def\shortchaplabel#1{%
6840  % This space should be enough, since a single number is .5em, and the
6841  % widest letter (M) is 1em, at least in the Computer Modern fonts.
6842  % But use \hss just in case.
6843  % (This space doesn't include the extra space that gets added after
6844  % the label; that gets put in by \shortchapentry above.)
6845  %
6846  % We'd like to right-justify chapter numbers, but that looks strange
6847  % with appendix letters.  And right-justifying numbers and
6848  % left-justifying letters looks strange when there is less than 10
6849  % chapters.  Have to read the whole toc once to know how many chapters
6850  % there are before deciding ...
6851  \hbox to 1em{#1\hss}%
6852}
6853
6854% These macros generate individual entries in the table of contents.
6855% The first argument is the chapter or section name.
6856% The last argument is the page number.
6857% The arguments in between are the chapter number, section number, ...
6858
6859% Parts, in the main contents.  Replace the part number, which doesn't
6860% exist, with an empty box.  Let's hope all the numbers have the same width.
6861% Also ignore the page number, which is conventionally not printed.
6862\def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6863\def\partentry#1#2#3#4{%
6864  % Add stretch and a bonus for breaking the page before the part heading.
6865  % This reduces the chance of the page being broken immediately after the
6866  % part heading, before a following chapter heading.
6867  \vskip 0pt plus 5\baselineskip
6868  \penalty-300
6869  \vskip 0pt plus -5\baselineskip
6870  \dochapentry{\numeralbox\labelspace#1}{}%
6871}
6872%
6873% Parts, in the short toc.
6874\def\shortpartentry#1#2#3#4{%
6875  \penalty-300
6876  \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
6877  \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
6878}
6879
6880% Chapters, in the main contents.
6881\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
6882
6883% Chapters, in the short toc.
6884% See comments in \dochapentry re vbox and related settings.
6885\def\shortchapentry#1#2#3#4{%
6886  \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
6887}
6888
6889% Appendices, in the main contents.
6890% Need the word Appendix, and a fixed-size box.
6891%
6892\def\appendixbox#1{%
6893  % We use M since it's probably the widest letter.
6894  \setbox0 = \hbox{\putwordAppendix{} M}%
6895  \hbox to \wd0{\putwordAppendix{} #1\hss}}
6896%
6897\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
6898
6899% Unnumbered chapters.
6900\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
6901\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
6902
6903% Sections.
6904\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
6905\let\appsecentry=\numsecentry
6906\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
6907
6908% Subsections.
6909\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
6910\let\appsubsecentry=\numsubsecentry
6911\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
6912
6913% And subsubsections.
6914\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
6915\let\appsubsubsecentry=\numsubsubsecentry
6916\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
6917
6918% This parameter controls the indentation of the various levels.
6919% Same as \defaultparindent.
6920\newdimen\tocindent \tocindent = 15pt
6921
6922% Now for the actual typesetting. In all these, #1 is the text and #2 is the
6923% page number.
6924%
6925% If the toc has to be broken over pages, we want it to be at chapters
6926% if at all possible; hence the \penalty.
6927\def\dochapentry#1#2{%
6928   \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
6929   \begingroup
6930     % Move the page numbers slightly to the right
6931     \advance\entryrightmargin by -0.05em
6932     \chapentryfonts
6933     \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6934   \endgroup
6935   \nobreak\vskip .25\baselineskip plus.1\baselineskip
6936}
6937
6938\def\dosecentry#1#2{\begingroup
6939  \secentryfonts \leftskip=\tocindent
6940  \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6941\endgroup}
6942
6943\def\dosubsecentry#1#2{\begingroup
6944  \subsecentryfonts \leftskip=2\tocindent
6945  \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6946\endgroup}
6947
6948\def\dosubsubsecentry#1#2{\begingroup
6949  \subsubsecentryfonts \leftskip=3\tocindent
6950  \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6951\endgroup}
6952
6953% We use the same \entry macro as for the index entries.
6954\let\tocentry = \entry
6955
6956% Space between chapter (or whatever) number and the title.
6957\def\labelspace{\hskip1em \relax}
6958
6959\def\dopageno#1{{\rm #1}}
6960\def\doshortpageno#1{{\rm #1}}
6961
6962\def\chapentryfonts{\secfonts \rm}
6963\def\secentryfonts{\textfonts}
6964\def\subsecentryfonts{\textfonts}
6965\def\subsubsecentryfonts{\textfonts}
6966
6967
6968\message{environments,}
6969% @foo ... @end foo.
6970
6971% @tex ... @end tex    escapes into raw TeX temporarily.
6972% One exception: @ is still an escape character, so that @end tex works.
6973% But \@ or @@ will get a plain @ character.
6974
6975\envdef\tex{%
6976  \setregularquotes
6977  \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
6978  \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
6979  \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
6980  \catcode `\%=14
6981  \catcode `\+=\other
6982  \catcode `\"=\other
6983  \catcode `\|=\other
6984  \catcode `\<=\other
6985  \catcode `\>=\other
6986  \catcode `\`=\other
6987  \catcode `\'=\other
6988  %
6989  % ' is active in math mode (mathcode"8000).  So reset it, and all our
6990  % other math active characters (just in case), to plain's definitions.
6991  \mathactive
6992  %
6993  % Inverse of the list at the beginning of the file.
6994  \let\b=\ptexb
6995  \let\bullet=\ptexbullet
6996  \let\c=\ptexc
6997  \let\,=\ptexcomma
6998  \let\.=\ptexdot
6999  \let\dots=\ptexdots
7000  \let\equiv=\ptexequiv
7001  \let\!=\ptexexclam
7002  \let\i=\ptexi
7003  \let\indent=\ptexindent
7004  \let\noindent=\ptexnoindent
7005  \let\{=\ptexlbrace
7006  \let\+=\tabalign
7007  \let\}=\ptexrbrace
7008  \let\/=\ptexslash
7009  \let\sp=\ptexsp
7010  \let\*=\ptexstar
7011  %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
7012  \let\t=\ptext
7013  \expandafter \let\csname top\endcsname=\ptextop  % we've made it outer
7014  \let\frenchspacing=\plainfrenchspacing
7015  %
7016  \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
7017  \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
7018  \def\@{@}%
7019}
7020% There is no need to define \Etex.
7021
7022% Define @lisp ... @end lisp.
7023% @lisp environment forms a group so it can rebind things,
7024% including the definition of @end lisp (which normally is erroneous).
7025
7026% Amount to narrow the margins by for @lisp.
7027\newskip\lispnarrowing \lispnarrowing=0.4in
7028
7029% This is the definition that ^^M gets inside @lisp, @example, and other
7030% such environments.  \null is better than a space, since it doesn't
7031% have any width.
7032\def\lisppar{\null\endgraf}
7033
7034% This space is always present above and below environments.
7035\newskip\envskipamount \envskipamount = 0pt
7036
7037% Make spacing and below environment symmetrical.  We use \parskip here
7038% to help in doing that, since in @example-like environments \parskip
7039% is reset to zero; thus the \afterenvbreak inserts no space -- but the
7040% start of the next paragraph will insert \parskip.
7041%
7042\def\aboveenvbreak{{%
7043  % =10000 instead of <10000 because of a special case in \itemzzz and
7044  % \sectionheading, q.v.
7045  \ifnum \lastpenalty=10000 \else
7046    \advance\envskipamount by \parskip
7047    \endgraf
7048    \ifdim\lastskip<\envskipamount
7049      \removelastskip
7050      \ifnum\lastpenalty<10000
7051        % Penalize breaking before the environment, because preceding text
7052        % often leads into it.
7053        \penalty100
7054      \fi
7055      \vskip\envskipamount
7056    \fi
7057  \fi
7058}}
7059
7060\def\afterenvbreak{{%
7061  % =10000 instead of <10000 because of a special case in \itemzzz and
7062  % \sectionheading, q.v.
7063  \ifnum \lastpenalty=10000 \else
7064    \advance\envskipamount by \parskip
7065    \endgraf
7066    \ifdim\lastskip<\envskipamount
7067      \removelastskip
7068      % it's not a good place to break if the last penalty was \nobreak
7069      % or better ...
7070      \ifnum\lastpenalty<10000 \penalty-50 \fi
7071      \vskip\envskipamount
7072    \fi
7073  \fi
7074}}
7075
7076% \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins; it will
7077% also clear it, so that its embedded environments do the narrowing again.
7078\let\nonarrowing=\relax
7079
7080% @cartouche ... @end cartouche: draw rectangle w/rounded corners around
7081% environment contents.
7082
7083%
7084\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
7085\def\ctr{{\hskip 6pt\circle\char'010}}
7086\def\cbl{{\circle\char'012\hskip -6pt}}
7087\def\cbr{{\hskip 6pt\circle\char'011}}
7088\def\carttop{\hbox to \cartouter{\hskip\lskip
7089        \ctl\leaders\hrule height\circthick\hfil\ctr
7090        \hskip\rskip}}
7091\def\cartbot{\hbox to \cartouter{\hskip\lskip
7092        \cbl\leaders\hrule height\circthick\hfil\cbr
7093        \hskip\rskip}}
7094%
7095\newskip\lskip\newskip\rskip
7096
7097% only require the font if @cartouche is actually used
7098\def\cartouchefontdefs{%
7099  \font\circle=lcircle10\relax
7100  \circthick=\fontdimen8\circle
7101}
7102\newdimen\circthick
7103\newdimen\cartouter\newdimen\cartinner
7104\newskip\normbskip\newskip\normpskip\newskip\normlskip
7105
7106
7107\envdef\cartouche{%
7108  \cartouchefontdefs
7109  \ifhmode\par\fi  % can't be in the midst of a paragraph.
7110  \startsavinginserts
7111  \lskip=\leftskip \rskip=\rightskip
7112  \leftskip=0pt\rightskip=0pt % we want these *outside*.
7113  \cartinner=\hsize \advance\cartinner by-\lskip
7114  \advance\cartinner by-\rskip
7115  \cartouter=\hsize
7116  \advance\cartouter by 18.4pt	% allow for 3pt kerns on either
7117				% side, and for 6pt waste from
7118				% each corner char, and rule thickness
7119  \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
7120  %
7121  % If this cartouche directly follows a sectioning command, we need the
7122  % \parskip glue (backspaced over by default) or the cartouche can
7123  % collide with the section heading.
7124  \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
7125  %
7126  \setbox\groupbox=\vbox\bgroup
7127      \baselineskip=0pt\parskip=0pt\lineskip=0pt
7128      \carttop
7129      \hbox\bgroup
7130	  \hskip\lskip
7131	  \vrule\kern3pt
7132	  \vbox\bgroup
7133	      \kern3pt
7134	      \hsize=\cartinner
7135	      \baselineskip=\normbskip
7136	      \lineskip=\normlskip
7137	      \parskip=\normpskip
7138	      \vskip -\parskip
7139	      \comment % For explanation, see the end of def\group.
7140}
7141\def\Ecartouche{%
7142              \ifhmode\par\fi
7143	      \kern3pt
7144	  \egroup
7145	  \kern3pt\vrule
7146	  \hskip\rskip
7147      \egroup
7148      \cartbot
7149  \egroup
7150  \addgroupbox
7151  \checkinserts
7152}
7153
7154
7155% This macro is called at the beginning of all the @example variants,
7156% inside a group.
7157\newdimen\nonfillparindent
7158\def\nonfillstart{%
7159  \aboveenvbreak
7160  \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
7161  \sepspaces % Make spaces be word-separators rather than space tokens.
7162  \let\par = \lisppar % don't ignore blank lines
7163  \obeylines % each line of input is a line of output
7164  \parskip = 0pt
7165  % Turn off paragraph indentation but redefine \indent to emulate
7166  % the normal \indent.
7167  \nonfillparindent=\parindent
7168  \parindent = 0pt
7169  \let\indent\nonfillindent
7170  %
7171  \emergencystretch = 0pt % don't try to avoid overfull boxes
7172  \ifx\nonarrowing\relax
7173    \advance \leftskip by \lispnarrowing
7174    \exdentamount=\lispnarrowing
7175  \else
7176    \let\nonarrowing = \relax
7177  \fi
7178  \let\exdent=\nofillexdent
7179}
7180
7181\begingroup
7182\obeyspaces
7183% We want to swallow spaces (but not other tokens) after the fake
7184% @indent in our nonfill-environments, where spaces are normally
7185% active and set to @tie, resulting in them not being ignored after
7186% @indent.
7187\gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
7188\gdef\nonfillindentcheck{%
7189\ifx\temp %
7190\expandafter\nonfillindentgobble%
7191\else%
7192\leavevmode\nonfillindentbox%
7193\fi%
7194}%
7195\endgroup
7196\def\nonfillindentgobble#1{\nonfillindent}
7197\def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7198
7199% If you want all examples etc. small: @set dispenvsize small.
7200% If you want even small examples the full size: @set dispenvsize nosmall.
7201% This affects the following displayed environments:
7202%    @example, @display, @format, @lisp, @verbatim
7203%
7204\def\smallword{small}
7205\def\nosmallword{nosmall}
7206\let\SETdispenvsize\relax
7207\def\setnormaldispenv{%
7208  \ifx\SETdispenvsize\smallword
7209    % end paragraph for sake of leading, in case document has no blank
7210    % line.  This is redundant with what happens in \aboveenvbreak, but
7211    % we need to do it before changing the fonts, and it's inconvenient
7212    % to change the fonts afterward.
7213    \ifnum \lastpenalty=10000 \else \endgraf \fi
7214    \smallexamplefonts \rm
7215  \fi
7216}
7217\def\setsmalldispenv{%
7218  \ifx\SETdispenvsize\nosmallword
7219  \else
7220    \ifnum \lastpenalty=10000 \else \endgraf \fi
7221    \smallexamplefonts \rm
7222  \fi
7223}
7224
7225% We often define two environments, @foo and @smallfoo.
7226% Let's do it in one command.  #1 is the env name, #2 the definition.
7227\def\makedispenvdef#1#2{%
7228  \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7229  \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
7230  \expandafter\let\csname E#1\endcsname \afterenvbreak
7231  \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
7232}
7233
7234% Define two environment synonyms (#1 and #2) for an environment.
7235\def\maketwodispenvdef#1#2#3{%
7236  \makedispenvdef{#1}{#3}%
7237  \makedispenvdef{#2}{#3}%
7238}
7239%
7240% @lisp: indented, narrowed, typewriter font;
7241% @example: same as @lisp.
7242%
7243% @smallexample and @smalllisp: use smaller fonts.
7244% Originally contributed by Pavel@xerox.
7245%
7246\maketwodispenvdef{lisp}{example}{%
7247  \nonfillstart
7248  \tt\setcodequotes
7249  \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
7250  \parsearg\gobble
7251}
7252% @display/@smalldisplay: same as @lisp except keep current font.
7253%
7254\makedispenvdef{display}{%
7255  \nonfillstart
7256  \gobble
7257}
7258
7259% @format/@smallformat: same as @display except don't narrow margins.
7260%
7261\makedispenvdef{format}{%
7262  \let\nonarrowing = t%
7263  \nonfillstart
7264  \gobble
7265}
7266
7267% @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7268\envdef\flushleft{%
7269  \let\nonarrowing = t%
7270  \nonfillstart
7271  \gobble
7272}
7273\let\Eflushleft = \afterenvbreak
7274
7275% @flushright.
7276%
7277\envdef\flushright{%
7278  \let\nonarrowing = t%
7279  \nonfillstart
7280  \advance\leftskip by 0pt plus 1fill\relax
7281  \gobble
7282}
7283\let\Eflushright = \afterenvbreak
7284
7285
7286% @raggedright does more-or-less normal line breaking but no right
7287% justification.  From plain.tex.
7288\envdef\raggedright{%
7289  \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7290}
7291\let\Eraggedright\par
7292
7293\envdef\raggedleft{%
7294  \parindent=0pt \leftskip0pt plus2em
7295  \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7296  \hbadness=10000 % Last line will usually be underfull, so turn off
7297                  % badness reporting.
7298}
7299\let\Eraggedleft\par
7300
7301\envdef\raggedcenter{%
7302  \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
7303  \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7304  \hbadness=10000 % Last line will usually be underfull, so turn off
7305                  % badness reporting.
7306}
7307\let\Eraggedcenter\par
7308
7309
7310% @quotation does normal linebreaking (hence we can't use \nonfillstart)
7311% and narrows the margins.  We keep \parskip nonzero in general, since
7312% we're doing normal filling.  So, when using \aboveenvbreak and
7313% \afterenvbreak, temporarily make \parskip 0.
7314%
7315\makedispenvdef{quotation}{\quotationstart}
7316%
7317\def\quotationstart{%
7318  \indentedblockstart % same as \indentedblock, but increase right margin too.
7319  \ifx\nonarrowing\relax
7320    \advance\rightskip by \lispnarrowing
7321  \fi
7322  \parsearg\quotationlabel
7323}
7324
7325% We have retained a nonzero parskip for the environment, since we're
7326% doing normal filling.
7327%
7328\def\Equotation{%
7329  \par
7330  \ifx\quotationauthor\thisisundefined\else
7331    % indent a bit.
7332    \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7333  \fi
7334  {\parskip=0pt \afterenvbreak}%
7335}
7336\def\Esmallquotation{\Equotation}
7337
7338% If we're given an argument, typeset it in bold with a colon after.
7339\def\quotationlabel#1{%
7340  \def\temp{#1}%
7341  \ifx\temp\empty \else
7342    {\bf #1: }%
7343  \fi
7344}
7345
7346% @indentedblock is like @quotation, but indents only on the left and
7347% has no optional argument.
7348%
7349\makedispenvdef{indentedblock}{\indentedblockstart}
7350%
7351\def\indentedblockstart{%
7352  {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7353  \parindent=0pt
7354  %
7355  % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7356  \ifx\nonarrowing\relax
7357    \advance\leftskip by \lispnarrowing
7358    \exdentamount = \lispnarrowing
7359  \else
7360    \let\nonarrowing = \relax
7361  \fi
7362}
7363
7364% Keep a nonzero parskip for the environment, since we're doing normal filling.
7365%
7366\def\Eindentedblock{%
7367  \par
7368  {\parskip=0pt \afterenvbreak}%
7369}
7370\def\Esmallindentedblock{\Eindentedblock}
7371
7372
7373% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7374% If we want to allow any <char> as delimiter,
7375% we need the curly braces so that makeinfo sees the @verb command, eg:
7376% `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
7377%
7378% [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
7379%
7380% [Knuth] p.344; only we need to do the other characters Texinfo sets
7381% active too.  Otherwise, they get lost as the first character on a
7382% verbatim line.
7383\def\dospecials{%
7384  \do\ \do\\\do\{\do\}\do\$\do\&%
7385  \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7386  \do\<\do\>\do\|\do\@\do+\do\"%
7387  % Don't do the quotes -- if we do, @set txicodequoteundirected and
7388  % @set txicodequotebacktick will not have effect on @verb and
7389  % @verbatim, and ?` and !` ligatures won't get disabled.
7390  %\do\`\do\'%
7391}
7392%
7393% [Knuth] p. 380
7394\def\uncatcodespecials{%
7395  \def\do##1{\catcode`##1=\other}\dospecials}
7396%
7397% Setup for the @verb command.
7398%
7399% Eight spaces for a tab
7400\begingroup
7401  \catcode`\^^I=\active
7402  \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7403\endgroup
7404%
7405\def\setupverb{%
7406  \tt  % easiest (and conventionally used) font for verbatim
7407  \def\par{\leavevmode\endgraf}%
7408  \setcodequotes
7409  \tabeightspaces
7410  % Respect line breaks,
7411  % print special symbols as themselves, and
7412  % make each space count
7413  % must do in this order:
7414  \obeylines \uncatcodespecials \sepspaces
7415}
7416
7417% Setup for the @verbatim environment
7418%
7419% Real tab expansion.
7420\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7421%
7422% We typeset each line of the verbatim in an \hbox, so we can handle
7423% tabs.
7424\newbox\verbbox
7425\def\starttabbox{\setbox\verbbox=\hbox\bgroup}
7426%
7427\begingroup
7428  \catcode`\^^I=\active
7429  \gdef\tabexpand{%
7430    \catcode`\^^I=\active
7431    \def^^I{\leavevmode\egroup
7432      \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7433      \divide\dimen\verbbox by\tabw
7434      \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7435      \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
7436      \wd\verbbox=\dimen\verbbox
7437      \leavevmode\box\verbbox \starttabbox
7438    }%
7439  }
7440\endgroup
7441
7442% start the verbatim environment.
7443\def\setupverbatim{%
7444  \let\nonarrowing = t%
7445  \nonfillstart
7446  \tt % easiest (and conventionally used) font for verbatim
7447  \def\par{\egroup\leavevmode\box\verbbox\endgraf\starttabbox}%
7448  \tabexpand
7449  \setcodequotes
7450  % Respect line breaks,
7451  % print special symbols as themselves, and
7452  % make each space count.
7453  % Must do in this order:
7454  \obeylines \uncatcodespecials \sepspaces
7455}
7456
7457% Do the @verb magic: verbatim text is quoted by unique
7458% delimiter characters.  Before first delimiter expect a
7459% right brace, after last delimiter expect closing brace:
7460%
7461%    \def\doverb'{'<char>#1<char>'}'{#1}
7462%
7463% [Knuth] p. 382; only eat outer {}
7464\begingroup
7465  \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
7466  \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7467\endgroup
7468%
7469\def\verb{\begingroup\setupverb\doverb}
7470%
7471%
7472% Do the @verbatim magic: define the macro \doverbatim so that
7473% the (first) argument ends when '@end verbatim' is reached, ie:
7474%
7475%     \def\doverbatim#1@end verbatim{#1}
7476%
7477% For Texinfo it's a lot easier than for LaTeX,
7478% because texinfo's \verbatim doesn't stop at '\end{verbatim}':
7479% we need not redefine '\', '{' and '}'.
7480%
7481% Inspired by LaTeX's verbatim command set [latex.ltx]
7482%
7483\begingroup
7484  \catcode`\ =\active
7485  \obeylines %
7486  % ignore everything up to the first ^^M, that's the newline at the end
7487  % of the @verbatim input line itself.  Otherwise we get an extra blank
7488  % line in the output.
7489  \xdef\doverbatim#1^^M#2@end verbatim{%
7490    \starttabbox#2\egroup\noexpand\end\gobble verbatim}%
7491  % We really want {...\end verbatim} in the body of the macro, but
7492  % without the active space; thus we have to use \xdef and \gobble.
7493  % The \egroup ends the \verbbox started at the end of the last line in
7494  % the block.
7495\endgroup
7496%
7497\envdef\verbatim{%
7498    \setnormaldispenv\setupverbatim\doverbatim
7499}
7500\let\Everbatim = \afterenvbreak
7501
7502
7503% @verbatiminclude FILE - insert text of file in verbatim environment.
7504%
7505\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
7506%
7507\def\doverbatiminclude#1{%
7508  {%
7509    \makevalueexpandable
7510    \setupverbatim
7511    {%
7512      \indexnofonts       % Allow `@@' and other weird things in file names.
7513      \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
7514      \edef\tmp{\noexpand\input #1 }
7515      \expandafter
7516    }\expandafter\starttabbox\tmp\egroup
7517    \afterenvbreak
7518  }%
7519}
7520
7521% @copying ... @end copying.
7522% Save the text away for @insertcopying later.
7523%
7524% We save the uninterpreted tokens, rather than creating a box.
7525% Saving the text in a box would be much easier, but then all the
7526% typesetting commands (@smallbook, font changes, etc.) have to be done
7527% beforehand -- and a) we want @copying to be done first in the source
7528% file; b) letting users define the frontmatter in as flexible order as
7529% possible is desirable.
7530%
7531\def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
7532\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
7533%
7534\def\insertcopying{%
7535  \begingroup
7536    \parindent = 0pt  % paragraph indentation looks wrong on title page
7537    \scanexp\copyingtext
7538  \endgroup
7539}
7540
7541
7542\message{defuns,}
7543% @defun etc.
7544
7545\newskip\defbodyindent \defbodyindent=.4in
7546\newskip\defargsindent \defargsindent=50pt
7547\newskip\deflastargmargin \deflastargmargin=18pt
7548\newcount\defunpenalty
7549
7550% Start the processing of @deffn:
7551\def\startdefun{%
7552  \ifnum\lastpenalty<10000
7553    \medbreak
7554    \defunpenalty=10003 % Will keep this @deffn together with the
7555                        % following @def command, see below.
7556  \else
7557    % If there are two @def commands in a row, we'll have a \nobreak,
7558    % which is there to keep the function description together with its
7559    % header.  But if there's nothing but headers, we need to allow a
7560    % break somewhere.  Check specifically for penalty 10002, inserted
7561    % by \printdefunline, instead of 10000, since the sectioning
7562    % commands also insert a nobreak penalty, and we don't want to allow
7563    % a break between a section heading and a defun.
7564    %
7565    % As a further refinement, we avoid "club" headers by signalling
7566    % with penalty of 10003 after the very first @deffn in the
7567    % sequence (see above), and penalty of 10002 after any following
7568    % @def command.
7569    \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
7570    %
7571    % Similarly, after a section heading, do not allow a break.
7572    % But do insert the glue.
7573    \medskip  % preceded by discardable penalty, so not a breakpoint
7574  \fi
7575  %
7576  \parindent=0in
7577  \advance\leftskip by \defbodyindent
7578  \exdentamount=\defbodyindent
7579}
7580
7581\def\dodefunx#1{%
7582  % First, check whether we are in the right environment:
7583  \checkenv#1%
7584  %
7585  % As above, allow line break if we have multiple x headers in a row.
7586  % It's not a great place, though.
7587  \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
7588  %
7589  % And now, it's time to reuse the body of the original defun:
7590  \expandafter\gobbledefun#1%
7591}
7592\def\gobbledefun#1\startdefun{}
7593
7594% \printdefunline \deffnheader{text}
7595%
7596\def\printdefunline#1#2{%
7597  \begingroup
7598    \plainfrenchspacing
7599    % call \deffnheader:
7600    #1#2 \endheader
7601    % common ending:
7602    \interlinepenalty = 10000
7603    \advance\rightskip by 0pt plus 1fil\relax
7604    \endgraf
7605    \nobreak\vskip -\parskip
7606    \penalty\defunpenalty  % signal to \startdefun and \dodefunx
7607    % Some of the @defun-type tags do not enable magic parentheses,
7608    % rendering the following check redundant.  But we don't optimize.
7609    \checkparencounts
7610  \endgroup
7611}
7612
7613\def\Edefun{\endgraf\medbreak}
7614
7615% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
7616% the only thing remaining is to define \deffnheader.
7617%
7618\def\makedefun#1{%
7619  \expandafter\let\csname E#1\endcsname = \Edefun
7620  \edef\temp{\noexpand\domakedefun
7621    \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7622  \temp
7623}
7624
7625% \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
7626%
7627% Define \deffn and \deffnx, without parameters.
7628% \deffnheader has to be defined explicitly.
7629%
7630\def\domakedefun#1#2#3{%
7631  \envdef#1{%
7632    \startdefun
7633    \doingtypefnfalse    % distinguish typed functions from all else
7634    \parseargusing\activeparens{\printdefunline#3}%
7635  }%
7636  \def#2{\dodefunx#1}%
7637  \def#3%
7638}
7639
7640\newif\ifdoingtypefn       % doing typed function?
7641\newif\ifrettypeownline    % typeset return type on its own line?
7642
7643% @deftypefnnewline on|off says whether the return type of typed functions
7644% are printed on their own line.  This affects @deftypefn, @deftypefun,
7645% @deftypeop, and @deftypemethod.
7646%
7647\parseargdef\deftypefnnewline{%
7648  \def\temp{#1}%
7649  \ifx\temp\onword
7650    \expandafter\let\csname SETtxideftypefnnl\endcsname
7651      = \empty
7652  \else\ifx\temp\offword
7653    \expandafter\let\csname SETtxideftypefnnl\endcsname
7654      = \relax
7655  \else
7656    \errhelp = \EMsimple
7657    \errmessage{Unknown @txideftypefnnl value `\temp',
7658                must be on|off}%
7659  \fi\fi
7660}
7661
7662% \dosubind {index}{topic}{subtopic}
7663%
7664% If SUBTOPIC is present, precede it with a space, and call \doind.
7665% (At some time during the 20th century, this made a two-level entry in an
7666% index such as the operation index.  Nobody seemed to notice the change in
7667% behaviour though.)
7668\def\dosubind#1#2#3{%
7669  \def\thirdarg{#3}%
7670  \ifx\thirdarg\empty
7671    \doind{#1}{#2}%
7672  \else
7673    \doind{#1}{#2\space#3}%
7674  \fi
7675}
7676
7677% Untyped functions:
7678
7679% @deffn category name args
7680\makedefun{deffn}{\deffngeneral{}}
7681
7682% @deffn category class name args
7683\makedefun{defop}#1 {\defopon{#1\ \putwordon}}
7684
7685% \defopon {category on}class name args
7686\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7687
7688% \deffngeneral {subind}category name args
7689%
7690\def\deffngeneral#1#2 #3 #4\endheader{%
7691  \dosubind{fn}{\code{#3}}{#1}%
7692  \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
7693}
7694
7695% Typed functions:
7696
7697% @deftypefn category type name args
7698\makedefun{deftypefn}{\deftypefngeneral{}}
7699
7700% @deftypeop category class type name args
7701\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
7702
7703% \deftypeopon {category on}class type name args
7704\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7705
7706% \deftypefngeneral {subind}category type name args
7707%
7708\def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
7709  \dosubind{fn}{\code{#4}}{#1}%
7710  \doingtypefntrue
7711  \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7712}
7713
7714% Typed variables:
7715
7716% @deftypevr category type var args
7717\makedefun{deftypevr}{\deftypecvgeneral{}}
7718
7719% @deftypecv category class type var args
7720\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
7721
7722% \deftypecvof {category of}class type var args
7723\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
7724
7725% \deftypecvgeneral {subind}category type var args
7726%
7727\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
7728  \dosubind{vr}{\code{#4}}{#1}%
7729  \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7730}
7731
7732% Untyped variables:
7733
7734% @defvr category var args
7735\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
7736
7737% @defcv category class var args
7738\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
7739
7740% \defcvof {category of}class var args
7741\def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
7742
7743% Types:
7744
7745% @deftp category name args
7746\makedefun{deftp}#1 #2 #3\endheader{%
7747  \doind{tp}{\code{#2}}%
7748  \defname{#1}{}{#2}\defunargs{#3\unskip}%
7749}
7750
7751% Remaining @defun-like shortcuts:
7752\makedefun{defun}{\deffnheader{\putwordDeffunc} }
7753\makedefun{defmac}{\deffnheader{\putwordDefmac} }
7754\makedefun{defspec}{\deffnheader{\putwordDefspec} }
7755\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7756\makedefun{defvar}{\defvrheader{\putwordDefvar} }
7757\makedefun{defopt}{\defvrheader{\putwordDefopt} }
7758\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
7759\makedefun{defmethod}{\defopon\putwordMethodon}
7760\makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
7761\makedefun{defivar}{\defcvof\putwordInstanceVariableof}
7762\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
7763
7764% \defname, which formats the name of the @def (not the args).
7765% #1 is the category, such as "Function".
7766% #2 is the return type, if any.
7767% #3 is the function name.
7768%
7769% We are followed by (but not passed) the arguments, if any.
7770%
7771\def\defname#1#2#3{%
7772  \par
7773  % Get the values of \leftskip and \rightskip as they were outside the @def...
7774  \advance\leftskip by -\defbodyindent
7775  %
7776  % Determine if we are typesetting the return type of a typed function
7777  % on a line by itself.
7778  \rettypeownlinefalse
7779  \ifdoingtypefn  % doing a typed function specifically?
7780    % then check user option for putting return type on its own line:
7781    \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
7782      \rettypeownlinetrue
7783    \fi
7784  \fi
7785  %
7786  % How we'll format the category name.  Putting it in brackets helps
7787  % distinguish it from the body text that may end up on the next line
7788  % just below it.
7789  \def\temp{#1}%
7790  \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7791  %
7792  % Figure out line sizes for the paragraph shape.  We'll always have at
7793  % least two.
7794  \tempnum = 2
7795  %
7796  % The first line needs space for \box0; but if \rightskip is nonzero,
7797  % we need only space for the part of \box0 which exceeds it:
7798  \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
7799  %
7800  % If doing a return type on its own line, we'll have another line.
7801  \ifrettypeownline
7802    \advance\tempnum by 1
7803    \def\maybeshapeline{0in \hsize}%
7804  \else
7805    \def\maybeshapeline{}%
7806  \fi
7807  %
7808  % The continuations:
7809  \dimen2=\hsize  \advance\dimen2 by -\defargsindent
7810  %
7811  % The final paragraph shape:
7812  \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
7813  %
7814  % Put the category name at the right margin.
7815  \noindent
7816  \hbox to 0pt{%
7817    \hfil\box0 \kern-\hsize
7818    % \hsize has to be shortened this way:
7819    \kern\leftskip
7820    % Intentionally do not respect \rightskip, since we need the space.
7821  }%
7822  %
7823  % Allow all lines to be underfull without complaint:
7824  \tolerance=10000 \hbadness=10000
7825  \exdentamount=\defbodyindent
7826  {%
7827    % defun fonts. We use typewriter by default (used to be bold) because:
7828    % . we're printing identifiers, they should be in tt in principle.
7829    % . in languages with many accents, such as Czech or French, it's
7830    %   common to leave accents off identifiers.  The result looks ok in
7831    %   tt, but exceedingly strange in rm.
7832    % . we don't want -- and --- to be treated as ligatures.
7833    % . this still does not fix the ?` and !` ligatures, but so far no
7834    %   one has made identifiers using them :).
7835    \df \tt
7836    \def\temp{#2}% text of the return type
7837    \ifx\temp\empty\else
7838      \tclose{\temp}% typeset the return type
7839      \ifrettypeownline
7840        % put return type on its own line; prohibit line break following:
7841        \hfil\vadjust{\nobreak}\break
7842      \else
7843        \space  % type on same line, so just followed by a space
7844      \fi
7845    \fi           % no return type
7846    #3% output function name
7847  }%
7848  {\rm\enskip}% hskip 0.5 em of \rmfont
7849  %
7850  \boldbrax
7851  % arguments will be output next, if any.
7852}
7853
7854% Print arguments in slanted roman (not ttsl), inconsistently with using
7855% tt for the name.  This is because literal text is sometimes needed in
7856% the argument list (groff manual), and ttsl and tt are not very
7857% distinguishable.  Prevent hyphenation at `-' chars.
7858%
7859\def\defunargs#1{%
7860  % use sl by default (not ttsl),
7861  % tt for the names.
7862  \df \sl \hyphenchar\font=0
7863  %
7864  % On the other hand, if an argument has two dashes (for instance), we
7865  % want a way to get ttsl.  We used to recommend @var for that, so
7866  % leave the code in, but it's strange for @var to lead to typewriter.
7867  % Nowadays we recommend @code, since the difference between a ttsl hyphen
7868  % and a tt hyphen is pretty tiny.  @code also disables ?` !`.
7869  \def\var##1{{\setregularquotes\ttslanted{##1}}}%
7870  #1%
7871  \sl\hyphenchar\font=45
7872}
7873
7874% We want ()&[] to print specially on the defun line.
7875%
7876\def\activeparens{%
7877  \catcode`\(=\active \catcode`\)=\active
7878  \catcode`\[=\active \catcode`\]=\active
7879  \catcode`\&=\active
7880}
7881
7882% Make control sequences which act like normal parenthesis chars.
7883\let\lparen = ( \let\rparen = )
7884
7885% Be sure that we always have a definition for `(', etc.  For example,
7886% if the fn name has parens in it, \boldbrax will not be in effect yet,
7887% so TeX would otherwise complain about undefined control sequence.
7888{
7889  \activeparens
7890  \global\let(=\lparen \global\let)=\rparen
7891  \global\let[=\lbrack \global\let]=\rbrack
7892  \global\let& = \&
7893
7894  \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
7895  \gdef\magicamp{\let&=\amprm}
7896}
7897\let\ampchar\&
7898
7899\newcount\parencount
7900
7901% If we encounter &foo, then turn on ()-hacking afterwards
7902\newif\ifampseen
7903\def\amprm#1 {\ampseentrue{\bf\&#1 }}
7904
7905\def\parenfont{%
7906  \ifampseen
7907    % At the first level, print parens in roman,
7908    % otherwise use the default font.
7909    \ifnum \parencount=1 \rm \fi
7910  \else
7911    % The \sf parens (in \boldbrax) actually are a little bolder than
7912    % the contained text.  This is especially needed for [ and ] .
7913    \sf
7914  \fi
7915}
7916\def\infirstlevel#1{%
7917  \ifampseen
7918    \ifnum\parencount=1
7919      #1%
7920    \fi
7921  \fi
7922}
7923\def\bfafterword#1 {#1 \bf}
7924
7925\def\opnr{%
7926  \global\advance\parencount by 1
7927  {\parenfont(}%
7928  \infirstlevel \bfafterword
7929}
7930\def\clnr{%
7931  {\parenfont)}%
7932  \infirstlevel \sl
7933  \global\advance\parencount by -1
7934}
7935
7936\newcount\brackcount
7937\def\lbrb{%
7938  \global\advance\brackcount by 1
7939  {\bf[}%
7940}
7941\def\rbrb{%
7942  {\bf]}%
7943  \global\advance\brackcount by -1
7944}
7945
7946\def\checkparencounts{%
7947  \ifnum\parencount=0 \else \badparencount \fi
7948  \ifnum\brackcount=0 \else \badbrackcount \fi
7949}
7950% these should not use \errmessage; the glibc manual, at least, actually
7951% has such constructs (when documenting function pointers).
7952\def\badparencount{%
7953  \message{Warning: unbalanced parentheses in @def...}%
7954  \global\parencount=0
7955}
7956\def\badbrackcount{%
7957  \message{Warning: unbalanced square brackets in @def...}%
7958  \global\brackcount=0
7959}
7960
7961
7962\message{macros,}
7963% @macro.
7964
7965% To do this right we need a feature of e-TeX, \scantokens,
7966% which we arrange to emulate with a temporary file in ordinary TeX.
7967\ifx\eTeXversion\thisisundefined
7968  \newwrite\macscribble
7969  \def\scantokens#1{%
7970    \toks0={#1}%
7971    \immediate\openout\macscribble=\jobname.tmp
7972    \immediate\write\macscribble{\the\toks0}%
7973    \immediate\closeout\macscribble
7974    \input \jobname.tmp
7975  }
7976\fi
7977
7978\let\E=\expandafter
7979
7980% Used at the time of macro expansion.
7981% Argument is macro body with arguments substituted
7982\def\scanmacro#1{%
7983  \newlinechar`\^^M
7984  % expand the expansion of \eatleadingcr twice to maybe remove a leading
7985  % newline (and \else and \fi tokens), then call \eatspaces on the result.
7986  \def\xeatspaces##1{%
7987    \E\E\E\E\E\E\E\eatspaces\E\E\E\E\E\E\E{\eatleadingcr##1%
7988  }}%
7989  \def\xempty##1{}%
7990  %
7991  % Process the macro body under the current catcode regime.
7992  \scantokens{#1@comment}%
7993  %
7994  % The \comment is to remove the \newlinechar added by \scantokens, and
7995  % can be noticed by \parsearg.  Note \c isn't used because this means cedilla
7996  % in math mode.
7997}
7998
7999% Used for copying and captions
8000\def\scanexp#1{%
8001  \expandafter\scanmacro\expandafter{#1}%
8002}
8003
8004\newcount\paramno   % Count of parameters
8005\newtoks\macname    % Macro name
8006\newif\ifrecursive  % Is it recursive?
8007
8008% List of all defined macros in the form
8009%    \commondummyword\macro1\commondummyword\macro2...
8010% Currently is also contains all @aliases; the list can be split
8011% if there is a need.
8012\def\macrolist{}
8013
8014% Add the macro to \macrolist
8015\def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
8016\def\addtomacrolistxxx#1{%
8017     \toks0 = \expandafter{\macrolist\commondummyword#1}%
8018     \xdef\macrolist{\the\toks0}%
8019}
8020
8021% Utility routines.
8022% This does \let #1 = #2, with \csnames; that is,
8023%   \let \csname#1\endcsname = \csname#2\endcsname
8024% (except of course we have to play expansion games).
8025%
8026\def\cslet#1#2{%
8027  \expandafter\let
8028  \csname#1\expandafter\endcsname
8029  \csname#2\endcsname
8030}
8031
8032% Trim leading and trailing spaces off a string.
8033% Concepts from aro-bend problem 15 (see CTAN).
8034{\catcode`\@=11
8035\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
8036\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
8037\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
8038\def\unbrace#1{#1}
8039\unbrace{\gdef\trim@@@ #1 } #2@{#1}
8040}
8041
8042{\catcode`\^^M=\other%
8043\gdef\eatleadingcr#1{\if\noexpand#1\noexpand^^M\else\E#1\fi}}%
8044% Warning: this won't work for a delimited argument
8045% or for an empty argument
8046
8047% Trim a single trailing ^^M off a string.
8048{\catcode`\^^M=\other \catcode`\Q=3%
8049\gdef\eatcr #1{\eatcra #1Q^^MQ}%
8050\gdef\eatcra#1^^MQ{\eatcrb#1Q}%
8051\gdef\eatcrb#1Q#2Q{#1}%
8052}
8053
8054% Macro bodies are absorbed as an argument in a context where
8055% all characters are catcode 10, 11 or 12, except \ which is active
8056% (as in normal texinfo). It is necessary to change the definition of \
8057% to recognize macro arguments; this is the job of \mbodybackslash.
8058%
8059% Non-ASCII encodings make 8-bit characters active, so un-activate
8060% them to avoid their expansion.  Must do this non-globally, to
8061% confine the change to the current group.
8062%
8063% It's necessary to have hard CRs when the macro is executed. This is
8064% done by making ^^M (\endlinechar) catcode 12 when reading the macro
8065% body, and then making it the \newlinechar in \scanmacro.
8066%
8067\def\scanctxt{% used as subroutine
8068  \catcode`\"=\other
8069  \catcode`\+=\other
8070  \catcode`\<=\other
8071  \catcode`\>=\other
8072  \catcode`\^=\other
8073  \catcode`\_=\other
8074  \catcode`\|=\other
8075  \catcode`\~=\other
8076  \passthroughcharstrue
8077}
8078
8079\def\scanargctxt{% used for copying and captions, not macros.
8080  \scanctxt
8081  \catcode`\@=\other
8082  \catcode`\\=\other
8083  \catcode`\^^M=\other
8084}
8085
8086\def\macrobodyctxt{% used for @macro definitions
8087  \scanctxt
8088  \catcode`\ =\other
8089  \catcode`\@=\other
8090  \catcode`\{=\other
8091  \catcode`\}=\other
8092  \catcode`\^^M=\other
8093  \usembodybackslash
8094}
8095
8096% Used when scanning braced macro arguments.  Note, however, that catcode
8097% changes here are ineffectual if the macro invocation was nested inside
8098% an argument to another Texinfo command.
8099\def\macroargctxt{%
8100  \scanctxt
8101  \catcode`\ =\active
8102  \catcode`\@=\other
8103  \catcode`\^^M=\other
8104  \catcode`\\=\active
8105}
8106
8107\def\macrolineargctxt{% used for whole-line arguments without braces
8108  \scanctxt
8109  \catcode`\@=\other
8110  \catcode`\{=\other
8111  \catcode`\}=\other
8112}
8113
8114% \mbodybackslash is the definition of \ in @macro bodies.
8115% It maps \foo\ => \csname macarg.foo\endcsname => #N
8116% where N is the macro parameter number.
8117% We define \csname macarg.\endcsname to be \realbackslash, so
8118% \\ in macro replacement text gets you a backslash.
8119%
8120{\catcode`@=0 @catcode`@\=@active
8121 @gdef@usembodybackslash{@let\=@mbodybackslash}
8122 @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
8123}
8124\expandafter\def\csname macarg.\endcsname{\realbackslash}
8125
8126\def\margbackslash#1{\char`\#1 }
8127
8128\def\macro{\recursivefalse\parsearg\macroxxx}
8129\def\rmacro{\recursivetrue\parsearg\macroxxx}
8130
8131\def\macroxxx#1{%
8132  \getargs{#1}% now \macname is the macname and \argl the arglist
8133  \ifx\argl\empty       % no arguments
8134     \paramno=0\relax
8135  \else
8136     \expandafter\parsemargdef \argl;%
8137     \if\paramno>256\relax
8138       \ifx\eTeXversion\thisisundefined
8139         \errhelp = \EMsimple
8140         \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
8141       \fi
8142     \fi
8143  \fi
8144  \if1\csname ismacro.\the\macname\endcsname
8145     \message{Warning: redefining \the\macname}%
8146  \else
8147     \expandafter\ifx\csname \the\macname\endcsname \relax
8148     \else \errmessage{Macro name \the\macname\space already defined}\fi
8149     \global\cslet{macsave.\the\macname}{\the\macname}%
8150     \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
8151     \addtomacrolist{\the\macname}%
8152  \fi
8153  \begingroup \macrobodyctxt
8154  \ifrecursive \expandafter\parsermacbody
8155  \else \expandafter\parsemacbody
8156  \fi}
8157
8158\parseargdef\unmacro{%
8159  \if1\csname ismacro.#1\endcsname
8160    \global\cslet{#1}{macsave.#1}%
8161    \global\expandafter\let \csname ismacro.#1\endcsname=0%
8162    % Remove the macro name from \macrolist:
8163    \begingroup
8164      \expandafter\let\csname#1\endcsname \relax
8165      \let\commondummyword\unmacrodo
8166      \xdef\macrolist{\macrolist}%
8167    \endgroup
8168  \else
8169    \errmessage{Macro #1 not defined}%
8170  \fi
8171}
8172
8173% Called by \do from \dounmacro on each macro.  The idea is to omit any
8174% macro definitions that have been changed to \relax.
8175%
8176\def\unmacrodo#1{%
8177  \ifx #1\relax
8178    % remove this
8179  \else
8180    \noexpand\commondummyword \noexpand#1%
8181  \fi
8182}
8183
8184% \getargs -- Parse the arguments to a @macro line.  Set \macname to
8185% the name of the macro, and \argl to the braced argument list.
8186\def\getargs#1{\getargsxxx#1{}}
8187\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
8188\def\getmacname#1 #2\relax{\macname={#1}}
8189\def\getmacargs#1{\def\argl{#1}}
8190% This made use of the feature that if the last token of a
8191% <parameter list> is #, then the preceding argument is delimited by
8192% an opening brace, and that opening brace is not consumed.
8193
8194% Parse the optional {params} list to @macro or @rmacro.
8195% Set \paramno to the number of arguments,
8196% and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
8197% three-param macro.)  Define \macarg.BLAH for each BLAH in the params
8198% list to some hook where the argument is to be expanded.  If there are
8199% less than 10 arguments that hook is to be replaced by ##N where N
8200% is the position in that list, that is to say the macro arguments are to be
8201% defined `a la TeX in the macro body.
8202%
8203% That gets used by \mbodybackslash (above).
8204%
8205% If there are 10 or more arguments, a different technique is used: see
8206% \parsemmanyargdef.
8207%
8208\def\parsemargdef#1;{%
8209  \paramno=0\def\paramlist{}%
8210  \let\hash\relax
8211  % \hash is redefined to `#' later to get it into definitions
8212  \let\xeatspaces\relax
8213  \let\xempty\relax
8214  \parsemargdefxxx#1,;,%
8215  \ifnum\paramno<10\relax\else
8216    \paramno0\relax
8217    \parsemmanyargdef@@#1,;,% 10 or more arguments
8218  \fi
8219}
8220\def\parsemargdefxxx#1,{%
8221  \if#1;\let\next=\relax
8222  \else \let\next=\parsemargdefxxx
8223    \advance\paramno by 1
8224    \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
8225        {\xeatspaces{\hash\the\paramno\noexpand\xempty{}}}%
8226    \edef\paramlist{\paramlist\hash\the\paramno,}%
8227  \fi\next}
8228% the \xempty{} is to give \eatleadingcr an argument in the case of an
8229% empty macro argument.
8230
8231% \parsemacbody, \parsermacbody
8232%
8233% Read recursive and nonrecursive macro bodies. (They're different since
8234% rec and nonrec macros end differently.)
8235%
8236% We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro
8237% body to be transformed.
8238% Set \macrobody to the body of the macro, and call \defmacro.
8239%
8240{\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{%
8241\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8242{\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
8243\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8244
8245% Make @ a letter, so that we can make private-to-Texinfo macro names.
8246\edef\texiatcatcode{\the\catcode`\@}
8247\catcode `@=11\relax
8248
8249%%%%%%%%%%%%%% Code for > 10 arguments only   %%%%%%%%%%%%%%%%%%
8250
8251% If there are 10 or more arguments, a different technique is used, where the
8252% hook remains in the body, and when macro is to be expanded the body is
8253% processed again to replace the arguments.
8254%
8255% In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
8256% argument N value and then \edef the body (nothing else will expand because of
8257% the catcode regime under which the body was input).
8258%
8259% If you compile with TeX (not eTeX), and you have macros with 10 or more
8260% arguments, no macro can have more than 256 arguments (else error).
8261%
8262% In case that there are 10 or more arguments we parse again the arguments
8263% list to set new definitions for the \macarg.BLAH macros corresponding to
8264% each BLAH argument. It was anyhow needed to parse already once this list
8265% in order to count the arguments, and as macros with at most 9 arguments
8266% are by far more frequent than macro with 10 or more arguments, defining
8267% twice the \macarg.BLAH macros does not cost too much processing power.
8268\def\parsemmanyargdef@@#1,{%
8269  \if#1;\let\next=\relax
8270  \else
8271    \let\next=\parsemmanyargdef@@
8272    \edef\tempb{\eatspaces{#1}}%
8273    \expandafter\def\expandafter\tempa
8274       \expandafter{\csname macarg.\tempb\endcsname}%
8275    % Note that we need some extra \noexpand\noexpand, this is because we
8276    % don't want \the  to be expanded in the \parsermacbody  as it uses an
8277    % \xdef .
8278    \expandafter\edef\tempa
8279      {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
8280    \advance\paramno by 1\relax
8281  \fi\next}
8282
8283
8284\let\endargs@\relax
8285\let\nil@\relax
8286\def\nilm@{\nil@}%
8287\long\def\nillm@{\nil@}%
8288
8289% This macro is expanded during the Texinfo macro expansion, not during its
8290% definition.  It gets all the arguments' values and assigns them to macros
8291% macarg.ARGNAME
8292%
8293% #1 is the macro name
8294% #2 is the list of argument names
8295% #3 is the list of argument values
8296\def\getargvals@#1#2#3{%
8297  \def\macargdeflist@{}%
8298  \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
8299  \def\paramlist{#2,\nil@}%
8300  \def\macroname{#1}%
8301  \begingroup
8302  \macroargctxt
8303  \def\argvaluelist{#3,\nil@}%
8304  \def\@tempa{#3}%
8305  \ifx\@tempa\empty
8306    \setemptyargvalues@
8307  \else
8308    \getargvals@@
8309  \fi
8310}
8311\def\getargvals@@{%
8312  \ifx\paramlist\nilm@
8313      % Some sanity check needed here that \argvaluelist is also empty.
8314      \ifx\argvaluelist\nillm@
8315      \else
8316        \errhelp = \EMsimple
8317        \errmessage{Too many arguments in macro `\macroname'!}%
8318      \fi
8319      \let\next\macargexpandinbody@
8320  \else
8321    \ifx\argvaluelist\nillm@
8322       % No more arguments values passed to macro.  Set remaining named-arg
8323       % macros to empty.
8324       \let\next\setemptyargvalues@
8325    \else
8326      % pop current arg name into \@tempb
8327      \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
8328      \expandafter\@tempa\expandafter{\paramlist}%
8329       % pop current argument value into \@tempc
8330      \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
8331      \expandafter\@tempa\expandafter{\argvaluelist}%
8332       % Here \@tempb is the current arg name and \@tempc is the current arg value.
8333       % First place the new argument macro definition into \@tempd
8334       \expandafter\macname\expandafter{\@tempc}%
8335       \expandafter\let\csname macarg.\@tempb\endcsname\relax
8336       \expandafter\def\expandafter\@tempe\expandafter{%
8337         \csname macarg.\@tempb\endcsname}%
8338       \edef\@tempd{\long\def\@tempe{\the\macname}}%
8339       \push@\@tempd\macargdeflist@
8340       \let\next\getargvals@@
8341    \fi
8342  \fi
8343  \next
8344}
8345
8346\def\push@#1#2{%
8347  \expandafter\expandafter\expandafter\def
8348  \expandafter\expandafter\expandafter#2%
8349  \expandafter\expandafter\expandafter{%
8350  \expandafter#1#2}%
8351}
8352
8353% Replace arguments by their values in the macro body, and place the result
8354% in macro \@tempa.
8355%
8356\def\macvalstoargs@{%
8357  %  To do this we use the property that token registers that are \the'ed
8358  % within an \edef  expand only once. So we are going to place all argument
8359  % values into respective token registers.
8360  %
8361  % First we save the token context, and initialize argument numbering.
8362  \begingroup
8363    \paramno0\relax
8364    % Then, for each argument number #N, we place the corresponding argument
8365    % value into a new token list register \toks#N
8366    \expandafter\putargsintokens@\saveparamlist@,;,%
8367    % Then, we expand the body so that argument are replaced by their
8368    % values. The trick for values not to be expanded themselves is that they
8369    % are within tokens and that tokens expand only once in an \edef .
8370    \edef\@tempc{\csname mac.\macroname .body\endcsname}%
8371    % Now we restore the token stack pointer to free the token list registers
8372    % which we have used, but we make sure that expanded body is saved after
8373    % group.
8374    \expandafter
8375  \endgroup
8376  \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
8377  }
8378
8379% Define the named-macro outside of this group and then close this group.
8380%
8381\def\macargexpandinbody@{%
8382  \expandafter
8383  \endgroup
8384  \macargdeflist@
8385  % First the replace in body the macro arguments by their values, the result
8386  % is in \@tempa .
8387  \macvalstoargs@
8388  % Then we point at the \norecurse or \gobble (for recursive) macro value
8389  % with \@tempb .
8390  \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
8391  % Depending on whether it is recursive or not, we need some tailing
8392  % \egroup .
8393  \ifx\@tempb\gobble
8394     \let\@tempc\relax
8395  \else
8396     \let\@tempc\egroup
8397  \fi
8398  % And now we do the real job:
8399  \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
8400  \@tempd
8401}
8402
8403\def\putargsintokens@#1,{%
8404  \if#1;\let\next\relax
8405  \else
8406    \let\next\putargsintokens@
8407    % First we allocate the new token list register, and give it a temporary
8408    % alias \@tempb .
8409    \toksdef\@tempb\the\paramno
8410    % Then we place the argument value into that token list register.
8411    \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
8412    \expandafter\@tempb\expandafter{\@tempa}%
8413    \advance\paramno by 1\relax
8414  \fi
8415  \next
8416}
8417
8418% Trailing missing arguments are set to empty.
8419%
8420\def\setemptyargvalues@{%
8421  \ifx\paramlist\nilm@
8422    \let\next\macargexpandinbody@
8423  \else
8424    \expandafter\setemptyargvaluesparser@\paramlist\endargs@
8425    \let\next\setemptyargvalues@
8426  \fi
8427  \next
8428}
8429
8430\def\setemptyargvaluesparser@#1,#2\endargs@{%
8431  \expandafter\def\expandafter\@tempa\expandafter{%
8432    \expandafter\def\csname macarg.#1\endcsname{}}%
8433  \push@\@tempa\macargdeflist@
8434  \def\paramlist{#2}%
8435}
8436
8437% #1 is the element target macro
8438% #2 is the list macro
8439% #3,#4\endargs@ is the list value
8440\def\pop@#1#2#3,#4\endargs@{%
8441   \def#1{#3}%
8442   \def#2{#4}%
8443}
8444\long\def\longpop@#1#2#3,#4\endargs@{%
8445   \long\def#1{#3}%
8446   \long\def#2{#4}%
8447}
8448
8449
8450%%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
8451
8452
8453% This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
8454%    \macrobody has the body of the macro in it, with placeholders for
8455% its parameters, looking like "\xeatspaces{\hash 1}".
8456%    \paramno is the number of parameters
8457%    \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
8458% There are four cases: macros of zero, one, up to nine, and many arguments.
8459% \xdef is used so that macro definitions will survive the file
8460% they're defined in: @include reads the file inside a group.
8461%
8462\def\defmacro{%
8463  \let\hash=##% convert placeholders to macro parameter chars
8464  \ifnum\paramno=1
8465    \def\xeatspaces##1{##1}%
8466    % This removes the pair of braces around the argument.  We don't
8467    % use \eatspaces, because this can cause ends of lines to be lost
8468    % when the argument to \eatspaces is read, leading to line-based
8469    % commands like "@itemize" not being read correctly.
8470  \else
8471    \let\xeatspaces\relax % suppress expansion
8472  \fi
8473  \ifcase\paramno
8474  % 0
8475    \expandafter\xdef\csname\the\macname\endcsname{%
8476      \bgroup
8477        \noexpand\spaceisspace
8478        \noexpand\endlineisspace
8479        \noexpand\expandafter % skip any whitespace after the macro name.
8480        \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8481    \expandafter\xdef\csname\the\macname @@@\endcsname{%
8482      \egroup
8483      \noexpand\scanmacro{\macrobody}}%
8484  \or % 1
8485    \expandafter\xdef\csname\the\macname\endcsname{%
8486       \bgroup
8487       \noexpand\braceorline
8488       \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8489    \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8490      \egroup
8491      \noexpand\scanmacro{\macrobody}%
8492      }%
8493  \else % at most 9
8494    \ifnum\paramno<10\relax
8495      % @MACNAME sets the context for reading the macro argument
8496      % @MACNAME@@ gets the argument, processes backslashes and appends a
8497      % comma.
8498      % @MACNAME@@@ removes braces surrounding the argument list.
8499      % @MACNAME@@@@ scans the macro body with arguments substituted.
8500      \expandafter\xdef\csname\the\macname\endcsname{%
8501        \bgroup
8502        \noexpand\expandafter  % This \expandafter skip any spaces after the
8503        \noexpand\macroargctxt % macro before we change the catcode of space.
8504        \noexpand\expandafter
8505        \expandafter\noexpand\csname\the\macname @@\endcsname}%
8506      \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8507          \noexpand\passargtomacro
8508          \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8509      \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8510          \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8511      \expandafter\expandafter
8512      \expandafter\xdef
8513      \expandafter\expandafter
8514        \csname\the\macname @@@@\endcsname\paramlist{%
8515          \egroup\noexpand\scanmacro{\macrobody}}%
8516    \else % 10 or more:
8517      \expandafter\xdef\csname\the\macname\endcsname{%
8518        \noexpand\getargvals@{\the\macname}{\argl}%
8519      }%
8520      \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8521      \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
8522    \fi
8523  \fi}
8524
8525\catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
8526
8527\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
8528
8529
8530%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8531%
8532{\catcode`\@=0 \catcode`\\=13  % We need to manipulate \ so use @ as escape
8533@catcode`@_=11  % private names
8534@catcode`@!=11  % used as argument separator
8535
8536% \passargtomacro#1#2 -
8537% Call #1 with a list of tokens #2, with any doubled backslashes in #2
8538% compressed to one.
8539%
8540% This implementation works by expansion, and not execution (so we cannot use
8541% \def or similar).  This reduces the risk of this failing in contexts where
8542% complete expansion is done with no execution (for example, in writing out to
8543% an auxiliary file for an index entry).
8544%
8545% State is kept in the input stream: the argument passed to
8546% @look_ahead, @gobble_and_check_finish and @add_segment is
8547%
8548% THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN  (... rest of input)
8549%
8550% where:
8551% THE_MACRO - name of the macro we want to call
8552% ARG_RESULT - argument list we build to pass to that macro
8553% PENDING_BS - either a backslash or nothing
8554% NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
8555
8556@gdef@passargtomacro#1#2{%
8557  @add_segment #1!{}@relax#2\@_finish\%
8558}
8559@gdef@_finish{@_finishx} @global@let@_finishx@relax
8560
8561% #1 - THE_MACRO ARG_RESULT
8562% #2 - PENDING_BS
8563% #3 - NEXT_TOKEN
8564% #4 used to look ahead
8565%
8566% If the next token is not a backslash, process the rest of the argument;
8567% otherwise, remove the next token.
8568@gdef@look_ahead#1!#2#3#4{%
8569  @ifx#4\%
8570   @expandafter@gobble_and_check_finish
8571  @else
8572   @expandafter@add_segment
8573  @fi#1!{#2}#4#4%
8574}
8575
8576% #1 - THE_MACRO ARG_RESULT
8577% #2 - PENDING_BS
8578% #3 - NEXT_TOKEN
8579% #4 should be a backslash, which is gobbled.
8580% #5 looks ahead
8581%
8582% Double backslash found.  Add a single backslash, and look ahead.
8583@gdef@gobble_and_check_finish#1!#2#3#4#5{%
8584  @add_segment#1\!{}#5#5%
8585}
8586
8587@gdef@is_fi{@fi}
8588
8589% #1 - THE_MACRO ARG_RESULT
8590% #2 - PENDING_BS
8591% #3 - NEXT_TOKEN
8592% #4 is input stream until next backslash
8593%
8594% Input stream is either at the start of the argument, or just after a
8595% backslash sequence, either a lone backslash, or a doubled backslash.
8596% NEXT_TOKEN contains the first token in the input stream: if it is \finish,
8597% finish; otherwise, append to ARG_RESULT the segment of the argument up until
8598% the next backslash.  PENDING_BACKSLASH contains a backslash to represent
8599% a backslash just before the start of the input stream that has not been
8600% added to ARG_RESULT.
8601@gdef@add_segment#1!#2#3#4\{%
8602@ifx#3@_finish
8603  @call_the_macro#1!%
8604@else
8605  % append the pending backslash to the result, followed by the next segment
8606  @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
8607  % this @fi is discarded by @look_ahead.
8608  % we can't get rid of it with \expandafter because we don't know how
8609  % long #4 is.
8610}
8611
8612% #1 - THE_MACRO
8613% #2 - ARG_RESULT
8614% #3 discards the res of the conditional in @add_segment, and @is_fi ends the
8615% conditional.
8616@gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
8617
8618}
8619%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8620
8621% \braceorline MAC is used for a one-argument macro MAC.  It checks
8622% whether the next non-whitespace character is a {.  It sets the context
8623% for reading the argument (slightly different in the two cases).  Then,
8624% to read the argument, in the whole-line case, it then calls the regular
8625% \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
8626%
8627\def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
8628\def\braceorlinexxx{%
8629  \ifx\nchar\bgroup
8630    \macroargctxt
8631    \expandafter\passargtomacro
8632  \else
8633    \macrolineargctxt\expandafter\parsearg
8634  \fi \macnamexxx}
8635
8636
8637% @alias.
8638% We need some trickery to remove the optional spaces around the equal
8639% sign.  Make them active and then expand them all to nothing.
8640%
8641\def\alias{\parseargusing\obeyspaces\aliasxxx}
8642\def\aliasxxx #1{\aliasyyy#1\relax}
8643\def\aliasyyy #1=#2\relax{%
8644  {%
8645    \expandafter\let\obeyedspace=\empty
8646    \addtomacrolist{#1}%
8647    \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
8648  }%
8649  \next
8650}
8651
8652
8653\message{cross references,}
8654
8655\newwrite\auxfile
8656\newif\ifhavexrefs    % True if xref values are known.
8657\newif\ifwarnedxrefs  % True if we warned once that they aren't known.
8658
8659% @inforef is relatively simple.
8660\def\inforef #1{\inforefzzz #1,,,,**}
8661\def\inforefzzz #1,#2,#3,#4**{%
8662  \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
8663  node \samp{\ignorespaces#1{}}}
8664
8665% @node's only job in TeX is to define \lastnode, which is used in
8666% cross-references.  The @node line might or might not have commas, and
8667% might or might not have spaces before the first comma, like:
8668% @node foo , bar , ...
8669% We don't want such trailing spaces in the node name.
8670%
8671\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
8672%
8673% also remove a trailing comma, in case of something like this:
8674% @node Help-Cross,  ,  , Cross-refs
8675\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
8676\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}\omittopnode}
8677
8678% Used so that the @top node doesn't have to be wrapped in an @ifnottex
8679% conditional.
8680% \doignore goes to more effort to skip nested conditionals but we don't need
8681% that here.
8682\def\omittopnode{%
8683   \ifx\lastnode\wordTop
8684   \expandafter\ignorenode\fi
8685}
8686\def\wordTop{Top}
8687
8688% Until the next @node or @bye command, divert output to a box that is not
8689% output.
8690\def\ignorenode{\setbox\dummybox\vbox\bgroup\def\node{\egroup\node}%
8691\ignorenodebye
8692}
8693
8694{\let\bye\relax
8695\gdef\ignorenodebye{\let\bye\ignorenodebyedef}
8696\gdef\ignorenodebyedef{\egroup(`Top' node ignored)\bye}}
8697% The redefinition of \bye here is because it is declared \outer
8698
8699\let\lastnode=\empty
8700
8701% Write a cross-reference definition for the current node.  #1 is the
8702% type (Ynumbered, Yappendix, Ynothing).
8703%
8704\def\donoderef#1{%
8705  \ifx\lastnode\empty\else
8706    \setref{\lastnode}{#1}%
8707    \global\let\lastnode=\empty
8708  \fi
8709}
8710
8711% @anchor{NAME} -- define xref target at arbitrary point.
8712%
8713\newcount\savesfregister
8714%
8715\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
8716\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
8717\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
8718
8719% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
8720% anchor), which consists of three parts:
8721% 1) NAME-title - the current sectioning name taken from \currentsection,
8722%                 or the anchor name.
8723% 2) NAME-snt   - section number and type, passed as the SNT arg, or
8724%                 empty for anchors.
8725% 3) NAME-pg    - the page number.
8726%
8727% This is called from \donoderef, \anchor, and \dofloat.  In the case of
8728% floats, there is an additional part, which is not written here:
8729% 4) NAME-lof   - the text as it should appear in a @listoffloats.
8730%
8731\def\setref#1#2{%
8732  \pdfmkdest{#1}%
8733  \iflinks
8734    {%
8735      \requireauxfile
8736      \atdummies  % preserve commands, but don't expand them
8737      % match definition in \xrdef, \refx, \xrefX.
8738      \def\value##1{##1}%
8739      \edef\writexrdef##1##2{%
8740	\write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
8741	  ##1}{##2}}% these are parameters of \writexrdef
8742      }%
8743      \toks0 = \expandafter{\currentsection}%
8744      \immediate \writexrdef{title}{\the\toks0 }%
8745      \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
8746      \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
8747    }%
8748  \fi
8749}
8750
8751% @xrefautosectiontitle on|off says whether @section(ing) names are used
8752% automatically in xrefs, if the third arg is not explicitly specified.
8753% This was provided as a "secret" @set xref-automatic-section-title
8754% variable, now it's official.
8755%
8756\parseargdef\xrefautomaticsectiontitle{%
8757  \def\temp{#1}%
8758  \ifx\temp\onword
8759    \expandafter\let\csname SETxref-automatic-section-title\endcsname
8760      = \empty
8761  \else\ifx\temp\offword
8762    \expandafter\let\csname SETxref-automatic-section-title\endcsname
8763      = \relax
8764  \else
8765    \errhelp = \EMsimple
8766    \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
8767                must be on|off}%
8768  \fi\fi
8769}
8770
8771%
8772% @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
8773% the node name, #2 the name of the Info cross-reference, #3 the printed
8774% node name, #4 the name of the Info file, #5 the name of the printed
8775% manual.  All but the node name can be omitted.
8776%
8777\def\pxref{\putwordsee{} \xrefXX}
8778\def\xref{\putwordSee{} \xrefXX}
8779\def\ref{\xrefXX}
8780
8781\def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
8782\def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
8783%
8784\newbox\toprefbox
8785\newbox\printedrefnamebox
8786\newbox\infofilenamebox
8787\newbox\printedmanualbox
8788%
8789\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
8790  \unsepspaces
8791  %
8792  % Get args without leading/trailing spaces.
8793  \def\printedrefname{\ignorespaces #3}%
8794  \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
8795  %
8796  \def\infofilename{\ignorespaces #4}%
8797  \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
8798  %
8799  \def\printedmanual{\ignorespaces #5}%
8800  \setbox\printedmanualbox  = \hbox{\printedmanual\unskip}%
8801  %
8802  % If the printed reference name (arg #3) was not explicitly given in
8803  % the @xref, figure out what we want to use.
8804  \ifdim \wd\printedrefnamebox = 0pt
8805    % No printed node name was explicitly given.
8806    \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
8807      % Not auto section-title: use node name inside the square brackets.
8808      \def\printedrefname{\ignorespaces #1}%
8809    \else
8810      % Auto section-title: use chapter/section title inside
8811      % the square brackets if we have it.
8812      \ifdim \wd\printedmanualbox > 0pt
8813        % It is in another manual, so we don't have it; use node name.
8814        \def\printedrefname{\ignorespaces #1}%
8815      \else
8816        \ifhavexrefs
8817          % We (should) know the real title if we have the xref values.
8818          \def\printedrefname{\refx{#1-title}}%
8819        \else
8820          % Otherwise just copy the Info node name.
8821          \def\printedrefname{\ignorespaces #1}%
8822        \fi%
8823      \fi
8824    \fi
8825  \fi
8826  %
8827  % Make link in pdf output.
8828  \ifpdf
8829    % For pdfTeX and LuaTeX
8830    {\indexnofonts
8831     \makevalueexpandable
8832     \turnoffactive
8833     % This expands tokens, so do it after making catcode changes, so _
8834     % etc. don't get their TeX definitions.  This ignores all spaces in
8835     % #4, including (wrongly) those in the middle of the filename.
8836     \getfilename{#4}%
8837     %
8838     % This (wrongly) does not take account of leading or trailing
8839     % spaces in #1, which should be ignored.
8840     \setpdfdestname{#1}%
8841     %
8842     \ifx\pdfdestname\empty
8843       \def\pdfdestname{Top}% no empty targets
8844     \fi
8845     %
8846     \leavevmode
8847     \startlink attr{/Border [0 0 0]}%
8848     \ifnum\filenamelength>0
8849       goto file{\the\filename.pdf} name{\pdfdestname}%
8850     \else
8851       goto name{\pdfmkpgn{\pdfdestname}}%
8852     \fi
8853    }%
8854    \setcolor{\linkcolor}%
8855  \else
8856    \ifx\XeTeXrevision\thisisundefined
8857    \else
8858      % For XeTeX
8859      {\indexnofonts
8860       \makevalueexpandable
8861       \turnoffactive
8862       % This expands tokens, so do it after making catcode changes, so _
8863       % etc. don't get their TeX definitions.  This ignores all spaces in
8864       % #4, including (wrongly) those in the middle of the filename.
8865       \getfilename{#4}%
8866       %
8867       % This (wrongly) does not take account of leading or trailing
8868       % spaces in #1, which should be ignored.
8869       \setpdfdestname{#1}%
8870       %
8871       \ifx\pdfdestname\empty
8872         \def\pdfdestname{Top}% no empty targets
8873       \fi
8874       %
8875       \leavevmode
8876       \ifnum\filenamelength>0
8877         % With default settings,
8878         % XeTeX (xdvipdfmx) replaces link destination names with integers.
8879         % In this case, the replaced destination names of
8880         % remote PDFs are no longer known.  In order to avoid a replacement,
8881         % you can use xdvipdfmx's command line option `-C 0x0010'.
8882         % If you use XeTeX 0.99996+ (TeX Live 2016+),
8883         % this command line option is no longer necessary
8884         % because we can use the `dvipdfmx:config' special.
8885         \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8886           << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}%
8887       \else
8888         \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8889           << /S /GoTo /D (\pdfdestname) >> >>}%
8890       \fi
8891      }%
8892      \setcolor{\linkcolor}%
8893    \fi
8894  \fi
8895  {%
8896    % Have to otherify everything special to allow the \csname to
8897    % include an _ in the xref name, etc.
8898    \indexnofonts
8899    \turnoffactive
8900    \def\value##1{##1}%
8901    \expandafter\global\expandafter\let\expandafter\Xthisreftitle
8902      \csname XR#1-title\endcsname
8903  }%
8904  %
8905  % Float references are printed completely differently: "Figure 1.2"
8906  % instead of "[somenode], p.3".  \iffloat distinguishes them by
8907  % \Xthisreftitle being set to a magic string.
8908  \iffloat\Xthisreftitle
8909    % If the user specified the print name (third arg) to the ref,
8910    % print it instead of our usual "Figure 1.2".
8911    \ifdim\wd\printedrefnamebox = 0pt
8912      \refx{#1-snt}%
8913    \else
8914      \printedrefname
8915    \fi
8916    %
8917    % If the user also gave the printed manual name (fifth arg), append
8918    % "in MANUALNAME".
8919    \ifdim \wd\printedmanualbox > 0pt
8920      \space \putwordin{} \cite{\printedmanual}%
8921    \fi
8922  \else
8923    % node/anchor (non-float) references.
8924    %
8925    % If we use \unhbox to print the node names, TeX does not insert
8926    % empty discretionaries after hyphens, which means that it will not
8927    % find a line break at a hyphen in a node names.  Since some manuals
8928    % are best written with fairly long node names, containing hyphens,
8929    % this is a loss.  Therefore, we give the text of the node name
8930    % again, so it is as if TeX is seeing it for the first time.
8931    %
8932    \ifdim \wd\printedmanualbox > 0pt
8933      % Cross-manual reference with a printed manual name.
8934      %
8935      \crossmanualxref{\cite{\printedmanual\unskip}}%
8936    %
8937    \else\ifdim \wd\infofilenamebox > 0pt
8938      % Cross-manual reference with only an info filename (arg 4), no
8939      % printed manual name (arg 5).  This is essentially the same as
8940      % the case above; we output the filename, since we have nothing else.
8941      %
8942      \crossmanualxref{\code{\infofilename\unskip}}%
8943    %
8944    \else
8945      % Reference within this manual.
8946      %
8947      % Only output a following space if the -snt ref is nonempty, as the ref
8948      % will be empty for @unnumbered and @anchor.
8949      \setbox2 = \hbox{\ignorespaces \refx{#1-snt}}%
8950      \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
8951      %
8952      % output the `[mynode]' via the macro below so it can be overridden.
8953      \xrefprintnodename\printedrefname
8954      %
8955      \expandafter\ifx\csname SETtxiomitxrefpg\endcsname\relax
8956        % But we always want a comma and a space:
8957        ,\space
8958        %
8959        % output the `page 3'.
8960        \turnoffactive \putwordpage\tie\refx{#1-pg}%
8961        % Add a , if xref followed by a space
8962        \if\space\noexpand\tokenafterxref ,%
8963        \else\ifx\	\tokenafterxref ,% @TAB
8964        \else\ifx\*\tokenafterxref ,%   @*
8965        \else\ifx\ \tokenafterxref ,%   @SPACE
8966        \else\ifx\
8967                  \tokenafterxref ,%    @NL
8968        \else\ifx\tie\tokenafterxref ,% @tie
8969        \fi\fi\fi\fi\fi\fi
8970      \fi
8971    \fi\fi
8972  \fi
8973  \endlink
8974\endgroup}
8975
8976% Output a cross-manual xref to #1.  Used just above (twice).
8977%
8978% Only include the text "Section ``foo'' in" if the foo is neither
8979% missing or Top.  Thus, @xref{,,,foo,The Foo Manual} outputs simply
8980% "see The Foo Manual", the idea being to refer to the whole manual.
8981%
8982% But, this being TeX, we can't easily compare our node name against the
8983% string "Top" while ignoring the possible spaces before and after in
8984% the input.  By adding the arbitrary 7sp below, we make it much less
8985% likely that a real node name would have the same width as "Top" (e.g.,
8986% in a monospaced font).  Hopefully it will never happen in practice.
8987%
8988% For the same basic reason, we retypeset the "Top" at every
8989% reference, since the current font is indeterminate.
8990%
8991\def\crossmanualxref#1{%
8992  \setbox\toprefbox = \hbox{Top\kern7sp}%
8993  \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
8994  \ifdim \wd2 > 7sp  % nonempty?
8995    \ifdim \wd2 = \wd\toprefbox \else  % same as Top?
8996      \putwordSection{} ``\printedrefname'' \putwordin{}\space
8997    \fi
8998  \fi
8999  #1%
9000}
9001
9002% This macro is called from \xrefX for the `[nodename]' part of xref
9003% output.  It's a separate macro only so it can be changed more easily,
9004% since square brackets don't work well in some documents.  Particularly
9005% one that Bob is working on :).
9006%
9007\def\xrefprintnodename#1{[#1]}
9008
9009% Things referred to by \setref.
9010%
9011\def\Ynothing{}
9012\def\Yomitfromtoc{}
9013\def\Ynumbered{%
9014  \ifnum\secno=0
9015    \putwordChapter@tie \the\chapno
9016  \else \ifnum\subsecno=0
9017    \putwordSection@tie \the\chapno.\the\secno
9018  \else \ifnum\subsubsecno=0
9019    \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
9020  \else
9021    \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
9022  \fi\fi\fi
9023}
9024\def\Yappendix{%
9025  \ifnum\secno=0
9026     \putwordAppendix@tie @char\the\appendixno{}%
9027  \else \ifnum\subsecno=0
9028     \putwordSection@tie @char\the\appendixno.\the\secno
9029  \else \ifnum\subsubsecno=0
9030    \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
9031  \else
9032    \putwordSection@tie
9033      @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
9034  \fi\fi\fi
9035}
9036
9037% \refx{NAME} - reference a cross-reference string named NAME.
9038\def\refx#1{%
9039  \requireauxfile
9040  {%
9041    \indexnofonts
9042    \turnoffactive
9043    \def\value##1{##1}%
9044    \expandafter\global\expandafter\let\expandafter\thisrefX
9045      \csname XR#1\endcsname
9046  }%
9047  \ifx\thisrefX\relax
9048    % If not defined, say something at least.
9049    \angleleft un\-de\-fined\angleright
9050    \iflinks
9051      \ifhavexrefs
9052        {\toks0 = {#1}% avoid expansion of possibly-complex value
9053         \message{\linenumber Undefined cross reference `\the\toks0'.}}%
9054      \else
9055        \ifwarnedxrefs\else
9056          \global\warnedxrefstrue
9057          \message{Cross reference values unknown; you must run TeX again.}%
9058        \fi
9059      \fi
9060    \fi
9061  \else
9062    % It's defined, so just use it.
9063    \thisrefX
9064  \fi
9065}
9066
9067% This is the macro invoked by entries in the aux file.  Define a control
9068% sequence for a cross-reference target (we prepend XR to the control sequence
9069% name to avoid collisions).  The value is the page number.  If this is a float
9070% type, we have more work to do.
9071%
9072\def\xrdef#1#2{%
9073  {% Expand the node or anchor name to remove control sequences.
9074   % \turnoffactive stops 8-bit characters being changed to commands
9075   % like @'e.  \refx does the same to retrieve the value in the definition.
9076    \indexnofonts
9077    \turnoffactive
9078    \def\value##1{##1}%
9079    \xdef\safexrefname{#1}%
9080  }%
9081  %
9082  \bgroup
9083    \expandafter\gdef\csname XR\safexrefname\endcsname{#2}%
9084  \egroup
9085  % We put the \gdef inside a group to avoid the definitions building up on
9086  % TeX's save stack, which can cause it to run out of space for aux files with
9087  % thousands of lines.  \gdef doesn't use the save stack, but \csname does
9088  % when it defines an unknown control sequence as \relax.
9089  %
9090  % Was that xref control sequence that we just defined for a float?
9091  \expandafter\iffloat\csname XR\safexrefname\endcsname
9092    % it was a float, and we have the (safe) float type in \iffloattype.
9093    \expandafter\let\expandafter\floatlist
9094      \csname floatlist\iffloattype\endcsname
9095    %
9096    % Is this the first time we've seen this float type?
9097    \expandafter\ifx\floatlist\relax
9098      \toks0 = {\do}% yes, so just \do
9099    \else
9100      % had it before, so preserve previous elements in list.
9101      \toks0 = \expandafter{\floatlist\do}%
9102    \fi
9103    %
9104    % Remember this xref in the control sequence \floatlistFLOATTYPE,
9105    % for later use in \listoffloats.
9106    \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
9107      {\safexrefname}}%
9108  \fi
9109}
9110
9111% If working on a large document in chapters, it is convenient to
9112% be able to disable indexing, cross-referencing, and contents, for test runs.
9113% This is done with @novalidate at the beginning of the file.
9114%
9115\newif\iflinks \linkstrue % by default we want the aux files.
9116\let\novalidate = \linksfalse
9117
9118% Used when writing to the aux file, or when using data from it.
9119\def\requireauxfile{%
9120  \iflinks
9121    \tryauxfile
9122    % Open the new aux file.  TeX will close it automatically at exit.
9123    \immediate\openout\auxfile=\jobname.aux
9124  \fi
9125  \global\let\requireauxfile=\relax   % Only do this once.
9126}
9127
9128% Read the last existing aux file, if any.  No error if none exists.
9129%
9130\def\tryauxfile{%
9131  \openin 1 \jobname.aux
9132  \ifeof 1 \else
9133    \readdatafile{aux}%
9134    \global\havexrefstrue
9135  \fi
9136  \closein 1
9137}
9138
9139\def\setupdatafile{%
9140  \catcode`\^^@=\other
9141  \catcode`\^^A=\other
9142  \catcode`\^^B=\other
9143  \catcode`\^^C=\other
9144  \catcode`\^^D=\other
9145  \catcode`\^^E=\other
9146  \catcode`\^^F=\other
9147  \catcode`\^^G=\other
9148  \catcode`\^^H=\other
9149  \catcode`\^^K=\other
9150  \catcode`\^^L=\other
9151  \catcode`\^^N=\other
9152  \catcode`\^^P=\other
9153  \catcode`\^^Q=\other
9154  \catcode`\^^R=\other
9155  \catcode`\^^S=\other
9156  \catcode`\^^T=\other
9157  \catcode`\^^U=\other
9158  \catcode`\^^V=\other
9159  \catcode`\^^W=\other
9160  \catcode`\^^X=\other
9161  \catcode`\^^Z=\other
9162  \catcode`\^^[=\other
9163  \catcode`\^^\=\other
9164  \catcode`\^^]=\other
9165  \catcode`\^^^=\other
9166  \catcode`\^^_=\other
9167  \catcode`\^=\other
9168  %
9169  % Special characters.  Should be turned off anyway, but...
9170  \catcode`\~=\other
9171  \catcode`\[=\other
9172  \catcode`\]=\other
9173  \catcode`\"=\other
9174  \catcode`\_=\active
9175  \catcode`\|=\active
9176  \catcode`\<=\active
9177  \catcode`\>=\active
9178  \catcode`\$=\other
9179  \catcode`\#=\other
9180  \catcode`\&=\other
9181  \catcode`\%=\other
9182  \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
9183  %
9184  \catcode`\\=\active
9185  %
9186  % @ is our escape character in .aux files, and we need braces.
9187  \catcode`\{=1
9188  \catcode`\}=2
9189  \catcode`\@=0
9190}
9191
9192\def\readdatafile#1{%
9193\begingroup
9194  \setupdatafile
9195  \input\jobname.#1
9196\endgroup}
9197
9198
9199\message{insertions,}
9200% including footnotes.
9201
9202\newcount \footnoteno
9203
9204% The trailing space in the following definition for supereject is
9205% vital for proper filling; pages come out unaligned when you do a
9206% pagealignmacro call if that space before the closing brace is
9207% removed. (Generally, numeric constants should always be followed by a
9208% space to prevent strange expansion errors.)
9209\def\supereject{\par\penalty -20000\footnoteno =0 }
9210
9211% @footnotestyle is meaningful for Info output only.
9212\let\footnotestyle=\comment
9213
9214{\catcode `\@=11
9215%
9216% Auto-number footnotes.  Otherwise like plain.
9217\gdef\footnote{%
9218  \global\advance\footnoteno by \@ne
9219  \edef\thisfootno{$^{\the\footnoteno}$}%
9220  %
9221  % In case the footnote comes at the end of a sentence, preserve the
9222  % extra spacing after we do the footnote number.
9223  \let\@sf\empty
9224  \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9225  %
9226  % Remove inadvertent blank space before typesetting the footnote number.
9227  \unskip
9228  \thisfootno\@sf
9229  \dofootnote
9230}%
9231
9232% Don't bother with the trickery in plain.tex to not require the
9233% footnote text as a parameter.  Our footnotes don't need to be so general.
9234%
9235% Oh yes, they do; otherwise, @ifset (and anything else that uses
9236% \parseargline) fails inside footnotes because the tokens are fixed when
9237% the footnote is read.  --karl, 16nov96.
9238%
9239\gdef\dofootnote{%
9240  \insert\footins\bgroup
9241  %
9242  % Nested footnotes are not supported in TeX, that would take a lot
9243  % more work.  (\startsavinginserts does not suffice.)
9244  \let\footnote=\errfootnotenest
9245  %
9246  % We want to typeset this text as a normal paragraph, even if the
9247  % footnote reference occurs in (for example) a display environment.
9248  % So reset some parameters.
9249  \hsize=\txipagewidth
9250  \interlinepenalty\interfootnotelinepenalty
9251  \splittopskip\ht\strutbox % top baseline for broken footnotes
9252  \splitmaxdepth\dp\strutbox
9253  \floatingpenalty\@MM
9254  \leftskip\z@skip
9255  \rightskip\z@skip
9256  \spaceskip\z@skip
9257  \xspaceskip\z@skip
9258  \parindent\defaultparindent
9259  %
9260  \smallfonts \rm
9261  %
9262  % Because we use hanging indentation in footnotes, a @noindent appears
9263  % to exdent this text, so make it be a no-op.  makeinfo does not use
9264  % hanging indentation so @noindent can still be needed within footnote
9265  % text after an @example or the like (not that this is good style).
9266  \let\noindent = \relax
9267  %
9268  % Hang the footnote text off the number.  Use \everypar in case the
9269  % footnote extends for more than one paragraph.
9270  \everypar = {\hang}%
9271  \textindent{\thisfootno}%
9272  %
9273  % Don't crash into the line above the footnote text.  Since this
9274  % expands into a box, it must come within the paragraph, lest it
9275  % provide a place where TeX can split the footnote.
9276  \footstrut
9277  %
9278  % Invoke rest of plain TeX footnote routine.
9279  \futurelet\next\fo@t
9280}
9281}%end \catcode `\@=11
9282
9283\def\errfootnotenest{%
9284  \errhelp=\EMsimple
9285  \errmessage{Nested footnotes not supported in texinfo.tex,
9286    even though they work in makeinfo; sorry}
9287}
9288
9289\def\errfootnoteheading{%
9290  \errhelp=\EMsimple
9291  \errmessage{Footnotes in chapters, sections, etc., are not supported}
9292}
9293
9294% In case a @footnote appears in a vbox, save the footnote text and create
9295% the real \insert just after the vbox finished.  Otherwise, the insertion
9296% would be lost.
9297% Similarly, if a @footnote appears inside an alignment, save the footnote
9298% text to a box and make the \insert when a row of the table is finished.
9299% And the same can be done for other insert classes.  --kasal, 16nov03.
9300%
9301% Replace the \insert primitive by a cheating macro.
9302% Deeper inside, just make sure that the saved insertions are not spilled
9303% out prematurely.
9304%
9305\def\startsavinginserts{%
9306  \ifx \insert\ptexinsert
9307    \let\insert\saveinsert
9308  \else
9309    \let\checkinserts\relax
9310  \fi
9311}
9312
9313% This \insert replacement works for both \insert\footins{foo} and
9314% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9315%
9316\def\saveinsert#1{%
9317  \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9318  \afterassignment\next
9319  % swallow the left brace
9320  \let\temp =
9321}
9322\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9323\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9324
9325\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9326
9327\def\placesaveins#1{%
9328  \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9329    {\box#1}%
9330}
9331
9332% eat @SAVE -- beware, all of them have catcode \other:
9333{
9334  \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials  %  ;-)
9335  \gdef\gobblesave @SAVE{}
9336}
9337
9338% initialization:
9339\def\newsaveins #1{%
9340  \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9341  \next
9342}
9343\def\newsaveinsX #1{%
9344  \csname newbox\endcsname #1%
9345  \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9346    \checksaveins #1}%
9347}
9348
9349% initialize:
9350\let\checkinserts\empty
9351\newsaveins\footins
9352\newsaveins\margin
9353
9354
9355% @image.  We use the macros from epsf.tex to support this.
9356% If epsf.tex is not installed and @image is used, we complain.
9357%
9358% Check for and read epsf.tex up front.  If we read it only at @image
9359% time, we might be inside a group, and then its definitions would get
9360% undone and the next image would fail.
9361\openin 1 = epsf.tex
9362\ifeof 1 \else
9363  % Do not bother showing banner with epsf.tex v2.7k (available in
9364  % doc/epsf.tex and on ctan).
9365  \def\epsfannounce{\toks0 = }%
9366  \input epsf.tex
9367\fi
9368\closein 1
9369%
9370% We will only complain once about lack of epsf.tex.
9371\newif\ifwarnednoepsf
9372\newhelp\noepsfhelp{epsf.tex must be installed for images to
9373  work.  It is also included in the Texinfo distribution, or you can get
9374  it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.}
9375%
9376\def\image#1{%
9377  \ifx\epsfbox\thisisundefined
9378    \ifwarnednoepsf \else
9379      \errhelp = \noepsfhelp
9380      \errmessage{epsf.tex not found, images will be ignored}%
9381      \global\warnednoepsftrue
9382    \fi
9383  \else
9384    \imagexxx #1,,,,,\finish
9385  \fi
9386}
9387%
9388% Arguments to @image:
9389% #1 is (mandatory) image filename; we tack on .eps extension.
9390% #2 is (optional) width, #3 is (optional) height.
9391% #4 is (ignored optional) html alt text.
9392% #5 is (ignored optional) extension.
9393% #6 is just the usual extra ignored arg for parsing stuff.
9394\newif\ifimagevmode
9395\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
9396  \catcode`\^^M = 5     % in case we're inside an example
9397  \normalturnoffactive  % allow _ et al. in names
9398  \makevalueexpandable
9399  % If the image is by itself, center it.
9400  \ifvmode
9401    \imagevmodetrue
9402  \else \ifx\centersub\centerV
9403    % for @center @image, we need a vbox so we can have our vertical space
9404    \imagevmodetrue
9405    \vbox\bgroup % vbox has better behavior than vtop herev
9406  \fi\fi
9407  %
9408  \ifimagevmode
9409    \medskip
9410    % Usually we'll have text after the image which will insert
9411    % \parskip glue, so insert it here too to equalize the space
9412    % above and below.
9413    \nobreak\vskip\parskip
9414    \nobreak
9415  \fi
9416  %
9417  % Leave vertical mode so that indentation from an enclosing
9418  %  environment such as @quotation is respected.
9419  % However, if we're at the top level, we don't want the
9420  %  normal paragraph indentation.
9421  % On the other hand, if we are in the case of @center @image, we don't
9422  %  want to start a paragraph, which will create a hsize-width box and
9423  %  eradicate the centering.
9424  \ifx\centersub\centerV \else \imageindent \fi
9425  %
9426  % Output the image.
9427  \ifpdf
9428    % For pdfTeX and LuaTeX <= 0.80
9429    \dopdfimage{#1}{#2}{#3}%
9430  \else
9431    \ifx\XeTeXrevision\thisisundefined
9432      % For epsf.tex
9433      % \epsfbox itself resets \epsf?size at each figure.
9434      \setbox0 = \hbox{\ignorespaces #2}%
9435        \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9436      \setbox0 = \hbox{\ignorespaces #3}%
9437        \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9438      \epsfbox{#1.eps}%
9439    \else
9440      % For XeTeX
9441      \doxeteximage{#1}{#2}{#3}%
9442    \fi
9443  \fi
9444  %
9445  \ifimagevmode
9446    \medskip  % space after a standalone image
9447  \fi
9448  \ifx\centersub\centerV \egroup \fi
9449\endgroup}
9450
9451
9452% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9453% etc.  We don't actually implement floating yet, we always include the
9454% float "here".  But it seemed the best name for the future.
9455%
9456\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9457
9458% There may be a space before second and/or third parameter; delete it.
9459\def\eatcommaspace#1, {#1,}
9460
9461% #1 is the optional FLOATTYPE, the text label for this float, typically
9462% "Figure", "Table", "Example", etc.  Can't contain commas.  If omitted,
9463% this float will not be numbered and cannot be referred to.
9464%
9465% #2 is the optional xref label.  Also must be present for the float to
9466% be referable.
9467%
9468% #3 is the optional positioning argument; for now, it is ignored.  It
9469% will somehow specify the positions allowed to float to (here, top, bottom).
9470%
9471% We keep a separate counter for each FLOATTYPE, which we reset at each
9472% chapter-level command.
9473\let\resetallfloatnos=\empty
9474%
9475\def\dofloat#1,#2,#3,#4\finish{%
9476  \let\thiscaption=\empty
9477  \let\thisshortcaption=\empty
9478  %
9479  % don't lose footnotes inside @float.
9480  %
9481  % BEWARE: when the floats start float, we have to issue warning whenever an
9482  % insert appears inside a float which could possibly float. --kasal, 26may04
9483  %
9484  \startsavinginserts
9485  %
9486  % We can't be used inside a paragraph.
9487  \par
9488  %
9489  \vtop\bgroup
9490    \def\floattype{#1}%
9491    \def\floatlabel{#2}%
9492    \def\floatloc{#3}% we do nothing with this yet.
9493    %
9494    \ifx\floattype\empty
9495      \let\safefloattype=\empty
9496    \else
9497      {%
9498        % the floattype might have accents or other special characters,
9499        % but we need to use it in a control sequence name.
9500        \indexnofonts
9501        \turnoffactive
9502        \xdef\safefloattype{\floattype}%
9503      }%
9504    \fi
9505    %
9506    % If label is given but no type, we handle that as the empty type.
9507    \ifx\floatlabel\empty \else
9508      % We want each FLOATTYPE to be numbered separately (Figure 1,
9509      % Table 1, Figure 2, ...).  (And if no label, no number.)
9510      %
9511      \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9512      \global\advance\floatno by 1
9513      %
9514      {%
9515        % This magic value for \currentsection is output by \setref as the
9516        % XREFLABEL-title value.  \xrefX uses it to distinguish float
9517        % labels (which have a completely different output format) from
9518        % node and anchor labels.  And \xrdef uses it to construct the
9519        % lists of floats.
9520        %
9521        \edef\currentsection{\floatmagic=\safefloattype}%
9522        \setref{\floatlabel}{Yfloat}%
9523      }%
9524    \fi
9525    %
9526    % start with \parskip glue, I guess.
9527    \vskip\parskip
9528    %
9529    % Don't suppress indentation if a float happens to start a section.
9530    \restorefirstparagraphindent
9531}
9532
9533% we have these possibilities:
9534% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9535% @float Foo,lbl & no caption:    Foo 1.1
9536% @float Foo & @caption{Cap}:     Foo: Cap
9537% @float Foo & no caption:        Foo
9538% @float ,lbl & Caption{Cap}:     1.1: Cap
9539% @float ,lbl & no caption:       1.1
9540% @float & @caption{Cap}:         Cap
9541% @float & no caption:
9542%
9543\def\Efloat{%
9544    \let\floatident = \empty
9545    %
9546    % In all cases, if we have a float type, it comes first.
9547    \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9548    %
9549    % If we have an xref label, the number comes next.
9550    \ifx\floatlabel\empty \else
9551      \ifx\floattype\empty \else % if also had float type, need tie first.
9552        \appendtomacro\floatident{\tie}%
9553      \fi
9554      % the number.
9555      \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9556    \fi
9557    %
9558    % Start the printed caption with what we've constructed in
9559    % \floatident, but keep it separate; we need \floatident again.
9560    \let\captionline = \floatident
9561    %
9562    \ifx\thiscaption\empty \else
9563      \ifx\floatident\empty \else
9564        \appendtomacro\captionline{: }% had ident, so need a colon between
9565      \fi
9566      %
9567      % caption text.
9568      \appendtomacro\captionline{\scanexp\thiscaption}%
9569    \fi
9570    %
9571    % If we have anything to print, print it, with space before.
9572    % Eventually this needs to become an \insert.
9573    \ifx\captionline\empty \else
9574      \vskip.5\parskip
9575      \captionline
9576      %
9577      % Space below caption.
9578      \vskip\parskip
9579    \fi
9580    %
9581    % If have an xref label, write the list of floats info.  Do this
9582    % after the caption, to avoid chance of it being a breakpoint.
9583    \ifx\floatlabel\empty \else
9584      % Write the text that goes in the lof to the aux file as
9585      % \floatlabel-lof.  Besides \floatident, we include the short
9586      % caption if specified, else the full caption if specified, else nothing.
9587      {%
9588        \requireauxfile
9589        \atdummies
9590        %
9591        \ifx\thisshortcaption\empty
9592          \def\gtemp{\thiscaption}%
9593        \else
9594          \def\gtemp{\thisshortcaption}%
9595        \fi
9596        \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
9597          \ifx\gtemp\empty \else : \gtemp \fi}}%
9598      }%
9599    \fi
9600  \egroup  % end of \vtop
9601  %
9602  \checkinserts
9603}
9604
9605% Append the tokens #2 to the definition of macro #1, not expanding either.
9606%
9607\def\appendtomacro#1#2{%
9608  \expandafter\def\expandafter#1\expandafter{#1#2}%
9609}
9610
9611% @caption, @shortcaption
9612%
9613\def\caption{\docaption\thiscaption}
9614\def\shortcaption{\docaption\thisshortcaption}
9615\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
9616\def\defcaption#1#2{\egroup \def#1{#2}}
9617
9618% The parameter is the control sequence identifying the counter we are
9619% going to use.  Create it if it doesn't exist and assign it to \floatno.
9620\def\getfloatno#1{%
9621  \ifx#1\relax
9622      % Haven't seen this figure type before.
9623      \csname newcount\endcsname #1%
9624      %
9625      % Remember to reset this floatno at the next chap.
9626      \expandafter\gdef\expandafter\resetallfloatnos
9627        \expandafter{\resetallfloatnos #1=0 }%
9628  \fi
9629  \let\floatno#1%
9630}
9631
9632% \setref calls this to get the XREFLABEL-snt value.  We want an @xref
9633% to the FLOATLABEL to expand to "Figure 3.1".  We call \setref when we
9634% first read the @float command.
9635%
9636\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9637
9638% Magic string used for the XREFLABEL-title value, so \xrefX can
9639% distinguish floats from other xref types.
9640\def\floatmagic{!!float!!}
9641
9642% #1 is the control sequence we are passed; we expand into a conditional
9643% which is true if #1 represents a float ref.  That is, the magic
9644% \currentsection value which we \setref above.
9645%
9646\def\iffloat#1{\expandafter\doiffloat#1==\finish}
9647%
9648% #1 is (maybe) the \floatmagic string.  If so, #2 will be the
9649% (safe) float type for this float.  We set \iffloattype to #2.
9650%
9651\def\doiffloat#1=#2=#3\finish{%
9652  \def\temp{#1}%
9653  \def\iffloattype{#2}%
9654  \ifx\temp\floatmagic
9655}
9656
9657% @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9658%
9659\parseargdef\listoffloats{%
9660  \def\floattype{#1}% floattype
9661  {%
9662    % the floattype might have accents or other special characters,
9663    % but we need to use it in a control sequence name.
9664    \indexnofonts
9665    \turnoffactive
9666    \xdef\safefloattype{\floattype}%
9667  }%
9668  %
9669  % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9670  \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9671    \ifhavexrefs
9672      % if the user said @listoffloats foo but never @float foo.
9673      \message{\linenumber No `\safefloattype' floats to list.}%
9674    \fi
9675  \else
9676    \begingroup
9677      \leftskip=\tocindent  % indent these entries like a toc
9678      \let\do=\listoffloatsdo
9679      \csname floatlist\safefloattype\endcsname
9680    \endgroup
9681  \fi
9682}
9683
9684% This is called on each entry in a list of floats.  We're passed the
9685% xref label, in the form LABEL-title, which is how we save it in the
9686% aux file.  We strip off the -title and look up \XRLABEL-lof, which
9687% has the text we're supposed to typeset here.
9688%
9689% Figures without xref labels will not be included in the list (since
9690% they won't appear in the aux file).
9691%
9692\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9693\def\listoffloatsdoentry#1-title\finish{{%
9694  % Can't fully expand XR#1-lof because it can contain anything.  Just
9695  % pass the control sequence.  On the other hand, XR#1-pg is just the
9696  % page number, and we want to fully expand that so we can get a link
9697  % in pdf output.
9698  \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9699  %
9700  % use the same \entry macro we use to generate the TOC and index.
9701  \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9702  \writeentry
9703}}
9704
9705
9706\message{localization,}
9707
9708% For single-language documents, @documentlanguage is usually given very
9709% early, just after @documentencoding.  Single argument is the language
9710% (de) or locale (de_DE) abbreviation.
9711%
9712{
9713  \catcode`\_ = \active
9714  \globaldefs=1
9715\parseargdef\documentlanguage{%
9716  \tex % read txi-??.tex file in plain TeX.
9717    % Read the file by the name they passed if it exists.
9718    \let_ = \normalunderscore  % normal _ character for filename test
9719    \openin 1 txi-#1.tex
9720    \ifeof 1
9721      \documentlanguagetrywithoutunderscore #1_\finish
9722    \else
9723      \globaldefs = 1  % everything in the txi-LL files needs to persist
9724      \input txi-#1.tex
9725    \fi
9726    \closein 1
9727  \endgroup % end raw TeX
9728}
9729%
9730% If they passed de_DE, and txi-de_DE.tex doesn't exist,
9731% try txi-de.tex.
9732%
9733\gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
9734  \openin 1 txi-#1.tex
9735  \ifeof 1
9736    \errhelp = \nolanghelp
9737    \errmessage{Cannot read language file txi-#1.tex}%
9738  \else
9739    \globaldefs = 1  % everything in the txi-LL files needs to persist
9740    \input txi-#1.tex
9741  \fi
9742  \closein 1
9743}
9744}% end of special _ catcode
9745%
9746\newhelp\nolanghelp{The given language definition file cannot be found or
9747is empty.  Maybe you need to install it?  Putting it in the current
9748directory should work if nowhere else does.}
9749
9750% This macro is called from txi-??.tex files; the first argument is the
9751% \language name to set (without the "\lang@" prefix), the second and
9752% third args are \{left,right}hyphenmin.
9753%
9754% The language names to pass are determined when the format is built.
9755% See the etex.log file created at that time, e.g.,
9756% /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9757%
9758% With TeX Live 2008, etex now includes hyphenation patterns for all
9759% available languages.  This means we can support hyphenation in
9760% Texinfo, at least to some extent.  (This still doesn't solve the
9761% accented characters problem.)
9762%
9763\catcode`@=11
9764\def\txisetlanguage#1#2#3{%
9765  % do not set the language if the name is undefined in the current TeX.
9766  \expandafter\ifx\csname lang@#1\endcsname \relax
9767    \message{no patterns for #1}%
9768  \else
9769    \global\language = \csname lang@#1\endcsname
9770  \fi
9771  % but there is no harm in adjusting the hyphenmin values regardless.
9772  \global\lefthyphenmin = #2\relax
9773  \global\righthyphenmin = #3\relax
9774}
9775
9776% XeTeX and LuaTeX can handle Unicode natively.
9777% Their default I/O uses UTF-8 sequences instead of a byte-wise operation.
9778% Other TeX engines' I/O (pdfTeX, etc.) is byte-wise.
9779%
9780\newif\iftxinativeunicodecapable
9781\newif\iftxiusebytewiseio
9782
9783\ifx\XeTeXrevision\thisisundefined
9784  \ifx\luatexversion\thisisundefined
9785    \txinativeunicodecapablefalse
9786    \txiusebytewiseiotrue
9787  \else
9788    \txinativeunicodecapabletrue
9789    \txiusebytewiseiofalse
9790  \fi
9791\else
9792  \txinativeunicodecapabletrue
9793  \txiusebytewiseiofalse
9794\fi
9795
9796% Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9797% for non-UTF-8 (byte-wise) encodings.
9798%
9799\def\setbytewiseio{%
9800  \ifx\XeTeXrevision\thisisundefined
9801  \else
9802    \XeTeXdefaultencoding "bytes"  % For subsequent files to be read
9803    \XeTeXinputencoding "bytes"  % For document root file
9804    % Unfortunately, there seems to be no corresponding XeTeX command for
9805    % output encoding.  This is a problem for auxiliary index and TOC files.
9806    % The only solution would be perhaps to write out @U{...} sequences in
9807    % place of non-ASCII characters.
9808  \fi
9809
9810  \ifx\luatexversion\thisisundefined
9811  \else
9812    \directlua{
9813    local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9814    local function convert_char (char)
9815      return utf8_char(byte(char))
9816    end
9817
9818    local function convert_line (line)
9819      return gsub(line, ".", convert_char)
9820    end
9821
9822    callback.register("process_input_buffer", convert_line)
9823
9824    local function convert_line_out (line)
9825      local line_out = ""
9826      for c in string.utfvalues(line) do
9827         line_out = line_out .. string.char(c)
9828      end
9829      return line_out
9830    end
9831
9832    callback.register("process_output_buffer", convert_line_out)
9833    }
9834  \fi
9835
9836  \txiusebytewiseiotrue
9837}
9838
9839
9840% Helpers for encodings.
9841% Set the catcode of characters 128 through 255 to the specified number.
9842%
9843\def\setnonasciicharscatcode#1{%
9844   \count255=128
9845   \loop\ifnum\count255<256
9846      \global\catcode\count255=#1\relax
9847      \advance\count255 by 1
9848   \repeat
9849}
9850
9851\def\setnonasciicharscatcodenonglobal#1{%
9852   \count255=128
9853   \loop\ifnum\count255<256
9854      \catcode\count255=#1\relax
9855      \advance\count255 by 1
9856   \repeat
9857}
9858
9859% @documentencoding sets the definition of non-ASCII characters
9860% according to the specified encoding.
9861%
9862\def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9863\def\documentencodingzzz#1{%
9864  %
9865  % Encoding being declared for the document.
9866  \def\declaredencoding{\csname #1.enc\endcsname}%
9867  %
9868  % Supported encodings: names converted to tokens in order to be able
9869  % to compare them with \ifx.
9870  \def\ascii{\csname US-ASCII.enc\endcsname}%
9871  \def\latnine{\csname ISO-8859-15.enc\endcsname}%
9872  \def\latone{\csname ISO-8859-1.enc\endcsname}%
9873  \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
9874  \def\utfeight{\csname UTF-8.enc\endcsname}%
9875  %
9876  \ifx \declaredencoding \ascii
9877     \asciichardefs
9878  %
9879  \else \ifx \declaredencoding \lattwo
9880     \iftxinativeunicodecapable
9881       \setbytewiseio
9882     \fi
9883     \setnonasciicharscatcode\active
9884     \lattwochardefs
9885  %
9886  \else \ifx \declaredencoding \latone
9887     \iftxinativeunicodecapable
9888       \setbytewiseio
9889     \fi
9890     \setnonasciicharscatcode\active
9891     \latonechardefs
9892  %
9893  \else \ifx \declaredencoding \latnine
9894     \iftxinativeunicodecapable
9895       \setbytewiseio
9896     \fi
9897     \setnonasciicharscatcode\active
9898     \latninechardefs
9899  %
9900  \else \ifx \declaredencoding \utfeight
9901     \iftxinativeunicodecapable
9902       % For native Unicode handling (XeTeX and LuaTeX)
9903       \nativeunicodechardefs
9904     \else
9905       % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX)
9906       \setnonasciicharscatcode\active
9907       % since we already invoked \utfeightchardefs at the top level
9908       % (below), do not re-invoke it, otherwise our check for duplicated
9909       % definitions gets triggered.  Making non-ascii chars active is
9910       % sufficient.
9911     \fi
9912  %
9913  \else
9914    \message{Ignoring unknown document encoding: #1.}%
9915  %
9916  \fi % utfeight
9917  \fi % latnine
9918  \fi % latone
9919  \fi % lattwo
9920  \fi % ascii
9921  %
9922  \ifx\XeTeXrevision\thisisundefined
9923  \else
9924    \ifx \declaredencoding \utfeight
9925    \else
9926      \ifx \declaredencoding \ascii
9927      \else
9928        \message{Warning: XeTeX with non-UTF-8 encodings cannot handle %
9929        non-ASCII characters in auxiliary files.}%
9930      \fi
9931    \fi
9932  \fi
9933}
9934
9935% emacs-page
9936% A message to be logged when using a character that isn't available
9937% the default font encoding (OT1).
9938%
9939\def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
9940
9941% Take account of \c (plain) vs. \, (Texinfo) difference.
9942\def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
9943
9944% First, make active non-ASCII characters in order for them to be
9945% correctly categorized when TeX reads the replacement text of
9946% macros containing the character definitions.
9947\setnonasciicharscatcode\active
9948%
9949
9950\def\gdefchar#1#2{%
9951\gdef#1{%
9952   \ifpassthroughchars
9953     \string#1%
9954   \else
9955     #2%
9956   \fi
9957}}
9958
9959% Latin1 (ISO-8859-1) character definitions.
9960\def\latonechardefs{%
9961  \gdefchar^^a0{\tie}
9962  \gdefchar^^a1{\exclamdown}
9963  \gdefchar^^a2{{\tcfont \char162}} % cent
9964  \gdefchar^^a3{\pounds{}}
9965  \gdefchar^^a4{{\tcfont \char164}} % currency
9966  \gdefchar^^a5{{\tcfont \char165}} % yen
9967  \gdefchar^^a6{{\tcfont \char166}} % broken bar
9968  \gdefchar^^a7{\S}
9969  \gdefchar^^a8{\"{}}
9970  \gdefchar^^a9{\copyright{}}
9971  \gdefchar^^aa{\ordf}
9972  \gdefchar^^ab{\guillemetleft{}}
9973  \gdefchar^^ac{\ensuremath\lnot}
9974  \gdefchar^^ad{\-}
9975  \gdefchar^^ae{\registeredsymbol{}}
9976  \gdefchar^^af{\={}}
9977  %
9978  \gdefchar^^b0{\textdegree}
9979  \gdefchar^^b1{$\pm$}
9980  \gdefchar^^b2{$^2$}
9981  \gdefchar^^b3{$^3$}
9982  \gdefchar^^b4{\'{}}
9983  \gdefchar^^b5{$\mu$}
9984  \gdefchar^^b6{\P}
9985  \gdefchar^^b7{\ensuremath\cdot}
9986  \gdefchar^^b8{\cedilla\ }
9987  \gdefchar^^b9{$^1$}
9988  \gdefchar^^ba{\ordm}
9989  \gdefchar^^bb{\guillemetright{}}
9990  \gdefchar^^bc{$1\over4$}
9991  \gdefchar^^bd{$1\over2$}
9992  \gdefchar^^be{$3\over4$}
9993  \gdefchar^^bf{\questiondown}
9994  %
9995  \gdefchar^^c0{\`A}
9996  \gdefchar^^c1{\'A}
9997  \gdefchar^^c2{\^A}
9998  \gdefchar^^c3{\~A}
9999  \gdefchar^^c4{\"A}
10000  \gdefchar^^c5{\ringaccent A}
10001  \gdefchar^^c6{\AE}
10002  \gdefchar^^c7{\cedilla C}
10003  \gdefchar^^c8{\`E}
10004  \gdefchar^^c9{\'E}
10005  \gdefchar^^ca{\^E}
10006  \gdefchar^^cb{\"E}
10007  \gdefchar^^cc{\`I}
10008  \gdefchar^^cd{\'I}
10009  \gdefchar^^ce{\^I}
10010  \gdefchar^^cf{\"I}
10011  %
10012  \gdefchar^^d0{\DH}
10013  \gdefchar^^d1{\~N}
10014  \gdefchar^^d2{\`O}
10015  \gdefchar^^d3{\'O}
10016  \gdefchar^^d4{\^O}
10017  \gdefchar^^d5{\~O}
10018  \gdefchar^^d6{\"O}
10019  \gdefchar^^d7{$\times$}
10020  \gdefchar^^d8{\O}
10021  \gdefchar^^d9{\`U}
10022  \gdefchar^^da{\'U}
10023  \gdefchar^^db{\^U}
10024  \gdefchar^^dc{\"U}
10025  \gdefchar^^dd{\'Y}
10026  \gdefchar^^de{\TH}
10027  \gdefchar^^df{\ss}
10028  %
10029  \gdefchar^^e0{\`a}
10030  \gdefchar^^e1{\'a}
10031  \gdefchar^^e2{\^a}
10032  \gdefchar^^e3{\~a}
10033  \gdefchar^^e4{\"a}
10034  \gdefchar^^e5{\ringaccent a}
10035  \gdefchar^^e6{\ae}
10036  \gdefchar^^e7{\cedilla c}
10037  \gdefchar^^e8{\`e}
10038  \gdefchar^^e9{\'e}
10039  \gdefchar^^ea{\^e}
10040  \gdefchar^^eb{\"e}
10041  \gdefchar^^ec{\`{\dotless i}}
10042  \gdefchar^^ed{\'{\dotless i}}
10043  \gdefchar^^ee{\^{\dotless i}}
10044  \gdefchar^^ef{\"{\dotless i}}
10045  %
10046  \gdefchar^^f0{\dh}
10047  \gdefchar^^f1{\~n}
10048  \gdefchar^^f2{\`o}
10049  \gdefchar^^f3{\'o}
10050  \gdefchar^^f4{\^o}
10051  \gdefchar^^f5{\~o}
10052  \gdefchar^^f6{\"o}
10053  \gdefchar^^f7{$\div$}
10054  \gdefchar^^f8{\o}
10055  \gdefchar^^f9{\`u}
10056  \gdefchar^^fa{\'u}
10057  \gdefchar^^fb{\^u}
10058  \gdefchar^^fc{\"u}
10059  \gdefchar^^fd{\'y}
10060  \gdefchar^^fe{\th}
10061  \gdefchar^^ff{\"y}
10062}
10063
10064% Latin9 (ISO-8859-15) encoding character definitions.
10065\def\latninechardefs{%
10066  % Encoding is almost identical to Latin1.
10067  \latonechardefs
10068  %
10069  \gdefchar^^a4{\euro{}}
10070  \gdefchar^^a6{\v S}
10071  \gdefchar^^a8{\v s}
10072  \gdefchar^^b4{\v Z}
10073  \gdefchar^^b8{\v z}
10074  \gdefchar^^bc{\OE}
10075  \gdefchar^^bd{\oe}
10076  \gdefchar^^be{\"Y}
10077}
10078
10079% Latin2 (ISO-8859-2) character definitions.
10080\def\lattwochardefs{%
10081  \gdefchar^^a0{\tie}
10082  \gdefchar^^a1{\ogonek{A}}
10083  \gdefchar^^a2{\u{}}
10084  \gdefchar^^a3{\L}
10085  \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
10086  \gdefchar^^a5{\v L}
10087  \gdefchar^^a6{\'S}
10088  \gdefchar^^a7{\S}
10089  \gdefchar^^a8{\"{}}
10090  \gdefchar^^a9{\v S}
10091  \gdefchar^^aa{\cedilla S}
10092  \gdefchar^^ab{\v T}
10093  \gdefchar^^ac{\'Z}
10094  \gdefchar^^ad{\-}
10095  \gdefchar^^ae{\v Z}
10096  \gdefchar^^af{\dotaccent Z}
10097  %
10098  \gdefchar^^b0{\textdegree{}}
10099  \gdefchar^^b1{\ogonek{a}}
10100  \gdefchar^^b2{\ogonek{ }}
10101  \gdefchar^^b3{\l}
10102  \gdefchar^^b4{\'{}}
10103  \gdefchar^^b5{\v l}
10104  \gdefchar^^b6{\'s}
10105  \gdefchar^^b7{\v{}}
10106  \gdefchar^^b8{\cedilla\ }
10107  \gdefchar^^b9{\v s}
10108  \gdefchar^^ba{\cedilla s}
10109  \gdefchar^^bb{\v t}
10110  \gdefchar^^bc{\'z}
10111  \gdefchar^^bd{\H{}}
10112  \gdefchar^^be{\v z}
10113  \gdefchar^^bf{\dotaccent z}
10114  %
10115  \gdefchar^^c0{\'R}
10116  \gdefchar^^c1{\'A}
10117  \gdefchar^^c2{\^A}
10118  \gdefchar^^c3{\u A}
10119  \gdefchar^^c4{\"A}
10120  \gdefchar^^c5{\'L}
10121  \gdefchar^^c6{\'C}
10122  \gdefchar^^c7{\cedilla C}
10123  \gdefchar^^c8{\v C}
10124  \gdefchar^^c9{\'E}
10125  \gdefchar^^ca{\ogonek{E}}
10126  \gdefchar^^cb{\"E}
10127  \gdefchar^^cc{\v E}
10128  \gdefchar^^cd{\'I}
10129  \gdefchar^^ce{\^I}
10130  \gdefchar^^cf{\v D}
10131  %
10132  \gdefchar^^d0{\DH}
10133  \gdefchar^^d1{\'N}
10134  \gdefchar^^d2{\v N}
10135  \gdefchar^^d3{\'O}
10136  \gdefchar^^d4{\^O}
10137  \gdefchar^^d5{\H O}
10138  \gdefchar^^d6{\"O}
10139  \gdefchar^^d7{$\times$}
10140  \gdefchar^^d8{\v R}
10141  \gdefchar^^d9{\ringaccent U}
10142  \gdefchar^^da{\'U}
10143  \gdefchar^^db{\H U}
10144  \gdefchar^^dc{\"U}
10145  \gdefchar^^dd{\'Y}
10146  \gdefchar^^de{\cedilla T}
10147  \gdefchar^^df{\ss}
10148  %
10149  \gdefchar^^e0{\'r}
10150  \gdefchar^^e1{\'a}
10151  \gdefchar^^e2{\^a}
10152  \gdefchar^^e3{\u a}
10153  \gdefchar^^e4{\"a}
10154  \gdefchar^^e5{\'l}
10155  \gdefchar^^e6{\'c}
10156  \gdefchar^^e7{\cedilla c}
10157  \gdefchar^^e8{\v c}
10158  \gdefchar^^e9{\'e}
10159  \gdefchar^^ea{\ogonek{e}}
10160  \gdefchar^^eb{\"e}
10161  \gdefchar^^ec{\v e}
10162  \gdefchar^^ed{\'{\dotless{i}}}
10163  \gdefchar^^ee{\^{\dotless{i}}}
10164  \gdefchar^^ef{\v d}
10165  %
10166  \gdefchar^^f0{\dh}
10167  \gdefchar^^f1{\'n}
10168  \gdefchar^^f2{\v n}
10169  \gdefchar^^f3{\'o}
10170  \gdefchar^^f4{\^o}
10171  \gdefchar^^f5{\H o}
10172  \gdefchar^^f6{\"o}
10173  \gdefchar^^f7{$\div$}
10174  \gdefchar^^f8{\v r}
10175  \gdefchar^^f9{\ringaccent u}
10176  \gdefchar^^fa{\'u}
10177  \gdefchar^^fb{\H u}
10178  \gdefchar^^fc{\"u}
10179  \gdefchar^^fd{\'y}
10180  \gdefchar^^fe{\cedilla t}
10181  \gdefchar^^ff{\dotaccent{}}
10182}
10183
10184% UTF-8 character definitions.
10185%
10186% This code to support UTF-8 is based on LaTeX's utf8.def, with some
10187% changes for Texinfo conventions.  It is included here under the GPL by
10188% permission from Frank Mittelbach and the LaTeX team.
10189%
10190\newcount\countUTFx
10191\newcount\countUTFy
10192\newcount\countUTFz
10193
10194\gdef\UTFviiiTwoOctets#1#2{\expandafter
10195   \UTFviiiDefined\csname u8:#1\string #2\endcsname}
10196%
10197\gdef\UTFviiiThreeOctets#1#2#3{\expandafter
10198   \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
10199%
10200\gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
10201   \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
10202
10203\gdef\UTFviiiDefined#1{%
10204  \ifx #1\relax
10205    \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10206  \else
10207    \expandafter #1%
10208  \fi
10209}
10210
10211% Give non-ASCII bytes the active definitions for processing UTF-8 sequences
10212\begingroup
10213  \catcode`\~13
10214  \catcode`\$12
10215  \catcode`\"12
10216
10217  % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
10218  % substituting ~ and $ with a character token of that value.
10219  \def\UTFviiiLoop{%
10220    \global\catcode\countUTFx\active
10221    \uccode`\~\countUTFx
10222    \uccode`\$\countUTFx
10223    \uppercase\expandafter{\UTFviiiTmp}%
10224    \advance\countUTFx by 1
10225    \ifnum\countUTFx < \countUTFy
10226      \expandafter\UTFviiiLoop
10227    \fi}
10228
10229  % For bytes other than the first in a UTF-8 sequence.  Not expected to
10230  % be expanded except when writing to auxiliary files.
10231  \countUTFx = "80
10232  \countUTFy = "C2
10233  \def\UTFviiiTmp{%
10234    \gdef~{%
10235        \ifpassthroughchars $\fi}}%
10236  \UTFviiiLoop
10237
10238  \countUTFx = "C2
10239  \countUTFy = "E0
10240  \def\UTFviiiTmp{%
10241    \gdef~{%
10242        \ifpassthroughchars $%
10243        \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
10244  \UTFviiiLoop
10245
10246  \countUTFx = "E0
10247  \countUTFy = "F0
10248  \def\UTFviiiTmp{%
10249    \gdef~{%
10250        \ifpassthroughchars $%
10251        \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
10252  \UTFviiiLoop
10253
10254  \countUTFx = "F0
10255  \countUTFy = "F4
10256  \def\UTFviiiTmp{%
10257    \gdef~{%
10258        \ifpassthroughchars $%
10259        \else\expandafter\UTFviiiFourOctets\expandafter$\fi
10260        }}%
10261  \UTFviiiLoop
10262\endgroup
10263
10264\def\globallet{\global\let} % save some \expandafter's below
10265
10266% @U{xxxx} to produce U+xxxx, if we support it.
10267\def\U#1{%
10268  \expandafter\ifx\csname uni:#1\endcsname \relax
10269    \iftxinativeunicodecapable
10270      % All Unicode characters can be used if native Unicode handling is
10271      % active.  However, if the font does not have the glyph,
10272      % letters are missing.
10273      \begingroup
10274        \uccode`\.="#1\relax
10275        \uppercase{.}
10276      \endgroup
10277    \else
10278      \errhelp = \EMsimple
10279      \errmessage{Unicode character U+#1 not supported, sorry}%
10280    \fi
10281  \else
10282    \csname uni:#1\endcsname
10283  \fi
10284}
10285
10286% These macros are used here to construct the name of a control
10287% sequence to be defined.
10288\def\UTFviiiTwoOctetsName#1#2{%
10289  \csname u8:#1\string #2\endcsname}%
10290\def\UTFviiiThreeOctetsName#1#2#3{%
10291  \csname u8:#1\string #2\string #3\endcsname}%
10292\def\UTFviiiFourOctetsName#1#2#3#4{%
10293  \csname u8:#1\string #2\string #3\string #4\endcsname}%
10294
10295% For UTF-8 byte sequences (TeX, e-TeX and pdfTeX),
10296% provide a definition macro to replace a Unicode character;
10297% this gets used by the @U command
10298%
10299\begingroup
10300  \catcode`\"=12
10301  \catcode`\<=12
10302  \catcode`\.=12
10303  \catcode`\,=12
10304  \catcode`\;=12
10305  \catcode`\!=12
10306  \catcode`\~=13
10307  \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
10308    \countUTFz = "#1\relax
10309    \begingroup
10310      \parseXMLCharref
10311
10312      % Give \u8:... its definition.  The sequence of seven \expandafter's
10313      % expands after the \gdef three times, e.g.
10314      %
10315      % 1.  \UTFviiTwoOctetsName B1 B2
10316      % 2.  \csname u8:B1 \string B2 \endcsname
10317      % 3.  \u8: B1 B2  (a single control sequence token)
10318      %
10319      \expandafter\expandafter
10320      \expandafter\expandafter
10321      \expandafter\expandafter
10322      \expandafter\gdef       \UTFviiiTmp{#2}%
10323      %
10324      \expandafter\ifx\csname uni:#1\endcsname \relax \else
10325       \message{Internal error, already defined: #1}%
10326      \fi
10327      %
10328      % define an additional control sequence for this code point.
10329      \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
10330    \endgroup}
10331  %
10332  % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp
10333  % to the corresponding UTF-8 sequence.
10334  \gdef\parseXMLCharref{%
10335    \ifnum\countUTFz < "A0\relax
10336      \errhelp = \EMsimple
10337      \errmessage{Cannot define Unicode char value < 00A0}%
10338    \else\ifnum\countUTFz < "800\relax
10339      \parseUTFviiiA,%
10340      \parseUTFviiiB C\UTFviiiTwoOctetsName.,%
10341    \else\ifnum\countUTFz < "10000\relax
10342      \parseUTFviiiA;%
10343      \parseUTFviiiA,%
10344      \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}%
10345    \else
10346      \parseUTFviiiA;%
10347      \parseUTFviiiA,%
10348      \parseUTFviiiA!%
10349      \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}%
10350    \fi\fi\fi
10351  }
10352
10353  % Extract a byte from the end of the UTF-8 representation of \countUTFx.
10354  % It must be a non-initial byte in the sequence.
10355  % Change \uccode of #1 for it to be used in \parseUTFviiiB as one
10356  % of the bytes.
10357  \gdef\parseUTFviiiA#1{%
10358    \countUTFx = \countUTFz
10359    \divide\countUTFz by 64
10360    \countUTFy = \countUTFz  % Save to be the future value of \countUTFz.
10361    \multiply\countUTFz by 64
10362
10363    % \countUTFz is now \countUTFx with the last 5 bits cleared.  Subtract
10364    % in order to get the last five bits.
10365    \advance\countUTFx by -\countUTFz
10366
10367    % Convert this to the byte in the UTF-8 sequence.
10368    \advance\countUTFx by 128
10369    \uccode `#1\countUTFx
10370    \countUTFz = \countUTFy}
10371
10372  % Used to put a UTF-8 byte sequence into \UTFviiiTmp
10373  % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8
10374  %    sequence.
10375  % #2 is one of the \UTFviii*OctetsName macros.
10376  % #3 is always a full stop (.)
10377  % #4 is a template for the other bytes in the sequence.  The values for these
10378  %    bytes is substituted in here with \uppercase using the \uccode's.
10379  \gdef\parseUTFviiiB#1#2#3#4{%
10380    \advance\countUTFz by "#10\relax
10381    \uccode `#3\countUTFz
10382    \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10383\endgroup
10384
10385% For native Unicode handling (XeTeX and LuaTeX),
10386% provide a definition macro that sets a catcode to `other' non-globally
10387%
10388\def\DeclareUnicodeCharacterNativeOther#1#2{%
10389  \catcode"#1=\other
10390}
10391
10392% https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10393% U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10394% U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10395% U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10396% U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10397%
10398% Many of our renditions are less than wonderful, and all the missing
10399% characters are available somewhere.  Loading the necessary fonts
10400% awaits user request.  We can't truly support Unicode without
10401% reimplementing everything that's been done in LaTeX for many years,
10402% plus probably using luatex or xetex, and who knows what else.
10403% We won't be doing that here in this simple file.  But we can try to at
10404% least make most of the characters not bomb out.
10405%
10406\def\unicodechardefs{%
10407  \DeclareUnicodeCharacter{00A0}{\tie}%
10408  \DeclareUnicodeCharacter{00A1}{\exclamdown}%
10409  \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
10410  \DeclareUnicodeCharacter{00A3}{\pounds{}}%
10411  \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10412  \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10413  \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
10414  \DeclareUnicodeCharacter{00A7}{\S}%
10415  \DeclareUnicodeCharacter{00A8}{\"{ }}%
10416  \DeclareUnicodeCharacter{00A9}{\copyright{}}%
10417  \DeclareUnicodeCharacter{00AA}{\ordf}%
10418  \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}%
10419  \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10420  \DeclareUnicodeCharacter{00AD}{\-}%
10421  \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}%
10422  \DeclareUnicodeCharacter{00AF}{\={ }}%
10423  %
10424  \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
10425  \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10426  \DeclareUnicodeCharacter{00B2}{$^2$}%
10427  \DeclareUnicodeCharacter{00B3}{$^3$}%
10428  \DeclareUnicodeCharacter{00B4}{\'{ }}%
10429  \DeclareUnicodeCharacter{00B5}{$\mu$}%
10430  \DeclareUnicodeCharacter{00B6}{\P}%
10431  \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10432  \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10433  \DeclareUnicodeCharacter{00B9}{$^1$}%
10434  \DeclareUnicodeCharacter{00BA}{\ordm}%
10435  \DeclareUnicodeCharacter{00BB}{\guillemetright{}}%
10436  \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10437  \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10438  \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10439  \DeclareUnicodeCharacter{00BF}{\questiondown}%
10440  %
10441  \DeclareUnicodeCharacter{00C0}{\`A}%
10442  \DeclareUnicodeCharacter{00C1}{\'A}%
10443  \DeclareUnicodeCharacter{00C2}{\^A}%
10444  \DeclareUnicodeCharacter{00C3}{\~A}%
10445  \DeclareUnicodeCharacter{00C4}{\"A}%
10446  \DeclareUnicodeCharacter{00C5}{\AA}%
10447  \DeclareUnicodeCharacter{00C6}{\AE}%
10448  \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10449  \DeclareUnicodeCharacter{00C8}{\`E}%
10450  \DeclareUnicodeCharacter{00C9}{\'E}%
10451  \DeclareUnicodeCharacter{00CA}{\^E}%
10452  \DeclareUnicodeCharacter{00CB}{\"E}%
10453  \DeclareUnicodeCharacter{00CC}{\`I}%
10454  \DeclareUnicodeCharacter{00CD}{\'I}%
10455  \DeclareUnicodeCharacter{00CE}{\^I}%
10456  \DeclareUnicodeCharacter{00CF}{\"I}%
10457  %
10458  \DeclareUnicodeCharacter{00D0}{\DH}%
10459  \DeclareUnicodeCharacter{00D1}{\~N}%
10460  \DeclareUnicodeCharacter{00D2}{\`O}%
10461  \DeclareUnicodeCharacter{00D3}{\'O}%
10462  \DeclareUnicodeCharacter{00D4}{\^O}%
10463  \DeclareUnicodeCharacter{00D5}{\~O}%
10464  \DeclareUnicodeCharacter{00D6}{\"O}%
10465  \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10466  \DeclareUnicodeCharacter{00D8}{\O}%
10467  \DeclareUnicodeCharacter{00D9}{\`U}%
10468  \DeclareUnicodeCharacter{00DA}{\'U}%
10469  \DeclareUnicodeCharacter{00DB}{\^U}%
10470  \DeclareUnicodeCharacter{00DC}{\"U}%
10471  \DeclareUnicodeCharacter{00DD}{\'Y}%
10472  \DeclareUnicodeCharacter{00DE}{\TH}%
10473  \DeclareUnicodeCharacter{00DF}{\ss}%
10474  %
10475  \DeclareUnicodeCharacter{00E0}{\`a}%
10476  \DeclareUnicodeCharacter{00E1}{\'a}%
10477  \DeclareUnicodeCharacter{00E2}{\^a}%
10478  \DeclareUnicodeCharacter{00E3}{\~a}%
10479  \DeclareUnicodeCharacter{00E4}{\"a}%
10480  \DeclareUnicodeCharacter{00E5}{\aa}%
10481  \DeclareUnicodeCharacter{00E6}{\ae}%
10482  \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10483  \DeclareUnicodeCharacter{00E8}{\`e}%
10484  \DeclareUnicodeCharacter{00E9}{\'e}%
10485  \DeclareUnicodeCharacter{00EA}{\^e}%
10486  \DeclareUnicodeCharacter{00EB}{\"e}%
10487  \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10488  \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10489  \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10490  \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10491  %
10492  \DeclareUnicodeCharacter{00F0}{\dh}%
10493  \DeclareUnicodeCharacter{00F1}{\~n}%
10494  \DeclareUnicodeCharacter{00F2}{\`o}%
10495  \DeclareUnicodeCharacter{00F3}{\'o}%
10496  \DeclareUnicodeCharacter{00F4}{\^o}%
10497  \DeclareUnicodeCharacter{00F5}{\~o}%
10498  \DeclareUnicodeCharacter{00F6}{\"o}%
10499  \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10500  \DeclareUnicodeCharacter{00F8}{\o}%
10501  \DeclareUnicodeCharacter{00F9}{\`u}%
10502  \DeclareUnicodeCharacter{00FA}{\'u}%
10503  \DeclareUnicodeCharacter{00FB}{\^u}%
10504  \DeclareUnicodeCharacter{00FC}{\"u}%
10505  \DeclareUnicodeCharacter{00FD}{\'y}%
10506  \DeclareUnicodeCharacter{00FE}{\th}%
10507  \DeclareUnicodeCharacter{00FF}{\"y}%
10508  %
10509  \DeclareUnicodeCharacter{0100}{\=A}%
10510  \DeclareUnicodeCharacter{0101}{\=a}%
10511  \DeclareUnicodeCharacter{0102}{\u{A}}%
10512  \DeclareUnicodeCharacter{0103}{\u{a}}%
10513  \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10514  \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10515  \DeclareUnicodeCharacter{0106}{\'C}%
10516  \DeclareUnicodeCharacter{0107}{\'c}%
10517  \DeclareUnicodeCharacter{0108}{\^C}%
10518  \DeclareUnicodeCharacter{0109}{\^c}%
10519  \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10520  \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10521  \DeclareUnicodeCharacter{010C}{\v{C}}%
10522  \DeclareUnicodeCharacter{010D}{\v{c}}%
10523  \DeclareUnicodeCharacter{010E}{\v{D}}%
10524  \DeclareUnicodeCharacter{010F}{d'}%
10525  %
10526  \DeclareUnicodeCharacter{0110}{\DH}%
10527  \DeclareUnicodeCharacter{0111}{\dh}%
10528  \DeclareUnicodeCharacter{0112}{\=E}%
10529  \DeclareUnicodeCharacter{0113}{\=e}%
10530  \DeclareUnicodeCharacter{0114}{\u{E}}%
10531  \DeclareUnicodeCharacter{0115}{\u{e}}%
10532  \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10533  \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10534  \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10535  \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10536  \DeclareUnicodeCharacter{011A}{\v{E}}%
10537  \DeclareUnicodeCharacter{011B}{\v{e}}%
10538  \DeclareUnicodeCharacter{011C}{\^G}%
10539  \DeclareUnicodeCharacter{011D}{\^g}%
10540  \DeclareUnicodeCharacter{011E}{\u{G}}%
10541  \DeclareUnicodeCharacter{011F}{\u{g}}%
10542  %
10543  \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10544  \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10545  \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10546  \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10547  \DeclareUnicodeCharacter{0124}{\^H}%
10548  \DeclareUnicodeCharacter{0125}{\^h}%
10549  \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10550  \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10551  \DeclareUnicodeCharacter{0128}{\~I}%
10552  \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10553  \DeclareUnicodeCharacter{012A}{\=I}%
10554  \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10555  \DeclareUnicodeCharacter{012C}{\u{I}}%
10556  \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10557  \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10558  \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10559  %
10560  \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10561  \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10562  \DeclareUnicodeCharacter{0132}{IJ}%
10563  \DeclareUnicodeCharacter{0133}{ij}%
10564  \DeclareUnicodeCharacter{0134}{\^J}%
10565  \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10566  \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10567  \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10568  \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10569  \DeclareUnicodeCharacter{0139}{\'L}%
10570  \DeclareUnicodeCharacter{013A}{\'l}%
10571  \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10572  \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
10573  \DeclareUnicodeCharacter{013D}{L'}% should kern
10574  \DeclareUnicodeCharacter{013E}{l'}% should kern
10575  \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10576  %
10577  \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10578  \DeclareUnicodeCharacter{0141}{\L}%
10579  \DeclareUnicodeCharacter{0142}{\l}%
10580  \DeclareUnicodeCharacter{0143}{\'N}%
10581  \DeclareUnicodeCharacter{0144}{\'n}%
10582  \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10583  \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10584  \DeclareUnicodeCharacter{0147}{\v{N}}%
10585  \DeclareUnicodeCharacter{0148}{\v{n}}%
10586  \DeclareUnicodeCharacter{0149}{'n}%
10587  \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10588  \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10589  \DeclareUnicodeCharacter{014C}{\=O}%
10590  \DeclareUnicodeCharacter{014D}{\=o}%
10591  \DeclareUnicodeCharacter{014E}{\u{O}}%
10592  \DeclareUnicodeCharacter{014F}{\u{o}}%
10593  %
10594  \DeclareUnicodeCharacter{0150}{\H{O}}%
10595  \DeclareUnicodeCharacter{0151}{\H{o}}%
10596  \DeclareUnicodeCharacter{0152}{\OE}%
10597  \DeclareUnicodeCharacter{0153}{\oe}%
10598  \DeclareUnicodeCharacter{0154}{\'R}%
10599  \DeclareUnicodeCharacter{0155}{\'r}%
10600  \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10601  \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10602  \DeclareUnicodeCharacter{0158}{\v{R}}%
10603  \DeclareUnicodeCharacter{0159}{\v{r}}%
10604  \DeclareUnicodeCharacter{015A}{\'S}%
10605  \DeclareUnicodeCharacter{015B}{\'s}%
10606  \DeclareUnicodeCharacter{015C}{\^S}%
10607  \DeclareUnicodeCharacter{015D}{\^s}%
10608  \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10609  \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10610  %
10611  \DeclareUnicodeCharacter{0160}{\v{S}}%
10612  \DeclareUnicodeCharacter{0161}{\v{s}}%
10613  \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10614  \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10615  \DeclareUnicodeCharacter{0164}{\v{T}}%
10616  \DeclareUnicodeCharacter{0165}{\v{t}}%
10617  \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10618  \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10619  \DeclareUnicodeCharacter{0168}{\~U}%
10620  \DeclareUnicodeCharacter{0169}{\~u}%
10621  \DeclareUnicodeCharacter{016A}{\=U}%
10622  \DeclareUnicodeCharacter{016B}{\=u}%
10623  \DeclareUnicodeCharacter{016C}{\u{U}}%
10624  \DeclareUnicodeCharacter{016D}{\u{u}}%
10625  \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10626  \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10627  %
10628  \DeclareUnicodeCharacter{0170}{\H{U}}%
10629  \DeclareUnicodeCharacter{0171}{\H{u}}%
10630  \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10631  \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10632  \DeclareUnicodeCharacter{0174}{\^W}%
10633  \DeclareUnicodeCharacter{0175}{\^w}%
10634  \DeclareUnicodeCharacter{0176}{\^Y}%
10635  \DeclareUnicodeCharacter{0177}{\^y}%
10636  \DeclareUnicodeCharacter{0178}{\"Y}%
10637  \DeclareUnicodeCharacter{0179}{\'Z}%
10638  \DeclareUnicodeCharacter{017A}{\'z}%
10639  \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10640  \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10641  \DeclareUnicodeCharacter{017D}{\v{Z}}%
10642  \DeclareUnicodeCharacter{017E}{\v{z}}%
10643  \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10644  %
10645  \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10646  \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10647  \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10648  \DeclareUnicodeCharacter{01C7}{LJ}%
10649  \DeclareUnicodeCharacter{01C8}{Lj}%
10650  \DeclareUnicodeCharacter{01C9}{lj}%
10651  \DeclareUnicodeCharacter{01CA}{NJ}%
10652  \DeclareUnicodeCharacter{01CB}{Nj}%
10653  \DeclareUnicodeCharacter{01CC}{nj}%
10654  \DeclareUnicodeCharacter{01CD}{\v{A}}%
10655  \DeclareUnicodeCharacter{01CE}{\v{a}}%
10656  \DeclareUnicodeCharacter{01CF}{\v{I}}%
10657  %
10658  \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10659  \DeclareUnicodeCharacter{01D1}{\v{O}}%
10660  \DeclareUnicodeCharacter{01D2}{\v{o}}%
10661  \DeclareUnicodeCharacter{01D3}{\v{U}}%
10662  \DeclareUnicodeCharacter{01D4}{\v{u}}%
10663  %
10664  \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10665  \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10666  \DeclareUnicodeCharacter{01E6}{\v{G}}%
10667  \DeclareUnicodeCharacter{01E7}{\v{g}}%
10668  \DeclareUnicodeCharacter{01E8}{\v{K}}%
10669  \DeclareUnicodeCharacter{01E9}{\v{k}}%
10670  %
10671  \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10672  \DeclareUnicodeCharacter{01F1}{DZ}%
10673  \DeclareUnicodeCharacter{01F2}{Dz}%
10674  \DeclareUnicodeCharacter{01F3}{dz}%
10675  \DeclareUnicodeCharacter{01F4}{\'G}%
10676  \DeclareUnicodeCharacter{01F5}{\'g}%
10677  \DeclareUnicodeCharacter{01F8}{\`N}%
10678  \DeclareUnicodeCharacter{01F9}{\`n}%
10679  \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10680  \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10681  \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10682  \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10683  %
10684  \DeclareUnicodeCharacter{021E}{\v{H}}%
10685  \DeclareUnicodeCharacter{021F}{\v{h}}%
10686  %
10687  \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10688  \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10689  \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10690  \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10691  \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10692  \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10693  %
10694  \DeclareUnicodeCharacter{0232}{\=Y}%
10695  \DeclareUnicodeCharacter{0233}{\=y}%
10696  \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10697  %
10698  \DeclareUnicodeCharacter{02BC}{'}%
10699  %
10700  \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10701  %
10702  % Greek letters upper case
10703  \DeclareUnicodeCharacter{0391}{{\it A}}%
10704  \DeclareUnicodeCharacter{0392}{{\it B}}%
10705  \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10706  \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10707  \DeclareUnicodeCharacter{0395}{{\it E}}%
10708  \DeclareUnicodeCharacter{0396}{{\it Z}}%
10709  \DeclareUnicodeCharacter{0397}{{\it H}}%
10710  \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10711  \DeclareUnicodeCharacter{0399}{{\it I}}%
10712  \DeclareUnicodeCharacter{039A}{{\it K}}%
10713  \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10714  \DeclareUnicodeCharacter{039C}{{\it M}}%
10715  \DeclareUnicodeCharacter{039D}{{\it N}}%
10716  \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10717  \DeclareUnicodeCharacter{039F}{{\it O}}%
10718  \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10719  \DeclareUnicodeCharacter{03A1}{{\it P}}%
10720  %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
10721  \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10722  \DeclareUnicodeCharacter{03A4}{{\it T}}%
10723  \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10724  \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10725  \DeclareUnicodeCharacter{03A7}{{\it X}}%
10726  \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10727  \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10728  %
10729  % Vowels with accents
10730  \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10731  \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10732  \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10733  \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10734  \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10735  \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10736  %
10737  % Standalone accent
10738  \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10739  %
10740  % Greek letters lower case
10741  \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10742  \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10743  \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10744  \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10745  \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10746  \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10747  \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10748  \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10749  \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10750  \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10751  \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10752  \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10753  \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10754  \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10755  \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10756  \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10757  \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10758  \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10759  \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10760  \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10761  \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10762  \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10763  \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10764  \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10765  \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10766  %
10767  % More Greek vowels with accents
10768  \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10769  \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10770  \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10771  \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10772  \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10773  %
10774  % Variant Greek letters
10775  \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10776  \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10777  \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10778  %
10779  \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10780  \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10781  \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10782  \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10783  \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10784  \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10785  \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10786  \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10787  \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10788  \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10789  \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10790  \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10791  %
10792  \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10793  \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10794  %
10795  \DeclareUnicodeCharacter{1E20}{\=G}%
10796  \DeclareUnicodeCharacter{1E21}{\=g}%
10797  \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10798  \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10799  \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10800  \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10801  \DeclareUnicodeCharacter{1E26}{\"H}%
10802  \DeclareUnicodeCharacter{1E27}{\"h}%
10803  %
10804  \DeclareUnicodeCharacter{1E30}{\'K}%
10805  \DeclareUnicodeCharacter{1E31}{\'k}%
10806  \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10807  \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10808  \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10809  \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10810  \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10811  \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10812  \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10813  \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10814  \DeclareUnicodeCharacter{1E3E}{\'M}%
10815  \DeclareUnicodeCharacter{1E3F}{\'m}%
10816  %
10817  \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10818  \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10819  \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10820  \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10821  \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10822  \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10823  \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10824  \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10825  \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10826  \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10827  %
10828  \DeclareUnicodeCharacter{1E54}{\'P}%
10829  \DeclareUnicodeCharacter{1E55}{\'p}%
10830  \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10831  \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10832  \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10833  \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10834  \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10835  \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10836  \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10837  \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10838  %
10839  \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10840  \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10841  \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10842  \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10843  \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10844  \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10845  \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10846  \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10847  \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10848  \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10849  %
10850  \DeclareUnicodeCharacter{1E7C}{\~V}%
10851  \DeclareUnicodeCharacter{1E7D}{\~v}%
10852  \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10853  \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10854  %
10855  \DeclareUnicodeCharacter{1E80}{\`W}%
10856  \DeclareUnicodeCharacter{1E81}{\`w}%
10857  \DeclareUnicodeCharacter{1E82}{\'W}%
10858  \DeclareUnicodeCharacter{1E83}{\'w}%
10859  \DeclareUnicodeCharacter{1E84}{\"W}%
10860  \DeclareUnicodeCharacter{1E85}{\"w}%
10861  \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10862  \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10863  \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10864  \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10865  \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10866  \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10867  \DeclareUnicodeCharacter{1E8C}{\"X}%
10868  \DeclareUnicodeCharacter{1E8D}{\"x}%
10869  \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10870  \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10871  %
10872  \DeclareUnicodeCharacter{1E90}{\^Z}%
10873  \DeclareUnicodeCharacter{1E91}{\^z}%
10874  \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
10875  \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
10876  \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
10877  \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
10878  \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
10879  \DeclareUnicodeCharacter{1E97}{\"t}%
10880  \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
10881  \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
10882  %
10883  \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
10884  \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
10885  %
10886  \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
10887  \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
10888  \DeclareUnicodeCharacter{1EBC}{\~E}%
10889  \DeclareUnicodeCharacter{1EBD}{\~e}%
10890  %
10891  \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
10892  \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
10893  \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
10894  \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
10895  %
10896  \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
10897  \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
10898  %
10899  \DeclareUnicodeCharacter{1EF2}{\`Y}%
10900  \DeclareUnicodeCharacter{1EF3}{\`y}%
10901  \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
10902  %
10903  \DeclareUnicodeCharacter{1EF8}{\~Y}%
10904  \DeclareUnicodeCharacter{1EF9}{\~y}%
10905  %
10906  % Punctuation
10907  \DeclareUnicodeCharacter{2013}{--}%
10908  \DeclareUnicodeCharacter{2014}{---}%
10909  \DeclareUnicodeCharacter{2018}{\quoteleft{}}%
10910  \DeclareUnicodeCharacter{2019}{\quoteright{}}%
10911  \DeclareUnicodeCharacter{201A}{\quotesinglbase{}}%
10912  \DeclareUnicodeCharacter{201C}{\quotedblleft{}}%
10913  \DeclareUnicodeCharacter{201D}{\quotedblright{}}%
10914  \DeclareUnicodeCharacter{201E}{\quotedblbase{}}%
10915  \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}%
10916  \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}%
10917  \DeclareUnicodeCharacter{2022}{\bullet{}}%
10918  \DeclareUnicodeCharacter{202F}{\thinspace}%
10919  \DeclareUnicodeCharacter{2026}{\dots{}}%
10920  \DeclareUnicodeCharacter{2039}{\guilsinglleft{}}%
10921  \DeclareUnicodeCharacter{203A}{\guilsinglright{}}%
10922  %
10923  \DeclareUnicodeCharacter{20AC}{\euro{}}%
10924  %
10925  \DeclareUnicodeCharacter{2192}{\expansion{}}%
10926  \DeclareUnicodeCharacter{21D2}{\result{}}%
10927  %
10928  % Mathematical symbols
10929  \DeclareUnicodeCharacter{2200}{\ensuremath\forall}%
10930  \DeclareUnicodeCharacter{2203}{\ensuremath\exists}%
10931  \DeclareUnicodeCharacter{2208}{\ensuremath\in}%
10932  \DeclareUnicodeCharacter{2212}{\minus{}}%
10933  \DeclareUnicodeCharacter{2217}{\ast}%
10934  \DeclareUnicodeCharacter{221E}{\ensuremath\infty}%
10935  \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}%
10936  \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}%
10937  \DeclareUnicodeCharacter{2229}{\ensuremath\cap}%
10938  \DeclareUnicodeCharacter{2261}{\equiv{}}%
10939  \DeclareUnicodeCharacter{2264}{\ensuremath\leq}%
10940  \DeclareUnicodeCharacter{2265}{\ensuremath\geq}%
10941  \DeclareUnicodeCharacter{2282}{\ensuremath\subset}%
10942  \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}%
10943  %
10944  \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}%
10945  \DeclareUnicodeCharacter{2032}{\ensuremath\prime}%
10946  \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}%
10947  \DeclareUnicodeCharacter{2111}{\ensuremath\Im}%
10948  \DeclareUnicodeCharacter{2113}{\ensuremath\ell}%
10949  \DeclareUnicodeCharacter{2118}{\ensuremath\wp}%
10950  \DeclareUnicodeCharacter{211C}{\ensuremath\Re}%
10951  \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}%
10952  \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}%
10953  \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}%
10954  \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}%
10955  \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}%
10956  \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}%
10957  \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}%
10958  \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}%
10959  \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}%
10960  \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}%
10961  \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}%
10962  \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}%
10963  \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}%
10964  \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}%
10965  \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}%
10966  \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}%
10967  \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}%
10968  \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}%
10969  \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}%
10970  \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}%
10971  \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}%
10972  \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}%
10973  \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}%
10974  \DeclareUnicodeCharacter{2202}{\ensuremath\partial}%
10975  \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}%
10976  \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}%
10977  \DeclareUnicodeCharacter{2209}{\ensuremath\notin}%
10978  \DeclareUnicodeCharacter{220B}{\ensuremath\owns}%
10979  \DeclareUnicodeCharacter{220F}{\ensuremath\prod}%
10980  \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}%
10981  \DeclareUnicodeCharacter{2211}{\ensuremath\sum}%
10982  \DeclareUnicodeCharacter{2213}{\ensuremath\mp}%
10983  \DeclareUnicodeCharacter{2218}{\ensuremath\circ}%
10984  \DeclareUnicodeCharacter{221A}{\ensuremath\surd}%
10985  \DeclareUnicodeCharacter{221D}{\ensuremath\propto}%
10986  \DeclareUnicodeCharacter{2220}{\ensuremath\angle}%
10987  \DeclareUnicodeCharacter{2223}{\ensuremath\mid}%
10988  \DeclareUnicodeCharacter{2228}{\ensuremath\vee}%
10989  \DeclareUnicodeCharacter{222A}{\ensuremath\cup}%
10990  \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}%
10991  \DeclareUnicodeCharacter{222E}{\ensuremath\oint}%
10992  \DeclareUnicodeCharacter{223C}{\ensuremath\sim}%
10993  \DeclareUnicodeCharacter{2240}{\ensuremath\wr}%
10994  \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}%
10995  \DeclareUnicodeCharacter{2245}{\ensuremath\cong}%
10996  \DeclareUnicodeCharacter{2248}{\ensuremath\approx}%
10997  \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}%
10998  \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}%
10999  \DeclareUnicodeCharacter{2260}{\ensuremath\neq}%
11000  \DeclareUnicodeCharacter{226A}{\ensuremath\ll}%
11001  \DeclareUnicodeCharacter{226B}{\ensuremath\gg}%
11002  \DeclareUnicodeCharacter{227A}{\ensuremath\prec}%
11003  \DeclareUnicodeCharacter{227B}{\ensuremath\succ}%
11004  \DeclareUnicodeCharacter{2283}{\ensuremath\supset}%
11005  \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}%
11006  \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}%
11007  \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}%
11008  \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}%
11009  \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}%
11010  \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}%
11011  \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}%
11012  \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}%
11013  \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}%
11014  \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}%
11015  \DeclareUnicodeCharacter{2299}{\ensuremath\odot}%
11016  \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}%
11017  \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}%
11018  \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}%
11019  \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}%
11020  \DeclareUnicodeCharacter{22A8}{\ensuremath\models}%
11021  \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}%
11022  \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}%
11023  \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}%
11024  \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}%
11025  \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}%
11026  \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}%
11027  \DeclareUnicodeCharacter{22C6}{\ensuremath\star}%
11028  \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}%
11029  \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}%
11030  \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}%
11031  \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}%
11032  \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}%
11033  \DeclareUnicodeCharacter{2322}{\ensuremath\frown}%
11034  \DeclareUnicodeCharacter{2323}{\ensuremath\smile}%
11035  %
11036  \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
11037  \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
11038  \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
11039  \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
11040  \DeclareUnicodeCharacter{25C7}{\ensuremath\diamond}%
11041  \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}%
11042  \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}%
11043  \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}%
11044  \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}%
11045  \DeclareUnicodeCharacter{266D}{\ensuremath\flat}%
11046  \DeclareUnicodeCharacter{266E}{\ensuremath\natural}%
11047  \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}%
11048  \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}%
11049  \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}%
11050  \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}%
11051  \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}%
11052  \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}%
11053  \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}%
11054  \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}%
11055  \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}%
11056  \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}%
11057  \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}%
11058  \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}%
11059  \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}%
11060  \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}%
11061  \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}%
11062  \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}%
11063  \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}%
11064  \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}%
11065  %
11066  \global\mathchardef\checkmark="1370% actually the square root sign
11067  \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}%
11068}% end of \unicodechardefs
11069
11070% UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
11071% It makes the setting that replace UTF-8 byte sequence.
11072\def\utfeightchardefs{%
11073  \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
11074  \unicodechardefs
11075}
11076
11077% Whether the active definitions of non-ASCII characters expand to
11078% non-active tokens with the same character code.  This is used to
11079% write characters literally, instead of using active definitions for
11080% printing the correct glyphs.
11081\newif\ifpassthroughchars
11082\passthroughcharsfalse
11083
11084% For native Unicode handling (XeTeX and LuaTeX),
11085% provide a definition macro to replace/pass-through a Unicode character
11086%
11087\def\DeclareUnicodeCharacterNative#1#2{%
11088  \catcode"#1=\active
11089  \def\dodeclareunicodecharacternative##1##2##3{%
11090    \begingroup
11091      \uccode`\~="##2\relax
11092      \uppercase{\gdef~}{%
11093        \ifpassthroughchars
11094          ##1%
11095        \else
11096          ##3%
11097        \fi
11098      }
11099    \endgroup
11100  }
11101  \begingroup
11102    \uccode`\.="#1\relax
11103    \uppercase{\def\UTFNativeTmp{.}}%
11104    \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
11105  \endgroup
11106}
11107
11108% Native Unicode handling (XeTeX and LuaTeX) character replacing definition.
11109% It activates the setting that replaces Unicode characters.
11110\def\nativeunicodechardefs{%
11111  \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
11112  \unicodechardefs
11113}
11114
11115% For native Unicode handling (XeTeX and LuaTeX),
11116% make the character token expand
11117% to the sequences given in \unicodechardefs for printing.
11118\def\DeclareUnicodeCharacterNativeAtU#1#2{%
11119  \def\UTFAtUTmp{#2}
11120  \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
11121}
11122
11123% @U command definitions for native Unicode handling (XeTeX and LuaTeX).
11124\def\nativeunicodechardefsatu{%
11125  \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
11126  \unicodechardefs
11127}
11128
11129% US-ASCII character definitions.
11130\def\asciichardefs{% nothing need be done
11131   \relax
11132}
11133
11134% Define all Unicode characters we know about.  This makes UTF-8 the default
11135% input encoding and allows @U to work.
11136\iftxinativeunicodecapable
11137  \nativeunicodechardefsatu
11138\else
11139  \utfeightchardefs
11140\fi
11141
11142\message{formatting,}
11143
11144\newdimen\defaultparindent \defaultparindent = 15pt
11145
11146\chapheadingskip = 15pt plus 4pt minus 2pt
11147\secheadingskip = 12pt plus 3pt minus 2pt
11148\subsecheadingskip = 9pt plus 2pt minus 2pt
11149
11150% Prevent underfull vbox error messages.
11151\vbadness = 10000
11152
11153% Don't be very finicky about underfull hboxes, either.
11154\hbadness = 6666
11155
11156% Following George Bush, get rid of widows and orphans.
11157\widowpenalty=10000
11158\clubpenalty=10000
11159
11160% Use TeX 3.0's \emergencystretch to help line breaking, but if we're
11161% using an old version of TeX, don't do anything.  We want the amount of
11162% stretch added to depend on the line length, hence the dependence on
11163% \hsize.  We call this whenever the paper size is set.
11164%
11165\def\setemergencystretch{%
11166  \ifx\emergencystretch\thisisundefined
11167    % Allow us to assign to \emergencystretch anyway.
11168    \def\emergencystretch{\dimen0}%
11169  \else
11170    \emergencystretch = .15\hsize
11171  \fi
11172}
11173
11174% Parameters in order: 1) textheight; 2) textwidth;
11175% 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11176% 7) physical page height; 8) physical page width.
11177%
11178% We also call \setleading{\textleading}, so the caller should define
11179% \textleading.  The caller should also set \parskip.
11180%
11181\def\internalpagesizes#1#2#3#4#5#6#7#8{%
11182  \voffset = #3\relax
11183  \topskip = #6\relax
11184  \splittopskip = \topskip
11185  %
11186  \vsize = #1\relax
11187  \advance\vsize by \topskip
11188  \outervsize = \vsize
11189  \advance\outervsize by 2\topandbottommargin
11190  \txipageheight = \vsize
11191  %
11192  \hsize = #2\relax
11193  \outerhsize = \hsize
11194  \advance\outerhsize by 0.5in
11195  \txipagewidth = \hsize
11196  %
11197  \normaloffset = #4\relax
11198  \bindingoffset = #5\relax
11199  %
11200  \ifpdf
11201    \pdfpageheight #7\relax
11202    \pdfpagewidth #8\relax
11203    % if we don't reset these, they will remain at "1 true in" of
11204    % whatever layout pdftex was dumped with.
11205    \pdfhorigin = 1 true in
11206    \pdfvorigin = 1 true in
11207  \else
11208    \ifx\XeTeXrevision\thisisundefined
11209      \special{papersize=#8,#7}%
11210    \else
11211      \pdfpageheight #7\relax
11212      \pdfpagewidth #8\relax
11213      % XeTeX does not have \pdfhorigin and \pdfvorigin.
11214    \fi
11215  \fi
11216  %
11217  \setleading{\textleading}
11218  %
11219  \parindent = \defaultparindent
11220  \setemergencystretch
11221}
11222
11223% @letterpaper (the default).
11224\def\letterpaper{{\globaldefs = 1
11225  \parskip = 3pt plus 2pt minus 1pt
11226  \textleading = 13.2pt
11227  %
11228  % If page is nothing but text, make it come out even.
11229  \internalpagesizes{607.2pt}{6in}% that's 46 lines
11230                    {\voffset}{.25in}%
11231                    {\bindingoffset}{36pt}%
11232                    {11in}{8.5in}%
11233}}
11234
11235% Use @smallbook to reset parameters for 7x9.25 trim size.
11236\def\smallbook{{\globaldefs = 1
11237  \parskip = 2pt plus 1pt
11238  \textleading = 12pt
11239  %
11240  \internalpagesizes{7.5in}{5in}%
11241                    {-.2in}{0in}%
11242                    {\bindingoffset}{16pt}%
11243                    {9.25in}{7in}%
11244  %
11245  \lispnarrowing = 0.3in
11246  \tolerance = 700
11247  \contentsrightmargin = 0pt
11248  \defbodyindent = .5cm
11249}}
11250
11251% Use @smallerbook to reset parameters for 6x9 trim size.
11252% (Just testing, parameters still in flux.)
11253\def\smallerbook{{\globaldefs = 1
11254  \parskip = 1.5pt plus 1pt
11255  \textleading = 12pt
11256  %
11257  \internalpagesizes{7.4in}{4.8in}%
11258                    {-.2in}{-.4in}%
11259                    {0pt}{14pt}%
11260                    {9in}{6in}%
11261  %
11262  \lispnarrowing = 0.25in
11263  \tolerance = 700
11264  \contentsrightmargin = 0pt
11265  \defbodyindent = .4cm
11266}}
11267
11268% Use @afourpaper to print on European A4 paper.
11269\def\afourpaper{{\globaldefs = 1
11270  \parskip = 3pt plus 2pt minus 1pt
11271  \textleading = 13.2pt
11272  %
11273  % Double-side printing via postscript on Laserjet 4050
11274  % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11275  % To change the settings for a different printer or situation, adjust
11276  % \normaloffset until the front-side and back-side texts align.  Then
11277  % do the same for \bindingoffset.  You can set these for testing in
11278  % your texinfo source file like this:
11279  % @tex
11280  % \global\normaloffset = -6mm
11281  % \global\bindingoffset = 10mm
11282  % @end tex
11283  \internalpagesizes{673.2pt}{160mm}% that's 51 lines
11284                    {\voffset}{\hoffset}%
11285                    {\bindingoffset}{44pt}%
11286                    {297mm}{210mm}%
11287  %
11288  \tolerance = 700
11289  \contentsrightmargin = 0pt
11290  \defbodyindent = 5mm
11291}}
11292
11293% Use @afivepaper to print on European A5 paper.
11294% From romildo@urano.iceb.ufop.br, 2 July 2000.
11295% He also recommends making @example and @lisp be small.
11296\def\afivepaper{{\globaldefs = 1
11297  \parskip = 2pt plus 1pt minus 0.1pt
11298  \textleading = 12.5pt
11299  %
11300  \internalpagesizes{160mm}{120mm}%
11301                    {\voffset}{\hoffset}%
11302                    {\bindingoffset}{8pt}%
11303                    {210mm}{148mm}%
11304  %
11305  \lispnarrowing = 0.2in
11306  \tolerance = 800
11307  \contentsrightmargin = 0pt
11308  \defbodyindent = 2mm
11309  \tableindent = 12mm
11310}}
11311
11312% A specific text layout, 24x15cm overall, intended for A4 paper.
11313\def\afourlatex{{\globaldefs = 1
11314  \afourpaper
11315  \internalpagesizes{237mm}{150mm}%
11316                    {\voffset}{4.6mm}%
11317                    {\bindingoffset}{7mm}%
11318                    {297mm}{210mm}%
11319  %
11320  % Must explicitly reset to 0 because we call \afourpaper.
11321  \globaldefs = 0
11322}}
11323
11324% Use @afourwide to print on A4 paper in landscape format.
11325\def\afourwide{{\globaldefs = 1
11326  \afourpaper
11327  \internalpagesizes{241mm}{165mm}%
11328                    {\voffset}{-2.95mm}%
11329                    {\bindingoffset}{7mm}%
11330                    {297mm}{210mm}%
11331  \globaldefs = 0
11332}}
11333
11334\def\bsixpaper{{\globaldefs = 1
11335  \afourpaper
11336  \internalpagesizes{140mm}{100mm}%
11337                    {-6.35mm}{-12.7mm}%
11338                    {\bindingoffset}{14pt}%
11339                    {176mm}{125mm}%
11340  \let\SETdispenvsize=\smallword
11341  \lispnarrowing = 0.2in
11342  \globaldefs = 0
11343}}
11344
11345
11346% @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11347% Perhaps we should allow setting the margins, \topskip, \parskip,
11348% and/or leading, also. Or perhaps we should compute them somehow.
11349%
11350\parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
11351\def\pagesizesyyy#1,#2,#3\finish{{%
11352  \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11353  \globaldefs = 1
11354  %
11355  \parskip = 3pt plus 2pt minus 1pt
11356  \setleading{\textleading}%
11357  %
11358  \dimen0 = #1\relax
11359  \advance\dimen0 by 2.5in % default 1in margin above heading line
11360                           % and 1.5in to include heading, footing and
11361                           % bottom margin
11362  %
11363  \dimen2 = \hsize
11364  \advance\dimen2 by 2in % default to 1 inch margin on each side
11365  %
11366  \internalpagesizes{#1}{\hsize}%
11367                    {\voffset}{\normaloffset}%
11368                    {\bindingoffset}{44pt}%
11369                    {\dimen0}{\dimen2}%
11370}}
11371
11372% Set default to letter.
11373%
11374\letterpaper
11375
11376% Default value of \hfuzz, for suppressing warnings about overfull hboxes.
11377\hfuzz = 1pt
11378
11379
11380\message{and turning on texinfo input format.}
11381
11382\def^^L{\par} % remove \outer, so ^L can appear in an @comment
11383
11384% DEL is a comment character, in case @c does not suffice.
11385\catcode`\^^? = 14
11386
11387% Define macros to output various characters with catcode for normal text.
11388\catcode`\"=\other \def\normaldoublequote{"}
11389\catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11390\catcode`\+=\other \def\normalplus{+}
11391\catcode`\<=\other \def\normalless{<}
11392\catcode`\>=\other \def\normalgreater{>}
11393\catcode`\^=\other \def\normalcaret{^}
11394\catcode`\_=\other \def\normalunderscore{_}
11395\catcode`\|=\other \def\normalverticalbar{|}
11396\catcode`\~=\other \def\normaltilde{~}
11397
11398% This macro is used to make a character print one way in \tt
11399% (where it can probably be output as-is), and another way in other fonts,
11400% where something hairier probably needs to be done.
11401%
11402% #1 is what to print if we are indeed using \tt; #2 is what to print
11403% otherwise.  Since all the Computer Modern typewriter fonts have zero
11404% interword stretch (and shrink), and it is reasonable to expect all
11405% typewriter fonts to have this, we can check that font parameter.
11406%
11407\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
11408
11409% Same as above, but check for italic font.  Actually this also catches
11410% non-italic slanted fonts since it is impossible to distinguish them from
11411% italic fonts.  But since this is only used by $ and it uses \sl anyway
11412% this is not a problem.
11413\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
11414
11415% Set catcodes for Texinfo file
11416
11417% Active characters for printing the wanted glyph.
11418% Most of these we simply print from the \tt font, but for some, we can
11419% use math or other variants that look better in normal text.
11420%
11421\catcode`\"=\active
11422\def\activedoublequote{{\tt\char34}}
11423\let"=\activedoublequote
11424\catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
11425\chardef\hatchar=`\^
11426\catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
11427
11428\catcode`\_=\active
11429\def_{\ifusingtt\normalunderscore\_}
11430\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
11431\let\realunder=_
11432
11433\catcode`\|=\active \def|{{\tt\char124}}
11434
11435\chardef \less=`\<
11436\catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
11437\chardef \gtr=`\>
11438\catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11439\catcode`\+=\active \def+{{\tt \char 43}}
11440\catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
11441\catcode`\-=\active \let-=\normaldash
11442
11443
11444% used for headline/footline in the output routine, in case the page
11445% breaks in the middle of an @tex block.
11446\def\texinfochars{%
11447  \let< = \activeless
11448  \let> = \activegtr
11449  \let~ = \activetilde
11450  \let^ = \activehat
11451  \setregularquotes
11452  \let\b = \strong
11453  \let\i = \smartitalic
11454  % in principle, all other definitions in \tex have to be undone too.
11455}
11456
11457% Used sometimes to turn off (effectively) the active characters even after
11458% parsing them.
11459\def\turnoffactive{%
11460  \normalturnoffactive
11461  \otherbackslash
11462}
11463
11464\catcode`\@=0
11465
11466% \backslashcurfont outputs one backslash character in current font,
11467% as in \char`\\.
11468\global\chardef\backslashcurfont=`\\
11469
11470% \realbackslash is an actual character `\' with catcode other.
11471{\catcode`\\=\other @gdef@realbackslash{\}}
11472
11473% In Texinfo, backslash is an active character; it prints the backslash
11474% in fixed width font.
11475\catcode`\\=\active  % @ for escape char from now on.
11476
11477% Print a typewriter backslash.  For math mode, we can't simply use
11478% \backslashcurfont: the story here is that in math mode, the \char
11479% of \backslashcurfont ends up printing the roman \ from the math symbol
11480% font (because \char in math mode uses the \mathcode, and plain.tex
11481% sets \mathcode`\\="026E).  Hence we use an explicit \mathchar,
11482% which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11483% ignored family value; char position "5C).  We can't use " for the
11484% usual hex value because it has already been made active.
11485
11486@def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
11487@let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
11488
11489% \otherbackslash defines an active \ to be a literal `\' character with
11490% catcode other.
11491@gdef@otherbackslash{@let\=@realbackslash}
11492
11493% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
11494% the literal character `\'.
11495%
11496{@catcode`- = @active
11497 @gdef@normalturnoffactive{%
11498   @passthroughcharstrue
11499   @let-=@normaldash
11500   @let"=@normaldoublequote
11501   @let$=@normaldollar %$ font-lock fix
11502   @let+=@normalplus
11503   @let<=@normalless
11504   @let>=@normalgreater
11505   @let^=@normalcaret
11506   @let_=@normalunderscore
11507   @let|=@normalverticalbar
11508   @let~=@normaltilde
11509   @let\=@ttbackslash
11510   @setregularquotes
11511   @unsepspaces
11512 }
11513}
11514
11515% If a .fmt file is being used, characters that might appear in a file
11516% name cannot be active until we have parsed the command line.
11517% So turn them off again, and have @fixbackslash turn them back on.
11518@catcode`+=@other @catcode`@_=@other
11519
11520% \enablebackslashhack - allow file to begin `\input texinfo'
11521%
11522% If a .fmt file is being used, we don't want the `\input texinfo' to show up.
11523% That is what \eatinput is for; after that, the `\' should revert to printing
11524% a backslash.
11525% If the file did not have a `\input texinfo', then it is turned off after
11526% the first line; otherwise the first `\' in the file would cause an error.
11527% This is used on the very last line of this file, texinfo.tex.
11528% We also use @c to call @fixbackslash, in case ends of lines are hidden.
11529{
11530@catcode`@^=7
11531@catcode`@^^M=13@gdef@enablebackslashhack{%
11532  @global@let\ = @eatinput%
11533  @catcode`@^^M=13%
11534  @def@c{@fixbackslash@c}%
11535  % Definition for the newline at the end of this file.
11536  @def ^^M{@let^^M@secondlinenl}%
11537  % Definition for a newline in the main Texinfo file.
11538  @gdef @secondlinenl{@fixbackslash}%
11539  % In case the first line has a whole-line command on it
11540  @let@originalparsearg@parsearg
11541  @def@parsearg{@fixbackslash@originalparsearg}
11542}}
11543
11544{@catcode`@^=7 @catcode`@^^M=13%
11545@gdef@eatinput input texinfo#1^^M{@fixbackslash}}
11546
11547% Emergency active definition of newline, in case an active newline token
11548% appears by mistake.
11549{@catcode`@^=7 @catcode13=13%
11550@gdef@enableemergencynewline{%
11551  @gdef^^M{%
11552    @par%
11553    %<warning: active newline>@par%
11554}}}
11555
11556
11557@gdef@fixbackslash{%
11558  @ifx\@eatinput @let\ = @ttbackslash @fi
11559  @catcode13=5 % regular end of line
11560  @enableemergencynewline
11561  @let@c=@comment
11562  @let@parsearg@originalparsearg
11563  % Also turn back on active characters that might appear in the input
11564  % file name, in case not using a pre-dumped format.
11565  @catcode`+=@active
11566  @catcode`@_=@active
11567  %
11568  % If texinfo.cnf is present on the system, read it.
11569  % Useful for site-wide @afourpaper, etc.  This macro, @fixbackslash, gets
11570  % called at the beginning of every Texinfo file.  Not opening texinfo.cnf
11571  % directly in this file, texinfo.tex, makes it possible to make a format
11572  % file for Texinfo.
11573  %
11574  @openin 1 texinfo.cnf
11575  @ifeof 1 @else @input texinfo.cnf @fi
11576  @closein 1
11577}
11578
11579
11580% Say @foo, not \foo, in error messages.
11581@escapechar = `@@
11582
11583% These (along with & and #) are made active for url-breaking, so need
11584% active definitions as the normal characters.
11585@def@normaldot{.}
11586@def@normalquest{?}
11587@def@normalslash{/}
11588
11589% These look ok in all fonts, so just make them not special.
11590% @hashchar{} gets its own user-level command, because of #line.
11591@catcode`@& = @other @def@normalamp{&}
11592@catcode`@# = @other @def@normalhash{#}
11593@catcode`@% = @other @def@normalpercent{%}
11594
11595@let @hashchar = @normalhash
11596
11597@c Finally, make ` and ' active, so that txicodequoteundirected and
11598@c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
11599@c don't make ` and ' active, @code will not get them as active chars.
11600@c Do this last of all since we use ` in the previous @catcode assignments.
11601@catcode`@'=@active
11602@catcode`@`=@active
11603@setregularquotes
11604
11605@c Local variables:
11606@c eval: (add-hook 'before-save-hook 'time-stamp nil t)
11607@c time-stamp-pattern: "texinfoversion{%Y-%02m-%02d.%02H}"
11608@c page-delimiter: "^\\\\message\\|emacs-page"
11609@c End:
11610
11611@c vim:sw=2:
11612
11613@enablebackslashhack
11614
11615