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{2019-06-01.23}
7%
8% Copyright 1985, 1986, 1988, 1990-2019 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 including 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  % Retrieve the information for the headings from the marks in the page,
353  % and call Plain TeX's \makeheadline and \makefootline, which use the
354  % values in \headline and \footline.
355  %
356  % This is used to check if we are on the first page of a chapter.
357  \ifcase1\the\savedtopmark\fi
358  \let\prevchaptername\thischaptername
359  \ifcase0\firstmark\fi
360  \let\curchaptername\thischaptername
361  %
362  \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
363  %
364  \ifx\curchaptername\prevchaptername
365    \let\thischapterheading\thischapter
366  \else
367    % \thischapterheading is the same as \thischapter except it is blank
368    % for the first page of a chapter.  This is to prevent the chapter name
369    % being shown twice.
370    \def\thischapterheading{}%
371  \fi
372  %
373  % Common context changes for both heading and footing.
374  % Do this outside of the \shipout so @code etc. will be expanded in
375  % the headline as they should be, not taken literally (outputting ''code).
376  \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars}
377  %
378  \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}%
379  %
380  \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
381  \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}%
382  %
383  {%
384    % Set context for writing to auxiliary files like index files.
385    % Have to do this stuff outside the \shipout because we want it to
386    % take effect in \write's, yet the group defined by the \vbox ends
387    % before the \shipout runs.
388    %
389    \atdummies         % don't expand commands in the output.
390    \turnoffactive
391    \shipout\vbox{%
392      % Do this early so pdf references go to the beginning of the page.
393      \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
394      %
395      \unvbox\headlinebox
396      \pagebody{#1}%
397      \ifdim\ht\footlinebox > 0pt
398        % Only leave this space if the footline is nonempty.
399        % (We lessened \vsize for it in \oddfootingyyy.)
400        % The \baselineskip=24pt in plain's \makefootline has no effect.
401        \vskip 24pt
402        \unvbox\footlinebox
403      \fi
404      %
405    }%
406  }%
407  \global\topmarksavedfalse
408  \advancepageno
409  \ifnum\outputpenalty>-20000 \else\dosupereject\fi
410}
411
412\newinsert\margin \dimen\margin=\maxdimen
413
414% Main part of page, including any footnotes
415\def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
416{\catcode`\@ =11
417\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
418% marginal hacks, juha@viisa.uucp (Juha Takala)
419\ifvoid\margin\else % marginal info is present
420  \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
421\dimen@=\dp#1\relax \unvbox#1\relax
422\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
423\ifr@ggedbottom \kern-\dimen@ \vfil \fi}
424}
425
426
427% Argument parsing
428
429% Parse an argument, then pass it to #1.  The argument is the rest of
430% the input line (except we remove a trailing comment).  #1 should be a
431% macro which expects an ordinary undelimited TeX argument.
432% For example, \def\foo{\parsearg\fooxxx}.
433%
434\def\parsearg{\parseargusing{}}
435\def\parseargusing#1#2{%
436  \def\argtorun{#2}%
437  \begingroup
438    \obeylines
439    \spaceisspace
440    #1%
441    \parseargline\empty% Insert the \empty token, see \finishparsearg below.
442}
443
444{\obeylines %
445  \gdef\parseargline#1^^M{%
446    \endgroup % End of the group started in \parsearg.
447    \argremovecomment #1\comment\ArgTerm%
448  }%
449}
450
451% First remove any @comment, then any @c comment.  Pass the result on to
452% \argcheckspaces.
453\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
454\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
455
456% Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
457%
458% \argremovec might leave us with trailing space, e.g.,
459%    @end itemize  @c foo
460% This space token undergoes the same procedure and is eventually removed
461% by \finishparsearg.
462%
463\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
464\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
465\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
466  \def\temp{#3}%
467  \ifx\temp\empty
468    % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
469    \let\temp\finishparsearg
470  \else
471    \let\temp\argcheckspaces
472  \fi
473  % Put the space token in:
474  \temp#1 #3\ArgTerm
475}
476
477% If a _delimited_ argument is enclosed in braces, they get stripped; so
478% to get _exactly_ the rest of the line, we had to prevent such situation.
479% We prepended an \empty token at the very beginning and we expand it now,
480% just before passing the control to \argtorun.
481% (Similarly, we have to think about #3 of \argcheckspacesY above: it is
482% either the null string, or it ends with \^^M---thus there is no danger
483% that a pair of braces would be stripped.
484%
485% But first, we have to remove the trailing space token.
486%
487\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
488
489
490% \parseargdef - define a command taking an argument on the line
491%
492% \parseargdef\foo{...}
493%	is roughly equivalent to
494% \def\foo{\parsearg\Xfoo}
495% \def\Xfoo#1{...}
496\def\parseargdef#1{%
497  \expandafter \doparseargdef \csname\string#1\endcsname #1%
498}
499\def\doparseargdef#1#2{%
500  \def#2{\parsearg#1}%
501  \def#1##1%
502}
503
504% Several utility definitions with active space:
505{
506  \obeyspaces
507  \gdef\obeyedspace{ }
508
509  % Make each space character in the input produce a normal interword
510  % space in the output.  Don't allow a line break at this space, as this
511  % is used only in environments like @example, where each line of input
512  % should produce a line of output anyway.
513  %
514  \gdef\sepspaces{\obeyspaces\let =\tie}
515
516  % If an index command is used in an @example environment, any spaces
517  % therein should become regular spaces in the raw index file, not the
518  % expansion of \tie (\leavevmode \penalty \@M \ ).
519  \gdef\unsepspaces{\let =\space}
520}
521
522
523\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
524
525% Define the framework for environments in texinfo.tex.  It's used like this:
526%
527%   \envdef\foo{...}
528%   \def\Efoo{...}
529%
530% It's the responsibility of \envdef to insert \begingroup before the
531% actual body; @end closes the group after calling \Efoo.  \envdef also
532% defines \thisenv, so the current environment is known; @end checks
533% whether the environment name matches.  The \checkenv macro can also be
534% used to check whether the current environment is the one expected.
535%
536% Non-false conditionals (@iftex, @ifset) don't fit into this, so they
537% are not treated as environments; they don't open a group.  (The
538% implementation of @end takes care not to call \endgroup in this
539% special case.)
540
541
542% At run-time, environments start with this:
543\def\startenvironment#1{\begingroup\def\thisenv{#1}}
544% initialize
545\let\thisenv\empty
546
547% ... but they get defined via ``\envdef\foo{...}'':
548\long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
549\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
550
551% Check whether we're in the right environment:
552\def\checkenv#1{%
553  \def\temp{#1}%
554  \ifx\thisenv\temp
555  \else
556    \badenverr
557  \fi
558}
559
560% Environment mismatch, #1 expected:
561\def\badenverr{%
562  \errhelp = \EMsimple
563  \errmessage{This command can appear only \inenvironment\temp,
564    not \inenvironment\thisenv}%
565}
566\def\inenvironment#1{%
567  \ifx#1\empty
568    outside of any environment%
569  \else
570    in environment \expandafter\string#1%
571  \fi
572}
573
574% @end foo executes the definition of \Efoo.
575% But first, it executes a specialized version of \checkenv
576%
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
1006% @refill is a no-op.
1007\let\refill=\relax
1008
1009% @setfilename INFO-FILENAME - ignored
1010\let\setfilename=\comment
1011
1012% @bye.
1013\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
1014
1015
1016\message{pdf,}
1017% adobe `portable' document format
1018\newcount\tempnum
1019\newcount\lnkcount
1020\newtoks\filename
1021\newcount\filenamelength
1022\newcount\pgn
1023\newtoks\toksA
1024\newtoks\toksB
1025\newtoks\toksC
1026\newtoks\toksD
1027\newbox\boxA
1028\newbox\boxB
1029\newcount\countA
1030\newif\ifpdf
1031\newif\ifpdfmakepagedest
1032
1033%
1034% For LuaTeX
1035%
1036
1037\newif\iftxiuseunicodedestname
1038\txiuseunicodedestnamefalse % For pdfTeX etc.
1039
1040\ifx\luatexversion\thisisundefined
1041\else
1042  % Use Unicode destination names
1043  \txiuseunicodedestnametrue
1044  % Escape PDF strings with converting UTF-16 from UTF-8
1045  \begingroup
1046    \catcode`\%=12
1047    \directlua{
1048      function UTF16oct(str)
1049        tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
1050        for c in string.utfvalues(str) do
1051          if c < 0x10000 then
1052            tex.sprint(
1053              string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1054                            string.char(0x5c) .. string.char(0x25) .. '03o',
1055                            (c / 256), (c % 256)))
1056          else
1057            c = c - 0x10000
1058            local c_hi = c / 1024 + 0xd800
1059            local c_lo = c % 1024 + 0xdc00
1060            tex.sprint(
1061              string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1062                            string.char(0x5c) .. string.char(0x25) .. '03o' ..
1063                            string.char(0x5c) .. string.char(0x25) .. '03o' ..
1064                            string.char(0x5c) .. string.char(0x25) .. '03o',
1065                            (c_hi / 256), (c_hi % 256),
1066                            (c_lo / 256), (c_lo % 256)))
1067          end
1068        end
1069      end
1070    }
1071  \endgroup
1072  \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
1073  % Escape PDF strings without converting
1074  \begingroup
1075    \directlua{
1076      function PDFescstr(str)
1077        for c in string.bytes(str) do
1078          if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
1079            tex.sprint(
1080              string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
1081                            c))
1082          else
1083            tex.sprint(string.char(c))
1084          end
1085        end
1086      end
1087    }
1088  \endgroup
1089  \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
1090  \ifnum\luatexversion>84
1091    % For LuaTeX >= 0.85
1092    \def\pdfdest{\pdfextension dest}
1093    \let\pdfoutput\outputmode
1094    \def\pdfliteral{\pdfextension literal}
1095    \def\pdfcatalog{\pdfextension catalog}
1096    \def\pdftexversion{\numexpr\pdffeedback version\relax}
1097    \let\pdfximage\saveimageresource
1098    \let\pdfrefximage\useimageresource
1099    \let\pdflastximage\lastsavedimageresourceindex
1100    \def\pdfendlink{\pdfextension endlink\relax}
1101    \def\pdfoutline{\pdfextension outline}
1102    \def\pdfstartlink{\pdfextension startlink}
1103    \def\pdffontattr{\pdfextension fontattr}
1104    \def\pdfobj{\pdfextension obj}
1105    \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
1106    \let\pdfpagewidth\pagewidth
1107    \let\pdfpageheight\pageheight
1108    \edef\pdfhorigin{\pdfvariable horigin}
1109    \edef\pdfvorigin{\pdfvariable vorigin}
1110  \fi
1111\fi
1112
1113% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1114% can be set).  So we test for \relax and 0 as well as being undefined.
1115\ifx\pdfoutput\thisisundefined
1116\else
1117  \ifx\pdfoutput\relax
1118  \else
1119    \ifcase\pdfoutput
1120    \else
1121      \pdftrue
1122    \fi
1123  \fi
1124\fi
1125
1126\newif\ifpdforxetex
1127\pdforxetexfalse
1128\ifpdf
1129  \pdforxetextrue
1130\fi
1131\ifx\XeTeXrevision\thisisundefined\else
1132  \pdforxetextrue
1133\fi
1134
1135
1136% PDF uses PostScript string constants for the names of xref targets,
1137% for display in the outlines, and in other places.  Thus, we have to
1138% double any backslashes.  Otherwise, a name like "\node" will be
1139% interpreted as a newline (\n), followed by o, d, e.  Not good.
1140%
1141% See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
1142% related messages.  The final outcome is that it is up to the TeX user
1143% to double the backslashes and otherwise make the string valid, so
1144% that's what we do.  pdftex 1.30.0 (ca.2005) introduced a primitive to
1145% do this reliably, so we use it.
1146
1147% #1 is a control sequence in which to do the replacements,
1148% which we \xdef.
1149\def\txiescapepdf#1{%
1150  \ifx\pdfescapestring\thisisundefined
1151    % No primitive available; should we give a warning or log?
1152    % Many times it won't matter.
1153    \xdef#1{#1}%
1154  \else
1155    % The expandable \pdfescapestring primitive escapes parentheses,
1156    % backslashes, and other special chars.
1157    \xdef#1{\pdfescapestring{#1}}%
1158  \fi
1159}
1160\def\txiescapepdfutfsixteen#1{%
1161  \ifx\pdfescapestrutfsixteen\thisisundefined
1162    % No UTF-16 converting macro available.
1163    \txiescapepdf{#1}%
1164  \else
1165    \xdef#1{\pdfescapestrutfsixteen{#1}}%
1166  \fi
1167}
1168
1169\newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1170with PDF output, and none of those formats could be found.  (.eps cannot
1171be supported due to the design of the PDF format; use regular TeX (DVI
1172output) for that.)}
1173
1174\ifpdf
1175  %
1176  % Color manipulation macros using ideas from pdfcolor.tex,
1177  % except using rgb instead of cmyk; the latter is said to render as a
1178  % very dark gray on-screen and a very dark halftone in print, instead
1179  % of actual black. The dark red here is dark enough to print on paper as
1180  % nearly black, but still distinguishable for online viewing.  We use
1181  % black by default, though.
1182  \def\rgbDarkRed{0.50 0.09 0.12}
1183  \def\rgbBlack{0 0 0}
1184  %
1185  % rg sets the color for filling (usual text, etc.);
1186  % RG sets the color for stroking (thin rules, e.g., normal _'s).
1187  \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
1188  %
1189  % Set color, and create a mark which defines \thiscolor accordingly,
1190  % so that \makeheadline knows which color to restore.
1191  \def\setcolor#1{%
1192    \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
1193    \domark
1194    \pdfsetcolor{#1}%
1195  }
1196  %
1197  \def\maincolor{\rgbBlack}
1198  \pdfsetcolor{\maincolor}
1199  \edef\thiscolor{\maincolor}
1200  \def\currentcolordefs{}
1201  %
1202  \def\makefootline{%
1203    \baselineskip24pt
1204    \line{\pdfsetcolor{\maincolor}\the\footline}%
1205  }
1206  %
1207  \def\makeheadline{%
1208    \vbox to 0pt{%
1209      \vskip-22.5pt
1210      \line{%
1211        \vbox to8.5pt{}%
1212        % Extract \thiscolor definition from the marks.
1213        \getcolormarks
1214        % Typeset the headline with \maincolor, then restore the color.
1215        \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1216      }%
1217      \vss
1218    }%
1219    \nointerlineskip
1220  }
1221  %
1222  %
1223  \pdfcatalog{/PageMode /UseOutlines}
1224  %
1225  % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1226  \def\dopdfimage#1#2#3{%
1227    \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1228    \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1229    %
1230    % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1231    % others).  Let's try in that order, PDF first since if
1232    % someone has a scalable image, presumably better to use that than a
1233    % bitmap.
1234    \let\pdfimgext=\empty
1235    \begingroup
1236      \openin 1 #1.pdf \ifeof 1
1237        \openin 1 #1.PDF \ifeof 1
1238          \openin 1 #1.png \ifeof 1
1239            \openin 1 #1.jpg \ifeof 1
1240              \openin 1 #1.jpeg \ifeof 1
1241                \openin 1 #1.JPG \ifeof 1
1242                  \errhelp = \nopdfimagehelp
1243                  \errmessage{Could not find image file #1 for pdf}%
1244                \else \gdef\pdfimgext{JPG}%
1245                \fi
1246              \else \gdef\pdfimgext{jpeg}%
1247              \fi
1248            \else \gdef\pdfimgext{jpg}%
1249            \fi
1250          \else \gdef\pdfimgext{png}%
1251          \fi
1252        \else \gdef\pdfimgext{PDF}%
1253        \fi
1254      \else \gdef\pdfimgext{pdf}%
1255      \fi
1256      \closein 1
1257    \endgroup
1258    %
1259    % without \immediate, ancient pdftex seg faults when the same image is
1260    % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
1261    \ifnum\pdftexversion < 14
1262      \immediate\pdfimage
1263    \else
1264      \immediate\pdfximage
1265    \fi
1266      \ifdim \wd0 >0pt width \pdfimagewidth \fi
1267      \ifdim \wd2 >0pt height \pdfimageheight \fi
1268      \ifnum\pdftexversion<13
1269         #1.\pdfimgext
1270       \else
1271         {#1.\pdfimgext}%
1272       \fi
1273    \ifnum\pdftexversion < 14 \else
1274      \pdfrefximage \pdflastximage
1275    \fi}
1276  %
1277  \def\setpdfdestname#1{{%
1278    % We have to set dummies so commands such as @code, and characters
1279    % such as \, aren't expanded when present in a section title.
1280    \indexnofonts
1281    \makevalueexpandable
1282    \turnoffactive
1283    \iftxiuseunicodedestname
1284      \ifx \declaredencoding \latone
1285        % Pass through Latin-1 characters.
1286        % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode.
1287      \else
1288        \ifx \declaredencoding \utfeight
1289          % Pass through Unicode characters.
1290        \else
1291          % Use ASCII approximations in destination names.
1292          \passthroughcharsfalse
1293        \fi
1294      \fi
1295    \else
1296      % Use ASCII approximations in destination names.
1297      \passthroughcharsfalse
1298    \fi
1299    \def\pdfdestname{#1}%
1300    \txiescapepdf\pdfdestname
1301  }}
1302  %
1303  \def\setpdfoutlinetext#1{{%
1304    \indexnofonts
1305    \makevalueexpandable
1306    \turnoffactive
1307    \ifx \declaredencoding \latone
1308      % The PDF format can use an extended form of Latin-1 in bookmark
1309      % strings.  See Appendix D of the PDF Reference, Sixth Edition, for
1310      % the "PDFDocEncoding".
1311      \passthroughcharstrue
1312      % Pass through Latin-1 characters.
1313      %   LuaTeX: Convert to Unicode
1314      %   pdfTeX: Use Latin-1 as PDFDocEncoding
1315      \def\pdfoutlinetext{#1}%
1316    \else
1317      \ifx \declaredencoding \utfeight
1318        \ifx\luatexversion\thisisundefined
1319          % For pdfTeX  with UTF-8.
1320          % TODO: the PDF format can use UTF-16 in bookmark strings,
1321          % but the code for this isn't done yet.
1322          % Use ASCII approximations.
1323          \passthroughcharsfalse
1324          \def\pdfoutlinetext{#1}%
1325        \else
1326          % For LuaTeX with UTF-8.
1327          % Pass through Unicode characters for title texts.
1328          \passthroughcharstrue
1329          \def\pdfoutlinetext{#1}%
1330        \fi
1331      \else
1332        % For non-Latin-1 or non-UTF-8 encodings.
1333        % Use ASCII approximations.
1334        \passthroughcharsfalse
1335        \def\pdfoutlinetext{#1}%
1336      \fi
1337    \fi
1338    % LuaTeX: Convert to UTF-16
1339    % pdfTeX: Use Latin-1 as PDFDocEncoding
1340    \txiescapepdfutfsixteen\pdfoutlinetext
1341  }}
1342  %
1343  \def\pdfmkdest#1{%
1344    \setpdfdestname{#1}%
1345    \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1346  }
1347  %
1348  % used to mark target names; must be expandable.
1349  \def\pdfmkpgn#1{#1}
1350  %
1351  % by default, use black for everything.
1352  \def\urlcolor{\rgbBlack}
1353  \def\linkcolor{\rgbBlack}
1354  \def\endlink{\setcolor{\maincolor}\pdfendlink}
1355  %
1356  % Adding outlines to PDF; macros for calculating structure of outlines
1357  % come from Petr Olsak
1358  \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1359    \else \csname#1\endcsname \fi}
1360  \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1361    \advance\tempnum by 1
1362    \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1363  %
1364  % #1 is the section text, which is what will be displayed in the
1365  % outline by the pdf viewer.  #2 is the pdf expression for the number
1366  % of subentries (or empty, for subsubsections).  #3 is the node text,
1367  % which might be empty if this toc entry had no corresponding node.
1368  % #4 is the page number
1369  %
1370  \def\dopdfoutline#1#2#3#4{%
1371    % Generate a link to the node text if that exists; else, use the
1372    % page number.  We could generate a destination for the section
1373    % text in the case where a section has no node, but it doesn't
1374    % seem worth the trouble, since most documents are normally structured.
1375    \setpdfoutlinetext{#1}
1376    \setpdfdestname{#3}
1377    \ifx\pdfdestname\empty
1378      \def\pdfdestname{#4}%
1379    \fi
1380    %
1381    \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}%
1382  }
1383  %
1384  \def\pdfmakeoutlines{%
1385    \begingroup
1386      % Read toc silently, to get counts of subentries for \pdfoutline.
1387      \def\partentry##1##2##3##4{}% ignore parts in the outlines
1388      \def\numchapentry##1##2##3##4{%
1389	\def\thischapnum{##2}%
1390	\def\thissecnum{0}%
1391	\def\thissubsecnum{0}%
1392      }%
1393      \def\numsecentry##1##2##3##4{%
1394	\advancenumber{chap\thischapnum}%
1395	\def\thissecnum{##2}%
1396	\def\thissubsecnum{0}%
1397      }%
1398      \def\numsubsecentry##1##2##3##4{%
1399	\advancenumber{sec\thissecnum}%
1400	\def\thissubsecnum{##2}%
1401      }%
1402      \def\numsubsubsecentry##1##2##3##4{%
1403	\advancenumber{subsec\thissubsecnum}%
1404      }%
1405      \def\thischapnum{0}%
1406      \def\thissecnum{0}%
1407      \def\thissubsecnum{0}%
1408      %
1409      % use \def rather than \let here because we redefine \chapentry et
1410      % al. a second time, below.
1411      \def\appentry{\numchapentry}%
1412      \def\appsecentry{\numsecentry}%
1413      \def\appsubsecentry{\numsubsecentry}%
1414      \def\appsubsubsecentry{\numsubsubsecentry}%
1415      \def\unnchapentry{\numchapentry}%
1416      \def\unnsecentry{\numsecentry}%
1417      \def\unnsubsecentry{\numsubsecentry}%
1418      \def\unnsubsubsecentry{\numsubsubsecentry}%
1419      \readdatafile{toc}%
1420      %
1421      % Read toc second time, this time actually producing the outlines.
1422      % The `-' means take the \expnumber as the absolute number of
1423      % subentries, which we calculated on our first read of the .toc above.
1424      %
1425      % We use the node names as the destinations.
1426      \def\numchapentry##1##2##3##4{%
1427        \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1428      \def\numsecentry##1##2##3##4{%
1429        \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1430      \def\numsubsecentry##1##2##3##4{%
1431        \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1432      \def\numsubsubsecentry##1##2##3##4{% count is always zero
1433        \dopdfoutline{##1}{}{##3}{##4}}%
1434      %
1435      % PDF outlines are displayed using system fonts, instead of
1436      % document fonts.  Therefore we cannot use special characters,
1437      % since the encoding is unknown.  For example, the eogonek from
1438      % Latin 2 (0xea) gets translated to a | character.  Info from
1439      % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1440      %
1441      % TODO this right, we have to translate 8-bit characters to
1442      % their "best" equivalent, based on the @documentencoding.  Too
1443      % much work for too little return.  Just use the ASCII equivalents
1444      % we use for the index sort strings.
1445      %
1446      \indexnofonts
1447      \setupdatafile
1448      % We can have normal brace characters in the PDF outlines, unlike
1449      % Texinfo index files.  So set that up.
1450      \def\{{\lbracecharliteral}%
1451      \def\}{\rbracecharliteral}%
1452      \catcode`\\=\active \otherbackslash
1453      \input \tocreadfilename
1454    \endgroup
1455  }
1456  {\catcode`[=1 \catcode`]=2
1457   \catcode`{=\other \catcode`}=\other
1458   \gdef\lbracecharliteral[{]%
1459   \gdef\rbracecharliteral[}]%
1460  ]
1461  %
1462  \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1463    \ifx\PP\D\let\nextsp\relax
1464    \else\let\nextsp\skipspaces
1465      \addtokens{\filename}{\PP}%
1466      \advance\filenamelength by 1
1467    \fi
1468    \nextsp}
1469  \def\getfilename#1{%
1470    \filenamelength=0
1471    % If we don't expand the argument now, \skipspaces will get
1472    % snagged on things like "@value{foo}".
1473    \edef\temp{#1}%
1474    \expandafter\skipspaces\temp|\relax
1475  }
1476  \ifnum\pdftexversion < 14
1477    \let \startlink \pdfannotlink
1478  \else
1479    \let \startlink \pdfstartlink
1480  \fi
1481  % make a live url in pdf output.
1482  \def\pdfurl#1{%
1483    \begingroup
1484      % it seems we really need yet another set of dummies; have not
1485      % tried to figure out what each command should do in the context
1486      % of @url.  for now, just make @/ a no-op, that's the only one
1487      % people have actually reported a problem with.
1488      %
1489      \normalturnoffactive
1490      \def\@{@}%
1491      \let\/=\empty
1492      \makevalueexpandable
1493      % do we want to go so far as to use \indexnofonts instead of just
1494      % special-casing \var here?
1495      \def\var##1{##1}%
1496      %
1497      \leavevmode\setcolor{\urlcolor}%
1498      \startlink attr{/Border [0 0 0]}%
1499        user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1500    \endgroup}
1501  % \pdfgettoks - Surround page numbers in #1 with @pdflink.  #1 may
1502  % be a simple number, or a list of numbers in the case of an index
1503  % entry.
1504  \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1505  \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1506  \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1507  \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1508  \def\maketoks{%
1509    \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1510    \ifx\first0\adn0
1511    \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1512    \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1513    \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1514    \else
1515      \ifnum0=\countA\else\makelink\fi
1516      \ifx\first.\let\next=\done\else
1517        \let\next=\maketoks
1518        \addtokens{\toksB}{\the\toksD}
1519        \ifx\first,\addtokens{\toksB}{\space}\fi
1520      \fi
1521    \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1522    \next}
1523  \def\makelink{\addtokens{\toksB}%
1524    {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1525  \def\pdflink#1{%
1526    \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1527    \setcolor{\linkcolor}#1\endlink}
1528  \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1529\else
1530  % non-pdf mode
1531  \let\pdfmkdest = \gobble
1532  \let\pdfurl = \gobble
1533  \let\endlink = \relax
1534  \let\setcolor = \gobble
1535  \let\pdfsetcolor = \gobble
1536  \let\pdfmakeoutlines = \relax
1537\fi  % \ifx\pdfoutput
1538
1539%
1540% For XeTeX
1541%
1542\ifx\XeTeXrevision\thisisundefined
1543\else
1544  %
1545  % XeTeX version check
1546  %
1547  \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1
1548    % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307.
1549    % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941).
1550    % For avoiding PDF destination name replacement, we use this special
1551    % instead of xdvipdfmx's command line option `-C 0x0010'.
1552    \special{dvipdfmx:config C 0x0010}
1553    % XeTeX 0.99995+ comes with xdvipdfmx 20160307+.
1554    % It can handle Unicode destination names for PDF.
1555    \txiuseunicodedestnametrue
1556  \else
1557    % XeTeX < 0.99996 (TeX Live < 2016) cannot use the
1558    % `dvipdfmx:config' special.
1559    % So for avoiding PDF destination name replacement,
1560    % xdvipdfmx's command line option `-C 0x0010' is necessary.
1561    %
1562    % XeTeX < 0.99995 can not handle Unicode destination names for PDF
1563    % because xdvipdfmx 20150315 has a UTF-16 conversion issue.
1564    % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1565    \txiuseunicodedestnamefalse
1566  \fi
1567  %
1568  % Color support
1569  %
1570  \def\rgbDarkRed{0.50 0.09 0.12}
1571  \def\rgbBlack{0 0 0}
1572  %
1573  \def\pdfsetcolor#1{\special{pdf:scolor [#1]}}
1574  %
1575  % Set color, and create a mark which defines \thiscolor accordingly,
1576  % so that \makeheadline knows which color to restore.
1577  \def\setcolor#1{%
1578    \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
1579    \domark
1580    \pdfsetcolor{#1}%
1581  }
1582  %
1583  \def\maincolor{\rgbBlack}
1584  \pdfsetcolor{\maincolor}
1585  \edef\thiscolor{\maincolor}
1586  \def\currentcolordefs{}
1587  %
1588  \def\makefootline{%
1589    \baselineskip24pt
1590    \line{\pdfsetcolor{\maincolor}\the\footline}%
1591  }
1592  %
1593  \def\makeheadline{%
1594    \vbox to 0pt{%
1595      \vskip-22.5pt
1596      \line{%
1597        \vbox to8.5pt{}%
1598        % Extract \thiscolor definition from the marks.
1599        \getcolormarks
1600        % Typeset the headline with \maincolor, then restore the color.
1601        \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1602      }%
1603      \vss
1604    }%
1605    \nointerlineskip
1606  }
1607  %
1608  % PDF outline support
1609  %
1610  % Emulate pdfTeX primitive
1611  \def\pdfdest name#1 xyz{%
1612    \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}%
1613  }
1614  %
1615  \def\setpdfdestname#1{{%
1616    % We have to set dummies so commands such as @code, and characters
1617    % such as \, aren't expanded when present in a section title.
1618    \indexnofonts
1619    \makevalueexpandable
1620    \turnoffactive
1621    \iftxiuseunicodedestname
1622      % Pass through Unicode characters.
1623    \else
1624      % Use ASCII approximations in destination names.
1625      \passthroughcharsfalse
1626    \fi
1627    \def\pdfdestname{#1}%
1628    \txiescapepdf\pdfdestname
1629  }}
1630  %
1631  \def\setpdfoutlinetext#1{{%
1632    \turnoffactive
1633    % Always use Unicode characters in title texts.
1634    \def\pdfoutlinetext{#1}%
1635    % For XeTeX, xdvipdfmx converts to UTF-16.
1636    % So we do not convert.
1637    \txiescapepdf\pdfoutlinetext
1638  }}
1639  %
1640  \def\pdfmkdest#1{%
1641    \setpdfdestname{#1}%
1642    \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1643  }
1644  %
1645  % by default, use black for everything.
1646  \def\urlcolor{\rgbBlack}
1647  \def\linkcolor{\rgbBlack}
1648  \def\endlink{\setcolor{\maincolor}\pdfendlink}
1649  %
1650  \def\dopdfoutline#1#2#3#4{%
1651    \setpdfoutlinetext{#1}
1652    \setpdfdestname{#3}
1653    \ifx\pdfdestname\empty
1654      \def\pdfdestname{#4}%
1655    \fi
1656    %
1657    \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
1658      << /S /GoTo /D (\pdfdestname) >> >> }%
1659  }
1660  %
1661  \def\pdfmakeoutlines{%
1662    \begingroup
1663      %
1664      % For XeTeX, counts of subentries are not necessary.
1665      % Therefore, we read toc only once.
1666      %
1667      % We use node names as destinations.
1668      \def\partentry##1##2##3##4{}% ignore parts in the outlines
1669      \def\numchapentry##1##2##3##4{%
1670        \dopdfoutline{##1}{1}{##3}{##4}}%
1671      \def\numsecentry##1##2##3##4{%
1672        \dopdfoutline{##1}{2}{##3}{##4}}%
1673      \def\numsubsecentry##1##2##3##4{%
1674        \dopdfoutline{##1}{3}{##3}{##4}}%
1675      \def\numsubsubsecentry##1##2##3##4{%
1676        \dopdfoutline{##1}{4}{##3}{##4}}%
1677      %
1678      \let\appentry\numchapentry%
1679      \let\appsecentry\numsecentry%
1680      \let\appsubsecentry\numsubsecentry%
1681      \let\appsubsubsecentry\numsubsubsecentry%
1682      \let\unnchapentry\numchapentry%
1683      \let\unnsecentry\numsecentry%
1684      \let\unnsubsecentry\numsubsecentry%
1685      \let\unnsubsubsecentry\numsubsubsecentry%
1686      %
1687      % For XeTeX, xdvipdfmx converts strings to UTF-16.
1688      % Therefore, the encoding and the language may not be considered.
1689      %
1690      \indexnofonts
1691      \setupdatafile
1692      % We can have normal brace characters in the PDF outlines, unlike
1693      % Texinfo index files.  So set that up.
1694      \def\{{\lbracecharliteral}%
1695      \def\}{\rbracecharliteral}%
1696      \catcode`\\=\active \otherbackslash
1697      \input \tocreadfilename
1698    \endgroup
1699  }
1700  {\catcode`[=1 \catcode`]=2
1701   \catcode`{=\other \catcode`}=\other
1702   \gdef\lbracecharliteral[{]%
1703   \gdef\rbracecharliteral[}]%
1704  ]
1705
1706  \special{pdf:docview << /PageMode /UseOutlines >> }
1707  % ``\special{pdf:tounicode ...}'' is not necessary
1708  % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
1709  % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315,
1710  % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings.
1711  % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1712%
1713  \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1714    \ifx\PP\D\let\nextsp\relax
1715    \else\let\nextsp\skipspaces
1716      \addtokens{\filename}{\PP}%
1717      \advance\filenamelength by 1
1718    \fi
1719    \nextsp}
1720  \def\getfilename#1{%
1721    \filenamelength=0
1722    % If we don't expand the argument now, \skipspaces will get
1723    % snagged on things like "@value{foo}".
1724    \edef\temp{#1}%
1725    \expandafter\skipspaces\temp|\relax
1726  }
1727  % make a live url in pdf output.
1728  \def\pdfurl#1{%
1729    \begingroup
1730      % it seems we really need yet another set of dummies; have not
1731      % tried to figure out what each command should do in the context
1732      % of @url.  for now, just make @/ a no-op, that's the only one
1733      % people have actually reported a problem with.
1734      %
1735      \normalturnoffactive
1736      \def\@{@}%
1737      \let\/=\empty
1738      \makevalueexpandable
1739      % do we want to go so far as to use \indexnofonts instead of just
1740      % special-casing \var here?
1741      \def\var##1{##1}%
1742      %
1743      \leavevmode\setcolor{\urlcolor}%
1744      \special{pdf:bann << /Border [0 0 0]
1745        /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
1746    \endgroup}
1747  \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
1748  \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1749  \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1750  \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1751  \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1752  \def\maketoks{%
1753    \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1754    \ifx\first0\adn0
1755    \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1756    \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1757    \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1758    \else
1759      \ifnum0=\countA\else\makelink\fi
1760      \ifx\first.\let\next=\done\else
1761        \let\next=\maketoks
1762        \addtokens{\toksB}{\the\toksD}
1763        \ifx\first,\addtokens{\toksB}{\space}\fi
1764      \fi
1765    \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1766    \next}
1767  \def\makelink{\addtokens{\toksB}%
1768    {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1769  \def\pdflink#1{%
1770    \special{pdf:bann << /Border [0 0 0]
1771      /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}%
1772    \setcolor{\linkcolor}#1\endlink}
1773  \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1774%
1775  %
1776  % @image support
1777  %
1778  % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1779  \def\doxeteximage#1#2#3{%
1780    \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1781    \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1782    %
1783    % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among
1784    % others).  Let's try in that order, PDF first since if
1785    % someone has a scalable image, presumably better to use that than a
1786    % bitmap.
1787    \let\xeteximgext=\empty
1788    \begingroup
1789      \openin 1 #1.pdf \ifeof 1
1790        \openin 1 #1.PDF \ifeof 1
1791          \openin 1 #1.png \ifeof 1
1792            \openin 1 #1.jpg \ifeof 1
1793              \openin 1 #1.jpeg \ifeof 1
1794                \openin 1 #1.JPG \ifeof 1
1795                  \errmessage{Could not find image file #1 for XeTeX}%
1796                \else \gdef\xeteximgext{JPG}%
1797                \fi
1798              \else \gdef\xeteximgext{jpeg}%
1799              \fi
1800            \else \gdef\xeteximgext{jpg}%
1801            \fi
1802          \else \gdef\xeteximgext{png}%
1803          \fi
1804        \else \gdef\xeteximgext{PDF}%
1805        \fi
1806      \else \gdef\xeteximgext{pdf}%
1807      \fi
1808      \closein 1
1809    \endgroup
1810    %
1811    \def\xetexpdfext{pdf}%
1812    \ifx\xeteximgext\xetexpdfext
1813      \XeTeXpdffile "#1".\xeteximgext ""
1814    \else
1815      \def\xetexpdfext{PDF}%
1816      \ifx\xeteximgext\xetexpdfext
1817        \XeTeXpdffile "#1".\xeteximgext ""
1818      \else
1819        \XeTeXpicfile "#1".\xeteximgext ""
1820      \fi
1821    \fi
1822    \ifdim \wd0 >0pt width \xeteximagewidth \fi
1823    \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1824  }
1825\fi
1826
1827
1828%
1829\message{fonts,}
1830
1831% Set the baselineskip to #1, and the lineskip and strut size
1832% correspondingly.  There is no deep meaning behind these magic numbers
1833% used as factors; they just match (closely enough) what Knuth defined.
1834%
1835\def\lineskipfactor{.08333}
1836\def\strutheightpercent{.70833}
1837\def\strutdepthpercent {.29167}
1838%
1839% can get a sort of poor man's double spacing by redefining this.
1840\def\baselinefactor{1}
1841%
1842\newdimen\textleading
1843\def\setleading#1{%
1844  \dimen0 = #1\relax
1845  \normalbaselineskip = \baselinefactor\dimen0
1846  \normallineskip = \lineskipfactor\normalbaselineskip
1847  \normalbaselines
1848  \setbox\strutbox =\hbox{%
1849    \vrule width0pt height\strutheightpercent\baselineskip
1850                    depth \strutdepthpercent \baselineskip
1851  }%
1852}
1853
1854% PDF CMaps.  See also LaTeX's t1.cmap.
1855%
1856% do nothing with this by default.
1857\expandafter\let\csname cmapOT1\endcsname\gobble
1858\expandafter\let\csname cmapOT1IT\endcsname\gobble
1859\expandafter\let\csname cmapOT1TT\endcsname\gobble
1860
1861% if we are producing pdf, and we have \pdffontattr, then define cmaps.
1862% (\pdffontattr was introduced many years ago, but people still run
1863% older pdftex's; it's easy to conditionalize, so we do.)
1864\ifpdf \ifx\pdffontattr\thisisundefined \else
1865  \begingroup
1866    \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1867    \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1868%%DocumentNeededResources: ProcSet (CIDInit)
1869%%IncludeResource: ProcSet (CIDInit)
1870%%BeginResource: CMap (TeX-OT1-0)
1871%%Title: (TeX-OT1-0 TeX OT1 0)
1872%%Version: 1.000
1873%%EndComments
1874/CIDInit /ProcSet findresource begin
187512 dict begin
1876begincmap
1877/CIDSystemInfo
1878<< /Registry (TeX)
1879/Ordering (OT1)
1880/Supplement 0
1881>> def
1882/CMapName /TeX-OT1-0 def
1883/CMapType 2 def
18841 begincodespacerange
1885<00> <7F>
1886endcodespacerange
18878 beginbfrange
1888<00> <01> <0393>
1889<09> <0A> <03A8>
1890<23> <26> <0023>
1891<28> <3B> <0028>
1892<3F> <5B> <003F>
1893<5D> <5E> <005D>
1894<61> <7A> <0061>
1895<7B> <7C> <2013>
1896endbfrange
189740 beginbfchar
1898<02> <0398>
1899<03> <039B>
1900<04> <039E>
1901<05> <03A0>
1902<06> <03A3>
1903<07> <03D2>
1904<08> <03A6>
1905<0B> <00660066>
1906<0C> <00660069>
1907<0D> <0066006C>
1908<0E> <006600660069>
1909<0F> <00660066006C>
1910<10> <0131>
1911<11> <0237>
1912<12> <0060>
1913<13> <00B4>
1914<14> <02C7>
1915<15> <02D8>
1916<16> <00AF>
1917<17> <02DA>
1918<18> <00B8>
1919<19> <00DF>
1920<1A> <00E6>
1921<1B> <0153>
1922<1C> <00F8>
1923<1D> <00C6>
1924<1E> <0152>
1925<1F> <00D8>
1926<21> <0021>
1927<22> <201D>
1928<27> <2019>
1929<3C> <00A1>
1930<3D> <003D>
1931<3E> <00BF>
1932<5C> <201C>
1933<5F> <02D9>
1934<60> <2018>
1935<7D> <02DD>
1936<7E> <007E>
1937<7F> <00A8>
1938endbfchar
1939endcmap
1940CMapName currentdict /CMap defineresource pop
1941end
1942end
1943%%EndResource
1944%%EOF
1945    }\endgroup
1946  \expandafter\edef\csname cmapOT1\endcsname#1{%
1947    \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1948  }%
1949%
1950% \cmapOT1IT
1951  \begingroup
1952    \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1953    \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1954%%DocumentNeededResources: ProcSet (CIDInit)
1955%%IncludeResource: ProcSet (CIDInit)
1956%%BeginResource: CMap (TeX-OT1IT-0)
1957%%Title: (TeX-OT1IT-0 TeX OT1IT 0)
1958%%Version: 1.000
1959%%EndComments
1960/CIDInit /ProcSet findresource begin
196112 dict begin
1962begincmap
1963/CIDSystemInfo
1964<< /Registry (TeX)
1965/Ordering (OT1IT)
1966/Supplement 0
1967>> def
1968/CMapName /TeX-OT1IT-0 def
1969/CMapType 2 def
19701 begincodespacerange
1971<00> <7F>
1972endcodespacerange
19738 beginbfrange
1974<00> <01> <0393>
1975<09> <0A> <03A8>
1976<25> <26> <0025>
1977<28> <3B> <0028>
1978<3F> <5B> <003F>
1979<5D> <5E> <005D>
1980<61> <7A> <0061>
1981<7B> <7C> <2013>
1982endbfrange
198342 beginbfchar
1984<02> <0398>
1985<03> <039B>
1986<04> <039E>
1987<05> <03A0>
1988<06> <03A3>
1989<07> <03D2>
1990<08> <03A6>
1991<0B> <00660066>
1992<0C> <00660069>
1993<0D> <0066006C>
1994<0E> <006600660069>
1995<0F> <00660066006C>
1996<10> <0131>
1997<11> <0237>
1998<12> <0060>
1999<13> <00B4>
2000<14> <02C7>
2001<15> <02D8>
2002<16> <00AF>
2003<17> <02DA>
2004<18> <00B8>
2005<19> <00DF>
2006<1A> <00E6>
2007<1B> <0153>
2008<1C> <00F8>
2009<1D> <00C6>
2010<1E> <0152>
2011<1F> <00D8>
2012<21> <0021>
2013<22> <201D>
2014<23> <0023>
2015<24> <00A3>
2016<27> <2019>
2017<3C> <00A1>
2018<3D> <003D>
2019<3E> <00BF>
2020<5C> <201C>
2021<5F> <02D9>
2022<60> <2018>
2023<7D> <02DD>
2024<7E> <007E>
2025<7F> <00A8>
2026endbfchar
2027endcmap
2028CMapName currentdict /CMap defineresource pop
2029end
2030end
2031%%EndResource
2032%%EOF
2033    }\endgroup
2034  \expandafter\edef\csname cmapOT1IT\endcsname#1{%
2035    \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2036  }%
2037%
2038% \cmapOT1TT
2039  \begingroup
2040    \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2041    \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2042%%DocumentNeededResources: ProcSet (CIDInit)
2043%%IncludeResource: ProcSet (CIDInit)
2044%%BeginResource: CMap (TeX-OT1TT-0)
2045%%Title: (TeX-OT1TT-0 TeX OT1TT 0)
2046%%Version: 1.000
2047%%EndComments
2048/CIDInit /ProcSet findresource begin
204912 dict begin
2050begincmap
2051/CIDSystemInfo
2052<< /Registry (TeX)
2053/Ordering (OT1TT)
2054/Supplement 0
2055>> def
2056/CMapName /TeX-OT1TT-0 def
2057/CMapType 2 def
20581 begincodespacerange
2059<00> <7F>
2060endcodespacerange
20615 beginbfrange
2062<00> <01> <0393>
2063<09> <0A> <03A8>
2064<21> <26> <0021>
2065<28> <5F> <0028>
2066<61> <7E> <0061>
2067endbfrange
206832 beginbfchar
2069<02> <0398>
2070<03> <039B>
2071<04> <039E>
2072<05> <03A0>
2073<06> <03A3>
2074<07> <03D2>
2075<08> <03A6>
2076<0B> <2191>
2077<0C> <2193>
2078<0D> <0027>
2079<0E> <00A1>
2080<0F> <00BF>
2081<10> <0131>
2082<11> <0237>
2083<12> <0060>
2084<13> <00B4>
2085<14> <02C7>
2086<15> <02D8>
2087<16> <00AF>
2088<17> <02DA>
2089<18> <00B8>
2090<19> <00DF>
2091<1A> <00E6>
2092<1B> <0153>
2093<1C> <00F8>
2094<1D> <00C6>
2095<1E> <0152>
2096<1F> <00D8>
2097<20> <2423>
2098<27> <2019>
2099<60> <2018>
2100<7F> <00A8>
2101endbfchar
2102endcmap
2103CMapName currentdict /CMap defineresource pop
2104end
2105end
2106%%EndResource
2107%%EOF
2108    }\endgroup
2109  \expandafter\edef\csname cmapOT1TT\endcsname#1{%
2110    \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2111  }%
2112\fi\fi
2113
2114
2115% Set the font macro #1 to the font named \fontprefix#2.
2116% #3 is the font's design size, #4 is a scale factor, #5 is the CMap
2117% encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
2118% Example:
2119% #1 = \textrm
2120% #2 = \rmshape
2121% #3 = 10
2122% #4 = \mainmagstep
2123% #5 = OT1
2124%
2125\def\setfont#1#2#3#4#5{%
2126  \font#1=\fontprefix#2#3 scaled #4
2127  \csname cmap#5\endcsname#1%
2128}
2129% This is what gets called when #5 of \setfont is empty.
2130\let\cmap\gobble
2131%
2132% (end of cmaps)
2133
2134% Use cm as the default font prefix.
2135% To specify the font prefix, you must define \fontprefix
2136% before you read in texinfo.tex.
2137\ifx\fontprefix\thisisundefined
2138\def\fontprefix{cm}
2139\fi
2140% Support font families that don't use the same naming scheme as CM.
2141\def\rmshape{r}
2142\def\rmbshape{bx}               % where the normal face is bold
2143\def\bfshape{b}
2144\def\bxshape{bx}
2145\def\ttshape{tt}
2146\def\ttbshape{tt}
2147\def\ttslshape{sltt}
2148\def\itshape{ti}
2149\def\itbshape{bxti}
2150\def\slshape{sl}
2151\def\slbshape{bxsl}
2152\def\sfshape{ss}
2153\def\sfbshape{ss}
2154\def\scshape{csc}
2155\def\scbshape{csc}
2156
2157% Definitions for a main text size of 11pt.  (The default in Texinfo.)
2158%
2159\def\definetextfontsizexi{%
2160% Text fonts (11.2pt, magstep1).
2161\def\textnominalsize{11pt}
2162\edef\mainmagstep{\magstephalf}
2163\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2164\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2165\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2166\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2167\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2168\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2169\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2170\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2171\font\texti=cmmi10 scaled \mainmagstep
2172\font\textsy=cmsy10 scaled \mainmagstep
2173\def\textecsize{1095}
2174
2175% A few fonts for @defun names and args.
2176\setfont\defbf\bfshape{10}{\magstep1}{OT1}
2177\setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
2178\setfont\defsl\slshape{10}{\magstep1}{OT1}
2179\setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
2180\def\df{\let\ttfont=\deftt \let\bffont = \defbf
2181\let\ttslfont=\defttsl \let\slfont=\defsl \bf}
2182
2183% Fonts for indices, footnotes, small examples (9pt).
2184\def\smallnominalsize{9pt}
2185\setfont\smallrm\rmshape{9}{1000}{OT1}
2186\setfont\smalltt\ttshape{9}{1000}{OT1TT}
2187\setfont\smallbf\bfshape{10}{900}{OT1}
2188\setfont\smallit\itshape{9}{1000}{OT1IT}
2189\setfont\smallsl\slshape{9}{1000}{OT1}
2190\setfont\smallsf\sfshape{9}{1000}{OT1}
2191\setfont\smallsc\scshape{10}{900}{OT1}
2192\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2193\font\smalli=cmmi9
2194\font\smallsy=cmsy9
2195\def\smallecsize{0900}
2196
2197% Fonts for small examples (8pt).
2198\def\smallernominalsize{8pt}
2199\setfont\smallerrm\rmshape{8}{1000}{OT1}
2200\setfont\smallertt\ttshape{8}{1000}{OT1TT}
2201\setfont\smallerbf\bfshape{10}{800}{OT1}
2202\setfont\smallerit\itshape{8}{1000}{OT1IT}
2203\setfont\smallersl\slshape{8}{1000}{OT1}
2204\setfont\smallersf\sfshape{8}{1000}{OT1}
2205\setfont\smallersc\scshape{10}{800}{OT1}
2206\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2207\font\smalleri=cmmi8
2208\font\smallersy=cmsy8
2209\def\smallerecsize{0800}
2210
2211% Fonts for math mode superscripts (7pt).
2212\def\sevennominalsize{7pt}
2213\setfont\sevenrm\rmshape{7}{1000}{OT1}
2214\setfont\seventt\ttshape{10}{700}{OT1TT}
2215\setfont\sevenbf\bfshape{10}{700}{OT1}
2216\setfont\sevenit\itshape{7}{1000}{OT1IT}
2217\setfont\sevensl\slshape{10}{700}{OT1}
2218\setfont\sevensf\sfshape{10}{700}{OT1}
2219\setfont\sevensc\scshape{10}{700}{OT1}
2220\setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2221\font\seveni=cmmi7
2222\font\sevensy=cmsy7
2223\def\sevenecsize{0700}
2224
2225% Fonts for title page (20.4pt):
2226\def\titlenominalsize{20pt}
2227\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2228\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2229\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2230\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2231\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2232\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2233\let\titlebf=\titlerm
2234\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2235\font\titlei=cmmi12 scaled \magstep3
2236\font\titlesy=cmsy10 scaled \magstep4
2237\def\titleecsize{2074}
2238
2239% Chapter (and unnumbered) fonts (17.28pt).
2240\def\chapnominalsize{17pt}
2241\setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2242\setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2243\setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2244\setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2245\setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2246\setfont\chapsf\sfbshape{17}{1000}{OT1}
2247\let\chapbf=\chaprm
2248\setfont\chapsc\scbshape{10}{\magstep3}{OT1}
2249\font\chapi=cmmi12 scaled \magstep2
2250\font\chapsy=cmsy10 scaled \magstep3
2251\def\chapecsize{1728}
2252
2253% Section fonts (14.4pt).
2254\def\secnominalsize{14pt}
2255\setfont\secrm\rmbshape{12}{\magstep1}{OT1}
2256\setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
2257\setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2258\setfont\secsl\slbshape{10}{\magstep2}{OT1}
2259\setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2260\setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2261\setfont\secsf\sfbshape{12}{\magstep1}{OT1}
2262\let\secbf\secrm
2263\setfont\secsc\scbshape{10}{\magstep2}{OT1}
2264\font\seci=cmmi12 scaled \magstep1
2265\font\secsy=cmsy10 scaled \magstep2
2266\def\sececsize{1440}
2267
2268% Subsection fonts (13.15pt).
2269\def\ssecnominalsize{13pt}
2270\setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2271\setfont\ssecit\itbshape{10}{1315}{OT1IT}
2272\setfont\ssecsl\slbshape{10}{1315}{OT1}
2273\setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2274\setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2275\setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
2276\let\ssecbf\ssecrm
2277\setfont\ssecsc\scbshape{10}{1315}{OT1}
2278\font\sseci=cmmi12 scaled \magstephalf
2279\font\ssecsy=cmsy10 scaled 1315
2280\def\ssececsize{1200}
2281
2282% Reduced fonts for @acronym in text (10pt).
2283\def\reducednominalsize{10pt}
2284\setfont\reducedrm\rmshape{10}{1000}{OT1}
2285\setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2286\setfont\reducedbf\bfshape{10}{1000}{OT1}
2287\setfont\reducedit\itshape{10}{1000}{OT1IT}
2288\setfont\reducedsl\slshape{10}{1000}{OT1}
2289\setfont\reducedsf\sfshape{10}{1000}{OT1}
2290\setfont\reducedsc\scshape{10}{1000}{OT1}
2291\setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
2292\font\reducedi=cmmi10
2293\font\reducedsy=cmsy10
2294\def\reducedecsize{1000}
2295
2296\textleading = 13.2pt % line spacing for 11pt CM
2297\textfonts            % reset the current fonts
2298\rm
2299} % end of 11pt text font size definitions, \definetextfontsizexi
2300
2301
2302% Definitions to make the main text be 10pt Computer Modern, with
2303% section, chapter, etc., sizes following suit.  This is for the GNU
2304% Press printing of the Emacs 22 manual.  Maybe other manuals in the
2305% future.  Used with @smallbook, which sets the leading to 12pt.
2306%
2307\def\definetextfontsizex{%
2308% Text fonts (10pt).
2309\def\textnominalsize{10pt}
2310\edef\mainmagstep{1000}
2311\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2312\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2313\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2314\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2315\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2316\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2317\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2318\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2319\font\texti=cmmi10 scaled \mainmagstep
2320\font\textsy=cmsy10 scaled \mainmagstep
2321\def\textecsize{1000}
2322
2323% A few fonts for @defun names and args.
2324\setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2325\setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
2326\setfont\defsl\slshape{10}{\magstephalf}{OT1}
2327\setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
2328\def\df{\let\ttfont=\deftt \let\bffont = \defbf
2329\let\slfont=\defsl \let\ttslfont=\defttsl \bf}
2330
2331% Fonts for indices, footnotes, small examples (9pt).
2332\def\smallnominalsize{9pt}
2333\setfont\smallrm\rmshape{9}{1000}{OT1}
2334\setfont\smalltt\ttshape{9}{1000}{OT1TT}
2335\setfont\smallbf\bfshape{10}{900}{OT1}
2336\setfont\smallit\itshape{9}{1000}{OT1IT}
2337\setfont\smallsl\slshape{9}{1000}{OT1}
2338\setfont\smallsf\sfshape{9}{1000}{OT1}
2339\setfont\smallsc\scshape{10}{900}{OT1}
2340\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2341\font\smalli=cmmi9
2342\font\smallsy=cmsy9
2343\def\smallecsize{0900}
2344
2345% Fonts for small examples (8pt).
2346\def\smallernominalsize{8pt}
2347\setfont\smallerrm\rmshape{8}{1000}{OT1}
2348\setfont\smallertt\ttshape{8}{1000}{OT1TT}
2349\setfont\smallerbf\bfshape{10}{800}{OT1}
2350\setfont\smallerit\itshape{8}{1000}{OT1IT}
2351\setfont\smallersl\slshape{8}{1000}{OT1}
2352\setfont\smallersf\sfshape{8}{1000}{OT1}
2353\setfont\smallersc\scshape{10}{800}{OT1}
2354\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2355\font\smalleri=cmmi8
2356\font\smallersy=cmsy8
2357\def\smallerecsize{0800}
2358
2359% Fonts for math mode superscripts (7pt).
2360\def\sevennominalsize{7pt}
2361\setfont\sevenrm\rmshape{7}{1000}{OT1}
2362\setfont\seventt\ttshape{10}{700}{OT1TT}
2363\setfont\sevenbf\bfshape{10}{700}{OT1}
2364\setfont\sevenit\itshape{7}{1000}{OT1IT}
2365\setfont\sevensl\slshape{10}{700}{OT1}
2366\setfont\sevensf\sfshape{10}{700}{OT1}
2367\setfont\sevensc\scshape{10}{700}{OT1}
2368\setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2369\font\seveni=cmmi7
2370\font\sevensy=cmsy7
2371\def\sevenecsize{0700}
2372
2373% Fonts for title page (20.4pt):
2374\def\titlenominalsize{20pt}
2375\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2376\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2377\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2378\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2379\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2380\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2381\let\titlebf=\titlerm
2382\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2383\font\titlei=cmmi12 scaled \magstep3
2384\font\titlesy=cmsy10 scaled \magstep4
2385\def\titleecsize{2074}
2386
2387% Chapter fonts (14.4pt).
2388\def\chapnominalsize{14pt}
2389\setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2390\setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2391\setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2392\setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2393\setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2394\setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2395\let\chapbf\chaprm
2396\setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2397\font\chapi=cmmi12 scaled \magstep1
2398\font\chapsy=cmsy10 scaled \magstep2
2399\def\chapecsize{1440}
2400
2401% Section fonts (12pt).
2402\def\secnominalsize{12pt}
2403\setfont\secrm\rmbshape{12}{1000}{OT1}
2404\setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2405\setfont\secsl\slbshape{10}{\magstep1}{OT1}
2406\setfont\sectt\ttbshape{12}{1000}{OT1TT}
2407\setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2408\setfont\secsf\sfbshape{12}{1000}{OT1}
2409\let\secbf\secrm
2410\setfont\secsc\scbshape{10}{\magstep1}{OT1}
2411\font\seci=cmmi12
2412\font\secsy=cmsy10 scaled \magstep1
2413\def\sececsize{1200}
2414
2415% Subsection fonts (10pt).
2416\def\ssecnominalsize{10pt}
2417\setfont\ssecrm\rmbshape{10}{1000}{OT1}
2418\setfont\ssecit\itbshape{10}{1000}{OT1IT}
2419\setfont\ssecsl\slbshape{10}{1000}{OT1}
2420\setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2421\setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2422\setfont\ssecsf\sfbshape{10}{1000}{OT1}
2423\let\ssecbf\ssecrm
2424\setfont\ssecsc\scbshape{10}{1000}{OT1}
2425\font\sseci=cmmi10
2426\font\ssecsy=cmsy10
2427\def\ssececsize{1000}
2428
2429% Reduced fonts for @acronym in text (9pt).
2430\def\reducednominalsize{9pt}
2431\setfont\reducedrm\rmshape{9}{1000}{OT1}
2432\setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2433\setfont\reducedbf\bfshape{10}{900}{OT1}
2434\setfont\reducedit\itshape{9}{1000}{OT1IT}
2435\setfont\reducedsl\slshape{9}{1000}{OT1}
2436\setfont\reducedsf\sfshape{9}{1000}{OT1}
2437\setfont\reducedsc\scshape{10}{900}{OT1}
2438\setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2439\font\reducedi=cmmi9
2440\font\reducedsy=cmsy9
2441\def\reducedecsize{0900}
2442
2443\divide\parskip by 2  % reduce space between paragraphs
2444\textleading = 12pt   % line spacing for 10pt CM
2445\textfonts            % reset the current fonts
2446\rm
2447} % end of 10pt text font size definitions, \definetextfontsizex
2448
2449% Fonts for short table of contents.
2450\setfont\shortcontrm\rmshape{12}{1000}{OT1}
2451\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
2452\setfont\shortcontsl\slshape{12}{1000}{OT1}
2453\setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2454
2455
2456% We provide the user-level command
2457%   @fonttextsize 10
2458% (or 11) to redefine the text font size.  pt is assumed.
2459%
2460\def\xiword{11}
2461\def\xword{10}
2462\def\xwordpt{10pt}
2463%
2464\parseargdef\fonttextsize{%
2465  \def\textsizearg{#1}%
2466  %\wlog{doing @fonttextsize \textsizearg}%
2467  %
2468  % Set \globaldefs so that documents can use this inside @tex, since
2469  % makeinfo 4.8 does not support it, but we need it nonetheless.
2470  %
2471 \begingroup \globaldefs=1
2472  \ifx\textsizearg\xword \definetextfontsizex
2473  \else \ifx\textsizearg\xiword \definetextfontsizexi
2474  \else
2475    \errhelp=\EMsimple
2476    \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2477  \fi\fi
2478 \endgroup
2479}
2480
2481%
2482% Change the current font style to #1, remembering it in \curfontstyle.
2483% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
2484% italics, not bold italics.
2485%
2486\def\setfontstyle#1{%
2487  \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
2488  \csname #1font\endcsname  % change the current font
2489}
2490
2491\def\rm{\fam=0 \setfontstyle{rm}}
2492\def\it{\fam=\itfam \setfontstyle{it}}
2493\def\sl{\fam=\slfam \setfontstyle{sl}}
2494\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
2495\def\tt{\fam=\ttfam \setfontstyle{tt}}
2496
2497% Texinfo sort of supports the sans serif font style, which plain TeX does not.
2498% So we set up a \sf.
2499\newfam\sffam
2500\def\sf{\fam=\sffam \setfontstyle{sf}}
2501
2502% We don't need math for this font style.
2503\def\ttsl{\setfontstyle{ttsl}}
2504
2505
2506% In order for the font changes to affect most math symbols and letters,
2507% we have to define the \textfont of the standard families.
2508% We don't bother to reset \scriptscriptfont; awaiting user need.
2509%
2510\def\resetmathfonts{%
2511  \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont
2512  \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont
2513  \textfont\ttfam=\ttfont \textfont\sffam=\sffont
2514  %
2515  % Fonts for superscript.  Note that the 7pt fonts are used regardless
2516  % of the current font size.
2517  \scriptfont0=\sevenrm \scriptfont1=\seveni \scriptfont2=\sevensy
2518  \scriptfont\itfam=\sevenit \scriptfont\slfam=\sevensl
2519  \scriptfont\bffam=\sevenbf \scriptfont\ttfam=\seventt
2520  \scriptfont\sffam=\sevensf
2521}
2522
2523%
2524
2525% The font-changing commands (all called \...fonts) redefine the meanings
2526% of \STYLEfont, instead of just \STYLE.  We do this because \STYLE needs
2527% to also set the current \fam for math mode.  Our \STYLE (e.g., \rm)
2528% commands hardwire \STYLEfont to set the current font.
2529%
2530% The fonts used for \ifont are for "math italics"  (\itfont is for italics
2531% in regular text).  \syfont is also used in math mode only.
2532%
2533% Each font-changing command also sets the names \lsize (one size lower)
2534% and \lllsize (three sizes lower).  These relative commands are used
2535% in, e.g., the LaTeX logo and acronyms.
2536%
2537% This all needs generalizing, badly.
2538%
2539
2540\def\assignfonts#1{%
2541  \expandafter\let\expandafter\rmfont\csname #1rm\endcsname
2542  \expandafter\let\expandafter\itfont\csname #1it\endcsname
2543  \expandafter\let\expandafter\slfont\csname #1sl\endcsname
2544  \expandafter\let\expandafter\bffont\csname #1bf\endcsname
2545  \expandafter\let\expandafter\ttfont\csname #1tt\endcsname
2546  \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname
2547  \expandafter\let\expandafter\sffont  \csname #1sf\endcsname
2548  \expandafter\let\expandafter\ifont   \csname #1i\endcsname
2549  \expandafter\let\expandafter\syfont  \csname #1sy\endcsname
2550  \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname
2551}
2552
2553\newif\ifrmisbold
2554
2555% Select smaller font size with the current style.  Used to change font size
2556% in, e.g., the LaTeX logo and acronyms.  If we are using bold fonts for
2557% normal roman text, also use bold fonts for roman text in the smaller size.
2558\def\switchtolllsize{%
2559   \expandafter\assignfonts\expandafter{\lllsize}%
2560   \ifrmisbold
2561     \let\rmfont\bffont
2562   \fi
2563   \csname\curfontstyle\endcsname
2564}%
2565
2566\def\switchtolsize{%
2567   \expandafter\assignfonts\expandafter{\lsize}%
2568   \ifrmisbold
2569     \let\rmfont\bffont
2570   \fi
2571   \csname\curfontstyle\endcsname
2572}%
2573
2574\def\definefontsetatsize#1#2#3#4#5{%
2575\expandafter\def\csname #1fonts\endcsname{%
2576  \def\curfontsize{#1}%
2577  \def\lsize{#2}\def\lllsize{#3}%
2578  \csname rmisbold#5\endcsname
2579  \assignfonts{#1}%
2580  \resetmathfonts
2581  \setleading{#4}%
2582}}
2583
2584\definefontsetatsize{text}   {reduced}{smaller}{\textleading}{false}
2585\definefontsetatsize{title}  {chap}   {subsec} {27pt}  {true}
2586\definefontsetatsize{chap}   {sec}    {text}   {19pt}  {true}
2587\definefontsetatsize{sec}    {subsec} {reduced}{17pt}  {true}
2588\definefontsetatsize{ssec}   {text}   {small}  {15pt}  {true}
2589\definefontsetatsize{reduced}{small}  {smaller}{10.5pt}{false}
2590\definefontsetatsize{small}  {smaller}{smaller}{10.5pt}{false}
2591\definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false}
2592
2593\def\titlefont#1{{\titlefonts\rm #1}}
2594\let\subsecfonts = \ssecfonts
2595\let\subsubsecfonts = \ssecfonts
2596
2597% Define these just so they can be easily changed for other fonts.
2598\def\angleleft{$\langle$}
2599\def\angleright{$\rangle$}
2600
2601% Set the fonts to use with the @small... environments.
2602\let\smallexamplefonts = \smallfonts
2603
2604% About \smallexamplefonts.  If we use \smallfonts (9pt), @smallexample
2605% can fit this many characters:
2606%   8.5x11=86   smallbook=72  a4=90  a5=69
2607% If we use \scriptfonts (8pt), then we can fit this many characters:
2608%   8.5x11=90+  smallbook=80  a4=90+  a5=77
2609% For me, subjectively, the few extra characters that fit aren't worth
2610% the additional smallness of 8pt.  So I'm making the default 9pt.
2611%
2612% By the way, for comparison, here's what fits with @example (10pt):
2613%   8.5x11=71  smallbook=60  a4=75  a5=58
2614% --karl, 24jan03.
2615
2616% Set up the default fonts, so we can use them for creating boxes.
2617%
2618\definetextfontsizexi
2619
2620
2621\message{markup,}
2622
2623% Check if we are currently using a typewriter font.  Since all the
2624% Computer Modern typewriter fonts have zero interword stretch (and
2625% shrink), and it is reasonable to expect all typewriter fonts to have
2626% this property, we can check that font parameter.
2627%
2628\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
2629
2630% Markup style infrastructure.  \defmarkupstylesetup\INITMACRO will
2631% define and register \INITMACRO to be called on markup style changes.
2632% \INITMACRO can check \currentmarkupstyle for the innermost
2633% style.
2634
2635\let\currentmarkupstyle\empty
2636
2637\def\setupmarkupstyle#1{%
2638  \def\currentmarkupstyle{#1}%
2639  \markupstylesetup
2640}
2641
2642\let\markupstylesetup\empty
2643
2644\def\defmarkupstylesetup#1{%
2645  \expandafter\def\expandafter\markupstylesetup
2646    \expandafter{\markupstylesetup #1}%
2647  \def#1%
2648}
2649
2650% Markup style setup for left and right quotes.
2651\defmarkupstylesetup\markupsetuplq{%
2652  \expandafter\let\expandafter \temp
2653    \csname markupsetuplq\currentmarkupstyle\endcsname
2654  \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
2655}
2656
2657\defmarkupstylesetup\markupsetuprq{%
2658  \expandafter\let\expandafter \temp
2659    \csname markupsetuprq\currentmarkupstyle\endcsname
2660  \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
2661}
2662
2663{
2664\catcode`\'=\active
2665\catcode`\`=\active
2666
2667\gdef\markupsetuplqdefault{\let`\lq}
2668\gdef\markupsetuprqdefault{\let'\rq}
2669
2670\gdef\markupsetcodequoteleft{\let`\codequoteleft}
2671\gdef\markupsetcodequoteright{\let'\codequoteright}
2672}
2673
2674\let\markupsetuplqcode \markupsetcodequoteleft
2675\let\markupsetuprqcode \markupsetcodequoteright
2676%
2677\let\markupsetuplqexample \markupsetcodequoteleft
2678\let\markupsetuprqexample \markupsetcodequoteright
2679%
2680\let\markupsetuplqkbd     \markupsetcodequoteleft
2681\let\markupsetuprqkbd     \markupsetcodequoteright
2682%
2683\let\markupsetuplqsamp \markupsetcodequoteleft
2684\let\markupsetuprqsamp \markupsetcodequoteright
2685%
2686\let\markupsetuplqverb \markupsetcodequoteleft
2687\let\markupsetuprqverb \markupsetcodequoteright
2688%
2689\let\markupsetuplqverbatim \markupsetcodequoteleft
2690\let\markupsetuprqverbatim \markupsetcodequoteright
2691
2692% Allow an option to not use regular directed right quote/apostrophe
2693% (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2694% The undirected quote is ugly, so don't make it the default, but it
2695% works for pasting with more pdf viewers (at least evince), the
2696% lilypond developers report.  xpdf does work with the regular 0x27.
2697%
2698\def\codequoteright{%
2699  \ifmonospace
2700    \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
2701      \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
2702        '%
2703      \else \char'15 \fi
2704    \else \char'15 \fi
2705   \else
2706     '%
2707   \fi
2708}
2709%
2710% and a similar option for the left quote char vs. a grave accent.
2711% Modern fonts display ASCII 0x60 as a grave accent, so some people like
2712% the code environments to do likewise.
2713%
2714\def\codequoteleft{%
2715  \ifmonospace
2716    \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
2717      \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
2718        % [Knuth] pp. 380,381,391
2719        % \relax disables Spanish ligatures ?` and !` of \tt font.
2720        \relax`%
2721      \else \char'22 \fi
2722    \else \char'22 \fi
2723   \else
2724     \relax`%
2725   \fi
2726}
2727
2728% Commands to set the quote options.
2729%
2730\parseargdef\codequoteundirected{%
2731  \def\temp{#1}%
2732  \ifx\temp\onword
2733    \expandafter\let\csname SETtxicodequoteundirected\endcsname
2734      = t%
2735  \else\ifx\temp\offword
2736    \expandafter\let\csname SETtxicodequoteundirected\endcsname
2737      = \relax
2738  \else
2739    \errhelp = \EMsimple
2740    \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2741  \fi\fi
2742}
2743%
2744\parseargdef\codequotebacktick{%
2745  \def\temp{#1}%
2746  \ifx\temp\onword
2747    \expandafter\let\csname SETtxicodequotebacktick\endcsname
2748      = t%
2749  \else\ifx\temp\offword
2750    \expandafter\let\csname SETtxicodequotebacktick\endcsname
2751      = \relax
2752  \else
2753    \errhelp = \EMsimple
2754    \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2755  \fi\fi
2756}
2757
2758% [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2759\def\noligaturesquoteleft{\relax\lq}
2760
2761% Count depth in font-changes, for error checks
2762\newcount\fontdepth \fontdepth=0
2763
2764% Font commands.
2765
2766% #1 is the font command (\sl or \it), #2 is the text to slant.
2767% If we are in a monospaced environment, however, 1) always use \ttsl,
2768% and 2) do not add an italic correction.
2769\def\dosmartslant#1#2{%
2770  \ifusingtt
2771    {{\ttsl #2}\let\next=\relax}%
2772    {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
2773  \next
2774}
2775\def\smartslanted{\dosmartslant\sl}
2776\def\smartitalic{\dosmartslant\it}
2777
2778% Output an italic correction unless \next (presumed to be the following
2779% character) is such as not to need one.
2780\def\smartitaliccorrection{%
2781  \ifx\next,%
2782  \else\ifx\next-%
2783  \else\ifx\next.%
2784  \else\ifx\next\.%
2785  \else\ifx\next\comma%
2786  \else\ptexslash
2787  \fi\fi\fi\fi\fi
2788  \aftersmartic
2789}
2790
2791% Unconditional use \ttsl, and no ic.  @var is set to this for defuns.
2792\def\ttslanted#1{{\ttsl #1}}
2793
2794% @cite is like \smartslanted except unconditionally use \sl.  We never want
2795% ttsl for book titles, do we?
2796\def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
2797
2798\def\aftersmartic{}
2799\def\var#1{%
2800  \let\saveaftersmartic = \aftersmartic
2801  \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
2802  \smartslanted{#1}%
2803}
2804
2805\let\i=\smartitalic
2806\let\slanted=\smartslanted
2807\let\dfn=\smartslanted
2808\let\emph=\smartitalic
2809
2810% Explicit font changes: @r, @sc, undocumented @ii.
2811\def\r#1{{\rm #1}}              % roman font
2812\def\sc#1{{\smallcaps#1}}       % smallcaps font
2813\def\ii#1{{\it #1}}             % italic font
2814
2815% @b, explicit bold.  Also @strong.
2816\def\b#1{{\bf #1}}
2817\let\strong=\b
2818
2819% @sansserif, explicit sans.
2820\def\sansserif#1{{\sf #1}}
2821
2822% We can't just use \exhyphenpenalty, because that only has effect at
2823% the end of a paragraph.  Restore normal hyphenation at the end of the
2824% group within which \nohyphenation is presumably called.
2825%
2826\def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
2827\def\restorehyphenation{\hyphenchar\font = `- }
2828
2829% Set sfcode to normal for the chars that usually have another value.
2830% Can't use plain's \frenchspacing because it uses the `\x notation, and
2831% sometimes \x has an active definition that messes things up.
2832%
2833\catcode`@=11
2834  \def\plainfrenchspacing{%
2835    \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
2836    \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
2837    \def\endofsentencespacefactor{1000}% for @. and friends
2838  }
2839  \def\plainnonfrenchspacing{%
2840    \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2841    \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2842    \def\endofsentencespacefactor{3000}% for @. and friends
2843  }
2844\catcode`@=\other
2845\def\endofsentencespacefactor{3000}% default
2846
2847% @t, explicit typewriter.
2848\def\t#1{%
2849  {\tt \plainfrenchspacing #1}%
2850  \null
2851}
2852
2853% @samp.
2854\def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
2855
2856% @indicateurl is \samp, that is, with quotes.
2857\let\indicateurl=\samp
2858
2859% @code (and similar) prints in typewriter, but with spaces the same
2860% size as normal in the surrounding text, without hyphenation, etc.
2861% This is a subroutine for that.
2862\def\tclose#1{%
2863  {%
2864    % Change normal interword space to be same as for the current font.
2865    \spaceskip = \fontdimen2\font
2866    %
2867    % Switch to typewriter.
2868    \tt
2869    %
2870    % But `\ ' produces the large typewriter interword space.
2871    \def\ {{\spaceskip = 0pt{} }}%
2872    %
2873    % Turn off hyphenation.
2874    \nohyphenation
2875    %
2876    \plainfrenchspacing
2877    #1%
2878  }%
2879  \null % reset spacefactor to 1000
2880}
2881
2882% We *must* turn on hyphenation at `-' and `_' in @code.
2883% (But see \codedashfinish below.)
2884% Otherwise, it is too hard to avoid overfull hboxes
2885% in the Emacs manual, the Library manual, etc.
2886%
2887% Unfortunately, TeX uses one parameter (\hyphenchar) to control
2888% both hyphenation at - and hyphenation within words.
2889% We must therefore turn them both off (\tclose does that)
2890% and arrange explicitly to hyphenate at a dash. -- rms.
2891{
2892  \catcode`\-=\active \catcode`\_=\active
2893  \catcode`\'=\active \catcode`\`=\active
2894  \global\let'=\rq \global\let`=\lq  % default definitions
2895  %
2896  \global\def\code{\begingroup
2897    \setupmarkupstyle{code}%
2898    % The following should really be moved into \setupmarkupstyle handlers.
2899    \catcode\dashChar=\active  \catcode\underChar=\active
2900    \ifallowcodebreaks
2901     \let-\codedash
2902     \let_\codeunder
2903    \else
2904     \let-\normaldash
2905     \let_\realunder
2906    \fi
2907    % Given -foo (with a single dash), we do not want to allow a break
2908    % after the hyphen.
2909    \global\let\codedashprev=\codedash
2910    %
2911    \codex
2912  }
2913  %
2914  \gdef\codedash{\futurelet\next\codedashfinish}
2915  \gdef\codedashfinish{%
2916    \normaldash % always output the dash character itself.
2917    %
2918    % Now, output a discretionary to allow a line break, unless
2919    % (a) the next character is a -, or
2920    % (b) the preceding character is a -.
2921    % E.g., given --posix, we do not want to allow a break after either -.
2922    % Given --foo-bar, we do want to allow a break between the - and the b.
2923    \ifx\next\codedash \else
2924      \ifx\codedashprev\codedash
2925      \else \discretionary{}{}{}\fi
2926    \fi
2927    % we need the space after the = for the case when \next itself is a
2928    % space token; it would get swallowed otherwise.  As in @code{- a}.
2929    \global\let\codedashprev= \next
2930  }
2931}
2932\def\normaldash{-}
2933%
2934\def\codex #1{\tclose{#1}\endgroup}
2935
2936\def\codeunder{%
2937  % this is all so @math{@code{var_name}+1} can work.  In math mode, _
2938  % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2939  % will therefore expand the active definition of _, which is us
2940  % (inside @code that is), therefore an endless loop.
2941  \ifusingtt{\ifmmode
2942               \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2943             \else\normalunderscore \fi
2944             \discretionary{}{}{}}%
2945            {\_}%
2946}
2947
2948% An additional complication: the above will allow breaks after, e.g.,
2949% each of the four underscores in __typeof__.  This is bad.
2950% @allowcodebreaks provides a document-level way to turn breaking at -
2951% and _ on and off.
2952%
2953\newif\ifallowcodebreaks  \allowcodebreakstrue
2954
2955\def\keywordtrue{true}
2956\def\keywordfalse{false}
2957
2958\parseargdef\allowcodebreaks{%
2959  \def\txiarg{#1}%
2960  \ifx\txiarg\keywordtrue
2961    \allowcodebreakstrue
2962  \else\ifx\txiarg\keywordfalse
2963    \allowcodebreaksfalse
2964  \else
2965    \errhelp = \EMsimple
2966    \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
2967  \fi\fi
2968}
2969
2970% For @command, @env, @file, @option quotes seem unnecessary,
2971% so use \code rather than \samp.
2972\let\command=\code
2973\let\env=\code
2974\let\file=\code
2975\let\option=\code
2976
2977% @uref (abbreviation for `urlref') aka @url takes an optional
2978% (comma-separated) second argument specifying the text to display and
2979% an optional third arg as text to display instead of (rather than in
2980% addition to) the url itself.  First (mandatory) arg is the url.
2981
2982% TeX-only option to allow changing PDF output to show only the second
2983% arg (if given), and not the url (which is then just the link target).
2984\newif\ifurefurlonlylink
2985
2986% The main macro is \urefbreak, which allows breaking at expected
2987% places within the url.  (There used to be another version, which
2988% didn't support automatic breaking.)
2989\def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
2990\let\uref=\urefbreak
2991%
2992\def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
2993\def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
2994  \unsepspaces
2995  \pdfurl{#1}%
2996  \setbox0 = \hbox{\ignorespaces #3}%
2997  \ifdim\wd0 > 0pt
2998    \unhbox0 % third arg given, show only that
2999  \else
3000    \setbox0 = \hbox{\ignorespaces #2}% look for second arg
3001    \ifdim\wd0 > 0pt
3002      \ifpdf
3003        % For pdfTeX and LuaTeX
3004        \ifurefurlonlylink
3005          % PDF plus option to not display url, show just arg
3006          \unhbox0
3007        \else
3008          % PDF, normally display both arg and url for consistency,
3009          % visibility, if the pdf is eventually used to print, etc.
3010          \unhbox0\ (\urefcode{#1})%
3011        \fi
3012      \else
3013        \ifx\XeTeXrevision\thisisundefined
3014          \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
3015        \else
3016          % For XeTeX
3017          \ifurefurlonlylink
3018            % PDF plus option to not display url, show just arg
3019            \unhbox0
3020          \else
3021            % PDF, normally display both arg and url for consistency,
3022            % visibility, if the pdf is eventually used to print, etc.
3023            \unhbox0\ (\urefcode{#1})%
3024          \fi
3025        \fi
3026      \fi
3027    \else
3028      \urefcode{#1}% only url given, so show it
3029    \fi
3030  \fi
3031  \endlink
3032\endgroup}
3033
3034% Allow line breaks around only a few characters (only).
3035\def\urefcatcodes{%
3036  \catcode`\&=\active \catcode`\.=\active
3037  \catcode`\#=\active \catcode`\?=\active
3038  \catcode`\/=\active
3039}
3040{
3041  \urefcatcodes
3042  %
3043  \global\def\urefcode{\begingroup
3044    \setupmarkupstyle{code}%
3045    \urefcatcodes
3046    \let&\urefcodeamp
3047    \let.\urefcodedot
3048    \let#\urefcodehash
3049    \let?\urefcodequest
3050    \let/\urefcodeslash
3051    \codex
3052  }
3053  %
3054  % By default, they are just regular characters.
3055  \global\def&{\normalamp}
3056  \global\def.{\normaldot}
3057  \global\def#{\normalhash}
3058  \global\def?{\normalquest}
3059  \global\def/{\normalslash}
3060}
3061
3062\def\urefcodeamp{\urefprebreak \&\urefpostbreak}
3063\def\urefcodedot{\urefprebreak .\urefpostbreak}
3064\def\urefcodehash{\urefprebreak \#\urefpostbreak}
3065\def\urefcodequest{\urefprebreak ?\urefpostbreak}
3066\def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
3067{
3068  \catcode`\/=\active
3069  \global\def\urefcodeslashfinish{%
3070    \urefprebreak \slashChar
3071    % Allow line break only after the final / in a sequence of
3072    % slashes, to avoid line break between the slashes in http://.
3073    \ifx\next/\else \urefpostbreak \fi
3074  }
3075}
3076
3077% By default we'll break after the special characters, but some people like to
3078% break before the special chars, so allow that.  Also allow no breaking at
3079% all, for manual control.
3080%
3081\parseargdef\urefbreakstyle{%
3082  \def\txiarg{#1}%
3083  \ifx\txiarg\wordnone
3084    \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
3085  \else\ifx\txiarg\wordbefore
3086    \def\urefprebreak{\urefallowbreak}\def\urefpostbreak{\nobreak}
3087  \else\ifx\txiarg\wordafter
3088    \def\urefprebreak{\nobreak}\def\urefpostbreak{\urefallowbreak}
3089  \else
3090    \errhelp = \EMsimple
3091    \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
3092  \fi\fi\fi
3093}
3094\def\wordafter{after}
3095\def\wordbefore{before}
3096\def\wordnone{none}
3097
3098% Allow a ragged right output to aid breaking long URL's.  Putting stretch in
3099% between characters of the URL doesn't look good.
3100\def\urefallowbreak{%
3101  \hskip 0pt plus 4 em\relax
3102  \allowbreak
3103  \hskip 0pt plus -4 em\relax
3104}
3105
3106\urefbreakstyle after
3107
3108% @url synonym for @uref, since that's how everyone uses it.
3109%
3110\let\url=\uref
3111
3112% rms does not like angle brackets --karl, 17may97.
3113% So now @email is just like @uref, unless we are pdf.
3114%
3115%\def\email#1{\angleleft{\tt #1}\angleright}
3116\ifpdforxetex
3117  \def\email#1{\doemail#1,,\finish}
3118  \def\doemail#1,#2,#3\finish{\begingroup
3119    \unsepspaces
3120    \pdfurl{mailto:#1}%
3121    \setbox0 = \hbox{\ignorespaces #2}%
3122    \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3123    \endlink
3124  \endgroup}
3125\else
3126  \let\email=\uref
3127\fi
3128
3129% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
3130%   `example' (@kbd uses ttsl only inside of @example and friends),
3131%   or `code' (@kbd uses normal tty font always).
3132\parseargdef\kbdinputstyle{%
3133  \def\txiarg{#1}%
3134  \ifx\txiarg\worddistinct
3135    \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
3136  \else\ifx\txiarg\wordexample
3137    \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
3138  \else\ifx\txiarg\wordcode
3139    \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
3140  \else
3141    \errhelp = \EMsimple
3142    \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
3143  \fi\fi\fi
3144}
3145\def\worddistinct{distinct}
3146\def\wordexample{example}
3147\def\wordcode{code}
3148
3149% Default is `distinct'.
3150\kbdinputstyle distinct
3151
3152% @kbd is like @code, except that if the argument is just one @key command,
3153% then @kbd has no effect.
3154\def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
3155
3156\def\xkey{\key}
3157\def\kbdsub#1#2#3\par{%
3158  \def\one{#1}\def\three{#3}\def\threex{??}%
3159  \ifx\one\xkey\ifx\threex\three \key{#2}%
3160  \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3161  \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3162}
3163
3164% definition of @key that produces a lozenge.  Doesn't adjust to text size.
3165%\setfont\keyrm\rmshape{8}{1000}{OT1}
3166%\font\keysy=cmsy9
3167%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
3168%  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
3169%    \vbox{\hrule\kern-0.4pt
3170%     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
3171%    \kern-0.4pt\hrule}%
3172%  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
3173
3174% definition of @key with no lozenge.  If the current font is already
3175% monospace, don't change it; that way, we respect @kbdinputstyle.  But
3176% if it isn't monospace, then use \tt.
3177%
3178\def\key#1{{\setupmarkupstyle{key}%
3179  \nohyphenation
3180  \ifmonospace\else\tt\fi
3181  #1}\null}
3182
3183% @clicksequence{File @click{} Open ...}
3184\def\clicksequence#1{\begingroup #1\endgroup}
3185
3186% @clickstyle @arrow   (by default)
3187\parseargdef\clickstyle{\def\click{#1}}
3188\def\click{\arrow}
3189
3190% Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
3191% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
3192%
3193\def\dmn#1{\thinspace #1}
3194
3195% @acronym for "FBI", "NATO", and the like.
3196% We print this one point size smaller, since it's intended for
3197% all-uppercase.
3198%
3199\def\acronym#1{\doacronym #1,,\finish}
3200\def\doacronym#1,#2,#3\finish{%
3201  {\switchtolsize #1}%
3202  \def\temp{#2}%
3203  \ifx\temp\empty \else
3204    \space ({\unsepspaces \ignorespaces \temp \unskip})%
3205  \fi
3206  \null % reset \spacefactor=1000
3207}
3208
3209% @abbr for "Comput. J." and the like.
3210% No font change, but don't do end-of-sentence spacing.
3211%
3212\def\abbr#1{\doabbr #1,,\finish}
3213\def\doabbr#1,#2,#3\finish{%
3214  {\plainfrenchspacing #1}%
3215  \def\temp{#2}%
3216  \ifx\temp\empty \else
3217    \space ({\unsepspaces \ignorespaces \temp \unskip})%
3218  \fi
3219  \null % reset \spacefactor=1000
3220}
3221
3222% @asis just yields its argument.  Used with @table, for example.
3223%
3224\def\asis#1{#1}
3225
3226% @math outputs its argument in math mode.
3227%
3228% One complication: _ usually means subscripts, but it could also mean
3229% an actual _ character, as in @math{@var{some_variable} + 1}.  So make
3230% _ active, and distinguish by seeing if the current family is \slfam,
3231% which is what @var uses.
3232{
3233  \catcode`\_ = \active
3234  \gdef\mathunderscore{%
3235    \catcode`\_=\active
3236    \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
3237  }
3238}
3239% Another complication: we want \\ (and @\) to output a math (or tt) \.
3240% FYI, plain.tex uses \\ as a temporary control sequence (for no
3241% particular reason), but this is not advertised and we don't care.
3242%
3243% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
3244\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
3245%
3246\def\math{%
3247  \ifmmode\else % only go into math if not in math mode already
3248    \tex
3249    \mathunderscore
3250    \let\\ = \mathbackslash
3251    \mathactive
3252    % make the texinfo accent commands work in math mode
3253    \let\"=\ddot
3254    \let\'=\acute
3255    \let\==\bar
3256    \let\^=\hat
3257    \let\`=\grave
3258    \let\u=\breve
3259    \let\v=\check
3260    \let\~=\tilde
3261    \let\dotaccent=\dot
3262    % have to provide another name for sup operator
3263    \let\mathopsup=\sup
3264  $\expandafter\finishmath\fi
3265}
3266\def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
3267
3268% Some active characters (such as <) are spaced differently in math.
3269% We have to reset their definitions in case the @math was an argument
3270% to a command which sets the catcodes (such as @item or @section).
3271%
3272{
3273  \catcode`^ = \active
3274  \catcode`< = \active
3275  \catcode`> = \active
3276  \catcode`+ = \active
3277  \catcode`' = \active
3278  \gdef\mathactive{%
3279    \let^ = \ptexhat
3280    \let< = \ptexless
3281    \let> = \ptexgtr
3282    \let+ = \ptexplus
3283    \let' = \ptexquoteright
3284  }
3285}
3286
3287% for @sub and @sup, if in math mode, just do a normal sub/superscript.
3288% If in text, use math to place as sub/superscript, but switch
3289% into text mode, with smaller fonts.  This is a different font than the
3290% one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3291% fix it (significant additions to font machinery) until someone notices.
3292%
3293\def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
3294\def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}%
3295%
3296\def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
3297\def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}%
3298
3299% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3300% Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3301% except specified as a normal braced arg, so no newlines to worry about.
3302%
3303\def\outfmtnametex{tex}
3304%
3305\long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3306\long\def\doinlinefmt#1,#2,\finish{%
3307  \def\inlinefmtname{#1}%
3308  \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3309}
3310%
3311% @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3312% FMTNAME is tex, else ELSE-TEXT.
3313\long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3314\long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3315  \def\inlinefmtname{#1}%
3316  \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3317}
3318%
3319% For raw, must switch into @tex before parsing the argument, to avoid
3320% setting catcodes prematurely.  Doing it this way means that, for
3321% example, @inlineraw{html, foo{bar} gets a parse error instead of being
3322% ignored.  But this isn't important because if people want a literal
3323% *right* brace they would have to use a command anyway, so they may as
3324% well use a command to get a left brace too.  We could re-use the
3325% delimiter character idea from \verb, but it seems like overkill.
3326%
3327\long\def\inlineraw{\tex \doinlineraw}
3328\long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3329\def\doinlinerawtwo#1,#2,\finish{%
3330  \def\inlinerawname{#1}%
3331  \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3332  \endgroup % close group opened by \tex.
3333}
3334
3335% @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3336%
3337\long\def\inlineifset#1{\doinlineifset #1,\finish}
3338\long\def\doinlineifset#1,#2,\finish{%
3339  \def\inlinevarname{#1}%
3340  \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3341  \else\ignorespaces#2\fi
3342}
3343
3344% @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3345%
3346\long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3347\long\def\doinlineifclear#1,#2,\finish{%
3348  \def\inlinevarname{#1}%
3349  \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3350}
3351
3352
3353\message{glyphs,}
3354% and logos.
3355
3356% @@ prints an @, as does @atchar{}.
3357\def\@{\char64 }
3358\let\atchar=\@
3359
3360% @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
3361\def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}}
3362\def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}}
3363\let\{=\lbracechar
3364\let\}=\rbracechar
3365
3366% @comma{} to avoid , parsing problems.
3367\let\comma = ,
3368
3369% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3370% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3371\let\, = \ptexc
3372\let\dotaccent = \ptexdot
3373\def\ringaccent#1{{\accent23 #1}}
3374\let\tieaccent = \ptext
3375\let\ubaraccent = \ptexb
3376\let\udotaccent = \d
3377
3378% Other special characters: @questiondown @exclamdown @ordf @ordm
3379% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3380\def\questiondown{?`}
3381\def\exclamdown{!`}
3382\def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}}
3383\def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}}
3384
3385% Dotless i and dotless j, used for accents.
3386\def\imacro{i}
3387\def\jmacro{j}
3388\def\dotless#1{%
3389  \def\temp{#1}%
3390  \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3391  \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3392  \else \errmessage{@dotless can be used only with i or j}%
3393  \fi\fi
3394}
3395
3396% The \TeX{} logo, as in plain, but resetting the spacing so that a
3397% period following counts as ending a sentence.  (Idea found in latex.)
3398%
3399\edef\TeX{\TeX \spacefactor=1000 }
3400
3401% @LaTeX{} logo.  Not quite the same results as the definition in
3402% latex.ltx, since we use a different font for the raised A; it's most
3403% convenient for us to use an explicitly smaller font, rather than using
3404% the \scriptstyle font (since we don't reset \scriptstyle and
3405% \scriptscriptstyle).
3406%
3407\def\LaTeX{%
3408  L\kern-.36em
3409  {\setbox0=\hbox{T}%
3410   \vbox to \ht0{\hbox{%
3411     \ifx\textnominalsize\xwordpt
3412       % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX.
3413       % Revert to plain's \scriptsize, which is 7pt.
3414       \count255=\the\fam $\fam\count255 \scriptstyle A$%
3415     \else
3416       % For 11pt, we can use our lllsize.
3417       \switchtolllsize A%
3418     \fi
3419     }%
3420     \vss
3421  }}%
3422  \kern-.15em
3423  \TeX
3424}
3425
3426% Some math mode symbols.  Define \ensuremath to switch into math mode
3427% unless we are already there.  Expansion tricks may not be needed here,
3428% but safer, and can't hurt.
3429\def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3430\def\ensuredmath#1{$\relax#1$}
3431%
3432\def\bullet{\ensuremath\ptexbullet}
3433\def\geq{\ensuremath\ge}
3434\def\leq{\ensuremath\le}
3435\def\minus{\ensuremath-}
3436
3437% @dots{} outputs an ellipsis using the current font.
3438% We do .5em per period so that it has the same spacing in the cm
3439% typewriter fonts as three actual period characters; on the other hand,
3440% in other typewriter fonts three periods are wider than 1.5em.  So do
3441% whichever is larger.
3442%
3443\def\dots{%
3444  \leavevmode
3445  \setbox0=\hbox{...}% get width of three periods
3446  \ifdim\wd0 > 1.5em
3447    \dimen0 = \wd0
3448  \else
3449    \dimen0 = 1.5em
3450  \fi
3451  \hbox to \dimen0{%
3452    \hskip 0pt plus.25fil
3453    .\hskip 0pt plus1fil
3454    .\hskip 0pt plus1fil
3455    .\hskip 0pt plus.5fil
3456  }%
3457}
3458
3459% @enddots{} is an end-of-sentence ellipsis.
3460%
3461\def\enddots{%
3462  \dots
3463  \spacefactor=\endofsentencespacefactor
3464}
3465
3466% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3467%
3468% Since these characters are used in examples, they should be an even number of
3469% \tt widths. Each \tt character is 1en, so two makes it 1em.
3470%
3471\def\point{$\star$}
3472\def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3473\def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3474\def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3475\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3476\def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3477
3478% The @error{} command.
3479% Adapted from the TeXbook's \boxit.
3480%
3481\newbox\errorbox
3482%
3483{\ttfont \global\dimen0 = 3em}% Width of the box.
3484\dimen2 = .55pt % Thickness of rules
3485% The text. (`r' is open on the right, `e' somewhat less so on the left.)
3486\setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3487%
3488\setbox\errorbox=\hbox to \dimen0{\hfil
3489   \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3490   \advance\hsize by -2\dimen2 % Rules.
3491   \vbox{%
3492      \hrule height\dimen2
3493      \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
3494         \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3495         \kern3pt\vrule width\dimen2}% Space to right.
3496      \hrule height\dimen2}
3497    \hfil}
3498%
3499\def\error{\leavevmode\lower.7ex\copy\errorbox}
3500
3501% @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3502%
3503\def\pounds{{\it\$}}
3504
3505% @euro{} comes from a separate font, depending on the current style.
3506% We use the free feym* fonts from the eurosym package by Henrik
3507% Theiling, which support regular, slanted, bold and bold slanted (and
3508% "outlined" (blackboard board, sort of) versions, which we don't need).
3509% It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3510%
3511% Although only regular is the truly official Euro symbol, we ignore
3512% that.  The Euro is designed to be slightly taller than the regular
3513% font height.
3514%
3515% feymr - regular
3516% feymo - slanted
3517% feybr - bold
3518% feybo - bold slanted
3519%
3520% There is no good (free) typewriter version, to my knowledge.
3521% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3522% Hmm.
3523%
3524% Also doesn't work in math.  Do we need to do math with euro symbols?
3525% Hope not.
3526%
3527%
3528\def\euro{{\eurofont e}}
3529\def\eurofont{%
3530  % We set the font at each command, rather than predefining it in
3531  % \textfonts and the other font-switching commands, so that
3532  % installations which never need the symbol don't have to have the
3533  % font installed.
3534  %
3535  % There is only one designed size (nominal 10pt), so we always scale
3536  % that to the current nominal size.
3537  %
3538  % By the way, simply using "at 1em" works for cmr10 and the like, but
3539  % does not work for cmbx10 and other extended/shrunken fonts.
3540  %
3541  \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3542  %
3543  \ifx\curfontstyle\bfstylename
3544    % bold:
3545    \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3546  \else
3547    % regular:
3548    \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3549  \fi
3550  \thiseurofont
3551}
3552
3553% Glyphs from the EC fonts.  We don't use \let for the aliases, because
3554% sometimes we redefine the original macro, and the alias should reflect
3555% the redefinition.
3556%
3557% Use LaTeX names for the Icelandic letters.
3558\def\DH{{\ecfont \char"D0}} % Eth
3559\def\dh{{\ecfont \char"F0}} % eth
3560\def\TH{{\ecfont \char"DE}} % Thorn
3561\def\th{{\ecfont \char"FE}} % thorn
3562%
3563\def\guillemetleft{{\ecfont \char"13}}
3564\def\guillemotleft{\guillemetleft}
3565\def\guillemetright{{\ecfont \char"14}}
3566\def\guillemotright{\guillemetright}
3567\def\guilsinglleft{{\ecfont \char"0E}}
3568\def\guilsinglright{{\ecfont \char"0F}}
3569\def\quotedblbase{{\ecfont \char"12}}
3570\def\quotesinglbase{{\ecfont \char"0D}}
3571%
3572% This positioning is not perfect (see the ogonek LaTeX package), but
3573% we have the precomposed glyphs for the most common cases.  We put the
3574% tests to use those glyphs in the single \ogonek macro so we have fewer
3575% dummy definitions to worry about for index entries, etc.
3576%
3577% ogonek is also used with other letters in Lithuanian (IOU), but using
3578% the precomposed glyphs for those is not so easy since they aren't in
3579% the same EC font.
3580\def\ogonek#1{{%
3581  \def\temp{#1}%
3582  \ifx\temp\macrocharA\Aogonek
3583  \else\ifx\temp\macrochara\aogonek
3584  \else\ifx\temp\macrocharE\Eogonek
3585  \else\ifx\temp\macrochare\eogonek
3586  \else
3587    \ecfont \setbox0=\hbox{#1}%
3588    \ifdim\ht0=1ex\accent"0C #1%
3589    \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3590    \fi
3591  \fi\fi\fi\fi
3592  }%
3593}
3594\def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3595\def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3596\def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3597\def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3598%
3599% Use the European Computer Modern fonts (cm-super in outline format)
3600% for non-CM glyphs.  That is ec* for regular text and tc* for the text
3601% companion symbols (LaTeX TS1 encoding).  Both are part of the ec
3602% package and follow the same conventions.
3603%
3604\def\ecfont{\etcfont{e}}
3605\def\tcfont{\etcfont{t}}
3606%
3607\def\etcfont#1{%
3608  % We can't distinguish serif/sans and italic/slanted, but this
3609  % is used for crude hacks anyway (like adding French and German
3610  % quotes to documents typeset with CM, where we lose kerning), so
3611  % hopefully nobody will notice/care.
3612  \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3613  \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
3614  \ifmonospace
3615    % typewriter:
3616    \font\thisecfont = #1ctt\ecsize \space at \nominalsize
3617  \else
3618    \ifx\curfontstyle\bfstylename
3619      % bold:
3620      \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
3621    \else
3622      % regular:
3623      \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
3624    \fi
3625  \fi
3626  \thisecfont
3627}
3628
3629% @registeredsymbol - R in a circle.  The font for the R should really
3630% be smaller yet, but lllsize is the best we can do for now.
3631% Adapted from the plain.tex definition of \copyright.
3632%
3633\def\registeredsymbol{%
3634  $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}%
3635               \hfil\crcr\Orb}}%
3636    }$%
3637}
3638
3639% @textdegree - the normal degrees sign.
3640%
3641\def\textdegree{$^\circ$}
3642
3643% Laurent Siebenmann reports \Orb undefined with:
3644%  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
3645% so we'll define it if necessary.
3646%
3647\ifx\Orb\thisisundefined
3648\def\Orb{\mathhexbox20D}
3649\fi
3650
3651% Quotes.
3652\chardef\quotedblleft="5C
3653\chardef\quotedblright=`\"
3654\chardef\quoteleft=`\`
3655\chardef\quoteright=`\'
3656
3657
3658\message{page headings,}
3659
3660\newskip\titlepagetopglue \titlepagetopglue = 1.5in
3661\newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3662
3663% First the title page.  Must do @settitle before @titlepage.
3664\newif\ifseenauthor
3665\newif\iffinishedtitlepage
3666
3667% @setcontentsaftertitlepage used to do an implicit @contents or
3668% @shortcontents after @end titlepage, but it is now obsolete.
3669\def\setcontentsaftertitlepage{%
3670  \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
3671              command; move your @contents command if you want the contents
3672              after the title page.}}%
3673\def\setshortcontentsaftertitlepage{%
3674  \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
3675              command; move your @shortcontents and @contents commands if you
3676              want the contents after the title page.}}%
3677
3678\parseargdef\shorttitlepage{%
3679  \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3680  \endgroup\page\hbox{}\page}
3681
3682\envdef\titlepage{%
3683  % Open one extra group, as we want to close it in the middle of \Etitlepage.
3684  \begingroup
3685    \parindent=0pt \textfonts
3686    % Leave some space at the very top of the page.
3687    \vglue\titlepagetopglue
3688    % No rule at page bottom unless we print one at the top with @title.
3689    \finishedtitlepagetrue
3690    %
3691    % Most title ``pages'' are actually two pages long, with space
3692    % at the top of the second.  We don't want the ragged left on the second.
3693    \let\oldpage = \page
3694    \def\page{%
3695      \iffinishedtitlepage\else
3696	 \finishtitlepage
3697      \fi
3698      \let\page = \oldpage
3699      \page
3700      \null
3701    }%
3702}
3703
3704\def\Etitlepage{%
3705    \iffinishedtitlepage\else
3706	\finishtitlepage
3707    \fi
3708    % It is important to do the page break before ending the group,
3709    % because the headline and footline are only empty inside the group.
3710    % If we use the new definition of \page, we always get a blank page
3711    % after the title page, which we certainly don't want.
3712    \oldpage
3713  \endgroup
3714  %
3715  % Need this before the \...aftertitlepage checks so that if they are
3716  % in effect the toc pages will come out with page numbers.
3717  \HEADINGSon
3718}
3719
3720\def\finishtitlepage{%
3721  \vskip4pt \hrule height 2pt width \hsize
3722  \vskip\titlepagebottomglue
3723  \finishedtitlepagetrue
3724}
3725
3726% Settings used for typesetting titles: no hyphenation, no indentation,
3727% don't worry much about spacing, ragged right.  This should be used
3728% inside a \vbox, and fonts need to be set appropriately first. \par should
3729% be specified before the end of the \vbox, since a vbox is a group.
3730%
3731\def\raggedtitlesettings{%
3732  \rm
3733  \hyphenpenalty=10000
3734  \parindent=0pt
3735  \tolerance=5000
3736  \ptexraggedright
3737}
3738
3739% Macros to be used within @titlepage:
3740
3741\let\subtitlerm=\rmfont
3742\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3743
3744\parseargdef\title{%
3745  \checkenv\titlepage
3746  \vbox{\titlefonts \raggedtitlesettings #1\par}%
3747  % print a rule at the page bottom also.
3748  \finishedtitlepagefalse
3749  \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3750}
3751
3752\parseargdef\subtitle{%
3753  \checkenv\titlepage
3754  {\subtitlefont \rightline{#1}}%
3755}
3756
3757% @author should come last, but may come many times.
3758% It can also be used inside @quotation.
3759%
3760\parseargdef\author{%
3761  \def\temp{\quotation}%
3762  \ifx\thisenv\temp
3763    \def\quotationauthor{#1}% printed in \Equotation.
3764  \else
3765    \checkenv\titlepage
3766    \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3767    {\secfonts\rm \leftline{#1}}%
3768  \fi
3769}
3770
3771
3772% Set up page headings and footings.
3773
3774\let\thispage=\folio
3775
3776\newtoks\evenheadline    % headline on even pages
3777\newtoks\oddheadline     % headline on odd pages
3778\newtoks\evenfootline    % footline on even pages
3779\newtoks\oddfootline     % footline on odd pages
3780
3781% Now make \makeheadline and \makefootline in Plain TeX use those variables
3782\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
3783                            \else \the\evenheadline \fi}}
3784\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
3785                            \else \the\evenfootline \fi}\HEADINGShook}
3786\let\HEADINGShook=\relax
3787
3788% Commands to set those variables.
3789% For example, this is what  @headings on  does
3790% @evenheading @thistitle|@thispage|@thischapter
3791% @oddheading @thischapter|@thispage|@thistitle
3792% @evenfooting @thisfile||
3793% @oddfooting ||@thisfile
3794
3795
3796\def\evenheading{\parsearg\evenheadingxxx}
3797\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3798\def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
3799\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3800
3801\def\oddheading{\parsearg\oddheadingxxx}
3802\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3803\def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
3804\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3805
3806\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3807
3808\def\evenfooting{\parsearg\evenfootingxxx}
3809\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3810\def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3811\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3812
3813\def\oddfooting{\parsearg\oddfootingxxx}
3814\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3815\def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3816  \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3817  %
3818  % Leave some space for the footline.  Hopefully ok to assume
3819  % @evenfooting will not be used by itself.
3820  \global\advance\txipageheight by -12pt
3821  \global\advance\vsize by -12pt
3822}
3823
3824\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3825
3826% @evenheadingmarks top     \thischapter <- chapter at the top of a page
3827% @evenheadingmarks bottom  \thischapter <- chapter at the bottom of a page
3828%
3829% The same set of arguments for:
3830%
3831% @oddheadingmarks
3832% @evenfootingmarks
3833% @oddfootingmarks
3834% @everyheadingmarks
3835% @everyfootingmarks
3836
3837% These define \getoddheadingmarks, \getevenheadingmarks,
3838% \getoddfootingmarks, and \getevenfootingmarks, each to one of
3839% \gettopheadingmarks, \getbottomheadingmarks.
3840%
3841\def\evenheadingmarks{\headingmarks{even}{heading}}
3842\def\oddheadingmarks{\headingmarks{odd}{heading}}
3843\def\evenfootingmarks{\headingmarks{even}{footing}}
3844\def\oddfootingmarks{\headingmarks{odd}{footing}}
3845\parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
3846                          \headingmarks{odd}{heading}{#1} }
3847\parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
3848                          \headingmarks{odd}{footing}{#1} }
3849% #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3850\def\headingmarks#1#2#3 {%
3851  \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3852  \global\expandafter\let\csname get#1#2marks\endcsname \temp
3853}
3854
3855\everyheadingmarks bottom
3856\everyfootingmarks bottom
3857
3858% @headings double      turns headings on for double-sided printing.
3859% @headings single      turns headings on for single-sided printing.
3860% @headings off         turns them off.
3861% @headings on          same as @headings double, retained for compatibility.
3862% @headings after       turns on double-sided headings after this page.
3863% @headings doubleafter turns on double-sided headings after this page.
3864% @headings singleafter turns on single-sided headings after this page.
3865% By default, they are off at the start of a document,
3866% and turned `on' after @end titlepage.
3867
3868\parseargdef\headings{\csname HEADINGS#1\endcsname}
3869
3870\def\headingsoff{% non-global headings elimination
3871  \evenheadline={\hfil}\evenfootline={\hfil}%
3872   \oddheadline={\hfil}\oddfootline={\hfil}%
3873}
3874
3875\def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3876\HEADINGSoff  % it's the default
3877
3878% When we turn headings on, set the page number to 1.
3879% For double-sided printing, put current file name in lower left corner,
3880% chapter name on inside top of right hand pages, document
3881% title on inside top of left hand pages, and page numbers on outside top
3882% edge of all pages.
3883\def\HEADINGSdouble{%
3884\global\pageno=1
3885\global\evenfootline={\hfil}
3886\global\oddfootline={\hfil}
3887\global\evenheadline={\line{\folio\hfil\thistitle}}
3888\global\oddheadline={\line{\thischapterheading\hfil\folio}}
3889\global\let\contentsalignmacro = \chapoddpage
3890}
3891\let\contentsalignmacro = \chappager
3892
3893% For single-sided printing, chapter title goes across top left of page,
3894% page number on top right.
3895\def\HEADINGSsingle{%
3896\global\pageno=1
3897\global\evenfootline={\hfil}
3898\global\oddfootline={\hfil}
3899\global\evenheadline={\line{\thischapterheading\hfil\folio}}
3900\global\oddheadline={\line{\thischapterheading\hfil\folio}}
3901\global\let\contentsalignmacro = \chappager
3902}
3903\def\HEADINGSon{\HEADINGSdouble}
3904
3905\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
3906\let\HEADINGSdoubleafter=\HEADINGSafter
3907\def\HEADINGSdoublex{%
3908\global\evenfootline={\hfil}
3909\global\oddfootline={\hfil}
3910\global\evenheadline={\line{\folio\hfil\thistitle}}
3911\global\oddheadline={\line{\thischapterheading\hfil\folio}}
3912\global\let\contentsalignmacro = \chapoddpage
3913}
3914
3915\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
3916\def\HEADINGSsinglex{%
3917\global\evenfootline={\hfil}
3918\global\oddfootline={\hfil}
3919\global\evenheadline={\line{\thischapterheading\hfil\folio}}
3920\global\oddheadline={\line{\thischapterheading\hfil\folio}}
3921\global\let\contentsalignmacro = \chappager
3922}
3923
3924% Subroutines used in generating headings
3925% This produces Day Month Year style of output.
3926% Only define if not already defined, in case a txi-??.tex file has set
3927% up a different format (e.g., txi-cs.tex does this).
3928\ifx\today\thisisundefined
3929\def\today{%
3930  \number\day\space
3931  \ifcase\month
3932  \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
3933  \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
3934  \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
3935  \fi
3936  \space\number\year}
3937\fi
3938
3939% @settitle line...  specifies the title of the document, for headings.
3940% It generates no output of its own.
3941\def\thistitle{\putwordNoTitle}
3942\def\settitle{\parsearg{\gdef\thistitle}}
3943
3944
3945\message{tables,}
3946% Tables -- @table, @ftable, @vtable, @item(x).
3947
3948% default indentation of table text
3949\newdimen\tableindent \tableindent=.8in
3950% default indentation of @itemize and @enumerate text
3951\newdimen\itemindent  \itemindent=.3in
3952% margin between end of table item and start of table text.
3953\newdimen\itemmargin  \itemmargin=.1in
3954
3955% used internally for \itemindent minus \itemmargin
3956\newdimen\itemmax
3957
3958% Note @table, @ftable, and @vtable define @item, @itemx, etc., with
3959% these defs.
3960% They also define \itemindex
3961% to index the item name in whatever manner is desired (perhaps none).
3962
3963\newif\ifitemxneedsnegativevskip
3964
3965\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
3966
3967\def\internalBitem{\smallbreak \parsearg\itemzzz}
3968\def\internalBitemx{\itemxpar \parsearg\itemzzz}
3969
3970\def\itemzzz #1{\begingroup %
3971  \advance\hsize by -\rightskip
3972  \advance\hsize by -\tableindent
3973  \setbox0=\hbox{\itemindicate{#1}}%
3974  \itemindex{#1}%
3975  \nobreak % This prevents a break before @itemx.
3976  %
3977  % If the item text does not fit in the space we have, put it on a line
3978  % by itself, and do not allow a page break either before or after that
3979  % line.  We do not start a paragraph here because then if the next
3980  % command is, e.g., @kindex, the whatsit would get put into the
3981  % horizontal list on a line by itself, resulting in extra blank space.
3982  \ifdim \wd0>\itemmax
3983    %
3984    % Make this a paragraph so we get the \parskip glue and wrapping,
3985    % but leave it ragged-right.
3986    \begingroup
3987      \advance\leftskip by-\tableindent
3988      \advance\hsize by\tableindent
3989      \advance\rightskip by0pt plus1fil\relax
3990      \leavevmode\unhbox0\par
3991    \endgroup
3992    %
3993    % We're going to be starting a paragraph, but we don't want the
3994    % \parskip glue -- logically it's part of the @item we just started.
3995    \nobreak \vskip-\parskip
3996    %
3997    % Stop a page break at the \parskip glue coming up.  However, if
3998    % what follows is an environment such as @example, there will be no
3999    % \parskip glue; then the negative vskip we just inserted would
4000    % cause the example and the item to crash together.  So we use this
4001    % bizarre value of 10001 as a signal to \aboveenvbreak to insert
4002    % \parskip glue after all.  Section titles are handled this way also.
4003    %
4004    \penalty 10001
4005    \endgroup
4006    \itemxneedsnegativevskipfalse
4007  \else
4008    % The item text fits into the space.  Start a paragraph, so that the
4009    % following text (if any) will end up on the same line.
4010    \noindent
4011    % Do this with kerns and \unhbox so that if there is a footnote in
4012    % the item text, it can migrate to the main vertical list and
4013    % eventually be printed.
4014    \nobreak\kern-\tableindent
4015    \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
4016    \unhbox0
4017    \nobreak\kern\dimen0
4018    \endgroup
4019    \itemxneedsnegativevskiptrue
4020  \fi
4021}
4022
4023\def\item{\errmessage{@item while not in a list environment}}
4024\def\itemx{\errmessage{@itemx while not in a list environment}}
4025
4026% @table, @ftable, @vtable.
4027\envdef\table{%
4028  \let\itemindex\gobble
4029  \tablecheck{table}%
4030}
4031\envdef\ftable{%
4032  \def\itemindex ##1{\doind {fn}{\code{##1}}}%
4033  \tablecheck{ftable}%
4034}
4035\envdef\vtable{%
4036  \def\itemindex ##1{\doind {vr}{\code{##1}}}%
4037  \tablecheck{vtable}%
4038}
4039\def\tablecheck#1{%
4040  \ifnum \the\catcode`\^^M=\active
4041    \endgroup
4042    \errmessage{This command won't work in this context; perhaps the problem is
4043      that we are \inenvironment\thisenv}%
4044    \def\next{\doignore{#1}}%
4045  \else
4046    \let\next\tablex
4047  \fi
4048  \next
4049}
4050\def\tablex#1{%
4051  \def\itemindicate{#1}%
4052  \parsearg\tabley
4053}
4054\def\tabley#1{%
4055  {%
4056    \makevalueexpandable
4057    \edef\temp{\noexpand\tablez #1\space\space\space}%
4058    \expandafter
4059  }\temp \endtablez
4060}
4061\def\tablez #1 #2 #3 #4\endtablez{%
4062  \aboveenvbreak
4063  \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
4064  \ifnum 0#2>0 \tableindent=#2\mil \fi
4065  \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
4066  \itemmax=\tableindent
4067  \advance \itemmax by -\itemmargin
4068  \advance \leftskip by \tableindent
4069  \exdentamount=\tableindent
4070  \parindent = 0pt
4071  \parskip = \smallskipamount
4072  \ifdim \parskip=0pt \parskip=2pt \fi
4073  \let\item = \internalBitem
4074  \let\itemx = \internalBitemx
4075}
4076\def\Etable{\endgraf\afterenvbreak}
4077\let\Eftable\Etable
4078\let\Evtable\Etable
4079\let\Eitemize\Etable
4080\let\Eenumerate\Etable
4081
4082% This is the counter used by @enumerate, which is really @itemize
4083
4084\newcount \itemno
4085
4086\envdef\itemize{\parsearg\doitemize}
4087
4088\def\doitemize#1{%
4089  \aboveenvbreak
4090  \itemmax=\itemindent
4091  \advance\itemmax by -\itemmargin
4092  \advance\leftskip by \itemindent
4093  \exdentamount=\itemindent
4094  \parindent=0pt
4095  \parskip=\smallskipamount
4096  \ifdim\parskip=0pt \parskip=2pt \fi
4097  %
4098  % Try typesetting the item mark so that if the document erroneously says
4099  % something like @itemize @samp (intending @table), there's an error
4100  % right away at the @itemize.  It's not the best error message in the
4101  % world, but it's better than leaving it to the @item.  This means if
4102  % the user wants an empty mark, they have to say @w{} not just @w.
4103  \def\itemcontents{#1}%
4104  \setbox0 = \hbox{\itemcontents}%
4105  %
4106  % @itemize with no arg is equivalent to @itemize @bullet.
4107  \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
4108  %
4109  \let\item=\itemizeitem
4110}
4111
4112% Definition of @item while inside @itemize and @enumerate.
4113%
4114\def\itemizeitem{%
4115  \advance\itemno by 1  % for enumerations
4116  {\let\par=\endgraf \smallbreak}% reasonable place to break
4117  {%
4118   % If the document has an @itemize directly after a section title, a
4119   % \nobreak will be last on the list, and \sectionheading will have
4120   % done a \vskip-\parskip.  In that case, we don't want to zero
4121   % parskip, or the item text will crash with the heading.  On the
4122   % other hand, when there is normal text preceding the item (as there
4123   % usually is), we do want to zero parskip, or there would be too much
4124   % space.  In that case, we won't have a \nobreak before.  At least
4125   % that's the theory.
4126   \ifnum\lastpenalty<10000 \parskip=0in \fi
4127   \noindent
4128   \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
4129   %
4130   \ifinner\else
4131     \vadjust{\penalty 1200}% not good to break after first line of item.
4132   \fi
4133   % We can be in inner vertical mode in a footnote, although an
4134   % @itemize looks awful there.
4135  }%
4136  \flushcr
4137}
4138
4139% \splitoff TOKENS\endmark defines \first to be the first token in
4140% TOKENS, and \rest to be the remainder.
4141%
4142\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
4143
4144% Allow an optional argument of an uppercase letter, lowercase letter,
4145% or number, to specify the first label in the enumerated list.  No
4146% argument is the same as `1'.
4147%
4148\envparseargdef\enumerate{\enumeratey #1  \endenumeratey}
4149\def\enumeratey #1 #2\endenumeratey{%
4150  % If we were given no argument, pretend we were given `1'.
4151  \def\thearg{#1}%
4152  \ifx\thearg\empty \def\thearg{1}\fi
4153  %
4154  % Detect if the argument is a single token.  If so, it might be a
4155  % letter.  Otherwise, the only valid thing it can be is a number.
4156  % (We will always have one token, because of the test we just made.
4157  % This is a good thing, since \splitoff doesn't work given nothing at
4158  % all -- the first parameter is undelimited.)
4159  \expandafter\splitoff\thearg\endmark
4160  \ifx\rest\empty
4161    % Only one token in the argument.  It could still be anything.
4162    % A ``lowercase letter'' is one whose \lccode is nonzero.
4163    % An ``uppercase letter'' is one whose \lccode is both nonzero, and
4164    %   not equal to itself.
4165    % Otherwise, we assume it's a number.
4166    %
4167    % We need the \relax at the end of the \ifnum lines to stop TeX from
4168    % continuing to look for a <number>.
4169    %
4170    \ifnum\lccode\expandafter`\thearg=0\relax
4171      \numericenumerate % a number (we hope)
4172    \else
4173      % It's a letter.
4174      \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
4175        \lowercaseenumerate % lowercase letter
4176      \else
4177        \uppercaseenumerate % uppercase letter
4178      \fi
4179    \fi
4180  \else
4181    % Multiple tokens in the argument.  We hope it's a number.
4182    \numericenumerate
4183  \fi
4184}
4185
4186% An @enumerate whose labels are integers.  The starting integer is
4187% given in \thearg.
4188%
4189\def\numericenumerate{%
4190  \itemno = \thearg
4191  \startenumeration{\the\itemno}%
4192}
4193
4194% The starting (lowercase) letter is in \thearg.
4195\def\lowercaseenumerate{%
4196  \itemno = \expandafter`\thearg
4197  \startenumeration{%
4198    % Be sure we're not beyond the end of the alphabet.
4199    \ifnum\itemno=0
4200      \errmessage{No more lowercase letters in @enumerate; get a bigger
4201                  alphabet}%
4202    \fi
4203    \char\lccode\itemno
4204  }%
4205}
4206
4207% The starting (uppercase) letter is in \thearg.
4208\def\uppercaseenumerate{%
4209  \itemno = \expandafter`\thearg
4210  \startenumeration{%
4211    % Be sure we're not beyond the end of the alphabet.
4212    \ifnum\itemno=0
4213      \errmessage{No more uppercase letters in @enumerate; get a bigger
4214                  alphabet}
4215    \fi
4216    \char\uccode\itemno
4217  }%
4218}
4219
4220% Call \doitemize, adding a period to the first argument and supplying the
4221% common last two arguments.  Also subtract one from the initial value in
4222% \itemno, since @item increments \itemno.
4223%
4224\def\startenumeration#1{%
4225  \advance\itemno by -1
4226  \doitemize{#1.}\flushcr
4227}
4228
4229% @alphaenumerate and @capsenumerate are abbreviations for giving an arg
4230% to @enumerate.
4231%
4232\def\alphaenumerate{\enumerate{a}}
4233\def\capsenumerate{\enumerate{A}}
4234\def\Ealphaenumerate{\Eenumerate}
4235\def\Ecapsenumerate{\Eenumerate}
4236
4237
4238% @multitable macros
4239% Amy Hendrickson, 8/18/94, 3/6/96
4240%
4241% @multitable ... @end multitable will make as many columns as desired.
4242% Contents of each column will wrap at width given in preamble.  Width
4243% can be specified either with sample text given in a template line,
4244% or in percent of \hsize, the current width of text on page.
4245
4246% Table can continue over pages but will only break between lines.
4247
4248% To make preamble:
4249%
4250% Either define widths of columns in terms of percent of \hsize:
4251%   @multitable @columnfractions .25 .3 .45
4252%   @item ...
4253%
4254%   Numbers following @columnfractions are the percent of the total
4255%   current hsize to be used for each column. You may use as many
4256%   columns as desired.
4257
4258
4259% Or use a template:
4260%   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4261%   @item ...
4262%   using the widest term desired in each column.
4263
4264% Each new table line starts with @item, each subsequent new column
4265% starts with @tab. Empty columns may be produced by supplying @tab's
4266% with nothing between them for as many times as empty columns are needed,
4267% ie, @tab@tab@tab will produce two empty columns.
4268
4269% @item, @tab do not need to be on their own lines, but it will not hurt
4270% if they are.
4271
4272% Sample multitable:
4273
4274%   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4275%   @item first col stuff @tab second col stuff @tab third col
4276%   @item
4277%   first col stuff
4278%   @tab
4279%   second col stuff
4280%   @tab
4281%   third col
4282%   @item first col stuff @tab second col stuff
4283%   @tab Many paragraphs of text may be used in any column.
4284%
4285%         They will wrap at the width determined by the template.
4286%   @item@tab@tab This will be in third column.
4287%   @end multitable
4288
4289% Default dimensions may be reset by user.
4290% @multitableparskip is vertical space between paragraphs in table.
4291% @multitableparindent is paragraph indent in table.
4292% @multitablecolmargin is horizontal space to be left between columns.
4293% @multitablelinespace is space to leave between table items, baseline
4294%                                                            to baseline.
4295%   0pt means it depends on current normal line spacing.
4296%
4297\newskip\multitableparskip
4298\newskip\multitableparindent
4299\newdimen\multitablecolspace
4300\newskip\multitablelinespace
4301\multitableparskip=0pt
4302\multitableparindent=6pt
4303\multitablecolspace=12pt
4304\multitablelinespace=0pt
4305
4306% Macros used to set up halign preamble:
4307%
4308\let\endsetuptable\relax
4309\def\xendsetuptable{\endsetuptable}
4310\let\columnfractions\relax
4311\def\xcolumnfractions{\columnfractions}
4312\newif\ifsetpercent
4313
4314% #1 is the @columnfraction, usually a decimal number like .5, but might
4315% be just 1.  We just use it, whatever it is.
4316%
4317\def\pickupwholefraction#1 {%
4318  \global\advance\colcount by 1
4319  \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
4320  \setuptable
4321}
4322
4323\newcount\colcount
4324\def\setuptable#1{%
4325  \def\firstarg{#1}%
4326  \ifx\firstarg\xendsetuptable
4327    \let\go = \relax
4328  \else
4329    \ifx\firstarg\xcolumnfractions
4330      \global\setpercenttrue
4331    \else
4332      \ifsetpercent
4333         \let\go\pickupwholefraction
4334      \else
4335         \global\advance\colcount by 1
4336         \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
4337                   % separator; typically that is always in the input, anyway.
4338         \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
4339      \fi
4340    \fi
4341    \ifx\go\pickupwholefraction
4342      % Put the argument back for the \pickupwholefraction call, so
4343      % we'll always have a period there to be parsed.
4344      \def\go{\pickupwholefraction#1}%
4345    \else
4346      \let\go = \setuptable
4347    \fi%
4348  \fi
4349  \go
4350}
4351
4352% multitable-only commands.
4353%
4354% @headitem starts a heading row, which we typeset in bold.  Assignments
4355% have to be global since we are inside the implicit group of an
4356% alignment entry.  \everycr below resets \everytab so we don't have to
4357% undo it ourselves.
4358\def\headitemfont{\b}% for people to use in the template row; not changeable
4359\def\headitem{%
4360  \checkenv\multitable
4361  \crcr
4362  \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
4363  \global\everytab={\bf}% can't use \headitemfont since the parsing differs
4364  \the\everytab % for the first item
4365}%
4366%
4367% default for tables with no headings.
4368\let\headitemcrhook=\relax
4369%
4370% A \tab used to include \hskip1sp.  But then the space in a template
4371% line is not enough.  That is bad.  So let's go back to just `&' until
4372% we again encounter the problem the 1sp was intended to solve.
4373%					--karl, nathan@acm.org, 20apr99.
4374\def\tab{\checkenv\multitable &\the\everytab}%
4375
4376% @multitable ... @end multitable definitions:
4377%
4378\newtoks\everytab  % insert after every tab.
4379%
4380\envdef\multitable{%
4381  \vskip\parskip
4382  \startsavinginserts
4383  %
4384  % @item within a multitable starts a normal row.
4385  % We use \def instead of \let so that if one of the multitable entries
4386  % contains an @itemize, we don't choke on the \item (seen as \crcr aka
4387  % \endtemplate) expanding \doitemize.
4388  \def\item{\crcr}%
4389  %
4390  \tolerance=9500
4391  \hbadness=9500
4392  \setmultitablespacing
4393  \parskip=\multitableparskip
4394  \parindent=\multitableparindent
4395  \overfullrule=0pt
4396  \global\colcount=0
4397  %
4398  \everycr = {%
4399    \noalign{%
4400      \global\everytab={}% Reset from possible headitem.
4401      \global\colcount=0 % Reset the column counter.
4402      %
4403      % Check for saved footnotes, etc.:
4404      \checkinserts
4405      %
4406      % Perhaps a \nobreak, then reset:
4407      \headitemcrhook
4408      \global\let\headitemcrhook=\relax
4409    }%
4410  }%
4411  %
4412  \parsearg\domultitable
4413}
4414\def\domultitable#1{%
4415  % To parse everything between @multitable and @item:
4416  \setuptable#1 \endsetuptable
4417  %
4418  % This preamble sets up a generic column definition, which will
4419  % be used as many times as user calls for columns.
4420  % \vtop will set a single line and will also let text wrap and
4421  % continue for many paragraphs if desired.
4422  \halign\bgroup &%
4423    \global\advance\colcount by 1
4424    \multistrut
4425    \vtop{%
4426      % Use the current \colcount to find the correct column width:
4427      \hsize=\expandafter\csname col\the\colcount\endcsname
4428      %
4429      % In order to keep entries from bumping into each other
4430      % we will add a \leftskip of \multitablecolspace to all columns after
4431      % the first one.
4432      %
4433      % If a template has been used, we will add \multitablecolspace
4434      % to the width of each template entry.
4435      %
4436      % If the user has set preamble in terms of percent of \hsize we will
4437      % use that dimension as the width of the column, and the \leftskip
4438      % will keep entries from bumping into each other.  Table will start at
4439      % left margin and final column will justify at right margin.
4440      %
4441      % Make sure we don't inherit \rightskip from the outer environment.
4442      \rightskip=0pt
4443      \ifnum\colcount=1
4444	% The first column will be indented with the surrounding text.
4445	\advance\hsize by\leftskip
4446      \else
4447	\ifsetpercent \else
4448	  % If user has not set preamble in terms of percent of \hsize
4449	  % we will advance \hsize by \multitablecolspace.
4450	  \advance\hsize by \multitablecolspace
4451	\fi
4452       % In either case we will make \leftskip=\multitablecolspace:
4453      \leftskip=\multitablecolspace
4454      \fi
4455      % Ignoring space at the beginning and end avoids an occasional spurious
4456      % blank line, when TeX decides to break the line at the space before the
4457      % box from the multistrut, so the strut ends up on a line by itself.
4458      % For example:
4459      % @multitable @columnfractions .11 .89
4460      % @item @code{#}
4461      % @tab Legal holiday which is valid in major parts of the whole country.
4462      % Is automatically provided with highlighting sequences respectively
4463      % marking characters.
4464      \noindent\ignorespaces##\unskip\multistrut
4465    }\cr
4466}
4467\def\Emultitable{%
4468  \crcr
4469  \egroup % end the \halign
4470  \global\setpercentfalse
4471}
4472
4473\def\setmultitablespacing{%
4474  \def\multistrut{\strut}% just use the standard line spacing
4475  %
4476  % Compute \multitablelinespace (if not defined by user) for use in
4477  % \multitableparskip calculation.  We used define \multistrut based on
4478  % this, but (ironically) that caused the spacing to be off.
4479  % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
4480\ifdim\multitablelinespace=0pt
4481\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
4482\global\advance\multitablelinespace by-\ht0
4483\fi
4484% Test to see if parskip is larger than space between lines of
4485% table. If not, do nothing.
4486%        If so, set to same dimension as multitablelinespace.
4487\ifdim\multitableparskip>\multitablelinespace
4488\global\multitableparskip=\multitablelinespace
4489\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4490                                      % than skip between lines in the table.
4491\fi%
4492\ifdim\multitableparskip=0pt
4493\global\multitableparskip=\multitablelinespace
4494\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4495                                      % than skip between lines in the table.
4496\fi}
4497
4498
4499\message{conditionals,}
4500
4501% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
4502% @ifnotxml always succeed.  They currently do nothing; we don't
4503% attempt to check whether the conditionals are properly nested.  But we
4504% have to remember that they are conditionals, so that @end doesn't
4505% attempt to close an environment group.
4506%
4507\def\makecond#1{%
4508  \expandafter\let\csname #1\endcsname = \relax
4509  \expandafter\let\csname iscond.#1\endcsname = 1
4510}
4511\makecond{iftex}
4512\makecond{ifnotdocbook}
4513\makecond{ifnothtml}
4514\makecond{ifnotinfo}
4515\makecond{ifnotplaintext}
4516\makecond{ifnotxml}
4517
4518% Ignore @ignore, @ifhtml, @ifinfo, and the like.
4519%
4520\def\direntry{\doignore{direntry}}
4521\def\documentdescription{\doignore{documentdescription}}
4522\def\docbook{\doignore{docbook}}
4523\def\html{\doignore{html}}
4524\def\ifdocbook{\doignore{ifdocbook}}
4525\def\ifhtml{\doignore{ifhtml}}
4526\def\ifinfo{\doignore{ifinfo}}
4527\def\ifnottex{\doignore{ifnottex}}
4528\def\ifplaintext{\doignore{ifplaintext}}
4529\def\ifxml{\doignore{ifxml}}
4530\def\ignore{\doignore{ignore}}
4531\def\menu{\doignore{menu}}
4532\def\xml{\doignore{xml}}
4533
4534% Ignore text until a line `@end #1', keeping track of nested conditionals.
4535%
4536% A count to remember the depth of nesting.
4537\newcount\doignorecount
4538
4539\def\doignore#1{\begingroup
4540  % Scan in ``verbatim'' mode:
4541  \obeylines
4542  \catcode`\@ = \other
4543  \catcode`\{ = \other
4544  \catcode`\} = \other
4545  %
4546  % Make sure that spaces turn into tokens that match what \doignoretext wants.
4547  \spaceisspace
4548  %
4549  % Count number of #1's that we've seen.
4550  \doignorecount = 0
4551  %
4552  % Swallow text until we reach the matching `@end #1'.
4553  \dodoignore{#1}%
4554}
4555
4556{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4557  \obeylines %
4558  %
4559  \gdef\dodoignore#1{%
4560    % #1 contains the command name as a string, e.g., `ifinfo'.
4561    %
4562    % Define a command to find the next `@end #1'.
4563    \long\def\doignoretext##1^^M@end #1{%
4564      \doignoretextyyy##1^^M@#1\_STOP_}%
4565    %
4566    % And this command to find another #1 command, at the beginning of a
4567    % line.  (Otherwise, we would consider a line `@c @ifset', for
4568    % example, to count as an @ifset for nesting.)
4569    \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
4570    %
4571    % And now expand that command.
4572    \doignoretext ^^M%
4573  }%
4574}
4575
4576\def\doignoreyyy#1{%
4577  \def\temp{#1}%
4578  \ifx\temp\empty			% Nothing found.
4579    \let\next\doignoretextzzz
4580  \else					% Found a nested condition, ...
4581    \advance\doignorecount by 1
4582    \let\next\doignoretextyyy		% ..., look for another.
4583    % If we're here, #1 ends with ^^M\ifinfo (for example).
4584  \fi
4585  \next #1% the token \_STOP_ is present just after this macro.
4586}
4587
4588% We have to swallow the remaining "\_STOP_".
4589%
4590\def\doignoretextzzz#1{%
4591  \ifnum\doignorecount = 0	% We have just found the outermost @end.
4592    \let\next\enddoignore
4593  \else				% Still inside a nested condition.
4594    \advance\doignorecount by -1
4595    \let\next\doignoretext      % Look for the next @end.
4596  \fi
4597  \next
4598}
4599
4600% Finish off ignored text.
4601{ \obeylines%
4602  % Ignore anything after the last `@end #1'; this matters in verbatim
4603  % environments, where otherwise the newline after an ignored conditional
4604  % would result in a blank line in the output.
4605  \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4606}
4607
4608
4609% @set VAR sets the variable VAR to an empty value.
4610% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4611%
4612% Since we want to separate VAR from REST-OF-LINE (which might be
4613% empty), we can't just use \parsearg; we have to insert a space of our
4614% own to delimit the rest of the line, and then take it out again if we
4615% didn't need it.
4616% We rely on the fact that \parsearg sets \catcode`\ =10.
4617%
4618\parseargdef\set{\setyyy#1 \endsetyyy}
4619\def\setyyy#1 #2\endsetyyy{%
4620  {%
4621    \makevalueexpandable
4622    \def\temp{#2}%
4623    \edef\next{\gdef\makecsname{SET#1}}%
4624    \ifx\temp\empty
4625      \next{}%
4626    \else
4627      \setzzz#2\endsetzzz
4628    \fi
4629  }%
4630}
4631% Remove the trailing space \setxxx inserted.
4632\def\setzzz#1 \endsetzzz{\next{#1}}
4633
4634% @clear VAR clears (i.e., unsets) the variable VAR.
4635%
4636\parseargdef\clear{%
4637  {%
4638    \makevalueexpandable
4639    \global\expandafter\let\csname SET#1\endcsname=\relax
4640  }%
4641}
4642
4643% @value{foo} gets the text saved in variable foo.
4644\def\value{\begingroup\makevalueexpandable\valuexxx}
4645\def\valuexxx#1{\expandablevalue{#1}\endgroup}
4646{
4647  \catcode`\-=\active \catcode`\_=\active
4648  %
4649  \gdef\makevalueexpandable{%
4650    \let\value = \expandablevalue
4651    % We don't want these characters active, ...
4652    \catcode`\-=\other \catcode`\_=\other
4653    % ..., but we might end up with active ones in the argument if
4654    % we're called from @code, as @code{@value{foo-bar_}}, though.
4655    % So \let them to their normal equivalents.
4656    \let-\normaldash \let_\normalunderscore
4657  }
4658}
4659
4660\def\expandablevalue#1{%
4661  \expandafter\ifx\csname SET#1\endcsname\relax
4662    {[No value for ``#1'']}%
4663    \message{Variable `#1', used in @value, is not set.}%
4664  \else
4665    \csname SET#1\endcsname
4666  \fi
4667}
4668
4669% Like \expandablevalue, but completely expandable (the \message in the
4670% definition above operates at the execution level of TeX).  Used when
4671% writing to auxiliary files, due to the expansion that \write does.
4672% If flag is undefined, pass through an unexpanded @value command: maybe it
4673% will be set by the time it is read back in.
4674%
4675% NB flag names containing - or _ may not work here.
4676\def\dummyvalue#1{%
4677  \expandafter\ifx\csname SET#1\endcsname\relax
4678    \noexpand\value{#1}%
4679  \else
4680    \csname SET#1\endcsname
4681  \fi
4682}
4683
4684% Used for @value's in index entries to form the sort key: expand the @value
4685% if possible, otherwise sort late.
4686\def\indexnofontsvalue#1{%
4687  \expandafter\ifx\csname SET#1\endcsname\relax
4688    ZZZZZZZ%
4689  \else
4690    \csname SET#1\endcsname
4691  \fi
4692}
4693
4694% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4695% with @set.
4696%
4697% To get the special treatment we need for `@end ifset,' we call
4698% \makecond and then redefine.
4699%
4700\makecond{ifset}
4701\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4702\def\doifset#1#2{%
4703  {%
4704    \makevalueexpandable
4705    \let\next=\empty
4706    \expandafter\ifx\csname SET#2\endcsname\relax
4707      #1% If not set, redefine \next.
4708    \fi
4709    \expandafter
4710  }\next
4711}
4712\def\ifsetfail{\doignore{ifset}}
4713
4714% @ifclear VAR ... @end executes the `...' iff VAR has never been
4715% defined with @set, or has been undefined with @clear.
4716%
4717% The `\else' inside the `\doifset' parameter is a trick to reuse the
4718% above code: if the variable is not set, do nothing, if it is set,
4719% then redefine \next to \ifclearfail.
4720%
4721\makecond{ifclear}
4722\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4723\def\ifclearfail{\doignore{ifclear}}
4724
4725% @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
4726% without the @) is in fact defined.  We can only feasibly check at the
4727% TeX level, so something like `mathcode' is going to considered
4728% defined even though it is not a Texinfo command.
4729%
4730\makecond{ifcommanddefined}
4731\def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
4732%
4733\def\doifcmddefined#1#2{{%
4734    \makevalueexpandable
4735    \let\next=\empty
4736    \expandafter\ifx\csname #2\endcsname\relax
4737      #1% If not defined, \let\next as above.
4738    \fi
4739    \expandafter
4740  }\next
4741}
4742\def\ifcmddefinedfail{\doignore{ifcommanddefined}}
4743
4744% @ifcommandnotdefined CMD ... handled similar to @ifclear above.
4745\makecond{ifcommandnotdefined}
4746\def\ifcommandnotdefined{%
4747  \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
4748\def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
4749
4750% Set the `txicommandconditionals' variable, so documents have a way to
4751% test if the @ifcommand...defined conditionals are available.
4752\set txicommandconditionals
4753
4754% @dircategory CATEGORY  -- specify a category of the dir file
4755% which this file should belong to.  Ignore this in TeX.
4756\let\dircategory=\comment
4757
4758% @defininfoenclose.
4759\let\definfoenclose=\comment
4760
4761
4762\message{indexing,}
4763% Index generation facilities
4764
4765% Define \newwrite to be identical to plain tex's \newwrite
4766% except not \outer, so it can be used within macros and \if's.
4767\edef\newwrite{\makecsname{ptexnewwrite}}
4768
4769% \newindex {foo} defines an index named IX.
4770% It automatically defines \IXindex such that
4771% \IXindex ...rest of line... puts an entry in the index IX.
4772% It also defines \IXindfile to be the number of the output channel for
4773% the file that accumulates this index.  The file's extension is IX.
4774% The name of an index should be no more than 2 characters long
4775% for the sake of vms.
4776%
4777\def\newindex#1{%
4778  \expandafter\chardef\csname#1indfile\endcsname=0
4779  \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
4780    \noexpand\doindex{#1}}
4781}
4782
4783% @defindex foo  ==  \newindex{foo}
4784%
4785\def\defindex{\parsearg\newindex}
4786
4787% Define @defcodeindex, like @defindex except put all entries in @code.
4788%
4789\def\defcodeindex{\parsearg\newcodeindex}
4790%
4791\def\newcodeindex#1{%
4792  \expandafter\chardef\csname#1indfile\endcsname=0
4793  \expandafter\xdef\csname#1index\endcsname{%
4794    \noexpand\docodeindex{#1}}%
4795}
4796
4797% The default indices:
4798\newindex{cp}%      concepts,
4799\newcodeindex{fn}%  functions,
4800\newcodeindex{vr}%  variables,
4801\newcodeindex{tp}%  types,
4802\newcodeindex{ky}%  keys
4803\newcodeindex{pg}%  and programs.
4804
4805
4806% @synindex foo bar    makes index foo feed into index bar.
4807% Do this instead of @defindex foo if you don't want it as a separate index.
4808%
4809% @syncodeindex foo bar   similar, but put all entries made for index foo
4810% inside @code.
4811%
4812\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4813\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4814
4815% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4816% #3 the target index (bar).
4817\def\dosynindex#1#2#3{%
4818  \requireopenindexfile{#3}%
4819  % redefine \fooindfile:
4820  \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4821  \expandafter\let\csname#2indfile\endcsname=\temp
4822  % redefine \fooindex:
4823  \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
4824}
4825
4826% Define \doindex, the driver for all index macros.
4827% Argument #1 is generated by the calling \fooindex macro,
4828% and it is the two-letter name of the index.
4829
4830\def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
4831\def\doindexxxx #1{\doind{\indexname}{#1}}
4832
4833% like the previous two, but they put @code around the argument.
4834\def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
4835\def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
4836
4837
4838% Used for the aux, toc and index files to prevent expansion of Texinfo
4839% commands.
4840%
4841\def\atdummies{%
4842  \definedummyletter\@%
4843  \definedummyletter\ %
4844  \definedummyletter\{%
4845  \definedummyletter\}%
4846  %
4847  % Do the redefinitions.
4848  \definedummies
4849  \otherbackslash
4850}
4851
4852% \definedummyword defines \#1 as \string\#1\space, thus effectively
4853% preventing its expansion.  This is used only for control words,
4854% not control letters, because the \space would be incorrect for
4855% control characters, but is needed to separate the control word
4856% from whatever follows.
4857%
4858% These can be used both for control words that take an argument and
4859% those that do not.  If it is followed by {arg} in the input, then
4860% that will dutifully get written to the index (or wherever).
4861%
4862% For control letters, we have \definedummyletter, which omits the
4863% space.
4864%
4865\def\definedummyword  #1{\def#1{\string#1\space}}%
4866\def\definedummyletter#1{\def#1{\string#1}}%
4867\let\definedummyaccent\definedummyletter
4868
4869% Called from \atdummies to prevent the expansion of commands.
4870%
4871\def\definedummies{%
4872  %
4873  \let\commondummyword\definedummyword
4874  \let\commondummyletter\definedummyletter
4875  \let\commondummyaccent\definedummyaccent
4876  \commondummiesnofonts
4877  %
4878  \definedummyletter\_%
4879  \definedummyletter\-%
4880  %
4881  % Non-English letters.
4882  \definedummyword\AA
4883  \definedummyword\AE
4884  \definedummyword\DH
4885  \definedummyword\L
4886  \definedummyword\O
4887  \definedummyword\OE
4888  \definedummyword\TH
4889  \definedummyword\aa
4890  \definedummyword\ae
4891  \definedummyword\dh
4892  \definedummyword\exclamdown
4893  \definedummyword\l
4894  \definedummyword\o
4895  \definedummyword\oe
4896  \definedummyword\ordf
4897  \definedummyword\ordm
4898  \definedummyword\questiondown
4899  \definedummyword\ss
4900  \definedummyword\th
4901  %
4902  % Although these internal commands shouldn't show up, sometimes they do.
4903  \definedummyword\bf
4904  \definedummyword\gtr
4905  \definedummyword\hat
4906  \definedummyword\less
4907  \definedummyword\sf
4908  \definedummyword\sl
4909  \definedummyword\tclose
4910  \definedummyword\tt
4911  %
4912  \definedummyword\LaTeX
4913  \definedummyword\TeX
4914  %
4915  % Assorted special characters.
4916  \definedummyword\atchar
4917  \definedummyword\arrow
4918  \definedummyword\backslashchar
4919  \definedummyword\bullet
4920  \definedummyword\comma
4921  \definedummyword\copyright
4922  \definedummyword\registeredsymbol
4923  \definedummyword\dots
4924  \definedummyword\enddots
4925  \definedummyword\entrybreak
4926  \definedummyword\equiv
4927  \definedummyword\error
4928  \definedummyword\euro
4929  \definedummyword\expansion
4930  \definedummyword\geq
4931  \definedummyword\guillemetleft
4932  \definedummyword\guillemetright
4933  \definedummyword\guilsinglleft
4934  \definedummyword\guilsinglright
4935  \definedummyword\lbracechar
4936  \definedummyword\leq
4937  \definedummyword\mathopsup
4938  \definedummyword\minus
4939  \definedummyword\ogonek
4940  \definedummyword\pounds
4941  \definedummyword\point
4942  \definedummyword\print
4943  \definedummyword\quotedblbase
4944  \definedummyword\quotedblleft
4945  \definedummyword\quotedblright
4946  \definedummyword\quoteleft
4947  \definedummyword\quoteright
4948  \definedummyword\quotesinglbase
4949  \definedummyword\rbracechar
4950  \definedummyword\result
4951  \definedummyword\sub
4952  \definedummyword\sup
4953  \definedummyword\textdegree
4954  %
4955  \definedummyword\subentry
4956  %
4957  % We want to disable all macros so that they are not expanded by \write.
4958  \macrolist
4959  \let\value\dummyvalue
4960  %
4961  \normalturnoffactive
4962}
4963
4964% \commondummiesnofonts: common to \definedummies and \indexnofonts.
4965% Define \commondummyletter, \commondummyaccent and \commondummyword before
4966% using.  Used for accents, font commands, and various control letters.
4967%
4968\def\commondummiesnofonts{%
4969  % Control letters and accents.
4970  \commondummyletter\!%
4971  \commondummyaccent\"%
4972  \commondummyaccent\'%
4973  \commondummyletter\*%
4974  \commondummyaccent\,%
4975  \commondummyletter\.%
4976  \commondummyletter\/%
4977  \commondummyletter\:%
4978  \commondummyaccent\=%
4979  \commondummyletter\?%
4980  \commondummyaccent\^%
4981  \commondummyaccent\`%
4982  \commondummyaccent\~%
4983  \commondummyword\u
4984  \commondummyword\v
4985  \commondummyword\H
4986  \commondummyword\dotaccent
4987  \commondummyword\ogonek
4988  \commondummyword\ringaccent
4989  \commondummyword\tieaccent
4990  \commondummyword\ubaraccent
4991  \commondummyword\udotaccent
4992  \commondummyword\dotless
4993  %
4994  % Texinfo font commands.
4995  \commondummyword\b
4996  \commondummyword\i
4997  \commondummyword\r
4998  \commondummyword\sansserif
4999  \commondummyword\sc
5000  \commondummyword\slanted
5001  \commondummyword\t
5002  %
5003  % Commands that take arguments.
5004  \commondummyword\abbr
5005  \commondummyword\acronym
5006  \commondummyword\anchor
5007  \commondummyword\cite
5008  \commondummyword\code
5009  \commondummyword\command
5010  \commondummyword\dfn
5011  \commondummyword\dmn
5012  \commondummyword\email
5013  \commondummyword\emph
5014  \commondummyword\env
5015  \commondummyword\file
5016  \commondummyword\image
5017  \commondummyword\indicateurl
5018  \commondummyword\inforef
5019  \commondummyword\kbd
5020  \commondummyword\key
5021  \commondummyword\math
5022  \commondummyword\option
5023  \commondummyword\pxref
5024  \commondummyword\ref
5025  \commondummyword\samp
5026  \commondummyword\strong
5027  \commondummyword\tie
5028  \commondummyword\U
5029  \commondummyword\uref
5030  \commondummyword\url
5031  \commondummyword\var
5032  \commondummyword\verb
5033  \commondummyword\w
5034  \commondummyword\xref
5035}
5036
5037\let\indexlbrace\relax
5038\let\indexrbrace\relax
5039\let\indexatchar\relax
5040\let\indexbackslash\relax
5041
5042{\catcode`\@=0
5043\catcode`\\=13
5044  @gdef@backslashdisappear{@def\{}}
5045}
5046
5047{
5048\catcode`\<=13
5049\catcode`\-=13
5050\catcode`\`=13
5051  \gdef\indexnonalnumdisappear{%
5052    \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
5053      % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
5054      % (Introduced for FSFS 2nd ed.)
5055      \let`=\empty
5056    \fi
5057    %
5058    \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
5059      \backslashdisappear
5060    \fi
5061    %
5062    \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
5063      \def-{}%
5064    \fi
5065    \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
5066      \def<{}%
5067    \fi
5068    \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
5069      \def\@{}%
5070    \fi
5071  }
5072
5073  \gdef\indexnonalnumreappear{%
5074    \let-\normaldash
5075    \let<\normalless
5076  }
5077}
5078
5079
5080% \indexnofonts is used when outputting the strings to sort the index
5081% by, and when constructing control sequence names.  It eliminates all
5082% control sequences and just writes whatever the best ASCII sort string
5083% would be for a given command (usually its argument).
5084%
5085\def\indexnofonts{%
5086  % Accent commands should become @asis.
5087  \def\commondummyaccent##1{\let##1\asis}%
5088  % We can just ignore other control letters.
5089  \def\commondummyletter##1{\let##1\empty}%
5090  % All control words become @asis by default; overrides below.
5091  \let\commondummyword\commondummyaccent
5092  \commondummiesnofonts
5093  %
5094  % Don't no-op \tt, since it isn't a user-level command
5095  % and is used in the definitions of the active chars like <, >, |, etc.
5096  % Likewise with the other plain tex font commands.
5097  %\let\tt=\asis
5098  %
5099  \def\ { }%
5100  \def\@{@}%
5101  \def\_{\normalunderscore}%
5102  \def\-{}% @- shouldn't affect sorting
5103  %
5104  \uccode`\1=`\{ \uppercase{\def\{{1}}%
5105  \uccode`\1=`\} \uppercase{\def\}{1}}%
5106  \let\lbracechar\{%
5107  \let\rbracechar\}%
5108  %
5109  % Non-English letters.
5110  \def\AA{AA}%
5111  \def\AE{AE}%
5112  \def\DH{DZZ}%
5113  \def\L{L}%
5114  \def\OE{OE}%
5115  \def\O{O}%
5116  \def\TH{TH}%
5117  \def\aa{aa}%
5118  \def\ae{ae}%
5119  \def\dh{dzz}%
5120  \def\exclamdown{!}%
5121  \def\l{l}%
5122  \def\oe{oe}%
5123  \def\ordf{a}%
5124  \def\ordm{o}%
5125  \def\o{o}%
5126  \def\questiondown{?}%
5127  \def\ss{ss}%
5128  \def\th{th}%
5129  %
5130  \def\LaTeX{LaTeX}%
5131  \def\TeX{TeX}%
5132  %
5133  % Assorted special characters.  \defglyph gives the control sequence a
5134  % definition that removes the {} that follows its use.
5135  \defglyph\atchar{@}%
5136  \defglyph\arrow{->}%
5137  \defglyph\bullet{bullet}%
5138  \defglyph\comma{,}%
5139  \defglyph\copyright{copyright}%
5140  \defglyph\dots{...}%
5141  \defglyph\enddots{...}%
5142  \defglyph\equiv{==}%
5143  \defglyph\error{error}%
5144  \defglyph\euro{euro}%
5145  \defglyph\expansion{==>}%
5146  \defglyph\geq{>=}%
5147  \defglyph\guillemetleft{<<}%
5148  \defglyph\guillemetright{>>}%
5149  \defglyph\guilsinglleft{<}%
5150  \defglyph\guilsinglright{>}%
5151  \defglyph\leq{<=}%
5152  \defglyph\lbracechar{\{}%
5153  \defglyph\minus{-}%
5154  \defglyph\point{.}%
5155  \defglyph\pounds{pounds}%
5156  \defglyph\print{-|}%
5157  \defglyph\quotedblbase{"}%
5158  \defglyph\quotedblleft{"}%
5159  \defglyph\quotedblright{"}%
5160  \defglyph\quoteleft{`}%
5161  \defglyph\quoteright{'}%
5162  \defglyph\quotesinglbase{,}%
5163  \defglyph\rbracechar{\}}%
5164  \defglyph\registeredsymbol{R}%
5165  \defglyph\result{=>}%
5166  \defglyph\textdegree{o}%
5167  %
5168  % We need to get rid of all macros, leaving only the arguments (if present).
5169  % Of course this is not nearly correct, but it is the best we can do for now.
5170  % makeinfo does not expand macros in the argument to @deffn, which ends up
5171  % writing an index entry, and texindex isn't prepared for an index sort entry
5172  % that starts with \.
5173  %
5174  % Since macro invocations are followed by braces, we can just redefine them
5175  % to take a single TeX argument.  The case of a macro invocation that
5176  % goes to end-of-line is not handled.
5177  %
5178  \macrolist
5179  \let\value\indexnofontsvalue
5180}
5181\def\defglyph#1#2{\def#1##1{#2}} % see above
5182
5183
5184
5185
5186% #1 is the index name, #2 is the entry text.
5187\def\doind#1#2{%
5188  \iflinks
5189  {%
5190    %
5191    \requireopenindexfile{#1}%
5192    \edef\writeto{\csname#1indfile\endcsname}%
5193    %
5194    \def\indextext{#2}%
5195    \safewhatsit\doindwrite
5196  }%
5197  \fi
5198}
5199
5200% Check if an index file has been opened, and if not, open it.
5201\def\requireopenindexfile#1{%
5202\ifnum\csname #1indfile\endcsname=0
5203  \expandafter\newwrite \csname#1indfile\endcsname
5204  \edef\suffix{#1}%
5205  % A .fls suffix would conflict with the file extension for the output
5206  % of -recorder, so use .f1s instead.
5207  \ifx\suffix\indexisfl\def\suffix{f1}\fi
5208  % Open the file
5209  \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
5210  % Using \immediate above here prevents an object entering into the current
5211  % box, which could confound checks such as those in \safewhatsit for
5212  % preceding skips.
5213  \typeout{Writing index file \jobname.\suffix}%
5214\fi}
5215\def\indexisfl{fl}
5216
5217% Definition for writing index entry sort key.
5218{
5219\catcode`\-=13
5220\gdef\indexwritesortas{%
5221  \begingroup
5222  \indexnonalnumreappear
5223  \indexwritesortasxxx}
5224\gdef\indexwritesortasxxx#1{%
5225  \xdef\indexsortkey{#1}\endgroup}
5226}
5227
5228\def\indexwriteseealso#1{
5229  \gdef\pagenumbertext{\string\seealso{#1}}%
5230}
5231\def\indexwriteseeentry#1{
5232  \gdef\pagenumbertext{\string\seeentry{#1}}%
5233}
5234
5235% The default definitions
5236\def\sortas#1{}%
5237\def\seealso#1{\i{\putwordSeeAlso}\ #1}% for sorted index file only
5238\def\putwordSeeAlso{See also}
5239\def\seeentry#1{\i{\putwordSee}\ #1}% for sorted index file only
5240
5241
5242% Given index entry text like "aaa @subentry bbb @sortas{ZZZ}":
5243%   * Set \bracedtext to "{aaa}{bbb}"
5244%   * Set \fullindexsortkey to "aaa @subentry ZZZ"
5245%   * If @seealso occurs, set \pagenumbertext
5246%
5247\def\splitindexentry#1{%
5248  \gdef\fullindexsortkey{}%
5249  \xdef\bracedtext{}%
5250  \def\sep{}%
5251  \def\seealso##1{}%
5252  \def\seeentry##1{}%
5253  \expandafter\doindexsegment#1\subentry\finish\subentry
5254}
5255
5256% append the results from the next segment
5257\def\doindexsegment#1\subentry{%
5258  \def\segment{#1}%
5259  \ifx\segment\isfinish
5260  \else
5261    %
5262    % Fully expand the segment, throwing away any @sortas directives, and
5263    % trim spaces.
5264    \edef\trimmed{\segment}%
5265    \edef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
5266    %
5267    \xdef\bracedtext{\bracedtext{\trimmed}}%
5268    %
5269    % Get the string to sort by.  Process the segment with all
5270    % font commands turned off.
5271    \bgroup
5272      \let\sortas\indexwritesortas
5273      \let\seealso\indexwriteseealso
5274      \let\seeentry\indexwriteseeentry
5275      \indexnofonts
5276      % The braces around the commands are recognized by texindex.
5277      \def\lbracechar{{\string\indexlbrace}}%
5278      \def\rbracechar{{\string\indexrbrace}}%
5279      \let\{=\lbracechar
5280      \let\}=\rbracechar
5281      \def\@{{\string\indexatchar}}%
5282      \def\atchar##1{\@}%
5283      \def\backslashchar{{\string\indexbackslash}}%
5284      \uccode`\~=`\\ \uppercase{\let~\backslashchar}%
5285      %
5286      \let\indexsortkey\empty
5287      \global\let\pagenumbertext\empty
5288      % Execute the segment and throw away the typeset output.  This executes
5289      % any @sortas or @seealso commands in this segment.
5290      \setbox\dummybox = \hbox{\segment}%
5291      \ifx\indexsortkey\empty{%
5292        \indexnonalnumdisappear
5293        \xdef\trimmed{\segment}%
5294        \xdef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
5295        \xdef\indexsortkey{\trimmed}%
5296        \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
5297      }\fi
5298      %
5299      % Append to \fullindexsortkey.
5300      \edef\tmp{\gdef\noexpand\fullindexsortkey{%
5301                  \fullindexsortkey\sep\indexsortkey}}%
5302      \tmp
5303    \egroup
5304    \def\sep{\subentry}%
5305    %
5306    \expandafter\doindexsegment
5307  \fi
5308}
5309\def\isfinish{\finish}%
5310\newbox\dummybox % used above
5311
5312\let\subentry\relax
5313
5314% Use \ instead of @ in index files.  To support old texi2dvi and texindex.
5315% This works without changing the escape character used in the toc or aux
5316% files because the index entries are fully expanded here, and \string uses
5317% the current value of \escapechar.
5318\def\escapeisbackslash{\escapechar=`\\}
5319
5320% Use \ in index files by default.  texi2dvi didn't support @ as the escape
5321% character (as it checked for "\entry" in the files, and not "@entry").  When
5322% the new version of texi2dvi has had a chance to become more prevalent, then
5323% the escape character can change back to @ again.  This should be an easy
5324% change to make now because both @ and \ are only used as escape characters in
5325% index files, never standing for themselves.
5326%
5327\set txiindexescapeisbackslash
5328
5329% Write the entry in \indextext to the index file.
5330%
5331\def\doindwrite{%
5332  \maybemarginindex
5333  %
5334  \atdummies
5335  %
5336  \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax\else
5337    \escapeisbackslash
5338  \fi
5339  %
5340  % For texindex which always views { and } as separators.
5341  \def\{{\lbracechar{}}%
5342  \def\}{\rbracechar{}}%
5343  \uccode`\~=`\\ \uppercase{\def~{\backslashchar{}}}%
5344  %
5345  % Split the entry into primary entry and any subentries, and get the index
5346  % sort key.
5347  \splitindexentry\indextext
5348  %
5349  % Set up the complete index entry, with both the sort key and
5350  % the original text, including any font commands.  We write
5351  % three arguments to \entry to the .?? file (four in the
5352  % subentry case), texindex reduces to two when writing the .??s
5353  % sorted result.
5354  %
5355  \edef\temp{%
5356    \write\writeto{%
5357      \string\entry{\fullindexsortkey}%
5358        {\ifx\pagenumbertext\empty\noexpand\folio\else\pagenumbertext\fi}%
5359        \bracedtext}%
5360  }%
5361  \temp
5362}
5363
5364% Put the index entry in the margin if desired (undocumented).
5365\def\maybemarginindex{%
5366  \ifx\SETmarginindex\relax\else
5367    \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \relax\indextext}}%
5368  \fi
5369}
5370\let\SETmarginindex=\relax
5371
5372
5373% Take care of unwanted page breaks/skips around a whatsit:
5374%
5375% If a skip is the last thing on the list now, preserve it
5376% by backing up by \lastskip, doing the \write, then inserting
5377% the skip again.  Otherwise, the whatsit generated by the
5378% \write or \pdfdest will make \lastskip zero.  The result is that
5379% sequences like this:
5380% @end defun
5381% @tindex whatever
5382% @defun ...
5383% will have extra space inserted, because the \medbreak in the
5384% start of the @defun won't see the skip inserted by the @end of
5385% the previous defun.
5386%
5387% But don't do any of this if we're not in vertical mode.  We
5388% don't want to do a \vskip and prematurely end a paragraph.
5389%
5390% Avoid page breaks due to these extra skips, too.
5391%
5392% But wait, there is a catch there:
5393% We'll have to check whether \lastskip is zero skip.  \ifdim is not
5394% sufficient for this purpose, as it ignores stretch and shrink parts
5395% of the skip.  The only way seems to be to check the textual
5396% representation of the skip.
5397%
5398% The following is almost like \def\zeroskipmacro{0.0pt} except that
5399% the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
5400%
5401\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
5402%
5403\newskip\whatsitskip
5404\newcount\whatsitpenalty
5405%
5406% ..., ready, GO:
5407%
5408\def\safewhatsit#1{\ifhmode
5409  #1%
5410 \else
5411  % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
5412  \whatsitskip = \lastskip
5413  \edef\lastskipmacro{\the\lastskip}%
5414  \whatsitpenalty = \lastpenalty
5415  %
5416  % If \lastskip is nonzero, that means the last item was a
5417  % skip.  And since a skip is discardable, that means this
5418  % -\whatsitskip glue we're inserting is preceded by a
5419  % non-discardable item, therefore it is not a potential
5420  % breakpoint, therefore no \nobreak needed.
5421  \ifx\lastskipmacro\zeroskipmacro
5422  \else
5423    \vskip-\whatsitskip
5424  \fi
5425  %
5426  #1%
5427  %
5428  \ifx\lastskipmacro\zeroskipmacro
5429    % If \lastskip was zero, perhaps the last item was a penalty, and
5430    % perhaps it was >=10000, e.g., a \nobreak.  In that case, we want
5431    % to re-insert the same penalty (values >10000 are used for various
5432    % signals); since we just inserted a non-discardable item, any
5433    % following glue (such as a \parskip) would be a breakpoint.  For example:
5434    %   @deffn deffn-whatever
5435    %   @vindex index-whatever
5436    %   Description.
5437    % would allow a break between the index-whatever whatsit
5438    % and the "Description." paragraph.
5439    \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
5440  \else
5441    % On the other hand, if we had a nonzero \lastskip,
5442    % this make-up glue would be preceded by a non-discardable item
5443    % (the whatsit from the \write), so we must insert a \nobreak.
5444    \nobreak\vskip\whatsitskip
5445  \fi
5446\fi}
5447
5448% The index entry written in the file actually looks like
5449%  \entry {sortstring}{page}{topic}
5450% or
5451%  \entry {sortstring}{page}{topic}{subtopic}
5452% The texindex program reads in these files and writes files
5453% containing these kinds of lines:
5454%  \initial {c}
5455%     before the first topic whose initial is c
5456%  \entry {topic}{pagelist}
5457%     for a topic that is used without subtopics
5458%  \primary {topic}
5459%  \entry {topic}{}
5460%     for the beginning of a topic that is used with subtopics
5461%  \secondary {subtopic}{pagelist}
5462%     for each subtopic.
5463%  \secondary {subtopic}{}
5464%     for a subtopic with sub-subtopics
5465%  \tertiary {subtopic}{subsubtopic}{pagelist}
5466%     for each sub-subtopic.
5467
5468% Define the user-accessible indexing commands
5469% @findex, @vindex, @kindex, @cindex.
5470
5471\def\findex {\fnindex}
5472\def\kindex {\kyindex}
5473\def\cindex {\cpindex}
5474\def\vindex {\vrindex}
5475\def\tindex {\tpindex}
5476\def\pindex {\pgindex}
5477
5478% Define the macros used in formatting output of the sorted index material.
5479
5480% @printindex causes a particular index (the ??s file) to get printed.
5481% It does not print any chapter heading (usually an @unnumbered).
5482%
5483\parseargdef\printindex{\begingroup
5484  \dobreak \chapheadingskip{10000}%
5485  %
5486  \smallfonts \rm
5487  \tolerance = 9500
5488  \plainfrenchspacing
5489  \everypar = {}% don't want the \kern\-parindent from indentation suppression.
5490  %
5491  % See comment in \requireopenindexfile.
5492  \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
5493  %
5494  % See if the index file exists and is nonempty.
5495  \openin 1 \jobname.\indexname s
5496  \ifeof 1
5497    % \enddoublecolumns gets confused if there is no text in the index,
5498    % and it loses the chapter title and the aux file entries for the
5499    % index.  The easiest way to prevent this problem is to make sure
5500    % there is some text.
5501    \putwordIndexNonexistent
5502    \typeout{No file \jobname.\indexname s.}%
5503  \else
5504    % If the index file exists but is empty, then \openin leaves \ifeof
5505    % false.  We have to make TeX try to read something from the file, so
5506    % it can discover if there is anything in it.
5507    \read 1 to \thisline
5508    \ifeof 1
5509      \putwordIndexIsEmpty
5510    \else
5511      \expandafter\printindexzz\thisline\relax\relax\finish%
5512    \fi
5513  \fi
5514  \closein 1
5515\endgroup}
5516
5517% If the index file starts with a backslash, forgo reading the index
5518% file altogether.  If somebody upgrades texinfo.tex they may still have
5519% old index files using \ as the escape character.  Reading this would
5520% at best lead to typesetting garbage, at worst a TeX syntax error.
5521\def\printindexzz#1#2\finish{%
5522  \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax
5523    \uccode`\~=`\\ \uppercase{\if\noexpand~}\noexpand#1
5524      \expandafter\ifx\csname SETtxiskipindexfileswithbackslash\endcsname\relax
5525\errmessage{%
5526ERROR: A sorted index file in an obsolete format was skipped.
5527To fix this problem, please upgrade your version of 'texi2dvi'
5528or 'texi2pdf' to that at <https://ftp.gnu.org/gnu/texinfo>.
5529If you are using an old version of 'texindex' (part of the Texinfo
5530distribution), you may also need to upgrade to a newer version (at least 6.0).
5531You may be able to typeset the index if you run
5532'texindex \jobname.\indexname' yourself.
5533You could also try setting the 'txiindexescapeisbackslash' flag by
5534running a command like
5535'texi2dvi -t "@set txiindexescapeisbackslash" \jobname.texi'.  If you do
5536this, Texinfo will try to use index files in the old format.
5537If you continue to have problems, deleting the index files and starting again
5538might help (with 'rm \jobname.?? \jobname.??s')%
5539}%
5540      \else
5541        (Skipped sorted index file in obsolete format)
5542      \fi
5543    \else
5544      \begindoublecolumns
5545      \input \jobname.\indexname s
5546      \enddoublecolumns
5547    \fi
5548  \else
5549    \begindoublecolumns
5550    \catcode`\\=0\relax
5551    \catcode`\@=12\relax
5552    \input \jobname.\indexname s
5553    \enddoublecolumns
5554  \fi
5555}
5556
5557% These macros are used by the sorted index file itself.
5558% Change them to control the appearance of the index.
5559
5560{\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
5561\catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
5562\catcode`\$=3
5563\gdef\initialglyphs{%
5564  % special control sequences used in the index sort key
5565  \let\indexlbrace\{%
5566  \let\indexrbrace\}%
5567  \let\indexatchar\@%
5568  \def\indexbackslash{\math{\backslash}}%
5569  %
5570  % Some changes for non-alphabetic characters.  Using the glyphs from the
5571  % math fonts looks more consistent than the typewriter font used elsewhere
5572  % for these characters.
5573  \uccode`\~=`\\ \uppercase{\def~{\math{\backslash}}}
5574  %
5575  % In case @\ is used for backslash
5576  \uppercase{\let\\=~}
5577  % Can't get bold backslash so don't use bold forward slash
5578  \catcode`\/=13
5579  \def/{{\secrmnotbold \normalslash}}%
5580  \def-{{\normaldash\normaldash}}% en dash `--'
5581  \def^{{\chapbf \normalcaret}}%
5582  \def~{{\chapbf \normaltilde}}%
5583  \def\_{%
5584     \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
5585  \def|{$\vert$}%
5586  \def<{$\less$}%
5587  \def>{$\gtr$}%
5588  \def+{$\normalplus$}%
5589}}
5590
5591\def\initial{%
5592  \bgroup
5593  \initialglyphs
5594  \initialx
5595}
5596
5597\def\initialx#1{%
5598  % Remove any glue we may have, we'll be inserting our own.
5599  \removelastskip
5600  %
5601  % We like breaks before the index initials, so insert a bonus.
5602  % The glue before the bonus allows a little bit of space at the
5603  % bottom of a column to reduce an increase in inter-line spacing.
5604  \nobreak
5605  \vskip 0pt plus 5\baselineskip
5606  \penalty -300
5607  \vskip 0pt plus -5\baselineskip
5608  %
5609  % Typeset the initial.  Making this add up to a whole number of
5610  % baselineskips increases the chance of the dots lining up from column
5611  % to column.  It still won't often be perfect, because of the stretch
5612  % we need before each entry, but it's better.
5613  %
5614  % No shrink because it confuses \balancecolumns.
5615  \vskip 1.67\baselineskip plus 1\baselineskip
5616  \leftline{\secfonts \kern-0.05em \secbf #1}%
5617  % \secfonts is inside the argument of \leftline so that the change of
5618  % \baselineskip will not affect any glue inserted before the vbox that
5619  % \leftline creates.
5620  % Do our best not to break after the initial.
5621  \nobreak
5622  \vskip .33\baselineskip plus .1\baselineskip
5623  \egroup % \initialglyphs
5624}
5625
5626\newdimen\entryrightmargin
5627\entryrightmargin=0pt
5628
5629% \entry typesets a paragraph consisting of the text (#1), dot leaders, and
5630% then page number (#2) flushed to the right margin.  It is used for index
5631% and table of contents entries.  The paragraph is indented by \leftskip.
5632%
5633\def\entry{%
5634  \begingroup
5635    %
5636    % Start a new paragraph if necessary, so our assignments below can't
5637    % affect previous text.
5638    \par
5639    %
5640    % No extra space above this paragraph.
5641    \parskip = 0in
5642    %
5643    % When reading the text of entry, convert explicit line breaks
5644    % from @* into spaces.  The user might give these in long section
5645    % titles, for instance.
5646    \def\*{\unskip\space\ignorespaces}%
5647    \def\entrybreak{\hfil\break}% An undocumented command
5648    %
5649    % Swallow the left brace of the text (first parameter):
5650    \afterassignment\doentry
5651    \let\temp =
5652}
5653\def\entrybreak{\unskip\space\ignorespaces}%
5654\def\doentry{%
5655    % Save the text of the entry
5656    \global\setbox\boxA=\hbox\bgroup
5657    \bgroup % Instead of the swallowed brace.
5658      \noindent
5659      \aftergroup\finishentry
5660      % And now comes the text of the entry.
5661      % Not absorbing as a macro argument reduces the chance of problems
5662      % with catcodes occurring.
5663}
5664{\catcode`\@=11
5665\gdef\finishentry#1{%
5666    \egroup % end box A
5667    \dimen@ = \wd\boxA % Length of text of entry
5668    \global\setbox\boxA=\hbox\bgroup
5669      \unhbox\boxA
5670      % #1 is the page number.
5671      %
5672      % Get the width of the page numbers, and only use
5673      % leaders if they are present.
5674      \global\setbox\boxB = \hbox{#1}%
5675      \ifdim\wd\boxB = 0pt
5676        \null\nobreak\hfill\ %
5677      \else
5678        %
5679        \null\nobreak\indexdotfill % Have leaders before the page number.
5680        %
5681        \ifpdforxetex
5682          \pdfgettoks#1.%
5683          \hskip\skip\thinshrinkable\the\toksA
5684        \else
5685          \hskip\skip\thinshrinkable #1%
5686        \fi
5687      \fi
5688    \egroup % end \boxA
5689    \ifdim\wd\boxB = 0pt
5690      \noindent\unhbox\boxA\par
5691      \nobreak
5692    \else\bgroup
5693      % We want the text of the entries to be aligned to the left, and the
5694      % page numbers to be aligned to the right.
5695      %
5696      \parindent = 0pt
5697      \advance\leftskip by 0pt plus 1fil
5698      \advance\leftskip by 0pt plus -1fill
5699      \rightskip = 0pt plus -1fil
5700      \advance\rightskip by 0pt plus 1fill
5701      % Cause last line, which could consist of page numbers on their own
5702      % if the list of page numbers is long, to be aligned to the right.
5703      \parfillskip=0pt plus -1fill
5704      %
5705      \advance\rightskip by \entryrightmargin
5706      % Determine how far we can stretch into the margin.
5707      % This allows, e.g., "Appendix H  GNU Free Documentation License" to
5708      % fit on one line in @letterpaper format.
5709      \ifdim\entryrightmargin>2.1em
5710        \dimen@i=2.1em
5711      \else
5712        \dimen@i=0em
5713      \fi
5714      \advance \parfillskip by 0pt minus 1\dimen@i
5715      %
5716      \dimen@ii = \hsize
5717      \advance\dimen@ii by -1\leftskip
5718      \advance\dimen@ii by -1\entryrightmargin
5719      \advance\dimen@ii by 1\dimen@i
5720      \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
5721      \ifdim\dimen@ > 0.8\dimen@ii   % due to long index text
5722        % Try to split the text roughly evenly.  \dimen@ will be the length of
5723        % the first line.
5724        \dimen@ = 0.7\dimen@
5725        \dimen@ii = \hsize
5726        \ifnum\dimen@>\dimen@ii
5727          % If the entry is too long (for example, if it needs more than
5728          % two lines), use all the space in the first line.
5729          \dimen@ = \dimen@ii
5730        \fi
5731        \advance\leftskip by 0pt plus 1fill % ragged right
5732        \advance \dimen@ by 1\rightskip
5733        \parshape = 2 0pt \dimen@ 0em \dimen@ii
5734        % Ideally we'd add a finite glue at the end of the first line only,
5735        % instead of using \parshape with explicit line lengths, but TeX
5736        % doesn't seem to provide a way to do such a thing.
5737        %
5738        % Indent all lines but the first one.
5739        \advance\leftskip by 1em
5740        \advance\parindent by -1em
5741      \fi\fi
5742      \indent % start paragraph
5743      \unhbox\boxA
5744      %
5745      % Do not prefer a separate line ending with a hyphen to fewer lines.
5746      \finalhyphendemerits = 0
5747      %
5748      % Word spacing - no stretch
5749      \spaceskip=\fontdimen2\font minus \fontdimen4\font
5750      %
5751      \linepenalty=1000  % Discourage line breaks.
5752      \hyphenpenalty=5000  % Discourage hyphenation.
5753      %
5754      \par % format the paragraph
5755    \egroup % The \vbox
5756    \fi
5757  \endgroup
5758}}
5759
5760\newskip\thinshrinkable
5761\skip\thinshrinkable=.15em minus .15em
5762
5763% Like plain.tex's \dotfill, except uses up at least 1 em.
5764% The filll stretch here overpowers both the fil and fill stretch to push
5765% the page number to the right.
5766\def\indexdotfill{\cleaders
5767  \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
5768
5769
5770\def\primary #1{\line{#1\hfil}}
5771
5772\def\secondary{\indententry{0.5cm}}
5773\def\tertiary{\indententry{1cm}}
5774
5775\def\indententry#1#2#3{%
5776  \bgroup
5777  \leftskip=#1
5778  \entry{#2}{#3}%
5779  \egroup
5780}
5781
5782% Define two-column mode, which we use to typeset indexes.
5783% Adapted from the TeXbook, page 416, which is to say,
5784% the manmac.tex format used to print the TeXbook itself.
5785\catcode`\@=11  % private names
5786
5787\newbox\partialpage
5788\newdimen\doublecolumnhsize
5789
5790\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
5791  % If not much space left on page, start a new page.
5792  \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
5793  %
5794  % Grab any single-column material above us.
5795  \output = {%
5796    \savetopmark
5797    %
5798    \global\setbox\partialpage = \vbox{%
5799      % Unvbox the main output page.
5800      \unvbox\PAGE
5801      \kern-\topskip \kern\baselineskip
5802    }%
5803  }%
5804  \eject % run that output routine to set \partialpage
5805  %
5806  % Use the double-column output routine for subsequent pages.
5807  \output = {\doublecolumnout}%
5808  %
5809  % Change the page size parameters.  We could do this once outside this
5810  % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5811  % format, but then we repeat the same computation.  Repeating a couple
5812  % of assignments once per index is clearly meaningless for the
5813  % execution time, so we may as well do it in one place.
5814  %
5815  % First we halve the line length, less a little for the gutter between
5816  % the columns.  We compute the gutter based on the line length, so it
5817  % changes automatically with the paper format.  The magic constant
5818  % below is chosen so that the gutter has the same value (well, +-<1pt)
5819  % as it did when we hard-coded it.
5820  %
5821  % We put the result in a separate register, \doublecolumhsize, so we
5822  % can restore it in \pagesofar, after \hsize itself has (potentially)
5823  % been clobbered.
5824  %
5825  \doublecolumnhsize = \hsize
5826    \advance\doublecolumnhsize by -.04154\hsize
5827    \divide\doublecolumnhsize by 2
5828  \hsize = \doublecolumnhsize
5829  %
5830  % Get the available space for the double columns -- the normal
5831  % (undoubled) page height minus any material left over from the
5832  % previous page.
5833  \advance\vsize by -\ht\partialpage
5834  \vsize = 2\vsize
5835  %
5836  % For the benefit of balancing columns
5837  \advance\baselineskip by 0pt plus 0.5pt
5838}
5839
5840% The double-column output routine for all double-column pages except
5841% the last, which is done by \balancecolumns.
5842%
5843\def\doublecolumnout{%
5844  %
5845  \savetopmark
5846  \splittopskip=\topskip \splitmaxdepth=\maxdepth
5847  \dimen@ = \vsize
5848  \divide\dimen@ by 2
5849  %
5850  % box0 will be the left-hand column, box2 the right.
5851  \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@
5852  \global\advance\vsize by 2\ht\partialpage
5853  \onepageout\pagesofar % empty except for the first time we are called
5854  \unvbox\PAGE
5855  \penalty\outputpenalty
5856}
5857%
5858% Re-output the contents of the output page -- any previous material,
5859% followed by the two boxes we just split, in box0 and box2.
5860\def\pagesofar{%
5861  \unvbox\partialpage
5862  %
5863  \hsize = \doublecolumnhsize
5864  \wd0=\hsize \wd2=\hsize
5865  \hbox to\txipagewidth{\box0\hfil\box2}%
5866}
5867
5868
5869% Finished with double columns.
5870\def\enddoublecolumns{%
5871  % The following penalty ensures that the page builder is exercised
5872  % _before_ we change the output routine.  This is necessary in the
5873  % following situation:
5874  %
5875  % The last section of the index consists only of a single entry.
5876  % Before this section, \pagetotal is less than \pagegoal, so no
5877  % break occurs before the last section starts.  However, the last
5878  % section, consisting of \initial and the single \entry, does not
5879  % fit on the page and has to be broken off.  Without the following
5880  % penalty the page builder will not be exercised until \eject
5881  % below, and by that time we'll already have changed the output
5882  % routine to the \balancecolumns version, so the next-to-last
5883  % double-column page will be processed with \balancecolumns, which
5884  % is wrong:  The two columns will go to the main vertical list, with
5885  % the broken-off section in the recent contributions.  As soon as
5886  % the output routine finishes, TeX starts reconsidering the page
5887  % break.  The two columns and the broken-off section both fit on the
5888  % page, because the two columns now take up only half of the page
5889  % goal.  When TeX sees \eject from below which follows the final
5890  % section, it invokes the new output routine that we've set after
5891  % \balancecolumns below; \onepageout will try to fit the two columns
5892  % and the final section into the vbox of \txipageheight (see
5893  % \pagebody), causing an overfull box.
5894  %
5895  % Note that glue won't work here, because glue does not exercise the
5896  % page builder, unlike penalties (see The TeXbook, pp. 280-281).
5897  \penalty0
5898  %
5899  \output = {%
5900    % Split the last of the double-column material.
5901    \savetopmark
5902    \balancecolumns
5903  }%
5904  \eject % call the \output just set
5905  \ifdim\pagetotal=0pt
5906    % Having called \balancecolumns once, we do not
5907    % want to call it again.  Therefore, reset \output to its normal
5908    % definition right away.
5909    \global\output=\expandafter{\the\defaultoutput}
5910    %
5911    \endgroup % started in \begindoublecolumns
5912    % Leave the double-column material on the current page, no automatic
5913    % page break.
5914    \box\balancedcolumns
5915    %
5916    % \pagegoal was set to the doubled \vsize above, since we restarted
5917    % the current page.  We're now back to normal single-column
5918    % typesetting, so reset \pagegoal to the normal \vsize.
5919    \global\vsize = \txipageheight %
5920    \pagegoal = \txipageheight %
5921  \else
5922    % We had some left-over material.  This might happen when \doublecolumnout
5923    % is called in \balancecolumns.  Try again.
5924    \expandafter\enddoublecolumns
5925  \fi
5926}
5927\newbox\balancedcolumns
5928\setbox\balancedcolumns=\vbox{shouldnt see this}%
5929%
5930% Only called for the last of the double column material.  \doublecolumnout
5931% does the others.
5932\def\balancecolumns{%
5933  \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120.
5934  \dimen@ = \ht0
5935  \ifdim\dimen@<7\baselineskip
5936    % Don't split a short final column in two.
5937    \setbox2=\vbox{}%
5938    \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5939  \else
5940    % double the leading vertical space
5941    \advance\dimen@ by \topskip
5942    \advance\dimen@ by-\baselineskip
5943    \divide\dimen@ by 2 % target to split to
5944    \dimen@ii = \dimen@
5945    \splittopskip = \topskip
5946    % Loop until left column is at least as high as the right column.
5947    {%
5948      \vbadness = 10000
5949      \loop
5950        \global\setbox3 = \copy0
5951        \global\setbox1 = \vsplit3 to \dimen@
5952      \ifdim\ht1<\ht3
5953        \global\advance\dimen@ by 1pt
5954      \repeat
5955    }%
5956    % Now the left column is in box 1, and the right column in box 3.
5957    %
5958    % Check whether the left column has come out higher than the page itself.
5959    % (Note that we have doubled \vsize for the double columns, so
5960    % the actual height of the page is 0.5\vsize).
5961    \ifdim2\ht1>\vsize
5962      % It appears that we have been called upon to balance too much material.
5963      % Output some of it with \doublecolumnout, leaving the rest on the page.
5964      \setbox\PAGE=\box0
5965      \doublecolumnout
5966    \else
5967      % Compare the heights of the two columns.
5968      \ifdim4\ht1>5\ht3
5969        % Column heights are too different, so don't make their bottoms
5970        % flush with each other.
5971        \setbox2=\vbox to \ht1 {\unvbox3\vfill}%
5972        \setbox0=\vbox to \ht1 {\unvbox1\vfill}%
5973      \else
5974        % Make column bottoms flush with each other.
5975        \setbox2=\vbox to\ht1{\unvbox3\unskip}%
5976        \setbox0=\vbox to\ht1{\unvbox1\unskip}%
5977      \fi
5978      \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5979    \fi
5980  \fi
5981  %
5982}
5983\catcode`\@ = \other
5984
5985
5986\message{sectioning,}
5987% Chapters, sections, etc.
5988
5989% Let's start with @part.
5990\outer\parseargdef\part{\partzzz{#1}}
5991\def\partzzz#1{%
5992  \chapoddpage
5993  \null
5994  \vskip.3\vsize  % move it down on the page a bit
5995  \begingroup
5996    \noindent \titlefonts\rm #1\par % the text
5997    \let\lastnode=\empty      % no node to associate with
5998    \writetocentry{part}{#1}{}% but put it in the toc
5999    \headingsoff              % no headline or footline on the part page
6000    % This outputs a mark at the end of the page that clears \thischapter
6001    % and \thissection, as is done in \startcontents.
6002    \let\pchapsepmacro\relax
6003    \chapmacro{}{Yomitfromtoc}{}%
6004    \chapoddpage
6005  \endgroup
6006}
6007
6008% \unnumberedno is an oxymoron.  But we count the unnumbered
6009% sections so that we can refer to them unambiguously in the pdf
6010% outlines by their "section number".  We avoid collisions with chapter
6011% numbers by starting them at 10000.  (If a document ever has 10000
6012% chapters, we're in trouble anyway, I'm sure.)
6013\newcount\unnumberedno \unnumberedno = 10000
6014\newcount\chapno
6015\newcount\secno        \secno=0
6016\newcount\subsecno     \subsecno=0
6017\newcount\subsubsecno  \subsubsecno=0
6018
6019% This counter is funny since it counts through charcodes of letters A, B, ...
6020\newcount\appendixno  \appendixno = `\@
6021%
6022% \def\appendixletter{\char\the\appendixno}
6023% We do the following ugly conditional instead of the above simple
6024% construct for the sake of pdftex, which needs the actual
6025% letter in the expansion, not just typeset.
6026%
6027\def\appendixletter{%
6028  \ifnum\appendixno=`A A%
6029  \else\ifnum\appendixno=`B B%
6030  \else\ifnum\appendixno=`C C%
6031  \else\ifnum\appendixno=`D D%
6032  \else\ifnum\appendixno=`E E%
6033  \else\ifnum\appendixno=`F F%
6034  \else\ifnum\appendixno=`G G%
6035  \else\ifnum\appendixno=`H H%
6036  \else\ifnum\appendixno=`I I%
6037  \else\ifnum\appendixno=`J J%
6038  \else\ifnum\appendixno=`K K%
6039  \else\ifnum\appendixno=`L L%
6040  \else\ifnum\appendixno=`M M%
6041  \else\ifnum\appendixno=`N N%
6042  \else\ifnum\appendixno=`O O%
6043  \else\ifnum\appendixno=`P P%
6044  \else\ifnum\appendixno=`Q Q%
6045  \else\ifnum\appendixno=`R R%
6046  \else\ifnum\appendixno=`S S%
6047  \else\ifnum\appendixno=`T T%
6048  \else\ifnum\appendixno=`U U%
6049  \else\ifnum\appendixno=`V V%
6050  \else\ifnum\appendixno=`W W%
6051  \else\ifnum\appendixno=`X X%
6052  \else\ifnum\appendixno=`Y Y%
6053  \else\ifnum\appendixno=`Z Z%
6054  % The \the is necessary, despite appearances, because \appendixletter is
6055  % expanded while writing the .toc file.  \char\appendixno is not
6056  % expandable, thus it is written literally, thus all appendixes come out
6057  % with the same letter (or @) in the toc without it.
6058  \else\char\the\appendixno
6059  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
6060  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
6061
6062% Each @chapter defines these (using marks) as the number+name, number
6063% and name of the chapter.  Page headings and footings can use
6064% these.  @section does likewise.
6065\def\thischapter{}
6066\def\thischapternum{}
6067\def\thischaptername{}
6068\def\thissection{}
6069\def\thissectionnum{}
6070\def\thissectionname{}
6071
6072\newcount\absseclevel % used to calculate proper heading level
6073\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
6074
6075% @raisesections: treat @section as chapter, @subsection as section, etc.
6076\def\raisesections{\global\advance\secbase by -1}
6077
6078% @lowersections: treat @chapter as section, @section as subsection, etc.
6079\def\lowersections{\global\advance\secbase by 1}
6080
6081% we only have subsub.
6082\chardef\maxseclevel = 3
6083%
6084% A numbered section within an unnumbered changes to unnumbered too.
6085% To achieve this, remember the "biggest" unnum. sec. we are currently in:
6086\chardef\unnlevel = \maxseclevel
6087%
6088% Trace whether the current chapter is an appendix or not:
6089% \chapheadtype is "N" or "A", unnumbered chapters are ignored.
6090\def\chapheadtype{N}
6091
6092% Choose a heading macro
6093% #1 is heading type
6094% #2 is heading level
6095% #3 is text for heading
6096\def\genhead#1#2#3{%
6097  % Compute the abs. sec. level:
6098  \absseclevel=#2
6099  \advance\absseclevel by \secbase
6100  % Make sure \absseclevel doesn't fall outside the range:
6101  \ifnum \absseclevel < 0
6102    \absseclevel = 0
6103  \else
6104    \ifnum \absseclevel > 3
6105      \absseclevel = 3
6106    \fi
6107  \fi
6108  % The heading type:
6109  \def\headtype{#1}%
6110  \if \headtype U%
6111    \ifnum \absseclevel < \unnlevel
6112      \chardef\unnlevel = \absseclevel
6113    \fi
6114  \else
6115    % Check for appendix sections:
6116    \ifnum \absseclevel = 0
6117      \edef\chapheadtype{\headtype}%
6118    \else
6119      \if \headtype A\if \chapheadtype N%
6120	\errmessage{@appendix... within a non-appendix chapter}%
6121      \fi\fi
6122    \fi
6123    % Check for numbered within unnumbered:
6124    \ifnum \absseclevel > \unnlevel
6125      \def\headtype{U}%
6126    \else
6127      \chardef\unnlevel = 3
6128    \fi
6129  \fi
6130  % Now print the heading:
6131  \if \headtype U%
6132    \ifcase\absseclevel
6133	\unnumberedzzz{#3}%
6134    \or \unnumberedseczzz{#3}%
6135    \or \unnumberedsubseczzz{#3}%
6136    \or \unnumberedsubsubseczzz{#3}%
6137    \fi
6138  \else
6139    \if \headtype A%
6140      \ifcase\absseclevel
6141	  \appendixzzz{#3}%
6142      \or \appendixsectionzzz{#3}%
6143      \or \appendixsubseczzz{#3}%
6144      \or \appendixsubsubseczzz{#3}%
6145      \fi
6146    \else
6147      \ifcase\absseclevel
6148	  \chapterzzz{#3}%
6149      \or \seczzz{#3}%
6150      \or \numberedsubseczzz{#3}%
6151      \or \numberedsubsubseczzz{#3}%
6152      \fi
6153    \fi
6154  \fi
6155  \suppressfirstparagraphindent
6156}
6157
6158% an interface:
6159\def\numhead{\genhead N}
6160\def\apphead{\genhead A}
6161\def\unnmhead{\genhead U}
6162
6163% @chapter, @appendix, @unnumbered.  Increment top-level counter, reset
6164% all lower-level sectioning counters to zero.
6165%
6166% Also set \chaplevelprefix, which we prepend to @float sequence numbers
6167% (e.g., figures), q.v.  By default (before any chapter), that is empty.
6168\let\chaplevelprefix = \empty
6169%
6170\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
6171\def\chapterzzz#1{%
6172  % section resetting is \global in case the chapter is in a group, such
6173  % as an @include file.
6174  \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6175    \global\advance\chapno by 1
6176  %
6177  % Used for \float.
6178  \gdef\chaplevelprefix{\the\chapno.}%
6179  \resetallfloatnos
6180  %
6181  % \putwordChapter can contain complex things in translations.
6182  \toks0=\expandafter{\putwordChapter}%
6183  \message{\the\toks0 \space \the\chapno}%
6184  %
6185  % Write the actual heading.
6186  \chapmacro{#1}{Ynumbered}{\the\chapno}%
6187  %
6188  % So @section and the like are numbered underneath this chapter.
6189  \global\let\section = \numberedsec
6190  \global\let\subsection = \numberedsubsec
6191  \global\let\subsubsection = \numberedsubsubsec
6192}
6193
6194\outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
6195%
6196\def\appendixzzz#1{%
6197  \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6198    \global\advance\appendixno by 1
6199  \gdef\chaplevelprefix{\appendixletter.}%
6200  \resetallfloatnos
6201  %
6202  % \putwordAppendix can contain complex things in translations.
6203  \toks0=\expandafter{\putwordAppendix}%
6204  \message{\the\toks0 \space \appendixletter}%
6205  %
6206  \chapmacro{#1}{Yappendix}{\appendixletter}%
6207  %
6208  \global\let\section = \appendixsec
6209  \global\let\subsection = \appendixsubsec
6210  \global\let\subsubsection = \appendixsubsubsec
6211}
6212
6213% normally unnmhead0 calls unnumberedzzz:
6214\outer\parseargdef\unnumbered{\unnmhead0{#1}}
6215\def\unnumberedzzz#1{%
6216  \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6217    \global\advance\unnumberedno by 1
6218  %
6219  % Since an unnumbered has no number, no prefix for figures.
6220  \global\let\chaplevelprefix = \empty
6221  \resetallfloatnos
6222  %
6223  % This used to be simply \message{#1}, but TeX fully expands the
6224  % argument to \message.  Therefore, if #1 contained @-commands, TeX
6225  % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
6226  % expanded @cite (which turns out to cause errors because \cite is meant
6227  % to be executed, not expanded).
6228  %
6229  % Anyway, we don't want the fully-expanded definition of @cite to appear
6230  % as a result of the \message, we just want `@cite' itself.  We use
6231  % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6232  % simply yielding the contents of <toks register>.  (We also do this for
6233  % the toc entries.)
6234  \toks0 = {#1}%
6235  \message{(\the\toks0)}%
6236  %
6237  \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
6238  %
6239  \global\let\section = \unnumberedsec
6240  \global\let\subsection = \unnumberedsubsec
6241  \global\let\subsubsection = \unnumberedsubsubsec
6242}
6243
6244% @centerchap is like @unnumbered, but the heading is centered.
6245\outer\parseargdef\centerchap{%
6246  \let\centerparametersmaybe = \centerparameters
6247  \unnmhead0{#1}%
6248  \let\centerparametersmaybe = \relax
6249}
6250
6251% @top is like @unnumbered.
6252\let\top\unnumbered
6253
6254% Sections.
6255%
6256\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6257\def\seczzz#1{%
6258  \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6259  \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
6260}
6261
6262% normally calls appendixsectionzzz:
6263\outer\parseargdef\appendixsection{\apphead1{#1}}
6264\def\appendixsectionzzz#1{%
6265  \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6266  \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
6267}
6268\let\appendixsec\appendixsection
6269
6270% normally calls unnumberedseczzz:
6271\outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
6272\def\unnumberedseczzz#1{%
6273  \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6274  \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
6275}
6276
6277% Subsections.
6278%
6279% normally calls numberedsubseczzz:
6280\outer\parseargdef\numberedsubsec{\numhead2{#1}}
6281\def\numberedsubseczzz#1{%
6282  \global\subsubsecno=0  \global\advance\subsecno by 1
6283  \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
6284}
6285
6286% normally calls appendixsubseczzz:
6287\outer\parseargdef\appendixsubsec{\apphead2{#1}}
6288\def\appendixsubseczzz#1{%
6289  \global\subsubsecno=0  \global\advance\subsecno by 1
6290  \sectionheading{#1}{subsec}{Yappendix}%
6291                 {\appendixletter.\the\secno.\the\subsecno}%
6292}
6293
6294% normally calls unnumberedsubseczzz:
6295\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
6296\def\unnumberedsubseczzz#1{%
6297  \global\subsubsecno=0  \global\advance\subsecno by 1
6298  \sectionheading{#1}{subsec}{Ynothing}%
6299                 {\the\unnumberedno.\the\secno.\the\subsecno}%
6300}
6301
6302% Subsubsections.
6303%
6304% normally numberedsubsubseczzz:
6305\outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
6306\def\numberedsubsubseczzz#1{%
6307  \global\advance\subsubsecno by 1
6308  \sectionheading{#1}{subsubsec}{Ynumbered}%
6309                 {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
6310}
6311
6312% normally appendixsubsubseczzz:
6313\outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
6314\def\appendixsubsubseczzz#1{%
6315  \global\advance\subsubsecno by 1
6316  \sectionheading{#1}{subsubsec}{Yappendix}%
6317                 {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
6318}
6319
6320% normally unnumberedsubsubseczzz:
6321\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
6322\def\unnumberedsubsubseczzz#1{%
6323  \global\advance\subsubsecno by 1
6324  \sectionheading{#1}{subsubsec}{Ynothing}%
6325                 {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
6326}
6327
6328% These macros control what the section commands do, according
6329% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6330% Define them by default for a numbered chapter.
6331\let\section = \numberedsec
6332\let\subsection = \numberedsubsec
6333\let\subsubsection = \numberedsubsubsec
6334
6335% Define @majorheading, @heading and @subheading
6336
6337\def\majorheading{%
6338  {\advance\chapheadingskip by 10pt \chapbreak }%
6339  \parsearg\chapheadingzzz
6340}
6341
6342\def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6343\def\chapheadingzzz#1{%
6344  \vbox{\chapfonts \raggedtitlesettings #1\par}%
6345  \nobreak\bigskip \nobreak
6346  \suppressfirstparagraphindent
6347}
6348
6349% @heading, @subheading, @subsubheading.
6350\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6351  \suppressfirstparagraphindent}
6352\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6353  \suppressfirstparagraphindent}
6354\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6355  \suppressfirstparagraphindent}
6356
6357% These macros generate a chapter, section, etc. heading only
6358% (including whitespace, linebreaking, etc. around it),
6359% given all the information in convenient, parsed form.
6360
6361% Args are the skip and penalty (usually negative)
6362\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6363
6364% Parameter controlling skip before chapter headings (if needed)
6365\newskip\chapheadingskip
6366
6367% Define plain chapter starts, and page on/off switching for it.
6368\def\chapbreak{\dobreak \chapheadingskip {-4000}}
6369
6370% Start a new page
6371\def\chappager{\par\vfill\supereject}
6372
6373% \chapoddpage - start on an odd page for a new chapter
6374% Because \domark is called before \chapoddpage, the filler page will
6375% get the headings for the next chapter, which is wrong.  But we don't
6376% care -- we just disable all headings on the filler page.
6377\def\chapoddpage{%
6378  \chappager
6379  \ifodd\pageno \else
6380    \begingroup
6381      \headingsoff
6382      \null
6383      \chappager
6384    \endgroup
6385  \fi
6386}
6387
6388\parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
6389
6390\def\CHAPPAGoff{%
6391\global\let\contentsalignmacro = \chappager
6392\global\let\pchapsepmacro=\chapbreak
6393\global\let\pagealignmacro=\chappager}
6394
6395\def\CHAPPAGon{%
6396\global\let\contentsalignmacro = \chappager
6397\global\let\pchapsepmacro=\chappager
6398\global\let\pagealignmacro=\chappager
6399\global\def\HEADINGSon{\HEADINGSsingle}}
6400
6401\def\CHAPPAGodd{%
6402\global\let\contentsalignmacro = \chapoddpage
6403\global\let\pchapsepmacro=\chapoddpage
6404\global\let\pagealignmacro=\chapoddpage
6405\global\def\HEADINGSon{\HEADINGSdouble}}
6406
6407\CHAPPAGon
6408
6409% \chapmacro - Chapter opening.
6410%
6411% #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6412% Yappendix, Yomitfromtoc), #3 the chapter number.
6413% Not used for @heading series.
6414%
6415% To test against our argument.
6416\def\Ynothingkeyword{Ynothing}
6417\def\Yappendixkeyword{Yappendix}
6418\def\Yomitfromtockeyword{Yomitfromtoc}
6419%
6420\def\chapmacro#1#2#3{%
6421  \expandafter\ifx\thisenv\titlepage\else
6422    \checkenv{}% chapters, etc., should not start inside an environment.
6423  \fi
6424  % Insert the first mark before the heading break (see notes for \domark).
6425  \let\prevchapterdefs=\currentchapterdefs
6426  \let\prevsectiondefs=\currentsectiondefs
6427  \gdef\currentsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6428                        \gdef\thissection{}}%
6429  %
6430  \def\temptype{#2}%
6431  \ifx\temptype\Ynothingkeyword
6432    \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6433                          \gdef\thischapter{\thischaptername}}%
6434  \else\ifx\temptype\Yomitfromtockeyword
6435    \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6436                          \gdef\thischapter{}}%
6437  \else\ifx\temptype\Yappendixkeyword
6438    \toks0={#1}%
6439    \xdef\currentchapterdefs{%
6440      \gdef\noexpand\thischaptername{\the\toks0}%
6441      \gdef\noexpand\thischapternum{\appendixletter}%
6442      % \noexpand\putwordAppendix avoids expanding indigestible
6443      % commands in some of the translations.
6444      \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
6445                                 \noexpand\thischapternum:
6446                                 \noexpand\thischaptername}%
6447    }%
6448  \else
6449    \toks0={#1}%
6450    \xdef\currentchapterdefs{%
6451      \gdef\noexpand\thischaptername{\the\toks0}%
6452      \gdef\noexpand\thischapternum{\the\chapno}%
6453      % \noexpand\putwordChapter avoids expanding indigestible
6454      % commands in some of the translations.
6455      \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
6456                                 \noexpand\thischapternum:
6457                                 \noexpand\thischaptername}%
6458    }%
6459  \fi\fi\fi
6460  %
6461  % Output the mark.  Pass it through \safewhatsit, to take care of
6462  % the preceding space.
6463  \safewhatsit\domark
6464  %
6465  % Insert the chapter heading break.
6466  \pchapsepmacro
6467  %
6468  % Now the second mark, after the heading break.  No break points
6469  % between here and the heading.
6470  \let\prevchapterdefs=\currentchapterdefs
6471  \let\prevsectiondefs=\currentsectiondefs
6472  \domark
6473  %
6474  {%
6475    \chapfonts \rm
6476    \let\footnote=\errfootnoteheading % give better error message
6477    %
6478    % Have to define \currentsection before calling \donoderef, because the
6479    % xref code eventually uses it.  On the other hand, it has to be called
6480    % after \pchapsepmacro, or the headline will change too soon.
6481    \gdef\currentsection{#1}%
6482    %
6483    % Only insert the separating space if we have a chapter/appendix
6484    % number, and don't print the unnumbered ``number''.
6485    \ifx\temptype\Ynothingkeyword
6486      \setbox0 = \hbox{}%
6487      \def\toctype{unnchap}%
6488    \else\ifx\temptype\Yomitfromtockeyword
6489      \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6490      \def\toctype{omit}%
6491    \else\ifx\temptype\Yappendixkeyword
6492      \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6493      \def\toctype{app}%
6494    \else
6495      \setbox0 = \hbox{#3\enspace}%
6496      \def\toctype{numchap}%
6497    \fi\fi\fi
6498    %
6499    % Write the toc entry for this chapter.  Must come before the
6500    % \donoderef, because we include the current node name in the toc
6501    % entry, and \donoderef resets it to empty.
6502    \writetocentry{\toctype}{#1}{#3}%
6503    %
6504    % For pdftex, we have to write out the node definition (aka, make
6505    % the pdfdest) after any page break, but before the actual text has
6506    % been typeset.  If the destination for the pdf outline is after the
6507    % text, then jumping from the outline may wind up with the text not
6508    % being visible, for instance under high magnification.
6509    \donoderef{#2}%
6510    %
6511    % Typeset the actual heading.
6512    \nobreak % Avoid page breaks at the interline glue.
6513    \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
6514          \unhbox0 #1\par}%
6515  }%
6516  \nobreak\bigskip % no page break after a chapter title
6517  \nobreak
6518}
6519
6520% @centerchap -- centered and unnumbered.
6521\let\centerparametersmaybe = \relax
6522\def\centerparameters{%
6523  \advance\rightskip by 3\rightskip
6524  \leftskip = \rightskip
6525  \parfillskip = 0pt
6526}
6527
6528
6529% Section titles.  These macros combine the section number parts and
6530% call the generic \sectionheading to do the printing.
6531%
6532\newskip\secheadingskip
6533\def\secheadingbreak{\dobreak \secheadingskip{-1000}}
6534
6535% Subsection titles.
6536\newskip\subsecheadingskip
6537\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
6538
6539% Subsubsection titles.
6540\def\subsubsecheadingskip{\subsecheadingskip}
6541\def\subsubsecheadingbreak{\subsecheadingbreak}
6542
6543
6544% Print any size, any type, section title.
6545%
6546% #1 is the text of the title,
6547% #2 is the section level (sec/subsec/subsubsec),
6548% #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6549% #4 is the section number.
6550%
6551\def\seckeyword{sec}
6552%
6553\def\sectionheading#1#2#3#4{%
6554  {%
6555    \def\sectionlevel{#2}%
6556    \def\temptype{#3}%
6557    %
6558    % It is ok for the @heading series commands to appear inside an
6559    % environment (it's been historically allowed, though the logic is
6560    % dubious), but not the others.
6561    \ifx\temptype\Yomitfromtockeyword\else
6562      \checkenv{}% non-@*heading should not be in an environment.
6563    \fi
6564    \let\footnote=\errfootnoteheading
6565    %
6566    % Switch to the right set of fonts.
6567    \csname #2fonts\endcsname \rm
6568    %
6569    % Insert first mark before the heading break (see notes for \domark).
6570    \let\prevsectiondefs=\currentsectiondefs
6571    \ifx\temptype\Ynothingkeyword
6572      \ifx\sectionlevel\seckeyword
6573        \gdef\currentsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6574                              \gdef\thissection{\thissectionname}}%
6575      \fi
6576    \else\ifx\temptype\Yomitfromtockeyword
6577      % Don't redefine \thissection.
6578    \else\ifx\temptype\Yappendixkeyword
6579      \ifx\sectionlevel\seckeyword
6580        \toks0={#1}%
6581        \xdef\currentsectiondefs{%
6582          \gdef\noexpand\thissectionname{\the\toks0}%
6583          \gdef\noexpand\thissectionnum{#4}%
6584          % \noexpand\putwordSection avoids expanding indigestible
6585          % commands in some of the translations.
6586          \gdef\noexpand\thissection{\noexpand\putwordSection{}
6587                                     \noexpand\thissectionnum:
6588                                     \noexpand\thissectionname}%
6589        }%
6590      \fi
6591    \else
6592      \ifx\sectionlevel\seckeyword
6593        \toks0={#1}%
6594        \xdef\currentsectiondefs{%
6595          \gdef\noexpand\thissectionname{\the\toks0}%
6596          \gdef\noexpand\thissectionnum{#4}%
6597          % \noexpand\putwordSection avoids expanding indigestible
6598          % commands in some of the translations.
6599          \gdef\noexpand\thissection{\noexpand\putwordSection{}
6600                                     \noexpand\thissectionnum:
6601                                     \noexpand\thissectionname}%
6602        }%
6603      \fi
6604    \fi\fi\fi
6605    %
6606    % Go into vertical mode.  Usually we'll already be there, but we
6607    % don't want the following whatsit to end up in a preceding paragraph
6608    % if the document didn't happen to have a blank line.
6609    \par
6610    %
6611    % Output the mark.  Pass it through \safewhatsit, to take care of
6612    % the preceding space.
6613    \safewhatsit\domark
6614    %
6615    % Insert space above the heading.
6616    \csname #2headingbreak\endcsname
6617    %
6618    % Now the second mark, after the heading break.  No break points
6619    % between here and the heading.
6620    \global\let\prevsectiondefs=\currentsectiondefs
6621    \domark
6622    %
6623    % Only insert the space after the number if we have a section number.
6624    \ifx\temptype\Ynothingkeyword
6625      \setbox0 = \hbox{}%
6626      \def\toctype{unn}%
6627      \gdef\currentsection{#1}%
6628    \else\ifx\temptype\Yomitfromtockeyword
6629      % for @headings -- no section number, don't include in toc,
6630      % and don't redefine \currentsection.
6631      \setbox0 = \hbox{}%
6632      \def\toctype{omit}%
6633      \let\sectionlevel=\empty
6634    \else\ifx\temptype\Yappendixkeyword
6635      \setbox0 = \hbox{#4\enspace}%
6636      \def\toctype{app}%
6637      \gdef\currentsection{#1}%
6638    \else
6639      \setbox0 = \hbox{#4\enspace}%
6640      \def\toctype{num}%
6641      \gdef\currentsection{#1}%
6642    \fi\fi\fi
6643    %
6644    % Write the toc entry (before \donoderef).  See comments in \chapmacro.
6645    \writetocentry{\toctype\sectionlevel}{#1}{#4}%
6646    %
6647    % Write the node reference (= pdf destination for pdftex).
6648    % Again, see comments in \chapmacro.
6649    \donoderef{#3}%
6650    %
6651    % Interline glue will be inserted when the vbox is completed.
6652    % That glue will be a valid breakpoint for the page, since it'll be
6653    % preceded by a whatsit (usually from the \donoderef, or from the
6654    % \writetocentry if there was no node).  We don't want to allow that
6655    % break, since then the whatsits could end up on page n while the
6656    % section is on page n+1, thus toc/etc. are wrong.  Debian bug 276000.
6657    \nobreak
6658    %
6659    % Output the actual section heading.
6660    \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
6661          \hangindent=\wd0  % zero if no section number
6662          \unhbox0 #1}%
6663  }%
6664  % Add extra space after the heading -- half of whatever came above it.
6665  % Don't allow stretch, though.
6666  \kern .5 \csname #2headingskip\endcsname
6667  %
6668  % Do not let the kern be a potential breakpoint, as it would be if it
6669  % was followed by glue.
6670  \nobreak
6671  %
6672  % We'll almost certainly start a paragraph next, so don't let that
6673  % glue accumulate.  (Not a breakpoint because it's preceded by a
6674  % discardable item.)  However, when a paragraph is not started next
6675  % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6676  % or the negative glue will cause weirdly wrong output, typically
6677  % obscuring the section heading with something else.
6678  \vskip-\parskip
6679  %
6680  % This is so the last item on the main vertical list is a known
6681  % \penalty > 10000, so \startdefun, etc., can recognize the situation
6682  % and do the needful.
6683  \penalty 10001
6684}
6685
6686
6687\message{toc,}
6688% Table of contents.
6689\newwrite\tocfile
6690
6691% Write an entry to the toc file, opening it if necessary.
6692% Called from @chapter, etc.
6693%
6694% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6695% We append the current node name (if any) and page number as additional
6696% arguments for the \{chap,sec,...}entry macros which will eventually
6697% read this.  The node name is used in the pdf outlines as the
6698% destination to jump to.
6699%
6700% We open the .toc file for writing here instead of at @setfilename (or
6701% any other fixed time) so that @contents can be anywhere in the document.
6702% But if #1 is `omit', then we don't do anything.  This is used for the
6703% table of contents chapter openings themselves.
6704%
6705\newif\iftocfileopened
6706\def\omitkeyword{omit}%
6707%
6708\def\writetocentry#1#2#3{%
6709  \edef\writetoctype{#1}%
6710  \ifx\writetoctype\omitkeyword \else
6711    \iftocfileopened\else
6712      \immediate\openout\tocfile = \jobname.toc
6713      \global\tocfileopenedtrue
6714    \fi
6715    %
6716    \iflinks
6717      {\atdummies
6718       \edef\temp{%
6719         \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6720       \temp
6721      }%
6722    \fi
6723  \fi
6724  %
6725  % Tell \shipout to create a pdf destination on each page, if we're
6726  % writing pdf.  These are used in the table of contents.  We can't
6727  % just write one on every page because the title pages are numbered
6728  % 1 and 2 (the page numbers aren't printed), and so are the first
6729  % two pages of the document.  Thus, we'd have two destinations named
6730  % `1', and two named `2'.
6731  \ifpdforxetex
6732    \global\pdfmakepagedesttrue
6733  \fi
6734}
6735
6736
6737% These characters do not print properly in the Computer Modern roman
6738% fonts, so we must take special care.  This is more or less redundant
6739% with the Texinfo input format setup at the end of this file.
6740%
6741\def\activecatcodes{%
6742  \catcode`\"=\active
6743  \catcode`\$=\active
6744  \catcode`\<=\active
6745  \catcode`\>=\active
6746  \catcode`\\=\active
6747  \catcode`\^=\active
6748  \catcode`\_=\active
6749  \catcode`\|=\active
6750  \catcode`\~=\active
6751}
6752
6753
6754% Read the toc file, which is essentially Texinfo input.
6755\def\readtocfile{%
6756  \setupdatafile
6757  \activecatcodes
6758  \input \tocreadfilename
6759}
6760
6761\newskip\contentsrightmargin \contentsrightmargin=1in
6762\newcount\savepageno
6763\newcount\lastnegativepageno \lastnegativepageno = -1
6764
6765% Prepare to read what we've written to \tocfile.
6766%
6767\def\startcontents#1{%
6768  % If @setchapternewpage on, and @headings double, the contents should
6769  % start on an odd page, unlike chapters.  Thus, we maintain
6770  % \contentsalignmacro in parallel with \pagealignmacro.
6771  % From: Torbjorn Granlund <tege@matematik.su.se>
6772  \contentsalignmacro
6773  \immediate\closeout\tocfile
6774  %
6775  % Don't need to put `Contents' or `Short Contents' in the headline.
6776  % It is abundantly clear what they are.
6777  \chapmacro{#1}{Yomitfromtoc}{}%
6778  %
6779  \savepageno = \pageno
6780  \begingroup                  % Set up to handle contents files properly.
6781    \raggedbottom              % Worry more about breakpoints than the bottom.
6782    \entryrightmargin=\contentsrightmargin % Don't use the full line length.
6783    %
6784    % Roman numerals for page numbers.
6785    \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
6786}
6787
6788% redefined for the two-volume lispref.  We always output on
6789% \jobname.toc even if this is redefined.
6790%
6791\def\tocreadfilename{\jobname.toc}
6792
6793% Normal (long) toc.
6794%
6795\def\contents{%
6796  \startcontents{\putwordTOC}%
6797    \openin 1 \tocreadfilename\space
6798    \ifeof 1 \else
6799      \readtocfile
6800    \fi
6801    \vfill \eject
6802    \contentsalignmacro % in case @setchapternewpage odd is in effect
6803    \ifeof 1 \else
6804      \pdfmakeoutlines
6805    \fi
6806    \closein 1
6807  \endgroup
6808  \lastnegativepageno = \pageno
6809  \global\pageno = \savepageno
6810}
6811
6812% And just the chapters.
6813\def\summarycontents{%
6814  \startcontents{\putwordShortTOC}%
6815    %
6816    \let\partentry = \shortpartentry
6817    \let\numchapentry = \shortchapentry
6818    \let\appentry = \shortchapentry
6819    \let\unnchapentry = \shortunnchapentry
6820    % We want a true roman here for the page numbers.
6821    \secfonts
6822    \let\rm=\shortcontrm \let\bf=\shortcontbf
6823    \let\sl=\shortcontsl \let\tt=\shortconttt
6824    \rm
6825    \hyphenpenalty = 10000
6826    \advance\baselineskip by 1pt % Open it up a little.
6827    \def\numsecentry##1##2##3##4{}
6828    \let\appsecentry = \numsecentry
6829    \let\unnsecentry = \numsecentry
6830    \let\numsubsecentry = \numsecentry
6831    \let\appsubsecentry = \numsecentry
6832    \let\unnsubsecentry = \numsecentry
6833    \let\numsubsubsecentry = \numsecentry
6834    \let\appsubsubsecentry = \numsecentry
6835    \let\unnsubsubsecentry = \numsecentry
6836    \openin 1 \tocreadfilename\space
6837    \ifeof 1 \else
6838      \readtocfile
6839    \fi
6840    \closein 1
6841    \vfill \eject
6842    \contentsalignmacro % in case @setchapternewpage odd is in effect
6843  \endgroup
6844  \lastnegativepageno = \pageno
6845  \global\pageno = \savepageno
6846}
6847\let\shortcontents = \summarycontents
6848
6849% Typeset the label for a chapter or appendix for the short contents.
6850% The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6851%
6852\def\shortchaplabel#1{%
6853  % This space should be enough, since a single number is .5em, and the
6854  % widest letter (M) is 1em, at least in the Computer Modern fonts.
6855  % But use \hss just in case.
6856  % (This space doesn't include the extra space that gets added after
6857  % the label; that gets put in by \shortchapentry above.)
6858  %
6859  % We'd like to right-justify chapter numbers, but that looks strange
6860  % with appendix letters.  And right-justifying numbers and
6861  % left-justifying letters looks strange when there is less than 10
6862  % chapters.  Have to read the whole toc once to know how many chapters
6863  % there are before deciding ...
6864  \hbox to 1em{#1\hss}%
6865}
6866
6867% These macros generate individual entries in the table of contents.
6868% The first argument is the chapter or section name.
6869% The last argument is the page number.
6870% The arguments in between are the chapter number, section number, ...
6871
6872% Parts, in the main contents.  Replace the part number, which doesn't
6873% exist, with an empty box.  Let's hope all the numbers have the same width.
6874% Also ignore the page number, which is conventionally not printed.
6875\def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6876\def\partentry#1#2#3#4{%
6877  % Add stretch and a bonus for breaking the page before the part heading.
6878  % This reduces the chance of the page being broken immediately after the
6879  % part heading, before a following chapter heading.
6880  \vskip 0pt plus 5\baselineskip
6881  \penalty-300
6882  \vskip 0pt plus -5\baselineskip
6883  \dochapentry{\numeralbox\labelspace#1}{}%
6884}
6885%
6886% Parts, in the short toc.
6887\def\shortpartentry#1#2#3#4{%
6888  \penalty-300
6889  \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
6890  \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
6891}
6892
6893% Chapters, in the main contents.
6894\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
6895
6896% Chapters, in the short toc.
6897% See comments in \dochapentry re vbox and related settings.
6898\def\shortchapentry#1#2#3#4{%
6899  \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
6900}
6901
6902% Appendices, in the main contents.
6903% Need the word Appendix, and a fixed-size box.
6904%
6905\def\appendixbox#1{%
6906  % We use M since it's probably the widest letter.
6907  \setbox0 = \hbox{\putwordAppendix{} M}%
6908  \hbox to \wd0{\putwordAppendix{} #1\hss}}
6909%
6910\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
6911
6912% Unnumbered chapters.
6913\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
6914\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
6915
6916% Sections.
6917\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
6918\let\appsecentry=\numsecentry
6919\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
6920
6921% Subsections.
6922\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
6923\let\appsubsecentry=\numsubsecentry
6924\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
6925
6926% And subsubsections.
6927\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
6928\let\appsubsubsecentry=\numsubsubsecentry
6929\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
6930
6931% This parameter controls the indentation of the various levels.
6932% Same as \defaultparindent.
6933\newdimen\tocindent \tocindent = 15pt
6934
6935% Now for the actual typesetting. In all these, #1 is the text and #2 is the
6936% page number.
6937%
6938% If the toc has to be broken over pages, we want it to be at chapters
6939% if at all possible; hence the \penalty.
6940\def\dochapentry#1#2{%
6941   \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
6942   \begingroup
6943     % Move the page numbers slightly to the right
6944     \advance\entryrightmargin by -0.05em
6945     \chapentryfonts
6946     \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6947   \endgroup
6948   \nobreak\vskip .25\baselineskip plus.1\baselineskip
6949}
6950
6951\def\dosecentry#1#2{\begingroup
6952  \secentryfonts \leftskip=\tocindent
6953  \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6954\endgroup}
6955
6956\def\dosubsecentry#1#2{\begingroup
6957  \subsecentryfonts \leftskip=2\tocindent
6958  \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6959\endgroup}
6960
6961\def\dosubsubsecentry#1#2{\begingroup
6962  \subsubsecentryfonts \leftskip=3\tocindent
6963  \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6964\endgroup}
6965
6966% We use the same \entry macro as for the index entries.
6967\let\tocentry = \entry
6968
6969% Space between chapter (or whatever) number and the title.
6970\def\labelspace{\hskip1em \relax}
6971
6972\def\dopageno#1{{\rm #1}}
6973\def\doshortpageno#1{{\rm #1}}
6974
6975\def\chapentryfonts{\secfonts \rm}
6976\def\secentryfonts{\textfonts}
6977\def\subsecentryfonts{\textfonts}
6978\def\subsubsecentryfonts{\textfonts}
6979
6980
6981\message{environments,}
6982% @foo ... @end foo.
6983
6984% @tex ... @end tex    escapes into raw TeX temporarily.
6985% One exception: @ is still an escape character, so that @end tex works.
6986% But \@ or @@ will get a plain @ character.
6987
6988\envdef\tex{%
6989  \setupmarkupstyle{tex}%
6990  \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
6991  \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
6992  \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
6993  \catcode `\%=14
6994  \catcode `\+=\other
6995  \catcode `\"=\other
6996  \catcode `\|=\other
6997  \catcode `\<=\other
6998  \catcode `\>=\other
6999  \catcode `\`=\other
7000  \catcode `\'=\other
7001  %
7002  % ' is active in math mode (mathcode"8000).  So reset it, and all our
7003  % other math active characters (just in case), to plain's definitions.
7004  \mathactive
7005  %
7006  % Inverse of the list at the beginning of the file.
7007  \let\b=\ptexb
7008  \let\bullet=\ptexbullet
7009  \let\c=\ptexc
7010  \let\,=\ptexcomma
7011  \let\.=\ptexdot
7012  \let\dots=\ptexdots
7013  \let\equiv=\ptexequiv
7014  \let\!=\ptexexclam
7015  \let\i=\ptexi
7016  \let\indent=\ptexindent
7017  \let\noindent=\ptexnoindent
7018  \let\{=\ptexlbrace
7019  \let\+=\tabalign
7020  \let\}=\ptexrbrace
7021  \let\/=\ptexslash
7022  \let\sp=\ptexsp
7023  \let\*=\ptexstar
7024  %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
7025  \let\t=\ptext
7026  \expandafter \let\csname top\endcsname=\ptextop  % we've made it outer
7027  \let\frenchspacing=\plainfrenchspacing
7028  %
7029  \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
7030  \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
7031  \def\@{@}%
7032}
7033% There is no need to define \Etex.
7034
7035% Define @lisp ... @end lisp.
7036% @lisp environment forms a group so it can rebind things,
7037% including the definition of @end lisp (which normally is erroneous).
7038
7039% Amount to narrow the margins by for @lisp.
7040\newskip\lispnarrowing \lispnarrowing=0.4in
7041
7042% This is the definition that ^^M gets inside @lisp, @example, and other
7043% such environments.  \null is better than a space, since it doesn't
7044% have any width.
7045\def\lisppar{\null\endgraf}
7046
7047% This space is always present above and below environments.
7048\newskip\envskipamount \envskipamount = 0pt
7049
7050% Make spacing and below environment symmetrical.  We use \parskip here
7051% to help in doing that, since in @example-like environments \parskip
7052% is reset to zero; thus the \afterenvbreak inserts no space -- but the
7053% start of the next paragraph will insert \parskip.
7054%
7055\def\aboveenvbreak{{%
7056  % =10000 instead of <10000 because of a special case in \itemzzz and
7057  % \sectionheading, q.v.
7058  \ifnum \lastpenalty=10000 \else
7059    \advance\envskipamount by \parskip
7060    \endgraf
7061    \ifdim\lastskip<\envskipamount
7062      \removelastskip
7063      \ifnum\lastpenalty<10000
7064        % Penalize breaking before the environment, because preceding text
7065        % often leads into it.
7066        \penalty100
7067      \fi
7068      \vskip\envskipamount
7069    \fi
7070  \fi
7071}}
7072
7073\def\afterenvbreak{{%
7074  % =10000 instead of <10000 because of a special case in \itemzzz and
7075  % \sectionheading, q.v.
7076  \ifnum \lastpenalty=10000 \else
7077    \advance\envskipamount by \parskip
7078    \endgraf
7079    \ifdim\lastskip<\envskipamount
7080      \removelastskip
7081      % it's not a good place to break if the last penalty was \nobreak
7082      % or better ...
7083      \ifnum\lastpenalty<10000 \penalty-50 \fi
7084      \vskip\envskipamount
7085    \fi
7086  \fi
7087}}
7088
7089% \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins; it will
7090% also clear it, so that its embedded environments do the narrowing again.
7091\let\nonarrowing=\relax
7092
7093% @cartouche ... @end cartouche: draw rectangle w/rounded corners around
7094% environment contents.
7095
7096%
7097\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
7098\def\ctr{{\hskip 6pt\circle\char'010}}
7099\def\cbl{{\circle\char'012\hskip -6pt}}
7100\def\cbr{{\hskip 6pt\circle\char'011}}
7101\def\carttop{\hbox to \cartouter{\hskip\lskip
7102        \ctl\leaders\hrule height\circthick\hfil\ctr
7103        \hskip\rskip}}
7104\def\cartbot{\hbox to \cartouter{\hskip\lskip
7105        \cbl\leaders\hrule height\circthick\hfil\cbr
7106        \hskip\rskip}}
7107%
7108\newskip\lskip\newskip\rskip
7109
7110% only require the font if @cartouche is actually used
7111\def\cartouchefontdefs{%
7112  \font\circle=lcircle10\relax
7113  \circthick=\fontdimen8\circle
7114}
7115\newdimen\circthick
7116\newdimen\cartouter\newdimen\cartinner
7117\newskip\normbskip\newskip\normpskip\newskip\normlskip
7118
7119
7120\envdef\cartouche{%
7121  \cartouchefontdefs
7122  \ifhmode\par\fi  % can't be in the midst of a paragraph.
7123  \startsavinginserts
7124  \lskip=\leftskip \rskip=\rightskip
7125  \leftskip=0pt\rightskip=0pt % we want these *outside*.
7126  \cartinner=\hsize \advance\cartinner by-\lskip
7127  \advance\cartinner by-\rskip
7128  \cartouter=\hsize
7129  \advance\cartouter by 18.4pt	% allow for 3pt kerns on either
7130				% side, and for 6pt waste from
7131				% each corner char, and rule thickness
7132  \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
7133  %
7134  % If this cartouche directly follows a sectioning command, we need the
7135  % \parskip glue (backspaced over by default) or the cartouche can
7136  % collide with the section heading.
7137  \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
7138  %
7139  \setbox\groupbox=\vbox\bgroup
7140      \baselineskip=0pt\parskip=0pt\lineskip=0pt
7141      \carttop
7142      \hbox\bgroup
7143	  \hskip\lskip
7144	  \vrule\kern3pt
7145	  \vbox\bgroup
7146	      \kern3pt
7147	      \hsize=\cartinner
7148	      \baselineskip=\normbskip
7149	      \lineskip=\normlskip
7150	      \parskip=\normpskip
7151	      \vskip -\parskip
7152	      \comment % For explanation, see the end of def\group.
7153}
7154\def\Ecartouche{%
7155              \ifhmode\par\fi
7156	      \kern3pt
7157	  \egroup
7158	  \kern3pt\vrule
7159	  \hskip\rskip
7160      \egroup
7161      \cartbot
7162  \egroup
7163  \addgroupbox
7164  \checkinserts
7165}
7166
7167
7168% This macro is called at the beginning of all the @example variants,
7169% inside a group.
7170\newdimen\nonfillparindent
7171\def\nonfillstart{%
7172  \aboveenvbreak
7173  \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
7174  \sepspaces % Make spaces be word-separators rather than space tokens.
7175  \let\par = \lisppar % don't ignore blank lines
7176  \obeylines % each line of input is a line of output
7177  \parskip = 0pt
7178  % Turn off paragraph indentation but redefine \indent to emulate
7179  % the normal \indent.
7180  \nonfillparindent=\parindent
7181  \parindent = 0pt
7182  \let\indent\nonfillindent
7183  %
7184  \emergencystretch = 0pt % don't try to avoid overfull boxes
7185  \ifx\nonarrowing\relax
7186    \advance \leftskip by \lispnarrowing
7187    \exdentamount=\lispnarrowing
7188  \else
7189    \let\nonarrowing = \relax
7190  \fi
7191  \let\exdent=\nofillexdent
7192}
7193
7194\begingroup
7195\obeyspaces
7196% We want to swallow spaces (but not other tokens) after the fake
7197% @indent in our nonfill-environments, where spaces are normally
7198% active and set to @tie, resulting in them not being ignored after
7199% @indent.
7200\gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
7201\gdef\nonfillindentcheck{%
7202\ifx\temp %
7203\expandafter\nonfillindentgobble%
7204\else%
7205\leavevmode\nonfillindentbox%
7206\fi%
7207}%
7208\endgroup
7209\def\nonfillindentgobble#1{\nonfillindent}
7210\def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7211
7212% If you want all examples etc. small: @set dispenvsize small.
7213% If you want even small examples the full size: @set dispenvsize nosmall.
7214% This affects the following displayed environments:
7215%    @example, @display, @format, @lisp
7216%
7217\def\smallword{small}
7218\def\nosmallword{nosmall}
7219\let\SETdispenvsize\relax
7220\def\setnormaldispenv{%
7221  \ifx\SETdispenvsize\smallword
7222    % end paragraph for sake of leading, in case document has no blank
7223    % line.  This is redundant with what happens in \aboveenvbreak, but
7224    % we need to do it before changing the fonts, and it's inconvenient
7225    % to change the fonts afterward.
7226    \ifnum \lastpenalty=10000 \else \endgraf \fi
7227    \smallexamplefonts \rm
7228  \fi
7229}
7230\def\setsmalldispenv{%
7231  \ifx\SETdispenvsize\nosmallword
7232  \else
7233    \ifnum \lastpenalty=10000 \else \endgraf \fi
7234    \smallexamplefonts \rm
7235  \fi
7236}
7237
7238% We often define two environments, @foo and @smallfoo.
7239% Let's do it in one command.  #1 is the env name, #2 the definition.
7240\def\makedispenvdef#1#2{%
7241  \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7242  \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
7243  \expandafter\let\csname E#1\endcsname \afterenvbreak
7244  \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
7245}
7246
7247% Define two environment synonyms (#1 and #2) for an environment.
7248\def\maketwodispenvdef#1#2#3{%
7249  \makedispenvdef{#1}{#3}%
7250  \makedispenvdef{#2}{#3}%
7251}
7252%
7253% @lisp: indented, narrowed, typewriter font;
7254% @example: same as @lisp.
7255%
7256% @smallexample and @smalllisp: use smaller fonts.
7257% Originally contributed by Pavel@xerox.
7258%
7259\maketwodispenvdef{lisp}{example}{%
7260  \nonfillstart
7261  \tt\setupmarkupstyle{example}%
7262  \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
7263  \gobble % eat return
7264}
7265% @display/@smalldisplay: same as @lisp except keep current font.
7266%
7267\makedispenvdef{display}{%
7268  \nonfillstart
7269  \gobble
7270}
7271
7272% @format/@smallformat: same as @display except don't narrow margins.
7273%
7274\makedispenvdef{format}{%
7275  \let\nonarrowing = t%
7276  \nonfillstart
7277  \gobble
7278}
7279
7280% @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7281\envdef\flushleft{%
7282  \let\nonarrowing = t%
7283  \nonfillstart
7284  \gobble
7285}
7286\let\Eflushleft = \afterenvbreak
7287
7288% @flushright.
7289%
7290\envdef\flushright{%
7291  \let\nonarrowing = t%
7292  \nonfillstart
7293  \advance\leftskip by 0pt plus 1fill\relax
7294  \gobble
7295}
7296\let\Eflushright = \afterenvbreak
7297
7298
7299% @raggedright does more-or-less normal line breaking but no right
7300% justification.  From plain.tex.
7301\envdef\raggedright{%
7302  \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7303}
7304\let\Eraggedright\par
7305
7306\envdef\raggedleft{%
7307  \parindent=0pt \leftskip0pt plus2em
7308  \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7309  \hbadness=10000 % Last line will usually be underfull, so turn off
7310                  % badness reporting.
7311}
7312\let\Eraggedleft\par
7313
7314\envdef\raggedcenter{%
7315  \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
7316  \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7317  \hbadness=10000 % Last line will usually be underfull, so turn off
7318                  % badness reporting.
7319}
7320\let\Eraggedcenter\par
7321
7322
7323% @quotation does normal linebreaking (hence we can't use \nonfillstart)
7324% and narrows the margins.  We keep \parskip nonzero in general, since
7325% we're doing normal filling.  So, when using \aboveenvbreak and
7326% \afterenvbreak, temporarily make \parskip 0.
7327%
7328\makedispenvdef{quotation}{\quotationstart}
7329%
7330\def\quotationstart{%
7331  \indentedblockstart % same as \indentedblock, but increase right margin too.
7332  \ifx\nonarrowing\relax
7333    \advance\rightskip by \lispnarrowing
7334  \fi
7335  \parsearg\quotationlabel
7336}
7337
7338% We have retained a nonzero parskip for the environment, since we're
7339% doing normal filling.
7340%
7341\def\Equotation{%
7342  \par
7343  \ifx\quotationauthor\thisisundefined\else
7344    % indent a bit.
7345    \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7346  \fi
7347  {\parskip=0pt \afterenvbreak}%
7348}
7349\def\Esmallquotation{\Equotation}
7350
7351% If we're given an argument, typeset it in bold with a colon after.
7352\def\quotationlabel#1{%
7353  \def\temp{#1}%
7354  \ifx\temp\empty \else
7355    {\bf #1: }%
7356  \fi
7357}
7358
7359% @indentedblock is like @quotation, but indents only on the left and
7360% has no optional argument.
7361%
7362\makedispenvdef{indentedblock}{\indentedblockstart}
7363%
7364\def\indentedblockstart{%
7365  {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7366  \parindent=0pt
7367  %
7368  % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7369  \ifx\nonarrowing\relax
7370    \advance\leftskip by \lispnarrowing
7371    \exdentamount = \lispnarrowing
7372  \else
7373    \let\nonarrowing = \relax
7374  \fi
7375}
7376
7377% Keep a nonzero parskip for the environment, since we're doing normal filling.
7378%
7379\def\Eindentedblock{%
7380  \par
7381  {\parskip=0pt \afterenvbreak}%
7382}
7383\def\Esmallindentedblock{\Eindentedblock}
7384
7385
7386% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7387% If we want to allow any <char> as delimiter,
7388% we need the curly braces so that makeinfo sees the @verb command, eg:
7389% `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
7390%
7391% [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
7392%
7393% [Knuth] p.344; only we need to do the other characters Texinfo sets
7394% active too.  Otherwise, they get lost as the first character on a
7395% verbatim line.
7396\def\dospecials{%
7397  \do\ \do\\\do\{\do\}\do\$\do\&%
7398  \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7399  \do\<\do\>\do\|\do\@\do+\do\"%
7400  % Don't do the quotes -- if we do, @set txicodequoteundirected and
7401  % @set txicodequotebacktick will not have effect on @verb and
7402  % @verbatim, and ?` and !` ligatures won't get disabled.
7403  %\do\`\do\'%
7404}
7405%
7406% [Knuth] p. 380
7407\def\uncatcodespecials{%
7408  \def\do##1{\catcode`##1=\other}\dospecials}
7409%
7410% Setup for the @verb command.
7411%
7412% Eight spaces for a tab
7413\begingroup
7414  \catcode`\^^I=\active
7415  \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7416\endgroup
7417%
7418\def\setupverb{%
7419  \tt  % easiest (and conventionally used) font for verbatim
7420  \def\par{\leavevmode\endgraf}%
7421  \setupmarkupstyle{verb}%
7422  \tabeightspaces
7423  % Respect line breaks,
7424  % print special symbols as themselves, and
7425  % make each space count
7426  % must do in this order:
7427  \obeylines \uncatcodespecials \sepspaces
7428}
7429
7430% Setup for the @verbatim environment
7431%
7432% Real tab expansion.
7433\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7434%
7435% We typeset each line of the verbatim in an \hbox, so we can handle
7436% tabs.  The \global is in case the verbatim line starts with an accent,
7437% or some other command that starts with a begin-group.  Otherwise, the
7438% entire \verbbox would disappear at the corresponding end-group, before
7439% it is typeset.  Meanwhile, we can't have nested verbatim commands
7440% (can we?), so the \global won't be overwriting itself.
7441\newbox\verbbox
7442\def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
7443%
7444\begingroup
7445  \catcode`\^^I=\active
7446  \gdef\tabexpand{%
7447    \catcode`\^^I=\active
7448    \def^^I{\leavevmode\egroup
7449      \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7450      \divide\dimen\verbbox by\tabw
7451      \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7452      \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
7453      \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
7454    }%
7455  }
7456\endgroup
7457
7458% start the verbatim environment.
7459\def\setupverbatim{%
7460  \let\nonarrowing = t%
7461  \nonfillstart
7462  \tt % easiest (and conventionally used) font for verbatim
7463  % The \leavevmode here is for blank lines.  Otherwise, we would
7464  % never \starttabbox and the \egroup would end verbatim mode.
7465  \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
7466  \tabexpand
7467  \setupmarkupstyle{verbatim}%
7468  % Respect line breaks,
7469  % print special symbols as themselves, and
7470  % make each space count.
7471  % Must do in this order:
7472  \obeylines \uncatcodespecials \sepspaces
7473  \everypar{\starttabbox}%
7474}
7475
7476% Do the @verb magic: verbatim text is quoted by unique
7477% delimiter characters.  Before first delimiter expect a
7478% right brace, after last delimiter expect closing brace:
7479%
7480%    \def\doverb'{'<char>#1<char>'}'{#1}
7481%
7482% [Knuth] p. 382; only eat outer {}
7483\begingroup
7484  \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
7485  \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7486\endgroup
7487%
7488\def\verb{\begingroup\setupverb\doverb}
7489%
7490%
7491% Do the @verbatim magic: define the macro \doverbatim so that
7492% the (first) argument ends when '@end verbatim' is reached, ie:
7493%
7494%     \def\doverbatim#1@end verbatim{#1}
7495%
7496% For Texinfo it's a lot easier than for LaTeX,
7497% because texinfo's \verbatim doesn't stop at '\end{verbatim}':
7498% we need not redefine '\', '{' and '}'.
7499%
7500% Inspired by LaTeX's verbatim command set [latex.ltx]
7501%
7502\begingroup
7503  \catcode`\ =\active
7504  \obeylines %
7505  % ignore everything up to the first ^^M, that's the newline at the end
7506  % of the @verbatim input line itself.  Otherwise we get an extra blank
7507  % line in the output.
7508  \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
7509  % We really want {...\end verbatim} in the body of the macro, but
7510  % without the active space; thus we have to use \xdef and \gobble.
7511\endgroup
7512%
7513\envdef\verbatim{%
7514    \setupverbatim\doverbatim
7515}
7516\let\Everbatim = \afterenvbreak
7517
7518
7519% @verbatiminclude FILE - insert text of file in verbatim environment.
7520%
7521\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
7522%
7523\def\doverbatiminclude#1{%
7524  {%
7525    \makevalueexpandable
7526    \setupverbatim
7527    {%
7528      \indexnofonts       % Allow `@@' and other weird things in file names.
7529      \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
7530      \edef\tmp{\noexpand\input #1 }
7531      \expandafter
7532    }\tmp
7533    \afterenvbreak
7534  }%
7535}
7536
7537% @copying ... @end copying.
7538% Save the text away for @insertcopying later.
7539%
7540% We save the uninterpreted tokens, rather than creating a box.
7541% Saving the text in a box would be much easier, but then all the
7542% typesetting commands (@smallbook, font changes, etc.) have to be done
7543% beforehand -- and a) we want @copying to be done first in the source
7544% file; b) letting users define the frontmatter in as flexible order as
7545% possible is desirable.
7546%
7547\def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
7548\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
7549%
7550\def\insertcopying{%
7551  \begingroup
7552    \parindent = 0pt  % paragraph indentation looks wrong on title page
7553    \scanexp\copyingtext
7554  \endgroup
7555}
7556
7557
7558\message{defuns,}
7559% @defun etc.
7560
7561\newskip\defbodyindent \defbodyindent=.4in
7562\newskip\defargsindent \defargsindent=50pt
7563\newskip\deflastargmargin \deflastargmargin=18pt
7564\newcount\defunpenalty
7565
7566% Start the processing of @deffn:
7567\def\startdefun{%
7568  \ifnum\lastpenalty<10000
7569    \medbreak
7570    \defunpenalty=10003 % Will keep this @deffn together with the
7571                        % following @def command, see below.
7572  \else
7573    % If there are two @def commands in a row, we'll have a \nobreak,
7574    % which is there to keep the function description together with its
7575    % header.  But if there's nothing but headers, we need to allow a
7576    % break somewhere.  Check specifically for penalty 10002, inserted
7577    % by \printdefunline, instead of 10000, since the sectioning
7578    % commands also insert a nobreak penalty, and we don't want to allow
7579    % a break between a section heading and a defun.
7580    %
7581    % As a further refinement, we avoid "club" headers by signalling
7582    % with penalty of 10003 after the very first @deffn in the
7583    % sequence (see above), and penalty of 10002 after any following
7584    % @def command.
7585    \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
7586    %
7587    % Similarly, after a section heading, do not allow a break.
7588    % But do insert the glue.
7589    \medskip  % preceded by discardable penalty, so not a breakpoint
7590  \fi
7591  %
7592  \parindent=0in
7593  \advance\leftskip by \defbodyindent
7594  \exdentamount=\defbodyindent
7595}
7596
7597\def\dodefunx#1{%
7598  % First, check whether we are in the right environment:
7599  \checkenv#1%
7600  %
7601  % As above, allow line break if we have multiple x headers in a row.
7602  % It's not a great place, though.
7603  \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
7604  %
7605  % And now, it's time to reuse the body of the original defun:
7606  \expandafter\gobbledefun#1%
7607}
7608\def\gobbledefun#1\startdefun{}
7609
7610% \printdefunline \deffnheader{text}
7611%
7612\def\printdefunline#1#2{%
7613  \begingroup
7614    % call \deffnheader:
7615    #1#2 \endheader
7616    % common ending:
7617    \interlinepenalty = 10000
7618    \advance\rightskip by 0pt plus 1fil\relax
7619    \endgraf
7620    \nobreak\vskip -\parskip
7621    \penalty\defunpenalty  % signal to \startdefun and \dodefunx
7622    % Some of the @defun-type tags do not enable magic parentheses,
7623    % rendering the following check redundant.  But we don't optimize.
7624    \checkparencounts
7625  \endgroup
7626}
7627
7628\def\Edefun{\endgraf\medbreak}
7629
7630% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
7631% the only thing remaining is to define \deffnheader.
7632%
7633\def\makedefun#1{%
7634  \expandafter\let\csname E#1\endcsname = \Edefun
7635  \edef\temp{\noexpand\domakedefun
7636    \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7637  \temp
7638}
7639
7640% \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
7641%
7642% Define \deffn and \deffnx, without parameters.
7643% \deffnheader has to be defined explicitly.
7644%
7645\def\domakedefun#1#2#3{%
7646  \envdef#1{%
7647    \startdefun
7648    \doingtypefnfalse    % distinguish typed functions from all else
7649    \parseargusing\activeparens{\printdefunline#3}%
7650  }%
7651  \def#2{\dodefunx#1}%
7652  \def#3%
7653}
7654
7655\newif\ifdoingtypefn       % doing typed function?
7656\newif\ifrettypeownline    % typeset return type on its own line?
7657
7658% @deftypefnnewline on|off says whether the return type of typed functions
7659% are printed on their own line.  This affects @deftypefn, @deftypefun,
7660% @deftypeop, and @deftypemethod.
7661%
7662\parseargdef\deftypefnnewline{%
7663  \def\temp{#1}%
7664  \ifx\temp\onword
7665    \expandafter\let\csname SETtxideftypefnnl\endcsname
7666      = \empty
7667  \else\ifx\temp\offword
7668    \expandafter\let\csname SETtxideftypefnnl\endcsname
7669      = \relax
7670  \else
7671    \errhelp = \EMsimple
7672    \errmessage{Unknown @txideftypefnnl value `\temp',
7673                must be on|off}%
7674  \fi\fi
7675}
7676
7677% \dosubind {index}{topic}{subtopic}
7678%
7679% If SUBTOPIC is present, precede it with a space, and call \doind.
7680% (At some time during the 20th century, this made a two-level entry in an
7681% index such as the operation index.  Nobody seemed to notice the change in
7682% behaviour though.)
7683\def\dosubind#1#2#3{%
7684  \def\thirdarg{#3}%
7685  \ifx\thirdarg\empty
7686    \doind{#1}{#2}%
7687  \else
7688    \doind{#1}{#2\space#3}%
7689  \fi
7690}
7691
7692% Untyped functions:
7693
7694% @deffn category name args
7695\makedefun{deffn}{\deffngeneral{}}
7696
7697% @deffn category class name args
7698\makedefun{defop}#1 {\defopon{#1\ \putwordon}}
7699
7700% \defopon {category on}class name args
7701\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7702
7703% \deffngeneral {subind}category name args
7704%
7705\def\deffngeneral#1#2 #3 #4\endheader{%
7706  \dosubind{fn}{\code{#3}}{#1}%
7707  \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
7708}
7709
7710% Typed functions:
7711
7712% @deftypefn category type name args
7713\makedefun{deftypefn}{\deftypefngeneral{}}
7714
7715% @deftypeop category class type name args
7716\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
7717
7718% \deftypeopon {category on}class type name args
7719\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7720
7721% \deftypefngeneral {subind}category type name args
7722%
7723\def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
7724  \dosubind{fn}{\code{#4}}{#1}%
7725  \doingtypefntrue
7726  \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7727}
7728
7729% Typed variables:
7730
7731% @deftypevr category type var args
7732\makedefun{deftypevr}{\deftypecvgeneral{}}
7733
7734% @deftypecv category class type var args
7735\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
7736
7737% \deftypecvof {category of}class type var args
7738\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
7739
7740% \deftypecvgeneral {subind}category type var args
7741%
7742\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
7743  \dosubind{vr}{\code{#4}}{#1}%
7744  \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7745}
7746
7747% Untyped variables:
7748
7749% @defvr category var args
7750\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
7751
7752% @defcv category class var args
7753\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
7754
7755% \defcvof {category of}class var args
7756\def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
7757
7758% Types:
7759
7760% @deftp category name args
7761\makedefun{deftp}#1 #2 #3\endheader{%
7762  \doind{tp}{\code{#2}}%
7763  \defname{#1}{}{#2}\defunargs{#3\unskip}%
7764}
7765
7766% Remaining @defun-like shortcuts:
7767\makedefun{defun}{\deffnheader{\putwordDeffunc} }
7768\makedefun{defmac}{\deffnheader{\putwordDefmac} }
7769\makedefun{defspec}{\deffnheader{\putwordDefspec} }
7770\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7771\makedefun{defvar}{\defvrheader{\putwordDefvar} }
7772\makedefun{defopt}{\defvrheader{\putwordDefopt} }
7773\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
7774\makedefun{defmethod}{\defopon\putwordMethodon}
7775\makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
7776\makedefun{defivar}{\defcvof\putwordInstanceVariableof}
7777\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
7778
7779% \defname, which formats the name of the @def (not the args).
7780% #1 is the category, such as "Function".
7781% #2 is the return type, if any.
7782% #3 is the function name.
7783%
7784% We are followed by (but not passed) the arguments, if any.
7785%
7786\def\defname#1#2#3{%
7787  \par
7788  % Get the values of \leftskip and \rightskip as they were outside the @def...
7789  \advance\leftskip by -\defbodyindent
7790  %
7791  % Determine if we are typesetting the return type of a typed function
7792  % on a line by itself.
7793  \rettypeownlinefalse
7794  \ifdoingtypefn  % doing a typed function specifically?
7795    % then check user option for putting return type on its own line:
7796    \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
7797      \rettypeownlinetrue
7798    \fi
7799  \fi
7800  %
7801  % How we'll format the category name.  Putting it in brackets helps
7802  % distinguish it from the body text that may end up on the next line
7803  % just below it.
7804  \def\temp{#1}%
7805  \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7806  %
7807  % Figure out line sizes for the paragraph shape.  We'll always have at
7808  % least two.
7809  \tempnum = 2
7810  %
7811  % The first line needs space for \box0; but if \rightskip is nonzero,
7812  % we need only space for the part of \box0 which exceeds it:
7813  \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
7814  %
7815  % If doing a return type on its own line, we'll have another line.
7816  \ifrettypeownline
7817    \advance\tempnum by 1
7818    \def\maybeshapeline{0in \hsize}%
7819  \else
7820    \def\maybeshapeline{}%
7821  \fi
7822  %
7823  % The continuations:
7824  \dimen2=\hsize  \advance\dimen2 by -\defargsindent
7825  %
7826  % The final paragraph shape:
7827  \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
7828  %
7829  % Put the category name at the right margin.
7830  \noindent
7831  \hbox to 0pt{%
7832    \hfil\box0 \kern-\hsize
7833    % \hsize has to be shortened this way:
7834    \kern\leftskip
7835    % Intentionally do not respect \rightskip, since we need the space.
7836  }%
7837  %
7838  % Allow all lines to be underfull without complaint:
7839  \tolerance=10000 \hbadness=10000
7840  \exdentamount=\defbodyindent
7841  {%
7842    % defun fonts. We use typewriter by default (used to be bold) because:
7843    % . we're printing identifiers, they should be in tt in principle.
7844    % . in languages with many accents, such as Czech or French, it's
7845    %   common to leave accents off identifiers.  The result looks ok in
7846    %   tt, but exceedingly strange in rm.
7847    % . we don't want -- and --- to be treated as ligatures.
7848    % . this still does not fix the ?` and !` ligatures, but so far no
7849    %   one has made identifiers using them :).
7850    \df \tt
7851    \def\temp{#2}% text of the return type
7852    \ifx\temp\empty\else
7853      \tclose{\temp}% typeset the return type
7854      \ifrettypeownline
7855        % put return type on its own line; prohibit line break following:
7856        \hfil\vadjust{\nobreak}\break
7857      \else
7858        \space  % type on same line, so just followed by a space
7859      \fi
7860    \fi           % no return type
7861    #3% output function name
7862  }%
7863  {\rm\enskip}% hskip 0.5 em of \rmfont
7864  %
7865  \boldbrax
7866  % arguments will be output next, if any.
7867}
7868
7869% Print arguments in slanted roman (not ttsl), inconsistently with using
7870% tt for the name.  This is because literal text is sometimes needed in
7871% the argument list (groff manual), and ttsl and tt are not very
7872% distinguishable.  Prevent hyphenation at `-' chars.
7873%
7874\def\defunargs#1{%
7875  % use sl by default (not ttsl),
7876  % tt for the names.
7877  \df \sl \hyphenchar\font=0
7878  %
7879  % On the other hand, if an argument has two dashes (for instance), we
7880  % want a way to get ttsl.  We used to recommend @var for that, so
7881  % leave the code in, but it's strange for @var to lead to typewriter.
7882  % Nowadays we recommend @code, since the difference between a ttsl hyphen
7883  % and a tt hyphen is pretty tiny.  @code also disables ?` !`.
7884  \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
7885  #1%
7886  \sl\hyphenchar\font=45
7887}
7888
7889% We want ()&[] to print specially on the defun line.
7890%
7891\def\activeparens{%
7892  \catcode`\(=\active \catcode`\)=\active
7893  \catcode`\[=\active \catcode`\]=\active
7894  \catcode`\&=\active
7895}
7896
7897% Make control sequences which act like normal parenthesis chars.
7898\let\lparen = ( \let\rparen = )
7899
7900% Be sure that we always have a definition for `(', etc.  For example,
7901% if the fn name has parens in it, \boldbrax will not be in effect yet,
7902% so TeX would otherwise complain about undefined control sequence.
7903{
7904  \activeparens
7905  \global\let(=\lparen \global\let)=\rparen
7906  \global\let[=\lbrack \global\let]=\rbrack
7907  \global\let& = \&
7908
7909  \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
7910  \gdef\magicamp{\let&=\amprm}
7911}
7912\let\ampchar\&
7913
7914\newcount\parencount
7915
7916% If we encounter &foo, then turn on ()-hacking afterwards
7917\newif\ifampseen
7918\def\amprm#1 {\ampseentrue{\bf\&#1 }}
7919
7920\def\parenfont{%
7921  \ifampseen
7922    % At the first level, print parens in roman,
7923    % otherwise use the default font.
7924    \ifnum \parencount=1 \rm \fi
7925  \else
7926    % The \sf parens (in \boldbrax) actually are a little bolder than
7927    % the contained text.  This is especially needed for [ and ] .
7928    \sf
7929  \fi
7930}
7931\def\infirstlevel#1{%
7932  \ifampseen
7933    \ifnum\parencount=1
7934      #1%
7935    \fi
7936  \fi
7937}
7938\def\bfafterword#1 {#1 \bf}
7939
7940\def\opnr{%
7941  \global\advance\parencount by 1
7942  {\parenfont(}%
7943  \infirstlevel \bfafterword
7944}
7945\def\clnr{%
7946  {\parenfont)}%
7947  \infirstlevel \sl
7948  \global\advance\parencount by -1
7949}
7950
7951\newcount\brackcount
7952\def\lbrb{%
7953  \global\advance\brackcount by 1
7954  {\bf[}%
7955}
7956\def\rbrb{%
7957  {\bf]}%
7958  \global\advance\brackcount by -1
7959}
7960
7961\def\checkparencounts{%
7962  \ifnum\parencount=0 \else \badparencount \fi
7963  \ifnum\brackcount=0 \else \badbrackcount \fi
7964}
7965% these should not use \errmessage; the glibc manual, at least, actually
7966% has such constructs (when documenting function pointers).
7967\def\badparencount{%
7968  \message{Warning: unbalanced parentheses in @def...}%
7969  \global\parencount=0
7970}
7971\def\badbrackcount{%
7972  \message{Warning: unbalanced square brackets in @def...}%
7973  \global\brackcount=0
7974}
7975
7976
7977\message{macros,}
7978% @macro.
7979
7980% To do this right we need a feature of e-TeX, \scantokens,
7981% which we arrange to emulate with a temporary file in ordinary TeX.
7982\ifx\eTeXversion\thisisundefined
7983  \newwrite\macscribble
7984  \def\scantokens#1{%
7985    \toks0={#1}%
7986    \immediate\openout\macscribble=\jobname.tmp
7987    \immediate\write\macscribble{\the\toks0}%
7988    \immediate\closeout\macscribble
7989    \input \jobname.tmp
7990  }
7991\fi
7992
7993% Used at the time of macro expansion.
7994% Argument is macro body with arguments substituted
7995\def\scanmacro#1{%
7996  \newlinechar`\^^M
7997  \def\xeatspaces{\eatspaces}%
7998  %
7999  % Process the macro body under the current catcode regime.
8000  \scantokens{#1@comment}%
8001  %
8002  % The \comment is to remove the \newlinechar added by \scantokens, and
8003  % can be noticed by \parsearg.  Note \c isn't used because this means cedilla
8004  % in math mode.
8005}
8006
8007% Used for copying and captions
8008\def\scanexp#1{%
8009  \expandafter\scanmacro\expandafter{#1}%
8010}
8011
8012\newcount\paramno   % Count of parameters
8013\newtoks\macname    % Macro name
8014\newif\ifrecursive  % Is it recursive?
8015
8016% List of all defined macros in the form
8017%    \commondummyword\macro1\commondummyword\macro2...
8018% Currently is also contains all @aliases; the list can be split
8019% if there is a need.
8020\def\macrolist{}
8021
8022% Add the macro to \macrolist
8023\def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
8024\def\addtomacrolistxxx#1{%
8025     \toks0 = \expandafter{\macrolist\commondummyword#1}%
8026     \xdef\macrolist{\the\toks0}%
8027}
8028
8029% Utility routines.
8030% This does \let #1 = #2, with \csnames; that is,
8031%   \let \csname#1\endcsname = \csname#2\endcsname
8032% (except of course we have to play expansion games).
8033%
8034\def\cslet#1#2{%
8035  \expandafter\let
8036  \csname#1\expandafter\endcsname
8037  \csname#2\endcsname
8038}
8039
8040% Trim leading and trailing spaces off a string.
8041% Concepts from aro-bend problem 15 (see CTAN).
8042{\catcode`\@=11
8043\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
8044\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
8045\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
8046\def\unbrace#1{#1}
8047\unbrace{\gdef\trim@@@ #1 } #2@{#1}
8048}
8049
8050% Trim a single trailing ^^M off a string.
8051{\catcode`\^^M=\other \catcode`\Q=3%
8052\gdef\eatcr #1{\eatcra #1Q^^MQ}%
8053\gdef\eatcra#1^^MQ{\eatcrb#1Q}%
8054\gdef\eatcrb#1Q#2Q{#1}%
8055}
8056
8057% Macro bodies are absorbed as an argument in a context where
8058% all characters are catcode 10, 11 or 12, except \ which is active
8059% (as in normal texinfo). It is necessary to change the definition of \
8060% to recognize macro arguments; this is the job of \mbodybackslash.
8061%
8062% Non-ASCII encodings make 8-bit characters active, so un-activate
8063% them to avoid their expansion.  Must do this non-globally, to
8064% confine the change to the current group.
8065%
8066% It's necessary to have hard CRs when the macro is executed. This is
8067% done by making ^^M (\endlinechar) catcode 12 when reading the macro
8068% body, and then making it the \newlinechar in \scanmacro.
8069%
8070\def\scanctxt{% used as subroutine
8071  \catcode`\"=\other
8072  \catcode`\+=\other
8073  \catcode`\<=\other
8074  \catcode`\>=\other
8075  \catcode`\^=\other
8076  \catcode`\_=\other
8077  \catcode`\|=\other
8078  \catcode`\~=\other
8079  \passthroughcharstrue
8080}
8081
8082\def\scanargctxt{% used for copying and captions, not macros.
8083  \scanctxt
8084  \catcode`\@=\other
8085  \catcode`\\=\other
8086  \catcode`\^^M=\other
8087}
8088
8089\def\macrobodyctxt{% used for @macro definitions
8090  \scanctxt
8091  \catcode`\ =\other
8092  \catcode`\@=\other
8093  \catcode`\{=\other
8094  \catcode`\}=\other
8095  \catcode`\^^M=\other
8096  \usembodybackslash
8097}
8098
8099% Used when scanning braced macro arguments.  Note, however, that catcode
8100% changes here are ineffectual if the macro invocation was nested inside
8101% an argument to another Texinfo command.
8102\def\macroargctxt{%
8103  \scanctxt
8104  \catcode`\ =\active
8105  \catcode`\@=\other
8106  \catcode`\^^M=\other
8107  \catcode`\\=\active
8108}
8109
8110\def\macrolineargctxt{% used for whole-line arguments without braces
8111  \scanctxt
8112  \catcode`\@=\other
8113  \catcode`\{=\other
8114  \catcode`\}=\other
8115}
8116
8117% \mbodybackslash is the definition of \ in @macro bodies.
8118% It maps \foo\ => \csname macarg.foo\endcsname => #N
8119% where N is the macro parameter number.
8120% We define \csname macarg.\endcsname to be \realbackslash, so
8121% \\ in macro replacement text gets you a backslash.
8122%
8123{\catcode`@=0 @catcode`@\=@active
8124 @gdef@usembodybackslash{@let\=@mbodybackslash}
8125 @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
8126}
8127\expandafter\def\csname macarg.\endcsname{\realbackslash}
8128
8129\def\margbackslash#1{\char`\#1 }
8130
8131\def\macro{\recursivefalse\parsearg\macroxxx}
8132\def\rmacro{\recursivetrue\parsearg\macroxxx}
8133
8134\def\macroxxx#1{%
8135  \getargs{#1}% now \macname is the macname and \argl the arglist
8136  \ifx\argl\empty       % no arguments
8137     \paramno=0\relax
8138  \else
8139     \expandafter\parsemargdef \argl;%
8140     \if\paramno>256\relax
8141       \ifx\eTeXversion\thisisundefined
8142         \errhelp = \EMsimple
8143         \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
8144       \fi
8145     \fi
8146  \fi
8147  \if1\csname ismacro.\the\macname\endcsname
8148     \message{Warning: redefining \the\macname}%
8149  \else
8150     \expandafter\ifx\csname \the\macname\endcsname \relax
8151     \else \errmessage{Macro name \the\macname\space already defined}\fi
8152     \global\cslet{macsave.\the\macname}{\the\macname}%
8153     \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
8154     \addtomacrolist{\the\macname}%
8155  \fi
8156  \begingroup \macrobodyctxt
8157  \ifrecursive \expandafter\parsermacbody
8158  \else \expandafter\parsemacbody
8159  \fi}
8160
8161\parseargdef\unmacro{%
8162  \if1\csname ismacro.#1\endcsname
8163    \global\cslet{#1}{macsave.#1}%
8164    \global\expandafter\let \csname ismacro.#1\endcsname=0%
8165    % Remove the macro name from \macrolist:
8166    \begingroup
8167      \expandafter\let\csname#1\endcsname \relax
8168      \let\commondummyword\unmacrodo
8169      \xdef\macrolist{\macrolist}%
8170    \endgroup
8171  \else
8172    \errmessage{Macro #1 not defined}%
8173  \fi
8174}
8175
8176% Called by \do from \dounmacro on each macro.  The idea is to omit any
8177% macro definitions that have been changed to \relax.
8178%
8179\def\unmacrodo#1{%
8180  \ifx #1\relax
8181    % remove this
8182  \else
8183    \noexpand\commondummyword \noexpand#1%
8184  \fi
8185}
8186
8187% \getargs -- Parse the arguments to a @macro line.  Set \macname to
8188% the name of the macro, and \argl to the braced argument list.
8189\def\getargs#1{\getargsxxx#1{}}
8190\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
8191\def\getmacname#1 #2\relax{\macname={#1}}
8192\def\getmacargs#1{\def\argl{#1}}
8193% This made use of the feature that if the last token of a
8194% <parameter list> is #, then the preceding argument is delimited by
8195% an opening brace, and that opening brace is not consumed.
8196
8197% Parse the optional {params} list to @macro or @rmacro.
8198% Set \paramno to the number of arguments,
8199% and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
8200% three-param macro.)  Define \macarg.BLAH for each BLAH in the params
8201% list to some hook where the argument is to be expanded.  If there are
8202% less than 10 arguments that hook is to be replaced by ##N where N
8203% is the position in that list, that is to say the macro arguments are to be
8204% defined `a la TeX in the macro body.
8205%
8206% That gets used by \mbodybackslash (above).
8207%
8208% If there are 10 or more arguments, a different technique is used: see
8209% \parsemmanyargdef.
8210%
8211\def\parsemargdef#1;{%
8212  \paramno=0\def\paramlist{}%
8213  \let\hash\relax
8214  % \hash is redefined to `#' later to get it into definitions
8215  \let\xeatspaces\relax
8216  \parsemargdefxxx#1,;,%
8217  \ifnum\paramno<10\relax\else
8218    \paramno0\relax
8219    \parsemmanyargdef@@#1,;,% 10 or more arguments
8220  \fi
8221}
8222\def\parsemargdefxxx#1,{%
8223  \if#1;\let\next=\relax
8224  \else \let\next=\parsemargdefxxx
8225    \advance\paramno by 1
8226    \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
8227        {\xeatspaces{\hash\the\paramno}}%
8228    \edef\paramlist{\paramlist\hash\the\paramno,}%
8229  \fi\next}
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      % _ (for example) has to be the character _ for the purposes of the
8948      % control sequence corresponding to the node, but it has to expand
8949      % into the usual \leavevmode...\vrule stuff for purposes of
8950      % printing. So we \turnoffactive for the \refx-snt, back on for the
8951      % printing, back off for the \refx-pg.
8952      {\turnoffactive
8953       % Only output a following space if the -snt ref is nonempty; for
8954       % @unnumbered and @anchor, it won't be.
8955       \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
8956       \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
8957      }%
8958      % output the `[mynode]' via the macro below so it can be overridden.
8959      \xrefprintnodename\printedrefname
8960      %
8961      % But we always want a comma and a space:
8962      ,\space
8963      %
8964      % output the `page 3'.
8965      \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
8966      % Add a , if xref followed by a space
8967      \if\space\noexpand\tokenafterxref ,%
8968      \else\ifx\	\tokenafterxref ,% @TAB
8969      \else\ifx\*\tokenafterxref ,%   @*
8970      \else\ifx\ \tokenafterxref ,%   @SPACE
8971      \else\ifx\
8972                \tokenafterxref ,%    @NL
8973      \else\ifx\tie\tokenafterxref ,% @tie
8974      \fi\fi\fi\fi\fi\fi
8975    \fi\fi
8976  \fi
8977  \endlink
8978\endgroup}
8979
8980% Output a cross-manual xref to #1.  Used just above (twice).
8981%
8982% Only include the text "Section ``foo'' in" if the foo is neither
8983% missing or Top.  Thus, @xref{,,,foo,The Foo Manual} outputs simply
8984% "see The Foo Manual", the idea being to refer to the whole manual.
8985%
8986% But, this being TeX, we can't easily compare our node name against the
8987% string "Top" while ignoring the possible spaces before and after in
8988% the input.  By adding the arbitrary 7sp below, we make it much less
8989% likely that a real node name would have the same width as "Top" (e.g.,
8990% in a monospaced font).  Hopefully it will never happen in practice.
8991%
8992% For the same basic reason, we retypeset the "Top" at every
8993% reference, since the current font is indeterminate.
8994%
8995\def\crossmanualxref#1{%
8996  \setbox\toprefbox = \hbox{Top\kern7sp}%
8997  \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
8998  \ifdim \wd2 > 7sp  % nonempty?
8999    \ifdim \wd2 = \wd\toprefbox \else  % same as Top?
9000      \putwordSection{} ``\printedrefname'' \putwordin{}\space
9001    \fi
9002  \fi
9003  #1%
9004}
9005
9006% This macro is called from \xrefX for the `[nodename]' part of xref
9007% output.  It's a separate macro only so it can be changed more easily,
9008% since square brackets don't work well in some documents.  Particularly
9009% one that Bob is working on :).
9010%
9011\def\xrefprintnodename#1{[#1]}
9012
9013% Things referred to by \setref.
9014%
9015\def\Ynothing{}
9016\def\Yomitfromtoc{}
9017\def\Ynumbered{%
9018  \ifnum\secno=0
9019    \putwordChapter@tie \the\chapno
9020  \else \ifnum\subsecno=0
9021    \putwordSection@tie \the\chapno.\the\secno
9022  \else \ifnum\subsubsecno=0
9023    \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
9024  \else
9025    \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
9026  \fi\fi\fi
9027}
9028\def\Yappendix{%
9029  \ifnum\secno=0
9030     \putwordAppendix@tie @char\the\appendixno{}%
9031  \else \ifnum\subsecno=0
9032     \putwordSection@tie @char\the\appendixno.\the\secno
9033  \else \ifnum\subsubsecno=0
9034    \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
9035  \else
9036    \putwordSection@tie
9037      @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
9038  \fi\fi\fi
9039}
9040
9041% \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME.  SUFFIX
9042% is output afterwards if non-empty.
9043\def\refx#1#2{%
9044  \requireauxfile
9045  {%
9046    \indexnofonts
9047    \otherbackslash
9048    \def\value##1{##1}%
9049    \expandafter\global\expandafter\let\expandafter\thisrefX
9050      \csname XR#1\endcsname
9051  }%
9052  \ifx\thisrefX\relax
9053    % If not defined, say something at least.
9054    \angleleft un\-de\-fined\angleright
9055    \iflinks
9056      \ifhavexrefs
9057        {\toks0 = {#1}% avoid expansion of possibly-complex value
9058         \message{\linenumber Undefined cross reference `\the\toks0'.}}%
9059      \else
9060        \ifwarnedxrefs\else
9061          \global\warnedxrefstrue
9062          \message{Cross reference values unknown; you must run TeX again.}%
9063        \fi
9064      \fi
9065    \fi
9066  \else
9067    % It's defined, so just use it.
9068    \thisrefX
9069  \fi
9070  #2% Output the suffix in any case.
9071}
9072
9073% This is the macro invoked by entries in the aux file.  Define a control
9074% sequence for a cross-reference target (we prepend XR to the control sequence
9075% name to avoid collisions).  The value is the page number.  If this is a float
9076% type, we have more work to do.
9077%
9078\def\xrdef#1#2{%
9079  {% Expand the node or anchor name to remove control sequences.
9080   % \turnoffactive stops 8-bit characters being changed to commands
9081   % like @'e.  \refx does the same to retrieve the value in the definition.
9082    \indexnofonts
9083    \turnoffactive
9084    \def\value##1{##1}%
9085    \xdef\safexrefname{#1}%
9086  }%
9087  %
9088  \bgroup
9089    \expandafter\gdef\csname XR\safexrefname\endcsname{#2}%
9090  \egroup
9091  % We put the \gdef inside a group to avoid the definitions building up on
9092  % TeX's save stack, which can cause it to run out of space for aux files with
9093  % thousands of lines.  \gdef doesn't use the save stack, but \csname does
9094  % when it defines an unknown control sequence as \relax.
9095  %
9096  % Was that xref control sequence that we just defined for a float?
9097  \expandafter\iffloat\csname XR\safexrefname\endcsname
9098    % it was a float, and we have the (safe) float type in \iffloattype.
9099    \expandafter\let\expandafter\floatlist
9100      \csname floatlist\iffloattype\endcsname
9101    %
9102    % Is this the first time we've seen this float type?
9103    \expandafter\ifx\floatlist\relax
9104      \toks0 = {\do}% yes, so just \do
9105    \else
9106      % had it before, so preserve previous elements in list.
9107      \toks0 = \expandafter{\floatlist\do}%
9108    \fi
9109    %
9110    % Remember this xref in the control sequence \floatlistFLOATTYPE,
9111    % for later use in \listoffloats.
9112    \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
9113      {\safexrefname}}%
9114  \fi
9115}
9116
9117% If working on a large document in chapters, it is convenient to
9118% be able to disable indexing, cross-referencing, and contents, for test runs.
9119% This is done with @novalidate at the beginning of the file.
9120%
9121\newif\iflinks \linkstrue % by default we want the aux files.
9122\let\novalidate = \linksfalse
9123
9124% Used when writing to the aux file, or when using data from it.
9125\def\requireauxfile{%
9126  \iflinks
9127    \tryauxfile
9128    % Open the new aux file.  TeX will close it automatically at exit.
9129    \immediate\openout\auxfile=\jobname.aux
9130  \fi
9131  \global\let\requireauxfile=\relax   % Only do this once.
9132}
9133
9134% Read the last existing aux file, if any.  No error if none exists.
9135%
9136\def\tryauxfile{%
9137  \openin 1 \jobname.aux
9138  \ifeof 1 \else
9139    \readdatafile{aux}%
9140    \global\havexrefstrue
9141  \fi
9142  \closein 1
9143}
9144
9145\def\setupdatafile{%
9146  \catcode`\^^@=\other
9147  \catcode`\^^A=\other
9148  \catcode`\^^B=\other
9149  \catcode`\^^C=\other
9150  \catcode`\^^D=\other
9151  \catcode`\^^E=\other
9152  \catcode`\^^F=\other
9153  \catcode`\^^G=\other
9154  \catcode`\^^H=\other
9155  \catcode`\^^K=\other
9156  \catcode`\^^L=\other
9157  \catcode`\^^N=\other
9158  \catcode`\^^P=\other
9159  \catcode`\^^Q=\other
9160  \catcode`\^^R=\other
9161  \catcode`\^^S=\other
9162  \catcode`\^^T=\other
9163  \catcode`\^^U=\other
9164  \catcode`\^^V=\other
9165  \catcode`\^^W=\other
9166  \catcode`\^^X=\other
9167  \catcode`\^^Z=\other
9168  \catcode`\^^[=\other
9169  \catcode`\^^\=\other
9170  \catcode`\^^]=\other
9171  \catcode`\^^^=\other
9172  \catcode`\^^_=\other
9173  \catcode`\^=\other
9174  %
9175  % Special characters.  Should be turned off anyway, but...
9176  \catcode`\~=\other
9177  \catcode`\[=\other
9178  \catcode`\]=\other
9179  \catcode`\"=\other
9180  \catcode`\_=\other
9181  \catcode`\|=\other
9182  \catcode`\<=\other
9183  \catcode`\>=\other
9184  \catcode`\$=\other
9185  \catcode`\#=\other
9186  \catcode`\&=\other
9187  \catcode`\%=\other
9188  \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
9189  %
9190  \catcode`\\=\active
9191  %
9192  % @ is our escape character in .aux files, and we need braces.
9193  \catcode`\{=1
9194  \catcode`\}=2
9195  \catcode`\@=0
9196}
9197
9198\def\readdatafile#1{%
9199\begingroup
9200  \setupdatafile
9201  \input\jobname.#1
9202\endgroup}
9203
9204
9205\message{insertions,}
9206% including footnotes.
9207
9208\newcount \footnoteno
9209
9210% The trailing space in the following definition for supereject is
9211% vital for proper filling; pages come out unaligned when you do a
9212% pagealignmacro call if that space before the closing brace is
9213% removed. (Generally, numeric constants should always be followed by a
9214% space to prevent strange expansion errors.)
9215\def\supereject{\par\penalty -20000\footnoteno =0 }
9216
9217% @footnotestyle is meaningful for Info output only.
9218\let\footnotestyle=\comment
9219
9220{\catcode `\@=11
9221%
9222% Auto-number footnotes.  Otherwise like plain.
9223\gdef\footnote{%
9224  \global\advance\footnoteno by \@ne
9225  \edef\thisfootno{$^{\the\footnoteno}$}%
9226  %
9227  % In case the footnote comes at the end of a sentence, preserve the
9228  % extra spacing after we do the footnote number.
9229  \let\@sf\empty
9230  \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9231  %
9232  % Remove inadvertent blank space before typesetting the footnote number.
9233  \unskip
9234  \thisfootno\@sf
9235  \dofootnote
9236}%
9237
9238% Don't bother with the trickery in plain.tex to not require the
9239% footnote text as a parameter.  Our footnotes don't need to be so general.
9240%
9241% Oh yes, they do; otherwise, @ifset (and anything else that uses
9242% \parseargline) fails inside footnotes because the tokens are fixed when
9243% the footnote is read.  --karl, 16nov96.
9244%
9245\gdef\dofootnote{%
9246  \insert\footins\bgroup
9247  %
9248  % Nested footnotes are not supported in TeX, that would take a lot
9249  % more work.  (\startsavinginserts does not suffice.)
9250  \let\footnote=\errfootnotenest
9251  %
9252  % We want to typeset this text as a normal paragraph, even if the
9253  % footnote reference occurs in (for example) a display environment.
9254  % So reset some parameters.
9255  \hsize=\txipagewidth
9256  \interlinepenalty\interfootnotelinepenalty
9257  \splittopskip\ht\strutbox % top baseline for broken footnotes
9258  \splitmaxdepth\dp\strutbox
9259  \floatingpenalty\@MM
9260  \leftskip\z@skip
9261  \rightskip\z@skip
9262  \spaceskip\z@skip
9263  \xspaceskip\z@skip
9264  \parindent\defaultparindent
9265  %
9266  \smallfonts \rm
9267  %
9268  % Because we use hanging indentation in footnotes, a @noindent appears
9269  % to exdent this text, so make it be a no-op.  makeinfo does not use
9270  % hanging indentation so @noindent can still be needed within footnote
9271  % text after an @example or the like (not that this is good style).
9272  \let\noindent = \relax
9273  %
9274  % Hang the footnote text off the number.  Use \everypar in case the
9275  % footnote extends for more than one paragraph.
9276  \everypar = {\hang}%
9277  \textindent{\thisfootno}%
9278  %
9279  % Don't crash into the line above the footnote text.  Since this
9280  % expands into a box, it must come within the paragraph, lest it
9281  % provide a place where TeX can split the footnote.
9282  \footstrut
9283  %
9284  % Invoke rest of plain TeX footnote routine.
9285  \futurelet\next\fo@t
9286}
9287}%end \catcode `\@=11
9288
9289\def\errfootnotenest{%
9290  \errhelp=\EMsimple
9291  \errmessage{Nested footnotes not supported in texinfo.tex,
9292    even though they work in makeinfo; sorry}
9293}
9294
9295\def\errfootnoteheading{%
9296  \errhelp=\EMsimple
9297  \errmessage{Footnotes in chapters, sections, etc., are not supported}
9298}
9299
9300% In case a @footnote appears in a vbox, save the footnote text and create
9301% the real \insert just after the vbox finished.  Otherwise, the insertion
9302% would be lost.
9303% Similarly, if a @footnote appears inside an alignment, save the footnote
9304% text to a box and make the \insert when a row of the table is finished.
9305% And the same can be done for other insert classes.  --kasal, 16nov03.
9306%
9307% Replace the \insert primitive by a cheating macro.
9308% Deeper inside, just make sure that the saved insertions are not spilled
9309% out prematurely.
9310%
9311\def\startsavinginserts{%
9312  \ifx \insert\ptexinsert
9313    \let\insert\saveinsert
9314  \else
9315    \let\checkinserts\relax
9316  \fi
9317}
9318
9319% This \insert replacement works for both \insert\footins{foo} and
9320% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9321%
9322\def\saveinsert#1{%
9323  \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9324  \afterassignment\next
9325  % swallow the left brace
9326  \let\temp =
9327}
9328\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9329\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9330
9331\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9332
9333\def\placesaveins#1{%
9334  \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9335    {\box#1}%
9336}
9337
9338% eat @SAVE -- beware, all of them have catcode \other:
9339{
9340  \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials  %  ;-)
9341  \gdef\gobblesave @SAVE{}
9342}
9343
9344% initialization:
9345\def\newsaveins #1{%
9346  \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9347  \next
9348}
9349\def\newsaveinsX #1{%
9350  \csname newbox\endcsname #1%
9351  \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9352    \checksaveins #1}%
9353}
9354
9355% initialize:
9356\let\checkinserts\empty
9357\newsaveins\footins
9358\newsaveins\margin
9359
9360
9361% @image.  We use the macros from epsf.tex to support this.
9362% If epsf.tex is not installed and @image is used, we complain.
9363%
9364% Check for and read epsf.tex up front.  If we read it only at @image
9365% time, we might be inside a group, and then its definitions would get
9366% undone and the next image would fail.
9367\openin 1 = epsf.tex
9368\ifeof 1 \else
9369  % Do not bother showing banner with epsf.tex v2.7k (available in
9370  % doc/epsf.tex and on ctan).
9371  \def\epsfannounce{\toks0 = }%
9372  \input epsf.tex
9373\fi
9374\closein 1
9375%
9376% We will only complain once about lack of epsf.tex.
9377\newif\ifwarnednoepsf
9378\newhelp\noepsfhelp{epsf.tex must be installed for images to
9379  work.  It is also included in the Texinfo distribution, or you can get
9380  it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.}
9381%
9382\def\image#1{%
9383  \ifx\epsfbox\thisisundefined
9384    \ifwarnednoepsf \else
9385      \errhelp = \noepsfhelp
9386      \errmessage{epsf.tex not found, images will be ignored}%
9387      \global\warnednoepsftrue
9388    \fi
9389  \else
9390    \imagexxx #1,,,,,\finish
9391  \fi
9392}
9393%
9394% Arguments to @image:
9395% #1 is (mandatory) image filename; we tack on .eps extension.
9396% #2 is (optional) width, #3 is (optional) height.
9397% #4 is (ignored optional) html alt text.
9398% #5 is (ignored optional) extension.
9399% #6 is just the usual extra ignored arg for parsing stuff.
9400\newif\ifimagevmode
9401\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
9402  \catcode`\^^M = 5     % in case we're inside an example
9403  \normalturnoffactive  % allow _ et al. in names
9404  \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
9405  % If the image is by itself, center it.
9406  \ifvmode
9407    \imagevmodetrue
9408  \else \ifx\centersub\centerV
9409    % for @center @image, we need a vbox so we can have our vertical space
9410    \imagevmodetrue
9411    \vbox\bgroup % vbox has better behavior than vtop herev
9412  \fi\fi
9413  %
9414  \ifimagevmode
9415    \nobreak\medskip
9416    % Usually we'll have text after the image which will insert
9417    % \parskip glue, so insert it here too to equalize the space
9418    % above and below.
9419    \nobreak\vskip\parskip
9420    \nobreak
9421  \fi
9422  %
9423  % Leave vertical mode so that indentation from an enclosing
9424  %  environment such as @quotation is respected.
9425  % However, if we're at the top level, we don't want the
9426  %  normal paragraph indentation.
9427  % On the other hand, if we are in the case of @center @image, we don't
9428  %  want to start a paragraph, which will create a hsize-width box and
9429  %  eradicate the centering.
9430  \ifx\centersub\centerV\else \noindent \fi
9431  %
9432  % Output the image.
9433  \ifpdf
9434    % For pdfTeX and LuaTeX <= 0.80
9435    \dopdfimage{#1}{#2}{#3}%
9436  \else
9437    \ifx\XeTeXrevision\thisisundefined
9438      % For epsf.tex
9439      % \epsfbox itself resets \epsf?size at each figure.
9440      \setbox0 = \hbox{\ignorespaces #2}%
9441        \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9442      \setbox0 = \hbox{\ignorespaces #3}%
9443        \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9444      \epsfbox{#1.eps}%
9445    \else
9446      % For XeTeX
9447      \doxeteximage{#1}{#2}{#3}%
9448    \fi
9449  \fi
9450  %
9451  \ifimagevmode
9452    \medskip  % space after a standalone image
9453  \fi
9454  \ifx\centersub\centerV \egroup \fi
9455\endgroup}
9456
9457
9458% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9459% etc.  We don't actually implement floating yet, we always include the
9460% float "here".  But it seemed the best name for the future.
9461%
9462\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9463
9464% There may be a space before second and/or third parameter; delete it.
9465\def\eatcommaspace#1, {#1,}
9466
9467% #1 is the optional FLOATTYPE, the text label for this float, typically
9468% "Figure", "Table", "Example", etc.  Can't contain commas.  If omitted,
9469% this float will not be numbered and cannot be referred to.
9470%
9471% #2 is the optional xref label.  Also must be present for the float to
9472% be referable.
9473%
9474% #3 is the optional positioning argument; for now, it is ignored.  It
9475% will somehow specify the positions allowed to float to (here, top, bottom).
9476%
9477% We keep a separate counter for each FLOATTYPE, which we reset at each
9478% chapter-level command.
9479\let\resetallfloatnos=\empty
9480%
9481\def\dofloat#1,#2,#3,#4\finish{%
9482  \let\thiscaption=\empty
9483  \let\thisshortcaption=\empty
9484  %
9485  % don't lose footnotes inside @float.
9486  %
9487  % BEWARE: when the floats start float, we have to issue warning whenever an
9488  % insert appears inside a float which could possibly float. --kasal, 26may04
9489  %
9490  \startsavinginserts
9491  %
9492  % We can't be used inside a paragraph.
9493  \par
9494  %
9495  \vtop\bgroup
9496    \def\floattype{#1}%
9497    \def\floatlabel{#2}%
9498    \def\floatloc{#3}% we do nothing with this yet.
9499    %
9500    \ifx\floattype\empty
9501      \let\safefloattype=\empty
9502    \else
9503      {%
9504        % the floattype might have accents or other special characters,
9505        % but we need to use it in a control sequence name.
9506        \indexnofonts
9507        \turnoffactive
9508        \xdef\safefloattype{\floattype}%
9509      }%
9510    \fi
9511    %
9512    % If label is given but no type, we handle that as the empty type.
9513    \ifx\floatlabel\empty \else
9514      % We want each FLOATTYPE to be numbered separately (Figure 1,
9515      % Table 1, Figure 2, ...).  (And if no label, no number.)
9516      %
9517      \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9518      \global\advance\floatno by 1
9519      %
9520      {%
9521        % This magic value for \currentsection is output by \setref as the
9522        % XREFLABEL-title value.  \xrefX uses it to distinguish float
9523        % labels (which have a completely different output format) from
9524        % node and anchor labels.  And \xrdef uses it to construct the
9525        % lists of floats.
9526        %
9527        \edef\currentsection{\floatmagic=\safefloattype}%
9528        \setref{\floatlabel}{Yfloat}%
9529      }%
9530    \fi
9531    %
9532    % start with \parskip glue, I guess.
9533    \vskip\parskip
9534    %
9535    % Don't suppress indentation if a float happens to start a section.
9536    \restorefirstparagraphindent
9537}
9538
9539% we have these possibilities:
9540% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9541% @float Foo,lbl & no caption:    Foo 1.1
9542% @float Foo & @caption{Cap}:     Foo: Cap
9543% @float Foo & no caption:        Foo
9544% @float ,lbl & Caption{Cap}:     1.1: Cap
9545% @float ,lbl & no caption:       1.1
9546% @float & @caption{Cap}:         Cap
9547% @float & no caption:
9548%
9549\def\Efloat{%
9550    \let\floatident = \empty
9551    %
9552    % In all cases, if we have a float type, it comes first.
9553    \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9554    %
9555    % If we have an xref label, the number comes next.
9556    \ifx\floatlabel\empty \else
9557      \ifx\floattype\empty \else % if also had float type, need tie first.
9558        \appendtomacro\floatident{\tie}%
9559      \fi
9560      % the number.
9561      \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9562    \fi
9563    %
9564    % Start the printed caption with what we've constructed in
9565    % \floatident, but keep it separate; we need \floatident again.
9566    \let\captionline = \floatident
9567    %
9568    \ifx\thiscaption\empty \else
9569      \ifx\floatident\empty \else
9570        \appendtomacro\captionline{: }% had ident, so need a colon between
9571      \fi
9572      %
9573      % caption text.
9574      \appendtomacro\captionline{\scanexp\thiscaption}%
9575    \fi
9576    %
9577    % If we have anything to print, print it, with space before.
9578    % Eventually this needs to become an \insert.
9579    \ifx\captionline\empty \else
9580      \vskip.5\parskip
9581      \captionline
9582      %
9583      % Space below caption.
9584      \vskip\parskip
9585    \fi
9586    %
9587    % If have an xref label, write the list of floats info.  Do this
9588    % after the caption, to avoid chance of it being a breakpoint.
9589    \ifx\floatlabel\empty \else
9590      % Write the text that goes in the lof to the aux file as
9591      % \floatlabel-lof.  Besides \floatident, we include the short
9592      % caption if specified, else the full caption if specified, else nothing.
9593      {%
9594        \requireauxfile
9595        \atdummies
9596        %
9597        \ifx\thisshortcaption\empty
9598          \def\gtemp{\thiscaption}%
9599        \else
9600          \def\gtemp{\thisshortcaption}%
9601        \fi
9602        \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
9603          \ifx\gtemp\empty \else : \gtemp \fi}}%
9604      }%
9605    \fi
9606  \egroup  % end of \vtop
9607  %
9608  \checkinserts
9609}
9610
9611% Append the tokens #2 to the definition of macro #1, not expanding either.
9612%
9613\def\appendtomacro#1#2{%
9614  \expandafter\def\expandafter#1\expandafter{#1#2}%
9615}
9616
9617% @caption, @shortcaption
9618%
9619\def\caption{\docaption\thiscaption}
9620\def\shortcaption{\docaption\thisshortcaption}
9621\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
9622\def\defcaption#1#2{\egroup \def#1{#2}}
9623
9624% The parameter is the control sequence identifying the counter we are
9625% going to use.  Create it if it doesn't exist and assign it to \floatno.
9626\def\getfloatno#1{%
9627  \ifx#1\relax
9628      % Haven't seen this figure type before.
9629      \csname newcount\endcsname #1%
9630      %
9631      % Remember to reset this floatno at the next chap.
9632      \expandafter\gdef\expandafter\resetallfloatnos
9633        \expandafter{\resetallfloatnos #1=0 }%
9634  \fi
9635  \let\floatno#1%
9636}
9637
9638% \setref calls this to get the XREFLABEL-snt value.  We want an @xref
9639% to the FLOATLABEL to expand to "Figure 3.1".  We call \setref when we
9640% first read the @float command.
9641%
9642\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9643
9644% Magic string used for the XREFLABEL-title value, so \xrefX can
9645% distinguish floats from other xref types.
9646\def\floatmagic{!!float!!}
9647
9648% #1 is the control sequence we are passed; we expand into a conditional
9649% which is true if #1 represents a float ref.  That is, the magic
9650% \currentsection value which we \setref above.
9651%
9652\def\iffloat#1{\expandafter\doiffloat#1==\finish}
9653%
9654% #1 is (maybe) the \floatmagic string.  If so, #2 will be the
9655% (safe) float type for this float.  We set \iffloattype to #2.
9656%
9657\def\doiffloat#1=#2=#3\finish{%
9658  \def\temp{#1}%
9659  \def\iffloattype{#2}%
9660  \ifx\temp\floatmagic
9661}
9662
9663% @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9664%
9665\parseargdef\listoffloats{%
9666  \def\floattype{#1}% floattype
9667  {%
9668    % the floattype might have accents or other special characters,
9669    % but we need to use it in a control sequence name.
9670    \indexnofonts
9671    \turnoffactive
9672    \xdef\safefloattype{\floattype}%
9673  }%
9674  %
9675  % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9676  \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9677    \ifhavexrefs
9678      % if the user said @listoffloats foo but never @float foo.
9679      \message{\linenumber No `\safefloattype' floats to list.}%
9680    \fi
9681  \else
9682    \begingroup
9683      \leftskip=\tocindent  % indent these entries like a toc
9684      \let\do=\listoffloatsdo
9685      \csname floatlist\safefloattype\endcsname
9686    \endgroup
9687  \fi
9688}
9689
9690% This is called on each entry in a list of floats.  We're passed the
9691% xref label, in the form LABEL-title, which is how we save it in the
9692% aux file.  We strip off the -title and look up \XRLABEL-lof, which
9693% has the text we're supposed to typeset here.
9694%
9695% Figures without xref labels will not be included in the list (since
9696% they won't appear in the aux file).
9697%
9698\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9699\def\listoffloatsdoentry#1-title\finish{{%
9700  % Can't fully expand XR#1-lof because it can contain anything.  Just
9701  % pass the control sequence.  On the other hand, XR#1-pg is just the
9702  % page number, and we want to fully expand that so we can get a link
9703  % in pdf output.
9704  \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9705  %
9706  % use the same \entry macro we use to generate the TOC and index.
9707  \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9708  \writeentry
9709}}
9710
9711
9712\message{localization,}
9713
9714% For single-language documents, @documentlanguage is usually given very
9715% early, just after @documentencoding.  Single argument is the language
9716% (de) or locale (de_DE) abbreviation.
9717%
9718{
9719  \catcode`\_ = \active
9720  \globaldefs=1
9721\parseargdef\documentlanguage{%
9722  \tex % read txi-??.tex file in plain TeX.
9723    % Read the file by the name they passed if it exists.
9724    \let_ = \normalunderscore  % normal _ character for filename test
9725    \openin 1 txi-#1.tex
9726    \ifeof 1
9727      \documentlanguagetrywithoutunderscore #1_\finish
9728    \else
9729      \globaldefs = 1  % everything in the txi-LL files needs to persist
9730      \input txi-#1.tex
9731    \fi
9732    \closein 1
9733  \endgroup % end raw TeX
9734}
9735%
9736% If they passed de_DE, and txi-de_DE.tex doesn't exist,
9737% try txi-de.tex.
9738%
9739\gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
9740  \openin 1 txi-#1.tex
9741  \ifeof 1
9742    \errhelp = \nolanghelp
9743    \errmessage{Cannot read language file txi-#1.tex}%
9744  \else
9745    \globaldefs = 1  % everything in the txi-LL files needs to persist
9746    \input txi-#1.tex
9747  \fi
9748  \closein 1
9749}
9750}% end of special _ catcode
9751%
9752\newhelp\nolanghelp{The given language definition file cannot be found or
9753is empty.  Maybe you need to install it?  Putting it in the current
9754directory should work if nowhere else does.}
9755
9756% This macro is called from txi-??.tex files; the first argument is the
9757% \language name to set (without the "\lang@" prefix), the second and
9758% third args are \{left,right}hyphenmin.
9759%
9760% The language names to pass are determined when the format is built.
9761% See the etex.log file created at that time, e.g.,
9762% /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9763%
9764% With TeX Live 2008, etex now includes hyphenation patterns for all
9765% available languages.  This means we can support hyphenation in
9766% Texinfo, at least to some extent.  (This still doesn't solve the
9767% accented characters problem.)
9768%
9769\catcode`@=11
9770\def\txisetlanguage#1#2#3{%
9771  % do not set the language if the name is undefined in the current TeX.
9772  \expandafter\ifx\csname lang@#1\endcsname \relax
9773    \message{no patterns for #1}%
9774  \else
9775    \global\language = \csname lang@#1\endcsname
9776  \fi
9777  % but there is no harm in adjusting the hyphenmin values regardless.
9778  \global\lefthyphenmin = #2\relax
9779  \global\righthyphenmin = #3\relax
9780}
9781
9782% XeTeX and LuaTeX can handle Unicode natively.
9783% Their default I/O uses UTF-8 sequences instead of a byte-wise operation.
9784% Other TeX engines' I/O (pdfTeX, etc.) is byte-wise.
9785%
9786\newif\iftxinativeunicodecapable
9787\newif\iftxiusebytewiseio
9788
9789\ifx\XeTeXrevision\thisisundefined
9790  \ifx\luatexversion\thisisundefined
9791    \txinativeunicodecapablefalse
9792    \txiusebytewiseiotrue
9793  \else
9794    \txinativeunicodecapabletrue
9795    \txiusebytewiseiofalse
9796  \fi
9797\else
9798  \txinativeunicodecapabletrue
9799  \txiusebytewiseiofalse
9800\fi
9801
9802% Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9803% for non-UTF-8 (byte-wise) encodings.
9804%
9805\def\setbytewiseio{%
9806  \ifx\XeTeXrevision\thisisundefined
9807  \else
9808    \XeTeXdefaultencoding "bytes"  % For subsequent files to be read
9809    \XeTeXinputencoding "bytes"  % For document root file
9810    % Unfortunately, there seems to be no corresponding XeTeX command for
9811    % output encoding.  This is a problem for auxiliary index and TOC files.
9812    % The only solution would be perhaps to write out @U{...} sequences in
9813    % place of non-ASCII characters.
9814  \fi
9815
9816  \ifx\luatexversion\thisisundefined
9817  \else
9818    \directlua{
9819    local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9820    local function convert_char (char)
9821      return utf8_char(byte(char))
9822    end
9823
9824    local function convert_line (line)
9825      return gsub(line, ".", convert_char)
9826    end
9827
9828    callback.register("process_input_buffer", convert_line)
9829
9830    local function convert_line_out (line)
9831      local line_out = ""
9832      for c in string.utfvalues(line) do
9833         line_out = line_out .. string.char(c)
9834      end
9835      return line_out
9836    end
9837
9838    callback.register("process_output_buffer", convert_line_out)
9839    }
9840  \fi
9841
9842  \txiusebytewiseiotrue
9843}
9844
9845
9846% Helpers for encodings.
9847% Set the catcode of characters 128 through 255 to the specified number.
9848%
9849\def\setnonasciicharscatcode#1{%
9850   \count255=128
9851   \loop\ifnum\count255<256
9852      \global\catcode\count255=#1\relax
9853      \advance\count255 by 1
9854   \repeat
9855}
9856
9857\def\setnonasciicharscatcodenonglobal#1{%
9858   \count255=128
9859   \loop\ifnum\count255<256
9860      \catcode\count255=#1\relax
9861      \advance\count255 by 1
9862   \repeat
9863}
9864
9865% @documentencoding sets the definition of non-ASCII characters
9866% according to the specified encoding.
9867%
9868\def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9869\def\documentencodingzzz#1{%
9870  %
9871  % Encoding being declared for the document.
9872  \def\declaredencoding{\csname #1.enc\endcsname}%
9873  %
9874  % Supported encodings: names converted to tokens in order to be able
9875  % to compare them with \ifx.
9876  \def\ascii{\csname US-ASCII.enc\endcsname}%
9877  \def\latnine{\csname ISO-8859-15.enc\endcsname}%
9878  \def\latone{\csname ISO-8859-1.enc\endcsname}%
9879  \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
9880  \def\utfeight{\csname UTF-8.enc\endcsname}%
9881  %
9882  \ifx \declaredencoding \ascii
9883     \asciichardefs
9884  %
9885  \else \ifx \declaredencoding \lattwo
9886     \iftxinativeunicodecapable
9887       \setbytewiseio
9888     \fi
9889     \setnonasciicharscatcode\active
9890     \lattwochardefs
9891  %
9892  \else \ifx \declaredencoding \latone
9893     \iftxinativeunicodecapable
9894       \setbytewiseio
9895     \fi
9896     \setnonasciicharscatcode\active
9897     \latonechardefs
9898  %
9899  \else \ifx \declaredencoding \latnine
9900     \iftxinativeunicodecapable
9901       \setbytewiseio
9902     \fi
9903     \setnonasciicharscatcode\active
9904     \latninechardefs
9905  %
9906  \else \ifx \declaredencoding \utfeight
9907     \iftxinativeunicodecapable
9908       % For native Unicode handling (XeTeX and LuaTeX)
9909       \nativeunicodechardefs
9910     \else
9911       % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX)
9912       \setnonasciicharscatcode\active
9913       % since we already invoked \utfeightchardefs at the top level
9914       % (below), do not re-invoke it, otherwise our check for duplicated
9915       % definitions gets triggered.  Making non-ascii chars active is
9916       % sufficient.
9917     \fi
9918  %
9919  \else
9920    \message{Ignoring unknown document encoding: #1.}%
9921  %
9922  \fi % utfeight
9923  \fi % latnine
9924  \fi % latone
9925  \fi % lattwo
9926  \fi % ascii
9927  %
9928  \ifx\XeTeXrevision\thisisundefined
9929  \else
9930    \ifx \declaredencoding \utfeight
9931    \else
9932      \ifx \declaredencoding \ascii
9933      \else
9934        \message{Warning: XeTeX with non-UTF-8 encodings cannot handle %
9935        non-ASCII characters in auxiliary files.}%
9936      \fi
9937    \fi
9938  \fi
9939}
9940
9941% emacs-page
9942% A message to be logged when using a character that isn't available
9943% the default font encoding (OT1).
9944%
9945\def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
9946
9947% Take account of \c (plain) vs. \, (Texinfo) difference.
9948\def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
9949
9950% First, make active non-ASCII characters in order for them to be
9951% correctly categorized when TeX reads the replacement text of
9952% macros containing the character definitions.
9953\setnonasciicharscatcode\active
9954%
9955
9956\def\gdefchar#1#2{%
9957\gdef#1{%
9958   \ifpassthroughchars
9959     \string#1%
9960   \else
9961     #2%
9962   \fi
9963}}
9964
9965% Latin1 (ISO-8859-1) character definitions.
9966\def\latonechardefs{%
9967  \gdefchar^^a0{\tie}
9968  \gdefchar^^a1{\exclamdown}
9969  \gdefchar^^a2{{\tcfont \char162}} % cent
9970  \gdefchar^^a3{\pounds{}}
9971  \gdefchar^^a4{{\tcfont \char164}} % currency
9972  \gdefchar^^a5{{\tcfont \char165}} % yen
9973  \gdefchar^^a6{{\tcfont \char166}} % broken bar
9974  \gdefchar^^a7{\S}
9975  \gdefchar^^a8{\"{}}
9976  \gdefchar^^a9{\copyright{}}
9977  \gdefchar^^aa{\ordf}
9978  \gdefchar^^ab{\guillemetleft{}}
9979  \gdefchar^^ac{\ensuremath\lnot}
9980  \gdefchar^^ad{\-}
9981  \gdefchar^^ae{\registeredsymbol{}}
9982  \gdefchar^^af{\={}}
9983  %
9984  \gdefchar^^b0{\textdegree}
9985  \gdefchar^^b1{$\pm$}
9986  \gdefchar^^b2{$^2$}
9987  \gdefchar^^b3{$^3$}
9988  \gdefchar^^b4{\'{}}
9989  \gdefchar^^b5{$\mu$}
9990  \gdefchar^^b6{\P}
9991  \gdefchar^^b7{\ensuremath\cdot}
9992  \gdefchar^^b8{\cedilla\ }
9993  \gdefchar^^b9{$^1$}
9994  \gdefchar^^ba{\ordm}
9995  \gdefchar^^bb{\guillemetright{}}
9996  \gdefchar^^bc{$1\over4$}
9997  \gdefchar^^bd{$1\over2$}
9998  \gdefchar^^be{$3\over4$}
9999  \gdefchar^^bf{\questiondown}
10000  %
10001  \gdefchar^^c0{\`A}
10002  \gdefchar^^c1{\'A}
10003  \gdefchar^^c2{\^A}
10004  \gdefchar^^c3{\~A}
10005  \gdefchar^^c4{\"A}
10006  \gdefchar^^c5{\ringaccent A}
10007  \gdefchar^^c6{\AE}
10008  \gdefchar^^c7{\cedilla C}
10009  \gdefchar^^c8{\`E}
10010  \gdefchar^^c9{\'E}
10011  \gdefchar^^ca{\^E}
10012  \gdefchar^^cb{\"E}
10013  \gdefchar^^cc{\`I}
10014  \gdefchar^^cd{\'I}
10015  \gdefchar^^ce{\^I}
10016  \gdefchar^^cf{\"I}
10017  %
10018  \gdefchar^^d0{\DH}
10019  \gdefchar^^d1{\~N}
10020  \gdefchar^^d2{\`O}
10021  \gdefchar^^d3{\'O}
10022  \gdefchar^^d4{\^O}
10023  \gdefchar^^d5{\~O}
10024  \gdefchar^^d6{\"O}
10025  \gdefchar^^d7{$\times$}
10026  \gdefchar^^d8{\O}
10027  \gdefchar^^d9{\`U}
10028  \gdefchar^^da{\'U}
10029  \gdefchar^^db{\^U}
10030  \gdefchar^^dc{\"U}
10031  \gdefchar^^dd{\'Y}
10032  \gdefchar^^de{\TH}
10033  \gdefchar^^df{\ss}
10034  %
10035  \gdefchar^^e0{\`a}
10036  \gdefchar^^e1{\'a}
10037  \gdefchar^^e2{\^a}
10038  \gdefchar^^e3{\~a}
10039  \gdefchar^^e4{\"a}
10040  \gdefchar^^e5{\ringaccent a}
10041  \gdefchar^^e6{\ae}
10042  \gdefchar^^e7{\cedilla c}
10043  \gdefchar^^e8{\`e}
10044  \gdefchar^^e9{\'e}
10045  \gdefchar^^ea{\^e}
10046  \gdefchar^^eb{\"e}
10047  \gdefchar^^ec{\`{\dotless i}}
10048  \gdefchar^^ed{\'{\dotless i}}
10049  \gdefchar^^ee{\^{\dotless i}}
10050  \gdefchar^^ef{\"{\dotless i}}
10051  %
10052  \gdefchar^^f0{\dh}
10053  \gdefchar^^f1{\~n}
10054  \gdefchar^^f2{\`o}
10055  \gdefchar^^f3{\'o}
10056  \gdefchar^^f4{\^o}
10057  \gdefchar^^f5{\~o}
10058  \gdefchar^^f6{\"o}
10059  \gdefchar^^f7{$\div$}
10060  \gdefchar^^f8{\o}
10061  \gdefchar^^f9{\`u}
10062  \gdefchar^^fa{\'u}
10063  \gdefchar^^fb{\^u}
10064  \gdefchar^^fc{\"u}
10065  \gdefchar^^fd{\'y}
10066  \gdefchar^^fe{\th}
10067  \gdefchar^^ff{\"y}
10068}
10069
10070% Latin9 (ISO-8859-15) encoding character definitions.
10071\def\latninechardefs{%
10072  % Encoding is almost identical to Latin1.
10073  \latonechardefs
10074  %
10075  \gdefchar^^a4{\euro{}}
10076  \gdefchar^^a6{\v S}
10077  \gdefchar^^a8{\v s}
10078  \gdefchar^^b4{\v Z}
10079  \gdefchar^^b8{\v z}
10080  \gdefchar^^bc{\OE}
10081  \gdefchar^^bd{\oe}
10082  \gdefchar^^be{\"Y}
10083}
10084
10085% Latin2 (ISO-8859-2) character definitions.
10086\def\lattwochardefs{%
10087  \gdefchar^^a0{\tie}
10088  \gdefchar^^a1{\ogonek{A}}
10089  \gdefchar^^a2{\u{}}
10090  \gdefchar^^a3{\L}
10091  \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
10092  \gdefchar^^a5{\v L}
10093  \gdefchar^^a6{\'S}
10094  \gdefchar^^a7{\S}
10095  \gdefchar^^a8{\"{}}
10096  \gdefchar^^a9{\v S}
10097  \gdefchar^^aa{\cedilla S}
10098  \gdefchar^^ab{\v T}
10099  \gdefchar^^ac{\'Z}
10100  \gdefchar^^ad{\-}
10101  \gdefchar^^ae{\v Z}
10102  \gdefchar^^af{\dotaccent Z}
10103  %
10104  \gdefchar^^b0{\textdegree{}}
10105  \gdefchar^^b1{\ogonek{a}}
10106  \gdefchar^^b2{\ogonek{ }}
10107  \gdefchar^^b3{\l}
10108  \gdefchar^^b4{\'{}}
10109  \gdefchar^^b5{\v l}
10110  \gdefchar^^b6{\'s}
10111  \gdefchar^^b7{\v{}}
10112  \gdefchar^^b8{\cedilla\ }
10113  \gdefchar^^b9{\v s}
10114  \gdefchar^^ba{\cedilla s}
10115  \gdefchar^^bb{\v t}
10116  \gdefchar^^bc{\'z}
10117  \gdefchar^^bd{\H{}}
10118  \gdefchar^^be{\v z}
10119  \gdefchar^^bf{\dotaccent z}
10120  %
10121  \gdefchar^^c0{\'R}
10122  \gdefchar^^c1{\'A}
10123  \gdefchar^^c2{\^A}
10124  \gdefchar^^c3{\u A}
10125  \gdefchar^^c4{\"A}
10126  \gdefchar^^c5{\'L}
10127  \gdefchar^^c6{\'C}
10128  \gdefchar^^c7{\cedilla C}
10129  \gdefchar^^c8{\v C}
10130  \gdefchar^^c9{\'E}
10131  \gdefchar^^ca{\ogonek{E}}
10132  \gdefchar^^cb{\"E}
10133  \gdefchar^^cc{\v E}
10134  \gdefchar^^cd{\'I}
10135  \gdefchar^^ce{\^I}
10136  \gdefchar^^cf{\v D}
10137  %
10138  \gdefchar^^d0{\DH}
10139  \gdefchar^^d1{\'N}
10140  \gdefchar^^d2{\v N}
10141  \gdefchar^^d3{\'O}
10142  \gdefchar^^d4{\^O}
10143  \gdefchar^^d5{\H O}
10144  \gdefchar^^d6{\"O}
10145  \gdefchar^^d7{$\times$}
10146  \gdefchar^^d8{\v R}
10147  \gdefchar^^d9{\ringaccent U}
10148  \gdefchar^^da{\'U}
10149  \gdefchar^^db{\H U}
10150  \gdefchar^^dc{\"U}
10151  \gdefchar^^dd{\'Y}
10152  \gdefchar^^de{\cedilla T}
10153  \gdefchar^^df{\ss}
10154  %
10155  \gdefchar^^e0{\'r}
10156  \gdefchar^^e1{\'a}
10157  \gdefchar^^e2{\^a}
10158  \gdefchar^^e3{\u a}
10159  \gdefchar^^e4{\"a}
10160  \gdefchar^^e5{\'l}
10161  \gdefchar^^e6{\'c}
10162  \gdefchar^^e7{\cedilla c}
10163  \gdefchar^^e8{\v c}
10164  \gdefchar^^e9{\'e}
10165  \gdefchar^^ea{\ogonek{e}}
10166  \gdefchar^^eb{\"e}
10167  \gdefchar^^ec{\v e}
10168  \gdefchar^^ed{\'{\dotless{i}}}
10169  \gdefchar^^ee{\^{\dotless{i}}}
10170  \gdefchar^^ef{\v d}
10171  %
10172  \gdefchar^^f0{\dh}
10173  \gdefchar^^f1{\'n}
10174  \gdefchar^^f2{\v n}
10175  \gdefchar^^f3{\'o}
10176  \gdefchar^^f4{\^o}
10177  \gdefchar^^f5{\H o}
10178  \gdefchar^^f6{\"o}
10179  \gdefchar^^f7{$\div$}
10180  \gdefchar^^f8{\v r}
10181  \gdefchar^^f9{\ringaccent u}
10182  \gdefchar^^fa{\'u}
10183  \gdefchar^^fb{\H u}
10184  \gdefchar^^fc{\"u}
10185  \gdefchar^^fd{\'y}
10186  \gdefchar^^fe{\cedilla t}
10187  \gdefchar^^ff{\dotaccent{}}
10188}
10189
10190% UTF-8 character definitions.
10191%
10192% This code to support UTF-8 is based on LaTeX's utf8.def, with some
10193% changes for Texinfo conventions.  It is included here under the GPL by
10194% permission from Frank Mittelbach and the LaTeX team.
10195%
10196\newcount\countUTFx
10197\newcount\countUTFy
10198\newcount\countUTFz
10199
10200\gdef\UTFviiiTwoOctets#1#2{\expandafter
10201   \UTFviiiDefined\csname u8:#1\string #2\endcsname}
10202%
10203\gdef\UTFviiiThreeOctets#1#2#3{\expandafter
10204   \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
10205%
10206\gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
10207   \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
10208
10209\gdef\UTFviiiDefined#1{%
10210  \ifx #1\relax
10211    \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10212  \else
10213    \expandafter #1%
10214  \fi
10215}
10216
10217% Give non-ASCII bytes the active definitions for processing UTF-8 sequences
10218\begingroup
10219  \catcode`\~13
10220  \catcode`\$12
10221  \catcode`\"12
10222
10223  % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
10224  % substituting ~ and $ with a character token of that value.
10225  \def\UTFviiiLoop{%
10226    \global\catcode\countUTFx\active
10227    \uccode`\~\countUTFx
10228    \uccode`\$\countUTFx
10229    \uppercase\expandafter{\UTFviiiTmp}%
10230    \advance\countUTFx by 1
10231    \ifnum\countUTFx < \countUTFy
10232      \expandafter\UTFviiiLoop
10233    \fi}
10234
10235  % For bytes other than the first in a UTF-8 sequence.  Not expected to
10236  % be expanded except when writing to auxiliary files.
10237  \countUTFx = "80
10238  \countUTFy = "C2
10239  \def\UTFviiiTmp{%
10240    \gdef~{%
10241        \ifpassthroughchars $\fi}}%
10242  \UTFviiiLoop
10243
10244  \countUTFx = "C2
10245  \countUTFy = "E0
10246  \def\UTFviiiTmp{%
10247    \gdef~{%
10248        \ifpassthroughchars $%
10249        \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
10250  \UTFviiiLoop
10251
10252  \countUTFx = "E0
10253  \countUTFy = "F0
10254  \def\UTFviiiTmp{%
10255    \gdef~{%
10256        \ifpassthroughchars $%
10257        \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
10258  \UTFviiiLoop
10259
10260  \countUTFx = "F0
10261  \countUTFy = "F4
10262  \def\UTFviiiTmp{%
10263    \gdef~{%
10264        \ifpassthroughchars $%
10265        \else\expandafter\UTFviiiFourOctets\expandafter$\fi
10266        }}%
10267  \UTFviiiLoop
10268\endgroup
10269
10270\def\globallet{\global\let} % save some \expandafter's below
10271
10272% @U{xxxx} to produce U+xxxx, if we support it.
10273\def\U#1{%
10274  \expandafter\ifx\csname uni:#1\endcsname \relax
10275    \iftxinativeunicodecapable
10276      % All Unicode characters can be used if native Unicode handling is
10277      % active.  However, if the font does not have the glyph,
10278      % letters are missing.
10279      \begingroup
10280        \uccode`\.="#1\relax
10281        \uppercase{.}
10282      \endgroup
10283    \else
10284      \errhelp = \EMsimple
10285      \errmessage{Unicode character U+#1 not supported, sorry}%
10286    \fi
10287  \else
10288    \csname uni:#1\endcsname
10289  \fi
10290}
10291
10292% These macros are used here to construct the name of a control
10293% sequence to be defined.
10294\def\UTFviiiTwoOctetsName#1#2{%
10295  \csname u8:#1\string #2\endcsname}%
10296\def\UTFviiiThreeOctetsName#1#2#3{%
10297  \csname u8:#1\string #2\string #3\endcsname}%
10298\def\UTFviiiFourOctetsName#1#2#3#4{%
10299  \csname u8:#1\string #2\string #3\string #4\endcsname}%
10300
10301% For UTF-8 byte sequences (TeX, e-TeX and pdfTeX),
10302% provide a definition macro to replace a Unicode character;
10303% this gets used by the @U command
10304%
10305\begingroup
10306  \catcode`\"=12
10307  \catcode`\<=12
10308  \catcode`\.=12
10309  \catcode`\,=12
10310  \catcode`\;=12
10311  \catcode`\!=12
10312  \catcode`\~=13
10313  \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
10314    \countUTFz = "#1\relax
10315    \begingroup
10316      \parseXMLCharref
10317
10318      % Give \u8:... its definition.  The sequence of seven \expandafter's
10319      % expands after the \gdef three times, e.g.
10320      %
10321      % 1.  \UTFviiTwoOctetsName B1 B2
10322      % 2.  \csname u8:B1 \string B2 \endcsname
10323      % 3.  \u8: B1 B2  (a single control sequence token)
10324      %
10325      \expandafter\expandafter
10326      \expandafter\expandafter
10327      \expandafter\expandafter
10328      \expandafter\gdef       \UTFviiiTmp{#2}%
10329      %
10330      \expandafter\ifx\csname uni:#1\endcsname \relax \else
10331       \message{Internal error, already defined: #1}%
10332      \fi
10333      %
10334      % define an additional control sequence for this code point.
10335      \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
10336    \endgroup}
10337  %
10338  % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp
10339  % to the corresponding UTF-8 sequence.
10340  \gdef\parseXMLCharref{%
10341    \ifnum\countUTFz < "A0\relax
10342      \errhelp = \EMsimple
10343      \errmessage{Cannot define Unicode char value < 00A0}%
10344    \else\ifnum\countUTFz < "800\relax
10345      \parseUTFviiiA,%
10346      \parseUTFviiiB C\UTFviiiTwoOctetsName.,%
10347    \else\ifnum\countUTFz < "10000\relax
10348      \parseUTFviiiA;%
10349      \parseUTFviiiA,%
10350      \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}%
10351    \else
10352      \parseUTFviiiA;%
10353      \parseUTFviiiA,%
10354      \parseUTFviiiA!%
10355      \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}%
10356    \fi\fi\fi
10357  }
10358
10359  % Extract a byte from the end of the UTF-8 representation of \countUTFx.
10360  % It must be a non-initial byte in the sequence.
10361  % Change \uccode of #1 for it to be used in \parseUTFviiiB as one
10362  % of the bytes.
10363  \gdef\parseUTFviiiA#1{%
10364    \countUTFx = \countUTFz
10365    \divide\countUTFz by 64
10366    \countUTFy = \countUTFz  % Save to be the future value of \countUTFz.
10367    \multiply\countUTFz by 64
10368
10369    % \countUTFz is now \countUTFx with the last 5 bits cleared.  Subtract
10370    % in order to get the last five bits.
10371    \advance\countUTFx by -\countUTFz
10372
10373    % Convert this to the byte in the UTF-8 sequence.
10374    \advance\countUTFx by 128
10375    \uccode `#1\countUTFx
10376    \countUTFz = \countUTFy}
10377
10378  % Used to put a UTF-8 byte sequence into \UTFviiiTmp
10379  % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8
10380  %    sequence.
10381  % #2 is one of the \UTFviii*OctetsName macros.
10382  % #3 is always a full stop (.)
10383  % #4 is a template for the other bytes in the sequence.  The values for these
10384  %    bytes is substituted in here with \uppercase using the \uccode's.
10385  \gdef\parseUTFviiiB#1#2#3#4{%
10386    \advance\countUTFz by "#10\relax
10387    \uccode `#3\countUTFz
10388    \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10389\endgroup
10390
10391% For native Unicode handling (XeTeX and LuaTeX),
10392% provide a definition macro that sets a catcode to `other' non-globally
10393%
10394\def\DeclareUnicodeCharacterNativeOther#1#2{%
10395  \catcode"#1=\other
10396}
10397
10398% https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10399% U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10400% U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10401% U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10402% U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10403%
10404% Many of our renditions are less than wonderful, and all the missing
10405% characters are available somewhere.  Loading the necessary fonts
10406% awaits user request.  We can't truly support Unicode without
10407% reimplementing everything that's been done in LaTeX for many years,
10408% plus probably using luatex or xetex, and who knows what else.
10409% We won't be doing that here in this simple file.  But we can try to at
10410% least make most of the characters not bomb out.
10411%
10412\def\unicodechardefs{%
10413  \DeclareUnicodeCharacter{00A0}{\tie}%
10414  \DeclareUnicodeCharacter{00A1}{\exclamdown}%
10415  \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
10416  \DeclareUnicodeCharacter{00A3}{\pounds{}}%
10417  \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10418  \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10419  \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
10420  \DeclareUnicodeCharacter{00A7}{\S}%
10421  \DeclareUnicodeCharacter{00A8}{\"{ }}%
10422  \DeclareUnicodeCharacter{00A9}{\copyright{}}%
10423  \DeclareUnicodeCharacter{00AA}{\ordf}%
10424  \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}%
10425  \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10426  \DeclareUnicodeCharacter{00AD}{\-}%
10427  \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}%
10428  \DeclareUnicodeCharacter{00AF}{\={ }}%
10429  %
10430  \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
10431  \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10432  \DeclareUnicodeCharacter{00B2}{$^2$}%
10433  \DeclareUnicodeCharacter{00B3}{$^3$}%
10434  \DeclareUnicodeCharacter{00B4}{\'{ }}%
10435  \DeclareUnicodeCharacter{00B5}{$\mu$}%
10436  \DeclareUnicodeCharacter{00B6}{\P}%
10437  \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10438  \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10439  \DeclareUnicodeCharacter{00B9}{$^1$}%
10440  \DeclareUnicodeCharacter{00BA}{\ordm}%
10441  \DeclareUnicodeCharacter{00BB}{\guillemetright{}}%
10442  \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10443  \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10444  \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10445  \DeclareUnicodeCharacter{00BF}{\questiondown}%
10446  %
10447  \DeclareUnicodeCharacter{00C0}{\`A}%
10448  \DeclareUnicodeCharacter{00C1}{\'A}%
10449  \DeclareUnicodeCharacter{00C2}{\^A}%
10450  \DeclareUnicodeCharacter{00C3}{\~A}%
10451  \DeclareUnicodeCharacter{00C4}{\"A}%
10452  \DeclareUnicodeCharacter{00C5}{\AA}%
10453  \DeclareUnicodeCharacter{00C6}{\AE}%
10454  \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10455  \DeclareUnicodeCharacter{00C8}{\`E}%
10456  \DeclareUnicodeCharacter{00C9}{\'E}%
10457  \DeclareUnicodeCharacter{00CA}{\^E}%
10458  \DeclareUnicodeCharacter{00CB}{\"E}%
10459  \DeclareUnicodeCharacter{00CC}{\`I}%
10460  \DeclareUnicodeCharacter{00CD}{\'I}%
10461  \DeclareUnicodeCharacter{00CE}{\^I}%
10462  \DeclareUnicodeCharacter{00CF}{\"I}%
10463  %
10464  \DeclareUnicodeCharacter{00D0}{\DH}%
10465  \DeclareUnicodeCharacter{00D1}{\~N}%
10466  \DeclareUnicodeCharacter{00D2}{\`O}%
10467  \DeclareUnicodeCharacter{00D3}{\'O}%
10468  \DeclareUnicodeCharacter{00D4}{\^O}%
10469  \DeclareUnicodeCharacter{00D5}{\~O}%
10470  \DeclareUnicodeCharacter{00D6}{\"O}%
10471  \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10472  \DeclareUnicodeCharacter{00D8}{\O}%
10473  \DeclareUnicodeCharacter{00D9}{\`U}%
10474  \DeclareUnicodeCharacter{00DA}{\'U}%
10475  \DeclareUnicodeCharacter{00DB}{\^U}%
10476  \DeclareUnicodeCharacter{00DC}{\"U}%
10477  \DeclareUnicodeCharacter{00DD}{\'Y}%
10478  \DeclareUnicodeCharacter{00DE}{\TH}%
10479  \DeclareUnicodeCharacter{00DF}{\ss}%
10480  %
10481  \DeclareUnicodeCharacter{00E0}{\`a}%
10482  \DeclareUnicodeCharacter{00E1}{\'a}%
10483  \DeclareUnicodeCharacter{00E2}{\^a}%
10484  \DeclareUnicodeCharacter{00E3}{\~a}%
10485  \DeclareUnicodeCharacter{00E4}{\"a}%
10486  \DeclareUnicodeCharacter{00E5}{\aa}%
10487  \DeclareUnicodeCharacter{00E6}{\ae}%
10488  \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10489  \DeclareUnicodeCharacter{00E8}{\`e}%
10490  \DeclareUnicodeCharacter{00E9}{\'e}%
10491  \DeclareUnicodeCharacter{00EA}{\^e}%
10492  \DeclareUnicodeCharacter{00EB}{\"e}%
10493  \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10494  \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10495  \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10496  \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10497  %
10498  \DeclareUnicodeCharacter{00F0}{\dh}%
10499  \DeclareUnicodeCharacter{00F1}{\~n}%
10500  \DeclareUnicodeCharacter{00F2}{\`o}%
10501  \DeclareUnicodeCharacter{00F3}{\'o}%
10502  \DeclareUnicodeCharacter{00F4}{\^o}%
10503  \DeclareUnicodeCharacter{00F5}{\~o}%
10504  \DeclareUnicodeCharacter{00F6}{\"o}%
10505  \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10506  \DeclareUnicodeCharacter{00F8}{\o}%
10507  \DeclareUnicodeCharacter{00F9}{\`u}%
10508  \DeclareUnicodeCharacter{00FA}{\'u}%
10509  \DeclareUnicodeCharacter{00FB}{\^u}%
10510  \DeclareUnicodeCharacter{00FC}{\"u}%
10511  \DeclareUnicodeCharacter{00FD}{\'y}%
10512  \DeclareUnicodeCharacter{00FE}{\th}%
10513  \DeclareUnicodeCharacter{00FF}{\"y}%
10514  %
10515  \DeclareUnicodeCharacter{0100}{\=A}%
10516  \DeclareUnicodeCharacter{0101}{\=a}%
10517  \DeclareUnicodeCharacter{0102}{\u{A}}%
10518  \DeclareUnicodeCharacter{0103}{\u{a}}%
10519  \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10520  \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10521  \DeclareUnicodeCharacter{0106}{\'C}%
10522  \DeclareUnicodeCharacter{0107}{\'c}%
10523  \DeclareUnicodeCharacter{0108}{\^C}%
10524  \DeclareUnicodeCharacter{0109}{\^c}%
10525  \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10526  \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10527  \DeclareUnicodeCharacter{010C}{\v{C}}%
10528  \DeclareUnicodeCharacter{010D}{\v{c}}%
10529  \DeclareUnicodeCharacter{010E}{\v{D}}%
10530  \DeclareUnicodeCharacter{010F}{d'}%
10531  %
10532  \DeclareUnicodeCharacter{0110}{\DH}%
10533  \DeclareUnicodeCharacter{0111}{\dh}%
10534  \DeclareUnicodeCharacter{0112}{\=E}%
10535  \DeclareUnicodeCharacter{0113}{\=e}%
10536  \DeclareUnicodeCharacter{0114}{\u{E}}%
10537  \DeclareUnicodeCharacter{0115}{\u{e}}%
10538  \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10539  \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10540  \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10541  \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10542  \DeclareUnicodeCharacter{011A}{\v{E}}%
10543  \DeclareUnicodeCharacter{011B}{\v{e}}%
10544  \DeclareUnicodeCharacter{011C}{\^G}%
10545  \DeclareUnicodeCharacter{011D}{\^g}%
10546  \DeclareUnicodeCharacter{011E}{\u{G}}%
10547  \DeclareUnicodeCharacter{011F}{\u{g}}%
10548  %
10549  \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10550  \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10551  \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10552  \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10553  \DeclareUnicodeCharacter{0124}{\^H}%
10554  \DeclareUnicodeCharacter{0125}{\^h}%
10555  \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10556  \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10557  \DeclareUnicodeCharacter{0128}{\~I}%
10558  \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10559  \DeclareUnicodeCharacter{012A}{\=I}%
10560  \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10561  \DeclareUnicodeCharacter{012C}{\u{I}}%
10562  \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10563  \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10564  \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10565  %
10566  \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10567  \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10568  \DeclareUnicodeCharacter{0132}{IJ}%
10569  \DeclareUnicodeCharacter{0133}{ij}%
10570  \DeclareUnicodeCharacter{0134}{\^J}%
10571  \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10572  \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10573  \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10574  \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10575  \DeclareUnicodeCharacter{0139}{\'L}%
10576  \DeclareUnicodeCharacter{013A}{\'l}%
10577  \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10578  \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
10579  \DeclareUnicodeCharacter{013D}{L'}% should kern
10580  \DeclareUnicodeCharacter{013E}{l'}% should kern
10581  \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10582  %
10583  \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10584  \DeclareUnicodeCharacter{0141}{\L}%
10585  \DeclareUnicodeCharacter{0142}{\l}%
10586  \DeclareUnicodeCharacter{0143}{\'N}%
10587  \DeclareUnicodeCharacter{0144}{\'n}%
10588  \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10589  \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10590  \DeclareUnicodeCharacter{0147}{\v{N}}%
10591  \DeclareUnicodeCharacter{0148}{\v{n}}%
10592  \DeclareUnicodeCharacter{0149}{'n}%
10593  \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10594  \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10595  \DeclareUnicodeCharacter{014C}{\=O}%
10596  \DeclareUnicodeCharacter{014D}{\=o}%
10597  \DeclareUnicodeCharacter{014E}{\u{O}}%
10598  \DeclareUnicodeCharacter{014F}{\u{o}}%
10599  %
10600  \DeclareUnicodeCharacter{0150}{\H{O}}%
10601  \DeclareUnicodeCharacter{0151}{\H{o}}%
10602  \DeclareUnicodeCharacter{0152}{\OE}%
10603  \DeclareUnicodeCharacter{0153}{\oe}%
10604  \DeclareUnicodeCharacter{0154}{\'R}%
10605  \DeclareUnicodeCharacter{0155}{\'r}%
10606  \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10607  \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10608  \DeclareUnicodeCharacter{0158}{\v{R}}%
10609  \DeclareUnicodeCharacter{0159}{\v{r}}%
10610  \DeclareUnicodeCharacter{015A}{\'S}%
10611  \DeclareUnicodeCharacter{015B}{\'s}%
10612  \DeclareUnicodeCharacter{015C}{\^S}%
10613  \DeclareUnicodeCharacter{015D}{\^s}%
10614  \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10615  \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10616  %
10617  \DeclareUnicodeCharacter{0160}{\v{S}}%
10618  \DeclareUnicodeCharacter{0161}{\v{s}}%
10619  \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10620  \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10621  \DeclareUnicodeCharacter{0164}{\v{T}}%
10622  \DeclareUnicodeCharacter{0165}{\v{t}}%
10623  \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10624  \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10625  \DeclareUnicodeCharacter{0168}{\~U}%
10626  \DeclareUnicodeCharacter{0169}{\~u}%
10627  \DeclareUnicodeCharacter{016A}{\=U}%
10628  \DeclareUnicodeCharacter{016B}{\=u}%
10629  \DeclareUnicodeCharacter{016C}{\u{U}}%
10630  \DeclareUnicodeCharacter{016D}{\u{u}}%
10631  \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10632  \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10633  %
10634  \DeclareUnicodeCharacter{0170}{\H{U}}%
10635  \DeclareUnicodeCharacter{0171}{\H{u}}%
10636  \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10637  \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10638  \DeclareUnicodeCharacter{0174}{\^W}%
10639  \DeclareUnicodeCharacter{0175}{\^w}%
10640  \DeclareUnicodeCharacter{0176}{\^Y}%
10641  \DeclareUnicodeCharacter{0177}{\^y}%
10642  \DeclareUnicodeCharacter{0178}{\"Y}%
10643  \DeclareUnicodeCharacter{0179}{\'Z}%
10644  \DeclareUnicodeCharacter{017A}{\'z}%
10645  \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10646  \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10647  \DeclareUnicodeCharacter{017D}{\v{Z}}%
10648  \DeclareUnicodeCharacter{017E}{\v{z}}%
10649  \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10650  %
10651  \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10652  \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10653  \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10654  \DeclareUnicodeCharacter{01C7}{LJ}%
10655  \DeclareUnicodeCharacter{01C8}{Lj}%
10656  \DeclareUnicodeCharacter{01C9}{lj}%
10657  \DeclareUnicodeCharacter{01CA}{NJ}%
10658  \DeclareUnicodeCharacter{01CB}{Nj}%
10659  \DeclareUnicodeCharacter{01CC}{nj}%
10660  \DeclareUnicodeCharacter{01CD}{\v{A}}%
10661  \DeclareUnicodeCharacter{01CE}{\v{a}}%
10662  \DeclareUnicodeCharacter{01CF}{\v{I}}%
10663  %
10664  \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10665  \DeclareUnicodeCharacter{01D1}{\v{O}}%
10666  \DeclareUnicodeCharacter{01D2}{\v{o}}%
10667  \DeclareUnicodeCharacter{01D3}{\v{U}}%
10668  \DeclareUnicodeCharacter{01D4}{\v{u}}%
10669  %
10670  \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10671  \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10672  \DeclareUnicodeCharacter{01E6}{\v{G}}%
10673  \DeclareUnicodeCharacter{01E7}{\v{g}}%
10674  \DeclareUnicodeCharacter{01E8}{\v{K}}%
10675  \DeclareUnicodeCharacter{01E9}{\v{k}}%
10676  %
10677  \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10678  \DeclareUnicodeCharacter{01F1}{DZ}%
10679  \DeclareUnicodeCharacter{01F2}{Dz}%
10680  \DeclareUnicodeCharacter{01F3}{dz}%
10681  \DeclareUnicodeCharacter{01F4}{\'G}%
10682  \DeclareUnicodeCharacter{01F5}{\'g}%
10683  \DeclareUnicodeCharacter{01F8}{\`N}%
10684  \DeclareUnicodeCharacter{01F9}{\`n}%
10685  \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10686  \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10687  \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10688  \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10689  %
10690  \DeclareUnicodeCharacter{021E}{\v{H}}%
10691  \DeclareUnicodeCharacter{021F}{\v{h}}%
10692  %
10693  \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10694  \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10695  \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10696  \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10697  \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10698  \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10699  %
10700  \DeclareUnicodeCharacter{0232}{\=Y}%
10701  \DeclareUnicodeCharacter{0233}{\=y}%
10702  \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10703  %
10704  \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10705  %
10706  % Greek letters upper case
10707  \DeclareUnicodeCharacter{0391}{{\it A}}%
10708  \DeclareUnicodeCharacter{0392}{{\it B}}%
10709  \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10710  \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10711  \DeclareUnicodeCharacter{0395}{{\it E}}%
10712  \DeclareUnicodeCharacter{0396}{{\it Z}}%
10713  \DeclareUnicodeCharacter{0397}{{\it H}}%
10714  \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10715  \DeclareUnicodeCharacter{0399}{{\it I}}%
10716  \DeclareUnicodeCharacter{039A}{{\it K}}%
10717  \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10718  \DeclareUnicodeCharacter{039C}{{\it M}}%
10719  \DeclareUnicodeCharacter{039D}{{\it N}}%
10720  \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10721  \DeclareUnicodeCharacter{039F}{{\it O}}%
10722  \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10723  \DeclareUnicodeCharacter{03A1}{{\it P}}%
10724  %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
10725  \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10726  \DeclareUnicodeCharacter{03A4}{{\it T}}%
10727  \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10728  \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10729  \DeclareUnicodeCharacter{03A7}{{\it X}}%
10730  \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10731  \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10732  %
10733  % Vowels with accents
10734  \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10735  \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10736  \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10737  \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10738  \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10739  \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10740  %
10741  % Standalone accent
10742  \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10743  %
10744  % Greek letters lower case
10745  \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10746  \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10747  \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10748  \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10749  \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10750  \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10751  \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10752  \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10753  \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10754  \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10755  \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10756  \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10757  \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10758  \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10759  \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10760  \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10761  \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10762  \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10763  \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10764  \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10765  \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10766  \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10767  \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10768  \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10769  \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10770  %
10771  % More Greek vowels with accents
10772  \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10773  \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10774  \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10775  \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10776  \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10777  %
10778  % Variant Greek letters
10779  \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10780  \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10781  \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10782  %
10783  \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10784  \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10785  \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10786  \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10787  \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10788  \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10789  \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10790  \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10791  \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10792  \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10793  \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10794  \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10795  %
10796  \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10797  \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10798  %
10799  \DeclareUnicodeCharacter{1E20}{\=G}%
10800  \DeclareUnicodeCharacter{1E21}{\=g}%
10801  \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10802  \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10803  \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10804  \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10805  \DeclareUnicodeCharacter{1E26}{\"H}%
10806  \DeclareUnicodeCharacter{1E27}{\"h}%
10807  %
10808  \DeclareUnicodeCharacter{1E30}{\'K}%
10809  \DeclareUnicodeCharacter{1E31}{\'k}%
10810  \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10811  \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10812  \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10813  \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10814  \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10815  \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10816  \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10817  \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10818  \DeclareUnicodeCharacter{1E3E}{\'M}%
10819  \DeclareUnicodeCharacter{1E3F}{\'m}%
10820  %
10821  \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10822  \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10823  \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10824  \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10825  \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10826  \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10827  \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10828  \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10829  \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10830  \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10831  %
10832  \DeclareUnicodeCharacter{1E54}{\'P}%
10833  \DeclareUnicodeCharacter{1E55}{\'p}%
10834  \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10835  \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10836  \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10837  \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10838  \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10839  \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10840  \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10841  \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10842  %
10843  \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10844  \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10845  \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10846  \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10847  \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10848  \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10849  \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10850  \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10851  \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10852  \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10853  %
10854  \DeclareUnicodeCharacter{1E7C}{\~V}%
10855  \DeclareUnicodeCharacter{1E7D}{\~v}%
10856  \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10857  \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10858  %
10859  \DeclareUnicodeCharacter{1E80}{\`W}%
10860  \DeclareUnicodeCharacter{1E81}{\`w}%
10861  \DeclareUnicodeCharacter{1E82}{\'W}%
10862  \DeclareUnicodeCharacter{1E83}{\'w}%
10863  \DeclareUnicodeCharacter{1E84}{\"W}%
10864  \DeclareUnicodeCharacter{1E85}{\"w}%
10865  \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10866  \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10867  \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10868  \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10869  \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10870  \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10871  \DeclareUnicodeCharacter{1E8C}{\"X}%
10872  \DeclareUnicodeCharacter{1E8D}{\"x}%
10873  \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10874  \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10875  %
10876  \DeclareUnicodeCharacter{1E90}{\^Z}%
10877  \DeclareUnicodeCharacter{1E91}{\^z}%
10878  \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
10879  \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
10880  \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
10881  \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
10882  \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
10883  \DeclareUnicodeCharacter{1E97}{\"t}%
10884  \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
10885  \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
10886  %
10887  \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
10888  \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
10889  %
10890  \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
10891  \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
10892  \DeclareUnicodeCharacter{1EBC}{\~E}%
10893  \DeclareUnicodeCharacter{1EBD}{\~e}%
10894  %
10895  \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
10896  \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
10897  \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
10898  \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
10899  %
10900  \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
10901  \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
10902  %
10903  \DeclareUnicodeCharacter{1EF2}{\`Y}%
10904  \DeclareUnicodeCharacter{1EF3}{\`y}%
10905  \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
10906  %
10907  \DeclareUnicodeCharacter{1EF8}{\~Y}%
10908  \DeclareUnicodeCharacter{1EF9}{\~y}%
10909  %
10910  % Punctuation
10911  \DeclareUnicodeCharacter{2013}{--}%
10912  \DeclareUnicodeCharacter{2014}{---}%
10913  \DeclareUnicodeCharacter{2018}{\quoteleft{}}%
10914  \DeclareUnicodeCharacter{2019}{\quoteright{}}%
10915  \DeclareUnicodeCharacter{201A}{\quotesinglbase{}}%
10916  \DeclareUnicodeCharacter{201C}{\quotedblleft{}}%
10917  \DeclareUnicodeCharacter{201D}{\quotedblright{}}%
10918  \DeclareUnicodeCharacter{201E}{\quotedblbase{}}%
10919  \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}%
10920  \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}%
10921  \DeclareUnicodeCharacter{2022}{\bullet{}}%
10922  \DeclareUnicodeCharacter{202F}{\thinspace}%
10923  \DeclareUnicodeCharacter{2026}{\dots{}}%
10924  \DeclareUnicodeCharacter{2039}{\guilsinglleft{}}%
10925  \DeclareUnicodeCharacter{203A}{\guilsinglright{}}%
10926  %
10927  \DeclareUnicodeCharacter{20AC}{\euro{}}%
10928  %
10929  \DeclareUnicodeCharacter{2192}{\expansion{}}%
10930  \DeclareUnicodeCharacter{21D2}{\result{}}%
10931  %
10932  % Mathematical symbols
10933  \DeclareUnicodeCharacter{2200}{\ensuremath\forall}%
10934  \DeclareUnicodeCharacter{2203}{\ensuremath\exists}%
10935  \DeclareUnicodeCharacter{2208}{\ensuremath\in}%
10936  \DeclareUnicodeCharacter{2212}{\minus{}}%
10937  \DeclareUnicodeCharacter{2217}{\ast}%
10938  \DeclareUnicodeCharacter{221E}{\ensuremath\infty}%
10939  \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}%
10940  \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}%
10941  \DeclareUnicodeCharacter{2229}{\ensuremath\cap}%
10942  \DeclareUnicodeCharacter{2261}{\equiv{}}%
10943  \DeclareUnicodeCharacter{2264}{\ensuremath\leq}%
10944  \DeclareUnicodeCharacter{2265}{\ensuremath\geq}%
10945  \DeclareUnicodeCharacter{2282}{\ensuremath\subset}%
10946  \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}%
10947  %
10948  \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}%
10949  \DeclareUnicodeCharacter{2032}{\ensuremath\prime}%
10950  \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}%
10951  \DeclareUnicodeCharacter{2111}{\ensuremath\Im}%
10952  \DeclareUnicodeCharacter{2113}{\ensuremath\ell}%
10953  \DeclareUnicodeCharacter{2118}{\ensuremath\wp}%
10954  \DeclareUnicodeCharacter{211C}{\ensuremath\Re}%
10955  \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}%
10956  \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}%
10957  \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}%
10958  \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}%
10959  \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}%
10960  \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}%
10961  \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}%
10962  \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}%
10963  \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}%
10964  \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}%
10965  \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}%
10966  \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}%
10967  \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}%
10968  \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}%
10969  \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}%
10970  \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}%
10971  \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}%
10972  \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}%
10973  \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}%
10974  \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}%
10975  \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}%
10976  \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}%
10977  \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}%
10978  \DeclareUnicodeCharacter{2202}{\ensuremath\partial}%
10979  \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}%
10980  \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}%
10981  \DeclareUnicodeCharacter{2209}{\ensuremath\notin}%
10982  \DeclareUnicodeCharacter{220B}{\ensuremath\owns}%
10983  \DeclareUnicodeCharacter{220F}{\ensuremath\prod}%
10984  \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}%
10985  \DeclareUnicodeCharacter{2211}{\ensuremath\sum}%
10986  \DeclareUnicodeCharacter{2213}{\ensuremath\mp}%
10987  \DeclareUnicodeCharacter{2218}{\ensuremath\circ}%
10988  \DeclareUnicodeCharacter{221A}{\ensuremath\surd}%
10989  \DeclareUnicodeCharacter{221D}{\ensuremath\propto}%
10990  \DeclareUnicodeCharacter{2220}{\ensuremath\angle}%
10991  \DeclareUnicodeCharacter{2223}{\ensuremath\mid}%
10992  \DeclareUnicodeCharacter{2228}{\ensuremath\vee}%
10993  \DeclareUnicodeCharacter{222A}{\ensuremath\cup}%
10994  \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}%
10995  \DeclareUnicodeCharacter{222E}{\ensuremath\oint}%
10996  \DeclareUnicodeCharacter{223C}{\ensuremath\sim}%
10997  \DeclareUnicodeCharacter{2240}{\ensuremath\wr}%
10998  \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}%
10999  \DeclareUnicodeCharacter{2245}{\ensuremath\cong}%
11000  \DeclareUnicodeCharacter{2248}{\ensuremath\approx}%
11001  \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}%
11002  \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}%
11003  \DeclareUnicodeCharacter{2260}{\ensuremath\neq}%
11004  \DeclareUnicodeCharacter{226A}{\ensuremath\ll}%
11005  \DeclareUnicodeCharacter{226B}{\ensuremath\gg}%
11006  \DeclareUnicodeCharacter{227A}{\ensuremath\prec}%
11007  \DeclareUnicodeCharacter{227B}{\ensuremath\succ}%
11008  \DeclareUnicodeCharacter{2283}{\ensuremath\supset}%
11009  \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}%
11010  \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}%
11011  \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}%
11012  \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}%
11013  \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}%
11014  \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}%
11015  \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}%
11016  \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}%
11017  \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}%
11018  \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}%
11019  \DeclareUnicodeCharacter{2299}{\ensuremath\odot}%
11020  \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}%
11021  \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}%
11022  \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}%
11023  \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}%
11024  \DeclareUnicodeCharacter{22A8}{\ensuremath\models}%
11025  \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}%
11026  \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}%
11027  \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}%
11028  \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}%
11029  \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}%
11030  \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}%
11031  \DeclareUnicodeCharacter{22C6}{\ensuremath\star}%
11032  \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}%
11033  \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}%
11034  \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}%
11035  \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}%
11036  \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}%
11037  \DeclareUnicodeCharacter{2322}{\ensuremath\frown}%
11038  \DeclareUnicodeCharacter{2323}{\ensuremath\smile}%
11039  %
11040  \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
11041  \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
11042  \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
11043  \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
11044  \DeclareUnicodeCharacter{25C7}{\ensuremath\diamond}%
11045  \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}%
11046  \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}%
11047  \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}%
11048  \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}%
11049  \DeclareUnicodeCharacter{266D}{\ensuremath\flat}%
11050  \DeclareUnicodeCharacter{266E}{\ensuremath\natural}%
11051  \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}%
11052  \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}%
11053  \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}%
11054  \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}%
11055  \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}%
11056  \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}%
11057  \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}%
11058  \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}%
11059  \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}%
11060  \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}%
11061  \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}%
11062  \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}%
11063  \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}%
11064  \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}%
11065  \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}%
11066  \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}%
11067  \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}%
11068  \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}%
11069  %
11070  \global\mathchardef\checkmark="1370% actually the square root sign
11071  \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}%
11072}% end of \unicodechardefs
11073
11074% UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
11075% It makes the setting that replace UTF-8 byte sequence.
11076\def\utfeightchardefs{%
11077  \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
11078  \unicodechardefs
11079}
11080
11081% Whether the active definitions of non-ASCII characters expand to
11082% non-active tokens with the same character code.  This is used to
11083% write characters literally, instead of using active definitions for
11084% printing the correct glyphs.
11085\newif\ifpassthroughchars
11086\passthroughcharsfalse
11087
11088% For native Unicode handling (XeTeX and LuaTeX),
11089% provide a definition macro to replace/pass-through a Unicode character
11090%
11091\def\DeclareUnicodeCharacterNative#1#2{%
11092  \catcode"#1=\active
11093  \def\dodeclareunicodecharacternative##1##2##3{%
11094    \begingroup
11095      \uccode`\~="##2\relax
11096      \uppercase{\gdef~}{%
11097        \ifpassthroughchars
11098          ##1%
11099        \else
11100          ##3%
11101        \fi
11102      }
11103    \endgroup
11104  }
11105  \begingroup
11106    \uccode`\.="#1\relax
11107    \uppercase{\def\UTFNativeTmp{.}}%
11108    \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
11109  \endgroup
11110}
11111
11112% Native Unicode handling (XeTeX and LuaTeX) character replacing definition.
11113% It activates the setting that replaces Unicode characters.
11114\def\nativeunicodechardefs{%
11115  \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
11116  \unicodechardefs
11117}
11118
11119% For native Unicode handling (XeTeX and LuaTeX),
11120% make the character token expand
11121% to the sequences given in \unicodechardefs for printing.
11122\def\DeclareUnicodeCharacterNativeAtU#1#2{%
11123  \def\UTFAtUTmp{#2}
11124  \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
11125}
11126
11127% @U command definitions for native Unicode handling (XeTeX and LuaTeX).
11128\def\nativeunicodechardefsatu{%
11129  \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
11130  \unicodechardefs
11131}
11132
11133% US-ASCII character definitions.
11134\def\asciichardefs{% nothing need be done
11135   \relax
11136}
11137
11138% Define all Unicode characters we know about.  This makes UTF-8 the default
11139% input encoding and allows @U to work.
11140\iftxinativeunicodecapable
11141  \nativeunicodechardefsatu
11142\else
11143  \utfeightchardefs
11144\fi
11145
11146\message{formatting,}
11147
11148\newdimen\defaultparindent \defaultparindent = 15pt
11149
11150\chapheadingskip = 15pt plus 4pt minus 2pt
11151\secheadingskip = 12pt plus 3pt minus 2pt
11152\subsecheadingskip = 9pt plus 2pt minus 2pt
11153
11154% Prevent underfull vbox error messages.
11155\vbadness = 10000
11156
11157% Don't be very finicky about underfull hboxes, either.
11158\hbadness = 6666
11159
11160% Following George Bush, get rid of widows and orphans.
11161\widowpenalty=10000
11162\clubpenalty=10000
11163
11164% Use TeX 3.0's \emergencystretch to help line breaking, but if we're
11165% using an old version of TeX, don't do anything.  We want the amount of
11166% stretch added to depend on the line length, hence the dependence on
11167% \hsize.  We call this whenever the paper size is set.
11168%
11169\def\setemergencystretch{%
11170  \ifx\emergencystretch\thisisundefined
11171    % Allow us to assign to \emergencystretch anyway.
11172    \def\emergencystretch{\dimen0}%
11173  \else
11174    \emergencystretch = .15\hsize
11175  \fi
11176}
11177
11178% Parameters in order: 1) textheight; 2) textwidth;
11179% 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11180% 7) physical page height; 8) physical page width.
11181%
11182% We also call \setleading{\textleading}, so the caller should define
11183% \textleading.  The caller should also set \parskip.
11184%
11185\def\internalpagesizes#1#2#3#4#5#6#7#8{%
11186  \voffset = #3\relax
11187  \topskip = #6\relax
11188  \splittopskip = \topskip
11189  %
11190  \vsize = #1\relax
11191  \advance\vsize by \topskip
11192  \outervsize = \vsize
11193  \advance\outervsize by 2\topandbottommargin
11194  \txipageheight = \vsize
11195  %
11196  \hsize = #2\relax
11197  \outerhsize = \hsize
11198  \advance\outerhsize by 0.5in
11199  \txipagewidth = \hsize
11200  %
11201  \normaloffset = #4\relax
11202  \bindingoffset = #5\relax
11203  %
11204  \ifpdf
11205    \pdfpageheight #7\relax
11206    \pdfpagewidth #8\relax
11207    % if we don't reset these, they will remain at "1 true in" of
11208    % whatever layout pdftex was dumped with.
11209    \pdfhorigin = 1 true in
11210    \pdfvorigin = 1 true in
11211  \else
11212    \ifx\XeTeXrevision\thisisundefined
11213      \special{papersize=#8,#7}%
11214    \else
11215      \pdfpageheight #7\relax
11216      \pdfpagewidth #8\relax
11217      % XeTeX does not have \pdfhorigin and \pdfvorigin.
11218    \fi
11219  \fi
11220  %
11221  \setleading{\textleading}
11222  %
11223  \parindent = \defaultparindent
11224  \setemergencystretch
11225}
11226
11227% @letterpaper (the default).
11228\def\letterpaper{{\globaldefs = 1
11229  \parskip = 3pt plus 2pt minus 1pt
11230  \textleading = 13.2pt
11231  %
11232  % If page is nothing but text, make it come out even.
11233  \internalpagesizes{607.2pt}{6in}% that's 46 lines
11234                    {\voffset}{.25in}%
11235                    {\bindingoffset}{36pt}%
11236                    {11in}{8.5in}%
11237}}
11238
11239% Use @smallbook to reset parameters for 7x9.25 trim size.
11240\def\smallbook{{\globaldefs = 1
11241  \parskip = 2pt plus 1pt
11242  \textleading = 12pt
11243  %
11244  \internalpagesizes{7.5in}{5in}%
11245                    {-.2in}{0in}%
11246                    {\bindingoffset}{16pt}%
11247                    {9.25in}{7in}%
11248  %
11249  \lispnarrowing = 0.3in
11250  \tolerance = 700
11251  \contentsrightmargin = 0pt
11252  \defbodyindent = .5cm
11253}}
11254
11255% Use @smallerbook to reset parameters for 6x9 trim size.
11256% (Just testing, parameters still in flux.)
11257\def\smallerbook{{\globaldefs = 1
11258  \parskip = 1.5pt plus 1pt
11259  \textleading = 12pt
11260  %
11261  \internalpagesizes{7.4in}{4.8in}%
11262                    {-.2in}{-.4in}%
11263                    {0pt}{14pt}%
11264                    {9in}{6in}%
11265  %
11266  \lispnarrowing = 0.25in
11267  \tolerance = 700
11268  \contentsrightmargin = 0pt
11269  \defbodyindent = .4cm
11270}}
11271
11272% Use @afourpaper to print on European A4 paper.
11273\def\afourpaper{{\globaldefs = 1
11274  \parskip = 3pt plus 2pt minus 1pt
11275  \textleading = 13.2pt
11276  %
11277  % Double-side printing via postscript on Laserjet 4050
11278  % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11279  % To change the settings for a different printer or situation, adjust
11280  % \normaloffset until the front-side and back-side texts align.  Then
11281  % do the same for \bindingoffset.  You can set these for testing in
11282  % your texinfo source file like this:
11283  % @tex
11284  % \global\normaloffset = -6mm
11285  % \global\bindingoffset = 10mm
11286  % @end tex
11287  \internalpagesizes{673.2pt}{160mm}% that's 51 lines
11288                    {\voffset}{\hoffset}%
11289                    {\bindingoffset}{44pt}%
11290                    {297mm}{210mm}%
11291  %
11292  \tolerance = 700
11293  \contentsrightmargin = 0pt
11294  \defbodyindent = 5mm
11295}}
11296
11297% Use @afivepaper to print on European A5 paper.
11298% From romildo@urano.iceb.ufop.br, 2 July 2000.
11299% He also recommends making @example and @lisp be small.
11300\def\afivepaper{{\globaldefs = 1
11301  \parskip = 2pt plus 1pt minus 0.1pt
11302  \textleading = 12.5pt
11303  %
11304  \internalpagesizes{160mm}{120mm}%
11305                    {\voffset}{\hoffset}%
11306                    {\bindingoffset}{8pt}%
11307                    {210mm}{148mm}%
11308  %
11309  \lispnarrowing = 0.2in
11310  \tolerance = 800
11311  \contentsrightmargin = 0pt
11312  \defbodyindent = 2mm
11313  \tableindent = 12mm
11314}}
11315
11316% A specific text layout, 24x15cm overall, intended for A4 paper.
11317\def\afourlatex{{\globaldefs = 1
11318  \afourpaper
11319  \internalpagesizes{237mm}{150mm}%
11320                    {\voffset}{4.6mm}%
11321                    {\bindingoffset}{7mm}%
11322                    {297mm}{210mm}%
11323  %
11324  % Must explicitly reset to 0 because we call \afourpaper.
11325  \globaldefs = 0
11326}}
11327
11328% Use @afourwide to print on A4 paper in landscape format.
11329\def\afourwide{{\globaldefs = 1
11330  \afourpaper
11331  \internalpagesizes{241mm}{165mm}%
11332                    {\voffset}{-2.95mm}%
11333                    {\bindingoffset}{7mm}%
11334                    {297mm}{210mm}%
11335  \globaldefs = 0
11336}}
11337
11338% @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11339% Perhaps we should allow setting the margins, \topskip, \parskip,
11340% and/or leading, also. Or perhaps we should compute them somehow.
11341%
11342\parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
11343\def\pagesizesyyy#1,#2,#3\finish{{%
11344  \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11345  \globaldefs = 1
11346  %
11347  \parskip = 3pt plus 2pt minus 1pt
11348  \setleading{\textleading}%
11349  %
11350  \dimen0 = #1\relax
11351  \advance\dimen0 by \voffset
11352  \advance\dimen0 by 1in % reference point for DVI is 1 inch from top of page
11353  %
11354  \dimen2 = \hsize
11355  \advance\dimen2 by \normaloffset
11356  \advance\dimen2 by 1in % reference point is 1 inch from left edge of page
11357  %
11358  \internalpagesizes{#1}{\hsize}%
11359                    {\voffset}{\normaloffset}%
11360                    {\bindingoffset}{44pt}%
11361                    {\dimen0}{\dimen2}%
11362}}
11363
11364% Set default to letter.
11365%
11366\letterpaper
11367
11368% Default value of \hfuzz, for suppressing warnings about overfull hboxes.
11369\hfuzz = 1pt
11370
11371
11372\message{and turning on texinfo input format.}
11373
11374\def^^L{\par} % remove \outer, so ^L can appear in an @comment
11375
11376% DEL is a comment character, in case @c does not suffice.
11377\catcode`\^^? = 14
11378
11379% Define macros to output various characters with catcode for normal text.
11380\catcode`\"=\other \def\normaldoublequote{"}
11381\catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11382\catcode`\+=\other \def\normalplus{+}
11383\catcode`\<=\other \def\normalless{<}
11384\catcode`\>=\other \def\normalgreater{>}
11385\catcode`\^=\other \def\normalcaret{^}
11386\catcode`\_=\other \def\normalunderscore{_}
11387\catcode`\|=\other \def\normalverticalbar{|}
11388\catcode`\~=\other \def\normaltilde{~}
11389
11390% This macro is used to make a character print one way in \tt
11391% (where it can probably be output as-is), and another way in other fonts,
11392% where something hairier probably needs to be done.
11393%
11394% #1 is what to print if we are indeed using \tt; #2 is what to print
11395% otherwise.  Since all the Computer Modern typewriter fonts have zero
11396% interword stretch (and shrink), and it is reasonable to expect all
11397% typewriter fonts to have this, we can check that font parameter.
11398%
11399\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
11400
11401% Same as above, but check for italic font.  Actually this also catches
11402% non-italic slanted fonts since it is impossible to distinguish them from
11403% italic fonts.  But since this is only used by $ and it uses \sl anyway
11404% this is not a problem.
11405\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
11406
11407% Set catcodes for Texinfo file
11408
11409% Active characters for printing the wanted glyph.
11410% Most of these we simply print from the \tt font, but for some, we can
11411% use math or other variants that look better in normal text.
11412%
11413\catcode`\"=\active
11414\def\activedoublequote{{\tt\char34}}
11415\let"=\activedoublequote
11416\catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
11417\chardef\hatchar=`\^
11418\catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
11419
11420\catcode`\_=\active
11421\def_{\ifusingtt\normalunderscore\_}
11422\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
11423\let\realunder=_
11424
11425\catcode`\|=\active \def|{{\tt\char124}}
11426
11427\chardef \less=`\<
11428\catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
11429\chardef \gtr=`\>
11430\catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11431\catcode`\+=\active \def+{{\tt \char 43}}
11432\catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
11433\catcode`\-=\active \let-=\normaldash
11434
11435
11436% used for headline/footline in the output routine, in case the page
11437% breaks in the middle of an @tex block.
11438\def\texinfochars{%
11439  \let< = \activeless
11440  \let> = \activegtr
11441  \let~ = \activetilde
11442  \let^ = \activehat
11443  \markupsetuplqdefault \markupsetuprqdefault
11444  \let\b = \strong
11445  \let\i = \smartitalic
11446  % in principle, all other definitions in \tex have to be undone too.
11447}
11448
11449% Used sometimes to turn off (effectively) the active characters even after
11450% parsing them.
11451\def\turnoffactive{%
11452  \normalturnoffactive
11453  \otherbackslash
11454}
11455
11456\catcode`\@=0
11457
11458% \backslashcurfont outputs one backslash character in current font,
11459% as in \char`\\.
11460\global\chardef\backslashcurfont=`\\
11461
11462% \realbackslash is an actual character `\' with catcode other.
11463{\catcode`\\=\other @gdef@realbackslash{\}}
11464
11465% In Texinfo, backslash is an active character; it prints the backslash
11466% in fixed width font.
11467\catcode`\\=\active  % @ for escape char from now on.
11468
11469% Print a typewriter backslash.  For math mode, we can't simply use
11470% \backslashcurfont: the story here is that in math mode, the \char
11471% of \backslashcurfont ends up printing the roman \ from the math symbol
11472% font (because \char in math mode uses the \mathcode, and plain.tex
11473% sets \mathcode`\\="026E).  Hence we use an explicit \mathchar,
11474% which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11475% ignored family value; char position "5C).  We can't use " for the
11476% usual hex value because it has already been made active.
11477
11478@def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
11479@let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
11480
11481% \otherbackslash defines an active \ to be a literal `\' character with
11482% catcode other.
11483@gdef@otherbackslash{@let\=@realbackslash}
11484
11485% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
11486% the literal character `\'.
11487%
11488{@catcode`- = @active
11489 @gdef@normalturnoffactive{%
11490   @passthroughcharstrue
11491   @let-=@normaldash
11492   @let"=@normaldoublequote
11493   @let$=@normaldollar %$ font-lock fix
11494   @let+=@normalplus
11495   @let<=@normalless
11496   @let>=@normalgreater
11497   @let^=@normalcaret
11498   @let_=@normalunderscore
11499   @let|=@normalverticalbar
11500   @let~=@normaltilde
11501   @let\=@ttbackslash
11502   @markupsetuplqdefault
11503   @markupsetuprqdefault
11504   @unsepspaces
11505 }
11506}
11507
11508% If a .fmt file is being used, characters that might appear in a file
11509% name cannot be active until we have parsed the command line.
11510% So turn them off again, and have @fixbackslash turn them back on.
11511@catcode`+=@other @catcode`@_=@other
11512
11513% \enablebackslashhack - allow file to begin `\input texinfo'
11514%
11515% If a .fmt file is being used, we don't want the `\input texinfo' to show up.
11516% That is what \eatinput is for; after that, the `\' should revert to printing
11517% a backslash.
11518% If the file did not have a `\input texinfo', then it is turned off after
11519% the first line; otherwise the first `\' in the file would cause an error.
11520% This is used on the very last line of this file, texinfo.tex.
11521% We also use @c to call @fixbackslash, in case ends of lines are hidden.
11522{
11523@catcode`@^=7
11524@catcode`@^^M=13@gdef@enablebackslashhack{%
11525  @global@let\ = @eatinput%
11526  @catcode`@^^M=13%
11527  @def@c{@fixbackslash@c}%
11528  % Definition for the newline at the end of this file.
11529  @def ^^M{@let^^M@secondlinenl}%
11530  % Definition for a newline in the main Texinfo file.
11531  @gdef @secondlinenl{@fixbackslash}%
11532  % In case the first line has a whole-line command on it
11533  @let@originalparsearg@parsearg
11534  @def@parsearg{@fixbackslash@originalparsearg}
11535}}
11536
11537{@catcode`@^=7 @catcode`@^^M=13%
11538@gdef@eatinput input texinfo#1^^M{@fixbackslash}}
11539
11540% Emergency active definition of newline, in case an active newline token
11541% appears by mistake.
11542{@catcode`@^=7 @catcode13=13%
11543@gdef@enableemergencynewline{%
11544  @gdef^^M{%
11545    @par%
11546    %<warning: active newline>@par%
11547}}}
11548
11549
11550@gdef@fixbackslash{%
11551  @ifx\@eatinput @let\ = @ttbackslash @fi
11552  @catcode13=5 % regular end of line
11553  @enableemergencynewline
11554  @let@c=@comment
11555  @let@parsearg@originalparsearg
11556  % Also turn back on active characters that might appear in the input
11557  % file name, in case not using a pre-dumped format.
11558  @catcode`+=@active
11559  @catcode`@_=@active
11560  %
11561  % If texinfo.cnf is present on the system, read it.
11562  % Useful for site-wide @afourpaper, etc.  This macro, @fixbackslash, gets
11563  % called at the beginning of every Texinfo file.  Not opening texinfo.cnf
11564  % directly in this file, texinfo.tex, makes it possible to make a format
11565  % file for Texinfo.
11566  %
11567  @openin 1 texinfo.cnf
11568  @ifeof 1 @else @input texinfo.cnf @fi
11569  @closein 1
11570}
11571
11572
11573% Say @foo, not \foo, in error messages.
11574@escapechar = `@@
11575
11576% These (along with & and #) are made active for url-breaking, so need
11577% active definitions as the normal characters.
11578@def@normaldot{.}
11579@def@normalquest{?}
11580@def@normalslash{/}
11581
11582% These look ok in all fonts, so just make them not special.
11583% @hashchar{} gets its own user-level command, because of #line.
11584@catcode`@& = @other @def@normalamp{&}
11585@catcode`@# = @other @def@normalhash{#}
11586@catcode`@% = @other @def@normalpercent{%}
11587
11588@let @hashchar = @normalhash
11589
11590@c Finally, make ` and ' active, so that txicodequoteundirected and
11591@c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
11592@c don't make ` and ' active, @code will not get them as active chars.
11593@c Do this last of all since we use ` in the previous @catcode assignments.
11594@catcode`@'=@active
11595@catcode`@`=@active
11596@markupsetuplqdefault
11597@markupsetuprqdefault
11598
11599@c Local variables:
11600@c eval: (add-hook 'before-save-hook 'time-stamp)
11601@c page-delimiter: "^\\\\message\\|emacs-page"
11602@c time-stamp-start: "def\\\\texinfoversion{"
11603@c time-stamp-format: "%:y-%02m-%02d.%02H"
11604@c time-stamp-end: "}"
11605@c End:
11606
11607@c vim:sw=2:
11608
11609@enablebackslashhack
11610